maindb-procedure-6.sql 609 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327
  1. /****** Object: StoredProcedure [dbo].[ProcBaiduXmlSelect] Script Date: 2018/12/13 19:09:31 ******/
  2. SET ANSI_NULLS ON
  3. GO
  4. SET QUOTED_IDENTIFIER ON
  5. GO
  6. CREATE PROCEDURE [dbo].[ProcBaiduXmlSelect]
  7. (
  8. @SiteId INT
  9. )
  10. AS
  11. SET NOCOUNT ON
  12. BEGIN
  13. IF @SiteId = 32
  14. BEGIN
  15. SELECT id, jobname, JobDESC, JobDemand, jobregion, companyname, edulevel, IsDelete,
  16. experiencelevel, AnnounceDate, dcSalaryID, dcjobtypeID, ShortName, Address, dcCompanySizeID, Brief,
  17. EmployType, adddate, dcCompanyKindID, enddate, email, EnJobID, EnCpMainID,
  18. IndustryId, SubSiteUrl, SubSiteName, NeedNumber, Welfare1, Welfare2, Welfare3, Welfare4, Welfare5,
  19. Welfare6, Welfare7, Welfare8, Welfare9, Welfare10, Welfare11, Welfare12, Welfare13, Welfare14,
  20. Welfare15, Welfare16, Welfare17, Welfare18
  21. FROM ShortDb..BaiduXMLJobQlrcOut WITH(NOLOCK)
  22. WHERE SiteId = 32
  23. ORDER BY RowNo
  24. RETURN
  25. END
  26. IF EXISTS(SELECT 'x' FROM ShortDb..BaiduXMLJobOut WHERE SiteId = @SiteID AND crDate > GETDATE() - 1)
  27. BEGIN
  28. SELECT id, jobname, JobDESC, JobDemand, jobregion, companyname, edulevel, IsDelete,
  29. experiencelevel, AnnounceDate, dcSalaryID, dcjobtypeID, ShortName, Address, dcCompanySizeID, Brief,
  30. EmployType, adddate, dcCompanyKindID, CASE WHEN EndDate < GETDATE() THEN GETDATE() + 10 ELSE EndDate END enddate, email, EnJobID, EnCpMainID,
  31. IndustryId, SubSiteUrl, SubSiteName, NeedNumber, Welfare1, Welfare2, Welfare3, Welfare4, Welfare5,
  32. Welfare6, Welfare7, Welfare8, Welfare9, Welfare10, Welfare11, Welfare12, Welfare13, Welfare14,
  33. Welfare15, Welfare16, Welfare17, Welfare18
  34. FROM ShortDb..BaiduXMLJobOut WITH(NOLOCK)
  35. WHERE SiteId = @SiteId
  36. ORDER BY RowNo
  37. RETURN
  38. END
  39. CREATE TABLE #t
  40. (
  41. RowNo INT IDENTITY(1, 1),
  42. [Id] [int] NOT NULL,
  43. [JobName] [nvarchar](80) NOT NULL,
  44. [JobDESC] [varchar](max) NOT NULL,
  45. [JobDemand] [varchar](max) NOT NULL,
  46. [JobRegion] [varchar](6) NULL,
  47. [CompanyName] [varchar](100) NOT NULL,
  48. [EduLevel] [tinyint] NOT NULL,
  49. [IsDelete] [bit] NOT NULL,
  50. [ExperienceLevel] [tinyint] NOT NULL,
  51. [Announcedate] [datetime] NOT NULL,
  52. [dcSalaryID] [tinyint] NOT NULL,
  53. [dcJobtypeID] [smallint] NOT NULL,
  54. [ShortName] [varchar](40) NULL,
  55. [Address] [nvarchar](100) NULL,
  56. [dcCompanySizeID] [tinyint] NULL,
  57. [Brief] [varchar](6000) NULL,
  58. [EmployType] [tinyint] NOT NULL,
  59. [AddDate] [smalldatetime] NOT NULL,
  60. [dcCompanyKindID] [smallint] NULL,
  61. [EndDate] [smalldatetime] NULL,
  62. [Email] [varchar](50) NOT NULL,
  63. [EnJobID] [varchar](12) NULL,
  64. [EnCpMainID] [varchar](10) NULL,
  65. [IndustryId] [smallint] NULL,
  66. [SubSiteUrl] [varchar](50) NOT NULL,
  67. [SubSiteName] [varchar](50) NOT NULL,
  68. NeedNumber VARCHAR(10),
  69. [Welfare1] [bit] NULL,
  70. [Welfare2] [bit] NULL,
  71. [Welfare3] [bit] NULL,
  72. [Welfare4] [bit] NULL,
  73. [Welfare5] [bit] NULL,
  74. [Welfare6] [bit] NULL,
  75. [Welfare7] [bit] NULL,
  76. [Welfare8] [bit] NULL,
  77. [Welfare9] [bit] NULL,
  78. [Welfare10] [bit] NULL,
  79. [Welfare11] [bit] NULL,
  80. [Welfare12] [bit] NULL,
  81. [Welfare13] [bit] NULL,
  82. [Welfare14] [bit] NULL,
  83. [Welfare15] [bit] NULL,
  84. [Welfare16] [bit] NULL,
  85. [Welfare17] [bit] NULL,
  86. [Welfare18] [bit] NULL,
  87. RegionDesc NVARCHAR(50)
  88. )
  89. DECLARE @SubSiteUrl VARCHAR(100), @SubSiteName VARCHAR(100)
  90. SELECT @SubSiteUrl = SubSiteUrl, @SubSiteName = SubSiteName
  91. FROM dcsubsite WITH(NOLOCK)
  92. WHERE Id = LEFT(@SiteId, 2)
  93. IF @SiteId > 99
  94. INSERT INTO #t
  95. SELECT a.Id, a.Name JobName, a.Responsibility JobDESC, a.Demand JobDemand,
  96. a.dcRegionId JobRegion, b.Name CompanyName, a.dcEducationID EduLevel, a.IsDelete,
  97. a.MinExperience ExperienceLevel, a.RefreshDate Announcedate,
  98. a.dcSalaryID, a.dcJobtypeID, ISNULL(b.ShortName, b.Name) ShortName, b.Address, dcCompanySizeID, Brief,
  99. a.EmployType, a.AddDate, b.dcCompanyKindID, a.IssueEnd EndDate, c.Email, a.SecondId EnJobID, b.SecondId EnCpMainID,
  100. (SELECT TOP 1 dcIndustryId FROM cpIndustry WITH(NOLOCK) WHERE cpIndustry.cpMainID = b.ID) IndustryId,
  101. @SubSiteUrl SubSiteUrl, @SubSiteName SubSiteName, a.NeedNumber, a.Welfare1, a.Welfare2, a.Welfare3, a.Welfare4,
  102. a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8, a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13,
  103. a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18, ''
  104. FROM job a WITH(NOLOCK),cpmain b WITH(NOLOCK),camain c WITH(NOLOCK)
  105. WHERE c.Id = a.caMainId AND a.cpMainId = b.Id
  106. AND a.Valid = 1 AND b.Valid = 1
  107. AND a.cpMainId NOT IN(select distinct cpMainId from noshowoldjob WITH(NOLOCK) )--harry2016-11-29
  108. AND IssueEnd > CONVERT(VARCHAR(10), GETDATE() + 1, 120) AND b.VerifyCount > 0
  109. --AND (b.dcSubsiteId = @SiteId OR b.dcRegionId = @SiteId)
  110. AND a.dcRegionId LIKE LTRIM(STR(@SiteId)) + '%'
  111. AND LEN(RTRIM(a.Name)) > 1
  112. AND a.Refreshdate > CONVERT(VARCHAR(10), GETDATE() - 1, 120)
  113. ORDER BY a.RefreshDate DESC
  114. ELSE
  115. BEGIN
  116. IF @SiteId <> 32
  117. BEGIN
  118. INSERT INTO #t
  119. SELECT a.id, a.name jobname, a.responsibility JobDESC, a.Demand JobDemand,
  120. a.dcregionid jobregion, b.name companyname, a.dcEducationID edulevel, a.IsDelete,
  121. a.MinExperience experiencelevel, a.RefreshDate announcedate,
  122. a.dcSalaryID, a.dcjobtypeID, ISNULL(b.ShortName, b.Name) ShortName, b.Address, dcCompanySizeID, Brief,
  123. a.EmployType, a.adddate, b.dcCompanyKindID, a.IssueEnd enddate, c.email, a.SecondId EnJobID, b.SecondId EnCpMainID,
  124. (SELECT TOP 1 dcIndustryId FROM cpindustry WITH(NOLOCK) WHERE cpindustry.cpMainID = b.ID) IndustryId,
  125. @SubSiteUrl SubSiteUrl, @SubSiteName SubSiteName, a.NeedNumber, a.Welfare1, a.Welfare2, a.Welfare3, a.Welfare4,
  126. a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8, a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13,
  127. a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18, ''
  128. FROM job a WITH(NOLOCK),cpmain b WITH(NOLOCK),camain c
  129. WHERE a.camainid=c.id AND a.cpmainid=b.id
  130. AND a.valid=1--harry2016-11-29
  131. AND issueend>CONVERT(VARCHAR(10),GETDATE()+1,120)--harry2016-11-29
  132. AND b.valid=1 AND b.VerifyCount > 0 --harry2016-11-29
  133. AND a.cpMainId NOT IN(select distinct cpMainId from noshowoldjob WITH(NOLOCK) )--harry2016-11-29
  134. AND b.dcprovinceid = @SiteId AND LEN(RTRIM(a.name)) > 1
  135. AND a.dcRegionId LIKE LTRIM(STR(@SiteId)) + '%'
  136. --AND a.Refreshdate>CONVERT(VARCHAR(10), GETDATE()-1,120)
  137. ORDER BY a.RefreshDate DESC
  138. END
  139. END
  140. ALTER TABLE #t ADD RegionName VARCHAR(50)
  141. ALTER TABLE #t ADD RegionName2 VARCHAR(50)
  142. UPDATE a SET a.RegionName = b.Description FROM #t a, dcRegion b WHERE LEFT(a.JobRegion, 4) = b.Id
  143. UPDATE #t SET RegionName2 = LEFT(RegionName, LEN(RegionName) - 1) WHERE LEN(RegionName) > 2
  144. UPDATE #t SET JobName = RegionName + JobName WHERE CHARINDEX(RegionName2, JobName) = 0
  145. UPDATE #t SET JobName = JobName + '招聘' WHERE CHARINDEX('聘', JobName) = 0
  146. DECLARE @t AS TABLE(Id INT, Description NVARCHAR(110))
  147. INSERT INTO @t SELECT DetailId, REPLACE(Description, '以上', '') FROM dcOthers WHERE Category = '招聘人数' AND Description NOT LIKE '%~%'
  148. INSERT INTO @t SELECT DetailId, LEFT(Description, CHARINDEX('~', Description) - 1) + '人' FROM dcOthers WHERE Category = '招聘人数' AND Description LIKE '%~%'
  149. UPDATE a SET NeedNumber = b.Description FROM #t a, @t b WHERE a.NeedNumber = b.Id
  150. UPDATE #t
  151. SET JobDesc = REPLACE(JobDesc, ' ',''),
  152. JobDemand = REPLACE(JobDemand, ' ',''),
  153. Brief = REPLACE(Brief, ' ','')
  154. WHERE CHARINDEX(' ', JobDesc) > 0
  155. OR CHARINDEX(' ', JobDemand) > 0
  156. OR CHARINDEX(' ', Brief) > 0
  157. UPDATE a
  158. SET a.RegionDesc = b.FullName
  159. FROM #t a, MainDb..dcRegion b
  160. WHERE a.JobREgion = b.Id
  161. UPDATE #t SET RegionDesc = '' WHERE CHARINDEX(RegionDesc, Address) > 0
  162. UPDATE #t
  163. SET Address = RIGHT(Address, LEN(Address) - 3)
  164. WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
  165. AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
  166. UPDATE #t
  167. SET Address = RIGHT(Address, LEN(Address) - 3)
  168. WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
  169. AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
  170. UPDATE #t
  171. SET Address = RIGHT(Address, LEN(Address) - 3)
  172. WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
  173. AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
  174. UPDATE #t SET Address = '' WHERE CHARINDEX(Address, RegionDesc) > 0 AND LEN(RegionDesc) > 0
  175. UPDATE #t SET Address = RegionDesc + Address WHERE LEN(RegionDesc) > 0
  176. SELECT id, jobname, JobDESC, JobDemand, jobregion, companyname, edulevel, IsDelete,
  177. experiencelevel, AnnounceDate, dcSalaryID, dcjobtypeID, ShortName, Address, dcCompanySizeID, Brief,
  178. EmployType, adddate, dcCompanyKindID, CASE WHEN EndDate < GETDATE() THEN GETDATE() + 10 ELSE EndDate END enddate, email, EnJobID, EnCpMainID,
  179. IndustryId, SubSiteUrl, SubSiteName, NeedNumber, Welfare1, Welfare2, Welfare3, Welfare4, Welfare5,
  180. Welfare6, Welfare7, Welfare8, Welfare9, Welfare10, Welfare11, Welfare12, Welfare13, Welfare14,
  181. Welfare15, Welfare16, Welfare17, Welfare18
  182. FROM #t ORDER BY RowNo
  183. END
  184. GO
  185. /****** Object: StoredProcedure [dbo].[ProcBaiduZhidaoProcess] Script Date: 2018/12/13 19:09:32 ******/
  186. SET ANSI_NULLS ON
  187. GO
  188. SET QUOTED_IDENTIFIER ON
  189. GO
  190. CREATE PROCEDURE [dbo].[ProcBaiduZhidaoProcess]
  191. AS
  192. BEGIN
  193. UPDATE Marketdb..BaiduZhidaoAnswer SET AnswerKeyWord='伍亿人才网' WHERE CHARINDEX('伍亿人才网',Answer)>0 AND CheckDate>CONVERT(VARCHAR(10),GETDATE(),120)
  194. UPDATE Marketdb..BaiduZhidaoAnswer SET IsLink=1 WHERE CHARINDEX('www.51rc.com',Lower(Answer))>0 AND CheckDate>CONVERT(VARCHAR(10),GETDATE(),120)
  195. UPDATE a SET AnswerKeyWord=b.SubSiteName FROM Marketdb..BaiduZhidaoAnswer a,(
  196. SELECT (SELECT TOP 1 SubSiteName FROM dcSubSite WHERE CHARINDEX(SubSiteName,f.Answer)>0 AND IsMainSite=1) SubSiteName,ID
  197. FROM Marketdb..BaiduZhidaoAnswer f WHERE EXISTS(SELECT 'x' FROM dcSubSite b WHERE CHARINDEX(SubSiteName ,f.Answer)>0 AND IsMainSite=1)
  198. ) b
  199. WHERE a.ID=b.ID AND CheckDate>CONVERT(VARCHAR(10),GETDATE(),120)
  200. UPDATE Marketdb..BaiduZhidaoAnswer SET IsValid=0 WHERE LEN(ANSWER)<10 AND CheckDate>CONVERT(VARCHAR(10),GETDATE(),120)
  201. UPDATE a SET IsLink=1 FROM Marketdb..BaiduZhidaoAnswer a,(
  202. SELECT (SELECT TOP 1 Replace(SubSiteUrl,'www.','') FROM dcSubSite WHERE CHARINDEX(Replace(SubSiteUrl,'www.',''),f.Answer)>0 AND IsMainSite=1) ProvinceDomain,ID
  203. FROM Marketdb..BaiduZhidaoAnswer f WHERE EXISTS(SELECT 'x' FROM dcSubSite b WHERE CHARINDEX(Replace(SubSiteUrl,'www.','') ,f.Answer)>0)
  204. ) b
  205. WHERE a.ID=b.ID AND CheckDate>CONVERT(VARCHAR(10),GETDATE(),120)
  206. UPDATE Marketdb..BaiduZhidaoAnswer SET IsValid=0 WHERE AnswerKeyWord IS NULL AND CheckDate>CONVERT(VARCHAR(10),GETDATE(),120)
  207. UPDATE a SET IsValid=0 FROM Marketdb..BaiduZhidaoAnswer a,dcProvince b WHERE a.dcProvinceID=b.ID AND a.AnswerKeyWord<>b.WebSiteName
  208. AND CheckDate>CONVERT(VARCHAR(10),GETDATE(),120) AND a.AnswerKeyWord<>'伍亿人才网' AND NOT EXISTS(
  209. SELECT 'x' FROM dcSubSite WHERE IsMainSite=1 AND a.dcProvinceID=dcSubSite.ProvinceID AND a.AnswerKeyWord=dcSubSite.SubSiteName
  210. )
  211. UPDATE Marketdb..BaiduZhidaoAnswer SET IsValid=0 WHERE
  212. (SELECT Type FROM WorkDate WITH(NOLOCK) WHERE WorkDate = CONVERT(VARCHAR(8), AnswerDate, 112))=1
  213. AND AnswerDate>CONVERT(VARCHAR(10), AnswerDate, 120)+' 7:00' AND AnswerDate<CONVERT(VARCHAR(10), AnswerDate, 120)+' 18:00'
  214. AND CheckDate>CONVERT(VARCHAR(10),GETDATE(),120)
  215. END
  216. GO
  217. /****** Object: StoredProcedure [dbo].[ProcBatchSms] Script Date: 2018/12/13 19:09:32 ******/
  218. SET ANSI_NULLS ON
  219. GO
  220. SET QUOTED_IDENTIFIER ON
  221. GO
  222. CREATE PROCEDURE [dbo].[ProcBatchSms]
  223. AS
  224. BEGIN
  225. BEGIN TRY
  226. DROP Table a_00
  227. END TRY
  228. BEGIN CATCH
  229. END CATCH
  230. BEGIN TRY
  231. DROP Table A_01
  232. END TRY
  233. BEGIN CATCH
  234. END CATCH
  235. BEGIN TRY
  236. DROP Table A_02
  237. END TRY
  238. BEGIN CATCH
  239. END CATCH
  240. BEGIN TRY
  241. DROP Table A_03
  242. END TRY
  243. BEGIN CATCH
  244. END CATCH
  245. --个人:年前一个月注册且年后没登陆。(北京、上海、山东)
  246. --尊敬的会员,3月5日xxx人才x元宵节找工作送福利,多名就业导师为您求职答疑解惑,期待您的登录www.xxxxrc.com
  247. select DISTINCT dcProvinceId, space(50) SiteName, space(50) SiteUrl, Mobile, space(300) Msg, 0 Status
  248. INTO a_00
  249. from pamain
  250. where id between 25572640 and 25629133
  251. and mobile like '1%'
  252. and lastlogindate < '2015-2-18'
  253. and dcprovinceid in(10,30,32)
  254. delete a_00 where mobile in(select mobile from paMain where lastlogindate > '2015-2-18')
  255. INSERT INTO a_00 select 10, '', '', '13455496132', '', 0
  256. --单位:1个月内即将到期的付费会员
  257. --尊敬的会员,3月5日xxx人才x元宵节嗨聊全场,多种活动期待您的参与,www.xxxxrc.com
  258. select id cpMainId, id camainid, dcProvinceId, space(50) SiteName, space(50) SiteUrl, space(11) Mobile, space(300) Msg, 0 Status
  259. into A_01
  260. from cpmain
  261. where membertype=3
  262. and id not in(select cpmainid from caorder where enddate > getdate()+30 and ordertype=8 and isdeleted=0 and opendate > '')
  263. and dcprovinceid in(10,30,32)
  264. INSERT into A_01 SELECT 371108, 371108, 32,'','','','',0
  265. --单位:年后查看过资费标准的免费会员 5100
  266. --drop table A_02
  267. select DISTINCT caMainId cpMainId, caMainId, 999 dcProvinceId, space(50) SiteName, space(50) SiteUrl, space(11) Mobile, space(300) Msg
  268. into A_02
  269. from cafeepageviewlog
  270. where adddate >'2015-2-18'
  271. UPDATE A_01 SET caMainId = 0
  272. UPDATE A_02 SET cpMainId = 0
  273. UPDATE A_02 SET cpMainId = (SELECT cpMainId FROM caMain WHERE caMain.ID = A_02.caMainId)
  274. INSERT A_01(cpMainID, caMainId, dcProvinceId, status) SELECT DISTINCT cpMainID, 0, 0, 0 FROM A_02 WHERE cpMainId NOT IN(SELECT CpMainID FROM A_01) AND cpMainId > 0
  275. UPDATE a SET a.dcProvinceID = b.dcProvinceId FROM A_01 a, cpMain b WHERE a.cpMainId = b.Id
  276. UPDATE a SET a.caMainId = b.Id,
  277. a.Mobile = b.Mobile
  278. FROM A_01 a, caMain b
  279. WHERE b.AccountType = 1 AND a.cpMainId = b.cpMainId
  280. DELETE A_01 WHERE CaMainId = 0
  281. DELETE A_01 WHERE Mobile NOT LIKE '1%'
  282. DELETE A_01 WHERE LEN(Mobile) <> 11
  283. DELETE A_01 WHERE Mobile IS NULL
  284. DELETE A_01 WHERE Mobile = '13000000000'
  285. DELETE A_01 WHERE dcProvinceId NOT IN(10, 30, 32)
  286. UPDATE a SET a.SiteName = b.WebSiteName, a.SiteUrl = 'www.' + b.ProvinceDomain
  287. FROM A_01 a, dcProvince b
  288. WHERE a.dcProvinceID = b.Id
  289. UPDATE a SET a.SiteName = b.WebSiteName, a.SiteUrl = 'www.' + b.ProvinceDomain
  290. FROM a_00 a, dcProvince b
  291. WHERE a.dcProvinceID = b.Id
  292. UPDATE a_00 SET Msg = '尊敬的会员,3月5日' + SiteName + '元宵节找工作送福利,多名就业导师为您求职答疑解惑,期待您的登录' + SiteUrl
  293. UPDATE A_01 set Msg = '尊敬的会员,3月5日' + SiteName + '元宵节嗨聊全场,多种活动期待您的参与' + SiteUrl
  294. --drop table A_03
  295. SELECT DISTINCT dcProvinceID, Mobile, Msg, Status INTO A_03 FROM A_01
  296. -- select * from a_00 where mobile='13455496132'
  297. -- select * from A_03 where mobile='13455496132'
  298. -- select mobile, count(*) from a_00 group by mobile having count(*) >1 order by count(*) DESC
  299. -- select mobile, count(*) from A_03 group by mobile having count(*) >1 order by count(*) DESC
  300. ---must updated
  301. CREATE TABLE #t(Id INT IDENTITY(1, 1), ProvinceId INT, Cnt INT, Msg NVARCHAR(500))
  302. CREATE TABLE #m(Mobile VARCHAR(20))
  303. INSERT INTO #t(provinceid, cnt, msg)
  304. SELECT dcProvinceId, COUNT(*) Cnt, msg
  305. FROM a_00
  306. WHERE Status = 0
  307. GROUP BY dcProvinceId,msg
  308. DECLARE @Id INT, @MobileString VARCHAR(MAX), @Msg NVARCHAR(500), @ProvinceId INT
  309. SET @Id = 0
  310. WHILE EXISTS(SELECT Id FROM #t WHERE Id > @Id)
  311. BEGIN
  312. SELECT TOP 1 @MobileString = '', @Id = Id, @ProvinceId = ProvinceId, @Msg = Msg FROM #t WHERE Id > @Id ORDER BY Id
  313. TRUNCATE TABLE #m
  314. INSERT INTO #m
  315. SELECT TOP 500 Mobile
  316. FROM a_00
  317. WHERE dcProvinceId = @ProvinceId
  318. AND Status = 0
  319. ORDER BY Mobile
  320. SELECT TOP 500 @MobileString = @MobileString + ',' + Mobile
  321. FROM #m
  322. IF LEN(@MobileString) > 1
  323. BEGIN
  324. SET @MobileString = RIGHT(@MobileString, LEN(@MobileString) - 1)
  325. INSERT INTO a04(Mobile, Msg) SELECT @MobileString, @Msg
  326. UPDATE a_00 SET Status = 1 WHERE Mobile IN(SELECT Mobile FROM #m)
  327. END
  328. END
  329. /*
  330. insert smsBatchSend(mobile,msg) select mobile,msg from a04
  331. SELECT top 100 * FROM smsBatchSend
  332. --where sendstatus is null
  333. order by id desc
  334. */
  335. /*
  336. truncate table a04
  337. drop table #t
  338. drop table #m
  339. CREATE TABLE #t(Id INT IDENTITY(1, 1), ProvinceId INT, Cnt INT, Msg NVARCHAR(500))
  340. CREATE TABLE #m(Mobile VARCHAR(20))
  341. select * from #t
  342. select * from #m
  343. select * from A_03
  344. INSERT INTO #t(provinceid, cnt, msg)
  345. SELECT dcProvinceId, COUNT(*) Cnt, msg
  346. FROM A_03
  347. WHERE Status = 0
  348. GROUP BY dcProvinceId,msg
  349. DECLARE @Id INT, @MobileString VARCHAR(MAX), @Msg NVARCHAR(500), @ProvinceId INT
  350. SET @Id = 0
  351. WHILE EXISTS(SELECT Id FROM #t WHERE Id > @Id)
  352. BEGIN
  353. SELECT TOP 1 @MobileString = '', @Id = Id, @ProvinceId = ProvinceId, @Msg = Msg FROM #t WHERE Id > @Id ORDER BY Id
  354. TRUNCATE TABLE #m
  355. INSERT INTO #m
  356. SELECT TOP 500 Mobile
  357. FROM A_03
  358. WHERE dcProvinceId = @ProvinceId
  359. AND Status = 0
  360. ORDER BY Mobile
  361. SELECT TOP 500 @MobileString = @MobileString + ',' + Mobile
  362. FROM #m
  363. IF LEN(@MobileString) > 1
  364. BEGIN
  365. SET @MobileString = RIGHT(@MobileString, LEN(@MobileString) - 1)
  366. INSERT INTO a04(Mobile, Msg) SELECT @MobileString, @Msg
  367. UPDATE A_03 SET Status = 1 WHERE Mobile IN(SELECT Mobile FROM #m)
  368. END
  369. END
  370. select len(mobile)/12,* from a04
  371. -----
  372. select * from a04
  373. insert smsBatchSend(mobile,msg) select mobile,msg from a04
  374. SELECT top 100 * FROM smsBatchSend
  375. where sendstatus is null
  376. order by id desc
  377. */
  378. END
  379. GO
  380. /****** Object: StoredProcedure [dbo].[procbatchsms2] Script Date: 2018/12/13 19:09:33 ******/
  381. SET ANSI_NULLS ON
  382. GO
  383. SET QUOTED_IDENTIFIER ON
  384. GO
  385. CREATE procedure [dbo].[procbatchsms2]
  386. as
  387. begin
  388. BEGIN TRY
  389. DROP Table a_00
  390. END TRY
  391. BEGIN CATCH
  392. END CATCH
  393. BEGIN TRY
  394. DROP Table A_01
  395. END TRY
  396. BEGIN CATCH
  397. END CATCH
  398. BEGIN TRY
  399. DROP Table A_02
  400. END TRY
  401. BEGIN CATCH
  402. END CATCH
  403. BEGIN TRY
  404. DROP Table A_03
  405. END TRY
  406. BEGIN CATCH
  407. END CATCH
  408. BEGIN TRY
  409. DROP Table A_04
  410. END TRY
  411. BEGIN CATCH
  412. END CATCH
  413. /*
  414. --1、一个月即将到期的(后续没有开通订单的)会员。
  415. select distinct id cpMainId, id camainid, dcProvinceId, space(50) SiteName, space(50) SiteUrl, space(11) Mobile, space(300) Msg, 0 Status
  416. into A_00
  417. from cpmain
  418. where MemberType = 3
  419. AND Id IN(SELECT cpMainId FROM caorder
  420. WHERE OrderType = 8 AND IsDeleted = 0 AND OpenDate > 0
  421. AND EndDate BETWEEN getdate() and GETDATE() + 31)
  422. AND Id NOT IN(SELECT cpMainId FROM caorder WHERE OrderType = 8 AND IsDeleted = 0 AND EndDate > GETDATE()+ 31)
  423. --2、两个月内查看资费标准在三次以上的处于免费会员状态的。
  424. select id cpMainId, id camainid, dcProvinceId, space(50) SiteName, space(50) SiteUrl, space(11) Mobile, space(300) Msg, 0 Status
  425. into A_01
  426. from cpmain
  427. where membertype=3
  428. and id IN(
  429. SELECT a.cpMainId
  430. FROM caMain a, caFeePageViewLog b
  431. WHERE a.Id = b.caMainId
  432. AND b.AddDate > GETDATE() - 61
  433. GROUP BY a.cpMainId
  434. HAVING COUNT(*) > 2
  435. )
  436. AND ID NOT IN(SELECT cpMainId FROM A_00)
  437. INSERT into A_01 select * from a_00
  438. --3、到期后三个月内没有付费并处于免费会员状态的。
  439. insert into a_01
  440. select distinct id cpMainId, id camainid, dcProvinceId, space(50) SiteName, space(50) SiteUrl, space(11) Mobile, space(300) Msg, 0 Status
  441. from cpmain
  442. where MemberType < 3
  443. AND Id IN(SELECT cpMainId FROM caorder
  444. WHERE OrderType = 8 AND IsDeleted = 0 AND OpenDate > 0
  445. AND EndDate > getdate() - 92)
  446. AND Id NOT IN(SELECT cpMainId FROM caorder WHERE OrderType = 8 AND IsDeleted = 0 AND EndDate > GETDATE() AND OpenDate > '')
  447. AND Id NOT IN(SELECT cpMainId FROM A_01)
  448. --4、本月提交订单未开通并处于免费会员状态的。
  449. insert into a_01
  450. select distinct id cpMainId, id camainid, dcProvinceId, space(50) SiteName, space(50) SiteUrl, space(11) Mobile, space(300) Msg, 0 Status
  451. from cpmain
  452. where MemberType < 3
  453. AND Id IN(SELECT cpMainId FROM caorder
  454. WHERE OrderType = 8 AND IsDeleted = 0 AND OpenDate IS NULL
  455. AND AddDate > '2016-5-26')
  456. AND Id NOT IN(SELECT cpMainId FROM caorder WHERE OrderType = 8 AND IsDeleted = 0 AND EndDate > GETDATE() AND OpenDate > '')
  457. AND Id NOT IN(SELECT cpMainId FROM A_01)
  458. -- INSERT into A_01 SELECT 371108, 371108, 32,'','','','',0
  459. --UPDATE A_01 SET caMainId = 0
  460. --UPDATE A_02 SET cpMainId = 0
  461. --UPDATE A_02 SET cpMainId = ISNULL((SELECT cpMainId FROM caMain WHERE caMain.ID = A_02.caMainId), 0)
  462. --DELETE from a_02 where cpmainid=0
  463. --INSERT A_01(cpMainID, caMainId, dcProvinceId, status)
  464. --SELECT DISTINCT cpMainID, 0, 0, 0 FROM A_02 WHERE cpMainId NOT IN(SELECT CpMainID FROM A_01) AND cpMainId > 0
  465. ---------------------------
  466. UPDATE a SET a.dcProvinceID = b.dcProvinceId FROM A_01 a, cpMain b WHERE a.cpMainId = b.Id
  467. UPDATE a SET a.caMainId = b.Id,
  468. a.Mobile = b.Mobile
  469. FROM A_01 a, caMain b
  470. WHERE b.AccountType = 1 AND a.cpMainId = b.cpMainId
  471. DELETE A_01 WHERE CaMainId = 0
  472. DELETE A_01 WHERE Mobile NOT LIKE '1%'
  473. DELETE A_01 WHERE LEN(Mobile) <> 11
  474. DELETE A_01 WHERE Mobile IS NULL
  475. DELETE A_01 WHERE Mobile = '13000000000'
  476. DELETE A_01 WHERE Mobile = '15000000000'
  477. DELETE A_01 WHERE Mobile = '15555555555'
  478. DELETE A_01 WHERE Mobile = '13222222222'
  479. delete a_01 WHERE cpMainId NOT IN(select max(cpMainId) cpMainId FROM a_01 group by Mobile)
  480. DELETE a_01 where mobile in(select mobile from marketdb..NoSendSms)
  481. --select mobile, count(*) from a_01 group by mobile order by count(*) desc
  482. UPDATE a SET a.SiteName = b.WebSiteName, a.SiteUrl = 'www.' + b.ProvinceDomain
  483. FROM A_01 a, dcProvince b
  484. WHERE a.dcProvinceID = b.Id
  485. -- UPDATE a SET a.SiteName = b.WebSiteName, a.SiteUrl = 'www.' + b.ProvinceDomain
  486. -- FROM a_00 a, dcProvince b
  487. -- WHERE a.dcProvinceID = b.Id
  488. -- select * from a_01 where subno > 7000
  489. select * from a_01 where subno > 7900 or subno < 5600
  490. alter table a_01 add subno int
  491. update a set a.subno = b.consultantid from a_01 a, cpmain b where a.cpmainid= b.id
  492. update a_01 set subno = subno + 6000 where subno > 699
  493. update a_01 set subno = subno + 6000 where subno < 600
  494. update a_01 set subno = subno + 5000 where subno between 600 and 699
  495. --UPDATE a_00 SET Msg = '尊敬的会员,3月5日' + SiteName + '元宵节找工作送福利,多名就业导师为您求职答疑解惑,期待您的登录' + SiteUrl
  496. UPDATE A_01 set Msg = '亲爱的会员,' + SiteName + '粽情端午套餐优惠活动邀您参与,时间有限快来咨询吧!4006265151'
  497. + CASE WHEN SubNo IS NULL THEN '' ELSE '-' + LTRIM(STR(SubNo)) END + '。'
  498. --select sitename, count(*) from a_01 group by sitename order by count(*)
  499. --select * from a_01
  500. alter table a_01 add id int identity(1,1)
  501. SELECT min(id) id, Mobile, Status INTO A_03 FROM A_01 group by Mobile, Status
  502. alter table a_03 add dcProvinceId int
  503. alter table a_03 add msg nvarchar(200)
  504. update a set a.dcProvinceId = b.dcProvinceId,a.msg=b.msg from a_03 a, a_01 b where a.id=b.id
  505. --select left(msg, 5), count(*) from a_03 group by left(msg, 5) order by count(*) Desc
  506. -- select * from a_00 where mobile='13455496132'
  507. -- select * from A_03 where mobile='13455496132'
  508. -- select mobile, count(*) from a_00 group by mobile having count(*) >1 order by count(*) DESC
  509. -- select mobile, count(*) from A_03 group by mobile having count(*) >1 order by count(*) DESC
  510. ---must updated
  511. --delete a_03 where msg in(select msg from a_03 group by msg having count(*) < 120)
  512. --select count(distinct mobile), count(*) from a_03
  513. --select * from a_03
  514. --drop table #t
  515. --drop table #m
  516. --drop table a_04
  517. CREATE TABLE #t(Id INT IDENTITY(1, 1), ProvinceId INT, Cnt INT, Msg NVARCHAR(500))
  518. CREATE TABLE #m(Mobile VARCHAR(20))
  519. INSERT INTO #t(provinceid, cnt, msg)
  520. SELECT dcProvinceId, COUNT(*) Cnt, msg
  521. FROM a_03
  522. WHERE Status = 0
  523. GROUP BY dcProvinceId, msg
  524. CREATE TABLE a_04(Id INT IDENTITY(1, 1), Mobile varchar(MAX), Msg NVARCHAR(300))
  525. --select * from a_03
  526. DECLARE @Id INT, @MobileString VARCHAR(MAX), @Msg NVARCHAR(500), @ProvinceId INT
  527. SET @Id = 0
  528. WHILE EXISTS(SELECT Id FROM #t WHERE Id > @Id)
  529. BEGIN
  530. SELECT TOP 1 @MobileString = '', @Id = Id, @ProvinceId = ProvinceId, @Msg = Msg FROM #t WHERE Id > @Id ORDER BY Id
  531. TRUNCATE TABLE #m
  532. INSERT INTO #m
  533. SELECT TOP 500 Mobile
  534. FROM a_03
  535. WHERE dcProvinceId = @ProvinceId
  536. AND Status = 0
  537. ORDER BY Mobile
  538. SELECT TOP 500 @MobileString = @MobileString + ',' + Mobile
  539. FROM #m
  540. IF LEN(@MobileString) > 1
  541. BEGIN
  542. SET @MobileString = RIGHT(@MobileString, LEN(@MobileString) - 1)
  543. INSERT INTO a_04(Mobile, Msg) SELECT @MobileString, @Msg
  544. UPDATE a_03 SET Status = 1 WHERE Mobile IN(SELECT Mobile FROM #m)
  545. END
  546. END
  547. --update a_04 set mobile='18363443519,' + mobile where id=2
  548. select sum((len(mobile)+1)/12.0) from a_04
  549. select (len(mobile)+1)/12.0,* from a_04 order by id
  550. insert smsBatchSend(mobile,msg) select mobile,msg from a_04 WHERE ID <> 2
  551. SELECT top 35 * FROM smsBatchSend
  552. where sendstatus is null
  553. order by id desc
  554. */
  555. end
  556. GO
  557. /****** Object: StoredProcedure [dbo].[ProcBeisenAdsSave] Script Date: 2018/12/13 19:09:33 ******/
  558. SET ANSI_NULLS ON
  559. GO
  560. SET QUOTED_IDENTIFIER ON
  561. GO
  562. CREATE PROCEDURE [dbo].[ProcBeisenAdsSave]
  563. (
  564. @Id INT,
  565. @TenantId VARCHAR(50),
  566. @JobAdId VARCHAR(50),
  567. @JobAdName NVARCHAR(500),
  568. @JobType NVARCHAR(500),
  569. @LocID NVARCHAR(500),
  570. @Salary NVARCHAR(500),
  571. @Degree NVARCHAR(500),
  572. @YearsofWorking NVARCHAR(50),
  573. @EndTime DATETIME,
  574. @Email VARCHAR,
  575. @Status NVARCHAR(100),
  576. @CreateDate DATETIME,
  577. @ModifiedDate DATETIME
  578. )
  579. AS
  580. SET NOCOUNT ON
  581. BEGIN
  582. IF NOT EXISTS (SELECT 'x' FROM BeisenAds WHERE Id = @Id)
  583. BEGIN
  584. INSERT INTO BeisenAds(Id, TenantId, JobAdId, JobAdName, JobType, LocID, Salary, Degree, YearsofWorking, EndTime, Email, Status, CreateDate, ModifiedDate, Adddate, LastGetDate)
  585. SELECT @Id, @TenantId, @JobAdId, @JobAdName, @JobType, @LocID, @Salary, @Degree, @YearsofWorking, @EndTime, @Email, @Status, @CreateDate, @ModifiedDate, GETDATE(), GETDATE()
  586. END
  587. ELSE
  588. BEGIN
  589. DECLARE @ModifiedDate2 AS DATETIME
  590. SELECT @ModifiedDate2 FROM BeisenAds WHERE Id = @Id
  591. IF @ModifiedDate2 < @ModifiedDate
  592. BEGIN
  593. UPDATE BeisenAds
  594. SET TenantId = @TenantId,
  595. JobAdId = @JobAdId,
  596. JobAdName = @JobAdName,
  597. JobType = @JobType,
  598. LocID = @LocID,
  599. Salary = @Salary,
  600. Degree = @Degree,
  601. YearsofWorking = @YearsofWorking,
  602. EndTime = @EndTime,
  603. Email = @Email,
  604. Status = @Status,
  605. CreateDate = @CreateDate,
  606. ModifiedDate = @ModifiedDate,
  607. LastGetDate = GETDATE()
  608. WHERE ID = @Id
  609. UPDATE BeisenAdsId SET IsModified = 1 WHERE BeisenAdsId = @Id
  610. END
  611. END
  612. RETURN 1
  613. END
  614. GO
  615. /****** Object: StoredProcedure [dbo].[ProcBeiSenCompanySave] Script Date: 2018/12/13 19:09:34 ******/
  616. SET ANSI_NULLS ON
  617. GO
  618. SET QUOTED_IDENTIFIER ON
  619. GO
  620. CREATE PROCEDURE [dbo].[ProcBeiSenCompanySave]
  621. (
  622. @TenantId VARCHAR(50),
  623. @Name NVARCHAR(500),
  624. @Domain NVARCHAR(500),
  625. @Abbreviation NVARCHAR(500),
  626. @Address NVARCHAR(500),
  627. @PostalCode NVARCHAR(500),
  628. @EmailHost NVARCHAR(500),
  629. @Logo VARCHAR(500)
  630. )
  631. AS
  632. SET NOCOUNT ON
  633. BEGIN
  634. IF NOT EXISTS (SELECT 'x' FROM BeiSenCompany WHERE TenantId = @TenantId)
  635. BEGIN
  636. INSERT INTO BeiSenCompany(TenantId, Name, Domain, Abbreviation, Address, PostalCode, EmailHost, Logo, AddDate)
  637. SELECT @TenantId, @Name, @Domain, @Abbreviation, @Address, @PostalCode, @EmailHost, @Logo, GETDATE()
  638. END
  639. ELSE
  640. BEGIN
  641. DECLARE @IsModified BIT
  642. IF EXISTS(SELECT 'x' FROM BeisenCompany
  643. WHERE TenantId = @TenantId
  644. AND ISNULL(Name, '') != ISNULL(@Name, '')
  645. AND ISNULL(Domain, '') != ISNULL(@Domain, '')
  646. AND ISNULL(Abbreviation, '') != ISNULL(@Abbreviation, '')
  647. AND ISNULL(Address, '') != ISNULL(@Address, '')
  648. AND ISNULL(PostalCode, '') != ISNULL(@PostalCode, '')
  649. AND ISNULL(EmailHost, '') != ISNULL(@EmailHost, '')
  650. AND ISNULL(Logo, '') != ISNULL(@Logo, ''))
  651. BEGIN
  652. UPDATE BeisenCompany
  653. SET Name= @Name,
  654. Domain= @Domain,
  655. Abbreviation= @Abbreviation,
  656. Address= @Address,
  657. PostalCode= @PostalCode,
  658. EmailHost= @EmailHost,
  659. Logo= @Logo
  660. WHERE TenantId = @TenantId
  661. END
  662. END
  663. RETURN 1
  664. END
  665. GO
  666. /****** Object: StoredProcedure [dbo].[ProcBeisenJobApplyBySendSelect] Script Date: 2018/12/13 19:09:34 ******/
  667. SET ANSI_NULLS ON
  668. GO
  669. SET QUOTED_IDENTIFIER ON
  670. GO
  671. CREATE PROCEDURE [dbo].[ProcBeisenJobApplyBySendSelect]
  672. AS
  673. SET NOCOUNT ON
  674. BEGIN
  675. IF NOT EXISTS(SELECT '' FROM BeisenJobApply WHERE BeisenHasApply IS NULL)
  676. BEGIN
  677. SELECT TOP 0 'a' a
  678. RETURN
  679. END
  680. SELECT TOP 99 *
  681. INTO #t
  682. FROM BeisenJobApply
  683. WHERE BeisenHasApply IS NULL
  684. UPDATE #t SET cvText = dbo.GetBeiSenCvText(cvMainID) WHERE cvText IS NULL
  685. UPDATE a SET a.cvText = b.cvText FROM BeisenJobApply a, #t b WHERE a.Id = b.Id AND a.cvText = ''
  686. DELETE a FROM BeisenJobApply a, #t b WHERE a.Id = b.Id AND b.cvText = ''
  687. DELETE #t WHERE cvText = ''
  688. IF EXISTS(SELECT 'x' FROM #t)
  689. BEGIN
  690. SELECT a.Id, b.Name, d.TenantID, d.JobAdId, c.Id BeisenJobApplyId, c.cvText, b.Mobile, b.Email
  691. FROM cvMain a, paMain b, #t c, BeisenAds d
  692. WHERE a.paMainId = b.Id
  693. AND a.Id = c.cvMainId
  694. AND c.BeisenHasApply IS NULL
  695. AND c.JobId = d.JobId
  696. END
  697. ELSE
  698. SELECT * FROM #t
  699. END
  700. GO
  701. /****** Object: StoredProcedure [dbo].[procBestEmployerByCpMainIDSelect] Script Date: 2018/12/13 19:09:34 ******/
  702. SET ANSI_NULLS ON
  703. GO
  704. SET QUOTED_IDENTIFIER ON
  705. GO
  706. CREATE PROCEDURE [dbo].[procBestEmployerByCpMainIDSelect]
  707. (
  708. @cpMainID INT
  709. )
  710. AS
  711. BEGIN
  712. SET NOCOUNT OFF
  713. SELECT * FROM BestEmployer WITH(NOLOCK) WHERE cpMainID = @cpMainID
  714. SET NOCOUNT ON
  715. END
  716. GO
  717. /****** Object: StoredProcedure [dbo].[procBestEmployerInsert] Script Date: 2018/12/13 19:09:35 ******/
  718. SET ANSI_NULLS ON
  719. GO
  720. SET QUOTED_IDENTIFIER ON
  721. GO
  722. CREATE PROCEDURE [dbo].[procBestEmployerInsert]
  723. (
  724. @cpMainID INT
  725. )
  726. AS
  727. BEGIN
  728. SET NOCOUNT OFF
  729. IF EXISTS(SELECT 'X' FROM BestEmployer WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  730. RETURN
  731. INSERT INTO BestEmployer(cpMainID, CompanyName)
  732. SELECT ID, [Name] FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
  733. SET NOCOUNT ON
  734. END
  735. GO
  736. /****** Object: StoredProcedure [dbo].[procBestEmployerSelect] Script Date: 2018/12/13 19:09:35 ******/
  737. SET ANSI_NULLS ON
  738. GO
  739. SET QUOTED_IDENTIFIER ON
  740. GO
  741. CREATE PROCEDURE [dbo].[procBestEmployerSelect]
  742. (
  743. @Where VARCHAR(500)
  744. )
  745. AS
  746. BEGIN
  747. SET NOCOUNT OFF
  748. DECLARE @SQL VARCHAR(2000)
  749. SET @SQL = 'SELECT * FROM BestEmployer WITH(NOLOCK) WHERE 1 = 1' + @Where + ' ORDER BY ID DESC'
  750. EXEC(@SQL)
  751. SET NOCOUNT ON
  752. END
  753. GO
  754. /****** Object: StoredProcedure [dbo].[procBestEmployVoteInsert] Script Date: 2018/12/13 19:09:35 ******/
  755. SET ANSI_NULLS ON
  756. GO
  757. SET QUOTED_IDENTIFIER ON
  758. GO
  759. CREATE PROCEDURE [dbo].[procBestEmployVoteInsert]
  760. (
  761. @ID INT,
  762. @OpenID VARCHAR(50)
  763. )
  764. AS
  765. BEGIN
  766. SET NOCOUNT OFF
  767. IF EXISTS(SELECT 'X' FROM BestEmployerVote WHERE OpenID = @OpenID AND BestEmployerID = @ID AND CONVERT(VARCHAR(8), GETDATE(), 112) = CONVERT(VARCHAR(8), AddDate, 112))
  768. RETURN -1
  769. IF (SELECT COUNT(1) FROM BestEmployerVote WHERE OpenID = @OpenID AND CONVERT(VARCHAR(8), GETDATE(), 112) = CONVERT(VARCHAR(8), AddDate, 112)) >= 3
  770. RETURN -2
  771. INSERT INTO BestEmployerVote(BestEmployerID, OpenID) VALUES(@ID, @OpenID)
  772. RETURN 1
  773. SET NOCOUNT ON
  774. END
  775. GO
  776. /****** Object: StoredProcedure [dbo].[ProcbsAskDetailSelect] Script Date: 2018/12/13 19:09:35 ******/
  777. SET ANSI_NULLS ON
  778. GO
  779. SET QUOTED_IDENTIFIER ON
  780. GO
  781. CREATE PROCEDURE [dbo].[ProcbsAskDetailSelect]
  782. (
  783. @ID INT
  784. )
  785. AS
  786. SET NOCOUNT ON
  787. BEGIN
  788. --修改点击量
  789. UPDATE bsASKInfo SET ClickNumber = ClickNumber + 1 WHERE ID = @ID
  790. --记录每日点击
  791. -- DECLARE @bsAskInfoDayReportId INT
  792. -- SELECT @bsAskInfoDayReportId = ID FROM bsAskInfoDayReport WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112) AND bsAskInfoId = @Id
  793. -- IF @bsAskInfoDayReportId &gt; 0
  794. -- UPDATE bsAskInfoDayReport
  795. -- SET VisitNumber = VisitNumber + 1
  796. -- WHERE Id = @bsAskInfoDayReportId
  797. -- ELSE
  798. -- INSERT INTO bsAskInfoDayReport
  799. -- SELECT CONVERT(VARCHAR(8), GETDATE(), 112), @id, 1
  800. SELECT ID, Title, Question, Answer, SolveDate, UpdateDate, UserName, Mark, ProvinceIDs, TypeID,
  801. (SELECT TypeName FROM bsAskTypeSet WITH(NOLOCK) WHERE ID = bsaskinfo.TypeID) TypeName,ClickNumber
  802. FROM bsASKInfo WITH(NOLOCK)
  803. WHERE ID = @ID
  804. END
  805. SET NOCOUNT OFF
  806. GO
  807. /****** Object: StoredProcedure [dbo].[ProcbsASKInfoALLSelect] Script Date: 2018/12/13 19:09:35 ******/
  808. SET ANSI_NULLS ON
  809. GO
  810. SET QUOTED_IDENTIFIER ON
  811. GO
  812. --#####################################################
  813. --创建时间:2014.10.28
  814. --创建人:Nick
  815. --说明:获取全部求职互助
  816. --#####################################################
  817. CREATE PROCEDURE [dbo].[ProcbsASKInfoALLSelect]
  818. @dcProvinceId INT,
  819. @PageNo INT
  820. AS
  821. BEGIN TRY
  822. SELECT *
  823. FROM bsAskInfoTmp WITH(NOLOCK)
  824. WHERE dcProvinceId=@dcProvinceId
  825. AND PageNo=@PageNo ORDER BY OrderNo
  826. END TRY
  827. BEGIN CATCH
  828. RETURN 0
  829. END CATCH
  830. GO
  831. /****** Object: StoredProcedure [dbo].[ProcBsAskInfoByAdvicesSelect] Script Date: 2018/12/13 19:09:35 ******/
  832. SET ANSI_NULLS ON
  833. GO
  834. SET QUOTED_IDENTIFIER ON
  835. GO
  836. --sean 2014-11-19
  837. CREATE PROCEDURE [dbo].[ProcBsAskInfoByAdvicesSelect]
  838. (
  839. @ProvinceId INT
  840. )
  841. AS
  842. SET NOCOUNT ON
  843. --INSERT INTO procLog SELECT 'ProcBsAskInfoByAdvicesSelect', @ProvinceId, GETDATE()
  844. BEGIN
  845. SET @ProvinceId = LEFT(@ProvinceId, 2)
  846. DECLARE @p VARCHAR(10), @u VARCHAR(100), @s VARCHAR(50)
  847. SELECT @p = ',' + LTRIM(STR(@ProvinceId)), @s = SubSiteUrl, @u = 'http://' + SubSiteUrl + '/ask/' FROM dcSubSite WHERE Id = @ProvinceId
  848. CREATE TABLE #t(
  849. Title VARCHAR(300),
  850. Question NVARCHAR(MAX),
  851. Answer NVARCHAR(MAX),
  852. ID INT,
  853. Url VARCHAR(100),
  854. UserName VARCHAR(20),
  855. AddDate SMALLDATETIME,
  856. SubSiteUrl VARCHAR(50))
  857. INSERT INTO #t
  858. SELECT Title, Question, Answer, Id, SPACE(100) Url, UserName, AddDate, @s
  859. FROM bsAskInfo WITH(NOLOCK)
  860. WHERE CHARINDEX(@p, ProvinceIds) > 0
  861. UPDATE #t SET Url = @u + LTRIM(STR(ID)) + '.html'
  862. SELECT *, AddDate + 1 Replydate FROM #t ORDER BY ID DESC
  863. END
  864. GO
  865. /****** Object: StoredProcedure [dbo].[procBsAskInfoByProvinceIDSelect] Script Date: 2018/12/13 19:09:36 ******/
  866. SET ANSI_NULLS ON
  867. GO
  868. SET QUOTED_IDENTIFIER ON
  869. GO
  870. --#####################################################
  871. --创建时间:2014.11.5
  872. --创建人:NICK
  873. --说明:求职互助
  874. --#####################################################
  875. CREATE PROCEDURE [dbo].[procBsAskInfoByProvinceIDSelect]
  876. (
  877. @provinceID VARCHAR(20)
  878. )
  879. AS
  880. BEGIN
  881. SELECT TOP 11 a.id, a.title, a.typeid, a.solvedate, a.updatedate, t.typename
  882. FROM bsaskinfo a WITH(NOLOCK), bsAskTypeSet t WITH(NOLOCK)
  883. WHERE a.typeid=t.id
  884. AND a.isonline=1
  885. AND provinceids LIKE '%,'+@provinceID+',%'
  886. ORDER BY a.updatedate DESC
  887. END
  888. GO
  889. /****** Object: StoredProcedure [dbo].[ProcBsAskInfoByXmlSelect] Script Date: 2018/12/13 19:09:36 ******/
  890. SET ANSI_NULLS ON
  891. GO
  892. SET QUOTED_IDENTIFIER ON
  893. GO
  894. CREATE PROCEDURE [dbo].[ProcBsAskInfoByXmlSelect]
  895. (
  896. @ProvinceId INT
  897. )
  898. AS
  899. --INSERT INTO procLog SELECT 'ProcBsAskInfoByXmlSelect', @ProvinceId, GETDATE()
  900. BEGIN
  901. SELECT TOP 5000 '/ask/' + CONVERT(VARCHAR,ID) + '.html' link
  902. FROM bsAskInfo WITH(NOLOCK)
  903. WHERE IsOnline = 1
  904. AND ProvinceIds LIKE '%,' + LTRIM(STR(@ProvinceId)) + '%'
  905. AND SolveDate > GETDATE() - 14
  906. END
  907. GO
  908. /****** Object: StoredProcedure [dbo].[ProcbsASKInfoHotQuestionSelect] Script Date: 2018/12/13 19:09:36 ******/
  909. SET ANSI_NULLS ON
  910. GO
  911. SET QUOTED_IDENTIFIER ON
  912. GO
  913. --#####################################################
  914. --创建时间:2014.10.28
  915. --创建人:Nick
  916. --说明:获取求职互助热门话题
  917. --#####################################################
  918. CREATE PROCEDURE [dbo].[ProcbsASKInfoHotQuestionSelect]
  919. (
  920. @ProvinceID INT
  921. )
  922. AS
  923. BEGIN TRY
  924. /*
  925. SELECT TOP 10 a.Id, a.Title
  926. FROM bsAskInfo a WITH(NOLOCK)
  927. WHERE a.IsOnline = 1
  928. AND ProvinceIds LIKE '%'+CONVERT(VARCHAR(10),@ProvinceID)+'%'
  929. AND AddDate > DATEADD(MONTH, -1, GETDATE())
  930. ORDER BY a.ClickNumber DESC
  931. */
  932. SELECT TOP 10 ID, Title
  933. FROM SearchDb..bsAskInfoHot WITH(NOLOCK)
  934. WHERE ProvinceId = @ProvinceId
  935. ORDER BY ClickNumber DESC
  936. END TRY
  937. BEGIN CATCH
  938. RETURN 0
  939. END CATCH
  940. GO
  941. /****** Object: StoredProcedure [dbo].[ProcBsAskInfoIdByBatchUpdate] Script Date: 2018/12/13 19:09:36 ******/
  942. SET ANSI_NULLS ON
  943. GO
  944. SET QUOTED_IDENTIFIER ON
  945. GO
  946. --sean 2014-8-13
  947. CREATE PROCEDURE [dbo].[ProcBsAskInfoIdByBatchUpdate]
  948. AS
  949. BEGIN
  950. SELECT TOP 1000 bsAskInfoId INTO #t FROM Marketdb..bsaskInfoInclude where checkdate > '' AND IncludeDate IS NULL ORDER BY bsAskInfoId
  951. INSERT INTO bsAskInfo(Title, Url, ClassID, Question, Answer, TypeID, Mark, UserName, AddUserID, AddDate, Comment, SolveDate, IsOnline, UpdateDate, ProvinceIds, GetWay, ReferUrl, ClickNumber)
  952. SELECT Title, Url, ClassID, Question, Answer, TypeID, Mark, UserName, AddUserID, AddDate + DATEDIFF(DAY, AddDate, GETDATE() -1 ),
  953. Comment, SolveDate + DATEDIFF(DAY, SolveDate, GETDATE() -1 ), IsOnline, UpdateDate + DATEDIFF(DAY, UpdateDate, GETDATE() -1 ), ProvinceIds, GetWay, ReferUrl, ClickNumber
  954. FROM bsAskInfo
  955. WHERE ID IN(SELECT bsAskInfoId FROM #t)
  956. DELETE bsAskInfo WHERE ID IN(SELECT bsAskInfoId FROM #t)
  957. DELETE Marketdb..bsaskInfoInclude WHERE bsAskInfoId NOT IN (SELECT ID FROM bsAskInfo)
  958. --------------------------
  959. INSERT INTO Marketdb..bsaskInfoInclude
  960. SELECT Id, REPLACE(ProvinceIds, ',', ''), NULL, NULL
  961. FROM bsAskInfo WITH(NOLOCK)
  962. WHERE LEN(provinceids) < 10
  963. AND ID NOT IN(SELECT bsAskInfoId FROM Marketdb..bsaskInfoInclude)
  964. /*
  965. INSERT INTO Marketdb..bsaskInfoInclude
  966. SELECT a.Id, b.Id, NULL, NULL
  967. FROM bsAskInfo a WITH(NOLOCK), dcProvince b
  968. WHERE LEN(a.provinceids) > 10
  969. AND a.ID NOT IN(SELECT bsAskInfoId FROM Marketdb..bsaskInfoInclude)
  970. */
  971. END
  972. GO
  973. /****** Object: StoredProcedure [dbo].[ProcBsAskInfoIncludeSelect] Script Date: 2018/12/13 19:09:36 ******/
  974. SET ANSI_NULLS ON
  975. GO
  976. SET QUOTED_IDENTIFIER ON
  977. GO
  978. --sean 2014-8-13
  979. CREATE PROCEDURE [dbo].[ProcBsAskInfoIncludeSelect]
  980. AS
  981. BEGIN
  982. SELECT TOP 100 id, ProvinceId, bsAskInfoId
  983. FROM MarketDb..bsAskInfoInclude
  984. ORDER BY ISNULL(CheckDate, '2000-1-1'), IncludeDate, BsAskInfoId
  985. END
  986. GO
  987. /****** Object: StoredProcedure [dbo].[ProcbsAskInfoNewSelect] Script Date: 2018/12/13 19:09:36 ******/
  988. SET ANSI_NULLS ON
  989. GO
  990. SET QUOTED_IDENTIFIER ON
  991. GO
  992. --#####################################################
  993. --创建时间:2014.10.27
  994. --创建人:Nick
  995. --说明:得到最新5条求职互助
  996. --#####################################################
  997. CREATE PROCEDURE [dbo].[ProcbsAskInfoNewSelect]
  998. (
  999. @ProvinceID INT,
  1000. @SubSiteID INT
  1001. )
  1002. AS
  1003. BEGIN TRY
  1004. SELECT TOP 5 ID,Title
  1005. FROM bsAskInfo WITH(NOLOCK)
  1006. WHERE IsOnline = 1
  1007. AND (Provinceids LIKE '%'+CONVERT(VARCHAR(10),@ProvinceID)+'%'
  1008. OR Provinceids LIKE '%'+CONVERT(VARCHAR(10),@SubSiteID)+'%')
  1009. ORDER BY UpdateDate DESC
  1010. END TRY
  1011. BEGIN CATCH
  1012. RETURN 0
  1013. END CATCH
  1014. GO
  1015. /****** Object: StoredProcedure [dbo].[ProcbsAskInfoSelect] Script Date: 2018/12/13 19:09:37 ******/
  1016. SET ANSI_NULLS ON
  1017. GO
  1018. SET QUOTED_IDENTIFIER ON
  1019. GO
  1020. --#####################################################
  1021. --创建时间:2014.10.28
  1022. --创建人:Nick
  1023. --说明:求职互助列表
  1024. --#####################################################
  1025. CREATE PROCEDURE [dbo].[ProcbsAskInfoSelect]
  1026. (
  1027. @TypeId INT,
  1028. @ProvinceId INT,
  1029. @KeyWord VARCHAR(50)
  1030. )
  1031. AS
  1032. SET NOCOUNT ON
  1033. BEGIN
  1034. DECLARE @SQL VARCHAR(1000)
  1035. SET @SQL = 'SELECT TOP 1000 a.Id, a.title, a.TypeId, a.solvedate, a.updatedate, t.Typename
  1036. FROM bsAskInfo a WITH(NOLOCK), bsAskTypeSet t WITH(NOLOCK)
  1037. WHERE a.TypeId = t.Id
  1038. AND a.isonline = 1
  1039. AND ProvinceIds = '',' + CONVERT(VARCHAR(10), @ProvinceId) + ',''
  1040. '
  1041. IF @TypeId <> 0
  1042. BEGIN
  1043. SET @SQL = @SQL + ' AND a.TypeId = ' + CONVERT(VARCHAR(10), @TypeId)
  1044. END
  1045. IF @KeyWord <> ''
  1046. BEGIN
  1047. SET @SQL = @SQL + ' AND a.Title LIKE ''%' + dbo.SafeSql(@KeyWord) + '%'''
  1048. END
  1049. SET @SQL = @SQL + ' ORDER BY a.UpdateDate DESC '
  1050. --print @sql
  1051. EXEC(@SQL)
  1052. END
  1053. GO
  1054. /****** Object: StoredProcedure [dbo].[ProcbsASKTagInfoByIDSelect] Script Date: 2018/12/13 19:09:37 ******/
  1055. SET ANSI_NULLS ON
  1056. GO
  1057. SET QUOTED_IDENTIFIER ON
  1058. GO
  1059. --#####################################################
  1060. --创建时间:2014.10.28
  1061. --创建人:Nick
  1062. --说明:获取求职互助标签
  1063. --#####################################################
  1064. CREATE PROCEDURE [dbo].[ProcbsASKTagInfoByIDSelect]
  1065. @ID INT
  1066. AS
  1067. BEGIN TRY
  1068. SELECT * FROM bsASKTagInfo WHERE ID = @ID
  1069. END TRY
  1070. BEGIN CATCH
  1071. RETURN 0
  1072. END CATCH
  1073. GO
  1074. /****** Object: StoredProcedure [dbo].[procbsASKTypeSetAllSelect] Script Date: 2018/12/13 19:09:37 ******/
  1075. SET ANSI_NULLS ON
  1076. GO
  1077. SET QUOTED_IDENTIFIER ON
  1078. GO
  1079. --#####################################################
  1080. --创建时间:2014.11.04
  1081. --创建人:Nick
  1082. --说明:select bsASKTypeSet
  1083. --#####################################################
  1084. CREATE PROCEDURE [dbo].[procbsASKTypeSetAllSelect]
  1085. AS
  1086. BEGIN TRY
  1087. SELECT * FROM bsASKTypeSet WHERE id>0 AND typename<>'美通社' ORDER BY orderno
  1088. END TRY
  1089. BEGIN CATCH
  1090. RETURN 0
  1091. END CATCH
  1092. GO
  1093. /****** Object: StoredProcedure [dbo].[ProcbsAskTypeSetSelect] Script Date: 2018/12/13 19:09:37 ******/
  1094. SET ANSI_NULLS ON
  1095. GO
  1096. SET QUOTED_IDENTIFIER ON
  1097. GO
  1098. --#####################################################
  1099. --创建时间:2014.10.27
  1100. --创建人:Nick
  1101. --说明:得到热门求职互助类别
  1102. --#####################################################
  1103. CREATE PROCEDURE [dbo].[ProcbsAskTypeSetSelect]
  1104. AS
  1105. BEGIN TRY
  1106. SELECT TOP 14 *
  1107. FROM bsAskTypeSet WITH(NOLOCK)
  1108. WHERE ID>0
  1109. ORDER BY Newid()
  1110. END TRY
  1111. BEGIN CATCH
  1112. RETURN 0
  1113. END CATCH
  1114. GO
  1115. /****** Object: StoredProcedure [dbo].[ProcBsPageClickLogInsert] Script Date: 2018/12/13 19:09:37 ******/
  1116. SET ANSI_NULLS ON
  1117. GO
  1118. SET QUOTED_IDENTIFIER ON
  1119. GO
  1120. CREATE PROCEDURE [dbo].[ProcBsPageClickLogInsert]
  1121. AS
  1122. BEGIN
  1123. DECLARE @M AS VARCHAR(6)
  1124. SET @m = CONVERT(VARCHAR(6), GETDATE(), 112)
  1125. DELETE bsPageClickLog WHERE CountMonth = @M
  1126. -- 职场资讯
  1127. INSERT bsPageClickLog(PageType, PageId, ClickNumber, ClickNumberAll)
  1128. SELECT 1, ID, ViewNumber, ViewNUmber_All FROM QlrcNews WITH(NOLOCK)
  1129. --招聘会
  1130. INSERT bsPageClickLog(PageType, PageId, ClickNumber)
  1131. SELECT 2, ID, ViewNumber FROM recruitment WITH(NOLOCK)
  1132. --文档下载
  1133. INSERT bsPageClickLog(PageType, PageId, ClickNumber)
  1134. SELECT 3, ID, dwnnum FROM dwndoc WITH(NOLOCK)
  1135. DECLARE @ThisMonth AS VARCHAR(6), @PrevMonth AS VARCHAR(6)
  1136. SELECT @ThisMonth = CONVERT(VARCHAR(6), GETDATE(), 112),
  1137. @PrevMonth = CONVERT(VARCHAR(6), DATEADD(mm, -1, GETDATE()), 112)
  1138. UPDATE a
  1139. SET a.Increase = a.ClickNumber - b.ClickNumber,
  1140. a.IncreaseAll = a.ClickNumberAll - b.ClickNumberAll
  1141. FROM bsPageClickLog a, bsPageClickLog b
  1142. WHERE a.CountMonth = @ThisMonth
  1143. AND b.CountMonth = @PrevMonth
  1144. AND a.PageID = b.PageID
  1145. AND a.PageType = b.PageType
  1146. UPDATE bsPageClickLog
  1147. SET Increase = ClickNumber,
  1148. IncreaseAll = ClickNumberAll
  1149. FROM bsPageClickLog
  1150. WHERE CountMonth = @ThisMonth
  1151. AND PageID NOT IN(
  1152. SELECT PageID FROM bsPageClickLog WITH(NOLOCK)
  1153. WHERE CountMonth = @PrevMonth)
  1154. END
  1155. GO
  1156. /****** Object: StoredProcedure [dbo].[procBsSourceDetailInsert] Script Date: 2018/12/13 19:09:38 ******/
  1157. SET ANSI_NULLS ON
  1158. GO
  1159. SET QUOTED_IDENTIFIER ON
  1160. GO
  1161. --创建人 Nick 20141015
  1162. --用于记录每个页面的来源访问情况
  1163. CREATE PROCEDURE [dbo].[procBsSourceDetailInsert]
  1164. (
  1165. @SubSiteID INT,
  1166. @SiteType SMALLINT,
  1167. @SessionID VARCHAR(100),
  1168. @Referer VARCHAR(200),
  1169. @IP VARCHAR(15),
  1170. @Url VARCHAR(200)
  1171. )
  1172. AS
  1173. return 0
  1174. BEGIN
  1175. DECLARE @MaxID INT
  1176. SELECT @MaxID = Id FROM BsSourceDetail WITH(NOLOCK) WHERE SessionId = @SessionID
  1177. IF @MaxID IS NULL
  1178. BEGIN
  1179. INSERT INTO BsSourceDetail
  1180. VALUES (@SubSiteID, @SiteType, @SessionID, @IP, @Referer, 1, GETDATE(), GETDATE())
  1181. SET @MaxID = @@IDENTITY
  1182. END
  1183. ELSE
  1184. BEGIN
  1185. UPDATE BsSourceDetail
  1186. SET ViewNumber = ViewNumber+1, LastViewDate = GETDATE()
  1187. WHERE ID = @MaxId
  1188. END
  1189. RETURN @MaxID
  1190. END
  1191. GO
  1192. /****** Object: StoredProcedure [dbo].[procBsSourceDetailInsert2] Script Date: 2018/12/13 19:09:38 ******/
  1193. SET ANSI_NULLS ON
  1194. GO
  1195. SET QUOTED_IDENTIFIER ON
  1196. GO
  1197. --创建人 Nick 20141015
  1198. --用于记录每个页面的来源访问情况
  1199. CREATE PROCEDURE [dbo].[procBsSourceDetailInsert2]
  1200. (
  1201. @SubSiteID INT,
  1202. @SiteType SMALLINT,
  1203. @SessionID VARCHAR(100),
  1204. @Referer VARCHAR(200),
  1205. @IP VARCHAR(15),
  1206. @Url VARCHAR(200)
  1207. )
  1208. AS
  1209. return 0
  1210. BEGIN
  1211. DECLARE @MaxID INT
  1212. SELECT @MaxID = Id FROM BsSourceDetail WITH(NOLOCK) WHERE SessionId = @SessionID
  1213. IF @MaxID IS NULL
  1214. BEGIN
  1215. INSERT INTO BsSourceDetail
  1216. VALUES (@SubSiteID, @SiteType, @SessionID, @IP, @Referer, 1, GETDATE(), GETDATE())
  1217. SET @MaxID = @@IDENTITY
  1218. END
  1219. ELSE
  1220. BEGIN
  1221. UPDATE BsSourceDetail
  1222. SET ViewNumber = ViewNumber+1, LastViewDate = GETDATE()
  1223. WHERE ID = @MaxId
  1224. END
  1225. RETURN @MaxID
  1226. END
  1227. GO
  1228. /****** Object: StoredProcedure [dbo].[procBsSourceDetailUpdate] Script Date: 2018/12/13 19:09:38 ******/
  1229. SET ANSI_NULLS ON
  1230. GO
  1231. SET QUOTED_IDENTIFIER ON
  1232. GO
  1233. /****** Object: StoredProcedure [dbo].[procBsSourceDetailInsert] Script Date: 10/20/2014 08:46:46 ******/
  1234. --创建人 Nick 20141015
  1235. --用于记录每个页面的来源访问情况
  1236. CREATE PROCEDURE [dbo].[procBsSourceDetailUpdate]
  1237. (
  1238. @bsSourceDetailID INT,
  1239. @url VARCHAR(200)
  1240. )
  1241. AS
  1242. return
  1243. BEGIN TRY
  1244. UPDATE BsSourceDetail
  1245. SET ViewNumber = ViewNumber+1, LastViewDate = GETDATE()
  1246. WHERE ID = @bsSourceDetailID
  1247. IF @@ROWCOUNT = 0
  1248. BEGIN
  1249. IF NOT EXISTS(SELECT 'x' FROM BsSourceDetail WITH(NOLOCK) WHERE ID = @bsSourceDetailID)
  1250. BEGIN
  1251. SET IDENTITY_INSERT LogDb..bsSourceDetail ON
  1252. INSERT INTO BsSourceDetail(ID, SubSiteID, SiteType, SessionID, IP, Referer, ViewNumber, LastViewDate, AddDate)
  1253. SELECT ID, SubSiteID, SiteType, SessionID, IP, Referer, ViewNumber, LastViewDate, AddDate
  1254. FROM BsSourceDetailAll WITH(NOLOCK) WHERE Id = @bsSourceDetailID
  1255. SET IDENTITY_INSERT LogDb..bsSourceDetail OFF
  1256. DELETE FROM BsSourceDetailAll WHERE Id = @bsSourceDetailID
  1257. UPDATE BsSourceDetail
  1258. SET ViewNumber = ViewNumber+1, LastViewDate = GETDATE()
  1259. WHERE ID = @bsSourceDetailID
  1260. END
  1261. END
  1262. END TRY
  1263. BEGIN CATCH
  1264. END CATCH
  1265. GO
  1266. /****** Object: StoredProcedure [dbo].[procBsSourceDetailUpdate2] Script Date: 2018/12/13 19:09:38 ******/
  1267. SET ANSI_NULLS ON
  1268. GO
  1269. SET QUOTED_IDENTIFIER ON
  1270. GO
  1271. /****** Object: StoredProcedure [dbo].[procBsSourceDetailInsert] Script Date: 10/20/2014 08:46:46 ******/
  1272. --创建人 Nick 20141015
  1273. --用于记录每个页面的来源访问情况
  1274. CREATE PROCEDURE [dbo].[procBsSourceDetailUpdate2]
  1275. (
  1276. @bsSourceDetailID INT,
  1277. @url VARCHAR(200)
  1278. )
  1279. AS
  1280. return
  1281. BEGIN TRY
  1282. UPDATE BsSourceDetail
  1283. SET ViewNumber = ViewNumber+1, LastViewDate = GETDATE()
  1284. WHERE ID = @bsSourceDetailID
  1285. IF @@ROWCOUNT = 0
  1286. BEGIN
  1287. IF NOT EXISTS(SELECT 'x' FROM BsSourceDetail WITH(NOLOCK) WHERE ID = @bsSourceDetailID)
  1288. BEGIN
  1289. SET IDENTITY_INSERT LogDb..bsSourceDetail ON
  1290. INSERT INTO BsSourceDetail(ID, SubSiteID, SiteType, SessionID, IP, Referer, ViewNumber, LastViewDate, AddDate)
  1291. SELECT ID, SubSiteID, SiteType, SessionID, IP, Referer, ViewNumber, LastViewDate, AddDate
  1292. FROM BsSourceDetailAll WITH(NOLOCK) WHERE Id = @bsSourceDetailID
  1293. SET IDENTITY_INSERT LogDb..bsSourceDetail OFF
  1294. DELETE FROM BsSourceDetailAll WHERE Id = @bsSourceDetailID
  1295. UPDATE BsSourceDetail
  1296. SET ViewNumber = ViewNumber+1, LastViewDate = GETDATE()
  1297. WHERE ID = @bsSourceDetailID
  1298. END
  1299. END
  1300. END TRY
  1301. BEGIN CATCH
  1302. END CATCH
  1303. GO
  1304. /****** Object: StoredProcedure [dbo].[ProcBsSourceRefererCountUpdate] Script Date: 2018/12/13 19:09:38 ******/
  1305. SET ANSI_NULLS ON
  1306. GO
  1307. SET QUOTED_IDENTIFIER ON
  1308. GO
  1309. --创建人 Nick 20141020
  1310. --生成推广每天的统计数据
  1311. CREATE PROCEDURE [dbo].[ProcBsSourceRefererCountUpdate]
  1312. AS
  1313. BEGIN
  1314. DECLARE @Countdate VARCHAR(8), @Referer_AllNum INT,
  1315. @Referer_Ref VARCHAR(200), @dcSubSiteID INT,
  1316. @dcSubsiteDomain VARCHAR(50), @CountNumber AS INT,
  1317. @p INT, @StartTime DATETIME , @EndTime DATETIME
  1318. SELECT @CountDate = CONVERT(VARCHAR(8), GETDATE() - 1, 112),
  1319. @StartTime = CONVERT(VARCHAR(10), GETDATE() - 1, 120),
  1320. @EndTime = CONVERT(VARCHAR(10), GETDATE(), 120)
  1321. --select @CountDate, @StartTime, @EndTime
  1322. --SET @CountDate = '20141020'
  1323. --SET @StartTime = '2014-10-20'
  1324. --SET @EndTime = '2014-10-20 23:59:00'
  1325. --删除当前统计天数据
  1326. DELETE FROM bsSourceRefererCount WHERE CountDate = @CountDate
  1327. DELETE FROM bsSourceCount WHERE CountDate = @CountDate
  1328. DECLARE @t AS TABLE(
  1329. ID INT,
  1330. Domain VARCHAR(100),
  1331. CountNumber INT
  1332. )
  1333. INSERT INTO @t SELECT Id, SubSiteUrl, 200 FROM dcSubsite WITH(NOLOCK) ORDER BY Id
  1334. DECLARE curSite CURSOR FOR
  1335. SELECT Id, Domain, CountNumber FROM @t ORDER BY Id
  1336. FOR READ ONLY
  1337. OPEN curSite
  1338. FETCH NEXT FROM curSite INTO @dcSubSiteID, @dcSubsiteDomain, @CountNumber
  1339. WHILE @@FETCH_STATUS = 0
  1340. BEGIN
  1341. INSERT INTO bsSourceRefererCount(subSiteID, CountDate, Referer, HowMany, SiteType)
  1342. SELECT TOP (@CountNumber) @dcSubSiteID, @CountDate, LEFT(Referer, CHARINDEX('/', Referer, 8)) Ref, COUNT(*), 1
  1343. FROM bsSourceDetailAll WITH(NOLOCK)
  1344. WHERE CHARINDEX('/', Referer, 8) > 0
  1345. AND SubSiteID = @dcSubSiteID
  1346. AND SiteType = 1
  1347. AND LastViewDate > @StartTime AND LastViewDate < @EndTime
  1348. AND CHARINDEX(SUBSTRING(@dcSubsiteDomain, CHARINDEX('.', @dcSubsiteDomain) + 1, LEN(@dcSubsiteDomain)), Referer, 0) = 0
  1349. GROUP BY LEFT(Referer, CHARINDEX('/', Referer, 8))
  1350. ORDER BY COUNT(*) DESC
  1351. IF @dcSubSiteID > 0 AND LEN(@dcSubSiteID) = 2
  1352. BEGIN
  1353. --手机m站
  1354. INSERT INTO bsSourceRefererCount(subSiteID, CountDate, Referer, HowMany, SiteType)
  1355. SELECT TOP (@CountNumber) @dcSubSiteID, @CountDate, LEFT(Referer, CHARINDEX('/', Referer, 8)) Ref, COUNT(*), 2
  1356. FROM bsSourceDetailAll WITH(NOLOCK)
  1357. WHERE CHARINDEX('/', Referer, 8) > 0
  1358. AND SubSiteID = @dcSubSiteID
  1359. AND SiteType = 2
  1360. AND LastViewDate > @StartTime AND LastViewDate < @EndTime
  1361. AND CHARINDEX(SUBSTRING(@dcSubsiteDomain, CHARINDEX('.', @dcSubsiteDomain) + 1, LEN(@dcSubsiteDomain)), Referer, 0) = 0
  1362. GROUP BY LEFT(Referer, CHARINDEX('/', Referer, 8))
  1363. ORDER BY COUNT(*) DESC
  1364. --县级站
  1365. INSERT INTO bsSourceRefererCount(subSiteID, CountDate, Referer, HowMany, SiteType)
  1366. SELECT TOP (@CountNumber) CONVERT(VARCHAR(10), @dcSubSiteID) + '0000', @CountDate, LEFT(Referer, CHARINDEX('/', Referer, 8)) Ref, COUNT(*), 1
  1367. FROM bsSourceDetailAll WITH(NOLOCK)
  1368. WHERE CHARINDEX('/', Referer, 8) > 0
  1369. AND SUBSTRING(CONVERT(VARCHAR(10), SubSiteID), 0, 2) = @dcSubSiteID
  1370. AND LEN(SubSiteID) = 6
  1371. AND LastViewDate > @StartTime AND LastViewDate < @EndTime
  1372. AND CHARINDEX(SUBSTRING(@dcSubsiteDomain, CHARINDEX('.', @dcSubsiteDomain) + 1, LEN(@dcSubsiteDomain)), Referer, 0) = 0
  1373. GROUP BY LEFT(Referer, CHARINDEX('/', Referer, 8))
  1374. ORDER BY COUNT(*) DESC
  1375. END
  1376. FETCH NEXT FROM curSite INTO @dcSubSiteID, @dcSubsiteDomain, @CountNumber
  1377. END
  1378. CLOSE curSite
  1379. DEALLOCATE curSite
  1380. --修改bsSourceRefererCount typeID 字段
  1381. --搜索引擎
  1382. UPDATE a SET a.TypeID = 1,
  1383. a.Referer = c.Item_Name
  1384. FROM bsSourceRefererCount a, Referer_Item_Keywords b, Referer_Item c
  1385. WHERE b.Item_Id = c.ID
  1386. AND CHARINDEX(b.Keywords, a.referer) > 0
  1387. AND C.ID IN (3, 8, 14, 11, 31, 45, 62, 74)
  1388. AND CountDate = @CountDate
  1389. --修改外部链接 typeid
  1390. UPDATE bsSourceRefererCount
  1391. SET TypeID = 2, SiteType = 1
  1392. WHERE (CHARINDEX('mail.qq.com', referer) > 0
  1393. OR CHARINDEX('mail.126.com', referer) > 0
  1394. OR CHARINDEX('mail.163.com', referer) > 0
  1395. OR CHARINDEX('mail.sina.com.cn', referer) > 0
  1396. OR CHARINDEX('mail.10086.cn', referer) > 0
  1397. OR CHARINDEX('mail.sohu.com', referer) > 0
  1398. OR CHARINDEX('mail.189.cn', referer) > 0
  1399. OR CHARINDEX('www.126.com', referer) > 0
  1400. OR CHARINDEX('www.2345.com', referer) > 0
  1401. OR CHARINDEX('www.hao123.com', referer) > 0
  1402. OR CHARINDEX('www.dn1234.com', referer) > 0
  1403. OR CHARINDEX('hao.360.com', referer) > 0
  1404. OR CHARINDEX('www.3600.com', referer) > 0
  1405. )
  1406. AND TypeID IS NULL
  1407. AND CountDate = @CountDate
  1408. --修改外部链接其他
  1409. UPDATE bsSourceRefererCount
  1410. SET TypeID = 2, SiteType = 1, Referer='外部链接其他'
  1411. WHERE TypeID IS NULL
  1412. AND CountDate = @CountDate
  1413. --修改bssourcecount表数据--
  1414. --省份、城市 访问的访客数、ip数
  1415. INSERT INTO bsSourceCount (SubSiteID, CountDate, VisitorCount, IPCount, SiteType)
  1416. SELECT SubSiteID, @CountDate, COUNT(DISTINCT SessionID), COUNT(DISTINCT IP), SiteType
  1417. FROM bsSourceDetailAll WITH(NOLOCK)
  1418. WHERE LastViewDate > @StartTime AND LastViewDate < @EndTime
  1419. AND LEN(SubSiteID) < = 4
  1420. GROUP BY SubSiteID, SiteType
  1421. --县级市 访问的访客数、IP数
  1422. INSERT INTO bsSourceCount (SubSiteID, CountDate, VisitorCount, IPCount, SiteType)
  1423. SELECT SUBSTRING(CONVERT(VARCHAR(10), SubSiteID), 0, 2) + '0000', @CountDate, COUNT(DISTINCT SessionID), COUNT(DISTINCT IP), 1
  1424. FROM bsSourceDetailAll
  1425. WHERE LastViewDate > @StartTime AND LastViewDate < @EndTime
  1426. AND LEN(SubSiteID)=6
  1427. GROUP BY SUBSTRING(CONVERT(VARCHAR(10), SubSiteID), 0, 2)
  1428. --省份、城市、县级市 访问的来源总数
  1429. UPDATE bsSourceCount
  1430. SET RefererCount = VisitorCount
  1431. WHERE CountDate = @CountDate
  1432. --省份 城市 只访问一个页面的访客数量
  1433. UPDATE a
  1434. SET a.VisitOnePageCount = b.cnt
  1435. FROM bsSourceCount a,
  1436. ( SELECT SubSiteID, SiteType , COUNT(*) cnt
  1437. FROM bsSourceDetailAll WITH(NOLOCK)
  1438. WHERE LastViewDate > @StartTime AND LastViewDate < @EndTime
  1439. AND LEN(SubSiteID) < = 4
  1440. AND ViewNumber = 1
  1441. GROUP BY SubSiteID, SiteType
  1442. ) b
  1443. WHERE a.SubSiteID = b.SubSiteID
  1444. AND a.SiteType = b.SiteType
  1445. AND a.CountDate = @CountDate
  1446. --县级站 只访问一个页面的访客数量
  1447. UPDATE a
  1448. SET a.VisitOnePageCount = b.cnt
  1449. FROM bsSourceCount a,
  1450. (SELECT SUBSTRING(CONVERT(VARCHAR(10), SubSiteID), 0, 2) + '0000' SubSiteID, SiteType , COUNT(*) cnt
  1451. FROM bsSourceDetailAll WITH(NOLOCK)
  1452. WHERE LastViewDate > @StartTime AND LastViewDate < @EndTime
  1453. AND LEN(SubSiteID)=6
  1454. AND ViewNumber = 1
  1455. GROUP BY SubSiteID, SiteType
  1456. ) b
  1457. WHERE a.SubSiteID = b.SubSiteID
  1458. AND a.SiteType = b.SiteType
  1459. AND a.CountDate = @CountDate
  1460. --省份、城市 访问小时数合计
  1461. UPDATE a
  1462. SET a.VisitTimeCount = b.tSum
  1463. FROM bsSourceCount a,
  1464. (SELECT SubSiteID, SiteType, SUM(DATEDIFF(Second, AddDate, LastViewDate)) tSum
  1465. FROM bsSourceDetailAll WITH(NOLOCK)
  1466. WHERE LastViewDate > @StartTime AND LastViewDate < @EndTime
  1467. AND LEN(SubSiteID) < = 4
  1468. GROUP BY SubSiteID, SiteType
  1469. ) b
  1470. WHERE a.SubSiteID = b.SubSiteID
  1471. AND a.SiteType = b.SiteType
  1472. AND a.CountDate = @CountDate
  1473. --县级市 访问小时数合计
  1474. UPDATE a
  1475. SET a.VisitTimeCount = b.tSum
  1476. FROM bsSourceCount a,
  1477. (SELECT SUBSTRING(CONVERT(VARCHAR(10), SubSiteID), 0, 2) + '0000' AS SubSiteID, SiteType,
  1478. SUM(DATEDIFF(Second, AddDate, LastViewDate)) AS tSum
  1479. FROM bsSourceDetailAll WITH(NOLOCK)
  1480. WHERE LastViewDate > @StartTime AND LastViewDate < @EndTime
  1481. AND LEN(SubSiteID)=6 GROUP BY SUBSTRING(CONVERT(VARCHAR(10), SubSiteID), 0, 2) + '0000', SiteType
  1482. ) b
  1483. WHERE a.SubSiteID = b.SubSiteID
  1484. AND a.SiteType = b.SiteType
  1485. AND a.CountDate = @CountDate
  1486. --省份、城市 个人手机注册数
  1487. UPDATE A
  1488. SET A.PersonRegisterCount = B.CNT
  1489. FROM bsSourceCount A,
  1490. (SELECT dcSubSiteID, COUNT(*) CNT
  1491. FROM PaMain
  1492. WHERE (RegisterMode in (4, 5, 6) OR RegisterFrom > 1)
  1493. AND AddDate > @StartTime
  1494. AND AddDate < @EndTime
  1495. GROUP BY dcSubSiteID
  1496. ) b
  1497. WHERE a.CountDate = @CountDate
  1498. AND SiteType = 2
  1499. AND A.SubSiteID = B.dcSubSiteID
  1500. --省份、城市 个人电脑注册数
  1501. UPDATE A
  1502. SET A.PersonRegisterCount = B.CNT
  1503. FROM bsSourceCount A,
  1504. (SELECT dcSubSiteID, COUNT(*) CNT
  1505. FROM PaMain
  1506. WHERE (RegisterMode = 1 OR RegisterType = 101)
  1507. AND AddDate > @StartTime
  1508. AND AddDate < @EndTime
  1509. GROUP BY dcSubSiteID
  1510. ) b
  1511. WHERE a.CountDate = @CountDate
  1512. AND SiteType = 1
  1513. AND A.SubSiteID = B.dcSubSiteID
  1514. --省份、城市 企业电脑注册数
  1515. UPDATE A
  1516. SET A.CompanyRegisterCount = B.CNT
  1517. FROM bsSourceCount A,
  1518. (SELECT dcSubSiteID, COUNT(*) CNT
  1519. FROM CpMain
  1520. WHERE RegisterMode = 1
  1521. AND RegDate > @StartTime
  1522. AND RegDate < @EndTime
  1523. GROUP BY dcSubSiteID
  1524. ) b
  1525. WHERE a.CountDate = @CountDate
  1526. AND SiteType = 1
  1527. AND A.SubSiteID = B.dcSubSiteID
  1528. --搜索引擎数量
  1529. UPDATE a
  1530. SET a.SearchEngineCount = b.cnt
  1531. FROM bsSourceCount a,
  1532. (SELECT SubSiteID, SiteType, SUM(HowMany) cnt
  1533. FROM bsSourceRefererCount
  1534. WHERE CountDate = @CountDate
  1535. AND TypeID = 1
  1536. Group By SubSiteID, SiteType
  1537. ) b
  1538. WHERE a.SubSiteID = b.SubSiteID
  1539. AND a.SiteType = b.SiteType
  1540. AND a.CountDate = @CountDate
  1541. --外部链接数量
  1542. UPDATE a
  1543. SET a.ExternalLinkCount = b.cnt
  1544. FROM bsSourceCount a,
  1545. (SELECT SubSiteID, SiteType, SUM(HowMany) cnt
  1546. FROM bsSourceRefererCount
  1547. WHERE CountDate = @CountDate
  1548. AND TypeID = 2
  1549. Group By SubSiteID, SiteType
  1550. ) b
  1551. WHERE a.SubSiteID = b.SubSiteID
  1552. AND a.SiteType = b.SiteType
  1553. AND a.CountDate = @CountDate
  1554. --直接输入数量
  1555. --省份、城市 访问的直接输入数量
  1556. UPDATE a
  1557. SET a.DirectInputCount = b.cnt
  1558. FROM bsSourceCount a,
  1559. (SELECT SubSiteID, SiteType, COUNT(*) cnt
  1560. FROM bsSourceDetailAll WITH(NOLOCK)
  1561. WHERE LastViewDate > @StartTime
  1562. AND LastViewDate < @EndTime
  1563. AND LEN(SubSiteID) < =4
  1564. AND Referer = ''
  1565. Group By SubSiteID, SiteType
  1566. ) b
  1567. WHERE a.SubSiteID = b.SubSiteID
  1568. AND a.SiteType = b.SiteType
  1569. AND a.CountDate = @CountDate
  1570. --县级市 访问的访直接输入数量
  1571. UPDATE a
  1572. SET a.DirectInputCount = b.cnt
  1573. FROM bsSourceCount a,
  1574. (SELECT SUBSTRING(CONVERT(VARCHAR(10), SubSiteID), 0, 2) + '0000' AS SubSiteID, 1 AS SiteType, COUNT(*) cnt
  1575. FROM bsSourceDetailAll WITH(NOLOCK)
  1576. WHERE LastViewDate > @StartTime
  1577. AND LastViewDate < @EndTime
  1578. AND LEN(SubSiteID)=6
  1579. AND Referer = ''
  1580. Group By SUBSTRING(CONVERT(VARCHAR(10), SubSiteID), 0, 2) + '0000', SiteType
  1581. ) b
  1582. WHERE a.SubSiteID = b.SubSiteID
  1583. AND a.SiteType = b.SiteType
  1584. AND a.CountDate = @CountDate
  1585. --百度竞价数量 BaiduBiddingCount
  1586. --每天注册简历数
  1587. UPDATE a
  1588. SET BaiduBiddingResumeCount = B.resumeCnt
  1589. FROM bsSourceCount a,
  1590. (SELECT province_Id, SUM(toDayResume) AS resumeCnt
  1591. FROM Url
  1592. WHERE BeginDate > @StartTime AND BeginDate < @EndTime
  1593. GROUP BY province_Id
  1594. ) b
  1595. WHERE a.SubSiteID = b.province_Id
  1596. AND a.CountDate = @CountDate
  1597. --每天注册单位数
  1598. UPDATE a
  1599. SET BaiduBiddingCompanyCount = B.companyCnt
  1600. FROM bsSourceCount a,
  1601. (SELECT province_Id, SUM(toDayCompany) AS companyCnt
  1602. FROM Url
  1603. WHERE BeginDate > @StartTime AND BeginDate < @EndTime
  1604. GROUP BY province_Id
  1605. ) b
  1606. WHERE a.SubSiteID = b.province_Id
  1607. AND a.CountDate = @CountDate
  1608. --清空表数据 加入备份表
  1609. --INSERT INTO bsSourceDetailBak SELECT * FROM bsSourceDetail
  1610. --TRUNCATE TABLE bsSourceDetail
  1611. SELECT * INTO #t FROM bsSourceDetailAll WHERE LastViewDate > CONVERT(VARCHAR(10), GETDATE(), 120)
  1612. TRUNCATE TABLE LogDb..bsSourceDetailAll
  1613. INSERT INTO bsSourceDetailAll SELECT * FROM #t
  1614. END
  1615. GO
  1616. /****** Object: StoredProcedure [dbo].[ProcCaActiveStatusByCaMainIDSelect] Script Date: 2018/12/13 19:09:39 ******/
  1617. SET ANSI_NULLS ON
  1618. GO
  1619. SET QUOTED_IDENTIFIER ON
  1620. GO
  1621. --#####################################################
  1622. --创建时间:2014.10.30
  1623. --创建人:John
  1624. --说明:获取企业用户的当前状态
  1625. --#####################################################
  1626. CREATE PROCEDURE [dbo].[ProcCaActiveStatusByCaMainIDSelect]
  1627. (
  1628. @caMainID INT
  1629. )
  1630. AS
  1631. BEGIN
  1632. SELECT TOP 1 * FROM caActiveStatus WHERE camainid = @caMainID
  1633. END
  1634. GO
  1635. /****** Object: StoredProcedure [dbo].[ProcCaActiveStatusUpdate] Script Date: 2018/12/13 19:09:39 ******/
  1636. SET ANSI_NULLS ON
  1637. GO
  1638. SET QUOTED_IDENTIFIER ON
  1639. GO
  1640. CREATE PROCEDURE [dbo].[ProcCaActiveStatusUpdate]
  1641. AS
  1642. BEGIN
  1643. BEGIN TRY
  1644. INSERT caActiveStatus(caMainId)
  1645. SELECT DISTINCT caMainId FROM cpSession WHERE RefreshDate > DATEADD(MINUTE, -2, GETDATE())
  1646. AND caMainId NOT IN(SELECT caMainId FROM caActiveStatus)
  1647. END TRY
  1648. BEGIN CATCH
  1649. END CATCH
  1650. DELETE caActiveStatus
  1651. WHERE caMainId NOT IN(SELECT caMainId FROM cpSession WHERE RefreshDate > DATEADD(MINUTE, -2, GETDATE()))
  1652. SELECT caMainId, MIN(Id) ID, MIN(InterviewDate) InterviewDate
  1653. INTO #t
  1654. FROM viPlan WHERE InterviewDate > GETDATE() AND IsCancel = 0
  1655. GROUP BY caMainId
  1656. UPDATE #t SET InterviewDate = (SELECT InterviewDate FROM viPlan WHERE ID= #t.Id)
  1657. UPDATE caActiveStatus SET viPlanId = NULL, InterviewDate = NULL WHERE viPlanId > 0
  1658. INSERT caActiveStatus(caMainId, IsOnline)
  1659. SELECT caMainId, 0 FROM #t WHERE caMainId NOT IN(SELECT caMainId FROM caActiveStatus)
  1660. UPDATE a
  1661. SET a.viPlanId = b.Id,
  1662. a.InterviewDate = b.InterviewDate
  1663. FROM caActiveStatus a, #t b
  1664. WHERE a.caMainId = b.caMainId
  1665. UPDATE caActiveStatus SET IsVi = 0 WHERE caMainId NOT IN(SELECT caMainId FROM viRoom WHERE EndDate IS NULL) AND IsVi = 1
  1666. UPDATE caActiveStatus SET IsVi = 1 WHERE caMainId IN(SELECT caMainId FROM viRoom WHERE EndDate IS NULL)
  1667. END
  1668. GO
  1669. /****** Object: StoredProcedure [dbo].[procCaFavoratecaDailyGiftLogcaActiveLogSelect] Script Date: 2018/12/13 19:09:39 ******/
  1670. SET ANSI_NULLS ON
  1671. GO
  1672. SET QUOTED_IDENTIFIER ON
  1673. GO
  1674. --创建时间:2017-11-26
  1675. --创建人:harry
  1676. --说明:数据统计 --获取企业 收藏和下载的简历数量
  1677. --#####################################################
  1678. CREATE PROCEDURE [dbo].[procCaFavoratecaDailyGiftLogcaActiveLogSelect]
  1679. (
  1680. @beginDate DATETIME,
  1681. @endDate DATETIME,
  1682. @caMainId INT,
  1683. @cpMainId INT
  1684. )
  1685. AS
  1686. SET NOCOUNT ON
  1687. BEGIN
  1688. CREATE TABLE #t(
  1689. viewInt INT NULL,
  1690. downloadInt INT NULL,
  1691. favourateInt INT NULL,
  1692. intentionInt INT NULL,
  1693. interviewInt INT NULL,
  1694. addDate VARCHAR(10)
  1695. )
  1696. --生成数据表
  1697. IF @caMainId =0
  1698. BEGIN
  1699. --计算收藏的简历量
  1700. --更新#t
  1701. INSERT INTO #t (favourateInt,addDate)
  1702. SELECT COUNT (1) AS favourateInt, CONVERT(varchar(10),AddDate,23) AS addDate
  1703. FROM caFavorate
  1704. WHERE caMainId IN(select id FROM caMain WITH(NOLOCK) WHERE cpMainId = @cpMainId)
  1705. AND AddDate BETWEEN @beginDate AND @endDate
  1706. GROUP BY CONVERT(varchar(10),AddDate,23)
  1707. --计算下载的简历量
  1708. SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS downloadInt
  1709. INTO #td11
  1710. FROM caDailyGiftLog
  1711. WHERE cpMainId = @cpMainId
  1712. AND AddDate BETWEEN @beginDate AND @endDate
  1713. GROUP BY CONVERT(varchar(10),AddDate,23)
  1714. SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS downloadInt
  1715. INTO #td12
  1716. FROM caActiveLog
  1717. WHERE cpMainId = @cpMainId
  1718. AND AddDate BETWEEN @beginDate AND @endDate
  1719. GROUP BY CONVERT(varchar(10),AddDate,23)
  1720. --更新#t,插入
  1721. UPDATE #t
  1722. SET downloadInt= ISNULL(#t.downloadInt,0)+#td11.downloadInt
  1723. FROM #td11
  1724. WHERE #td11.addDate = #t.addDate
  1725. INSERT INTO #t(downloadInt,addDate)
  1726. SELECT downloadInt, addDate
  1727. FROM #td11
  1728. WHERE #td11.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
  1729. DROP TABLE #td11
  1730. --更新#t,插入
  1731. UPDATE #t
  1732. SET downloadInt= ISNULL(#t.downloadInt,0)+#td12.downloadInt
  1733. FROM #td12
  1734. WHERE #td12.addDate = #t.addDate
  1735. INSERT INTO #t(downloadInt,addDate)
  1736. SELECT downloadInt, addDate
  1737. FROM #td12
  1738. WHERE #td12.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
  1739. DROP TABLE #td12
  1740. --计算浏览量
  1741. SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS viewInt
  1742. INTO #td13
  1743. FROM CaCvViewLog
  1744. WHERE caMainId IN(select id FROM caMain WITH(NOLOCK) WHERE cpMainId = @cpMainId)
  1745. AND AddDate BETWEEN @beginDate AND @endDate
  1746. GROUP BY CONVERT(varchar(10),AddDate,23)
  1747. --计算应聘邀请
  1748. SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS viewInt
  1749. INTO #td14
  1750. FROM caCvIntention
  1751. WHERE caMainId IN(select id FROM caMain WITH(NOLOCK) WHERE cpMainId = @cpMainId)
  1752. AND AddDate BETWEEN @beginDate AND @endDate
  1753. GROUP BY CONVERT(varchar(10),AddDate,23)
  1754. --计算面试通知
  1755. SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS viewInt
  1756. INTO #td15
  1757. FROM exInterview
  1758. WHERE JobID IN(
  1759. SELECT ID FROM Job WITH(NOLOCK)
  1760. WHERE CpMainID = @cpMainID
  1761. )
  1762. AND AddDate BETWEEN @beginDate AND @endDate
  1763. GROUP BY CONVERT(varchar(10),AddDate,23)
  1764. --浏览,邀请,面试 数据更新插入
  1765. UPDATE #t
  1766. SET viewInt= ISNULL(#t.viewInt,0)+#td13.viewInt
  1767. FROM #td13
  1768. WHERE #td13.addDate = #t.addDate
  1769. INSERT INTO #t(viewInt,addDate)
  1770. SELECT viewInt, addDate
  1771. FROM #td13
  1772. WHERE #td13.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
  1773. DROP TABLE #td13
  1774. UPDATE #t
  1775. SET intentionInt= ISNULL(#t.intentionInt,0)+#td14.viewInt
  1776. FROM #td14
  1777. WHERE #td14.addDate = #t.addDate
  1778. INSERT INTO #t(intentionInt,addDate)
  1779. SELECT viewInt, addDate
  1780. FROM #td14
  1781. WHERE #td14.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
  1782. DROP TABLE #td14
  1783. UPDATE #t
  1784. SET interviewInt= ISNULL(#t.interviewInt,0)+#td15.viewInt
  1785. FROM #td15
  1786. WHERE #td15.addDate = #t.addDate
  1787. INSERT INTO #t(interviewInt,addDate)
  1788. SELECT viewInt, addDate
  1789. FROM #td15
  1790. WHERE #td15.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
  1791. DROP TABLE #td15
  1792. END
  1793. ELSE
  1794. BEGIN
  1795. --计算收藏的简历量
  1796. INSERT INTO #t (favourateInt,addDate)
  1797. SELECT COUNT (1) AS favourateInt, CONVERT(varchar(10),AddDate,23) AS addDate
  1798. FROM caFavorate
  1799. WHERE caMainId = @caMainId
  1800. AND AddDate BETWEEN @beginDate AND @endDate
  1801. GROUP BY CONVERT(varchar(10),AddDate,23)
  1802. --计算下载的简历量
  1803. SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS downloadInt
  1804. INTO #td21
  1805. FROM caDailyGiftLog
  1806. WHERE caMainId = @caMainId
  1807. AND AddDate BETWEEN @beginDate AND @endDate
  1808. GROUP BY CONVERT(varchar(10),AddDate,23)
  1809. SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS downloadInt
  1810. INTO #td22
  1811. FROM caActiveLog
  1812. WHERE caMainId = @caMainId
  1813. AND AddDate BETWEEN @beginDate AND @endDate
  1814. GROUP BY CONVERT(varchar(10),AddDate,23)
  1815. --更新#t
  1816. UPDATE #t
  1817. SET downloadInt= ISNULL(#t.downloadInt,0)+#td21.downloadInt
  1818. FROM #td21
  1819. WHERE #td21.addDate = #t.addDate
  1820. INSERT INTO #t(downloadInt,addDate)
  1821. SELECT downloadInt, addDate
  1822. FROM #td21
  1823. WHERE #td21.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
  1824. DROP TABLE #td21
  1825. --更新#t
  1826. UPDATE #t
  1827. SET downloadInt= ISNULL(#t.downloadInt,0)+#td22.downloadInt
  1828. FROM #td22
  1829. WHERE #td22.addDate = #t.addDate
  1830. INSERT INTO #t(downloadInt,addDate)
  1831. SELECT downloadInt, addDate
  1832. FROM #td22
  1833. WHERE #td22.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
  1834. DROP TABLE #td22
  1835. --计算浏览量
  1836. SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS viewInt
  1837. INTO #td23
  1838. FROM CaCvViewLog
  1839. WHERE caMainId = @caMainId
  1840. AND AddDate BETWEEN @beginDate AND @endDate
  1841. GROUP BY CONVERT(varchar(10),AddDate,23)
  1842. --计算应聘邀请
  1843. SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS viewInt
  1844. INTO #td24
  1845. FROM caCvIntention
  1846. WHERE caMainId = @caMainId
  1847. AND AddDate BETWEEN @beginDate AND @endDate
  1848. GROUP BY CONVERT(varchar(10),AddDate,23)
  1849. --计算面试通知
  1850. SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS viewInt
  1851. INTO #td25
  1852. FROM exInterview
  1853. WHERE JobID IN(
  1854. SELECT ID FROM Job WITH(NOLOCK)
  1855. WHERE CaMainID = @caMainId
  1856. )
  1857. AND AddDate BETWEEN @beginDate AND @endDate
  1858. GROUP BY CONVERT(varchar(10),AddDate,23)
  1859. --浏览,邀请,面试 数据更新插入
  1860. UPDATE #t
  1861. SET viewInt= ISNULL(#t.viewInt,0)+#td23.viewInt
  1862. FROM #td23
  1863. WHERE #td23.addDate = #t.addDate
  1864. INSERT INTO #t(viewInt,addDate)
  1865. SELECT viewInt, addDate
  1866. FROM #td23
  1867. WHERE #td23.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
  1868. DROP TABLE #td23
  1869. UPDATE #t
  1870. SET intentionInt= ISNULL(#t.intentionInt,0)+#td24.viewInt
  1871. FROM #td24
  1872. WHERE #td24.addDate = #t.addDate
  1873. INSERT INTO #t(intentionInt,addDate)
  1874. SELECT viewInt, addDate
  1875. FROM #td24
  1876. WHERE #td24.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
  1877. DROP TABLE #td24
  1878. UPDATE #t
  1879. SET interviewInt= ISNULL(#t.interviewInt,0)+#td25.viewInt
  1880. FROM #td25
  1881. WHERE #td25.addDate = #t.addDate
  1882. INSERT INTO #t(interviewInt,addDate)
  1883. SELECT viewInt, addDate
  1884. FROM #td25
  1885. WHERE #td25.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
  1886. DROP TABLE #td25
  1887. END
  1888. SELECT * FROM #t ORDER BY addDate
  1889. DROP TABLE #t
  1890. END
  1891. SET NOCOUNT OFF
  1892. GO
  1893. /****** Object: StoredProcedure [dbo].[procCaFeedbackHomepageSelect] Script Date: 2018/12/13 19:09:40 ******/
  1894. SET ANSI_NULLS ON
  1895. GO
  1896. SET QUOTED_IDENTIFIER ON
  1897. GO
  1898. --创建人 Lambo 20101010
  1899. --用于网站首页查询来信答复
  1900. CREATE PROCEDURE [dbo].[procCaFeedbackHomepageSelect]
  1901. (
  1902. @dcProvinceID SMALLINT
  1903. )
  1904. AS
  1905. BEGIN
  1906. -- SELECT TOP 15 a.*, c.Name
  1907. -- FROM caFeedback a WITH(NOLOCK),
  1908. -- caMain b WITH(NOLOCK),
  1909. -- cpMain c WITH(NOLOCK)
  1910. -- WHERE a.caMainID = b.id
  1911. -- AND b.cpMainID = c.id
  1912. -- AND a.homepage = 1
  1913. -- AND c.dcProvinceID = 32
  1914. -- AND c.Valid = 1
  1915. -- AND b.IsDelete = 0
  1916. -- AND b.IsPAuse = 0
  1917. -- ORDER BY a.AddDate DESC
  1918. SELECT TOP 15 ID newids,Preid ID,ProvinceID, Name, Message, AddDate, ReplyMan, ReplyMessage, ReplyDate
  1919. FROM SearchDb..hpcaFeedbackDay WITH(NOLOCK)
  1920. WHERE ProvinceID = @dcProvinceID
  1921. ORDER BY newids
  1922. END
  1923. GO
  1924. /****** Object: StoredProcedure [dbo].[procCaJobCvMatchInsert] Script Date: 2018/12/13 19:09:41 ******/
  1925. SET ANSI_NULLS ON
  1926. GO
  1927. SET QUOTED_IDENTIFIER ON
  1928. GO
  1929. ---------------------
  1930. --创建人 Peter
  1931. --时间 2016-10-13
  1932. --企业精确匹配数据插入
  1933. --peter 2018-4-2
  1934. CREATE PROCEDURE [dbo].[procCaJobCvMatchInsert]
  1935. AS
  1936. SET NOCOUNT ON
  1937. BEGIN
  1938. DECLARE @Today DATETIME
  1939. SET @Today = GETDATE()
  1940. --将最近一个月内企业个人交互存放到临时表
  1941. SELECT JobID, cvMainID
  1942. INTO #TCaJobCvOperateLog
  1943. FROM caCvIntention WITH(NOLOCK)
  1944. WHERE Adddate > GETDATE() - 30
  1945. INSERT INTO #TCaJobCvOperateLog
  1946. SELECT JobID, cvMainID
  1947. FROM exInterview WITH(NOLOCK)
  1948. WHERE Adddate > GETDATE() - 30
  1949. AND NOT EXISTS(
  1950. SELECT 'x'
  1951. FROM #TCaJobCvOperateLog
  1952. WHERE JobID = exInterview.JobID
  1953. AND cvMainID = exInterview.cvMainID
  1954. )
  1955. INSERT INTO #TCaJobCvOperateLog
  1956. SELECT JobID, cvMainID
  1957. FROM exJobApply WITH(NOLOCK)
  1958. WHERE Adddate > GETDATE() - 30
  1959. AND reply = 1
  1960. AND NOT EXISTS(
  1961. SELECT 'x'
  1962. FROM #TCaJobCvOperateLog
  1963. WHERE JobID = exJobApply.JobID
  1964. AND cvMainID = exJobApply.cvMainID
  1965. )
  1966. --排除海量操作
  1967. DELETE FROM #TCaJobCvOperateLog
  1968. WHERE JobID IN (
  1969. SELECT JobID
  1970. FROM #TCaJobCvOperateLog
  1971. GROUP BY JobID
  1972. HAVING COUNT(1) > 50
  1973. )
  1974. --排除受限制的企业操作
  1975. DELETE FROM #TCaJobCvOperateLog
  1976. WHERE JobID IN (
  1977. SELECT ID
  1978. FROM Job WHERE cpMainId IN(SELECT ID FROM cpMain WHERE IsLimitLogin = 9)
  1979. )
  1980. --需要推荐简历的职位
  1981. CREATE TABLE #TJobNeedPush(JobID INT)
  1982. --插入需要推送的职位
  1983. DECLARE @t AS TABLE(EMailSendFreq INT)
  1984. DECLARE @num INT
  1985. SET @Num = 0
  1986. WHILE @Num < 128
  1987. BEGIN
  1988. SET @Num = @Num + 1
  1989. IF SUBSTRING(RIGHT('0000000' + dbo.Int2Bin(@Num), 7), DATEPART(WEEKDAY, GETDATE() - 1), 1) = '1'
  1990. INSERT INTO @t SELECT @Num
  1991. END
  1992. INSERT INTO #TJobNeedPush
  1993. SELECT ID
  1994. FROM Job a WITH(NOLOCK)
  1995. WHERE EMailSendFreq IN(SELECT EMailSendFreq FROM @t)
  1996. AND valid = 1
  1997. SELECT CvMainID, COUNT(1) Cnt INTO #TCvOperateCount
  1998. FROM #TCaJobCvOperateLog
  1999. GROUP BY CvMainID
  2000. --生成所有记录简历的近似简历
  2001. CREATE TABLE #TCvSimilar1
  2002. (
  2003. MainCvID INT,
  2004. SimilarCvID INT,
  2005. MainCvCount INT,
  2006. SimilarCvCount INT,
  2007. Rate FLOAT
  2008. )
  2009. --按照操作简历记录分组
  2010. INSERT INTO #TCvSimilar1(MainCvID, SimilarCvID, SimilarCvCount)
  2011. SELECT b.CvMainID MainCvID, a.CvMainID SimilarCvID, COUNT(1) SimilarCvCount
  2012. FROM #TCaJobCvOperateLog a, #TCaJobCvOperateLog b
  2013. WHERE a.JobID = b.JobID
  2014. GROUP BY a.CvMainID, b.CvMainID
  2015. HAVING COUNT(1) > 1
  2016. ORDER BY b.CvMainID, COUNT(1) DESC
  2017. --删除无效的,以及自己的推荐
  2018. DELETE FROM #TCvSimilar1 WHERE MainCvID = 0
  2019. DELETE FROM #TCvSimilar1 WHERE MainCvID = SimilarCvID
  2020. --修改总的简历操作次数
  2021. UPDATE a SET a.MainCvCount = b.Cnt
  2022. FROM #TCvSimilar1 a, #TCvOperateCount b
  2023. WHERE a.MainCvID = b.CvMainID
  2024. --排除无效简历
  2025. DELETE FROM #TCvSimilar1 WHERE Rate = 100
  2026. DELETE FROM #TCvSimilar1
  2027. WHERE (
  2028. SELECT Valid
  2029. FROM CvMain WITH(NOLOCK)
  2030. WHERE id = #TCvSimilar1.SimilarCvID
  2031. ) = 0
  2032. --通过职位操作简历记录 匹配职位与简历
  2033. SELECT a.JobID, b.SimilarCvID, b.MainCvCount, b.SimilarCvCount, b.Rate
  2034. INTO #TCvSimilar2
  2035. FROM #TCaJobCvOperateLog a, #TCvSimilar1 b
  2036. WHERE a.CvMainID = b.MainCvID
  2037. ORDER BY a.JobID, b.Rate DESC
  2038. --删除已经操作的简历
  2039. DELETE FROM a
  2040. FROM #TCvSimilar2 a, #TCaJobCvOperateLog b
  2041. WHERE a.JobID = b.JobID
  2042. AND a.SimilarCvID = b.CvMainID
  2043. --整理 一份简历被推荐给同一个职位的次数
  2044. SELECT JobID, SimilarCvID, COUNT(1) Cnt
  2045. INTO #TCvSimilar3
  2046. FROM #TCvSimilar2
  2047. GROUP BY JobID, SimilarCvID
  2048. --排序整理 根据简历近似简历分析结束
  2049. SELECT *, ROW_NUMBER() OVER(PARTITION BY JobID ORDER BY Cnt DESC) CvRank
  2050. INTO #TJobSimilarCv
  2051. FROM #TCvSimilar3
  2052. --根据职位的近似职位推荐简历
  2053. CREATE TABLE #TJobSimilar1
  2054. (
  2055. MainJobID INT,
  2056. SimilarJobID INT,
  2057. SimilarJobCount INT
  2058. )
  2059. --按照职位操作简历进行分组排序查询 分析职位近似职位
  2060. INSERT INTO #TJobSimilar1(MainJobID, SimilarJobID, SimilarJobCount)
  2061. SELECT a.JobID, b.JobID, COUNT(1)
  2062. FROM #TCaJobCvOperateLog a, #TCaJobCvOperateLog b
  2063. WHERE a.CvMainID = b.CvMainID
  2064. AND a.JobID <> b.JobID
  2065. GROUP BY a.JobID, b.JobID
  2066. ORDER BY COUNT(1) DESC
  2067. --按照近似的相同个数进行排序整理
  2068. SELECT *, ROW_NUMBER() OVER(PARTITION BY MainJobID ORDER BY SimilarJobCount DESC) JobRank
  2069. INTO #TJobSimilar2
  2070. FROM #TJobSimilar1
  2071. --DELETE FROM #TJobSimilar2 WHERE JobRank > 10
  2072. --根据相似职位推荐 操作简历的相似推荐
  2073. SELECT a.MainJobID, b.CvMainID, COUNT(1) Cnt
  2074. INTO #TJobSimilar3
  2075. FROM #TJobSimilar2 a, #TCaJobCvOperateLog b
  2076. WHERE a.SimilarJobID = b.JobID
  2077. GROUP BY a.MainJobID, b.CvMainID
  2078. HAVING COUNT(1) > 1
  2079. --插入到总的推荐列表
  2080. INSERT INTO #TJobSimilarCv (JobID, SimilarCvID, Cnt)
  2081. SELECT MainJobID, CvMainID, 1
  2082. FROM #TJobSimilar3
  2083. --删除曾经推荐过的
  2084. DELETE FROM #TJobSimilarCv
  2085. WHERE EXISTS(
  2086. SELECT 'x'
  2087. FROM caJobCvMatch WITH(NOLOCK)
  2088. WHERE MatchCvMainID = #TJobSimilarCv.SimilarCvID
  2089. )
  2090. --删除已经操作的简历
  2091. DELETE FROM a
  2092. FROM #TJobSimilarCv a, #TCaJobCvOperateLog b
  2093. WHERE a.JobID = b.JobID
  2094. AND a.SimilarCvID = b.CvMainID
  2095. --整理两种推荐方式推荐的所有简历
  2096. SELECT JobID, SimilarCvID, SUM(Cnt) Cnt
  2097. INTO #TJobSimilarCv1
  2098. FROM #TJobSimilarCv
  2099. GROUP BY JobID, SimilarCvID
  2100. SELECT *, ROW_NUMBER() OVER(PARTITION BY JobID ORDER BY Cnt DESC) JobRank
  2101. INTO #TJobSimilarCv2
  2102. FROM #TJobSimilarCv1
  2103. WHERE EXISTS( --最后一次登录在一个月内,并且有效的简历
  2104. SELECT 'x'
  2105. FROM cvMain a WITH(NOLOCK), paMain b WITH(NOLOCK)
  2106. WHERE a.ID = #TJobSimilarCv1.SimilarCvID
  2107. AND a.paMainID = b.ID
  2108. AND b.LastLoginDate > GETDATE() - 30
  2109. AND a.Valid = 1
  2110. )
  2111. --取10个推荐放到推荐表中
  2112. INSERT INTO caJobCvMatch(JobID, MatchCvMainID, DataSource, AddDate)
  2113. SELECT JobID, SimilarCvID, 1, GETDATE()
  2114. FROM #TJobSimilarCv2
  2115. WHERE JobID IN(SELECT JobID FROM #TJobNeedPush) --需要发送的职位
  2116. AND JobRank <= 10
  2117. GROUP BY JobID, SimilarCvID
  2118. ORDER BY SUM(Cnt) DESC
  2119. --为推荐不足10个的根据职位要求第一次匹配数据
  2120. SELECT a.JobID, c.ResumeID CvMainID, ROW_NUMBER() OVER(PARTITION BY a.JobID ORDER BY COUNT(1) DESC) RowIndex
  2121. INTO #TJobSimilarCvSearch
  2122. FROM #TJobNeedPush a, JobPublish b WITH(NOLOCK), caJobResumePre c WITH(NOLOCK)
  2123. WHERE a.JobID = b.ID
  2124. AND (SELECT COUNT(1) FROM caJobCvMatch WHERE JobID = a.JobID AND AddDate > @Today) < 10
  2125. AND b.dcRegionID = c.AtPlace
  2126. AND c.Age BETWEEN b.MinAge AND b.MaxAge
  2127. AND EXISTS(SELECT 'x' FROM cvJobType WHERE cvMainID = c.ResumeID AND dcJobTypeID = b.dcJobTypeID)
  2128. GROUP BY a.JobID, c.ResumeID
  2129. ORDER BY a.JobID
  2130. DELETE FROM #TJobSimilarCvSearch
  2131. WHERE EXISTS(
  2132. SELECT 'x'
  2133. FROM caJobCvMatch WITH(NOLOCK)
  2134. WHERE JobID = #TJobSimilarCvSearch.JobID
  2135. AND MatchCvMainID = #TJobSimilarCvSearch.CvMainID
  2136. )
  2137. INSERT INTO caJobCvMatch (JobID, MatchCvMainID, DataSource, AddDate)
  2138. SELECT JobID, CvMainID, 2, GETDATE()
  2139. FROM #TJobSimilarCvSearch a
  2140. WHERE RowIndex <= (SELECT (10 - COUNT(1)) FROM caJobCvMatch WHERE JobID = a.JobID AND AddDate > @Today)
  2141. GROUP BY JobID, CvMainID
  2142. --为推荐不足10个的根据职位要求第二次匹配数据 放宽地点要求 放宽职位类别
  2143. SELECT a.JobID, c.ResumeID CvMainID, ROW_NUMBER() OVER(PARTITION BY a.JobID ORDER BY COUNT(1) DESC) RowIndex
  2144. INTO #TJobSimilarCvSearch1
  2145. FROM #TJobNeedPush a, JobPublish b WITH(NOLOCK), caJobResumePre c WITH(NOLOCK)
  2146. WHERE a.JobID = b.ID
  2147. AND (SELECT COUNT(1) FROM caJobCvMatch WHERE JobID = a.JobID AND AddDate > @Today) < 10
  2148. AND LEFT(b.dcRegionID, 4) = LEFT(c.AtPlace, 4)
  2149. AND c.Age BETWEEN b.MinAge AND b.MaxAge
  2150. AND EXISTS(SELECT 'x' FROM cvJobType WHERE cvMainID = c.ResumeID AND LEFT(dcJobTypeID, 2) = LEFT(b.dcJobTypeID, 2))
  2151. GROUP BY a.JobID, c.ResumeID
  2152. ORDER BY a.JobID
  2153. DELETE FROM #TJobSimilarCvSearch1
  2154. WHERE EXISTS(
  2155. SELECT 'x'
  2156. FROM caJobCvMatch WITH(NOLOCK)
  2157. WHERE JobID = #TJobSimilarCvSearch1.JobID
  2158. AND MatchCvMainID = #TJobSimilarCvSearch1.CvMainID
  2159. )
  2160. INSERT INTO caJobCvMatch(JobID, MatchCvMainID, DataSource, AddDate)
  2161. SELECT JobID, CvMainID, 2, GETDATE()
  2162. FROM #TJobSimilarCvSearch1 a
  2163. WHERE RowIndex <= (SELECT (10 - COUNT(1)) FROM caJobCvMatch WHERE JobID = a.JobID)
  2164. GROUP BY JobID, CvMainID
  2165. --修改相关的推送信息
  2166. UPDATE Job
  2167. SET LastEmailDate = GETDATE()
  2168. WHERE ID IN(SELECT JobID FROM #TJobNeedPush)
  2169. --papush
  2170. SELECT b.caMainId,count(1) cvcnt
  2171. INTO #t
  2172. FROM caJobCvMatch a LEFT JOIN job b ON a.jobId= b.Id
  2173. WHERE a.AddDate> @Today
  2174. GROUP BY b.caMainId
  2175. DELETE FROM #t WHERE cvcnt=0
  2176. INSERT INTO paPushLog(paMainID, PushMessage, PushType)
  2177. SELECT a.caMainID, '今天给您推荐了'+CONVERT(char(5),a.cvcnt)+'个简历了解一下→', 12
  2178. FROM #t a,caIOSBind b
  2179. WHERE a.caMainId=b.caMainId
  2180. --删除所有临时表
  2181. DROP TABLE #t
  2182. DROP TABLE #TCaJobCvOperateLog
  2183. DROP TABLE #TJobNeedPush
  2184. DROP TABLE #TCvOperateCount
  2185. DROP TABLE #TCvSimilar1
  2186. DROP TABLE #TCvSimilar2
  2187. DROP TABLE #TCvSimilar3
  2188. DROP TABLE #TJobSimilarCv
  2189. DROP TABLE #TJobSimilarCv1
  2190. DROP TABLE #TJobSimilarCv2
  2191. DROP TABLE #TJobSimilar1
  2192. DROP TABLE #TJobSimilar2
  2193. DROP TABLE #TJobSimilar3
  2194. DROP TABLE #TJobSimilarCvSearch
  2195. DROP TABLE #TJobSimilarCvSearch1
  2196. END
  2197. GO
  2198. /****** Object: StoredProcedure [dbo].[ProcCaJobResumePreRebuild] Script Date: 2018/12/13 19:09:42 ******/
  2199. SET ANSI_NULLS ON
  2200. GO
  2201. SET QUOTED_IDENTIFIER ON
  2202. GO
  2203. CREATE PROCEDURE [dbo].[ProcCaJobResumePreRebuild]
  2204. AS
  2205. SET NOCOUNT ON
  2206. BEGIN
  2207. TRUNCATE TABLE caJobResumePre
  2208. INSERT INTO caJobResumePre(ResumeID, Name, Sex, Age, BirthDay, EduLevel, Experience, JobType, AtPlace, LastLoginDate, paMainId, SecondId)
  2209. SELECT a.id resumeid, b.name name, b.gender sex, dbo.BirthToAge(b.birthday) age,
  2210. b.birthday, a.degree edulevel, a.relatedworkyears experience,
  2211. dbo.GetCvJobType(a.id) jobtype, b.LivePlace AtPlace, b.LastLoginDate, a.paMainId, LOWER(a.SecondId)
  2212. FROM cvMain a with(nolock), paMain b with(nolock)
  2213. WHERE a.paMainID=b.ID
  2214. And b.lastlogindate>getdate()-30
  2215. And a.valid > 0
  2216. UPDATE a SET a.AtPlaceDesc = b.Description
  2217. FROM caJobResumePre a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  2218. WHERE LEFT(a.AtPlace, 2) = b.ID
  2219. UPDATE a SET a.AtPlaceDesc = a.AtPlaceDesc + b.Description
  2220. FROM caJobResumePre a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  2221. WHERE a.AtPlace = b.ID
  2222. AND Len(A.AtPlace) > 2
  2223. AND LEFT(a.AtPlace, 4) = b.ID
  2224. TRUNCATE TABLE caJobResumePreJobType
  2225. INSERT INTO caJobResumePreJobType
  2226. SELECT * FROM cvJobType WHERE cvMainID IN(SELECT ResumeID FROM caJobResumePre)
  2227. END
  2228. GO
  2229. /****** Object: StoredProcedure [dbo].[ProcCaLoginLogByWeiXinInsert] Script Date: 2018/12/13 19:09:42 ******/
  2230. SET ANSI_NULLS ON
  2231. GO
  2232. SET QUOTED_IDENTIFIER ON
  2233. GO
  2234. CREATE PROCEDURE [dbo].[ProcCaLoginLogByWeiXinInsert]
  2235. (
  2236. @FromUserName VARCHAR(100)
  2237. )
  2238. AS
  2239. SET NOCOUNT ON
  2240. BEGIN
  2241. DECLARE @caMainId INT
  2242. SELECT @caMainId = caMainId FROM wxFans WITH(NOLOCK) WHERE OpenId = @FromUserName
  2243. IF @caMainId IS NULL
  2244. BEGIN
  2245. SELECT @caMainId = paMainId FROM palogincontact WITH(NOLOCK) WHERE OpenId = @FromUserName AND ContactType = 101
  2246. IF @caMainId IS NULL
  2247. RETURN
  2248. END
  2249. DECLARE @Ip VARCHAR(31), @AddDate SMALLDATETIME, @Name NVARCHAR(100)
  2250. SELECT TOP 1 @AddDate = AddDate, @ip = LoginIp FROM caLoginLog WITH(NOLOCK)
  2251. WHERE caMainId = @caMainId ORDER BY Id DESC
  2252. SELECT @Name = Name FROM cpMain WITH(NOLOCK) WHERE Id = (SELECT cpMainId FROM caMain WITH(NOLOCK) WHERE Id = @caMainId)
  2253. IF @Ip IS NULL
  2254. BEGIN
  2255. INSERT INTO caLoginLog
  2256. SELECT @caMainId, @Name, '', '', '', GETDATE(), 'weixin', 10
  2257. RETURN
  2258. END
  2259. DECLARE @cpMainId INT, @LastLoginDate DATETIME
  2260. SELECT @cpMainId = Id, @LastLoginDate = LastLoginDate FROM cpMain WITH(NOLOCK) WHERE Id = (SELECT cpMainId FROM caMain WITH(NOLOCK) WHERE id = @caMainId)
  2261. IF @LastLoginDate < CONVERT(VARCHAR(10), GETDATE(), 120)
  2262. BEGIN
  2263. INSERT INTO caLoginLog
  2264. SELECT @caMainId, @Name, '', '', '未记录', GETDATE(), 'weixin', 11
  2265. UPDATE cpMaIn SET LastLoginDate = GETDATE(), RefreshDate = GETDATE() WHERE Id = @cpMainId
  2266. UPDATE Job SET RefreshDate = GETDATE() WHERE caMainId = @caMainId AND Valid = 1
  2267. END
  2268. END
  2269. GO
  2270. /****** Object: StoredProcedure [dbo].[procCaMainByUserNameLowerSelect] Script Date: 2018/12/13 19:09:42 ******/
  2271. SET ANSI_NULLS ON
  2272. GO
  2273. SET QUOTED_IDENTIFIER ON
  2274. GO
  2275. --#####################################################
  2276. --创建时间:2014.11.10
  2277. --创建人:NICK
  2278. --说明:
  2279. --#####################################################
  2280. CREATE PROCEDURE [dbo].[procCaMainByUserNameLowerSelect]
  2281. (
  2282. @UserName VARCHAR(50)
  2283. )
  2284. AS
  2285. BEGIN
  2286. SELECT TOP 1 cpMainID FROM camain WHERE UserNameLower = @UserName
  2287. END
  2288. GO
  2289. /****** Object: StoredProcedure [dbo].[ProcCampusBrochure30Select] Script Date: 2018/12/13 19:09:43 ******/
  2290. SET ANSI_NULLS ON
  2291. GO
  2292. SET QUOTED_IDENTIFIER ON
  2293. GO
  2294. --#####################################################
  2295. --创建时间:2014.10.29
  2296. --创建人:Nick
  2297. --说明:获取最新校园招聘结束时间在30天内的,取120条,点击量前15的加hot
  2298. --#####################################################
  2299. CREATE PROCEDURE [dbo].[ProcCampusBrochure30Select]
  2300. (
  2301. @ProvinceID INT
  2302. )
  2303. AS
  2304. BEGIN TRY
  2305. SELECT TOP 120 a.id, a.CompanyID, a.Title,0 IsHot
  2306. FROM marketdb..CampusBrochure a WITH(NOLOCK),
  2307. marketdb..CampusBrochureSite b WITH(NOLOCK)
  2308. WHERE a.EndDate>Getdate()
  2309. AND a.id = b.CampusBrochure
  2310. AND b.dcSubSiteID = @provinceID
  2311. ORDER BY CASE a.id WHEN 7866 THEN 1 WHEN 7865 THEN 1 WHEN 7870 THEN 1 ELSE 2 END ,a.OrderBy ,AddDate DESC
  2312. END TRY
  2313. BEGIN CATCH
  2314. RETURN 0
  2315. END CATCH
  2316. GO
  2317. /****** Object: StoredProcedure [dbo].[procCampusBrochureByConditionSelect] Script Date: 2018/12/13 19:09:43 ******/
  2318. SET ANSI_NULLS ON
  2319. GO
  2320. SET QUOTED_IDENTIFIER ON
  2321. GO
  2322. --#####################################################
  2323. --创建时间:2014.11.10
  2324. --创建人:Nick
  2325. --说明:根据条件获取 校园招聘信息
  2326. --#####################################################
  2327. CREATE PROCEDURE [dbo].[procCampusBrochureByConditionSelect]
  2328. (
  2329. @Condition VARCHAR(MAX)
  2330. )
  2331. AS
  2332. BEGIN
  2333. DECLARE @SQL VARCHAR(MAX)
  2334. SET @SQL = '
  2335. SELECT top 5 A.id, a.Title
  2336. FROM marketdb..CampusBrochure a WITH(nolock),marketdb..CampusBrochureSite b WITH(nolock)
  2337. WHERE a.EndDate>Getdate()
  2338. AND a.id = b.CampusBrochure '+@Condition+'
  2339. ORDER BY CASE a.id WHEN 7866 THEN 1 WHEN 7865 THEN 1 WHEN 7870 THEN 1 ELSE 2 END , AddDate DESC '
  2340. EXEC(@SQL)
  2341. END
  2342. GO
  2343. /****** Object: StoredProcedure [dbo].[ProcCampusBrochureByIDSelect] Script Date: 2018/12/13 19:09:43 ******/
  2344. SET ANSI_NULLS ON
  2345. GO
  2346. SET QUOTED_IDENTIFIER ON
  2347. GO
  2348. --#####################################################
  2349. --创建时间:2014.10.28
  2350. --创建人:Nick
  2351. --说明:通过ID获取公司信息数据
  2352. --#####################################################
  2353. CREATE PROCEDURE [dbo].[ProcCampusBrochureByIDSelect]
  2354. (
  2355. @ID INT
  2356. )
  2357. AS
  2358. BEGIN TRY
  2359. --修改点击量
  2360. UPDATE marketdb..CampusBrochure
  2361. SET ClickNumber=ClickNumber+1
  2362. WHERE id = @ID
  2363. SELECT TOP 1 a.*,b.ID CompanyID,b.CompanyName,b.Description CompanyDescription,
  2364. d.Description RegionName,e.Description Industry,b.Homepage
  2365. FROM marketdb..CampusBrochure a WITH(NOLOCK) ,marketdb..CampusCompany b WITH(NOLOCK) ,
  2366. dcRegion d WITH(NOLOCK) ,dcIndustry e WITH(NOLOCK)
  2367. WHERE a.CompanyID = b.ID
  2368. AND b.dcRegionID = d.id
  2369. AND b.dcIndustryID = e.ID
  2370. AND a.ID = @ID
  2371. END TRY
  2372. BEGIN CATCH
  2373. RETURN 0
  2374. END CATCH
  2375. GO
  2376. /****** Object: StoredProcedure [dbo].[ProcCampusBrochureByIndustryIDSelect] Script Date: 2018/12/13 19:09:43 ******/
  2377. SET ANSI_NULLS ON
  2378. GO
  2379. SET QUOTED_IDENTIFIER ON
  2380. GO
  2381. -- =============================================
  2382. -- Author: <Mice 123>
  2383. -- Create date: <2014-11-25>
  2384. -- Description: <按照industryids查询招聘简章>
  2385. -- Modify:harry
  2386. -- 修改取前210条,不再按照行业取,优先显示未过期,然后显现过期的
  2387. -- =============================================
  2388. CREATE PROCEDURE [dbo].[ProcCampusBrochureByIndustryIDSelect]
  2389. (
  2390. @ProvinceID INT,
  2391. @IndustryID VARCHAR(200)
  2392. )
  2393. AS
  2394. --INSERT INTO procLog SELECT 'ProcCampusBrochureByIndustryIDSelect', @ProvinceID, GETDATE()
  2395. BEGIN
  2396. SELECT TOP 210 c.dcIndustryID, a.id, a.CompanyID, a.Title, 0 IsHot , a.ClickNumber
  2397. FROM MarketDb..CampusBrochure a WITH(NOLOCK),
  2398. MarketDb..CampusBrochureSite b WITH(NOLOCK) ,
  2399. MarketDb..campuscompany c WITH(NOLOCK)
  2400. WHERE a.id = b.CampusBrochure AND a.CompanyID = c.id
  2401. AND b.dcSubSiteID = @ProvinceID
  2402. --AND c.dcIndustryID IN ( SELECT a FROM dbo.fnsplit(@IndustryID,',') )
  2403. ORDER BY a.EndDate DESC, a.id, a.OrderBy , a.AddDate DESC
  2404. END
  2405. GO
  2406. /****** Object: StoredProcedure [dbo].[procCampusBrochureByKeyWordSelect] Script Date: 2018/12/13 19:09:43 ******/
  2407. SET ANSI_NULLS ON
  2408. GO
  2409. SET QUOTED_IDENTIFIER ON
  2410. GO
  2411. --#####################################################
  2412. --创建时间:2014.11.5
  2413. --创建人:NICK
  2414. --说明:
  2415. --#####################################################
  2416. CREATE PROCEDURE [dbo].[procCampusBrochureByKeyWordSelect]
  2417. (
  2418. @keyword VARCHAR(50)
  2419. )
  2420. AS
  2421. BEGIN
  2422. SELECT a.id,a.Title,a.addDate
  2423. FROM marketdb..CampusBrochure a WITH(NOLOCK) ,
  2424. marketdb..CampusBrochureSite b WITH(NOLOCK)
  2425. WHERE a.EndDate>Getdate() and a.id = b.CampusBrochure
  2426. AND a.Title LIKE '%'+@keyword+'%'
  2427. ORDER BY a.AddDate DESC
  2428. END
  2429. GO
  2430. /****** Object: StoredProcedure [dbo].[procCampusBrochureByProvinceIDSelect] Script Date: 2018/12/13 19:09:44 ******/
  2431. SET ANSI_NULLS ON
  2432. GO
  2433. SET QUOTED_IDENTIFIER ON
  2434. GO
  2435. --#####################################################
  2436. --创建时间:2014.11.10
  2437. --创建人:Nick
  2438. --说明:根据省份获取校园招聘信息
  2439. --#####################################################
  2440. CREATE PROCEDURE [dbo].[procCampusBrochureByProvinceIDSelect]
  2441. (
  2442. @ProvinceID INT
  2443. )
  2444. AS
  2445. BEGIN
  2446. SELECT top 5 A.id, a.Title FROM marketdb..CampusBrochure a WITH(nolock),marketdb..CampusBrochureSite b WITH(nolock)
  2447. WHERE a.EndDate>Getdate()
  2448. AND a.id = b.CampusBrochure
  2449. AND b.dcSubSiteID = @ProvinceID
  2450. ORDER BY CASE a.id WHEN 7866 THEN 1 WHEN 7865 THEN 1 WHEN 7870 THEN 1 ELSE 2 END , AddDate DESC
  2451. END
  2452. GO
  2453. /****** Object: StoredProcedure [dbo].[ProcCampusBrochureFamousSelect] Script Date: 2018/12/13 19:09:44 ******/
  2454. SET ANSI_NULLS ON
  2455. GO
  2456. SET QUOTED_IDENTIFIER ON
  2457. GO
  2458. --#####################################################
  2459. --创建时间:2014.10.29
  2460. --创建人:Nick
  2461. --说明:获取64条名企招聘简章
  2462. --#####################################################
  2463. CREATE PROCEDURE [dbo].[ProcCampusBrochureFamousSelect]
  2464. (
  2465. @ProvinceID INT
  2466. )
  2467. AS
  2468. BEGIN TRY
  2469. SELECT TOP 64 a.id , a.CompanyID ,a.Title,0 IsHot
  2470. FROM marketdb..CampusBrochure a WITH(NOLOCK),
  2471. marketdb..CampusBrochureSite b WITH(NOLOCK)
  2472. WHERE a.EndDate>Getdate()
  2473. AND a.id = b.CampusBrochure
  2474. AND b.dcSubSiteID = @provinceID
  2475. ORDER BY CASE a.id WHEN 7866 THEN 1 WHEN 7865 THEN 1 WHEN 7870 THEN 1 ELSE 2 END ,a.OrderBy ,AddDate DESC
  2476. END TRY
  2477. BEGIN CATCH
  2478. RETURN 0
  2479. END CATCH
  2480. GO
  2481. /****** Object: StoredProcedure [dbo].[ProcCampusBrochureHotSelect] Script Date: 2018/12/13 19:09:44 ******/
  2482. SET ANSI_NULLS ON
  2483. GO
  2484. SET QUOTED_IDENTIFIER ON
  2485. GO
  2486. --#####################################################
  2487. --创建时间:2014.10.29
  2488. --创建人:Nick
  2489. --说明:获取热门企业招聘
  2490. --#####################################################
  2491. CREATE PROCEDURE [dbo].[ProcCampusBrochureHotSelect]
  2492. (
  2493. @ProvinceID INT
  2494. )
  2495. AS
  2496. BEGIN TRY
  2497. SELECT TOP 10 a.id,a.Title
  2498. FROM marketdb..CampusBrochure a WITH(NOLOCK),marketdb..CampusBrochureSite b WITH(NOLOCK)
  2499. WHERE a.id = b.CampusBrochure
  2500. AND a.EndDate < GETDATE()+30
  2501. AND b.dcSubSiteID = @ProvinceID
  2502. ORDER BY AddDate
  2503. END TRY
  2504. BEGIN CATCH
  2505. RETURN 0
  2506. END CATCH
  2507. GO
  2508. /****** Object: StoredProcedure [dbo].[ProcCampusBrochureListSelect] Script Date: 2018/12/13 19:09:45 ******/
  2509. SET ANSI_NULLS ON
  2510. GO
  2511. SET QUOTED_IDENTIFIER ON
  2512. GO
  2513. -- =============================================
  2514. -- Author: <Mice 123>
  2515. -- Create date: <2014-11-26>
  2516. -- Description: <查询该省份下符合行业的未举行的招聘简章>
  2517. -- =============================================
  2518. CREATE PROCEDURE [dbo].[ProcCampusBrochureListSelect]
  2519. (
  2520. @ProvinceID INT,
  2521. @IndustryID VARCHAR(200)
  2522. )
  2523. AS
  2524. BEGIN
  2525. SELECT c.dcIndustryID, a.id, a.CompanyID, a.Title, 0 IsHot, a.ClickNumber
  2526. FROM marketdb..CampusBrochure a WITH(NOLOCK),
  2527. marketdb..CampusBrochureSite b WITH(NOLOCK) ,
  2528. marketdb..campuscompany c WITH(NOLOCK)
  2529. WHERE a.EndDate > Getdate()
  2530. AND a.id = b.CampusBrochure
  2531. AND a.CompanyID = c.id
  2532. AND b.dcSubSiteID = @ProvinceID
  2533. AND c.dcIndustryID IN(SELECT a FROM dbo.fnsplit(@IndustryID, ','))
  2534. ORDER BY a.id , a.OrderBy , a.AddDate DESC
  2535. END
  2536. GO
  2537. /****** Object: StoredProcedure [dbo].[ProcCampusBrochureOtherByIDSelect] Script Date: 2018/12/13 19:09:45 ******/
  2538. SET ANSI_NULLS ON
  2539. GO
  2540. SET QUOTED_IDENTIFIER ON
  2541. GO
  2542. --#####################################################
  2543. --创建时间:2014.10.28
  2544. --创建人:Nick
  2545. --说明:通过公司ID获取公司其他招聘简章
  2546. --#####################################################
  2547. CREATE PROCEDURE [dbo].[ProcCampusBrochureOtherByIDSelect]
  2548. (
  2549. @CompanyID INT
  2550. )
  2551. AS
  2552. BEGIN TRY
  2553. SELECT TOP 8 a.*,b.Id CompanyID,a.Adddate,b.CompanyName,b.Description CompanyDescription,
  2554. d.Description RegionName,e.Description Industry,b.Homepage
  2555. FROM marketdb..CampusBrochure a WITH(NOLOCK) ,marketdb..CampusCompany b WITH(NOLOCK) ,
  2556. dcRegion d WITH(NOLOCK) ,dcIndustry e WITH(NOLOCK)
  2557. WHERE a.CompanyID = b.ID
  2558. AND b.dcRegionID = d.id
  2559. AND b.dcIndustryID = e.ID
  2560. AND a.CompanyID = @CompanyID
  2561. ORDER BY a.Adddate DESC
  2562. END TRY
  2563. BEGIN CATCH
  2564. RETURN 0
  2565. END CATCH
  2566. GO
  2567. /****** Object: StoredProcedure [dbo].[ProcCampusBrochurePeriodSelect] Script Date: 2018/12/13 19:09:45 ******/
  2568. SET ANSI_NULLS ON
  2569. GO
  2570. SET QUOTED_IDENTIFIER ON
  2571. GO
  2572. --#####################################################
  2573. --创建时间:2014.10.29
  2574. --创建人:Nick
  2575. --说明:获取公司往期招聘简章
  2576. --#####################################################
  2577. CREATE PROCEDURE [dbo].[ProcCampusBrochurePeriodSelect]
  2578. (
  2579. @ProvinceID INT,
  2580. @CompanyID INT
  2581. )
  2582. AS
  2583. BEGIN TRY
  2584. SELECT a.*
  2585. FROM marketdb..CampusBrochure a WITH(NOLOCK),marketdb..CampusBrochureSite b WITH(NOLOCK)
  2586. WHERE a.ID = b.CampusBrochure
  2587. AND a.EndDate<Getdate()
  2588. AND b.dcSubSiteID = @ProvinceID
  2589. AND a.CompanyId = @CompanyID
  2590. END TRY
  2591. BEGIN CATCH
  2592. RETURN 0
  2593. END CATCH
  2594. GO
  2595. /****** Object: StoredProcedure [dbo].[procCampusByHomePageList] Script Date: 2018/12/13 19:09:46 ******/
  2596. SET ANSI_NULLS ON
  2597. GO
  2598. SET QUOTED_IDENTIFIER ON
  2599. GO
  2600. --#####################################
  2601. --创建人: Lambo
  2602. --创建时间:20120628
  2603. --用于首页校园招聘宣讲会
  2604. --######################################
  2605. CREATE PROCEDURE [dbo].[procCampusByHomePageList]
  2606. (
  2607. @ProvinceID SMALLINT
  2608. )
  2609. AS
  2610. BEGIN
  2611. SET NOCOUNT ON
  2612. SELECT TOP 1 ImageFile,alt FROM fpHomePageImage WITH(NOLOCK)
  2613. WHERE ImageType = 5
  2614. AND dcProvinceID = LEFT(@ProvinceID, 2)
  2615. ORDER BY AddDate DESC
  2616. SELECT TOP 5 * FROM SearchDb..HPCampus WITH(NOLOCK)
  2617. WHERE provinceID = LEFT(@ProvinceID, 2)
  2618. ORDER BY ID
  2619. SET NOCOUNT OFF
  2620. END
  2621. GO
  2622. /****** Object: StoredProcedure [dbo].[procCampusByHomePageListNew] Script Date: 2018/12/13 19:09:46 ******/
  2623. SET ANSI_NULLS ON
  2624. GO
  2625. SET QUOTED_IDENTIFIER ON
  2626. GO
  2627. CREATE PROCEDURE [dbo].[procCampusByHomePageListNew]
  2628. (
  2629. @ProvinceID SMALLINT
  2630. )
  2631. AS
  2632. BEGIN
  2633. SET NOCOUNT ON
  2634. SELECT TOP 1 ImageFile,alt FROM fpHomePageImage WITH(NOLOCK)
  2635. WHERE ImageType = 5
  2636. AND dcProvinceID = LEFT(@ProvinceID, 2)
  2637. ORDER BY AddDate DESC
  2638. SELECT TOP 15 * FROM SearchDb..HPCampus WITH(NOLOCK)
  2639. WHERE provinceID =LEFT(@ProvinceID, 2)
  2640. ORDER BY ID
  2641. SET NOCOUNT OFF
  2642. END
  2643. GO
  2644. /****** Object: StoredProcedure [dbo].[ProcCampusCollectInsert] Script Date: 2018/12/13 19:09:46 ******/
  2645. SET ANSI_NULLS ON
  2646. GO
  2647. SET QUOTED_IDENTIFIER ON
  2648. GO
  2649. CREATE PROCEDURE [dbo].[ProcCampusCollectInsert]
  2650. (
  2651. @InfoText NVARCHAR(Max)
  2652. )
  2653. AS
  2654. BEGIN
  2655. DECLARE @SourceType VARCHAR(1),
  2656. @HostDate VARCHAR(50),
  2657. @HostTime VARCHAR(50),
  2658. @CompanyName VARCHAR(50),
  2659. @SchoolName VARCHAR(50),
  2660. @HostAddress VARCHAR(50),
  2661. @CityName VARCHAR(10),
  2662. @i AS INT,
  2663. @Sql VARCHAR(MAX)
  2664. SET @SourceType = LEFT(@InfoText, 1)
  2665. IF @SourceType NOT IN('1', '2', '3')
  2666. BEGIN
  2667. SELECT 0 [RowCount]
  2668. RETURN
  2669. END
  2670. SET @InfoText = RIGHT(@InfoText, LEN(@InfoText) - 1)
  2671. DECLARE @campus AS TABLE(
  2672. Id INT,
  2673. [SourceType] [tinyint],
  2674. [HostDate] [nvarchar](50),
  2675. [HostTime] [nvarchar](50),
  2676. [CompanyName] [nvarchar](50),
  2677. [SchoolName] [nvarchar](50),
  2678. [HostAddress] [nvarchar](50),
  2679. [CityName] [nvarchar](10),
  2680. RowNo int identity(1,1)
  2681. )
  2682. DECLARE @campus1 AS TABLE(
  2683. [SourceType] [tinyint],
  2684. [HostDate] [nvarchar](50),
  2685. [HostTime] [nvarchar](50),
  2686. [CompanyName] [nvarchar](50),
  2687. [SchoolName] [nvarchar](50),
  2688. [HostAddress] [nvarchar](50),
  2689. [CityName] [nvarchar](10),
  2690. RowNo INT
  2691. )
  2692. DECLARE @t1 AS TABLE (ID INT Identity(1, 1), infoText NVARCHAR(MAX))
  2693. CREATE TABLE #t2 (ID INT Identity(1, 1), infoText NVARCHAR(100))
  2694. INSERT @t1(infoText)
  2695. SELECT * FROM dbo.FnSplit(@InfoText, '^')
  2696. SET @i = 0
  2697. WHILE EXISTS(SELECT 'x' FROM @t1 WHERE @i < Id)
  2698. BEGIN
  2699. SET @I = @I + 1
  2700. SELECT TOP 1 @Sql = infoText FROM @t1 WHERE Id = @i
  2701. TRUNCATE TABLE #t2
  2702. INSERT INTO #t2(infoText)
  2703. SELECT * FROM Dbo.FnSplit(@Sql, '|')
  2704. IF @@RowCount = 6
  2705. BEGIN
  2706. SELECT @HostDate = infoText FROM #t2 WHERE Id = 1
  2707. SELECT @HostTime = CASE WHEN infoText = '-' THEN '' ELSE infoText END FROM #t2 WHERE Id = 2
  2708. SELECT @CompanyName = infoText FROM #t2 WHERE Id = 3
  2709. SELECT @SchoolName = infoText FROM #t2 WHERE Id = 4
  2710. SELECT @HostAddress = infoText FROM #t2 WHERE Id = 5
  2711. SELECT @CityName = infoText FROM #t2 WHERE Id = 6
  2712. INSERT INTO @campus(Id, SourceType, HostDate, HostTime, CompanyName, SchoolName, HostAddress, CityName)
  2713. SELECT 0, @SourceType, @HostDate, @HostTime, @CompanyName, @SchoolName, @HostAddress, @CityName
  2714. END
  2715. END
  2716. UPDATE a
  2717. SET a.Id = b.Id
  2718. FROM @campus a, CampusCollect b
  2719. WHERE a.SourceType = b.SourceType
  2720. AND a.HostDate = b.HostDate
  2721. AND a.HostTime = b.HostTime
  2722. AND a.CompanyName = b.CompanyName
  2723. AND a.SchoolName = b.SchoolName
  2724. AND a.HostAddress = b.HostAddress
  2725. AND a.CityName = b.CityName
  2726. INSERT INTO @campus1
  2727. SELECT SourceType, HostDate, HostTime, CompanyName, SchoolName, HostAddress, CityName, MIN(RowNo) RowNo
  2728. FROM @Campus
  2729. WHERE Id = 0
  2730. GROUP BY SourceType, HostDate, HostTime, CompanyName, SchoolName, HostAddress, CityName
  2731. INSERT INTO CampusCollect(SourceType, HostDate, HostTime, CompanyName, SchoolName, HostAddress, CityName)
  2732. SELECT SourceType, HostDate, HostTime, CompanyName, SchoolName, HostAddress, CityName
  2733. FROM @Campus1
  2734. ORDER BY RowNo
  2735. UPDATE CampusCollect SET CheckDate = GETDATE() WHERE Id IN(SELECT ID FROM @Campus WHERE Id > 0)
  2736. SELECT 1 [RowCount]
  2737. END
  2738. GO
  2739. /****** Object: StoredProcedure [dbo].[ProcCampusCompanyByCompanyIDSelect] Script Date: 2018/12/13 19:09:46 ******/
  2740. SET ANSI_NULLS ON
  2741. GO
  2742. SET QUOTED_IDENTIFIER ON
  2743. GO
  2744. --#####################################################
  2745. --创建时间:2014.10.28
  2746. --创建人:Nick
  2747. --说明:通过公司ID获取公司信息的数据
  2748. --#####################################################
  2749. CREATE PROCEDURE [dbo].[ProcCampusCompanyByCompanyIDSelect]
  2750. (
  2751. @CompanyID INT
  2752. )
  2753. AS
  2754. BEGIN TRY
  2755. SELECT a.*,b.Id CompanyID,b.CompanyName,b.Description CompanyDescription,d.Description RegionName,
  2756. e.Description Industry,b.Homepage
  2757. FROM marketdb..CampusCompany b WITH(NOLOCK)
  2758. INNER JOIN dcRegion d WITH(NOLOCK) ON b.dcRegionID = d.id
  2759. INNER JOIN dcIndustry e WITH(NOLOCK) ON b.dcIndustryID = e.ID
  2760. LEFT JOIN marketdb..CampusBrochure a WITH(NOLOCK) ON a.CompanyID = b.ID And EndDate>Getdate()
  2761. WHERE b.ID = @CompanyID
  2762. ORDER BY EndDate DESC
  2763. END TRY
  2764. BEGIN CATCH
  2765. RETURN 0
  2766. END CATCH
  2767. GO
  2768. /****** Object: StoredProcedure [dbo].[ProcCampusCompanyByProvinceIDSelect] Script Date: 2018/12/13 19:09:46 ******/
  2769. SET ANSI_NULLS ON
  2770. GO
  2771. SET QUOTED_IDENTIFIER ON
  2772. GO
  2773. --#####################################################
  2774. --创建时间:2014.10.28
  2775. --创建人:Nick
  2776. --说明:通过公司ID获取公司信息的数据
  2777. --#####################################################
  2778. CREATE PROCEDURE [dbo].[ProcCampusCompanyByProvinceIDSelect]
  2779. (
  2780. @ProvinceID INT
  2781. )
  2782. AS
  2783. BEGIN TRY
  2784. SELECT TOP 1 a.*,b.Id CompanyID,b.CompanyName,b.Description
  2785. CompanyDescription,d.Description RegionName,e.Description Industry,b.Homepage
  2786. FROM marketdb..CampusBrochure a WITH(NOLOCK) ,marketdb..CampusCompany b WITH(NOLOCK),
  2787. marketdb..CampusBrochureSite c WITH(NOLOCK),dcRegion d WITH(NOLOCK),dcIndustry e WITH(NOLOCK)
  2788. WHERE a.CompanyID = b.ID
  2789. AND a.ID = c.CampusBrochure
  2790. AND b.dcRegionID = d.id
  2791. AND b.dcIndustryID = e.ID
  2792. AND c.dcSubsiteID = @ProvinceID
  2793. ORDER BY addDate DESC
  2794. END TRY
  2795. BEGIN CATCH
  2796. RETURN 0
  2797. END CATCH
  2798. GO
  2799. /****** Object: StoredProcedure [dbo].[ProcCampusListTmpInsert] Script Date: 2018/12/13 19:09:47 ******/
  2800. SET ANSI_NULLS ON
  2801. GO
  2802. SET QUOTED_IDENTIFIER ON
  2803. GO
  2804. --#####################################################
  2805. --创建时间:2014.10.29
  2806. --创建人:Nick
  2807. --说明:生成宣讲会信息 每小时生成一次
  2808. --#####################################################
  2809. CREATE PROCEDURE [dbo].[ProcCampusListTmpInsert]
  2810. AS
  2811. BEGIN
  2812. DECLARE @Ok INT, @MaxID INT
  2813. SELECT TOP 1 @MaxId = ID, @Ok = 0 FROM MarketDb..CampusPresentation WITH(NOLOCK) ORDER BY Id DESC
  2814. IF EXISTS(SELECT 'x' FROM SearchDb..CampusListTmp WITH(NOLOCK) WHERE CampusPresentationID > @MaxID)
  2815. SET @Ok = 1
  2816. IF @Ok = 0
  2817. SELECT @Ok = 1
  2818. FROM MarketDb..CampusPresentation WITH(NOLOCK)
  2819. WHERE BeginTime BETWEEN DATEADD(MINUTE, -5, GETDATE()) AND GETDATE()
  2820. OR EndTime BETWEEN DATEADD(MINUTE, -5, GETDATE()) AND GETDATE()
  2821. IF @Ok = 0
  2822. RETURN
  2823. SELECT TOP 0 * INTO #t FROM SearchDb..CampusListTmp
  2824. --插入数据
  2825. INSERT INTO #t
  2826. SELECT b.Homepage,b.dcRegionID, a.CompanyID, d.Description RegionName, b.id SchoolID, b.SchoolName,
  2827. a.Address, c.CompanyName, a.BeginTime, a.EndTime, a.Id
  2828. FROM MarketDb..CampusPresentation a WITH(NOLOCK),
  2829. MarketDb..CampusSchool b WITH(NOLOCK),
  2830. MarketDb..CampusCompany c WITH(NOLOCK),
  2831. MainDb..dcRegion d WITH(NOLOCK)
  2832. WHERE a.CompanyID = c.id
  2833. AND a.SchoolID = b.ID
  2834. AND b.dcRegionID = d.id
  2835. ORDER BY a.BeginTime
  2836. --删除数据
  2837. TRUNCATE TABLE SearchDb..CampusListTmp
  2838. INSERT SearchDb..CampusListTmp(Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName,
  2839. Address, CompanyName, BeginTime, EndTime, CampusPresentationId)
  2840. SELECT Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName,
  2841. Address, CompanyName, BeginTime, EndTime, CampusPresentationId
  2842. FROM #t
  2843. ORDER BY ID
  2844. END
  2845. GO
  2846. /****** Object: StoredProcedure [dbo].[ProcCampusPresentation10Select] Script Date: 2018/12/13 19:09:47 ******/
  2847. SET ANSI_NULLS ON
  2848. GO
  2849. SET QUOTED_IDENTIFIER ON
  2850. GO
  2851. --#####################################################
  2852. --创建时间:2014.10.29
  2853. --创建人:Nick
  2854. --说明:获取前10条重点高校宣讲会
  2855. --#####################################################
  2856. CREATE PROCEDURE [dbo].[ProcCampusPresentation10Select]
  2857. AS
  2858. BEGIN TRY
  2859. SELECT a.* , b.Homepage, b.SchoolName
  2860. FROM marketdb..CampusPresentation a WITH(NOLOCK),marketdb..CampusSchool b WITH(NOLOCK)
  2861. WHERE a.SchoolID = b.ID
  2862. AND a.id IN (
  2863. SELECT TOP 10 MAX(id)
  2864. FROM marketdb..CampusPresentation a WITH(NOLOCK)
  2865. WHERE a.beginTime > GETDATE()
  2866. GROUP BY a.SchoolID )
  2867. END TRY
  2868. BEGIN CATCH
  2869. RETURN 0
  2870. END CATCH
  2871. GO
  2872. /****** Object: StoredProcedure [dbo].[ProcCampusPresentationPeriodSelect] Script Date: 2018/12/13 19:09:47 ******/
  2873. SET ANSI_NULLS ON
  2874. GO
  2875. SET QUOTED_IDENTIFIER ON
  2876. GO
  2877. --#####################################################
  2878. --创建时间:2014.10.29
  2879. --创建人:Nick
  2880. --说明:获取公司往期宣讲会
  2881. --#####################################################
  2882. CREATE PROCEDURE [dbo].[ProcCampusPresentationPeriodSelect]
  2883. (
  2884. @CompanyID INT
  2885. )
  2886. AS
  2887. BEGIN TRY
  2888. SELECT a.*,b.Homepage,b.SchoolName
  2889. FROM marketdb..CampusPresentation a WITH(NOLOCK),marketdb..CampusSchool b WITH(NOLOCK)
  2890. WHERE a.SchoolID = b.ID
  2891. AND EndTime<Getdate()
  2892. AND a.CompanyId = @CompanyID
  2893. END TRY
  2894. BEGIN CATCH
  2895. RETURN 0
  2896. END CATCH
  2897. GO
  2898. /****** Object: StoredProcedure [dbo].[ProcCampusPresentationSelect] Script Date: 2018/12/13 19:09:47 ******/
  2899. SET ANSI_NULLS ON
  2900. GO
  2901. SET QUOTED_IDENTIFIER ON
  2902. GO
  2903. --#####################################################
  2904. --创建时间:2014.10.28
  2905. --创建人:Nick
  2906. --说明:获取校园宣讲会数据
  2907. --#####################################################
  2908. CREATE PROCEDURE [dbo].[ProcCampusPresentationSelect]
  2909. @ProvinceID INT
  2910. AS
  2911. BEGIN TRY
  2912. SELECT TOP 8 a.ID,b.id SchoolID,b.dcRegionID, c.ID CompanyID, Replace(d.Description,'市','')
  2913. RegionName, b.SchoolName, a.Address, c.CompanyName, BeginTime, EndTime, b.Homepage
  2914. FROM marketdb..CampusPresentation a WITH(NOLOCK),
  2915. marketdb..CampusSchool b WITH(NOLOCK),
  2916. marketdb..CampusCompany c WITH(NOLOCK),
  2917. dcRegion d WITH(NOLOCK)
  2918. WHERE a.CompanyID = c.id
  2919. AND a.SchoolID = b.ID
  2920. AND b.dcRegionID = d.id
  2921. AND EndTime>GETDATE()
  2922. ORDER BY CASE CHARINDEX(CONVERT(VARCHAR(10),@ProvinceID),b.dcRegionID)
  2923. WHEN 1 THEN 1 ELSE 2 END ,
  2924. a.BeginTime, a.AddDate DESC
  2925. END TRY
  2926. BEGIN CATCH
  2927. RETURN 0
  2928. END CATCH
  2929. GO
  2930. /****** Object: StoredProcedure [dbo].[ProcCampusRecruitmentListSelect] Script Date: 2018/12/13 19:09:47 ******/
  2931. SET ANSI_NULLS ON
  2932. GO
  2933. SET QUOTED_IDENTIFIER ON
  2934. GO
  2935. --#####################################################
  2936. --创建时间:2014.10.29
  2937. --创建人:Nick
  2938. --说明:获取学校的校园招聘会
  2939. --#####################################################
  2940. CREATE PROCEDURE [dbo].[ProcCampusRecruitmentListSelect]
  2941. (
  2942. @CampusID INT,
  2943. @PaMainID INT
  2944. )
  2945. AS
  2946. --INSERT INTO procLog SELECT 'ProcCampusRecruitmentListSelect', @PaMAinId, GETDATE()
  2947. BEGIN TRY
  2948. SELECT TOP 500 a.ID, a.RecruitmentName,a.BeginDate,a.EndDate,a.CityID,a.RecruitmentPlaceId , a.CanBook, b.PlaceName ,
  2949. (
  2950. SELECT COUNT(*) FROM marketdb..rmplacephoto m WITH(NOLOCK) ,marketdb..rmmyplace n WITH(NOLOCK)
  2951. WHERE m.rmmyplaceid=n.id
  2952. AND n.rmdeptid=a.RecruitmentDeptID
  2953. AND n.rmplaceid=a.RecruitmentPlaceId
  2954. ) AS photoCount ,
  2955. (
  2956. SELECT c.AddDate
  2957. FROM Marketdb..RmPerson c WITH(NOLOCK)
  2958. WHERE c.RecruitmentID=a.id and c.paMainID = @PaMainID
  2959. ) AS AddDate
  2960. FROM recruitment a WITH(NOLOCK) , recruitmentPlace b WITH(NOLOCK)
  2961. WHERE b.id= a.RecruitmentPlaceId
  2962. AND a.BeginDate > DATEADD(YEAR,-1,GETDATE())
  2963. AND b.CampusSchoolID = @CampusID
  2964. order by a.BeginDate DESC
  2965. END TRY
  2966. BEGIN CATCH
  2967. RETURN 0
  2968. END CATCH
  2969. GO
  2970. /****** Object: StoredProcedure [dbo].[ProcCampusSchoolBydcRegionIDSelect] Script Date: 2018/12/13 19:09:48 ******/
  2971. SET ANSI_NULLS ON
  2972. GO
  2973. SET QUOTED_IDENTIFIER ON
  2974. GO
  2975. --#####################################################
  2976. --创建时间:2014.10.28
  2977. --创建人:Nick
  2978. --说明:根据regionID 获取学校信息
  2979. --#####################################################
  2980. CREATE PROCEDURE [dbo].[ProcCampusSchoolBydcRegionIDSelect]
  2981. (
  2982. @RegionID INT
  2983. )
  2984. AS
  2985. BEGIN
  2986. SELECT *
  2987. FROM MarketDb..CampusSchool
  2988. WHERE dcRegionID LIKE CONVERT(VARCHAR(10), @RegionID) + '%'
  2989. AND EXISTS(SELECT 'X' FROM CampusListTmp WHERE SchoolID = MarketDb..CampusSchool.ID)
  2990. ORDER BY OrderBy
  2991. END
  2992. GO
  2993. /****** Object: StoredProcedure [dbo].[ProcCampusSchoolByIDSelect] Script Date: 2018/12/13 19:09:48 ******/
  2994. SET ANSI_NULLS ON
  2995. GO
  2996. SET QUOTED_IDENTIFIER ON
  2997. GO
  2998. --#####################################################
  2999. --创建时间:2014.10.29
  3000. --创建人:Nick
  3001. --说明:返回学校信息
  3002. --#####################################################
  3003. CREATE PROCEDURE [dbo].[ProcCampusSchoolByIDSelect]
  3004. (
  3005. @campusID INT
  3006. )
  3007. AS
  3008. BEGIN TRY
  3009. SELECT TOP 1 *
  3010. FROM MarketDB..CampusSchool WITH(NOLOCK)
  3011. WHERE ID=@campusID
  3012. END TRY
  3013. BEGIN CATCH
  3014. RETURN 0
  3015. END CATCH
  3016. GO
  3017. /****** Object: StoredProcedure [dbo].[ProcCampusSchoolPartner12Select] Script Date: 2018/12/13 19:09:48 ******/
  3018. SET ANSI_NULLS ON
  3019. GO
  3020. SET QUOTED_IDENTIFIER ON
  3021. GO
  3022. --#####################################################
  3023. --创建时间:2014.10.29 --创建人:Nick
  3024. --说明:获取前12条合作院校
  3025. --sean update 2015-3-19
  3026. --#####################################################
  3027. CREATE PROCEDURE [dbo].[ProcCampusSchoolPartner12Select]
  3028. (
  3029. @ProvinceID INT
  3030. )
  3031. AS
  3032. BEGIN
  3033. IF @ProvinceID > 9999
  3034. SET @ProvinceID = LEFT(@ProvinceID, 4)
  3035. SELECT *
  3036. FROM SearchDb..CampusSchoolPartner12 WITH(NOLOCK)
  3037. WHERE dcProvinceID = @ProvinceID
  3038. ORDER BY RowNo
  3039. END
  3040. GO
  3041. /****** Object: StoredProcedure [dbo].[ProcCampusSchoolPartnerSelect] Script Date: 2018/12/13 19:09:48 ******/
  3042. SET ANSI_NULLS ON
  3043. GO
  3044. SET QUOTED_IDENTIFIER ON
  3045. GO
  3046. --#####################################################
  3047. --创建时间:2014.10.29
  3048. --创建人:Nick
  3049. --说明:获取合作院校
  3050. --#####################################################
  3051. CREATE PROCEDURE [dbo].[ProcCampusSchoolPartnerSelect]
  3052. (
  3053. @ProvinceID INT
  3054. )
  3055. AS
  3056. BEGIN TRY
  3057. SELECT a.*
  3058. FROM MarketDB..CampusSchool a WITH(NOLOCK)
  3059. WHERE EXISTS(
  3060. SELECT 'x'
  3061. FROM marketdb..CampusPresentation b WITH(NOLOCK)
  3062. WHERE SchoolID = a.id
  3063. ) AND dcRegionID LIKE ''+CONVERT(VARCHAR(4),@ProvinceID)+'%'
  3064. ORDER BY OrderBy, AddDate DESC
  3065. END TRY
  3066. BEGIN CATCH
  3067. RETURN 0
  3068. END CATCH
  3069. GO
  3070. /****** Object: StoredProcedure [dbo].[ProcCampusTalkByCompanyIDSelect] Script Date: 2018/12/13 19:09:48 ******/
  3071. SET ANSI_NULLS ON
  3072. GO
  3073. SET QUOTED_IDENTIFIER ON
  3074. GO
  3075. --#####################################################
  3076. --创建时间:2014.10.28
  3077. --创建人:Nick
  3078. --说明:获取企业校园宣讲会数据
  3079. --#####################################################
  3080. CREATE PROCEDURE [dbo].[ProcCampusTalkByCompanyIDSelect]
  3081. @CompanyID INT
  3082. AS
  3083. BEGIN TRY
  3084. select top 4 a.ID,b.dcRegionID, c.ID CompanyID, Replace(d.Description,'市','')
  3085. RegionName, b.SchoolName,a.schoolid, a.Address, c.CompanyName, BeginTime, EndTime, b.Homepage
  3086. FROM marketdb..CampusPresentation a WITH(NOLOCK),
  3087. marketdb..CampusSchool b WITH(NOLOCK),
  3088. marketdb..CampusCompany c WITH(NOLOCK),
  3089. dcRegion d WITH(NOLOCK)
  3090. WHERE a.CompanyID = c.id
  3091. AND a.SchoolID = b.ID
  3092. AND b.dcRegionID = d.id
  3093. AND a.CompanyID = @CompanyID
  3094. ORDER BY a.BeginTime DESC, a.AddDate
  3095. END TRY
  3096. BEGIN CATCH
  3097. RETURN 0
  3098. END CATCH
  3099. GO
  3100. /****** Object: StoredProcedure [dbo].[ProcCampusTalkByProvinceIDCompanyIDSelect] Script Date: 2018/12/13 19:09:49 ******/
  3101. SET ANSI_NULLS ON
  3102. GO
  3103. SET QUOTED_IDENTIFIER ON
  3104. GO
  3105. --#####################################################
  3106. --创建时间:2014.10.28
  3107. --创建人:Nick
  3108. --说明:通过省ID和公司ID获取该公司在页面所在省的校园宣讲会内容
  3109. --#####################################################
  3110. CREATE PROCEDURE [dbo].[ProcCampusTalkByProvinceIDCompanyIDSelect]
  3111. (
  3112. @ProvinceID INT,
  3113. @CompanyID INT
  3114. )
  3115. AS
  3116. SET NOCOUNT ON
  3117. BEGIN
  3118. SELECT TOP 8 ID, dcRegionID, CompanyID, RegionName, SchoolName, SchoolID, Address, CompanyName,
  3119. BeginTime, EndTime, Homepage
  3120. FROM SearchDb..cpPreachTmp WITH(NOLOCK)
  3121. WHERE dcProvinceId = @ProvinceID
  3122. ORDER BY RowNo
  3123. END
  3124. GO
  3125. /****** Object: StoredProcedure [dbo].[ProcCampusTalkByProvinceIDSelect] Script Date: 2018/12/13 19:09:49 ******/
  3126. SET ANSI_NULLS ON
  3127. GO
  3128. SET QUOTED_IDENTIFIER ON
  3129. GO
  3130. --#####################################################
  3131. --创建时间:2014.10.29
  3132. --创建人:Nick
  3133. --说明:取校园宣讲会数据
  3134. --#####################################################
  3135. CREATE PROCEDURE [dbo].[ProcCampusTalkByProvinceIDSelect]
  3136. (
  3137. @ProvinceID INT
  3138. )
  3139. AS
  3140. BEGIN
  3141. SELECT TOP 10 a.ID,b.id SchoolID,b.dcRegionID, c.ID CompanyID, Replace(d.Description,'市','')
  3142. RegionName, b.SchoolName, a.Address, c.CompanyName, BeginTime, EndTime, b.Homepage
  3143. FROM marketdb..CampusPresentation a WITH(NOLOCK),
  3144. marketdb..CampusSchool b WITH(NOLOCK),
  3145. marketdb..CampusCompany c WITH(NOLOCK),
  3146. dcRegion d WITH(NOLOCK)
  3147. WHERE a.CompanyID = c.id
  3148. AND a.SchoolID = b.ID
  3149. AND b.dcRegionID = d.id
  3150. AND EndTime > GETDATE()
  3151. ORDER BY CASE CHARINDEX(CONVERT(VARCHAR(4),@ProvinceID),b.dcRegionID) WHEN 1 THEN 1 ELSE 2 END ,
  3152. a.BeginTime, a.AddDate DESC
  3153. END
  3154. GO
  3155. /****** Object: StoredProcedure [dbo].[ProcCampusTalkInfoOneYearSelect] Script Date: 2018/12/13 19:09:49 ******/
  3156. SET ANSI_NULLS ON
  3157. GO
  3158. SET QUOTED_IDENTIFIER ON
  3159. GO
  3160. --#####################################################
  3161. --创建时间:2014.10.29
  3162. --创建人:Nick
  3163. --说明:获取校园宣讲会信息 一年之内
  3164. --#####################################################
  3165. CREATE PROCEDURE [dbo].[ProcCampusTalkInfoOneYearSelect]
  3166. (
  3167. @RegionID INT,
  3168. @SchoolID INT,
  3169. @ProvinceID INT
  3170. )
  3171. AS
  3172. --INSERT INTO procLog SELECT 'ProcCampusTalkInfoOneYearSelect', @Regionid, GETDATE()
  3173. BEGIN
  3174. DECLARE @SQL VARCHAR(2000)
  3175. SET @SQL = 'SELECT * FROM (SELECT '
  3176. IF(@RegionID>0)
  3177. BEGIN
  3178. SET @SQL = @SQL + ' ROW_NUMBER() OVER(ORDER BY CASE CHARINDEX('''+CONVERT(VARCHAR(10),@RegionID)+''',b.dcRegionID) when 1 then 1 else 2 end ,case
  3179. b.dcRegionID when '''+CONVERT(VARCHAR(10),@RegionID)+''' then 1 else 2 end, BeginTime) as tline,'
  3180. END
  3181. ELSE
  3182. BEGIN
  3183. SET @SQL = @SQL +' ROW_NUMBER() OVER(ORDER BY CASE CHARINDEX('''+CONVERT(VARCHAR(10),@ProvinceID)+''',b.dcRegionID) when 1 then 1 else 2 end ,
  3184. BeginTime) as tline,'
  3185. END
  3186. SET @SQL = @SQL +' b.Homepage,b.dcRegionID, a.CompanyID, d.Description RegionName,b.id SchoolID, b.SchoolName, a.Address, c.CompanyName, BeginTime, EndTime '
  3187. SET @SQL = @SQL +' FROM marketdb..CampusPresentation a WITH(NOLOCK),'
  3188. SET @SQL = @SQL +' marketdb..CampusSchool b WITH(NOLOCK),'
  3189. SET @SQL = @SQL +' marketdb..CampusCompany c WITH(NOLOCK),'
  3190. SET @SQL = @SQL +' dcRegion d WITH(NOLOCK) '
  3191. SET @SQL = @SQL +' WHERE EndTime>getdate() AND a.CompanyID = c.id AND a.SchoolID = b.ID AND b.dcRegionID = d.id'
  3192. IF @SchoolID>0
  3193. BEGIN
  3194. SET @SQL = @SQL+' AND (b.ID = ' + CONVERT(VARCHAR(10),@SchoolID)+')'
  3195. END
  3196. IF (@RegionID>0)
  3197. BEGIN
  3198. SET @SQL = @SQL+ ' AND b.dcRegionID like '''+CONVERT(VARCHAR(10),@RegionID)+'%'''
  3199. END
  3200. SET @SQL = @SQL+ ') as t1 union '
  3201. SET @SQL = @SQL+ 'SELECT 999 as tline,b.Homepage,b.dcRegionID, a.CompanyID, d.Description RegionName,b.id SchoolID, b.SchoolName, a.Address, c.CompanyName,
  3202. BeginTime, EndTime '
  3203. SET @SQL = @SQL +' FROM marketdb..CampusPresentation a WITH(NOLOCK),'
  3204. SET @SQL = @SQL +' marketdb..CampusSchool b WITH(NOLOCK),'
  3205. SET @SQL = @SQL +' marketdb..CampusCompany c with(NOLOCK),'
  3206. SET @SQL = @SQL +' dcRegion d WITH(NOLOCK) '
  3207. SET @SQL = @SQL +' WHERE EndTime<getdate() AND BeginTime>'''+CONVERT(VARCHAR(20),DATEADD(YEAR,-1,GETDATE())) +''' AND a.CompanyID = c.id AND a.SchoolID = b.ID AND b.dcRegionID = d.id'
  3208. IF @SchoolID>0
  3209. BEGIN
  3210. SET @SQL = @SQL+' AND (b.ID = '+CONVERT(VARCHAR(10),@SchoolID)+')'
  3211. END
  3212. SET @SQL = @SQL + ' ORDER BY tline,BeginTime desc'
  3213. PRINT(@SQL)
  3214. EXEC(@SQL)
  3215. END
  3216. GO
  3217. /****** Object: StoredProcedure [dbo].[ProcCampusTalkInfoSelect] Script Date: 2018/12/13 19:09:49 ******/
  3218. SET ANSI_NULLS ON
  3219. GO
  3220. SET QUOTED_IDENTIFIER ON
  3221. GO
  3222. --#####################################################
  3223. --创建时间:2014.10.29
  3224. --创建人:Nick
  3225. --说明:获取校园宣讲会信息
  3226. --修改:默认优先显示本省的(按照举办时间正序显示),后面是邻近四个省份的(按照举办时间正序显示),再后面是其他省(按照举办时间正序显示),最后就是本省过期的(按举办时间倒叙显示)
  3227. --修改人:Lucifer 2014.12.1
  3228. --#####################################################
  3229. CREATE PROCEDURE [dbo].[ProcCampusTalkInfoSelect]
  3230. (
  3231. @RegionID INT,
  3232. @SchoolID INT,
  3233. @PageNo INT
  3234. )
  3235. AS
  3236. --INSERT INTO procLog select 'ProcCampusTalkInfoSelect', LTRIM(STR(@RegionId)) + '|' + LTRIM(STR(@SchoolId)) + '|' + LTRIM(STR(@PageNo)), GETDATE()
  3237. BEGIN
  3238. IF ISNULL(@PageNo, 1) < 1
  3239. SET @PageNo = 1
  3240. DECLARE @t AS TABLE(
  3241. ID [int] IDENTITY(1, 1),
  3242. [Homepage] [varchar](200),
  3243. [dcRegionID] [int],
  3244. [CompanyID] [varchar](20),
  3245. [RegionName] [nvarchar](50),
  3246. [SchoolID] [int],
  3247. [SchoolName] [nvarchar](50),
  3248. [Address] [nvarchar](100),
  3249. [CompanyName] [nvarchar](50),
  3250. [BeginTime] [smalldatetime],
  3251. [EndTime] [smalldatetime],
  3252. PageNo INT,
  3253. AllNumber INT
  3254. )
  3255. IF @SchoolID > 0
  3256. BEGIN
  3257. INSERT @t(Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime)
  3258. SELECT Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime
  3259. FROM CampusListTmp WITH(NOLOCK)
  3260. WHERE SchoolId = @schoolId
  3261. AND EndTime > GETDATE()
  3262. ORDER BY BeginTime
  3263. INSERT @t(Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime)
  3264. SELECT Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime
  3265. FROM CampusListTmp WITH(NOLOCK)
  3266. WHERE SchoolId = @schoolId
  3267. AND EndTime < GETDATE()
  3268. ORDER BY BeginTime DESC
  3269. UPDATE @t SET PageNo = (ID - 1) / 20 + 1
  3270. UPDATE @t SET AllNumber = (SELECT COUNT(*) FROM @t)
  3271. SELECT * FROM @t WHERE PageNo = @PageNo ORDER BY ID
  3272. END
  3273. ELSE
  3274. BEGIN
  3275. IF NOT EXISTS(SELECT 'x' FROM ShortDb..campusRegionTmp WITH(NOLOCK) WHERE ProvinceId = @RegionId AND AddDate > DATEADD(MINUTE, -10, GETDATE()))
  3276. BEGIN
  3277. DELETE FROM ShortDb..campusRegionTmp WHERE ProvinceId = @RegionId
  3278. INSERT @t(Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime)
  3279. SELECT Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime
  3280. FROM CampusListTmp WITH(NOLOCK)
  3281. WHERE dcRegionID LIKE LTRIM(STR(@RegionID)) + '%'
  3282. AND EndTime > GETDATE()
  3283. ORDER BY CASE WHEN Companyid = 29247 THEN 0 ELSE 1 END, BeginTime
  3284. IF LEN(@RegionID) = 2
  3285. BEGIN
  3286. INSERT @t(Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime)
  3287. SELECT Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime
  3288. FROM CampusListTmp WITH(NOLOCK)
  3289. WHERE LEFT(dcRegionID,2) IN(SELECT NearProvinceID FROM dcProvinceNear WITH(NOLOCK) WHERE dcProvinceID = @RegionID)
  3290. AND EndTime > GETDATE()
  3291. ORDER BY CASE WHEN Companyid = 29247 THEN 0 ELSE 1 END, BeginTime
  3292. INSERT @t(Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime)
  3293. SELECT Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime
  3294. FROM CampusListTmp WITH(NOLOCK)
  3295. WHERE LEFT(dcRegionID,2) NOT IN(SELECT NearProvinceID FROM dcProvinceNear WITH(NOLOCK) WHERE dcProvinceID = @RegionID)
  3296. AND LEFT(dcRegionID, 2) <> @RegionID
  3297. AND EndTime > GETDATE()
  3298. ORDER BY CASE WHEN Companyid = 29247 THEN 0 ELSE 1 END, BeginTime
  3299. END
  3300. INSERT @t(Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime)
  3301. SELECT Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime
  3302. FROM CampusListTmp WITH(NOLOCK)
  3303. WHERE dcRegionID LIKE LTRIM(STR(@RegionID)) + '%'
  3304. AND EndTime < GETDATE()
  3305. ORDER BY BeginTime DESC
  3306. UPDATE @t SET PageNo = (ID - 1) / 20 + 1
  3307. UPDATE @t SET AllNumber = (SELECT COUNT(*) FROM @t)
  3308. INSERT INTO ShortDb..campusRegionTmp(Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime, ProvinceId, RowId, PageNo, AllNumber, AddDate)
  3309. SELECT Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime, @RegionID, Id, PageNo, AllNumber, GETDATE() FROM @t
  3310. END
  3311. SELECT * FROM ShortDb..campusRegionTmp WITH(NOLOCK)
  3312. WHERE ProvinceId = @RegionId
  3313. AND PageNo = @PageNo
  3314. ORDER BY RowID
  3315. END
  3316. END
  3317. GO
  3318. /****** Object: StoredProcedure [dbo].[ProcCampusTalkNewByProvinceIDCompanyIDSelect] Script Date: 2018/12/13 19:09:50 ******/
  3319. SET ANSI_NULLS ON
  3320. GO
  3321. SET QUOTED_IDENTIFIER ON
  3322. GO
  3323. --#####################################################
  3324. --创建时间:2014.10.28
  3325. --创建人:Nick
  3326. --说明:通过省ID和公司ID获取该公司在页面所在省的校园宣讲会内容
  3327. --#####################################################
  3328. CREATE PROCEDURE [dbo].[ProcCampusTalkNewByProvinceIDCompanyIDSelect]
  3329. (
  3330. @ProvinceID INT,
  3331. @CompanyID INT
  3332. )
  3333. AS
  3334. BEGIN TRY
  3335. SELECT TOP 8 b.dcRegionID, c.ID CompanyID, REPLACE(d.Description,'市','')
  3336. RegionName, b.SchoolName, a.Address, c.CompanyName,b.ID SchoolID, BeginTime, EndTime, b.Homepage
  3337. FROM marketdb..CampusPresentation a WITH(NOLOCK),
  3338. marketdb..CampusSchool b WITH(NOLOCK),
  3339. marketdb..CampusCompany c WITH(NOLOCK),
  3340. dcRegion d WITH(NOLOCK)
  3341. WHERE a.CompanyID = c.id
  3342. AND a.SchoolID = b.ID
  3343. AND b.dcRegionID = d.id
  3344. AND c.ID = @CompanyID
  3345. ORDER BY a.BeginTime, a.AddDate DESC
  3346. END TRY
  3347. BEGIN CATCH
  3348. RETURN 0
  3349. END CATCH
  3350. GO
  3351. /****** Object: StoredProcedure [dbo].[ProcCampusTopBannerSelect] Script Date: 2018/12/13 19:09:50 ******/
  3352. SET ANSI_NULLS ON
  3353. GO
  3354. SET QUOTED_IDENTIFIER ON
  3355. GO
  3356. --#####################################################
  3357. --创建时间:2014.10.29
  3358. --创建人:Nick
  3359. --说明:新版校园招聘 图片列表
  3360. --#####################################################
  3361. CREATE PROCEDURE [dbo].[ProcCampusTopBannerSelect]
  3362. (
  3363. @ProvinceID INT,
  3364. @TypeID INT
  3365. )
  3366. AS
  3367. BEGIN TRY
  3368. DECLARE @SQL VARCHAR(1000)
  3369. SET @SQL = 'SELECT '
  3370. IF @TypeID = 26
  3371. BEGIN
  3372. SET @SQL = @SQL + ' TOP 3 '
  3373. END
  3374. ELSE IF @TypeID = 27
  3375. BEGIN
  3376. SET @SQL = @SQL + ' TOP 6 '
  3377. END
  3378. SET @SQL = @SQL + ' * FROM AdverProject WITH(NOLOCK) '
  3379. SET @SQL = @SQL + ' WHERE Valid=''1'' AND BeginTime < GETDATE() '
  3380. SET @SQL = @SQL + ' AND EndTime > GETDATE() AND Province_Id = ' + CONVERT(VARCHAR(4),@ProvinceID)
  3381. SET @SQL = @SQL + ' AND Type = ' + CONVERT(VARCHAR(4),@TypeID)
  3382. SET @SQL = @SQL + ' ORDER BY OrderBy ASC'
  3383. print (@SQL)
  3384. EXEC(@SQL)
  3385. END TRY
  3386. BEGIN CATCH
  3387. RETURN 0
  3388. END CATCH
  3389. GO
  3390. /****** Object: StoredProcedure [dbo].[ProcCaOnlineBycaMainIdUpdate] Script Date: 2018/12/13 19:09:51 ******/
  3391. SET ANSI_NULLS ON
  3392. GO
  3393. SET QUOTED_IDENTIFIER ON
  3394. GO
  3395. CREATE PROCEDURE [dbo].[ProcCaOnlineBycaMainIdUpdate]
  3396. (
  3397. @caMainID INT,
  3398. @Status VARCHAR(5)
  3399. )
  3400. AS
  3401. BEGIN
  3402. DELETE FROM caOnline WHERE caMainID = @caMainID
  3403. IF @Status = '1'
  3404. INSERT INTO caOnline VALUES(@caMainID, 1, 0, NULL, NULL, GETDATE())
  3405. END
  3406. GO
  3407. /****** Object: StoredProcedure [dbo].[ProcCaOnlineStatusUpdate] Script Date: 2018/12/13 19:09:51 ******/
  3408. SET ANSI_NULLS ON
  3409. GO
  3410. SET QUOTED_IDENTIFIER ON
  3411. GO
  3412. CREATE PROCEDURE [dbo].[ProcCaOnlineStatusUpdate]
  3413. (
  3414. @caMainIDs VARCHAR(MAX)
  3415. )
  3416. AS
  3417. BEGIN
  3418. SELECT a ID INTO #t FROM dbo.fnSplit(@caMainIDs,',')
  3419. UPDATE CaOnline SET IsOnline=1, RefreshDate=GETDATE() WHERE caMainID IN(SELECT ID FROM #t)
  3420. INSERT caOnline(caMainId, IsOnline, IsVi, RefreshDate)
  3421. SELECT Id, 1, 0, GETDATE() FROM #t WHERE ID NOT IN(SELECT caMainId FROM caOnline)
  3422. UPDATE caOnline SET IsOnline = 0 WHERE caMainID NOT IN(SELECT ID FROM #t)
  3423. END
  3424. GO
  3425. /****** Object: StoredProcedure [dbo].[ProcCaOnlineUpdate] Script Date: 2018/12/13 19:09:51 ******/
  3426. SET ANSI_NULLS ON
  3427. GO
  3428. SET QUOTED_IDENTIFIER ON
  3429. GO
  3430. CREATE PROCEDURE [dbo].[ProcCaOnlineUpdate]
  3431. AS
  3432. BEGIN
  3433. SELECT caMainId, MIN(Id) ID, MIN(InterviewDate) InterviewDate
  3434. INTO #t
  3435. FROM viPlan WHERE InterviewDate > GETDATE() AND IsCancel = 0
  3436. GROUP BY caMainId
  3437. UPDATE #t SET InterviewDate = (SELECT InterviewDate FROM viPlan WHERE ID= #t.Id)
  3438. UPDATE caOnline SET viPlanId = NULL, InterviewDate = NULL WHERE viPlanId > 0
  3439. INSERT caOnline(caMainId, IsOnline)
  3440. SELECT caMainId, 0 FROM #t WHERE caMainId NOT IN(SELECT caMainId FROM caOnline)
  3441. UPDATE a
  3442. SET a.viPlanId = b.Id,
  3443. a.InterviewDate = b.InterviewDate
  3444. FROM caOnline a, #t b
  3445. WHERE a.caMainId = b.caMainId
  3446. UPDATE caOnline SET IsVi = 0 WHERE caMainId NOT IN(SELECT caMainId FROM viRoom WHERE EndDate IS NULL) AND IsVi = 1
  3447. UPDATE caOnline SET IsVi = 1 WHERE caMainId IN(SELECT caMainId FROM viRoom WHERE EndDate IS NULL)
  3448. UPDATE caOnline SET isOnline = 0 WHERE RefreshDate < DATEADD(MINUTE,-2, GETDATE())
  3449. DELETE caOnline WHERE RefreshDate < DATEADD(MINUTE, -7, GETDATE()) AND IsVi = 0 AND ViPlanId IS NULL
  3450. UPDATE paOnline SET isOnline = 0 WHERE RefreshDate < DATEADD(MINUTE,-2, GETDATE())
  3451. DELETE paOnline WHERE RefreshDate < DATEADD(MINUTE, -7, GETDATE())
  3452. END
  3453. GO
  3454. /****** Object: StoredProcedure [dbo].[procCaorderByBalanceUpdate] Script Date: 2018/12/13 19:09:51 ******/
  3455. SET ANSI_NULLS ON
  3456. GO
  3457. SET QUOTED_IDENTIFIER ON
  3458. GO
  3459. --###################################################3
  3460. --2011-9-1 sean 用于知名企业招聘 点击数 balance=clickcount
  3461. --###################################################3
  3462. CREATE PROCEDURE [dbo].[procCaorderByBalanceUpdate]
  3463. (
  3464. @Id INT,
  3465. @CompanyID INT,
  3466. @JobId INT
  3467. )
  3468. AS
  3469. BEGIN
  3470. SELECT @CompanyID = ISNULL(@CompanyID, 0), @JobId = ISNULL(@JobId, 0)
  3471. IF @CompanyID = 0 AND @JobID = 0
  3472. RETURN
  3473. IF @CompanyID = 0 AND @JobID > 0
  3474. SELECT @CompanyID = cpMainID FROM Job WITH(NOLOCK) WHERE ID = @JobID
  3475. IF @CompanyID > 0
  3476. UPDATE caOrder SET Balance = ISNULL(Balance, 0) + 1
  3477. WHERE ID = @ID
  3478. AND cpMainId = @CompanyID
  3479. AND OrderType = 7
  3480. END
  3481. GO
  3482. /****** Object: StoredProcedure [dbo].[procCaPageViewLogUpdate] Script Date: 2018/12/13 19:09:52 ******/
  3483. SET ANSI_NULLS ON
  3484. GO
  3485. SET QUOTED_IDENTIFIER ON
  3486. GO
  3487. CREATE PROCEDURE [dbo].[procCaPageViewLogUpdate]
  3488. (
  3489. @caMainID INT,
  3490. @ViewPageType TINYINT --1.应聘的简历 2.推荐的简历,3.面试通知答复 4.聊天
  3491. )
  3492. AS
  3493. SET NOCOUNT ON
  3494. BEGIN
  3495. IF NOT EXISTS(SELECT 'x' FROM caPageViewLog WITH(NOLOCK) WHERE caMainId = @caMainID)
  3496. BEGIN
  3497. INSERT INTO caPageViewLog(caMainId,addDate,ApplyCvDate,RecommendCvDate,InterviewReplyDate)
  3498. VALUES(@caMainID, DATEADD(MINUTE, -10, GETDATE()), DATEADD(MINUTE, -10, GETDATE()), DATEADD(MINUTE, -10, GETDATE()), DATEADD(MINUTE, -10, GETDATE()))
  3499. RETURN
  3500. END
  3501. IF @ViewPageType = 1
  3502. UPDATE caPageViewLog SET ApplyCvDate = GETDATE(), ApplyCvCount = 0 WHERE caMainId = @caMainID
  3503. IF @ViewPageType = 2
  3504. UPDATE caPageViewLog SET RecommendCvDate = GETDATE(), RecommendCvCount = 0 WHERE caMainId = @caMainID
  3505. IF @ViewPageType = 3
  3506. UPDATE caPageViewLog SET InterviewReplyDate = GETDATE(), InterviewReplyCount = 0 WHERE caMainId = @caMainID
  3507. IF @ViewPageType = 4
  3508. UPDATE caPageViewLog SET ChatCount = 0 WHERE caMainId = @caMainID
  3509. END
  3510. GO
  3511. /****** Object: StoredProcedure [dbo].[ProcCaSMSWaitSelect] Script Date: 2018/12/13 19:09:52 ******/
  3512. SET ANSI_NULLS ON
  3513. GO
  3514. SET QUOTED_IDENTIFIER ON
  3515. GO
  3516. -----------------
  3517. --创建日期:2012-4-17
  3518. --创建人:lambo
  3519. --功能说明:企业汇总类短信发送。将marketdb..caSMSWait里的数据转入SmsMessageLog
  3520. -----------------
  3521. CREATE PROCEDURE [dbo].[ProcCaSMSWaitSelect]
  3522. AS
  3523. BEGIN TRY
  3524. IF oadb.dbo.IsWorkDate(getdate())<>1
  3525. RETURN
  3526. --删除今天已经登录过的企业的记录
  3527. If DATEPART(HOUR,GETDATE())*100 + DATEPART(MINUTE,GETDATE()) <= 905
  3528. DELETE FROM marketdb..cpSmsWait WHERE cpMainID IN(SELECT ID FROM cpMain WITH(NOLOCK) WHERE LastLoginDate > GETDATE() - 1)
  3529. ELSE
  3530. DELETE FROM marketdb..cpSmsWait WHERE cpMainID IN(SELECT ID FROM cpMain WITH(NOLOCK) WHERE LastLoginDate > DATEADD(MINUTE, -10, GETDATE()))
  3531. SELECT TOP 20 * INTO #T FROM marketdb..cpSmsWait WHERE LastLoginTime < DATEPART(HOUR, GETDATE()) * 100 + DATEPART(MINUTE, GETDATE()) AND Msg > '' ORDER BY CASE WHEN SmsType > 16 THEN 0 ELSE 1 END, LastLoginTime
  3532. INSERT SmsMessageLog(SendMan, ManagerUSerId, paMainId, caMainId, Mobile, MsgType, IsCat, Msg)
  3533. SELECT 0, NULL, NULL, caMainID, Mobile, SmsType-1, 0,Msg FROM #T
  3534. DELETE FROM marketdb..cpSMSWait WHERE ID IN (select ID FROM #T)
  3535. END TRY
  3536. BEGIN CATCH
  3537. END CATCH
  3538. GO
  3539. /****** Object: StoredProcedure [dbo].[ProcCategoryIdByJobTypeIdSelect] Script Date: 2018/12/13 19:09:52 ******/
  3540. SET ANSI_NULLS ON
  3541. GO
  3542. SET QUOTED_IDENTIFIER ON
  3543. GO
  3544. --#####################################################
  3545. --创建时间:2014.11.4
  3546. --创建人:John
  3547. --说明:根据子类别获取上级职位类别
  3548. --#####################################################
  3549. CREATE PROCEDURE [dbo].[ProcCategoryIdByJobTypeIdSelect]
  3550. (
  3551. @JobTypeId INT
  3552. )
  3553. AS
  3554. BEGIN
  3555. SELECT CategoryId FROM dcJobTypeMap WITH(NOLOCK) WHERE JobTypeId = @JobTypeId
  3556. END
  3557. GO
  3558. /****** Object: StoredProcedure [dbo].[ProcChatOnlineByEndDateUpdate] Script Date: 2018/12/13 19:09:52 ******/
  3559. SET ANSI_NULLS ON
  3560. GO
  3561. SET QUOTED_IDENTIFIER ON
  3562. GO
  3563. CREATE PROCEDURE [dbo].[ProcChatOnlineByEndDateUpdate]
  3564. (
  3565. @EndType TINYINT,
  3566. @Evaluate TINYINT,
  3567. @cvMainID INT,
  3568. @caMainID INT,
  3569. @ManageruserID SMALLINT
  3570. )
  3571. AS
  3572. --INSERT INTO procLog SELECT 'ProcChatOnlineByEndDateUpdate', @caMainID, GETDATE()
  3573. BEGIN
  3574. IF @ManageruserID > 0 AND @caMainID > 0 AND @Evaluate > 0
  3575. BEGIN
  3576. DECLARE @Evaluation NVARCHAR(10)
  3577. IF @Evaluate = 1
  3578. SET @Evaluation = '满意'
  3579. ELSE IF @Evaluate = 2
  3580. SET @Evaluation = '一般'
  3581. ELSE IF @Evaluate = 3
  3582. SET @Evaluation = '不满意'
  3583. INSERT INTO RtxNotifyLog (Receiver, RtxTitle, RtxMessage, SendType, ShowType, DelayTime)
  3584. VALUES(@ManageruserID, '在线客服评价', '有企业对您的在线客服服务做出了评价,“' + @Evaluation + '”', 1, 0, 0)
  3585. END
  3586. IF EXISTS(SELECT 'X' FROM ChatOnline WHERE cvMainID = @cvMainID
  3587. AND caMainID = @caMainID
  3588. AND ManageruserID = @ManageruserID
  3589. AND EndDate IS NULL)
  3590. BEGIN
  3591. UPDATE ChatOnline SET EndDate = GETDATE(),EndType = @EndType,Evaluate = @Evaluate
  3592. WHERE cvMainID = @cvMainID
  3593. AND caMainID = @caMainID
  3594. AND ManageruserID = @ManageruserID
  3595. AND EndDate IS NULL
  3596. IF @cvMainID > 0
  3597. BEGIN
  3598. DECLARE @paMainID INT
  3599. SELECT @paMainID = paMainID FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
  3600. IF NOT EXISTS(SELECT 'X' FROM ChatOnlineExchange WHERE UserID = @paMainID AND UserType = 0)
  3601. INSERT INTO ChatOnlineExchange VALUES(@paMainID,0)
  3602. END
  3603. IF @caMainID > 0
  3604. BEGIN
  3605. IF NOT EXISTS(SELECT 'X' FROM ChatOnlineExchange WHERE UserID = @caMainID AND UserType = 1)
  3606. INSERT INTO ChatOnlineExchange VALUES(@caMainID,1)
  3607. END
  3608. IF @ManageruserID > 0
  3609. BEGIN
  3610. IF NOT EXISTS(SELECT 'X' FROM ChatOnlineExchange WHERE UserID = @ManageruserID AND UserType = 3)
  3611. INSERT INTO ChatOnlineExchange VALUES(@ManageruserID,3)
  3612. END
  3613. END
  3614. ELSE
  3615. BEGIN
  3616. UPDATE ChatOnline SET EndType = 0,Evaluate = @Evaluate
  3617. WHERE ID IN
  3618. (
  3619. SELECT TOP 1 ID FROM ChatOnline WHERE cvMainID = @cvMainID
  3620. AND caMainID = @caMainID
  3621. AND ManageruserID = @ManageruserID
  3622. ORDER BY EndDate DESC
  3623. )
  3624. END
  3625. END
  3626. GO
  3627. /****** Object: StoredProcedure [dbo].[ProcChatOnLineByManagerUserIDNoEndSelect] Script Date: 2018/12/13 19:09:53 ******/
  3628. SET ANSI_NULLS ON
  3629. GO
  3630. SET QUOTED_IDENTIFIER ON
  3631. GO
  3632. --Andy.Yin 2014-06-26
  3633. --获取客服的15日内联系人列表,或者曾经有留言的的联系人
  3634. -------------------------------
  3635. CREATE PROCEDURE [dbo].[ProcChatOnLineByManagerUserIDNoEndSelect]
  3636. (
  3637. @UserID INT --客服的ID
  3638. )
  3639. AS
  3640. --INSERT INTO procLog SELECT 'ProcChatOnLineByManagerUserIDNoEndSelect', @UserID, GETDATE()
  3641. BEGIN
  3642. --首先获取联系人列表中的企业-------------------
  3643. CREATE TABLE #CpUserList
  3644. (
  3645. ChatOnlineID INT,
  3646. CaMainID INT,
  3647. CvMainID INT,
  3648. ManagerUserID INT,
  3649. LastChatDate SMALLDATETIME,
  3650. SumUnRead INT,
  3651. IsHidden BIT
  3652. )
  3653. --客服的联系人企业列表,有留言的
  3654. INSERT INTO #CpUserList
  3655. SELECT
  3656. MAX(a.ID),
  3657. a.CaMainID,
  3658. a.CvMainID,
  3659. a.ManagerUserID,
  3660. MAX(b.Adddate),
  3661. COUNT(1),
  3662. 0
  3663. FROM ChatOnline a, ChatOnlineLog b
  3664. WHERE a.id = b.ChatOnlineID
  3665. AND b.IsViewed = 0
  3666. AND b.SenderType <> 3 --不是自己发送的
  3667. AND a.ManagerUserID = @UserID
  3668. GROUP BY a.CaMainID,a.CvMainID, a.ManagerUserID
  3669. --客服联系人企业列表,未结束的回话
  3670. INSERT INTO #CpUserList
  3671. SELECT
  3672. MAX(ID),
  3673. CaMainID,
  3674. CvMainID,
  3675. ManagerUserID,
  3676. (SELECT MAX(Adddate) FROM ChatOnlineLog WHERE ChatOnlineLog.ChatOnlineID IN(SELECT ID FROM ChatOnline a WHERE a.cvMainID = ChatOnline.cvMainID AND a.caMainID = ChatOnline.caMainID)),
  3677. 0,
  3678. 0
  3679. FROM ChatOnline
  3680. WHERE ManagerUserID = @UserID
  3681. AND EndDate IS NULL
  3682. AND NOT EXISTS(SELECT 'X' FROM #CpUserList b WHERE b.cvMainID = ChatOnline.cvMainID AND b.caMainID = ChatOnline.caMainID)
  3683. GROUP BY CaMainID,CvMainID, ManagerUserID
  3684. --最终联系人中企业列表
  3685. SELECT
  3686. a.*,
  3687. b.Name CpName,
  3688. b.SecondID,
  3689. c.Name UserName,
  3690. c.cpMainID,
  3691. dbo.GetCaOnlineStatus(a.caMainID) IsOnline
  3692. FROM #CpUserList a, cpMain b, caMain c
  3693. WHERE a.caMainID = c.ID
  3694. AND b.ID = c.cpMainID
  3695. ORDER BY a.LastChatDate DESC
  3696. DROP TABLE #CpUserList
  3697. ---------------首先获取联系人列表中的个人-------------------
  3698. CREATE TABLE #PaUserList
  3699. (
  3700. ChatOnlineID INT,
  3701. CaMainID INT,
  3702. CvMainID INT,
  3703. ManagerUserID INT,
  3704. LastChatDate SMALLDATETIME,
  3705. SumUnRead INT,
  3706. IsHidden BIT
  3707. )
  3708. --客服的联系人求职者列表,有留言的
  3709. INSERT INTO #PaUserList
  3710. SELECT
  3711. MAX(a.ID),
  3712. a.CaMainID,
  3713. a.CvMainID,
  3714. a.ManagerUserID,
  3715. MAX(b.Adddate),
  3716. COUNT(1),
  3717. 0
  3718. FROM ChatOnline a, ChatOnlineLog b
  3719. WHERE a.id = b.ChatOnlineID
  3720. AND b.IsViewed = 0
  3721. AND b.SenderType <> 3 --不是客服发送的
  3722. AND a.ManagerUserID = @UserID
  3723. GROUP BY a.CaMainID, a.CvMainID, A.ManagerUserID
  3724. --客服联系人求职者列表,未结束的回话
  3725. INSERT INTO #PaUserList
  3726. SELECT
  3727. MAX(ID),
  3728. CaMainID,
  3729. CvMainID,
  3730. ManagerUserID,
  3731. (SELECT MAX(Adddate) FROM ChatOnlineLog WHERE ChatOnlineLog.ChatOnlineID IN(SELECT ID FROM ChatOnline a WHERE a.cvMainID = ChatOnline.cvMainID AND a.caMainID = ChatOnline.caMainID)),
  3732. 0,
  3733. 0
  3734. FROM ChatOnline
  3735. WHERE ManagerUserID = @UserID
  3736. AND EndDate IS NULL
  3737. AND NOT EXISTS(SELECT 'X' FROM #PaUserList b WHERE b.cvMainID = ChatOnline.cvMainID AND b.caMainID = ChatOnline.caMainID)
  3738. GROUP BY CaMainID,CvMainID, ManagerUserID
  3739. --最终结果
  3740. SELECT
  3741. a.*,
  3742. b.Name PaName,
  3743. b.ID PaMainID,
  3744. c.Name UserName,
  3745. dbo.GetPaOnlineStatus(a.cvMainID) IsOnline
  3746. FROM #PaUserList a, PaMain b, cvMain c
  3747. WHERE a.cvMainID = c.ID
  3748. AND b.ID = c.paMainID
  3749. ORDER BY a.LastChatDate DESC
  3750. --检查数据库,把曾经已经结束但是还有unread的记录都设置为已读
  3751. UPDATE ChatOnlineLog
  3752. SET IsViewed=1
  3753. WHERE IsViewed=0 AND chatOnlineID IN (SELECT ID FROM ChatOnline where ManagerUserID=@UserID and EndDate is not null)
  3754. DROP TABLE #PaUserList
  3755. END
  3756. GO
  3757. /****** Object: StoredProcedure [dbo].[ProcChatOnlineByMoveDelete] Script Date: 2018/12/13 19:09:54 ******/
  3758. SET ANSI_NULLS ON
  3759. GO
  3760. SET QUOTED_IDENTIFIER ON
  3761. GO
  3762. CREATE PROCEDURE [dbo].[ProcChatOnlineByMoveDelete]
  3763. AS
  3764. BEGIN
  3765. select id into #t from chatonline where startdate < convert(varchar(10), getdate() - 366)
  3766. INSERT INTO LogDb..ChatOnline
  3767. select * FROM chatonline WHERE ID IN(SELECT ID FROM #t)
  3768. INSERT INTO LogDb..ChatOnlineLog
  3769. select * FROM ChatOnlineLog WHERE ChatOnlineId IN(SELECT ID FROM #t)
  3770. DELETE FROM chatonline WHERE ID IN(SELECT ID FROM #t)
  3771. END
  3772. GO
  3773. /****** Object: StoredProcedure [dbo].[procChatOnlineByRefreshDateUpdate] Script Date: 2018/12/13 19:09:54 ******/
  3774. SET ANSI_NULLS ON
  3775. GO
  3776. SET QUOTED_IDENTIFIER ON
  3777. GO
  3778. CREATE PROCEDURE [dbo].[procChatOnlineByRefreshDateUpdate]
  3779. (
  3780. @UserID INT,
  3781. @UserType TINYINT
  3782. )
  3783. AS
  3784. --INSERT INTO procLog SELECT 'procChatOnlineByRefreshDateUpdate', @UserID, GETDATE()
  3785. BEGIN
  3786. DELETE FROM ChatOnlineExchange WHERE UserID=@UserID AND UserType=@UserType
  3787. IF @UserType = 0
  3788. BEGIN
  3789. IF EXISTS(SELECT 'X' FROM paOnline WITH(NOLOCK) WHERE paMainID=@UserID)
  3790. UPDATE paOnline SET IsOnline=1,RefreshDate=GETDATE() WHERE paMainID=@UserID
  3791. ELSE
  3792. INSERT INTO paOnline (paMainID, IsOnline, RefreshDate) VALUES(@UserID, 1, GETDATE())
  3793. END
  3794. ELSE IF @UserType = 1
  3795. BEGIN
  3796. IF EXISTS(SELECT 'X' FROM caOnline WITH(NOLOCK) WHERE caMainID=@UserID)
  3797. UPDATE caOnline SET IsOnline=1,RefreshDate = GETDATE() WHERE caMainID=@UserID
  3798. ELSE
  3799. INSERT INTO caOnline (caMainID, IsOnline, IsVi, RefreshDate) VALUES(@UserID, 1, '0', GETDATE())
  3800. END
  3801. ELSE IF @UserType = 3
  3802. BEGIN
  3803. UPDATE Manageruser SET SOLStatus = 1,SOLTime = GETDATE() WHERE ID = @UserID
  3804. UPDATE a SET IsOnline = b.SOLStatus FROM ChatService a WITH(NOLOCK),Manageruser b WITH(NOLOCK) WHERE a.ManageruserID = b.ID
  3805. END
  3806. END
  3807. GO
  3808. /****** Object: StoredProcedure [dbo].[ProcChatOnlineExchangeSelect] Script Date: 2018/12/13 19:09:54 ******/
  3809. SET ANSI_NULLS ON
  3810. GO
  3811. SET QUOTED_IDENTIFIER ON
  3812. GO
  3813. CREATE PROCEDURE [dbo].[ProcChatOnlineExchangeSelect]
  3814. AS
  3815. --INSERT INTO procLog SELECT 'ProcChatOnlineExchangeSelect', '', GETDATE()
  3816. BEGIN
  3817. SELECT * FROM ChatOnlineExchange WITH(NOLOCK)
  3818. END
  3819. GO
  3820. /****** Object: StoredProcedure [dbo].[ProcChatOnlineLogByCaMainIDAndManageruserIDSelect] Script Date: 2018/12/13 19:09:54 ******/
  3821. SET ANSI_NULLS ON
  3822. GO
  3823. SET QUOTED_IDENTIFIER ON
  3824. GO
  3825. CREATE PROCEDURE [dbo].[ProcChatOnlineLogByCaMainIDAndManageruserIDSelect]
  3826. (
  3827. @caMainID INT,
  3828. @ManageruserID INT,
  3829. @userType TINYINT
  3830. )
  3831. AS
  3832. --INSERT INTO procLog SELECT 'ProcChatOnlineLogByCaMainIDAndManageruserIDSelect', @caMainID, GETDATE()
  3833. BEGIN
  3834. IF @userType = 1
  3835. UPDATE ChatOnlineLog SET IsViewed=1
  3836. WHERE SenderType = 3 AND ChatOnlineID IN(
  3837. SELECT ID FROM ChatOnline WHERE caMainID=@caMainID AND ManageruserID=@ManageruserID
  3838. )
  3839. ELSE
  3840. UPDATE ChatOnlineLog SET IsViewed=1
  3841. WHERE SenderType = 1 AND ChatOnlineID IN(
  3842. SELECT ID FROM ChatOnline WHERE caMainID=@caMainID AND ManageruserID=@ManageruserID
  3843. )
  3844. SELECT * FROM ChatOnlineLog
  3845. WHERE ChatOnlineID IN(
  3846. SELECT ID FROM ChatOnline WHERE caMainID=@caMainID AND ManageruserID=@ManageruserID
  3847. ) AND (
  3848. CheckResult=0 OR CheckResult IS NULL
  3849. ) ORDER BY AddDate
  3850. END
  3851. GO
  3852. /****** Object: StoredProcedure [dbo].[ProcChatOnlineLogByCvMainIDAndCaMainIDSelect] Script Date: 2018/12/13 19:09:54 ******/
  3853. SET ANSI_NULLS ON
  3854. GO
  3855. SET QUOTED_IDENTIFIER ON
  3856. GO
  3857. CREATE PROCEDURE [dbo].[ProcChatOnlineLogByCvMainIDAndCaMainIDSelect]
  3858. (
  3859. @cvMainID INT,
  3860. @caMainID INT,
  3861. @UserType TINYINT
  3862. )
  3863. AS
  3864. SET NOCOUNT ON
  3865. --INSERT INTO procLog SELECT 'ProcChatOnlineLogByCvMainIDAndCaMainIDSelect', LTRIM(STR(@cvMainID)) + ' ' + LTRIM(STR(@caMainID)) + ' ' + LTRIM(STR(@UserType)), GETDATE()
  3866. BEGIN
  3867. DECLARE @t AS TABLE(ID INT)
  3868. DECLARE @n1 INT, @N2 INT
  3869. INSERT INTO @t
  3870. SELECT ID
  3871. FROM ChatOnline WITH(NOLOCK INDEX(IX_ChatOnline_Complex))
  3872. WHERE cvMainID = @cvMainID
  3873. AND caMainID = @caMainID
  3874. --AND AddDate > DATEADD(MONTH, -2, GETDATE())
  3875. IF @@RowCount = 0
  3876. BEGIN
  3877. SELECT TOP 0 * FROM ChatOnlineLog WITH(NOLOCK)
  3878. RETURN
  3879. END
  3880. IF @UserType = 0
  3881. BEGIN
  3882. UPDATE ChatOnlineLog
  3883. SET IsViewed = 1
  3884. WHERE SenderType = 1
  3885. AND ChatOnlineID IN(SELECT ID FROM @t)
  3886. --AND AddDate > DATEADD(MONTH, -2, GETDATE())
  3887. AND IsViewed = 0
  3888. SET @n1 = @@ROWCOUNT
  3889. UPDATE ChatOnline
  3890. SET paUnViewed = 0
  3891. WHERE Id IN(SELECT ID FROM @t)
  3892. AND caUnViewed > 0
  3893. SET @n2 = @@ROWCOUNT
  3894. IF @n1 + @n2 > 0
  3895. DELETE SearchDb..ChatOnlineListLog WHERE caMainId = @caMainId
  3896. END
  3897. ELSE
  3898. BEGIN
  3899. UPDATE ChatOnlineLog
  3900. SET IsViewed = 1
  3901. WHERE SenderType = 2
  3902. AND ChatOnlineID IN(SELECT ID FROM ChatOnline WHERE cvMainID=@cvMainID AND caMainID=@caMainID)
  3903. --AND AddDate > DATEADD(MONTH, -2, GETDATE())
  3904. AND IsViewed = 0
  3905. SET @n1 = @@ROWCOUNT
  3906. UPDATE ChatOnline
  3907. SET caUnViewed = 0
  3908. WHERE Id IN(SELECT ID FROM ChatOnline WITH(NOLOCK) WHERE cvMainID=@cvMainID AND caMainID=@caMainID)
  3909. AND caUnViewed > 0
  3910. SET @n2 = @@ROWCOUNT
  3911. IF @n1 + @n2 > 0
  3912. DELETE SearchDb..ChatOnlineListLog WHERE caMainId = @caMainId
  3913. END
  3914. SELECT *
  3915. FROM ChatOnlineLog WITH(NOLOCK)
  3916. WHERE ChatOnlineID IN(SELECT ID FROM ChatOnline WITH(NOLOCK) WHERE cvMainID=@cvMainID AND caMainID=@caMainID)
  3917. AND (CheckResult=1 OR CheckResult IS NULL)
  3918. ORDER BY AddDate
  3919. END
  3920. GO
  3921. /****** Object: StoredProcedure [dbo].[ProcChatOnlineLogByCvMainIDAndManageruserIDSelect] Script Date: 2018/12/13 19:09:54 ******/
  3922. SET ANSI_NULLS ON
  3923. GO
  3924. SET QUOTED_IDENTIFIER ON
  3925. GO
  3926. CREATE PROCEDURE [dbo].[ProcChatOnlineLogByCvMainIDAndManageruserIDSelect]
  3927. (
  3928. @cvMainID INT,
  3929. @ManageruserID INT,
  3930. @userType TINYINT
  3931. )
  3932. AS
  3933. --INSERT INTO procLog SELECT 'ProcChatOnlineLogByCvMainIDAndManageruserIDSelect', @cvMainID, GETDATE()
  3934. BEGIN
  3935. IF @userType = 0
  3936. UPDATE ChatOnlineLog SET IsViewed=1
  3937. WHERE SenderType = 3 AND ChatOnlineID IN(
  3938. SELECT ID FROM ChatOnline WHERE cvMainID=@cvMainID AND ManageruserID=@ManageruserID
  3939. )
  3940. ELSE
  3941. UPDATE ChatOnlineLog SET IsViewed=1
  3942. WHERE SenderType = 2 AND ChatOnlineID IN(
  3943. SELECT ID FROM ChatOnline WHERE cvMainID=@cvMainID AND ManageruserID=@ManageruserID
  3944. )
  3945. SELECT * FROM ChatOnlineLog
  3946. WHERE ChatOnlineID IN(
  3947. SELECT ID FROM ChatOnline WHERE cvMainID=@cvMainID AND ManageruserID=@ManageruserID
  3948. ) AND (
  3949. CheckResult=0 OR CheckResult IS NULL
  3950. ) ORDER BY AddDate
  3951. END
  3952. GO
  3953. /****** Object: StoredProcedure [dbo].[ProcChatOnlineLogSave] Script Date: 2018/12/13 19:09:55 ******/
  3954. SET ANSI_NULLS ON
  3955. GO
  3956. SET QUOTED_IDENTIFIER ON
  3957. GO
  3958. --在线客服
  3959. --修改人:Andy
  3960. --修改内容:修改客服自己首次给某其发送消息时,自己也收到rtx提醒的bug
  3961. --修改时间:2015-3-20
  3962. --修改人:harry 2015-7-7
  3963. --修改:增加与陌生人发起聊天,增加积分
  3964. ---20160216 Lucifer 添加推送
  3965. ---20160411 Lucifer 添加企业微信提醒
  3966. --修改Harry2017-4-17 修改积分
  3967. --修改Harry2018-06-12 修改企业推送
  3968. CREATE PROCEDURE [dbo].[ProcChatOnlineLogSave]
  3969. (
  3970. @cvMainID INT,
  3971. @caMainID INT,
  3972. @ManageruserID INT,
  3973. @Message VARCHAR(MAX),
  3974. @UserType TINYINT,
  3975. @ClientType TINYINT
  3976. )
  3977. AS
  3978. SET NOCOUNT ON
  3979. DECLARE @cpMainID INT
  3980. IF ISNULL(@cvMainID,0) <> 0 AND ISNULL(@caMainID,0) <> 0 AND @UserType = 1
  3981. BEGIN
  3982. SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
  3983. IF dbo.GetChatPrivi(@cvMainID, @cpMainID) = 0
  3984. RETURN -1
  3985. END
  3986. ELSE
  3987. BEGIN
  3988. SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
  3989. END
  3990. BEGIN
  3991. DECLARE @ChatOnlineID INT, @IsNew INT, @Initiative TINYINT, @SenderType TINYINT,
  3992. @ChatToUserID INT, @ChatToUserType INT, @paMainID INT, @IsPaNew INT
  3993. SELECT @ChatOnlineID = 0, @IsNew = 0
  3994. IF @UserType = 0
  3995. SET @SenderType = 2
  3996. ELSE IF @UserType = 1
  3997. SET @SenderType = 1
  3998. ELSE
  3999. SET @SenderType = 3
  4000. IF ISNULL(@ManageruserID,0) = 0
  4001. BEGIN
  4002. SELECT @paMainID = paMainID FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
  4003. SELECT @ChatOnlineID = ID FROM ChatOnline WITH(NOLOCK)
  4004. WHERE cvMainID = @cvMainID AND caMainID = @caMainID AND EndDate IS NULL
  4005. IF @UserType = 0
  4006. BEGIN
  4007. SET @Initiative = 1
  4008. SET @ChatToUserID = @caMainID
  4009. SET @ChatToUserType = 1
  4010. END
  4011. ELSE
  4012. BEGIN
  4013. SET @Initiative = 2
  4014. SET @ChatToUserID = @paMainID
  4015. SET @ChatToUserType = 0
  4016. END
  4017. END
  4018. ELSE IF ISNULL(@caMainID,0) = 0
  4019. BEGIN
  4020. SELECT @ChatOnlineID = ID FROM ChatOnline WITH(NOLOCK)
  4021. WHERE cvMainID = @cvMainID AND ManageruserID = @ManageruserID AND EndDate IS NULL
  4022. SET @Initiative = 3
  4023. IF @UserType = 0
  4024. BEGIN
  4025. SET @ChatToUserID = @ManageruserID
  4026. SET @ChatToUserType = 3
  4027. END
  4028. ELSE
  4029. BEGIN
  4030. SELECT @paMainID = paMainID FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
  4031. SET @ChatToUserID = @paMainID
  4032. SET @ChatToUserType = 0
  4033. END
  4034. END
  4035. ELSE IF ISNULL(@cvMainID,0) = 0
  4036. BEGIN
  4037. SELECT @ChatOnlineID = ID FROM ChatOnline WITH(NOLOCK)
  4038. WHERE caMainID = @caMainID AND ManageruserID = @ManageruserID AND EndDate IS NULL
  4039. IF @UserType = 1
  4040. BEGIN
  4041. SET @Initiative = 4
  4042. SET @ChatToUserID = @ManageruserID
  4043. SET @ChatToUserType = 3
  4044. END
  4045. ELSE
  4046. BEGIN
  4047. SET @Initiative = 5
  4048. SET @ChatToUserID = @caMainID
  4049. SET @ChatToUserType = 1
  4050. END
  4051. END
  4052. IF @ChatOnlineID = 0
  4053. BEGIN
  4054. IF ISNULL(@cvMainID,0) = 0
  4055. UPDATE ChatService SET ChatCount = ChatCount + 1 WHERE ManageruserID = @ManageruserID
  4056. INSERT INTO ChatOnline(cvMainID,caMainID,ManagerUserID,Initiative,StartDate,AddDate,ClientType)
  4057. VALUES(@cvMainID,@caMainID,@ManagerUserID,@Initiative,GETDATE(),GETDATE(),@ClientType)
  4058. SET @ChatOnlineID = @@IDENTITY
  4059. IF ISNULL(@ManageruserID,0) <> 0
  4060. BEGIN
  4061. DECLARE @Status INT
  4062. DECLARE @Superior INT
  4063. SET @Status=(SELECT Status FROM Maindb..Manageruser WHERE Id=@ManageruserID)
  4064. IF(@Status=3)--如果为空岗,则将消息发给经理
  4065. BEGIN
  4066. SET @Superior = (SELECT Superior FROM Maindb..Manageruser WHERE Id=@ManageruserID)
  4067. INSERT INTO RtxNotifyLog(Receiver,RtxTitle,RtxMessage,SendType,DelayTime,ShowType)
  4068. VALUES(@Superior,'新在线客服消息',CONVERT(VARCHAR(10),@ManageruserID)+'号顾问有新的在线客服消息,请及时查看',1,0,0)
  4069. END
  4070. ELSE IF (@UserType <> 3)--不是客服自己发送的
  4071. INSERT INTO RtxNotifyLog(Receiver,RtxTitle,RtxMessage,SendType,DelayTime,ShowType)
  4072. VALUES(@ManageruserID,'新在线客服消息','您有新的在线客服消息,请及时查看',1,0,0)
  4073. END
  4074. ELSE
  4075. BEGIN
  4076. IF @UserType = 1
  4077. SET @IsNew = 1
  4078. IF @UserType = 0
  4079. SET @IsPaNew = 1
  4080. END
  4081. END
  4082. IF NOT EXISTS(SELECT 'X' FROM ChatOnlineExchange WHERE UserID = @ChatToUserID AND UserType = @ChatToUserType)
  4083. INSERT INTO ChatOnlineExchange VALUES(@ChatToUserID,@ChatToUserType)
  4084. DECLARE @ChatOnlineLogId INT
  4085. IF @UserType = 0
  4086. BEGIN
  4087. IF CHARINDEX('通讯录', @Message) > 0 OR CHARINDEX('名单', @Message) > 0
  4088. OR CHARINDEX('QQ群', UPPER(@Message)) > 0 OR CHARINDEX('招聘工作', @Message) > 0 OR CHARINDEX('近期招聘', @Message) > 0
  4089. SET @Message = @Message + '<br /><p class="ChatWarning">涉及公司重要信息请一定电话确认!发现可疑,请马上反馈。</p>'
  4090. END
  4091. INSERT INTO ChatOnlineLog(ChatOnlineID,SenderType,IsViewed,[Message],AddDate)
  4092. VALUES(@ChatOnlineID,@SenderType,0,@Message,GETDATE())
  4093. SET @ChatOnlineLogId = @@IDENTITY
  4094. --插入积分 Harry
  4095. --判断是否为初次聊天
  4096. IF @IsNew = 1
  4097. BEGIN
  4098. DECLARE @Count AS INT
  4099. SET @Count=0
  4100. SELECT @Count=Count(1) FROM ChatOnline
  4101. WHERE cvMainID=@cvMainID
  4102. AND caMainID=@caMainID
  4103. AND ID < @ChatOnlineId
  4104. IF @Count = 0 --从未聊过
  4105. BEGIN
  4106. DECLARE @TodayPoint AS INT
  4107. DECLARE @TodayID AS INT
  4108. SET @TodayPoint = 0
  4109. SET @TodayID = 0
  4110. SELECT TOP 1 @TodayPoint = ISNULL(Point,0), @TodayID = ISNULL(ID,0)
  4111. FROM cpPoint WITH(NOLOCK)
  4112. WHERE changeID = 6
  4113. AND LastModifyDate > CONVERT(VARCHAR(10), GETDATE(),120)
  4114. AND cpMainID = @cpMainID
  4115. SET @TodayPoint = @TodayPoint + 10
  4116. IF @TodayPoint <= 200
  4117. BEGIN
  4118. IF @TodayID = 0
  4119. INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@cpMainID,6,10,GETDATE())
  4120. ELSE
  4121. UPDATE cpPoint SET Point = @TodayPoint,LastModifyDate = GETDATE() WHERE ID = @TodayID
  4122. END
  4123. END
  4124. IF @paMainID > 0
  4125. INSERT INTO paPushLog(paMainID, PushMessage, PushType)
  4126. SELECT @paMainID, '亲,收到一条HR发送的消息!', 5 WHERE EXISTS(SELECT 'X' FROM paIOSBind WHERE paMainID = @paMainID)
  4127. END
  4128. IF @IsPaNew = 1
  4129. BEGIN
  4130. IF @paMainID > 0 AND @cpMainID > 0
  4131. BEGIN
  4132. INSERT wxMessageSend2(Templatetype, WxFansID, PaMainId, CvMainId, CpMainID, CaMainId, AddDate)
  4133. SELECT 17, b.ID, @paMainID, @cvMainID, @cpMainID, a.paMainID, GETDATE()
  4134. FROM paLoginContact a WITH(NOLOCK), wxFans b WITH(NOLOCK)
  4135. WHERE a.OpenID = b.OpenID AND a.ContactType = 101 AND a.paMainID = @caMainID
  4136. END
  4137. INSERT INTO paPushLog(paMainID, PushMessage, PushType)
  4138. SELECT @caMainID, '亲,收到一条求职者发送的消息!', 11 WHERE EXISTS(SELECT 'X' FROM caIOSBind WHERE caMainID = @caMainID)
  4139. END
  4140. --Harry
  4141. SET NOCOUNT OFF
  4142. RETURN @ChatOnlineLogId
  4143. END
  4144. GO
  4145. /****** Object: StoredProcedure [dbo].[ProcChatOnlineLogSave20170428] Script Date: 2018/12/13 19:09:55 ******/
  4146. SET ANSI_NULLS ON
  4147. GO
  4148. SET QUOTED_IDENTIFIER ON
  4149. GO
  4150. --@MessageType 1 文本 2 表情 3 图片 4 职位 5 面试通知 6 相关职位 7 相关简历
  4151. --@Initiative 1 个人主动 2 企业主动
  4152. --@SenderType 1 企业 2 个人
  4153. --Carl 2018-05-08 企业黑名单中的用户无法给该企业发消息
  4154. --修改harry 增加企业app提醒2018-6-11
  4155. --修改harry 发送图片时增加提醒2018-8-17
  4156. --修改harry 增加一些关键词增加提醒2018-9-21
  4157. -- 修改Sunshine2018-10-17Sunhsine注释rtx弹窗
  4158. CREATE PROCEDURE [dbo].[ProcChatOnlineLogSave20170428]
  4159. (
  4160. @cvMainID INT,
  4161. @caMainID INT,
  4162. @ManagerUserID INT,
  4163. @Message VARCHAR(MAX),
  4164. @MessageType TINYINT,
  4165. @SenderType TINYINT
  4166. )
  4167. AS
  4168. SET NOCOUNT ON
  4169. BEGIN
  4170. DECLARE @cpMainID INT, @paMainID INT, @ChatOnlineID INT
  4171. SET @ChatOnlineID = 0
  4172. SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
  4173. SELECT @paMainID = paMainID FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
  4174. IF @SenderType = 1 AND dbo.GetChatPrivi(@cvMainID, @cpMainID) = 0 --企业发起会话,检查是否有权限
  4175. RETURN -1
  4176. --新增的
  4177. IF EXISTS(SELECT 'X' FROM cpCvShield a WITH(NOLOCK) WHERE a.cpMainId=@cpMainID
  4178. AND EXISTS(SELECT 'X' FROM cvMain c WHERE c.paMainId = @paMainID AND a.cvMainId = c.Id))
  4179. RETURN -1
  4180. SELECT @ChatOnlineID = ID FROM ChatOnline WITH(NOLOCK)
  4181. WHERE cvMainID = @cvMainID AND caMainID = @caMainID AND ManagerUserID = @ManagerUserID
  4182. IF @ChatOnlineID = 0 --第一次聊
  4183. BEGIN
  4184. DECLARE @Initiative TINYINT
  4185. IF @SenderType = 1
  4186. SET @Initiative = 2
  4187. ELSE
  4188. SET @Initiative = 1
  4189. INSERT INTO ChatOnline(cvMainID, caMainID, ManagerUserID, Initiative, StartDate, AddDate)
  4190. VALUES(@cvMainID, @caMainID, @ManagerUserID, @Initiative, GETDATE(), GETDATE())
  4191. SET @ChatOnlineID = @@IDENTITY
  4192. IF @SenderType = 1
  4193. BEGIN
  4194. --如果是企业发起,添加积分
  4195. EXEC ccCpPointByChatOnlineInsert @caMainID
  4196. --IF @ManagerUserID > 0
  4197. INSERT INTO paPushLog(paMainID, PushMessage, PushType)
  4198. SELECT @paMainID, '亲,收到一条HR发送的消息!', 5 WHERE EXISTS(SELECT 'X' FROM paIOSBind WHERE paMainID = @paMainID)
  4199. END
  4200. IF @SenderType = 2
  4201. BEGIN
  4202. --如果是个人发起,企业添加微信消息提醒
  4203. INSERT wxMessageSend2(Templatetype, WxFansID, PaMainId, CvMainId, CpMainID, CaMainId, AddDate)
  4204. SELECT 17, b.ID, @paMainID, @cvMainID, @cpMainID, a.paMainID, GETDATE()
  4205. FROM paLoginContact a WITH(NOLOCK), wxFans b WITH(NOLOCK)
  4206. WHERE a.OpenID = b.OpenID AND a.ContactType = 101 AND a.paMainID = @caMainID
  4207. INSERT INTO paPushLog(paMainID, PushMessage, PushType)
  4208. SELECT @caMainID, '亲,收到一条求职者发送的消息!', 11 WHERE EXISTS(SELECT 'X' FROM caIOSBind WHERE caMainID = @caMainID)
  4209. END
  4210. END
  4211. IF @MessageType=1 AND @SenderType=2
  4212. BEGIN
  4213. IF CHARINDEX('最近招聘', @Message) > 0 OR CHARINDEX('招聘效果', @Message) > 0
  4214. OR CHARINDEX('招聘进展', UPPER(@Message)) > 0 OR CHARINDEX('人员名单', @Message) > 0
  4215. OR CHARINDEX('招聘', @Message) > 0 OR CHARINDEX('效果', @Message) > 0 OR CHARINDEX('进展', @Message) > 0
  4216. OR CHARINDEX('开展', @Message) > 0 OR CHARINDEX('进度', @Message) > 0 OR CHARINDEX('情况', @Message) > 0
  4217. OR CHARINDEX('事情', @Message) > 0 OR CHARINDEX('名单', @Message) > 0 OR CHARINDEX('工作', @Message) > 0
  4218. OR CHARINDEX('事情', @Message) > 0 OR CHARINDEX('重要', @Message) > 0 OR CHARINDEX('要事', @Message) > 0
  4219. OR CHARINDEX('有事', @Message) > 0 OR CHARINDEX('事情', @Message) > 0 OR CHARINDEX('急', @Message) > 0
  4220. OR CHARINDEX('安排', @Message) > 0 OR CHARINDEX('QQ', @Message) > 0 OR CHARINDEX('扣扣', @Message) > 0
  4221. OR CHARINDEX('抠抠', @Message) > 0 OR CHARINDEX('叩叩', @Message) > 0 OR CHARINDEX('蔻蔻', @Message) > 0
  4222. OR CHARINDEX('口口', @Message) > 0 OR CHARINDEX('微信', @Message) > 0 OR CHARINDEX('weixin', @Message) > 0
  4223. OR CHARINDEX('qiuqiu', @Message) > 0 OR CHARINDEX('面试', @Message) > 0 OR CHARINDEX('手机', @Message) > 0
  4224. OR CHARINDEX('qq', @Message) > 0 OR CHARINDEX('球球', @Message) > 0 OR CHARINDEX('求求', @Message) > 0
  4225. BEGIN
  4226. SET @Message = @Message + '<br /><p class="ChatWarning">涉及公司重要信息请一定电话确认!发现可疑,请马上反馈。</p>'
  4227. END
  4228. END
  4229. IF @MessageType = 5
  4230. BEGIN
  4231. SELECT TOP 1 @Message = ID FROM exInterview WITH(NOLOCK) WHERE cvMainID = @cvMainID ORDER BY ID DESC
  4232. END
  4233. IF LEN(@Message) = 0
  4234. RETURN -1
  4235. INSERT INTO ChatOnlineLog(ChatOnlineID, SenderType, IsViewed, [Message], MessageType, AddDate)
  4236. VALUES(@ChatOnlineID, @SenderType, 0, @Message, @MessageType, GETDATE())
  4237. DECLARE @LogId INT
  4238. SET @LogId = @@IDENTITY
  4239. --rtx提醒审核 最近招聘 招聘效果 招聘进展 人员名单 2018-10-17Sunhsine注释
  4240. --IF @MessageType=1 AND @SenderType=2
  4241. --BEGIN
  4242. --IF CHARINDEX('最近招聘', @Message) > 0 OR CHARINDEX('招聘效果', @Message) > 0
  4243. --OR CHARINDEX('招聘进展', UPPER(@Message)) > 0 OR CHARINDEX('人员名单', @Message) > 0
  4244. --OR CHARINDEX('招聘', @Message) > 0 OR CHARINDEX('效果', @Message) > 0 OR CHARINDEX('进展', @Message) > 0
  4245. --OR CHARINDEX('开展', @Message) > 0 OR CHARINDEX('进度', @Message) > 0 OR CHARINDEX('情况', @Message) > 0
  4246. --OR CHARINDEX('事情', @Message) > 0 OR CHARINDEX('名单', @Message) > 0 OR CHARINDEX('工作', @Message) > 0
  4247. --OR CHARINDEX('事情', @Message) > 0 OR CHARINDEX('重要', @Message) > 0 OR CHARINDEX('要事', @Message) > 0
  4248. --OR CHARINDEX('有事', @Message) > 0 OR CHARINDEX('事情', @Message) > 0 OR CHARINDEX('急', @Message) > 0
  4249. --OR CHARINDEX('安排', @Message) > 0 OR CHARINDEX('QQ', @Message) > 0 OR CHARINDEX('扣扣', @Message) > 0
  4250. --OR CHARINDEX('抠抠', @Message) > 0 OR CHARINDEX('叩叩', @Message) > 0 OR CHARINDEX('蔻蔻', @Message) > 0
  4251. --OR CHARINDEX('口口', @Message) > 0 OR CHARINDEX('微信', @Message) > 0 OR CHARINDEX('weixin', @Message) > 0
  4252. --OR CHARINDEX('qiuqiu', @Message) > 0 OR CHARINDEX('面试', @Message) > 0 OR CHARINDEX('手机', @Message) > 0
  4253. --OR CHARINDEX('qq', @Message) > 0 OR CHARINDEX('球球', @Message) > 0 OR CHARINDEX('求求', @Message) > 0
  4254. --BEGIN
  4255. --INSERT INTO RtxNotifyLog(Receiver, RtxTitle, RtxMessage, SendType, DelayTime, ShowType)
  4256. -- SELECT '155,180,216,222,223', '聊聊内容监控提醒','【公司id】'+CONVERT(CHAR(10),@cpMainID)+'【个人id】'+CONVERT(CHAR--(10),@paMainID)+ 'http://sysback.51rc.com/newoa/operate/chatOnline/LogDetails?ID='+CONVERT(CHAR(10),@ChatOnlineID), 1, 0, 0
  4257. --END
  4258. --END
  4259. IF CHARINDEX('相关职位:',@Message) > 0 OR CHARINDEX('相关简历:',@Message) > 0
  4260. BEGIN
  4261. UPDATE ChatOnlineLog SET CheckUserID = 182,CheckResult = 1 WHERE ID = @LogId
  4262. END
  4263. UPDATE ChatOnline SET AddDate = GETDATE() WHERE ID = @ChatOnlineID
  4264. IF @SenderType = 1
  4265. BEGIN
  4266. IF NOT EXISTS(SELECT 'X' FROM ChatOnlineExchange WHERE UserID = @paMainID AND UserType = 2)
  4267. BEGIN
  4268. INSERT INTO ChatOnlineExchange VALUES(@paMainID, 2)
  4269. END
  4270. END
  4271. ELSE
  4272. BEGIN
  4273. IF NOT EXISTS(SELECT 'X' FROM ChatOnlineExchange WHERE UserID = @caMainID AND UserType = 1)
  4274. BEGIN
  4275. INSERT INTO ChatOnlineExchange VALUES(@caMainID, 1)
  4276. END
  4277. END
  4278. RETURN @LogId
  4279. END
  4280. GO
  4281. /****** Object: StoredProcedure [dbo].[procChatOnlineLogSelect] Script Date: 2018/12/13 19:09:56 ******/
  4282. SET ANSI_NULLS ON
  4283. GO
  4284. SET QUOTED_IDENTIFIER ON
  4285. GO
  4286. CREATE PROCEDURE [dbo].[procChatOnlineLogSelect]
  4287. (
  4288. @caMainId INT,
  4289. @cvMainId INT,
  4290. @SenderType TINYINT
  4291. )
  4292. AS
  4293. SET NOCOUNT ON
  4294. BEGIN
  4295. UPDATE a SET IsViewed = 1
  4296. FROM ChatOnlineLog a WITH(NOLOCK), ChatOnline b WITH(NOLOCK)
  4297. WHERE a.ChatOnlineID = b.ID AND b.caMainID = @caMainId AND b.cvMainID = @cvMainId AND SenderType <> @SenderType
  4298. SELECT a.*
  4299. FROM ChatOnlineLog a WITH(NOLOCK), ChatOnline b WITH(NOLOCK)
  4300. WHERE a.ChatOnlineID = b.ID AND b.caMainID = @caMainId AND b.cvMainID = @cvMainId
  4301. END
  4302. GO
  4303. /****** Object: StoredProcedure [dbo].[ProcChatOnlineSchedule] Script Date: 2018/12/13 19:09:56 ******/
  4304. SET ANSI_NULLS ON
  4305. GO
  4306. SET QUOTED_IDENTIFIER ON
  4307. GO
  4308. CREATE PROCEDURE [dbo].[ProcChatOnlineSchedule]
  4309. AS
  4310. --INSERT INTO procLog SELECT 'ProcChatOnlineSchedule', '', GETDATE()
  4311. BEGIN
  4312. --删除离线的数据(1分钟不刷新)
  4313. DELETE FROM caOnline WHERE RefreshDate < DATEADD(SECOND, -80, GETDATE())
  4314. DELETE FROM paOnline WHERE RefreshDate < DATEADD(SECOND, -80, GETDATE())
  4315. --DELETE FROM paOnline WHERE RefreshDate < DATEADD(Minute, -70, GETDATE())
  4316. UPDATE Manageruser SET SOLStatus = 0 WHERE SOLTime < DATEADD(SECOND, -80, GETDATE())
  4317. UPDATE a SET IsOnline = b.SOLStatus FROM ChatService a,Manageruser b WHERE a.ManageruserID = b.ID
  4318. --删除交互表中的记录
  4319. DELETE FROM ChatOnlineExchange WHERE UserID NOT IN(SELECT paMainID FROM paOnline) AND UserType = 2
  4320. DELETE FROM ChatOnlineExchange WHERE UserID NOT IN(SELECT caMainID FROM caOnline) AND UserType = 1
  4321. --结束两方都不在线的聊天记录
  4322. UPDATE ChatOnline SET EndDate = GETDATE()
  4323. WHERE ManageruserID = 0
  4324. AND EndDate IS NULL
  4325. AND caMainID NOT IN(SELECT caMainID FROM caOnline)
  4326. AND cvMainID NOT IN(SELECT a.ID FROM cvMain a,paOnline b WHERE a.paMainID = b.paMainID)
  4327. UPDATE ChatOnline SET EndDate = GETDATE()
  4328. WHERE cvMainID = 0
  4329. AND EndDate IS NULL
  4330. AND caMainID NOT IN(SELECT caMainID FROM caOnline)
  4331. AND ManageruserID NOT IN(SELECT ID FROM Manageruser WHERE SOLStatus = 1)
  4332. UPDATE ChatOnline SET EndDate = GETDATE()
  4333. WHERE caMainID = 0
  4334. AND EndDate IS NULL
  4335. AND ManageruserID NOT IN(SELECT ID FROM Manageruser WHERE SOLStatus = 1)
  4336. AND cvMainID NOT IN(SELECT a.ID FROM cvMain a,paOnline b WHERE a.paMainID = b.paMainID)
  4337. END
  4338. GO
  4339. /****** Object: StoredProcedure [dbo].[procChatOnlineSelect] Script Date: 2018/12/13 19:09:56 ******/
  4340. SET ANSI_NULLS ON
  4341. GO
  4342. SET QUOTED_IDENTIFIER ON
  4343. GO
  4344. --lucifer2018-4-27
  4345. CREATE PROCEDURE [dbo].[procChatOnlineSelect]
  4346. (
  4347. @caMainId INT,
  4348. @paMainId INT
  4349. )
  4350. AS
  4351. SET NOCOUNT ON
  4352. BEGIN
  4353. CREATE TABLE #ChatList(
  4354. cvMainID INT,
  4355. caMainID INT,
  4356. [Name] VARCHAR(100),
  4357. [Message] VARCHAR(MAX),
  4358. LastSendDate DATETIME,
  4359. NoViewedNum INT,
  4360. OnlineStatus INT,
  4361. PhotoUrl VARCHAR(300),
  4362. paMainId INT,
  4363. SecondId VARCHAR(10),
  4364. Gender BIT
  4365. )
  4366. IF @paMainId > 0
  4367. BEGIN
  4368. INSERT INTO #ChatList(cvMainID, caMainID, LastSendDate, OnlineStatus, [Message])
  4369. SELECT cvMainID, caMainID, AddDate, dbo.GetCaOnlineStatus(caMainID),
  4370. CASE MessageType
  4371. WHEN 1 THEN [Message]
  4372. WHEN 2 THEN '[表情]'
  4373. WHEN 3 THEN '[图片]'
  4374. WHEN 4 THEN '[职位]'
  4375. WHEN 5 THEN '[面试通知]'
  4376. ELSE '' END
  4377. FROM (SELECT TOP 100000 a.cvMainID, a.caMainID, b.AddDate, b.Message, b.MessageType, ROW_NUMBER() OVER(PARTITION BY a.cvMainID, a.caMainID ORDER BY b.ID DESC) row
  4378. FROM ChatOnline a WITH(NOLOCK), ChatOnlineLog b WITH(NOLOCK)
  4379. WHERE a.ID = b.ChatOnlineID AND a.caMainID > 0 AND b.MessageType <> 6 AND a.cvMainID IN(
  4380. SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID = @paMainId
  4381. )
  4382. ORDER BY b.ID DESC
  4383. ) t WHERE row = 1
  4384. UPDATE #ChatList SET NoViewedNum = (SELECT COUNT(1)
  4385. FROM ChatOnlineLog WITH(NOLOCK)
  4386. WHERE ChatOnlineID IN (SELECT ID FROM ChatOnline WITH(NOLOCK) WHERE cvMainID = #ChatList.cvMainID AND caMainID = #ChatList.caMainID)
  4387. AND IsViewed = 0 AND SenderType = 1 AND MessageType NOT IN(6, 7))
  4388. UPDATE a SET a.PhotoUrl = b.LogoFile, a.[Name] = c.[Name] + ' ' + b.[Name]
  4389. FROM #ChatList a, cpMain b WITH(NOLOCK), caMain c WITH(NOLOCK)
  4390. WHERE b.ID = c.cpMainID AND c.ID = a.caMainID
  4391. END
  4392. ELSE IF @caMainID > 0
  4393. BEGIN
  4394. INSERT INTO #ChatList(cvMainID, caMainID, LastSendDate, [Message])
  4395. SELECT cvMainID, caMainID, AddDate,
  4396. CASE MessageType
  4397. WHEN 1 THEN [Message]
  4398. WHEN 2 THEN '[表情]'
  4399. WHEN 3 THEN '[图片]'
  4400. WHEN 4 THEN '[职位]'
  4401. WHEN 5 THEN '[面试通知]'
  4402. ELSE '' END
  4403. FROM (SELECT TOP 100000 a.cvMainID, a.caMainID, b.AddDate, b.Message, b.MessageType, ROW_NUMBER() OVER(PARTITION BY a.cvMainID, a.caMainID ORDER BY b.ID DESC) row
  4404. FROM ChatOnline a WITH(NOLOCK), ChatOnlineLog b WITH(NOLOCK)
  4405. WHERE a.ID = b.ChatOnlineID AND a.caMainID = @caMainId AND b.MessageType <> 7 AND a.cvMainID > 0
  4406. ORDER BY b.ID DESC) t
  4407. WHERE row = 1
  4408. UPDATE #ChatList
  4409. SET NoViewedNum = (SELECT COUNT(1)
  4410. FROM ChatOnlineLog WITH(NOLOCK)
  4411. WHERE ChatOnlineID IN (SELECT ID FROM ChatOnline WITH(NOLOCK)
  4412. WHERE cvMainID = #ChatList.cvMainID AND caMainID = #ChatList.caMainID)
  4413. AND IsViewed = 0 AND SenderType = 2 AND MessageType NOT IN(6, 7))
  4414. UPDATE #ChatList
  4415. SET PhotoUrl = (
  4416. SELECT TOP 1 a.PhotoProcessed
  4417. FROM paPhoto a WITH(NOLOCK), cvMain b WITH(NOLOCK)
  4418. WHERE a.paMainID = b.paMainID AND b.ID = #ChatList.cvMainID)
  4419. WHERE EXISTS(SELECT 'X' FROM cpMain a, caMain b WHERE a.ID = b.cpMainID AND b.ID = #ChatList.caMainID AND a.MemberType > 1)
  4420. UPDATE #ChatList
  4421. SET OnlineStatus = (SELECT TOP 1 dbo.GetPaOnlineStatus(paMainID)
  4422. FROM cvMain WITH(NOLOCK)
  4423. WHERE ID = #ChatList.cvMainID)
  4424. UPDATE a SET a.paMainId = b.paMainId, a.SecondId = b.SecondId FROM #ChatList a, cvMAin b WHERE a.cvMainId = b.Id
  4425. UPDATE a SET a.Gender = c.Gender FROM #ChatList a, cvMain b, paMain c WHERE a.cvMainId = b.Id AND b.paMainID = c.ID
  4426. UPDATE #ChatList
  4427. SET [Name] = (SELECT TOP 1 dbo.GetPaName(#ChatList.cvMainId, cpMainId)
  4428. FROM caMain WITH(NOLOCK)
  4429. WHERE ID = #ChatList.caMainId)
  4430. END
  4431. SELECT * FROM #ChatList
  4432. END
  4433. GO
  4434. /****** Object: StoredProcedure [dbo].[ProcChatOnlineUpdate] Script Date: 2018/12/13 19:09:56 ******/
  4435. SET ANSI_NULLS ON
  4436. GO
  4437. SET QUOTED_IDENTIFIER ON
  4438. GO
  4439. CREATE PROCEDURE [dbo].[ProcChatOnlineUpdate]
  4440. AS
  4441. --INSERT INTO procLog SELECT 'ProcChatOnlineUpdate', '', GETDATE()
  4442. BEGIN
  4443. UPDATE ChatOnline
  4444. SET caUnViewed = 0
  4445. WHERE caUnViewed > 0
  4446. AND StartDate < DATEADD(MINUTE, -30, GETDATE())
  4447. AND EndDate > DATEADD(MINUTE, -30, GETDATE())
  4448. UPDATE a
  4449. SET a.caUnViewed = b.Cnt
  4450. FROM ChatOnline a, (
  4451. SELECT MAX(a.ID) Id, COUNT(*) Cnt
  4452. FROM ChatOnline a, ChatOnlineLog b
  4453. WHERE a.id = b.ChatOnlineID
  4454. AND b.IsViewed = 0
  4455. AND b.SenderType <> 1 --不是企业发送的
  4456. AND StartDate < DATEADD(MINUTE, -30, GETDATE())
  4457. AND EndDate > DATEADD(MINUTE, -30, GETDATE())
  4458. GROUP BY a.CaMainID, a.CvMainID
  4459. ) b
  4460. WHERE a.Id = b.Id
  4461. ------------------
  4462. UPDATE ChatOnline
  4463. SET paUnViewed = 0
  4464. WHERE paUnViewed > 0
  4465. AND StartDate < DATEADD(MINUTE, -30, GETDATE())
  4466. AND EndDate > DATEADD(MINUTE, -30, GETDATE())
  4467. UPDATE a
  4468. SET a.paUnViewed = b.Cnt
  4469. FROM ChatOnline a, (
  4470. SELECT MAX(a.ID) ID, COUNT(1) Cnt
  4471. FROM ChatOnline a, ChatOnlineLog b
  4472. WHERE a.id = b.ChatOnlineID
  4473. AND b.IsViewed = 0
  4474. AND b.SenderType <> 2 --不是自己发送的
  4475. AND StartDate < DATEADD(MINUTE, -30, GETDATE())
  4476. AND EndDate > DATEADD(MINUTE, -30, GETDATE())
  4477. GROUP BY a.CaMainID, a.CvMainID
  4478. ) b
  4479. WHERE a.Id = b.Id
  4480. END
  4481. GO
  4482. /****** Object: StoredProcedure [dbo].[procChatRoomUserByUserIdDelete] Script Date: 2018/12/13 19:09:57 ******/
  4483. SET ANSI_NULLS ON
  4484. GO
  4485. SET QUOTED_IDENTIFIER ON
  4486. GO
  4487. CREATE PROCEDURE [dbo].[procChatRoomUserByUserIdDelete]
  4488. (
  4489. @UserID INT,
  4490. @UserType INT,
  4491. @RoomID INT,
  4492. @IpAddress VARCHAR(50)
  4493. )
  4494. AS
  4495. BEGIN
  4496. SET NOCOUNT ON
  4497. --从用户列表中删除
  4498. DELETE FROM Shortdb..ChatRoomUser WHERE ChatRoomID = @RoomID AND UserID = @UserID AND UserType = @UserType
  4499. --加入黑名单
  4500. INSERT INTO Shortdb..ChatRoomBlack( ChatRoomID, UserID, UserType, IP, AddDate )
  4501. VALUES ( @RoomID ,@UserID, @UserType, @IpAddress , getDate() )
  4502. SET NOCOUNT OFF
  4503. END
  4504. GO
  4505. /****** Object: StoredProcedure [dbo].[ProcCitySalaryRankByReginIDSelect] Script Date: 2018/12/13 19:09:57 ******/
  4506. SET ANSI_NULLS ON
  4507. GO
  4508. SET QUOTED_IDENTIFIER ON
  4509. GO
  4510. --#####################################################
  4511. --创建时间:2014.11.3
  4512. --创建人:John
  4513. --说明:根据RegionID获取当前地区所在省级下属城市薪水排行
  4514. --#####################################################
  4515. CREATE PROCEDURE [dbo].[ProcCitySalaryRankByReginIDSelect]
  4516. (
  4517. @dcRegionID VARCHAR(6)
  4518. )
  4519. AS
  4520. BEGIN
  4521. IF LEN(@dcRegionID) > 4
  4522. SET @dcRegionID = LEFT(@dcRegionID, LEN(@dcRegionId) - 2) + '__'
  4523. ELSE
  4524. SET @dcRegionID = @dcRegionId + '__'
  4525. IF LEFT(@dcRegionID, 2) = '32'
  4526. SELECT dcRegionID,AvgSalary
  4527. FROM reportdb..SalaryReportRegion
  4528. WHERE dcRegionid LIKE @dcRegionID AND LEN(dcRegionid) > 2
  4529. ORDER BY AvgSalary DESC
  4530. ELSE
  4531. SELECT TOP 10 dcRegionID,AvgSalary
  4532. FROM reportdb..SalaryReportRegion
  4533. WHERE dcRegionid LIKE @dcRegionID AND LEN(dcRegionid) > 2
  4534. ORDER BY AvgSalary DESC
  4535. END
  4536. GO
  4537. /****** Object: StoredProcedure [dbo].[procColdCustomerInsert] Script Date: 2018/12/13 19:09:57 ******/
  4538. SET ANSI_NULLS ON
  4539. GO
  4540. SET QUOTED_IDENTIFIER ON
  4541. GO
  4542. --采集的冷客户分配
  4543. --harry
  4544. --2016-10-13
  4545. --修改harry 2018-1-25 增加推广
  4546. --harry 2018-1-26
  4547. CREATE PROCEDURE [dbo].[procColdCustomerInsert]
  4548. (
  4549. @ManagerUserId INT,
  4550. @Allocater INT,
  4551. @SourceType INT,
  4552. @AllocateNumber INT,
  4553. @isSpread INT
  4554. )
  4555. AS
  4556. SET NOCOUNT ON
  4557. BEGIN
  4558. DECLARE @Id INT
  4559. DECLARE @AllocateId INT
  4560. DECLARE @cpName VARCHAR(200)
  4561. DECLARE @ProvinceId INT
  4562. SET @ProvinceId=32
  4563. DECLARE @dtLastLoginDate DATETIME
  4564. DECLARE @dtLastContactDate DATETIME
  4565. SET @dtLastLoginDate=dateAdd(month,-6,getdate())
  4566. SET @dtLastContactDate=dateAdd(month,-6,getdate())
  4567. IF(@ProvinceId=32)
  4568. SET @dtLastContactDate=dateAdd(month,-3,getdate())
  4569. --分配前,更新已被注册的信息
  4570. CREATE TABLE #t(
  4571. Id INT ,
  4572. [state] INT,
  4573. SourceType INT,
  4574. RegType INT,
  4575. CompanyName VARCHAR(200),
  4576. LinkMan varchar(50),
  4577. Phone varchar(50),
  4578. Tel varchar(50),
  4579. Email varchar(50),
  4580. SourceLink varchar(500),
  4581. [Address] varchar(200),
  4582. QQ char(15),
  4583. IsNameRepeat BIT,
  4584. IsEmailRepeat BIT,
  4585. IsMobileRepeat BIT,
  4586. IsAgree BIT,
  4587. IsValid BIT,
  4588. CheckDate DATETIME,
  4589. AddDate DATETIME
  4590. )
  4591. INSERT #t(id,[state],sourceType,companyName,LinkMan,Phone,Tel,Email,SourceLink,[address],qq)
  4592. SELECT id,[state],sourceType,companyName,linkMan,Phone,Tel,Email,SourceLink,[address],qq
  4593. FROM precoldCustomer
  4594. WHERE [state]=0--未分配
  4595. AND ISNULL(isSpread,0) = @isSpread
  4596. IF EXISTS(SELECT 'x' FROM #t )
  4597. BEGIN
  4598. --删除在coldcustomer表中的数据
  4599. UPDATE #t SET [state]=2
  4600. WHERE EXISTS(SELECT 'x' FROM Maindb..coldcustomer
  4601. WHERE companyName=#t.CompanyName AND ProvinceID=@ProvinceId)
  4602. AND [state]=0
  4603. IF @isSpread = 0 --冷客户部门的规则
  4604. BEGIN
  4605. --有顾问的(上次联系时间,和登录时间不为空的)
  4606. --3(6)个月内未联系,删除3(6)个月内联系过的
  4607. UPDATE #t SET [state]=2
  4608. WHERE EXISTS
  4609. (
  4610. SELECT 'x' FROM cpMain
  4611. WHERE NAME=#t.CompanyName
  4612. AND dcProvinceID = @ProvinceId
  4613. AND ISNULL(ConsultantID, -1) != -1
  4614. AND id =(
  4615. SELECT TOP 1 companyID
  4616. FROM MainDB..contact
  4617. WHERE companyID = CpMain.ID
  4618. AND addDate>@dtLastContactDate
  4619. ORDER BY addDate DESC
  4620. )
  4621. )
  4622. AND [state]=0
  4623. --6个月未登录,删除6个月内登录过的
  4624. UPDATE #t SET [state]=2
  4625. WHERE EXISTS(
  4626. SELECT 'x' FROM cpMain
  4627. WHERE NAME=#t.CompanyName
  4628. AND dcProvinceID=@ProvinceId
  4629. AND ISNULL(ConsultantID,-1)!=-1
  4630. AND LastLoginDate>@dtLastLoginDate
  4631. )
  4632. AND [state]=0
  4633. --无顾问
  4634. --无执照且一个月未登录,删除一个月内登录的
  4635. UPDATE #t SET [state]=2
  4636. WHERE EXISTS(
  4637. SELECT 'x' FROM cpMain
  4638. WHERE NAME=#t.CompanyName
  4639. AND dcProvinceID=@ProvinceId
  4640. AND ISNULL(ConsultantID,-1)=-1
  4641. AND HasLicence=0
  4642. AND LastLoginDate>DateAdd(month,-1,getdate())
  4643. )
  4644. AND [state]=0
  4645. --有执照且三个月未登录,删除3个月内登录的
  4646. UPDATE #t SET [state]=2
  4647. WHERE EXISTS
  4648. (
  4649. SELECT 'x' FROM cpMain
  4650. WHERE NAME=#t.CompanyName
  4651. AND dcProvinceID=@ProvinceId
  4652. AND ISNULL(ConsultantID,-1)=-1
  4653. AND HasLicence=1
  4654. AND LastLoginDate>DateAdd(month,-3,getdate())
  4655. )
  4656. AND [state]=0
  4657. END
  4658. ELSE
  4659. BEGIN
  4660. --推广的规则
  4661. --有顾问的,已认证的
  4662. UPDATE #t SET [state]=2
  4663. WHERE EXISTS
  4664. (
  4665. SELECT 'x' FROM cpMain
  4666. WHERE NAME=#t.CompanyName
  4667. AND dcProvinceID=@ProvinceId
  4668. AND (ISNULL(ConsultantID,0)!=0 OR memberType>1)
  4669. )
  4670. AND [state]=0
  4671. END
  4672. END
  4673. --更新新结束,开始分配
  4674. UPDATE precoldCustomer
  4675. SET [state]=2
  4676. WHERE id in(select id FROM #t where [state]=2)
  4677. TRUNCATE TABLE #t
  4678. INSERT INTO #t(id,sourceType,companyName,LinkMan,Phone,Tel,Email,SourceLink,[address],qq,IsAgree,IsValid,CheckDate,AddDate)
  4679. SELECT TOP (@AllocateNumber) id,sourceType,companyName,
  4680. REPLACE(linkMan,'_',''),
  4681. REPLACE(Phone,'_',''),
  4682. REPLACE(Tel,'_',''),
  4683. REPLACE(Email,'_',''),
  4684. REPLACE(SourceLink,'_',''),
  4685. REPLACE([address],'_',''),
  4686. REPLACE(qq,'_',''),1,1,GETDATE(),GETDATE()
  4687. FROM precoldCustomer
  4688. WHERE [state]=0
  4689. AND SourceType=@SourceType
  4690. AND ISNULL(isSpread,0) = @isSpread
  4691. --判断用户名,手机,邮箱等是否重复IsNameRepeat BIT,IsEmailRepeat BIT, IsMobileRepeat BIT,
  4692. UPDATE #t
  4693. SET IsNameRepeat=(CASE WHEN EXISTS(select 'x' from MainDB..CpMain where name =#t.CompanyName)
  4694. THEN 1
  4695. ELSE 0 END),
  4696. IsEmailRepeat=(
  4697. CASE WHEN Email!=''
  4698. THEN
  4699. (CASE WHEN EXISTS(select 'x' from MainDB..CaMain a,MainDB..CpMain b where a.email =#t.Email and a.CpMainID=b.ID)
  4700. THEN 1
  4701. ELSE 0 END)
  4702. ELSE 0 END),
  4703. IsMobileRepeat=(CASE WHEN #t.Phone!='' OR #t.Tel !=''
  4704. THEN (CASE
  4705. WHEN #t.Phone!='' AND #t.Tel!='' AND EXISTS(select 'x' from MainDB..CaMain a,MainDB..cpmain b
  4706. where (a.telephone like #t.Tel+ '%' or a.mobile=#t.Phone)
  4707. and a.CpMainID=b.ID)
  4708. THEN 1
  4709. WHEN #t.Phone!='' AND #t.Tel ='' AND EXISTS(select 'x' from MainDB..CaMain a,MainDB..cpmain b
  4710. where a.mobile=#t.Phone and a.CpMainID=b.ID)
  4711. THEN 1
  4712. WHEN #t.Phone ='' AND #t.Tel!='' AND EXISTS(select a.cpmainid,b.ConsultantID,b.LastLoginDate,b.HasLicence
  4713. from MainDB..CaMain a,MainDB..cpmain b
  4714. where a.telephone like #t.Tel+'%' and a.CpMainID=b.ID)
  4715. THEN 1
  4716. ELSE 0
  4717. END)
  4718. ELSE 0
  4719. END)
  4720. --更新regtype
  4721. UPDATE #t SET regType=1 --无顾问的
  4722. --有顾问的 regType=4,HasLicence=1 regtype=3 haslicence=0 regtype=2
  4723. UPDATE #t
  4724. SET regType=4
  4725. WHERE EXISTS(SELECT 'x' FROM cpMain
  4726. WHERE NAME=#t.CompanyName
  4727. AND dcProvinceID=@ProvinceId
  4728. AND ISNULL(ConsultantID,-1)!=-1)
  4729. UPDATE #t
  4730. SET regType=3
  4731. WHERE EXISTS(
  4732. SELECT 'x' FROM cpMain
  4733. WHERE NAME=#t.CompanyName
  4734. AND dcProvinceID=@ProvinceId
  4735. AND HasLicence=1
  4736. AND ISNULL(ConsultantID,-1)!=-1)
  4737. UPDATE #t
  4738. SET regType=3
  4739. WHERE EXISTS(
  4740. SELECT 'x' FROM cpMain
  4741. WHERE NAME=#t.CompanyName
  4742. AND dcProvinceID=@ProvinceId
  4743. AND HasLicence=0
  4744. AND ISNULL(ConsultantID,-1)!=-1)
  4745. --#t
  4746. IF EXISTS(SELECT 'x' FROM #t)
  4747. BEGIN
  4748. INSERT INTO ColdCustomerAllocateLog(ManagerUserId,SourceType,Allocater,AllocateNumber,Adddate)
  4749. SELECT @ManagerUserId,@SourceType,@Allocater,(SELECT COUNT(*) FROM #t),GETDATE()
  4750. SELECT @AllocateId=(SELECT @@IDENTITY) --赋值
  4751. --插入冷客户表
  4752. INSERT INTO coldCustomer(CompanyName, ProvinceId, Email, Phone, SourceLink, LinkMan, [Address], qq, AllocateLogID, AddWorkUserID,AddMan,IsNameRepeat,IsEmailRepeat,IsMobilerepeat,IsAgree,IsValid,CheckDate,addDate,regType)
  4753. SELECT CompanyName,32,Email,Phone,SourceLink,LinkMan,[Address],qq,@AllocateId,(select TOP 1 id from oadb..workuser where manageruserid=@ManagerUserId and loginstatus=1 AND JobStatus<3 ),@ManagerUserId,IsNameRepeat, IsEmailRepeat,IsMobileRepeat,IsAgree,IsValid,CheckDate ,AddDate,regType
  4754. FROM #t
  4755. UPDATE precoldCustomer SET [state]=1,ColdCustomerAllocateLogID=@AllocateId WHERE ID IN(SELECT id FROM #t)
  4756. --释放顾问
  4757. UPDATE Maindb..cpMain SET ConsultantID = NULL, ConsultantDate = NULL WHERE [Name] IN(SELECT CompanyName FROM #t) AND dcProvinceID=32
  4758. --rtx 通知 操作人和分配人
  4759. INSERT RtxNotifyLog SELECT @ManagerUserId, Convert(VARCHAR,@Allocater)+'分配给您'+Convert(VARCHAR,(SELECT COUNT(*) FROM #t))+'个新的冷客户', Convert(VARCHAR,@Allocater)+'分配给您'+Convert(VARCHAR,(SELECT COUNT(*) FROM #t))+'个新的冷客户,请及时处理', 0, 0, 0, Null, GETDATE()
  4760. INSERT RtxNotifyLog SELECT @Allocater, '分配冷客户成功通知', '成功分配'+Convert(VARCHAR,(SELECT COUNT(*) FROM #t))+'个新的冷客户给'+Convert(VARCHAR,@ManagerUserId), 0, 0, 0, Null, GETDATE()
  4761. END
  4762. END
  4763. SET NOCOUNT OFF
  4764. GO
  4765. /****** Object: StoredProcedure [dbo].[ProcColdCustomerSave] Script Date: 2018/12/13 19:09:58 ******/
  4766. SET ANSI_NULLS ON
  4767. GO
  4768. SET QUOTED_IDENTIFIER ON
  4769. GO
  4770. --冷客户采集插入
  4771. --Harry
  4772. --2016-10-11
  4773. --修改harry2017-7-31 0库中的数据重新采集,同时删除存在的0库数据
  4774. --修改harry2017-10-12 删除vip用户
  4775. --修改harry 2018-1-24 增加推广采集 @ProvinceId len=4时为推广采集,推广采集原则:无顾问,未认证
  4776. CREATE PROCEDURE [dbo].[ProcColdCustomerSave]
  4777. (
  4778. @CompanyInfo VARCHAR(MAX),
  4779. @ProvinceId INT
  4780. )
  4781. AS
  4782. SET NOCOUNT ON
  4783. BEGIN
  4784. DECLARE @dtLastLoginDate DATETIME
  4785. DECLARE @dtLastContactDate DATETIME
  4786. DECLARE @cpName VARCHAR(200)
  4787. SET @dtLastLoginDate=dateAdd(month,-6,getdate())
  4788. SET @dtLastContactDate=dateAdd(month,-6,getdate())
  4789. IF(LEFT(@ProvinceId,2)=32)
  4790. SET @dtLastContactDate=dateAdd(month,-3,getdate())
  4791. CREATE TABLE #t(
  4792. Id INT IDENTITY,
  4793. SeekInfo VARCHAR(MAX),
  4794. SourceType INT,
  4795. CompanyName VARCHAR(200),
  4796. LinkMan varchar(50),
  4797. Phone varchar(50),
  4798. Tel varchar(50),
  4799. Email varchar(50),
  4800. SourceLink varchar(500),
  4801. [Address] varchar(200),
  4802. QQ char(15),
  4803. )
  4804. INSERT INTO #t(SeekInfo)
  4805. SELECT * FROM dbo.FnSplit(@CompanyInfo, '#')
  4806. DECLARE @Id INT, @Info VARCHAR(MAX)
  4807. CREATE TABLE #One(
  4808. Id INT IDENTITY(1, 1),
  4809. Info VARCHAR(1000)
  4810. )
  4811. SET @Id = 0
  4812. WHILE EXISTS(SELECT 'x' FROM #t WHERE Id > @Id)
  4813. BEGIN
  4814. SELECT TOP 1 @Id = Id, @Info = SeekInfo FROM #t WHERE Id > @Id ORDER BY ID
  4815. TRUNCATE TABLE #One
  4816. INSERT INTO #One
  4817. SELECT * FROM dbo.FnSplit(@Info, '|')
  4818. IF(SELECT COUNT(*) FROM #One) = 9
  4819. BEGIN
  4820. UPDATE #t SET SourceType = convert(INT,b.Info) FROM #t a, #One b WHERE a.Id = @Id AND b.Id = 1
  4821. UPDATE #t SET CompanyName = LEFT(b.Info, 200) FROM #t a, #One b WHERE a.Id = @Id AND b.Id = 2
  4822. UPDATE #t SET LinkMan = LEFT(b.Info, 50) FROM #t a, #One b WHERE a.Id = @Id AND b.Id = 3
  4823. UPDATE #t SET Phone = LEFT(b.Info, 50) FROM #t a, #One b WHERE a.Id = @Id AND b.Id = 4
  4824. UPDATE #t SET Tel= LEFT(b.Info, 50) FROM #t a, #One b WHERE a.Id = @Id AND b.Id = 5
  4825. UPDATE #t SET Email = LEFT(b.Info, 50) FROM #t a, #One b WHERE a.Id = @Id AND b.Id = 6
  4826. UPDATE #t SET SourceLink = LEFT(b.Info, 500) FROM #t a, #One b WHERE a.Id = @Id AND b.Id = 7
  4827. UPDATE #t SET [Address] = LEFT(b.Info,200) FROM #t a, #One b WHERE a.Id = @Id AND b.Id = 8
  4828. UPDATE #t SET QQ = LEFT(b.Info,15) FROM #t a, #One b WHERE a.Id = @Id AND b.Id = 9
  4829. END
  4830. END
  4831. --插入maindb..precoldcustomer表中
  4832. SET @Id = 0
  4833. WHILE EXISTS(SELECT 'x' FROM #t WHERE Id > @Id)
  4834. BEGIN
  4835. SELECT TOP 1 @Id = Id, @cpName = CompanyName FROM #t WHERE Id > @Id ORDER BY ID
  4836. --删除在maindb..precoldcustomer的数据
  4837. DELETE FROM #t WHERE EXISTS(SELECT 'x' FROM Maindb..precoldcustomer WHERE companyName=@cpName) AND companyName=@cpName
  4838. --删除在coldcustomer表中的数据,0库的保留,同时删除0库数据
  4839. DELETE FROM #t WHERE EXISTS(SELECT 'x' FROM Maindb..coldcustomer WHERE companyName=@cpName AND ProvinceID=LEFT(@ProvinceId,2) AND ISNULL(addMan,0)!=0) AND companyName=@cpName
  4840. --删除0库数据
  4841. DELETE FROM Maindb..coldcustomer WHERE companyName=@cpName AND ProvinceID=LEFT(@ProvinceId,2) AND ISNULL(addMan,0) =0
  4842. DELETE FROM #t WHERE companyName LIKE '%保险%'
  4843. IF LEN(@ProvinceId )=4
  4844. BEGIN
  4845. --删除有顾问的--删除已认证的
  4846. DELETE FROM #t WHERE companyName=@cpName AND EXISTS(SELECT 'X' FROM cpMain WHERE name =@cpName AND dcProvinceID=LEFT(@ProvinceId,2) AND (ISNULL(ConsultantID,0)>0 OR ISNULL(MemberType,0)>1))
  4847. END
  4848. ELSE
  4849. BEGIN
  4850. --有顾问的(上次联系时间,和登录时间不为空的)
  4851. --3(6)个月内未联系,删除3(6)个月内联系过的
  4852. DELETE FROM #t
  4853. WHERE EXISTS
  4854. (
  4855. SELECT 'x' FROM cpMain
  4856. WHERE NAME=@cpName
  4857. AND dcProvinceID=LEFT(@ProvinceId,2)
  4858. AND ISNULL(ConsultantID,-1)!=-1
  4859. AND id =(
  4860. SELECT TOP 1 companyID
  4861. FROM MainDB..contact
  4862. WHERE companyID = CpMain.ID
  4863. AND addDate>@dtLastContactDate
  4864. ORDER BY addDate DESC
  4865. )
  4866. ) AND companyName=@cpName
  4867. --6个月未登录,删除6个月内登录过的
  4868. DELETE FROM #t
  4869. WHERE EXISTS
  4870. (
  4871. SELECT 'x' FROM cpMain
  4872. WHERE NAME=@cpName
  4873. AND dcProvinceID=LEFT(@ProvinceId,2)
  4874. AND ISNULL(ConsultantID,-1)!=-1
  4875. AND LastLoginDate>@dtLastLoginDate
  4876. ) AND companyName=@cpName
  4877. --无顾问
  4878. --无执照且一个月未登录,删除一个月内登录的
  4879. DELETE FROM #t
  4880. WHERE EXISTS
  4881. (
  4882. SELECT 'x' FROM cpMain
  4883. WHERE NAME=@cpName
  4884. AND dcProvinceID=LEFT(@ProvinceId,2)
  4885. AND ISNULL(ConsultantID,-1)=-1
  4886. AND HasLicence=0
  4887. AND LastLoginDate>DateAdd(month,-1,getdate())
  4888. ) AND companyName=@cpName
  4889. --有执照且三个月未登录,删除3个月内登录的
  4890. DELETE FROM #t
  4891. WHERE EXISTS
  4892. (
  4893. SELECT 'x' FROM cpMain
  4894. WHERE NAME=@cpName
  4895. AND dcProvinceID=LEFT(@ProvinceId,2)
  4896. AND ISNULL(ConsultantID,-1)=-1
  4897. AND HasLicence=1
  4898. AND LastLoginDate>DateAdd(month,-3,getdate())
  4899. ) AND companyName=@cpName
  4900. --删除vip
  4901. DELETE FROM #t
  4902. WHERE EXISTS
  4903. (
  4904. SELECT 'x' FROM cpMain
  4905. WHERE NAME=@cpName
  4906. AND dcProvinceID=LEFT(@ProvinceId,2)
  4907. AND MemberType=3
  4908. ) AND companyName=@cpName
  4909. END
  4910. END
  4911. --插入数据
  4912. IF EXISTS(SELECT 'x' FROM #t)
  4913. BEGIN
  4914. IF LEN(@ProvinceId)=4
  4915. BEGIN
  4916. INSERT INTO precoldcustomer(State,SourceType,CompanyName,LinkMan,Phone,Tel,Email,SourceLink,[Address],QQ, AddDate, IsSpread )
  4917. SELECT 0,SourceType,CompanyName,LinkMan,Phone,Tel,Email,SourceLink,[Address],QQ, GETDATE(), 1 FROM #t
  4918. END
  4919. ELSE
  4920. BEGIN
  4921. INSERT INTO precoldcustomer(State,SourceType,CompanyName,LinkMan,Phone,Tel,Email,SourceLink,[Address],QQ, AddDate)
  4922. SELECT 0,SourceType,CompanyName,LinkMan,Phone,Tel,Email,SourceLink,[Address],QQ, GETDATE() FROM #t
  4923. END
  4924. END
  4925. END
  4926. SET NOCOUNT OFF
  4927. GO
  4928. /****** Object: StoredProcedure [dbo].[proccoldcustomerUpdate] Script Date: 2018/12/13 19:09:58 ******/
  4929. SET ANSI_NULLS ON
  4930. GO
  4931. SET QUOTED_IDENTIFIER ON
  4932. GO
  4933. --proccoldcustomerUpdate
  4934. --后台冷客户的手机号,邮箱重复校正,每天运行一次
  4935. --harry
  4936. --2017-12-28
  4937. CREATE PROCEDURE [dbo].[proccoldcustomerUpdate]
  4938. AS
  4939. BEGIN
  4940. SET NOCOUNT ON
  4941. CREATE TABLE #t(
  4942. Id INT ,
  4943. coldId INT,
  4944. CompanyName VARCHAR(200),
  4945. Phone varchar(50),
  4946. Tel varchar(50),
  4947. Email varchar(50),
  4948. IsNameRepeat BIT,
  4949. IsEmailRepeat BIT,
  4950. IsMobileRepeat BIT
  4951. )
  4952. INSERT INTO #t(id,coldId,companyName,Phone,Tel,Email,IsNameRepeat,IsEmailRepeat,IsMobileRepeat)
  4953. select b.id,a.id, a.companyName, a.Phone, a.Phone, a.Email,a.IsNameRepeat,a.IsEmailRepeat,a.IsMobileRepeat
  4954. from coldcustomer a, cpmain b
  4955. WHERE (a.IsNameRepeat=1 OR a.isEmailRepeat =1 OR a.IsMobilerepeat=1 )
  4956. and b.name =a.CompanyName
  4957. and a.cpmainid is NOT null
  4958. UPDATE u
  4959. SET u.IsNameRepeat=(
  4960. CASE WHEN EXISTS(select 'x' from MainDB..CpMain a where a.name =#t.CompanyName AND a.id!=#t.id )
  4961. THEN 1
  4962. ELSE 0 END),
  4963. u.IsEmailRepeat=(
  4964. CASE WHEN #t.Email!=''
  4965. THEN
  4966. (CASE WHEN EXISTS(select 'x' from MainDB..CaMain a where a.email =#t.Email and a.id=#t.id)
  4967. THEN 1
  4968. ELSE 0 END)
  4969. ELSE 0 END),
  4970. u.IsMobileRepeat=(
  4971. CASE WHEN ISNULL(#t.Phone,'')!=''
  4972. THEN
  4973. (CASE WHEN ISNULL(#t.Phone,'')!='' AND EXISTS(select 'x' from MainDB..CaMain a
  4974. where (a.Telephone like #t.Phone+ '%' or a.mobile=#t.Phone)
  4975. AND a.CpMainId !=#t.id)
  4976. THEN 1
  4977. WHEN ISNULL(#t.Phone,'')!='' AND EXISTS(select 'x' from MainDB..CaMain a
  4978. where a.mobile=#t.Phone and a.cpMainID !=#t.id)
  4979. THEN 1
  4980. WHEN ISNULL(#t.Phone,'')!='' AND EXISTS(select 'x' from MainDB..CaMain a
  4981. where a.Telephone like #t.Phone+'%' and a.CpMainID!=#t.id)
  4982. THEN 1
  4983. ELSE 0
  4984. END)
  4985. ELSE 0
  4986. END)
  4987. FROM coldcustomer u, #t
  4988. WHERE u.id =#t.coldid
  4989. DROP TABLE #t
  4990. SET NOCOUNT OFF
  4991. END
  4992. GO
  4993. /****** Object: StoredProcedure [dbo].[ProcCommentCompanyListSelect] Script Date: 2018/12/13 19:09:58 ******/
  4994. SET ANSI_NULLS ON
  4995. GO
  4996. SET QUOTED_IDENTIFIER ON
  4997. GO
  4998. --#####################################################
  4999. --创建时间:2014.11.27
  5000. --创建人:Nick
  5001. --说明:获取点评公司列表
  5002. --#####################################################
  5003. CREATE PROCEDURE [dbo].[ProcCommentCompanyListSelect]
  5004. (
  5005. @dcRegionID VARCHAR(100),
  5006. @PageNo INT,
  5007. @KeyWord VARCHAR(50)
  5008. )
  5009. AS
  5010. BEGIN TRY
  5011. DECLARE @WHERE VARCHAR(MAX),@JobPlace AS VARCHAR(2000)
  5012. SET @JobPlace = ''
  5013. SET @WHERE = ''
  5014. IF CHARINDEX(',',@dcRegionID)>0
  5015. BEGIN
  5016. DECLARE @T_JobPlace AS TABLE(ID INT)
  5017. INSERT INTO @T_JobPlace
  5018. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  5019. SELECT @JobPlace = (@JobPlace + ' OR b.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  5020. IF LEN(@JobPlace) > 0
  5021. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  5022. SET @WHERE = @WHERE + '
  5023. AND (' + @JobPlace + ')'
  5024. END
  5025. ELSE
  5026. BEGIN
  5027. SET @WHERE = ' AND (b.dcRegionID Like '''+@dcRegionID+'%'')'
  5028. END
  5029. SET @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, ''))
  5030. IF @KeyWord <> ''
  5031. BEGIN
  5032. SET @WHERE = @WHERE + ' AND b.Name LIKE ''%'+@KeyWord+'%'' '
  5033. END
  5034. DECLARE @PageSize INT
  5035. SET @PageSize = 5
  5036. DECLARE @PageLowerBound INT --定义此页的底码
  5037. DECLARE @PageUpperBound INT --定义此页的顶码
  5038. SET @PageLowerBound = (@PageNo -1) * @pagesize
  5039. SET @PageUpperBound = @PageLowerBound + @pagesize
  5040. DECLARE @AllCnt INT
  5041. SET @AllCnt = 0
  5042. DECLARE @SQL NVARCHAR(MAX)
  5043. SET @SQL = N'
  5044. SELECT @All = COUNT(DISTINCT CpMainID)
  5045. FROM Comments a,Cpmain b
  5046. WHERE (a.CommentType IN (1,2))
  5047. AND a.id IN(SELECT MAX(id) FROM comments GROUP BY cpmainid)
  5048. AND a.CpMainID = b.ID
  5049. '+@WHERE
  5050. exec sp_executesql @SQL,N'@All INT output',@AllCnt output
  5051. IF @AllCnt>500
  5052. BEGIN
  5053. SET @AllCnt = 500
  5054. END
  5055. --SET @SQL = 'SELECT TOP 5000 rid=ROW_NUMBER() OVER(PARTITION BY CpmainID ORDER BY a.AddDate DESC),a.CpMainID,a.AddDate INTO ##Tmp
  5056. -- FROM Comments a, CpMain b WHERE a.cpMainID=b.ID '+@WHERE
  5057. ----exec sp_executesql @SQL,N'#Tmp INT output',#Tmp2 output
  5058. SET @SQL = '
  5059. SELECT TOP 500 cpmainid,b.name,b.secondid,a.AddDate INTO ##T1
  5060. FROM comments a,cpmain b
  5061. WHERE a.id IN(SELECT MAX(id) FROM comments GROUP BY cpmainid)
  5062. AND a.cpmainid = b.id AND a.CommentType IN(1,2) '+@WHERE+'
  5063. ORDER BY a.adddate DESC '
  5064. EXEC(@SQL)
  5065. SELECT * ,ROW_NUMBER() OVER( ORDER BY AddDate DESC) AS num INTO #T2 FROM ##T1
  5066. SELECT *,0 AS cnt,0 AS Score INTO #T3 FROM #T2 WHERE NUM > @PageLowerBound AND NUM <= @PageUpperBound
  5067. --修改评价数量
  5068. UPDATE a
  5069. SET a.cnt = b.Num
  5070. FROM #T3 a,(
  5071. SELECT COUNT(*) AS num,CpMainID
  5072. FROM Comments
  5073. WHERE (CommentType IN (1,2))
  5074. AND CpMainID IN (SELECT CpMainID FROM #T3)
  5075. GROUP BY CpMainID
  5076. )b
  5077. WHERE a.CpMainID = b.CpMainID
  5078. --修改平均分数
  5079. UPDATE a
  5080. SET a.Score = b.Score
  5081. FROM #T3 a,(
  5082. SELECT CONVERT(DECIMAL(18,1),(SUM(GradeStar)*1.0)/(COUNT(*)*1.0)) AS Score,CpMainID
  5083. FROM Comments
  5084. WHERE CommentType IN (1,2)
  5085. AND CpMainID IN (SELECT CpMainID FROM #T3)
  5086. GROUP BY CpMainID
  5087. )b
  5088. WHERE a.CpMainID = b.CpMainID
  5089. SELECT * FROM #T3
  5090. SELECT @AllCnt
  5091. SELECT * FROM
  5092. (
  5093. SELECT rid=ROW_NUMBER() OVER(PARTITION BY a.CpmainID ORDER BY a.AddDate DESC),*
  5094. FROM Comments a
  5095. WHERE (a.CommentType IN (1,2))
  5096. AND CpMainID IN (SELECT CpMainID FROM #T3)
  5097. ) AS c
  5098. WHERE c.rid<=2
  5099. DROP TABLE ##T1
  5100. END TRY
  5101. BEGIN CATCH
  5102. DROP TABLE ##T1
  5103. END CATCH
  5104. GO
  5105. /****** Object: StoredProcedure [dbo].[ProcCommentPraiseByIDUpdate] Script Date: 2018/12/13 19:09:59 ******/
  5106. SET ANSI_NULLS ON
  5107. GO
  5108. SET QUOTED_IDENTIFIER ON
  5109. GO
  5110. --#####################################################
  5111. --创建时间:2014.11.20
  5112. --创建人:Nick
  5113. --说明:根据点评ID 点赞
  5114. --修改:harry,修改登录用户未点击提示点击的bug20151224
  5115. --#####################################################
  5116. CREATE PROCEDURE [dbo].[ProcCommentPraiseByIDUpdate]
  5117. (
  5118. @ID INT,
  5119. @PaMainID INT,
  5120. @CommentType INT --1 点评 2面试经历
  5121. )
  5122. AS
  5123. BEGIN
  5124. IF @PaMainID = 0
  5125. BEGIN
  5126. --只更新总数
  5127. IF @CommentType = 1
  5128. BEGIN
  5129. UPDATE Comments
  5130. SET PraiseCount = PraiseCount+1
  5131. WHERE ID = @ID
  5132. END
  5133. ELSE
  5134. BEGIN
  5135. UPDATE InterView
  5136. SET PraiseCount = PraiseCount+1
  5137. WHERE ID = @ID
  5138. END
  5139. RETURN 1
  5140. END
  5141. ELSE
  5142. BEGIN
  5143. --判断用户是否点过赞
  5144. DECLARE @Tmp INT
  5145. SELECT @Tmp = COUNT(*) FROM CommentPraise WHERE CommentID = @ID AND CommentType = @CommentType AND pamainId=@PaMainID
  5146. IF @Tmp = 0 --没点过
  5147. BEGIN
  5148. INSERT INTO CommentPraise (CommentID,CommentType,AddDate,PamainID)
  5149. VAlUES (@ID,@CommentType,GETDATE(),@PaMainID)
  5150. IF @CommentType = 1 --更新点评 点赞总数
  5151. BEGIN
  5152. UPDATE Comments
  5153. SET PraiseCount = PraiseCount+1,
  5154. LoginPraiseCount = LoginPraiseCount+1
  5155. WHERE ID = @ID
  5156. END
  5157. ELSE
  5158. BEGIN
  5159. UPDATE InterView
  5160. SET PraiseCount = PraiseCount+1,
  5161. LoginPraiseCount = LoginPraiseCount+1
  5162. WHERE ID = @ID
  5163. END
  5164. RETURN 1
  5165. END
  5166. ELSE
  5167. RETURN 0
  5168. END
  5169. RETURN 0
  5170. End
  5171. GO
  5172. /****** Object: StoredProcedure [dbo].[ProcCommentsByCompanyIDSelect] Script Date: 2018/12/13 19:09:59 ******/
  5173. SET ANSI_NULLS ON
  5174. GO
  5175. SET QUOTED_IDENTIFIER ON
  5176. GO
  5177. --#####################################################
  5178. --创建时间:2014.11.20
  5179. --创建人:Nick
  5180. --说明:根据公司ID获取 点评信息,以及平均分
  5181. --#####################################################
  5182. CREATE PROCEDURE [dbo].[ProcCommentsByCompanyIDSelect]
  5183. (
  5184. @CpMainID INT,
  5185. @SessionID VARCHAR(50),
  5186. @paMainID INT
  5187. )
  5188. AS
  5189. SET NOCOUNT ON
  5190. --insert a2 select @cpmainid, @sessionId, @paMainID, GETDATE()
  5191. BEGIN
  5192. DECLARE @CommentCount INT --评论人数
  5193. DECLARE @StarCount INT --星星数量
  5194. DECLARE @StarScore DECIMAL(18,1) --综合评分
  5195. SELECT @CommentCount = COUNT(1),@StarCount = SUM(GradeStar) FROM Comments
  5196. WHERE CpMainID = @CpMainID
  5197. AND CommentType<>3
  5198. AND VerifyDate IS NOT NULL
  5199. IF @CommentCount>0
  5200. SET @StarScore = @StarCount * 1.0 / @CommentCount
  5201. ELSE
  5202. SET @StarScore = 0
  5203. IF @paMainID <> 0
  5204. BEGIN
  5205. SELECT * FROM Comments
  5206. WHERE CpMainID = @CpMainID
  5207. AND CommentType<>3
  5208. AND (VerifyDate IS NOT NULL OR PaMainID = @paMainID)
  5209. ORDER BY ADDDATE DESC
  5210. END
  5211. ELSE
  5212. BEGIN
  5213. -- IF @SessionID<>''
  5214. -- BEGIN
  5215. -- SELECT * FROM Comments
  5216. -- WHERE CpMainID = @CpMainID
  5217. -- AND CommentType<>3
  5218. -- AND (VerifyDate IS NOT NULL OR (PaMainID = 0 AND SessionID = @SessionID))
  5219. -- ORDER BY ADDDATE DESC
  5220. -- END
  5221. -- ELSE
  5222. -- BEGIN
  5223. SELECT * FROM Comments WITH(NOLOCK INDEX(IX_Comments_Complex))
  5224. WHERE CpMainID = @CpMainID
  5225. AND CommentType <> 3
  5226. AND VerifyDate IS NOT NULL
  5227. ORDER BY ADDDATE DESC
  5228. -- END
  5229. END
  5230. SELECT @StarScore AS Score
  5231. End
  5232. GO
  5233. /****** Object: StoredProcedure [dbo].[ProcCommentsByID] Script Date: 2018/12/13 19:09:59 ******/
  5234. SET ANSI_NULLS ON
  5235. GO
  5236. SET QUOTED_IDENTIFIER ON
  5237. GO
  5238. --#####################################################
  5239. --创建时间:2014.11.24
  5240. --创建人:Nick
  5241. --说明:根据ID获取点评信息
  5242. --#####################################################
  5243. CREATE PROCEDURE [dbo].[ProcCommentsByID]
  5244. (
  5245. @ID INT
  5246. )
  5247. AS
  5248. BEGIN
  5249. SELECT * FROM Comments WHERE ID = @ID AND CommentType <> 3
  5250. End
  5251. GO
  5252. /****** Object: StoredProcedure [dbo].[ProcCommentsByIDUpdate] Script Date: 2018/12/13 19:09:59 ******/
  5253. SET ANSI_NULLS ON
  5254. GO
  5255. SET QUOTED_IDENTIFIER ON
  5256. GO
  5257. --#####################################################
  5258. --创建时间:2014.11.18
  5259. --创建人:Nick
  5260. --说明:根据ID修改点评信息
  5261. --#####################################################
  5262. CREATE PROCEDURE [dbo].[ProcCommentsByIDUpdate]
  5263. (
  5264. @ID INT,
  5265. @Relation INT,
  5266. @GradeStar INT,
  5267. @Remark1 NVARCHAR(MAX),
  5268. @Remark2 NVARCHAR(MAX),
  5269. @Remark3 NVARCHAR(MAX),
  5270. @Title NVARCHAR(50),
  5271. @Position NVARCHAR(50),
  5272. @WorkRegionID INT,
  5273. @EntryDate VARCHAR(6),
  5274. @QuitDate VARCHAR(6),
  5275. @CommentType INT,
  5276. @VerifyMan INT
  5277. )
  5278. AS
  5279. BEGIN TRY
  5280. DECLARE @AddDate DATETIME,@CpName NVARCHAR(100),@Title2 NVARCHAR(50)
  5281. SELECT @AddDate = a.AddDate,@CpName = b.Name,@Title2 = a.Title
  5282. FROM Comments a,Cpmain b
  5283. WHERE a.ID = @ID
  5284. AND a.CpMainID = b.ID
  5285. UPDATE Comments
  5286. SET Relation = @Relation,
  5287. GradeStar = @GradeStar,
  5288. Remark1 = @Remark1,
  5289. Remark2 = @Remark2,
  5290. Remark3 = @Remark3,
  5291. Title = @Title,
  5292. Position = @Position,
  5293. WorkRegionID = @WorkRegionID,
  5294. EntryDate = @EntryDate,
  5295. QuitDate = @QuitDate,
  5296. CommentType = @CommentType,
  5297. VerifyMan = @VerifyMan,
  5298. VerifyDate = GETDATE()
  5299. WHERE CpMainID IN (SELECT ID FROM CPMAIN WHERE Name = @CpName)
  5300. AND AddDate = @AddDate
  5301. AND Title = @Title2
  5302. END TRY
  5303. BEGIN CATCH
  5304. RETURN 0
  5305. END CATCH
  5306. GO
  5307. /****** Object: StoredProcedure [dbo].[ProcCommentsByKeyWordSelect] Script Date: 2018/12/13 19:09:59 ******/
  5308. SET ANSI_NULLS ON
  5309. GO
  5310. SET QUOTED_IDENTIFIER ON
  5311. GO
  5312. --###########################
  5313. --创建时间:2014.11.27
  5314. --创建人:Nick
  5315. --说明:获取点评公司列表
  5316. --###########################
  5317. CREATE PROCEDURE [dbo].[ProcCommentsByKeyWordSelect]
  5318. (
  5319. @dcRegionID VARCHAR(100),
  5320. @PageNo INT,
  5321. @KeyWord VARCHAR(50)
  5322. )
  5323. AS
  5324. BEGIN
  5325. DECLARE @WHERE VARCHAR(MAX),@JobPlace AS VARCHAR(2000),@WHERE2 VARCHAR(MAX)
  5326. SET @JobPlace = ''
  5327. SET @WHERE = ''
  5328. SET @WHERE2 = ''
  5329. IF CHARINDEX(',',@dcRegionID)>0
  5330. BEGIN
  5331. DECLARE @T_JobPlace AS TABLE(ID INT)
  5332. INSERT INTO @T_JobPlace
  5333. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  5334. SELECT @JobPlace = (@JobPlace + ' OR b.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  5335. IF LEN(@JobPlace) > 0
  5336. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  5337. SET @WHERE = @WHERE + '
  5338. AND (' + @JobPlace + ')'
  5339. SET @WHERE2 = @WHERE2 + '
  5340. AND (' + @JobPlace + ')'
  5341. END
  5342. ELSE
  5343. BEGIN
  5344. SET @WHERE = ' AND (b.dcRegionID Like '''+@dcRegionID+'%'')'
  5345. SET @WHERE2 = ' AND (b.dcRegionID Like '''+@dcRegionID+'%'')'
  5346. END
  5347. SET @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, ''))
  5348. IF @KeyWord <> ''
  5349. BEGIN
  5350. SET @WHERE = @WHERE + ' AND b.Name LIKE ''%'+@KeyWord+'%'' '
  5351. END
  5352. DECLARE @PageSize INT
  5353. SET @PageSize = 5
  5354. DECLARE @PageLowerBound INT --定义此页的底码
  5355. DECLARE @PageUpperBound INT --定义此页的顶码
  5356. SET @PageLowerBound = (@PageNo -1) * @pagesize
  5357. SET @PageUpperBound = @PageLowerBound + @pagesize
  5358. DECLARE @AllCnt INT
  5359. SET @AllCnt = 0
  5360. DECLARE @SQL NVARCHAR(MAX)
  5361. --创建临时表
  5362. CREATE TABLE #T1(
  5363. [cpmainid] [int] NOT NULL,
  5364. [name] [varchar](100) NULL,
  5365. [secondid] varchar(12) NULL,
  5366. [AddDate] [datetime] NULL,
  5367. [OrderBY] [int] NULL
  5368. )
  5369. IF @KeyWord = ''
  5370. BEGIN
  5371. SET @SQL = '
  5372. INSERT INTO #T1
  5373. SELECT TOP 500 cpmainid,b.name,b.secondid,a.AddDate,1 AS OrderBY
  5374. FROM comments a,cpmain b
  5375. WHERE a.id IN(SELECT TOP 999 MAX(id) FROM comments GROUP BY cpmainid ORDER BY MAX(ID) DESC)
  5376. AND a.cpmainid = b.id AND a.CommentType IN(1,2) '+@WHERE+'
  5377. AND a.IsDirect = 1
  5378. ORDER BY a.adddate DESC '
  5379. EXEC(@SQL)
  5380. END
  5381. ELSE
  5382. BEGIN
  5383. SET @SQL = '
  5384. INSERT INTO #T1
  5385. SELECT TOP 500 b.ID AS cpmainid,b.Name, b.SecondId, LastLoginDate AS AddDate,1 AS OrderBY
  5386. FROM cpMainPublish b WITH(NOLOCK),
  5387. CONTAINSTABLE(cpMainPublish, Name, '''+@KeyWord+''', 100) AS a
  5388. WHERE b.Id = a.[Key] '+@WHERE2+'
  5389. ORDER BY b. LastLoginDate DESC '
  5390. --PRINT(@SQL)
  5391. EXEC(@SQL)
  5392. IF NOT EXISTS(SELECT 'x' FROM #T1)
  5393. BEGIN
  5394. SET @SQL = '
  5395. INSERT INTO #T1
  5396. SELECT TOP 500 b.ID AS cpmainid,b.Name, b.SecondId, LastLoginDate AS AddDate,1 AS OrderBY
  5397. FROM cpMainPublish b WITH(NOLOCK INDEX(IX_cpMainPublish_Name))
  5398. WHERE 1=1 '+@WHERE+'
  5399. ORDER BY b. LastLoginDate DESC '
  5400. --PRINT(@SQL)
  5401. EXEC(@SQL)
  5402. END
  5403. END
  5404. SELECT @AllCnt = COUNT(*) FROM #T1
  5405. IF @KeyWord <> '' --对临时表 #T1 进行排序 修改最后点评时间
  5406. BEGIN
  5407. UPDATE a
  5408. SET a.AddDate = b.AddDate,a.OrderBY = b.OrderBY
  5409. FROM #T1 a,(
  5410. SELECT AddDate,CpMainID,2 AS OrderBy
  5411. FROM Comments
  5412. WHERE ID IN(SELECT MAX(id) FROM comments GROUP BY cpmainid)
  5413. ) b
  5414. WHERE a.CpmainID = b.CpMainID
  5415. END
  5416. SELECT * ,ROW_NUMBER() OVER( ORDER BY OrderBY DESC,AddDate DESC) AS num INTO #T2 FROM #T1
  5417. --创建临时表
  5418. CREATE TABLE #T3(
  5419. [cpmainid] [int] NOT NULL,
  5420. [name] [varchar](100) NULL,
  5421. [secondid] varchar(12) NULL,
  5422. [AddDate] [datetime] NULL,
  5423. [OrderBY] [int] NULL,
  5424. [num] [int] null,
  5425. cnt INT NULL,
  5426. Score DECIMAL(18, 1) NULL
  5427. )
  5428. INSERT INTO #T3
  5429. SELECT *,0 AS cnt,1.0 AS Score FROM #T2 WHERE NUM > @PageLowerBound AND NUM <= @PageUpperBound
  5430. --修改评价数量
  5431. UPDATE a
  5432. SET a.cnt = b.Num
  5433. FROM #T3 a,(
  5434. SELECT COUNT(*) AS num,CpMainID
  5435. FROM Comments
  5436. WHERE (CommentType IN (1,2))
  5437. AND CpMainID IN (SELECT CpMainID FROM #T3)
  5438. GROUP BY CpMainID
  5439. )b
  5440. WHERE a.CpMainID = b.CpMainID
  5441. --修改平均分数
  5442. UPDATE a
  5443. SET a.Score = b.Score
  5444. FROM #T3 a,(
  5445. SELECT SUM(GradeStar)*1.0 AS Score,CpMainID
  5446. FROM Comments
  5447. WHERE CommentType IN (1,2)
  5448. AND CpMainID IN (SELECT CpMainID FROM #T3)
  5449. GROUP BY CpMainID
  5450. )b
  5451. WHERE a.CpMainID = b.CpMainID
  5452. UPDATE #T3
  5453. SET Score = CONVERT(DECIMAL(18,1),(Score*1.0)/(cnt*1.0))
  5454. WHERE cnt>0
  5455. UPDATE #T3
  5456. SET Score = 0
  5457. WHERE cnt = 0
  5458. --拷贝列
  5459. CREATE TABLE #T5(
  5460. [ID] [int] NOT NULL,
  5461. [CpMainID] [int] NOT NULL,
  5462. [PaMainID] [int] NOT NULL,
  5463. [IP] [varchar](15) NULL,
  5464. [SessionID] [varchar](50) NULL,
  5465. [Relation] [tinyint] NOT NULL,
  5466. [GradeStar] [tinyint] NOT NULL,
  5467. [Remark1] [nvarchar](max) NOT NULL,
  5468. [Remark2] [nvarchar](max) NOT NULL,
  5469. [Remark3] [nvarchar](max) NOT NULL,
  5470. [Title] [nvarchar](50) NOT NULL,
  5471. [Position] [nvarchar](50) NULL,
  5472. [WorkRegionID] [varchar](6) NULL,
  5473. [EntryDate] [varchar](6) NULL,
  5474. [QuitDate] [varchar](6) NULL,
  5475. [AddDate] [smalldatetime] NOT NULL,
  5476. [CommentType] [tinyint] NULL,
  5477. [VerifyMan] [int] NULL,
  5478. [VerifyDate] [smalldatetime] NULL,
  5479. [ReplyDate] [smalldatetime] NULL,
  5480. [ReplyContent] [nvarchar](max) NULL,
  5481. [ReplyVerifyMan] [int] NULL,
  5482. [ReplyVerifyDate] [smalldatetime] NULL,
  5483. [PraiseCount] [int] NULL,
  5484. [LoginPraiseCount] [int] NULL,
  5485. [ReplyVerifyResult] [int] NULL,
  5486. [IsDirect] [BIT] NULL,
  5487. [rid] [int] NULL
  5488. )
  5489. DECLARE @CpCnt INT --公司数量
  5490. SELECT @CpCnt = COUNT(*) FROM #T3
  5491. IF @CpCnt = 1
  5492. BEGIN
  5493. --取10条点评
  5494. INSERT INTO #T5
  5495. SELECT * FROM
  5496. (
  5497. SELECT *,rid=ROW_NUMBER() OVER(PARTITION BY a.CpmainID ORDER BY a.AddDate DESC)
  5498. FROM Comments a
  5499. WHERE (a.CommentType IN (1,2))
  5500. AND CpMainID IN (SELECT CpMainID FROM #T3)
  5501. ) AS c
  5502. WHERE c.rid<=10
  5503. END
  5504. ELSE
  5505. BEGIN
  5506. --取2条点评
  5507. INSERT INTO #T5
  5508. SELECT * FROM
  5509. (
  5510. SELECT *,rid=ROW_NUMBER() OVER(PARTITION BY a.CpmainID ORDER BY a.AddDate DESC)
  5511. FROM Comments a
  5512. WHERE (a.CommentType IN (1,2))
  5513. AND CpMainID IN (SELECT CpMainID FROM #T3)
  5514. ) AS c
  5515. WHERE c.rid<=2
  5516. END
  5517. SELECT * FROM #T3 --公司列表
  5518. SELECT @AllCnt --所有公司数
  5519. SELECT * FROM #T5 --点评数
  5520. --DROP TABLE #T1
  5521. DROP TABLE #T5
  5522. END
  5523. GO
  5524. /****** Object: StoredProcedure [dbo].[ProcCommentsByPaMainIDSelect] Script Date: 2018/12/13 19:10:00 ******/
  5525. SET ANSI_NULLS ON
  5526. GO
  5527. SET QUOTED_IDENTIFIER ON
  5528. GO
  5529. --#####################################################
  5530. --创建时间:2014.11.12
  5531. --创建人:Nick
  5532. --说明:判断用户是否发布过点评或面试经历
  5533. --#####################################################
  5534. CREATE PROCEDURE [dbo].[ProcCommentsByPaMainIDSelect]
  5535. (
  5536. @PamainID INT,
  5537. @Type INT --1点评 2面试经历
  5538. )
  5539. AS
  5540. BEGIN
  5541. IF @Type = 1
  5542. BEGIN
  5543. SELECT ID FROM Comments WHERE CommentType<>3 AND PamainID = @PamainID
  5544. END
  5545. ELSE
  5546. BEGIN
  5547. SELECT ID FROM InterView WHERE InterviewType<>3 AND PamainID = @PamainID
  5548. END
  5549. End
  5550. GO
  5551. /****** Object: StoredProcedure [dbo].[ProcCommentsByReplyUpdate] Script Date: 2018/12/13 19:10:00 ******/
  5552. SET ANSI_NULLS ON
  5553. GO
  5554. SET QUOTED_IDENTIFIER ON
  5555. GO
  5556. --#####################################################
  5557. --创建时间:2014.11.20
  5558. --创建人:Nick
  5559. --说明:点评回复
  5560. --#####################################################
  5561. CREATE PROCEDURE [dbo].[ProcCommentsByReplyUpdate]
  5562. (
  5563. @ID INT,
  5564. @ReplyContent NVARCHAR(MAX)
  5565. )
  5566. AS
  5567. BEGIN
  5568. UPDATE Comments
  5569. SET ReplyContent = @ReplyContent,
  5570. ReplyDate = GETDATE() ,
  5571. ReplyVerifyResult = NULL ,
  5572. ReplyVerifyDate = NULL
  5573. WHERE ID = @ID
  5574. AND (ReplyVerifyResult <> 1 OR ReplyVerifyResult IS NULL)
  5575. End
  5576. GO
  5577. /****** Object: StoredProcedure [dbo].[ProcCommentsHotSelect] Script Date: 2018/12/13 19:10:00 ******/
  5578. SET ANSI_NULLS ON
  5579. GO
  5580. SET QUOTED_IDENTIFIER ON
  5581. GO
  5582. --#####################################################
  5583. --创建时间:2014.11.27
  5584. --创建人:Nick
  5585. --说明:获取最多点评排行 最佳点评排行
  5586. --#####################################################
  5587. CREATE PROCEDURE [dbo].[ProcCommentsHotSelect]
  5588. (
  5589. @ProvinceID INT
  5590. )
  5591. AS
  5592. BEGIN
  5593. --最多面经排行
  5594. SELECT * FROM SearchDB..CommentsHot
  5595. WHERE CommentType = 1
  5596. AND TypeID = 1
  5597. AND dcProvinceID = @ProvinceID
  5598. ORDER BY Cnt DESC
  5599. --最佳点评排行
  5600. SELECT * FROM SearchDB..CommentsHot
  5601. WHERE CommentType = 1
  5602. AND TypeID = 2
  5603. AND dcProvinceID = @ProvinceID
  5604. ORDER BY Cnt DESC
  5605. END
  5606. GO
  5607. /****** Object: StoredProcedure [dbo].[ProcCommentsInsert] Script Date: 2018/12/13 19:10:00 ******/
  5608. SET ANSI_NULLS ON
  5609. GO
  5610. SET QUOTED_IDENTIFIER ON
  5611. GO
  5612. --#####################################################
  5613. --创建时间:2014.11.20
  5614. --创建人:Nick
  5615. --说明:插入点评
  5616. --#####################################################
  5617. CREATE PROCEDURE [dbo].[ProcCommentsInsert]
  5618. (
  5619. @CpmainID INT,
  5620. @PaMainID INT,
  5621. @IP VARCHAR(15),
  5622. @SessionID VARCHAR(50),
  5623. @Relation INT,
  5624. @GradeStar INT,
  5625. @Remark1 NVARCHAR(MAX),
  5626. @Remark2 NVARCHAR(MAX),
  5627. @Remark3 NVARCHAR(MAX),
  5628. @Title NVARCHAR(50),
  5629. @Position NVARCHAR(50),
  5630. @WorkRegionID INT,
  5631. @EntryDate VARCHAR(6),
  5632. @QuitDate VARCHAR(6)
  5633. )
  5634. AS
  5635. BEGIN
  5636. DECLARE @MemberType INT
  5637. SELECT @MemberType = MemberType FROM CpMain WHERE ID = @CpmainID
  5638. IF @MemberType > 1
  5639. BEGIN
  5640. INSERT INTO Comments (CpmainID,PaMainID,IP,SessionID,Relation,GradeStar,Remark1,Remark2,Remark3,Title,
  5641. Position,WorkRegionID,EntryDate,QuitDate,AddDate,PraiseCount,LoginPraiseCount,CommentType,IsDirect)
  5642. SELECT ID,@PaMainID,@IP,@SessionID,@Relation,@GradeStar,@Remark1,@Remark2,@Remark3,@Title,
  5643. @Position,@WorkRegionID,@EntryDate,@QuitDate,GETDATE(),0,0 ,0,0
  5644. FROM CPMAIN
  5645. WHERE NAME = (
  5646. SELECT Name FROM CpMain WHERE ID = @CpmainID)
  5647. AND MemberType > 1
  5648. AND ID <> @CpmainID
  5649. END
  5650. INSERT INTO Comments (CpmainID,PaMainID,IP,SessionID,Relation,GradeStar,Remark1,Remark2,Remark3,Title,
  5651. Position,WorkRegionID,EntryDate,QuitDate,AddDate,PraiseCount,LoginPraiseCount,CommentType,IsDirect)
  5652. VALUES(@CpmainID,@PaMainID,@IP,@SessionID,@Relation,@GradeStar,@Remark1,@Remark2,@Remark3,@Title,
  5653. @Position,@WorkRegionID,@EntryDate,@QuitDate,GETDATE(),0,0 ,0,1 )
  5654. End
  5655. GO
  5656. /****** Object: StoredProcedure [dbo].[ProcCommentsInterviewByHomePageSelect] Script Date: 2018/12/13 19:10:01 ******/
  5657. SET ANSI_NULLS ON
  5658. GO
  5659. SET QUOTED_IDENTIFIER ON
  5660. GO
  5661. --#####################################################
  5662. --创建时间:2014.12.3
  5663. --创建人:John
  5664. --说明:前台首页根据省份ID获取点评与面经的最新5条记录
  5665. --#####################################################
  5666. CREATE PROCEDURE [dbo].[ProcCommentsInterviewByHomePageSelect]
  5667. (
  5668. @dcProvinceID INT
  5669. )
  5670. AS
  5671. BEGIN
  5672. SELECT TOP 0 * FROM SearchDb..Hp_Comments WITH(NOLOCK) --WHERE ProvinceId = @dcProvinceID ORDER BY AddDate DESC
  5673. /*
  5674. SELECT TOP 5 * FROM
  5675. (
  5676. SELECT * FROM
  5677. (
  5678. SELECT TOP 5 a.ID,a.CpMainID,a.Title,a.AddDate,1 AS CIType, a.CommentType AS IsGood,b.Name,b.SecondID
  5679. FROM Comments a WITH(NOLOCK),CpMain b WITH(NOLOCK)
  5680. WHERE a.CommentType IN (1,2)
  5681. AND a.CpMainID = b.ID
  5682. AND b.dcRegionID like ''+CONVERT(VARCHAR(6),@dcProvinceID)+'%'
  5683. AND a.IsDirect = 1
  5684. ORDER BY a.AddDate DESC
  5685. ) AS tempComment
  5686. UNION
  5687. SELECT * FROM
  5688. (
  5689. SELECT TOP 5 a.ID,a.CpMainID,a.Title,a.AddDate,2 AS CIType, a.InterviewType AS IsGood,b.Name,b.SecondID
  5690. FROM InterView a WITH(NOLOCK), cpmain b WITH(NOLOCK)
  5691. WHERE a.InterviewType IN (1,2)
  5692. AND a.CpMainID = b.ID
  5693. AND b.dcRegionID like ''+CONVERT(VARCHAR(6),@dcProvinceID)+'%'
  5694. AND a.IsDirect = 1
  5695. ORDER BY a.AddDate DESC
  5696. ) AS tempInterview
  5697. ) AS CIResult ORDER BY AddDate DESC
  5698. */
  5699. END
  5700. GO
  5701. /****** Object: StoredProcedure [dbo].[ProcCommentsReplyByIDUpdate] Script Date: 2018/12/13 19:10:01 ******/
  5702. SET ANSI_NULLS ON
  5703. GO
  5704. SET QUOTED_IDENTIFIER ON
  5705. GO
  5706. --#####################################################
  5707. --创建时间:2014.11.18
  5708. --创建人:Nick
  5709. --说明:根据ID修改点评回复信息
  5710. --#####################################################
  5711. CREATE PROCEDURE [dbo].[ProcCommentsReplyByIDUpdate]
  5712. (
  5713. @ID INT,
  5714. @ReplyContent NVARCHAR(MAX),
  5715. @ReplyVerifyMan INT,
  5716. @ReplyVerifyResult INT
  5717. )
  5718. AS
  5719. BEGIN
  5720. UPDATE Comments
  5721. SET ReplyContent = @ReplyContent,
  5722. ReplyVerifyMan = @ReplyVerifyMan,
  5723. ReplyVerifyDate = GETDATE(),
  5724. ReplyVerifyResult = @ReplyVerifyResult
  5725. WHERE ID = @ID
  5726. END
  5727. GO
  5728. /****** Object: StoredProcedure [dbo].[ProcCommentsSelect] Script Date: 2018/12/13 19:10:01 ******/
  5729. SET ANSI_NULLS ON
  5730. GO
  5731. SET QUOTED_IDENTIFIER ON
  5732. GO
  5733. --#####################################################
  5734. --创建时间:2014.11.18
  5735. --创建人:Nick
  5736. --说明:查询 点评信息 用于后台审核
  5737. --#####################################################
  5738. CREATE PROCEDURE [dbo].[ProcCommentsSelect]
  5739. (
  5740. @Type INT, --1 待审核 点评 2 最近审核 点评 3待审核点评回复 4最近审核 点评回复
  5741. @Where VARCHAR(MAX)
  5742. )
  5743. AS
  5744. BEGIN
  5745. DECLARE @SQL VARCHAR(MAX)
  5746. IF @Type = 1
  5747. BEGIN
  5748. SET @SQL = '
  5749. SELECT a.*,b.name AS CpName,b.RegDate,
  5750. CASE a.PamainID
  5751. WHEN 0 THEN IP
  5752. ELSE (SELECT Name FROM PaMain WHERE ID = a.PaMainID)
  5753. END AS PaName
  5754. FROM Comments a,CpMain b
  5755. WHERE VerifyDate IS NULL
  5756. AND a.IsDirect = 1
  5757. AND a.CpMainID = b.ID '+@Where+'
  5758. ORDER BY AddDate DESC '
  5759. END
  5760. ELSE IF @Type = 2
  5761. BEGIN
  5762. SET @SQL = '
  5763. SELECT a.*,b.name AS CpName ,b.RegDate,
  5764. CASE a.PamainID
  5765. WHEN 0 THEN IP
  5766. ELSE (SELECT Name FROM PaMain WHERE ID = a.PaMainID)
  5767. END AS PaName
  5768. FROM Comments a,CpMain b
  5769. WHERE VerifyDate IS NOT NULL
  5770. AND a.CpMainID = b.ID '+@Where+'
  5771. ORDER BY VerifyDate DESC'
  5772. END
  5773. ELSE IF @Type = 3
  5774. BEGIN
  5775. SET @SQL = '
  5776. SELECT a.*,b.name AS CpName ,b.RegDate,
  5777. CASE a.PamainID
  5778. WHEN 0 THEN IP
  5779. ELSE (SELECT Name FROM PaMain WHERE ID = a.PaMainID)
  5780. END AS PaName
  5781. FROM Comments a,CpMain b
  5782. WHERE ReplyVerifyDate IS NULL
  5783. AND a.CpMainID = b.ID '+@Where+'
  5784. ORDER BY ReplyDate DESC'
  5785. END
  5786. ELSE IF @Type = 4
  5787. BEGIN
  5788. SET @SQL = '
  5789. SELECT a.*,b.name AS CpName ,b.RegDate,
  5790. CASE a.PamainID
  5791. WHEN 0 THEN IP
  5792. ELSE (SELECT Name FROM PaMain WHERE ID = a.PaMainID)
  5793. END AS PaName
  5794. FROM Comments a,CpMain b
  5795. WHERE ReplyVerifyDate IS NOT NULL
  5796. AND a.CpMainID = b.ID '+@Where+'
  5797. ORDER BY ReplyVerifyDate DESC'
  5798. END
  5799. EXEC(@SQL)
  5800. END
  5801. GO
  5802. /****** Object: StoredProcedure [dbo].[ProcCommentsVerifyUpdate] Script Date: 2018/12/13 19:10:01 ******/
  5803. SET ANSI_NULLS ON
  5804. GO
  5805. SET QUOTED_IDENTIFIER ON
  5806. GO
  5807. --#####################################################
  5808. --创建时间:2014.11.19
  5809. --创建人:Nick
  5810. --说明:批量审核点评或面试信息
  5811. ---增加审核记录,用于计算审核延误7
  5812. --#####################################################
  5813. CREATE PROCEDURE [dbo].[ProcCommentsVerifyUpdate]
  5814. (
  5815. @ID INT,
  5816. @Type INT , -- 1点评 2点评 回复 3 面试经历 4面试经历回复
  5817. @VerifyMan INT,
  5818. @VerifyResult INT
  5819. )
  5820. AS
  5821. SET NOCOUNT ON
  5822. BEGIN
  5823. DECLARE @submitDate DATETIME
  5824. IF @Type = 1
  5825. BEGIN
  5826. UPDATE Comments
  5827. SET VerifyMan = @VerifyMan,
  5828. VerifyDate = GETDATE(),
  5829. CommentType = @VerifyResult
  5830. WHERE ID =@ID
  5831. SELECT @submitDate=AddDate
  5832. FROM Comments
  5833. WHERE ID =@ID
  5834. END
  5835. ELSE IF @Type = 2
  5836. BEGIN
  5837. UPDATE Comments
  5838. SET ReplyVerifyMan = @VerifyMan,
  5839. ReplyVerifyDate = GETDATE(),
  5840. ReplyVerifyResult = @VerifyResult
  5841. WHERE ID =@ID
  5842. SELECT @submitDate=ReplyDate
  5843. FROM Comments
  5844. WHERE ID =@ID
  5845. END
  5846. ELSE IF @Type = 3
  5847. BEGIN
  5848. UPDATE Interview
  5849. SET VerifyMan = @VerifyMan,
  5850. VerifyDate = GETDATE(),
  5851. InterviewType = @VerifyResult
  5852. WHERE ID =@ID
  5853. SELECT @submitDate=AddDate
  5854. FROM Interview
  5855. WHERE ID =@ID
  5856. END
  5857. ELSE IF @Type = 4
  5858. BEGIN
  5859. UPDATE Interview
  5860. SET ReplyVerifyMan = @VerifyMan,
  5861. ReplyVerifyDate = GETDATE(),
  5862. ReplyVerifyResult = @VerifyResult
  5863. WHERE ID =@ID
  5864. SELECT @submitDate=ReplyDate
  5865. FROM Interview
  5866. WHERE ID =@ID
  5867. END
  5868. --插入审核延误记录表
  5869. INSERT INTO logdb..VerifyDelayLog(verifyType, relationId, submitDate, verifyDate, verifyMan)
  5870. SELECT 7,@ID,@submitDate, GETDATE(), @VerifyMan
  5871. END
  5872. GO
  5873. /****** Object: StoredProcedure [dbo].[procCompanyByFixPositionIndustrySelect] Script Date: 2018/12/13 19:10:01 ******/
  5874. SET ANSI_NULLS ON
  5875. GO
  5876. SET QUOTED_IDENTIFIER ON
  5877. GO
  5878. --创建人 sean
  5879. --20111121
  5880. --用于首页查询固定位置单位名称,按行业划分的
  5881. --###########################3
  5882. ---知名企业招聘的hot 是按照 职位的最新增加日期, 加hot的大约是总数的1/5
  5883. ---推荐职位 是在最新发布的职位上加new,数量平均6、7个
  5884. ---热门职位是根据营业执照审核时间最新的加hot,数量是10个
  5885. --###########################3
  5886. CREATE PROCEDURE [dbo].[procCompanyByFixPositionIndustrySelect]
  5887. (
  5888. @subSiteID INT
  5889. )
  5890. AS
  5891. BEGIN
  5892. DECLARE @t AS TABLE(
  5893. ID int IDENTITY(1,1),
  5894. cpMainID VARCHAR(10),
  5895. Name varchar(100),
  5896. JobID varchar(max),
  5897. JobName nvarchar(max),
  5898. Paid numeric(18, 2),
  5899. OpenDate smalldatetime,
  5900. NewXId VARCHAR(12),
  5901. AddDate datetime,
  5902. caORderID INT,
  5903. IndustryCategory INT,
  5904. NoFollow VARCHAR(1)
  5905. )
  5906. IF @subSiteID < 100 --省站
  5907. INSERT @t(cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, IndustryCategory, NoFollow)
  5908. SELECT cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, IndustryCategory, NoFollow
  5909. FROM FpFixPosition
  5910. WHERE dcProvinceId = @subSiteID
  5911. ORDER BY AddDate DESC
  5912. ELSE
  5913. INSERT @t(cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, IndustryCategory, NoFollow)
  5914. SELECT cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, IndustryCategory, NoFollow
  5915. FROM FpFixPosition
  5916. WHERE dcRegionID LIKE LTRIM(STR(@subSiteID)) + '%'
  5917. OR dcSubSiteID LIKE LTRIM(STR(@subSiteID)) + '%'
  5918. ORDER BY AddDate DESC
  5919. DECLARE @Num INT, @FlagNum INT, @Sql VARCHAR(MAX)
  5920. SELECT @Num = COUNT(1) FROM @t
  5921. IF @Num > 3
  5922. BEGIN
  5923. SELECT @FlagNum = @Num / 3 + 1
  5924. UPDATE @t SET NewXId = NULL WHERE ID > @FlagNum
  5925. END
  5926. ----加New图标
  5927. SELECT ID, NoFollow + cpMainID cpMainID, Name, JobID, JobName, Paid, OpenDate, NewXId, AddDate, caORderID, IndustryCategory
  5928. FROM @t
  5929. ORDER BY IndustryCategory, CASE Paid WHEN 0 THEN 100 ELSE 0 END, OpenDate DESC
  5930. END
  5931. GO
  5932. /****** Object: StoredProcedure [dbo].[procCompanyByFixPositionSecIndustrySelect] Script Date: 2018/12/13 19:10:02 ******/
  5933. SET ANSI_NULLS ON
  5934. GO
  5935. SET QUOTED_IDENTIFIER ON
  5936. GO
  5937. --创建人 sean
  5938. --20111121
  5939. --用于首页查询固定位置单位名称,按行业划分的
  5940. --###########################3
  5941. ---知名企业招聘的hot 是按照 职位的最新增加日期, 加hot的大约是总数的1/5
  5942. ---推荐职位 是在最新发布的职位上加new,数量平均6、7个
  5943. ---热门职位是根据营业执照审核时间最新的加hot,数量是10个
  5944. --###########################3
  5945. CREATE PROCEDURE [dbo].[procCompanyByFixPositionSecIndustrySelect]
  5946. (
  5947. @subSiteID INT
  5948. )
  5949. AS
  5950. BEGIN
  5951. DECLARE @t AS TABLE(
  5952. ID int IDENTITY(1,1),
  5953. cpMainID VARCHAR(10),
  5954. Name varchar(100),
  5955. JobID varchar(max),
  5956. JobName nvarchar(max),
  5957. Paid numeric(18, 2),
  5958. OpenDate smalldatetime,
  5959. NewXId VARCHAR(12),
  5960. AddDate datetime,
  5961. caORderID INT,
  5962. IndustryCategory INT,
  5963. NoFollow VARCHAR(1)
  5964. )
  5965. IF @subSiteID < 100 --省站
  5966. INSERT @t(cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, IndustryCategory, NoFollow)
  5967. SELECT cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, IndustryCategory, NoFollow
  5968. FROM FpFixPosition
  5969. WHERE dcProvinceId = @subSiteID
  5970. ORDER BY AddDate DESC
  5971. ELSE
  5972. INSERT @t(cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, IndustryCategory, NoFollow)
  5973. SELECT cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, IndustryCategory, NoFollow
  5974. FROM FpFixPosition
  5975. WHERE dcRegionID LIKE LTRIM(STR(@subSiteID)) + '%'
  5976. OR dcSubSiteID LIKE LTRIM(STR(@subSiteID)) + '%'
  5977. ORDER BY AddDate DESC
  5978. DECLARE @Num INT, @FlagNum INT, @Sql VARCHAR(MAX)
  5979. SELECT @Num = COUNT(1) FROM @t
  5980. IF @Num > 3
  5981. BEGIN
  5982. SELECT @FlagNum = @Num / 3 + 1
  5983. UPDATE @t SET NewXId = NULL WHERE ID > @FlagNum
  5984. END
  5985. ----加New图标
  5986. SELECT ID, NoFollow + cpMainID cpMainID, Name, JobID, JobName, Paid, OpenDate, NewXId, AddDate, caORderID, IndustryCategory
  5987. FROM @t
  5988. ORDER BY IndustryCategory, CASE Paid WHEN 0 THEN 100 ELSE 0 END, OpenDate DESC
  5989. END
  5990. GO
  5991. /****** Object: StoredProcedure [dbo].[procCompanyByFixPositionSecSelect] Script Date: 2018/12/13 19:10:02 ******/
  5992. SET ANSI_NULLS ON
  5993. GO
  5994. SET QUOTED_IDENTIFIER ON
  5995. GO
  5996. --创建人 Lambo
  5997. --20101009
  5998. --用于首页查询固定位置单位名称
  5999. --###########################3
  6000. ---知名企业招聘的hot 是按照 职位的最新增加日期, 加hot的大约是总数的1/5
  6001. ---推荐职位 是在最新发布的职位上加new,数量平均6、7个
  6002. ---热门职位是根据营业执照审核时间最新的加hot,数量是10个
  6003. --###########################3
  6004. CREATE PROCEDURE [dbo].[procCompanyByFixPositionSecSelect]
  6005. (
  6006. @subSiteID INT
  6007. )
  6008. AS
  6009. BEGIN
  6010. DECLARE @t AS TABLE(
  6011. ID int IDENTITY(1,1),
  6012. cpMainID varchar(10),
  6013. Name varchar(100),
  6014. JobID varchar(max),
  6015. JobName nvarchar(max),
  6016. Paid numeric(18, 2),
  6017. OpenDate smalldatetime,
  6018. NewXId VARCHAR(12),
  6019. AddDate datetime,
  6020. caORderID INT,
  6021. NoFollow VARCHAR(1)
  6022. )
  6023. IF @subSiteID < 100 --省站
  6024. INSERT @t(cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow)
  6025. SELECT cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow
  6026. FROM FpFixPosition WITH(NOLOCK)
  6027. WHERE dcProvinceId = @subSiteID
  6028. ORDER BY AddDate DESC
  6029. ELSE
  6030. INSERT @t(cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow)
  6031. SELECT cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow
  6032. FROM FpFixPosition WITH(NOLOCK)
  6033. WHERE dcRegionID LIKE LTRIM(STR(@subSiteID)) + '%'
  6034. OR dcSubSiteID LIKE LTRIM(STR(@subSiteID)) + '%'
  6035. ORDER BY AddDate DESC
  6036. DECLARE @Num INT, @FlagNum INT, @Sql VARCHAR(MAX)
  6037. SELECT @Num = COUNT(1) FROM @t
  6038. IF @Num > 3
  6039. BEGIN
  6040. SELECT @FlagNum = @Num / 3 + 1
  6041. UPDATE @t SET NewXId = NULL WHERE ID > @FlagNum
  6042. END
  6043. ----加New图标
  6044. SELECT ID, NoFollow + cpMainID cpMainID, Name, JobID, JobName, Paid, OpenDate, NewXId, AddDate, caORderID
  6045. FROM @t
  6046. ORDER BY CASE Paid WHEN 0 THEN 100 ELSE 0 END, OpenDate DESC
  6047. END
  6048. GO
  6049. /****** Object: StoredProcedure [dbo].[procCompanyByFixPositionSelect] Script Date: 2018/12/13 19:10:02 ******/
  6050. SET ANSI_NULLS ON
  6051. GO
  6052. SET QUOTED_IDENTIFIER ON
  6053. GO
  6054. --创建人 Lambo
  6055. --20101009
  6056. --用于首页查询固定位置单位名称
  6057. --###########################3
  6058. ---知名企业招聘的hot 是按照 职位的最新增加日期, 加hot的大约是总数的1/5
  6059. ---推荐职位 是在最新发布的职位上加new,数量平均6、7个
  6060. ---热门职位是根据营业执照审核时间最新的加hot,数量是10个
  6061. --###########################3
  6062. CREATE PROCEDURE [dbo].[procCompanyByFixPositionSelect]
  6063. (
  6064. @subSiteID INT
  6065. )
  6066. AS
  6067. BEGIN
  6068. DECLARE @t AS TABLE(
  6069. ID int IDENTITY(1,1),
  6070. cpMainID varchar(10),
  6071. Name varchar(100),
  6072. JobID varchar(max),
  6073. JobName nvarchar(max),
  6074. Paid numeric(18, 2),
  6075. OpenDate smalldatetime,
  6076. NewXId VARCHAR(12),
  6077. AddDate datetime,
  6078. caORderID INT,
  6079. NoFollow VARCHAR(1)
  6080. )
  6081. IF @subSiteID < 100 --省站
  6082. INSERT @t(cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow)
  6083. SELECT cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow
  6084. FROM FpFixPosition WITH(NOLOCK)
  6085. WHERE dcProvinceId = @subSiteID
  6086. ORDER BY Paid DESC, AddDate DESC
  6087. ELSE
  6088. BEGIN
  6089. IF @subSiteID = 3206 AND GETDATE() < '2017-4-29'
  6090. INSERT @t(cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow)
  6091. SELECT cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow
  6092. FROM FpFixPosition WITH(NOLOCK)
  6093. WHERE dcRegionID LIKE LTRIM(STR(@subSiteID)) + '%'
  6094. OR dcSubSiteID LIKE LTRIM(STR(@subSiteID)) + '%'
  6095. OR cpMainId = 'BFE74A5251'
  6096. ORDER BY Paid DESC, AddDate DESC
  6097. ELSE
  6098. INSERT @t(cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow)
  6099. SELECT cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow
  6100. FROM FpFixPosition WITH(NOLOCK)
  6101. WHERE dcRegionID LIKE LTRIM(STR(@subSiteID)) + '%'
  6102. OR dcSubSiteID LIKE LTRIM(STR(@subSiteID)) + '%'
  6103. ORDER BY Paid DESC, AddDate DESC
  6104. END
  6105. DECLARE @Num INT, @FlagNum INT, @Sql VARCHAR(MAX)
  6106. SELECT @Num = COUNT(1) FROM @t
  6107. IF @Num > 3
  6108. BEGIN
  6109. SELECT @FlagNum = @Num / 3 + 1
  6110. UPDATE @t SET NewXId = NULL WHERE ID > @FlagNum
  6111. END
  6112. ----加New图标
  6113. SELECT ID, NoFollow + cpMainID cpMainID, Name, JobID, JobName, Paid, OpenDate, NewXId, AddDate, caORderID
  6114. FROM @t
  6115. ORDER BY CASE Paid WHEN 0 THEN 100 ELSE 0 END, OpenDate DESC
  6116. END
  6117. GO
  6118. /****** Object: StoredProcedure [dbo].[procCompanyHomepageLogoSecSelect] Script Date: 2018/12/13 19:10:02 ******/
  6119. SET ANSI_NULLS ON
  6120. GO
  6121. SET QUOTED_IDENTIFIER ON
  6122. GO
  6123. CREATE PROCEDURE [dbo].[procCompanyHomepageLogoSecSelect]
  6124. (
  6125. @ProvinceID SMALLINT
  6126. )
  6127. AS
  6128. BEGIN
  6129. SELECT ID, Name, ImgFile, JobIDs, JobNames
  6130. FROM SearchDb..cpMainLogoShot
  6131. WHERE dcProvinceID = @ProvinceID
  6132. ORDER BY RowNo
  6133. END
  6134. GO
  6135. /****** Object: StoredProcedure [dbo].[procCompanyHomepageLogoSelect] Script Date: 2018/12/13 19:10:03 ******/
  6136. SET ANSI_NULLS ON
  6137. GO
  6138. SET QUOTED_IDENTIFIER ON
  6139. GO
  6140. CREATE PROCEDURE [dbo].[procCompanyHomepageLogoSelect]
  6141. (
  6142. @ProvinceID SMALLINT
  6143. )
  6144. AS
  6145. BEGIN
  6146. SELECT ID, Name, ImgFile, JobIDs, JobNames, RealCpMainId cpMainId
  6147. FROM SearchDb..cpMainLogoShot
  6148. WHERE dcProvinceID = @ProvinceID
  6149. ORDER BY RowNo
  6150. END
  6151. GO
  6152. /****** Object: StoredProcedure [dbo].[procCompanyHomepageLogoSelectNew] Script Date: 2018/12/13 19:10:03 ******/
  6153. SET ANSI_NULLS ON
  6154. GO
  6155. SET QUOTED_IDENTIFIER ON
  6156. GO
  6157. CREATE PROCEDURE [dbo].[procCompanyHomepageLogoSelectNew]
  6158. (
  6159. @ProvinceID SMALLINT
  6160. )
  6161. AS
  6162. BEGIN
  6163. SELECT ID, Name, ImgFile, JobIDs, JobNames
  6164. FROM SEARCHDB..cpMainLogoShot
  6165. WHERE dcProvinceID = @ProvinceID
  6166. ORDER BY RowNo
  6167. END
  6168. GO
  6169. /****** Object: StoredProcedure [dbo].[procCompanyHomepageSecSelect] Script Date: 2018/12/13 19:10:03 ******/
  6170. SET ANSI_NULLS ON
  6171. GO
  6172. SET QUOTED_IDENTIFIER ON
  6173. GO
  6174. CREATE PROCEDURE [dbo].[procCompanyHomepageSecSelect]
  6175. (
  6176. @SubSiteId INT
  6177. )
  6178. AS
  6179. SET NOCOUNT ON
  6180. BEGIN
  6181. DECLARE @ProvinceID AS INT,
  6182. @RegionType AS INT, ----1:省站;2:二级站
  6183. @RecommendNumber AS INT, ----推荐职位行数
  6184. @HotNumber AS INT, ----热门职位行数
  6185. @RowNumber AS INT,
  6186. @Sql AS VARCHAR(MAX),
  6187. @strRegion AS VARCHAR(100),
  6188. @strMember AS VARCHAR(100)
  6189. SELECT @RecommendNumber = 75, @RegionType = 1, @ProvinceID = @subSiteId
  6190. IF @subSiteId > 100
  6191. BEGIN
  6192. SET @RegionType = 2
  6193. SET @ProvinceID = LEFT(@subSiteId, 2)
  6194. END
  6195. ---将推荐职位的和热门的企业都放在临时表中
  6196. CREATE TABLE #t(
  6197. ID int IDENTITY(1,1) NOT NULL,
  6198. dcSubsiteID smallint NULL,
  6199. dcRegionID varchar(6) COLLATE Chinese_PRC_CI_AS NULL,
  6200. cpMainID VARCHAR(11) NULL,
  6201. Name varchar(100) COLLATE Chinese_PRC_CI_AS NULL,
  6202. IsAgent bit NULL,
  6203. JobNumber int NULL,
  6204. JobID varchar(max) COLLATE Chinese_PRC_CI_AS NULL,
  6205. JobName nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL,
  6206. LastJobIssueDate smalldatetime NULL,
  6207. LastJobId VARCHAR(12) NULL,
  6208. cpLicenceDate smalldatetime NULL,
  6209. RefreshDate smalldatetime NULL,
  6210. MemberType tinyint NULL,
  6211. NewXID VARCHAR(12),
  6212. NoFollow VARCHAR(1),
  6213. RealCpMainId INT
  6214. )
  6215. ---向临时表中填入75行推荐职位的
  6216. AddRecommend:
  6217. SELECT @RowNumber = COUNT(1) FROM #t
  6218. IF @RowNumber = 0
  6219. SET @RowNumber = @RecommendNumber
  6220. ELSE
  6221. SET @RowNumber = @RecommendNumber - @RowNumber
  6222. IF @RegionType = 1 --省
  6223. SET @strRegion = '
  6224. AND dcSubsiteID LIKE ''' + LTRIM(STR(@ProvinceID)) + '%'''
  6225. ELSE
  6226. SET @strRegion = '
  6227. AND (dcRegionID like ''' + LTRIM(STR(@subSiteId)) + '%''
  6228. OR dcSubsiteID = ' + LTRIM(STR(@SubsiteID)) + ')'
  6229. ----再该市注测的企业
  6230. SET @Sql = '
  6231. INSERT #t(dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId)
  6232. SELECT TOP ' + LTRIM(STR(@RowNumber)) + ' dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId
  6233. FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK)
  6234. WHERE JobNumber > 0
  6235. AND MemberType > 2
  6236. AND cpMainID Not IN(SELECT cpMainID FROM #t)'
  6237. SET @Sql = @Sql + @strRegion + '
  6238. ORDER BY RefreshDate DESC'
  6239. EXEC(@SQL)
  6240. SELECT @RowNumber = COUNT(1) FROM #t
  6241. IF((@RowNumber < @RecommendNumber) AND (@RegionType = 2))
  6242. BEGIN
  6243. SELECT @RegionType = 1
  6244. GOTO AddRecommend
  6245. END
  6246. ---向临时表中填入热门职位,按照普通会员的刷新时间计算
  6247. SELECT @HotNumber = 80, @RegionType = 1
  6248. IF @subSiteId > 100
  6249. SET @RegionType = 2
  6250. AddHot:
  6251. SELECT @RowNumber = COUNT(1) FROM #t
  6252. SET @RowNumber = @HotNumber + @RecommendNumber - @RowNumber
  6253. IF @RowNumber < 1
  6254. GOTO AddFlag
  6255. IF @ProvinceID IN (32, 30, 31, 35, 10, 11, 12, 40)
  6256. SET @strMember = '
  6257. AND MemberType = 2'
  6258. ELSE
  6259. BEGIN
  6260. SET @strMember = '
  6261. AND MemberType IN(1, 2)'
  6262. END
  6263. SET @Sql = '
  6264. INSERT #t(dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId)
  6265. SELECT TOP ' + LTRIM(STR(@RowNumber)) + ' dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId
  6266. FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK)
  6267. WHERE JobNumber > 0
  6268. AND cpMainID Not IN(SELECT cpMainID FROM #t)'
  6269. SET @Sql = @Sql + @strRegion + @strMember + '
  6270. ORDER BY RefreshDate DESC'
  6271. EXEC(@SQL)
  6272. SELECT @RowNumber = COUNT(1) FROM #t
  6273. IF((@RowNumber < @RecommendNumber + @HotNumber) AND (@RegionType = 2))
  6274. BEGIN
  6275. SELECT @RegionType = 1
  6276. GOTO AddHot
  6277. END
  6278. AddFlag:
  6279. DELETE FROM #t WHERE ID > @RecommendNumber + @HotNumber
  6280. SELECT @RowNumber = 1 + COUNT(1) / 6 FROM #t WHERE MemberType > 2
  6281. SELECT @SQL = 'UPDATE #t SET NewXId = LastJobID WHERE ID IN(SELECT TOP ' + LTRIM(STR(@RowNumber)) +' ID FROM #t WHERE MemberType > 2 ORDER BY LastJobIssueDate DESC)'
  6282. EXEC(@SQL)
  6283. SELECT @RowNumber = 1 + COUNT(1) / 8 FROM #t WHERE MemberType < 3
  6284. SELECT @SQL = 'UPDATE #t SET NewXId = 1 WHERE ID IN(SELECT TOP ' + LTRIM(STR(@RowNumber)) +' ID FROM #t WHERE MemberType < 3 ORDER BY cpLicenceDate DESC)'
  6285. EXEC(@SQL)
  6286. UPDATE #t SET Name = LEFT(Name, 16) WHERE ID > @RecommendNumber AND NewXId = 1 AND LEN(Name) > 16
  6287. UPDATE #t SET cpMainID = NoFollow + cpMainID
  6288. SELECT ID, dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName,
  6289. LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NewXID
  6290. FROM #t WITH(NOLOCK)
  6291. ORDER BY ID
  6292. DROP TABLE #t
  6293. SET NOCOUNT OFF
  6294. END
  6295. GO
  6296. /****** Object: StoredProcedure [dbo].[procCompanyHomepageSelect] Script Date: 2018/12/13 19:10:04 ******/
  6297. SET ANSI_NULLS ON
  6298. GO
  6299. SET QUOTED_IDENTIFIER ON
  6300. GO
  6301. /***
  6302. *Peter 2014-02-20修改 添加修正热门职位的地区判断
  6303. *
  6304. */
  6305. CREATE PROCEDURE [dbo].[procCompanyHomepageSelect]
  6306. (
  6307. @SubSiteId INT
  6308. )
  6309. AS
  6310. SET NOCOUNT ON
  6311. --INSERT ProcLog SELECT 'procCompanyHomepageSelect', @SubSiteId, GETDATE()
  6312. IF @SubSiteId > 9999
  6313. BEGIN
  6314. EXEC ProcCountyJobSelect @SubSiteId
  6315. RETURN
  6316. END
  6317. BEGIN
  6318. DECLARE @ProvinceID AS INT,
  6319. @RegionType AS INT, ----1:省站;2:二级站
  6320. @RecommendNumber AS INT, ----推荐职位行数
  6321. @HotNumber AS INT, ----热门职位行数
  6322. @RowNumber AS INT,
  6323. @Sql AS VARCHAR(MAX),
  6324. @strRegion AS VARCHAR(100),
  6325. @strMember AS VARCHAR(100)
  6326. SELECT @RecommendNumber = 75, @RegionType = 1, @ProvinceID = @subSiteId
  6327. IF @subSiteId > 100
  6328. BEGIN
  6329. SET @RegionType = 2
  6330. SET @ProvinceID = LEFT(@subSiteId, 2)
  6331. END
  6332. ---将推荐职位的和热门的企业都放在临时表中
  6333. CREATE TABLE #t(
  6334. ID int IDENTITY(1,1) NOT NULL,
  6335. dcSubsiteID smallint NULL,
  6336. dcRegionID varchar(6) COLLATE Chinese_PRC_CI_AS NULL,
  6337. cpMainID VARCHAR(11) NULL,
  6338. Name varchar(100) COLLATE Chinese_PRC_CI_AS NULL,
  6339. IsAgent bit NULL,
  6340. JobNumber int NULL,
  6341. JobID varchar(max) COLLATE Chinese_PRC_CI_AS NULL,
  6342. JobName nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL,
  6343. LastJobIssueDate smalldatetime NULL,
  6344. LastJobId VARCHAR(12) NULL,
  6345. cpLicenceDate smalldatetime NULL,
  6346. RefreshDate smalldatetime NULL,
  6347. MemberType tinyint NULL,
  6348. NewXID VARCHAR(12),
  6349. NoFollow VARCHAR(1),
  6350. RealCpMainId INT
  6351. )
  6352. ---向临时表中填入75行推荐职位的
  6353. AddRecommend:
  6354. SELECT @RowNumber = COUNT(1) FROM #t
  6355. IF @RowNumber = 0
  6356. SET @RowNumber = @RecommendNumber
  6357. ELSE
  6358. SET @RowNumber = @RecommendNumber - @RowNumber
  6359. IF @RegionType = 1 --省
  6360. SET @strRegion = '
  6361. AND dcSubsiteID LIKE ''' + LTRIM(STR(@ProvinceID)) + '%'''
  6362. ELSE
  6363. SET @strRegion = '
  6364. AND (dcRegionID like ''' + LTRIM(STR(@subSiteId)) + '%''
  6365. OR dcSubsiteID = ' + LTRIM(STR(@SubsiteID)) + ')'
  6366. ----再该市注测的企业
  6367. SET @Sql = '
  6368. INSERT #t(dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId)
  6369. SELECT TOP ' + LTRIM(STR(@RowNumber)) + ' dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId
  6370. FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK)
  6371. WHERE JobNumber > 0
  6372. AND MemberType > 2
  6373. AND cpMainID Not IN(SELECT cpMainID FROM #t)'
  6374. SET @Sql = @Sql + @strRegion + '
  6375. ORDER BY RefreshDate DESC'
  6376. --print @sql
  6377. EXEC(@SQL)
  6378. SELECT @RowNumber = COUNT(1) FROM #t
  6379. IF((@RowNumber < @RecommendNumber) AND (@RegionType = 2))
  6380. BEGIN
  6381. SELECT @RegionType = 1
  6382. GOTO AddRecommend
  6383. END
  6384. ---向临时表中填入热门职位,按照普通会员的刷新时间计算
  6385. SELECT @HotNumber = 80, @RegionType = 1
  6386. IF @subSiteId > 100
  6387. SET @RegionType = 2
  6388. AddHot:
  6389. SELECT @RowNumber = COUNT(1) FROM #t
  6390. SET @RowNumber = @HotNumber + @RecommendNumber - @RowNumber
  6391. IF @RowNumber < 1
  6392. GOTO AddFlag
  6393. IF @ProvinceID IN (32, 30, 31, 35, 10, 11, 12, 40)
  6394. SET @strMember = '
  6395. AND MemberType = 2'
  6396. ELSE
  6397. BEGIN
  6398. SET @strMember = '
  6399. AND MemberType IN(1, 2)'
  6400. END
  6401. IF @RegionType = 1 --省
  6402. SET @strRegion = '
  6403. AND dcSubsiteID LIKE ''' + LTRIM(STR(@ProvinceID)) + '%'''
  6404. ELSE
  6405. SET @strRegion = '
  6406. AND (dcRegionID like ''' + LTRIM(STR(@subSiteId)) + '%''
  6407. OR dcSubsiteID = ' + LTRIM(STR(@SubsiteID)) + ')'
  6408. SET @Sql = '
  6409. INSERT #t(dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId)
  6410. SELECT TOP ' + LTRIM(STR(@RowNumber)) + ' dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId
  6411. FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK)
  6412. WHERE JobNumber > 0
  6413. AND cpMainID Not IN(SELECT cpMainID FROM #t)'
  6414. SET @Sql = @Sql + @strRegion + @strMember + '
  6415. ORDER BY RefreshDate DESC'
  6416. EXEC(@SQL)
  6417. SELECT @RowNumber = COUNT(1) FROM #t
  6418. IF((@RowNumber < @RecommendNumber + @HotNumber) AND (@RegionType = 2))
  6419. BEGIN
  6420. SELECT @RegionType = 1
  6421. GOTO AddHot
  6422. END
  6423. AddFlag:
  6424. DELETE FROM #t WHERE ID > @RecommendNumber + @HotNumber
  6425. SELECT @RowNumber = 1 + COUNT(1) / 6 FROM #t WHERE MemberType > 2
  6426. SELECT @SQL = 'UPDATE #t SET NewXId = LastJobID WHERE ID IN(SELECT TOP ' + LTRIM(STR(@RowNumber)) +' ID FROM #t WHERE MemberType > 2 ORDER BY LastJobIssueDate DESC)'
  6427. EXEC(@SQL)
  6428. SELECT @RowNumber = 1 + COUNT(1) / 8 FROM #t WHERE MemberType < 3
  6429. SELECT @SQL = 'UPDATE #t SET NewXId = 1 WHERE ID IN(SELECT TOP ' + LTRIM(STR(@RowNumber)) +' ID FROM #t WHERE MemberType < 3 ORDER BY cpLicenceDate DESC)'
  6430. EXEC(@SQL)
  6431. UPDATE #t SET Name = LEFT(Name, 16) WHERE ID > @RecommendNumber AND NewXId = 1 AND LEN(Name) > 16
  6432. UPDATE #t SET cpMainID = NoFollow + cpMainID
  6433. SELECT ID, dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName,
  6434. LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NewXID
  6435. FROM #t WITH(NOLOCK)
  6436. ORDER BY ID
  6437. DROP TABLE #t
  6438. SET NOCOUNT OFF
  6439. END
  6440. GO
  6441. /****** Object: StoredProcedure [dbo].[ProcCompanyListByCpIDsSelect] Script Date: 2018/12/13 19:10:05 ******/
  6442. SET ANSI_NULLS ON
  6443. GO
  6444. SET QUOTED_IDENTIFIER ON
  6445. GO
  6446. --#####################################################
  6447. --创建时间:2014.11.3
  6448. --创建人:John
  6449. --说明:返回cpid在参数内的企业信息
  6450. --#####################################################
  6451. CREATE PROCEDURE [dbo].[ProcCompanyListByCpIDsSelect]
  6452. (
  6453. @CpIDs VARCHAR(1000)
  6454. )
  6455. AS
  6456. BEGIN
  6457. DECLARE @SQL VARCHAR(2000)
  6458. SET @SQL = 'SELECT TOP 500 a.id AS cpid, a.Name AS companyName, b.id AS caid
  6459. FROM [MainDb]..[cpMain] a, [MainDb]..[caMain] b
  6460. WHERE a.id = b.cpMainID
  6461. AND b.IsPause = 0
  6462. AND b.IsDelete = 0
  6463. AND b.AccountType = 1
  6464. AND a.id IN ( ' + @CpIDs + ' )'
  6465. EXEC(@SQL)
  6466. END
  6467. GO
  6468. /****** Object: StoredProcedure [dbo].[procCoorperation8Select] Script Date: 2018/12/13 19:10:05 ******/
  6469. SET ANSI_NULLS ON
  6470. GO
  6471. SET QUOTED_IDENTIFIER ON
  6472. GO
  6473. --#####################################################
  6474. --创建时间:2014.11.10
  6475. --创建人:NICK
  6476. --说明:获取合作伙伴
  6477. --#####################################################
  6478. CREATE PROCEDURE [dbo].[procCoorperation8Select]
  6479. AS
  6480. BEGIN
  6481. SELECT top 8 * FROM Maindb..Coorperation WITH(NOLOCK)
  6482. END
  6483. GO
  6484. /****** Object: StoredProcedure [dbo].[procCounterByVersionIDUpdate] Script Date: 2018/12/13 19:10:06 ******/
  6485. SET ANSI_NULLS ON
  6486. GO
  6487. SET QUOTED_IDENTIFIER ON
  6488. GO
  6489. CREATE PROCEDURE [dbo].[procCounterByVersionIDUpdate]
  6490. (
  6491. @VersionId SMALLINT,
  6492. @VNumber INT,
  6493. @SVNumber INT
  6494. )
  6495. AS
  6496. BEGIN
  6497. SET NOCOUNT ON
  6498. UPDATE Counter SET ViewNumber = ViewNumber + @VNumber,
  6499. SpiderViewNumber = SpiderViewNumber + @SVNumber
  6500. WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  6501. AND VersionId = @VersionId
  6502. END
  6503. GO
  6504. /****** Object: StoredProcedure [dbo].[procCounterSpiderUpdate] Script Date: 2018/12/13 19:10:06 ******/
  6505. SET ANSI_NULLS ON
  6506. GO
  6507. SET QUOTED_IDENTIFIER OFF
  6508. GO
  6509. CREATE PROCEDURE [dbo].[procCounterSpiderUpdate]
  6510. (
  6511. @VersionId SMALLINT
  6512. )
  6513. AS
  6514. SET NOCOUNT ON
  6515. BEGIN
  6516. -- UPDATE Counter SET SpiderViewNumber = SpiderViewNumber + 1
  6517. -- WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  6518. -- AND VersionId = @VersionId
  6519. INSERT INTO CounterSpider SELECT @VersionId, GETDATE()
  6520. END
  6521. GO
  6522. /****** Object: StoredProcedure [dbo].[procCounterUpdate] Script Date: 2018/12/13 19:10:06 ******/
  6523. SET ANSI_NULLS ON
  6524. GO
  6525. SET QUOTED_IDENTIFIER OFF
  6526. GO
  6527. CREATE PROCEDURE [dbo].[procCounterUpdate]
  6528. (
  6529. @VersionId SMALLINT
  6530. )
  6531. AS
  6532. BEGIN
  6533. SET NOCOUNT ON
  6534. UPDATE Counter SET ViewNumber = ViewNumber + 1
  6535. WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  6536. AND VersionId = @VersionId
  6537. SET NOCOUNT OFF
  6538. END
  6539. GO
  6540. /****** Object: StoredProcedure [dbo].[procCountyHotJobSelect] Script Date: 2018/12/13 19:10:06 ******/
  6541. SET ANSI_NULLS ON
  6542. GO
  6543. SET QUOTED_IDENTIFIER ON
  6544. GO
  6545. /***
  6546. *Peter 2014-02-20修改 添加修正热门职位的地区判断
  6547. *
  6548. */
  6549. CREATE PROCEDURE [dbo].[procCountyHotJobSelect]
  6550. (
  6551. @RegionId INT
  6552. )
  6553. AS
  6554. BEGIN
  6555. SET NOCOUNT ON
  6556. DECLARE @HotNumber AS INT, ----热门职位行数
  6557. @ProvinceID AS INT,
  6558. @RegionType AS INT,
  6559. @RowNumber AS INT,
  6560. @Sql AS VARCHAR(MAX),
  6561. @strMember AS VARCHAR(100),
  6562. @strRegion AS VARCHAR(100)
  6563. ---将推荐职位的和热门的企业都放在临时表中
  6564. CREATE TABLE #t(
  6565. ID int IDENTITY(1,1) NOT NULL,
  6566. dcSubsiteID smallint NULL,
  6567. dcRegionID varchar(6) COLLATE Chinese_PRC_CI_AS NULL,
  6568. cpMainID VARCHAR(11) NULL,
  6569. Name varchar(100) COLLATE Chinese_PRC_CI_AS NULL,
  6570. IsAgent bit NULL,
  6571. JobNumber int NULL,
  6572. JobID varchar(max) COLLATE Chinese_PRC_CI_AS NULL,
  6573. JobName nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL,
  6574. LastJobIssueDate smalldatetime NULL,
  6575. LastJobId VARCHAR(12) NULL,
  6576. cpLicenceDate smalldatetime NULL,
  6577. RefreshDate smalldatetime NULL,
  6578. MemberType tinyint NULL,
  6579. NewXID VARCHAR(12),
  6580. NoFollow VARCHAR(1),
  6581. RealCpMainId INT
  6582. )
  6583. ---向临时表中填入热门职位,按照普通会员的刷新时间计算
  6584. SELECT @HotNumber = 60
  6585. SET @ProvinceID = LEFT(@RegionId, 2)
  6586. SET @RegionType=3--县级市
  6587. AddHot:
  6588. SELECT @RowNumber = COUNT(1) FROM #t
  6589. IF @RowNumber < 1
  6590. GOTO AddFlag
  6591. IF @ProvinceID IN (32, 30, 31, 35, 10, 11, 12, 40)
  6592. SET @strMember = '
  6593. AND MemberType = 2'
  6594. ELSE
  6595. BEGIN
  6596. SET @strMember = '
  6597. AND MemberType IN(1, 2)'
  6598. END
  6599. IF @RegionType = 1 --省
  6600. SET @strRegion = '
  6601. AND dcSubsiteID LIKE ''' + LTRIM(STR(@ProvinceID)) + '%'''
  6602. IF @RegionType = 2 --市
  6603. SET @strRegion = '
  6604. AND (dcRegionID like ''' + LTRIM(STR(@ProvinceID)) + '%''
  6605. OR dcSubsiteID = ' + LTRIM(STR(@ProvinceID)) + ')'
  6606. IF @RegionType = 3 --县级
  6607. SET @strRegion = '
  6608. AND (dcRegionID = ''' + LTRIM(STR(@RegionId)) + '%''
  6609. OR dcSubsiteID = ' + LTRIM(STR(@RegionId)) + ')'
  6610. SET @Sql = '
  6611. INSERT #t(dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId)
  6612. SELECT TOP ' + LTRIM(STR(@RowNumber)) + ' dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId
  6613. FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK)
  6614. WHERE JobNumber > 0
  6615. AND cpMainID Not IN(SELECT cpMainID FROM #t)'
  6616. SET @Sql = @Sql + @strRegion + @strMember + '
  6617. ORDER BY RefreshDate DESC'
  6618. print @sql
  6619. EXEC(@SQL)
  6620. SELECT @RowNumber = COUNT(1) FROM #t
  6621. IF((@RowNumber <@HotNumber))
  6622. BEGIN
  6623. IF @RegionType = 3
  6624. SELECT @RegionType = 2
  6625. ELSE IF @RegionType = 2
  6626. SELECT @RegionType = 1
  6627. GOTO AddHot
  6628. END
  6629. AddFlag:
  6630. DELETE FROM #t WHERE ID > @HotNumber
  6631. SELECT @RowNumber = 1 + COUNT(1) / 6 FROM #t WHERE MemberType > 2
  6632. SELECT @SQL = 'UPDATE #t SET NewXId = LastJobID WHERE ID IN(SELECT TOP ' + LTRIM(STR(@RowNumber)) +' ID FROM #t WHERE MemberType > 2 ORDER BY LastJobIssueDate DESC)'
  6633. EXEC(@SQL)
  6634. SELECT @RowNumber = 1 + COUNT(1) / 8 FROM #t WHERE MemberType < 3
  6635. SELECT @SQL = 'UPDATE #t SET NewXId = 1 WHERE ID IN(SELECT TOP ' + LTRIM(STR(@RowNumber)) +' ID FROM #t WHERE MemberType < 3 ORDER BY cpLicenceDate DESC)'
  6636. EXEC(@SQL)
  6637. UPDATE #t SET cpMainID = NoFollow + cpMainID
  6638. SELECT ID, dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName,
  6639. LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NewXID
  6640. FROM #t WITH(NOLOCK)
  6641. ORDER BY ID
  6642. DROP TABLE #t
  6643. SET NOCOUNT OFF
  6644. END
  6645. GO
  6646. /****** Object: StoredProcedure [dbo].[procCountyJobInsert] Script Date: 2018/12/13 19:10:06 ******/
  6647. SET ANSI_NULLS ON
  6648. GO
  6649. SET QUOTED_IDENTIFIER ON
  6650. GO
  6651. CREATE PROCEDURE [dbo].[procCountyJobInsert]
  6652. (
  6653. @RegionId VARCHAR(6)
  6654. )
  6655. AS
  6656. SET NOCOUNT ON
  6657. INSERT INTO ProcLog SELECT 'procCountyJobInsert', @RegionId, GETDATE()
  6658. IF EXISTS(SELECT 'x' FROM SearchDb..CountyJob WHERE JobPlaceId = @RegionId AND crDate > DATEADD(MINUTE, -120, GETDATE()))
  6659. RETURN
  6660. BEGIN TRY
  6661. CREATE TABLE #t(
  6662. RowID int IDENTITY(1, 1) NOT NULL,
  6663. PageId int NOT NULL DEFAULT ((0)),
  6664. ID int NOT NULL,
  6665. cpMainID int NOT NULL,
  6666. caMainID int NOT NULL,
  6667. JobName nvarchar(50) NOT NULL,
  6668. dcJobTypeID smallint NOT NULL,
  6669. dcJobTypeIDMinor smallint NULL,
  6670. NeedNumber tinyint NULL,
  6671. dcSalaryID tinyint NOT NULL,
  6672. EmployType tinyint NOT NULL,
  6673. dcRegionID varchar(6) NOT NULL,
  6674. Responsibility nvarchar(max) NULL,
  6675. Demand nvarchar(max) NULL,
  6676. dcEducationID tinyint NOT NULL,
  6677. MinExperience tinyint NOT NULL,
  6678. MinAge tinyint NULL,
  6679. MaxAge tinyint NULL,
  6680. IssueDate smalldatetime NULL,
  6681. IssueEND smalldatetime NULL,
  6682. IsDelete bit NOT NULL,
  6683. AddDate smalldatetime NOT NULL,
  6684. RefreshDate smalldatetime NULL,
  6685. Welfare1 bit NULL,
  6686. Welfare2 bit NULL,
  6687. Welfare3 bit NULL,
  6688. Welfare4 bit NULL,
  6689. Welfare5 bit NULL,
  6690. Welfare6 bit NULL,
  6691. Welfare7 bit NULL,
  6692. Welfare8 bit NULL,
  6693. Welfare9 bit NULL,
  6694. Welfare10 bit NULL,
  6695. Welfare11 bit NULL,
  6696. Welfare12 bit NULL,
  6697. Welfare13 bit NULL,
  6698. Welfare14 bit NULL,
  6699. Welfare15 bit NULL,
  6700. Welfare16 bit NULL,
  6701. Welfare17 bit NULL,
  6702. Welfare18 bit NULL,
  6703. EnJobID varchar(12) NULL,
  6704. EnCpMainID varchar(10) NULL,
  6705. LastModifyDate smalldatetime NOT NULL,
  6706. cpName nvarchar(100) NULL,
  6707. dcCompanySizeID tinyint NULL,
  6708. HasLicence bit NOT NULL,
  6709. UnLimitedDate smalldatetime NOT NULL,
  6710. BalanceDate smalldatetime NOT NULL,
  6711. Balance smallint NOT NULL,
  6712. MemberType tinyint NOT NULL,
  6713. cpIndustry nvarchar(max) NULL,
  6714. IsRefreshed bit NOT NULL
  6715. )
  6716. ----建立临时表
  6717. CREATE TABLE #Job(
  6718. ID int NOT NULL,
  6719. cpMainID int NOT NULL,
  6720. caMainID int NOT NULL,
  6721. JobName nvarchar(50) NOT NULL,
  6722. dcJobTypeID smallint NOT NULL,
  6723. dcJobTypeIDMinor smallint NULL,
  6724. NeedNumber tinyint NULL,
  6725. dcSalaryID tinyint NOT NULL,
  6726. EmployType tinyint NOT NULL,
  6727. dcRegionID varchar(6) NOT NULL,
  6728. Responsibility nvarchar(max) NULL,
  6729. Demand nvarchar(max) NULL,
  6730. dcEducationID tinyint NOT NULL,
  6731. MinExperience tinyint NOT NULL,
  6732. MinAge tinyint NULL,
  6733. MaxAge tinyint NULL,
  6734. IssueDate smalldatetime NULL,
  6735. IssueEND smalldatetime NULL,
  6736. IsDelete bit NOT NULL,
  6737. AddDate smalldatetime NOT NULL,
  6738. RefreshDate smalldatetime NULL,
  6739. Welfare1 bit NULL,
  6740. Welfare2 bit NULL,
  6741. Welfare3 bit NULL,
  6742. Welfare4 bit NULL,
  6743. Welfare5 bit NULL,
  6744. Welfare6 bit NULL,
  6745. Welfare7 bit NULL,
  6746. Welfare8 bit NULL,
  6747. Welfare9 bit NULL,
  6748. Welfare10 bit NULL,
  6749. Welfare11 bit NULL,
  6750. Welfare12 bit NULL,
  6751. Welfare13 bit NULL,
  6752. Welfare14 bit NULL,
  6753. Welfare15 bit NULL,
  6754. Welfare16 bit NULL,
  6755. Welfare17 bit NULL,
  6756. Welfare18 bit NULL,
  6757. EnJobID varchar(12) NULL,
  6758. EnCpMainID varchar(10) NULL,
  6759. LastModifyDate smalldatetime NOT NULL,
  6760. cpName nvarchar(100) NULL,
  6761. dcCompanySizeID tinyint NULL,
  6762. HasLicence bit NOT NULL,
  6763. UnLimitedDate smalldatetime NOT NULL,
  6764. BalanceDate smalldatetime NOT NULL,
  6765. Balance smallint NOT NULL,
  6766. MemberType tinyint NOT NULL,
  6767. cpIndustry nvarchar(max) NULL,
  6768. IsRefreshed bit NOT NULL
  6769. )
  6770. INSERT INTO #Job
  6771. SELECT TOP 2000 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  6772. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  6773. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  6774. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  6775. a.IsDelete, a.AddDate, a.RefreshDate, a.Welfare1, a.Welfare2, a.Welfare3,
  6776. a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8,
  6777. a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13,
  6778. a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18, a.SecondId EnJobID, b.SecondId EnCpMainID,
  6779. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  6780. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  6781. b.MemberType,
  6782. STUFF(
  6783. (SELECT ', ' + LTRIM(x.dcIndustryid) + ', c'+LTRIM(isnull(y.Category, 0))
  6784. FROM cpIndustry x, dcIndustry y
  6785. WHERE x.dcIndustryid = y.id
  6786. AND x.cpMainid = b.id
  6787. FOR XML PATH('')
  6788. ),
  6789. 1, 1, '') cpIndustry,
  6790. b.IsRefreshed
  6791. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK)
  6792. WHERE a.cpMainID = b.ID
  6793. AND a.dcRegionId LIKE LEFT(@RegionId, 2) + '%'
  6794. AND a.Valid = 1
  6795. AND b.Valid = 1
  6796. ORDER BY a.RefreshDate DESC
  6797. DELETE #Job WHERE dcRegionId = @RegionId
  6798. INSERT INTO #Job
  6799. SELECT TOP 2000 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  6800. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  6801. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  6802. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  6803. a.IsDelete, a.AddDate, a.RefreshDate, a.Welfare1, a.Welfare2, a.Welfare3,
  6804. a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8,
  6805. a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13,
  6806. a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18, a.SecondId EnJobID, b.SecondId EnCpMainID,
  6807. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  6808. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  6809. b.MemberType,
  6810. STUFF(
  6811. (SELECT ', ' + LTRIM(x.dcIndustryid) + ', c'+LTRIM(isnull(y.Category, 0))
  6812. FROM cpIndustry x, dcIndustry y
  6813. WHERE x.dcIndustryid = y.id
  6814. AND x.cpMainid = b.id
  6815. FOR XML PATH('')
  6816. ),
  6817. 1, 1, '') cpIndustry,
  6818. b.IsRefreshed
  6819. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK)
  6820. WHERE a.cpMainID = b.ID
  6821. AND a.dcRegionId = @RegionId
  6822. AND a.Valid = 1
  6823. AND b.Valid = 1
  6824. ORDER BY a.RefreshDate DESC
  6825. CREATE NONCLUSTERED INDEX [IX_#Job_dcRegionID] ON [dbo].[#Job](dcRegionId ASC)
  6826. CREATE NONCLUSTERED INDEX [IX_#Job_RefreshDate] ON [dbo].[#Job](RefreshDate DESC)
  6827. --DELETE SearchDb..CountyJobNumber WHERE ProvinceId = @ProvinceId
  6828. --INSERT SearchDb..CountyJobNumber SELECT @ProvinceId, COUNT(*) FROM #Job
  6829. INSERT #t
  6830. SELECT TOP 2000 0, ID, cpMainID, caMainID, JobName, dcJobTypeID,
  6831. dcJobTypeIDMinor, NeedNumber, dcSalaryID, EmployType,
  6832. dcRegionID, Responsibility, Demand, dcEducationID,
  6833. MinExperience, MinAge, MaxAge, IssueDate, IssueEND,
  6834. IsDelete, AddDate, RefreshDate, Welfare1, Welfare2, Welfare3,
  6835. Welfare4, Welfare5, Welfare6, Welfare7, Welfare8,
  6836. Welfare9, Welfare10, Welfare11, Welfare12, Welfare13,
  6837. Welfare14, Welfare15, Welfare16, Welfare17, Welfare18, EnJobID, EnCpMainID,
  6838. LastModifyDate, cpName, dcCompanySizeID,
  6839. HasLicence, UnLimitedDate, BalanceDate, Balance,
  6840. MemberType, cpIndustry, IsRefreshed
  6841. FROM #Job WITH(NOLOCK)
  6842. ORDER BY CASE dcRegionID WHEN @RegionId THEN 1 ELSE 2 END,
  6843. RefreshDate DESC
  6844. BEGIN TRY
  6845. UPDATE #t SET PageId = (RowId + 19) / 20
  6846. DELETE SearchDb..CountyJob WHERE JobPlaceId = @RegionID
  6847. INSERT INTO SearchDb..CountyJob SELECT @RegionID, *, GETDATE() FROM #t
  6848. TRUNCATE TABLE #t
  6849. END TRY
  6850. BEGIN CATCH
  6851. END CATCH
  6852. END TRY
  6853. BEGIN CATCH
  6854. ---检查是否已经建立临时表,已经建立则删除
  6855. PRINT 'error'
  6856. PRINT error_Message()
  6857. PRINT error_number()
  6858. PRINT error_line()
  6859. END CATCH
  6860. GO
  6861. /****** Object: StoredProcedure [dbo].[ProcCountyJobSelect] Script Date: 2018/12/13 19:10:07 ******/
  6862. SET ANSI_NULLS ON
  6863. GO
  6864. SET QUOTED_IDENTIFIER ON
  6865. GO
  6866. CREATE PROCEDURE [dbo].[ProcCountyJobSelect]
  6867. (
  6868. @SubSiteId INT
  6869. )
  6870. AS
  6871. SET NOCOUNT ON
  6872. --this proc is valid
  6873. BEGIN
  6874. DECLARE @Refresh INT
  6875. SET @Refresh = 0
  6876. IF @SubSiteId LIKE '32%'
  6877. BEGIN
  6878. IF ISNULL((SELECT TOP 1 DATEDIFF(MINUTE, AddDate, GETDATE()) FROM ShortDb..CountyJob WHERE CountyId = @SubSiteId), 999) > 120
  6879. SET @Refresh = 1
  6880. END
  6881. ELSE
  6882. BEGIN
  6883. IF ISNULL((SELECT TOP 1 DATEDIFF(MINUTE, AddDate, GETDATE()) FROM ShortDb..CountyJob WHERE CountyId = @SubSiteId), 999) > 480
  6884. SET @Refresh = 1
  6885. END
  6886. IF @Refresh = 1
  6887. BEGIN
  6888. DECLARE @RowNumber AS INT, @SiteId INT
  6889. SELECT @SiteId = @SubSiteId, @RowNumber = 0
  6890. ---将推荐职位的和热门的企业都放在临时表中
  6891. DECLARE @t AS TABLE(
  6892. ID int IDENTITY(1, 1) NOT NULL,
  6893. dcSubsiteID smallint NOT NULL,
  6894. dcRegionID varchar(6) NULL,
  6895. cpMainID varchar(11) NULL,
  6896. Name varchar(100) NULL,
  6897. IsAgent bit NULL,
  6898. JobNumber int NULL,
  6899. JobID varchar(max) NULL,
  6900. JobName nvarchar(max) NULL,
  6901. LastJobIssueDate smalldatetime NULL,
  6902. LastJobId varchar(12) NULL,
  6903. cpLicenceDate smalldatetime NULL,
  6904. RefreshDate smalldatetime NULL,
  6905. MemberType tinyint NULL,
  6906. NewXID varchar(12) NULL,
  6907. NoFollow varchar(1) NULL,
  6908. RealCpMainId int NULL,
  6909. AddDate smalldatetime NOT NULL DEFAULT (getdate())
  6910. )
  6911. ---向临时表中填入75行推荐职位的
  6912. AddRecommend:
  6913. INSERT @t(cpMainId, dcSubsiteID, dcRegionID, Name, IsAgent, JobNumber, RefreshDate, MemberType, RealCpMainId)
  6914. SELECT TOP (75 - @RowNumber) SecondId, dcSubsiteID, dcRegionID, Name, IsAgent, JobNumber, RefreshDate, MemberType, Id
  6915. FROM MainDb..cpMain WITH(NOLOCK)
  6916. WHERE JobNumber > 0
  6917. AND MemberType > 1
  6918. AND (dcRegionID = @SiteId
  6919. OR dcSubsiteID = @SiteId)
  6920. ORDER BY MemberType DESC, RefreshDate DESC
  6921. SELECT @RowNumber = COUNT(1) FROM @t
  6922. IF(@RowNumber < 75)
  6923. BEGIN
  6924. INSERT @t(cpMainId, dcSubsiteID, dcRegionID, Name, IsAgent, JobNumber, RefreshDate, MemberType, RealCpMainId)
  6925. SELECT TOP (75 - @RowNumber) SecondId, dcSubsiteID, dcRegionID, Name, IsAgent, JobNumber, RefreshDate, MemberType, Id
  6926. FROM MainDb..cpMain WITH(NOLOCK)
  6927. WHERE JobNumber > 0
  6928. AND MemberType = 1
  6929. AND (dcRegionID = @SiteId
  6930. OR dcSubsiteID = @SiteId)
  6931. ORDER BY RefreshDate DESC
  6932. END
  6933. SELECT @RowNumber = COUNT(1) FROM @t
  6934. IF(@RowNumber < 75 AND @SiteId > 99)
  6935. BEGIN
  6936. SET @SiteId = LEFT(@SiteId, LEN(@SiteId) - 2)
  6937. GOTO AddRecommend
  6938. END
  6939. DELETE @t WHERE Id > 75
  6940. UPDATE @t SET JobId = dbo.getJobSecondIds(RealCpMainid), JobName = dbo.getJobNames(RealCpMainid)
  6941. UPDATE a SET a.cplicenceDate = b.checkDate
  6942. FROM @t a, cpLicence b
  6943. WHERE a.RealCpMainid = b.cpMainid
  6944. AND a.MemberType < 3
  6945. SELECT @RowNumber = COUNT(*) FROM @t WHERE MemberType = 3
  6946. UPDATE a SET LastJobId = (SELECT TOP 1 ID FROM Job WITH(NOLOCK) WHERE Job.cpMainid = a.RealCpMainid AND Valid = 1 ORDER BY IssueDate DESC) FROM @t a
  6947. UPDATE a SET LastJobIssueDate = (SELECT IssueDate FROM Job WHERE Job.id = a.LastJobid) FROM @t a WHERE MemberType > 2
  6948. UPDATE @t SET NewXId = LastJobID WHERE Id IN(SELECT TOP (@RowNumber / 4) Id FROM @t WHERE MemberType = 3 ORDER BY LastJobIssueDate DESC)
  6949. UPDATE @t SET NewXId = LastJobID WHERE Id IN(SELECT TOP (@RowNumber / 6) Id FROM @t WHERE MemberType < 3 ORDER BY cplicenceDate DESC)
  6950. DELETE FROM ShortDb..CountyJob WHERE CountyId = @SubSiteId
  6951. INSERT INTO ShortDb..CountyJob(ID, CountyId, dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName,
  6952. LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NewXID)
  6953. SELECT ID, @SubsiteID, dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName,
  6954. LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NewXID
  6955. FROM @t
  6956. ORDER BY ID
  6957. END
  6958. SELECT * FROM ShortDb..CountyJob WHERE CountyId = @SubSiteId ORDER BY ID
  6959. END
  6960. GO
  6961. /****** Object: StoredProcedure [dbo].[procCpImageSelect] Script Date: 2018/12/13 19:10:07 ******/
  6962. SET ANSI_NULLS ON
  6963. GO
  6964. SET QUOTED_IDENTIFIER ON
  6965. GO
  6966. --------------------------------------------------
  6967. --创建:Nick
  6968. --创建日期:2016-2-15
  6969. --获取环境照片企业列表
  6970. --------------------------------------------------
  6971. CREATE PROCEDURE [dbo].[procCpImageSelect]
  6972. (
  6973. @ProvinceID INT,
  6974. @PageNo INT
  6975. )
  6976. AS
  6977. BEGIN
  6978. CREATE TABLE #indextable(
  6979. [NUM] int identity(1,1),
  6980. ID INT NULL,
  6981. chDate DATETIME
  6982. )
  6983. INSERT INTO #indextable(ID,chDate)
  6984. SELECT TOP 500 CpmainID,MAX(a.CheckDate) AS ChDate
  6985. FROM CpImage a WITH(NOLOCK),CpMain b WITH(NOLOCK)
  6986. WHERE a.Imgtype = 3
  6987. AND a.HasPassed=1
  6988. AND a.CheckDate IS NOT NULL
  6989. AND A.CpMainID = b.ID
  6990. AND dcProvinceID = @ProvinceID
  6991. AND a.AddDate > '2016-2-17'
  6992. GROUP BY a.CpmainID
  6993. ORDER BY ChDate DESC
  6994. --分页
  6995. DECLARE @PageSize INT
  6996. SET @PageSize = 10
  6997. DECLARE @PageLowerBound INT --定义此页的底码
  6998. DECLARE @PageUpperBound INT --定义此页的顶码
  6999. SET @PageLowerBound = (@PageNo -1) * @pagesize
  7000. SET @PageUpperBound = @PageLowerBound + @pagesize
  7001. DECLARE @Campus AS TABLE(
  7002. [CpMainID] INT,
  7003. SecondID VARCHAR(100),
  7004. ImgFile VARCHAR(200),
  7005. Name NVARCHAR(100),
  7006. Content VARCHAR(200)
  7007. )
  7008. INSERT INTO @Campus (CpMainID,SecondID,Name)
  7009. SELECT b.ID,b.SecondID,b.Name
  7010. FROM (SELECT * FROM #indextable WHERE Num > @PageLowerBound AND Num <= @PageUpperBound)a,
  7011. CpMain b WITH(NOLOCK)
  7012. WHERE a.ID = b.ID
  7013. UPDATE a
  7014. SET ImgFile = (
  7015. SELECT TOP 1 ImgFile
  7016. FROM CpImage WITH(NOLOCK)
  7017. WHERE CpMainID = a.CpMainID
  7018. AND Imgtype = 3
  7019. AND HasPassed=1
  7020. AND CheckDate IS NOT NULL
  7021. ORDER BY CheckDate DESC
  7022. ) FROM @Campus a
  7023. UPDATE a
  7024. SET Content = (
  7025. SELECT TOP 1 Description
  7026. FROM CpImage WITH(NOLOCK)
  7027. WHERE CpMainID = a.CpMainID
  7028. AND Imgtype = 3
  7029. AND HasPassed=1
  7030. AND CheckDate IS NOT NULL
  7031. ORDER BY CheckDate DESC
  7032. ) FROM @Campus a
  7033. SELECT COUNT(*) FROM #indextable
  7034. SELECT * FROM @Campus
  7035. END
  7036. GO
  7037. /****** Object: StoredProcedure [dbo].[proccpIndustryByJobIDSelect] Script Date: 2018/12/13 19:10:07 ******/
  7038. SET ANSI_NULLS ON
  7039. GO
  7040. SET QUOTED_IDENTIFIER ON
  7041. GO
  7042. --#####################################################
  7043. --创建时间:2014.10.31
  7044. --创建人:Nick
  7045. --说明:获取职位信息 用于计算与简历的匹配度
  7046. --#####################################################
  7047. CREATE PROCEDURE [dbo].[proccpIndustryByJobIDSelect]
  7048. (
  7049. @JobID INT
  7050. )
  7051. AS
  7052. BEGIN TRY
  7053. SELECT x.*,','+STUFF((
  7054. SELECT ','+LTRIM(a.dcIndustryid)+',c'+LTRIM(b.CateGory)
  7055. FROM cpIndustry a,dcIndustry b
  7056. WHERE a.dcIndustryid = b.ID AND cpMainid = x.cpMainID FOR XML PATH('')),1,1,'')+',' cpIndustry
  7057. FROM Job x WITH(NOLOCK)
  7058. WHERE ID = @JobID
  7059. END TRY
  7060. BEGIN CATCH
  7061. RETURN 0
  7062. END CATCH
  7063. GO
  7064. /****** Object: StoredProcedure [dbo].[procCpMainByCpImageSelect] Script Date: 2018/12/13 19:10:07 ******/
  7065. SET ANSI_NULLS ON
  7066. GO
  7067. SET QUOTED_IDENTIFIER ON
  7068. GO
  7069. --福利分享专题根据公司上传环境图获取公司列表
  7070. --创建时间 2016-02-15
  7071. --创建人 Peter
  7072. CREATE PROCEDURE [dbo].[procCpMainByCpImageSelect]
  7073. (
  7074. @SqlWhere AS VARCHAR(500),
  7075. @PageNo AS INT
  7076. )
  7077. AS
  7078. BEGIN
  7079. CREATE TABLE #T(
  7080. cpMainID INT,
  7081. CheckDate DATETIME
  7082. )
  7083. SET @SqlWhere = dbo.SafeSql(@SqlWhere)
  7084. DECLARE @SQL AS VARCHAR(1000)
  7085. SET @SQL='INSERT INTO #T SELECT cpmainid,MAX(CheckDate) CheckDate
  7086. FROM cpImage WITH(NOLOCK)
  7087. WHERE HasPassed = 1
  7088. AND ImgType = 3
  7089. AND (SELECT TOP 1 Valid FROM CpMain WITH(NOLOCK) WHERE id = cpImage.cpMainID) = 1
  7090. AND EXISTS(SELECT id FROM Job WITH(NOLOCK) WHERE cpMainID = cpimage.cpMainid AND IsDelete = 0 AND IssueEnd > GETDATE() AND IssueDate < GETDATE()) ' + @SqlWhere + '
  7091. GROUP BY cpmainid '
  7092. EXEC(@SQL)
  7093. SELECT b.PageIndex,a.id,a.Name,a.SecondID
  7094. FROM cpMain a WITH(NOLOCK),(
  7095. SELECT TOP (@PageNo*12) ROW_NUMBER() OVER (ORDER BY CheckDate DESC) PageIndex,cpMainID
  7096. FROM #T) b
  7097. WHERE b.cpMainID=a.id
  7098. AND b.PageIndex > (@PageNo-1)*12
  7099. ORDER BY b.PageIndex ASC
  7100. SELECT COUNT(1) FROM #T
  7101. DROP TABLE #T
  7102. END
  7103. GO
  7104. /****** Object: StoredProcedure [dbo].[ProcCpMainByEndDateSelect] Script Date: 2018/12/13 19:10:08 ******/
  7105. SET ANSI_NULLS ON
  7106. GO
  7107. SET QUOTED_IDENTIFIER ON
  7108. GO
  7109. CREATE PROCEDURE [dbo].[ProcCpMainByEndDateSelect]
  7110. AS
  7111. BEGIN
  7112. CREATE TABLE #t(ID INT, CompanyName NVARCHAR(60), ConsultantID INT, Superior INT, Code INT)
  7113. INSERT INTO #t
  7114. SELECT ID, Name, ConsultantID, 0, DATEPART(HOUR, RegDate) * 100 + DATEPART(MINUTE, RegDate) FROM cpMain WITH(NOLOCK)
  7115. WHERE UnlimitedDate BETWEEN GETDATE() AND GETDATE() + 7
  7116. INSERT INTO #t
  7117. SELECT ID, Name, ConsultantID, 0, DATEPART(HOUR, RegDate) * 100 + DATEPART(MINUTE, RegDate) FROM cpMain WITH(NOLOCK)
  7118. WHERE BalanceDate BETWEEN GETDATE() AND GETDATE() + 7
  7119. INSERT INTO #t
  7120. SELECT ID, Name, ConsultantID, 0, DATEPART(HOUR, RegDate) * 100 + DATEPART(MINUTE, RegDate) FROM cpMain WITH(NOLOCK)
  7121. WHERE MemberType = 3 AND id IN
  7122. (
  7123. SELECT cpmainid FROM caOrder WITH(NOLOCK)
  7124. WHERE ORderType = 8
  7125. GROUP BY cpMainid
  7126. HAVING MAX(EndDate) BETWEEN GETDATE() AND GETDATE() + 7
  7127. )
  7128. --DELETE FROM #t WHERE ConsultantID IN(SELECT ID FROM ManagerUser WHERE Status<> 3)
  7129. UPDATE #t SET Superior = ConsultantId WHERE ConsultantId IN(SELECT ID FROM ManagerUser WHERE Status<3 AND RtxStatus IN(1, 2))
  7130. UPDATE #t SET Superior = (SELECT Superior FROM ManagerUser WHERE ManagerUser.Id = ConsultantID) WHERE ISNULL(Superior, 0) = 0
  7131. UPDATE #t SET Superior = 180 + (ID % 4) WHERE ISNULL(Superior, 0) = 0
  7132. --SELECT * FROM #t
  7133. INSERT INTO OaDb..RtxSend(Receiver, RtxTitle, RtxMessage, SendType, DelayTime, ShowType, SendTime, AddTime)
  7134. SELECT Superior, '订单到期通知', CompanyName + '(' + LTRIM(STR(ID)) + ') http://sysback.51rc.com/newoa/company/cp/cpMainInfo?id=' + LTRIM(STR(ID)) + '&code=' + LTRIM(STR(Code)) + ' 将在7天内到期,请关注。', 1, 0, 0, NULL, GETDATE()
  7135. FROM #t
  7136. DROP TABLE #t
  7137. END
  7138. GO
  7139. /****** Object: StoredProcedure [dbo].[procCpMainByFewSelect] Script Date: 2018/12/13 19:10:08 ******/
  7140. SET ANSI_NULLS ON
  7141. GO
  7142. SET QUOTED_IDENTIFIER ON
  7143. GO
  7144. CREATE PROCEDURE [dbo].[procCpMainByFewSelect]
  7145. (
  7146. @ID INT
  7147. )
  7148. AS
  7149. BEGIN
  7150. SELECT RegisterIp
  7151. FROM cpMain a WITH(NOLOCK)
  7152. WHERE a.ID =@ID
  7153. END
  7154. GO
  7155. /****** Object: StoredProcedure [dbo].[procCpMainByIDSelect] Script Date: 2018/12/13 19:10:08 ******/
  7156. SET ANSI_NULLS ON
  7157. GO
  7158. SET QUOTED_IDENTIFIER ON
  7159. GO
  7160. --#####################################################
  7161. --创建时间:2014.11.10
  7162. --创建人:NICK
  7163. --说明:根据ID获取cpmain
  7164. --#####################################################
  7165. CREATE PROCEDURE [dbo].[procCpMainByIDSelect]
  7166. (
  7167. @ID INT
  7168. )
  7169. AS
  7170. BEGIN
  7171. SELECT TOP 1 * FROM cpmain WHERE ID = @ID
  7172. END
  7173. GO
  7174. /****** Object: StoredProcedure [dbo].[procCpMainByKeyWordSelect] Script Date: 2018/12/13 19:10:08 ******/
  7175. SET ANSI_NULLS ON
  7176. GO
  7177. SET QUOTED_IDENTIFIER ON
  7178. GO
  7179. --#####################################################
  7180. --创建时间:2014.11.25
  7181. --创建人:Nick
  7182. --说明:点评 搜索公司
  7183. --#####################################################
  7184. CREATE PROCEDURE [dbo].[procCpMainByKeyWordSelect]
  7185. (
  7186. @Name VARCHAR(25),
  7187. @ProvinceID INT
  7188. )
  7189. AS
  7190. BEGIN
  7191. DECLARE @t AS TABLE(ID INT,
  7192. SecondId VARCHAR(12),
  7193. Name NVARCHAR(50)
  7194. )
  7195. INSERT INTO @t
  7196. SELECT TOP 48 a.ID, a.SecondId, a.Name
  7197. FROM cpMainPublish a WITH(NOLOCK),
  7198. CONTAINSTABLE(cpMainPublish, Name, @Name, 100) AS b
  7199. WHERE a.Id = b.[Key]
  7200. AND a.dcRegionID LIKE LTRIM(STR(@ProvinceID)) + '%'
  7201. IF NOT EXISTS(SELECT 'x' FROM @t)
  7202. BEGIN
  7203. INSERT @t
  7204. SELECT TOP 48 ID,SecondId, Name
  7205. FROM cpMainPublish WITH(NOLOCK INDEX(IX_cpMainPublish_Name))
  7206. WHERE Name LIKE @Name + '%'
  7207. AND LEFT(cpMainPublish.dcRegionID, 2) = @ProvinceID
  7208. ORDER BY RefreshDate DESC
  7209. END
  7210. SELECT * FROM @t
  7211. END
  7212. GO
  7213. /****** Object: StoredProcedure [dbo].[procCpMainByReplyRateUpdate] Script Date: 2018/12/13 19:10:09 ******/
  7214. SET ANSI_NULLS ON
  7215. GO
  7216. SET QUOTED_IDENTIFIER ON
  7217. GO
  7218. --计算企业回复率
  7219. --20151126 nick
  7220. --修改harry,修改此方法只计算未确认自动答复的答复率2017-5-25,答复率小于0.6的也显示
  7221. CREATE PROCEDURE [dbo].[procCpMainByReplyRateUpdate]
  7222. AS
  7223. SET NOCOUNT ON
  7224. BEGIN
  7225. UPDATE ExjobApply SET ReplyDate = CompanyDeleteDate WHERE ReplyDate IS NULL AND Reply = 4
  7226. UPDATE ExjobApply SET ReplyDate = CompanyDeleteDate WHERE ReplyDate IS NULL AND Reply = 4
  7227. UPDATE ExjobApply SET ReplyDate = ViewDate WHERE ReplyDate IS NULL AND Reply = 1 AND ViewDate IS NOT NULL
  7228. UPDATE ExjobApply SET ReplyDate = CompanyDeleteDate WHERE ReplyDate IS NULL AND Reply = 1 AND CompanyDeleteDate IS NOT NULL
  7229. UPDATE ExjobApply SET ReplyDate = AddDate + 1 WHERE ReplyDate IS NULL AND Reply > 0
  7230. SELECT DISTINCT a.cpMainId
  7231. INTO #t
  7232. FROM Job a, ExJobApply b, cpMain c
  7233. WHERE a.id = b.JobId
  7234. AND b.ReplyDate > CONVERT(VARCHAR(10), GETDate() - 2, 120)
  7235. AND c.id = a.cpMainId
  7236. AND c.AutoReplyConfirm is NULL --harry
  7237. SELECT a.cpMainId, COUNT(*) Cnt, COUNT(ReplyDate) ReplyCnt
  7238. INTO #1
  7239. FROM #t a, ExjobApply b, Job c
  7240. WHERE a.cpMainId = c.cpMainId
  7241. AND c.Id = b.JobId
  7242. AND b.AddDate > GETDate() - 183
  7243. GROUP BY a.cpMainId
  7244. --HAVING COUNT(*) > 9
  7245. UPDATE a
  7246. SET a.ReplyRate = b.ReplyCnt * 1.0 / b.Cnt
  7247. FROM cpMain a, #1 b
  7248. WHERE a.Id = b.cpMainId
  7249. AND b.ReplyCnt * 1.0 / b.Cnt > = 0.1
  7250. --UPDATE cpMain SET ReplyRate = NULL WHERE ReplyRate < 0.6
  7251. SELECT a.id, a.ReplyRate rate1, b.ReplyRate rate2
  7252. INTO #t2
  7253. FROM cpMainpublish a, cpMain b
  7254. WHERE a.id = b.id
  7255. AND isNULL(a.ReplyRate,0) <> ISNULL(b.ReplyRate, 0)
  7256. UPDATE a SET a.ReplyRate = b.rate2 FROM cpMainpublish a, #t2 b WHERE a.id = b.id --AND b.rate2> = 0.6
  7257. UPDATE a
  7258. SET a.ReplyRate = b.ReplyRate
  7259. FROM cpMainpublish a, cpMain b WHERE a.id = b.id AND ISNULL(a.ReplyRate, 0) <> ISNULL(b.ReplyRate, 0)
  7260. --UPDATE cpMainpublish SET ReplyRate = NULL WHERE ReplyRate <0.6
  7261. END
  7262. GO
  7263. /****** Object: StoredProcedure [dbo].[procCpMainHomepageLogoSelect] Script Date: 2018/12/13 19:10:09 ******/
  7264. SET ANSI_NULLS ON
  7265. GO
  7266. SET QUOTED_IDENTIFIER ON
  7267. GO
  7268. --创建人 Lambo 20101014
  7269. --用于首页免费logo区查询单位logo
  7270. CREATE PROCEDURE [dbo].[procCpMainHomepageLogoSelect]
  7271. (
  7272. @province_id SMALLINT
  7273. )
  7274. AS
  7275. BEGIN
  7276. SELECT TOP 24 a.id companyid, a.Name companyname, b.ImgFile filename
  7277. FROM cpMain a, cpImage b WITH(nolock)
  7278. WHERE a.Jobnumber > 0
  7279. AND a.MemberType > 1
  7280. AND a.Valid = 1
  7281. AND a.HasLogo = 1
  7282. AND a.dcProvinceid = @province_id
  7283. ORDER BY RefreshDate DESC
  7284. OPTION (KEEPFIXED PLAN)
  7285. END
  7286. GO
  7287. /****** Object: StoredProcedure [dbo].[ProcCpMainHomepageSnapshotDelete] Script Date: 2018/12/13 19:10:09 ******/
  7288. SET ANSI_NULLS ON
  7289. GO
  7290. SET QUOTED_IDENTIFIER ON
  7291. GO
  7292. CREATE PROCEDURE [dbo].[ProcCpMainHomepageSnapshotDelete]
  7293. AS
  7294. BEGIN
  7295. CREATE TABLE #t(Id INT)
  7296. CREATE TABLE #t1(Id INT)
  7297. DELETE FROM SearchDB..CpMainHomepageSnapshot WHERE MemberType IS NULL
  7298. UPDATE CpMainHomepageSnapshot SET dcRegionId = LEFT(dcRegionId, 4) WHERE Len(dcRegionId) > 4
  7299. INSERT INTO #t
  7300. SELECT ID FROM (SELECT dcRegionID, ID, ROW_NUMBER() over(PARTITION by dcRegionID order by RefreshDate desc) as num
  7301. FROM SearchDB..CpMainHomepageSnapshot WITH(NOLOCK)
  7302. WHERE MemberType > 2) a
  7303. WHERE Num <= 74
  7304. INSERT INTO #t
  7305. SELECT ID FROM (SELECT dcRegionID, ID, ROW_NUMBER() over(PARTITION by dcRegionID order by RefreshDate desc) as num
  7306. FROM SearchDB..CpMainHomepageSnapshot WITH(NOLOCK)
  7307. WHERE MemberType < 3) a
  7308. WHERE Num <= 80
  7309. INSERT INTO #t
  7310. SELECT ID FROM (SELECT dcSubSiteID, ID, ROW_NUMBER() over(PARTITION by dcSubSiteID order by RefreshDate desc) as num
  7311. FROM SearchDB..CpMainHomepageSnapshot WITH(NOLOCK)
  7312. WHERE MemberType > 2) a
  7313. WHERE Num <= 74
  7314. INSERT INTO #t
  7315. SELECT ID FROM (SELECT dcSubSiteID, ID, ROW_NUMBER() over(PARTITION by dcSubSiteID order by RefreshDate desc) as num
  7316. FROM SearchDB..CpMainHomepageSnapshot WITH(NOLOCK)
  7317. WHERE MemberType < 3) a
  7318. WHERE Num <= 80
  7319. INSERT #t1 SELECT ID FROM SearchDB..CpMainHomepageSnapshot
  7320. DELETE #t1 WHERE ID IN(SELECT ID FROM #t)
  7321. DELETE FROM SearchDB..CpMainHomepageSnapshot WHERE ID IN(SELECT ID FROM #t1)
  7322. END
  7323. GO
  7324. /****** Object: StoredProcedure [dbo].[ProcCpMainHomepageSnapShotFix] Script Date: 2018/12/13 19:10:09 ******/
  7325. SET ANSI_NULLS ON
  7326. GO
  7327. SET QUOTED_IDENTIFIER ON
  7328. GO
  7329. /*
  7330. sean 2013-8-21
  7331. 写一下注释,以便以后容易检查和阅读
  7332. */
  7333. CREATE PROCEDURE [dbo].[ProcCpMainHomepageSnapShotFix]
  7334. AS
  7335. BEGIN
  7336. --清空暂存表
  7337. TRUNCATE TABLE SearchDB..cpMainHomepageSnapshotTmp
  7338. DELETE CpMainHomepageSnapshot WHERE Name IS NULL OR RealCpMainId IS NULL Or RefreshDate IS NULL
  7339. DECLARE @t AS TABLE(CpMainID INT)
  7340. SELECT Id cpMainID
  7341. INTO #t
  7342. FROM cpMain WITH(NOLOCK)
  7343. WHERE MemberType > 0
  7344. AND (RefreshDate > DATEADD(MINUTE, -10, GETDATE())
  7345. OR LastLoginDate > DATEADD(MINUTE, -10, GETDATE())
  7346. )
  7347. AND Valid = 1
  7348. DELETE #t WHERE cpMainId IN(SELECT RealCpMainId FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK))
  7349. INSERT @t SELECT * FROM #t
  7350. --加入cpmaintmp临时表
  7351. INSERT INTO @t
  7352. SELECT DISTINCT cpMainID
  7353. FROM SearchDB..cpMainTmp WITH(NOLOCK)
  7354. INSERT INTO @t
  7355. SELECT a.Id
  7356. FROM cpMain a WITH(NOLOCK), SearchDB..cpMainHomepageSnapshot b WITH(NOLOCK)
  7357. WHERE a.Id = b.RealCpMainId
  7358. AND a.RefreshDate <> b.RefreshDate
  7359. --加入12分钟内修改过职位的企业
  7360. INSERT INTO @t(CpMainID)
  7361. SELECT DISTINCT cpMainID FROM Job WITH(NOLOCK)
  7362. WHERE LastModifyDate > DATEADD(MINUTE, -12, GETDATE())
  7363. AND cpMainID NOT IN(SELECT cpMainID FROM @t)
  7364. --把临时表的数据加入暂存表
  7365. INSERT INTO SearchDB..cpMainHomepageSnapshotTmp(cpMainId, RefreshDate, MemberType, dcSubsiteId, dcRegionId, Name, IsAgent, RealCpMainId)
  7366. SELECT SecondId, RefreshDate, MemberType, dcSubsiteId, dcRegionId, Name, IsAgent, Id
  7367. FROM cpMain WITH(NOLOCK)
  7368. WHERE ID IN(SELECT CpMainId FROM @t)
  7369. AND MemberType > 0 AND Valid = 1
  7370. --没有在百度上抓到的,设置nofollow="",就是要 follow
  7371. UPDATE SearchDB..cpMainHomepageSnapshotTmp SET NoFollow = ''
  7372. --WHERE cpMainId IN(SELECT PageID FROM PageBaiduInclude WHERE PageType = 1 AND IncludeDate IS NULL)
  7373. --填充暂存表数据
  7374. UPDATE a
  7375. SET a.JobNumber = b.JobNumber, a.IsAgent = b.IsAgent, a.dcSubSiteID = b.dcSubSiteID, a.MemberType = b.MemberType,
  7376. a.Name = b.Name, a.dcRegionID = b.dcRegionID
  7377. FROM SearchDB..cpMainHomepageSnapshotTmp a, cpMain b
  7378. WHERE a.RealCpMainid = b.id
  7379. --填充暂存表数据 jobids
  7380. UPDATE SearchDB..cpMainHomepageSnapshotTmp
  7381. SET JobId = dbo.getJobSecondIds(RealCpMainid), JobName = dbo.getJobNames(RealCpMainid)
  7382. --填充暂存表数据 最新职位
  7383. -- UPDATE SearchDB..CpMainHomepageSnapshotTmp
  7384. -- SET LastJobId = (SELECT TOP 1 SecondID FROM Job WITH(NOLOCK) WHERE Job.cpMainid = SearchDB..CpMainHomepageSnapshotTmp.RealCpMainId
  7385. -- AND Valid = 1 ORDER BY IssueDate DESC)
  7386. UPDATE a
  7387. SET a.LastJobId = (SELECT TOP 1 SecondID FROM Job WITH(NOLOCK) WHERE Job.cpMainid = a.RealCpMainId
  7388. AND Valid = 1 AND CHARINDEX(Job.SecondId, LEFT(a.JobId, 21)) > 0 ORDER BY IssueDate DESC)
  7389. FROM SearchDB..CpMainHomepageSnapshotTmp a
  7390. WHERE MemberType > 2
  7391. --填充暂存表数据最后发布时间
  7392. UPDATE SearchDB..cpMainHomepageSnapshotTmp
  7393. SET LastJobIssueDate = (SELECT IssueDate FROM Job WHERE Job.Secondid = SearchDB..cpMainHomepageSnapshotTmp.LastJobid)
  7394. WHERE MemberType > 2
  7395. --填充暂存表数据 营业执照审核时间
  7396. UPDATE a SET a.cplicenceDate=b.checkDate
  7397. FROM SearchDB..cpMainHomepageSnapshotTmp a, cpLicence b
  7398. WHERE a.RealCpMainid = b.cpMainid
  7399. AND a.MemberType < 3
  7400. --先添加未增加的
  7401. INSERT INTO SearchDB..cpMainHomepageSnapshot(cpMainId, NoFollow, RealCpMainid)
  7402. SELECT cpMainId, NoFollow, RealCpMainid
  7403. FROM SearchDB..cpMainHomepageSnapshotTmp WITH(NOLOCK)
  7404. WHERE RealCpMainid NOT IN(SELECT RealCpMainid FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK))
  7405. --再更改数据
  7406. UPDATE a
  7407. SET a.dcSubsiteID = b.dcSubsiteID,
  7408. a.dcRegionID = b.dcRegionID,
  7409. a.MemberType = b.MemberType,
  7410. a.Name = b.Name,
  7411. a.IsAgent = b.IsAgent,
  7412. a.JobNumber = b.JobNumber,
  7413. a.JobID = b.JobID,
  7414. a.JobName = b.JobName,
  7415. a.LastJobIssueDate = b.LastJobIssueDate,
  7416. a.LastJobId = b.LastJobId,
  7417. a.cpLicenceDate = b.cpLicenceDate,
  7418. a.RefreshDate = b.RefreshDate
  7419. FROM SearchDb..cpMainHomepageSnapshot a WITH(NOLOCK),
  7420. SearchDb..cpMainHomepageSnapshotTmp b WITH(NOLOCK)
  7421. WHERE a.RealCpMainid = b.RealCpMainid
  7422. UPDATE a
  7423. SET a.LastJobId = (SELECT TOP 1 SecondID FROM Job WITH(NOLOCK) WHERE Job.cpMainid = a.RealCpMainId
  7424. AND Valid = 1 AND CHARINDEX(Job.SecondId, LEFT(a.JobId, 21)) > 0 ORDER BY IssueDate DESC)
  7425. FROM SearchDB..CpMainHomepageSnapshot a
  7426. WHERE MemberType > 2
  7427. TRUNCATE TABLE SearchDB..cpMainTmp
  7428. END
  7429. GO
  7430. /****** Object: StoredProcedure [dbo].[ProcCpMainHomepageSnapshotRebuild] Script Date: 2018/12/13 19:10:10 ******/
  7431. SET ANSI_NULLS ON
  7432. GO
  7433. SET QUOTED_IDENTIFIER ON
  7434. GO
  7435. CREATE PROCEDURE [dbo].[ProcCpMainHomepageSnapshotRebuild]
  7436. AS
  7437. BEGIN
  7438. TRUNCATE TABLE SearchDB..CpMainHomepageSnapshotTmp
  7439. --找出所有1天内刷新的,未认证的或普通或缴费的,并且有效的企业
  7440. INSERT SearchDB..CpMainHomepageSnapshotTmp(cpMainId, RefreshDate, RealCpMainId, MemberType, dcRegionID, dcSubSiteId)
  7441. SELECT SecondId, RefreshDate, Id, MemberType, dcRegionID, dcSubSiteId
  7442. FROM cpMain WITH(NOLOCK)
  7443. WHERE Refreshdate > GETDATE() - 1 AND MemberType > 0 AND Valid = 1
  7444. EXEC ProcCpMainHomepageSnapshotTmpDelete
  7445. --没有在百度上抓到的,设置nofollow="",就是要 follow
  7446. UPDATE SearchDB..CpMainHomepageSnapshotTmp SET NoFollow = ''
  7447. --WHERE CpMainId IN(SELECT PageID FROM PageBaiduInclude WHERE PageType = 1 AND IncludeDate IS NULL)
  7448. --填写内容
  7449. UPDATE a
  7450. SET a.JobNumber = b.JobNumber, a.IsAgent = b.IsAgent, a.Name = b.Name
  7451. FROM SearchDB..CpMainHomepageSnapshotTmp a, cpMain b
  7452. WHERE a.RealCpMainId=b.id
  7453. --填写jobids
  7454. UPDATE SearchDB..CpMainHomepageSnapshotTmp
  7455. SET JobId = dbo.GetJobSecondIds(RealCpMainId), JobName = dbo.GetJobNames(RealCpMainId)
  7456. --找出收费用户的最新职位id
  7457. -- UPDATE SearchDB..CpMainHomepageSnapshotTmp
  7458. -- SET LastJobId = (SELECT TOP 1 SecondID FROM Job WITH(NOLOCK) WHERE Job.cpMainid = SearchDB..CpMainHomepageSnapshotTmp.RealCpMainId
  7459. -- AND Valid = 1 ORDER BY IssueDate DESC)
  7460. UPDATE a
  7461. SET a.LastJobId = (SELECT TOP 1 SecondID FROM Job WITH(NOLOCK) WHERE Job.cpMainid = a.RealCpMainId
  7462. AND Valid = 1 AND CHARINDEX(Job.SecondId, LEFT(a.JobId, 21)) > 0 ORDER BY IssueDate DESC)
  7463. FROM SearchDB..CpMainHomepageSnapshotTmp a
  7464. WHERE MemberType > 2
  7465. --找出收费用户的最后发布日期
  7466. UPDATE SearchDB..CpMainHomepageSnapshotTmp
  7467. SET LastJobIssueDate = (SELECT IssueDate FROM Job WHERE Job.SecondId = SearchDB..CpMainHomepageSnapshotTmp.LastJobid)
  7468. WHERE MemberType > 2
  7469. --普通用户填写营业执照审核时间
  7470. UPDATE a SET a.cplicenceDate=b.checkDate
  7471. FROM SearchDB..CpMainHomepageSnapshotTmp a, cpLicence b
  7472. WHERE a.RealCpMainId = b.cpMainid
  7473. AND a.MemberType < 3
  7474. --如果CpMainHomepageSnapshotTmp数量少于3000行就不更新了,因为很可能是出错了
  7475. IF (SELECT COUNT(*) FROM SearchDB..CpMainHomepageSnapshotTmp WITH(NOLOCK)) > 3000
  7476. BEGIN
  7477. TRUNCATE TABLE SearchDB..CpMainHomepageSnapshot
  7478. SET IDENTITY_INSERT SearchDB..CpMainHomepageSnapshot ON
  7479. INSERT INTO SearchDB..CpMainHomepageSnapshot(ID, dcSubsiteID, dcRegionID, cpMainID, MemberType, Name, IsAgent, JobNumber, JobID,
  7480. JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, NoFollow, RealCpMainId)
  7481. SELECT ID, dcSubsiteID, dcRegionID, cpMainID, MemberType, Name, IsAgent, JobNumber, JobID,
  7482. JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, NoFollow, RealCpMainId
  7483. FROM SearchDB..CpMainHomepageSnapshotTmp
  7484. SET IDENTITY_INSERT SearchDB..CpMainHomepageSnapshot OFF
  7485. END
  7486. ELSE
  7487. RETURN
  7488. --如果CpMainHomepageSnapshot数量少于3000行,尝试更新一次
  7489. IF (SELECT COUNT(*) FROM SearchDB..CpMainHomepageSnapshot WITH(NOLOCK)) < 3000
  7490. BEGIN
  7491. TRUNCATE TABLE SearchDB..CpMainHomepageSnapshot
  7492. SET IDENTITY_INSERT SearchDB..CpMainHomepageSnapshot ON
  7493. INSERT INTO SearchDB..CpMainHomepageSnapshot(ID, dcSubsiteID, dcRegionID, cpMainID, MemberType, Name, IsAgent, JobNumber, JobID,
  7494. JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, NoFollow, RealCpMainId)
  7495. SELECT ID, dcSubsiteID, dcRegionID, cpMainID, MemberType, Name, IsAgent, JobNumber, JobID,
  7496. JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, NoFollow, RealCpMainId
  7497. FROM SearchDB..CpMainHomepageSnapshotTmp
  7498. SET IDENTITY_INSERT SearchDB..CpMainHomepageSnapshot OFF
  7499. END
  7500. --如果CpMainHomepageSnapshot数量少于3000行,再尝试更新一次
  7501. IF (SELECT COUNT(*) FROM SearchDB..CpMainHomepageSnapshot WITH(NOLOCK)) < 3000
  7502. BEGIN
  7503. TRUNCATE TABLE SearchDB..CpMainHomepageSnapshot
  7504. SET IDENTITY_INSERT SearchDB..CpMainHomepageSnapshot ON
  7505. INSERT INTO SearchDB..CpMainHomepageSnapshot(ID, dcSubsiteID, dcRegionID, cpMainID, MemberType, Name, IsAgent, JobNumber, JobID,
  7506. JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, NoFollow, RealCpMainId)
  7507. SELECT ID, dcSubsiteID, dcRegionID, cpMainID, MemberType, Name, IsAgent, JobNumber, JobID,
  7508. JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, NoFollow, RealCpMainId
  7509. FROM SearchDB..CpMainHomepageSnapshotTmp
  7510. SET IDENTITY_INSERT SearchDB..CpMainHomepageSnapshot OFF
  7511. END
  7512. END
  7513. GO
  7514. /****** Object: StoredProcedure [dbo].[ProcCpMainHomepageSnapshotTmpDelete] Script Date: 2018/12/13 19:10:11 ******/
  7515. SET ANSI_NULLS ON
  7516. GO
  7517. SET QUOTED_IDENTIFIER ON
  7518. GO
  7519. CREATE PROCEDURE [dbo].[ProcCpMainHomepageSnapshotTmpDelete]
  7520. AS
  7521. BEGIN
  7522. CREATE TABLE #t(Id INT)
  7523. CREATE TABLE #t1(Id INT)
  7524. DELETE FROM SearchDB..CpMainHomepageSnapshotTmp WHERE MemberType IS NULL
  7525. UPDATE SearchDb..CpMainHomepageSnapshotTmp SET dcRegionId = LEFT(dcRegionId, 4) WHERE Len(dcRegionId) > 4
  7526. INSERT INTO #t
  7527. SELECT RealcpMainID FROM (SELECT dcRegionID, RealcpMainID, ROW_NUMBER() over(PARTITION by dcRegionID order by RefreshDate desc) as num
  7528. FROM SearchDB..CpMainHomepageSnapshotTmp WITH(NOLOCK)
  7529. WHERE MemberType > 2) a
  7530. WHERE Num <= 74
  7531. INSERT INTO #t
  7532. SELECT RealcpMainID FROM (SELECT dcRegionID, RealcpMainID, ROW_NUMBER() over(PARTITION by dcRegionID order by RefreshDate desc) as num
  7533. FROM SearchDB..CpMainHomepageSnapshotTmp WITH(NOLOCK)
  7534. WHERE MemberType < 3) a
  7535. WHERE Num <= 80
  7536. INSERT INTO #t
  7537. SELECT RealcpMainID FROM (SELECT dcSubSiteID, RealcpMainID, ROW_NUMBER() over(PARTITION by dcSubSiteID order by RefreshDate desc) as num
  7538. FROM SearchDB..CpMainHomepageSnapshotTmp WITH(NOLOCK)
  7539. WHERE MemberType > 2) a
  7540. WHERE Num <= 74
  7541. INSERT INTO #t
  7542. SELECT RealcpMainID FROM (SELECT dcSubSiteID, RealcpMainID, ROW_NUMBER() over(PARTITION by dcSubSiteID order by RefreshDate desc) as num
  7543. FROM SearchDB..CpMainHomepageSnapshotTmp WITH(NOLOCK)
  7544. WHERE MemberType < 3) a
  7545. WHERE Num <= 80
  7546. INSERT #t1 SELECT RealcpMainID FROM SearchDB..CpMainHomepageSnapshotTmp
  7547. DELETE #t1 WHERE ID IN(SELECT ID FROM #t)
  7548. DELETE FROM SearchDB..CpMainHomepageSnapshotTmp WHERE RealcpMainID IN(SELECT ID FROM #t1)
  7549. END
  7550. GO
  7551. /****** Object: StoredProcedure [dbo].[procCpMainProvinceIDByCaMainIDSelect] Script Date: 2018/12/13 19:10:11 ******/
  7552. SET ANSI_NULLS ON
  7553. GO
  7554. SET QUOTED_IDENTIFIER ON
  7555. GO
  7556. --#####################################################
  7557. --创建时间:2014.11.10
  7558. --创建人:John
  7559. --说明:获取公司所在地ID信息
  7560. --#####################################################
  7561. CREATE PROCEDURE [dbo].[procCpMainProvinceIDByCaMainIDSelect]
  7562. (
  7563. @caMainID INT
  7564. )
  7565. AS
  7566. BEGIN
  7567. SELECT b.dcProvinceID FROM caMain a WITH(NOLOCK),cpMain b WITH(NOLOCK) WHERE a.id = @caMainID AND a.cpMainID = b.id
  7568. END
  7569. GO
  7570. /****** Object: StoredProcedure [dbo].[ProcCpMainSameIndustry32Insert] Script Date: 2018/12/13 19:10:12 ******/
  7571. SET ANSI_NULLS ON
  7572. GO
  7573. SET QUOTED_IDENTIFIER ON
  7574. GO
  7575. CREATE PROCEDURE [dbo].[ProcCpMainSameIndustry32Insert]
  7576. AS
  7577. SET NOCOUNT ON
  7578. BEGIN
  7579. SELECT 32 dcRegionId, dcIndustryID, ID RealId, SecondID, Name, Row
  7580. INTO #t
  7581. FROM (SELECT Left(a.dcRegionId, 4) dcRegionId, b.dcIndustryID, a.Id, a.SecondID, a.Name, a.LastLoginDate,
  7582. ROW_NUMBER() OVER(PARTITION BY b.dcIndustryId ORDER BY a.Id DESC) Row
  7583. FROM cpMainPublish a WITH(NOLOCK)
  7584. LEFT JOIN cpIndustry b ON a.id = b.CpmainID
  7585. WHERE a.dcProvinceId = '30' --temp modify
  7586. AND MemberType > 1
  7587. ) a
  7588. WHERE a.Row < 11
  7589. AND a.Id IN (SELECT cpMainId FROM JobPublish WITH(NOLOCK) WHERE Valid > 0)
  7590. ORDER BY dcRegionId, dcIndustryID, Row
  7591. ALTER TABLE #t ADD LogoFile VARCHAR(90)
  7592. UPDATE a SET A.LogoFile = b.LogoFile FROM #t a, cpMain b WHERE a.RealId = b.ID
  7593. TRUNCATE TABLE SearchDb..CpMainSameIndustry32
  7594. INSERT INTO SearchDb..CpMainSameIndustry32 SELECT * FROM #t
  7595. END
  7596. GO
  7597. /****** Object: StoredProcedure [dbo].[ProcCpMainSameIndustryInsert] Script Date: 2018/12/13 19:10:12 ******/
  7598. SET ANSI_NULLS ON
  7599. GO
  7600. SET QUOTED_IDENTIFIER ON
  7601. GO
  7602. CREATE PROCEDURE [dbo].[ProcCpMainSameIndustryInsert]
  7603. AS
  7604. BEGIN
  7605. SELECT dcRegionId, dcIndustryID, ID RealId, SecondID, Name, Row
  7606. INTO #t
  7607. FROM (SELECT Left(a.dcRegionId, 4) dcRegionId, b.dcIndustryID, a.Id, a.SecondID, a.Name, a.LastLoginDate,
  7608. ROW_NUMBER() OVER(PARTITION BY Left(a.dcRegionId, 4), b.dcIndustryId ORDER BY a.LastLoginDate DESC) Row
  7609. FROM cpMainPublish a WITH(NOLOCK)
  7610. LEFT JOIN cpIndustry b ON a.id = b.CpmainID
  7611. WHERE a.dcRegionId NOT LIKE '32%' --temp modify
  7612. ) a
  7613. WHERE a.Row < 11
  7614. AND a.Id IN (SELECT cpMainId FROM JobPublish WITH(NOLOCK) WHERE Valid > 0)
  7615. ORDER BY dcRegionId, dcIndustryID, Row
  7616. ALTER TABLE #t ADD LogoFile VARCHAR(90)
  7617. UPDATE a SET A.LogoFile = b.LogoFile FROM #t a, cpMain b WHERE a.RealId = b.ID
  7618. TRUNCATE TABLE SearchDb..CpMainSameIndustry
  7619. INSERT INTO SearchDb..CpMainSameIndustry SELECT * FROM #t WHERE dcRegionId NOT LIKE '32%'
  7620. --TRUNCATE TABLE SearchDb..CpMainSameIndustry32
  7621. --INSERT INTO SearchDb..CpMainSameIndustry32 SELECT * FROM #t WHERE dcRegionId LIKE '32%'
  7622. EXEC ProcCpMainSameIndustry32Insert
  7623. END
  7624. GO
  7625. /****** Object: StoredProcedure [dbo].[ProcCpViPlanSmsMessageLogInsert] Script Date: 2018/12/13 19:10:12 ******/
  7626. SET ANSI_NULLS ON
  7627. GO
  7628. SET QUOTED_IDENTIFIER ON
  7629. GO
  7630. --#####################################################
  7631. --创建时间:2014.10.29
  7632. --创建人:John
  7633. --说明:企业邀请个人视频面试添加短信通知
  7634. --#####################################################
  7635. CREATE PROCEDURE [dbo].[ProcCpViPlanSmsMessageLogInsert]
  7636. (
  7637. @JobID INT,
  7638. @CvMainID INT
  7639. )
  7640. AS
  7641. BEGIN
  7642. DECLARE @cnt INT
  7643. SELECT @cnt = COUNT(1)
  7644. FROM SmsMessageLog
  7645. WHERE msgtype = 121
  7646. AND camainid =
  7647. (
  7648. SELECT camainid
  7649. FROM job
  7650. WHERE id = @JobID
  7651. )
  7652. AND adddate > CONVERT(VARCHAR(10), GETDATE(), 23)
  7653. IF @cnt < 10
  7654. BEGIN
  7655. INSERT SmsMessageLog(SendMan, ManagerUserId, paMainId, caMainId, Mobile, MsgType, IsCat, Msg)
  7656. SELECT TOP 1 0, NULL, a.ID, e.caMainID, b.Mobile, 121, 0, ISNULL(b.Name,'') +','+ d.Name +'在'+ c.SubSiteName + c.EmailSite +'上邀请您参加视频面试,请登录网站查看'
  7657. FROM cvMain a WITH(NOLOCK),
  7658. paMain b WITH(NOLOCK),
  7659. dcSubSite c WITH(NOLOCK),
  7660. cpMain d WITH(NOLOCK),
  7661. job e WITH(NOLOCK)
  7662. WHERE a.paMainID = b.ID
  7663. AND b.dcSubSiteID = c.ID
  7664. AND d.id = e.cpMainID
  7665. AND e.ID = @JobID
  7666. AND b.Mobile > ''
  7667. AND a.ID = @CvMainID
  7668. AND b.IsReceiveSms = 1
  7669. END
  7670. END
  7671. GO
  7672. /****** Object: StoredProcedure [dbo].[procCpwishByIDSelect] Script Date: 2018/12/13 19:10:12 ******/
  7673. SET ANSI_NULLS ON
  7674. GO
  7675. SET QUOTED_IDENTIFIER ON
  7676. GO
  7677. --#####################################################
  7678. --创建时间:2014.11.5
  7679. --创建人:NICK
  7680. --说明:祝福墙数据
  7681. --#####################################################
  7682. CREATE PROCEDURE [dbo].[procCpwishByIDSelect]
  7683. (
  7684. @ID INT
  7685. )
  7686. AS
  7687. BEGIN
  7688. UPDATE ShortDB..cpwish SET ClickNumber=ClickNumber+1 WHERE ID=@ID
  7689. SELECT * FROM ShortDB..cpwish WITH(NOLOCK) WHERE ID=@ID
  7690. END
  7691. GO
  7692. /****** Object: StoredProcedure [dbo].[procCpwishInsert] Script Date: 2018/12/13 19:10:13 ******/
  7693. SET ANSI_NULLS ON
  7694. GO
  7695. SET QUOTED_IDENTIFIER ON
  7696. GO
  7697. --#####################################################
  7698. --创建时间:2014.11.5
  7699. --创建人:NICK
  7700. --说明:祝福墙数据插入
  7701. --#####################################################
  7702. CREATE PROCEDURE [dbo].[procCpwishInsert]
  7703. (
  7704. @Content VARCHAR(500),
  7705. @cpMainID INT
  7706. )
  7707. AS
  7708. BEGIN
  7709. INSERT INTO ShortDB..cpwish VALUES(@cpMainID,@Content,1,0,GETDATE())
  7710. RETURN 1
  7711. END
  7712. GO
  7713. /****** Object: StoredProcedure [dbo].[procCpwishSelect] Script Date: 2018/12/13 19:10:13 ******/
  7714. SET ANSI_NULLS ON
  7715. GO
  7716. SET QUOTED_IDENTIFIER ON
  7717. GO
  7718. --#####################################################
  7719. --创建时间:2014.11.5
  7720. --创建人:NICK
  7721. --说明:祝福墙数据获取
  7722. --#####################################################
  7723. CREATE PROCEDURE [dbo].[procCpwishSelect]
  7724. AS
  7725. BEGIN
  7726. SELECT TOP 200 a.*,b.Name cpName
  7727. FROM ShortDB..cpwish a WITH(NOLOCK),cpMain b WITH(NOLOCK)
  7728. WHERE b.ID=a.cpMainID
  7729. AND IsDesplay='1'
  7730. ORDER BY addDate DESC
  7731. END
  7732. GO
  7733. /****** Object: StoredProcedure [dbo].[procCvDownDocByDowncountSelect] Script Date: 2018/12/13 19:10:13 ******/
  7734. SET ANSI_NULLS ON
  7735. GO
  7736. SET QUOTED_IDENTIFIER ON
  7737. GO
  7738. --type=1 首页/下载排行获取
  7739. --harry
  7740. --2017-12-18
  7741. --Carl 2018-02-01
  7742. --Carl 2018-02-28
  7743. CREATE PROCEDURE [dbo].[procCvDownDocByDowncountSelect]
  7744. (
  7745. @type INT
  7746. )
  7747. AS
  7748. BEGIN
  7749. SET NOCOUNT ON
  7750. IF @type =1 --首页
  7751. BEGIN
  7752. SELECT TOP 10 *
  7753. FROM cvdowndoc WITH(NOLOCK)
  7754. WHERE IsBeta=0 ORDER BY newid()
  7755. END
  7756. ELSE IF @type=2
  7757. BEGIN
  7758. SELECT *
  7759. FROM cvdowndoc WITH(NOLOCK)
  7760. WHERE IsBeta=0
  7761. ORDER BY downcount DESC
  7762. END
  7763. ELSE--测试用的
  7764. BEGIN
  7765. SELECT *
  7766. FROM cvdowndoc WITH(NOLOCK)
  7767. ORDER BY downcount DESC
  7768. END
  7769. SET NOCOUNT OFF
  7770. END
  7771. GO
  7772. /****** Object: StoredProcedure [dbo].[procCvDownDocByIdSelect] Script Date: 2018/12/13 19:10:13 ******/
  7773. SET ANSI_NULLS ON
  7774. GO
  7775. SET QUOTED_IDENTIFIER ON
  7776. GO
  7777. --获取简历模板详情
  7778. --harry
  7779. --2017-12-21
  7780. CREATE PROCEDURE [dbo].[procCvDownDocByIdSelect]
  7781. (
  7782. @Id INT
  7783. )
  7784. AS
  7785. BEGIN
  7786. SET NOCOUNT ON
  7787. SELECT *
  7788. FROM cvdowndoc WITH(NOLOCK)
  7789. WHERE id = @Id
  7790. SET NOCOUNT OFF
  7791. END
  7792. GO
  7793. /****** Object: StoredProcedure [dbo].[procCvDownDocUpdate] Script Date: 2018/12/13 19:10:14 ******/
  7794. SET ANSI_NULLS ON
  7795. GO
  7796. SET QUOTED_IDENTIFIER ON
  7797. GO
  7798. --更新简历模板的浏览量、下载量
  7799. --type 1浏览量 2下载量
  7800. --harry
  7801. --2017-12-21
  7802. CREATE PROCEDURE [dbo].[procCvDownDocUpdate]
  7803. (
  7804. @type INT,
  7805. @id INT
  7806. )
  7807. AS
  7808. BEGIN
  7809. IF @type = 1
  7810. BEGIN
  7811. UPDATE cvdowndoc
  7812. SET ViewCount = ISNULL(ViewCount,0) +1
  7813. WHERE id = @id
  7814. END
  7815. ELSE
  7816. BEGIN
  7817. UPDATE cvdowndoc
  7818. SET DownCount = ISNULL(DownCount,0) +1
  7819. WHERE id = @id
  7820. END
  7821. END
  7822. GO
  7823. /****** Object: StoredProcedure [dbo].[ProcCvMainByHasVerifySelect] Script Date: 2018/12/13 19:10:14 ******/
  7824. SET ANSI_NULLS ON
  7825. GO
  7826. SET QUOTED_IDENTIFIER ON
  7827. GO
  7828. create procedure [dbo].[ProcCvMainByHasVerifySelect]
  7829. (
  7830. @cvMainId INT
  7831. )
  7832. AS
  7833. BEGIN
  7834. IF EXISTS(SELECT 'x' FROM paMain a, cvMain b
  7835. WHERE a.Id = b.paMainId
  7836. AND a.VerifyCount > 0
  7837. AND b.Id = @cvMAinId
  7838. AND b.VerifyResult = 1
  7839. )
  7840. RETURN 1
  7841. ELSE
  7842. RETURN 0
  7843. END
  7844. GO
  7845. /****** Object: StoredProcedure [dbo].[procCvMainByPaMainIDSelect] Script Date: 2018/12/13 19:10:14 ******/
  7846. SET ANSI_NULLS ON
  7847. GO
  7848. SET QUOTED_IDENTIFIER ON
  7849. GO
  7850. --#####################################################
  7851. --创建时间:2014.11.10
  7852. --创建人:Nick
  7853. --说明:根据PaMianID来获取其简历的ID和AddDate
  7854. --#####################################################
  7855. CREATE PROCEDURE [dbo].[procCvMainByPaMainIDSelect]
  7856. (
  7857. @paMainID INT
  7858. )
  7859. AS
  7860. BEGIN TRY
  7861. SELECT * FROM cvmain a WITH(NOLOCK),pamain b WITH(NOLOCK)
  7862. WHERE a.paMainID=b.ID
  7863. AND pamainid= @paMainID
  7864. ORDER BY a.valid DESC,a.refreshdate DESC
  7865. END TRY
  7866. BEGIN CATCH
  7867. RETURN 0
  7868. END CATCH
  7869. GO
  7870. /****** Object: StoredProcedure [dbo].[proccvrExchangeByRecommendIDSelect] Script Date: 2018/12/13 19:10:15 ******/
  7871. SET ANSI_NULLS ON
  7872. GO
  7873. SET QUOTED_IDENTIFIER ON
  7874. GO
  7875. --#####################################################
  7876. --创建时间:2014.10.31
  7877. --创建人:Nick
  7878. --说明:获取礼品列表
  7879. --#####################################################
  7880. CREATE PROCEDURE [dbo].[proccvrExchangeByRecommendIDSelect]
  7881. (
  7882. @RecommendID INT
  7883. )
  7884. AS
  7885. BEGIN TRY
  7886. SELECT (
  7887. SELECT COUNT(*) cnt
  7888. FROM marketdb..cvrRecommend
  7889. WHERE RecommendID=@RecommendID
  7890. AND HasValid=3
  7891. AND HasReply=1
  7892. )
  7893. allIntegral,(
  7894. SELECT SUM(Amount)
  7895. FROM marketdb..cvrExchange
  7896. WHERE RecommendID=@RecommendID AND HasVerify<>2
  7897. ) lastIntegral
  7898. END TRY
  7899. BEGIN CATCH
  7900. RETURN 0
  7901. END CATCH
  7902. GO
  7903. /****** Object: StoredProcedure [dbo].[ProcDcAutoEmailInsert] Script Date: 2018/12/13 19:10:15 ******/
  7904. SET ANSI_NULLS ON
  7905. GO
  7906. SET QUOTED_IDENTIFIER ON
  7907. GO
  7908. CREATE PROCEDURE [dbo].[ProcDcAutoEmailInsert]
  7909. AS
  7910. BEGIN
  7911. IF(SELECT COUNT(*) FROM dcAutoEmail) > 50000
  7912. RETURN
  7913. SELECT TOP 0 * INTO #t FROM dcAutoEmail
  7914. INSERT #t
  7915. SELECT TOP 10000 LEFT(NEWID(), 3) + '_' + LEFT(NEWID(), 2) + '@your_email.com' FROM cpMain
  7916. UPDATE #t SET Email = CHAR(65 + id % 26) + Email
  7917. DELETE a
  7918. FROM #t a, dcAutoEmail b
  7919. WHERE a.Email = b.Email
  7920. DELETE a
  7921. FROM #t a, paMain b
  7922. WHERE a.Email = b.Email
  7923. DELETE a
  7924. FROM #t a, Resume_XinXi b
  7925. WHERE a.Email = b.Email
  7926. INSERT INTO dcAutoEmail SELECT DISTINCT Email FROM #t
  7927. END
  7928. GO
  7929. /****** Object: StoredProcedure [dbo].[procdcAutoEmailSelect] Script Date: 2018/12/13 19:10:15 ******/
  7930. SET ANSI_NULLS ON
  7931. GO
  7932. SET QUOTED_IDENTIFIER ON
  7933. GO
  7934. --#####################################################
  7935. --创建时间:2014.11.12
  7936. --创建人:Nick
  7937. --说明:
  7938. --#####################################################
  7939. CREATE PROCEDURE [dbo].[procdcAutoEmailSelect]
  7940. AS
  7941. BEGIN
  7942. SELECT top 1 * FROM dcAutoEmail ORDER BY id
  7943. END
  7944. GO
  7945. /****** Object: StoredProcedure [dbo].[procdcCollegeSelect] Script Date: 2018/12/13 19:10:15 ******/
  7946. SET ANSI_NULLS ON
  7947. GO
  7948. SET QUOTED_IDENTIFIER ON
  7949. GO
  7950. --#####################################################
  7951. --创建时间:2014.10.31
  7952. --创建人:Nick
  7953. --说明:读取学校信息
  7954. --#####################################################
  7955. CREATE PROCEDURE [dbo].[procdcCollegeSelect]
  7956. (
  7957. @CollegeName VARCHAR(50)
  7958. )
  7959. AS
  7960. BEGIN TRY
  7961. SELECT TOP 10 COLNAME
  7962. FROM dccollege
  7963. WHERE COLNAME LIKE ''+@CollegeName+'%'
  7964. OR Pinyin LIKE ''+@CollegeName+'%'
  7965. OR Jianpin LIKE ''+@CollegeName+'%'
  7966. END TRY
  7967. BEGIN CATCH
  7968. RETURN 0
  7969. END CATCH
  7970. GO
  7971. /****** Object: StoredProcedure [dbo].[procdcCvConvertMapSelect] Script Date: 2018/12/13 19:10:16 ******/
  7972. SET ANSI_NULLS ON
  7973. GO
  7974. SET QUOTED_IDENTIFIER ON
  7975. GO
  7976. --#####################################################
  7977. --创建时间:2014.10.31
  7978. --创建人:Nick
  7979. --说明:获取对应的自己数据库中的ID
  7980. --修改:Mice 123 修改@type 的长度为50
  7981. --#####################################################
  7982. CREATE PROCEDURE [dbo].[procdcCvConvertMapSelect]
  7983. (
  7984. @webName VARCHAR(100),
  7985. @type VARCHAR(50),
  7986. @description VARCHAR(500)
  7987. )
  7988. AS
  7989. BEGIN
  7990. SELECT *
  7991. FROM dcCvConvertMap WITH(NOLOCK)
  7992. WHERE webName = @webName
  7993. AND type = @type
  7994. AND description = @description
  7995. END
  7996. GO
  7997. /****** Object: StoredProcedure [dbo].[ProcDcFeeStandardByPriceCvSelect] Script Date: 2018/12/13 19:10:16 ******/
  7998. SET ANSI_NULLS ON
  7999. GO
  8000. SET QUOTED_IDENTIFIER ON
  8001. GO
  8002. CREATE PROCEDURE [dbo].[ProcDcFeeStandardByPriceCvSelect]
  8003. (
  8004. @dcProvinceID AS INT
  8005. )
  8006. AS
  8007. BEGIN
  8008. SELECT PriceCv FROM DcFeeStandard WITH(NOLOCK)
  8009. WHERE dcProvinceID = @dcProvinceID
  8010. END
  8011. GO
  8012. /****** Object: StoredProcedure [dbo].[procDcFeeStandardByProvinceIDSelect] Script Date: 2018/12/13 19:10:16 ******/
  8013. SET ANSI_NULLS ON
  8014. GO
  8015. SET QUOTED_IDENTIFIER ON
  8016. GO
  8017. --#####################################################
  8018. --创建时间:2014.11.03
  8019. --创建人:Nick
  8020. --说明:dcfeestandard
  8021. --#####################################################
  8022. CREATE PROCEDURE [dbo].[procDcFeeStandardByProvinceIDSelect]
  8023. (
  8024. @ProvinceID INT
  8025. )
  8026. AS
  8027. BEGIN TRY
  8028. SELECT NeedPoint FROM dcfeestandard With(Nolock) WHERE dcprovinceid=@ProvinceID
  8029. END TRY
  8030. BEGIN CATCH
  8031. RETURN 0
  8032. END CATCH
  8033. GO
  8034. /****** Object: StoredProcedure [dbo].[procDcIndustrySelect] Script Date: 2018/12/13 19:10:16 ******/
  8035. SET ANSI_NULLS ON
  8036. GO
  8037. SET QUOTED_IDENTIFIER ON
  8038. GO
  8039. --#####################################################
  8040. --创建时间:2014.11.5
  8041. --创建人:NICK
  8042. --说明:获取行业信息
  8043. --#####################################################
  8044. CREATE PROCEDURE [dbo].[procDcIndustrySelect]
  8045. AS
  8046. BEGIN
  8047. SELECT * FROM dcindustry ORDER BY category,orderno
  8048. END
  8049. GO
  8050. /****** Object: StoredProcedure [dbo].[procdcIpPlaceByIPMobileSelect] Script Date: 2018/12/13 19:10:17 ******/
  8051. SET ANSI_NULLS ON
  8052. GO
  8053. SET QUOTED_IDENTIFIER ON
  8054. GO
  8055. --#####################################################
  8056. --创建时间:2018.6.11
  8057. --创建人:harry
  8058. --说明:根据ip或mobile得到dcIpPlace
  8059. --#####################################################
  8060. CREATE PROCEDURE [dbo].[procdcIpPlaceByIPMobileSelect]
  8061. (
  8062. @IP INT,
  8063. @Mobile CHAR(11)
  8064. )
  8065. AS
  8066. BEGIN
  8067. DECLARE @regionId INT
  8068. IF LEN(@Mobile)>0
  8069. BEGIN
  8070. SELECT TOP 1 @regionId=dcRegionId
  8071. FROM dcMobilearea WITH (NOLOCK)
  8072. WHERE LEFT(@Mobile,7)=Num
  8073. END
  8074. ELSE
  8075. BEGIN
  8076. SELECT TOP 1 @regionId=dcSubSiteId
  8077. FROM dcIpPlace a WITH(NOLOCK INDEX(IX_dcIpPlace_IpStart))
  8078. WHERE IPStart <= @IP
  8079. ORDER BY IPStart DESC
  8080. IF LEN(@regionId)<3
  8081. BEGIN
  8082. SELECT TOP 1 @regionId=dcRegionId
  8083. FROM dcMobilearea WITH (NOLOCK)
  8084. WHERE LEFT(@Mobile,7)=Num
  8085. END
  8086. END
  8087. IF LEN(@regionId)<4
  8088. BEGIN
  8089. SELECT TOP 0 ID, Abbr
  8090. FROM dcRegion
  8091. END
  8092. ELSE
  8093. BEGIN
  8094. SELECT ID, Abbr
  8095. FROM dcRegion
  8096. WHERE ID=LEFT(@regionId,4)
  8097. END
  8098. END
  8099. GO
  8100. /****** Object: StoredProcedure [dbo].[procdcIpPlaceByIPSelect] Script Date: 2018/12/13 19:10:17 ******/
  8101. SET ANSI_NULLS ON
  8102. GO
  8103. SET QUOTED_IDENTIFIER ON
  8104. GO
  8105. --#####################################################
  8106. --创建时间:2014.11.3
  8107. --创建人:NICK
  8108. --说明:根据ip得到dcIpPlace
  8109. --#####################################################
  8110. CREATE PROCEDURE [dbo].[procdcIpPlaceByIPSelect]
  8111. (
  8112. @IP VARCHAR(20)
  8113. )
  8114. AS
  8115. BEGIN
  8116. SELECT TOP 1 *
  8117. FROM dcIpPlace WITH(NOLOCK INDEX(IX_dcIpPlace_IpStart))
  8118. WHERE IPStart <= @IP
  8119. ORDER BY IPStart DESC
  8120. END
  8121. GO
  8122. /****** Object: StoredProcedure [dbo].[ProcDcIpPlaceInsert] Script Date: 2018/12/13 19:10:17 ******/
  8123. SET ANSI_NULLS ON
  8124. GO
  8125. SET QUOTED_IDENTIFIER ON
  8126. GO
  8127. CREATE PROCEDURE [dbo].[ProcDcIpPlaceInsert]
  8128. AS
  8129. BEGIN
  8130. IF (SELECT COUNT(*) FROM tmp_IpPlace) < 400000
  8131. RETURN
  8132. TRUNCATE TABLE dcIPPlace
  8133. INSERT INTO dcIPPlace(ipstart, ipend, city, Provider, dcSubsiteId)
  8134. SELECT ipStart, ipEnd, City, Provider, 0 FROM tmp_ipplace --插入地址表
  8135. update dcIpplace set international = 1 where city in(select distinct city from dcipplace
  8136. where provider not in('CZ88.NET')
  8137. and provider not like ('%电信%')
  8138. and provider not like ('%联通%')
  8139. and left(city,2)not in(select left(description,2) from dcregion)
  8140. and city not like '%大学%'
  8141. and city not like '中%'
  8142. and city not like '东北%'
  8143. and city not like '华%'
  8144. and city not like '%网络'
  8145. and city not like '局域网'
  8146. and city not like '联通'
  8147. and city not like '全国通用'
  8148. and city not like '本机地址'
  8149. )
  8150. update dcipplace set provider='地址不详' where city='局域网'
  8151. update dcipplace set provider='地址不详' where city='本机地址'
  8152. UPDATE a SET a.dcSubSiteId = b.dcSubSiteID
  8153. FROM dcIpPlace a, dcIpPlaceCity b
  8154. WHERE a.City = b.City
  8155. UPDATE a SET a.dcSubSiteId = b.dcSubSiteID
  8156. FROM dcIpPlace a, dcIpPlaceCity b
  8157. WHERE a.City LIKE b.City + '%'
  8158. AND a.international IS NULL
  8159. AND a.dcSubSiteId = 0
  8160. AND LEN(b.dcSubSiteID) = 6
  8161. UPDATE a SET a.dcSubSiteId = b.dcSubSiteID
  8162. FROM dcIpPlace a, dcIpPlaceCity b
  8163. WHERE a.City LIKE b.City + '%'
  8164. AND a.international IS NULL
  8165. AND a.dcSubSiteId = 0
  8166. AND LEN(b.dcSubSiteID) = 4
  8167. UPDATE a SET a.dcSubSiteId = b.dcSubSiteID
  8168. FROM dcIpPlace a, dcIpPlaceCity b
  8169. WHERE a.City LIKE b.City + '%'
  8170. AND a.international IS NULL
  8171. AND a.dcSubSiteId = 0
  8172. AND LEN(b.dcSubSiteID) = 2
  8173. UPDATE a SET a.dcSubSiteId = b.ID
  8174. FROM dcIpPlace a, dcSubSite b
  8175. WHERE a.City LIKE b.SubSiteCity + '%'
  8176. AND a.international IS NULL
  8177. AND a.dcSubSiteId = 0
  8178. UPDATE dcIpPlace SET international = 1 WHERE international IS NULL AND dcSubSiteId = 0
  8179. UPDATE dcIpPlace SET dcSubSiteId = 0 WHERE international IS NULL AND dcSubSiteId = 1
  8180. DROP TABLE tmp_IpPlace
  8181. END
  8182. GO
  8183. /****** Object: StoredProcedure [dbo].[ProcdcJobtypeByIdSelect] Script Date: 2018/12/13 19:10:18 ******/
  8184. SET ANSI_NULLS ON
  8185. GO
  8186. SET QUOTED_IDENTIFIER ON
  8187. GO
  8188. --根据jobtypeID查询jobtype
  8189. --Harry
  8190. --2015-7-24
  8191. CREATE PROCEDURE [dbo].[ProcdcJobtypeByIdSelect]
  8192. (
  8193. @id INT
  8194. )
  8195. AS
  8196. BEGIN
  8197. SELECT [Description]
  8198. FROM dcjobtype
  8199. WHERE id=@id
  8200. END
  8201. GO
  8202. /****** Object: StoredProcedure [dbo].[procdcJobTypeByJobTypeID6Select] Script Date: 2018/12/13 19:10:18 ******/
  8203. SET ANSI_NULLS ON
  8204. GO
  8205. SET QUOTED_IDENTIFIER ON
  8206. GO
  8207. --#####################################################
  8208. --创建时间:2014.11.04
  8209. --创建人:Nick
  8210. --说明:根据职位id查询前6个感兴趣的职位
  8211. --#####################################################
  8212. CREATE PROCEDURE [dbo].[procdcJobTypeByJobTypeID6Select]
  8213. (
  8214. @JobTypeID VARCHAR(20)
  8215. )
  8216. AS
  8217. BEGIN TRY
  8218. Select TOP 6 id,description
  8219. FROM dcJobType
  8220. WHERE ID LIKE LEFT(@JobTypeID, 2) + '%' AND ID <> @JobTypeID
  8221. AND description NOT LIKE '其他%' ORDER BY NEWID()
  8222. END TRY
  8223. BEGIN CATCH
  8224. RETURN 0
  8225. END CATCH
  8226. GO
  8227. /****** Object: StoredProcedure [dbo].[procdcJobTypeByKeyWordSelect] Script Date: 2018/12/13 19:10:18 ******/
  8228. SET ANSI_NULLS ON
  8229. GO
  8230. SET QUOTED_IDENTIFIER ON
  8231. GO
  8232. --#####################################################
  8233. --创建时间:2014.11.03
  8234. --创建人:Nick
  8235. --说明:根据关键字获取职位类别
  8236. --#####################################################
  8237. CREATE PROCEDURE [dbo].[procdcJobTypeByKeyWordSelect]
  8238. (
  8239. @KeyWord VARCHAR(100),
  8240. @IsEnglish INT
  8241. )
  8242. AS
  8243. BEGIN TRY
  8244. IF @IsEnglish = 1
  8245. BEGIN
  8246. SELECT * FROM dcJobType WITH(NOLOCK) WHERE dbo.GetPyFirst(Description) LIKE '%'+@KeyWord+'%'
  8247. END
  8248. ELSE
  8249. BEGIN
  8250. SELECT * FROM dcJobType WITH(NOLOCK) WHERE Description LIKE '%'+@KeyWord+'%'
  8251. END
  8252. END TRY
  8253. BEGIN CATCH
  8254. RETURN 0
  8255. END CATCH
  8256. GO
  8257. /****** Object: StoredProcedure [dbo].[ProcdcJobTypeHotNumberInsert] Script Date: 2018/12/13 19:10:18 ******/
  8258. SET ANSI_NULLS ON
  8259. GO
  8260. SET QUOTED_IDENTIFIER ON
  8261. GO
  8262. --生成M站热门职位关键词对应的职位数量,计划任务每天凌晨1点执行
  8263. CREATE PROCEDURE [dbo].[ProcdcJobTypeHotNumberInsert]
  8264. AS
  8265. BEGIN
  8266. --清空dcJobTypeHotNumber
  8267. TRUNCATE TABLE dcJobTypeHotNumber
  8268. DECLARE DcProvince_Cursor CURSOR
  8269. FOR SELECT ID FROM dcProvince
  8270. OPEN DcProvince_Cursor
  8271. DECLARE @ProvinceID sysname
  8272. FETCH NEXT FROM DcProvince_Cursor INTO @ProvinceID
  8273. WHILE (@@FETCH_STATUS <> -1)
  8274. BEGIN
  8275. IF (@@FETCH_STATUS <> -2)
  8276. BEGIN
  8277. INSERT dcJobTypeHotNumber
  8278. SELECT @ProvinceID, a.Id,
  8279. CASE CHARINDEX(',', dcJobTypeId)
  8280. WHEN 0
  8281. THEN (
  8282. SELECT SUM(JobNum)
  8283. FROM hpJobTypeInfo
  8284. WHERE CONVERT(VARCHAR(8),dcJobTypeID) like ''+a.dcJobTypeId+'%'
  8285. AND dcRegionId like ''+CONVERT(VARCHAR,@ProvinceID)+'%'
  8286. )
  8287. ELSE(
  8288. SELECT SUM(JobNum)
  8289. FROM hpJobTypeInfo
  8290. WHERE CONVERT(VARCHAR(8),dcJobTypeID) IN (SELECT * FROM [fnSplit](a.dcJobTypeId,','))
  8291. AND dcRegionId like ''+CONVERT(VARCHAR(8),@ProvinceID)+'%'
  8292. )
  8293. END
  8294. FROM DcJobTypeHot a
  8295. END
  8296. FETCH NEXT FROM DcProvince_Cursor INTO @ProvinceID
  8297. END
  8298. CLOSE DcProvince_Cursor
  8299. DEALLOCATE DcProvince_Cursor
  8300. END
  8301. GO
  8302. /****** Object: StoredProcedure [dbo].[ProcDcJobTypeHotSelect] Script Date: 2018/12/13 19:10:19 ******/
  8303. SET ANSI_NULLS ON
  8304. GO
  8305. SET QUOTED_IDENTIFIER ON
  8306. GO
  8307. --M站获取热门职位关键词
  8308. --nick 20140539
  8309. CREATE PROCEDURE [dbo].[ProcDcJobTypeHotSelect]
  8310. (
  8311. @ProvinceID INT
  8312. )
  8313. AS
  8314. BEGIN
  8315. return
  8316. DECLARE @t AS TABLE(ID INT, JobTypeName VARCHAR(100), dcJobTypeId VARCHAR(200), PinYin VARCHAR(20), OrderBy INT,JobNum INT)
  8317. INSERT @t
  8318. SELECT *,
  8319. CASE CHARINDEX(',', dcJobTypeId)
  8320. WHEN 0
  8321. THEN (
  8322. SELECT SUM(JobNum)
  8323. FROM hpJobTypeInfo
  8324. WHERE CONVERT(VARCHAR(8),dcJobTypeID) like ''+a.dcJobTypeId+'%'
  8325. AND dcRegionID like ''+CONVERT(VARCHAR,@ProvinceID)+'%'
  8326. )
  8327. ELSE(
  8328. SELECT SUM(JobNum)
  8329. FROM hpJobTypeInfo
  8330. WHERE CONVERT(VARCHAR(8),dcJobTypeID) IN (SELECT * FROM [fnSplit](a.dcJobTypeId,','))
  8331. AND dcRegionID like ''+CONVERT(VARCHAR(8),@ProvinceID)+'%'
  8332. )
  8333. END
  8334. FROM DcJobTypeHot A
  8335. SELECT * FROM @t ORDER BY JobNum DESC
  8336. END
  8337. GO
  8338. /****** Object: StoredProcedure [dbo].[procdcJobTypeMapByRegionIDSelect] Script Date: 2018/12/13 19:10:19 ******/
  8339. SET ANSI_NULLS ON
  8340. GO
  8341. SET QUOTED_IDENTIFIER ON
  8342. GO
  8343. --#####################################################
  8344. --创建时间:2014.11.13
  8345. --创建人:Nick
  8346. --说明:获取各个站点下的热门职位类别
  8347. --#####################################################
  8348. CREATE PROCEDURE [dbo].[procdcJobTypeMapByRegionIDSelect]
  8349. (
  8350. @RegionID INT
  8351. )
  8352. AS
  8353. BEGIN
  8354. SELECT TOP 49 a.dcJobTypeId JobTypeID,a.JobNum JobNumber,b.CategoryId,c.parentID,c.grade,c.description,
  8355. c.parentID2,c.parentID3
  8356. FROM hpjobtypeinfo a
  8357. LEFT JOIN dcJobTypeMap b ON b.JobTypeId=a.dcJobtypeid
  8358. LEFT JOIN dcJobType c ON c.id=a.dcJobTypeid
  8359. WHERE a.dcRegionID = @RegionID
  8360. AND c.Grade = 3
  8361. AND c.description IS NOT NULL
  8362. ORDER BY JobNumber DESC
  8363. END
  8364. GO
  8365. /****** Object: StoredProcedure [dbo].[procdcJobTypeMapSelect] Script Date: 2018/12/13 19:10:19 ******/
  8366. SET ANSI_NULLS ON
  8367. GO
  8368. SET QUOTED_IDENTIFIER ON
  8369. GO
  8370. --#####################################################
  8371. --创建时间:2014.11.03
  8372. --创建人:Nick
  8373. --说明:获取职位地图的数据
  8374. --#####################################################
  8375. CREATE PROCEDURE [dbo].[procdcJobTypeMapSelect]
  8376. AS
  8377. BEGIN TRY
  8378. SELECT a.id,a.description jobtypel0,c.description jobtypel1,b.*
  8379. FROM dcJobtypeCategory a,dcJobTypeMap b,dcjobtype c
  8380. WHERE a.id=b.categoryid and b.jobtypeid=c.id and len(b.jobtypeid)>2
  8381. ORDER BY a.id,b.orderby
  8382. END TRY
  8383. BEGIN CATCH
  8384. RETURN 0
  8385. END CATCH
  8386. GO
  8387. /****** Object: StoredProcedure [dbo].[procDcJobTypeSelect] Script Date: 2018/12/13 19:10:19 ******/
  8388. SET ANSI_NULLS ON
  8389. GO
  8390. SET QUOTED_IDENTIFIER ON
  8391. GO
  8392. --#####################################################
  8393. --创建时间:2014.11.03
  8394. --创建人:Nick
  8395. --说明:获取职位类别
  8396. --#####################################################
  8397. CREATE PROCEDURE [dbo].[procDcJobTypeSelect]
  8398. AS
  8399. BEGIN TRY
  8400. SELECT ID, ParentID, ParentID2, ParentId3 FROM dcjobtype WITH(NOLOCK) WHERE ID > 100 ORDER BY ID
  8401. END TRY
  8402. BEGIN CATCH
  8403. RETURN 0
  8404. END CATCH
  8405. GO
  8406. /****** Object: StoredProcedure [dbo].[procdcjobtypesimilarSelect] Script Date: 2018/12/13 19:10:20 ******/
  8407. SET ANSI_NULLS ON
  8408. GO
  8409. SET QUOTED_IDENTIFIER ON
  8410. GO
  8411. --#####################################################
  8412. --创建时间:2014.10.31
  8413. --创建人:Nick
  8414. --说明:获取职位类别的匹配度
  8415. --#####################################################
  8416. CREATE PROCEDURE [dbo].[procdcjobtypesimilarSelect]
  8417. (
  8418. @JobTypeID VARCHAR(20)
  8419. )
  8420. AS
  8421. BEGIN
  8422. --SELECT * FROM dcjobtypesimilar WITH(NOLOCK) WHERE dcJobTypeId in (@JobTypeID) OR SimilarId IN (@JobTypeID)
  8423. SELECT TOP 0 0 ID, 0 dcJobTypeId, 0 SimilarId, 0 Coefficient
  8424. END
  8425. GO
  8426. /****** Object: StoredProcedure [dbo].[procdcJobTypeTemplateByJobTypeIDSelect] Script Date: 2018/12/13 19:10:20 ******/
  8427. SET ANSI_NULLS ON
  8428. GO
  8429. SET QUOTED_IDENTIFIER ON
  8430. GO
  8431. --#####################################################
  8432. --创建时间:2014.11.04
  8433. --创建人:Nick
  8434. --说明:取职位模版和晋升机制
  8435. --#####################################################
  8436. CREATE PROCEDURE [dbo].[procdcJobTypeTemplateByJobTypeIDSelect]
  8437. (
  8438. @dcJobTypeID INT
  8439. )
  8440. AS
  8441. BEGIN TRY
  8442. SELECT TOP 1 *
  8443. FROM dcJobTypeTemplate WITH(NOLOCK)
  8444. WHERE dcJobTypeID = @dcJobTypeID
  8445. END TRY
  8446. BEGIN CATCH
  8447. RETURN 0
  8448. END CATCH
  8449. GO
  8450. /****** Object: StoredProcedure [dbo].[ProcDcJobTypeTop6Insert] Script Date: 2018/12/13 19:10:20 ******/
  8451. SET ANSI_NULLS ON
  8452. GO
  8453. SET QUOTED_IDENTIFIER ON
  8454. GO
  8455. CREATE PROCEDURE [dbo].[ProcDcJobTypeTop6Insert]
  8456. AS
  8457. BEGIN
  8458. SELECT Id, LEFT(ID, 2) Id2, Description, NewID() Seq, 999 RowNo
  8459. INTO #t
  8460. FROM dcJobType
  8461. WHERE ID > 99
  8462. AND Description NOT LIKE '其他%'
  8463. UPDATE a
  8464. SET a.RowNo = b.RowNo
  8465. FROM #t a, (SELECT ID, Row_Number() OVER(PARTITION BY ID2 ORDER BY Seq) RowNo FROM #t) b
  8466. WHERE a.Id = b.Id
  8467. DELETE FROM #t WHERE RowNo > 7
  8468. TRUNCATE TABLE dcJobTypeTop6
  8469. INSERT INTO dcJobTypeTop6 SELECT Id, Id2, Description, RowNo FROM #t ORDER BY id2, rowno
  8470. END
  8471. GO
  8472. /****** Object: StoredProcedure [dbo].[procDcJobTypeTop6Select] Script Date: 2018/12/13 19:10:20 ******/
  8473. SET ANSI_NULLS ON
  8474. GO
  8475. SET QUOTED_IDENTIFIER ON
  8476. GO
  8477. --#####################################################
  8478. --创建时间:2014.11.03
  8479. --创建人:Nick
  8480. --说明:优化感兴趣的职位的搜索速度
  8481. --#####################################################
  8482. CREATE PROCEDURE [dbo].[procDcJobTypeTop6Select]
  8483. AS
  8484. BEGIN TRY
  8485. SELECT * FROM dcJobTypeTop6 With(Nolock) ORDER BY ID2, RowNo
  8486. END TRY
  8487. BEGIN CATCH
  8488. RETURN 0
  8489. END CATCH
  8490. GO
  8491. /****** Object: StoredProcedure [dbo].[procdcLinkManagerBySubSiteIDSelect] Script Date: 2018/12/13 19:10:21 ******/
  8492. SET ANSI_NULLS ON
  8493. GO
  8494. SET QUOTED_IDENTIFIER ON
  8495. GO
  8496. --#####################################################
  8497. --创建时间:2014.11.04
  8498. --创建人:Nick
  8499. --说明:根据subsiteid查询 dcLinkManager
  8500. --#####################################################
  8501. CREATE PROCEDURE [dbo].[procdcLinkManagerBySubSiteIDSelect]
  8502. (
  8503. @SubSiteID INT
  8504. )
  8505. AS
  8506. BEGIN TRY
  8507. SELECT a.ManagerUserId, b.Introduce
  8508. FROM dcLinkManager a WItH(NOLOCK), ManagerUser b WITH(NOLOCK)
  8509. WHERE a.ManagerUserId = b.Id AND a.SubSiteId = @SubSiteID
  8510. END TRY
  8511. BEGIN CATCH
  8512. RETURN 0
  8513. END CATCH
  8514. GO
  8515. /****** Object: StoredProcedure [dbo].[procdcMajorByKeyWordSelect] Script Date: 2018/12/13 19:10:21 ******/
  8516. SET ANSI_NULLS ON
  8517. GO
  8518. SET QUOTED_IDENTIFIER ON
  8519. GO
  8520. --#####################################################
  8521. --创建时间:2018.09.25
  8522. --创建人:Alen
  8523. --说明:根据关键字获取专业类别
  8524. --#####################################################
  8525. CREATE PROCEDURE [dbo].[procdcMajorByKeyWordSelect]
  8526. (
  8527. @KeyWord VARCHAR(100),
  8528. @IsEnglish TINYINT
  8529. )
  8530. AS
  8531. BEGIN
  8532. IF @IsEnglish = 1
  8533. BEGIN
  8534. SELECT *
  8535. FROM dcmajor WITH(NOLOCK)
  8536. WHERE dbo.GetPyFirst(Description) LIKE '%'+@KeyWord+'%'
  8537. END
  8538. ELSE
  8539. BEGIN
  8540. SELECT *
  8541. FROM dcmajor WITH(NOLOCK)
  8542. WHERE Description LIKE '%'+@KeyWord+'%'
  8543. END
  8544. END
  8545. GO
  8546. /****** Object: StoredProcedure [dbo].[ProcDcMajorKeywordSelect] Script Date: 2018/12/13 19:10:21 ******/
  8547. SET ANSI_NULLS ON
  8548. GO
  8549. SET QUOTED_IDENTIFIER ON
  8550. GO
  8551. CREATE PROCEDURE [dbo].[ProcDcMajorKeywordSelect]
  8552. (
  8553. @Major NVARCHAR(20)
  8554. )
  8555. AS
  8556. SET NOCOUNT ON
  8557. BEGIN
  8558. IF LEN(@Major) < 2
  8559. SELECT TOP 10 MajorName, dcMajorId, b.Description Major
  8560. FROM dcMajorKeyword a WITH(NOLOCK), dcMajor b WITH(NOLOCK)
  8561. WHERE a.dcMajorId = b.ID AND (MajorName LIKE @Major + '%'
  8562. OR PinYin LIKE @Major + '%'
  8563. OR JianPin LIKE @Major + '%')
  8564. ORDER BY MajorName
  8565. ELSE
  8566. BEGIN
  8567. IF ASCII(LEFT(@Major, 1)) > 127
  8568. SELECT TOP 10 MajorName, dcMajorId, b.Description Major
  8569. FROM dcMajorKeyword a WITH(NOLOCK), dcMajor b WITH(NOLOCK)
  8570. WHERE a.dcMajorId = b.ID AND CHARINDEX(@major, MajorName) > 0
  8571. ORDER BY CHARINDEX(@major, MajorName), MajorName
  8572. ELSE
  8573. SELECT TOP 10 MajorName, dcMajorId, b.Description Major
  8574. FROM dcMajorKeyword a WITH(NOLOCK), dcMajor b WITH(NOLOCK)
  8575. WHERE a.dcMajorId = b.ID AND (CHARINDEX(@major, PinYin) > 0
  8576. OR CHARINDEX(@major, JianPin) > 0)
  8577. ORDER BY MajorName
  8578. END
  8579. END
  8580. GO
  8581. /****** Object: StoredProcedure [dbo].[procDcMapLineSelect] Script Date: 2018/12/13 19:10:22 ******/
  8582. SET ANSI_NULLS ON
  8583. GO
  8584. SET QUOTED_IDENTIFIER ON
  8585. GO
  8586. --#####################################################
  8587. --创建时间:2014.11.03
  8588. --创建人:Nick
  8589. --说明:获取热门地标
  8590. --#####################################################
  8591. CREATE PROCEDURE [dbo].[procDcMapLineSelect]
  8592. AS
  8593. BEGIN TRY
  8594. SELECT * FROM dcMapLine WITH(NOLOCK) ORDER BY dcRegionId,OrderNo
  8595. END TRY
  8596. BEGIN CATCH
  8597. RETURN 0
  8598. END CATCH
  8599. GO
  8600. /****** Object: StoredProcedure [dbo].[procdcMapPlaceSelect] Script Date: 2018/12/13 19:10:22 ******/
  8601. SET ANSI_NULLS ON
  8602. GO
  8603. SET QUOTED_IDENTIFIER ON
  8604. GO
  8605. --#####################################################
  8606. --创建时间:2014.11.03
  8607. --创建人:Nick
  8608. --说明:dcMapPlace
  8609. --#####################################################
  8610. CREATE PROCEDURE [dbo].[procdcMapPlaceSelect]
  8611. AS
  8612. BEGIN TRY
  8613. SELECT * FROM dcMapPlace WITH(NOLOCK) ORDER BY dcRegionID,OrderNo
  8614. END TRY
  8615. BEGIN CATCH
  8616. RETURN 0
  8617. END CATCH
  8618. GO
  8619. /****** Object: StoredProcedure [dbo].[procDcMapStationSelect] Script Date: 2018/12/13 19:10:22 ******/
  8620. SET ANSI_NULLS ON
  8621. GO
  8622. SET QUOTED_IDENTIFIER ON
  8623. GO
  8624. --#####################################################
  8625. --创建时间:2014.11.03
  8626. --创建人:Nick
  8627. --说明:dcMapStation
  8628. --#####################################################
  8629. CREATE PROCEDURE [dbo].[procDcMapStationSelect]
  8630. AS
  8631. BEGIN TRY
  8632. SELECT * FROM dcMapStation WITH(NOLOCK) ORDER BY dcMapLineId,OrderNo
  8633. END TRY
  8634. BEGIN CATCH
  8635. RETURN 0
  8636. END CATCH
  8637. GO
  8638. /****** Object: StoredProcedure [dbo].[procdcNewsTypeByCategorySelect] Script Date: 2018/12/13 19:10:22 ******/
  8639. SET ANSI_NULLS ON
  8640. GO
  8641. SET QUOTED_IDENTIFIER ON
  8642. GO
  8643. --#####################################################
  8644. --创建时间:2014.11.5
  8645. --创建人:NICK
  8646. --说明:获取资讯类别
  8647. --#####################################################
  8648. CREATE PROCEDURE [dbo].[procdcNewsTypeByCategorySelect]
  8649. (
  8650. @Category INT
  8651. )
  8652. AS
  8653. BEGIN
  8654. DECLARE @SQL VARCHAR(MAX)
  8655. SET @SQL = 'SELECT * FROM dcNewsType WITH(NOLOCK) '
  8656. IF @Category > 0
  8657. BEGIN
  8658. SET @SQL = @SQL + ' WHERE Category = '+CONVERT(VARCHAR(20),@Category)
  8659. END
  8660. SET @SQL = @SQL + ' ORDER BY OrderNo'
  8661. EXEC(@SQL)
  8662. END
  8663. GO
  8664. /****** Object: StoredProcedure [dbo].[procdcNewsTypeByIDSelect] Script Date: 2018/12/13 19:10:22 ******/
  8665. SET ANSI_NULLS ON
  8666. GO
  8667. SET QUOTED_IDENTIFIER ON
  8668. GO
  8669. --#####################################################
  8670. --创建时间:2014.11.5
  8671. --创建人:NICK
  8672. --说明:获取一行资讯类别
  8673. --#####################################################
  8674. CREATE PROCEDURE [dbo].[procdcNewsTypeByIDSelect]
  8675. (
  8676. @ID INT
  8677. )
  8678. AS
  8679. BEGIN
  8680. SELECT * FROM dcNewsType WITH(NOLOCK) WHERE id = @ID
  8681. END
  8682. GO
  8683. /****** Object: StoredProcedure [dbo].[procDcProvinceByIDSelect] Script Date: 2018/12/13 19:10:22 ******/
  8684. SET ANSI_NULLS ON
  8685. GO
  8686. SET QUOTED_IDENTIFIER ON
  8687. GO
  8688. --#####################################################
  8689. --创建时间:2014.11.10
  8690. --创建人:Nick
  8691. --说明:获取省份信息
  8692. --#####################################################
  8693. CREATE PROCEDURE [dbo].[procDcProvinceByIDSelect]
  8694. (
  8695. @ID INT
  8696. )
  8697. AS
  8698. BEGIN
  8699. SELECT * FROM dcProvince WITH(NOLOCK) WHERE ID=@ID
  8700. END
  8701. GO
  8702. /****** Object: StoredProcedure [dbo].[procDcProvinceByPinyinSelect] Script Date: 2018/12/13 19:10:23 ******/
  8703. SET ANSI_NULLS ON
  8704. GO
  8705. SET QUOTED_IDENTIFIER ON
  8706. GO
  8707. --#####################################################
  8708. --创建时间:2014.11.10
  8709. --创建人:Nick
  8710. --说明:获取省份信息
  8711. --#####################################################
  8712. CREATE PROCEDURE [dbo].[procDcProvinceByPinyinSelect]
  8713. AS
  8714. BEGIN TRY
  8715. SELECT Id, ProvinceName, WebSiteName, dbo.ToPinYin(ProvinceName) PinYin,
  8716. ProvinceDomain
  8717. FROM dcProvince WITH(NOLOCK)
  8718. ORDER BY ID
  8719. END TRY
  8720. BEGIN CATCH
  8721. RETURN 0
  8722. END CATCH
  8723. GO
  8724. /****** Object: StoredProcedure [dbo].[ProcDcProvinceSelect] Script Date: 2018/12/13 19:10:23 ******/
  8725. SET ANSI_NULLS ON
  8726. GO
  8727. SET QUOTED_IDENTIFIER ON
  8728. GO
  8729. --#####################################################
  8730. --创建时间:2014.11.3
  8731. --创建人:John
  8732. --说明:获取省份信息
  8733. --#####################################################
  8734. CREATE PROCEDURE [dbo].[ProcDcProvinceSelect]
  8735. AS
  8736. BEGIN
  8737. SELECT * FROM dcProvince
  8738. END
  8739. GO
  8740. /****** Object: StoredProcedure [dbo].[procDcRegionAllSelect] Script Date: 2018/12/13 19:10:23 ******/
  8741. SET ANSI_NULLS ON
  8742. GO
  8743. SET QUOTED_IDENTIFIER ON
  8744. GO
  8745. --#####################################################
  8746. --创建时间:2014.11.03
  8747. --创建人:Nick
  8748. --说明:全部地区
  8749. --#####################################################
  8750. CREATE PROCEDURE [dbo].[procDcRegionAllSelect]
  8751. AS
  8752. BEGIN TRY
  8753. SELECT *
  8754. FROM dcRegion WITH(NOLOCK)
  8755. ORDER BY Id
  8756. END TRY
  8757. BEGIN CATCH
  8758. RETURN 0
  8759. END CATCH
  8760. GO
  8761. /****** Object: StoredProcedure [dbo].[procdcRegionByGradeParentIDSelect] Script Date: 2018/12/13 19:10:24 ******/
  8762. SET ANSI_NULLS ON
  8763. GO
  8764. SET QUOTED_IDENTIFIER ON
  8765. GO
  8766. --#####################################################
  8767. --创建时间:2014.11.11
  8768. --创建人:NICK
  8769. --说明:根据provincieid得到dcregion
  8770. --#####################################################
  8771. CREATE PROCEDURE [dbo].[procdcRegionByGradeParentIDSelect]
  8772. (
  8773. @ParentID INT,
  8774. @Grade INT
  8775. )
  8776. AS
  8777. BEGIN
  8778. IF @Grade = 1
  8779. BEGIN
  8780. SELECT TOP 100 *
  8781. FROM maindb..dcregion
  8782. WHERE grade = @Grade
  8783. ORDER BY id
  8784. END
  8785. ELSE
  8786. BEGIN
  8787. SELECT TOP 100 *
  8788. FROM maindb..dcregion
  8789. WHERE grade = @Grade
  8790. AND ParentID = @ParentID
  8791. ORDER BY id
  8792. END
  8793. END
  8794. GO
  8795. /****** Object: StoredProcedure [dbo].[procdcRegionByIDSelect] Script Date: 2018/12/13 19:10:24 ******/
  8796. SET ANSI_NULLS ON
  8797. GO
  8798. SET QUOTED_IDENTIFIER ON
  8799. GO
  8800. --#####################################################
  8801. --创建时间:2014.11.03
  8802. --创建人:Nick
  8803. --说明:根据ID获取dcRegion
  8804. --#####################################################
  8805. CREATE PROCEDURE [dbo].[procdcRegionByIDSelect]
  8806. (
  8807. @ID INT
  8808. )
  8809. AS
  8810. SET NOCOUNT ON
  8811. BEGIN
  8812. --SELECT * FROM dcRegion WITH(NOLOCK) WHERE ID = @ID
  8813. SELECT ID, Abbr Description, Abbr, TqPinyin, PinYin FROM dcRegion WITH(NOLOCK) WHERE ID = @ID
  8814. END
  8815. GO
  8816. /****** Object: StoredProcedure [dbo].[procdcRegionByParentIDSelect] Script Date: 2018/12/13 19:10:24 ******/
  8817. SET ANSI_NULLS ON
  8818. GO
  8819. SET QUOTED_IDENTIFIER ON
  8820. GO
  8821. --#####################################################
  8822. --创建时间:2014.11.3
  8823. --创建人:NICK
  8824. --说明:根据provincieid得到dcregion
  8825. --#####################################################
  8826. CREATE PROCEDURE [dbo].[procdcRegionByParentIDSelect]
  8827. (
  8828. @ProvinceID INT
  8829. )
  8830. AS
  8831. BEGIN
  8832. SELECT id,Description
  8833. FROM dcregion WHERE parentid=@ProvinceID
  8834. OR id=@ProvinceID
  8835. ORDER BY id
  8836. END
  8837. GO
  8838. /****** Object: StoredProcedure [dbo].[procdcRegionByPinYinSelect] Script Date: 2018/12/13 19:10:25 ******/
  8839. SET ANSI_NULLS ON
  8840. GO
  8841. SET QUOTED_IDENTIFIER ON
  8842. GO
  8843. --#####################################################
  8844. --创建时间:2014.11.03
  8845. --创建人:Nick
  8846. --说明:根据ProvinceID和pinyin获取dcRegion
  8847. --#####################################################
  8848. CREATE PROCEDURE [dbo].[procdcRegionByPinYinSelect]
  8849. (
  8850. @ProvinceID INT,
  8851. @PinYin1 VARCHAR(50),
  8852. @PinYin2 VARCHAR(50)
  8853. )
  8854. AS
  8855. BEGIN TRY
  8856. IF @PinYin2 = ''
  8857. BEGIN
  8858. SELECT * FROM dcRegion WITH(NOLOCK) WHERE Pinyin=@Pinyin1 AND LEN(ID)=4 AND LEFT(ID,2)=@ProvinceID
  8859. END
  8860. ELSE
  8861. BEGIN
  8862. SELECT a.*,b.Abbr UpperName
  8863. FROM dcRegion a,dcRegion b WITH(NOLOCK)
  8864. WHERE a.ParentID=b.ID
  8865. AND b.Pinyin=@Pinyin1
  8866. AND a.Pinyin=@Pinyin2
  8867. AND LEN(a.ID)=6
  8868. AND LEFT(a.ID,2)=@ProvinceID
  8869. END
  8870. END TRY
  8871. BEGIN CATCH
  8872. RETURN 0
  8873. END CATCH
  8874. GO
  8875. /****** Object: StoredProcedure [dbo].[procdcRegionByProvinceIDSelect] Script Date: 2018/12/13 19:10:25 ******/
  8876. SET ANSI_NULLS ON
  8877. GO
  8878. SET QUOTED_IDENTIFIER ON
  8879. GO
  8880. --#####################################################
  8881. --创建时间:2014.11.03
  8882. --创建人:Nick
  8883. --说明:根据ProvinceID获取dcRegion
  8884. --#####################################################
  8885. CREATE PROCEDURE [dbo].[procdcRegionByProvinceIDSelect]
  8886. (
  8887. @ProvinceID INT
  8888. )
  8889. AS
  8890. BEGIN TRY
  8891. SELECT * FROM dcRegion WITH(NOLOCK) WHERE LEFT(ID,2)=@ProvinceID AND Pinyin IS NOT NULL
  8892. END TRY
  8893. BEGIN CATCH
  8894. RETURN 0
  8895. END CATCH
  8896. GO
  8897. /****** Object: StoredProcedure [dbo].[procdcRegionByRegionNameSelect] Script Date: 2018/12/13 19:10:25 ******/
  8898. SET ANSI_NULLS ON
  8899. GO
  8900. SET QUOTED_IDENTIFIER ON
  8901. GO
  8902. --#####################################################
  8903. --创建时间:2014.10.31
  8904. --创建人:Nick
  8905. --说明:由地区名称获取地区ID
  8906. --#####################################################
  8907. CREATE PROCEDURE [dbo].[procdcRegionByRegionNameSelect]
  8908. (
  8909. @RegionName VARCHAR(20)
  8910. )
  8911. AS
  8912. BEGIN TRY
  8913. SELECT * FROM dcRegion WITH(NOLOCK) WHERE Description LIKE '%'+@RegionName+'%'
  8914. END TRY
  8915. BEGIN CATCH
  8916. RETURN 0
  8917. END CATCH
  8918. GO
  8919. /****** Object: StoredProcedure [dbo].[procDcRegionSelect] Script Date: 2018/12/13 19:10:25 ******/
  8920. SET ANSI_NULLS ON
  8921. GO
  8922. SET QUOTED_IDENTIFIER ON
  8923. GO
  8924. --#####################################################
  8925. --创建时间:2014.11.03
  8926. --创建人:Nick
  8927. --说明:获取地区
  8928. --#####################################################
  8929. CREATE PROCEDURE [dbo].[procDcRegionSelect]
  8930. AS
  8931. BEGIN TRY
  8932. SELECT ID, Description, DescriptionEng, OrderNo,Lng,Lat FROM dcRegion WITH(NOLOCK)
  8933. END TRY
  8934. BEGIN CATCH
  8935. RETURN 0
  8936. END CATCH
  8937. GO
  8938. /****** Object: StoredProcedure [dbo].[ProcDcRegionTDKSelect] Script Date: 2018/12/13 19:10:26 ******/
  8939. SET ANSI_NULLS ON
  8940. GO
  8941. SET QUOTED_IDENTIFIER ON
  8942. GO
  8943. CREATE PROCEDURE [dbo].[ProcDcRegionTDKSelect]
  8944. AS
  8945. BEGIN
  8946. SELECT * FROM dcRegionTDK
  8947. END
  8948. GO
  8949. /****** Object: StoredProcedure [dbo].[procDcRunParameterByNameSelect] Script Date: 2018/12/13 19:10:26 ******/
  8950. SET ANSI_NULLS ON
  8951. GO
  8952. SET QUOTED_IDENTIFIER ON
  8953. GO
  8954. --#####################################################
  8955. --创建时间:2014.11.03
  8956. --创建人:Nick
  8957. --说明:获取不显示职位广告的企业id。
  8958. --#####################################################
  8959. CREATE PROCEDURE [dbo].[procDcRunParameterByNameSelect]
  8960. AS
  8961. BEGIN TRY
  8962. SELECT Value FROM dcRunParameter WITH(NOLOCK) WHERE System = 1 AND Name = 'do not show Job Ads'
  8963. END TRY
  8964. BEGIN CATCH
  8965. RETURN 0
  8966. END CATCH
  8967. GO
  8968. /****** Object: StoredProcedure [dbo].[procDcRunParameterSelect] Script Date: 2018/12/13 19:10:26 ******/
  8969. SET ANSI_NULLS ON
  8970. GO
  8971. SET QUOTED_IDENTIFIER ON
  8972. GO
  8973. --#####################################################
  8974. --创建时间:2014.11.03
  8975. --创建人:Nick
  8976. --说明:获取iis运行参数,搜索职位和搜索简历使用数据库的信息。放在这里,便于数据库故障时及时调整
  8977. --#####################################################
  8978. CREATE PROCEDURE [dbo].[procDcRunParameterSelect]
  8979. AS
  8980. insert proclog select 'procDcRunParameterSelect','', getdate()
  8981. BEGIN
  8982. SELECT Name, Value
  8983. FROM dcRunParameter WITH(NOLOCK)
  8984. --WHERE System = 1
  8985. --AND (Name LIKE 'JobSearchDb%' OR Name LIKE 'CvSearchDb%' OR Name LIKE 'ueolog%')
  8986. END
  8987. GO
  8988. /****** Object: StoredProcedure [dbo].[procdcSubSiteByIDSelect] Script Date: 2018/12/13 19:10:26 ******/
  8989. SET ANSI_NULLS ON
  8990. GO
  8991. SET QUOTED_IDENTIFIER ON
  8992. GO
  8993. --#####################################################
  8994. --创建时间:2014.11.10
  8995. --创建人:NICK
  8996. --说明:根据省份编号获取 subsite信息
  8997. --#####################################################
  8998. CREATE PROCEDURE [dbo].[procdcSubSiteByIDSelect]
  8999. (
  9000. @ID INT
  9001. )
  9002. AS
  9003. BEGIN
  9004. SELECT * FROM dcSubSite WHERE id=@ID
  9005. END
  9006. GO
  9007. /****** Object: StoredProcedure [dbo].[ProcDcSubSiteByPinYinSelect] Script Date: 2018/12/13 19:10:26 ******/
  9008. SET ANSI_NULLS ON
  9009. GO
  9010. SET QUOTED_IDENTIFIER ON
  9011. GO
  9012. CREATE PROCEDURE [dbo].[ProcDcSubSiteByPinYinSelect]
  9013. (
  9014. @Pinyin NVARCHAR(20),
  9015. @dcProvinceID INT
  9016. )
  9017. AS
  9018. BEGIN
  9019. SELECT TOP 1 SubSiteUrl
  9020. FROM dcSubSite WITH(NOLOCK)
  9021. WHERE Pinyin = @Pinyin
  9022. AND ProvinceId = @dcProvinceID
  9023. ORDER BY IsMainSite
  9024. /*
  9025. SELECT TOP 1 a.SubSiteUrl
  9026. FROM dcSubSite a, dcRegion b
  9027. WHERE A.ID = B.ID
  9028. AND b.Pinyin = @Pinyin
  9029. AND a.ProvinceId = @dcProvinceID
  9030. AND b.Id < 9999
  9031. ORDER BY a.IsMainSite
  9032. */
  9033. END
  9034. GO
  9035. /****** Object: StoredProcedure [dbo].[procDcSubSiteByProvinceSelect] Script Date: 2018/12/13 19:10:27 ******/
  9036. SET ANSI_NULLS ON
  9037. GO
  9038. SET QUOTED_IDENTIFIER ON
  9039. GO
  9040. --#####################################################
  9041. --创建时间:2014.11.10
  9042. --创建人:John
  9043. --说明:获取所有省份相应的站点
  9044. --#####################################################
  9045. CREATE PROCEDURE [dbo].[procDcSubSiteByProvinceSelect]
  9046. AS
  9047. BEGIN
  9048. SELECT id, REPLACE(SubSiteUrl, 'www.', '') Domain,SubSiteName FROM dcSubSite WITH(NOLOCK) WHERE ismainsite = 1 AND LEN(ID)=2
  9049. END
  9050. GO
  9051. /****** Object: StoredProcedure [dbo].[procDcSubSiteBySecondSelect] Script Date: 2018/12/13 19:10:27 ******/
  9052. SET ANSI_NULLS ON
  9053. GO
  9054. SET QUOTED_IDENTIFIER ON
  9055. GO
  9056. --#####################################################
  9057. --创建时间:2015.5.06
  9058. --创建人: sean
  9059. --说明:获取网站PinYin信息
  9060. --#####################################################
  9061. CREATE PROCEDURE [dbo].[procDcSubSiteBySecondSelect]
  9062. AS
  9063. BEGIN
  9064. SELECT Id, SecondSite SubSiteUrl, PinYin
  9065. FROM dcSubSite a WITH(NOLOCK)
  9066. WHERE ID > 99
  9067. AND ProvinceId IN(10, 32, 13, 20, 21, 22, 30, 31, 33, 34, 35, 36, 40, 42, 62, 63, 70, 71, 83, 84, 12, 14, 41, 61, 72, 80)
  9068. ORDER BY ID
  9069. END
  9070. GO
  9071. /****** Object: StoredProcedure [dbo].[procDcSubSiteBySiteCitySelect] Script Date: 2018/12/13 19:10:27 ******/
  9072. SET ANSI_NULLS ON
  9073. GO
  9074. SET QUOTED_IDENTIFIER ON
  9075. GO
  9076. --#####################################################
  9077. --创建时间:2014.11.10
  9078. --创建人:Nick
  9079. --说明:根据城市名称获取省份编号
  9080. --#####################################################
  9081. CREATE PROCEDURE [dbo].[procDcSubSiteBySiteCitySelect]
  9082. (
  9083. @City VARCHAR(50)
  9084. )
  9085. AS
  9086. BEGIN
  9087. SELECT provinceID FROM dcsubsite WITH(NOLOCK) WHere subsitecity like '%'+@City+'%'
  9088. END
  9089. GO
  9090. /****** Object: StoredProcedure [dbo].[procDcSubSiteSelect] Script Date: 2018/12/13 19:10:27 ******/
  9091. SET ANSI_NULLS ON
  9092. GO
  9093. SET QUOTED_IDENTIFIER ON
  9094. GO
  9095. --#####################################################
  9096. --创建时间:2014.11.03
  9097. --创建人:Nick
  9098. --说明:获取所有网站信息
  9099. --#####################################################
  9100. CREATE PROCEDURE [dbo].[procDcSubSiteSelect]
  9101. AS
  9102. BEGIN
  9103. SELECT * FROM dcSubSite a WITH(NOLOCK) ORDER BY ProvinceId, ID
  9104. END
  9105. GO
  9106. /****** Object: StoredProcedure [dbo].[procDcSubSiteUrlByRegionNameSelect] Script Date: 2018/12/13 19:10:28 ******/
  9107. SET ANSI_NULLS ON
  9108. GO
  9109. SET QUOTED_IDENTIFIER ON
  9110. GO
  9111. --#####################################################
  9112. --创建时间:2014.11.10
  9113. --创建人:John
  9114. --说明:根据地区名获取网站地址
  9115. --#####################################################
  9116. CREATE PROCEDURE [dbo].[procDcSubSiteUrlByRegionNameSelect]
  9117. (
  9118. @RegionName NVARCHAR(12)
  9119. )
  9120. AS
  9121. BEGIN
  9122. SELECT SubSiteUrl FROM dcSubSite WHERE SubSiteCity LIKE @RegionName ORDER BY ismainsite DESC ,id
  9123. END
  9124. GO
  9125. /****** Object: StoredProcedure [dbo].[procDcSystemdataByIDSelect] Script Date: 2018/12/13 19:10:28 ******/
  9126. SET ANSI_NULLS ON
  9127. GO
  9128. SET QUOTED_IDENTIFIER ON
  9129. GO
  9130. --#####################################################
  9131. --创建时间:2014.11.10
  9132. --创建人:Nick
  9133. --说明:
  9134. --#####################################################
  9135. CREATE PROCEDURE [dbo].[procDcSystemdataByIDSelect]
  9136. (
  9137. @ID INT
  9138. )
  9139. AS
  9140. BEGIN TRY
  9141. SELECT CONVERT(INT, Value) AS cnt FROM dcsystemdata WITH(NOLOCK) WHERE Id = @ID
  9142. END TRY
  9143. BEGIN CATCH
  9144. RETURN 0
  9145. END CATCH
  9146. GO
  9147. /****** Object: StoredProcedure [dbo].[ProcdcVipStandardByPriceCvSelect] Script Date: 2018/12/13 19:10:28 ******/
  9148. SET ANSI_NULLS ON
  9149. GO
  9150. SET QUOTED_IDENTIFIER ON
  9151. GO
  9152. CREATE PROCEDURE [dbo].[ProcdcVipStandardByPriceCvSelect]
  9153. (
  9154. @dcProvinceID AS INT
  9155. )
  9156. AS
  9157. BEGIN
  9158. SELECT PriceCv FROM dcVipStandard WITH(NOLOCK)
  9159. WHERE dcProvinceID = @dcProvinceID
  9160. END
  9161. GO
  9162. /****** Object: StoredProcedure [dbo].[ProcDcWxTokenByJsApi_TicketUpdate] Script Date: 2018/12/13 19:10:28 ******/
  9163. SET ANSI_NULLS ON
  9164. GO
  9165. SET QUOTED_IDENTIFIER ON
  9166. GO
  9167. --#####################################################
  9168. --创建时间:2014.11.4
  9169. --创建人:John
  9170. --说明:根据id更新微信记录
  9171. --#####################################################
  9172. CREATE PROCEDURE [dbo].[ProcDcWxTokenByJsApi_TicketUpdate]
  9173. (
  9174. @JsApi_Ticket VARCHAR(200),
  9175. @ProvinceId TINYINT
  9176. )
  9177. AS
  9178. BEGIN
  9179. UPDATE dcWxToken SET JsApi_Ticket = @JsApi_Ticket,
  9180. JsApi_Ticket_adddate = GETDATE()
  9181. WHERE dcProvinceId = @ProvinceId
  9182. END
  9183. GO
  9184. /****** Object: StoredProcedure [dbo].[ProcDcWxTokenByProvinceIDSelect] Script Date: 2018/12/13 19:10:29 ******/
  9185. SET ANSI_NULLS ON
  9186. GO
  9187. SET QUOTED_IDENTIFIER ON
  9188. GO
  9189. --#####################################################
  9190. --创建时间:2014.11.4
  9191. --创建人:John
  9192. --说明:根据id获取微信生成记录
  9193. --#####################################################
  9194. CREATE PROCEDURE [dbo].[ProcDcWxTokenByProvinceIDSelect]
  9195. (
  9196. @ProvinceId TINYINT
  9197. )
  9198. AS
  9199. BEGIN
  9200. SELECT TOP 1 * FROM dcWxToken WHERE adddate > DATEADD(MINUTE,-60,GETDATE()) AND dcProvinceId = @ProvinceId
  9201. END
  9202. GO
  9203. /****** Object: StoredProcedure [dbo].[ProcDcWxTokenUpdate] Script Date: 2018/12/13 19:10:29 ******/
  9204. SET ANSI_NULLS ON
  9205. GO
  9206. SET QUOTED_IDENTIFIER ON
  9207. GO
  9208. --#####################################################
  9209. --创建时间:2014.11.4
  9210. --创建人:John
  9211. --说明:根据id更新微信记录
  9212. --#####################################################
  9213. CREATE PROCEDURE [dbo].[ProcDcWxTokenUpdate]
  9214. (
  9215. @token VARCHAR(200),
  9216. @ProvinceId TINYINT
  9217. )
  9218. AS
  9219. BEGIN
  9220. UPDATE dcWxToken SET Token = @token,adddate = GETDATE() WHERE dcProvinceId = @ProvinceId
  9221. END
  9222. GO
  9223. /****** Object: StoredProcedure [dbo].[ProcDeletedJobByRegionIdSelect] Script Date: 2018/12/13 19:10:29 ******/
  9224. SET ANSI_NULLS ON
  9225. GO
  9226. SET QUOTED_IDENTIFIER ON
  9227. GO
  9228. --#####################################################
  9229. --创建时间:2014.10.28
  9230. --创建人:John
  9231. --说明:获取一天之内删除的职位
  9232. --@regionId 地区编号
  9233. --#####################################################
  9234. CREATE PROCEDURE [dbo].[ProcDeletedJobByRegionIdSelect]
  9235. (
  9236. @regionId VARCHAR(6)
  9237. )
  9238. AS
  9239. BEGIN TRY
  9240. SELECT a.JobId
  9241. FROM JobDeleted a, Job b
  9242. WHERE DATEADD(DAY,1,a.DeleteDate) > GETDATE()
  9243. AND a.JobId = b.Id
  9244. AND b.dcRegionID = @regionId
  9245. END TRY
  9246. BEGIN CATCH
  9247. RETURN 0
  9248. END CATCH
  9249. GO
  9250. /****** Object: StoredProcedure [dbo].[procDicSelect] Script Date: 2018/12/13 19:10:29 ******/
  9251. SET ANSI_NULLS ON
  9252. GO
  9253. SET QUOTED_IDENTIFIER ON
  9254. GO
  9255. --#####################################################
  9256. --创建时间:2014.11.03
  9257. --创建人:Nick
  9258. --说明:获取字典信息
  9259. --#####################################################
  9260. CREATE PROCEDURE [dbo].[procDicSelect]
  9261. (
  9262. @TableName VARCHAR(20),
  9263. @queryCondition VARCHAR(200)
  9264. )
  9265. AS
  9266. SET NOCOUNT ON
  9267. BEGIN
  9268. DECLARE @SQL VARCHAR(500)
  9269. SET @SQL = 'Select ID, Description, Replace(DescriptionEng, '''', ''''''\'''''''''') FROM '+ @TableName + ' WITH(NOLOCK) ORDER BY ID'
  9270. IF @TableName = 'dcIndustry'
  9271. BEGIN
  9272. SET @SQL = 'SELECT ID, Description, Replace(DescriptionEng, '''', ''''''\'''''''''') FROM ' + @TableName + ' WITH(NOLOCK) ORDER BY OrderNo'
  9273. END
  9274. IF @TableName = 'dcMajor'
  9275. BEGIN
  9276. SET @SQL = 'SELECT ID, Description, Replace(DescriptionEng, '''', ''''''\'''''''''') FROM ' + @TableName + ' WITH(NOLOCK) ORDER BY OrderNo, Id'
  9277. END
  9278. IF @TableName = 'dcSalary'
  9279. BEGIN
  9280. SET @SQL = 'SELECT ID,Description,Replace(DescriptionEng, '''', ''''''\''''''''''), DescriptionCp FROM dcSalary' + ' WITH(NOLOCK) WHERE ID>1 ORDER BY OrderNo' END
  9281. IF @queryCondition <> ''
  9282. BEGIN
  9283. SET @SQL = 'SELECT DetailID, Description, Replace(DescriptionEng, '''', ''''''\'''''''''') FROM ' + @TableName + ' WITH(NOLOCK) WHERE '+ @queryCondition +' ORDER BY OrderNo'
  9284. END
  9285. -- IF @queryCondition = 'major'
  9286. -- BEGIN
  9287. -- SET @SQL = 'SELECT ID, Description, Replace(DescriptionEng, '''', ''''''\'''''''''') FROM dcMajor WITH(NOLOCK) WHERE Id NOT IN(1106, 1713) ORDER BY MajorCategoryId, OrderNo'
  9288. -- END
  9289. EXEC (@SQL)
  9290. END
  9291. GO
  9292. /****** Object: StoredProcedure [dbo].[ProcDouBanEmailUpdate] Script Date: 2018/12/13 19:10:30 ******/
  9293. SET ANSI_NULLS ON
  9294. GO
  9295. SET QUOTED_IDENTIFIER ON
  9296. GO
  9297. --#####################################################
  9298. --创建时间:2014.11.4
  9299. --创建人:John
  9300. --说明:更新豆瓣 邮件信息
  9301. --#####################################################
  9302. CREATE PROCEDURE [dbo].[ProcDouBanEmailUpdate]
  9303. (
  9304. @PaMainID INT,
  9305. @DouBanID INT
  9306. )
  9307. AS
  9308. BEGIN
  9309. UPDATE doubanmail SET isregister = 1, pamainid = @PaMainID WHERE id = @DouBanID
  9310. END
  9311. GO
  9312. /****** Object: StoredProcedure [dbo].[procDwnClass1ByDocIDSelect] Script Date: 2018/12/13 19:10:30 ******/
  9313. SET ANSI_NULLS ON
  9314. GO
  9315. SET QUOTED_IDENTIFIER ON
  9316. GO
  9317. --#####################################################
  9318. --创建时间:2014.11.5
  9319. --创建人:NICK
  9320. --说明:根据docid获取doc所在的大类名称
  9321. --#####################################################
  9322. CREATE PROCEDURE [dbo].[procDwnClass1ByDocIDSelect]
  9323. (
  9324. @ID INT
  9325. )
  9326. AS
  9327. BEGIN
  9328. SELECT a.id,b.title,b.id as typeid
  9329. FROM maindb..dwndoc a WITH(NOLOCK),maindb..dwnclass1 b WITH(NOLOCK),maindb..dwnclass2 c WITH(NOLOCK)
  9330. WHERE a.classid=c.id
  9331. AND c.class1id=b.id
  9332. AND a.id=@ID
  9333. END
  9334. GO
  9335. /****** Object: StoredProcedure [dbo].[procDwnClass1ByIDSelect] Script Date: 2018/12/13 19:10:30 ******/
  9336. SET ANSI_NULLS ON
  9337. GO
  9338. SET QUOTED_IDENTIFIER ON
  9339. GO
  9340. --#####################################################
  9341. --创建时间:2014.11.5
  9342. --创建人:NICK
  9343. --说明:获取个人文档下载大类名稱
  9344. --#####################################################
  9345. CREATE PROCEDURE [dbo].[procDwnClass1ByIDSelect]
  9346. (
  9347. @ID INT
  9348. )
  9349. AS
  9350. BEGIN
  9351. SELECT * FROM dwnclass1 WITH(NOLOCK) WHERE id=@ID
  9352. END
  9353. GO
  9354. /****** Object: StoredProcedure [dbo].[procDwnClass2ByIDSelect] Script Date: 2018/12/13 19:10:30 ******/
  9355. SET ANSI_NULLS ON
  9356. GO
  9357. SET QUOTED_IDENTIFIER ON
  9358. GO
  9359. --#####################################################
  9360. --创建时间:2014.11.5
  9361. --创建人:NICK
  9362. --说明:获取文档下载二级类别
  9363. --#####################################################
  9364. CREATE PROCEDURE [dbo].[procDwnClass2ByIDSelect]
  9365. (
  9366. @ID INT
  9367. )
  9368. AS
  9369. BEGIN
  9370. SELECT TOP 18 * FROM dwnclass2 WITH(NOLOCK) WHERE class1id=@ID ORDER BY power
  9371. END
  9372. GO
  9373. /****** Object: StoredProcedure [dbo].[procDwnDoc44ByCompanySelect] Script Date: 2018/12/13 19:10:31 ******/
  9374. SET ANSI_NULLS ON
  9375. GO
  9376. SET QUOTED_IDENTIFIER ON
  9377. GO
  9378. --#####################################################
  9379. --创建时间:2014.11.5
  9380. --创建人:NICK
  9381. --说明:文档下载 企业
  9382. --#####################################################
  9383. CREATE PROCEDURE [dbo].[procDwnDoc44ByCompanySelect]
  9384. AS
  9385. BEGIN
  9386. SELECT TOP 44 a.id,a.Name ,classid
  9387. FROM dwndoc a WITH(NOLOCK)
  9388. WHERE danwei=1
  9389. ORDER BY updatedate DESC
  9390. END
  9391. GO
  9392. /****** Object: StoredProcedure [dbo].[procDwnDoc44ByPersonSelect] Script Date: 2018/12/13 19:10:31 ******/
  9393. SET ANSI_NULLS ON
  9394. GO
  9395. SET QUOTED_IDENTIFIER ON
  9396. GO
  9397. --#####################################################
  9398. --创建时间:2014.11.5
  9399. --创建人:NICK
  9400. --说明:文档下载 个人
  9401. --#####################################################
  9402. CREATE PROCEDURE [dbo].[procDwnDoc44ByPersonSelect]
  9403. AS
  9404. BEGIN
  9405. SELECT TOP 44 a.id,a.Name ,classid
  9406. FROM dwndoc a WITH(NOLOCK)
  9407. WHERE geren=1
  9408. ORDER BY updatedate DESC
  9409. END
  9410. GO
  9411. /****** Object: StoredProcedure [dbo].[procDwnDoc51rcByIDSelect] Script Date: 2018/12/13 19:10:31 ******/
  9412. SET ANSI_NULLS ON
  9413. GO
  9414. SET QUOTED_IDENTIFIER ON
  9415. GO
  9416. --#####################################################
  9417. --创建时间:2014.11.10
  9418. --创建人:NICK
  9419. --说明:随机得到一定数目的个人文档
  9420. --alen 2018-3-26
  9421. --#####################################################
  9422. CREATE PROCEDURE [dbo].[procDwnDoc51rcByIDSelect]
  9423. (
  9424. @Second INT,
  9425. @Number INT
  9426. )
  9427. AS
  9428. BEGIN
  9429. DECLARE @SQL VARCHAR(MAX)
  9430. SET @SQL = '
  9431. SELECT TOP ' + CONVERT(VARCHAR(10), @Number)+' ID, Name, ClassId, Type
  9432. FROM Searchdb..DwnDoc51rc WITH(NOLOCK)
  9433. ORDER BY NEWID()'
  9434. EXEC(@SQL)
  9435. END
  9436. GO
  9437. /****** Object: StoredProcedure [dbo].[ProcDwnDocByClassIdSelect] Script Date: 2018/12/13 19:10:32 ******/
  9438. SET ANSI_NULLS ON
  9439. GO
  9440. SET QUOTED_IDENTIFIER ON
  9441. GO
  9442. CREATE PROCEDURE [dbo].[ProcDwnDocByClassIdSelect]
  9443. (
  9444. @ClassId INT,
  9445. @DocId INT
  9446. )
  9447. AS
  9448. BEGIN
  9449. IF ISNULL(@DocId, 0) = 0
  9450. SELECT Id, FileType, LEN(HtmlContent) HtmlContent, [Name], [Description]
  9451. FROM DwnDoc WITH(NOLOCK)
  9452. WHERE Classid = @ClassId
  9453. ORDER BY Id DESC
  9454. ELSE
  9455. SELECT Id, FileType, LEN(HtmlContent) HtmlContent, [Name], [Description]
  9456. FROM DwnDoc WITH(NOLOCK)
  9457. WHERE Classid = @ClassId
  9458. ORDER BY CASE Id WHEN @DocID THEN 1 ELSE 10 END, Id DESC
  9459. END
  9460. GO
  9461. /****** Object: StoredProcedure [dbo].[procDwnDocByCompanySelect] Script Date: 2018/12/13 19:10:32 ******/
  9462. SET ANSI_NULLS ON
  9463. GO
  9464. SET QUOTED_IDENTIFIER ON
  9465. GO
  9466. --#####################################################
  9467. --创建时间:2014.11.03
  9468. --创建人:Nick
  9469. --说明:获取企业doc文档下载排行(top10)
  9470. --#####################################################
  9471. CREATE PROCEDURE [dbo].[procDwnDocByCompanySelect]
  9472. AS
  9473. BEGIN TRY
  9474. SELECT TOP 10 id,name,dwnnum
  9475. FROM maindb..dwndoc
  9476. WHERE danwei=1
  9477. ORDER BY dwnnum DESC
  9478. END TRY
  9479. BEGIN CATCH
  9480. RETURN 0
  9481. END CATCH
  9482. GO
  9483. /****** Object: StoredProcedure [dbo].[procDwnDocByIDSelect] Script Date: 2018/12/13 19:10:32 ******/
  9484. SET ANSI_NULLS ON
  9485. GO
  9486. SET QUOTED_IDENTIFIER ON
  9487. GO
  9488. --#####################################################
  9489. --创建时间:2014.11.5
  9490. --创建人:NICK
  9491. --说明:获取doc文档内容
  9492. --#####################################################
  9493. CREATE PROCEDURE [dbo].[procDwnDocByIDSelect]
  9494. (
  9495. @ID INT
  9496. )
  9497. AS
  9498. BEGIN
  9499. SELECT a.*, b.dir dir1, c.dir dir2
  9500. FROM Maindb..DwnDoc a, DwnClass1 b, DwnClass2 c
  9501. WHERE a.ID = @ID
  9502. AND a.ClassID = c.ID
  9503. AND c.Class1ID = b.ID
  9504. END
  9505. GO
  9506. /****** Object: StoredProcedure [dbo].[procDwnDocByIDUpdate] Script Date: 2018/12/13 19:10:32 ******/
  9507. SET ANSI_NULLS ON
  9508. GO
  9509. SET QUOTED_IDENTIFIER ON
  9510. GO
  9511. --#####################################################
  9512. --创建时间:2014.11.5
  9513. --创建人:NICK
  9514. --说明:文档增加点击数
  9515. --#####################################################
  9516. CREATE PROCEDURE [dbo].[procDwnDocByIDUpdate]
  9517. (
  9518. @ID INT
  9519. )
  9520. AS
  9521. BEGIN
  9522. UPDATE dwndoc SET dwnnum=dwnnum+1 WHERE id=@ID
  9523. RETURN 1
  9524. END
  9525. GO
  9526. /****** Object: StoredProcedure [dbo].[procDwnDocByPersonSelect] Script Date: 2018/12/13 19:10:33 ******/
  9527. SET ANSI_NULLS ON
  9528. GO
  9529. SET QUOTED_IDENTIFIER ON
  9530. GO
  9531. --#####################################################
  9532. --创建时间:2014.11.03
  9533. --创建人:Nick
  9534. --说明:获取个人doc文档下载排行(top10)
  9535. --#####################################################
  9536. CREATE PROCEDURE [dbo].[procDwnDocByPersonSelect]
  9537. AS
  9538. BEGIN TRY
  9539. SELECT TOP 10 id,name,dwnnum
  9540. FROM maindb..dwndoc
  9541. WHERE geren=1
  9542. ORDER BY dwnnum DESC
  9543. END TRY
  9544. BEGIN CATCH
  9545. RETURN 0
  9546. END CATCH
  9547. GO
  9548. /****** Object: StoredProcedure [dbo].[ProcDwnDocByTop5Select] Script Date: 2018/12/13 19:10:33 ******/
  9549. SET ANSI_NULLS ON
  9550. GO
  9551. SET QUOTED_IDENTIFIER ON
  9552. GO
  9553. --修改harry 2017-10-10
  9554. --may要求按照添加时间排序
  9555. CREATE PROCEDURE [dbo].[ProcDwnDocByTop5Select]
  9556. AS
  9557. SET NOCOUNT ON
  9558. BEGIN
  9559. SELECT TOP 8 a.ID, a.Name, a.ClassID Class2ID, b.Title, c.ID Class1ID
  9560. FROM DwnDoc a WITH(NOLOCK),
  9561. DwnClass2 b WITH(NOLOCK),
  9562. DwnClass1 c WITH(NOLOCK)
  9563. WHERE a.Geren = 1
  9564. AND a.ClassID = b.ID
  9565. AND b.Class1ID = c.ID
  9566. ORDER BY a.adddate desc
  9567. END
  9568. SET NOCOUNT OFF
  9569. GO
  9570. /****** Object: StoredProcedure [dbo].[procDwnDocDetailByIDSelect] Script Date: 2018/12/13 19:10:33 ******/
  9571. SET ANSI_NULLS ON
  9572. GO
  9573. SET QUOTED_IDENTIFIER ON
  9574. GO
  9575. --#####################################################
  9576. --创建时间:2014.11.5
  9577. --创建人:NICK
  9578. --说明:获取文档内容
  9579. --#####################################################
  9580. CREATE PROCEDURE [dbo].[procDwnDocDetailByIDSelect]
  9581. (
  9582. @ID INT
  9583. )
  9584. AS
  9585. BEGIN
  9586. SELECT a.id,a.name,a.lgg,a.adddate,a.filetype,a.description,a.authtype,a.dwnnum,b.dir dir1,c.dir dir2,a.filename
  9587. FROM dwndoc a WITH(NOLOCK),dwnclass1 b WITH(NOLOCK),dwnclass2 c WITH(NOLOCK)
  9588. WHERE a.classid=c.id
  9589. AND c.class1id=b.id
  9590. AND a.id=@ID
  9591. END
  9592. GO
  9593. /****** Object: StoredProcedure [dbo].[ProcDwnDocSelect] Script Date: 2018/12/13 19:10:33 ******/
  9594. SET ANSI_NULLS ON
  9595. GO
  9596. SET QUOTED_IDENTIFIER ON
  9597. GO
  9598. --#####################################################
  9599. --创建时间:2014.10.28
  9600. --创建人:Nick
  9601. --说明:获取文档下载数据
  9602. --#####################################################
  9603. CREATE PROCEDURE [dbo].[ProcDwnDocSelect]
  9604. AS
  9605. BEGIN TRY
  9606. SELECT TOP 14 a.ID,a.Name,ClassID
  9607. FROM DwnDoc a WITH(NOLOCK)
  9608. WHERE Geren = 1
  9609. ORDER BY UpdateDate DESC
  9610. END TRY
  9611. BEGIN CATCH
  9612. RETURN 0
  9613. END CATCH
  9614. GO
  9615. /****** Object: StoredProcedure [dbo].[procDwnDocUpdate] Script Date: 2018/12/13 19:10:33 ******/
  9616. SET ANSI_NULLS ON
  9617. GO
  9618. SET QUOTED_IDENTIFIER ON
  9619. GO
  9620. --#####################################################
  9621. --创建时间:2014.10.31
  9622. --创建人:Nick
  9623. --说明:修改下载文档
  9624. --#####################################################
  9625. CREATE PROCEDURE [dbo].[procDwnDocUpdate]
  9626. (
  9627. @ID INT
  9628. )
  9629. AS
  9630. BEGIN TRY
  9631. UPDATE dwndoc SET dwnnum=dwnnum+1 WHERE id = @ID
  9632. RETURN 1
  9633. END TRY
  9634. BEGIN CATCH
  9635. RETURN 0
  9636. END CATCH
  9637. GO
  9638. /****** Object: StoredProcedure [dbo].[ProcEmailPrevSendInsert] Script Date: 2018/12/13 19:10:34 ******/
  9639. SET ANSI_NULLS ON
  9640. GO
  9641. SET QUOTED_IDENTIFIER ON
  9642. GO
  9643. --#####################################################
  9644. --创建时间:2014.10.28
  9645. --创建人:John
  9646. --说明:即时邮件发送
  9647. --#####################################################
  9648. CREATE PROCEDURE [dbo].[ProcEmailPrevSendInsert]
  9649. (
  9650. @cpMainID INT,
  9651. @paMainID INT,
  9652. @emailNo TINYINT,
  9653. @emailTitle NVARCHAR(50),
  9654. @jsonData NVARCHAR(MAX),
  9655. @email VARCHAR(100),
  9656. @subSiteID SMALLINT
  9657. )
  9658. AS
  9659. SET NOCOUNT ON
  9660. BEGIN
  9661. INSERT INTO msEmailPrevSend(cpMainId, paMainId, EmailNo, EmailTitle, JsonData, Email, dcSubsiteId, IsSend)
  9662. VALUES(@cpMainID, @paMainID, @emailNo, @emailTitle, @jsonData, @email, @subSiteID, 0)
  9663. END
  9664. GO
  9665. /****** Object: StoredProcedure [dbo].[procexInterviewByPamainIDSelect] Script Date: 2018/12/13 19:10:34 ******/
  9666. SET ANSI_NULLS ON
  9667. GO
  9668. SET QUOTED_IDENTIFIER ON
  9669. GO
  9670. --#####################################################
  9671. --创建时间:2014.11.10
  9672. --创建人:Nick
  9673. --说明:面试通知
  9674. --#####################################################
  9675. CREATE PROCEDURE [dbo].[procexInterviewByPamainIDSelect]
  9676. (
  9677. @PamainID INT
  9678. )
  9679. AS
  9680. BEGIN
  9681. SELECT TOP 5 a.*, b.Name as JobName, b.caMainID, b.dcRegionID, c.Name as cpName, c.ID as cpID,
  9682. c.HasLicence, c.IsAgent, b.IssueDate, b.IssueEND, b.IsDelete, d.Name cvName
  9683. FROM exInterview a WITH(NOLOCK)
  9684. INNER JOIN Job b WITH(NOLOCK) On b.ID=a.JobID
  9685. INNER JOIN cpMain c WITH(NOLOCK) ON b.cpMainID=c.ID
  9686. INNER JOIN cvMain d WITH(NOLOCK) ON a.cvMainID = d.ID
  9687. WHERE PersonDeleted=0 AND d.paMainID=@PamainID
  9688. ORDER BY a.adddate DESC
  9689. END
  9690. GO
  9691. /****** Object: StoredProcedure [dbo].[procExJobApplyByCvMainIDCpMainIDSelect] Script Date: 2018/12/13 19:10:34 ******/
  9692. SET ANSI_NULLS ON
  9693. GO
  9694. SET QUOTED_IDENTIFIER ON
  9695. GO
  9696. --#####################################################
  9697. --创建时间:2014.11.03
  9698. --创建人:Nick
  9699. --说明:
  9700. --#####################################################
  9701. CREATE PROCEDURE [dbo].[procExJobApplyByCvMainIDCpMainIDSelect]
  9702. (
  9703. @IsManager INT,
  9704. @CvMainID INT,
  9705. @ID INT
  9706. )
  9707. AS
  9708. BEGIN TRY
  9709. IF @IsManager = 1
  9710. BEGIN
  9711. SELECT TOP 1 JobID
  9712. FROM exJobApply a,Job b
  9713. WHERE a.JobID=b.ID
  9714. AND a.cvMainID=@CvMainID
  9715. AND b.cpMainID=@ID
  9716. ORDER BY a.AddDate DESC
  9717. END
  9718. ELSE
  9719. BEGIN
  9720. SELECT TOP 1 JobID
  9721. FROM exJobApply a,Job b
  9722. WHERE a.JobID=b.ID
  9723. AND a.cvMainID=@CvMainID
  9724. AND b.caMainID=@ID
  9725. ORDER BY a.AddDate DESC
  9726. END
  9727. END TRY
  9728. BEGIN CATCH
  9729. RETURN 0
  9730. END CATCH
  9731. GO
  9732. /****** Object: StoredProcedure [dbo].[procExJobApplyByCvMainIDSelect] Script Date: 2018/12/13 19:10:35 ******/
  9733. SET ANSI_NULLS ON
  9734. GO
  9735. SET QUOTED_IDENTIFIER ON
  9736. GO
  9737. --#####################################################
  9738. --创建时间:2014.11.03
  9739. --创建人:Nick
  9740. --说明:
  9741. --#####################################################
  9742. CREATE PROCEDURE [dbo].[procExJobApplyByCvMainIDSelect]
  9743. (
  9744. @IsManager INT,
  9745. @CvMainID INT,
  9746. @ID INT
  9747. )
  9748. AS
  9749. BEGIN TRY
  9750. IF @IsManager = 1
  9751. BEGIN
  9752. SELECT TOP 1 JobID
  9753. FROM exJobApply a,Job b
  9754. WHERE a.JobID=b.ID
  9755. AND a.cvMainID=@CvMainID
  9756. AND b.cpMainID=@ID
  9757. ORDER BY a.AddDate DESC
  9758. END
  9759. ELSE
  9760. BEGIN
  9761. SELECT TOP 1 JobID
  9762. FROM exJobApply a,Job b
  9763. WHERE a.JobID=b.ID
  9764. AND a.cvMainID=@CvMainID
  9765. AND b.caMainID=@ID
  9766. ORDER BY a.AddDate DESC
  9767. END
  9768. END TRY
  9769. BEGIN CATCH
  9770. RETURN 0
  9771. END CATCH
  9772. GO
  9773. /****** Object: StoredProcedure [dbo].[procexJobApplyByPamainIDSelect] Script Date: 2018/12/13 19:10:35 ******/
  9774. SET ANSI_NULLS ON
  9775. GO
  9776. SET QUOTED_IDENTIFIER ON
  9777. GO
  9778. --#####################################################
  9779. --创建时间:2014.11.10
  9780. --创建人:Nick
  9781. --说明:获取职位申请信息
  9782. --#####################################################
  9783. CREATE PROCEDURE [dbo].[procexJobApplyByPamainIDSelect]
  9784. (
  9785. @PamainID INT
  9786. )
  9787. AS
  9788. BEGIN
  9789. SELECT TOP 5 a.ID, a.JobID, a.cvMainID, a.ApplyMessage, a.AddDate, a.CompanyDeleted, a.CompanyDeleteDate,
  9790. a.PersonDeleted, a.Reply, a.ReplyDate, b.Name as JobName, b.caMainID, b.dcRegionID, c.Name as cpName, c.ID as cpID,
  9791. c.HasLicence, c.IsAgent, b.IssueDate, b.IssueEND, b.IsDelete, d.Name cvName
  9792. FROM exJobApply a WITH(NOLOCK)
  9793. INNER JOIN Job b WITH(NOLOCK) On b.ID=a.JobID
  9794. INNER JOIN cpMain c WITH(NOLOCK) ON b.cpMainID=c.ID
  9795. INNER JOIN cvMain d WITH(NOLOCK) ON a.cvMainID = d.ID
  9796. WHERE PersonDeleted=0 AND d.paMainID=@PamainID
  9797. ORDER BY a.AddDate DESC
  9798. END
  9799. GO
  9800. /****** Object: StoredProcedure [dbo].[ProcFamousCompanyGroupSelect] Script Date: 2018/12/13 19:10:35 ******/
  9801. SET ANSI_NULLS ON
  9802. GO
  9803. SET QUOTED_IDENTIFIER ON
  9804. GO
  9805. --#####################################################
  9806. --创建时间:2014.10.29
  9807. --创建人:Nick
  9808. --说明:获取名企导航Group
  9809. --#####################################################
  9810. CREATE PROCEDURE [dbo].[ProcFamousCompanyGroupSelect]
  9811. (
  9812. @ProvinceID INT
  9813. )
  9814. AS
  9815. BEGIN TRY
  9816. SELECT a.*,STUFF((SELECT ','+CONVERT(VARCHAR(10),dcRegionID)
  9817. FROM marketdb..CampusGroupRegion WITH(NOLOCK)
  9818. WHERE GroupID=a.id for xml path('')),1,1,'') RegionIDs FROM MarketDB..CampusGroup a WITH(NOLOCK)
  9819. WHERE EXISTS(
  9820. SELECT TOP 1 'x'
  9821. FROM MarketDB..CampusGroupRegion WITH(NOLOCK)
  9822. WHERE GroupID=a.ID
  9823. AND dcRegionID LIKE ''+CONVERT(VARCHAR(4),@ProvinceID)+'%'
  9824. )
  9825. ORDER BY a.id
  9826. END TRY
  9827. BEGIN CATCH
  9828. RETURN 0
  9829. END CATCH
  9830. GO
  9831. /****** Object: StoredProcedure [dbo].[ProcFamousCompanySelect] Script Date: 2018/12/13 19:10:35 ******/
  9832. SET ANSI_NULLS ON
  9833. GO
  9834. SET QUOTED_IDENTIFIER ON
  9835. GO
  9836. --#####################################################
  9837. --创建时间:2014.10.29
  9838. --创建人:Nick
  9839. --说明:获取名企导航
  9840. --#####################################################
  9841. CREATE PROCEDURE [dbo].[ProcFamousCompanySelect]
  9842. (
  9843. @ProvinceID INT,
  9844. @RegionIDs VARCHAR(100)
  9845. )
  9846. AS
  9847. BEGIN TRY
  9848. SELECT a.*
  9849. FROM MarketDB..CampusCompany a WITH(NOLOCK)
  9850. WHERE
  9851. (
  9852. dcRegionID = @ProvinceID OR dcRegionID IN (SELECT * FROM dbo.fnSplit(@RegionIDs,','))
  9853. )
  9854. AND (
  9855. EXISTS(
  9856. SELECT TOP 1 'x' FROM MarketDB..CampusBrochure x
  9857. WITH(NOLOCK),MarketDB..CampusBrochureSite y WITH(NOLOCK)
  9858. WHERE x.ID = y.CampusBrochure
  9859. AND x.CompanyID=a.ID
  9860. AND x.EndDate>getdate()
  9861. AND y.dcSubSiteId = @ProvinceID
  9862. )
  9863. OR EXISTS(
  9864. SELECT TOP 1 'x'
  9865. FROM MarketDB..CampusPresentation m WITH(NOLOCK),MarketDB..CampusSchool n WITH(NOLOCK)
  9866. WHERE m.SchoolID = n.ID
  9867. AND m.endtime>getdate()
  9868. AND m.CompanyID=a.ID
  9869. AND n.dcRegionID LIKE ''+CONVERT(VARCHAR(4),@ProvinceID)+'%'
  9870. )
  9871. ) ORDER BY AddDate DESC
  9872. END TRY
  9873. BEGIN CATCH
  9874. RETURN 0
  9875. END CATCH
  9876. GO
  9877. /****** Object: StoredProcedure [dbo].[procFeedback_NoregInsert] Script Date: 2018/12/13 19:10:35 ******/
  9878. SET ANSI_NULLS ON
  9879. GO
  9880. SET QUOTED_IDENTIFIER ON
  9881. GO
  9882. --#####################################################
  9883. --创建时间:2014.11.04
  9884. --创建人:Nick
  9885. --说明:插入 feedback_noreg
  9886. --#####################################################
  9887. CREATE PROCEDURE [dbo].[procFeedback_NoregInsert]
  9888. (
  9889. @Content VARCHAR(400),
  9890. @Name VARCHAR(50),
  9891. @IP VARCHAR(20),
  9892. @Tel VARCHAR(20),
  9893. @Email VARCHAR(50),
  9894. @SiteID INT
  9895. )
  9896. AS
  9897. BEGIN TRY
  9898. INSERT INTO feedback_noreg (content,name,ip,telephone,email,province_id)
  9899. SELECT dbo.SafeSQL(@Content), dbo.SafeSQL(@Name), @IP, dbo.SafeSQL(@Tel), dbo.SafeSQL(@Email), @SiteID
  9900. RETURN 1
  9901. END TRY
  9902. BEGIN CATCH
  9903. RETURN 0
  9904. END CATCH
  9905. GO
  9906. /****** Object: StoredProcedure [dbo].[procFixCompanyByRecruitmentSelect] Script Date: 2018/12/13 19:10:36 ******/
  9907. SET ANSI_NULLS ON
  9908. GO
  9909. SET QUOTED_IDENTIFIER ON
  9910. GO
  9911. CREATE PROCEDURE [dbo].[procFixCompanyByRecruitmentSelect]
  9912. (
  9913. @SubSiteID VARCHAR(4)
  9914. )
  9915. AS
  9916. BEGIN
  9917. CREATE TABLE #Tmp --创建临时表#Tmp
  9918. (
  9919. CpMainId INT,
  9920. SecondId VARCHAR(50),
  9921. Name NVARCHAR(50),
  9922. DcCompanySizeId SMALLINT,
  9923. Industry VARCHAR(100),
  9924. Logo VARCHAR(200)
  9925. )
  9926. INSERT INTO #Tmp (CpMainId,SecondId,Name,DcCompanySizeId)
  9927. SELECT DISTINCT TOP 8 cp.Id, fp.CpMainId,fp.Name,cp.DcCompanySizeId
  9928. FROM FpFixPosition fp LEFT JOIN cpMain cp ON fp.cpmainid = cp.SecondId
  9929. WHERE LEFT(fp.dcSubSiteID,LEN(@SubSiteID)) = @SubSiteID
  9930. ORDER BY DcCompanySizeID DESC
  9931. DECLARE @Cnt INT
  9932. SELECT @Cnt = COUNT(1) FROM #Tmp
  9933. IF @Cnt < 3 AND LEN(@SubSiteID) > 2
  9934. INSERT INTO #Tmp (CpMainId,SecondId,Name,DcCompanySizeId)
  9935. SELECT DISTINCT TOP 8 cp.Id, fp.CpMainId,fp.Name,cp.DcCompanySizeId
  9936. FROM FpFixPosition fp LEFT JOIN cpMain cp ON fp.cpmainid = cp.SecondId
  9937. WHERE fp.DcProvinceId = LEFT(@SubSiteID,2)
  9938. ORDER BY DcCompanySizeID DESC
  9939. UPDATE #Tmp SET Industry = dbo.GetCpIndustry(#Tmp.CpMainId)
  9940. UPDATE #Tmp SET Logo = dbo.GetCpLogo(#Tmp.CpMainId)
  9941. SELECT TOP 8 * FROM #Tmp
  9942. END
  9943. GO
  9944. /****** Object: StoredProcedure [dbo].[procFpcommonSearchByProvinceIDSelect] Script Date: 2018/12/13 19:10:36 ******/
  9945. SET ANSI_NULLS ON
  9946. GO
  9947. SET QUOTED_IDENTIFIER ON
  9948. GO
  9949. --#####################################################
  9950. --创建时间:2014.11.03
  9951. --创建人:Nick
  9952. --说明:获取地区
  9953. --#####################################################
  9954. CREATE PROCEDURE [dbo].[procFpcommonSearchByProvinceIDSelect]
  9955. (
  9956. @ProvinceID INT
  9957. )
  9958. AS
  9959. BEGIN TRY
  9960. SELECT SearchText, SearchValue, SearchType
  9961. FROM fpcommonsearch WITH(NOLOCK)
  9962. WHERE dcProvinceID = @ProvinceID
  9963. ORDER BY SearchType, Sequence
  9964. END TRY
  9965. BEGIN CATCH
  9966. RETURN 0
  9967. END CATCH
  9968. GO
  9969. /****** Object: StoredProcedure [dbo].[ProcFpFixPositionReBuild] Script Date: 2018/12/13 19:10:36 ******/
  9970. SET ANSI_NULLS ON
  9971. GO
  9972. SET QUOTED_IDENTIFIER ON
  9973. GO
  9974. CREATE PROCEDURE [dbo].[ProcFpFixPositionReBuild]
  9975. AS
  9976. SET NOCOUNT ON;
  9977. IF NOT EXISTS(SELECT 'x' FROM caOrder WITH(NOLOCK)
  9978. WHERE OrderType=7 AND BeginDate < GETDATE()
  9979. AND EndDate > GETDATE()
  9980. and (BeginDate > DaTEADD(MINUTE, -3, GETDATE())
  9981. OR OpenDate > DaTEADD(MINUTE, -3, GETDATE())
  9982. )
  9983. )
  9984. BEGIN
  9985. IF DATEPART(MINUTE, GETDATE()) % 10 > 20
  9986. RETURN
  9987. END
  9988. BEGIN TRAN
  9989. TRUNCATE TABLE SearchDb..FpFixPosition
  9990. INSERT FpFixPosition(RealCpMainID, cpMainID, Name, Paid, OpenDate, dcProvinceId, dcRegionID, dcSubsiteID, caOrderId, dcIndustryId)
  9991. SELECT a.ID CompanyId, a.SecondId SecondCompanyId, a.Name, b.Paid, b.OpenDate, a.dcProvinceID, a.dcRegionID, a.dcSubsiteID, b.Id, c.dcIndustryId
  9992. FROM cpMain a WITH(NOLOCK INDEX(IX_cpMain_HomepageFix))
  9993. INNER JOIN caOrder b WITH(NOLOCK) ON b.cpMainID = a.id
  9994. INNER JOIN cpIndustry c WITH(NOLOCK) ON a.id = c.cpMainId
  9995. WHERE b.BeginDate < GETDATE()
  9996. AND b.EndDate > GETDATE()
  9997. AND b.OpenDate IS NOT NULL
  9998. AND b.OrderType = 7
  9999. AND a.JobNumber>0
  10000. AND a.Valid = 1
  10001. AND b.IsDeleted = 0 --是否可被搜索
  10002. --UPDATE a SET a.Name = b.ShortName
  10003. --FROM FpFixPosition a, cpMain b
  10004. --WHERE a.RealCpMainID = b.Id
  10005. --AND b.ShortName > ''
  10006. UPDATE FpFixPosition SET Name = '日照天宁集团' WHERE RealCpMAinId = 10174411
  10007. UPDATE FpFixPosition SET JobID = dbo.GetJobSecondIds(RealCpMainID),
  10008. JobName = dbo.GetJobNames(RealCpMainID)
  10009. UPDATE FpFixPosition SET ThreeIds = dbo.TruncJobIDs(JobID)
  10010. UPDATE FpFixPosition
  10011. SET AddDate =
  10012. (SELECT MAX(AddDate) FROM Job WITH(NOLOCK)
  10013. WHERE Job.SecondID IN (SELECT REPLACE(ID, '_', '') FROM dbo.Get3JobSecondIds(FpFixPosition.ThreeIds))
  10014. )
  10015. UPDATE FpFixPosition SET NoFollow = ''
  10016. --WHERE CpMainId IN(SELECT PageId FROM MarketDb..PageBaiduInclude WITH(NOLOCK) WHERE PageType = 1 AND InCludeDate IS NULL)
  10017. UPDATE FpFixPosition
  10018. SET NewXId =
  10019. (SELECT TOP 1 SecondID FROM Job WITH(NOLOCK)
  10020. WHERE Job.SecondID IN (SELECT ID FROM dbo.Get3JobSecondIds(FpFixPosition.ThreeIds))
  10021. AND Job.AddDate = FpFixPosition.AddDate
  10022. )
  10023. --UPDATE FpFixPosition SET dcIndustryId =(SELECT TOP 1 dcIndustryID FROM cpIndustry WITH(NOLOCK) WHERE cpIndustry.cpMainID = FpFixPosition.RealCpMainID)
  10024. UPDATE FpFixPosition SET IndustryCategory=(SELECT CategoryId FROM dcIndustryCategory WITH(NOLOCK) WHERE dcIndustryCategory.dcIndustryId = FpFixPosition.dcIndustryId)
  10025. DELETE FpFixPosition WHERE Id IN(SELECT MAX(ID) ID FROM FpFixPosition GROUP BY cpMainId, INDustryCategory HAVING COUNT(*) > 1)
  10026. DELETE FpFixPosition WHERE Id IN(SELECT MAX(ID) ID FROM FpFixPosition GROUP BY cpMainId, INDustryCategory HAVING COUNT(*) > 1)
  10027. DELETE FpFixPosition WHERE Id IN(SELECT MAX(ID) ID FROM FpFixPosition GROUP BY cpMainId, INDustryCategory HAVING COUNT(*) > 1)
  10028. UPDATE a SET a.IndustryCategory = 8
  10029. FROM FpFixPosition a, (
  10030. SELECT dcProvinceId, IndustryCategory
  10031. FROM FpFixPosition WITH(NOLOCK)
  10032. GROUP BY dcProvinceId, IndustryCategory
  10033. HAVING COUNT(*) < 4) b
  10034. WHERE a.dcProvinceId = b.dcProvinceId
  10035. AND a.IndustryCategory = b.IndustryCategory
  10036. COMMIT
  10037. GO
  10038. /****** Object: StoredProcedure [dbo].[procFpHomepageimage51RCSelect] Script Date: 2018/12/13 19:10:36 ******/
  10039. SET ANSI_NULLS ON
  10040. GO
  10041. SET QUOTED_IDENTIFIER ON
  10042. GO
  10043. --#####################################################
  10044. --创建时间:2014.11.10
  10045. --创建人:NICK
  10046. --说明:
  10047. --#####################################################
  10048. CREATE PROCEDURE [dbo].[procFpHomepageimage51RCSelect]
  10049. AS
  10050. BEGIN
  10051. SELECT TOP 1 *
  10052. FROM fphomepageimage
  10053. WHERE url is not null
  10054. AND ltrim(url)<>'' ORDER BY adddate DESC
  10055. END
  10056. GO
  10057. /****** Object: StoredProcedure [dbo].[procfpHomepageImageByProvinceIDSelect] Script Date: 2018/12/13 19:10:37 ******/
  10058. SET ANSI_NULLS ON
  10059. GO
  10060. SET QUOTED_IDENTIFIER ON
  10061. GO
  10062. --#####################################################
  10063. --创建时间:2014.11.5
  10064. --创建人:NICK
  10065. --说明:获取网站头条
  10066. --#####################################################
  10067. CREATE PROCEDURE [dbo].[procfpHomepageImageByProvinceIDSelect]
  10068. (
  10069. @ProvinceID INT,
  10070. @Num INT
  10071. )
  10072. AS
  10073. BEGIN
  10074. DECLARE @SQL VARCHAR(MAX)
  10075. SET @SQL = 'SELECT TOP '+CONVERT(VARCHAR(10),@Num)+' *
  10076. FROM fpHomepageImage
  10077. WHERE dcProvinceID='+CONVERT(VARCHAR(10),@ProvinceID)+'
  10078. AND imagetype=1
  10079. AND url >''''
  10080. ORDER BY AddDate DESC '
  10081. EXEC(@SQL)
  10082. END
  10083. GO
  10084. /****** Object: StoredProcedure [dbo].[ProcGdFixedSelect] Script Date: 2018/12/13 19:10:37 ******/
  10085. SET ANSI_NULLS ON
  10086. GO
  10087. SET QUOTED_IDENTIFIER ON
  10088. GO
  10089. --创建人:lambo
  10090. --创建时间:2013-5-25
  10091. --用途:查询固定资产列表
  10092. CREATE PROCEDURE [dbo].[ProcGdFixedSelect]
  10093. (
  10094. @WorkUserID INT,
  10095. @Where NVARCHAR(MAX)
  10096. )
  10097. AS
  10098. BEGIN
  10099. --待确认的
  10100. SELECT a.*,0 OrderBY INTO #T FROM GdFixed a WITH(NOLOCK)
  10101. WHERE
  10102. EXISTS(SELECT 'x' FROM GdRepair x WITH(NOLOCK) WHERE x.GdFixedID = a.ID AND OwnerConfirmDate IS NULL AND Owner = @WorkUserID )
  10103. OR
  10104. EXISTS(SELECT 'x' FROM GdShift x WITH(NOLOCK) WHERE x.GdFixedID = a.ID AND ReceiverDate IS NULL AND Owner = @WorkUserID )
  10105. OR
  10106. EXISTS(SELECT 'x' FROM GdShift x WITH(NOLOCK) WHERE x.GdFixedID = a.ID AND ReceiverDate IS NULL AND GdHouseID IN (SELECT ID FROM GdHouse WITH(NOLOCK) WHERE HouseOwner = @WorkUserID ))
  10107. OR
  10108. (ScrapMan in
  10109. (
  10110. SELECT ID FROM WorkUser WITH(NOLOCK)
  10111. WHERE ManagerUserID IN
  10112. (
  10113. SELECT ID FROM ManagerUser WITH(NOLOCK)
  10114. WHERE Superior=(
  10115. SELECT ManagerUserID FROM WorkUser WITH(NOLOCK)
  10116. WHERE ID = @WorkUserID
  10117. )
  10118. )
  10119. )
  10120. AND ScrapConfirmdate IS NULL
  10121. )
  10122. SET IDENTITY_INSERT #t ON
  10123. --自己发出 别人代办的
  10124. INSERT INTO #t (ID,FixedName,Format,BarcodeText,BarcodeLabel,GdClassId,SourceType,Buyer,BuyDate,Price,UsedMonth,Warranty,AddMan,AddDate,PhotoFile,status,ScrapDate,ScrapMan,ScrapReason,ScrapConfirmor,ScrapConfirmDate,ScrapMemo,OrderBY)
  10125. SELECT ID,FixedName,Format,BarcodeText,BarcodeLabel,GdClassId,SourceType,Buyer,BuyDate,Price,UsedMonth,Warranty,AddMan,AddDate,PhotoFile,status,ScrapDate,ScrapMan,ScrapReason,ScrapConfirmor,ScrapConfirmDate,ScrapMemo,1 OrderBY FROM GdFixed a WITH(NOLOCK)
  10126. WHERE
  10127. (
  10128. EXISTS(SELECT 'x' FROM GdRepair x WITH(NOLOCK) WHERE x.GdFixedID = a.ID AND OwnerConfirmDate IS NULL AND AddMan = @WorkUserID )
  10129. OR
  10130. EXISTS(SELECT 'x' FROM GdShift x WITH(NOLOCK) WHERE x.GdFixedID = a.ID AND ReceiverDate IS NULL AND AddMan = @WorkUserID )
  10131. OR
  10132. (ScrapMan = @WorkUserID AND ScrapConfirmdate IS NULL)
  10133. )
  10134. AND ID NOT IN (SELECT ID FROM #t)
  10135. --自己使用的
  10136. INSERT INTO #t (ID,FixedName,Format,BarcodeText,BarcodeLabel,GdClassId,SourceType,Buyer,BuyDate,Price,UsedMonth,Warranty,AddMan,AddDate,PhotoFile,status,ScrapDate,ScrapMan,ScrapReason,ScrapConfirmor,ScrapConfirmDate,ScrapMemo,OrderBY)
  10137. SELECT ID,FixedName,Format,BarcodeText,BarcodeLabel,GdClassId,SourceType,Buyer,BuyDate,Price,UsedMonth,Warranty,AddMan,AddDate,PhotoFile,status,ScrapDate,ScrapMan,ScrapReason,ScrapConfirmor,ScrapConfirmDate,ScrapMemo,2 OrderBY FROM GdFixed a WITH(NOLOCK)
  10138. WHERE
  10139. EXISTS (SELECT 'x' FROM GdShift WITH(NOLOCK) WHERE GdFixedID = a.id AND Owner IS NOT NULL AND id = (SELECT MAX(id) FROM GdShift WITH(NOLOCK) WHERE ReceiverDate IS NOT NULL AND GdFixedID = a.id) AND Owner = @WorkUserID )
  10140. AND ID NOT IN (SELECT ID FROM #t)
  10141. --自己负责的
  10142. INSERT INTO #t (ID,FixedName,Format,BarcodeText,BarcodeLabel,GdClassId,SourceType,Buyer,BuyDate,Price,UsedMonth,Warranty,AddMan,AddDate,PhotoFile,status,ScrapDate,ScrapMan,ScrapReason,ScrapConfirmor,ScrapConfirmDate,ScrapMemo,OrderBY)
  10143. SELECT ID,FixedName,Format,BarcodeText,BarcodeLabel,GdClassId,SourceType,Buyer,BuyDate,Price,UsedMonth,Warranty,AddMan,AddDate,PhotoFile,status,ScrapDate,ScrapMan,ScrapReason,ScrapConfirmor,ScrapConfirmDate,ScrapMemo,2 OrderBY FROM GdFixed a WITH(NOLOCK)
  10144. WHERE
  10145. EXISTS (SELECT 'x' FROM GdShift WITH(NOLOCK) WHERE GdFixedID = a.id AND Owner IS NULL AND id = (SELECT MAX(id) FROM GdShift WITH(NOLOCK) WHERE ReceiverDate IS NOT NULL AND GdFixedID = a.id) AND GdHouseID IN (SELECT ID FROM GdHouse WITH(NOLOCK) WHERE HouseOwner = @WorkUserID) )
  10146. AND ID NOT IN (SELECT ID FROM #t)
  10147. --其它
  10148. INSERT INTO #t (ID,FixedName,Format,BarcodeText,BarcodeLabel,GdClassId,SourceType,Buyer,BuyDate,Price,UsedMonth,Warranty,AddMan,AddDate,PhotoFile,status,ScrapDate,ScrapMan,ScrapReason,ScrapConfirmor,ScrapConfirmDate,ScrapMemo,OrderBY)
  10149. SELECT ID,FixedName,Format,BarcodeText,BarcodeLabel,GdClassId,SourceType,Buyer,BuyDate,Price,UsedMonth,Warranty,AddMan,AddDate,PhotoFile,status,ScrapDate,ScrapMan,ScrapReason,ScrapConfirmor,ScrapConfirmDate,ScrapMemo,2 OrderBY FROM GdFixed a WITH (NOLOCK)
  10150. WHERE ID NOT IN (SELECT ID FROM #t)
  10151. SET @Where = dbo.SafeSql(@Where)
  10152. EXEC('SELECT a.*, b.ClassName,
  10153. ISNULL((SELECT LTRIM(STR(ManagerUserID)) + '' '' + Name From WorkUser WHERE ID IN( SELECT TOP 1 ISNULL(owner,0) FROM gdshift WITH(NOLOCK) WHERE gdfixedid=a.id and ReceiverDate IS NOT NULL ORDER BY ID DESC)),'''') WorkUserName,
  10154. ISNULL((SELECT HouseName+''(''+Ltrim(str(n.manageruserid))+n.Name+'')'' From GdHouse m with(nolock),workuser n with(nolock) WHERE m.HouseOwner=n.id and m.ID IN( SELECT TOP 1 ISNULL(GdHouseId,0) FROM gdshift WITH(NOLOCK) WHERE gdfixedid=a.id and ReceiverDate IS NOT NULL ORDER BY ID DESC)),'''') GdHouseName,
  10155. (SELECT count(1) FROM GdShift WITH(NOLOCK) WHERE gdFixedID=a.ID ) ShiftCount
  10156. FROM #t a WITH(NOLOCK) ,GdClass b WITH(NOLOCK) WHERE a.GdClassid = b.id ' + @Where)
  10157. END
  10158. GO
  10159. /****** Object: StoredProcedure [dbo].[procGetCvMatchSelect] Script Date: 2018/12/13 19:10:37 ******/
  10160. SET ANSI_NULLS ON
  10161. GO
  10162. SET QUOTED_IDENTIFIER ON
  10163. GO
  10164. --#####################################################
  10165. --创建时间:2014.11.03
  10166. --创建人:Nick
  10167. --说明:获取简历和职位的匹配度
  10168. --#####################################################
  10169. CREATE PROCEDURE [dbo].[procGetCvMatchSelect]
  10170. (
  10171. @CvMainID INT,
  10172. @JobID INT
  10173. )
  10174. AS
  10175. BEGIN TRY
  10176. SELECT dbo.GetCvMatch(@CvMainID,@JobID) MatchNo
  10177. END TRY
  10178. BEGIN CATCH
  10179. RETURN 0
  10180. END CATCH
  10181. GO
  10182. /****** Object: StoredProcedure [dbo].[ProcHotJobByRegionIDSelect] Script Date: 2018/12/13 19:10:38 ******/
  10183. SET ANSI_NULLS ON
  10184. GO
  10185. SET QUOTED_IDENTIFIER ON
  10186. GO
  10187. --#####################################################
  10188. --创建时间:2014.10.31
  10189. --创建人:John
  10190. --说明:根据RegionID 获取当前地区热门招聘职位
  10191. --#####################################################
  10192. CREATE PROCEDURE [dbo].[ProcHotJobByRegionIDSelect]
  10193. (
  10194. @dcRegionID VARCHAR(4)
  10195. )
  10196. AS
  10197. BEGIN
  10198. SELECT TOP 10 dcJobTypeID,AvgSalary FROM reportdb..SalaryReportJobtype WHERE dcRegionid = @dcRegionID ORDER BY JobNumber DESC
  10199. END
  10200. GO
  10201. /****** Object: StoredProcedure [dbo].[ProcHotRankingInsert] Script Date: 2018/12/13 19:10:38 ******/
  10202. SET ANSI_NULLS ON
  10203. GO
  10204. SET QUOTED_IDENTIFIER ON
  10205. GO
  10206. --sean 2014-8-14
  10207. CREATE PROCEDURE [dbo].[ProcHotRankingInsert]
  10208. AS
  10209. BEGIN
  10210. TRUNCATE TABLE SearchDb..HotRanking
  10211. DECLARE @ProvinceId INT
  10212. SET @ProvinceId = 0
  10213. WHILE EXISTS(SELECT 'x' FROM dcProvince WHERE ID > @ProvinceId)
  10214. BEGIN
  10215. SELECT TOP 1 @ProvinceId = ID FROM dcProvince WHERE ID > @ProvinceId ORDER BY ID
  10216. INSERT INTO SearchDb..HotRanking(Category, ProvinceId, ID, Title, ViewNumber_All, ResionOrder)
  10217. --SELECT TOP 10 2, @ProvinceId, a.ID, a.Title, CASE CHARINDEX(@RegionName, Title) WHEN 0 THEN 0 ELSE 1 END AS ResionOrder
  10218. SELECT TOP 10 2, @ProvinceId, a.ID, a.Title, ViewNumber_All, 0 ResionOrder
  10219. FROM QlrcNews a WITH(NOLOCK)
  10220. WHERE EXISTS(SELECT 'x' FROM fnSplit(DetailType, ',') b, dcNewsType c WITH(NOLOCK) WHERE b.a = c.id AND c.id = 2)
  10221. AND VersionID = @ProvinceId --OR VersionID = 0)
  10222. AND Type = 1
  10223. AND RefreshDate > DATEADD(MONTH, -3, GETDATE())
  10224. ORDER BY ResionOrder DESC, ViewNumber_All desc
  10225. INSERT INTO SearchDb..HotRanking(Category, ProvinceId, ID, Title, ViewNumber_All, ResionOrder)
  10226. SELECT TOP 10 1, @ProvinceId, ID, Title, ViewNumber_All, 0 ResionOrder
  10227. FROM QlrcNews a WITH(NOLOCK)
  10228. WHERE EXISTS(SELECT 'x' FROM fnSplit(DetailType, ',') b, dcNewsType c WITH(NOLOCK) WHERE b.a = c.id AND c.id <> 2)
  10229. AND VersionID = @ProvinceID --OR VersionID = 0)
  10230. AND Type = 1
  10231. AND RefreshDate > DATEADD(MONTH, -3, GETDATE())
  10232. ORDER BY ViewNumber_All desc
  10233. END
  10234. ---- '32__'
  10235. DECLARE @RegionName NVARCHAR(5)
  10236. SET @ProvinceId = 0
  10237. WHILE EXISTS(SELECT 'x' FROM dcRegion WHERE ID LIKE '32__' AND ID > @ProvinceId)
  10238. BEGIN
  10239. SELECT TOP 1 @ProvinceId = ID, @RegionName = LEFT(Description, 2)
  10240. FROM dcRegion WHERE ID LIKE '32__' AND ID > @ProvinceId ORDER BY ID
  10241. INSERT INTO SearchDb..HotRanking(Category, ProvinceId, ID, Title, ViewNumber_All, ResionOrder)
  10242. SELECT TOP 10 2, @ProvinceId, a.ID, a.Title, ViewNumber_All, CASE CHARINDEX(@RegionName, Title) WHEN 0 THEN 0 ELSE 1 END AS ResionOrder
  10243. FROM QlrcNews a WITH(NOLOCK)
  10244. WHERE EXISTS(SELECT 'x' FROM fnSplit(DetailType, ',') b, dcNewsType c WITH(NOLOCK) WHERE b.a = c.id AND c.id = 2)
  10245. AND (VersionID = 32 OR VersionID = 0)
  10246. AND Type = 1
  10247. AND RefreshDate > DATEADD(MONTH, -3, GETDATE())
  10248. ORDER BY ResionOrder DESC, ViewNumber_All desc
  10249. INSERT INTO SearchDb..HotRanking(Category, ProvinceId, ID, Title, ViewNumber_All, ResionOrder)
  10250. SELECT TOP 10 1, @ProvinceId, ID, Title, ViewNumber_All, 0 ResionOrder
  10251. FROM QlrcNews a WITH(NOLOCK)
  10252. WHERE EXISTS(SELECT 'x' FROM fnSplit(DetailType, ',') b, dcNewsType c WITH(NOLOCK) WHERE b.a = c.id AND c.id <> 2)
  10253. AND (VersionID LIKE '32%' OR VersionID = 0)
  10254. AND Type = 1
  10255. AND RefreshDate > DATEADD(MONTH, -3, GETDATE())
  10256. ORDER BY ViewNumber_All desc
  10257. END
  10258. END
  10259. GO
  10260. /****** Object: StoredProcedure [dbo].[ProcHotRankingSelect] Script Date: 2018/12/13 19:10:38 ******/
  10261. SET ANSI_NULLS ON
  10262. GO
  10263. SET QUOTED_IDENTIFIER ON
  10264. GO
  10265. -- sean 2014-8-14
  10266. CREATE PROCEDURE [dbo].[ProcHotRankingSelect]
  10267. (
  10268. @ProvinceID INT,
  10269. @Category INT
  10270. )
  10271. AS
  10272. BEGIN
  10273. IF @ProvinceID > 99 AND LEFT(@ProvinceID, 2) < '32'
  10274. SET @ProvinceID = LEFT(@ProvinceID, 2)
  10275. IF @Category > 0
  10276. BEGIN
  10277. IF @Category <> 2
  10278. SET @Category = 1
  10279. SELECT ID, Title, ResionOrder
  10280. FROM SearchDb..HotRanking WITH(NOLOCK)
  10281. WHERE ProvinceId = @ProvinceID
  10282. AND Category = @Category
  10283. ORDER BY ViewNumber_All DESC
  10284. END
  10285. ELSE
  10286. SELECT TOP 10 ID, Title, ResionOrder
  10287. FROM SearchDb..HotRanking WITH(NOLOCK)
  10288. WHERE ProvinceId = @ProvinceID
  10289. ORDER BY ViewNumber_All DESC
  10290. END
  10291. GO
  10292. /****** Object: StoredProcedure [dbo].[procHpHighSalaryJobNewSelect] Script Date: 2018/12/13 19:10:38 ******/
  10293. SET ANSI_NULLS ON
  10294. GO
  10295. SET QUOTED_IDENTIFIER ON
  10296. GO
  10297. /***
  10298. *Peter 2016-9-1
  10299. *首页高薪职位查询
  10300. *
  10301. */
  10302. CREATE PROCEDURE [dbo].[procHpHighSalaryJobNewSelect]
  10303. (
  10304. @dcSubSiteID SMALLINT
  10305. )
  10306. AS
  10307. SET NOCOUNT ON
  10308. BEGIN
  10309. SELECT TOP 10 a.*, b.dcRegionID JobRegionID, b.dcSalaryIdMax,b.Negotiable
  10310. FROM HpHighSalaryJobNew a WITH(NOLOCK), Job b WITH(NOLOCK)
  10311. WHERE a.JobID = b.ID AND a.dcRegionID = @dcSubSiteID
  10312. ORDER BY JobRefreshDate DESC, ID
  10313. END
  10314. GO
  10315. /****** Object: StoredProcedure [dbo].[procHpHighSalaryJobNewUpdate] Script Date: 2018/12/13 19:10:39 ******/
  10316. SET ANSI_NULLS ON
  10317. GO
  10318. SET QUOTED_IDENTIFIER ON
  10319. GO
  10320. CREATE PROCEDURE [dbo].[procHpHighSalaryJobNewUpdate]
  10321. AS
  10322. SET NOCOUNT ON
  10323. BEGIN
  10324. UPDATE a SET a.RefreshDate = b.RefreshDate
  10325. FROM hpHighSalaryCompanyNew a, cpMain b
  10326. WHERE a.cpMainId = b.Id AND a.RefreshDate != b.RefreshDate
  10327. UPDATE hpHighSalaryCompanyNew SET RowNo = 999 WHERE RowNo < 20
  10328. UPDATE a
  10329. SET a.RowNo = b.RowNo2
  10330. FROM hpHighSalaryCompanyNew a,
  10331. (SELECT Id, ROW_NUMBER() OVER(PARTITION BY dcRegionId ORDER BY RefreshDate DESC, cpMainId DESC) RowNo2 FROM hpHighSalaryCompanyNew WITH(NOLOCK) WHERE LogoUrl > '') b
  10332. WHERE a.id = b.Id
  10333. AND b.RowNo2 < 20
  10334. TRUNCATE TABLE HpHighSalaryJobNew;
  10335. INSERT INTO HpHighSalaryJobNew(dcRegionID, JobID, JobSecondID, JobName, CpMainID, CpSecondID, CpName, dcSalaryID, JobRefreshDate, LogoUrl)
  10336. SELECT dcRegionID, JobId, JobSecondID, JobName, CpMainID, CpSecondID, CpName, dcSalaryID, RefreshDate, LogoUrl
  10337. FROM hpHighSalaryCompanyNew
  10338. WHERE RowNo < 19
  10339. ORDER BY dcRegionId, RowNo;
  10340. IF GETDATE() < CONVERT(DATETIME, '2018-04-25')
  10341. BEGIN
  10342. IF EXISTS(SELECT 'x' FROM HpHighSalaryJobNew WITH(NOLOCK) WHERE cpMainId = 5654050)
  10343. UPDATE HpHighSalaryJobNew SET JobRefreshDate = GETDATE() + 1 WHERE cpMainId = 5654050
  10344. ELSE
  10345. INSERT INTO HpHighSalaryJobNew(dcRegionID, JobID, JobSecondID, JobName, CpMainID, CpSecondID, CpName, dcSalaryID, JobRefreshDate, LogoUrl)
  10346. SELECT dcRegionID, JobId, JobSecondID, JobName, CpMainID, CpSecondID, CpName, dcSalaryID, GETDATE() + 1, LogoUrl
  10347. FROM hpHighSalaryCompanyNew
  10348. WHERE cpMainId = 5654050
  10349. END
  10350. END
  10351. GO
  10352. /****** Object: StoredProcedure [dbo].[procHpHighSalaryJobSelect] Script Date: 2018/12/13 19:10:40 ******/
  10353. SET ANSI_NULLS ON
  10354. GO
  10355. SET QUOTED_IDENTIFIER ON
  10356. GO
  10357. /***
  10358. *Peter 2016-9-1
  10359. *首页高薪职位查询
  10360. *
  10361. */
  10362. CREATE PROCEDURE [dbo].[procHpHighSalaryJobSelect]
  10363. (
  10364. @dcSubSiteID SMALLINT
  10365. )
  10366. AS
  10367. SET NOCOUNT ON
  10368. BEGIN
  10369. SELECT a.*, b.dcRegionID JobRegionID
  10370. FROM HpHighSalaryJob a WITH(NOLOCK), Job b WITH(NOLOCK)
  10371. WHERE a.JobID = b.ID AND a.dcRegionID = @dcSubSiteID
  10372. ORDER BY ID
  10373. END
  10374. GO
  10375. /****** Object: StoredProcedure [dbo].[procHpHighSalaryJobUpdate] Script Date: 2018/12/13 19:10:40 ******/
  10376. SET ANSI_NULLS ON
  10377. GO
  10378. SET QUOTED_IDENTIFIER ON
  10379. GO
  10380. /***
  10381. *Peter 2016-9-1
  10382. *首页高薪职位更新
  10383. *
  10384. */
  10385. CREATE PROCEDURE [dbo].[procHpHighSalaryJobUpdate]
  10386. AS
  10387. SET NOCOUNT ON
  10388. BEGIN
  10389. UPDATE a SET a.RefreshDate = b.RefreshDate FROM hpHighSalaryCompany a, cpMain b WHERE a.cpMainId = b.Id AND a.RefreshDate != b.RefreshDate
  10390. UPDATE hpHighSalaryCompany SET RowNo = 0 WHERE RowNo < 20
  10391. UPDATE a
  10392. SET a.RowNo = b.RowNo2
  10393. FROM hpHighSalaryCompany a,
  10394. (SELECT Id, ROW_NUMBER() OVER(PARTITION BY dcRegionId ORDER BY RefreshDate DESC, cpMainId DESC) RowNo2 FROM hpHighSalaryCompany WITH(NOLOCK) WHERE LogoUrl > '') b
  10395. WHERE a.id = b.Id
  10396. AND b.RowNo2 < 7
  10397. UPDATE a
  10398. SET a.RowNo = 10 + b.RowNo2
  10399. FROM hpHighSalaryCompany a,
  10400. (SELECT Id, ROW_NUMBER() OVER(PARTITION BY dcRegionId ORDER BY RefreshDate DESC, cpMainId DESC) RowNo2 FROM hpHighSalaryCompany WITH(NOLOCK) WHERE RowNo = 0) b
  10401. WHERE a.id = b.Id
  10402. TRUNCATE TABLE HpHighSalaryJob
  10403. INSERT INTO hpHighSalaryJob(dcRegionID, JobID, JobSecondID, JobName, CpMainID, CpSecondID, CpName, dcSalaryID, JobRefreshDate, LogoUrl)
  10404. SELECT dcRegionID, JobId, JobSecondID, JobName, CpMainID, CpSecondID, CpName, dcSalaryID, RefreshDate, CASE WHEN RowNo < 10 THEN LogoUrl ELSE NULL END
  10405. FROM hpHighSalaryCompany
  10406. WHERE RowNo < 19
  10407. ORDER BY dcRegionId, RowNo
  10408. -- --=========================
  10409. -- CREATE TABLE #t2(
  10410. -- dcRegionId INT,
  10411. -- dcJobtypeId [varchar](4) NULL,
  10412. -- cpMainId INT,
  10413. -- cpSecondID [varchar](10) NULL,
  10414. -- ImgFile [varchar](50) NOT NULL
  10415. -- )
  10416. -- INSERT INTO #T2
  10417. -- SELECT dcRegionId, dcJobtypeId, cpMainId, cpSecondID, ImgFile
  10418. -- FROM (
  10419. -- SELECT a.dcProvinceid dcRegionId,
  10420. -- LEFT(b.dcJobTypeId, 2) dcJobtypeId,
  10421. -- a.Id cpMainId,
  10422. -- a.SecondID cpSecondID,
  10423. -- c.ImgFile,
  10424. -- ROW_NUMBER() OVER(PARTITION BY a.dcProvinceid, LEFT(b.dcJobTypeId, 2) ORDER BY a.RefreshDate DESC, a.Id DESC) Row
  10425. -- FROM cpMainPubLish a, JobPublish b, cpImage c
  10426. -- WHERE a.Id = b.cpMainId
  10427. -- AND a.Id = c.cpMainId
  10428. -- AND c.Imgtype = 1
  10429. -- AND b.RefreshDate > DATEADD(MINUTE, - 3, GETDATE())) a
  10430. -- WHERE a.Row = 1
  10431. -- ORDER BY dcRegionId, dcJobtypeId
  10432. --
  10433. -- DELETE a
  10434. -- FROM HpJobTypeCpLogo a, #T2 b
  10435. -- WHERE a.dcRegionId = b.dcRegionId AND a.dcJobtypeId = b.dcJobTypeId
  10436. --
  10437. -- INSERT INTO HpJobTypeCpLogo(dcRegionID,dcJobTypeID,CpMainID,CpSecondID,LogoUrl)
  10438. -- SELECT dcRegionID, dcJobtypeId, cpMainId,cpSecondID, ImgFile
  10439. -- FROM #T2
  10440. END
  10441. GO
  10442. /****** Object: StoredProcedure [dbo].[procHpJobNewsByDetailTypeSelect] Script Date: 2018/12/13 19:10:40 ******/
  10443. SET ANSI_NULLS ON
  10444. GO
  10445. SET QUOTED_IDENTIFIER ON
  10446. GO
  10447. --#####################################################
  10448. --创建时间:2014.11.5
  10449. --创建人:NICK
  10450. --说明:获取某类N条资讯
  10451. --#####################################################
  10452. CREATE PROCEDURE [dbo].[procHpJobNewsByDetailTypeSelect]
  10453. (
  10454. @newsNumber INT,
  10455. @detailType INT,
  10456. @provinceID INT
  10457. )
  10458. AS
  10459. BEGIN
  10460. DECLARE @SQL VARCHAR(MAX)
  10461. SET @SQL = 'SELECT TOP ' + CONVERT(VARCHAR(20),@newsNumber) + ' * '
  10462. SET @SQL = @SQL+' FROM HpJobNews WITH(NOLOCK)'
  10463. SET @SQL = @SQL+' WHERE DetailType = '+CONVERT(VARCHAR(20),@detailType)
  10464. SET @SQL = @SQL+' AND VersionId = '+CONVERT(VARCHAR(20),@provinceID)
  10465. SET @SQL = @SQL+' ORDER BY RefreshDate DESC '
  10466. EXEC(@SQL)
  10467. END
  10468. GO
  10469. /****** Object: StoredProcedure [dbo].[procHpJobTypeCpLogoSelect] Script Date: 2018/12/13 19:10:40 ******/
  10470. SET ANSI_NULLS ON
  10471. GO
  10472. SET QUOTED_IDENTIFIER ON
  10473. GO
  10474. /***
  10475. *Peter 2016-9-1
  10476. *首页职位类别Logo查询
  10477. *
  10478. */
  10479. CREATE PROCEDURE [dbo].[procHpJobTypeCpLogoSelect]
  10480. (
  10481. @dcSubSiteID SMALLINT
  10482. )
  10483. AS
  10484. SET NOCOUNT ON
  10485. BEGIN
  10486. SELECT *
  10487. FROM HpJobTypeCpLogo WITH(NOLOCK)
  10488. WHERE dcRegionID = @dcSubSiteID
  10489. END
  10490. GO
  10491. /****** Object: StoredProcedure [dbo].[procHpJobTypeinfoByRegionID24Select] Script Date: 2018/12/13 19:10:40 ******/
  10492. SET ANSI_NULLS ON
  10493. GO
  10494. SET QUOTED_IDENTIFIER ON
  10495. GO
  10496. --#####################################################
  10497. --创建时间:2014.11.03
  10498. --创建人:Nick
  10499. --说明:根据职位数量获取最多的职位类别
  10500. --#####################################################
  10501. CREATE PROCEDURE [dbo].[procHpJobTypeinfoByRegionID24Select]
  10502. (
  10503. @dcRegionID INT
  10504. )
  10505. AS
  10506. BEGIN TRY
  10507. SELECT TOP 24 dcJobTypeID,Description
  10508. FROM hpJobTypeInfo a, dcJobType b
  10509. WHERE a.dcJobTypeID=b.ID
  10510. AND a.dcRegionID=@dcRegionID
  10511. AND LEN(dcJobTypeID) = 4
  10512. ORDER BY JobNum DESC
  10513. END TRY
  10514. BEGIN CATCH
  10515. RETURN 0
  10516. END CATCH
  10517. GO
  10518. /****** Object: StoredProcedure [dbo].[procHpJobTypeinfoByRegionIDSelect] Script Date: 2018/12/13 19:10:42 ******/
  10519. SET ANSI_NULLS ON
  10520. GO
  10521. SET QUOTED_IDENTIFIER ON
  10522. GO
  10523. --#####################################################
  10524. --创建时间:2014.11.03
  10525. --创建人:Nick
  10526. --说明:添加获取职位类型左侧导航数据
  10527. --修改:harry2015-8-18
  10528. --增加c.orderNo
  10529. --#####################################################
  10530. CREATE PROCEDURE [dbo].[procHpJobTypeinfoByRegionIDSelect]
  10531. (
  10532. @dcRegionID INT
  10533. )
  10534. AS
  10535. BEGIN
  10536. SELECT TOP 1000 a.dcJobTypeId JobTypeID,a.JobNum JobNumber,b.CategoryId,c.parentID,c.grade,
  10537. c.description,c.parentID2,c.parentID3,c.OrderNo
  10538. FROM hpjobtypeinfo a
  10539. LEFT JOIN dcJobTypeMap b ON b.JobTypeId=a.dcJobtypeid
  10540. LEFT JOIN dcJobType c ON c.id=a.dcJobTypeid
  10541. WHERE a.dcRegionID = @dcRegionID
  10542. ORDER BY c.OrderNo,b.OrderBy
  10543. END
  10544. GO
  10545. /****** Object: StoredProcedure [dbo].[procHpJobTypeInfoUpdate] Script Date: 2018/12/13 19:10:42 ******/
  10546. SET ANSI_NULLS ON
  10547. GO
  10548. SET QUOTED_IDENTIFIER ON
  10549. GO
  10550. /**
  10551. *创建 Peter
  10552. *时间 2013-01-09 15:51
  10553. *作用 首页左侧职位索引区域职位数量更新
  10554. **/
  10555. CREATE PROCEDURE [dbo].[procHpJobTypeInfoUpdate]
  10556. AS
  10557. SET NOCOUNT ON
  10558. BEGIN
  10559. TRUNCATE TABLE LogDb..hpJobTypeInfo
  10560. CREATE TABLE #T(
  10561. dcJobTypeID INT,
  10562. dcRegionID INT,
  10563. JobNum INT
  10564. )
  10565. DELETE hpJobTypeInfo WHERE dcRegionId NOT IN(SELECT ID FROM dcSubSite)
  10566. DELETE hpJobTypeInfo WHERE dcJobTypeId NOT IN(SELECT ID FROM dcJobType)
  10567. INSERT INTO #T SELECT a.ID, b.Id, 0 FROM dcJobType a, dcSubSite b
  10568. DELETE #t FROM hpJobTypeInfo a WHERE #t.dcJobTypeId = a.dcJobTypeId AND a.dcRegionId = #t.dcRegionId
  10569. INSERT hpJobTypeInfo SELECT dcJobTypeID, dcRegionID, 0, GETDATE() FROM #t
  10570. TRUNCATE TABLE #t
  10571. INSERT INTO #T
  10572. SELECT dcJobTypeId, LEFT(dcRegionId, 4), COUNT(*)
  10573. FROM JobPublish WITH(NOLOCK)
  10574. WHERE Valid = 1
  10575. GROUP BY dcJobTypeId, LEFT(dcRegionId, 4)
  10576. SELECT LEFT(dcJobTypeId, 2) dcJobTypeID, dcRegionID, SUM(JobNum) JobNum
  10577. INTO #tt
  10578. FROM #t
  10579. GROUP BY LEFT(dcJobTypeId, 2), dcRegionID
  10580. DELETE #t WHERE dcJobTypeId < 99
  10581. INSERT #t SELECT * FROM #tt
  10582. TRUNCATE TABLE #tt
  10583. INSERT INTO #tt
  10584. SELECT dcJobTypeId, LEFT(dcRegionID, 2), SUM(JobNum) JobNum
  10585. FROM #t
  10586. GROUP BY dcJobTypeId, LEFT(dcRegionID, 2)
  10587. DELETE #t WHERE dcRegionId < 99
  10588. INSERT #t SELECT * FROM #tt
  10589. UPDATE hpJobTypeInfo SET JobNum = 0
  10590. UPDATE a
  10591. SET a.ModifyDate = GETDATE(), a.JobNum = b.JobNum
  10592. FROM hpJobTypeInfo a, #t b
  10593. WHERE a.dcRegionId = b.dcRegionId AND a.dcJobTypeId = b.dcJobTypeId
  10594. DROP TABLE #T
  10595. DROP TABLE #TT
  10596. END
  10597. GO
  10598. /****** Object: StoredProcedure [dbo].[prochpNewsSetByProvinceIDSelect] Script Date: 2018/12/13 19:10:42 ******/
  10599. SET ANSI_NULLS ON
  10600. GO
  10601. SET QUOTED_IDENTIFIER ON
  10602. GO
  10603. --#####################################################
  10604. --创建时间:2014.11.03
  10605. --创建人:Nick
  10606. --说明:取新首页职场新闻模块的显示
  10607. --#####################################################
  10608. CREATE PROCEDURE [dbo].[prochpNewsSetByProvinceIDSelect]
  10609. (
  10610. @ProvinceID INT
  10611. )
  10612. AS
  10613. BEGIN TRY
  10614. SELECT Section FROM hpNewsSet WHERE dcProvinceID=@ProvinceID
  10615. END TRY
  10616. BEGIN CATCH
  10617. RETURN 0
  10618. END CATCH
  10619. GO
  10620. /****** Object: StoredProcedure [dbo].[prociIvgt_AnswerSumByQuestionIDSelect] Script Date: 2018/12/13 19:10:42 ******/
  10621. SET ANSI_NULLS ON
  10622. GO
  10623. SET QUOTED_IDENTIFIER ON
  10624. GO
  10625. --#####################################################
  10626. --创建时间:2014.11.10
  10627. --创建人:NICK
  10628. --说明:获得调查的点击总数
  10629. --#####################################################
  10630. CREATE PROCEDURE [dbo].[prociIvgt_AnswerSumByQuestionIDSelect]
  10631. (
  10632. @QuesionID INT
  10633. )
  10634. AS
  10635. BEGIN
  10636. SELECT SUM(clicknum) cnt FROM ivgt_answer WITH(NOLOCK) WHERE questionid=@QuesionID
  10637. END
  10638. GO
  10639. /****** Object: StoredProcedure [dbo].[ProcIncludeRateSelect] Script Date: 2018/12/13 19:10:43 ******/
  10640. SET ANSI_NULLS ON
  10641. GO
  10642. SET QUOTED_IDENTIFIER ON
  10643. GO
  10644. CREATE PROCEDURE [dbo].[ProcIncludeRateSelect]
  10645. (
  10646. @ProvinceID INT, ----网站省份编号
  10647. @CatalogID INT, ----目录编号(1、职位页面;2、公司页面;3、招聘会页面4、求职互助页面;5、职场新闻页面;6、职位地图页面;7、校园招聘页面)
  10648. @GenerateStartDate DATETIME, ----生成开始时间
  10649. @GenerateEndDate DATETIME, ----生成结束时间
  10650. @FlashStartDate DATETIME, ----刷新开始时间
  10651. @FlashEndDate DATETIME, ----刷新结束时间
  10652. @Percentage DECIMAL(18, 4), ----百分比 (例0.1 百分之十)
  10653. @SortID INT, -----排序 (1、正序;2、倒序;3、随机)
  10654. @Type INT ------0,存储过程返回页面的数量;1、返回页面信息
  10655. )
  10656. AS
  10657. BEGIN
  10658. DECLARE @t AS TABLE(ID INT, Date DATETIME, Rnd VARCHAR(100))
  10659. DECLARE @Cnt AS INT, @p AS VARCHAR(4)
  10660. SELECT @GenerateStartDate = ISNULL(@GenerateStartDate, '2000-1-1'),
  10661. @GenerateEndDate = ISNULL(@GenerateEndDate, GETDATE()),
  10662. @FlashStartDate = ISNULL(@GenerateStartDate, '2000-1-1'),
  10663. @FlashEndDate = ISNULL(@GenerateEndDate, GETDATE()),
  10664. @p = CONVERT(VARCHAR, @ProvinceID)
  10665. IF (@CatalogID = 1)
  10666. BEGIN
  10667. INSERT INTO @t(ID, Date)
  10668. SELECT ID, RefreshDate FROM Job WITH(NOLOCK)
  10669. WHERE AddDate BETWEEN @GenerateStartDate AND @GenerateEndDate
  10670. AND RefreshDate BETWEEN @FlashStartDate AND @FlashEndDate
  10671. AND cpMainID IN(SELECT ID FROM cpMain WITH(NOLOCK) WHERE dcSUbSiteId LIKE @p + '%')
  10672. END
  10673. ELSE IF (@CatalogID = 2)
  10674. BEGIN
  10675. INSERT INTO @t(ID, Date)
  10676. SELECT ID, RefreshDate FROM cpMain WITH(NOLOCK)
  10677. WHERE RegDate BETWEEN @GenerateStartDate - 2 AND @GenerateEndDate - 2
  10678. AND RefreshDate BETWEEN @FlashStartDate AND @FlashEndDate
  10679. AND MemberType > 0
  10680. AND dcSubSiteId LIKE @p + '%'
  10681. END
  10682. ELSE IF (@CatalogID = 3)
  10683. BEGIN
  10684. INSERT INTO @t(ID, Date)
  10685. SELECT ID, AddDate FROM RecruitMent WITH(NOLOCK)
  10686. WHERE AddDate BETWEEN @GenerateStartDate AND @GenerateEndDate
  10687. AND CityId LIKE @p + '%'
  10688. END
  10689. ELSE IF (@CatalogID = 4)
  10690. BEGIN
  10691. INSERT INTO @t(ID, Date)
  10692. SELECT ID, AddDate FROM bsAskInfo WITH(NOLOCK)
  10693. WHERE AddDate BETWEEN @GenerateStartDate AND @GenerateEndDate
  10694. AND ProvinceIds LIKE '%,%' + @p + ',%'
  10695. END
  10696. ELSE IF (@CatalogID = 5)
  10697. BEGIN
  10698. INSERT INTO @t(ID, Date)
  10699. SELECT ID, AnnounceDate FROM QlrcNews WITH(NOLOCK)
  10700. WHERE AnnounceDate BETWEEN @GenerateStartDate AND @GenerateEndDate
  10701. AND VersionId LIKE @p + '%'
  10702. END
  10703. SELECT @Cnt = COUNT(*) FROM @t
  10704. IF @Cnt = 0
  10705. BEGIN
  10706. SELECT 0
  10707. RETURN
  10708. END
  10709. ELSE IF @Type = 0 OR @Percentage = 0
  10710. SELECT @Cnt
  10711. ELSE
  10712. BEGIN
  10713. DECLARE @FetchNumber AS INT
  10714. SELECT @FetchNumber = @Cnt * @Percentage
  10715. IF @FetchNumber = 0
  10716. BEGIN
  10717. SELECT 0
  10718. RETURN
  10719. END
  10720. IF @SortID = 3 ----随机
  10721. BEGIN
  10722. UPDATE @t SET Rnd = NewId()
  10723. SELECT TOP (@FetchNumber) ID FROM @t ORDER BY Rnd
  10724. END
  10725. ELSE
  10726. BEGIN
  10727. IF @CatalogID IN(1, 2) AND @FlashStartDate > '2001-1-1'
  10728. BEGIN
  10729. IF @SortID = 1
  10730. SELECT TOP (@FetchNumber) ID FROM @t ORDER BY Date
  10731. IF @SortID = 2
  10732. SELECT TOP (@FetchNumber) ID FROM @t ORDER BY Date DESC
  10733. END
  10734. ELSE
  10735. BEGIN
  10736. IF @SortID = 1 ----正序
  10737. SELECT TOP (@FetchNumber) ID FROM @t ORDER BY ID
  10738. IF @SortID = 2 ----倒序
  10739. SELECT TOP (@FetchNumber) ID FROM @t ORDER BY ID DESC
  10740. END
  10741. END
  10742. END
  10743. END
  10744. GO
  10745. /****** Object: StoredProcedure [dbo].[procInfo_datereportUpdate] Script Date: 2018/12/13 19:10:43 ******/
  10746. SET ANSI_NULLS ON
  10747. GO
  10748. SET QUOTED_IDENTIFIER ON
  10749. GO
  10750. CREATE PROCEDURE [dbo].[procInfo_datereportUpdate]
  10751. (
  10752. @province_id SMALLINT,
  10753. @infomanager_id SMALLINT,
  10754. @ip VARCHAR(15),
  10755. @referer VARCHAR(100),
  10756. @result SMALLINT OUTPUT
  10757. )
  10758. AS
  10759. BEGIN
  10760. SET NOCOUNT ON
  10761. SELECT TOP 1 countdate
  10762. FROM info_datereport WITH(NOLOCK)
  10763. WHERE countdate=YEAR(GETDATE())*10000+MONTH(GETDATE())*100+DAY(GETDATE())
  10764. AND province_id = @province_id
  10765. AND infomanager_id=@infomanager_id
  10766. IF (@@ROWCOUNT=0)
  10767. BEGIN
  10768. INSERT INTO info_datereport (province_id,infomanager_id,countdate)
  10769. VALUES(@province_id,@infomanager_id,YEAR(GETDATE())*10000+MONTH(GETDATE())*100+day(GETDATE()))
  10770. END
  10771. SELECT TOP 1 adddate
  10772. FROM infolog WITH(NOLOCK)
  10773. WHERE adddate > GETDATE()-1
  10774. AND infomanager_id = @infomanager_id
  10775. AND ip = @ip
  10776. AND Ip NOT LIKE '60.215.144%'
  10777. IF (@@ROWCOUNT=0)
  10778. BEGIN
  10779. UPDATE info_datereport SET homepage = homepage + 1
  10780. WHERE countdate=YEAR(GETDATE())*10000+MONTH(GETDATE())*100+DAY(GETDATE())
  10781. AND province_id = @province_id
  10782. AND infomanager_id=@infomanager_id
  10783. INSERT INTO infolog (infomanager_id,ip,referer) VALUES(@infomanager_id,@ip,@referer)
  10784. SET @result=1
  10785. END
  10786. ELSE
  10787. BEGIN
  10788. SET @result=0
  10789. END
  10790. --PRINT @result
  10791. SET NOCOUNT OFF
  10792. END
  10793. GO
  10794. /****** Object: StoredProcedure [dbo].[ProcInfoLogInsert] Script Date: 2018/12/13 19:10:44 ******/
  10795. SET ANSI_NULLS ON
  10796. GO
  10797. SET QUOTED_IDENTIFIER ON
  10798. GO
  10799. --#####################################################
  10800. --创建时间:2014.10.31
  10801. --创建人:John
  10802. --说明:新增InfoLog
  10803. --#####################################################
  10804. CREATE PROCEDURE [dbo].[ProcInfoLogInsert]
  10805. (
  10806. @InfoId SMALLINT,
  10807. @IP VARCHAR(15),
  10808. @Source VARCHAR(200),
  10809. @SubSiteID SMALLINT
  10810. )
  10811. AS
  10812. BEGIN
  10813. INSERT INTO reportdb..InfoLog(InfoId,IP,Source,SubSiteID,AddDate) VALUES(@InfoId,@IP,@Source,@SubSiteID,GETDATE())
  10814. END
  10815. GO
  10816. /****** Object: StoredProcedure [dbo].[ProcInfoSetByKeySelect] Script Date: 2018/12/13 19:10:44 ******/
  10817. SET ANSI_NULLS ON
  10818. GO
  10819. SET QUOTED_IDENTIFIER ON
  10820. GO
  10821. --#####################################################
  10822. --创建时间:2014.10.31
  10823. --创建人:John
  10824. --说明:根据Key查InfoSet
  10825. --#####################################################
  10826. CREATE PROCEDURE [dbo].[ProcInfoSetByKeySelect]
  10827. (
  10828. @InfoKey VARCHAR(200)
  10829. )
  10830. AS
  10831. BEGIN
  10832. SELECT * FROM reportdb..InfoSet WITH(NOLOCK) WHERE InfoKey = @InfoKey
  10833. END
  10834. GO
  10835. /****** Object: StoredProcedure [dbo].[procInnererInsert] Script Date: 2018/12/13 19:10:44 ******/
  10836. SET ANSI_NULLS ON
  10837. GO
  10838. SET QUOTED_IDENTIFIER ON
  10839. GO
  10840. CREATE PROCEDURE [dbo].[procInnererInsert]
  10841. (
  10842. @province_id SMALLINT,
  10843. @VersionID SMALLINT,
  10844. @referer VARCHAR(190),
  10845. @ip VARCHAR(15),
  10846. @keyve NVARCHAR(50),
  10847. @innerpage SMALLINT
  10848. )
  10849. AS
  10850. BEGIN
  10851. SET NOCOUNT ON
  10852. SELECT TOP 1 ip
  10853. FROM Innerer WITH(INDEX=IX_Innerer_VersionID, NOLOCK)
  10854. WHERE VersionID = @VersionID
  10855. AND referer=@referer
  10856. AND ip=@ip
  10857. AND LoginDate > DATEADD(MINUTE, -10, GETDATE())
  10858. IF (@@ROWCOUNT = 0)
  10859. BEGIN
  10860. INSERT INTO Innerer(province_id,VersionID,referer,ip,keywords,innerpage)
  10861. VALUES(ISNULL(@province_id, 0), ISNULL(@VersionID, 0),@referer,@ip,@keyve,@innerpage)
  10862. END
  10863. SET NOCOUNT OFF
  10864. END
  10865. GO
  10866. /****** Object: StoredProcedure [dbo].[ProcInterViewByCpMainIDSelect] Script Date: 2018/12/13 19:10:44 ******/
  10867. SET ANSI_NULLS ON
  10868. GO
  10869. SET QUOTED_IDENTIFIER ON
  10870. GO
  10871. --#####################################################
  10872. --创建时间:2014.11.20
  10873. --创建人:Nick
  10874. --说明:根据公司ID获取 面试经历信息,以及平均分
  10875. --#####################################################
  10876. CREATE PROCEDURE [dbo].[ProcInterViewByCpMainIDSelect]
  10877. (
  10878. @CpMainID INT,
  10879. @SessionID VARCHAR(50),
  10880. @PamainID INT
  10881. )
  10882. AS
  10883. BEGIN
  10884. IF @PamainID <> 0
  10885. BEGIN
  10886. SELECT * FROM InterView
  10887. WHERE CpMainID = @CpMainID
  10888. AND InterViewType<>3
  10889. AND (VerifyDate IS NOT NULL OR PaMainID = @PamainID)
  10890. ORDER BY ADDDATE DESC
  10891. END
  10892. ELSE
  10893. BEGIN
  10894. -- IF @SessionID<>''
  10895. -- BEGIN
  10896. -- SELECT * FROM InterView
  10897. -- WHERE CpMainID = @CpMainID
  10898. -- AND InterViewType<>3
  10899. -- AND (VerifyDate IS NOT NULL OR (PaMainID = 0 AND SessionID = @SessionID))
  10900. -- ORDER BY ADDDATE DESC
  10901. -- END
  10902. -- ELSE
  10903. -- BEGIN
  10904. SELECT * FROM InterView
  10905. WHERE CpMainID = @CpMainID
  10906. AND InterViewType<>3
  10907. AND VerifyDate IS NOT NULL
  10908. ORDER BY ADDDATE DESC
  10909. -- END
  10910. END
  10911. End
  10912. GO
  10913. /****** Object: StoredProcedure [dbo].[ProcInterViewByID] Script Date: 2018/12/13 19:10:44 ******/
  10914. SET ANSI_NULLS ON
  10915. GO
  10916. SET QUOTED_IDENTIFIER ON
  10917. GO
  10918. --#####################################################
  10919. --创建时间:2014.11.24
  10920. --创建人:Nick
  10921. --说明:根据ID获取面试经历信息
  10922. --#####################################################
  10923. CREATE PROCEDURE [dbo].[ProcInterViewByID]
  10924. (
  10925. @ID INT
  10926. )
  10927. AS
  10928. BEGIN
  10929. SELECT * FROM InterView WHERE ID = @ID
  10930. End
  10931. GO
  10932. /****** Object: StoredProcedure [dbo].[ProcInterviewByIDUpdate] Script Date: 2018/12/13 19:10:45 ******/
  10933. SET ANSI_NULLS ON
  10934. GO
  10935. SET QUOTED_IDENTIFIER ON
  10936. GO
  10937. --#####################################################
  10938. --创建时间:2014.11.19
  10939. --创建人:Nick
  10940. --说明:根据ID修改面试信息
  10941. --#####################################################
  10942. CREATE PROCEDURE [dbo].[ProcInterviewByIDUpdate]
  10943. (
  10944. @ID INT,
  10945. @JobName VARCHAR(50),
  10946. @InterviewDate VARCHAR(6),
  10947. @InterViewResult INT,
  10948. @SalaryMonth INT,
  10949. @InterViewExperience NVARCHAR(MAX),
  10950. @InterviewFeeling NVARCHAR(MAX),
  10951. @Title NVARCHAR(50),
  10952. @VerifyMan INT,
  10953. @InterviewType INT
  10954. )
  10955. AS
  10956. SET NOCOUNT ON
  10957. BEGIN TRY
  10958. DECLARE @AddDate DATETIME,@CpName NVARCHAR(100),@Title2 NVARCHAR(50)
  10959. SELECT @AddDate = a.AddDate,@CpName = b.Name,@Title2 = a.Title
  10960. FROM Interview a,Cpmain b
  10961. WHERE a.ID = @ID
  10962. AND a.CpMainID = b.ID
  10963. UPDATE Interview
  10964. SET JobName = @JobName,
  10965. InterviewDate = @InterviewDate,
  10966. InterViewResult = @InterViewResult,
  10967. SalaryMonth = @SalaryMonth,
  10968. InterViewExperience = @InterViewExperience,
  10969. InterviewFeeling = @InterviewFeeling,
  10970. Title = @Title,
  10971. VerifyMan = @VerifyMan,
  10972. VerifyDate = GETDATE(),
  10973. InterviewType = @InterviewType
  10974. WHERE CpMainID IN (SELECT ID FROM cpMain WITH(NOLOCK) WHERE Name = @CpName)
  10975. AND AddDate = @AddDate
  10976. AND Title = @Title2
  10977. END TRY
  10978. BEGIN CATCH
  10979. RETURN 0
  10980. END CATCH
  10981. GO
  10982. /****** Object: StoredProcedure [dbo].[ProcInterViewByKeyWordSelect] Script Date: 2018/12/13 19:10:45 ******/
  10983. SET ANSI_NULLS ON
  10984. GO
  10985. SET QUOTED_IDENTIFIER ON
  10986. GO
  10987. --###########################
  10988. --创建时间:2014.11.27
  10989. --创建人:Nick
  10990. --说明:获取面试经历公司列表
  10991. --###########################
  10992. CREATE PROCEDURE [dbo].[ProcInterViewByKeyWordSelect]
  10993. (
  10994. @dcRegionID VARCHAR(100),
  10995. @PageNo INT,
  10996. @KeyWord VARCHAR(50)
  10997. )
  10998. AS
  10999. BEGIN
  11000. DECLARE @WHERE VARCHAR(MAX),@JobPlace AS VARCHAR(2000),@WHERE2 VARCHAR(MAX)
  11001. SET @JobPlace = ''
  11002. SET @WHERE = ''
  11003. SET @WHERE2 = ''
  11004. IF CHARINDEX(',',@dcRegionID)>0
  11005. BEGIN
  11006. DECLARE @T_JobPlace AS TABLE(ID INT)
  11007. INSERT INTO @T_JobPlace
  11008. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  11009. SELECT @JobPlace = (@JobPlace + ' OR b.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  11010. IF LEN(@JobPlace) > 0
  11011. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  11012. SET @WHERE = @WHERE + '
  11013. AND (' + @JobPlace + ')'
  11014. SET @WHERE2 = @WHERE2 + '
  11015. AND (' + @JobPlace + ')'
  11016. END
  11017. ELSE
  11018. BEGIN
  11019. SET @WHERE = ' AND (b.dcRegionID Like '''+@dcRegionID+'%'')'
  11020. SET @WHERE2 = ' AND (b.dcRegionID Like '''+@dcRegionID+'%'')'
  11021. END
  11022. SET @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, ''))
  11023. IF @KeyWord <> ''
  11024. BEGIN
  11025. SET @WHERE = @WHERE + ' AND b.Name LIKE ''%'+@KeyWord+'%'' '
  11026. END
  11027. DECLARE @PageSize INT
  11028. SET @PageSize = 5
  11029. DECLARE @PageLowerBound INT --定义此页的底码
  11030. DECLARE @PageUpperBound INT --定义此页的顶码
  11031. SET @PageLowerBound = (@PageNo -1) * @pagesize
  11032. SET @PageUpperBound = @PageLowerBound + @pagesize
  11033. DECLARE @AllCnt INT
  11034. SET @AllCnt = 0
  11035. DECLARE @SQL NVARCHAR(MAX)
  11036. --创建临时表
  11037. CREATE TABLE #T1(
  11038. [cpmainid] [int] NOT NULL,
  11039. [name] [varchar](100) NULL,
  11040. [secondid] varchar(12) NULL,
  11041. [AddDate] [datetime] NULL,
  11042. [OrderBY] [int] NULL
  11043. )
  11044. IF @KeyWord = ''
  11045. BEGIN
  11046. SET @SQL = '
  11047. INSERT INTO #T1
  11048. SELECT TOP 500 cpmainid,b.name,b.secondid,a.AddDate,1 AS OrderBY
  11049. FROM InterView a,cpmain b
  11050. WHERE a.id IN(SELECT MAX(id) FROM InterView GROUP BY cpmainid)
  11051. AND b.valid=1
  11052. AND IsDirect=1
  11053. AND a.cpmainid = b.id AND a.InterViewType IN(1,2) '+@WHERE+'
  11054. ORDER BY a.adddate DESC '
  11055. EXEC(@SQL)
  11056. END
  11057. ELSE
  11058. BEGIN
  11059. SET @SQL = '
  11060. INSERT INTO #T1
  11061. SELECT TOP 500 b.ID AS cpmainid,b.Name, b.SecondId, LastLoginDate AS AddDate,1 AS OrderBY
  11062. FROM cpMainPublish b WITH(NOLOCK),
  11063. CONTAINSTABLE(cpMainPublish, Name, '''+@KeyWord+''', 100) AS a
  11064. WHERE b.Id = a.[Key] '+@WHERE2+'
  11065. AND b.valid=1
  11066. ORDER BY b. LastLoginDate DESC '
  11067. PRINT(@SQL)
  11068. EXEC(@SQL)
  11069. IF NOT EXISTS(SELECT 'x' FROM #T1)
  11070. BEGIN
  11071. SET @SQL = '
  11072. INSERT INTO #T1
  11073. SELECT TOP 500 b.ID AS cpmainid,b.Name, b.SecondId, LastLoginDate AS AddDate,1 AS OrderBY
  11074. FROM cpMainPublish b WITH(NOLOCK INDEX(IX_cpMainPublish_Name))
  11075. WHERE 1=1 '+@WHERE+'
  11076. AND b.valid=1
  11077. ORDER BY b. LastLoginDate DESC '
  11078. PRINT(@SQL)
  11079. EXEC(@SQL)
  11080. END
  11081. END
  11082. DELETE FROM #T1 WHERE cpmainid NOT IN (SELECT Max(cpMainID) FROM #T1 GROUP BY name)
  11083. SELECT @AllCnt = COUNT(*) FROM #T1
  11084. IF @KeyWord <> '' --对临时表 #T1 进行排序 修改最后点评时间
  11085. BEGIN
  11086. UPDATE a
  11087. SET a.AddDate = b.AddDate,a.OrderBY = b.OrderBY
  11088. FROM #T1 a,(
  11089. SELECT AddDate,CpMainID,2 AS OrderBy
  11090. FROM InterView
  11091. WHERE ID IN(SELECT MAX(id) FROM InterView GROUP BY cpmainid)
  11092. ) b
  11093. WHERE a.CpmainID = b.CpMainID
  11094. END
  11095. SELECT * ,ROW_NUMBER() OVER( ORDER BY OrderBY DESC,AddDate DESC) AS num INTO #T2 FROM #T1
  11096. SELECT *,0 AS cnt,0 AS Score INTO #T3 FROM #T2 WHERE NUM > @PageLowerBound AND NUM <= @PageUpperBound
  11097. --修改评价数量
  11098. UPDATE a
  11099. SET a.cnt = b.Num
  11100. FROM #T3 a,(
  11101. SELECT COUNT(*) AS num,CpMainID
  11102. FROM InterView
  11103. WHERE (InterViewType IN (1,2))
  11104. AND CpMainID IN (SELECT CpMainID FROM #T3)
  11105. GROUP BY CpMainID
  11106. )b
  11107. WHERE a.CpMainID = b.CpMainID
  11108. --拷贝列
  11109. CREATE TABLE #T5(
  11110. [ID] [int] NOT NULL,
  11111. [CpmainID] [int] NOT NULL,
  11112. [PaMainID] [int] NOT NULL,
  11113. [IP] [varchar](15) NOT NULL,
  11114. [SessionID] [varchar](50) NULL,
  11115. [JobName] [varchar](50) NOT NULL,
  11116. [InterviewDate] [varchar](6) NOT NULL,
  11117. [InterViewResult] [tinyint] NOT NULL,
  11118. [SalaryMonth] [int] NULL,
  11119. [InterViewExperience] [nvarchar](max) NOT NULL,
  11120. [InterviewFeeling] [nvarchar](max) NOT NULL,
  11121. [Title] [nvarchar](50) NOT NULL,
  11122. [AddDate] [smalldatetime] NULL,
  11123. [VerifyMan] [int] NULL,
  11124. [VerifyDate] [smalldatetime] NULL,
  11125. [InterviewType] [int] NULL,
  11126. [ReplyDate] [smalldatetime] NULL,
  11127. [ReplyContent] [nvarchar](max) NULL,
  11128. [ReplyVerifyMan] [int] NULL,
  11129. [ReplyVerifyDate] [smalldatetime] NULL,
  11130. [ReplyVerifyResult] [tinyint] NULL,
  11131. [PraiseCount] [int] NULL,
  11132. [LoginPraiseCount] [int] NULL,
  11133. [IsDirect] [BIT] NULL,
  11134. [rid] [int] NULL
  11135. )
  11136. DECLARE @CpCnt INT --公司数量
  11137. SELECT @CpCnt = COUNT(*) FROM #T3
  11138. IF @CpCnt = 1
  11139. BEGIN
  11140. --取10条点评
  11141. INSERT INTO #T5
  11142. SELECT * FROM
  11143. (
  11144. SELECT *,rid=ROW_NUMBER() OVER(PARTITION BY a.CpmainID ORDER BY a.AddDate DESC)
  11145. FROM InterView a
  11146. WHERE (a.InterViewType IN (1,2))
  11147. AND CpMainID IN (SELECT CpMainID FROM #T3)
  11148. ) AS c
  11149. WHERE c.rid<=10
  11150. END
  11151. ELSE
  11152. BEGIN
  11153. --取2条点评
  11154. INSERT INTO #T5
  11155. SELECT * FROM
  11156. (
  11157. SELECT *,rid=ROW_NUMBER() OVER(PARTITION BY a.CpmainID ORDER BY a.AddDate DESC)
  11158. FROM InterView a
  11159. WHERE (a.InterViewType IN (1,2))
  11160. AND CpMainID IN (SELECT CpMainID FROM #T3)
  11161. ) AS c
  11162. WHERE c.rid<=2
  11163. END
  11164. SELECT * FROM #T3 --公司列表
  11165. SELECT @AllCnt --所有公司数
  11166. SELECT * FROM #T5 --点评数
  11167. DROP TABLE #T5
  11168. END
  11169. GO
  11170. /****** Object: StoredProcedure [dbo].[ProcInterViewByReplyUpdate] Script Date: 2018/12/13 19:10:45 ******/
  11171. SET ANSI_NULLS ON
  11172. GO
  11173. SET QUOTED_IDENTIFIER ON
  11174. GO
  11175. --#####################################################
  11176. --创建时间:2014.11.20
  11177. --创建人:Nick
  11178. --说明:面试经历回复
  11179. --#####################################################
  11180. CREATE PROCEDURE [dbo].[ProcInterViewByReplyUpdate]
  11181. (
  11182. @ID INT,
  11183. @ReplyContent NVARCHAR(MAX)
  11184. )
  11185. AS
  11186. BEGIN
  11187. UPDATE InterView
  11188. SET ReplyContent = @ReplyContent,
  11189. ReplyDate = GETDATE() ,
  11190. ReplyVerifyResult = NULL ,
  11191. ReplyVerifyDate = NULL
  11192. WHERE ID = @ID
  11193. AND (ReplyVerifyResult <> 1 OR ReplyVerifyResult IS NULL)
  11194. End
  11195. GO
  11196. /****** Object: StoredProcedure [dbo].[ProcInterViewCompanyListSelect] Script Date: 2018/12/13 19:10:45 ******/
  11197. SET ANSI_NULLS ON
  11198. GO
  11199. SET QUOTED_IDENTIFIER ON
  11200. GO
  11201. --#####################################################
  11202. --创建时间:2014.11.27
  11203. --创建人:Nick
  11204. --说明:获取面试经历公司列表
  11205. --#####################################################
  11206. CREATE PROCEDURE [dbo].[ProcInterViewCompanyListSelect]
  11207. (
  11208. @dcRegionID VARCHAR(100),
  11209. @PageNo INT,
  11210. @KeyWord VARCHAR(50)
  11211. )
  11212. AS
  11213. BEGIN TRY
  11214. DECLARE @WHERE VARCHAR(MAX),@JobPlace AS VARCHAR(2000)
  11215. SET @JobPlace = ''
  11216. SET @WHERE = ''
  11217. IF CHARINDEX(',',@dcRegionID)>0
  11218. BEGIN
  11219. DECLARE @T_JobPlace AS TABLE(ID INT)
  11220. INSERT INTO @T_JobPlace
  11221. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  11222. SELECT @JobPlace = (@JobPlace + ' OR b.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  11223. IF LEN(@JobPlace) > 0
  11224. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  11225. SET @WHERE = @WHERE + '
  11226. AND (' + @JobPlace + ')'
  11227. END
  11228. ELSE
  11229. BEGIN
  11230. SET @WHERE = ' AND (b.dcRegionID Like '''+@dcRegionID+'%'')'
  11231. END
  11232. SET @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, ''))
  11233. IF @KeyWord <> ''
  11234. BEGIN
  11235. SET @WHERE = @WHERE+' AND b.Name LIKE ''%'+@KeyWord+'%'' '
  11236. END
  11237. DECLARE @PageSize INT
  11238. SET @PageSize = 5
  11239. DECLARE @PageLowerBound INT --定义此页的底码
  11240. DECLARE @PageUpperBound INT --定义此页的顶码
  11241. SET @PageLowerBound = (@PageNo -1) * @pagesize
  11242. SET @PageUpperBound = @PageLowerBound + @pagesize
  11243. DECLARE @AllCnt INT
  11244. SET @AllCnt = 0
  11245. DECLARE @SQL NVARCHAR(MAX)
  11246. SET @SQL = N'
  11247. SELECT @All = COUNT(DISTINCT CpMainID)
  11248. FROM InterView a,Cpmain b
  11249. WHERE (a.InterViewType IN (1,2))
  11250. AND a.id IN(SELECT MAX(id) FROM InterView GROUP BY cpmainid)
  11251. AND a.CpMainID = b.ID
  11252. '+@WHERE
  11253. print('123')
  11254. exec sp_executesql @SQL,N'@All INT output',@AllCnt output
  11255. IF @AllCnt>500
  11256. BEGIN
  11257. SET @AllCnt = 500
  11258. END
  11259. SET @SQL = '
  11260. SELECT TOP 500 cpmainid,b.name,b.secondid,a.AddDate INTO ##T1
  11261. FROM InterView a,cpmain b
  11262. WHERE a.id IN(SELECT MAX(id) FROM InterView GROUP BY cpmainid)
  11263. AND a.cpmainid = b.id AND a.InterViewType IN (1,2)'+@WHERE+'
  11264. ORDER BY a.adddate DESC '
  11265. print(@SQL)
  11266. EXEC(@SQL)
  11267. SELECT * ,ROW_NUMBER() OVER( ORDER BY AddDate DESC) AS num INTO #T2 FROM ##T1
  11268. SELECT *,0 AS cnt INTO #T3 FROM #T2 WHERE NUM > @PageLowerBound AND NUM <= @PageUpperBound
  11269. --修改评价数量
  11270. UPDATE a
  11271. SET a.cnt = b.Num
  11272. FROM #T3 a,(
  11273. SELECT COUNT(*) AS num,CpMainID
  11274. FROM InterView
  11275. WHERE (InterViewType IN (1,2))
  11276. AND CpMainID IN (SELECT CpMainID FROM #T3)
  11277. GROUP BY CpMainID
  11278. )b
  11279. WHERE a.CpMainID = b.CpMainID
  11280. SELECT * FROM #T3
  11281. SELECT @AllCnt
  11282. SELECT * FROM
  11283. (
  11284. SELECT rid=ROW_NUMBER() OVER(PARTITION BY a.CpmainID ORDER BY a.AddDate DESC),*
  11285. FROM InterView a
  11286. WHERE (a.InterViewType IN (1,2))
  11287. AND CpMainID IN (SELECT CpMainID FROM #T3)
  11288. ) AS c
  11289. WHERE c.rid<=2
  11290. DROP TABLE ##T1
  11291. END TRY
  11292. BEGIN CATCH
  11293. DROP TABLE ##T1
  11294. END CATCH
  11295. GO
  11296. /****** Object: StoredProcedure [dbo].[ProcInterViewHotSelect] Script Date: 2018/12/13 19:10:46 ******/
  11297. SET ANSI_NULLS ON
  11298. GO
  11299. SET QUOTED_IDENTIFIER ON
  11300. GO
  11301. --#####################################################
  11302. --创建时间:2014.11.27
  11303. --创建人:Nick
  11304. --说明:获取最多面经排行 最佳面经排行
  11305. --#####################################################
  11306. CREATE PROCEDURE [dbo].[ProcInterViewHotSelect]
  11307. (
  11308. @ProvinceID INT
  11309. )
  11310. AS
  11311. BEGIN
  11312. --最多面经排行
  11313. SELECT * FROM SearchDB..CommentsHot
  11314. WHERE CommentType = 2
  11315. AND TypeID = 1
  11316. AND dcProvinceID = @ProvinceID
  11317. ORDER BY Cnt DESC
  11318. --最佳点评排行
  11319. SELECT * FROM SearchDB..CommentsHot
  11320. WHERE CommentType = 2
  11321. AND TypeID = 2
  11322. AND dcProvinceID = @ProvinceID
  11323. ORDER BY Cnt DESC
  11324. END
  11325. GO
  11326. /****** Object: StoredProcedure [dbo].[ProcInterViewInsert] Script Date: 2018/12/13 19:10:46 ******/
  11327. SET ANSI_NULLS ON
  11328. GO
  11329. SET QUOTED_IDENTIFIER ON
  11330. GO
  11331. --#####################################################
  11332. --创建时间:2014.11.20
  11333. --创建人:Nick
  11334. --说明:插入面试经历
  11335. --#####################################################
  11336. CREATE PROCEDURE [dbo].[ProcInterViewInsert]
  11337. (
  11338. @CpmainID INT,
  11339. @PaMainID INT,
  11340. @IP VARCHAR(15),
  11341. @SessionID VARCHAR(50),
  11342. @JobName NVARCHAR(50),
  11343. @InterviewDate VARCHAR(6),
  11344. @InterViewResult INT,
  11345. @SalaryMonth INT,
  11346. @InterViewExperience NVARCHAR(MAX),
  11347. @InterviewFeeling NVARCHAR(MAX),
  11348. @Title NVARCHAR(50)
  11349. )
  11350. AS
  11351. BEGIN
  11352. DECLARE @MemberType INT
  11353. SELECT @MemberType = MemberType FROM CpMain WHERE ID = @CpmainID
  11354. IF @MemberType > 1
  11355. BEGIN
  11356. INSERT INTO InterView (CpmainID,PaMainID,IP,SessionID,JobName,InterviewDate,InterViewResult,SalaryMonth,
  11357. InterViewExperience,InterviewFeeling,Title,AddDate,PraiseCount,LoginPraiseCount,InterviewType,IsDirect)
  11358. SELECT ID,@PaMainID,@IP,@SessionID,@JobName,@InterviewDate,@InterViewResult,@SalaryMonth,
  11359. @InterViewExperience,@InterviewFeeling,@Title,GETDATE(),0,0,0,0
  11360. FROM CPMAIN
  11361. WHERE NAME = (
  11362. SELECT Name FROM CpMain WHERE ID = @CpmainID)
  11363. AND MemberType > 1
  11364. AND ID <> @CpmainID
  11365. END
  11366. INSERT INTO InterView (CpmainID,PaMainID,IP,SessionID,JobName,InterviewDate,InterViewResult,SalaryMonth,
  11367. InterViewExperience,InterviewFeeling,Title,AddDate,PraiseCount,LoginPraiseCount,InterviewType,IsDirect)
  11368. VALUES(@CpmainID,@PaMainID,@IP,@SessionID,@JobName,@InterviewDate,@InterViewResult,@SalaryMonth,
  11369. @InterViewExperience,@InterviewFeeling,@Title,GETDATE(),0,0,0,1)
  11370. End
  11371. GO
  11372. /****** Object: StoredProcedure [dbo].[ProcInterviewRecordByCaMainIDSelect] Script Date: 2018/12/13 19:10:46 ******/
  11373. SET ANSI_NULLS ON
  11374. GO
  11375. SET QUOTED_IDENTIFIER ON
  11376. GO
  11377. --#####################################################
  11378. --创建时间:2014.10.29
  11379. --创建人:John
  11380. --说明:获取企业面试大厅的记录
  11381. --#####################################################
  11382. CREATE PROCEDURE [dbo].[ProcInterviewRecordByCaMainIDSelect]
  11383. (
  11384. @caMainID INT
  11385. )
  11386. AS
  11387. BEGIN
  11388. SELECT a.*,c.Name paName,d.Name caName
  11389. FROM ViInterviewRecord a
  11390. LEFT JOIN viRoom b ON b.ID = a.viRoomID
  11391. LEFT JOIN paMain c ON c.ID = a.paMainID
  11392. LEFT JOIN caMain d ON d.ID = b.caMainID
  11393. WHERE a.Begindate IS NOT NULL
  11394. AND b.caMainID = @caMainID
  11395. ORDER BY a.Id DESC
  11396. END
  11397. GO
  11398. /****** Object: StoredProcedure [dbo].[ProcInterviewReplyByIDUpdate] Script Date: 2018/12/13 19:10:46 ******/
  11399. SET ANSI_NULLS ON
  11400. GO
  11401. SET QUOTED_IDENTIFIER ON
  11402. GO
  11403. --#####################################################
  11404. --创建时间:2014.11.18
  11405. --创建人:Nick
  11406. --说明:根据ID修改面试回复信息
  11407. --#####################################################
  11408. CREATE PROCEDURE [dbo].[ProcInterviewReplyByIDUpdate]
  11409. (
  11410. @ID INT,
  11411. @ReplyContent NVARCHAR(MAX),
  11412. @ReplyVerifyMan INT,
  11413. @ReplyVerifyResult INT
  11414. )
  11415. AS
  11416. BEGIN
  11417. UPDATE Interview
  11418. SET ReplyContent = @ReplyContent,
  11419. ReplyVerifyMan = @ReplyVerifyMan,
  11420. ReplyVerifyDate = GETDATE(),
  11421. ReplyVerifyResult = @ReplyVerifyResult
  11422. WHERE ID = @ID
  11423. END
  11424. GO
  11425. /****** Object: StoredProcedure [dbo].[ProcInterviewSelect] Script Date: 2018/12/13 19:10:47 ******/
  11426. SET ANSI_NULLS ON
  11427. GO
  11428. SET QUOTED_IDENTIFIER ON
  11429. GO
  11430. --#####################################################
  11431. --创建时间:2014.11.18
  11432. --创建人:Nick
  11433. --说明:查询 面试经历信息 用于后台审核
  11434. --#####################################################
  11435. CREATE PROCEDURE [dbo].[ProcInterviewSelect]
  11436. (
  11437. @Type INT, --1 待审核 面试经历 2 最近审核 面试经历 3待审核面试经历回复 4最近审核 面试经历回复
  11438. @Where VARCHAR(MAX)
  11439. )
  11440. AS
  11441. BEGIN
  11442. DECLARE @SQL VARCHAR(MAX)
  11443. IF @Type = 1
  11444. BEGIN
  11445. SET @SQL = '
  11446. SELECT a.*,b.name AS CpName ,b.RegDate,
  11447. CASE a.PamainID
  11448. WHEN 0 THEN IP
  11449. ELSE (SELECT Name FROM PaMain WHERE ID = a.PaMainID)
  11450. END AS PaName
  11451. FROM Interview a,CpMain b
  11452. WHERE VerifyDate IS NULL
  11453. AND a.IsDirect = 1
  11454. AND a.CpMainID = b.ID '+@Where+'
  11455. ORDER BY AddDate DESC '
  11456. END
  11457. ELSE IF @Type = 2
  11458. BEGIN
  11459. SET @SQL = '
  11460. SELECT TOP 200 a.*,b.name AS CpName ,b.RegDate,
  11461. CASE a.PamainID
  11462. WHEN 0 THEN IP
  11463. ELSE (SELECT Name FROM PaMain WHERE ID = a.PaMainID)
  11464. END AS PaName
  11465. FROM Interview a,CpMain b
  11466. WHERE VerifyDate IS NOT NULL
  11467. AND a.CpMainID = b.ID '+@Where+'
  11468. ORDER BY VerifyDate DESC '
  11469. END
  11470. ELSE IF @Type = 3
  11471. BEGIN
  11472. SET @SQL = '
  11473. SELECT a.*,b.name AS CpName ,b.RegDate,
  11474. CASE a.PamainID
  11475. WHEN 0 THEN IP
  11476. ELSE (SELECT Name FROM PaMain WHERE ID = a.PaMainID)
  11477. END AS PaName
  11478. FROM Interview a,CpMain b
  11479. WHERE ReplyVerifyDate IS NULL
  11480. AND a.CpMainID = b.ID '+@Where+'
  11481. ORDER BY ReplyDate DESC '
  11482. END
  11483. ELSE IF @Type = 4
  11484. BEGIN
  11485. SET @SQL = '
  11486. SELECT TOP 200 a.*,b.name AS CpName ,b.RegDate,
  11487. CASE a.PamainID
  11488. WHEN 0 THEN IP
  11489. ELSE (SELECT Name FROM PaMain WHERE ID = a.PaMainID)
  11490. END AS PaName
  11491. FROM Interview a,CpMain b
  11492. WHERE ReplyVerifyDate IS NOT NULL
  11493. AND a.CpMainID = b.ID '+@Where+'
  11494. ORDER BY ReplyVerifyDate DESC '
  11495. END
  11496. EXEC(@SQL)
  11497. END
  11498. GO
  11499. /****** Object: StoredProcedure [dbo].[ProcIp_BlackInsert] Script Date: 2018/12/13 19:10:47 ******/
  11500. SET ANSI_NULLS ON
  11501. GO
  11502. SET QUOTED_IDENTIFIER ON
  11503. GO
  11504. CREATE procedure [dbo].[ProcIp_BlackInsert]
  11505. AS
  11506. BEGIN
  11507. return
  11508. SELECT top 0 * into #t from ip_black
  11509. insert into #t
  11510. select top 199 ip, 'sean add 0706', getdate(), 2, '大量访问' from synueolog with(nolock) where adddate > dateadd(minute, -60, getdate()) group by ip order by count(*) desc
  11511. delete #t where ip in(select loginip from paloginlog where adddate > getdate() -1)
  11512. delete #t where ip in(select loginip from caloginlog where adddate > getdate() -1)
  11513. delete #t where ip in(select ip from ip_black)
  11514. insert into ip_black
  11515. select distinct ip,description,getdate(),type,remarks FROM #t order by ip
  11516. delete a from ip_black a, ip_white b where charindex(b.ip, a.ip) > 0
  11517. delete ip_black where ip in('218.201.144.184','111.16.244.80','27.204.87.36','223.96.158.225')
  11518. END
  11519. GO
  11520. /****** Object: StoredProcedure [dbo].[procIp_BlackSelect] Script Date: 2018/12/13 19:10:47 ******/
  11521. SET ANSI_NULLS ON
  11522. GO
  11523. SET QUOTED_IDENTIFIER ON
  11524. GO
  11525. --#####################################################
  11526. --创建时间:2014.11.03
  11527. --创建人:Nick
  11528. --说明:ip黑名单
  11529. --#####################################################
  11530. CREATE PROCEDURE [dbo].[procIp_BlackSelect]
  11531. AS
  11532. BEGIN TRY
  11533. SELECT * FROM ip_Black With(Nolock) ORDER BY ID
  11534. END TRY
  11535. BEGIN CATCH
  11536. RETURN 0
  11537. END CATCH
  11538. GO
  11539. /****** Object: StoredProcedure [dbo].[ProcIp_WhiteByBatchUpdate] Script Date: 2018/12/13 19:10:47 ******/
  11540. SET ANSI_NULLS ON
  11541. GO
  11542. SET QUOTED_IDENTIFIER ON
  11543. GO
  11544. create PROCEDURE [dbo].[ProcIp_WhiteByBatchUpdate]
  11545. AS
  11546. BEGIN
  11547. SELECT ip, COUNT(*) cnt INTO #t FROM IpVisitAll GROUP BY ip
  11548. TRUNCATE TABLE IpVisitAll
  11549. SELECT b.ip, sum(a.cnt) Cnt
  11550. INTO #1
  11551. FROM #t a, ip_white b
  11552. WHERE a.ip LIKE b.ip + '%'
  11553. GROUP BY b.ip
  11554. ORDER BY b.ip
  11555. UPDATE a
  11556. SET a.VisitNum = a.VisitNum + b.Cnt,
  11557. a.VisitNum_ThisMonth = a.VisitNum_ThisMonth + b.Cnt
  11558. FROM Ip_White a, #1 b
  11559. WHERE a.ip = b.ip
  11560. END
  11561. GO
  11562. /****** Object: StoredProcedure [dbo].[procIp_WhiteSelect] Script Date: 2018/12/13 19:10:48 ******/
  11563. SET ANSI_NULLS ON
  11564. GO
  11565. SET QUOTED_IDENTIFIER ON
  11566. GO
  11567. --#####################################################
  11568. --创建时间:2014.11.03
  11569. --创建人:Nick
  11570. --说明:ip白名单
  11571. --#####################################################
  11572. CREATE PROCEDURE [dbo].[procIp_WhiteSelect]
  11573. AS
  11574. BEGIN TRY
  11575. SELECT * FROM ip_White With(Nolock)
  11576. ORDER BY ID
  11577. END TRY
  11578. BEGIN CATCH
  11579. RETURN 0
  11580. END CATCH
  11581. GO
  11582. /****** Object: StoredProcedure [dbo].[ProcIp_WhiteUpdate] Script Date: 2018/12/13 19:10:48 ******/
  11583. SET ANSI_NULLS ON
  11584. GO
  11585. SET QUOTED_IDENTIFIER ON
  11586. GO
  11587. CREATE PROCEDURE [dbo].[ProcIp_WhiteUpdate]
  11588. (
  11589. @Ip VARCHAR(15)
  11590. )
  11591. AS
  11592. SET NOCOUNT ON
  11593. BEGIN
  11594. INSERT INTO IpVisitAll(Ip) SELECT @Ip
  11595. --UPDATE Ip_White SET VisitNum = VisitNum + 1, VisitNum_ThisMonth = VisitNum_ThisMonth + 1
  11596. --WHERE CHARINDEX(ip, @Ip) = 1
  11597. END
  11598. GO
  11599. /****** Object: StoredProcedure [dbo].[procIpJobViewInsert] Script Date: 2018/12/13 19:10:48 ******/
  11600. SET ANSI_NULLS ON
  11601. GO
  11602. SET QUOTED_IDENTIFIER ON
  11603. GO
  11604. --*********************************************************
  11605. --sean 2015-10-12 职位页面频繁访问的不显示联系方式
  11606. --*********************************************************
  11607. CREATE PROCEDURE [dbo].[procIpJobViewInsert]
  11608. (
  11609. @Ip VARCHAR(50),
  11610. @JobId INT,
  11611. @paMainId INT
  11612. )
  11613. AS
  11614. SET NOCOUNT ON
  11615. BEGIN
  11616. INSERT INTO IpJobView(Ip, JobId, paMainId) SELECT @Ip, @JobId, @paMainId
  11617. IF EXISTS(SELECT 'x' FROM IpJobViewRefuse WITH(NOLOCK) WHERE Ip = @Ip)
  11618. SELECT 'x'
  11619. ELSE
  11620. SELECT 'x' FROM IpJobViewRefuse WITH(NOLOCK) WHERE paMainId = @paMainId
  11621. END
  11622. GO
  11623. /****** Object: StoredProcedure [dbo].[procIpLogInsert] Script Date: 2018/12/13 19:10:48 ******/
  11624. SET ANSI_NULLS ON
  11625. GO
  11626. SET QUOTED_IDENTIFIER ON
  11627. GO
  11628. --#####################################################
  11629. --创建时间:2014.11.03
  11630. --创建人:Nick
  11631. --说明:插入iplog
  11632. --#####################################################
  11633. CREATE PROCEDURE [dbo].[procIpLogInsert]
  11634. @RemoteAddr VARCHAR(50),
  11635. @UserAgent VARCHAR(200),
  11636. @ServerName VARCHAR(100)
  11637. AS
  11638. BEGIN TRY
  11639. INSERT INTO iplog (ip,http_user_agent,type,path_info)
  11640. VALUES (@remoteAddr, @userAgent, 0, @ServerName)
  11641. RETURN 1
  11642. END TRY
  11643. BEGIN CATCH
  11644. RETURN 0
  11645. END CATCH
  11646. GO
  11647. /****** Object: StoredProcedure [dbo].[ProcIpPlaceSelect] Script Date: 2018/12/13 19:10:49 ******/
  11648. SET ANSI_NULLS ON
  11649. GO
  11650. SET QUOTED_IDENTIFIER ON
  11651. GO
  11652. --#####################################################
  11653. --创建时间:2014.10.31
  11654. --创建人:John
  11655. --说明:获取IP对应的地区
  11656. --#####################################################
  11657. CREATE PROCEDURE [dbo].[ProcIpPlaceSelect]
  11658. (
  11659. @ip BIGINT
  11660. )
  11661. AS
  11662. BEGIN
  11663. SELECT TOP 1 * FROM dcIpPlace WITH(NOLOCK INDEX(IX_dcIpPlace_IpStart)) WHERE IPStart <= @ip ORDER BY IPStart DESC
  11664. END
  11665. GO
  11666. /****** Object: StoredProcedure [dbo].[procIpReportByIDUpdate] Script Date: 2018/12/13 19:10:49 ******/
  11667. SET ANSI_NULLS ON
  11668. GO
  11669. SET QUOTED_IDENTIFIER ON
  11670. GO
  11671. --#####################################################
  11672. --创建时间:2014.10.31
  11673. --创建人:Nick
  11674. --说明:更新ipreport
  11675. --#####################################################
  11676. CREATE PROCEDURE [dbo].[procIpReportByIDUpdate]
  11677. (
  11678. @ID INT,
  11679. @IP VARCHAR(20)
  11680. )
  11681. AS
  11682. BEGIN TRY
  11683. UPDATE ipreport SET ip=@IP,refresh=getdate() WHERE id= @ID
  11684. RETURN 1
  11685. END TRY
  11686. BEGIN CATCH
  11687. RETURN 0
  11688. END CATCH
  11689. GO
  11690. /****** Object: StoredProcedure [dbo].[procIsWorkDateSelect] Script Date: 2018/12/13 19:10:49 ******/
  11691. SET ANSI_NULLS ON
  11692. GO
  11693. SET QUOTED_IDENTIFIER ON
  11694. GO
  11695. --#####################################################
  11696. --创建时间:2014.10.30
  11697. --创建人:Nick
  11698. --说明:判断是不是工作日
  11699. --#####################################################
  11700. CREATE PROCEDURE [dbo].[procIsWorkDateSelect]
  11701. AS
  11702. BEGIN TRY
  11703. SELECT oadb.dbo.isworkdate(GETDATE()) IsWorkDate
  11704. END TRY
  11705. BEGIN CATCH
  11706. RETURN 0
  11707. END CATCH
  11708. GO
  11709. /****** Object: StoredProcedure [dbo].[procIvgt_AnswerByIDIpUpdate] Script Date: 2018/12/13 19:10:49 ******/
  11710. SET ANSI_NULLS ON
  11711. GO
  11712. SET QUOTED_IDENTIFIER ON
  11713. GO
  11714. --#####################################################
  11715. --创建时间:2014.11.10
  11716. --创建人:NICK
  11717. --说明:修改调查文档点击次数
  11718. --#####################################################
  11719. CREATE PROCEDURE [dbo].[procIvgt_AnswerByIDIpUpdate]
  11720. (
  11721. @ID INT,
  11722. @Ip VARCHAR(15)
  11723. )
  11724. AS
  11725. SET NOCOUNT ON
  11726. BEGIN
  11727. INSERT INTO Ivgt_AnswerLog SELECT @ip, GETDATE()
  11728. IF (SELECT COUNT(*) FROM Ivgt_AnswerLog WITH(NOLOCK)
  11729. WHERE Ip = @ip AND AddDate > DATEADD(MINUTE, -240, GETDATE())) > 50
  11730. RETURN 1
  11731. UPDATE ivgt_answer SET clicknum = clicknum + 1 WHERE id = @ID
  11732. RETURN 1
  11733. END
  11734. GO
  11735. /****** Object: StoredProcedure [dbo].[procIvgt_AnswerByIDUpdate] Script Date: 2018/12/13 19:10:49 ******/
  11736. SET ANSI_NULLS ON
  11737. GO
  11738. SET QUOTED_IDENTIFIER ON
  11739. GO
  11740. --#####################################################
  11741. --创建时间:2014.11.10
  11742. --创建人:NICK
  11743. --说明:修改调查文档点击次数
  11744. --#####################################################
  11745. CREATE PROCEDURE [dbo].[procIvgt_AnswerByIDUpdate]
  11746. (
  11747. @ID INT
  11748. )
  11749. AS
  11750. BEGIN
  11751. UPDATE ivgt_answer SET clicknum=clicknum+1 WHERE id=@ID
  11752. RETURN 1
  11753. END
  11754. GO
  11755. /****** Object: StoredProcedure [dbo].[procIvgt_AnswerByQuesionIDSelect] Script Date: 2018/12/13 19:10:50 ******/
  11756. SET ANSI_NULLS ON
  11757. GO
  11758. SET QUOTED_IDENTIFIER ON
  11759. GO
  11760. --#####################################################
  11761. --创建时间:2014.11.10
  11762. --创建人:NICK
  11763. --说明:
  11764. --#####################################################
  11765. CREATE PROCEDURE [dbo].[procIvgt_AnswerByQuesionIDSelect]
  11766. (
  11767. @IvgID INT
  11768. )
  11769. AS
  11770. BEGIN
  11771. SELECT id,title,clicknum,showType
  11772. FROM ivgt_answer WITH(NOLOCK)
  11773. WHERE questionid=@IvgID
  11774. ORDER BY power
  11775. END
  11776. GO
  11777. /****** Object: StoredProcedure [dbo].[procIvgt_AnswerTextInsert] Script Date: 2018/12/13 19:10:50 ******/
  11778. SET ANSI_NULLS ON
  11779. GO
  11780. SET QUOTED_IDENTIFIER ON
  11781. GO
  11782. --#####################################################
  11783. --创建时间:2014.11.10
  11784. --创建人:NICK
  11785. --说明:ivgt_answerText插入
  11786. --Harry:增加返回id 2015-12-11
  11787. --#####################################################
  11788. CREATE PROCEDURE [dbo].[procIvgt_AnswerTextInsert]
  11789. (
  11790. @ID INT,
  11791. @Text VARCHAR(500)
  11792. )
  11793. AS
  11794. SET NOCOUNT ON
  11795. BEGIN
  11796. IF dbo.HaveChinese(@Text) = 0
  11797. SET @Text = '无'
  11798. INSERT INTO ivgt_answerText(answerid, answerText) VALUES(@ID, @Text)
  11799. SELECT @@IDENTITY AS ID
  11800. END
  11801. GO
  11802. /****** Object: StoredProcedure [dbo].[procIvgt_InvestigationBy51rcSelect] Script Date: 2018/12/13 19:10:50 ******/
  11803. SET ANSI_NULLS ON
  11804. GO
  11805. SET QUOTED_IDENTIFIER ON
  11806. GO
  11807. --#####################################################
  11808. --创建时间:2014.11.10
  11809. --创建人:Nick
  11810. --说明:51rc 调查
  11811. --#####################################################
  11812. CREATE PROCEDURE [dbo].[procIvgt_InvestigationBy51rcSelect]
  11813. AS
  11814. BEGIN TRY
  11815. SELECT TOP 3 id,title,adddate,enddate,clicknum,reporturl,reporttitle,description
  11816. FROM ivgt_investigation WITH(NOLOCK)
  11817. WHERE homepagesee=1
  11818. ORDER BY adddate desc
  11819. END TRY
  11820. BEGIN CATCH
  11821. RETURN 0
  11822. END CATCH
  11823. GO
  11824. /****** Object: StoredProcedure [dbo].[procIvgt_investigationByHomePageList] Script Date: 2018/12/13 19:10:50 ******/
  11825. SET ANSI_NULLS ON
  11826. GO
  11827. SET QUOTED_IDENTIFIER ON
  11828. GO
  11829. --创建人 Lambo
  11830. --20101009
  11831. --用于首页用户调查
  11832. --修改:增加exlink harry 2017-8-5
  11833. CREATE PROCEDURE [dbo].[procIvgt_investigationByHomePageList]
  11834. (
  11835. @ProvinceID SMALLINT
  11836. )
  11837. AS
  11838. BEGIN
  11839. SET NOCOUNT ON
  11840. SELECT TOP 1 ImageFile,alt FROM fpHomePageImage WITH(NOLOCK)
  11841. WHERE ImageType = 3
  11842. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11843. ORDER BY AddDate DESC
  11844. SELECT TOP 15 id newIDs,PreID id, title, description, reporturl, type, reporturl, reporttitle, addDate, exlink
  11845. FROM SearchDb..HPInvestigationDay WITH(NOLOCK)
  11846. WHERE
  11847. provinceID =LEFT(@ProvinceID, 2)
  11848. ORDER BY newIDs
  11849. SET NOCOUNT OFF
  11850. END
  11851. GO
  11852. /****** Object: StoredProcedure [dbo].[procIvgt_investigationByHomepageSelect] Script Date: 2018/12/13 19:10:50 ******/
  11853. SET ANSI_NULLS ON
  11854. GO
  11855. SET QUOTED_IDENTIFIER ON
  11856. GO
  11857. --修改harry
  11858. --增加exlink harry 2017-8-5
  11859. CREATE PROCEDURE [dbo].[procIvgt_investigationByHomepageSelect]
  11860. (
  11861. @province_id SMALLINT
  11862. )
  11863. AS
  11864. BEGIN
  11865. SELECT TOP 1 id, 99 ProvinceId, title, description, AddDate, exLink
  11866. FROM SearchDb..ivgt_investigationDay WITH(NOLOCK)
  11867. WHERE ProvinceID = @Province_ID
  11868. END
  11869. GO
  11870. /****** Object: StoredProcedure [dbo].[procIvgt_InvestigationBYIDSelect] Script Date: 2018/12/13 19:10:51 ******/
  11871. SET ANSI_NULLS ON
  11872. GO
  11873. SET QUOTED_IDENTIFIER ON
  11874. GO
  11875. CREATE PROCEDURE [dbo].[procIvgt_InvestigationBYIDSelect]
  11876. (
  11877. @ID INT
  11878. )
  11879. AS
  11880. BEGIN
  11881. SELECT * FROM Ivgt_Investigation WITH(NOLOCK)
  11882. WHERE ID = @ID
  11883. SELECT * FROM Ivgt_Question WITH(NOLOCK)
  11884. WHERE InvestID = @ID
  11885. ORDER BY ID
  11886. SELECT a.* FROM Ivgt_Answer a WITH(NOLOCK), Ivgt_Question b WITH(NOLOCK)
  11887. WHERE b.InvestID = @ID
  11888. AND a.QuestionID = b.id
  11889. ORDER BY a.QuestionID,a.ID
  11890. END
  11891. GO
  11892. /****** Object: StoredProcedure [dbo].[procIvgt_investigationByIDUpdate] Script Date: 2018/12/13 19:10:51 ******/
  11893. SET ANSI_NULLS ON
  11894. GO
  11895. SET QUOTED_IDENTIFIER ON
  11896. GO
  11897. --#####################################################
  11898. --创建时间:2014.11.10
  11899. --创建人:NICK
  11900. --说明:ivgt_investigation修改点击次数
  11901. --#####################################################
  11902. CREATE PROCEDURE [dbo].[procIvgt_investigationByIDUpdate]
  11903. (
  11904. @ID INT
  11905. )
  11906. AS
  11907. BEGIN
  11908. UPDATE ivgt_investigation SET clicknum=clicknum+1 WHERE id = @ID
  11909. RETURN 1
  11910. END
  11911. GO
  11912. /****** Object: StoredProcedure [dbo].[procIvgt_InvestigationByProvinceIDSelect] Script Date: 2018/12/13 19:10:51 ******/
  11913. SET ANSI_NULLS ON
  11914. GO
  11915. SET QUOTED_IDENTIFIER ON
  11916. GO
  11917. --#####################################################
  11918. --创建时间:2014.11.5
  11919. --创建人:NICK
  11920. --说明:根据省份ID得到用户调查列表
  11921. --修改:harry 2017-8-5 增加exlink
  11922. --#####################################################
  11923. CREATE PROCEDURE [dbo].[procIvgt_InvestigationByProvinceIDSelect]
  11924. (
  11925. @ProvinceID VARCHAR(20)
  11926. )
  11927. AS
  11928. BEGIN
  11929. IF @ProvinceID = '' OR @ProvinceID = '0'
  11930. BEGIN
  11931. SELECT id, title, reporturl, reporttitle, ReportType, exLink
  11932. FROM ivgt_investigation WITH(NOLOCK)
  11933. WHERE ENDdate < GETDATE()
  11934. AND homepagesee = 1
  11935. ORDER BY ENDdate DESC
  11936. END
  11937. ELSE
  11938. BEGIN
  11939. SELECT id, title, reporturl, reporttitle, ReportType, exLink
  11940. FROM ivgt_investigation WITH(NOLOCK)
  11941. WHERE ENDdate < GETDATE()
  11942. AND province LIKE '%'+@ProvinceID+'%'
  11943. AND homepagesee = 1
  11944. ORDER BY ENDdate DESC
  11945. END
  11946. END
  11947. GO
  11948. /****** Object: StoredProcedure [dbo].[procIvgt_InvestigationNotEndSelect] Script Date: 2018/12/13 19:10:51 ******/
  11949. SET ANSI_NULLS ON
  11950. GO
  11951. SET QUOTED_IDENTIFIER ON
  11952. GO
  11953. CREATE PROCEDURE [dbo].[procIvgt_InvestigationNotEndSelect]
  11954. (
  11955. @ProvinceID VARCHAR(2),
  11956. @Type SMALLINT
  11957. )
  11958. AS
  11959. BEGIN
  11960. SELECT ID,Title FROM Ivgt_Investigation WITH(NOLOCK)
  11961. WHERE ENDDate > GETDATE()
  11962. AND Province LIKE '%' + @ProvinceID+'%'
  11963. AND Type=@Type
  11964. ORDER BY ID DESC
  11965. END
  11966. GO
  11967. /****** Object: StoredProcedure [dbo].[procIvgt_InvestigationSelect] Script Date: 2018/12/13 19:10:53 ******/
  11968. SET ANSI_NULLS ON
  11969. GO
  11970. SET QUOTED_IDENTIFIER ON
  11971. GO
  11972. CREATE PROCEDURE [dbo].[procIvgt_InvestigationSelect]
  11973. (
  11974. @province_id VARCHAR(2),
  11975. @manid INTeger,
  11976. @type SMALLINT
  11977. )
  11978. as
  11979. BEGIN
  11980. SELECT id,title FROM Ivgt_investigation WITH(NOLOCK)
  11981. WHERE ENDdate>GETDATE()
  11982. AND province like '%'+@province_id+'%'
  11983. AND type=@type
  11984. ORDER BY adddate
  11985. END
  11986. GO
  11987. /****** Object: StoredProcedure [dbo].[procIvgt_QuestionByInvestIDSelect] Script Date: 2018/12/13 19:10:53 ******/
  11988. SET ANSI_NULLS ON
  11989. GO
  11990. SET QUOTED_IDENTIFIER ON
  11991. GO
  11992. --#####################################################
  11993. --创建时间:2014.11.10
  11994. --创建人:NICK
  11995. --说明:
  11996. --#####################################################
  11997. CREATE PROCEDURE [dbo].[procIvgt_QuestionByInvestIDSelect]
  11998. (
  11999. @IvgID INT
  12000. )
  12001. AS
  12002. BEGIN
  12003. SELECT id,title,type
  12004. FROM ivgt_question WITH(NOLOCK)
  12005. WHERE investid=@IvgID
  12006. ORDER BY power
  12007. END
  12008. GO
  12009. /****** Object: StoredProcedure [dbo].[ProcIvrDayReportInsert] Script Date: 2018/12/13 19:10:53 ******/
  12010. SET ANSI_NULLS ON
  12011. GO
  12012. SET QUOTED_IDENTIFIER ON
  12013. GO
  12014. --修改人:harry 2016-3-31
  12015. --修改冷客户顾问部deptid=42,时间按照all计算
  12016. CREATE PROCEDURE [dbo].[ProcIvrDayReportInsert]
  12017. AS
  12018. BEGIN
  12019. DECLARE @YearMonth VARCHAR(8)
  12020. IF DATEPART(DAY, GETDATE()) > 25
  12021. SET @YearMonth = CONVERT(VARCHAR(6), GETDATE() + 10, 112)
  12022. ELSE
  12023. SET @YearMonth = CONVERT(VARCHAR(6), GETDATE(), 112)
  12024. --IF NOT EXISTS(SELECT 'x' FROM Oadb..WorkDate WHERE WorkType = 1 AND Workdate = CONVERT(VARCHAR(8), GETDATE(), 112))
  12025. -- RETURN
  12026. INSERT IvrDayReport(CountDate, ManagerUserId, Status, Name, DeptID, RealWorkTime)
  12027. SELECT CONVERT(VARCHAR(8), GETDATE(), 112), a.ConsultantId, 0, b.Name, b.DeptId,8
  12028. FROM Consultant_Manageruser_Month a, ManagerUser b
  12029. WHERE b.id = a.ConsultantId
  12030. AND a.YearMonth = @YearMonth
  12031. AND b.Id NOT IN(SELECT ManagerUserId FROM IvrDayReport WHERE CountDate =CONVERT(VARCHAR(8), GETDATE(), 112))
  12032. AND b.ID <> 762
  12033. INSERT IvrDayReport(CountDate, ManagerUserId, Status, Name, DeptID, RealWorkTime)
  12034. SELECT CONVERT(VARCHAR(8), GETDATE(), 112), Id, 0, Name, DeptId, 8
  12035. FROM ManagerUser
  12036. WHERE DeptID =42 AND STatus < 3
  12037. AND LEN(Name) < 5
  12038. AND Id NOT IN(SELECT ManagerUserId FROM IvrDayReport WHERE CountDate =CONVERT(VARCHAR(8), GETDATE(), 112))
  12039. AND ID <> 762
  12040. INSERT IvrDayReport(CountDate, ManagerUserId, Status, Name, DeptID, RealWorkTime)
  12041. SELECT CONVERT(VARCHAR(8), GETDATE(), 112), Id, 0, Name, DeptId, 8
  12042. FROM ManagerUser
  12043. WHERE DeptID in (50,52) AND STatus < 3 AND id<>881
  12044. AND Id NOT IN(SELECT ManagerUserId FROM IvrDayReport WHERE CountDate =CONVERT(VARCHAR(8), GETDATE(), 112))
  12045. INSERT IvrDayReport(CountDate, ManagerUserId, Status, Name, DeptID, RealWorkTime)
  12046. SELECT CONVERT(VARCHAR(8), GETDATE(), 112), Id, 0, Name, DeptId, 8
  12047. FROM ManagerUser WHERE DeptID BETWEEN 180 AND 184 AND STatus < 3
  12048. UPDATE a
  12049. SET a.RealNumber = CallinNum_up40 + CalloutNum_up40,
  12050. a.RealMinute = (CallinInterval_Up40 + CalloutInterval_Up40) / 60
  12051. FROM IvrDayReport a, ivrList_Day b
  12052. WHERE a.CountDate = b.CountDate
  12053. AND a.ManagerUserId = b.ManagerUserId
  12054. AND a.RealNumber = 0
  12055. AND a.CountDate > CONVERT(VARCHAR(8), GETDATE() - 2, 112)
  12056. AND a.DeptID!=42--Harry2016-3-30
  12057. AND a.DeptID != 50
  12058. --Harry begin
  12059. UPDATE a
  12060. SET a.RealNumber = CallinNum_all + CalloutNum_all,
  12061. a.RealMinute = (CallinInterval_all + CalloutInterval_all) / 60
  12062. FROM IvrDayReport a, ivrList_Day b
  12063. WHERE a.CountDate = b.CountDate
  12064. AND a.ManagerUserId = b.ManagerUserId
  12065. AND a.RealNumber = 0
  12066. AND a.CountDate > CONVERT(VARCHAR(8), GETDATE() - 2, 112)
  12067. AND (a.DeptID=42 OR a.DeptID = 50 )
  12068. --Harry end
  12069. UPDATE IvrDayReport
  12070. SET RealNumber = 0, RealMinute = 0
  12071. FROM IvrDayReport
  12072. WHERE CountDate > CONVERT(VARCHAR(8), GETDATE() - 2, 112)
  12073. AND RealNumber IS NULL
  12074. END
  12075. GO
  12076. /****** Object: StoredProcedure [dbo].[ProcIvrList_DayInsert] Script Date: 2018/12/13 19:10:54 ******/
  12077. SET ANSI_NULLS ON
  12078. GO
  12079. SET QUOTED_IDENTIFIER ON
  12080. GO
  12081. CREATE PROCEDURE [dbo].[ProcIvrList_DayInsert]
  12082. AS
  12083. BEGIN
  12084. DECLARE @begindate varchar(50), @enddate varchar(50),
  12085. @id int, @name nvarchar(50), @status tinyint,
  12086. @CallinNum_all smallint, @CallinInterval_all int,
  12087. @CallinNum_up30 smallint, @CallinInterval_up30 int,
  12088. @CallinNum_up40 smallint, @CallinInterval_up40 int,
  12089. @CallinNum_up60 smallint, @CallinInterval_up60 int,
  12090. @CallinNum_up180 smallint, @CallinInterval_up180 int,
  12091. @CallinNum_up600 smallint, @CallinInterval_up600 int
  12092. DECLARE @CalloutNum_all smallint, @CalloutInterval_all int,
  12093. @CalloutNum_up30 smallint, @CalloutInterval_up30 int,
  12094. @CalloutNum_up40 smallint, @CalloutInterval_up40 int,
  12095. @CalloutNum_up60 smallint, @CalloutInterval_up60 int,
  12096. @CalloutNum_up180 smallint, @CalloutInterval_up180 int,
  12097. @CalloutNum_up600 smallint, @CalloutInterval_up600 int
  12098. DECLARE @Callin_notdeal smallint, @Callin_leak smallint,
  12099. @Callin_queueleak smallint, @Callin_blacklist smallint,
  12100. @Callin_voicemail smallint, @Callout_notdeal smallint,
  12101. @Callout_leak smallint, @Callout_queueleak smallint,
  12102. @Callout_blacklist smallint, @Callout_voicemail smallint
  12103. SET @begindate=ltrim(rtrim(str(year(getdate()))))+'-'+ltrim(rtrim(str(month(getdate()))))+'-'+ltrim(rtrim(str(day(getdate()))))+' 00:00:00'
  12104. SET @enddate=ltrim(rtrim(str(year(getdate()))))+'-'+ltrim(rtrim(str(month(getdate()))))+'-'+ltrim(rtrim(str(day(getdate()))))+' 23:59:59'
  12105. DECLARE manageruser CURSOR FOR
  12106. SELECT id, name, status from manageruser with(nolock) where (status=1 or status=2) and (type=1 or type=5) order by id
  12107. OPEN manageruser
  12108. FETCH NEXT FROM manageruser INTO @id, @name, @status
  12109. WHILE @@FETCH_STATUS = 0
  12110. BEGIN
  12111. BEGIN TRANSACTION
  12112. SELECT @CallinNum_all=count(1) from IvrList with(nolock)
  12113. where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate and exten=@id
  12114. SELECT @CallinInterval_all=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
  12115. where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate and exten=@id
  12116. if @CallinInterval_all is null
  12117. set @CallinInterval_all=0
  12118. SELECT @CallinNum_up30=count(1) from IvrList with(nolock)
  12119. where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
  12120. and datediff(s, begintime, endtime)>=30 and exten=@id
  12121. SELECT @CallinInterval_up30=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
  12122. where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
  12123. and datediff(s, begintime, endtime)>=30 and exten=@id
  12124. if @CallinInterval_up30 is null
  12125. set @CallinInterval_up30=0
  12126. SELECT @CallinNum_up40=count(1) from IvrList with(nolock)
  12127. where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
  12128. and datediff(s, begintime, endtime)>=40 and exten=@id
  12129. SELECT @CallinInterval_up40=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
  12130. where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
  12131. and datediff(s, begintime, endtime)>=40 and exten=@id
  12132. if @CallinInterval_up40 is null
  12133. set @CallinInterval_up40=0
  12134. SELECT @CallinNum_up60=count(1) from IvrList with(nolock)
  12135. where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
  12136. and datediff(s, begintime, endtime)>=60 and exten=@id
  12137. SELECT @CallinInterval_up60=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
  12138. where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
  12139. and datediff(s, begintime, endtime)>=60 and exten=@id
  12140. if @CallinInterval_up60 is null
  12141. set @CallinInterval_up60=0
  12142. SELECT @CallinNum_up180=count(1) from IvrList with(nolock)
  12143. where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
  12144. and datediff(s, begintime, endtime)>=180 and exten=@id
  12145. SELECT @CallinInterval_up180=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
  12146. where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
  12147. and datediff(s, begintime, endtime)>=180 and exten=@id
  12148. if @CallinInterval_up180 is null
  12149. set @CallinInterval_up180=0
  12150. SELECT @CallinNum_up600=count(1) from IvrList with(nolock)
  12151. where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
  12152. and datediff(s, begintime, endtime)>=600 and exten=@id
  12153. SELECT @CallinInterval_up600=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
  12154. where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
  12155. and datediff(s, begintime, endtime)>=600 and exten=@id
  12156. if @CallinInterval_up600 is null
  12157. set @CallinInterval_up600=0
  12158. SELECT @CalloutNum_all=count(1) from IvrList with(nolock)
  12159. where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate and exten=@id
  12160. SELECT @CalloutInterval_all=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
  12161. where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate and exten=@id
  12162. if @CalloutInterval_all is null
  12163. set @CalloutInterval_all=0
  12164. SELECT @CalloutNum_up30=count(1) from IvrList with(nolock)
  12165. where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
  12166. and datediff(s, begintime, endtime)>=30 and exten=@id
  12167. SELECT @CalloutInterval_up30=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
  12168. where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
  12169. and datediff(s, begintime, endtime)>=30 and exten=@id
  12170. if @CalloutInterval_up30 is null
  12171. set @CalloutInterval_up30=0
  12172. SELECT @CalloutNum_up40=count(1) from IvrList with(nolock)
  12173. where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
  12174. and datediff(s, begintime, endtime)>=40 and exten=@id
  12175. SELECT @CalloutInterval_up40=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
  12176. where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
  12177. and datediff(s, begintime, endtime)>=40 and exten=@id
  12178. if @CalloutInterval_up40 is null
  12179. set @CalloutInterval_up40=0
  12180. SELECT @CalloutNum_up60=count(1) from IvrList with(nolock)
  12181. where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
  12182. and datediff(s, begintime, endtime)>=60 and exten=@id
  12183. SELECT @CalloutInterval_up60=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
  12184. where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
  12185. and datediff(s, begintime, endtime)>=60 and exten=@id
  12186. if @CalloutInterval_up60 is null
  12187. set @CalloutInterval_up60=0
  12188. SELECT @CalloutNum_up180=count(1) from IvrList with(nolock)
  12189. where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
  12190. and datediff(s, begintime, endtime)>=180 and exten=@id
  12191. SELECT @CalloutInterval_up180=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
  12192. where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
  12193. and datediff(s, begintime, endtime)>=180 and exten=@id
  12194. if @CalloutInterval_up180 is null
  12195. set @CalloutInterval_up180=0
  12196. SELECT @CalloutNum_up600=count(1) from IvrList with(nolock)
  12197. where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
  12198. and datediff(s, begintime, endtime)>=600 and exten=@id
  12199. SELECT @CalloutInterval_up600=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
  12200. where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
  12201. and datediff(s, begintime, endtime)>=600 and exten=@id
  12202. if @CalloutInterval_up600 is null
  12203. set @CalloutInterval_up600=0
  12204. SELECT @Callin_notdeal=count(1) from IvrList with(nolock)
  12205. where CallType='normal' and State='notdeal' and endtime>@begindate and endtime<@enddate and exten=@id
  12206. SELECT @Callin_leak=count(1) from IvrList with(nolock)
  12207. where CallType='normal' and State='leak' and endtime>@begindate and endtime<@enddate and exten=@id
  12208. SELECT @Callin_queueleak=count(1) from IvrList with(nolock)
  12209. where CallType='normal' and State='queueleak' and endtime>@begindate and endtime<@enddate and exten=@id
  12210. SELECT @Callin_blacklist=count(1) from IvrList with(nolock)
  12211. where CallType='normal' and State='blacklist' and endtime>@begindate and endtime<@enddate and exten=@id
  12212. SELECT @Callin_voicemail=count(1) from IvrList with(nolock)
  12213. where CallType='normal' and State='voicemail' and endtime>@begindate and endtime<@enddate and exten=@id
  12214. SELECT @Callout_notdeal=count(1) from IvrList with(nolock)
  12215. where CallType='dialout' and State='notdeal' and endtime>@begindate and endtime<@enddate and exten=@id
  12216. SELECT @Callout_leak=count(1) from IvrList with(nolock)
  12217. where CallType='dialout' and State='leak' and endtime>@begindate and endtime<@enddate and exten=@id
  12218. SELECT @Callout_queueleak=count(1) from IvrList with(nolock)
  12219. where CallType='dialout' and State='queueleak' and endtime>@begindate and endtime<@enddate and exten=@id
  12220. SELECT @Callout_blacklist=count(1) from IvrList with(nolock)
  12221. where CallType='dialout' and State='blacklist' and endtime>@begindate and endtime<@enddate and exten=@id
  12222. SELECT @Callout_voicemail=count(1) from IvrList with(nolock)
  12223. where CallType='dialout' and State='voicemail' and endtime>@begindate and endtime<@enddate and exten=@id
  12224. insert into Ivrlist_day (countdate, manageruserid, name, status, CallinNum_all, CallinInterval_all,
  12225. CallinNum_up30, CallinInterval_up30, CallinNum_up40, CallinInterval_up40, CallinNum_up60, CallinInterval_up60, CallinNum_up180, CallinInterval_up180,
  12226. CallinNum_up600, CallinInterval_up600,
  12227. CalloutNum_all, CalloutInterval_all,
  12228. CalloutNum_up30, CalloutInterval_up30, CalloutNum_up40, CalloutInterval_up40, CalloutNum_up60, CalloutInterval_up60, CalloutNum_up180, CalloutInterval_up180,
  12229. CalloutNum_up600, CalloutInterval_up600, Callin_notdeal, Callin_leak, Callin_queueleak, Callin_blacklist, Callin_voicemail,
  12230. Callout_notdeal, Callout_leak, Callout_queueleak, Callout_blacklist, Callout_voicemail)
  12231. values ((year(getdate())*10000+month(getdate())*100+day(getdate())), @id, @name, @status,
  12232. @CallinNum_all, @CallinInterval_all,
  12233. @CallinNum_up30, @CallinInterval_up30, @CallinNum_up40, @CallinInterval_up40, @CallinNum_up60, @CallinInterval_up60, @CallinNum_up180, @CallinInterval_up180,
  12234. @CallinNum_up600, @CallinInterval_up600,
  12235. @CalloutNum_all, @CalloutInterval_all,
  12236. @CalloutNum_up30, @CalloutInterval_up30, @CalloutNum_up40, @CalloutInterval_up40, @CalloutNum_up60, @CalloutInterval_up60, @CalloutNum_up180,
  12237. @CalloutInterval_up180,
  12238. @CalloutNum_up600, @CalloutInterval_up600, @Callin_notdeal, @Callin_leak, @Callin_queueleak, @Callin_blacklist, @Callin_voicemail,
  12239. @Callout_notdeal, @Callout_leak, @Callout_queueleak, @Callout_blacklist, @Callout_voicemail)
  12240. COMMIT TRANSACTION
  12241. FETCH NEXT FROM manageruser INTO @id, @name, @status
  12242. END
  12243. CLOSE manageruser
  12244. DEALLOCATE manageruser
  12245. END
  12246. GO
  12247. /****** Object: StoredProcedure [dbo].[ProcIvrList_DaySelect] Script Date: 2018/12/13 19:10:54 ******/
  12248. SET ANSI_NULLS ON
  12249. GO
  12250. SET QUOTED_IDENTIFIER ON
  12251. GO
  12252. --Edit by 2014-12-17,修改Coefficient为:折算后个数/100+折算后时长/260
  12253. --修改:冷客户顾问部 电话量系数指标是80个,100分钟-harry2017-4-27
  12254. CREATE PROCEDURE [dbo].[ProcIvrList_DaySelect]
  12255. (
  12256. @QueryType TINYINT, --1:南北方个人;2:山东个人;3:客服个人;4:所有部门对比;5:部门查询
  12257. @BeginDate DATETIME, --20140505
  12258. @EndDate DATETIME, --20140510
  12259. @TimeType TINYINT, --0:不选择; 1:30秒以上;2:1分钟以上;3:3分钟以上;4:10分钟以上;
  12260. @CallType TINYINT, --0:不选择; 1:呼入; 2:呼出
  12261. --@Region TINYINT, --0:不选择; 1:北方; 2:南方; 3:山东
  12262. @DeptId INT --0:不选择; 其他见dept
  12263. )
  12264. AS
  12265. SET NOCOUNT ON
  12266. --insert a2 select @QueryType, @BeginDate, @EndDate, @TimeType, @CallType, @DeptId
  12267. BEGIN
  12268. --转换时间
  12269. DECLARE @BDate VARCHAR(8), @EDate VARCHAR(8),
  12270. @Sql VARCHAR(MAX), @CallNumber VARCHAR(100), @CallInterval VARCHAR(100)
  12271. SELECT @BDate = CONVERT(VARCHAR(8), @BeginDate, 112),
  12272. @EDate = CONVERT(VARCHAR(8), @EndDate, 112)
  12273. CREATE TABLE #t(
  12274. DeptId BIGINT,
  12275. DeptName NVARCHAR(20),
  12276. ManagerUserId BIGINT,
  12277. ManagerName NVARCHAR(20),
  12278. AvgNumber BIGINT,
  12279. AvgMinute BIGINT,
  12280. AvgConvertNumber BIGINT,
  12281. AvgConvertMinute BIGINT,
  12282. SumNumber BIGINT,
  12283. SumMinute BIGINT,
  12284. SumConvertNumber BIGINT,
  12285. SumConvertMinute BIGINT,
  12286. RealWorkTime DECIMAL(9, 2),
  12287. WorkDays BIGINT,
  12288. Coefficient DECIMAL(9, 3))
  12289. --@TimeType BIGINT, --0:不选择; 1:30秒以上;2:1分钟以上;3:3分钟以上;4:5分钟以上;5:10分钟以上;6:30分钟以上
  12290. IF @CallType = 1
  12291. SELECT @CallNumber = 'CallInNum_All', @CallInterval = 'CallInInterval_All'
  12292. ELSE IF @CallType = 2
  12293. SELECT @CallNumber = 'CallOutNum_All', @CallInterval = 'CallOutInterval_All'
  12294. ELSE
  12295. SELECT @CallNumber = 'CallInNum_All + CallOutNum_All',
  12296. @CallInterval = 'CallInInterval_All + CallOutInterval_All'
  12297. IF @TimeType = 1
  12298. SELECT @CallNumber = REPLACE(@CallNumber, '_All', '_Up30'),
  12299. @CallInterval = REPLACE(@CallInterval, '_All', '_Up30')
  12300. ELSE IF @TimeType = 2
  12301. SELECT @CallNumber = REPLACE(@CallNumber, '_All', '_Up60'),
  12302. @CallInterval = REPLACE(@CallInterval, '_All', '_Up60')
  12303. ELSE IF @TimeType = 3
  12304. SELECT @CallNumber = REPLACE(@CallNumber, '_All', '_Up180'),
  12305. @CallInterval = REPLACE(@CallInterval, '_All', '_Up180')
  12306. ELSE IF @TimeType = 4
  12307. SELECT @CallNumber = REPLACE(@CallNumber, '_All', '_Up600'),
  12308. @CallInterval = REPLACE(@CallInterval, '_All', '_Up600')
  12309. ELSE IF @TimeType = 5
  12310. SELECT @CallNumber = REPLACE(@CallNumber, '_All', '_Up40'),
  12311. @CallInterval = REPLACE(@CallInterval, '_All', '_Up40')
  12312. SET @Sql ='
  12313. INSERT #t(ManagerUserId, AvgNumber, AvgMinute, SumNumber, SumMinute, Coefficient, RealWorkTime, WorkDays)
  12314. SELECT a.ManagerUserId, AVG(' + @CallNumber + '), AVG(' + @CallInterval + '),
  12315. SUM(' + @CallNumber + '), SUM(' + @CallInterval + '), AVG(b.Coefficient),
  12316. SUM(b.RealWorkTime), COUNT(1)
  12317. FROM IvrList_Day a, IvrDayReport b
  12318. WHERE a.CountDate BETWEEN ' + @BDate + ' AND ' + @EDate + '
  12319. AND a.CountDate = b.Countdate
  12320. AND a.ManagerUserId = b.ManagerUserId
  12321. AND b.IsCheck = 1
  12322. GROUP BY a.ManagerUserId'
  12323. PRINT @SQL
  12324. EXEC(@SQL)
  12325. UPDATE a
  12326. Set a.ManagerName = b.Name,
  12327. a.DeptId = b.DeptId
  12328. FROM #t a, ManagerUser b
  12329. WHERE a.ManagerUSerId = b.Id
  12330. UPDATE a
  12331. Set a.DeptName = b.DeptName
  12332. FROM #t a, Dept b
  12333. WHERE a.DeptId = b.Id
  12334. --1:南北方个人;2:山东个人;3:客服个人;4:所有部门对比;5:部门查询
  12335. IF @QueryType = 1
  12336. DELETE #t WHERE DeptId NOT IN(4,19,25,28)
  12337. IF @QueryType = 2
  12338. DELETE #t WHERE DeptId NOT IN(31,34,36,37,39,42,54)
  12339. IF @QueryType = 3
  12340. DELETE #t WHERE DeptId <> 14
  12341. IF @QueryType = 5
  12342. BEGIN
  12343. DELETE #t WHERE DeptId <> @DeptId
  12344. INSERT #t(DeptId, DeptName, ManagerUserId, ManagerName, AvgNumber, AvgMinute,
  12345. SumNumber, SumMinute, RealWorkTime, WorkDays)
  12346. SELECT DeptId, DeptName, NULL, '部门', AVG(AvgNumber), AVG(AvgMinute),
  12347. SUM(SumNumber), SUM(SumMinute), SUM(RealWorkTime), SUM(WorkDays)
  12348. FROM #t
  12349. GROUP BY DeptID, DeptName
  12350. END
  12351. IF @QueryType = 4
  12352. BEGIN
  12353. DELETE #t WHERE DeptId = 14
  12354. INSERT #t(DeptId, DeptName, ManagerUserId, ManagerName, AvgNumber, AvgMinute,
  12355. SumNumber, SumMinute, RealWorkTime, WorkDays, Coefficient)
  12356. SELECT DeptId, DeptName, NULL, '', AVG(AvgNumber), AVG(AvgMinute),
  12357. SUM(SumNumber), SUM(SumMinute), SUM(RealWorkTime), SUM(WorkDays), AVG(Coefficient)
  12358. FROM #t
  12359. GROUP BY DeptID, DeptName
  12360. DELETE #t WHERE ManagerUserID < 1000
  12361. INSERT #t(DeptId, DeptName, ManagerUserId, ManagerName, AvgNumber, AvgMinute,
  12362. SumNumber, SumMinute, RealWorkTime, WorkDays)
  12363. SELECT 0, '体系', NULL, '', AVG(AvgNumber), AVG(AvgMinute),
  12364. SUM(SumNumber), SUM(SumMinute), SUM(RealWorkTime), SUM(WorkDays)
  12365. FROM #t
  12366. END
  12367. UPDATE #t SET AvgConvertNumber = AvgNumber * (WorkDays * 8) / RealWorkTime,
  12368. AvgConvertMinute = AvgMinute * (WorkDays * 8) / RealWorkTime,
  12369. SumConvertNumber = SumNumber * (WorkDays * 8) / RealWorkTime,
  12370. SumConvertMinute = SumMinute * (WorkDays * 8) / RealWorkTime
  12371. UPDATE #t SET Coefficient = (AvgConvertNumber / 100.0 + AvgConvertMinute / (260.0 * 60))
  12372. WHERE DeptId != 42
  12373. UPDATE #t SET Coefficient = (AvgConvertNumber / 160.0 + AvgConvertMinute / (200.0 * 60))
  12374. WHERE DeptId = 42
  12375. --WHERE ManagerUserId IS NULL
  12376. DECLARE @t AS TABLE(
  12377. DeptId BIGINT,
  12378. DeptName NVARCHAR(20),
  12379. ManagerUserId BIGINT,
  12380. ManagerName NVARCHAR(20),
  12381. CountType NVARCHAR(2),
  12382. RealNumber BIGINT,
  12383. RealMinute BIGINT,
  12384. ConvertNumber BIGINT,
  12385. ConvertMinute BIGINT,
  12386. Coefficient DECIMAL(9, 2))
  12387. INSERT @t(DeptId, DeptName, ManagerUserId, ManagerName, CountType,
  12388. RealNumber, RealMinute, ConvertNumber, ConvertMinute, Coefficient)
  12389. SELECT DeptId, DeptName, ManagerUserId, ManagerName, '平均',
  12390. AvgNumber, AvgMinute / 60, AvgConvertNumber, AvgConvertMinute / 60, Coefficient
  12391. FROM #t
  12392. INSERT @t(DeptId, DeptName, ManagerUserId, ManagerName, CountType,
  12393. RealNumber, RealMinute, ConvertNumber, ConvertMinute, Coefficient)
  12394. SELECT DeptId, DeptName, ManagerUserId, ManagerName, '合计',
  12395. SumNumber, SumMinute / 60, SumConvertNumber, SumConvertMinute / 60, Coefficient
  12396. FROM #t
  12397. DECLARE @d AS TABLE(DeptId BIGINT, OrderNo INT)
  12398. INSERT @d SELECT 4, 1
  12399. INSERT @d SELECT 28, 2
  12400. INSERT @d SELECT 19, 3
  12401. INSERT @d SELECT 25, 4
  12402. INSERT @d SELECT 39, 5
  12403. INSERT @d SELECT 31, 6
  12404. INSERT @d SELECT 34, 7
  12405. INSERT @d SELECT 36, 8
  12406. INSERT @d SELECT 37, 9
  12407. INSERT @d SELECT 42, 10
  12408. INSERT @d SELECT 14, 11
  12409. INSERT @d SELECT 54, 12
  12410. INSERT @d SELECT 0, 13
  12411. SELECT a.* FROM @t a, @d b WHERE a.DeptId = b.DeptId
  12412. ORDER BY b.OrderNo, CASE WHEN a.ManagerUserId IS NULL THEN 9999 ELSE a.ManagerUserId END, CASE CountType WHEN '平均' THEN 1 ELSE 2 END
  12413. SELECT * FROM #t ORDER BY DeptName, ManagerUserId
  12414. END
  12415. GO
  12416. /****** Object: StoredProcedure [dbo].[ProcIvrListByCaMainIdUpdate] Script Date: 2018/12/13 19:10:55 ******/
  12417. SET ANSI_NULLS ON
  12418. GO
  12419. SET QUOTED_IDENTIFIER ON
  12420. GO
  12421. CREATE PROCEDURE [dbo].[ProcIvrListByCaMainIdUpdate]
  12422. AS
  12423. BEGIN
  12424. --DECLARE @ID INT
  12425. --SELECT TOP 1 @ID = ID FROM IvrList WHERE caMainId IS NOT NULL ORDER BY ID DESC
  12426. DECLARE @t AS TABLE(ID INT,
  12427. CallNo VARCHAR(50),
  12428. CalledNo VARCHAR(50),
  12429. CallType VARCHAR(10),
  12430. Telephone VARCHAR(50),
  12431. Telephone2 VARCHAR(50),
  12432. Exten VARCHAR(10),
  12433. caMainId INT,
  12434. cpAccountID INT,
  12435. cpLinkManID INT,
  12436. IsWtg INT
  12437. )
  12438. INSERT INTO @t(ID, CallNo, CalledNo, CallType, Exten,cpAccountID,cpLinkManID, IsWtg)
  12439. SELECT ID, CallNo, CalledNo, CallType, Exten, 0,0,0 FROM IvrList WHERE caMainId IS NULL
  12440. IF (SELECT COUNT(*) FROM @t) = 0
  12441. RETURN
  12442. UPDATE a SET IsWtg = 1 FROM @t a WHERE Exten IN (SELECT LTRIM(STR(ID)) FROM Manageruser WITH(NOLOCK) WHERE DeptID IN (SELECT ID FROM Dept WITH(NOLOCK) WHERE Superior = 43))
  12443. UPDATE a
  12444. SET a.TelePhone = a.CallNo
  12445. FROM @t a
  12446. UPDATE a
  12447. SET a.TelePhone = a.CalledNo
  12448. FROM @t a
  12449. WHERE a.CallType = 'dialout'
  12450. UPDATE a
  12451. SET a.TelePhone2 = LEFT(TelePhone, 3) + '-' + RIGHT(TelePhone, LEN(TelePhone) - 3)
  12452. FROM @t a
  12453. WHERE LEFT(TelePhone, 2) IN('01', '02')
  12454. AND TelePhone NOT LIKE '1%'
  12455. UPDATE a
  12456. SET a.TelePhone2 = LEFT(TelePhone, 4) + '-' + RIGHT(TelePhone, LEN(TelePhone) - 4)
  12457. FROM @t a
  12458. WHERE TelePhone2 IS NULL
  12459. AND TelePhone NOT LIKE '1%'
  12460. --#############################判断是否是社招平台的联系方式
  12461. UPDATE a
  12462. SET a.caMainId = (SELECT TOP 1 Id FROM caMain WHERE caMain.Mobile = a.TelePhone AND cpMainId IN(SELECT id FROM cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY Id DESc)
  12463. FROM @t a
  12464. WHERE a.TelePhone LIKE '1%'
  12465. AND IsWtg = 0
  12466. UPDATE a
  12467. SET a.caMainId = (SELECT TOP 1 Id FROM caMain WHERE caMain.Mobile = a.TelePhone ORDER BY ID DESC)
  12468. FROM @t a
  12469. WHERE a.TelePhone LIKE '1%'
  12470. AND a.CaMainId IS NULL
  12471. AND IsWtg = 0
  12472. UPDATE a
  12473. SET a.caMainId = (SELECT TOP 1 Id FROM caMain WITH(NOLOCK INDEX(IX_CaMainID_TelePhone)) WHERE caMain.TelePhone LIKE a.TelePhone + '%' AND cpMainId IN(SELECT id FROM cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
  12474. FROM @t a
  12475. WHERE a.CaMainId IS NULL
  12476. AND IsWtg = 0
  12477. UPDATE a
  12478. SET a.caMainId = (SELECT TOP 1 Id FROM caMain WITH(NOLOCK INDEX(IX_CaMainID_TelePhone)) WHERE caMain.TelePhone LIKE a.TelePhone + '%' ORDER BY ID DESC)
  12479. FROM @t a
  12480. WHERE a.CaMainId IS NULL
  12481. AND IsWtg = 0
  12482. UPDATE a
  12483. SET a.caMainId = (SELECT TOP 1 Id FROM caMain WITH(NOLOCK INDEX(IX_CaMainID_TelePhone)) WHERE caMain.TelePhone LIKE a.TelePhone2 + '%' AND cpMainId IN(SELECT id FROM cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
  12484. FROM @t a
  12485. WHERE a.CaMainId IS NULL
  12486. AND IsWtg = 0
  12487. UPDATE a
  12488. SET a.caMainId = (SELECT TOP 1 Id FROM caMain WITH(NOLOCK INDEX(IX_CaMainID_TelePhone)) WHERE TelePhone LIKE a.TelePhone2 + '%' ORDER BY ID DESC)
  12489. FROM @t a
  12490. WHERE a.CaMainId IS NULL
  12491. AND IsWtg = 0
  12492. UPDATE a
  12493. SET a.caMainId = 0
  12494. FROM @t a
  12495. WHERE a.CaMainId IS NULL
  12496. --AND IsWtg = 0
  12497. UPDATE a
  12498. SET a.caMainId = b.caMainId
  12499. FROM IvrList a, @t b
  12500. WHERE a.Id = b.Id
  12501. --AND IsWtg = 0
  12502. --#############################判断是否是梧桐果校招平台的联系方式
  12503. UPDATE a
  12504. SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK) WHERE cpAccount.Mobile = a.TelePhone AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY Id DESc)
  12505. FROM @t a
  12506. WHERE a.TelePhone LIKE '1%'
  12507. AND cpAccountID = 0
  12508. AND IsWtg = 1
  12509. UPDATE a
  12510. SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK) WHERE cpAccount.Mobile = a.TelePhone ORDER BY Id DESc)
  12511. FROM @t a
  12512. WHERE a.TelePhone LIKE '1%'
  12513. AND cpAccountID = 0
  12514. AND IsWtg = 1
  12515. UPDATE a
  12516. SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK) WHERE CpLinkMan.Mobile = a.TelePhone AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
  12517. FROM @t a
  12518. WHERE a.TelePhone LIKE '1%'
  12519. AND IsWtg = 1
  12520. UPDATE a
  12521. SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK) WHERE CpLinkMan.Mobile = a.TelePhone ORDER BY ID DESC)
  12522. FROM @t a
  12523. WHERE a.TelePhone LIKE '1%'
  12524. AND CpLinkManID = 0
  12525. AND IsWtg = 1
  12526. UPDATE a
  12527. SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK INDEX(IX_CpAccount_TelePhone)) WHERE cpAccount.TelePhone LIKE a.TelePhone + '%' AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
  12528. FROM @t a
  12529. WHERE cpAccountID = 0
  12530. AND IsWtg = 1
  12531. UPDATE a
  12532. SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK INDEX(IX_CpAccount_TelePhone)) WHERE cpAccount.TelePhone LIKE a.TelePhone + '%' ORDER BY ID DESC)
  12533. FROM @t a
  12534. WHERE cpAccountID = 0
  12535. AND IsWtg = 1
  12536. UPDATE a
  12537. SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK INDEX(IX_CpLinkMan_Tel)) WHERE CpLinkMan.Tel LIKE a.TelePhone + '%' AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
  12538. FROM @t a
  12539. WHERE CpLinkManID = 0
  12540. AND IsWtg = 1
  12541. UPDATE a
  12542. SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK INDEX(IX_CpLinkMan_Tel)) WHERE CpLinkMan.Tel LIKE a.TelePhone + '%' ORDER BY ID DESC)
  12543. FROM @t a
  12544. WHERE CpLinkManID = 0
  12545. AND IsWtg = 1
  12546. UPDATE a
  12547. SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK INDEX(IX_CpAccount_TelePhone)) WHERE cpAccount.TelePhone LIKE a.TelePhone2 + '%' AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
  12548. FROM @t a
  12549. WHERE cpAccountID = 0
  12550. AND IsWtg = 1
  12551. UPDATE a
  12552. SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK INDEX(IX_CpAccount_TelePhone)) WHERE cpAccount.TelePhone LIKE a.TelePhone2 + '%' ORDER BY ID DESC)
  12553. FROM @t a
  12554. WHERE cpAccountID = 0
  12555. AND IsWtg = 1
  12556. UPDATE a
  12557. SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK INDEX(IX_CpLinkMan_Tel)) WHERE CpLinkMan.Tel LIKE a.TelePhone2 + '%' AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
  12558. FROM @t a
  12559. WHERE CpLinkManID = 0
  12560. AND IsWtg = 1
  12561. UPDATE a
  12562. SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK INDEX(IX_CpLinkMan_Tel)) WHERE CpLinkMan.Tel LIKE a.TelePhone2 + '%' ORDER BY ID DESC)
  12563. FROM @t a
  12564. WHERE CpLinkManID = 0
  12565. AND IsWtg = 1
  12566. UPDATE a
  12567. SET a.cpAccountID = b.cpAccountID
  12568. FROM IvrList a, @t b
  12569. WHERE a.Id = b.Id
  12570. AND IsWtg = 1
  12571. UPDATE a
  12572. SET a.CpLinkManID = b.CpLinkManID
  12573. FROM IvrList a, @t b
  12574. WHERE a.Id = b.Id
  12575. AND IsWtg = 1
  12576. -- INSERT INTO Wutongguodb..CpContactLog(CpMainID,IvrListID,CpLinkManID,CpAccountID,ContentText,ManageruserID,Name,Tel)
  12577. -- SELECT
  12578. -- ISNULL(b.CpMainID,c.CpMainID)
  12579. -- ,a.id
  12580. -- ,CpLinkManID
  12581. -- ,CpAccountID
  12582. -- ,''
  12583. -- ,Exten,ISNULL(b.Name,c.Name),a.TelePhone
  12584. -- FROM @t a LEFT JOIN Wutongguodb..CpLinkMan b WITH(NOLOCK) ON a.CpLinkManID = b.ID
  12585. -- LEFT JOIN Wutongguodb..CpAccount c WITH(NOLOCK) ON a.CpAccountID = c.ID
  12586. -- WHERE a.IsWtg=1 AND (CpLinkManID >0 OR CpLinkManID>0) and a.CallType = 'dialout'
  12587. END
  12588. GO
  12589. /****** Object: StoredProcedure [dbo].[ProcIvrListByCaMainIdUpdate2] Script Date: 2018/12/13 19:10:56 ******/
  12590. SET ANSI_NULLS ON
  12591. GO
  12592. SET QUOTED_IDENTIFIER ON
  12593. GO
  12594. CREATE PROCEDURE [dbo].[ProcIvrListByCaMainIdUpdate2]
  12595. AS
  12596. BEGIN
  12597. --DECLARE @ID INT
  12598. --SELECT TOP 1 @ID = ID FROM IvrList WHERE caMainId IS NOT NULL ORDER BY ID DESC
  12599. DECLARE @t AS TABLE(ID INT,
  12600. CallNo VARCHAR(50),
  12601. CalledNo VARCHAR(50),
  12602. CallType VARCHAR(10),
  12603. Telephone VARCHAR(50),
  12604. Telephone2 VARCHAR(50),
  12605. Exten VARCHAR(10),
  12606. caMainId INT,
  12607. cpAccountID INT,
  12608. cpLinkManID INT,
  12609. IsWtg INT
  12610. )
  12611. INSERT INTO @t(ID, CallNo, CalledNo, CallType, Exten,cpAccountID,cpLinkManID, IsWtg)
  12612. SELECT ID, CallNo, CalledNo, CallType, Exten, 0,0,0 FROM IvrList WHERE caMainId IS NULL
  12613. IF (SELECT COUNT(*) FROM @t) = 0
  12614. RETURN
  12615. UPDATE a SET IsWtg = 1 FROM @t a WHERE Exten IN (SELECT LTRIM(STR(ID)) FROM Manageruser WITH(NOLOCK) WHERE DeptID IN (SELECT ID FROM Dept WITH(NOLOCK) WHERE Superior = 43))
  12616. UPDATE a
  12617. SET a.TelePhone = a.CallNo
  12618. FROM @t a
  12619. UPDATE a
  12620. SET a.TelePhone = a.CalledNo
  12621. FROM @t a
  12622. WHERE a.CallType = 'dialout'
  12623. UPDATE a
  12624. SET a.TelePhone2 = LEFT(TelePhone, 3) + '-' + RIGHT(TelePhone, LEN(TelePhone) - 3)
  12625. FROM @t a
  12626. WHERE LEFT(TelePhone, 2) IN('01', '02')
  12627. AND TelePhone NOT LIKE '1%'
  12628. UPDATE a
  12629. SET a.TelePhone2 = LEFT(TelePhone, 4) + '-' + RIGHT(TelePhone, LEN(TelePhone) - 4)
  12630. FROM @t a
  12631. WHERE TelePhone2 IS NULL
  12632. AND TelePhone NOT LIKE '1%'
  12633. --#############################判断是否是社招平台的联系方式
  12634. UPDATE a
  12635. SET a.caMainId = (SELECT TOP 1 Id FROM caMain WHERE caMain.Mobile = a.TelePhone AND cpMainId IN(SELECT id FROM cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY Id DESc)
  12636. FROM @t a
  12637. WHERE a.TelePhone LIKE '1%'
  12638. AND IsWtg = 0
  12639. UPDATE a
  12640. SET a.caMainId = (SELECT TOP 1 Id FROM caMain WHERE caMain.Mobile = a.TelePhone ORDER BY ID DESC)
  12641. FROM @t a
  12642. WHERE a.TelePhone LIKE '1%'
  12643. AND a.CaMainId IS NULL
  12644. AND IsWtg = 0
  12645. UPDATE a
  12646. SET a.caMainId = (SELECT TOP 1 Id FROM caMain WITH(NOLOCK INDEX(IX_CaMainID_TelePhone)) WHERE caMain.TelePhone LIKE a.TelePhone + '%' AND cpMainId IN(SELECT id FROM cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
  12647. FROM @t a
  12648. WHERE a.CaMainId IS NULL
  12649. AND IsWtg = 0
  12650. UPDATE a
  12651. SET a.caMainId = (SELECT TOP 1 Id FROM caMain WITH(NOLOCK INDEX(IX_CaMainID_TelePhone)) WHERE caMain.TelePhone LIKE a.TelePhone + '%' ORDER BY ID DESC)
  12652. FROM @t a
  12653. WHERE a.CaMainId IS NULL
  12654. AND IsWtg = 0
  12655. UPDATE a
  12656. SET a.caMainId = (SELECT TOP 1 Id FROM caMain WITH(NOLOCK INDEX(IX_CaMainID_TelePhone)) WHERE caMain.TelePhone LIKE a.TelePhone2 + '%' AND cpMainId IN(SELECT id FROM cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
  12657. FROM @t a
  12658. WHERE a.CaMainId IS NULL
  12659. AND IsWtg = 0
  12660. UPDATE a
  12661. SET a.caMainId = (SELECT TOP 1 Id FROM caMain WITH(NOLOCK INDEX(IX_CaMainID_TelePhone)) WHERE TelePhone LIKE a.TelePhone2 + '%' ORDER BY ID DESC)
  12662. FROM @t a
  12663. WHERE a.CaMainId IS NULL
  12664. AND IsWtg = 0
  12665. UPDATE a
  12666. SET a.caMainId = 0
  12667. FROM @t a
  12668. WHERE a.CaMainId IS NULL
  12669. AND IsWtg = 0
  12670. UPDATE a
  12671. SET a.caMainId = b.caMainId
  12672. FROM IvrList a, @t b
  12673. WHERE a.Id = b.Id
  12674. AND IsWtg = 0
  12675. --#############################判断是否是梧桐果校招平台的联系方式
  12676. UPDATE a
  12677. SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK) WHERE cpAccount.Mobile = a.TelePhone AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY Id DESc)
  12678. FROM @t a
  12679. WHERE a.TelePhone LIKE '1%'
  12680. AND IsWtg = 1
  12681. UPDATE a
  12682. SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK) WHERE cpAccount.Mobile = a.TelePhone ORDER BY Id DESc)
  12683. FROM @t a
  12684. WHERE a.TelePhone LIKE '1%'
  12685. AND cpAccountID = 0
  12686. AND IsWtg = 1
  12687. UPDATE a
  12688. SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK) WHERE CpLinkMan.Mobile = a.TelePhone AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
  12689. FROM @t a
  12690. WHERE a.TelePhone LIKE '1%'
  12691. AND IsWtg = 1
  12692. UPDATE a
  12693. SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK) WHERE CpLinkMan.Mobile = a.TelePhone ORDER BY ID DESC)
  12694. FROM @t a
  12695. WHERE a.TelePhone LIKE '1%'
  12696. AND CpLinkManID = 0
  12697. AND IsWtg = 1
  12698. UPDATE a
  12699. SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK INDEX(IX_CpAccount_TelePhone)) WHERE cpAccount.TelePhone LIKE a.TelePhone + '%' AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
  12700. FROM @t a
  12701. WHERE cpAccountID = 0
  12702. AND IsWtg = 1
  12703. UPDATE a
  12704. SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK INDEX(IX_CpAccount_TelePhone)) WHERE cpAccount.TelePhone LIKE a.TelePhone + '%' ORDER BY ID DESC)
  12705. FROM @t a
  12706. WHERE cpAccountID = 0
  12707. AND IsWtg = 1
  12708. UPDATE a
  12709. SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK INDEX(IX_CpLinkMan_Tel)) WHERE CpLinkMan.Tel LIKE a.TelePhone + '%' AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
  12710. FROM @t a
  12711. WHERE CpLinkManID = 0
  12712. AND IsWtg = 1
  12713. UPDATE a
  12714. SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK INDEX(IX_CpLinkMan_Tel)) WHERE CpLinkMan.Tel LIKE a.TelePhone + '%' ORDER BY ID DESC)
  12715. FROM @t a
  12716. WHERE CpLinkManID = 0
  12717. AND IsWtg = 1
  12718. UPDATE a
  12719. SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK INDEX(IX_CpAccount_TelePhone)) WHERE cpAccount.TelePhone LIKE a.TelePhone2 + '%' AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
  12720. FROM @t a
  12721. WHERE cpAccountID = 0
  12722. AND IsWtg = 1
  12723. UPDATE a
  12724. SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK INDEX(IX_CpAccount_TelePhone)) WHERE cpAccount.TelePhone LIKE a.TelePhone2 + '%' ORDER BY ID DESC)
  12725. FROM @t a
  12726. WHERE cpAccountID = 0
  12727. AND IsWtg = 1
  12728. UPDATE a
  12729. SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK INDEX(IX_CpLinkMan_Tel)) WHERE CpLinkMan.Tel LIKE a.TelePhone2 + '%' AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
  12730. FROM @t a
  12731. WHERE CpLinkManID = 0
  12732. AND IsWtg = 1
  12733. UPDATE a
  12734. SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK INDEX(IX_CpLinkMan_Tel)) WHERE CpLinkMan.Tel LIKE a.TelePhone2 + '%' ORDER BY ID DESC)
  12735. FROM @t a
  12736. WHERE CpLinkManID = 0
  12737. AND IsWtg = 1
  12738. UPDATE a
  12739. SET a.cpAccountID = b.cpAccountID
  12740. FROM IvrList a, @t b
  12741. WHERE a.Id = b.Id
  12742. AND IsWtg = 1
  12743. UPDATE a
  12744. SET a.CpLinkManID = b.CpLinkManID
  12745. FROM IvrList a, @t b
  12746. WHERE a.Id = b.Id
  12747. AND IsWtg = 1
  12748. INSERT INTO Wutongguodb..CpContactLog(CpMainID,IvrListID,CpLinkManID,CpAccountID,ContentText,ManageruserID)
  12749. SELECT
  12750. ISNULL(b.CpMainID,c.CpMainID)
  12751. ,a.id
  12752. ,CpLinkManID
  12753. ,CpAccountID
  12754. ,''
  12755. ,Exten
  12756. FROM @t a LEFT JOIN Wutongguodb..CpLinkMan b WITH(NOLOCK) ON a.CpLinkManID = b.ID
  12757. LEFT JOIN Wutongguodb..CpAccount c WITH(NOLOCK) ON a.CpAccountID = c.ID
  12758. WHERE a.IsWtg=1 AND (CpLinkManID >0 OR CpLinkManID>0)
  12759. END
  12760. GO
  12761. /****** Object: StoredProcedure [dbo].[procJobByAlipayEndSelect] Script Date: 2018/12/13 19:10:56 ******/
  12762. SET ANSI_NULLS ON
  12763. GO
  12764. SET QUOTED_IDENTIFIER ON
  12765. GO
  12766. --职位下线存储过程
  12767. CREATE PROCEDURE [dbo].[procJobByAlipayEndSelect]
  12768. (
  12769. @BeginDate VARCHAR(50)
  12770. )
  12771. AS
  12772. BEGIN
  12773. SELECT ID
  12774. FROM Job WITH(NOLOCK)
  12775. WHERE IssueEnd BETWEEN @BeginDate AND GETDATE()
  12776. END
  12777. GO
  12778. /****** Object: StoredProcedure [dbo].[procJobByAlipayPushSelect] Script Date: 2018/12/13 19:10:56 ******/
  12779. SET ANSI_NULLS ON
  12780. GO
  12781. SET QUOTED_IDENTIFIER ON
  12782. GO
  12783. CREATE PROCEDURE [dbo].[procJobByAlipayPushSelect]
  12784. AS
  12785. BEGIN
  12786. CREATE TABLE #T(
  12787. JobID INT,
  12788. JobName NVARCHAR(128),
  12789. JobDesc NVARCHAR(MAX),
  12790. dcJobType INT,
  12791. JobTypeLevel1ID VARCHAR(32),
  12792. JobTypeLevel2ID VARCHAR(32),
  12793. JobTypeLevel3ID VARCHAR(32),
  12794. JobTypeLevel1Name NVARCHAR(50),
  12795. JobTypeLevel2Name NVARCHAR(50),
  12796. JobTypeLevel3Name NVARCHAR(50),
  12797. JobTag NVARCHAR(1000),
  12798. NeedNum INT,
  12799. EmployType TINYINT,
  12800. dcEducationID TINYINT,
  12801. dcSalaryMin VARCHAR(20),
  12802. dcSalaryMax VARCHAR(20),
  12803. CpMainID INT,
  12804. CpName NVARCHAR(256),
  12805. CpLogo VARCHAR(256),
  12806. dcRegionID VARCHAR(6),
  12807. ProvinceID VARCHAR(6),
  12808. ProvinceName NVARCHAR(20),
  12809. CityID VARCHAR(6),
  12810. CityName NVARCHAR(20),
  12811. DistrictID VARCHAR(6),
  12812. DistrictName NVARCHAR(20),
  12813. IssueEnd SMALLDATETIME,
  12814. IssueDate SMALLDATETIME,
  12815. RefreshDate SMALLDATETIME ,
  12816. industry_tier1_code VARCHAR(30),
  12817. industry_tier1 NVARCHAR(50),
  12818. industry_tier2_code VARCHAR(30),
  12819. industry_tier2 NVARCHAR(50),
  12820. homepage VARCHAR(256),
  12821. CpAddress NVARCHAR(256),
  12822. lng VARCHAR(20),
  12823. lat VARCHAR(20),
  12824. ApplyEmail VARCHAR(200)
  12825. )
  12826. INSERT INTO #T(JobID,JobName,JobDesc,dcJobType,NeedNum,EmployType,dcEducationID,CpMainID,dcRegionID,IssueEnd,IssueDate,RefreshDate,dcSalaryMin,dcSalaryMax)
  12827. SELECT TOP 100 a.ID,a.Name,'岗位职责:'+a.Responsibility+'岗位要求:'+a.Demand,a.dcJobTypeID,a.NeedNumber,a.EmployType,a.dcEducationID,a.cpMainID,a.dcRegionID,a.IssueEnd,a.IssueDate,a.RefreshDate,REPLACE(b.DescriptionCp,'K',''),REPLACE(c.DescriptionCp,'K','')
  12828. FROM Job a WITH(NOLOCK)
  12829. LEFT JOIN dcSalary b WITH(NOLOCK) ON b.id = a.dcSalaryID
  12830. LEFT JOIN dcSalary c WITH(NOLOCK) ON c.id = a.dcSalaryIdMax
  12831. WHERE a.Valid = 1
  12832. AND a.id > (SELECT ISNULL(MAX(JobID),0) FROM LogDb..AlipayJobPushLog WITH(NOLOCK))
  12833. AND a.dcSalaryID <> 100
  12834. ORDER BY a.ID ASC
  12835. INSERT INTO LogDb..AlipayJobPushLog(JobId,PushStatus)
  12836. SELECT JobID,0
  12837. FROM #T
  12838. --改为支付宝对应的职位类别信息
  12839. UPDATE a
  12840. SET a.JobTypeLevel3ID = c.alipayID,a.JobTypeLevel3Name = c.alipayDescription
  12841. FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
  12842. WHERE CONVERT(VARCHAR,a.dcJobType) = b.qlrcID
  12843. AND c.id = b.dcAlipayDicID
  12844. AND b.DataType = 3
  12845. AND c.AlipayLevel = 3
  12846. UPDATE #T
  12847. SET JobTypeLevel2ID = (SELECT TOP 1 alipayParentId FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.JobTypeLevel3ID AND DataType = 3)
  12848. WHERE JobTypeLevel3ID IS NOT NULL
  12849. UPDATE #T
  12850. SET JobTypeLevel2Name = (SELECT TOP 1 alipayDescription FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.JobTypeLevel2ID AND DataType = 3)
  12851. WHERE JobTypeLevel2ID IS NOT NULL
  12852. UPDATE a
  12853. SET a.JobTypeLevel2ID = c.alipayID,a.JobTypeLevel2Name = c.alipayDescription
  12854. FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
  12855. WHERE CONVERT(VARCHAR,a.dcJobType) = b.qlrcID
  12856. AND c.id = b.dcAlipayDicID
  12857. AND b.DataType = 3
  12858. AND c.AlipayLevel = 2
  12859. UPDATE #T
  12860. SET JobTypeLevel1ID = (SELECT TOP 1 alipayParentId FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.JobTypeLevel2ID AND DataType = 3)
  12861. WHERE JobTypeLevel2ID IS NOT NULL
  12862. UPDATE #T
  12863. SET JobTypeLevel1Name = (SELECT TOP 1 alipayDescription FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.JobTypeLevel1ID AND DataType = 3)
  12864. WHERE JobTypeLevel1ID IS NOT NULL
  12865. UPDATE a
  12866. SET a.JobTypeLevel1ID = c.alipayID,a.JobTypeLevel1Name = c.alipayDescription
  12867. FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
  12868. WHERE CONVERT(VARCHAR,a.dcJobType) = b.qlrcID
  12869. AND c.id = b.dcAlipayDicID
  12870. AND b.DataType = 3
  12871. AND c.AlipayLevel = 1
  12872. --改为支付宝对应的省份信息
  12873. UPDATE a
  12874. SET a.ProvinceID = c.alipayID,a.ProvinceName = c.alipayDescription
  12875. FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
  12876. WHERE LEFT(a.dcRegionID,2) = b.qlrcID
  12877. AND c.id = b.dcAlipayDicID
  12878. AND b.DataType = 1
  12879. --改为支付宝对应的城市信息
  12880. --修改直辖市的市与省对应
  12881. UPDATE #T
  12882. SET CityID = ProvinceID,CityName = ProvinceName
  12883. WHERE CONVERT(INT,LEFT(dcRegionID,2)) IN(10,11,30,60,90,91,92)
  12884. --非直辖市的并且可以查到城市信息的
  12885. UPDATE a
  12886. SET a.CityID = c.alipayID,a.CityName = c.alipayDescription
  12887. FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
  12888. WHERE LEFT(a.dcRegionID,4) = b.qlrcID
  12889. AND c.id = b.dcAlipayDicID
  12890. AND b.DataType = 1
  12891. AND c.alipaylevel = 2
  12892. AND a.CityID IS NULL
  12893. AND LEN(a.dcRegionID) >=4
  12894. --非直辖市,并且只有省份的修改为直辖市
  12895. UPDATE a
  12896. SET a.CityID = c.alipayID,a.CityName = c.alipayDescription
  12897. FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
  12898. WHERE a.dcRegionID+'01' = b.qlrcID
  12899. AND c.id = b.dcAlipayDicID
  12900. AND b.DataType = 1
  12901. AND c.alipaylevel = 2
  12902. AND a.CityID IS NULL
  12903. AND LEN(a.dcRegionID) = 2
  12904. --改为支付宝对应的区的信息
  12905. UPDATE a
  12906. SET a.DistrictID = c.alipayID,a.DistrictName = c.alipayDescription
  12907. FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
  12908. WHERE a.dcRegionID = b.qlrcID
  12909. AND c.id = b.dcAlipayDicID
  12910. AND b.DataType = 1
  12911. AND c.alipaylevel = 3
  12912. --修改企业名称字段
  12913. UPDATE a
  12914. SET cpName = b.Name
  12915. FROM #T a WITH(NOLOCK),cpMain b WITH(NOLOCK)
  12916. WHERE a.cpMainID = b.ID
  12917. UPDATE #T
  12918. SET CpLogo = (SELECT TOP 1 ImgFile FROM cpImage WITH(NOLOCK) WHERE cpMainID = #T.cpMainID AND ImgType = 1 ORDER BY AddDate DESC)
  12919. UPDATE #T
  12920. SET JobTag = (
  12921. SELECT STUFF((
  12922. SELECT ',' + Tags
  12923. FROM JobTags WITH(NOLOCK)
  12924. WHERE JobID = #T.JobID
  12925. FOR XML PATH('')),1,1,'' )
  12926. )
  12927. --设置企业信息结构
  12928. UPDATE a
  12929. SET a.homepage = b.HomePage,a.CpAddress = b.Address,a.lng = b.Lng,a.lat = b.Lat,a.ApplyEmail = c.EMail
  12930. FROM #T a WITH(NOLOCK),cpmain b WITH(NOLOCK),camain c WITH(NOLOCK)
  12931. WHERE a.CpMainID = b.ID
  12932. AND c.cpMainID = b.ID
  12933. AND c.AccountType = 1
  12934. --设置企业信息所属二级行业code
  12935. UPDATE #T
  12936. SET industry_tier2_code = (
  12937. SELECT TOP 1 d.alipayid
  12938. FROM #T a WITH(NOLOCK),cpIndustry b WITH(NOLOCK),dcAlipayDicConvert c WITH(NOLOCK),dcAlipayDic d WITH(NOLOCK)
  12939. WHERE a.CpMainID = b.cpMainID
  12940. AND c.qlrcId = b.dcIndustryID
  12941. AND d.id = c.dcAlipayDicId
  12942. AND c.DataType = 2
  12943. )
  12944. --设置企业信息所属二级行业
  12945. UPDATE #T
  12946. SET industry_tier2 = (SELECT TOP 1 alipayDescription FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.industry_tier2_code AND DataType = 2)
  12947. WHERE industry_tier2_code IS NOT NULL
  12948. --设置企业信息所属一级行业code
  12949. UPDATE #T
  12950. SET industry_tier1_code = (SELECT TOP 1 alipayParentId FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.industry_tier2_code AND DataType = 2)
  12951. WHERE industry_tier2_code IS NOT NULL
  12952. --设置企业信息所属一级行业
  12953. UPDATE #T
  12954. SET industry_tier1 = (SELECT TOP 1 alipayDescription FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.industry_tier1_code AND DataType = 2)
  12955. WHERE industry_tier1_code IS NOT NULL
  12956. SELECT a.*,b.Welfare1,b.Welfare2,b.Welfare3,b.Welfare4
  12957. ,b.Welfare5,b.Welfare6,b.Welfare7,b.Welfare8,b.Welfare9
  12958. ,b.Welfare10,b.Welfare11,b.Welfare12,b.Welfare13,b.Welfare14
  12959. ,b.Welfare15,b.Welfare16,b.Welfare17,b.Welfare18,b.Welfare19
  12960. FROM #T a
  12961. LEFT JOIN Job b WITH(NOLOCK) ON b.id = a.JobID
  12962. DROP TABLE #T
  12963. END
  12964. GO
  12965. /****** Object: StoredProcedure [dbo].[procJobByAlipayRefreshSelect] Script Date: 2018/12/13 19:10:57 ******/
  12966. SET ANSI_NULLS ON
  12967. GO
  12968. SET QUOTED_IDENTIFIER ON
  12969. GO
  12970. --职位刷新存储过程
  12971. CREATE PROCEDURE [dbo].[procJobByAlipayRefreshSelect]
  12972. (
  12973. @BeginDate VARCHAR(50)
  12974. )
  12975. AS
  12976. BEGIN
  12977. SELECT ID,IssueEnd,RefreshDate
  12978. FROM Job WITH(NOLOCK)
  12979. WHERE Valid = 1
  12980. AND RefreshDate > @BeginDate
  12981. END
  12982. GO
  12983. /****** Object: StoredProcedure [dbo].[procJobByAlipaySelect] Script Date: 2018/12/13 19:10:58 ******/
  12984. SET ANSI_NULLS ON
  12985. GO
  12986. SET QUOTED_IDENTIFIER ON
  12987. GO
  12988. CREATE PROCEDURE [dbo].[procJobByAlipaySelect]
  12989. (
  12990. @BeginDate VARCHAR(50)
  12991. )
  12992. AS
  12993. BEGIN
  12994. CREATE TABLE #T(
  12995. JobID INT,
  12996. JobName NVARCHAR(128),
  12997. JobDesc NVARCHAR(MAX),
  12998. dcJobType INT,
  12999. JobTypeLevel1ID VARCHAR(32),
  13000. JobTypeLevel2ID VARCHAR(32),
  13001. JobTypeLevel3ID VARCHAR(32),
  13002. JobTypeLevel1Name NVARCHAR(50),
  13003. JobTypeLevel2Name NVARCHAR(50),
  13004. JobTypeLevel3Name NVARCHAR(50),
  13005. JobTag NVARCHAR(1000),
  13006. NeedNum INT,
  13007. EmployType TINYINT,
  13008. dcEducationID TINYINT,
  13009. dcSalaryMin VARCHAR(20),
  13010. dcSalaryMax VARCHAR(20),
  13011. CpMainID INT,
  13012. CpName NVARCHAR(256),
  13013. CpLogo VARCHAR(256),
  13014. dcRegionID VARCHAR(6),
  13015. ProvinceID VARCHAR(6),
  13016. ProvinceName NVARCHAR(20),
  13017. CityID VARCHAR(6),
  13018. CityName NVARCHAR(20),
  13019. DistrictID VARCHAR(6),
  13020. DistrictName NVARCHAR(20),
  13021. IssueEnd SMALLDATETIME,
  13022. IssueDate SMALLDATETIME,
  13023. RefreshDate SMALLDATETIME ,
  13024. industry_tier1_code VARCHAR(30),
  13025. industry_tier1 NVARCHAR(50),
  13026. industry_tier2_code VARCHAR(30),
  13027. industry_tier2 NVARCHAR(50),
  13028. homepage VARCHAR(256),
  13029. CpAddress NVARCHAR(256),
  13030. lng VARCHAR(20),
  13031. lat VARCHAR(20),
  13032. ApplyEmail VARCHAR(200)
  13033. )
  13034. INSERT INTO #T(JobID,JobName,JobDesc,dcJobType,NeedNum,EmployType,dcEducationID,CpMainID,dcRegionID,IssueEnd,IssueDate,RefreshDate,dcSalaryMin,dcSalaryMax)
  13035. SELECT a.ID,a.Name,'岗位职责:'+a.Responsibility+'岗位要求:'+a.Demand,a.dcJobTypeID,a.NeedNumber,a.EmployType,a.dcEducationID,a.cpMainID,a.dcRegionID,a.IssueEnd,a.IssueDate,a.RefreshDate,REPLACE(b.DescriptionCp,'K',''),REPLACE(c.DescriptionCp,'K','')
  13036. FROM logdb..AlipayJobPushLog d WITH(NOLOCK)
  13037. LEFT JOIN Job a WITH(NOLOCK) ON d.JobId = a.ID
  13038. LEFT JOIN dcSalary b WITH(NOLOCK) ON b.id = a.dcSalaryID
  13039. LEFT JOIN dcSalary c WITH(NOLOCK) ON c.id = a.dcSalaryIdMax
  13040. WHERE a.dcSalaryID <> 100
  13041. AND d.PushDate IS NULL
  13042. UPDATE logdb..AlipayJobPushLog SET PushDate = GETDATE()
  13043. WHERE JobID IN(SELECT JobID FROM #T)
  13044. --改为支付宝对应的职位类别信息
  13045. UPDATE a
  13046. SET a.JobTypeLevel3ID = c.alipayID,a.JobTypeLevel3Name = c.alipayDescription
  13047. FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
  13048. WHERE CONVERT(VARCHAR,a.dcJobType) = b.qlrcID
  13049. AND c.id = b.dcAlipayDicID
  13050. AND b.DataType = 3
  13051. AND c.AlipayLevel = 3
  13052. UPDATE #T
  13053. SET JobTypeLevel2ID = (SELECT TOP 1 alipayParentId FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.JobTypeLevel3ID AND DataType = 3)
  13054. WHERE JobTypeLevel3ID IS NOT NULL
  13055. UPDATE #T
  13056. SET JobTypeLevel2Name = (SELECT TOP 1 alipayDescription FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.JobTypeLevel2ID AND DataType = 3)
  13057. WHERE JobTypeLevel2ID IS NOT NULL
  13058. UPDATE a
  13059. SET a.JobTypeLevel2ID = c.alipayID,a.JobTypeLevel2Name = c.alipayDescription
  13060. FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
  13061. WHERE CONVERT(VARCHAR,a.dcJobType) = b.qlrcID
  13062. AND c.id = b.dcAlipayDicID
  13063. AND b.DataType = 3
  13064. AND c.AlipayLevel = 2
  13065. UPDATE #T
  13066. SET JobTypeLevel1ID = (SELECT TOP 1 alipayParentId FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.JobTypeLevel2ID AND DataType = 3)
  13067. WHERE JobTypeLevel2ID IS NOT NULL
  13068. UPDATE #T
  13069. SET JobTypeLevel1Name = (SELECT TOP 1 alipayDescription FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.JobTypeLevel1ID AND DataType = 3)
  13070. WHERE JobTypeLevel1ID IS NOT NULL
  13071. UPDATE a
  13072. SET a.JobTypeLevel1ID = c.alipayID,a.JobTypeLevel1Name = c.alipayDescription
  13073. FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
  13074. WHERE CONVERT(VARCHAR,a.dcJobType) = b.qlrcID
  13075. AND c.id = b.dcAlipayDicID
  13076. AND b.DataType = 3
  13077. AND c.AlipayLevel = 1
  13078. --改为支付宝对应的省份信息
  13079. UPDATE a
  13080. SET a.ProvinceID = c.alipayID,a.ProvinceName = c.alipayDescription
  13081. FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
  13082. WHERE LEFT(a.dcRegionID,2) = b.qlrcID
  13083. AND c.id = b.dcAlipayDicID
  13084. AND b.DataType = 1
  13085. --改为支付宝对应的城市信息
  13086. --修改直辖市的市与省对应
  13087. UPDATE #T
  13088. SET CityID = ProvinceID,CityName = ProvinceName
  13089. WHERE CONVERT(INT,LEFT(dcRegionID,2)) IN(10,11,30,60,90,91,92)
  13090. --非直辖市的并且可以查到城市信息的
  13091. UPDATE a
  13092. SET a.CityID = c.alipayID,a.CityName = c.alipayDescription
  13093. FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
  13094. WHERE LEFT(a.dcRegionID,4) = b.qlrcID
  13095. AND c.id = b.dcAlipayDicID
  13096. AND b.DataType = 1
  13097. AND c.alipaylevel = 2
  13098. AND a.CityID IS NULL
  13099. AND LEN(a.dcRegionID) >=4
  13100. --非直辖市,并且只有省份的修改为直辖市
  13101. UPDATE a
  13102. SET a.CityID = c.alipayID,a.CityName = c.alipayDescription
  13103. FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
  13104. WHERE a.dcRegionID+'01' = b.qlrcID
  13105. AND c.id = b.dcAlipayDicID
  13106. AND b.DataType = 1
  13107. AND c.alipaylevel = 2
  13108. AND a.CityID IS NULL
  13109. AND LEN(a.dcRegionID) = 2
  13110. --改为支付宝对应的区的信息
  13111. UPDATE a
  13112. SET a.DistrictID = c.alipayID,a.DistrictName = c.alipayDescription
  13113. FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
  13114. WHERE a.dcRegionID = b.qlrcID
  13115. AND c.id = b.dcAlipayDicID
  13116. AND b.DataType = 1
  13117. AND c.alipaylevel = 3
  13118. --修改企业名称字段
  13119. UPDATE a
  13120. SET cpName = b.Name
  13121. FROM #T a WITH(NOLOCK),cpMain b WITH(NOLOCK)
  13122. WHERE a.cpMainID = b.ID
  13123. UPDATE #T
  13124. SET JobTag = (
  13125. SELECT STUFF((
  13126. SELECT ',' + Tags
  13127. FROM JobTags WITH(NOLOCK)
  13128. WHERE JobID = #T.JobID
  13129. FOR XML PATH('')),1,1,'' )
  13130. )
  13131. --设置企业信息结构
  13132. UPDATE a
  13133. SET a.homepage = b.HomePage,a.CpAddress = b.Address,a.lng = b.Lng,a.lat = b.Lat,a.ApplyEmail = c.EMail,CpLogo = b.LogoFile
  13134. FROM #T a WITH(NOLOCK),cpmain b WITH(NOLOCK),camain c WITH(NOLOCK)
  13135. WHERE a.CpMainID = b.ID
  13136. AND c.cpMainID = b.ID
  13137. AND c.AccountType = 1
  13138. --设置企业信息所属二级行业code
  13139. UPDATE #T
  13140. SET industry_tier2_code = (
  13141. SELECT TOP 1 d.alipayid
  13142. FROM #T a WITH(NOLOCK),cpIndustry b WITH(NOLOCK),dcAlipayDicConvert c WITH(NOLOCK),dcAlipayDic d WITH(NOLOCK)
  13143. WHERE a.CpMainID = b.cpMainID
  13144. AND c.qlrcId = b.dcIndustryID
  13145. AND d.id = c.dcAlipayDicId
  13146. AND c.DataType = 2
  13147. )
  13148. --设置企业信息所属二级行业
  13149. UPDATE #T
  13150. SET industry_tier2 = (SELECT TOP 1 alipayDescription FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.industry_tier2_code AND DataType = 2)
  13151. WHERE industry_tier2_code IS NOT NULL
  13152. --设置企业信息所属一级行业code
  13153. UPDATE #T
  13154. SET industry_tier1_code = (SELECT TOP 1 alipayParentId FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.industry_tier2_code AND DataType = 2)
  13155. WHERE industry_tier2_code IS NOT NULL
  13156. --设置企业信息所属一级行业
  13157. UPDATE #T
  13158. SET industry_tier1 = (SELECT TOP 1 alipayDescription FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.industry_tier1_code AND DataType = 2)
  13159. WHERE industry_tier1_code IS NOT NULL
  13160. SELECT a.*,b.Welfare1,b.Welfare2,b.Welfare3,b.Welfare4
  13161. ,b.Welfare5,b.Welfare6,b.Welfare7,b.Welfare8,b.Welfare9
  13162. ,b.Welfare10,b.Welfare11,b.Welfare12,b.Welfare13,b.Welfare14
  13163. ,b.Welfare15,b.Welfare16,b.Welfare17,b.Welfare18,b.Welfare19
  13164. FROM #T a
  13165. LEFT JOIN Job b WITH(NOLOCK) ON b.id = a.JobID
  13166. DROP TABLE #T
  13167. END
  13168. GO
  13169. /****** Object: StoredProcedure [dbo].[procJobByCaMainIDSelect] Script Date: 2018/12/13 19:10:58 ******/
  13170. SET ANSI_NULLS ON
  13171. GO
  13172. SET QUOTED_IDENTIFIER ON
  13173. GO
  13174. --#####################################################
  13175. --创建时间:2014.11.03
  13176. --创建人:Nick
  13177. --说明:本用户正在发布的职位列表
  13178. --修改:2015-01-15 Andy
  13179. -- 1. 添加dcRegionID列
  13180. -- 2. 去掉try catch
  13181. --#####################################################
  13182. CREATE PROCEDURE [dbo].[procJobByCaMainIDSelect]
  13183. (
  13184. @caMainID INT
  13185. )
  13186. AS
  13187. BEGIN
  13188. SELECT ID, Name, dcRegionID FROM job WITH(NOLOCK) WHERE camainid = @caMainID AND Valid = 1
  13189. END
  13190. GO
  13191. /****** Object: StoredProcedure [dbo].[procJobByConditionCaMainIDSelect] Script Date: 2018/12/13 19:10:59 ******/
  13192. SET ANSI_NULLS ON
  13193. GO
  13194. SET QUOTED_IDENTIFIER ON
  13195. GO
  13196. --#####################################################
  13197. --创建时间:2014.11.04
  13198. --创建人:Nick
  13199. --说明:
  13200. --修改harry 2017-10-19 修改status=1的显示定制刷新状态jobrefreshIng
  13201. --#####################################################
  13202. CREATE PROCEDURE [dbo].[procJobByConditionCaMainIDSelect]
  13203. (
  13204. @CaMainID INT,
  13205. @Condition VARCHAR(500),
  13206. @Status INT
  13207. )
  13208. AS
  13209. BEGIN TRY
  13210. IF CHARINDEX('@',@Condition)>0
  13211. BEGIN
  13212. IF @Status = 1
  13213. BEGIN
  13214. SELECT *,CASE WHEN EXISTS(SELECT 'X' FROM jobRefreshLog WHERE jobId = job.id AND runDateTime is NULL) THEN 1 ELSE 0 END AS jobrefreshIng
  13215. FROM Job WITH(NOLOCK)
  13216. WHERE caMainID=@CaMainID
  13217. AND [ForwardEmail] LIKE '%'+@Condition+'%'
  13218. AND IsDelete=0
  13219. AND IssueEND > GETDATE()
  13220. ORDER BY DisplayNo, IssueEnd, ID DESC
  13221. END
  13222. ELSE
  13223. BEGIN
  13224. SELECT * FROM Job WITH(NOLOCK)
  13225. WHERE caMainID=@CaMainID
  13226. AND [ForwardEmail] LIKE '%'+@Condition+'%'
  13227. AND IsDelete=0
  13228. AND IssueEND < GETDATE()
  13229. ORDER BY IssueEnd DESC
  13230. END
  13231. END
  13232. ELSE
  13233. BEGIN
  13234. IF @Status = 1
  13235. BEGIN
  13236. SELECT *,CASE WHEN EXISTS(SELECT 'X' FROM jobRefreshLog WHERE jobId = job.id AND runDateTime is NULL) THEN 1 ELSE 0 END AS jobrefreshIng
  13237. FROM Job WITH(NOLOCK)
  13238. WHERE caMainID=@CaMainID
  13239. AND [Name] LIKE '%'+@Condition+'%'
  13240. AND IsDelete=0
  13241. AND IssueEND > GETDATE()
  13242. ORDER BY DisplayNo, IssueEnd, ID DESC
  13243. END
  13244. ELSE
  13245. BEGIN
  13246. SELECT * FROM Job WITH(NOLOCK)
  13247. WHERE caMainID=@CaMainID
  13248. AND [Name] LIKE '%'+@Condition+'%'
  13249. AND IsDelete=0
  13250. AND IssueEND < GETDATE()
  13251. ORDER BY IssueEnd DESC
  13252. END
  13253. END
  13254. END TRY
  13255. BEGIN CATCH
  13256. RETURN 0
  13257. END CATCH
  13258. GO
  13259. /****** Object: StoredProcedure [dbo].[procJobByConditionSelect] Script Date: 2018/12/13 19:10:59 ******/
  13260. SET ANSI_NULLS ON
  13261. GO
  13262. SET QUOTED_IDENTIFIER ON
  13263. GO
  13264. --#####################################################
  13265. --创建时间:2014.11.04
  13266. --创建人:Nick
  13267. --说明:企业搜索发布的指定职位
  13268. --修改harry 2017-10-19 修改status=1的显示定制刷新状态jobrefreshIng
  13269. --#####################################################
  13270. CREATE PROCEDURE [dbo].[procJobByConditionSelect]
  13271. (
  13272. @CpMainID INT,
  13273. @Condition VARCHAR(500),
  13274. @Status INT
  13275. )
  13276. AS
  13277. BEGIN TRY
  13278. IF @Status = 1
  13279. BEGIN
  13280. SELECT * ,CASE WHEN EXISTS(SELECT 'X' FROM jobRefreshLog WHERE jobId = job.id AND runDateTime is NULL) THEN 1 ELSE 0 END AS jobrefreshIng
  13281. FROM Job WITH(NOLOCK)
  13282. WHERE cpMainID=@CpMainID
  13283. AND [Name] LIKE '%'+@Condition+'%'
  13284. AND IsDelete=0
  13285. AND IssueEND > GETDATE()
  13286. ORDER BY DisplayNo, IssueEnd, ID DESC
  13287. END
  13288. ELSE
  13289. BEGIN
  13290. SELECT * FROM Job WITH(NOLOCK)
  13291. WHERE cpMainID=@CpMainID
  13292. AND [Name] LIKE '%'+@Condition+'%'
  13293. AND IsDelete=0
  13294. AND IssueEND < GETDATE()
  13295. ORDER BY IssueEnd DESC
  13296. END
  13297. END TRY
  13298. BEGIN CATCH
  13299. RETURN 0
  13300. END CATCH
  13301. GO
  13302. /****** Object: StoredProcedure [dbo].[ProcJobByCpMainID] Script Date: 2018/12/13 19:10:59 ******/
  13303. SET ANSI_NULLS ON
  13304. GO
  13305. SET QUOTED_IDENTIFIER ON
  13306. GO
  13307. --创建人 Lambo
  13308. --20101009
  13309. --用于首页根据单位编号查询职位名称
  13310. CREATE PROCEDURE [dbo].[ProcJobByCpMainID]
  13311. (
  13312. @cpMainID INT
  13313. )
  13314. AS
  13315. BEGIN
  13316. SELECT TOP 20 Id, Name
  13317. FROM Job WITH(NOLOCK)
  13318. WHERE cpMainID = @cpMainID AND valid=1
  13319. ORDER BY DisplayNo, dcJobTypeID
  13320. END
  13321. GO
  13322. /****** Object: StoredProcedure [dbo].[procJobByCpMainIDSelect] Script Date: 2018/12/13 19:10:59 ******/
  13323. SET ANSI_NULLS ON
  13324. GO
  13325. SET QUOTED_IDENTIFIER ON
  13326. GO
  13327. --#####################################################
  13328. --创建时间:2014.11.03
  13329. --创建人:Nick
  13330. --说明:得到公司正在发布的职位列表
  13331. --#####################################################
  13332. CREATE PROCEDURE [dbo].[procJobByCpMainIDSelect]
  13333. (
  13334. @cpMainID INT
  13335. )
  13336. AS
  13337. BEGIN TRY
  13338. SELECT a.ID,a.Name,a.IssueEnd
  13339. FROM Job a WITH(NOLOCK)
  13340. WHERE a.cpMainID = @cpMainID AND Valid=1
  13341. ORDER BY a.Valid DESC,a.IssueEnd DESC
  13342. END TRY
  13343. BEGIN CATCH
  13344. RETURN 0
  13345. END CATCH
  13346. GO
  13347. /****** Object: StoredProcedure [dbo].[procJobByIDSelect] Script Date: 2018/12/13 19:10:59 ******/
  13348. SET ANSI_NULLS ON
  13349. GO
  13350. SET QUOTED_IDENTIFIER ON
  13351. GO
  13352. --#####################################################
  13353. --创建时间:2014.11.03
  13354. --创建人:Nick
  13355. --说明:获取职位的过滤条件
  13356. --#####################################################
  13357. CREATE PROCEDURE [dbo].[procJobByIDSelect]
  13358. (
  13359. @ID INT
  13360. )
  13361. AS
  13362. BEGIN
  13363. SELECT * FROM Job WITH(NOLOCK) WHERE Id = @ID
  13364. END
  13365. GO
  13366. /****** Object: StoredProcedure [dbo].[ProcJobByIndustryIdSelect] Script Date: 2018/12/13 19:11:00 ******/
  13367. SET ANSI_NULLS ON
  13368. GO
  13369. SET QUOTED_IDENTIFIER ON
  13370. GO
  13371. --#####################################################
  13372. --创建时间:2015.3.31
  13373. --创建人:Andy
  13374. --说明:获取可能感兴趣的公司
  13375. --#####################################################
  13376. --ProcJobByIndustryIdSelect 1,1
  13377. CREATE PROCEDURE [dbo].[ProcJobByIndustryIdSelect]
  13378. (
  13379. @RegionID INT,
  13380. @IndustryID INT
  13381. )
  13382. AS
  13383. BEGIN
  13384. SELECT TOP 10
  13385. a.cpMainID,
  13386. a.RefreshDate,
  13387. a.dcRegionID,
  13388. a.Name,
  13389. a.dcSalaryID,
  13390. a.SecondID,
  13391. b.Name cpName,
  13392. b.SecondID cpSecondID,
  13393. b.LastLoginDate,
  13394. (SELECT subSiteUrl FROM dcSubSite WHERE id = b.dcProvinceID) subSiteUrl
  13395. FROM jobPublish a
  13396. LEFT JOIN cpMain b ON a.CpMainID = b.ID
  13397. WHERE a.cpMainId IN
  13398. (
  13399. SELECT TOP 10 realid
  13400. FROM Searchdb..CpMainSameIndustry WITH(NOLOCK)
  13401. WHERE dcIndustryID = @IndustryID AND dcRegionId = @RegionID
  13402. )
  13403. ORDER BY RefreshDate DESC
  13404. END
  13405. GO
  13406. /****** Object: StoredProcedure [dbo].[ProcJobByJobuiIndexSelect] Script Date: 2018/12/13 19:11:00 ******/
  13407. SET ANSI_NULLS ON
  13408. GO
  13409. SET QUOTED_IDENTIFIER ON
  13410. GO
  13411. create PROCEDURE [dbo].[ProcJobByJobuiIndexSelect]
  13412. AS
  13413. SET NOCOUNT ON
  13414. BEGIN
  13415. SELECT DISTINCT dcProvinceId, PageNo
  13416. FROM ShortDb..JobuiJobXmlOut
  13417. ORDER BY dcProvinceId, PageNo
  13418. END
  13419. GO
  13420. /****** Object: StoredProcedure [dbo].[ProcJobByJobuiSelect] Script Date: 2018/12/13 19:11:00 ******/
  13421. SET ANSI_NULLS ON
  13422. GO
  13423. SET QUOTED_IDENTIFIER ON
  13424. GO
  13425. CREATE PROCEDURE [dbo].[ProcJobByJobuiSelect]
  13426. (
  13427. @ProvinceId INT,
  13428. @PageNo INT
  13429. )
  13430. AS
  13431. SET NOCOUNT ON
  13432. BEGIN
  13433. IF ISNULL(@ProvinceId, 0) < 10
  13434. SELECT @ProvinceId = 10
  13435. IF ISNULL(@PageNo, 0) < 1
  13436. SELECT @PageNo = 1
  13437. SELECT * FROM ShortDb..JobuiJobXmlOut WHERE dcProvinceId = @ProvinceId AND PageNo = @PageNo ORDER BY Id
  13438. END
  13439. GO
  13440. /****** Object: StoredProcedure [dbo].[ProcJobByNewst30Select] Script Date: 2018/12/13 19:11:00 ******/
  13441. SET ANSI_NULLS ON
  13442. GO
  13443. SET QUOTED_IDENTIFIER ON
  13444. GO
  13445. CREATE PROCEDURE [dbo].[ProcJobByNewst30Select]
  13446. (
  13447. @dcProvinceID INT
  13448. )
  13449. AS
  13450. SET NOCOUNT ON
  13451. BEGIN
  13452. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  13453. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  13454. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  13455. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  13456. a.IsDelete, a.AddDate, a.RefreshDate, a.Welfare1, a.Welfare2, a.Welfare3,
  13457. a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8,
  13458. a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13,
  13459. a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18, a.Welfare19,
  13460. a.SecondId EnJobID, b.SecondId EnCpMainID,
  13461. a.LastModifyDate, b.Name cpName, b.dcCompanySizeID,
  13462. b.HasLicence, b.RealName, b.UnLimitedDate, b.BalanceDate, b.Balance,
  13463. b.MemberType, '' cpIndustry, --STUFF((SELECT ',' + LTRIM(x.dcIndustryid) + ',c' + LTRIM(isnull(y.Category,0)) FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  13464. 0, b.IsRefreshed, ISNULL(d.IsOnline, 0) IsOnline, d.IsVi, d.ViPlanId, d.InterviewDate, CASE WHEN b.ReplyRate >= 0.6 THEN b.ReplyRate ELSE NULL END Replyrate,
  13465. NULL AttentionId
  13466. FROM JobPublish a WITH(NOLOCK)
  13467. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  13468. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  13469. WHERE b.dcProvinceId = @dcProvinceID
  13470. ORDER BY a.RefreshDate DESC
  13471. END
  13472. GO
  13473. /****** Object: StoredProcedure [dbo].[procJobBySalarySelect] Script Date: 2018/12/13 19:11:01 ******/
  13474. SET ANSI_NULLS ON
  13475. GO
  13476. SET QUOTED_IDENTIFIER ON
  13477. GO
  13478. CREATE PROCEDURE [dbo].[procJobBySalarySelect]
  13479. (
  13480. @dcJobTypeId INT,
  13481. @dcRegionId VARCHAR(6)
  13482. )
  13483. AS
  13484. SET NOCOUNT ON
  13485. BEGIN
  13486. DECLARE @AddDate DATETIME
  13487. SELECT TOP 1 @AddDate = AddDate FROM ShortDb..JobSalaryAnalysis QITH(NOLOCK) WHERE JobTypeId = @dcjobTypeId AND RegionId = @dcRegionId
  13488. IF @AddDate > DATEADD(MINUTE, -10, GETDATE())
  13489. BEGIN
  13490. SELECT * FROM ShortDb..JobSalaryAnalysis WITH(NOLOCK) WHERE JobTypeId = @dcjobTypeId AND RegionId = @dcRegionId ORDER BY RowNo
  13491. RETURN
  13492. END
  13493. ELSE
  13494. DELETE FROM ShortDb..JobSalaryAnalysis WHERE JobTypeId = @dcjobTypeId AND RegionId = @dcRegionId
  13495. DECLARE @SQL AS VARCHAR(MAX)
  13496. SET @SQL = 'INSERT INTO ShortDb..JobSalaryAnalysis
  13497. SELECT TOP 60 ' + @dcRegionId + ' RegionId, ' + LTRIM(STR(@dcJobTypeId)) + ' JobTypeId, GETDATE() AddDate, a.Id, a.SecondId, a.Name JobName, a.NeedNumber, a.DcSalaryID,
  13498. dbo.GetCaOnlineStatus(a.caMainID) AS IsOnline, a.MinExperience,a.caMainId, b.LogoFile LogoUrl, a.SecondId enjobid,
  13499. a.DcSalaryIdMax, a.DcRegionID, b.Name CpName, a.dcEducationID, b.SecondId cpSecondId,
  13500. STUFF((SELECT ''、'' + Tags FROM JobTags WITH(NOLOCK) WHERE jobID = a.ID FOR XML PATH('''')),1,1,'''') JobTags
  13501. FROM JobPublish a WITH(NOLOCK) INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainId=b.Id
  13502. WHERE a.cpMainID = b.ID AND dcSalaryIDMax < 100 AND dcSalaryID < 100'
  13503. IF ISNULL(@dcRegionId, '') <> ''
  13504. SET @SQL = @SQL + ' AND a.dcRegionID LIKE ''' + CONVERT(VARCHAR(4), @dcRegionId) + '%'''
  13505. IF @dcJobTypeId > 0
  13506. SET @SQL = @SQL + ' AND a.dcJobTypeID LIKE ''' + CONVERT(VARCHAR(4), @dcJobTypeId) + '%'''
  13507. SET @SQL = @SQL + ' ORDER BY (dcSalaryIDMax + dcSalaryID) DESC, a.RefreshDate DESC'
  13508. --PRINT @SQL
  13509. EXEC(@SQL)
  13510. SELECT * FROM ShortDb..JobSalaryAnalysis WITH(NOLOCK) WHERE JobTypeId = @dcjobTypeId AND RegionId = @dcRegionId ORDER BY RowNo
  13511. END
  13512. SET NOCOUNT OFF
  13513. GO
  13514. /****** Object: StoredProcedure [dbo].[procJobBySosoSelect] Script Date: 2018/12/13 19:11:01 ******/
  13515. SET ANSI_NULLS ON
  13516. GO
  13517. SET QUOTED_IDENTIFIER ON
  13518. GO
  13519. --#####################################################
  13520. --创建时间:2014.11.10
  13521. --创建人:John
  13522. --说明:获取SosoXML数据
  13523. --#####################################################
  13524. CREATE PROCEDURE [dbo].[procJobBySosoSelect]
  13525. (
  13526. @pid INT
  13527. )
  13528. AS
  13529. BEGIN
  13530. SELECT a.id jobid,b.id cpid,a.name jobname,dbo.GetCpIndustry(b.id) industry,b.name cpname,a.dcSalaryID,g.DescriptionEng NeedNumber,
  13531. f.description jobtypebig,b.dccompanykindid,e.description jobtypesmall,h.Description employtype,a.minexperience,c.fullname region,
  13532. i.description education,a.issuedate,a.issueend,a.responsibility
  13533. FROM job a WITH(NOLOCK) INNER JOIN cpmain b WITH(NOLOCK) ON a.cpmainid = b.id
  13534. LEFT JOIN dcRegion c WITH(NOLOCK) ON c.id = a.dcRegionID
  13535. LEFT JOIN dcJobType e WITH(NOLOCK) ON e.id = a.dcJobTypeID
  13536. LEFT JOIN dcJobType f WITH(NOLOCK) ON f.id = left(a.dcJobTypeID,2)
  13537. LEFT JOIN dcothers g WITH(NOLOCK) ON g.Category = '招聘人数' AND g.detailid = a.NeedNumber
  13538. LEFT JOIN dcothers h WITH(NOLOCK) ON h.Category = '工作性质' AND h.detailid = a.employtype
  13539. LEFT JOIN dceducation i WITH(NOLOCK) ON i.id = a.dceducationID
  13540. WHERE a.valid = 1 AND b.valid = 1 AND dcprovinceid = @pid ORDER BY a.refreshdate DESC
  13541. END
  13542. GO
  13543. /****** Object: StoredProcedure [dbo].[procJobCountByRegionIDSelect] Script Date: 2018/12/13 19:11:01 ******/
  13544. SET ANSI_NULLS ON
  13545. GO
  13546. SET QUOTED_IDENTIFIER ON
  13547. GO
  13548. --#####################################################
  13549. --创建时间:2014.11.03
  13550. --创建人:Nick
  13551. --说明:根据职位列表和工作地点获取数量
  13552. --#####################################################
  13553. CREATE PROCEDURE [dbo].[procJobCountByRegionIDSelect]
  13554. (
  13555. @RegionID VARCHAR(6),
  13556. @JobTypeID VARCHAR(20)
  13557. )
  13558. AS
  13559. BEGIN TRY
  13560. SELECT COUNT(1) cnt
  13561. FROM job a WITH(NOLOCK)
  13562. WHERE a.dcjobtypeid LIKE ''+@JobTypeID+'%'
  13563. AND a.dcregionid like ''+@RegionID+'%'
  13564. AND a.Valid>0
  13565. AND a.dcSalaryID IS NOT NULL
  13566. AND a.dcSalaryID<>100
  13567. AND a.RefreshDate>GetDate()-365
  13568. END TRY
  13569. BEGIN CATCH
  13570. RETURN 0
  13571. END CATCH
  13572. GO
  13573. /****** Object: StoredProcedure [dbo].[procJobEMailSendFreqByIDUpdate] Script Date: 2018/12/13 19:11:01 ******/
  13574. SET ANSI_NULLS ON
  13575. GO
  13576. SET QUOTED_IDENTIFIER ON
  13577. GO
  13578. --#####################################################
  13579. --创建时间:2014.11.04
  13580. --创建人:Nick
  13581. --说明:修改职位的订阅
  13582. --#####################################################
  13583. CREATE PROCEDURE [dbo].[procJobEMailSendFreqByIDUpdate]
  13584. (
  13585. @eMailSendFreq INT,
  13586. @eMailSendNumber INT,
  13587. @ID INT
  13588. )
  13589. AS
  13590. BEGIN TRY
  13591. UPDATE JOB SET EMailSendFreq=@eMailSendFreq, EMailSendNumber=@eMailSendNumber WHERE ID = @ID
  13592. RETURN 1
  13593. END TRY
  13594. BEGIN CATCH
  13595. RETURN 0
  13596. END CATCH
  13597. GO
  13598. /****** Object: StoredProcedure [dbo].[procJobJobTypeIDSelect] Script Date: 2018/12/13 19:11:01 ******/
  13599. SET ANSI_NULLS ON
  13600. GO
  13601. SET QUOTED_IDENTIFIER ON
  13602. GO
  13603. --#####################################################
  13604. --创建时间:2014.11.03
  13605. --创建人:Nick
  13606. --说明:获取职位列表、工作地点
  13607. --#####################################################
  13608. CREATE PROCEDURE [dbo].[procJobJobTypeIDSelect]
  13609. (
  13610. @CpMainID VARCHAR(20),
  13611. @JobID VARCHAR(20),
  13612. @CaMainID VARCHAR(20),
  13613. @IsManager INT
  13614. )
  13615. AS
  13616. BEGIN TRY
  13617. IF @JobID = ''
  13618. BEGIN
  13619. IF @IsManager = 1
  13620. BEGIN
  13621. SELECT TOP 1 dcJobtypeID,dcRegionID
  13622. FROM job WITH(NOLOCK)
  13623. WHERE issueEnd>getdate()
  13624. AND isdelete=0
  13625. AND valid=1
  13626. AND cpMainID= CONVERT(INT,@CpMainID)
  13627. ORDER BY AddDate DESC
  13628. END
  13629. ELSE
  13630. BEGIN
  13631. SELECT TOP 1 dcJobtypeID,dcRegionID
  13632. FROM job WITH(NOLOCK)
  13633. WHERE issueEnd>getdate() AND isdelete=0 AND valid=1
  13634. AND caMainID = CONVERT(INT,@CaMainID) ORDER BY AddDate DESC
  13635. END
  13636. END
  13637. ELSE
  13638. BEGIN
  13639. SELECT TOP 1 dcJobtypeID,dcRegionID
  13640. FROM job WITH(NOLOCK)
  13641. WHERE issueEnd>getdate() AND isdelete=0 AND valid=1
  13642. AND ID=CONVERT(INT,@JobID) AND cpMainID=CONVERT(INT,@CpMainID)
  13643. END
  13644. END TRY
  13645. BEGIN CATCH
  13646. RETURN 0
  13647. END CATCH
  13648. GO
  13649. /****** Object: StoredProcedure [dbo].[ProcJobMapIdByProvinceIdSelect] Script Date: 2018/12/13 19:11:02 ******/
  13650. SET ANSI_NULLS ON
  13651. GO
  13652. SET QUOTED_IDENTIFIER ON
  13653. GO
  13654. --#####################################################
  13655. --创建时间:2014.10.28
  13656. --创建人:John
  13657. --说明:根据省份得到JobMap信息
  13658. --@provinceId 省份编号
  13659. --#####################################################
  13660. CREATE PROCEDURE [dbo].[ProcJobMapIdByProvinceIdSelect]
  13661. (
  13662. @provinceId VARCHAR(2)
  13663. )
  13664. AS
  13665. BEGIN TRY
  13666. SELECT ID FROM marketdb..MapClass WHERE dcSubSiteId = @provinceId
  13667. END TRY
  13668. BEGIN CATCH
  13669. RETURN 0
  13670. END CATCH
  13671. GO
  13672. /****** Object: StoredProcedure [dbo].[ProcJobMatchDataByPaMainIDSelect] Script Date: 2018/12/13 19:11:02 ******/
  13673. SET ANSI_NULLS ON
  13674. GO
  13675. SET QUOTED_IDENTIFIER ON
  13676. GO
  13677. --#####################################################
  13678. --创建时间:2014.11.4
  13679. --创建人:John
  13680. --说明:获取用于职位匹配的数据
  13681. --#####################################################
  13682. CREATE PROCEDURE [dbo].[ProcJobMatchDataByPaMainIDSelect]
  13683. (
  13684. @paMainID INT
  13685. )
  13686. AS
  13687. BEGIN
  13688. SELECT TOP 1 a.ID cvMainID,Degree,ISNULL(RelatedWorkYears,0) RelatedWorkYears,dcSalaryID,IsNegotiable,dbo.BirthToAge(b.Birthday) age,
  13689. STUFF((SELECT ',' + LTRIM(dcJobTypeID) FROM cvJobType WHERE cvMainid = a.ID FOR XML PATH('')),1,1,'') JobTypeID,
  13690. STUFF((SELECT ',' + LTRIM(dcRegionID) FROM cvJobPlace WHERE cvMainid = a.ID FOR XML PATH('')),1,1,'') RegionID,
  13691. STUFF((
  13692. SELECT ','+LTRIM(x.dcIndustryID)+',c'+LTRIM(y.CateGoryId)
  13693. FROM cvIndustry x WITH(NOLOCK),dcIndustryCategory y WITH(NOLOCK)
  13694. WHERE x.dcIndustryid = y.dcIndustryid AND x.cvMainid = a.ID FOR XML PATH('')),1,1,'') Industry
  13695. From cvMain a WITH(NOLOCK), paMain b WITH(NOLOCK)
  13696. WHERE a.paMainID = b.ID AND paMainID = @paMainID
  13697. ORDER BY a.CvLevel DESC,a.RefreshDate DESC
  13698. END
  13699. GO
  13700. /****** Object: StoredProcedure [dbo].[procJobNameCopySelect] Script Date: 2018/12/13 19:11:02 ******/
  13701. SET ANSI_NULLS ON
  13702. GO
  13703. SET QUOTED_IDENTIFIER ON
  13704. GO
  13705. CREATE PROCEDURE [dbo].[procJobNameCopySelect]
  13706. (
  13707. @provinceId INT,
  13708. @KeyWord VARCHAR(50),
  13709. @Type INT
  13710. )
  13711. AS
  13712. SET NOCOUNT ON
  13713. BEGIN
  13714. DECLARE @t AS TABLE(id INT IDENTITY(1, 1), JobName NVARCHAR(50), JobNumber INT)
  13715. DECLARE @Top INT
  13716. IF @Type = 1
  13717. BEGIN
  13718. INSERT INTO @t
  13719. SELECT TOP 10 JobName, JobNumber
  13720. FROM JobNameCopy WITH(NOLOCK)
  13721. WHERE dcProvinceId = @provinceId
  13722. AND JobName LIKE @KeyWord + '_%'
  13723. ORDER BY JobNumber DESC
  13724. SET @Top = 10 - @@ROWCOUNT
  13725. END
  13726. ELSE
  13727. BEGIN
  13728. INSERT INTO @t
  13729. SELECT TOP 10 JobName, JobNumber
  13730. FROM JobNameCopy WITH(NOLOCK)
  13731. WHERE dcProvinceId = @provinceId
  13732. AND PinYin LIKE @KeyWord + '_%'
  13733. ORDER BY JobNumber DESC
  13734. SET @Top = 10 - @@ROWCOUNT
  13735. END
  13736. IF @Top > 0
  13737. INSERT INTO @t
  13738. SELECT TOP (@Top) Name, ISNULL(AvgSalary, 0)
  13739. FROM cpMainPublish WITH(NOLOCK)
  13740. WHERE dcProvinceId = @provinceId
  13741. AND CHARINDEX(@Keyword, Name) > 0
  13742. ORDER BY AvgSalary DESC
  13743. DECLARE @json VARCHAR(max)
  13744. SET @json = (SELECT * FROM @t ORDER BY Id FOR JSON AUTO)
  13745. SELECT @json jsonstr
  13746. END
  13747. GO
  13748. /****** Object: StoredProcedure [dbo].[procJobPublishByRegionIdSelect] Script Date: 2018/12/13 19:11:02 ******/
  13749. SET ANSI_NULLS ON
  13750. GO
  13751. SET QUOTED_IDENTIFIER ON
  13752. GO
  13753. --#####################################################
  13754. --创建时间:2015.7.3
  13755. --创建人:MICE
  13756. --说明:县级站获取5条最新职位
  13757. --#####################################################
  13758. CREATE PROCEDURE [dbo].[procJobPublishByRegionIdSelect]
  13759. (
  13760. @regionId INT
  13761. )
  13762. AS
  13763. BEGIN
  13764. SET NOCOUNT ON
  13765. SELECT TOP 5 a.cpmainId, a.[Name] AS jobName, a.SecondId AS jobId, b.[Name] AS cpName
  13766. FROM Maindb..JobPublish a WITH(NOLOCK) ,Maindb..cpMainPublish b WITH(NOLOCK)
  13767. WHERE a.dcregionId = @regionId AND a.valid = 1 AND a.cpmainId = b.id
  13768. ORDER BY a.LastModifyDate DESC
  13769. SET NOCOUNT OFF
  13770. END
  13771. GO
  13772. /****** Object: StoredProcedure [dbo].[ProcJobPublishMatch] Script Date: 2018/12/13 19:11:02 ******/
  13773. SET ANSI_NULLS ON
  13774. GO
  13775. SET QUOTED_IDENTIFIER ON
  13776. GO
  13777. CREATE PROCEDURE [dbo].[ProcJobPublishMatch]
  13778. AS
  13779. BEGIN
  13780. SET NOCOUNT on
  13781. delete jobpublish where id in(select top 100 id from JobPublish WITH(NOLOCK) where valid=0)
  13782. SELECT a.ID cpMainId, b.Id JobId
  13783. INTO #3
  13784. FROM cpMain a WITH(NOLOCK), Job b WITH(NOLOCK)
  13785. WHERE a.id = b.cpMainId AND a.Valid= 1 AND b.Valid = 1
  13786. AND b.id NOT IN(SELECT b.Id JobId
  13787. FROM cpMainPublish a WITH(NOLOCK), JobPublish b WITH(NOLOCK)
  13788. WHERE a.id = b.cpMainId AND a.Valid= 1 AND b.Valid = 1)
  13789. AND a.LastLoginDate > CONVERT(VARCHAR(10), GETDATE() - 183, 120)
  13790. DECLARE @S VARCHAR(MAX)
  13791. SET @s = ''
  13792. select DISTINCT @s = @s + 'UPDATE cpMain SET RefreshDate=RefreshDate WHERE ID = ' + LTRIM(STR(cpMainId)) + '
  13793. '
  13794. from #3
  13795. --print @s
  13796. EXEC(@S)
  13797. SET @s = ''
  13798. select @s = @s + 'UPDATE Job SET RefreshDate=RefreshDate WHERE ID = ' + LTRIM(STR(JobId)) + '
  13799. '
  13800. from #3
  13801. print @s
  13802. EXEC(@S)
  13803. END
  13804. GO
  13805. /****** Object: StoredProcedure [dbo].[procJobPublishSelect] Script Date: 2018/12/13 19:11:03 ******/
  13806. SET ANSI_NULLS ON
  13807. GO
  13808. SET QUOTED_IDENTIFIER ON
  13809. GO
  13810. /*
  13811. go
  13812. DECLARE @json NVARCHAR(MAX) = N'
  13813. {
  13814. "ip":"192.168.1.1",
  13815. "province":"32",
  13816. "JobType":"",
  13817. "region":"32",
  13818. "Negotiable":"0",
  13819. "keyword":"齐鲁 人才",
  13820. "cvJobType":"24",
  13821. "cvregion":"3212"
  13822. }';
  13823. set @json = '{"dcJobTypeID" : "",
  13824. "dcRegionId" : "32",
  13825. "dcIndustryID" : "",
  13826. "dcSalaryID" : "",
  13827. "IsNegotiable" : "",
  13828. "MinExperience" : "",
  13829. "dcEducationID" : "",
  13830. "EmployType" : "",
  13831. "KeyWord" : "请填写关键词或选择职位",
  13832. "KeyType" : "1",
  13833. "Order" : "",
  13834. "RefreshNo" : "32",
  13835. "Type" : "1",
  13836. "PageNumber" : "1",
  13837. "SessionID" : "60.215.144.163",
  13838. "CompanySizeID" : "",
  13839. "JobID" : "0",
  13840. "Welfare" : "",
  13841. "IsOnline" : ""
  13842. }
  13843. '
  13844. exec procJobPublishSelect '[{"dcRegionId":"32","dcIndustryID":"5"}]'
  13845. go
  13846. select * from jsonlist
  13847. */
  13848. CREATE PROCEDURE [dbo].[procJobPublishSelect]
  13849. (
  13850. @json nVARCHAR(max)
  13851. )
  13852. as
  13853. SET NOCOUNT ON
  13854. DECLARE @Start DATETIME
  13855. SET @Start = GETDATE()
  13856. DECLARE @Sql VARCHAR(MAX), @Order VARCHAR(1000), @Exe VARCHAR(MAX), @Result INT = 0, @CanReturn BIT = 0, @ValidJobNumber INT = 0
  13857. BEGIN TRY
  13858. --分析参数结束开始,约3ms
  13859. DECLARE @t_value AS TABLE (name VARCHAR(20), para VARCHAR(500), seq int);
  13860. INSERT INTO @t_value
  13861. SELECT * FROM OPENJSON(@json);
  13862. DECLARE @Province INT = 32,
  13863. @JobType VARCHAR(50) = '', --职位类别
  13864. @Region VARCHAR(50) = '', --求职地区
  13865. @MapPlace INT = 0,
  13866. @Industry VARCHAR(20) = '', --求职行业
  13867. @MinSalary TINYINT = 0, --月薪
  13868. @MaxSalary TINYINT = 0, --月薪
  13869. @ReplyRate TINYINT = 0,
  13870. @Negotiable TINYINT = 0, --1面议,不面议
  13871. @Experience TINYINT = 100, --工作经验,100为未选择
  13872. @Education TINYINT = 0, --最低学历
  13873. @EmpType VARCHAR(10) = '', --工作性质,1全职;3兼职;4实习,
  13874. @KeyWord NVARCHAR(50) = '', --关键词
  13875. @PageNumber INT = 1, --翻页页码
  13876. @CompanySize INT = 0, --企业规模
  13877. @Welfare VARCHAR(50) = '',
  13878. @OnlyOnline INT = 0, --1在线
  13879. @OnlyEnv INT = 0,
  13880. @cvRegion VARCHAR(50) = '',
  13881. @cvJobType VARCHAR(50) = '',
  13882. @ip VARCHAR(15) = '',
  13883. @paMainId INT = 0,
  13884. @JobSearchLogId INT = 0,
  13885. @FilterLogID INT = 0,
  13886. @Source INT = 1, --1-pc+m,10-app
  13887. @ShowFilter INT = 1
  13888. CREATE TABLE #t_jobid(Id INT IDENTITY(1, 1), JobId INT)
  13889. CREATE TABLE #t_companyList(Id int NOT NULL, SecondId varchar(10) NULL, Name nvarchar(100) NULL, RealName TINYINT, Lng Decimal(8, 5), Lat DEcimal(8, 5), HasLicence BIT, LogoFile VARCHAR(90), dcRegionId varchar(6) NULL, dcIndustryID smallint NULL, JobNumber int NULL, seq INT IDENTITY(1, 1))
  13890. CREATE TABLE #t_companyTemp(Id INT, AvgSalary INT, LastLogindate DATETIME, seq INT IDENTITY(1, 1))
  13891. CREATE TABLE #FullText(Id INT IDENTITY(1, 1), Priority INT, JobId INT NOT NULL)
  13892. DECLARE @t_filter AS TABLE (FilterType INT, TypeID VARCHAR(10), TypeNumber INT)
  13893. DECLARE @t_top AS TABLE(JobID INT, seq int IDENTITY(1, 1))
  13894. DECLARE @t_jobid AS TABLE(Id INT IDENTITY(1, 1), JobId INT, IsTop BIT)
  13895. DECLARE @PageSize INT = 30, @FillJobId INT = 0, @cpMainResult INT = 0, @KeyJobTypeIds VARCHAR(24) = '', @para VARCHAR(100)
  13896. DECLARE @strJobType AS VARCHAR(2000) = '', @strJobPlace AS VARCHAR(2000) = '', @strCvRegion VARCHAR(MAX) = '', @strCvJobType VARCHAR(MAX) = ''
  13897. DECLARE @filterExpired INT = -30, @jobExpired INT = -1, @Logo VARCHAR(50) = '/content/personal/images/defaultCpImg.png'
  13898. SELECT @Province = para FROM @t_value WHERE name = 'RefreshNo' AND para > 0
  13899. IF @Province > 100
  13900. SELECT @Province = @Province - 100, @OnlyEnv = 1
  13901. SELECT @para = para FROM @t_value WHERE name = 'order' AND para > ''
  13902. IF @para LIKE 'r=%'
  13903. SET @ReplyRate = CONVERT(DECIMAL(4, 2), RIGHT(LEFT(@para, 5), 3)) * 100
  13904. ELSE IF @para LIKE '%p=%'
  13905. SET @paMainId = RIGHT(@para, LEN(@para) - CHARINDEX('p=', @para) - 1)
  13906. SELECT @JobType = para FROM @t_value WHERE name = 'dcJobTypeID' AND para > ''
  13907. SELECT @Region = para FROM @t_value WHERE name = 'dcRegionId' AND para > ''
  13908. SELECT @Industry = para FROM @t_value WHERE name = 'dcIndustryID' AND para > ''
  13909. SELECT @MinSalary = para FROM @t_value WHERE name = 'dcSalaryID' AND para > 0
  13910. --SELECT @MaxSalary = para FROM @t_value WHERE name = 'maxSalary' AND para > 0
  13911. IF @MinSalary > 0
  13912. BEGIN
  13913. IF @MinSalary < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
  13914. SET @MaxSalary = @MinSalary + 1
  13915. ELSE IF @MinSalary BETWEEN 101 AND 106 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  13916. SELECT @MaxSalary = @MinSalary - 99, @MinSalary = @MinSalary - 99
  13917. ELSE IF @MinSalary BETWEEN 107 AND 113 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  13918. SELECT @MaxSalary = @MinSalary - 99, @MinSalary = @MinSalary - 100
  13919. ELSE IF @MinSalary BETWEEN 114 AND 120
  13920. SELECT @MaxSalary = @MinSalary - 99, @MinSalary = 17
  13921. END
  13922. SELECT @Negotiable = para FROM @t_value WHERE name = 'IsNegotiable' AND para = 1
  13923. SELECT @Experience = para FROM @t_value WHERE name = 'MinExperience' AND para > 0
  13924. SELECT @ReplyRate = para FROM @t_value WHERE name = 'replyrate' AND para > 0
  13925. SELECT @Education = para FROM @t_value WHERE name = 'dcEducationID' AND para > 0
  13926. SELECT @EmpType = para FROM @t_value WHERE name = 'EmployType' AND para > ''
  13927. SELECT @KeyWord = para FROM @t_value WHERE name = 'KeyWord' AND para > ''
  13928. SELECT @PageNumber = para FROM @t_value WHERE name = 'PageNumber' AND LEN(para) > 0 AND ISNUMERIC(para) = 1
  13929. IF EXISTS(SELECT 'x' FROM @t_value WHERE name = 'CompanySizeID' AND LEN(para) > 0 AND ISNUMERIC(para) = 1)
  13930. SELECT @CompanySize = para FROM @t_value WHERE name = 'CompanySizeID'
  13931. SELECT @Welfare = para FROM @t_value WHERE name = 'Welfare' AND para > ''
  13932. SELECT @OnlyOnline = para FROM @t_value WHERE name = 'IsOnline' AND para = 1
  13933. SELECT @cvRegion = para FROM @t_value WHERE name = 'cvRegion' AND para > ''
  13934. SELECT @cvJobType = para FROM @t_value WHERE name = 'cvJobType' AND para > ''
  13935. SELECT @ip = para FROM @t_value WHERE name = 'SessionId' AND para > ''
  13936. IF LEFT(@Region, 1) = 'p'
  13937. SELECT @MapPlace = RIGHT(@Region, LEN(@Region) - 1), @Region = ''
  13938. SELECT @Source = para FROM @t_value WHERE name = 'Source' AND para > 0
  13939. SELECT @ShowFilter = para FROM @t_value WHERE name = 'Type' AND LEN(para) > 0
  13940. IF LEN(@Keyword) > 14
  13941. SET @CanReturn = 1
  13942. IF EXISTS(SELECT TOP 1 'x' FROM RefuseIp WITH(NOLOCK) WHERE CHARINDEX(Ip, @ip) > 0)
  13943. SET @CanReturn = 1
  13944. IF CHARINDEX(', 0', @Region) > 0 OR CHARINDEX(', 0', @JobType) > 0
  13945. OR CHARINDEX(', , ', @Region) > 0 OR CHARINDEX(', , ', @JobType) > 0
  13946. OR LEN(@Region) > 35 OR LEN(@JobType) > 25
  13947. SET @CanReturn = 1
  13948. IF @CanReturn = 1
  13949. BEGIN
  13950. SELECT 0 ValidJobNumber
  13951. SELECT TOP 0 * FROM JobTemp
  13952. SELECT TOP 0 * FROM @t_filter
  13953. SELECT TOP 0 * FROM @t_filter
  13954. SELECT TOP 0 * FROM @t_filter
  13955. SELECT TOP 0 * FROM @t_filter
  13956. SELECT TOP 0 * FROM @t_filter
  13957. SELECT TOP 0 * FROM @t_filter
  13958. SELECT TOP 0 * FROM @t_filter
  13959. RETURN
  13960. END
  13961. IF CHARINDEX('请填写', @KeyWord) > 0
  13962. SET @KeyWord = ''
  13963. IF LEN(@KeyWord) > 1
  13964. BEGIN
  13965. SET @KeyWord = LTRIM(RTRIM(@Keyword))
  13966. WHILE CHARINDEX(' ', @Keyword) > 0
  13967. SET @KeyWord = REPLACE(@Keyword, ' ', ' ')
  13968. SET @KeyWord = REPLACE(REPLACE(@KeyWord, '''', ''''''), ';', '')
  13969. END
  13970. IF LEN(@KeyWord) < 2
  13971. SET @Keyword = ''
  13972. ----给null值变量赋默认值
  13973. IF @EmpType NOT IN('3', '4')
  13974. SET @EmpType = ''
  13975. IF @MinSalary > 20 OR @MinSalary < 2
  13976. SET @MinSalary = 0
  13977. IF @MaxSalary > 20 OR @MaxSalary < 2
  13978. SET @MaxSalary = 0
  13979. SELECT @JobType = RTRIM(dbo.FormatIDS(@JobType)),
  13980. @Industry = RTRIM(dbo.FormatIDS(@Industry)),
  13981. @Welfare = RTRIM(dbo.FormatIDS(@Welfare)),
  13982. @cvRegion = RTRIM(dbo.FormatIDS(@cvRegion)),
  13983. @cvJobType = RTRIM(dbo.FormatIDS(@cvJobType))
  13984. IF LEN(@Welfare) > 1
  13985. BEGIN
  13986. DECLARE @Welfare_temp VARCHAR(50)
  13987. SET @Welfare_temp = ''
  13988. SELECT @Welfare_temp = @Welfare_temp + a + ',' FROM dbo.fnSplit(@Welfare, ',') WHERE a <= 19 AND LEN(a) < 3
  13989. IF LEN(@Welfare_temp) > 1
  13990. SET @Welfare_temp = LEFT(@Welfare_temp, LEN(@Welfare_temp) - 1)
  13991. SET @Welfare = @Welfare_temp
  13992. END
  13993. IF RIGHT(@JobType, 1) = ','
  13994. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  13995. IF RIGHT(@Region, 1) = ','
  13996. SET @Region = LEFT(@Region, LEN(@Region) - 1)
  13997. IF RIGHT(@Industry, 1) = ','
  13998. SET @Industry = LEFT(@Industry, LEN(@Industry) - 1)
  13999. --分析参数结束
  14000. --记录参数开始
  14001. DECLARE @crDate DATETIME, @inttemp INT
  14002. SELECT TOP 1 @JobSearchLogId = id, @crDate = crDate, @inttemp = Result
  14003. FROM JobSearchLog WITH(NOLOCK)
  14004. WHERE Province = @Province AND JobType = @JobType AND Region = @Region AND MapPlace = @MapPlace AND Industry = @Industry
  14005. AND MinSalary = @MinSalary AND MaxSalary = @MaxSalary AND ReplyRate = @ReplyRate AND Negotiable = @Negotiable AND Experience = @Experience
  14006. AND Education = @Education AND EmpType = @EmpType AND KeyWord = @KeyWord AND CompanySize = @CompanySize
  14007. AND Welfare = @Welfare AND OnlyOnline = @OnlyOnline AND OnlyEnv = @OnlyEnv AND cvRegion = @cvRegion AND cvJobType = @cvJobType
  14008. AND crDate > DATEADD(MINUTE, @jobExpired, GETDATE())
  14009. ORDER BY ID DESC
  14010. --IF @JobSearchLogId > 0
  14011. --BEGIN
  14012. -- IF @inttemp >= 300
  14013. -- BEGIN
  14014. -- IF @crDate < DATEADD(MINUTE, @jobExpired, GETDATE())
  14015. -- SET @JobSearchLogId = 0
  14016. -- END
  14017. -- ELSE
  14018. -- BEGIN
  14019. -- IF @crDate < DATEADD(MINUTE, @jobExpired * 10, GETDATE())
  14020. -- SET @JobSearchLogId = 0
  14021. -- END
  14022. --END
  14023. SELECT TOP 1 @FilterLogId = Id, @ValidJobNumber = Result
  14024. FROM FilterLog WITH(NOLOCK)
  14025. WHERE Province = @Province AND JobType = @JobType AND Region = @Region AND MapPlace = @MapPlace AND Industry = @Industry
  14026. AND MinSalary = @MinSalary AND MaxSalary = @MaxSalary AND ReplyRate = @ReplyRate AND Negotiable = @Negotiable AND Experience = @Experience
  14027. AND Education = @Education AND EmpType = @EmpType AND KeyWord = @KeyWord AND CompanySize = @CompanySize
  14028. AND Welfare = @Welfare AND OnlyOnline = @OnlyOnline AND OnlyEnv = @OnlyEnv
  14029. AND crDate > DATEADD(MINUTE, @filterExpired, GETDATE())
  14030. ORDER BY ID DESC
  14031. --记录参数结束
  14032. --gen sql statement
  14033. IF @FilterLogId = 0 OR @JobSearchLogId = 0
  14034. BEGIN
  14035. --make sql where
  14036. ------生成具体的职位类别,因为职位类别有包含(父子)关系
  14037. ----生成求聘职位
  14038. IF LEN(@JobType) > 0
  14039. BEGIN
  14040. SELECT @strJobType = @strJobType + LTRIM(STR(a.id)) + ', '
  14041. FROM dcJobType a WITH(NOLOCK),
  14042. (SELECT * FROM dbo.fnSplit(@JobType, ',') WHERE a < 9999) b
  14043. WHERE a.Id = b.a
  14044. OR a.ParentId = b.a
  14045. OR a.ParentId2 = b.a
  14046. IF LEN(@strJobType) > 1
  14047. SET @strJobType = LEFT(@strJobType, LEN(@strJobType) - 1)
  14048. END
  14049. ----生成工作地点
  14050. IF @MapPlace > 0
  14051. BEGIN
  14052. DECLARE @Degree AS DECIMAL(8, 5), @Lat AS DECIMAL(8, 5), @Lng AS DECIMAL(8, 5)
  14053. SELECT @Lat = Lat, @Lng = Lng FROM dcMapPlace WITH(NOLOCK) WHERE ID = @MapPlace
  14054. IF @Region LIKE '3201%'
  14055. SET @Degree = 1000 / 100000.0
  14056. ELSE
  14057. SET @Degree = 2000 / 100000.0
  14058. SET @strJobPlace = 'a.Lng BETWEEN ' + CONVERT(VARCHAR, @Lng - @Degree) +
  14059. ' AND ' + CONVERT(VARCHAR, @Lng + @Degree) +
  14060. ' AND a.Lat BETWEEN ' + CONVERT(VARCHAR, @Lat - @Degree) +
  14061. ' AND ' + CONVERT(VARCHAR, @Lat + @Degree) +
  14062. ' AND (a.Lng - ' + CONVERT(VARCHAR, @Lng) + ') * (a.Lng - ' + CONVERT(VARCHAR, @Lng) +
  14063. ') + (a.Lat - ' + CONVERT(VARCHAR, @Lat) + ') * (a.Lat - ' + CONVERT(VARCHAR, @Lat) +
  14064. ') < ' + CONVERT(VARCHAR, @Degree * @Degree)
  14065. END
  14066. ELSE IF LEN(@Region) > 0
  14067. BEGIN
  14068. SELECT @strJobPlace =
  14069. @strJobPlace + ' OR a.dcRegionId ' +
  14070. CASE WHEN LEN(a) = 6
  14071. THEN '= ''' + a + ''''
  14072. ELSE 'LIKE ''' + a + '%'''
  14073. END
  14074. FROM dbo.fnSplit(@Region, ',')
  14075. WHERE LEN(a) IN(2, 4, 6)
  14076. IF LEN(@strJobPlace) > 4
  14077. SET @strJobPlace = RIGHT(@strJobPlace, LEN(@strJobPlace) - 4)
  14078. END
  14079. --从job中搜索数据 开始
  14080. ----组合语句 开始
  14081. --SELECT TOP 2000 a.ID, a.cpMainId, a.dcJobTypeID, a.dcJobTypeIDMinor, a.dcSalaryID, a.dcRegionId, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID
  14082. --SELECT #TOP# a.ID
  14083. SET @SQL='
  14084. FROM JobPublish a WITH(NOLOCK)
  14085. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID
  14086. WHERE a.Valid = 1
  14087. AND b.Valid = 1'
  14088. ----职位有效,单位新有效
  14089. IF LEN(@Industry) > 0
  14090. SET @Sql = @Sql + '
  14091. AND b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @Industry + '))'
  14092. IF @Province > 0
  14093. SET @Sql = @Sql + ' AND b.dcProvinceId = ' + LTRIM(STR(@Province))
  14094. IF @ReplyRate IN(60, 70, 80, 90, 100)
  14095. SET @Sql = @Sql + '
  14096. AND b.ReplyRate >= ' + LEFT(@ReplyRate / 100.0, 3)
  14097. IF @OnlyEnv = 1
  14098. SET @Sql = @Sql + '
  14099. AND b.HasEnvironment = 1'
  14100. ----工作经验要求
  14101. IF @Experience < 100
  14102. SET @Sql = @Sql + '
  14103. AND a.MinExperience = ' + LTRIM(STR(@Experience))
  14104. ----学历要求
  14105. ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
  14106. IF @Education > 0
  14107. IF @Education = 2
  14108. SET @Sql = @Sql + '
  14109. AND a.dcEducationID IN(2, 3, 4)'
  14110. ELSE
  14111. SET @Sql = @Sql + '
  14112. AND a.dcEducationID = ' + LTRIM(STR(@Education))
  14113. ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
  14114. IF LEN(@EmpType) > 0
  14115. SET @Sql = @Sql + '
  14116. AND a.EmployType IN (' + @EmpType + ')'
  14117. IF @CompanySize BETWEEN 1 AND 6
  14118. SET @Sql = @Sql + '
  14119. AND b.dcCompanySizeID = ' + LTRIM(STR(@CompanySize))
  14120. IF LEN(@Welfare) > 0
  14121. SET @Sql = @Sql + '
  14122. AND a.Welfare' + REPLACE(@Welfare, ',', ' = 1 AND a.Welfare') + ' = 1'
  14123. IF @OnlyOnline = 1
  14124. SET @Sql = @Sql + '
  14125. AND a.caMainId IN(SELECT caMainId FROM caOnline WITH(NOLOCK) WHERE IsOnline = 1)'
  14126. ----职位类别
  14127. IF @strJobType > ''
  14128. SET @Sql = @Sql + '
  14129. AND a.dcJobTypeID IN(' + @strJobType + ')'
  14130. IF LEN(@strJobPlace) > 0
  14131. SET @Sql = @Sql + '
  14132. AND (' + @strJobPlace + ')'
  14133. IF @Negotiable = 1
  14134. SET @Sql = @Sql + '
  14135. AND a.dcSalaryID = 100 ' -- OR a.Negotiable = 1
  14136. ELSE IF @MinSalary > 0 AND @MaxSalary > 0
  14137. SET @Sql = @Sql + '
  14138. AND a.dcSalaryID <= ' + LTRIM(STR(@MaxSalary)) + '
  14139. AND a.dcSalaryIdMax >= ' + LTRIM(STR(@MinSalary))
  14140. IF @cvRegion > ''
  14141. BEGIN
  14142. SELECT @strCvRegion =
  14143. @strCvRegion + ' OR a.dcRegionId ' +
  14144. CASE WHEN LEN(a) = 6
  14145. THEN '= ''' + a + ''''
  14146. ELSE 'LIKE ''' + a + '%'''
  14147. END
  14148. FROM dbo.fnSplit(@cvRegion, ',')
  14149. WHERE LEN(a) IN(2, 4, 6)
  14150. SET @strCvRegion = RIGHT(@strCvRegion, LEN(@strCvRegion) - 4)
  14151. END
  14152. IF @cvJobType > ''
  14153. BEGIN
  14154. SELECT @strCvJobType = @strCvJobType + LTRIM(STR(a.id)) + ', '
  14155. FROM dcJobType a WITH(NOLOCK),
  14156. (SELECT * FROM dbo.fnSplit(@cvJobType, ',')) b
  14157. WHERE a.Id = b.a
  14158. OR a.ParentId = b.a
  14159. OR a.ParentId2 = b.a
  14160. IF LEN(@strCvJobType) > 1
  14161. SET @strCvJobType = LEFT(@strCvJobType, LEN(@strCvJobType) - 1)
  14162. END
  14163. SET @Order = ' ORDER BY'
  14164. IF @strCvRegion > ''
  14165. BEGIN
  14166. SET @Order = @Order + ' CASE WHEN ' + @strCvRegion + ' THEN 0 ELSE 2 END'
  14167. IF @strCvJobType > ''
  14168. SET @Order = @Order + '
  14169. + CASE WHEN a.dcJobTypeId IN (' + @strCvJobType + ') THEN 0 ELSE 1 END,
  14170. '
  14171. ELSE
  14172. SET @Order = @Order + ',
  14173. '
  14174. END
  14175. ELSE IF @strCvJobType > ''
  14176. SET @Order = @Order + ' CASE WHEN a.dcJobTypeId IN (' + @strCvJobType + ') THEN 0 ELSE 1 END,
  14177. '
  14178. SET @Order = @Order + ' a.RefreshDate DESC, a.SecondId DESC'
  14179. END
  14180. --gen sql end
  14181. --get filter start
  14182. IF @FilterLogID != 0
  14183. BEGIN
  14184. INSERT INTO @t_filter
  14185. SELECT FilterType, TypeId, TypeNumber FROM JobFilter WITH(NOLOCK) WHERE FilterLogID = @FilterLogID
  14186. BEGIN TRY
  14187. UPDATE FilterLog SET ReUseNumber = ReUseNumber + 1 WHERE Id = @FilterLogID
  14188. END TRY
  14189. BEGIN CATCH
  14190. END CATCH
  14191. END
  14192. ELSE
  14193. BEGIN
  14194. --获取符合条件的所有数据
  14195. CREATE TABLE #Filter(
  14196. Id INT IDENTITY(1, 1),
  14197. [JobId] INT,
  14198. [cpMainId] INT,
  14199. [dcRegionId] [VARCHAR](6) NULL,
  14200. [dcJobTypeID] [smallint] NOT NULL,
  14201. [dcSalaryID] [tinyint] NOT NULL,
  14202. [dcEducationID] [tinyint] NOT NULL,
  14203. [MinExperience] [tinyint] NOT NULL,
  14204. [IssueDate] [smalldatetime] NULL,
  14205. [EmployType] [tinyint] NOT NULL,
  14206. [dcCompanySizeID] [tinyint] NULL
  14207. )
  14208. IF @KeyWord = ''
  14209. BEGIN
  14210. SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
  14211. + @Sql + @Order
  14212. INSERT INTO #Filter
  14213. EXEC(@Exe)
  14214. SELECT @Result = @@ROWCOUNT
  14215. END
  14216. ELSE
  14217. BEGIN
  14218. --(1)显示职位名称中包含搜索的关键词的职位列表
  14219. SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
  14220. + @Sql
  14221. + ' AND a.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%'' '
  14222. + @Order
  14223. INSERT INTO #Filter
  14224. EXEC(@Exe)
  14225. SELECT @Result = @@ROWCOUNT
  14226. --(2)显示按照职位类别匹配规则的职位列表
  14227. IF @Result < 2000
  14228. BEGIN
  14229. SELECT @KeyJobTypeIds = LTRIM(STR(id)) + ',' FROM dcJobType WHERE CHARINDEX(@Keyword, Description) > 0
  14230. IF LEN(@KeyJobTypeIds) > 2
  14231. SELECT @KeyJobTypeIds = LEFT(@KeyJobTypeIds, LEN(@KeyJobTypeIds) - 1)
  14232. ELSE
  14233. BEGIN
  14234. SET @KeyJobTypeIds= ''
  14235. SELECT @KeyJobTypeIds = dcJobtypeIds FROM KeyWord2JobType WITH(NOLOCK) WHERE Keyword = @Keyword
  14236. END
  14237. IF @KeyJobTypeIds > ''
  14238. BEGIN
  14239. SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
  14240. + @Sql
  14241. + ' AND a.dcJobTypeID IN(''' + @KeyJobTypeIds + ''')
  14242. AND a.Id NOT IN(SELECT JobId FROM #Filter)'
  14243. + @Order
  14244. INSERT INTO #Filter
  14245. EXEC(@Exe)
  14246. SELECT @Result = @Result + @@ROWCOUNT
  14247. END
  14248. ELSE IF LEN(@Keyword) < 11
  14249. INSERT INTO KeyWordLog(crDate, Keyword) SELECT GETDATE(), @Keyword
  14250. END
  14251. --(3)显示企业名称中包含搜索的关键词的职位列表
  14252. IF @Result = 0
  14253. BEGIN
  14254. SET @Exe = 'SELECT DISTINCT TOP 2000 a.cpMainId, AvgSalary,b.LastLogindate '
  14255. + @Sql
  14256. + ' AND b.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%'' '
  14257. + ' ORDER BY b.AvgSalary DESC, b.LastLogindate DESC'
  14258. INSERT INTO #t_companyTemp
  14259. EXEC(@Exe)
  14260. SELECT @Result = @@ROWCOUNT
  14261. IF @Result > 0
  14262. BEGIN
  14263. INSERT INTO #t_companyList
  14264. SELECT a.Id, a.SecondId, a.Name, a.RealName, a.Lng, a.Lat, HasLicence, ISNULL(a.LogoFile, @Logo), a.dcRegionId,
  14265. (SELECT TOP 1 dcIndustryId FROM cpIndustry WITH(NOLOCK) WHERE cpIndustry.cpMainID = a.Id) dcIndustryID,
  14266. (SELECT COUNT(*) FROM JobPublish WITH(NOLOCK) WHERE JobPublish.cpMainId = a.Id) JobNumber
  14267. FROM cpMainPublish a WITH(NOLOCK), #t_companyTemp b
  14268. WHERE a.Id = b.Id
  14269. ORDER BY b.seq
  14270. SELECT @cpMainResult = @@ROWCOUNT
  14271. SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
  14272. + @Sql
  14273. + ' AND a.cpMainId IN(SELECT ID FROM #t_companyTemp)'
  14274. + @Order
  14275. INSERT INTO #Filter
  14276. EXEC(@Exe)
  14277. SELECT @Result = @@ROWCOUNT
  14278. END
  14279. END
  14280. ELSE IF @Result < 2000
  14281. BEGIN
  14282. SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
  14283. + @Sql
  14284. + ' AND b.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%''
  14285. AND a.Id NOT IN(SELECT JobId FROM #Filter)'
  14286. + @Order
  14287. INSERT INTO #Filter
  14288. EXEC(@Exe)
  14289. SELECT @Result = @Result + @@ROWCOUNT
  14290. END
  14291. --(4)全文搜索匹配的职位列表
  14292. IF @Result < 2000
  14293. BEGIN
  14294. INSERT #FullText
  14295. SELECT TOP 5000 3000 + RANK, [Key]
  14296. FROM FREETEXTTABLE(cpMainJob, *, @KeyWord, 100000) AS KeyJob ORDER BY RANK DESC
  14297. SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
  14298. + REPLACE(@Sql, 'INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID', 'INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID INNER JOIN #FullText ON a.ID = #FullText.JobId')
  14299. + ' AND a.Id NOT IN(SELECT JobId FROM #Filter)'
  14300. + REPLACE(@Order, ' ORDER BY', ' ORDER BY #FullText.Priority,')
  14301. INSERT INTO #Filter
  14302. EXEC(@Exe)
  14303. SELECT @Result = @Result + @@ROWCOUNT
  14304. END
  14305. END
  14306. SET @ValidJobNumber = @Result
  14307. INSERT INTO #t_jobid
  14308. SELECT TOP 2000 JobId FROM #Filter ORDER BY Id
  14309. SET @FillJobId = 1
  14310. ----生成筛选数据
  14311. DECLARE @t_filtertemp1 AS TABLE (
  14312. FilterType INT, --1 jobtype,
  14313. TypeID VARCHAR(10),
  14314. TypeNumber INT
  14315. )
  14316. DECLARE @t_filtertemp2 AS TABLE (
  14317. FilterType INT,
  14318. TypeID VARCHAR(10),
  14319. TypeNumber INT
  14320. )
  14321. ----------------------------jobtype
  14322. INSERT INTO @t_filtertemp1
  14323. SELECT 1, dcJobTypeID, COUNT(*)
  14324. FROM #Filter WITH(NOLOCK)
  14325. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  14326. ----计算全部某职位类别,2, 4位的数据
  14327. IF LEN(@JobType) = 0
  14328. INSERT INTO @t_filtertemp2
  14329. SELECT 1, LEFT(TypeID, 2), SUM(TypeNumber)
  14330. FROM @t_filtertemp1 GROUP BY LEFT(TypeID, 2)
  14331. ELSE IF LEN(@JobType) = 2
  14332. INSERT INTO @t_filtertemp2
  14333. SELECT 1, TypeID, TypeNumber
  14334. FROM @t_filtertemp1
  14335. WHERE TypeID LIKE @JobType + '__'
  14336. ELSE IF LEN(@JobType) > 4
  14337. BEGIN
  14338. INSERT INTO @t_filtertemp2 SELECT * FROM @t_filtertemp1
  14339. INSERT INTO @t_filtertemp2
  14340. SELECT 1, LEFT(TypeID, 2), SUM(TypeNumber)
  14341. FROM @t_filtertemp1 GROUP BY LEFT(TypeID, 2)
  14342. DELETE @t_filtertemp2 WHERE TypeID NOT IN(SELECT a FROM dbo.fnSplit(@JobType, ','))
  14343. END
  14344. INSERT INTO @t_filter SELECT * FROM @t_filtertemp2
  14345. DELETE @t_filtertemp2
  14346. DELETE @t_filtertemp1
  14347. --------------------------region
  14348. IF @Mapplace = 0
  14349. BEGIN
  14350. INSERT INTO @t_filtertemp1
  14351. SELECT 2, dcRegionId, COUNT(*) FROM #Filter WITH(NOLOCK)
  14352. GROUP BY dcRegionId ORDER BY dcRegionId
  14353. ----计算全部地区,2位的数据
  14354. IF LEN(@Region) = 0
  14355. INSERT INTO @t_filtertemp2
  14356. SELECT 2, LEFT(TypeID, 2) TypeID, SUM(TypeNumber) TypeNumber
  14357. FROM @t_filtertemp1 GROUP BY LEFT(TypeID, 2)
  14358. ELSE IF LEN(@Region) = 2
  14359. INSERT INTO @t_filtertemp2
  14360. SELECT 2, LEFT(TypeID, 4) TypeID, SUM(TypeNumber) TypeNumber
  14361. FROM @t_filtertemp1 WHERE LEN(TypeID) >= 4 AND TypeId LIKE @Region + '%'
  14362. GROUP BY LEFT(TypeID, 4)
  14363. ELSE IF LEN(@Region) = 4
  14364. INSERT INTO @t_filtertemp2
  14365. SELECT 2, TypeID, TypeNumber
  14366. FROM @t_filtertemp1 WHERE LEN(TypeID) = 6
  14367. ELSE IF @Region LIKE '%,%'
  14368. BEGIN
  14369. INSERT INTO @t_filtertemp2
  14370. SELECT 2, LEFT(TypeID, 2) TypeID, SUM(TypeNumber) TypeNumber
  14371. FROM @t_filtertemp1 GROUP BY LEFT(TypeID, 2)
  14372. INSERT INTO @t_filtertemp2
  14373. SELECT 2, LEFT(TypeID, 4) TypeID, SUM(TypeNumber) TypeNumber
  14374. FROM @t_filtertemp1 WHERE LEN(TypeID) >= 4
  14375. GROUP BY LEFT(TypeID, 4)
  14376. INSERT INTO @t_filtertemp2 SELECT * FROM @t_filtertemp1 WHERE LEN(TypeID) = 6
  14377. DELETE @t_filtertemp2 WHERE TypeID NOT IN(SELECT a FROM dbo.FnSplit(@Region, ','))
  14378. END
  14379. INSERT INTO @t_filter SELECT * FROM @t_filtertemp2
  14380. --DELETE @t_filtertemp2
  14381. --DELETE @t_filtertemp1
  14382. END
  14383. ----------------------------
  14384. INSERT INTO @t_filter
  14385. SELECT 3, EmployType, COUNT(*)
  14386. FROM #Filter WITH(NOLOCK)
  14387. GROUP BY EmployType ORDER BY EmployType
  14388. INSERT INTO @t_filter
  14389. SELECT 4, CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  14390. FROM #Filter WITH(NOLOCK)
  14391. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  14392. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  14393. INSERT INTO @t_filter
  14394. SELECT 5, MinExperience, COUNT(*) FROM #Filter WITH(NOLOCK)
  14395. GROUP BY MinExperience ORDER BY MinExperience
  14396. INSERT INTO @t_filter
  14397. SELECT 6, dcCompanySizeID, COUNT(*) FROM #Filter WITH(NOLOCK)
  14398. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  14399. INSERT INTO @t_filter
  14400. SELECT 7, dcSalaryID, COUNT(*) FROM #Filter WITH(NOLOCK)
  14401. GROUP BY dcSalaryID ORDER BY dcSalaryID
  14402. INSERT INTO @t_filter
  14403. SELECT 8, dcIndustryID, COUNT(*)
  14404. FROM #Filter a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)-- INDEX(NonClusteredIndex_cpIndustry_cpMainId))
  14405. WHERE a.cpMainId = b.cpMainId
  14406. GROUP BY b.dcIndustryId ORDER BY b.dcIndustryId
  14407. ----记录筛选数据
  14408. INSERT INTO FilterLog(crDate, Source, ip, Province, JobType, Region, MapPlace, Industry, MinSalary,
  14409. MaxSalary, ReplyRate, Negotiable, Experience, Education, EmpType, KeyWord, CompanySize,
  14410. Welfare, OnlyOnline, OnlyEnv, Result, SqlString, RunTime, DayMinute)
  14411. SELECT GETDATE(), @Source, @ip, @Province, @JobType, @Region, @MapPlace, @Industry, @MinSalary,
  14412. @MaxSalary, @ReplyRate, @Negotiable, @Experience, @Education, @EmpType, @KeyWord, @CompanySize,
  14413. @Welfare, @OnlyOnline, @OnlyEnv, @ValidJobNumber, @Exe, DATEDIFF(MS, @Start, GETDATE()),
  14414. ROUND(CONVERT(DECIMAL(18, 9), GETDATE()) % 1.0 * 60 * 24, 0)
  14415. SET @FilterLogId = @@IDENTITY
  14416. INSERT INTO JobFilter
  14417. SELECT @FilterLogId FilterLogId, * FROM @t_filter
  14418. INSERT INTO CompanyList
  14419. SELECT @FilterLogId FilterLogId, * FROM #t_companyList
  14420. END
  14421. IF @JobSearchLogId > 0
  14422. BEGIN
  14423. UPDATE JobSearchLog SET ReUseNumber = ReUseNumber + 1 WHERE Id = @JobSearchLogId
  14424. END
  14425. ELSE
  14426. BEGIN
  14427. --select jobid
  14428. SET @Result = 0
  14429. IF @FillJobId = 1
  14430. BEGIN
  14431. SELECT @Result = COUNT(*) FROM #t_jobid
  14432. END
  14433. ELSE
  14434. BEGIN
  14435. TRUNCATE TABLE #t_jobid
  14436. IF @KeyWord = ''
  14437. BEGIN
  14438. SET @Exe = 'SELECT TOP 2000 a.Id ' + @Sql + @Order
  14439. INSERT INTO #t_jobid
  14440. EXEC(@Exe)
  14441. SET @Result = @@ROWCOUNT
  14442. END
  14443. ELSE
  14444. BEGIN
  14445. --(1)显示职位名称中包含搜索的关键词的职位列表
  14446. SET @Exe = 'SELECT TOP 2000 a.Id '
  14447. + @Sql
  14448. + ' AND a.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%'' '
  14449. + @Order
  14450. INSERT INTO #t_jobid
  14451. EXEC(@Exe)
  14452. SELECT @Result = @@ROWCOUNT
  14453. --(2)显示按照职位类别匹配规则的职位列表
  14454. IF @Result < 2000
  14455. BEGIN
  14456. SELECT @KeyJobTypeIds = ''
  14457. SELECT @KeyJobTypeIds = LTRIM(STR(id)) + ',' FROM dcJobType WHERE CHARINDEX(@Keyword, Description) > 0
  14458. IF LEN(@KeyJobTypeIds) > 2
  14459. SELECT @KeyJobTypeIds = LEFT(@KeyJobTypeIds, LEN(@KeyJobTypeIds) - 1)
  14460. ELSE
  14461. BEGIN
  14462. SET @KeyJobTypeIds= ''
  14463. SELECT @KeyJobTypeIds = dcJobtypeIds FROM KeyWord2JobType WITH(NOLOCK) WHERE Keyword = @Keyword
  14464. END
  14465. IF @KeyJobTypeIds > ''
  14466. BEGIN
  14467. SET @Exe = 'SELECT TOP 2000 a.Id '
  14468. + @Sql
  14469. + ' AND a.dcJobTypeID IN(''' + @KeyJobTypeIds + ''')
  14470. AND a.Id NOT IN(SELECT JobId FROM #t_jobid)'
  14471. + @Order
  14472. INSERT INTO #t_jobid
  14473. EXEC(@Exe)
  14474. SELECT @Result = @Result + @@ROWCOUNT
  14475. END
  14476. END
  14477. --(3)显示企业名称中包含搜索的关键词的职位列表
  14478. IF @Result = 0
  14479. BEGIN
  14480. INSERT INTO #t_companyList
  14481. SELECT Id, SecondId, Name, RealName, Lng, Lat, HasLicence, ISNULL(LogoFile, @Logo), dcRegionId, dcIndustryID, JobNumber
  14482. FROM CompanyList WITH(NOLOCK)
  14483. WHERE FilterLogID = @FilterLogID
  14484. ORDER BY seq
  14485. SELECT @cpMainResult = @@ROWCOUNT
  14486. SET @Exe = 'SELECT TOP 2000 a.Id '
  14487. + @Sql
  14488. + ' AND a.cpMainId IN(SELECT ID FROM #t_companyList)'
  14489. + @Order
  14490. INSERT INTO #t_jobid
  14491. EXEC(@Exe)
  14492. SELECT @Result = @@ROWCOUNT
  14493. END
  14494. ELSE IF @Result < 2000
  14495. BEGIN
  14496. SET @Exe = 'SELECT TOP 2000 a.Id '
  14497. + @Sql
  14498. + ' AND b.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%''
  14499. AND a.Id NOT IN(SELECT JobId FROM #t_jobid)'
  14500. + @Order
  14501. INSERT INTO #t_jobid
  14502. EXEC(@Exe)
  14503. SELECT @Result = @Result + @@ROWCOUNT
  14504. END
  14505. --(4)全文搜索匹配的职位列表
  14506. IF @Result < 2000
  14507. BEGIN
  14508. TRUNCATE TABLE #FullText
  14509. INSERT #FullText
  14510. SELECT TOP 5000 3000 + RANK, [Key]
  14511. FROM FREETEXTTABLE(cpMainJob, *, @KeyWord, 100000) AS KeyJob ORDER BY RANK DESC
  14512. SET @Exe = 'SELECT TOP 2000 a.Id '
  14513. + REPLACE(@Sql, 'INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID', 'INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID INNER JOIN #FullText ON a.ID = #FullText.JobId')
  14514. + ' AND a.Id IN(SELECT TOP 5000 [Key] FROM FREETEXTTABLE(cpMainJob, *, ''' + @KeyWord + ''', 100000) AS KeyJob ORDER BY RANK DESC)
  14515. AND a.Id NOT IN(SELECT JobId FROM #t_jobid)'
  14516. + REPLACE(@Order, ' ORDER BY', ' ORDER BY #FullText.Priority,')
  14517. INSERT INTO #t_jobid
  14518. EXEC(@Exe)
  14519. SELECT @Result = @Result + @@ROWCOUNT
  14520. END
  14521. END
  14522. END
  14523. ----set istop
  14524. IF @KeyWord > ''
  14525. INSERT INTO @t_top
  14526. SELECT TOP 10 a.JobId
  14527. FROM SearchJobTop a WITH(NOLOCK), #t_jobid b
  14528. WHERE b.JobId = a.JobId
  14529. AND EXISTS(SELECT 'x' FROM JobPublish c WITH(NOLOCK) WHERE CHARINDEX(@keyword, c.Name ) > 0 AND c.Id = a.JobId)
  14530. ORDER BY a.OrderType, a.OpenDate DESC
  14531. ELSE
  14532. INSERT INTO @t_top
  14533. SELECT TOP 10 a.JobId
  14534. FROM SearchJobTop a WITH(NOLOCK), #t_jobid b
  14535. WHERE b.JobId = a.JobId
  14536. ORDER BY a.OrderType, a.OpenDate DESC
  14537. IF EXISTS(SELECT TOP 1 'x' FROM @t_top)
  14538. DELETE FROM #t_jobid WHERE JobId IN(SELECT JobId FROM @t_top)
  14539. ----记录筛选数据
  14540. INSERT INTO JobSearchLog(crDate, Source, ip, Province, JobType, Region, MapPlace, Industry, MinSalary,
  14541. MaxSalary, ReplyRate, Negotiable, Experience, Education, EmpType, KeyWord, CompanySize,
  14542. Welfare, OnlyOnline, OnlyEnv, cvRegion, cvJobType, Result, SqlString, RunTime)
  14543. SELECT GETDATE(), @Source, @ip, @Province, @JobType, @Region, @MapPlace, @Industry, @MinSalary,
  14544. @MaxSalary, @ReplyRate, @Negotiable, @Experience, @Education, @EmpType, @KeyWord, @CompanySize,
  14545. @Welfare, @OnlyOnline, @OnlyEnv, @cvRegion, @cvJobType, @Result, @Exe, DATEDIFF(MS, @Start, GETDATE())
  14546. SET @JobSearchLogId = @@IDENTITY
  14547. IF EXISTS(SELECT TOP 1 'x' FROM @t_top)
  14548. BEGIN
  14549. INSERT INTO JobList
  14550. SELECT @JobSearchLogId JobSearchLogId, JobId, 1 FROM @t_top ORDER BY seq
  14551. INSERT INTO JobList
  14552. SELECT @JobSearchLogId JobSearchLogId, JobId, 0 FROM #t_jobid ORDER BY Id
  14553. END
  14554. ELSE
  14555. BEGIN
  14556. IF @Result > 99
  14557. INSERT INTO JobList
  14558. SELECT @JobSearchLogId JobSearchLogId, JobId, CASE WHEN Id < 4 THEN 1 ELSE 0 END FROM #t_jobid ORDER BY Id
  14559. ELSE
  14560. INSERT INTO JobList
  14561. SELECT @JobSearchLogId JobSearchLogId, JobId, 0 FROM #t_jobid ORDER BY Id
  14562. END
  14563. END
  14564. ----组合语句 结束
  14565. --从job中搜索数据 结束
  14566. ----show tables start
  14567. ----返回查询数量
  14568. DECLARE @ShowCompany INT = 0
  14569. IF @PageNumber = 1
  14570. BEGIN
  14571. IF NOT EXISTS(SELECT TOP 1 'x' FROM #t_companyList)
  14572. INSERT INTO #t_companyList(Id, SecondId, Name, RealName, Lng, Lat, HasLicence, LogoFile, dcRegionId, dcIndustryId, JobNumber)
  14573. SELECT Id, SecondId, Name, RealName, Lng, Lat, HasLicence, ISNULL(LogoFile, @Logo), dcRegionId, dcIndustryId, JobNumber FROM CompanyList WITH(NOLOCK) WHERE FilterLogId = @FilterLogID ORDER BY Seq
  14574. SELECT @ShowCompany = COUNT(*) FROM #t_companyList
  14575. END
  14576. SELECT @ValidJobNumber ValidJobNumber, @ShowFilter ShowFilter, @ShowCompany ShowCompany
  14577. ----返回@PageSize行查询结果
  14578. INSERT INTO @t_jobid
  14579. SELECT JobId, IsTop FROM JobList WITH(NOLOCK) WHERE JobSearchLogId = @JobSearchLogId ORDER BY Id
  14580. IF @Source = 10
  14581. SELECT TOP (@PageSize) a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
  14582. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  14583. a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
  14584. b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
  14585. ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
  14586. e.FullName Region, b.LogoFile LogoUrl, @ValidJobNumber JobNumber,
  14587. f.Description EducationName,g.Description ExperienceName,
  14588. h.DescriptionCp dcSalary,i.DescriptionCp dcSalaryMax
  14589. FROM JobPublish a WITH(NOLOCK)
  14590. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  14591. INNER JOIN @t_jobid c ON a.id = c.JobID
  14592. INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
  14593. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  14594. LEFT JOIN dcEducation f WITH(NOLOCK) ON f.ID = a.dcEducationID
  14595. INNER JOIN dcOthers g WITH(NOLOCK) ON g.DetailID = a.MinExperience AND g.Category='职位要求工作经验'
  14596. INNER JOIN dcSalary h WITH(NOLOCK) ON h.ID = a.dcSalaryID
  14597. INNER JOIN dcSalary i WITH(NOLOCK) ON i.ID = a.dcSalaryIDMax
  14598. WHERE c.ID >= (@PageNumber - 1) * @PageSize
  14599. ORDER BY c.ID, a.ID DESC
  14600. ELSE
  14601. SELECT TOP (@PageSize) a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  14602. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  14603. a.dcRegionId, a.Responsibility, a.Demand, a.dcEducationID,
  14604. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  14605. a.IsDelete, a.AddDate, a.RefreshDate, a.Welfare1, a.Welfare2, a.Welfare3,
  14606. a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8,
  14607. a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13,
  14608. a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18, a.Welfare19,
  14609. a.SecondId EnJobID, b.SecondId EnCpMainID,
  14610. a.LastModifyDate, b.Name cpName, b.dcCompanySizeID,
  14611. b.HasLicence, b.RealName, b.UnLimitedDate, b.BalanceDate, b.Balance, b.LogoFile LogoUrl,
  14612. b.MemberType, '' cpIndustry, --STUFF((SELECT ',' + LTRIM(x.dcIndustryid) + ',c' + LTRIM(isnull(y.Category,0)) FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  14613. c.IsTop, b.IsRefreshed, ISNULL(d.IsOnline, 0) IsOnline, d.IsVi, d.ViPlanId, d.InterviewDate, CASE WHEN b.ReplyRate >= 0.6 THEN b.ReplyRate ELSE NULL END Replyrate,
  14614. (SELECT TOP 1 ID from paAttention WITH(NOLOCK) WHERE AttentionType=2 AND AttentionID=a.ID AND paMainId = @paMainId) AttentionId
  14615. FROM JobPublish a WITH(NOLOCK)
  14616. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  14617. INNER JOIN @t_jobid c ON a.id = c.JobID
  14618. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  14619. WHERE c.ID >= (@PageNumber - 1) * @PageSize
  14620. ORDER BY c.ID, a.ID DESC
  14621. ----返回统计数量
  14622. IF @ShowFilter = 1
  14623. BEGIN
  14624. IF @Source = 10
  14625. BEGIN
  14626. SELECT 1 PaSearchConditionId, 'JobType' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
  14627. FROM @t_filter a LEFT JOIN dcJobType b ON b.ID = a.TypeId
  14628. WHERE FilterType = 1
  14629. ORDER BY TypeId
  14630. IF @MapPlace = 0
  14631. BEGIN
  14632. --level 3 region
  14633. IF LEN(@Region) > 0
  14634. AND @Region NOT LIKE '%,%'
  14635. AND NOT EXISTS(SELECT TOP 1 'x' FROM dcRegion WHERE ParentID = @Region)
  14636. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionId = @Region
  14637. ELSE
  14638. SELECT 1 PaSearchConditionId, 'Region' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
  14639. FROM @t_filter a
  14640. LEFT JOIN dcRegion b ON b.ID = a.TypeId
  14641. WHERE FilterType = 2
  14642. ORDER BY TypeId
  14643. END
  14644. SELECT 1 PaSearchConditionId, 'Education' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
  14645. FROM @t_filter a
  14646. LEFT JOIN dcEducation b ON b.ID = a.TypeId
  14647. WHERE FilterType = 4
  14648. ORDER BY CONVERT(INT, TypeId)
  14649. SELECT 1 PaSearchConditionId, 'Experience' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
  14650. FROM @t_filter a
  14651. LEFT JOIN dcOthers b ON b.DetailID = a.TypeId AND Category='职位要求工作经验'
  14652. WHERE FilterType = 5
  14653. ORDER BY CONVERT(INT, TypeId)
  14654. SELECT 1 PaSearchConditionId, 'Salary' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue
  14655. FROM @t_filter
  14656. WHERE FilterType = 7
  14657. ORDER BY CONVERT(INT, TypeId)
  14658. SELECT 1 PaSearchConditionId, 'EmployType' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
  14659. FROM @t_filter a
  14660. LEFT JOIN dcOthers b ON b.DetailID = a.TypeId AND Category='工作性质'
  14661. WHERE FilterType = 3
  14662. ORDER BY CONVERT(INT, TypeId)
  14663. SELECT 1 PaSearchConditionId, 'CompanySize' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
  14664. FROM @t_filter a
  14665. LEFT JOIN dcCompanySize b ON b.ID = a.TypeId
  14666. WHERE FilterType = 6
  14667. ORDER BY CONVERT(INT, TypeId)
  14668. END
  14669. ELSE
  14670. BEGIN
  14671. SELECT 1 PaSearchConditionId, 'JobType' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 1 ORDER BY TypeId
  14672. IF @MapPlace = 0
  14673. BEGIN
  14674. --level 3 region
  14675. IF LEN(@Region) > 0
  14676. AND @Region NOT LIKE '%,%'
  14677. AND NOT EXISTS(SELECT TOP 1 'x' FROM dcRegion WHERE ParentID = @Region)
  14678. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionId = @Region
  14679. ELSE
  14680. SELECT 1 PaSearchConditionId, 'Region' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 2 ORDER BY TypeId
  14681. END
  14682. SELECT 1 PaSearchConditionId, 'Education' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 4 ORDER BY TypeId
  14683. SELECT 1 PaSearchConditionId, 'Experience' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 5 ORDER BY TypeId
  14684. SELECT 1 PaSearchConditionId, 'Salary' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 7 ORDER BY TypeId
  14685. SELECT 1 PaSearchConditionId, 'EmployType' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 3 ORDER BY TypeId
  14686. SELECT 1 PaSearchConditionId, 'CompanySize' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 6 ORDER BY TypeId
  14687. SELECT 1 PaSearchConditionId, 'Industry' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 8 ORDER BY TypeId
  14688. END
  14689. END
  14690. --如果有companylist列表,则显示
  14691. IF @ShowCompany > 0
  14692. BEGIN
  14693. IF @paMainId > 0
  14694. SELECT Id, SecondId, Name, RealName, Lng, Lat, HasLicence, LogoFile, JobNumber,
  14695. (SELECT FullName FROM dcRegion WHERE Id = dcRegionId) Region,
  14696. (SELECT Description FROM dcIndustry WHERE Id = dcIndustryId) Industry,
  14697. (SELECT TOP 1 ID from paAttention WITH(NOLOCK)
  14698. WHERE AttentionType=1 AND AttentionID = a.ID
  14699. AND paMainId = @paMainId) AttentionId
  14700. FROM #t_CompanyList a
  14701. ORDER BY Seq
  14702. ELSE
  14703. SELECT Id, SecondId, Name, RealName, Lng, Lat, HasLicence, LogoFile, JobNumber, null AttentionId,
  14704. (SELECT FullName FROM dcRegion WHERE Id = dcRegionId) Region,
  14705. (SELECT Description FROM dcIndustry WHERE Id = dcIndustryId) Industry
  14706. FROM #t_CompanyList ORDER BY Seq
  14707. END
  14708. END TRY
  14709. BEGIN CATCH
  14710. INSERT INTO ErrLog
  14711. VALUES(ERROR_NUMBER(), ERROR_SEVERITY(), ERROR_STATE(), ERROR_PROCEDURE(), ERROR_LINE(),
  14712. ERROR_MESSAGE() + ' sql=' + ISNULL(@sql, 'null')
  14713. + ' @order=' + ISNULL(@order, 'null') + ' exe=' + ISNULL(@exe, 'null'), GETDATE())
  14714. END CATCH
  14715. GO
  14716. /****** Object: StoredProcedure [dbo].[procJobPublishSelect2] Script Date: 2018/12/13 19:11:03 ******/
  14717. SET ANSI_NULLS ON
  14718. GO
  14719. SET QUOTED_IDENTIFIER ON
  14720. GO
  14721. /*
  14722. go
  14723. DECLARE @json NVARCHAR(MAX) = N'
  14724. {
  14725. "ip":"192.168.1.1",
  14726. "province":"32",
  14727. "JobType":"",
  14728. "region":"32",
  14729. "Negotiable":"0",
  14730. "keyword":"齐鲁 人才",
  14731. "cvJobType":"24",
  14732. "cvregion":"3212"
  14733. }';
  14734. set @json = '{"dcJobTypeID" : "",
  14735. "dcRegionId" : "32",
  14736. "dcIndustryID" : "",
  14737. "dcSalaryID" : "",
  14738. "IsNegotiable" : "",
  14739. "MinExperience" : "",
  14740. "dcEducationID" : "",
  14741. "EmployType" : "",
  14742. "KeyWord" : "请填写关键词或选择职位",
  14743. "KeyType" : "1",
  14744. "Order" : "",
  14745. "RefreshNo" : "32",
  14746. "Type" : "1",
  14747. "PageNumber" : "1",
  14748. "SessionID" : "60.215.144.163",
  14749. "CompanySizeID" : "",
  14750. "JobID" : "0",
  14751. "Welfare" : "",
  14752. "IsOnline" : ""
  14753. }
  14754. '
  14755. exec procJobPublishSelect '[{"dcRegionId":"32","dcIndustryID":"5"}]'
  14756. go
  14757. select * from jsonlist
  14758. */
  14759. CREATE PROCEDURE [dbo].[procJobPublishSelect2]
  14760. (
  14761. @json nVARCHAR(max)
  14762. )
  14763. as
  14764. SET NOCOUNT ON
  14765. DECLARE @Start DATETIME
  14766. SET @Start = GETDATE()
  14767. DECLARE @Sql VARCHAR(MAX), @Order VARCHAR(1000), @Exe VARCHAR(MAX), @Result INT = 0, @CanReturn BIT = 0, @ValidJobNumber INT = 0
  14768. BEGIN TRY
  14769. --分析参数结束开始,约3ms
  14770. DECLARE @t_value AS TABLE (name VARCHAR(20), para VARCHAR(500), seq int);
  14771. INSERT INTO @t_value
  14772. SELECT * FROM OPENJSON(@json);
  14773. DECLARE @Province INT = 32,
  14774. @JobType VARCHAR(50) = '', --职位类别
  14775. @Region VARCHAR(50) = '', --求职地区
  14776. @MapPlace INT = 0,
  14777. @Industry VARCHAR(20) = '', --求职行业
  14778. @MinSalary TINYINT = 0, --月薪
  14779. @MaxSalary TINYINT = 0, --月薪
  14780. @ReplyRate TINYINT = 0,
  14781. @Negotiable TINYINT = 0, --1面议,不面议
  14782. @Experience TINYINT = 100, --工作经验,100为未选择
  14783. @Education TINYINT = 0, --最低学历
  14784. @EmpType VARCHAR(10) = '', --工作性质,1全职;3兼职;4实习,
  14785. @KeyWord NVARCHAR(50) = '', --关键词
  14786. @PageNumber INT = 1, --翻页页码
  14787. @CompanySize INT = 0, --企业规模
  14788. @Welfare VARCHAR(50) = '',
  14789. @OnlyOnline INT = 0, --1在线
  14790. @OnlyEnv INT = 0,
  14791. @cvRegion VARCHAR(50) = '',
  14792. @cvJobType VARCHAR(50) = '',
  14793. @ip VARCHAR(15) = '',
  14794. @paMainId INT = 0,
  14795. @JobSearchLogId INT = 0,
  14796. @FilterLogID INT = 0,
  14797. @Source INT = 1, --1-pc+m,10-app
  14798. @ShowFilter INT = 1
  14799. CREATE TABLE #t_jobid(Id INT IDENTITY(1, 1), JobId INT)
  14800. CREATE TABLE #t_companyList(Id int NOT NULL, SecondId varchar(10) NULL, Name nvarchar(100) NULL, RealName TINYINT, Lng Decimal(8, 5), Lat DEcimal(8, 5), HasLicence BIT, LogoFile VARCHAR(90), dcRegionId varchar(6) NULL, dcIndustryID smallint NULL, JobNumber int NULL, seq INT IDENTITY(1, 1))
  14801. CREATE TABLE #t_companyTemp(Id INT, AvgSalary INT, LastLogindate DATETIME, seq INT IDENTITY(1, 1))
  14802. CREATE TABLE #FullText(Id INT IDENTITY(1, 1), Priority INT, JobId INT NOT NULL)
  14803. DECLARE @t_filter AS TABLE (FilterType INT, TypeID VARCHAR(10), TypeNumber INT)
  14804. DECLARE @t_top AS TABLE(JobID INT, seq int IDENTITY(1, 1))
  14805. DECLARE @t_jobid AS TABLE(Id INT IDENTITY(1, 1), JobId INT, IsTop BIT)
  14806. DECLARE @PageSize INT = 30, @FillJobId INT = 0, @cpMainResult INT = 0, @KeyJobTypeIds VARCHAR(24) = '', @para VARCHAR(100)
  14807. DECLARE @strJobType AS VARCHAR(2000) = '', @strJobPlace AS VARCHAR(2000) = '', @strCvRegion VARCHAR(MAX) = '', @strCvJobType VARCHAR(MAX) = ''
  14808. DECLARE @filterExpired INT = -30, @jobExpired INT = -1, @Logo VARCHAR(50) = '/content/personal/images/defaultCpImg.png'
  14809. SELECT @Province = para FROM @t_value WHERE name = 'RefreshNo' AND para > 0
  14810. IF @Province > 100
  14811. SELECT @Province = @Province - 100, @OnlyEnv = 1
  14812. SELECT @para = para FROM @t_value WHERE name = 'order' AND para > ''
  14813. IF @para LIKE 'r=%'
  14814. SET @ReplyRate = CONVERT(DECIMAL(4, 2), RIGHT(LEFT(@para, 5), 3)) * 100
  14815. ELSE IF @para LIKE '%p=%'
  14816. SET @paMainId = RIGHT(@para, LEN(@para) - CHARINDEX('p=', @para) - 1)
  14817. SELECT @JobType = para FROM @t_value WHERE name = 'dcJobTypeID' AND para > ''
  14818. SELECT @Region = para FROM @t_value WHERE name = 'dcRegionId' AND para > ''
  14819. SELECT @Industry = para FROM @t_value WHERE name = 'dcIndustryID' AND para > ''
  14820. SELECT @MinSalary = para FROM @t_value WHERE name = 'dcSalaryID' AND para > 0
  14821. --SELECT @MaxSalary = para FROM @t_value WHERE name = 'maxSalary' AND para > 0
  14822. IF @MinSalary > 0
  14823. BEGIN
  14824. IF @MinSalary < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
  14825. SET @MaxSalary = @MinSalary + 1
  14826. ELSE IF @MinSalary BETWEEN 101 AND 106 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  14827. SELECT @MaxSalary = @MinSalary - 99, @MinSalary = @MinSalary - 99
  14828. ELSE IF @MinSalary BETWEEN 107 AND 113 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  14829. SELECT @MaxSalary = @MinSalary - 99, @MinSalary = @MinSalary - 100
  14830. ELSE IF @MinSalary BETWEEN 114 AND 120
  14831. SELECT @MaxSalary = @MinSalary - 99, @MinSalary = 17
  14832. END
  14833. SELECT @Negotiable = para FROM @t_value WHERE name = 'IsNegotiable' AND para = 1
  14834. SELECT @Experience = para FROM @t_value WHERE name = 'MinExperience' AND para > 0
  14835. SELECT @ReplyRate = para FROM @t_value WHERE name = 'replyrate' AND para > 0
  14836. SELECT @Education = para FROM @t_value WHERE name = 'dcEducationID' AND para > 0
  14837. SELECT @EmpType = para FROM @t_value WHERE name = 'EmployType' AND para > ''
  14838. SELECT @KeyWord = para FROM @t_value WHERE name = 'KeyWord' AND para > ''
  14839. SELECT @PageNumber = para FROM @t_value WHERE name = 'PageNumber' AND LEN(para) > 0 AND ISNUMERIC(para) = 1
  14840. IF EXISTS(SELECT 'x' FROM @t_value WHERE name = 'CompanySizeID' AND LEN(para) > 0 AND ISNUMERIC(para) = 1)
  14841. SELECT @CompanySize = para FROM @t_value WHERE name = 'CompanySizeID'
  14842. SELECT @Welfare = para FROM @t_value WHERE name = 'Welfare' AND para > ''
  14843. SELECT @OnlyOnline = para FROM @t_value WHERE name = 'IsOnline' AND para = 1
  14844. SELECT @cvRegion = para FROM @t_value WHERE name = 'cvRegion' AND para > ''
  14845. SELECT @cvJobType = para FROM @t_value WHERE name = 'cvJobType' AND para > ''
  14846. SELECT @ip = para FROM @t_value WHERE name = 'SessionId' AND para > ''
  14847. IF LEFT(@Region, 1) = 'p'
  14848. SELECT @MapPlace = RIGHT(@Region, LEN(@Region) - 1), @Region = ''
  14849. SELECT @Source = para FROM @t_value WHERE name = 'Source' AND para > 0
  14850. SELECT @ShowFilter = para FROM @t_value WHERE name = 'Type' AND LEN(para) > 0
  14851. IF LEN(@Keyword) > 14
  14852. SET @CanReturn = 1
  14853. IF EXISTS(SELECT TOP 1 'x' FROM RefuseIp WITH(NOLOCK) WHERE CHARINDEX(Ip, @ip) > 0)
  14854. SET @CanReturn = 1
  14855. IF CHARINDEX(', 0', @Region) > 0 OR CHARINDEX(', 0', @JobType) > 0
  14856. OR CHARINDEX(', , ', @Region) > 0 OR CHARINDEX(', , ', @JobType) > 0
  14857. OR LEN(@Region) > 35 OR LEN(@JobType) > 25
  14858. SET @CanReturn = 1
  14859. IF @CanReturn = 1
  14860. BEGIN
  14861. SELECT 0 ValidJobNumber
  14862. SELECT TOP 0 * FROM JobTemp
  14863. SELECT TOP 0 * FROM @t_filter
  14864. SELECT TOP 0 * FROM @t_filter
  14865. SELECT TOP 0 * FROM @t_filter
  14866. SELECT TOP 0 * FROM @t_filter
  14867. SELECT TOP 0 * FROM @t_filter
  14868. SELECT TOP 0 * FROM @t_filter
  14869. SELECT TOP 0 * FROM @t_filter
  14870. RETURN
  14871. END
  14872. IF CHARINDEX('请填写', @KeyWord) > 0
  14873. SET @KeyWord = ''
  14874. IF LEN(@KeyWord) > 1
  14875. BEGIN
  14876. SET @KeyWord = LTRIM(RTRIM(@Keyword))
  14877. WHILE CHARINDEX(' ', @Keyword) > 0
  14878. SET @KeyWord = REPLACE(@Keyword, ' ', ' ')
  14879. SET @KeyWord = REPLACE(REPLACE(@KeyWord, '''', ''''''), ';', '')
  14880. END
  14881. IF LEN(@KeyWord) < 2
  14882. SET @Keyword = ''
  14883. ----给null值变量赋默认值
  14884. IF @EmpType NOT IN('3', '4')
  14885. SET @EmpType = ''
  14886. IF @MinSalary > 20 OR @MinSalary < 2
  14887. SET @MinSalary = 0
  14888. IF @MaxSalary > 20 OR @MaxSalary < 2
  14889. SET @MaxSalary = 0
  14890. SELECT @JobType = RTRIM(dbo.FormatIDS(@JobType)),
  14891. @Industry = RTRIM(dbo.FormatIDS(@Industry)),
  14892. @Welfare = RTRIM(dbo.FormatIDS(@Welfare)),
  14893. @cvRegion = RTRIM(dbo.FormatIDS(@cvRegion)),
  14894. @cvJobType = RTRIM(dbo.FormatIDS(@cvJobType))
  14895. IF LEN(@Welfare) > 1
  14896. BEGIN
  14897. DECLARE @Welfare_temp VARCHAR(50)
  14898. SET @Welfare_temp = ''
  14899. SELECT @Welfare_temp = @Welfare_temp + a + ',' FROM dbo.fnSplit(@Welfare, ',') WHERE a <= 19 AND LEN(a) < 3
  14900. IF LEN(@Welfare_temp) > 1
  14901. SET @Welfare_temp = LEFT(@Welfare_temp, LEN(@Welfare_temp) - 1)
  14902. SET @Welfare = @Welfare_temp
  14903. END
  14904. IF RIGHT(@JobType, 1) = ','
  14905. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  14906. IF RIGHT(@Region, 1) = ','
  14907. SET @Region = LEFT(@Region, LEN(@Region) - 1)
  14908. IF RIGHT(@Industry, 1) = ','
  14909. SET @Industry = LEFT(@Industry, LEN(@Industry) - 1)
  14910. --分析参数结束
  14911. --记录参数开始
  14912. DECLARE @crDate DATETIME, @inttemp INT
  14913. SELECT TOP 1 @JobSearchLogId = id, @crDate = crDate, @inttemp = Result
  14914. FROM JobSearchLog WITH(NOLOCK)
  14915. WHERE Province = @Province AND JobType = @JobType AND Region = @Region AND MapPlace = @MapPlace AND Industry = @Industry
  14916. AND MinSalary = @MinSalary AND MaxSalary = @MaxSalary AND ReplyRate = @ReplyRate AND Negotiable = @Negotiable AND Experience = @Experience
  14917. AND Education = @Education AND EmpType = @EmpType AND KeyWord = @KeyWord AND CompanySize = @CompanySize
  14918. AND Welfare = @Welfare AND OnlyOnline = @OnlyOnline AND OnlyEnv = @OnlyEnv AND cvRegion = @cvRegion AND cvJobType = @cvJobType
  14919. AND crDate > DATEADD(MINUTE, @jobExpired, GETDATE())
  14920. ORDER BY ID DESC
  14921. --IF @JobSearchLogId > 0
  14922. --BEGIN
  14923. -- IF @inttemp >= 300
  14924. -- BEGIN
  14925. -- IF @crDate < DATEADD(MINUTE, @jobExpired, GETDATE())
  14926. -- SET @JobSearchLogId = 0
  14927. -- END
  14928. -- ELSE
  14929. -- BEGIN
  14930. -- IF @crDate < DATEADD(MINUTE, @jobExpired * 10, GETDATE())
  14931. -- SET @JobSearchLogId = 0
  14932. -- END
  14933. --END
  14934. SELECT TOP 1 @FilterLogId = Id, @ValidJobNumber = Result
  14935. FROM FilterLog WITH(NOLOCK)
  14936. WHERE Province = @Province AND JobType = @JobType AND Region = @Region AND MapPlace = @MapPlace AND Industry = @Industry
  14937. AND MinSalary = @MinSalary AND MaxSalary = @MaxSalary AND ReplyRate = @ReplyRate AND Negotiable = @Negotiable AND Experience = @Experience
  14938. AND Education = @Education AND EmpType = @EmpType AND KeyWord = @KeyWord AND CompanySize = @CompanySize
  14939. AND Welfare = @Welfare AND OnlyOnline = @OnlyOnline AND OnlyEnv = @OnlyEnv
  14940. AND crDate > DATEADD(MINUTE, @filterExpired, GETDATE())
  14941. ORDER BY ID DESC
  14942. --记录参数结束
  14943. --gen sql statement
  14944. IF @FilterLogId = 0 OR @JobSearchLogId = 0
  14945. BEGIN
  14946. --make sql where
  14947. ------生成具体的职位类别,因为职位类别有包含(父子)关系
  14948. ----生成求聘职位
  14949. IF LEN(@JobType) > 0
  14950. BEGIN
  14951. SELECT @strJobType = @strJobType + LTRIM(STR(a.id)) + ', '
  14952. FROM dcJobType a WITH(NOLOCK),
  14953. (SELECT * FROM dbo.fnSplit(@JobType, ',') WHERE a < 9999) b
  14954. WHERE a.Id = b.a
  14955. OR a.ParentId = b.a
  14956. OR a.ParentId2 = b.a
  14957. IF LEN(@strJobType) > 1
  14958. SET @strJobType = LEFT(@strJobType, LEN(@strJobType) - 1)
  14959. END
  14960. ----生成工作地点
  14961. IF @MapPlace > 0
  14962. BEGIN
  14963. DECLARE @Degree AS DECIMAL(8, 5), @Lat AS DECIMAL(8, 5), @Lng AS DECIMAL(8, 5)
  14964. SELECT @Lat = Lat, @Lng = Lng FROM dcMapPlace WITH(NOLOCK) WHERE ID = @MapPlace
  14965. IF @Region LIKE '3201%'
  14966. SET @Degree = 1000 / 100000.0
  14967. ELSE
  14968. SET @Degree = 2000 / 100000.0
  14969. SET @strJobPlace = 'a.Lng BETWEEN ' + CONVERT(VARCHAR, @Lng - @Degree) +
  14970. ' AND ' + CONVERT(VARCHAR, @Lng + @Degree) +
  14971. ' AND a.Lat BETWEEN ' + CONVERT(VARCHAR, @Lat - @Degree) +
  14972. ' AND ' + CONVERT(VARCHAR, @Lat + @Degree) +
  14973. ' AND (a.Lng - ' + CONVERT(VARCHAR, @Lng) + ') * (a.Lng - ' + CONVERT(VARCHAR, @Lng) +
  14974. ') + (a.Lat - ' + CONVERT(VARCHAR, @Lat) + ') * (a.Lat - ' + CONVERT(VARCHAR, @Lat) +
  14975. ') < ' + CONVERT(VARCHAR, @Degree * @Degree)
  14976. END
  14977. ELSE IF LEN(@Region) > 0
  14978. BEGIN
  14979. SELECT @strJobPlace =
  14980. @strJobPlace + ' OR a.dcRegionId ' +
  14981. CASE WHEN LEN(a) = 6
  14982. THEN '= ''' + a + ''''
  14983. ELSE 'LIKE ''' + a + '%'''
  14984. END
  14985. FROM dbo.fnSplit(@Region, ',')
  14986. WHERE LEN(a) IN(2, 4, 6)
  14987. IF LEN(@strJobPlace) > 4
  14988. SET @strJobPlace = RIGHT(@strJobPlace, LEN(@strJobPlace) - 4)
  14989. END
  14990. --从job中搜索数据 开始
  14991. ----组合语句 开始
  14992. --SELECT TOP 2000 a.ID, a.cpMainId, a.dcJobTypeID, a.dcJobTypeIDMinor, a.dcSalaryID, a.dcRegionId, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID
  14993. --SELECT #TOP# a.ID
  14994. SET @SQL='
  14995. FROM JobPublish a WITH(NOLOCK)
  14996. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID
  14997. WHERE a.Valid = 1
  14998. AND b.Valid = 1'
  14999. ----职位有效,单位新有效
  15000. IF LEN(@Industry) > 0
  15001. SET @Sql = @Sql + '
  15002. AND b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @Industry + '))'
  15003. IF @Province > 0
  15004. SET @Sql = @Sql + ' AND b.dcProvinceId = ' + LTRIM(STR(@Province))
  15005. IF @ReplyRate IN(60, 70, 80, 90, 100)
  15006. SET @Sql = @Sql + '
  15007. AND b.ReplyRate >= ' + LEFT(@ReplyRate / 100.0, 3)
  15008. IF @OnlyEnv = 1
  15009. SET @Sql = @Sql + '
  15010. AND b.HasEnvironment = 1'
  15011. ----工作经验要求
  15012. IF @Experience < 100
  15013. SET @Sql = @Sql + '
  15014. AND a.MinExperience = ' + LTRIM(STR(@Experience))
  15015. ----学历要求
  15016. ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
  15017. IF @Education > 0
  15018. IF @Education = 2
  15019. SET @Sql = @Sql + '
  15020. AND a.dcEducationID IN(2, 3, 4)'
  15021. ELSE
  15022. SET @Sql = @Sql + '
  15023. AND a.dcEducationID = ' + LTRIM(STR(@Education))
  15024. ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
  15025. IF LEN(@EmpType) > 0
  15026. SET @Sql = @Sql + '
  15027. AND a.EmployType IN (' + @EmpType + ')'
  15028. IF @CompanySize BETWEEN 1 AND 6
  15029. SET @Sql = @Sql + '
  15030. AND b.dcCompanySizeID = ' + LTRIM(STR(@CompanySize))
  15031. IF LEN(@Welfare) > 0
  15032. SET @Sql = @Sql + '
  15033. AND a.Welfare' + REPLACE(@Welfare, ',', ' = 1 AND a.Welfare') + ' = 1'
  15034. IF @OnlyOnline = 1
  15035. SET @Sql = @Sql + '
  15036. AND a.caMainId IN(SELECT caMainId FROM caOnline WITH(NOLOCK) WHERE IsOnline = 1)'
  15037. ----职位类别
  15038. IF @strJobType > ''
  15039. SET @Sql = @Sql + '
  15040. AND a.dcJobTypeID IN(' + @strJobType + ')'
  15041. IF LEN(@strJobPlace) > 0
  15042. SET @Sql = @Sql + '
  15043. AND (' + @strJobPlace + ')'
  15044. IF @Negotiable = 1
  15045. SET @Sql = @Sql + '
  15046. AND a.dcSalaryID = 100 ' -- OR a.Negotiable = 1
  15047. ELSE IF @MinSalary > 0 AND @MaxSalary > 0
  15048. SET @Sql = @Sql + '
  15049. AND a.dcSalaryID <= ' + LTRIM(STR(@MaxSalary)) + '
  15050. AND a.dcSalaryIdMax >= ' + LTRIM(STR(@MinSalary))
  15051. IF @cvRegion > ''
  15052. BEGIN
  15053. SELECT @strCvRegion =
  15054. @strCvRegion + ' OR a.dcRegionId ' +
  15055. CASE WHEN LEN(a) = 6
  15056. THEN '= ''' + a + ''''
  15057. ELSE 'LIKE ''' + a + '%'''
  15058. END
  15059. FROM dbo.fnSplit(@cvRegion, ',')
  15060. WHERE LEN(a) IN(2, 4, 6)
  15061. SET @strCvRegion = RIGHT(@strCvRegion, LEN(@strCvRegion) - 4)
  15062. END
  15063. IF @cvJobType > ''
  15064. BEGIN
  15065. SELECT @strCvJobType = @strCvJobType + LTRIM(STR(a.id)) + ', '
  15066. FROM dcJobType a WITH(NOLOCK),
  15067. (SELECT * FROM dbo.fnSplit(@cvJobType, ',')) b
  15068. WHERE a.Id = b.a
  15069. OR a.ParentId = b.a
  15070. OR a.ParentId2 = b.a
  15071. IF LEN(@strCvJobType) > 1
  15072. SET @strCvJobType = LEFT(@strCvJobType, LEN(@strCvJobType) - 1)
  15073. END
  15074. SET @Order = ' ORDER BY'
  15075. IF @strCvRegion > ''
  15076. BEGIN
  15077. SET @Order = @Order + ' CASE WHEN ' + @strCvRegion + ' THEN 0 ELSE 2 END'
  15078. IF @strCvJobType > ''
  15079. SET @Order = @Order + '
  15080. + CASE WHEN a.dcJobTypeId IN (' + @strCvJobType + ') THEN 0 ELSE 1 END,
  15081. '
  15082. ELSE
  15083. SET @Order = @Order + ',
  15084. '
  15085. END
  15086. ELSE IF @strCvJobType > ''
  15087. SET @Order = @Order + ' CASE WHEN a.dcJobTypeId IN (' + @strCvJobType + ') THEN 0 ELSE 1 END,
  15088. '
  15089. SET @Order = @Order + ' a.RefreshDate DESC, a.SecondId DESC'
  15090. END
  15091. --gen sql end
  15092. --get filter start
  15093. IF @FilterLogID != 0
  15094. BEGIN
  15095. INSERT INTO @t_filter
  15096. SELECT FilterType, TypeId, TypeNumber FROM JobFilter WITH(NOLOCK) WHERE FilterLogID = @FilterLogID
  15097. BEGIN TRY
  15098. UPDATE FilterLog SET ReUseNumber = ReUseNumber + 1 WHERE Id = @FilterLogID
  15099. END TRY
  15100. BEGIN CATCH
  15101. END CATCH
  15102. END
  15103. ELSE
  15104. BEGIN
  15105. --获取符合条件的所有数据
  15106. CREATE TABLE #Filter(
  15107. Id INT IDENTITY(1, 1),
  15108. [JobId] INT,
  15109. [cpMainId] INT,
  15110. [dcRegionId] [VARCHAR](6) NULL,
  15111. [dcJobTypeID] [smallint] NOT NULL,
  15112. [dcSalaryID] [tinyint] NOT NULL,
  15113. [dcEducationID] [tinyint] NOT NULL,
  15114. [MinExperience] [tinyint] NOT NULL,
  15115. [IssueDate] [smalldatetime] NULL,
  15116. [EmployType] [tinyint] NOT NULL,
  15117. [dcCompanySizeID] [tinyint] NULL
  15118. )
  15119. IF @KeyWord = ''
  15120. BEGIN
  15121. SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
  15122. + @Sql + @Order
  15123. INSERT INTO #Filter
  15124. EXEC(@Exe)
  15125. SELECT @Result = @@ROWCOUNT
  15126. END
  15127. ELSE
  15128. BEGIN
  15129. --(1)显示职位名称中包含搜索的关键词的职位列表
  15130. SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
  15131. + @Sql
  15132. + ' AND a.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%'' '
  15133. + @Order
  15134. INSERT INTO #Filter
  15135. EXEC(@Exe)
  15136. SELECT @Result = @@ROWCOUNT
  15137. --(2)显示按照职位类别匹配规则的职位列表
  15138. IF @Result < 2000
  15139. BEGIN
  15140. SELECT @KeyJobTypeIds = LTRIM(STR(id)) + ',' FROM dcJobType WHERE CHARINDEX(@Keyword, Description) > 0
  15141. IF LEN(@KeyJobTypeIds) > 2
  15142. SELECT @KeyJobTypeIds = LEFT(@KeyJobTypeIds, LEN(@KeyJobTypeIds) - 1)
  15143. ELSE
  15144. BEGIN
  15145. SET @KeyJobTypeIds= ''
  15146. SELECT @KeyJobTypeIds = dcJobtypeIds FROM KeyWord2JobType WITH(NOLOCK) WHERE Keyword = @Keyword
  15147. END
  15148. IF @KeyJobTypeIds > ''
  15149. BEGIN
  15150. SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
  15151. + @Sql
  15152. + ' AND a.dcJobTypeID IN(''' + @KeyJobTypeIds + ''')
  15153. AND a.Id NOT IN(SELECT JobId FROM #Filter)'
  15154. + @Order
  15155. INSERT INTO #Filter
  15156. EXEC(@Exe)
  15157. SELECT @Result = @Result + @@ROWCOUNT
  15158. END
  15159. ELSE IF LEN(@Keyword) < 11
  15160. INSERT INTO KeyWordLog(crDate, Keyword) SELECT GETDATE(), @Keyword
  15161. END
  15162. --(3)显示企业名称中包含搜索的关键词的职位列表
  15163. IF @Result = 0
  15164. BEGIN
  15165. SET @Exe = 'SELECT DISTINCT TOP 2000 a.cpMainId, AvgSalary,b.LastLogindate '
  15166. + @Sql
  15167. + ' AND b.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%'' '
  15168. + ' ORDER BY b.AvgSalary DESC, b.LastLogindate DESC'
  15169. INSERT INTO #t_companyTemp
  15170. EXEC(@Exe)
  15171. SELECT @Result = @@ROWCOUNT
  15172. IF @Result > 0
  15173. BEGIN
  15174. INSERT INTO #t_companyList
  15175. SELECT a.Id, a.SecondId, a.Name, a.RealName, a.Lng, a.Lat, HasLicence, ISNULL(a.LogoFile, @Logo), a.dcRegionId,
  15176. (SELECT TOP 1 dcIndustryId FROM cpIndustry WITH(NOLOCK) WHERE cpIndustry.cpMainID = a.Id) dcIndustryID,
  15177. (SELECT COUNT(*) FROM JobPublish WITH(NOLOCK) WHERE JobPublish.cpMainId = a.Id) JobNumber
  15178. FROM cpMainPublish a WITH(NOLOCK), #t_companyTemp b
  15179. WHERE a.Id = b.Id
  15180. ORDER BY b.seq
  15181. SELECT @cpMainResult = @@ROWCOUNT
  15182. SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
  15183. + @Sql
  15184. + ' AND a.cpMainId IN(SELECT ID FROM #t_companyTemp)'
  15185. + @Order
  15186. INSERT INTO #Filter
  15187. EXEC(@Exe)
  15188. SELECT @Result = @@ROWCOUNT
  15189. END
  15190. END
  15191. ELSE IF @Result < 2000
  15192. BEGIN
  15193. SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
  15194. + @Sql
  15195. + ' AND b.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%''
  15196. AND a.Id NOT IN(SELECT JobId FROM #Filter)'
  15197. + @Order
  15198. INSERT INTO #Filter
  15199. EXEC(@Exe)
  15200. SELECT @Result = @Result + @@ROWCOUNT
  15201. END
  15202. --(4)全文搜索匹配的职位列表
  15203. IF @Result < 2000
  15204. BEGIN
  15205. INSERT #FullText
  15206. SELECT TOP 5000 3000 + RANK, [Key]
  15207. FROM FREETEXTTABLE(cpMainJob, *, @KeyWord, 100000) AS KeyJob ORDER BY RANK DESC
  15208. SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
  15209. + REPLACE(@Sql, 'INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID', 'INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID INNER JOIN #FullText ON a.ID = #FullText.JobId')
  15210. + ' AND a.Id NOT IN(SELECT JobId FROM #Filter)'
  15211. + REPLACE(@Order, ' ORDER BY', ' ORDER BY #FullText.Priority,')
  15212. INSERT INTO #Filter
  15213. EXEC(@Exe)
  15214. SELECT @Result = @Result + @@ROWCOUNT
  15215. END
  15216. END
  15217. SET @ValidJobNumber = @Result
  15218. INSERT INTO #t_jobid
  15219. SELECT TOP 2000 JobId FROM #Filter ORDER BY Id
  15220. SET @FillJobId = 1
  15221. ----生成筛选数据
  15222. DECLARE @t_filtertemp1 AS TABLE (
  15223. FilterType INT, --1 jobtype,
  15224. TypeID VARCHAR(10),
  15225. TypeNumber INT
  15226. )
  15227. DECLARE @t_filtertemp2 AS TABLE (
  15228. FilterType INT,
  15229. TypeID VARCHAR(10),
  15230. TypeNumber INT
  15231. )
  15232. ----------------------------jobtype
  15233. INSERT INTO @t_filtertemp1
  15234. SELECT 1, dcJobTypeID, COUNT(*)
  15235. FROM #Filter WITH(NOLOCK)
  15236. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  15237. ----计算全部某职位类别,2, 4位的数据
  15238. IF LEN(@JobType) = 0
  15239. INSERT INTO @t_filtertemp2
  15240. SELECT 1, LEFT(TypeID, 2), SUM(TypeNumber)
  15241. FROM @t_filtertemp1 GROUP BY LEFT(TypeID, 2)
  15242. ELSE IF LEN(@JobType) = 2
  15243. INSERT INTO @t_filtertemp2
  15244. SELECT 1, TypeID, TypeNumber
  15245. FROM @t_filtertemp1
  15246. WHERE TypeID LIKE @JobType + '__'
  15247. ELSE IF LEN(@JobType) > 4
  15248. BEGIN
  15249. INSERT INTO @t_filtertemp2 SELECT * FROM @t_filtertemp1
  15250. INSERT INTO @t_filtertemp2
  15251. SELECT 1, LEFT(TypeID, 2), SUM(TypeNumber)
  15252. FROM @t_filtertemp1 GROUP BY LEFT(TypeID, 2)
  15253. DELETE @t_filtertemp2 WHERE TypeID NOT IN(SELECT a FROM dbo.fnSplit(@JobType, ','))
  15254. END
  15255. INSERT INTO @t_filter SELECT * FROM @t_filtertemp2
  15256. DELETE @t_filtertemp2
  15257. DELETE @t_filtertemp1
  15258. --------------------------region
  15259. IF @Mapplace = 0
  15260. BEGIN
  15261. INSERT INTO @t_filtertemp1
  15262. SELECT 2, dcRegionId, COUNT(*) FROM #Filter WITH(NOLOCK)
  15263. GROUP BY dcRegionId ORDER BY dcRegionId
  15264. ----计算全部地区,2位的数据
  15265. IF LEN(@Region) = 0
  15266. INSERT INTO @t_filtertemp2
  15267. SELECT 2, LEFT(TypeID, 2) TypeID, SUM(TypeNumber) TypeNumber
  15268. FROM @t_filtertemp1 GROUP BY LEFT(TypeID, 2)
  15269. ELSE IF LEN(@Region) = 2
  15270. INSERT INTO @t_filtertemp2
  15271. SELECT 2, LEFT(TypeID, 4) TypeID, SUM(TypeNumber) TypeNumber
  15272. FROM @t_filtertemp1 WHERE LEN(TypeID) >= 4 AND TypeId LIKE @Region + '%'
  15273. GROUP BY LEFT(TypeID, 4)
  15274. ELSE IF LEN(@Region) = 4
  15275. INSERT INTO @t_filtertemp2
  15276. SELECT 2, TypeID, TypeNumber
  15277. FROM @t_filtertemp1 WHERE LEN(TypeID) = 6
  15278. ELSE IF @Region LIKE '%,%'
  15279. BEGIN
  15280. INSERT INTO @t_filtertemp2
  15281. SELECT 2, LEFT(TypeID, 2) TypeID, SUM(TypeNumber) TypeNumber
  15282. FROM @t_filtertemp1 GROUP BY LEFT(TypeID, 2)
  15283. INSERT INTO @t_filtertemp2
  15284. SELECT 2, LEFT(TypeID, 4) TypeID, SUM(TypeNumber) TypeNumber
  15285. FROM @t_filtertemp1 WHERE LEN(TypeID) >= 4
  15286. GROUP BY LEFT(TypeID, 4)
  15287. INSERT INTO @t_filtertemp2 SELECT * FROM @t_filtertemp1 WHERE LEN(TypeID) = 6
  15288. DELETE @t_filtertemp2 WHERE TypeID NOT IN(SELECT a FROM dbo.FnSplit(@Region, ','))
  15289. END
  15290. INSERT INTO @t_filter SELECT * FROM @t_filtertemp2
  15291. --DELETE @t_filtertemp2
  15292. --DELETE @t_filtertemp1
  15293. END
  15294. ----------------------------
  15295. INSERT INTO @t_filter
  15296. SELECT 3, EmployType, COUNT(*)
  15297. FROM #Filter WITH(NOLOCK)
  15298. GROUP BY EmployType ORDER BY EmployType
  15299. INSERT INTO @t_filter
  15300. SELECT 4, CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  15301. FROM #Filter WITH(NOLOCK)
  15302. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  15303. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  15304. INSERT INTO @t_filter
  15305. SELECT 5, MinExperience, COUNT(*) FROM #Filter WITH(NOLOCK)
  15306. GROUP BY MinExperience ORDER BY MinExperience
  15307. INSERT INTO @t_filter
  15308. SELECT 6, dcCompanySizeID, COUNT(*) FROM #Filter WITH(NOLOCK)
  15309. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  15310. INSERT INTO @t_filter
  15311. SELECT 7, dcSalaryID, COUNT(*) FROM #Filter WITH(NOLOCK)
  15312. GROUP BY dcSalaryID ORDER BY dcSalaryID
  15313. INSERT INTO @t_filter
  15314. SELECT 8, dcIndustryID, COUNT(*)
  15315. FROM #Filter a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)-- INDEX(NonClusteredIndex_cpIndustry_cpMainId))
  15316. WHERE a.cpMainId = b.cpMainId
  15317. GROUP BY b.dcIndustryId ORDER BY b.dcIndustryId
  15318. ----记录筛选数据
  15319. INSERT INTO FilterLog(crDate, Source, ip, Province, JobType, Region, MapPlace, Industry, MinSalary,
  15320. MaxSalary, ReplyRate, Negotiable, Experience, Education, EmpType, KeyWord, CompanySize,
  15321. Welfare, OnlyOnline, OnlyEnv, Result, SqlString, RunTime, DayMinute)
  15322. SELECT GETDATE(), @Source, @ip, @Province, @JobType, @Region, @MapPlace, @Industry, @MinSalary,
  15323. @MaxSalary, @ReplyRate, @Negotiable, @Experience, @Education, @EmpType, @KeyWord, @CompanySize,
  15324. @Welfare, @OnlyOnline, @OnlyEnv, @ValidJobNumber, @Exe, DATEDIFF(MS, @Start, GETDATE()),
  15325. ROUND(CONVERT(DECIMAL(18, 9), GETDATE()) % 1.0 * 60 * 24, 0)
  15326. SET @FilterLogId = @@IDENTITY
  15327. INSERT INTO JobFilter
  15328. SELECT @FilterLogId FilterLogId, * FROM @t_filter
  15329. INSERT INTO CompanyList
  15330. SELECT @FilterLogId FilterLogId, * FROM #t_companyList
  15331. END
  15332. IF @JobSearchLogId > 0
  15333. BEGIN
  15334. UPDATE JobSearchLog SET ReUseNumber = ReUseNumber + 1 WHERE Id = @JobSearchLogId
  15335. END
  15336. ELSE
  15337. BEGIN
  15338. --select jobid
  15339. SET @Result = 0
  15340. IF @FillJobId = 1
  15341. BEGIN
  15342. SELECT @Result = COUNT(*) FROM #t_jobid
  15343. END
  15344. ELSE
  15345. BEGIN
  15346. TRUNCATE TABLE #t_jobid
  15347. IF @KeyWord = ''
  15348. BEGIN
  15349. SET @Exe = 'SELECT TOP 2000 a.Id ' + @Sql + @Order
  15350. INSERT INTO #t_jobid
  15351. EXEC(@Exe)
  15352. SET @Result = @@ROWCOUNT
  15353. END
  15354. ELSE
  15355. BEGIN
  15356. --(1)显示职位名称中包含搜索的关键词的职位列表
  15357. SET @Exe = 'SELECT TOP 2000 a.Id '
  15358. + @Sql
  15359. + ' AND a.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%'' '
  15360. + @Order
  15361. INSERT INTO #t_jobid
  15362. EXEC(@Exe)
  15363. SELECT @Result = @@ROWCOUNT
  15364. --(2)显示按照职位类别匹配规则的职位列表
  15365. IF @Result < 2000
  15366. BEGIN
  15367. SELECT @KeyJobTypeIds = ''
  15368. SELECT @KeyJobTypeIds = LTRIM(STR(id)) + ',' FROM dcJobType WHERE CHARINDEX(@Keyword, Description) > 0
  15369. IF LEN(@KeyJobTypeIds) > 2
  15370. SELECT @KeyJobTypeIds = LEFT(@KeyJobTypeIds, LEN(@KeyJobTypeIds) - 1)
  15371. ELSE
  15372. BEGIN
  15373. SET @KeyJobTypeIds= ''
  15374. SELECT @KeyJobTypeIds = dcJobtypeIds FROM KeyWord2JobType WITH(NOLOCK) WHERE Keyword = @Keyword
  15375. END
  15376. IF @KeyJobTypeIds > ''
  15377. BEGIN
  15378. SET @Exe = 'SELECT TOP 2000 a.Id '
  15379. + @Sql
  15380. + ' AND a.dcJobTypeID IN(''' + @KeyJobTypeIds + ''')
  15381. AND a.Id NOT IN(SELECT JobId FROM #t_jobid)'
  15382. + @Order
  15383. INSERT INTO #t_jobid
  15384. EXEC(@Exe)
  15385. SELECT @Result = @Result + @@ROWCOUNT
  15386. END
  15387. END
  15388. --(3)显示企业名称中包含搜索的关键词的职位列表
  15389. IF @Result = 0
  15390. BEGIN
  15391. INSERT INTO #t_companyList
  15392. SELECT Id, SecondId, Name, RealName, Lng, Lat, HasLicence, ISNULL(LogoFile, @Logo), dcRegionId, dcIndustryID, JobNumber
  15393. FROM CompanyList WITH(NOLOCK)
  15394. WHERE FilterLogID = @FilterLogID
  15395. ORDER BY seq
  15396. SELECT @cpMainResult = @@ROWCOUNT
  15397. SET @Exe = 'SELECT TOP 2000 a.Id '
  15398. + @Sql
  15399. + ' AND a.cpMainId IN(SELECT ID FROM #t_companyList)'
  15400. + @Order
  15401. INSERT INTO #t_jobid
  15402. EXEC(@Exe)
  15403. SELECT @Result = @@ROWCOUNT
  15404. END
  15405. ELSE IF @Result < 2000
  15406. BEGIN
  15407. SET @Exe = 'SELECT TOP 2000 a.Id '
  15408. + @Sql
  15409. + ' AND b.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%''
  15410. AND a.Id NOT IN(SELECT JobId FROM #t_jobid)'
  15411. + @Order
  15412. INSERT INTO #t_jobid
  15413. EXEC(@Exe)
  15414. SELECT @Result = @Result + @@ROWCOUNT
  15415. END
  15416. --(4)全文搜索匹配的职位列表
  15417. IF @Result < 2000
  15418. BEGIN
  15419. TRUNCATE TABLE #FullText
  15420. INSERT #FullText
  15421. SELECT TOP 5000 3000 + RANK, [Key]
  15422. FROM FREETEXTTABLE(cpMainJob, *, @KeyWord, 100000) AS KeyJob ORDER BY RANK DESC
  15423. SET @Exe = 'SELECT TOP 2000 a.Id '
  15424. + REPLACE(@Sql, 'INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID', 'INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID INNER JOIN #FullText ON a.ID = #FullText.JobId')
  15425. + ' AND a.Id IN(SELECT TOP 5000 [Key] FROM FREETEXTTABLE(cpMainJob, *, ''' + @KeyWord + ''', 100000) AS KeyJob ORDER BY RANK DESC)
  15426. AND a.Id NOT IN(SELECT JobId FROM #t_jobid)'
  15427. + REPLACE(@Order, ' ORDER BY', ' ORDER BY #FullText.Priority,')
  15428. INSERT INTO #t_jobid
  15429. EXEC(@Exe)
  15430. SELECT @Result = @Result + @@ROWCOUNT
  15431. END
  15432. END
  15433. END
  15434. ----set istop
  15435. IF @KeyWord > ''
  15436. INSERT INTO @t_top
  15437. SELECT TOP 10 a.JobId
  15438. FROM SearchJobTop a WITH(NOLOCK), #t_jobid b
  15439. WHERE b.JobId = a.JobId
  15440. AND EXISTS(SELECT 'x' FROM JobPublish c WITH(NOLOCK) WHERE CHARINDEX(@keyword, c.Name ) > 0 AND c.Id = a.JobId)
  15441. ORDER BY a.OrderType, a.OpenDate DESC
  15442. ELSE
  15443. INSERT INTO @t_top
  15444. SELECT TOP 10 a.JobId
  15445. FROM SearchJobTop a WITH(NOLOCK), #t_jobid b
  15446. WHERE b.JobId = a.JobId
  15447. ORDER BY a.OrderType, a.OpenDate DESC
  15448. IF EXISTS(SELECT TOP 1 'x' FROM @t_top)
  15449. DELETE FROM #t_jobid WHERE JobId IN(SELECT JobId FROM @t_top)
  15450. ----记录筛选数据
  15451. INSERT INTO JobSearchLog(crDate, Source, ip, Province, JobType, Region, MapPlace, Industry, MinSalary,
  15452. MaxSalary, ReplyRate, Negotiable, Experience, Education, EmpType, KeyWord, CompanySize,
  15453. Welfare, OnlyOnline, OnlyEnv, cvRegion, cvJobType, Result, SqlString, RunTime)
  15454. SELECT GETDATE(), @Source, @ip, @Province, @JobType, @Region, @MapPlace, @Industry, @MinSalary,
  15455. @MaxSalary, @ReplyRate, @Negotiable, @Experience, @Education, @EmpType, @KeyWord, @CompanySize,
  15456. @Welfare, @OnlyOnline, @OnlyEnv, @cvRegion, @cvJobType, @Result, @Exe, DATEDIFF(MS, @Start, GETDATE())
  15457. SET @JobSearchLogId = @@IDENTITY
  15458. IF EXISTS(SELECT TOP 1 'x' FROM @t_top)
  15459. BEGIN
  15460. INSERT INTO JobList
  15461. SELECT @JobSearchLogId JobSearchLogId, JobId, 1 FROM @t_top ORDER BY seq
  15462. INSERT INTO JobList
  15463. SELECT @JobSearchLogId JobSearchLogId, JobId, 0 FROM #t_jobid ORDER BY Id
  15464. END
  15465. ELSE
  15466. BEGIN
  15467. IF @Result > 99
  15468. INSERT INTO JobList
  15469. SELECT @JobSearchLogId JobSearchLogId, JobId, CASE WHEN Id < 4 THEN 1 ELSE 0 END FROM #t_jobid ORDER BY Id
  15470. ELSE
  15471. INSERT INTO JobList
  15472. SELECT @JobSearchLogId JobSearchLogId, JobId, 0 FROM #t_jobid ORDER BY Id
  15473. END
  15474. END
  15475. ----组合语句 结束
  15476. --从job中搜索数据 结束
  15477. ----show tables start
  15478. ----返回查询数量
  15479. DECLARE @ShowCompany INT = 0
  15480. IF @PageNumber = 1
  15481. BEGIN
  15482. IF NOT EXISTS(SELECT TOP 1 'x' FROM #t_companyList)
  15483. INSERT INTO #t_companyList(Id, SecondId, Name, RealName, Lng, Lat, HasLicence, LogoFile, dcRegionId, dcIndustryId, JobNumber)
  15484. SELECT Id, SecondId, Name, RealName, Lng, Lat, HasLicence, ISNULL(LogoFile, @Logo), dcRegionId, dcIndustryId, JobNumber FROM CompanyList WITH(NOLOCK) WHERE FilterLogId = @FilterLogID ORDER BY Seq
  15485. SELECT @ShowCompany = COUNT(*) FROM #t_companyList
  15486. END
  15487. SELECT @ValidJobNumber ValidJobNumber, @ShowFilter ShowFilter, @ShowCompany ShowCompany
  15488. ----返回@PageSize行查询结果
  15489. INSERT INTO @t_jobid
  15490. SELECT JobId, IsTop FROM JobList WITH(NOLOCK) WHERE JobSearchLogId = @JobSearchLogId ORDER BY Id
  15491. IF @Source = 10
  15492. SELECT TOP (@PageSize) a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
  15493. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  15494. a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
  15495. b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
  15496. ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
  15497. e.FullName Region, b.LogoFile LogoUrl, @ValidJobNumber JobNumber,
  15498. f.Description EducationName,g.Description ExperienceName,
  15499. h.DescriptionCp dcSalary,i.DescriptionCp dcSalaryMax
  15500. FROM JobPublish a WITH(NOLOCK)
  15501. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  15502. INNER JOIN @t_jobid c ON a.id = c.JobID
  15503. INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
  15504. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  15505. LEFT JOIN dcEducation f WITH(NOLOCK) ON f.ID = a.dcEducationID
  15506. INNER JOIN dcOthers g WITH(NOLOCK) ON g.DetailID = a.MinExperience AND g.Category='职位要求工作经验'
  15507. INNER JOIN dcSalary h WITH(NOLOCK) ON h.ID = a.dcSalaryID
  15508. INNER JOIN dcSalary i WITH(NOLOCK) ON i.ID = a.dcSalaryIDMax
  15509. WHERE c.ID >= (@PageNumber - 1) * @PageSize
  15510. ORDER BY c.ID, a.ID DESC
  15511. ELSE
  15512. SELECT TOP (@PageSize) a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  15513. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  15514. a.dcRegionId, a.Responsibility, a.Demand, a.dcEducationID,
  15515. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  15516. a.IsDelete, a.AddDate, a.RefreshDate, a.Welfare1, a.Welfare2, a.Welfare3,
  15517. a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8,
  15518. a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13,
  15519. a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18, a.Welfare19,
  15520. a.SecondId EnJobID, b.SecondId EnCpMainID,
  15521. a.LastModifyDate, b.Name cpName, b.dcCompanySizeID,
  15522. b.HasLicence, b.RealName, b.UnLimitedDate, b.BalanceDate, b.Balance, b.LogoFile LogoUrl,
  15523. b.MemberType, '' cpIndustry, --STUFF((SELECT ',' + LTRIM(x.dcIndustryid) + ',c' + LTRIM(isnull(y.Category,0)) FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  15524. c.IsTop, b.IsRefreshed, ISNULL(d.IsOnline, 0) IsOnline, d.IsVi, d.ViPlanId, d.InterviewDate, CASE WHEN b.ReplyRate >= 0.6 THEN b.ReplyRate ELSE NULL END Replyrate,
  15525. (SELECT TOP 1 ID from paAttention WITH(NOLOCK) WHERE AttentionType=2 AND AttentionID=a.ID AND paMainId = @paMainId) AttentionId
  15526. FROM JobPublish a WITH(NOLOCK)
  15527. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  15528. INNER JOIN @t_jobid c ON a.id = c.JobID
  15529. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  15530. WHERE c.ID >= (@PageNumber - 1) * @PageSize
  15531. ORDER BY c.ID, a.ID DESC
  15532. ----返回统计数量
  15533. IF @ShowFilter = 1
  15534. BEGIN
  15535. IF @Source = 10
  15536. BEGIN
  15537. SELECT 1 PaSearchConditionId, 'JobType' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
  15538. FROM @t_filter a LEFT JOIN dcJobType b ON b.ID = a.TypeId
  15539. WHERE FilterType = 1
  15540. ORDER BY TypeId
  15541. IF @MapPlace = 0
  15542. BEGIN
  15543. --level 3 region
  15544. IF LEN(@Region) > 0
  15545. AND @Region NOT LIKE '%,%'
  15546. AND NOT EXISTS(SELECT TOP 1 'x' FROM dcRegion WHERE ParentID = @Region)
  15547. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionId = @Region
  15548. ELSE
  15549. SELECT 1 PaSearchConditionId, 'Region' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
  15550. FROM @t_filter a
  15551. LEFT JOIN dcRegion b ON b.ID = a.TypeId
  15552. WHERE FilterType = 2
  15553. ORDER BY TypeId
  15554. END
  15555. SELECT 1 PaSearchConditionId, 'Education' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
  15556. FROM @t_filter a
  15557. LEFT JOIN dcEducation b ON b.ID = a.TypeId
  15558. WHERE FilterType = 4
  15559. ORDER BY CONVERT(INT, TypeId)
  15560. SELECT 1 PaSearchConditionId, 'Experience' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
  15561. FROM @t_filter a
  15562. LEFT JOIN dcOthers b ON b.DetailID = a.TypeId AND Category='职位要求工作经验'
  15563. WHERE FilterType = 5
  15564. ORDER BY CONVERT(INT, TypeId)
  15565. SELECT 1 PaSearchConditionId, 'Salary' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue
  15566. FROM @t_filter
  15567. WHERE FilterType = 7
  15568. ORDER BY CONVERT(INT, TypeId)
  15569. SELECT 1 PaSearchConditionId, 'EmployType' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
  15570. FROM @t_filter a
  15571. LEFT JOIN dcOthers b ON b.DetailID = a.TypeId AND Category='工作性质'
  15572. WHERE FilterType = 3
  15573. ORDER BY CONVERT(INT, TypeId)
  15574. SELECT 1 PaSearchConditionId, 'CompanySize' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
  15575. FROM @t_filter a
  15576. LEFT JOIN dcCompanySize b ON b.ID = a.TypeId
  15577. WHERE FilterType = 6
  15578. ORDER BY CONVERT(INT, TypeId)
  15579. END
  15580. ELSE
  15581. BEGIN
  15582. SELECT 1 PaSearchConditionId, 'JobType' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 1 ORDER BY TypeId
  15583. IF @MapPlace = 0
  15584. BEGIN
  15585. --level 3 region
  15586. IF LEN(@Region) > 0
  15587. AND @Region NOT LIKE '%,%'
  15588. AND NOT EXISTS(SELECT TOP 1 'x' FROM dcRegion WHERE ParentID = @Region)
  15589. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionId = @Region
  15590. ELSE
  15591. SELECT 1 PaSearchConditionId, 'Region' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 2 ORDER BY TypeId
  15592. END
  15593. SELECT 1 PaSearchConditionId, 'Education' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 4 ORDER BY TypeId
  15594. SELECT 1 PaSearchConditionId, 'Experience' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 5 ORDER BY TypeId
  15595. SELECT 1 PaSearchConditionId, 'Salary' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 7 ORDER BY TypeId
  15596. SELECT 1 PaSearchConditionId, 'EmployType' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 3 ORDER BY TypeId
  15597. SELECT 1 PaSearchConditionId, 'CompanySize' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 6 ORDER BY TypeId
  15598. SELECT 1 PaSearchConditionId, 'Industry' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 8 ORDER BY TypeId
  15599. END
  15600. END
  15601. --如果有companylist列表,则显示
  15602. IF @ShowCompany > 0
  15603. BEGIN
  15604. IF @paMainId > 0
  15605. SELECT Id, SecondId, Name, RealName, Lng, Lat, HasLicence, LogoFile, JobNumber,
  15606. (SELECT FullName FROM dcRegion WHERE Id = dcRegionId) Region,
  15607. (SELECT Description FROM dcIndustry WHERE Id = dcIndustryId) Industry,
  15608. (SELECT TOP 1 ID from paAttention WITH(NOLOCK)
  15609. WHERE AttentionType=1 AND AttentionID = a.ID
  15610. AND paMainId = @paMainId) AttentionId
  15611. FROM #t_CompanyList a
  15612. ORDER BY Seq
  15613. ELSE
  15614. SELECT Id, SecondId, Name, RealName, Lng, Lat, HasLicence, LogoFile, JobNumber, null AttentionId,
  15615. (SELECT FullName FROM dcRegion WHERE Id = dcRegionId) Region,
  15616. (SELECT Description FROM dcIndustry WHERE Id = dcIndustryId) Industry
  15617. FROM #t_CompanyList ORDER BY Seq
  15618. END
  15619. END TRY
  15620. BEGIN CATCH
  15621. INSERT INTO ErrLog
  15622. VALUES(ERROR_NUMBER(), ERROR_SEVERITY(), ERROR_STATE(), ERROR_PROCEDURE(), ERROR_LINE(),
  15623. ERROR_MESSAGE() + ' sql=' + ISNULL(@sql, 'null')
  15624. + ' @order=' + ISNULL(@order, 'null') + ' exe=' + ISNULL(@exe, 'null'), GETDATE())
  15625. END CATCH
  15626. GO
  15627. /****** Object: StoredProcedure [dbo].[ProcJobRecommendByPaMainIDUpdate] Script Date: 2018/12/13 19:11:05 ******/
  15628. SET ANSI_NULLS ON
  15629. GO
  15630. SET QUOTED_IDENTIFIER ON
  15631. GO
  15632. CREATE PROCEDURE [dbo].[ProcJobRecommendByPaMainIDUpdate]
  15633. (
  15634. @PaMainID INT,
  15635. @dcJobTypeID VARCHAR(100), --职位类别
  15636. @dcRegionID VARCHAR(100), --求职地区
  15637. @dcIndustryID VARCHAR(100), --求职行业
  15638. @dcSalaryID TINYINT, --月薪
  15639. @MinExperience TINYINT, --工作经验,100为未选择
  15640. @dcEducationID TINYINT, --最低学历
  15641. @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习
  15642. @RowCount SMALLINT, --需要显示的行数
  15643. @Type INT --1猜你喜欢 2小伙伴们都在申请
  15644. )
  15645. AS
  15646. BEGIN
  15647. IF @RowCount = 0
  15648. BEGIN
  15649. SET @RowCount = 20
  15650. END
  15651. --删除后重新生成数据
  15652. DELETE FROM SHORTDB..JobRecommend WHERE PaMainID = @PaMainID AND Type = @Type
  15653. IF @Type = 1
  15654. BEGIN
  15655. SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
  15656. @dcRegionID = RTRIM(dbo.FormatIDS(@dcRegionID)),
  15657. @dcIndustryID = RTRIM(dbo.FormatIDS(@dcIndustryID)),
  15658. @dcSalaryID = ISNULL(@dcSalaryID, 0),
  15659. @MinExperience = ISNULL(@MinExperience, 100),
  15660. @dcEducationID = ISNULL(@dcEducationID, 0),
  15661. @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END
  15662. IF @dcJobTypeID LIKE '%,%,%,%,%,%'
  15663. SET @dcJobTypeID = LEFT(@dcJobTypeID, 2)
  15664. IF @dcRegionID LIKE '%,%,%,%,%,%'
  15665. SET @dcRegionID = LEFT(@dcRegionID, 2)
  15666. IF RIGHT(@dcJobTypeID, 1) = ','
  15667. SET @dcJobTypeID = LEFT(@dcJobTypeID, LEN(@dcJobTypeID) - 1)
  15668. IF RIGHT(@dcRegionID, 1) = ','
  15669. SET @dcRegionID = LEFT(@dcRegionID, LEN(@dcRegionID) - 1)
  15670. IF RIGHT(@dcIndustryID, 1) = ','
  15671. SET @dcIndustryID = LEFT(@dcIndustryID, LEN(@dcIndustryID) - 1)
  15672. ------生成职位类别的表变量,因为职位类别有包含(父子)关系
  15673. DECLARE @T_JobPlace AS TABLE(ID INT)
  15674. DECLARE @T_JobType AS TABLE(ID INT)
  15675. DECLARE @JobType AS VARCHAR(3000)
  15676. DECLARE @JobPlace AS VARCHAR(2000)
  15677. DECLARE @SQL AS NVARCHAR(MAX)
  15678. DECLARE @WHERE AS VARCHAR(8000)
  15679. DECLARE @FROM AS VARCHAR(1000)
  15680. SET @JobPlace = ''
  15681. SET @JobType=''
  15682. ----生成工作地点的表变量
  15683. IF LEN(@dcRegionID) > 0
  15684. BEGIN
  15685. INSERT INTO @T_JobPlace
  15686. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  15687. SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  15688. IF LEN(@JobPlace) > 0
  15689. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  15690. END
  15691. ----生成求聘职位的表变量
  15692. IF LEN(@dcJobTypeID) > 0
  15693. BEGIN
  15694. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  15695. INSERT INTO @T_Temp
  15696. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  15697. INSERT INTO @T_JobType
  15698. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  15699. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  15700. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  15701. OR ID IN(SELECT ID FROM @T_TEMP)
  15702. ----生成in字符串
  15703. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  15704. IF RIGHT(@JobType, 1) = ','
  15705. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  15706. END
  15707. ----建立临时表
  15708. CREATE TABLE #Job(
  15709. RowID INT IDENTITY(1, 1),
  15710. ID INT NOT NULL,
  15711. dcJobTypeID SMALLINT NOT NULL,
  15712. dcJobTypeIDMinor SMALLINT NULL,
  15713. dcSalaryID TINYINT NOT NULL,
  15714. dcRegionID VARCHAR(6) NULL,
  15715. dcEducationID TINYINT NOT NULL,
  15716. MinExperience TINYINT NOT NULL,
  15717. RefreshDate SMALLDATETIME NULL
  15718. )
  15719. ----生成插入临时表的Sql语句
  15720. SET @SQL = '
  15721. INSERT INTO #Job
  15722. SELECT TOP ' + CONVERT(VARCHAR(3),@RowCount) + ' a.ID, a.dcJobTypeID,
  15723. a.dcJobTypeIDMinor, a.dcSalaryID,
  15724. a.dcRegionID, a.dcEducationID, a.MinExperience,
  15725. a.IssueDate'
  15726. SET @FROM = '
  15727. FROM JobPublish a WITH(NOLOCK)
  15728. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  15729. ----职位有效,单位新有效
  15730. IF LEN(@dcIndustryID) > 0
  15731. SET @WHERE = '
  15732. WHERE b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @dcIndustryID + '))
  15733. AND a.Valid = 1
  15734. AND b.Valid = 1'
  15735. ELSE
  15736. SET @WHERE = '
  15737. WHERE a.Valid = 1
  15738. AND b.Valid = 1'
  15739. ----职位类别
  15740. IF LEN(@dcJobTypeID) > 0
  15741. SET @WHERE = @WHERE + '
  15742. AND (a.dcJobTypeID IN(' + @JobType +')
  15743. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  15744. IF LEN(@JobPlace) > 0
  15745. SET @WHERE = @WHERE + '
  15746. AND (' + @JobPlace + ')'
  15747. IF @dcSalaryID > 0
  15748. BEGIN
  15749. IF @dcSalaryID < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
  15750. BEGIN
  15751. SET @WHERE = @WHERE + '
  15752. AND a.dcSalaryID IN(' + LTRIM(STR(@dcSalaryID)) + ',' + LTRIM(STR(@dcSalaryID + 1))
  15753. SET @WHERE = @WHERE + ')'
  15754. END
  15755. IF @dcSalaryID = 100 ----从筛选结果中点击面议,值是100
  15756. BEGIN
  15757. SET @WHERE = @WHERE + '
  15758. AND a.dcSalaryID = 100'
  15759. END
  15760. IF @dcSalaryID > 100 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  15761. SET @WHERE = @WHERE + '
  15762. AND a.dcSalaryID=' + LTRIM(STR(@dcSalaryID-100))
  15763. END
  15764. ----工作经验要求
  15765. IF @MinExperience < 100
  15766. SET @WHERE = @WHERE + '
  15767. AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
  15768. ----学历要求
  15769. ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
  15770. IF @dcEducationID > 0
  15771. IF @dcEducationID = 2
  15772. SET @WHERE = @WHERE + '
  15773. AND a.dcEducationID IN(2, 3, 4)'
  15774. ELSE
  15775. SET @WHERE = @WHERE + '
  15776. AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
  15777. ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
  15778. IF LEN(@EmployType) > 0
  15779. SET @WHERE = @WHERE + '
  15780. AND a.EmployType IN (' + @EmployType + ')'
  15781. SET @SQL = @SQL + @FROM + @WHERE
  15782. SET @SQL = @SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
  15783. EXEC(@SQL)
  15784. DECLARE @CurrentCount AS SMALLINT
  15785. DECLARE @NeedCount AS SMALLINT
  15786. SELECT @CurrentCount = COUNT(*) FROM #Job
  15787. IF @CurrentCount < @RowCount
  15788. BEGIN
  15789. SET @NeedCount = @RowCount - @CurrentCount
  15790. ----生成插入临时表的Sql语句
  15791. SET @SQL = '
  15792. INSERT INTO #Job
  15793. SELECT TOP ' + CONVERT(VARCHAR(3),@NeedCount) + ' a.ID, a.dcJobTypeID,
  15794. a.dcJobTypeIDMinor, a.dcSalaryID,
  15795. a.dcRegionID, a.dcEducationID, a.MinExperience,
  15796. a.IssueDate'
  15797. SET @FROM = '
  15798. FROM JobPublish a WITH(NOLOCK)
  15799. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  15800. ----职位有效,单位新有效
  15801. SET @WHERE = '
  15802. WHERE a.Valid = 1
  15803. AND b.Valid = 1 AND a.ID NOT IN(SELECT ID FROM #Job)'
  15804. ----职位类别
  15805. IF LEN(@dcJobTypeID) > 0
  15806. SET @WHERE = @WHERE + '
  15807. AND (a.dcJobTypeID IN(' + @JobType +')
  15808. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  15809. IF LEN(@JobPlace) > 0
  15810. SET @WHERE = @WHERE + '
  15811. AND (' + @JobPlace + ')'
  15812. SET @SQL = @SQL + @FROM + @WHERE
  15813. SET @SQL = @SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
  15814. EXEC(@SQL)
  15815. SELECT @CurrentCount = COUNT(*) FROM #Job
  15816. IF @CurrentCount < @RowCount
  15817. BEGIN
  15818. SET @NeedCount = @RowCount - @CurrentCount
  15819. --将工作地点扩大一级
  15820. DECLARE @T_JobPlaceDistinct AS TABLE(ID INT)
  15821. UPDATE @T_JobPlace SET ID = LEFT(ID,LEN(ID)-2) WHERE LEN(ID) > 2
  15822. INSERT INTO @T_JobPlaceDistinct SELECT DISTINCT ID FROM @T_JobPlace
  15823. SELECT @JobPlace = ''
  15824. SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlaceDistinct
  15825. IF LEN(@JobPlace) > 0
  15826. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  15827. --将职位类别扩大一级
  15828. UPDATE @T_TEMP SET ID = LEFT(ID,LEN(ID)-2) WHERE LEN(ID) > 2
  15829. DELETE FROM @T_JobType
  15830. INSERT INTO @T_JobType
  15831. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  15832. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  15833. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  15834. OR ID IN(SELECT ID FROM @T_TEMP)
  15835. SELECT @JobType = ''
  15836. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  15837. IF RIGHT(@JobType, 1) = ','
  15838. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  15839. ----生成插入临时表的Sql语句
  15840. SET @SQL = '
  15841. INSERT INTO #Job
  15842. SELECT TOP ' + CONVERT(VARCHAR(3),@NeedCount) + ' a.ID, a.dcJobTypeID,
  15843. a.dcJobTypeIDMinor, a.dcSalaryID,
  15844. a.dcRegionID, a.dcEducationID, a.MinExperience,
  15845. a.IssueDate'
  15846. SET @FROM = '
  15847. FROM JobPublish a WITH(NOLOCK)
  15848. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  15849. ----职位有效,单位新有效
  15850. SET @WHERE = '
  15851. WHERE a.Valid = 1
  15852. AND b.Valid = 1 AND a.ID NOT IN(SELECT ID FROM #Job)'
  15853. ----职位类别
  15854. IF LEN(@dcJobTypeID) > 0
  15855. SET @WHERE = @WHERE + '
  15856. AND (a.dcJobTypeID IN(' + @JobType +')
  15857. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  15858. IF LEN(@JobPlace) > 0
  15859. SET @WHERE = @WHERE + '
  15860. AND (' + @JobPlace + ')'
  15861. SET @SQL = @SQL + @FROM + @WHERE
  15862. SET @SQL = @SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
  15863. EXEC(@SQL)
  15864. END
  15865. END
  15866. --print '090909'
  15867. INSERT INTO SHORTDB..JobRecommend
  15868. SELECT TOP 20 @PaMainID,a.SecondId EnJobID, a.Name as JobName,b.Name as cpName,a.dcSalaryID,
  15869. a.EmployType,a.dcRegionID,a.dcEducationID,a.MinExperience,a.RefreshDate,b.SecondId EnCpMainID,
  15870. b.dcCompanySizeID,a.Welfare1,a.Welfare2,a.Welfare3,a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8,
  15871. a.Welfare9,a.Welfare10,a.Welfare11,a.Welfare12,a.Welfare13,a.Welfare14,a.Welfare15,a.Welfare16,
  15872. a.Welfare17,a.Welfare18,
  15873. ISNULL((SELECT IsOnline FROM caOnline WHERE caMainId =a.caMainID), 0) AS IsOnline,1,GETDATE(),b.HasLicence,a.ID,
  15874. a.CaMainiD, b.ReplyRate
  15875. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), #Job c WITH(NOLOCK)
  15876. WHERE a.cpMainID = b.ID AND a.ID = c.ID ORDER BY c.RowID
  15877. END
  15878. ELSE
  15879. BEGIN
  15880. SET @dcJobTypeID = dbo.FormatIDS(@dcJobTypeID)
  15881. DECLARE @T_JobType2 AS TABLE(ID INT)
  15882. DECLARE @JobTypeExpect AS VARCHAR(3000)
  15883. DECLARE @T_Temp1 AS TABLE(ID INT) --临时表,用于构建组合查询语句
  15884. INSERT INTO @T_Temp1
  15885. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  15886. INSERT INTO @T_JobType2
  15887. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  15888. WHERE ParentId IN(SELECT ID FROM @T_TEMP1)
  15889. OR ParentId2 in(SELECT ID FROM @T_TEMP1)
  15890. OR ID IN(SELECT ID FROM @T_TEMP1)
  15891. ----生成in字符串
  15892. SELECT @JobTypeExpect = ''
  15893. SELECT @JobTypeExpect = (@JobTypeExpect + LTRIM(STR(ID) + ',')) FROM @T_JobType2
  15894. IF RIGHT(@JobTypeExpect, 1) = ','
  15895. SET @JobTypeExpect = LEFT(@JobTypeExpect, LEN(@JobTypeExpect) - 1)
  15896. DECLARE @T_JobPlace2 AS TABLE(ID INT)
  15897. DECLARE @JobPlace2 AS VARCHAR(3000)
  15898. INSERT INTO @T_JobPlace2
  15899. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  15900. SELECT @JobPlace2 = ''
  15901. SELECT @JobPlace2 = (@JobPlace2 + ' OR c.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace2
  15902. SELECT @JobPlace2 = (@JobPlace2 + ' OR c.dcRegionID = ''' + LTRIM(STR(LEFT(ID,2)))+'''' )
  15903. FROM @T_JobPlace2 WHERE LEN(ID) > 2
  15904. SELECT @JobPlace2 = (@JobPlace2 + ' OR c.dcRegionID = ''' + LTRIM(STR(LEFT(ID,4)))+'''' )
  15905. FROM @T_JobPlace2 WHERE LEN(ID) > 4
  15906. SET @JobPlace2 = RIGHT(@JobPlace2, LEN(@JobPlace2) -4)
  15907. DECLARE @SQL2 AS VARCHAR(max)
  15908. SET @SQL2 = '
  15909. INSERT INTO SHORTDB..JobRecommend
  15910. SELECT TOP ' + CONVERT(VARCHAR, @RowCount) + ' '+CONVERT(VARCHAR(20),@PaMainID)+',b.SecondID EnJobID, b.Name JobName, c.Name CpName,
  15911. b.dcSalaryID, b.EmployType,b.dcRegionID, b.dcEducationID,b.MinExperience, b.Refreshdate,c.SecondID EnCpMainID,
  15912. c.dcCompanySizeID,b.Welfare1,b.Welfare2,b.Welfare3,b.Welfare4,b.Welfare5,b.Welfare6,b.Welfare7,b.Welfare8,
  15913. b.Welfare9,b.Welfare10,b.Welfare11,b.Welfare12,b.Welfare13,b.Welfare14,b.Welfare15,b.Welfare16,
  15914. b.Welfare17,b.Welfare18,dbo.GetCaOnlineStatus(b.caMainID) AS IsOnline,2,'''+CONVERT(VARCHAR(30),GETDATE())+''',
  15915. c.HasLicence, b.ID, b.CaMainID, c.ReplyRate
  15916. FROM exJobApply a WITH(NOLOCK), JobPublish b WITH(NOLOCK), cpMainPublish c WITH(NOLOCK)
  15917. WHERE a.JobID = b.ID AND b.cpMainID = c.ID AND a.cvMainID IN(
  15918. SELECT a.ID FROM cvMainPublish a WITH(NOLOCK)
  15919. INNER JOIN paMainPublish b WITH(NOLOCK) ON a.paMainID = b.ID
  15920. INNER JOIN cvJobPlacePublish c ON a.ID = c.cvMainID
  15921. INNER JOIN cvJobTypePublish d ON a.ID = d.cvMainID
  15922. WHERE d.dcJobTypeID IN(' + @JobTypeExpect +') AND (' + @JobPlace2 + ')
  15923. ) ORDER BY a.AddDate DESC'
  15924. EXEC (@SQL2)
  15925. END
  15926. END
  15927. GO
  15928. /****** Object: StoredProcedure [dbo].[ProcJobRecommendUpdate] Script Date: 2018/12/13 19:11:05 ******/
  15929. SET ANSI_NULLS ON
  15930. GO
  15931. SET QUOTED_IDENTIFIER ON
  15932. GO
  15933. CREATE PROCEDURE [dbo].[ProcJobRecommendUpdate]
  15934. (
  15935. @PaMainID INT,
  15936. @dcJobTypeID VARCHAR(100), --职位类别
  15937. @dcRegionID VARCHAR(100), --求职地区
  15938. @dcIndustryID VARCHAR(100), --求职行业
  15939. @dcSalaryID TINYINT, --月薪
  15940. @MinExperience TINYINT, --工作经验,100为未选择
  15941. @dcEducationID TINYINT, --最低学历
  15942. @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习
  15943. @RowCount SMALLINT, --需要显示的行数
  15944. @Type INT --1猜你喜欢 2小伙伴们都在申请
  15945. )
  15946. AS
  15947. BEGIN
  15948. IF @RowCount = 0
  15949. BEGIN
  15950. SET @RowCount = 20
  15951. END
  15952. DECLARE @UpdateDate DATETIME
  15953. SELECT TOP 1 @UpdateDate = UpdateDate
  15954. FROM ShortDB..JobRecommend
  15955. WHERE PaMainID = @PaMainID
  15956. AND Type = @Type
  15957. DECLARE @Minute INT --间隔分钟数
  15958. SELECT @Minute = DATEDIFF(MINUTE, ISNULL(@UpdateDate, GETDATE() - 1), GETDATE())
  15959. IF @Minute IS NULL OR @Minute <= 30
  15960. BEGIN
  15961. print '00'
  15962. --直接查询
  15963. SELECT TOP 20 * FROM SHORTDB..JobRecommend WHERE PaMainID = @PaMainID AND Type = @Type
  15964. END
  15965. ELSE
  15966. BEGIN
  15967. print '11'
  15968. --删除后重新生成数据
  15969. DELETE FROM SHORTDB..JobRecommend WHERE PaMainID = @PaMainID AND Type = @Type
  15970. IF @Type = 1
  15971. BEGIN
  15972. SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
  15973. @dcRegionID = RTRIM(dbo.FormatIDS(@dcRegionID)),
  15974. @dcIndustryID = RTRIM(dbo.FormatIDS(@dcIndustryID)),
  15975. @dcSalaryID = ISNULL(@dcSalaryID, 0),
  15976. @MinExperience = ISNULL(@MinExperience, 100),
  15977. @dcEducationID = ISNULL(@dcEducationID, 0),
  15978. @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END
  15979. IF @dcJobTypeID LIKE '%,%,%,%,%,%'
  15980. SET @dcJobTypeID = LEFT(@dcJobTypeID, 2)
  15981. IF @dcRegionID LIKE '%,%,%,%,%,%'
  15982. SET @dcRegionID = LEFT(@dcRegionID, 2)
  15983. IF RIGHT(@dcJobTypeID, 1) = ','
  15984. SET @dcJobTypeID = LEFT(@dcJobTypeID, LEN(@dcJobTypeID) - 1)
  15985. IF RIGHT(@dcRegionID, 1) = ','
  15986. SET @dcRegionID = LEFT(@dcRegionID, LEN(@dcRegionID) - 1)
  15987. IF RIGHT(@dcIndustryID, 1) = ','
  15988. SET @dcIndustryID = LEFT(@dcIndustryID, LEN(@dcIndustryID) - 1)
  15989. ------生成职位类别的表变量,因为职位类别有包含(父子)关系
  15990. DECLARE @T_JobPlace AS TABLE(ID INT)
  15991. DECLARE @T_JobType AS TABLE(ID INT)
  15992. DECLARE @JobType AS VARCHAR(3000)
  15993. DECLARE @JobPlace AS VARCHAR(2000)
  15994. DECLARE @SQL AS NVARCHAR(MAX)
  15995. DECLARE @WHERE AS VARCHAR(8000)
  15996. DECLARE @FROM AS VARCHAR(1000)
  15997. SET @JobPlace = ''
  15998. SET @JobType=''
  15999. ----生成工作地点的表变量
  16000. IF LEN(@dcRegionID) > 0
  16001. BEGIN
  16002. INSERT INTO @T_JobPlace
  16003. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  16004. SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  16005. IF LEN(@JobPlace) > 0
  16006. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  16007. END
  16008. ----生成求聘职位的表变量
  16009. IF LEN(@dcJobTypeID) > 0
  16010. BEGIN
  16011. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  16012. INSERT INTO @T_Temp
  16013. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  16014. INSERT INTO @T_JobType
  16015. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  16016. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  16017. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  16018. OR ID IN(SELECT ID FROM @T_TEMP)
  16019. ----生成in字符串
  16020. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  16021. IF RIGHT(@JobType, 1) = ','
  16022. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  16023. END
  16024. ----建立临时表
  16025. CREATE TABLE #Job(
  16026. RowID INT IDENTITY(1, 1),
  16027. ID INT NOT NULL,
  16028. dcJobTypeID SMALLINT NOT NULL,
  16029. dcJobTypeIDMinor SMALLINT NULL,
  16030. dcSalaryID TINYINT NOT NULL,
  16031. dcRegionID VARCHAR(6) NULL,
  16032. dcEducationID TINYINT NOT NULL,
  16033. MinExperience TINYINT NOT NULL,
  16034. RefreshDate SMALLDATETIME NULL
  16035. )
  16036. ----生成插入临时表的Sql语句
  16037. SET @SQL = '
  16038. INSERT INTO #Job
  16039. SELECT TOP ' + CONVERT(VARCHAR(3),@RowCount) + ' a.ID, a.dcJobTypeID,
  16040. a.dcJobTypeIDMinor, a.dcSalaryID,
  16041. a.dcRegionID, a.dcEducationID, a.MinExperience,
  16042. a.IssueDate'
  16043. SET @FROM = '
  16044. FROM JobPublish a WITH(NOLOCK)
  16045. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  16046. ----职位有效,单位新有效
  16047. IF LEN(@dcIndustryID) > 0
  16048. SET @WHERE = '
  16049. WHERE b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @dcIndustryID + '))
  16050. AND a.Valid = 1
  16051. AND b.Valid = 1'
  16052. ELSE
  16053. SET @WHERE = '
  16054. WHERE a.Valid = 1
  16055. AND b.Valid = 1'
  16056. ----职位类别
  16057. IF LEN(@dcJobTypeID) > 0
  16058. SET @WHERE = @WHERE + '
  16059. AND (a.dcJobTypeID IN(' + @JobType +')
  16060. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  16061. IF LEN(@JobPlace) > 0
  16062. SET @WHERE = @WHERE + '
  16063. AND (' + @JobPlace + ')'
  16064. IF @dcSalaryID > 0
  16065. BEGIN
  16066. IF @dcSalaryID < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
  16067. BEGIN
  16068. SET @WHERE = @WHERE + '
  16069. AND a.dcSalaryID IN(' + LTRIM(STR(@dcSalaryID)) + ',' + LTRIM(STR(@dcSalaryID + 1))
  16070. SET @WHERE = @WHERE + ')'
  16071. END
  16072. IF @dcSalaryID = 100 ----从筛选结果中点击面议,值是100
  16073. BEGIN
  16074. SET @WHERE = @WHERE + '
  16075. AND a.dcSalaryID = 100'
  16076. END
  16077. IF @dcSalaryID > 100 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  16078. SET @WHERE = @WHERE + '
  16079. AND a.dcSalaryID=' + LTRIM(STR(@dcSalaryID-100))
  16080. END
  16081. ----工作经验要求
  16082. IF @MinExperience < 100
  16083. SET @WHERE = @WHERE + '
  16084. AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
  16085. ----学历要求
  16086. ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
  16087. IF @dcEducationID > 0
  16088. IF @dcEducationID = 2
  16089. SET @WHERE = @WHERE + '
  16090. AND a.dcEducationID IN(2, 3, 4)'
  16091. ELSE
  16092. SET @WHERE = @WHERE + '
  16093. AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
  16094. ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
  16095. IF LEN(@EmployType) > 0
  16096. SET @WHERE = @WHERE + '
  16097. AND a.EmployType IN (' + @EmployType + ')'
  16098. SET @SQL = @SQL + @FROM + @WHERE
  16099. SET @SQL = @SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
  16100. EXEC(@SQL)
  16101. DECLARE @CurrentCount AS SMALLINT
  16102. DECLARE @NeedCount AS SMALLINT
  16103. SELECT @CurrentCount = COUNT(*) FROM #Job
  16104. IF @CurrentCount < @RowCount
  16105. BEGIN
  16106. SET @NeedCount = @RowCount - @CurrentCount
  16107. ----生成插入临时表的Sql语句
  16108. SET @SQL = '
  16109. INSERT INTO #Job
  16110. SELECT TOP ' + CONVERT(VARCHAR(3),@NeedCount) + ' a.ID, a.dcJobTypeID,
  16111. a.dcJobTypeIDMinor, a.dcSalaryID,
  16112. a.dcRegionID, a.dcEducationID, a.MinExperience,
  16113. a.IssueDate'
  16114. SET @FROM = '
  16115. FROM JobPublish a WITH(NOLOCK)
  16116. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  16117. ----职位有效,单位新有效
  16118. SET @WHERE = '
  16119. WHERE a.Valid = 1
  16120. AND b.Valid = 1 AND a.ID NOT IN(SELECT ID FROM #Job)'
  16121. ----职位类别
  16122. IF LEN(@dcJobTypeID) > 0
  16123. SET @WHERE = @WHERE + '
  16124. AND (a.dcJobTypeID IN(' + @JobType +')
  16125. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  16126. IF LEN(@JobPlace) > 0
  16127. SET @WHERE = @WHERE + '
  16128. AND (' + @JobPlace + ')'
  16129. SET @SQL = @SQL + @FROM + @WHERE
  16130. SET @SQL = @SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
  16131. EXEC(@SQL)
  16132. SELECT @CurrentCount = COUNT(*) FROM #Job
  16133. IF @CurrentCount < @RowCount
  16134. BEGIN
  16135. SET @NeedCount = @RowCount - @CurrentCount
  16136. --将工作地点扩大一级
  16137. DECLARE @T_JobPlaceDistinct AS TABLE(ID INT)
  16138. UPDATE @T_JobPlace SET ID = LEFT(ID,LEN(ID)-2) WHERE LEN(ID) > 2
  16139. INSERT INTO @T_JobPlaceDistinct SELECT DISTINCT ID FROM @T_JobPlace
  16140. SELECT @JobPlace = ''
  16141. SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlaceDistinct
  16142. IF LEN(@JobPlace) > 0
  16143. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  16144. --将职位类别扩大一级
  16145. UPDATE @T_TEMP SET ID = LEFT(ID,LEN(ID)-2) WHERE LEN(ID) > 2
  16146. DELETE FROM @T_JobType
  16147. INSERT INTO @T_JobType
  16148. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  16149. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  16150. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  16151. OR ID IN(SELECT ID FROM @T_TEMP)
  16152. SELECT @JobType = ''
  16153. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  16154. IF RIGHT(@JobType, 1) = ','
  16155. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  16156. ----生成插入临时表的Sql语句
  16157. SET @SQL = '
  16158. INSERT INTO #Job
  16159. SELECT TOP ' + CONVERT(VARCHAR(3),@NeedCount) + ' a.ID, a.dcJobTypeID,
  16160. a.dcJobTypeIDMinor, a.dcSalaryID,
  16161. a.dcRegionID, a.dcEducationID, a.MinExperience,
  16162. a.IssueDate'
  16163. SET @FROM = '
  16164. FROM JobPublish a WITH(NOLOCK)
  16165. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  16166. ----职位有效,单位新有效
  16167. SET @WHERE = '
  16168. WHERE a.Valid = 1
  16169. AND b.Valid = 1 AND a.ID NOT IN(SELECT ID FROM #Job)'
  16170. ----职位类别
  16171. IF LEN(@dcJobTypeID) > 0
  16172. SET @WHERE = @WHERE + '
  16173. AND (a.dcJobTypeID IN(' + @JobType +')
  16174. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  16175. IF LEN(@JobPlace) > 0
  16176. SET @WHERE = @WHERE + '
  16177. AND (' + @JobPlace + ')'
  16178. SET @SQL = @SQL + @FROM + @WHERE
  16179. SET @SQL = @SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
  16180. EXEC(@SQL)
  16181. END
  16182. END
  16183. print '090909'
  16184. INSERT INTO SHORTDB..JobRecommend
  16185. SELECT TOP 10 @PaMainID,a.SecondId EnJobID, a.Name as JobName,b.Name as cpName,a.dcSalaryID,
  16186. a.EmployType,a.dcRegionID,a.dcEducationID,a.MinExperience,a.RefreshDate,b.SecondId EnCpMainID,
  16187. b.dcCompanySizeID,a.Welfare1,a.Welfare2,a.Welfare3,a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8,
  16188. a.Welfare9,a.Welfare10,a.Welfare11,a.Welfare12,a.Welfare13,a.Welfare14,a.Welfare15,a.Welfare16,
  16189. a.Welfare17,a.Welfare18,
  16190. ISNULL((SELECT IsOnline FROM caOnline WHERE caMainId =a.caMainID), 0) AS IsOnline,1,GETDATE(),b.HasLicence,a.ID,
  16191. a.CaMainiD, b.ReplyRate
  16192. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), #Job c WITH(NOLOCK)
  16193. WHERE a.cpMainID = b.ID AND a.ID = c.ID ORDER BY c.RowID
  16194. END
  16195. ELSE
  16196. BEGIN
  16197. print '0909'
  16198. SET @dcJobTypeID = dbo.FormatIDS(@dcJobTypeID)
  16199. DECLARE @T_JobType2 AS TABLE(ID INT)
  16200. DECLARE @JobTypeExpect AS VARCHAR(3000)
  16201. DECLARE @T_Temp1 AS TABLE(ID INT) --临时表,用于构建组合查询语句
  16202. INSERT INTO @T_Temp1
  16203. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  16204. INSERT INTO @T_JobType2
  16205. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  16206. WHERE ParentId IN(SELECT ID FROM @T_TEMP1)
  16207. OR ParentId2 in(SELECT ID FROM @T_TEMP1)
  16208. OR ID IN(SELECT ID FROM @T_TEMP1)
  16209. ----生成in字符串
  16210. SELECT @JobTypeExpect = ''
  16211. SELECT @JobTypeExpect = (@JobTypeExpect + LTRIM(STR(ID) + ',')) FROM @T_JobType2
  16212. IF RIGHT(@JobTypeExpect, 1) = ','
  16213. SET @JobTypeExpect = LEFT(@JobTypeExpect, LEN(@JobTypeExpect) - 1)
  16214. DECLARE @T_JobPlace2 AS TABLE(ID INT)
  16215. DECLARE @JobPlace2 AS VARCHAR(3000)
  16216. INSERT INTO @T_JobPlace2
  16217. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  16218. SELECT @JobPlace2 = ''
  16219. SELECT @JobPlace2 = (@JobPlace2 + ' OR c.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace2
  16220. SELECT @JobPlace2 = (@JobPlace2 + ' OR c.dcRegionID = ''' + LTRIM(STR(LEFT(ID,2)))+'''' )
  16221. FROM @T_JobPlace2 WHERE LEN(ID) > 2
  16222. SELECT @JobPlace2 = (@JobPlace2 + ' OR c.dcRegionID = ''' + LTRIM(STR(LEFT(ID,4)))+'''' )
  16223. FROM @T_JobPlace2 WHERE LEN(ID) > 4
  16224. SET @JobPlace2 = RIGHT(@JobPlace2, LEN(@JobPlace2) -4)
  16225. DECLARE @SQL2 AS VARCHAR(max)
  16226. SET @SQL2 = '
  16227. INSERT INTO SHORTDB..JobRecommend
  16228. SELECT TOP ' + CONVERT(VARCHAR, @RowCount) + ' '+CONVERT(VARCHAR(20),@PaMainID)+',b.SecondID EnJobID, b.Name JobName, c.Name CpName,
  16229. b.dcSalaryID, b.EmployType,b.dcRegionID, b.dcEducationID,b.MinExperience, b.Refreshdate,c.SecondID EnCpMainID,
  16230. c.dcCompanySizeID,b.Welfare1,b.Welfare2,b.Welfare3,b.Welfare4,b.Welfare5,b.Welfare6,b.Welfare7,b.Welfare8,
  16231. b.Welfare9,b.Welfare10,b.Welfare11,b.Welfare12,b.Welfare13,b.Welfare14,b.Welfare15,b.Welfare16,
  16232. b.Welfare17,b.Welfare18,dbo.GetCaOnlineStatus(b.caMainID) AS IsOnline,2,'''+CONVERT(VARCHAR(30),GETDATE())+''',
  16233. c.HasLicence, b.ID, b.CaMainID, c.ReplyRate
  16234. FROM exJobApply a WITH(NOLOCK), JobPublish b WITH(NOLOCK), cpMainPublish c WITH(NOLOCK)
  16235. WHERE a.JobID = b.ID AND b.cpMainID = c.ID AND a.cvMainID IN(
  16236. SELECT a.ID FROM cvMainPublish a WITH(NOLOCK)
  16237. INNER JOIN paMainPublish b WITH(NOLOCK) ON a.paMainID = b.ID
  16238. INNER JOIN cvJobPlacePublish c ON a.ID = c.cvMainID
  16239. INNER JOIN cvJobTypePublish d ON a.ID = d.cvMainID
  16240. WHERE d.dcJobTypeID IN(' + @JobTypeExpect +') AND (' + @JobPlace2 + ')
  16241. ) ORDER BY a.AddDate DESC'
  16242. PRINT(@SQL2)
  16243. EXEC (@SQL2)
  16244. END
  16245. SELECT TOP 20 * FROM SHORTDB..JobRecommend WHERE PaMainID = @PaMainID AND Type = @Type
  16246. END
  16247. END
  16248. GO
  16249. /****** Object: StoredProcedure [dbo].[procJobRefreshLog_tempSelect] Script Date: 2018/12/13 19:11:06 ******/
  16250. SET ANSI_NULLS ON
  16251. GO
  16252. SET QUOTED_IDENTIFIER ON
  16253. GO
  16254. ---职位刷新数预设置,获取可用的职位刷新数(定制刷新)
  16255. ---harry
  16256. ---2017-11-1
  16257. CREATE PROCEDURE [dbo].[procJobRefreshLog_tempSelect]
  16258. (
  16259. @beginDate SMALLDATETIME,
  16260. @endDate SMALLDATETIME,
  16261. @refreshType TINYINT,
  16262. @weekDays CHAR(13),
  16263. @hours VARCHAR(100),
  16264. @minute INT,
  16265. @jobIds VARCHAR(200),
  16266. @caMainId INT,
  16267. @cpMainId INT
  16268. )
  16269. AS
  16270. SET NOCOUNT ON
  16271. BEGIN
  16272. --删除2分钟以上同一家企业的数据
  16273. DELETE FROM JobRefreshLog_temp WHERE AddDate < DATEADD(MINUTE, -2, GETDATE()) AND cpMainId = @cpMainId
  16274. DECLARE @sumRemain INT, @InsertRow INT
  16275. SELECT @sumRemain = sum(remainJobRefreshQuota)
  16276. FROM caOrder WITH(NOLOCK)
  16277. WHERE cpMainID = @cpMainId
  16278. AND openDate IS NOT NULL
  16279. AND endDate > GETDATE()
  16280. AND BeginDate < GETDATE()
  16281. AND IsDeleted = 0
  16282. AND OrderType IN(8, 15)
  16283. IF @sumRemain > 0
  16284. BEGIN
  16285. DELETE FROM JobRefreshLog_temp WHERE cpMainId = @cpMainId AND operateMan = @caMainId--清空数据,只能清除自己添加的
  16286. --职位id
  16287. DECLARE @TjobId AS TABLE(jobId INT, jobInfo NVARCHAR(200))
  16288. --周
  16289. DECLARE @Tweek AS TABLE(d INT)
  16290. --时间点
  16291. DECLARE @Thour AS TABLE(hour VARCHAR(10))
  16292. DECLARE @jobId INT, @jobinfo NVARCHAR(200), @hour VARCHAR(10), @weeknum TINYINT
  16293. --插入所有数据
  16294. INSERT INTO @TjobId (jobId)
  16295. SELECT * FROM dbo.fnSplit(@jobIds, ',')
  16296. WHERE a IN(SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainId = @cpMainId AND Valid = 1)
  16297. UPDATE @TjobId
  16298. SET jobInfo= (
  16299. SELECT name + ',' + b.FullName
  16300. FROM job a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  16301. WHERE a.id = jobId AND a.dcregionid = b.id
  16302. )
  16303. DECLARE @OneDay AS TABLE(RunDate DATETIME)
  16304. DECLARE @AllDay AS TABLE(RunDate DATETIME)
  16305. INSERT INTO @OneDay
  16306. SELECT DATEADD(MINUTE, @Minute, DATEADD(HOUR, CONVERT(INT, a), @beginDate)) FROM dbo.FnSplit(@hours, ',')
  16307. DECLARE @IntervalDay INT
  16308. SET @IntervalDay = 0
  16309. WHILE @IntervalDay <= DATEDIFF(DAY, @BeginDate, @endDate)
  16310. BEGIN
  16311. INSERT INTO @AllDay SELECT DATEADD(DAY, @IntervalDay, RunDate) FROM @OneDay
  16312. SET @IntervalDay = @IntervalDay + 1
  16313. END
  16314. IF @refreshType= 2 --按周刷
  16315. BEGIN
  16316. INSERT INTO @Tweek
  16317. SELECT * FROM dbo.fnSplit(@weekDays,',')---1,2,3,4,5,6,7
  16318. --将@Tweek数据更改为sql对应的数据
  16319. UPDATE @Tweek SET d= (
  16320. CASE d
  16321. WHEN 1 THEN 2
  16322. WHEN 2 THEN 3
  16323. WHEN 3 THEN 4
  16324. WHEN 4 THEN 5
  16325. WHEN 5 THEN 6
  16326. WHEN 6 THEN 7
  16327. ELSE 1 END )
  16328. --删除不在@Tweek中的数据
  16329. DELETE FROM @AllDay WHERE DATEPART(weekday,RunDate) NOT IN(SELECT d FROM @Tweek)
  16330. END
  16331. --每个职位,每天,每时刻
  16332. INSERT INTO JobRefreshLog_temp(jobid, jobInfo, refreshType, preRefreshDateTime, operateMan, cpMainId, AddDate)
  16333. SELECT a.jobId, a.jobinfo, 0, b.RunDate, @caMainId, @cpMainId, GETDATE()
  16334. FROM @AllDay b, @TjobId a
  16335. SELECT @InsertRow = @@ROWCOUNT
  16336. DECLARE @NeedQuota INT, @remainJobRefreshQuota INT, @AllInsertRow INT
  16337. SELECT @AllInsertRow =count(*) from jobrefreshlog_temp where cpmainid = @cpmainid and runDateTime is null
  16338. SELECT @NeedQuota = count(*) from jobrefreshlog where cpmainid = @cpmainid and runDateTime is null
  16339. SELECT @remainJobRefreshQuota = sum(remainJobRefreshQuota)
  16340. FROM caorder WITH(NOLOCK)
  16341. WHERE cpmainid = @cpmainid
  16342. AND ordertype in(8, 15) AND isdeleted=0 AND opendate > '' AND getdate() BETWEEN begindate AND enddate
  16343. --计算可用数量
  16344. IF (@NeedQuota +@AllInsertRow)> @remainJobRefreshQuota
  16345. BEGIN
  16346. SELECT (@remainJobRefreshQuota-(@NeedQuota+@AllInsertRow-@InsertRow)) AS availableNumber
  16347. END
  16348. ELSE
  16349. BEGIN
  16350. SELECT (@remainJobRefreshQuota-@NeedQuota) AS availableNumber
  16351. END
  16352. END
  16353. ELSE
  16354. BEGIN
  16355. SELECT 0 AS availableNumber
  16356. END
  16357. END
  16358. GO
  16359. /****** Object: StoredProcedure [dbo].[procJobRefreshLog_tempSelectSean] Script Date: 2018/12/13 19:11:07 ******/
  16360. SET ANSI_NULLS ON
  16361. GO
  16362. SET QUOTED_IDENTIFIER ON
  16363. GO
  16364. ---职位刷新数预设置,获取可用的职位刷新数(定制刷新)
  16365. ---harry
  16366. ---2017-11-1
  16367. CREATE PROCEDURE [dbo].[procJobRefreshLog_tempSelectSean]
  16368. (
  16369. @beginDate SMALLDATETIME,
  16370. @endDate SMALLDATETIME,
  16371. @refreshType TINYINT,
  16372. @weekDays CHAR(13),
  16373. @hours VARCHAR(100),
  16374. @minute INT,
  16375. @jobIds VARCHAR(200),
  16376. @caMainId INT,
  16377. @cpMainId INT
  16378. )
  16379. AS
  16380. SET NOCOUNT ON
  16381. BEGIN
  16382. select 1, getdate()
  16383. --删除2分钟以上同一家企业的数据
  16384. DELETE FROM JobRefreshLog_temp WHERE AddDate < DATEADD(MINUTE, -2, GETDATE()) AND cpMainId = @cpMainId
  16385. DECLARE @sumRemain INT
  16386. SELECT @sumRemain = sum(remainJobRefreshQuota)
  16387. FROM caOrder WITH(NOLOCK)
  16388. WHERE cpMainID = @cpMainId
  16389. AND openDate IS NOT NULL
  16390. AND endDate > GETDATE()
  16391. AND BeginDate < GETDATE()
  16392. AND IsDeleted = 0
  16393. AND OrderType IN(8, 15)
  16394. IF @sumRemain > 0
  16395. BEGIN
  16396. DELETE FROM JobRefreshLog_temp WHERE cpMainId = @cpMainId AND operateMan = @caMainId--清空数据,只能清除自己添加的
  16397. --职位id
  16398. DECLARE @TjobId AS TABLE(jobId INT, jobInfo NVARCHAR(200))
  16399. --周
  16400. DECLARE @Tweek AS TABLE(d INT)
  16401. --时间点
  16402. DECLARE @Thour AS TABLE(hour VARCHAR(10))
  16403. DECLARE @jobId INT, @jobinfo NVARCHAR(200), @hour VARCHAR(10), @weeknum TINYINT
  16404. --插入所有数据
  16405. INSERT INTO @TjobId (jobId)
  16406. SELECT * FROM dbo.fnSplit(@jobIds, ',')
  16407. WHERE a IN(SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainId = @cpMainId AND Valid = 1)
  16408. UPDATE @TjobId
  16409. SET jobInfo= (
  16410. SELECT name + ',' + b.FullName
  16411. FROM job a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  16412. WHERE a.id = jobId AND a.dcregionid = b.id
  16413. )
  16414. IF @refreshType = 1 --按天刷
  16415. BEGIN
  16416. DECLARE @OneDay AS TABLE(RunDate DATETIME)
  16417. DECLARE @AllDay AS TABLE(RunDate DATETIME)
  16418. INSERT INTO @OneDay
  16419. SELECT DATEADD(MINUTE, @Minute, DATEADD(HOUR, CONVERT(INT, a), @beginDate)) FROM dbo.FnSplit(@hours, ',')
  16420. DECLARE @IntervalDay INT
  16421. SET @IntervalDay = 0
  16422. WHILE @IntervalDay <= DATEDIFF(DAY, @BeginDate, @endDate)
  16423. BEGIN
  16424. INSERT INTO @AllDay SELECT DATEADD(DAY, @IntervalDay, RunDate) FROM @OneDay
  16425. SET @IntervalDay = @IntervalDay + 1
  16426. END
  16427. --每个职位,每天,每时刻
  16428. INSERT INTO JobRefreshLog_temp(jobid, jobInfo, refreshType, preRefreshDateTime, operateMan, cpMainId, AddDate)
  16429. SELECT a.jobId, a.jobinfo, 0, b.RunDate, @caMainId, @cpMainId, GETDATE()
  16430. FROM @AllDay b, @TjobId a
  16431. END
  16432. -- WHILE CONVERT(DATETIME, @beginDate, 101) <= CONVERT(DATETIME, @endDate, 101)
  16433. -- BEGIN
  16434. -- IF @refreshType = 1--按天刷
  16435. -- BEGIN
  16436. --
  16437. -- --每个职位,每天,每时刻
  16438. -- WHILE EXISTS(SELECT TOP 1 jobId FROM @TjobId)
  16439. -- BEGIN
  16440. -- DELETE FROM @Thour
  16441. -- INSERT INTO @Thour
  16442. -- SELECT * FROM dbo.fnSplit(@hours, ',')
  16443. -- SELECT TOP 1 @jobId = jobid, @jobinfo = jobInfo FROM @TjobId
  16444. -- WHILE EXISTS (SELECT TOP 1 [hour] FROM @Thour)
  16445. -- BEGIN
  16446. -- SELECT TOP 1 @hour = [hour] FROM @Thour
  16447. -- INSERT INTO JobRefreshLog_temp( jobid, jobInfo, refreshType, preRefreshDateTime, operateMan, cpMainId, AddDate)
  16448. -- SELECT @jobId, @jobinfo, 0, CONVERT(DATETIME, CONVERT(VARCHAR(10),@beginDate,120)+' '+@hour+':'+ CONVERT(VARCHAR(10),@minute)), @caMainId, @cpMainId, GETDATE()
  16449. -- DELETE FROM @Thour WHERE hour = @hour
  16450. -- END
  16451. -- DELETE FROM @TjobId WHERE jobid = @jobId
  16452. -- END
  16453. -- END
  16454. -- ELSE
  16455. -- BEGIN --按周刷
  16456. -- INSERT INTO @Tweek
  16457. -- SELECT * FROM dbo.fnSplit(@weekDays,',')---1,2,3,4,5,6,7
  16458. --
  16459. -- --判断时间是否在选择中
  16460. -- SELECT @weeknum =DATEPART(weekday,@beginDate)
  16461. -- SELECT @weeknum =(
  16462. -- CASE @weeknum
  16463. -- WHEN 1 THEN 7
  16464. -- WHEN 2 THEN 1
  16465. -- WHEN 3 THEN 2
  16466. -- WHEN 4 THEN 3
  16467. -- WHEN 5 THEN 4
  16468. -- WHEN 6 THEN 5
  16469. -- ELSE 6 END )
  16470. --
  16471. -- IF EXISTS(SELECT 'x' FROM @Tweek WHERE d = @weeknum )
  16472. -- BEGIN
  16473. -- --每个职位,每天,每时刻
  16474. -- DELETE FROM @TjobId
  16475. -- INSERT INTO @TjobId (jobId)
  16476. -- SELECT * FROM dbo.fnSplit(@jobIds, ',')
  16477. -- UPDATE @TjobId
  16478. -- SET jobInfo= (SELECT name+','+ b.FullName FROM job a WITH(NOLOCK), dcregion b WITH(NOLOCK) WHERE a.id = jobId AND a.dcregionid = b.id)
  16479. --
  16480. -- WHILE EXISTS (SELECT TOP 1 jobid FROM @TjobId)
  16481. -- BEGIN
  16482. -- SELECT TOP 1 @jobId = jobid, @jobinfo = jobInfo FROM @TjobId
  16483. --
  16484. -- DELETE FROM @Thour
  16485. --
  16486. -- INSERT INTO @Thour
  16487. -- SELECT * FROM dbo.fnSplit(@hours, ',')
  16488. --
  16489. -- WHILE EXISTS (SELECT TOP 1 [hour] FROM @Thour)
  16490. -- BEGIN
  16491. -- SELECT TOP 1 @hour = [hour] FROM @Thour
  16492. -- INSERT INTO JobRefreshLog_temp( jobid, jobInfo, refreshType, preRefreshDateTime, operateMan, cpMainId, AddDate)
  16493. -- SELECT @jobId, @jobinfo, 0, CONVERT(DATETIME, CONVERT(VARCHAR(10),@beginDate,120)+' '+@hour+':'+ CONVERT(VARCHAR(10),@minute)), @caMainId, @cpMainId, GETDATE()
  16494. -- DELETE FROM @Thour WHERE hour = @hour
  16495. -- END
  16496. -- DELETE FROM @TjobId WHERE jobid = @jobId
  16497. -- END
  16498. -- END
  16499. -- END
  16500. -- SELECT @beginDate = DATEADD(DAY, 1, @beginDate)---天数+1
  16501. -- END
  16502. select 2, getdate()
  16503. --获取占用的
  16504. DECLARE @AllQuota INT, @InsertROw INT
  16505. INSERT INTO JobRefreshLog_temp(jobRefreshSetId, jobid, jobInfo, refreshType, preRefreshDateTime, operateMan, cpMainId, AddDate)
  16506. SELECT jobRefreshSetId,jobid, jobInfo, refreshType, preRefreshDateTime, operateMan, cpMainId, GETDATE() FROM jobRefreshLog
  16507. WHERE cpMainId = @cpMainId AND runDateTime IS NULL AND refreshType = 0
  16508. SELECT @InsertROw = @@ROWCOUNT
  16509. select 3, getdate()
  16510. ---分配订单号,优先消耗订单结束时间早的,优分配占用时间早的刷新数
  16511. --获取所有可用的订单
  16512. SELECT ID, remainJobRefreshQuota, EndDate INTO #t FROM caOrder WITH(NOLOCK)
  16513. WHERE cpMainID = @cpMainID
  16514. AND openDate is NOT NULL
  16515. AND endDate >GETDATE()
  16516. AND OrderType IN(8,15)
  16517. AND ISNULL(remainJobRefreshQuota,0) != 0
  16518. ORDER BY endDate
  16519. SELECT @AllQuota = SUM(remainJobRefreshQuota) FROM #t
  16520. select 4, getdate()
  16521. DECLARE @NeedQuota INT, @caoderId INT, @remainJobRefreshQuota INT
  16522. SELECT @NeedQuota = COUNT(*) FROM JobRefreshLog_temp WHERE cpMainId = @CpMainId AND OrderId IS NULL
  16523. WHILE EXISTS(SELECT TOP 1 id FROM #t)
  16524. BEGIN
  16525. SELECT TOP 1 @caoderId = id, @remainJobRefreshQuota = remainJobRefreshQuota FROM #t ORDER BY endDate
  16526. IF @remainJobRefreshQuota >= @NeedQuota
  16527. BEGIN
  16528. UPDATE JobRefreshLog_temp SET orderId = @caoderId
  16529. WHERE cpMainId = @cpMainId AND ISNULL(orderid, 0) = 0
  16530. SET @NeedQuota = 0
  16531. DELETE FROM #t
  16532. END
  16533. ELSE
  16534. BEGIN
  16535. UPDATE JobRefreshLog_temp SET orderId = @caoderId
  16536. WHERE id IN(SELECT TOP (@remainJobRefreshQuota) Id FROM JobRefreshLog_temp
  16537. WHERE cpMainId = @cpMainId AND ISNULL(orderid, 0) = 0
  16538. ORDER BY preRefreshDateTime)
  16539. SET @NeedQuota = @NeedQuota - @remainJobRefreshQuota
  16540. END
  16541. DELETE FROM #t WHERE id = @caoderId
  16542. END
  16543. IF @NeedQuota > 0
  16544. BEGIN
  16545. SELECT 'zzz', getdate(), @NeedQuota
  16546. RETURN
  16547. END
  16548. select 5, getdate()
  16549. --计算可用的数据
  16550. DECLARE @availableNumber INT, @needNumber INT, @OccupiedNumber INT,@preUsedNumber INT, @OtherUserNeedNumber INT
  16551. SELECT @preUsedNumber=COUNT(1) FROM JobRefreshLog_temp WHERE jobid IN(SELECT jobid FROM @TjobId) AND ISNULL(orderid,0)!=0 AND ISNULL(jobRefreshSetId,0)=0 --本次成功的数量
  16552. SELECT @needNumber=COUNT(1) FROM JobRefreshLog_temp WHERE jobid IN(SELECT jobid FROM @TjobId) AND ISNULL(jobRefreshSetId,0)=0 --本次需要的量
  16553. SELECT @OtherUserNeedNumber=COUNT(1) FROM JobRefreshLog_temp WHERE ISNULL(jobRefreshSetId,0)=0 AND operateMan != @caMainId AND cpMainId = @cpMainId --其他人将要占用的
  16554. select 6, getdate()
  16555. ---计算已经占用的数量
  16556. SELECT @OccupiedNumber= COUNT(1)
  16557. FROM jobRefreshLog
  16558. WHERE runDateTime IS NULL--占用
  16559. AND refreshType= 0 --定制刷新
  16560. AND jobid IN(SELECT id FROM job WHERE valid = 1 AND IsDelete=0 AND IssueEND>=GETDATE() AND cpMainId = @cpMainID)
  16561. select 7, getdate()
  16562. SELECT @availableNumber = @sumRemain - @OccupiedNumber - @OtherUserNeedNumber
  16563. --如果neednumber>preUsedNumber 则返回可用 preUsedNumber; 否则返回@availableNumber
  16564. IF @needNumber> @preUsedNumber
  16565. BEGIN
  16566. SELECT @preUsedNumber AS availableNumber
  16567. END
  16568. ELSE
  16569. BEGIN
  16570. SELECT @availableNumber AS availableNumber
  16571. END
  16572. select 8, getdate()
  16573. END
  16574. ELSE
  16575. BEGIN
  16576. SELECT 0 AS availableNumber
  16577. END
  16578. select 'zzz', getdate()
  16579. END
  16580. GO
  16581. /****** Object: StoredProcedure [dbo].[procJobRefreshOldCompanyInsert] Script Date: 2018/12/13 19:11:07 ******/
  16582. SET ANSI_NULLS ON
  16583. GO
  16584. SET QUOTED_IDENTIFIER ON
  16585. GO
  16586. --职位刷新老用户数据表生成计划任务
  16587. --创建人:harry 2017-10-18
  16588. --规则 vip订单开通时间<刷新数上线时间同时订单未结束的 为老用户
  16589. CREATE PROCEDURE [dbo].[procJobRefreshOldCompanyInsert]
  16590. AS
  16591. BEGIN
  16592. DECLARE @onLineTime DATETIME
  16593. SET @onLineTime='2017-11-30 19:00'
  16594. TRUNCATE TABLE jobRefreshOldCompany
  16595. INSERT INTO jobRefreshOldCompany(cpMainId)
  16596. SELECT DISTINCT cpMainId FROM caorder WHERE opendate < @onLineTime AND EndDate > GETDATE() AND ordertype = 8 AND IsDeleted=0
  16597. END
  16598. GO
  16599. /****** Object: StoredProcedure [dbo].[procJobReportDataByCaMainIDSelect] Script Date: 2018/12/13 19:11:07 ******/
  16600. SET ANSI_NULLS ON
  16601. GO
  16602. SET QUOTED_IDENTIFIER ON
  16603. GO
  16604. --#####################################################
  16605. --创建时间:2014.11.03
  16606. --创建人:Nick
  16607. --说明:获取当前6个月内统计过的职位ID和Name
  16608. --#####################################################
  16609. CREATE PROCEDURE [dbo].[procJobReportDataByCaMainIDSelect]
  16610. (
  16611. @CaMainID INT,
  16612. @AccoutType INT
  16613. )
  16614. AS
  16615. BEGIN TRY
  16616. IF @AccoutType = 1
  16617. BEGIN
  16618. SELECT DISTINCT(jobid),b.*
  16619. FROM ReportDB..jobReportData a WITH(NOLOCK)
  16620. INNER JOIN (
  16621. SELECT id,camainid,cpmainid,name,issuedate,issueend,null deletedate
  16622. FROM Job b WITH(NOLOCK)
  16623. WHERE b.cpmainid=@CaMainID
  16624. AND isdelete=0
  16625. AND issueend > GETDATE()
  16626. ) b ON a.jobid=b.id
  16627. ORDER BY b.issuedate desc
  16628. SELECT DISTINCT(jobid),b.*
  16629. FROM ReportDB..jobReportData a WITH(NOLOCK)
  16630. INNER JOIN (
  16631. SELECT id,camainid,cpmainid,name,issuedate,issueend,null deletedate
  16632. FROM Job b WITH(NOLOCK)
  16633. WHERE b.cpmainid=@CaMainID
  16634. AND isdelete=0
  16635. AND issueend < GETDATE() ) b ON a.jobid=b.id
  16636. ORDER BY b.issueend DESC
  16637. SELECT DISTINCT(jobid),b.*
  16638. FROM ReportDB..jobReportData a WITH(NOLOCK)
  16639. INNER JOIN (
  16640. SELECT jobid id,camainid,cpmainid,jobname name,issuedate,issueend,deletedate
  16641. FROM JobDeleted b WITH(NOLOCK)
  16642. WHERE b.cpmainid=@CaMainID
  16643. ) b ON a.jobid =b.id
  16644. ORDER BY deletedate DESC
  16645. END
  16646. ELSE IF @AccoutType = 2
  16647. BEGIN
  16648. SELECT DISTINCT(jobid),b.*
  16649. FROM ReportDB..jobReportData a WITH(NOLOCK)
  16650. INNER JOIN (
  16651. SELECT id,camainid,cpmainid,name,issuedate,issueend,null deletedate
  16652. FROM Job b WITH(NOLOCK)
  16653. WHERE b.camainid=@CaMainID
  16654. AND isdelete=0
  16655. AND issueend > getdate()
  16656. ) b ON a.jobid=b.id
  16657. ORDER BY b.issuedate DESC
  16658. SELECT DISTINCT(jobid),b.*
  16659. FROM ReportDB..jobReportData a WITH(NOLOCK)
  16660. INNER JOIN (
  16661. SELECT id,camainid,cpmainid,name,issuedate,issueend,null deletedate
  16662. FROM Job b WITH(NOLOCK)
  16663. WHERE b.camainid=@CaMainID
  16664. AND isdelete=0
  16665. AND issueend < GETDATE()
  16666. ) b ON a.jobid=b.id
  16667. ORDER BY b.issueend DESC
  16668. SELECT DISTINCT(jobid),b.*
  16669. FROM ReportDB..jobReportData a WITH(NOLOCK)
  16670. INNER JOIN (
  16671. SELECT jobid id,camainid,cpmainid,jobname name,issuedate,issueend,deletedate
  16672. FROM JobDeleted b WITH(NOLOCK)
  16673. WHERE b.camainid=@CaMainID
  16674. ) b ON a.jobid =b.id
  16675. ORDER BY deletedate DESC
  16676. END
  16677. END TRY
  16678. BEGIN CATCH
  16679. RETURN 0
  16680. END CATCH
  16681. GO
  16682. /****** Object: StoredProcedure [dbo].[procJobReportDataSumDetailSelect] Script Date: 2018/12/13 19:11:08 ******/
  16683. SET ANSI_NULLS ON
  16684. GO
  16685. SET QUOTED_IDENTIFIER ON
  16686. GO
  16687. --#####################################################
  16688. --创建时间:2014.11.03
  16689. --创建人:Nick
  16690. --说明:根据参数从JobReportData表中取得详细数据
  16691. --修改:harry 增加jobidcount 2017-11-23
  16692. --#####################################################
  16693. CREATE PROCEDURE [dbo].[procJobReportDataSumDetailSelect]
  16694. (
  16695. @beginDays INT,
  16696. @endDays INT,
  16697. @jobID INT,
  16698. @cpMainID INT
  16699. )
  16700. AS
  16701. BEGIN TRY
  16702. DECLARE @SQL VARCHAR(MAX)
  16703. SET @SQL = 'SELECT countdate,SUM(applycount) applycount,SUM(viewcount) viewcount,SUM(interview) interview,
  16704. SUM(interviewreply) interviewreply,SUM(interviewresult) interviewresult
  16705. FROM ReportDB..jobReportData Where countdate >= '+CONVERT(VARCHAR(20),@beginDays)+'
  16706. AND countdate <= ' +CONVERT(VARCHAR(20),@endDays)
  16707. IF @jobID > 0
  16708. BEGIN
  16709. SET @SQL = @SQL + ' AND jobID='+CONVERT(VARCHAR(20),@jobID)
  16710. END
  16711. ELSE
  16712. BEGIN
  16713. SET @SQL = @SQL + ' AND jobid in (
  16714. (
  16715. SELECT id FROM Job with(nolock)
  16716. WHERE isdelete=0
  16717. AND cpmainid='+CONVERT(VARCHAR(20),@cpMainID)+'
  16718. ) union (
  16719. SELECT jobid id
  16720. FROM JobDeleted WITH(NOLOCK)
  16721. WHERE cpmainid='+CONVERT(VARCHAR(20),@cpMainID)+'
  16722. )
  16723. )'
  16724. END
  16725. SET @SQL = @SQL + ' AND countdate >= '+CONVERT(VARCHAR(20),@beginDays)+' AND countdate <= '+CONVERT(VARCHAR(20),@endDays)
  16726. SET @SQL = @SQL + ' GROUP BY countdate'
  16727. PRINT(@SQL)
  16728. EXEC(@SQL)
  16729. IF @jobID > 0
  16730. SELECT 1 AS jobCount
  16731. SELECT COUNT(distinct jobId) AS jobCount
  16732. FROM ReportDB..jobReportData Where countdate >= @beginDays
  16733. AND countdate <= @endDays
  16734. AND jobid in (
  16735. (
  16736. SELECT id FROM Job with(nolock)
  16737. WHERE isdelete=0
  16738. AND cpmainid= @cpMainID
  16739. ) union (
  16740. SELECT jobid id
  16741. FROM JobDeleted WITH(NOLOCK)
  16742. WHERE cpmainid= @cpMainID
  16743. ))
  16744. END TRY
  16745. BEGIN CATCH
  16746. RETURN 0
  16747. END CATCH
  16748. GO
  16749. /****** Object: StoredProcedure [dbo].[procJobReportDataSumSelect] Script Date: 2018/12/13 19:11:08 ******/
  16750. SET ANSI_NULLS ON
  16751. GO
  16752. SET QUOTED_IDENTIFIER ON
  16753. GO
  16754. --#####################################################
  16755. --创建时间:2014.11.03
  16756. --创建人:Nick
  16757. --说明:根据参数从JobReportData表中取得汇总数据
  16758. --#####################################################
  16759. CREATE PROCEDURE [dbo].[procJobReportDataSumSelect]
  16760. (
  16761. @beginDays INT,
  16762. @endDays INT,
  16763. @jobID INT,
  16764. @orderBy INT,
  16765. @caMainID INT,
  16766. @AccoutType INT
  16767. )
  16768. AS
  16769. BEGIN TRY
  16770. DECLARE @SQL VARCHAR(MAX)
  16771. SET @SQL = 'SELECT a.jobid,SUM(ApplyCount) ApplyCount,SUM(ViewCount) ViewCount,SUM(interView) interView,
  16772. SUM(interViewReply) interViewReply,SUM(interViewResult) interViewResult,b.id,camainid,cpmainid,name,
  16773. issuedate,issueend,b.IsDelete
  16774. FROM ReportDB..jobReportData a with(nolock)
  16775. INNER JOIN (
  16776. (
  16777. SELECT id,camainid,cpmainid,name,issuedate,issueend,0 IsDelete
  16778. FROM Job with(nolock)
  16779. WHERE isdelete=0
  16780. ) UNION (
  16781. SELECT jobid id,camainid,cpmainid,jobname name,issuedate,issueend,1 IsDelete
  16782. FROM JobDeleted with(nolock)
  16783. )
  16784. ) b ON a.jobid =b.id
  16785. WHERE a.countdate >= '+CONVERT(VARCHAR(20),@beginDays)+' AND a.countdate <= '+CONVERT(VARCHAR(20),@endDays)
  16786. IF @jobID > 0
  16787. BEGIN
  16788. SET @SQL = @SQL + ' AND a.jobID='+CONVERT(VARCHAR(20),@jobID)
  16789. END
  16790. IF @AccoutType = 1
  16791. BEGIN
  16792. SET @SQL = @SQL + ' AND b.cpmainid='+CONVERT(VARCHAR(20),@caMainID)
  16793. END
  16794. ELSE IF @AccoutType = 2
  16795. BEGIN
  16796. SET @SQL = @SQL + ' AND b.camainid='+CONVERT(VARCHAR(20),@caMainID)
  16797. END
  16798. SET @SQL = @SQL + ' GROUP BY a.jobid,b.id,camainid,cpmainid,name,issuedate,issueend,IsDelete'
  16799. IF @orderBy = 11
  16800. BEGIN
  16801. SET @SQL = @SQL + ' ORDER BY b.issuedate DESC'
  16802. END
  16803. ELSE IF @orderBy = 12
  16804. BEGIN
  16805. SET @SQL = @SQL + ' ORDER BY ApplyCount DESC'
  16806. END
  16807. ELSE IF @orderBy = 13
  16808. BEGIN
  16809. SET @SQL = @SQL + ' ORDER BY ViewCount DESC'
  16810. END
  16811. ELSE IF @orderBy = 14
  16812. BEGIN
  16813. SET @SQL = @SQL + ' ORDER BY interView DESC'
  16814. END
  16815. ELSE IF @orderBy = 15
  16816. BEGIN
  16817. SET @SQL = @SQL + ' ORDER BY interViewReply DESC'
  16818. END
  16819. ELSE IF @orderBy = 16
  16820. BEGIN
  16821. SET @SQL = @SQL + ' ORDER BY interViewResult DESC'
  16822. END
  16823. ELSE IF @orderBy = 21
  16824. BEGIN
  16825. SET @SQL = @SQL + ' ORDER BY b.issuedate'
  16826. END
  16827. ELSE IF @orderBy = 22
  16828. BEGIN
  16829. SET @SQL = @SQL + ' ORDER BY ApplyCount'
  16830. END
  16831. ELSE IF @orderBy = 23
  16832. BEGIN
  16833. SET @SQL = @SQL + ' ORDER BY ViewCount'
  16834. END
  16835. ELSE IF @orderBy = 24
  16836. BEGIN
  16837. SET @SQL = @SQL + ' ORDER BY interView'
  16838. END
  16839. ELSE IF @orderBy = 25
  16840. BEGIN
  16841. SET @SQL = @SQL + ' ORDER BY interViewReply'
  16842. END
  16843. ELSE IF @orderBy = 26
  16844. BEGIN
  16845. SET @SQL = @SQL + ' ORDER BY interViewResult'
  16846. END
  16847. PRINT(@SQL)
  16848. EXEC(@SQL)
  16849. END TRY
  16850. BEGIN CATCH
  16851. RETURN 0
  16852. END CATCH
  16853. GO
  16854. /****** Object: StoredProcedure [dbo].[procJobReportDetailDataByCaMainIDSelect] Script Date: 2018/12/13 19:11:08 ******/
  16855. SET ANSI_NULLS ON
  16856. GO
  16857. SET QUOTED_IDENTIFIER ON
  16858. GO
  16859. --#####################################################
  16860. --创建时间:2014.11.03
  16861. --创建人:Nick
  16862. --说明:根据参数从jobReportDetailData表中取得所有职位的详细数据
  16863. --#####################################################
  16864. CREATE PROCEDURE [dbo].[procJobReportDetailDataByCaMainIDSelect]
  16865. (
  16866. @beginDays INT,
  16867. @endDays INT,
  16868. @caMainID INT,
  16869. @AccoutType INT
  16870. )
  16871. AS
  16872. BEGIN TRY
  16873. IF @AccoutType = 1
  16874. BEGIN
  16875. SELECT SUM(workyears1) workyears1,SUM(workyears2) workyears2,SUM(workyears3) workyears3,
  16876. SUM(workyears4) workyears4,SUM(workyears5) workyears5,SUM(age1) age1,SUM(age2) age2,
  16877. SUM(age3) age3,SUM(age4) age4,SUM(age5) age5,SUM(age6) age6,SUM(degree1) degree1,
  16878. SUM(degree2) degree2,SUM(degree3) degree3,SUM(degree4) degree4,SUM(degree5) degree5,
  16879. SUM(degree6) degree6,SUM(degree7) degree7,SUM(degree8) degree8,SUM(degree9) degree9,
  16880. SUM(salary1) salary1,SUM(salary2) salary2,SUM(salary3) salary3,SUM(salary4) salary4,
  16881. SUM(salary5) salary5,SUM(salary6) salary6,SUM(salary7) salary7,SUM(salary8) salary8,
  16882. SUM(male) male,SUM(female) female,cpmainid
  16883. FROM ReportDB..jobReportDetailData a WITH(NOLOCK)
  16884. INNER JOIN (
  16885. (
  16886. SELECT id,camainid,cpmainid,name,issuedate,issueend
  16887. FROM Job WITH(NOLOCK)
  16888. WHERE isdelete=0
  16889. ) union (
  16890. SELECT jobid id,camainid,cpmainid,jobname name,issuedate,issueend
  16891. FROM JobDeleted WITH(NOLOCK)
  16892. )
  16893. ) b ON a.jobid =b.id
  16894. WHERE CpMainID=@caMainID
  16895. AND a.countdate >= @beginDays
  16896. AND a.countdate <= @endDays GROUP BY cpmainid
  16897. END
  16898. ELSE
  16899. BEGIN
  16900. SELECT SUM(workyears1) workyears1,SUM(workyears2) workyears2,SUM(workyears3) workyears3,
  16901. SUM(workyears4) workyears4,SUM(workyears5) workyears5,SUM(age1) age1,SUM(age2) age2,
  16902. SUM(age3) age3,SUM(age4) age4,SUM(age5) age5,SUM(age6) age6,SUM(degree1) degree1,
  16903. SUM(degree2) degree2,SUM(degree3) degree3,SUM(degree4) degree4,SUM(degree5) degree5,
  16904. SUM(degree6) degree6,SUM(degree7) degree7,SUM(degree8) degree8,SUM(degree9) degree9,
  16905. SUM(salary1) salary1,SUM(salary2) salary2,SUM(salary3) salary3,SUM(salary4) salary4,
  16906. SUM(salary5) salary5,SUM(salary6) salary6,SUM(salary7) salary7,SUM(salary8) salary8,
  16907. SUM(male) male,SUM(female) female,camainid FROM ReportDB..jobReportDetailData a WITH(NOLOCK)
  16908. INNER JOIN (
  16909. (
  16910. SELECT id,camainid,cpmainid,name,issuedate,issueend
  16911. FROM Job WITH(NOLOCK) WHERE isdelete=0
  16912. ) UNION
  16913. (
  16914. SELECT jobid id,camainid,cpmainid,jobname name,issuedate,issueend
  16915. FROM JobDeleted with(nolock)
  16916. )
  16917. ) b ON a.jobid =b.id
  16918. WHERE CaMainID=@caMainID
  16919. AND a.countdate >= @beginDays
  16920. AND a.countdate <= @endDays GROUP BY CaMainID
  16921. END
  16922. END TRY
  16923. BEGIN CATCH
  16924. RETURN 0
  16925. END CATCH
  16926. GO
  16927. /****** Object: StoredProcedure [dbo].[procjobReportDetailDataByJobIDSelect] Script Date: 2018/12/13 19:11:09 ******/
  16928. SET ANSI_NULLS ON
  16929. GO
  16930. SET QUOTED_IDENTIFIER ON
  16931. GO
  16932. --#####################################################
  16933. --创建时间:2014.11.04
  16934. --创建人:Nick
  16935. --说明:根据参数从jobReportDetailData表中取得详细数据
  16936. --#####################################################
  16937. CREATE PROCEDURE [dbo].[procjobReportDetailDataByJobIDSelect]
  16938. (
  16939. @BeginDays INT,
  16940. @EndDays INT,
  16941. @JobID iNT
  16942. )
  16943. AS
  16944. BEGIN TRY
  16945. SELECT a.jobid,SUM(workyears1) workyears1,SUM(workyears2) workyears2,SUM(workyears3) workyears3,
  16946. SUM(workyears4) workyears4,SUM(workyears5) workyears5,SUM(age1) age1,SUM(age2) age2,SUM(age3) age3,
  16947. SUM(age4) age4,SUM(age5) age5,SUM(age6) age6,SUM(degree1) degree1,SUM(degree2) degree2,
  16948. SUM(degree3) degree3,SUM(degree4) degree4,SUM(degree5) degree5,SUM(degree6) degree6,SUM(degree7) degree7,
  16949. SUM(degree8) degree8,SUM(degree9) degree9,SUM(salary1) salary1,SUM(salary2) salary2,SUM(salary3) salary3,
  16950. SUM(salary4) salary4,SUM(salary5) salary5,SUM(salary6) salary6,SUM(salary7) salary7,SUM(salary8) salary8,
  16951. SUM(male) male,SUM(female) female,b.id,camainid,cpmainid,name,issuedate,issueend
  16952. FROM ReportDB..jobReportDetailData a WITH(NOLOCK)
  16953. INNER JOIN (
  16954. (
  16955. SELECT id,camainid,cpmainid,name,issuedate,issueend
  16956. FROM Job WITH(NOLOCK)
  16957. WHERE isdelete=0
  16958. ) UNION (
  16959. SELECT jobid id,camainid,cpmainid,jobname name,issuedate,issueend
  16960. FROM JobDeleted WITH(NOLOCK)
  16961. )
  16962. ) b ON a.jobid =b.id
  16963. WHERE a.jobID=@JobID
  16964. AND a.countdate >= @BeginDays
  16965. AND a.countdate <= @EndDays
  16966. GROUP BY a.jobid,b.id,camainid,cpmainid,name,issuedate,issueend
  16967. END TRY
  16968. BEGIN CATCH
  16969. RETURN 0
  16970. END CATCH
  16971. GO
  16972. /****** Object: StoredProcedure [dbo].[ProcJobSimilarCompareMonthInsert] Script Date: 2018/12/13 19:11:09 ******/
  16973. SET ANSI_NULLS ON
  16974. GO
  16975. SET QUOTED_IDENTIFIER ON
  16976. GO
  16977. --#####################################################
  16978. --创建时间:2016.8.1
  16979. --创建人:Peter
  16980. --说明:根据一个月内的投递情况,获取职位相似性
  16981. --#####################################################
  16982. CREATE PROCEDURE [dbo].[ProcJobSimilarCompareMonthInsert]
  16983. AS
  16984. BEGIN
  16985. TRUNCATE TABLE exJobApplyMonthTemp
  16986. INSERT INTO exJobApplyMonthTemp (JobId,CvMainID)
  16987. SELECT jobID,CvMainID FROM exjobapply WITH(NOLOCK) WHERE addDate > GETDATE() - 30
  16988. SELECT jobID,COUNT(1) cnt INTO #TJobSimilar FROM exJobApplyMonthTemp GROUP BY jobID having COUNT(1) > 1
  16989. DECLARE @JobID INT,@JobCount INT
  16990. WHILE EXISTS(SELECT jobID FROM #TJobSimilar)
  16991. BEGIN
  16992. SELECT TOP 1 @JobID = jobID,@JobCount = cnt
  16993. FROM #TJobSimilar
  16994. INSERT INTO JobSimilarCompare (JobID,SimilarJobID,JobCount,Pecentage)
  16995. SELECT TOP 3 @JobID,JobID,@JobCount,CAST(COUNT(1) AS FLOAT)*100/@JobCount
  16996. FROM exJobApplyMonthTemp
  16997. WHERE cvmainid IN(
  16998. SELECT cvMainID
  16999. FROM exJobApplyMonthTemp
  17000. WHERE jobid = @JobID)
  17001. AND jobid <> @JobID
  17002. GROUP BY JobID
  17003. ORDER BY COUNT(1) desc
  17004. DELETE FROM #TJobSimilar WHERE jobID = @JobID
  17005. END
  17006. SELECT cvMainID,COUNT(1) cnt INTO #TCvLimite FROM exJobApplyMonthTemp GROUP BY cvMainID HAVING COUNT(1) > 1
  17007. DECLARE @CvMainID INT,@CvAppplyCount INT
  17008. WHILE EXISTS(SELECT CvMainID FROM #TCvLimite)
  17009. BEGIN
  17010. SELECT TOP 1 @CvMainID = cvMainID,@CvAppplyCount = cnt
  17011. FROM #TCvLimite
  17012. INSERT INTO CvSimilarCompare (CvMainID,SimilarJobID,JobNum)
  17013. SELECT TOP 10 @CvMainID,JobID,COUNT(1)
  17014. FROM exJobApplyMonthTemp
  17015. WHERE cvMainID IN(
  17016. SELECT TOP 10 CvMainID
  17017. FROM exJobApplyMonthTemp
  17018. WHERE JobID IN(
  17019. SELECT JobID
  17020. FROM exJobApplyMonthTemp
  17021. WHERE CvMainID = @CvMainID)
  17022. AND CvMainID <> @CvMainID
  17023. GROUP BY CvMainID
  17024. ORDER BY COUNT(1) DESC
  17025. )
  17026. AND CvMainID <> @CvMainID
  17027. AND JobID NOT IN(
  17028. SELECT SimilarJobID FROM CvSimilarCompare WITH(NOLOCK) WHERE cvMainID = @CvMainID --推荐过的就不再推荐了
  17029. )
  17030. GROUP BY JobID
  17031. ORDER BY COUNT(1) desc
  17032. DELETE FROM #TCvLimite WHERE CvMainID = @CvMainID
  17033. END
  17034. END
  17035. GO
  17036. /****** Object: StoredProcedure [dbo].[ProcJobSimilarCompareSelect] Script Date: 2018/12/13 19:11:09 ******/
  17037. SET ANSI_NULLS ON
  17038. GO
  17039. SET QUOTED_IDENTIFIER ON
  17040. GO
  17041. CREATE PROCEDURE [dbo].[ProcJobSimilarCompareSelect]
  17042. (
  17043. @CvMainID INT
  17044. )
  17045. AS
  17046. SET NOCOUNT ON
  17047. BEGIN
  17048. SELECT jobID, COUNT(1) cnt
  17049. INTO #TJobSimilar
  17050. FROM exJobApplyMonthTemp
  17051. WHERE JobID IN(
  17052. SELECT JobID
  17053. FROM exJobApplyMonthTemp
  17054. WHERE CvMainID = @CvMainID)
  17055. GROUP BY jobID
  17056. HAVING COUNT(1) > 1
  17057. DECLARE @T AS TABLE(
  17058. JobID INT,
  17059. SimilarJobID INT,
  17060. JobCount INT,
  17061. Pecentage FLOAT,
  17062. SimilarCount INT
  17063. )
  17064. DECLARE @JobID INT, @JobCount INT
  17065. WHILE EXISTS(SELECT jobID FROM #TJobSimilar)
  17066. BEGIN
  17067. SELECT TOP 1 @JobID = jobID, @JobCount = cnt
  17068. FROM #TJobSimilar
  17069. INSERT INTO @T (JobID, SimilarJobID, JobCount, Pecentage, SimilarCount)
  17070. SELECT @JobID, JobID, @JobCount, CAST(COUNT(1) AS FLOAT) * 100 / @JobCount, COUNT(1)
  17071. FROM exJobApplyMonthTemp
  17072. WHERE cvmainid IN(
  17073. SELECT cvMainID
  17074. FROM exJobApplyMonthTemp
  17075. WHERE jobid = @JobID)
  17076. AND jobid <> @JobID
  17077. -- AND EXISTS( --职位必须有效且没被删除
  17078. -- SELECT 'X'
  17079. -- FROM Job WITH(NOLOCK)
  17080. -- WHERE id = exJobApplyMonthTemp.JobID
  17081. -- AND Valid = 1
  17082. -- AND IsDelete = 0
  17083. -- AND IssueEnd > GETDATE())
  17084. -- AND JobID NOT IN( --已经申请过的不再推荐
  17085. -- SELECT JobID
  17086. -- FROM exJobApply WITH(NOLOCK)
  17087. -- WHERE CvMainID = @CvMainID
  17088. -- )
  17089. GROUP BY JobID
  17090. HAVING COUNT(1) > 1
  17091. ORDER BY COUNT(1) desc
  17092. DELETE FROM #TJobSimilar WHERE jobID = @JobID
  17093. END
  17094. DELETE FROM @t
  17095. WHERE SimilarJobID IN( --职位必须有效且没被删除
  17096. SELECT Id
  17097. FROM Job WITH(NOLOCK)
  17098. WHERE Valid = 0)
  17099. OR SimilarJobID IN( --已经申请过的不再推荐
  17100. SELECT JobID
  17101. FROM exJobApply WITH(NOLOCK)
  17102. WHERE CvMainID = @CvMainID)
  17103. INSERT INTO @T (SimilarJobID, JobCount)
  17104. SELECT TOP 10 JobID, COUNT(1)
  17105. FROM exJobApplyMonthTemp
  17106. WHERE cvMainID IN(
  17107. SELECT TOP 100 CvMainID
  17108. FROM exJobApplyMonthTemp
  17109. WHERE JobID IN(
  17110. SELECT JobID
  17111. FROM exJobApplyMonthTemp
  17112. WHERE CvMainID = @CvMainID)
  17113. AND CvMainID <> @CvMainID
  17114. GROUP BY CvMainID
  17115. ORDER BY COUNT(1) DESC
  17116. )
  17117. AND CvMainID <> @CvMainID
  17118. AND EXISTS( --职位必须有效且没被删除
  17119. SELECT 'X'
  17120. FROM Job WITH(NOLOCK)
  17121. WHERE id = exJobApplyMonthTemp.JobID
  17122. AND Valid = 1
  17123. AND IsDelete = 0
  17124. AND IssueEnd > GETDATE())
  17125. AND JobID NOT IN( --已经申请过的不再推荐
  17126. SELECT JobID
  17127. FROM exJobApply WITH(NOLOCK)
  17128. WHERE CvMainID = @CvMainID
  17129. )
  17130. GROUP BY JobID
  17131. HAVING COUNT(1) > 1
  17132. ORDER BY COUNT(1) desc
  17133. SELECT a.*, b.Name JobName, b.SecondID EnJobID, c.Name SimilarJobName, c.SecondID EnSimilarJobID, d.FullName JobRegion, e.FullName SimilarJobRegion
  17134. FROM @T a
  17135. LEFT JOIN Job b WITH(NOLOCK) ON b.ID = a.JobID
  17136. LEFT JOIN Job c WITH(NOLOCK) ON c.ID = a.SimilarJobID
  17137. LEFT JOIN dcRegion d WITH(NOLOCK) ON d.ID = b.dcRegionID
  17138. LEFT JOIN dcRegion e WITH(NOLOCK) ON e.ID = c.dcRegionID
  17139. ORDER BY a.JobId, a.Pecentage DESC
  17140. DROP TABLE #TJobSimilar
  17141. END
  17142. GO
  17143. /****** Object: StoredProcedure [dbo].[procJobTagsBySaveInsert] Script Date: 2018/12/13 19:11:10 ******/
  17144. SET ANSI_NULLS ON
  17145. GO
  17146. SET QUOTED_IDENTIFIER ON
  17147. GO
  17148. --保存职位标签信息
  17149. CREATE PROCEDURE [dbo].[procJobTagsBySaveInsert]
  17150. (
  17151. @JobID INT,
  17152. @JobTags NVARCHAR(100)
  17153. )
  17154. AS
  17155. BEGIN
  17156. IF (SELECT COUNT(1) FROM dbo.Split(@JobTags,'@')) > 5
  17157. BEGIN
  17158. RETURN -1
  17159. END
  17160. CREATE TABLE #T
  17161. (
  17162. Tags NVARCHAR(10),
  17163. VerifyDate SMALLDATETIME
  17164. )
  17165. INSERT INTO #T(Tags)
  17166. SELECT a
  17167. FROM dbo.Split(@JobTags,'@')
  17168. DECLARE @ExistsTags NVARCHAR(MAX)
  17169. SELECT @ExistsTags = 'A轮,水果零食,B轮,帅哥美女,C轮,定期团建,D轮,股权期权,13薪,国企控股,不出差,前瞻行业,扁平化,大厨三餐,寒暑假,朝十晚六,正能量,氛围融洽,不加班,弹性工作,下午茶,挑战高薪,牛人多,创新项目,大平台,环境优雅,健身房,季度加薪,台球桌,阳光团队,妹子多,CBD办公,高晋升,无需打卡,压力小,交通便利,自由互助,苹果电脑,领导Nice'
  17170. UPDATE #T
  17171. SET VerifyDate = GETDATE()
  17172. WHERE Tags IN(
  17173. SELECT a
  17174. FROM dbo.Split(@ExistsTags,',')
  17175. )
  17176. OR EXISTS(
  17177. SELECT TOP 1 'X'
  17178. FROM jobTags WITH(NOLOCK)
  17179. WHERE Tags = #T.Tags
  17180. AND VerifyDate IS NOT NULL
  17181. ORDER BY ID
  17182. )
  17183. DELETE FROM jobTags
  17184. WHERE JobID = @JobID
  17185. INSERT INTO jobTags(JobID,Tags,VerifyDate,AddDate)
  17186. SELECT @JobID,Tags,VerifyDate,GETDATE()
  17187. FROM #T
  17188. DROP TABLE #T
  17189. RETURN 1
  17190. END
  17191. GO
  17192. /****** Object: StoredProcedure [dbo].[procJobTagsByVerifyDelete] Script Date: 2018/12/13 19:11:10 ******/
  17193. SET ANSI_NULLS ON
  17194. GO
  17195. SET QUOTED_IDENTIFIER ON
  17196. GO
  17197. --职位标签审核不通过
  17198. CREATE PROCEDURE [dbo].[procJobTagsByVerifyDelete]
  17199. (
  17200. @TagsID INT
  17201. )
  17202. AS
  17203. BEGIN
  17204. DELETE FROM jobTags
  17205. WHERE id = @TagsID
  17206. END
  17207. GO
  17208. /****** Object: StoredProcedure [dbo].[procJobTagsByVerifyUpdate] Script Date: 2018/12/13 19:11:10 ******/
  17209. SET ANSI_NULLS ON
  17210. GO
  17211. SET QUOTED_IDENTIFIER ON
  17212. GO
  17213. --职位标签审核
  17214. CREATE PROCEDURE [dbo].[procJobTagsByVerifyUpdate]
  17215. (
  17216. @JobID INT
  17217. )
  17218. AS
  17219. BEGIN
  17220. UPDATE jobTags
  17221. SET VerifyDate = GETDATE()
  17222. WHERE JobID = @JobID
  17223. AND VerifyDate IS NULL
  17224. END
  17225. GO
  17226. /****** Object: StoredProcedure [dbo].[procJobTemplateWelfareByIDUpdate] Script Date: 2018/12/13 19:11:10 ******/
  17227. SET ANSI_NULLS ON
  17228. GO
  17229. SET QUOTED_IDENTIFIER ON
  17230. GO
  17231. --#####################################################
  17232. --创建时间:2014.11.04
  17233. --创建人:Nick
  17234. --说明:保存职位模版的薪酬福利
  17235. --修改:harry2016-3-29:修改job-jobtemplate
  17236. --#####################################################
  17237. CREATE PROCEDURE [dbo].[procJobTemplateWelfareByIDUpdate]
  17238. (
  17239. @Promotion VARCHAR(100),
  17240. @Welfare1 INT,
  17241. @Welfare2 INT,
  17242. @Welfare3 INT,
  17243. @Welfare4 INT,
  17244. @Welfare5 INT,
  17245. @Welfare6 INT,
  17246. @Welfare7 INT,
  17247. @Welfare8 INT,
  17248. @Welfare9 INT,
  17249. @Welfare10 INT,
  17250. @Welfare11 INT,
  17251. @Welfare12 INT,
  17252. @Welfare13 INT,
  17253. @Welfare14 INT,
  17254. @Welfare15 INT,
  17255. @Welfare16 INT,
  17256. @Welfare17 INT,
  17257. @Welfare18 INT,
  17258. @Welfare19 INT,
  17259. @ID INT
  17260. )
  17261. AS
  17262. BEGIN
  17263. UPDATE jobtemplate SET Promotion= @Promotion,
  17264. Welfare1 = @Welfare1,
  17265. Welfare2 = @Welfare2,
  17266. Welfare3 = @Welfare3,
  17267. Welfare4 = @Welfare4,
  17268. Welfare5 = @Welfare5,
  17269. Welfare6 = @Welfare6,
  17270. Welfare7 = @Welfare7,
  17271. Welfare8 = @Welfare8,
  17272. Welfare9 = @Welfare9,
  17273. Welfare10 = @Welfare10,
  17274. Welfare11 = @Welfare11,
  17275. Welfare12 = @Welfare12,
  17276. Welfare13 = @Welfare13,
  17277. Welfare14 = @Welfare14,
  17278. Welfare15 = @Welfare15,
  17279. Welfare16 = @Welfare16,
  17280. Welfare17 = @Welfare17,
  17281. Welfare18 = @Welfare18,
  17282. Welfare19 = @Welfare19
  17283. WHERE ID = @ID
  17284. RETURN 1
  17285. END
  17286. GO
  17287. /****** Object: StoredProcedure [dbo].[ProcJobToFriendInsert] Script Date: 2018/12/13 19:11:11 ******/
  17288. SET ANSI_NULLS ON
  17289. GO
  17290. SET QUOTED_IDENTIFIER ON
  17291. GO
  17292. CREATE PROCEDURE [dbo].[ProcJobToFriendInsert]
  17293. (
  17294. @Email VARCHAR(50),
  17295. @FriendName VARCHAR(20),
  17296. @FromName VARCHAR(20),
  17297. @IP VARCHAR(15),
  17298. @JobId INT
  17299. )
  17300. AS
  17301. BEGIN
  17302. INSERT INTO MarketDb..JobToFriend(Email, FriendName, FromName, IP, JobId)
  17303. SELECT @Email, @FriendName, @FromName, @IP, @JobId
  17304. RETURN 0
  17305. /*
  17306. IF (SELECT COUNT(*) FROM MarketDb..JobToFriend WITH(NOLOCK)
  17307. WHERE AddDate > GETDATE() - 1
  17308. AND JobId = @JobID
  17309. ) > 20
  17310. RETURN 0
  17311. IF (SELECT COUNT(*) FROM MarketDb..JobToFriend WITH(NOLOCK)
  17312. WHERE AddDate > GETDATE() - 1
  17313. AND IP = @IP
  17314. ) > 30
  17315. RETURN 0
  17316. IF (SELECT COUNT(*) FROM MarketDb..JobToFriend WITH(NOLOCK)
  17317. WHERE AddDate > GETDATE() - 1
  17318. AND FriendName = @FriendName
  17319. ) > 10
  17320. RETURN 0
  17321. IF (SELECT COUNT(*) FROM MarketDb..JobToFriend WITH(NOLOCK)
  17322. WHERE AddDate > GETDATE() - 1
  17323. AND Email = @Email
  17324. ) > 10
  17325. RETURN 0
  17326. /*
  17327. IF (SELECT COUNT(*) FROM MarketDb..JobToFriend WITH(NOLOCK)
  17328. WHERE AddDate > GETDATE() - 1
  17329. ) > 2000
  17330. RETURN 0
  17331. */
  17332. RETURN 1
  17333. */
  17334. END
  17335. GO
  17336. /****** Object: StoredProcedure [dbo].[ProcJobTypeL1ByParentIdSelect] Script Date: 2018/12/13 19:11:11 ******/
  17337. SET ANSI_NULLS ON
  17338. GO
  17339. SET QUOTED_IDENTIFIER ON
  17340. GO
  17341. --#####################################################
  17342. --创建时间:2014.10.28
  17343. --创建人:John
  17344. --说明:获取二级职位类别
  17345. --@parentId 一级职位类别编号
  17346. --修改记录:2014.11.04 增加查询字段
  17347. --#####################################################
  17348. CREATE PROCEDURE [dbo].[ProcJobTypeL1ByParentIdSelect]
  17349. (
  17350. @parentId INT
  17351. )
  17352. AS
  17353. BEGIN TRY
  17354. SELECT a.id,a.description jobtypel0,c.description jobtypel1,b.*
  17355. FROM dcJobTypeCategory a,dcJobTypeMap b,dcJobType c
  17356. WHERE a.Id = b.CategoryId
  17357. AND b.JobTypeId = c.Id
  17358. AND LEN(b.JobTypeId) > 2
  17359. AND a.Id = @parentId
  17360. ORDER BY a.Id,b.OrderBy
  17361. END TRY
  17362. BEGIN CATCH
  17363. RETURN 0
  17364. END CATCH
  17365. GO
  17366. /****** Object: StoredProcedure [dbo].[ProcJobTypeSimilarByIDSelect] Script Date: 2018/12/13 19:11:12 ******/
  17367. SET ANSI_NULLS ON
  17368. GO
  17369. SET QUOTED_IDENTIFIER ON
  17370. GO
  17371. --#####################################################
  17372. --创建时间:2014.11.4
  17373. --创建人:John
  17374. --说明:获取职位类别的匹配度范围
  17375. --#####################################################
  17376. CREATE PROCEDURE [dbo].[ProcJobTypeSimilarByIDSelect]
  17377. (
  17378. @JobTypeID VARCHAR(1000)
  17379. )
  17380. AS
  17381. BEGIN
  17382. --DECLARE @SQL AS VARCHAR(1000)
  17383. --SET @SQL = 'SELECT * FROM dcjobtypesimilar WITH(NOLOCK) WHERE dcJobTypeId in (0' + @JobTypeID + '0) OR SimilarId in (0' + @JobTypeID + '0)'
  17384. --EXEC(@SQL)
  17385. SELECT TOP 0 0 ID, 0 dcJobTypeId, 0 SimilarId, 0 Coefficient
  17386. END
  17387. GO
  17388. /****** Object: StoredProcedure [dbo].[ProcJobuiJobXmlOutSave] Script Date: 2018/12/13 19:11:12 ******/
  17389. SET ANSI_NULLS ON
  17390. GO
  17391. SET QUOTED_IDENTIFIER ON
  17392. GO
  17393. CREATE PROCEDURE [dbo].[ProcJobuiJobXmlOutSave]
  17394. AS
  17395. SET NOCOUNT ON
  17396. BEGIN
  17397. CREATE TABLE #t(
  17398. Id INT IDENTITY(1, 1),
  17399. dcProvinceId TINYINT,
  17400. JobId int NOT NULL,
  17401. CompanyId int NOT NULL,
  17402. EnJobID varchar(12) NULL,
  17403. IssueDate smalldatetime NULL,
  17404. IssueEnd smalldatetime NULL,
  17405. Area nvarchar(20) NULL,
  17406. JobName nvarchar(50) NOT NULL,
  17407. CompanyName varchar(100) NOT NULL,
  17408. JobDemand varchar(max) NULL,
  17409. Brief varchar(6000) NULL,
  17410. Email varchar(50) NOT NULL,
  17411. Education nvarchar(10) NULL,
  17412. Industry varchar(50) NULL,
  17413. Telephone varchar(25) NULL,
  17414. Fax varchar(20) NULL,
  17415. Address nvarchar(60) NOT NULL,
  17416. Zip char(6) NOT NULL,
  17417. HomePage varchar(100) NOT NULL,
  17418. LinkMan nvarchar(6) NULL,
  17419. CompanySize varchar(10) NULL,
  17420. Employtype varchar(6) NOT NULL,
  17421. Experience varchar(7) NULL,
  17422. Salary varchar(12) NOT NULL
  17423. )
  17424. INSERT INTO #t(dcProvinceId, JobId, CompanyId, EnJobID, IssueDate, IssueEnd, Area, JobName, CompanyName, JobDemand, Brief, Email, Education, Industry, Telephone, Fax, Address, Zip, HomePage, LinkMan, CompanySize, Employtype, Experience, Salary)
  17425. SELECT b.dcProvinceID, a.Id JobId, b.Id CompanyId, a.SecondId EnJobID, a.IssueDate, a.IssueEnd + 3 + a.Id % 30,
  17426. (SELECT MapBarName FROM dcRegion WHERE Id = a.dcRegionId) Area,
  17427. a.Name JobName, b.Name CompanyName, a.Responsibility + CHAR(13) + a.Demand JobDemand,
  17428. b.Brief, c.Email, (SELECT Description FROM dcEducation WHERE Id = dcEducationId) Education,
  17429. SPACE(50) Industry,
  17430. c.Telephone, c.Fax, ISNULL(b.Address, '') Address, ISNULL(b.Zip, '') Zip, ISNULL(b.HomePage, '') HomePage,
  17431. CASE WHEN c.IsNameHide = 1 THEN LEFT(c.Name, 1) + CASE WHEN c.Gender = 1 THEN '女士' ELSE '先生' END
  17432. ELSE c.Name
  17433. END LinkMan,
  17434. CASE WHEN b.dcCompanySizeId = 1 THEN '1-49人'
  17435. WHEN b.dcCompanySizeId = 2 THEN '50-99人'
  17436. WHEN b.dcCompanySizeId IN(3, 4) THEN '100-499人'
  17437. WHEN b.dcCompanySizeId = 5 THEN '500-999人'
  17438. WHEN b.dcCompanySizeId = 6 THEN '1000人以上'
  17439. END CompanySize,
  17440. CASE WHEN Employtype = 1 THEN ' 全职'
  17441. WHEN Employtype = 3 THEN '兼职'
  17442. WHEN Employtype = 4 THEN '实习'
  17443. ELSE '不限制'
  17444. END Employtype,
  17445. CASE WHEN MinExperience IN(1, 5) THEN '0-2年'
  17446. WHEN MinExperience = 2 THEN '3-5年'
  17447. WHEN MinExperience = 3 THEN '6-7年'
  17448. WHEN MinExperience = 4 THEN '11-15年'
  17449. WHEN MinExperience = 0 THEN '不限制'
  17450. END Experience,
  17451. CASE WHEN dcSalaryId < 3 THEN '2000以下'
  17452. WHEN dcSalaryId IN(4, 5, 6, 7) THEN '2000-3999'
  17453. WHEN dcSalaryId IN(8, 9) THEN '4000-5999'
  17454. WHEN dcSalaryId IN(10) THEN '6000-7999'
  17455. WHEN dcSalaryId IN(11) THEN '8000-9999'
  17456. WHEN dcSalaryId IN(12) THEN ' 10000-14999'
  17457. WHEN dcSalaryId IN(13) THEN '15000-19999'
  17458. WHEN dcSalaryId IN(14) THEN '20000-29999'
  17459. WHEN dcSalaryId IN(15) THEN '30000-49999'
  17460. WHEN dcSalaryId IN(16, 17) THEN '50000以上'
  17461. ELSE '面议'
  17462. END Salary
  17463. FROM Job a WITH(NOLOCK), cpMain b WITH(NOLOCK), caMain c WITH(NOLOCK)
  17464. WHERE a.cpMainId = b.Id
  17465. AND a.caMainId = c.Id
  17466. AND a.IsDelete = 0
  17467. AND a.Valid = 1
  17468. AND b.Valid = 1
  17469. AND a.IssueEnd > GETDATE()
  17470. AND b.dcProvinceId = LEFT(a.dcRegionId, 2)
  17471. ORDER BY b.dcProvinceId, a.IssueEnd, a.Id
  17472. UPDATE #t SET Industry = (SELECT Description FROM dcIndustry WHERE Id IN(SELECT TOP 1 dcIndustryId FROM cpIndustry WHERE cpMainId = CompanyId))
  17473. TRUNCATE TABLE ShortDb..JobuiJobXmlOut
  17474. INSERT INTO ShortDb..JobuiJobXmlOut(dcProvinceId, JobId, CompanyId, EnJobID, IssueDate, IssueEnd, Area, JobName, CompanyName, JobDemand, Brief, Email, Education, Industry, Telephone, Fax, Address, Zip, HomePage, LinkMan, CompanySize, Employtype, Experience, Salary)
  17475. SELECT dcProvinceId, JobId, CompanyId, EnJobID, IssueDate, IssueEnd, Area, JobName, CompanyName, JobDemand, Brief, Email, Education, Industry, Telephone, Fax, Address, Zip, HomePage, LinkMan, CompanySize, Employtype, Experience, Salary FROM #t ORDER BY ID
  17476. UPDATE a SET a.PageNo = (b.Row + 2999) / 3000
  17477. FROM ShortDb..JobuiJobXmlOut a, (SELECT id, dcProvinceId, ROW_NUMBER() OVER(PARTITION BY dcProvinceId ORDER BY Id) Row FROM ShortDb..JobuiJobXmlOut) b
  17478. WHERE a.Id = b.Id
  17479. DROP TABLE #t
  17480. END
  17481. GO
  17482. /****** Object: StoredProcedure [dbo].[procJobWelfareByIDUpdate] Script Date: 2018/12/13 19:11:13 ******/
  17483. SET ANSI_NULLS ON
  17484. GO
  17485. SET QUOTED_IDENTIFIER ON
  17486. GO
  17487. --#####################################################
  17488. --创建时间:2014.11.04
  17489. --创建人:Nick
  17490. --说明:保存薪酬福利
  17491. --#####################################################
  17492. CREATE PROCEDURE [dbo].[procJobWelfareByIDUpdate]
  17493. (
  17494. @Promotion VARCHAR(100),
  17495. @Welfare1 INT,
  17496. @Welfare2 INT,
  17497. @Welfare3 INT,
  17498. @Welfare4 INT,
  17499. @Welfare5 INT,
  17500. @Welfare6 INT,
  17501. @Welfare7 INT,
  17502. @Welfare8 INT,
  17503. @Welfare9 INT,
  17504. @Welfare10 INT,
  17505. @Welfare11 INT,
  17506. @Welfare12 INT,
  17507. @Welfare13 INT,
  17508. @Welfare14 INT,
  17509. @Welfare15 INT,
  17510. @Welfare16 INT,
  17511. @Welfare17 INT,
  17512. @Welfare18 INT,
  17513. @Welfare19 INT,
  17514. @ID INT
  17515. )
  17516. AS
  17517. SET NOCOUNT ON
  17518. DECLARE @p VARCHAR(100), @l INT, @L2 INT, @i INT
  17519. SELECT @p = LTRIM(RTRIM(@Promotion))
  17520. SET @L = LEN(@p)
  17521. IF @L > 6 AND CHARINDEX('$', @p) = 0 AND CHARINDEX(',', @p) = 0
  17522. SET @Promotion = ''
  17523. ELSE IF @L > 4
  17524. BEGIN
  17525. SELECT @I = 1, @L2 = 0
  17526. WHILE @I <= @L
  17527. BEGIN
  17528. IF NOT EXISTS(SELECt 'x' FROM CommonChar WHERE CommonChar = SUBSTRING(@P, @i, 1))
  17529. SET @L2 = @L2 + 1
  17530. SET @I = @I + 1
  17531. END
  17532. IF @L2 > 4 OR @L2 * 2 > @L
  17533. SET @Promotion = ''
  17534. IF @L2 * 2 > @L
  17535. SET @Promotion = ''
  17536. END
  17537. ------检查Promotion是否为正常汉字
  17538. BEGIN TRY
  17539. UPDATE JOB
  17540. SET Promotion= @Promotion,
  17541. Welfare1 = @Welfare1,
  17542. Welfare2 = @Welfare2,
  17543. Welfare3 = @Welfare3,
  17544. Welfare4 = @Welfare4,
  17545. Welfare5 = @Welfare5,
  17546. Welfare6 = @Welfare6,
  17547. Welfare7 = @Welfare7,
  17548. Welfare8 = @Welfare8,
  17549. Welfare9 = @Welfare9,
  17550. Welfare10 = @Welfare10,
  17551. Welfare11 = @Welfare11,
  17552. Welfare12 = @Welfare12,
  17553. Welfare13 = @Welfare13,
  17554. Welfare14 = @Welfare14,
  17555. Welfare15 = @Welfare15,
  17556. Welfare16 = @Welfare16,
  17557. Welfare17 = @Welfare17,
  17558. Welfare18 = @Welfare18,
  17559. Welfare19 = @Welfare19
  17560. WHERE ID = @ID
  17561. RETURN 1
  17562. END TRY
  17563. BEGIN CATCH
  17564. RETURN 0
  17565. END CATCH
  17566. GO
  17567. /****** Object: StoredProcedure [dbo].[procKpi_IeSelect] Script Date: 2018/12/13 19:11:14 ******/
  17568. SET ANSI_NULLS ON
  17569. GO
  17570. SET QUOTED_IDENTIFIER ON
  17571. GO
  17572. CREATE PROCEDURE [dbo].[procKpi_IeSelect]
  17573. AS
  17574. BEGIN
  17575. INSERT INTO Kpi_IeToSales
  17576. select id,title,present,improvement,effect,feasible,ApplyMeasure
  17577. from kpi_ie
  17578. where adddate > '2013-8-1'
  17579. and receiver in(select id from manageruser where deptid=24)
  17580. and (sender in(select id from manageruser where deptid in(3,4,5,19,25,27,28,31,34,36,37,39))
  17581. or sender between 180 and 190)
  17582. AND ApplyMeasure>''
  17583. AND ID NOT IN(select id from Kpi_IeToSales)
  17584. ORDER BY ID
  17585. END
  17586. GO
  17587. /****** Object: StoredProcedure [dbo].[procLinkByProvinceidSelect] Script Date: 2018/12/13 19:11:14 ******/
  17588. SET ANSI_NULLS ON
  17589. GO
  17590. SET QUOTED_IDENTIFIER ON
  17591. GO
  17592. CREATE PROCEDURE [dbo].[procLinkByProvinceidSelect]
  17593. (
  17594. @Province_Id SMALLINT,
  17595. @Type Smallint
  17596. )
  17597. AS
  17598. BEGIN
  17599. SELECT Id, Text, Link, FileName, nofollow
  17600. FROM Link WITH(NOLOCK)
  17601. WHERE versionId = @Province_Id
  17602. AND Type = @Type
  17603. AND Valid = 1
  17604. AND Orderby >= 100
  17605. AND Deleted = 0
  17606. ORDER BY ORDERby
  17607. END
  17608. GO
  17609. /****** Object: StoredProcedure [dbo].[procLinkByValidSelect] Script Date: 2018/12/13 19:11:14 ******/
  17610. SET ANSI_NULLS ON
  17611. GO
  17612. SET QUOTED_IDENTIFIER ON
  17613. GO
  17614. --#####################################################
  17615. --创建时间:2014.11.10
  17616. --创建人:NICK
  17617. --说明:获取友情链接
  17618. --#####################################################
  17619. CREATE PROCEDURE [dbo].[procLinkByValidSelect]
  17620. AS
  17621. BEGIN
  17622. SELECT * FROM Link WITH(NOLOCK) WHERE VersionID = 0 AND Valid = 1 AND Orderby >=100 AND Deleted = 0
  17623. END
  17624. GO
  17625. /****** Object: StoredProcedure [dbo].[procLinkHomepageTextSelect] Script Date: 2018/12/13 19:11:14 ******/
  17626. SET ANSI_NULLS ON
  17627. GO
  17628. SET QUOTED_IDENTIFIER ON
  17629. GO
  17630. --创建人 Lambo
  17631. --20101009
  17632. --用于首页查询友情链接
  17633. CREATE PROCEDURE [dbo].[procLinkHomepageTextSelect]
  17634. (
  17635. @province_id SMALLINT
  17636. )
  17637. AS
  17638. BEGIN
  17639. SELECT id, text, link, nofollow FROM SearchDb..hplinkDay
  17640. WHERE ProvinceID = @province_id
  17641. AND Category IS NULL
  17642. ORDER BY ID
  17643. /*
  17644. IF @province_id < 100
  17645. SELECT id, text, link, nofollow FROM SearchDb..hplinkDay
  17646. WHERE ProvinceID = @province_id
  17647. ORDER BY ID
  17648. ELSE
  17649. BEGIN
  17650. IF EXISTS(SELECT 'x' FROM SearchDb..hplinkDay WHERE ProvinceID = @province_id)
  17651. SELECT id, text, link, nofollow FROM SearchDb..hplinkDay
  17652. WHERE ProvinceID = @province_id
  17653. ORDER BY ID
  17654. ELSE
  17655. SELECT id, text, link, nofollow FROM SearchDb..hplinkDay
  17656. WHERE ProvinceID = LEFT(@province_id, 2)
  17657. ORDER BY ID
  17658. END
  17659. */
  17660. END
  17661. GO
  17662. /****** Object: StoredProcedure [dbo].[procLinkInsert] Script Date: 2018/12/13 19:11:14 ******/
  17663. SET ANSI_NULLS ON
  17664. GO
  17665. SET QUOTED_IDENTIFIER ON
  17666. GO
  17667. CREATE PROCEDURE [dbo].[procLinkInsert]
  17668. @text NVARCHAR(50),
  17669. @link VARCHAR(200),
  17670. @versionid INT,
  17671. @type TINYINT,
  17672. @filename VARCHAR(1000),
  17673. @valid SMALLINT,
  17674. @linkman NVARCHAR(50),
  17675. @telephone VARCHAR(50),
  17676. @email VARCHAR(100),
  17677. @nofollow bit
  17678. AS
  17679. INSERT INTO Link (text,link,versionid,type,filename,valid,linkman,telephone,email,nofollow)
  17680. VALUES(@text,@link,@versionid,@type,@filename,@valid,@linkman,@telephone,@email,@nofollow)
  17681. GO
  17682. /****** Object: StoredProcedure [dbo].[procLinkSelect] Script Date: 2018/12/13 19:11:15 ******/
  17683. SET ANSI_NULLS ON
  17684. GO
  17685. SET QUOTED_IDENTIFIER ON
  17686. GO
  17687. --#####################################################
  17688. --创建时间:2014.11.10
  17689. --创建人:NICK
  17690. --说明:获取友情链接
  17691. --#####################################################
  17692. CREATE PROCEDURE [dbo].[procLinkSelect]
  17693. AS
  17694. BEGIN
  17695. SELECT * FROM Link WITH(NOLOCK) WHERE VersionID = 0 AND Valid = 1 AND Orderby < 100 AND Deleted = 0
  17696. END
  17697. GO
  17698. /****** Object: StoredProcedure [dbo].[procLinkSelectByProvinceid] Script Date: 2018/12/13 19:11:15 ******/
  17699. SET ANSI_NULLS ON
  17700. GO
  17701. SET QUOTED_IDENTIFIER ON
  17702. GO
  17703. CREATE PROCEDURE [dbo].[procLinkSelectByProvinceid]
  17704. (
  17705. @Province_Id SMALLINT,
  17706. @Type Smallint
  17707. )
  17708. AS
  17709. BEGIN
  17710. SELECT Id, Text, Link, FileName, nofollow
  17711. FROM Link WITH(NOLOCK)
  17712. WHERE versionId = @Province_Id
  17713. AND Type = @Type
  17714. AND Valid = 1
  17715. AND Orderby >= 100
  17716. AND Deleted = 0
  17717. ORDER BY ORDERby
  17718. END
  17719. GO
  17720. /****** Object: StoredProcedure [dbo].[procLinkZhaopinTextSelect] Script Date: 2018/12/13 19:11:15 ******/
  17721. SET ANSI_NULLS ON
  17722. GO
  17723. SET QUOTED_IDENTIFIER ON
  17724. GO
  17725. --创建人 Lucifer
  17726. --20120213
  17727. --用于分类搜索查询友情链接
  17728. CREATE PROCEDURE [dbo].[procLinkZhaopinTextSelect]
  17729. (
  17730. @province_id SMALLINT,
  17731. @category TINYINT
  17732. )
  17733. AS
  17734. BEGIN
  17735. SELECT id, text, link, nofollow FROM SearchDb..hplinkDay
  17736. WHERE ProvinceID = @province_id
  17737. AND Category=@category
  17738. ORDER BY ID
  17739. END
  17740. GO
  17741. /****** Object: StoredProcedure [dbo].[procLotteryCompany50Select] Script Date: 2018/12/13 19:11:15 ******/
  17742. SET ANSI_NULLS ON
  17743. GO
  17744. SET QUOTED_IDENTIFIER ON
  17745. GO
  17746. --#####################################################
  17747. --创建时间:2014.11.5
  17748. --创建人:NICK
  17749. --说明:查询最新获奖的单位
  17750. --#####################################################
  17751. CREATE PROCEDURE [dbo].[procLotteryCompany50Select]
  17752. AS
  17753. BEGIN
  17754. SELECT TOP 50 a.*,b.Name,(
  17755. SELECT TOP 1 DetailName
  17756. FROM dcvipdetail
  17757. WHERE id IN (
  17758. SELECT TOP 1 dcfeedetailid
  17759. FROM caOrder
  17760. WHERE id = a.caorderid
  17761. )
  17762. ) ordername
  17763. FROM LotteryCompany a,cpmain b WITH(NOLOCK)
  17764. WHERE a.cpmainid = b.id
  17765. AND CaOrderID IS NOT NULL
  17766. AND Used=1
  17767. AND [Type] <> 9
  17768. AND CaOrderID IS NOT NULL
  17769. ORDER BY a.ID DESC
  17770. END
  17771. GO
  17772. /****** Object: StoredProcedure [dbo].[procLotteryCompanyByCpMainIDSelect] Script Date: 2018/12/13 19:11:15 ******/
  17773. SET ANSI_NULLS ON
  17774. GO
  17775. SET QUOTED_IDENTIFIER ON
  17776. GO
  17777. --#####################################################
  17778. --创建时间:2014.11.5
  17779. --创建人:NICK
  17780. --说明:查询本单位获奖记录
  17781. --#####################################################
  17782. CREATE PROCEDURE [dbo].[procLotteryCompanyByCpMainIDSelect]
  17783. (
  17784. @CpMainID INT
  17785. )
  17786. AS
  17787. BEGIN
  17788. SELECT top 20 * FROM LotteryCompany WITH(NOLOCK) WHERE Used=1 AND cpMainID=@CpMainID
  17789. END
  17790. GO
  17791. /****** Object: StoredProcedure [dbo].[procLotteryCompanyCountSelect] Script Date: 2018/12/13 19:11:16 ******/
  17792. SET ANSI_NULLS ON
  17793. GO
  17794. SET QUOTED_IDENTIFIER ON
  17795. GO
  17796. --#####################################################
  17797. --创建时间:2014.11.5
  17798. --创建人:NICK
  17799. --说明:
  17800. --#####################################################
  17801. CREATE PROCEDURE [dbo].[procLotteryCompanyCountSelect]
  17802. (
  17803. @CpMainID INT
  17804. )
  17805. AS
  17806. BEGIN
  17807. SELECT COUNT(*) FROM LotteryCompany WHERE cpmainid=@CpMainID and used=0
  17808. END
  17809. GO
  17810. /****** Object: StoredProcedure [dbo].[procLotteryCompanyLoginLogByCpMainIDSelect] Script Date: 2018/12/13 19:11:16 ******/
  17811. SET ANSI_NULLS ON
  17812. GO
  17813. SET QUOTED_IDENTIFIER ON
  17814. GO
  17815. --#####################################################
  17816. --创建时间:2014.11.5
  17817. --创建人:NICK
  17818. --说明:
  17819. --#####################################################
  17820. CREATE PROCEDURE [dbo].[procLotteryCompanyLoginLogByCpMainIDSelect]
  17821. (
  17822. @CpMainID INT
  17823. )
  17824. AS
  17825. BEGIN
  17826. SELECT * FROM LotteryCompanyLoginLog WITH(NOLOCK) WHERE cpMainID=@CpMainID ORDER BY LoginDate
  17827. END
  17828. GO
  17829. /****** Object: StoredProcedure [dbo].[procMajorClass1000Select] Script Date: 2018/12/13 19:11:16 ******/
  17830. SET ANSI_NULLS ON
  17831. GO
  17832. SET QUOTED_IDENTIFIER ON
  17833. GO
  17834. --#####################################################
  17835. --创建时间:2014.11.03
  17836. --创建人:Nick
  17837. --说明:根据字母得到专业信息
  17838. --#####################################################
  17839. CREATE PROCEDURE [dbo].[procMajorClass1000Select]
  17840. AS
  17841. BEGIN TRY
  17842. SELECT * FROM MajorClass WITH(NOLOCK) WHERE istop1000=1 ORDER BY id
  17843. END TRY
  17844. BEGIN CATCH
  17845. RETURN 0
  17846. END CATCH
  17847. GO
  17848. /****** Object: StoredProcedure [dbo].[procMajorClass100Select] Script Date: 2018/12/13 19:11:16 ******/
  17849. SET ANSI_NULLS ON
  17850. GO
  17851. SET QUOTED_IDENTIFIER ON
  17852. GO
  17853. --#####################################################
  17854. --创建时间:2014.11.04
  17855. --创建人:Nick
  17856. --说明:获取专业分类
  17857. --#####################################################
  17858. CREATE PROCEDURE [dbo].[procMajorClass100Select]
  17859. AS
  17860. BEGIN TRY
  17861. SELECT TOP 46 * FROM MajorClass WHERE IsTop100=1
  17862. END TRY
  17863. BEGIN CATCH
  17864. RETURN 0
  17865. END CATCH
  17866. GO
  17867. /****** Object: StoredProcedure [dbo].[ProcMajorClassByFirstLetterSelect] Script Date: 2018/12/13 19:11:17 ******/
  17868. SET ANSI_NULLS ON
  17869. GO
  17870. SET QUOTED_IDENTIFIER ON
  17871. GO
  17872. --#####################################################
  17873. --创建时间:2014.10.28
  17874. --创建人:John
  17875. --说明:根据字母得到专业信息
  17876. --@ch 专业信息第一个字母
  17877. --#####################################################
  17878. CREATE PROCEDURE [dbo].[ProcMajorClassByFirstLetterSelect]
  17879. (
  17880. @ch CHAR(1)
  17881. )
  17882. AS
  17883. BEGIN TRY
  17884. SELECT * FROM MajorClass WHERE FirstLetter = @ch
  17885. END TRY
  17886. BEGIN CATCH
  17887. RETURN 0
  17888. END CATCH
  17889. GO
  17890. /****** Object: StoredProcedure [dbo].[procMajorClassNameByIDSelect] Script Date: 2018/12/13 19:11:17 ******/
  17891. SET ANSI_NULLS ON
  17892. GO
  17893. SET QUOTED_IDENTIFIER ON
  17894. GO
  17895. --#####################################################
  17896. --创建时间:2014.11.03
  17897. --创建人:Nick
  17898. --说明:根据ID获得专业名称
  17899. --#####################################################
  17900. CREATE PROCEDURE [dbo].[procMajorClassNameByIDSelect]
  17901. (
  17902. @ID INT
  17903. )
  17904. AS
  17905. BEGIN TRY
  17906. SELECT majorname FROM MajorClass WITH(NOLOCK) WHERE id=@ID
  17907. END TRY
  17908. BEGIN CATCH
  17909. RETURN 0
  17910. END CATCH
  17911. GO
  17912. /****** Object: StoredProcedure [dbo].[ProcMajorClassSelect] Script Date: 2018/12/13 19:11:17 ******/
  17913. SET ANSI_NULLS ON
  17914. GO
  17915. SET QUOTED_IDENTIFIER ON
  17916. GO
  17917. --#####################################################
  17918. --创建时间:2014.10.28
  17919. --创建人:John
  17920. --说明:专业信息分类的列表Xml
  17921. --#####################################################
  17922. CREATE PROCEDURE [dbo].[ProcMajorClassSelect]
  17923. AS
  17924. BEGIN TRY
  17925. SELECT * FROM MajorClass WITH(NOLOCK) ORDER BY id
  17926. END TRY
  17927. BEGIN CATCH
  17928. RETURN 0
  17929. END CATCH
  17930. GO
  17931. /****** Object: StoredProcedure [dbo].[ProcManagerLogByAutoInsert] Script Date: 2018/12/13 19:11:17 ******/
  17932. SET ANSI_NULLS ON
  17933. GO
  17934. SET QUOTED_IDENTIFIER ON
  17935. GO
  17936. CREATE PROCEDURE [dbo].[ProcManagerLogByAutoInsert]
  17937. (
  17938. @ManagerId INT,
  17939. @Ip VARCHAR(15)
  17940. )
  17941. AS
  17942. BEGIN
  17943. INSERT ManagerLog
  17944. SELECT @ManagerId, GETDATE(), @ip, 'autoclick', '', NULL, NULL
  17945. END
  17946. GO
  17947. /****** Object: StoredProcedure [dbo].[ProcManagerLogByIpUpdate] Script Date: 2018/12/13 19:11:17 ******/
  17948. SET ANSI_NULLS ON
  17949. GO
  17950. SET QUOTED_IDENTIFIER ON
  17951. GO
  17952. CREATE PROCEDURE [dbo].[ProcManagerLogByIpUpdate]
  17953. (
  17954. @ManagerId INT,
  17955. @Ip VARCHAR(15)
  17956. )
  17957. AS
  17958. SET NOCOUNT ON
  17959. BEGIN
  17960. DECLARE @LoginDate DATETIME, @PrevIp VARCHAR(15)
  17961. SELECT TOP 1 @LoginDate = LoginDate, @PrevIp = Ip FROM ManagerLog WHERE ManagerId = @ManagerId ORDER BY LoginDate DESC
  17962. IF @LoginDate > DATEADD(MINUTE, -5, GETDATE()) AND @PrevIp <> @Ip
  17963. BEGIN
  17964. UPDATE ManagerLog SET Ip = @Ip, InternalIp = @PrevIp WHERE ManagerId = @ManagerId AND @LoginDate = LoginDate
  17965. END
  17966. END
  17967. GO
  17968. /****** Object: StoredProcedure [dbo].[procManagerUserAllSelect] Script Date: 2018/12/13 19:11:18 ******/
  17969. SET ANSI_NULLS ON
  17970. GO
  17971. SET QUOTED_IDENTIFIER ON
  17972. GO
  17973. --#####################################################
  17974. --创建时间:2014.11.03
  17975. --创建人:Nick
  17976. --说明:获取全部公司用户
  17977. --#####################################################
  17978. CREATE PROCEDURE [dbo].[procManagerUserAllSelect]
  17979. AS
  17980. BEGIN TRY
  17981. SELECT ID, Name, Name_Eng, Title, mobile, Email, Status, Type, Superior
  17982. FROM ManagerUser WITH(NOLOCK)
  17983. END TRY
  17984. BEGIN CATCH
  17985. RETURN 0
  17986. END CATCH
  17987. GO
  17988. /****** Object: StoredProcedure [dbo].[ProcManagerUserByIDSelect] Script Date: 2018/12/13 19:11:18 ******/
  17989. SET ANSI_NULLS ON
  17990. GO
  17991. SET QUOTED_IDENTIFIER ON
  17992. GO
  17993. --#####################################################
  17994. --创建时间:2014.10.30
  17995. --创建人:Nick
  17996. --说明:获取工位信息
  17997. --#####################################################
  17998. CREATE PROCEDURE [dbo].[ProcManagerUserByIDSelect]
  17999. (
  18000. @ID INT
  18001. )
  18002. AS
  18003. BEGIN TRY
  18004. SELECT * FROM ManagerUser WHERE ID=@ID
  18005. END TRY
  18006. BEGIN CATCH
  18007. RETURN 0
  18008. END CATCH
  18009. GO
  18010. /****** Object: StoredProcedure [dbo].[ProcManagerUserByServiceStatusSelect] Script Date: 2018/12/13 19:11:18 ******/
  18011. SET ANSI_NULLS ON
  18012. GO
  18013. SET QUOTED_IDENTIFIER ON
  18014. GO
  18015. CREATE PROCEDURE [dbo].[ProcManagerUserByServiceStatusSelect]
  18016. AS
  18017. BEGIN
  18018. SELECT Id, RtxStatus FROM Manageruser WITH(NOLOCK) WHERE ID BETWEEN 180 AND 182 OR ID = 222 OR ID = 223
  18019. END
  18020. GO
  18021. /****** Object: StoredProcedure [dbo].[ProcManageruserBySOLStatusUpdate] Script Date: 2018/12/13 19:11:18 ******/
  18022. SET ANSI_NULLS ON
  18023. GO
  18024. SET QUOTED_IDENTIFIER ON
  18025. GO
  18026. CREATE PROCEDURE [dbo].[ProcManageruserBySOLStatusUpdate]
  18027. (
  18028. @ManageruserID SMALLINT,
  18029. @Online TINYINT
  18030. )
  18031. AS
  18032. BEGIN
  18033. UPDATE Manageruser SET SOLStatus = @Online WHERE ID = @ManageruserID
  18034. UPDATE a SET a.IsOnline = b.SOLStatus FROM ChatService a, Manageruser b WHERE a.ManagerUserID = b.ID
  18035. END
  18036. GO
  18037. /****** Object: StoredProcedure [dbo].[procManagerUserDeptByIDSelect] Script Date: 2018/12/13 19:11:19 ******/
  18038. SET ANSI_NULLS ON
  18039. GO
  18040. SET QUOTED_IDENTIFIER ON
  18041. GO
  18042. CREATE PROCEDURE [dbo].[procManagerUserDeptByIDSelect]
  18043. (
  18044. @id INT
  18045. )
  18046. AS
  18047. BEGIN
  18048. SELECT a.id,a.name,b.DeptName FROM ManagerUser a WITH(NOLOCK),dept b WITH(NOLOCK) WHERE a.deptid = b.id AND a.id = @id
  18049. END
  18050. GO
  18051. /****** Object: StoredProcedure [dbo].[ProcManageruserOnlineStatusUpdate] Script Date: 2018/12/13 19:11:19 ******/
  18052. SET ANSI_NULLS ON
  18053. GO
  18054. SET QUOTED_IDENTIFIER ON
  18055. GO
  18056. CREATE PROCEDURE [dbo].[ProcManageruserOnlineStatusUpdate]
  18057. @ManageruserIDs VARCHAR(MAX)
  18058. AS
  18059. BEGIN
  18060. UPDATE Manageruser SET SOLStatus=1,SOLTime=GETDATE() WHERE ID IN(SELECT a FROM dbo.fnSplit(@ManageruserIDs,','))
  18061. UPDATE Manageruser SET SOLStatus=0 WHERE ID NOT IN(SELECT a FROM dbo.fnSplit(@ManageruserIDs,','))
  18062. UPDATE ChatService SET IsOnline=1 WHERE ManageruserID IN(SELECT a FROM dbo.fnSplit(@ManageruserIDs,','))
  18063. UPDATE ChatService SET IsOnline=0 WHERE ManageruserID NOT IN(SELECT a FROM dbo.fnSplit(@ManageruserIDs,','))
  18064. END
  18065. GO
  18066. /****** Object: StoredProcedure [dbo].[ProcManagerUserRtxStatusSelect] Script Date: 2018/12/13 19:11:19 ******/
  18067. SET ANSI_NULLS ON
  18068. GO
  18069. SET QUOTED_IDENTIFIER ON
  18070. GO
  18071. --#####################################################
  18072. --创建时间:2014.10.30
  18073. --创建人:Nick
  18074. --说明:获取状态
  18075. --#####################################################
  18076. CREATE PROCEDURE [dbo].[ProcManagerUserRtxStatusSelect]
  18077. (
  18078. @ID INT
  18079. )
  18080. AS
  18081. BEGIN
  18082. IF @ID = 0
  18083. SELECT RtxStatus FROM Manageruser WITH(NOLOCK) WHERE RtxStatus=1 AND type=5
  18084. ELSE
  18085. SELECT rtxstatus FROM ManagerUser WITH(NOLOCK) WHERE id=@ID
  18086. END
  18087. GO
  18088. /****** Object: StoredProcedure [dbo].[procManagerUserSelect] Script Date: 2018/12/13 19:11:19 ******/
  18089. SET ANSI_NULLS ON
  18090. GO
  18091. SET QUOTED_IDENTIFIER ON
  18092. GO
  18093. --#####################################################
  18094. --创建时间:2014.11.03
  18095. --创建人:Nick
  18096. --说明:获取公司用户
  18097. --#####################################################
  18098. CREATE PROCEDURE [dbo].[procManagerUserSelect]
  18099. AS
  18100. BEGIN TRY
  18101. SELECT ID, Name, Name_Eng, Title, mobile, Email, Type, Superior
  18102. FROM ManagerUser WITH(NOLOCK)
  18103. WHERE Status < 3
  18104. END TRY
  18105. BEGIN CATCH
  18106. RETURN 0
  18107. END CATCH
  18108. GO
  18109. /****** Object: StoredProcedure [dbo].[ProcManagerUserStatusSelect] Script Date: 2018/12/13 19:11:19 ******/
  18110. SET ANSI_NULLS ON
  18111. GO
  18112. SET QUOTED_IDENTIFIER ON
  18113. GO
  18114. --#####################################################
  18115. --创建时间:2014.10.30
  18116. --创建人:Nick
  18117. --说明:获取状态
  18118. --#####################################################
  18119. CREATE PROCEDURE [dbo].[ProcManagerUserStatusSelect]
  18120. (
  18121. @ID INT
  18122. )
  18123. AS
  18124. BEGIN TRY
  18125. SELECT ID
  18126. FROM manageruser
  18127. WHERE Status < 3
  18128. AND ID=@ID
  18129. END TRY
  18130. BEGIN CATCH
  18131. RETURN 0
  18132. END CATCH
  18133. GO
  18134. /****** Object: StoredProcedure [dbo].[procManageruserSuperior] Script Date: 2018/12/13 19:11:20 ******/
  18135. SET ANSI_NULLS ON
  18136. GO
  18137. SET QUOTED_IDENTIFIER OFF
  18138. GO
  18139. CREATE PROCEDURE [dbo].[procManageruserSuperior]
  18140. (
  18141. @sender INT,
  18142. @receiver INT
  18143. )
  18144. AS
  18145. --INSERT INTO procLog SELECT 'procManageruserSuperior', '', GETDATE()
  18146. BEGIN
  18147. DECLARE @superior INT,@r1 INT,@r2 INT,@r3 INT,@s1 INT,@s2 INT,@s3 INT
  18148. SELECT @s1=superior FROM manageruser WITH(nolock) WHERE id=@sender
  18149. SELECT @r1=superior FROM manageruser WITH(nolock) WHERE id=@receiver
  18150. SELECT @s2=superior FROM manageruser WITH(nolock) WHERE id=@s1
  18151. SELECT @r2=superior FROM manageruser WITH(nolock) WHERE id=@r1
  18152. SELECT @s3=superior FROM manageruser WITH(nolock) WHERE id=@s2
  18153. SELECT @r3=superior FROM manageruser WITH(nolock) WHERE id=@r2
  18154. IF @s1=@r1
  18155. SET @superior=@s1
  18156. ELSE IF @s1=@r2
  18157. SET @superior=@s1
  18158. ELSE IF @s2=@r1
  18159. SET @superior=@r1
  18160. ELSE IF @s1=@r3
  18161. SET @superior=@s1
  18162. ELSE IF @r1=@s3
  18163. SET @superior=@r1
  18164. ELSE IF @r2=@s2
  18165. SET @superior=@s2
  18166. ELSE IF @r2=@s3
  18167. SET @superior=@r2
  18168. ELSE IF @s2=@r3
  18169. SET @superior=@s2
  18170. ELSE IF @r3=@s3
  18171. SET @superior=@s3
  18172. ELSE
  18173. SET @superior=1
  18174. SELECT @superior AS superior
  18175. END
  18176. GO
  18177. /****** Object: StoredProcedure [dbo].[procManagerUserSuperiorByIDSelect] Script Date: 2018/12/13 19:11:20 ******/
  18178. SET ANSI_NULLS ON
  18179. GO
  18180. SET QUOTED_IDENTIFIER ON
  18181. GO
  18182. --#####################################################
  18183. --创建时间:2014.11.10
  18184. --创建人:John
  18185. --说明:获取顾问上级
  18186. --#####################################################
  18187. CREATE PROCEDURE [dbo].[procManagerUserSuperiorByIDSelect]
  18188. (
  18189. @ManagerID INT
  18190. )
  18191. AS
  18192. BEGIN
  18193. SELECT Superior FROM Manageruser WITH(NOLOCK) WHERE ID = @ManagerID
  18194. END
  18195. GO
  18196. /****** Object: StoredProcedure [dbo].[procMapClassByIDSelect] Script Date: 2018/12/13 19:11:20 ******/
  18197. SET ANSI_NULLS ON
  18198. GO
  18199. SET QUOTED_IDENTIFIER ON
  18200. GO
  18201. --#####################################################
  18202. --创建时间:2014.11.03
  18203. --创建人:Nick
  18204. --说明:根据ID获得专业名称
  18205. --#####################################################
  18206. CREATE PROCEDURE [dbo].[procMapClassByIDSelect]
  18207. (
  18208. @ID INT
  18209. )
  18210. AS
  18211. BEGIN TRY
  18212. SELECT MapName FROM MARKETDB..MapClass WHERE id=@ID
  18213. END TRY
  18214. BEGIN CATCH
  18215. RETURN 0
  18216. END CATCH
  18217. GO
  18218. /****** Object: StoredProcedure [dbo].[procMapClassBySubSiteIdSelect] Script Date: 2018/12/13 19:11:20 ******/
  18219. SET ANSI_NULLS ON
  18220. GO
  18221. SET QUOTED_IDENTIFIER ON
  18222. GO
  18223. --#####################################################
  18224. --创建时间:2014.11.04
  18225. --创建人:Nick
  18226. --说明:获取职位列表
  18227. --#####################################################
  18228. CREATE PROCEDURE [dbo].[procMapClassBySubSiteIdSelect]
  18229. (
  18230. @dcSubSiteId INT
  18231. )
  18232. AS
  18233. BEGIN TRY
  18234. SELECT * FROM MARKETDB..MapClass WITH(NOLOCK) WHERE dcSubSiteId=@dcSubSiteId
  18235. END TRY
  18236. BEGIN CATCH
  18237. RETURN 0
  18238. END CATCH
  18239. GO
  18240. /****** Object: StoredProcedure [dbo].[procMarketMediaByProvinceIdSelect] Script Date: 2018/12/13 19:11:20 ******/
  18241. SET ANSI_NULLS ON
  18242. GO
  18243. SET QUOTED_IDENTIFIER ON
  18244. GO