maindb-procedure-5.sql 812 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473
  1. /****** Object: StoredProcedure [dbo].[mblPaByExchangeSelect] Script Date: 2018/12/13 19:07:52 ******/
  2. SET ANSI_NULLS ON
  3. GO
  4. SET QUOTED_IDENTIFIER ON
  5. GO
  6. CREATE PROCEDURE [dbo].[mblPaByExchangeSelect]
  7. (
  8. @paMainId INT
  9. )
  10. AS
  11. BEGIN
  12. SELECT
  13. (SELECT COUNT(*) FROM ExJobApply WITH(NOLOCK) WHERE cvMainId IN(SELECT id FROM cvMain WITH(NOLOCK) WHERE paMainId = @paMainId)) AS JobApplyNumber,
  14. (SELECT COUNT(*) FROM paFavorate WITH(NOLOCK) WHERE paMainId = @paMainId) AS FavorateNumber,
  15. (SELECT COUNT(*) FROM caCvViewLog WITH(NOLOCK) WHERE cvMainId IN(SELECT id FROM cvMain WITH(NOLOCK) WHERE paMainId = @paMainId)) AS cvViewNumber
  16. END
  17. set ANSI_NULLS ON
  18. set QUOTED_IDENTIFIER ON
  19. GO
  20. /****** Object: StoredProcedure [dbo].[mblPaFavorateBatchDelete] Script Date: 2018/12/13 19:07:52 ******/
  21. SET ANSI_NULLS ON
  22. GO
  23. SET QUOTED_IDENTIFIER ON
  24. GO
  25. CREATE PROCEDURE [dbo].[mblPaFavorateBatchDelete]
  26. (
  27. @AllID VARCHAR(1000),
  28. @paMainID INT
  29. )
  30. AS
  31. BEGIN TRY
  32. --生成临时表
  33. DECLARE @t AS TABLE(ID INT)
  34. INSERT INTO @t
  35. SELECT * FROM dbo.fnSplit(@AllID, ',')
  36. DELETE FROM paFavorate WHERE JobID IN(SELECT ID FROM @t) AND paMainID=@paMainID
  37. END TRY
  38. BEGIN CATCH
  39. GOTO ERR
  40. END CATCH
  41. RETURN 1
  42. ERR:
  43. BEGIN
  44. RETURN 0
  45. END
  46. GO
  47. /****** Object: StoredProcedure [dbo].[mblPaFavorateSelect] Script Date: 2018/12/13 19:07:52 ******/
  48. SET ANSI_NULLS ON
  49. GO
  50. SET QUOTED_IDENTIFIER ON
  51. GO
  52. CREATE PROCEDURE [dbo].[mblPaFavorateSelect]
  53. (
  54. @WHERE VARCHAR(1000),
  55. @Order VARCHAR(100)
  56. )
  57. AS
  58. BEGIN
  59. BEGIN TRY
  60. SET @Where = dbo.SafeSql(@Where)
  61. SET @ORDER = dbo.SafeSql(@Order)
  62. IF LEN(@ORDER)=0
  63. SET @ORDER = 'a.ID DESC '
  64. DECLARE @SQL AS VARCHAR(2000)
  65. SET @SQL='SELECT a.ID,a.paMainID,a.JobID,a.AddDate,a.Remark,b.Name as JobName,b.IssueDate,
  66. b.IssueEND,b.dcRegionID,b.IsDelete, c.Name as cpName,c.ID as cpID,c.HasLicence,c.IsAgent,
  67. c.Membertype,d.FullName Region
  68. FROM paFavorate a WITH(NOLOCK) Inner Join Job b WITH(NOLOCK) ON a.JobID=b.ID
  69. Inner Join cpMain c WITH(NOLOCK) ON b.cpMainID=c.ID
  70. INNER JOIN dcRegion d ON d.ID=b.dcRegionID '
  71. IF LEN(@WHERE)>0
  72. SET @SQL=@SQL + ' WHERE '+ @WHERE
  73. IF LEN(@ORDER)>0
  74. SET @SQL=@SQL + ' ORDER BY '+@ORDER
  75. EXEC(@SQL)
  76. END TRY
  77. BEGIN CATCH
  78. END CATCH
  79. END
  80. GO
  81. /****** Object: StoredProcedure [dbo].[mblPaFeedBackInsert] Script Date: 2018/12/13 19:07:53 ******/
  82. SET ANSI_NULLS ON
  83. GO
  84. SET QUOTED_IDENTIFIER ON
  85. GO
  86. CREATE PROCEDURE [dbo].[mblPaFeedBackInsert]
  87. (
  88. @Content NVARCHAR(200),
  89. @Version VARCHAR(50),
  90. @paMainID INT,
  91. @Name VARCHAR(50),
  92. @Telephone VARCHAR(11),
  93. @Email VARCHAR(50)
  94. )
  95. AS
  96. BEGIN
  97. INSERT INTO mblFeedBack(Content,Version,paMainID,Name,Mobile,Email) VALUES(@Content,@Version,@paMainID,@Name,@Telephone,@Email)
  98. END
  99. GO
  100. /****** Object: StoredProcedure [dbo].[mblpaGetPasswordLogByPamainIDUpdate] Script Date: 2018/12/13 19:07:53 ******/
  101. SET ANSI_NULLS ON
  102. GO
  103. SET QUOTED_IDENTIFIER ON
  104. GO
  105. --#####################################################
  106. --创建时间:2014.11.6
  107. --创建人:Nick
  108. --说明:重置密码
  109. --#####################################################
  110. CREATE PROCEDURE [dbo].[mblpaGetPasswordLogByPamainIDUpdate]
  111. (
  112. @PaMainID INT
  113. )
  114. AS
  115. BEGIN
  116. UPDATE paGetPasswordLog SET IsReset=1
  117. WHERE AskNo=(
  118. SELECT TOP 1 AskNo
  119. FROM paGetPasswordLog WITH(NOLOCK)
  120. WHERE pamainID = @PaMainID
  121. ORDER BY ID DESC
  122. )
  123. END
  124. GO
  125. /****** Object: StoredProcedure [dbo].[mblpaIOSBindDelete] Script Date: 2018/12/13 19:07:53 ******/
  126. SET ANSI_NULLS ON
  127. GO
  128. SET QUOTED_IDENTIFIER ON
  129. GO
  130. CREATE PROCEDURE [dbo].[mblpaIOSBindDelete]
  131. (
  132. @paMainID INT,
  133. @UniqueID VARCHAR(100)
  134. )
  135. AS
  136. BEGIN
  137. DELETE FROM paIOSBind WHERE UniqueID = @UniqueID
  138. END
  139. GO
  140. /****** Object: StoredProcedure [dbo].[mblpaIOSBindInsert] Script Date: 2018/12/13 19:07:53 ******/
  141. SET ANSI_NULLS ON
  142. GO
  143. SET QUOTED_IDENTIFIER ON
  144. GO
  145. CREATE PROCEDURE [dbo].[mblpaIOSBindInsert]
  146. (
  147. @paMainID INT,
  148. @UniqueID VARCHAR(100),
  149. @ClientType TINYINT
  150. )
  151. AS
  152. BEGIN TRY
  153. IF LEN(ISNULL(@UniqueID,'')) = 0
  154. RETURN
  155. IF NOT EXISTS(SELECT 1 FROM paIOSBind WITH(NOLOCK) WHERE PaMainID = @paMainID AND UniqueID = @UniqueID AND ClientType = @ClientType)
  156. BEGIN
  157. INSERT INTO paIOSBind VALUES(@paMainID,@UniqueID,GETDATE(),@ClientType)
  158. RETURN 1
  159. END
  160. ELSE
  161. BEGIN
  162. RETURN 0
  163. END
  164. END TRY
  165. BEGIN CATCH
  166. RETURN 0
  167. END CATCH
  168. GO
  169. /****** Object: StoredProcedure [dbo].[mblpaLoginContactByIDSelect] Script Date: 2018/12/13 19:07:53 ******/
  170. SET ANSI_NULLS ON
  171. GO
  172. SET QUOTED_IDENTIFIER ON
  173. GO
  174. --#####################################################
  175. --创建时间:2014.11.6
  176. --创建人:Nick
  177. --说明:获取第三方登录的用户信息
  178. --#####################################################
  179. CREATE PROCEDURE [dbo].[mblpaLoginContactByIDSelect]
  180. (
  181. @Openid VARCHAR(100)
  182. )
  183. AS
  184. BEGIN
  185. SELECT TOP 1 b.ID,b.UserName,b.PassWord
  186. FROM paLoginContact a WITH(NOLOCK), paMain b WITH(NOLOCK)
  187. WHERE a.paMainID = b.ID
  188. AND a.OpenID = @Openid
  189. AND a.OpenID > ''
  190. ORDER BY a.AddDate DESC
  191. END
  192. GO
  193. /****** Object: StoredProcedure [dbo].[mblpaLoginContactByOpenIDSelect] Script Date: 2018/12/13 19:07:53 ******/
  194. SET ANSI_NULLS ON
  195. GO
  196. SET QUOTED_IDENTIFIER ON
  197. GO
  198. --#####################################################
  199. --创建时间:2014.11.06
  200. --创建人:Nick
  201. --说明:根据微信号得到微信绑定信息
  202. --#####################################################
  203. CREATE PROCEDURE [dbo].[mblpaLoginContactByOpenIDSelect]
  204. (
  205. @OpenID VARCHAR(50)
  206. )
  207. AS
  208. BEGIN TRY
  209. SELECT a.*,b.UserName
  210. FROM paLoginContact a,pamain b
  211. WHERE a.openid=@OpenID
  212. AND a.ContactType=4
  213. AND a.PamainID = b.ID
  214. END TRY
  215. BEGIN CATCH
  216. RETURN 0
  217. END CATCH
  218. GO
  219. /****** Object: StoredProcedure [dbo].[mblPaLoginContactDelete] Script Date: 2018/12/13 19:07:54 ******/
  220. SET ANSI_NULLS ON
  221. GO
  222. SET QUOTED_IDENTIFIER ON
  223. GO
  224. --#####################################################
  225. --创建时间:2014.11.4
  226. --创建人:Nick
  227. --说明:删除绑定信息
  228. --#####################################################
  229. CREATE PROCEDURE [dbo].[mblPaLoginContactDelete]
  230. (
  231. @OpenID VARCHAR(50)
  232. )
  233. AS
  234. BEGIN
  235. DECLARE @paMainId INT
  236. SELECT @paMainId = paMainId FROM PaLoginContact WHERE OpenID = @OpenID AND ContactType = 4
  237. DELETE FROM PaLoginContact WHERE OpenID = @OpenID AND ContactType = 4
  238. UPDATE paMain SET IsUseYourFood = 0 WHERE id = @paMainId AND isUseYourFood = 1
  239. END
  240. GO
  241. /****** Object: StoredProcedure [dbo].[mblPaMainByCvIDSelect] Script Date: 2018/12/13 19:07:54 ******/
  242. SET ANSI_NULLS ON
  243. GO
  244. SET QUOTED_IDENTIFIER ON
  245. GO
  246. --#####################################################
  247. --创建时间:2014.11.06
  248. --创建人:Nick
  249. --说明:获取个人用户信息
  250. --#####################################################
  251. CREATE PROCEDURE [dbo].[mblPaMainByCvIDSelect]
  252. (
  253. @cvMainID INT
  254. )
  255. AS
  256. BEGIN TRY
  257. SELECT a.mobile,a.Gender,a.id,dbo.GetPaOnlineStatus(a.id) IsOnline,name
  258. FROM pamain a
  259. WHERE id IN (
  260. SELECT pamainid
  261. FROM cvmain
  262. WHERE id=@cvMainID)
  263. END TRY
  264. BEGIN CATCH
  265. RETURN 0
  266. END CATCH
  267. GO
  268. /****** Object: StoredProcedure [dbo].[mblPaMainByIDSelect] Script Date: 2018/12/13 19:07:54 ******/
  269. SET ANSI_NULLS ON
  270. GO
  271. SET QUOTED_IDENTIFIER ON
  272. GO
  273. --#####################################################
  274. --创建时间:2014.11.6
  275. --创建人:Nick
  276. --说明:获取注册时间
  277. --#####################################################
  278. CREATE PROCEDURE [dbo].[mblPaMainByIDSelect]
  279. (
  280. @ID INT
  281. )
  282. AS
  283. BEGIN
  284. SELECT AddDate,name FROM paMain WITH(NOLOCK) WHERE ID=@ID
  285. END
  286. GO
  287. /****** Object: StoredProcedure [dbo].[mblPaMainRegisterModeUpdate] Script Date: 2018/12/13 19:07:54 ******/
  288. SET ANSI_NULLS ON
  289. GO
  290. SET QUOTED_IDENTIFIER ON
  291. GO
  292. --#####################################################
  293. --创建时间:2014.11.6
  294. --创建人:Nick
  295. --说明:修改mode
  296. --#####################################################
  297. CREATE PROCEDURE [dbo].[mblPaMainRegisterModeUpdate]
  298. (
  299. @RegisterMode INT,
  300. @ID INT
  301. )
  302. AS
  303. BEGIN
  304. UPDATE pamain SET RegisterMode=@RegisterMode WHERE id=@ID
  305. END
  306. GO
  307. /****** Object: StoredProcedure [dbo].[mblPaMainSelect] Script Date: 2018/12/13 19:07:54 ******/
  308. SET ANSI_NULLS ON
  309. GO
  310. SET QUOTED_IDENTIFIER ON
  311. GO
  312. CREATE PROCEDURE [dbo].[mblPaMainSelect]
  313. @ID INT
  314. AS
  315. BEGIN
  316. SELECT 1 dcCareerStatus,a.*, b.FullName LiveRegion, c.FullName GrowRegion, d.FullName AccountRegion, ISNULL(e.Description,'目前处于离职状态,可即刻上岗') CareerStatus, f.PhotoProcessed,
  317. (SELECT TOP 1 LoginIP FROM paLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = a.ID ORDER BY ID DESC) AS LastLoginIP,
  318. (SELECT COUNT(1) FROM paLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = a.ID AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)) AS TodayLoginNum
  319. FROM paMain a WITH(NOLOCK INDEX(PK_paMain))
  320. LEFT JOIN dcRegion b WITH(NOLOCK) ON a.LivePlace=b.ID
  321. LEFT JOIN dcRegion c WITH(NOLOCK) ON a.GrowPlace=c.ID
  322. LEFT JOIN dcRegion d WITH(NOLOCK) ON a.AccountPlace=d.ID
  323. LEFT JOIN dcCareerStatus e WITH(NOLOCK) ON a.dcCareerStatus=e.ID
  324. LEFT JOIN paPhoto f WITH(NOLOCK) ON a.HasPhoto<2 AND a.ID=f.paMainID
  325. WHERE a.ID=@ID
  326. END
  327. GO
  328. /****** Object: StoredProcedure [dbo].[mblPaMainUpdate] Script Date: 2018/12/13 19:07:54 ******/
  329. SET ANSI_NULLS ON
  330. GO
  331. SET QUOTED_IDENTIFIER ON
  332. GO
  333. --修改harry 2018-7-5 处理liveplace等
  334. CREATE PROCEDURE [dbo].[mblPaMainUpdate]
  335. (
  336. @paMainID INT,
  337. @cvMainID INT,
  338. @Name VARCHAR(30),
  339. @Gender BIT,
  340. @BirthDay INT,
  341. @LivePlace VARCHAR(6),
  342. @AccountPlace VARCHAR(6),
  343. @GrowPlace VARCHAR(6),
  344. @Mobile VARCHAR(13),
  345. @dcCareerStatus TINYINT,
  346. @IP VARCHAR(39)
  347. )
  348. AS
  349. IF ISNULL(@paMainID, 0) = 0
  350. RETURN -1
  351. IF dbo.TrimNULL(@Name) IS NULL
  352. RETURN -1
  353. IF dbo.TrimNULL(@Mobile) IS NULL
  354. RETURN -1
  355. IF CHARINDEX(' ', @LivePlace) >2
  356. BEGIN
  357. SET @LivePlace=substring(@LivePlace,1,charindex(' ',@LivePlace)-1)
  358. END
  359. IF CHARINDEX(' ', @AccountPlace) >2
  360. BEGIN
  361. SET @AccountPlace=substring(@AccountPlace,1,charindex(' ',@AccountPlace)-1)
  362. END
  363. IF CHARINDEX(' ', @GrowPlace) >2
  364. BEGIN
  365. SET @GrowPlace=substring(@GrowPlace,1,charindex(' ',@GrowPlace)-1)
  366. END
  367. IF EXISTS(SELECT 'x' FROM Person_BLACK WITH(NOLOCK) WHERE Mobile = @Mobile)
  368. BEGIN
  369. ----有黑名单,则增加拒绝次数
  370. UPDATE Person_Black SET RefuseCount = RefuseCount + 1 WHERE Mobile = @Mobile
  371. RETURN -1
  372. END
  373. BEGIN TRAN
  374. BEGIN TRY
  375. DECLARE @NameOld AS VARCHAR(12)
  376. DECLARE @MobileOld AS VARCHAR(13)
  377. DECLARE @Modify AS INT
  378. -- @Modify=-1未修改需审核项, @Modify=0修改中文项目; @Modify=1修改了英文项目
  379. SET @Modify=-1
  380. --获得原始数据
  381. SELECT @NameOld=Name,@MobileOld=Mobile
  382. FROM paMain WITH(NOLOCK INDEX(PK_paMain))
  383. WHERE ID = @paMainID
  384. DECLARE @CNAME AS VARCHAR(12)
  385. SET @CNAME = @Name
  386. IF @BirthDay!=0
  387. BEGIN
  388. UPDATE paMain
  389. SET Name=@CNAME,
  390. Gender=@Gender,
  391. BirthDay=@BirthDay,
  392. LivePlace=@LivePlace,
  393. AccountPlace=@AccountPlace,
  394. GrowPlace=@GrowPlace,
  395. Mobile=@Mobile,
  396. dcCareerStatus=@dcCareerStatus,
  397. LastModifyDate=GETDATE()
  398. WHERE ID=@paMainID
  399. END
  400. --保存到bsCvModify,姓名
  401. IF ISNULL(@NameOld, '') <> @CNAME
  402. BEGIN
  403. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac1'
  404. INSERT INTO bsCvModify(paMainID,Location,ColValue) VALUES(@paMainID,'ac1',@CNAME)
  405. SET @Modify=0
  406. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  407. VALUES(@paMainID, 30,'更新姓名,原姓名:<' + ISNULL(@NameOld, '') + '>;新姓名:<' + @CName + '>', @IP)
  408. END
  409. --手机号码
  410. IF ISNULL(@MobileOld, '') <> @Mobile
  411. BEGIN
  412. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac4'
  413. --INSERT INTO bsCvModify(paMainID,Location,ColValue) VALUES(@paMainID,'ac4',@Mobile)
  414. --SET @Modify=0
  415. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  416. VALUES(@paMainID, 35,'更新手机号,原手机号:<' + ISNULL(@MobileOld, '') + '>;新手机号:<' + @Mobile + '>', @IP)
  417. END
  418. ----修改cvMain.cvLevel
  419. UPDATE cvMain SET cvLevel='11' + RIGHT(cvLevel,8) WHERE paMainID = @paMainID
  420. --1小时内不重复刷新,防止刷新排名
  421. UPDATE cvmain SET RefreshDate = GETDATE() WHERE ID=@cvMainID AND DATEADD(HOUR, 1, RefreshDate) < GETDATE() AND paMainID = @paMainID
  422. ----12小时内只保留一次修改记录
  423. DELETE FROM paOperationLog WHERE paMainID=@paMainID AND Operation=11 AND AddDate>GETDATE()-0.5
  424. INSERT INTO paOperationLog (paMainID,Operation,Details,IP) VALUES(@paMainID,11,'更新基本信息成功。',@IP)
  425. END TRY
  426. BEGIN CATCH
  427. GOTO ERR
  428. END CATCH
  429. COMMIT TRAN
  430. RETURN 1
  431. ERR:
  432. BEGIN
  433. ROLLBACK TRAN
  434. RETURN 0
  435. END
  436. GO
  437. /****** Object: StoredProcedure [dbo].[mblPaMainUpdate20171110] Script Date: 2018/12/13 19:07:55 ******/
  438. SET ANSI_NULLS ON
  439. GO
  440. SET QUOTED_IDENTIFIER ON
  441. GO
  442. --修改harry 2018-7-5 处理liveplace等
  443. CREATE PROCEDURE [dbo].[mblPaMainUpdate20171110]
  444. (
  445. @paMainID INT,
  446. @cvMainID INT,
  447. @Name VARCHAR(30),
  448. @Gender BIT,
  449. @BirthDay INT,
  450. @LivePlace VARCHAR(6),
  451. @AccountPlace VARCHAR(6),
  452. @GrowPlace VARCHAR(6),
  453. @Mobile VARCHAR(13),
  454. @dcCareerStatus TINYINT,
  455. @IP VARCHAR(39),
  456. @dcMapPlaceID INT
  457. )
  458. AS
  459. IF ISNULL(@paMainID, 0) = 0
  460. RETURN -1
  461. IF dbo.TrimNULL(@Name) IS NULL
  462. RETURN -1
  463. IF dbo.TrimNULL(@Mobile) IS NULL
  464. RETURN -1
  465. IF EXISTS(SELECT 'x' FROM Person_BLACK WITH(NOLOCK) WHERE Mobile = @Mobile)
  466. BEGIN
  467. ----有黑名单,则增加拒绝次数
  468. UPDATE Person_Black SET RefuseCount = RefuseCount + 1 WHERE Mobile = @Mobile
  469. RETURN -1
  470. END
  471. BEGIN TRAN
  472. BEGIN TRY
  473. IF CHARINDEX(' ', @LivePlace) >2
  474. BEGIN
  475. SET @LivePlace=substring(@LivePlace,1,charindex(' ',@LivePlace)-1)
  476. END
  477. IF CHARINDEX(' ', @AccountPlace) >2
  478. BEGIN
  479. SET @AccountPlace=substring(@AccountPlace,1,charindex(' ',@AccountPlace)-1)
  480. END
  481. IF CHARINDEX(' ', @GrowPlace) >2
  482. BEGIN
  483. SET @GrowPlace=substring(@GrowPlace,1,charindex(' ',@GrowPlace)-1)
  484. END
  485. DECLARE @NameOld AS VARCHAR(12)
  486. DECLARE @MobileOld AS VARCHAR(13)
  487. DECLARE @Modify AS INT
  488. -- @Modify=-1未修改需审核项, @Modify=0修改中文项目; @Modify=1修改了英文项目
  489. SET @Modify=-1
  490. --获得原始数据
  491. SELECT @NameOld=Name,@MobileOld=Mobile
  492. FROM paMain WITH(NOLOCK INDEX(PK_paMain))
  493. WHERE ID = @paMainID
  494. DECLARE @CNAME AS VARCHAR(12)
  495. SET @CNAME = @Name
  496. UPDATE paMain
  497. SET Name=@CNAME,
  498. Gender=@Gender,
  499. BirthDay=@BirthDay,
  500. LivePlace=@LivePlace,
  501. AccountPlace=@AccountPlace,
  502. GrowPlace=@GrowPlace,
  503. Mobile=@Mobile,
  504. dcMapPlaceID=@dcMapPlaceID,
  505. --dcCareerStatus#@dcCareerStatus,
  506. LastModifyDate=GETDATE()
  507. WHERE ID=@paMainID
  508. --保存到bsCvModify,姓名
  509. IF ISNULL(@NameOld, '') <> @CNAME
  510. BEGIN
  511. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac1'
  512. INSERT INTO bsCvModify(paMainID,Location,ColValue) VALUES(@paMainID,'ac1',@CNAME)
  513. SET @Modify=0
  514. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  515. VALUES(@paMainID, 30,'更新姓名,原姓名:<' + ISNULL(@NameOld, '') + '>;新姓名:<' + @CName + '>', @IP)
  516. END
  517. --手机号码
  518. IF ISNULL(@MobileOld, '') <> @Mobile
  519. BEGIN
  520. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac4'
  521. --INSERT INTO bsCvModify(paMainID,Location,ColValue) VALUES(@paMainID,'ac4',@Mobile)
  522. --SET @Modify=0
  523. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  524. VALUES(@paMainID, 35,'更新手机号,原手机号:<' + ISNULL(@MobileOld, '') + '>;新手机号:<' + @Mobile + '>', @IP)
  525. END
  526. ----修改cvMain.cvLevel
  527. UPDATE cvMain SET cvLevel='11' + RIGHT(cvLevel,8) WHERE paMainID = @paMainID
  528. --1小时内不重复刷新,防止刷新排名
  529. UPDATE cvmain SET RefreshDate = GETDATE() WHERE ID=@cvMainID AND DATEADD(HOUR, 1, RefreshDate) < GETDATE() AND paMainID = @paMainID
  530. ----12小时内只保留一次修改记录
  531. DELETE FROM paOperationLog WHERE paMainID=@paMainID AND Operation=11 AND AddDate>GETDATE()-0.5
  532. INSERT INTO paOperationLog (paMainID,Operation,Details,IP) VALUES(@paMainID,11,'更新基本信息成功。',@IP)
  533. END TRY
  534. BEGIN CATCH
  535. GOTO ERR
  536. END CATCH
  537. COMMIT TRAN
  538. RETURN 1
  539. ERR:
  540. BEGIN
  541. ROLLBACK TRAN
  542. RETURN 0
  543. END
  544. GO
  545. /****** Object: StoredProcedure [dbo].[mblPaPageViewLogByNoViewSelect] Script Date: 2018/12/13 19:07:55 ******/
  546. SET ANSI_NULLS ON
  547. GO
  548. SET QUOTED_IDENTIFIER ON
  549. GO
  550. CREATE PROCEDURE [dbo].[mblPaPageViewLogByNoViewSelect]
  551. (
  552. @PaMainID INT,
  553. @PageType INT --页面类型1 页脚 2 Notice页面
  554. )
  555. AS
  556. SET NOCOUNT ON
  557. IF @paMainID = 0
  558. RETURN
  559. BEGIN
  560. IF NOT EXISTS(SELECT 'x' FROM paPageViewLog WITH(NOLOCK) WHERE paMainId = @PaMainID)
  561. BEGIN
  562. INSERT INTO paPageViewLog(paMainId,addDate,InterviewDate,IntentionDate,ViewLogDate,AttentionDate,YourFoodDate,ApplyReplyDate)
  563. VALUES(@PaMainID, GETDATE() - 10, GETDATE() - 10, GETDATE() - 10, GETDATE() - 10, GETDATE() - 10, GETDATE() - 10, GETDATE() - 10)
  564. --RETURN
  565. END
  566. DECLARE @AddDate DATETIME, @InterviewDate DATETIME, @IntentionDate DATETIME,
  567. @ViewLogDate DATETIME, @AttentionDate DATETIME, @YourFoodDate DATETIME,
  568. @ApplyReplyDate DATETIME, @ChangeCount INT, @CvViewLogCount INT,
  569. @YourFoodCount INT,@JobAppliedCount INT, @InterviewCount INT,
  570. @CpInvitationCount INT, @ChatCount INT
  571. SELECT @AddDate = AddDate, @InterviewDate = ISNULL(InterviewDate, GETDATE() - 10),
  572. @IntentionDate = ISNULL(IntentionDate, GETDATE() - 10),
  573. @ViewLogDate = ISNULL(ViewLogDate, GETDATE() - 10),
  574. @AttentionDate = ISNULL(AttentionDate, GETDATE() - 10),
  575. @YourFoodDate = ISNULL(YourFoodDate, GETDATE() - 10),
  576. @ApplyReplyDate = ISNULL(ApplyReplyDate, GETDATE() - 10),
  577. @ChangeCount = ISNULL(MyAttentionCount, 0),
  578. @CvViewLogCount = ISNULL(CvViewLogCount, 0),
  579. @YourFoodCount = ISNULL(YourFoodCount, 0),
  580. @JobAppliedCount = ISNULL(JobAppliedCount, 0),
  581. @InterviewCount = ISNULL(InterviewCount, 0),
  582. @CpInvitationCount = ISNULL(CpInvitationCount, 0),
  583. @ChatCount = ISNULL(ChatCount, 0)
  584. FROM paPageViewLog WITH(NOLOCK)
  585. WHERE paMainId = @PaMainID
  586. SELECT ID
  587. INTO #TCvIDs
  588. FROM cvMain WITH(NOLOCK)
  589. WHERE paMainID = @PaMainID
  590. --更新时间超过1个小时的,重新计算提醒内容
  591. IF GETDATE() > DATEADD(MINUTE, 60, @AddDate) --60分钟内的不重新生成
  592. BEGIN
  593. --我的关注
  594. SELECT AttentionID, AttentionType
  595. INTO #TAttention
  596. FROM PaAttention WITH(NOLOCK)
  597. WHERE PaMainID = @PaMainID
  598. --职位有更新数量
  599. SELECT @ChangeCount = COUNT(1)
  600. FROM Job WITH(NOLOCK)
  601. WHERE CpMainID IN (SELECT AttentionID
  602. FROM #TAttention WHERE AttentionType = 1)
  603. AND AddDate > @AttentionDate
  604. SELECT @ChangeCount = COUNT(1) + @ChangeCount
  605. FROM Job WITH(NOLOCK)
  606. WHERE ID IN (SELECT AttentionID
  607. FROM #TAttention WHERE AttentionType = 2)
  608. AND IssueEnd > @AttentionDate
  609. AND IssueEnd < GETDATE()
  610. --新环境照片数量
  611. SELECT @ChangeCount = COUNT(1) + @ChangeCount
  612. FROM cpImage WITH(NOLOCK)
  613. WHERE cpMainID IN (SELECT AttentionID FROM #TAttention WHERE AttentionType = 1)
  614. AND ImgType = 3
  615. AND CheckDate > @AttentionDate
  616. AND HasPassed = 1
  617. --删除临时表
  618. DROP TABLE #TAttention
  619. --更新简历浏览量
  620. SELECT @CvViewLogCount = COUNT(1)
  621. FROM caCvViewLog WITH(NOLOCK)
  622. WHERE cvMainID IN(SELECT ID FROM #TCvIDs)
  623. AND AddDate > @ViewLogDate
  624. --更新你的菜儿数量
  625. SELECT @YourFoodCount=COUNT(1)
  626. FROM PaJobCompare WITH(NOLOCK)
  627. WHERE PaMainID = @PaMainID
  628. AND AddDate > @YourFoodDate
  629. --申请的职位
  630. SELECT @JobAppliedCount=count(1)
  631. FROM exJobApply a WITH(NOLOCK)
  632. WHERE a.cvMainID IN(
  633. SELECT ID FROM #TCvIDs
  634. )
  635. AND a.ReplyDate > @ApplyReplyDate
  636. --面试通知
  637. SELECT @InterviewCount=COUNT(1)
  638. FROM exInterview a WITH(NOLOCK)
  639. WHERE a.cvMainID IN(
  640. SELECT ID FROM #TCvIDs
  641. )
  642. AND a.AddDate > @InterviewDate
  643. --应聘邀请
  644. SELECT @CpInvitationCount=COUNT(1)
  645. FROM caCvIntention a WITH(NOLOCK)
  646. WHERE a.cvMainID IN(
  647. SELECT ID FROM #TCvIDs
  648. )
  649. AND a.AddDate > @IntentionDate
  650. --聊天记录
  651. SELECT @ChatCount=COUNT(1)
  652. FROM ChatOnlineLog a WITH(NOLOCK)
  653. LEFT JOIN ChatOnline b WITH(NOLOCK) ON a.ChatOnlineID = b.ID
  654. WHERE b.cvMainID IN(
  655. SELECT ID FROM #TCvIDs
  656. )
  657. AND a.IsViewed = 0
  658. AND a.SenderType = 1
  659. --更新添加时间
  660. UPDATE paPageViewLog
  661. SET AddDate = GETDATE(),
  662. MyAttentionCount = @ChangeCount,
  663. CvViewLogCount = @CvViewLogCount,
  664. YourFoodCount = @YourFoodCount,
  665. JobAppliedCount =@JobAppliedCount,
  666. InterviewCount=@InterviewCount,
  667. CpInvitationCount=@CpInvitationCount,
  668. ChatCount = @ChatCount
  669. WHERE paMainId = @PaMainID
  670. END
  671. SELECT * FROM paPageViewLog WHERE paMainId = @PaMainID --查询表内容
  672. IF @PageType = 2 --通知页面-页脚不查询其他表内容
  673. BEGIN --通知页面
  674. --申请的职位
  675. IF @JobAppliedCount > 0
  676. SELECT TOP 1 a.Reply, a.ReplyDate, c.Name cpName
  677. FROM exJobApply a WITH(NOLOCK)
  678. LEFT JOIN Job b WITH(NOLOCK) ON b.ID = a.JobID
  679. LEFT JOIN CpMain c WITH(NOLOCK) ON c.ID = b.CpMainID
  680. WHERE a.cvMainID IN(
  681. SELECT ID FROM #TCvIDs
  682. )
  683. AND a.ReplyDate > @ApplyReplyDate
  684. ORDER BY a.ReplyDate DESC
  685. ELSE
  686. SELECT TOP 0 ''Reply,'' ReplyDate,'' cpName
  687. --面试通知
  688. IF @InterviewCount>0
  689. SELECT TOP 1 c.Name cpName, a.AddDate
  690. FROM exInterview a WITH(NOLOCK)
  691. LEFT JOIN Job b WITH(NOLOCK) ON b.ID = a.JobID
  692. LEFT JOIN CpMain c WITH(NOLOCK) ON c.ID = b.CpMainID
  693. WHERE a.cvMainID IN(
  694. SELECT ID FROM #TCvIDs
  695. )
  696. AND a.AddDate > @InterviewDate
  697. ORDER BY a.AddDate DESC
  698. ELSE
  699. SELECT TOP 0 '' cpName,'' AddDate
  700. --应聘邀请
  701. IF @CpInvitationCount > 0
  702. SELECT TOP 1 c.Name CpName, b.Name JobName, a.AddDate
  703. FROM caCvIntention a WITH(NOLOCK)
  704. LEFT JOIN Job b WITH(NOLOCK) ON b.ID = a.JobID
  705. LEFT JOIN CpMain c WITH(NOLOCK) ON c.ID = b.CpMainID
  706. WHERE a.cvMainID IN(
  707. SELECT ID FROM #TCvIDs
  708. )
  709. AND a.AddDate > @IntentionDate
  710. ORDER BY a.AddDate DESC
  711. ELSE
  712. SELECT TOP 0 '' CpName,'' JobName,'' AddDate
  713. --聊天记录
  714. IF @ChatCount > 0
  715. SELECT TOP 1 a.Message, a.AddDate, d.Name CpName
  716. FROM ChatOnlineLog a WITH(NOLOCK)
  717. LEFT JOIN ChatOnline b WITH(NOLOCK) ON a.ChatOnlineID = b.ID
  718. LEFT JOIN caMain c WITH(NOLOCK) ON c.ID = b.caMainID
  719. LEFT JOIN cpMain d WITH(NOLOCK) ON d.ID = c.cpMainID
  720. WHERE b.cvMainID IN(SELECT ID FROM #TCvIDs)
  721. AND a.IsViewed = 0
  722. AND a.SenderType = 1
  723. AND b.AddDate > GETDATE() - 7
  724. ORDER BY a.AddDate Desc
  725. ELSE
  726. SELECT TOP 0 '' [Message],'' AddDate,''CpName
  727. --谁在关注我
  728. IF @CvViewLogCount > 0
  729. SELECT TOP 1 c.Name CpName, a.AddDate
  730. FROM caCvViewLog a WITH(NOLOCK)
  731. INNER JOIN caMain b WITH(NOLOCK) ON a.caMainID = b.ID
  732. INNER JOIN cpMain c WITH(NOLOCK) ON b.cpMainID = c.ID
  733. WHERE a.cvMainID IN(SELECT ID FROM #TCvIDs)
  734. ORDER BY a.AddDate DESC
  735. ELSE
  736. SELECT TOP 0 '' AddDate,''CpName
  737. IF @ChangeCount > 0
  738. BEGIN
  739. SELECT AttentionID, AttentionType
  740. INTO #TAttention2
  741. FROM PaAttention WITH(NOLOCK)
  742. WHERE PaMainID = @PaMainID
  743. CREATE TABLE #TAttentionModify
  744. (
  745. ModifyDesc NVARCHAR(100),
  746. ModifyDate DATETIME
  747. )
  748. --企业新增职位了
  749. INSERT INTO #TAttentionModify(ModifyDesc,ModifyDate)
  750. SELECT TOP 1 '您关注的企业“' + b.Name + '”发布了新的职位' ModifyDesc,AddDate
  751. FROM Job a WITH(NOLOCK)
  752. LEFT JOIN CpMain b WITH(NOLOCK) ON b.ID = a.CpMainID
  753. WHERE CpMainID IN (SELECT AttentionID FROM #TAttention2 WHERE AttentionType = 1)
  754. ORDER BY AddDate DESC
  755. --职位截止
  756. INSERT INTO #TAttentionModify(ModifyDesc,ModifyDate)
  757. SELECT TOP 1 '您关注的职位“' + Name + '”已经过期' ModifyDesc,IssueEnd
  758. FROM Job WITH(NOLOCK)
  759. WHERE ID IN (SELECT AttentionID FROM #TAttention2 WHERE AttentionType = 2)
  760. AND IssueEnd < GETDATE()
  761. ORDER BY IssueEnd DESC
  762. INSERT INTO #TAttentionModify(ModifyDesc,ModifyDate)
  763. SELECT TOP 1 '您关注的企业“' + b.Name + '”上传了新的环境照片' ModifyDesc,CheckDate
  764. FROM cpImage a WITH(NOLOCK)
  765. LEFT JOIN CpMain b WITH(NOLOCK) ON b.ID = a.CpMainID
  766. WHERE cpMainID IN (SELECT AttentionID FROM #TAttention2 WHERE AttentionType = 1)
  767. AND ImgType = 3
  768. AND HasPassed = 1
  769. ORDER BY CheckDate DESC
  770. SELECT TOP 1 *
  771. FROM #TAttentionModify
  772. ORDER BY ModifyDate DESC
  773. DROP TABLE #TAttention2
  774. DROP TABLE #TAttentionModify
  775. END
  776. ELSE
  777. BEGIN
  778. SELECT TOP 0 '' ModifyDesc,'' ModifyDate
  779. END
  780. IF @YourFoodCount > 0
  781. BEGIN
  782. SELECT TOP 1 AddDate
  783. FROM paYourfood WITH(NOLOCK)
  784. WHERE PaMainID = @PaMainID
  785. ORDER BY AddDate DESC
  786. END
  787. ELSE
  788. BEGIN
  789. SELECT TOP 0 '' AddDate
  790. END
  791. END
  792. DROP TABLE #TCvIDs
  793. END
  794. GO
  795. /****** Object: StoredProcedure [dbo].[mblpaPhotoInsert] Script Date: 2018/12/13 19:07:56 ******/
  796. SET ANSI_NULLS ON
  797. GO
  798. SET QUOTED_IDENTIFIER ON
  799. GO
  800. CREATE PROCEDURE [dbo].[mblpaPhotoInsert]
  801. @paMainID INT,
  802. @Photo VARCHAR(50)
  803. AS
  804. BEGIN TRAN
  805. BEGIN TRY
  806. DELETE FROM paPhoto WHERE paMainID=@paMainID
  807. UPDATE paMain SET HasPhoto=0 WHERE ID=@paMainID
  808. INSERT INTO paPhoto (paMainID,Photo,PhotoProcessed) VALUES(@paMainID,@Photo,@Photo)
  809. INSERT INTO paOperationLog (paMainID,Operation,Details,IP)
  810. VALUES(@paMainID,40,'更新照片', '')
  811. END TRY
  812. BEGIN CATCH
  813. GOTO ERR
  814. END CATCH
  815. COMMIT TRAN
  816. RETURN 1
  817. ERR:
  818. BEGIN
  819. ROLLBACK TRAN
  820. RETURN 0
  821. END
  822. GO
  823. /****** Object: StoredProcedure [dbo].[mblPaPushLogSelect] Script Date: 2018/12/13 19:07:56 ******/
  824. SET ANSI_NULLS ON
  825. GO
  826. SET QUOTED_IDENTIFIER ON
  827. GO
  828. --读取未推送的消息
  829. --Lucifer 20160217
  830. --修改Harry 2018-6-11 增加企业推送9,10,11,12,13
  831. CREATE PROCEDURE [dbo].[mblPaPushLogSelect]
  832. AS
  833. BEGIN
  834. SELECT TOP 0 a.ID, a.PushMessage, a.PushType, a.DetailID, b.UniqueID, b.ClientType
  835. INTO #t
  836. FROM paPushLog a WITH(NOLOCK), paIOSBind b WITH(NOLOCK)
  837. WHERE a.paMainID = b.paMainID
  838. AND a.PushDate IS NULL
  839. AND a.AddDate > DATEADD(MINUTE, -20, GETDATE())
  840. --企业
  841. INSERT INTO #t
  842. SELECT TOP 130 a.ID, a.PushMessage, a.PushType, a.DetailID, b.UniqueID, b.ClientType
  843. FROM paPushLog a WITH(NOLOCK), caIOSBind b WITH(NOLOCK)
  844. WHERE a.paMainID = b.caMainID
  845. AND a.PushDate IS NULL
  846. AND a.AddDate > DATEADD(MINUTE, -20, GETDATE())
  847. AND PushType IN(9,10,11,12,13)
  848. ORDER BY a.Id DESC
  849. --个人
  850. INSERT INTO #t
  851. SELECT TOP 130 a.ID, a.PushMessage, a.PushType, a.DetailID, b.UniqueID, b.ClientType
  852. FROM paPushLog a WITH(NOLOCK), paIOSBind b WITH(NOLOCK)
  853. WHERE a.paMainID = b.paMainID
  854. AND a.PushDate IS NULL
  855. --AND a.paMainID IN(26537325, 12222868, 26502145, 26533836)
  856. AND a.AddDate > DATEADD(MINUTE, -20, GETDATE())
  857. AND PushType NOT IN(9,10,11,12,13)
  858. ORDER BY a.Id DESC
  859. SELECT * FROM #t
  860. drop table #t
  861. END
  862. GO
  863. /****** Object: StoredProcedure [dbo].[mblPaPushLogUpdate] Script Date: 2018/12/13 19:07:56 ******/
  864. SET ANSI_NULLS ON
  865. GO
  866. SET QUOTED_IDENTIFIER ON
  867. GO
  868. --将推送的加上推送时间
  869. --Lucifer 20160217
  870. CREATE PROCEDURE [dbo].[mblPaPushLogUpdate]
  871. (
  872. @ID INT
  873. )
  874. AS
  875. BEGIN TRY
  876. UPDATE paPushLog SET PushDate = GETDATE() WHERE ID = @ID
  877. END TRY
  878. BEGIN CATCH
  879. END CATCH
  880. GO
  881. /****** Object: StoredProcedure [dbo].[mblProjectErrorLogInsert] Script Date: 2018/12/13 19:07:56 ******/
  882. SET ANSI_NULLS ON
  883. GO
  884. SET QUOTED_IDENTIFIER ON
  885. GO
  886. --#####################################################
  887. --创建时间:2014.11.7
  888. --创建人:Nick
  889. --说明:提交崩溃,错误日志信息
  890. --#####################################################
  891. CREATE PROCEDURE [dbo].[mblProjectErrorLogInsert]
  892. (
  893. @ProjectType VARCHAR(20),
  894. @ErrorType VARCHAR(20),
  895. @AccountID VARCHAR(20),
  896. @ErrorLog VARCHAR(MAX),
  897. @Ip VARCHAR(20)
  898. )
  899. AS
  900. BEGIN
  901. INSERT INTO ProjectErrorLog VALUES(@ProjectType,@ErrorType,@Ip,@AccountID,'','',@ErrorLog,GETDATE())
  902. END
  903. GO
  904. /****** Object: StoredProcedure [dbo].[mblProvinceSelect] Script Date: 2018/12/13 19:07:56 ******/
  905. SET ANSI_NULLS ON
  906. GO
  907. SET QUOTED_IDENTIFIER ON
  908. GO
  909. --#####################################################
  910. --创建时间:2014.11.7
  911. --创建人:Nick
  912. --说明:获取省份
  913. --#####################################################
  914. CREATE PROCEDURE [dbo].[mblProvinceSelect]
  915. AS
  916. BEGIN
  917. SELECT * FROM dcProvince WITH(NOLOCK)
  918. END
  919. GO
  920. /****** Object: StoredProcedure [dbo].[mblQlrcNewsByIDSelect] Script Date: 2018/12/13 19:07:57 ******/
  921. SET ANSI_NULLS ON
  922. GO
  923. SET QUOTED_IDENTIFIER ON
  924. GO
  925. --#####################################################
  926. --创建时间:2014.11.06
  927. --创建人:Nick
  928. --说明:获取新闻内容
  929. --#####################################################
  930. CREATE PROCEDURE [dbo].[mblQlrcNewsByIDSelect]
  931. (
  932. @ID INT
  933. )
  934. AS
  935. BEGIN TRY
  936. SELECT TOP 1 id,title,refreshdate,Appendix,AppendixName,Label tag,author,ViewNumber_All ViewNumber,
  937. REPLACE(REPLACE(REPLACE(Content,'</p><p style=\"text-indent:2em\">','<br> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'),'</p><p>','<br> <br>'),'<p style=\"text-indent:2em\">','&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;') Content
  938. FROM QlrcNews WITH(NOLOCK) WHERE ID=@ID
  939. END TRY
  940. BEGIN CATCH
  941. RETURN 0
  942. END CATCH
  943. GO
  944. /****** Object: StoredProcedure [dbo].[mblQlrcNewsByProvinceIDSelect] Script Date: 2018/12/13 19:07:57 ******/
  945. SET ANSI_NULLS ON
  946. GO
  947. SET QUOTED_IDENTIFIER ON
  948. GO
  949. --#####################################################
  950. --创建时间:2014.11.06
  951. --创建人:Nick
  952. --说明:最新热点7条
  953. --#####################################################
  954. CREATE PROCEDURE [dbo].[mblQlrcNewsByProvinceIDSelect]
  955. (
  956. @ProvinceID INT
  957. )
  958. AS
  959. BEGIN TRY
  960. SELECT TOP 7 * FROM qlrcnews
  961. WHERE VersionId=@ProvinceID AND smallImg!=''
  962. ORDER BY announcedate DESC
  963. END TRY
  964. BEGIN CATCH
  965. RETURN 0
  966. END CATCH
  967. GO
  968. /****** Object: StoredProcedure [dbo].[mblQlrcNewsMobileByIDSelect] Script Date: 2018/12/13 19:07:57 ******/
  969. SET ANSI_NULLS ON
  970. GO
  971. SET QUOTED_IDENTIFIER ON
  972. GO
  973. --#####################################################
  974. --创建时间:2014.11.06
  975. --创建人:Nick
  976. --说明:获取新闻内容
  977. --#####################################################
  978. CREATE PROCEDURE [dbo].[mblQlrcNewsMobileByIDSelect]
  979. (
  980. @ID INT
  981. )
  982. AS
  983. BEGIN
  984. SELECT TOP 1 id, title, refreshdate, Appendix, AppendixName, author, ViewNumber_All ViewNumber, Label, Content, VersionId
  985. FROM QlrcNews WITH(NOLOCK)
  986. WHERE ID = @ID
  987. END
  988. GO
  989. /****** Object: StoredProcedure [dbo].[mblRecruitmentByBeginTimeSelect] Script Date: 2018/12/13 19:07:57 ******/
  990. SET ANSI_NULLS ON
  991. GO
  992. SET QUOTED_IDENTIFIER ON
  993. GO
  994. --#####################################################
  995. --创建时间:2014.11.7
  996. --创建人:Nick
  997. --说明:返回在指定该日期内举办招聘会的场馆,不重复
  998. --#####################################################
  999. CREATE PROCEDURE [dbo].[mblRecruitmentByBeginTimeSelect]
  1000. (
  1001. @ProvinceID INT,
  1002. @STime VARCHAR(500)
  1003. )
  1004. AS
  1005. BEGIN
  1006. DECLARE @SQL VARCHAR(MAX)
  1007. SET @SQL = '
  1008. SELECT DISTINCT TOP 500 b.id ,b.PlaceName
  1009. FROM [MarketDb]..[Recruitment] a, [MarketDb]..[RmPlace] b
  1010. WHERE a.RecruitmentPlaceId=b.id AND a.IsPause=0
  1011. AND b.dcRegionID LIKE '''+CONVERT(VARCHAR(6),@ProvinceID)+'%''
  1012. ' + @STime
  1013. PRINT (@SQL)
  1014. EXEC (@SQL)
  1015. END
  1016. GO
  1017. /****** Object: StoredProcedure [dbo].[mblRecruitmentByProvinceIDSelect] Script Date: 2018/12/13 19:07:57 ******/
  1018. SET ANSI_NULLS ON
  1019. GO
  1020. SET QUOTED_IDENTIFIER ON
  1021. GO
  1022. --#####################################################
  1023. --创建时间:2014.11.7
  1024. --创建人:John
  1025. --说明:企业客户端获取招聘会列表
  1026. --#####################################################
  1027. CREATE PROCEDURE [dbo].[mblRecruitmentByProvinceIDSelect]
  1028. (
  1029. @ProvinceID VARCHAR(6)
  1030. )
  1031. AS
  1032. BEGIN
  1033. SELECT TOP 100 a.ID,RecruitmentName,BeginDate,PlaceName
  1034. FROM Recruitment a WITH(NOLOCK),RecruitmentPlace b WITH(NOLOCK)
  1035. WHERE RecruitmentPlaceID = b.ID
  1036. AND CityID LIKE @ProvinceID + '%'
  1037. AND EndDate > GETDATE()
  1038. AND IsPause = 0
  1039. ORDER BY IsCompanyTop DESC, orderby, a.ID DESC
  1040. END
  1041. GO
  1042. /****** Object: StoredProcedure [dbo].[mblRecruitmentList] Script Date: 2018/12/13 19:07:57 ******/
  1043. SET ANSI_NULLS ON
  1044. GO
  1045. SET QUOTED_IDENTIFIER ON
  1046. GO
  1047. CREATE PROCEDURE [dbo].[mblRecruitmentList]
  1048. (
  1049. @dcProvinceID AS SMALLINT,
  1050. @PageNum AS INT,
  1051. @PageSize AS INT
  1052. )
  1053. AS
  1054. BEGIN
  1055. SELECT *
  1056. FROM RecruitmentList
  1057. WHERE ProvinceID = @dcProvinceID
  1058. AND Rows BETWEEN (@PageNum - 1) * @PageSize + 1
  1059. AND @PageNum * @PageSize
  1060. ORDER BY Rows
  1061. END
  1062. GO
  1063. /****** Object: StoredProcedure [dbo].[mblRecruitmentList0715] Script Date: 2018/12/13 19:07:57 ******/
  1064. SET ANSI_NULLS ON
  1065. GO
  1066. SET QUOTED_IDENTIFIER ON
  1067. GO
  1068. CREATE PROCEDURE [dbo].[mblRecruitmentList0715]
  1069. (
  1070. @dcProvinceID AS SMALLINT,
  1071. @PageNum AS INT,
  1072. @PageSize AS INT
  1073. )
  1074. AS
  1075. BEGIN
  1076. DECLARE @COUNT INT
  1077. SELECT @COUNT = COUNT(*)
  1078. FROM Recruitment a, dcRegion b, RecruitmentPlace c, RecruitmentDept d
  1079. WHERE d.ID = a.RecruitmentDeptID AND d.ID <> 1767 AND b.ID = c.dcRegionID AND a.RecruitmentPlaceId = c.id
  1080. AND LEFT(c.dcRegionID, 2) = @dcProvinceID AND EndDate>GETDATE() AND a.IsPause = 0 AND Len(ManagerUserID)>0
  1081. IF @COUNT > 200
  1082. SET @COUNT = 200
  1083. SELECT *, @COUNT AS cnt
  1084. FROM (SELECT TOP 200 ROW_NUMBER() OVER(ORDER BY OrderBy, a.EndDate) AS Rows, a.ID, a.RecruitmentName, a.EndDate, a.BeginDate, c.PlaceName, c.Address, b.Description City
  1085. FROM Recruitment a, dcRegion b, RecruitmentPlace c, RecruitmentDept d
  1086. WHERE d.ID = a.RecruitmentDeptID AND d.ID<>1767 AND b.ID = c.dcRegionID AND a.RecruitmentPlaceId = c.id
  1087. AND LEFT(c.dcRegionID, 2) = @dcProvinceID AND EndDate>GETDATE() AND a.IsPause = 0 AND LEN(ManagerUserID)>0
  1088. ) AS a
  1089. WHERE a.Rows BETWEEN (@PageNum - 1) * @PageSize + 1 AND @PageNum * @PageSize ORDER BY Rows
  1090. END
  1091. GO
  1092. /****** Object: StoredProcedure [dbo].[mblRmInvitationCodeByCodeSelect] Script Date: 2018/12/13 19:07:58 ******/
  1093. SET ANSI_NULLS ON
  1094. GO
  1095. SET QUOTED_IDENTIFIER ON
  1096. GO
  1097. --#####################################################
  1098. --创建时间:2014.11.7
  1099. --创建人:Nick
  1100. --说明:获取招聘会邀请码
  1101. --#####################################################
  1102. CREATE PROCEDURE [dbo].[mblRmInvitationCodeByCodeSelect]
  1103. (
  1104. @Code VARCHAR(50)
  1105. )
  1106. AS
  1107. BEGIN
  1108. SELECT * FROM MarketDB..RmInvitationCode WITH(NOLOCK)
  1109. WHERE AddDate>DateAdd(Month,1,Getdate()) AND Code = @Code
  1110. END
  1111. GO
  1112. /****** Object: StoredProcedure [dbo].[mblRmInvitationCodeByIDUpdate] Script Date: 2018/12/13 19:07:58 ******/
  1113. SET ANSI_NULLS ON
  1114. GO
  1115. SET QUOTED_IDENTIFIER ON
  1116. GO
  1117. --#####################################################
  1118. --创建时间:2014.11.7
  1119. --创建人:Nick
  1120. --说明:获取招聘会邀请码
  1121. --#####################################################
  1122. CREATE PROCEDURE [dbo].[mblRmInvitationCodeByIDUpdate]
  1123. (
  1124. @ID INT,
  1125. @Mobile VARCHAR(20)
  1126. )
  1127. AS
  1128. BEGIN
  1129. UPDATE MarketDB..RmInvitationCode SET Mobile=@Mobile WHERE ID=@ID
  1130. END
  1131. GO
  1132. /****** Object: StoredProcedure [dbo].[mblRmInvitationCodeByPaMainIDSelect] Script Date: 2018/12/13 19:07:58 ******/
  1133. SET ANSI_NULLS ON
  1134. GO
  1135. SET QUOTED_IDENTIFIER ON
  1136. GO
  1137. --#####################################################
  1138. --创建时间:2014.11.06
  1139. --创建人:Nick
  1140. --说明:获取应聘邀请列表
  1141. --#####################################################
  1142. CREATE PROCEDURE [dbo].[mblRmInvitationCodeByPaMainIDSelect]
  1143. (
  1144. @Mobile VARCHAR(20),
  1145. @PamainID INT,
  1146. @Type INT
  1147. )
  1148. AS
  1149. BEGIN TRY
  1150. IF @Type = 1
  1151. BEGIN
  1152. SELECT TOP 1 ID,code
  1153. FROM MarketDB..RmInvitationCode WITH(NOLOCK)
  1154. WHERE AddDate>DateAdd(Month,-1,Getdate())
  1155. AND (mobile=@Mobile OR paMainID=@PamainID)
  1156. ORDER BY ID DESC
  1157. END
  1158. ELSE
  1159. BEGIN
  1160. SELECT TOP 1 ID,code
  1161. FROM MarketDB..RmInvitationCode WITH(NOLOCK)
  1162. WHERE AddDate>CONVERT(VARCHAR(10),Getdate(),120)
  1163. AND AddDate<dateAdd(n,-10,Getdate())
  1164. AND (mobile=@Mobile OR paMainID=@PamainID)
  1165. ORDER BY ID DESC
  1166. END
  1167. END TRY
  1168. BEGIN CATCH
  1169. RETURN 0
  1170. END CATCH
  1171. GO
  1172. /****** Object: StoredProcedure [dbo].[mblRmInvitationCodeInsert] Script Date: 2018/12/13 19:07:58 ******/
  1173. SET ANSI_NULLS ON
  1174. GO
  1175. SET QUOTED_IDENTIFIER ON
  1176. GO
  1177. --#####################################################
  1178. --创建时间:2014.11.7
  1179. --创建人:Nick
  1180. --说明:插入招聘会邀请码
  1181. --#####################################################
  1182. CREATE PROCEDURE [dbo].[mblRmInvitationCodeInsert]
  1183. (
  1184. @paMainID INT,
  1185. @mobile VARCHAR(20),
  1186. @code VARCHAR(20)
  1187. )
  1188. AS
  1189. BEGIN
  1190. INSERT INTO MarketDB..RmInvitationCode(paMainID,Mobile,code) VALUES(@paMainID,@mobile,@code)
  1191. END
  1192. GO
  1193. /****** Object: StoredProcedure [dbo].[mblSchoolNewsList] Script Date: 2018/12/13 19:07:58 ******/
  1194. SET ANSI_NULLS ON
  1195. GO
  1196. SET QUOTED_IDENTIFIER ON
  1197. GO
  1198. --修改显示招聘简章显示全部(过期和非过期的)top 200 Harry 2015-7-15
  1199. CREATE PROCEDURE [dbo].[mblSchoolNewsList]
  1200. (
  1201. @dcProvinceID AS SMALLINT,
  1202. @PageNum AS INT,
  1203. @PageSize AS INT
  1204. )
  1205. AS
  1206. BEGIN
  1207. DECLARE @COUNT INT
  1208. SELECT @COUNT = COUNT(1)
  1209. FROM marketdb..CampusBrochure a WITH(nolock),
  1210. marketdb..CampusBrochureSite b WITH(nolock)
  1211. WHERE a.id = b.CampusBrochure and b.dcSubSiteID = @dcProvinceID
  1212. IF @COUNT > 200
  1213. SET @COUNT = 200
  1214. SELECT *,@COUNT AS cnt
  1215. FROM (SELECT TOP 200 ROW_NUMBER() OVER(ORDER BY EndDate DESC, CASE a.id WHEN 7866 THEN 1 WHEN 7865 THEN 1 WHEN 7870 THEN 1 ELSE 2 END ,a.OrderBy ,AddDate desc) AS Rows,
  1216. a.id,a.Title,0 IsHot
  1217. FROM marketdb..CampusBrochure a WITH(NOLOCK),
  1218. marketdb..CampusBrochureSite b WITH(nolock)
  1219. WHERE a.id = b.CampusBrochure AND b.dcSubSiteID = @dcProvinceID
  1220. ) AS a
  1221. WHERE a.Rows BETWEEN (@PageNum-1) * @PageSize + 1 AND @PageNum * @PageSize ORDER BY Rows
  1222. END
  1223. GO
  1224. /****** Object: StoredProcedure [dbo].[mblSearchHistoryInsert] Script Date: 2018/12/13 19:07:58 ******/
  1225. SET ANSI_NULLS ON
  1226. GO
  1227. SET QUOTED_IDENTIFIER ON
  1228. GO
  1229. CREATE PROCEDURE [dbo].[mblSearchHistoryInsert]
  1230. (
  1231. @paMainId INT,
  1232. @Title VARCHAR(50),
  1233. @dcRegionId int,
  1234. @dcIndustryId int,
  1235. @dcJobTypeId int
  1236. )
  1237. AS
  1238. BEGIN TRY
  1239. INSERT INTO mblSearchHistory(paMainId, Title, dcRegionId, dcIndustryId, dcJobTypeId)
  1240. VALUES(@paMainId, @Title, @dcRegionId, @dcIndustryId, @dcJobTypeId)
  1241. RETURN 1
  1242. END TRY
  1243. BEGIN CATCH
  1244. RETURN 0
  1245. END CATCH
  1246. set ANSI_NULLS ON
  1247. set QUOTED_IDENTIFIER ON
  1248. GO
  1249. /****** Object: StoredProcedure [dbo].[mblSearchHistorySelect] Script Date: 2018/12/13 19:07:59 ******/
  1250. SET ANSI_NULLS ON
  1251. GO
  1252. SET QUOTED_IDENTIFIER ON
  1253. GO
  1254. CREATE PROCEDURE [dbo].[mblSearchHistorySelect]
  1255. (
  1256. @paMainId int
  1257. )
  1258. AS
  1259. BEGIN
  1260. SELECT TOP 30 * FROM mblSearchHistory WITH(NOLOCK) WHERE paMainId = @paMainId ORDER BY AddDate DESC
  1261. END
  1262. GO
  1263. /****** Object: StoredProcedure [dbo].[mblSearchKeywordByKeyWordSelect] Script Date: 2018/12/13 19:07:59 ******/
  1264. SET ANSI_NULLS ON
  1265. GO
  1266. SET QUOTED_IDENTIFIER ON
  1267. GO
  1268. --#####################################################
  1269. --创建时间:2014.11.06
  1270. --创建人:Nick
  1271. --说明:获取关键词
  1272. --#####################################################
  1273. CREATE PROCEDURE [dbo].[mblSearchKeywordByKeyWordSelect]
  1274. (
  1275. @key VARCHAR(200)
  1276. )
  1277. AS
  1278. BEGIN TRY
  1279. SELECT TOP 10 KeyType,KeyWord,KeyWordPinYin,SearchResult,SearchType
  1280. FROM searchdb..SearchKeyword WITH(NOLOCK)
  1281. WHERE (KeyWord LIKE @key+'%' OR KeyWordPinYin LIKE @key+'%')
  1282. ORDER BY SearchNumber DESC
  1283. END TRY
  1284. BEGIN CATCH
  1285. RETURN 0
  1286. END CATCH
  1287. GO
  1288. /****** Object: StoredProcedure [dbo].[mblSpreadRefererLogSessionUpdate] Script Date: 2018/12/13 19:07:59 ******/
  1289. SET ANSI_NULLS ON
  1290. GO
  1291. SET QUOTED_IDENTIFIER ON
  1292. GO
  1293. --#####################################################
  1294. --创建时间:2014.11.7
  1295. --创建人:John
  1296. --说明:更新sessionid,因为是主站跳转到m站的
  1297. --#####################################################
  1298. CREATE PROCEDURE [dbo].[mblSpreadRefererLogSessionUpdate]
  1299. (
  1300. @Id INT,
  1301. @sessionId VARCHAR(30)
  1302. )
  1303. AS
  1304. BEGIN
  1305. UPDATE SpreadRefererLog SET VisitType = 2, SessionId = @sessionId
  1306. WHERE VisitType = 1 AND RefererDate > DATEADD(MINUTE, -12, GETDATE()) AND SpreadLoginLogid = @Id
  1307. END
  1308. GO
  1309. /****** Object: StoredProcedure [dbo].[mblWeixinSave] Script Date: 2018/12/13 19:07:59 ******/
  1310. SET ANSI_NULLS ON
  1311. GO
  1312. SET QUOTED_IDENTIFIER ON
  1313. GO
  1314. CREATE PROCEDURE [dbo].[mblWeixinSave]
  1315. (
  1316. @Content NVARCHAR(300),
  1317. @Lat VARCHAR(20),
  1318. @Lng VARCHAR(20),
  1319. @FromUserName VARCHAR(50)
  1320. )
  1321. AS
  1322. BEGIN TRY
  1323. SET @Content = dbo.SafeSql(@Content)
  1324. DELETE FROM wxMessage WHERE FromUserName=@FromUserName
  1325. IF ISNULL(@Content,'')=''
  1326. BEGIN
  1327. INSERT INTO wxMessage(FromUserName,Lat,Lng,Content) VALUES
  1328. (@FromUserName,@Lat,@Lng,@Content)
  1329. END
  1330. ELSE
  1331. BEGIN
  1332. DECLARE @dcRegionID INT, @KeyWord NVARCHAR(20), @c NVARCHAR(50)
  1333. IF @Content LIKE '% %'
  1334. SET @c = LEFT(@Content, CHARINDEX(' ', @Content) - 1)
  1335. ELSE
  1336. SET @c = @Content
  1337. SELECT TOP 1 @dcRegionID = ID FROM dcRegion WITH(NOLOCK)
  1338. WHERE CHARINDEX(Abbr, @c)>0
  1339. ORDER BY ID DESC
  1340. IF ISNULL(@dcRegionID,0)=0
  1341. RETURN 0
  1342. SELECT @KeyWord=REPLACE(REPLACE(@Content,MapbarName,''),REPLACE(MapbarName,'市',''),'') FROM dcRegion WITH(NOLOCK) WHERE ID=@dcRegionID
  1343. SELECT @KeyWord=REPLACE(REPLACE(REPLACE(@KeyWord,Description,''),REPLACE(Description,'市',''),''),REPLACE(Description,'区',''),'') FROM dcRegion WITH(NOLOCK) WHERE ID=@dcRegionID
  1344. SELECT @KeyWord=REPLACE(REPLACE(@KeyWord,LEFT(FullName,CHARINDEX('省',FullName)),''),REPLACE(LEFT(FullName,CHARINDEX('省',FullName)),'省',''),'') FROM dcRegion WITH(NOLOCK) WHERE ID=@dcRegionID
  1345. SELECT @KeyWord=REPLACE(@KeyWord,' ','')
  1346. SELECT @KeyWord=REPLACE(@KeyWord,'+','')
  1347. INSERT INTO wxMessage(FromUserName,dcRegionID,KeyWord,Content) VALUES
  1348. (@FromUserName,@dcRegionID,@KeyWord,@Content)
  1349. END
  1350. RETURN 1
  1351. END TRY
  1352. BEGIN CATCH
  1353. RETURN 0
  1354. END CATCH
  1355. GO
  1356. /****** Object: StoredProcedure [dbo].[mblWeixinServiceSave] Script Date: 2018/12/13 19:07:59 ******/
  1357. SET ANSI_NULLS ON
  1358. GO
  1359. SET QUOTED_IDENTIFIER ON
  1360. GO
  1361. CREATE PROCEDURE [dbo].[mblWeixinServiceSave]
  1362. (
  1363. @Content NVARCHAR(50),
  1364. @Lat VARCHAR(20),
  1365. @Lng VARCHAR(20),
  1366. @FromUserName VARCHAR(50),
  1367. @ProvinceID int
  1368. )
  1369. AS
  1370. BEGIN TRY
  1371. IF(@Content<>'推荐职位')
  1372. BEGIN
  1373. DELETE FROM wxMessage WHERE FromUserName=@FromUserName AND CONTENT <>'推荐职位'
  1374. END
  1375. ELSE
  1376. BEGIN
  1377. DELETE FROM wxMessage WHERE FromUserName=@FromUserName
  1378. END
  1379. IF ISNULL(@Content,'')='' OR @Content='推荐职位'
  1380. BEGIN
  1381. INSERT INTO wxMessage(FromUserName,Lat,Lng,Content) VALUES
  1382. (@FromUserName,@Lat,@Lng,@Content)
  1383. END
  1384. ELSE
  1385. BEGIN
  1386. DECLARE @dcRegionID INT,@KeyWord NVARCHAR(20)
  1387. SELECT TOP 1 @dcRegionID=ID FROM dcRegion WITH(NOLOCK) WHERE
  1388. CHARINDEX(Description,@Content)>0 OR
  1389. CHARINDEX(REPLACE(Description,'市',''),@Content)>0 OR
  1390. CHARINDEX(REPLACE(Description,'省',''),@Content)>0
  1391. ORDER BY ID DESC
  1392. IF ISNULL(@dcRegionID,0)=0
  1393. SELECT @dcRegionID = @ProvinceID
  1394. SELECT @KeyWord=REPLACE(REPLACE(@Content,MapbarName,''),REPLACE(MapbarName,'市',''),'') FROM dcRegion WITH(NOLOCK) WHERE ID=@dcRegionID
  1395. SELECT @KeyWord=REPLACE(REPLACE(REPLACE(@KeyWord,Description,''),REPLACE(Description,'市',''),''),REPLACE(Description,'区',''),'') FROM dcRegion WITH(NOLOCK) WHERE ID=@dcRegionID
  1396. SELECT @KeyWord=REPLACE(REPLACE(@KeyWord,LEFT(FullName,CHARINDEX('省',FullName)),''),REPLACE(LEFT(FullName,CHARINDEX('省',FullName)),'省',''),'') FROM dcRegion WITH(NOLOCK) WHERE ID=@dcRegionID
  1397. SELECT @KeyWord=REPLACE(@KeyWord,' ','')
  1398. SELECT @KeyWord=REPLACE(@KeyWord,'+','')
  1399. INSERT INTO wxMessage(FromUserName,dcRegionID,KeyWord,Content) VALUES
  1400. (@FromUserName,@dcRegionID,@KeyWord,@Content)
  1401. END
  1402. RETURN 1
  1403. END TRY
  1404. BEGIN CATCH
  1405. RETURN 0
  1406. END CATCH
  1407. GO
  1408. /****** Object: StoredProcedure [dbo].[mblWxMessageSendSelect] Script Date: 2018/12/13 19:07:59 ******/
  1409. SET ANSI_NULLS ON
  1410. GO
  1411. SET QUOTED_IDENTIFIER ON
  1412. GO
  1413. --#####################################################
  1414. --创建时间:2015.2.26
  1415. --创建人:Nick
  1416. --说明:获取提醒信息
  1417. --#####################################################
  1418. CREATE PROCEDURE [dbo].[mblWxMessageSendSelect]
  1419. AS
  1420. BEGIN
  1421. SET NOCOUNT ON
  1422. SELECT senddate,a.ID,c.ID PaMainID,a.Message ContentText,b.OpenID,c.Name,e.ProvinceId,d.Token,e.AppID, e.AppSecret,f.No AS TemplateNo
  1423. FROM WxMessageSend a WITH(NOLOCK),WxFans b WITH(NOLOCK),PaMain c WITH(NOLOCK),dcWxtoken d WITH(NOLOCK), wxServiceNo e,WxTemplateno f
  1424. WHERE a.SendDate IS NULL
  1425. AND a.WxFansID = b.id
  1426. AND b.Status = 2
  1427. AND b.PaMainID = c.ID
  1428. AND c.IsWeiXinNotice = 1
  1429. AND b.wxServiceNoId = e.ID
  1430. AND e.ProvinceId = d.dcProvinceId
  1431. AND a.WxTemplatenoID = f.ID
  1432. ORDER BY a.ID DESC
  1433. SET NOCOUNT OFF
  1434. END
  1435. GO
  1436. /****** Object: StoredProcedure [dbo].[mblWXQrImageByIDUpdate] Script Date: 2018/12/13 19:08:00 ******/
  1437. SET ANSI_NULLS ON
  1438. GO
  1439. SET QUOTED_IDENTIFIER ON
  1440. GO
  1441. --#####################################################
  1442. --创建时间:2014.11.7
  1443. --创建人:Nick
  1444. --说明:根据ID修改WXQrImage
  1445. --#####################################################
  1446. CREATE PROCEDURE [dbo].[mblWXQrImageByIDUpdate]
  1447. (
  1448. @ID INT,
  1449. @Status INT,
  1450. @OpenID VARCHAR(50)
  1451. )
  1452. AS
  1453. BEGIN
  1454. UPDATE WXQrImage
  1455. SET Status = @Status, paMainID=(
  1456. SELECT TOP 1 paMainID
  1457. FROM palogincontact WITH(NOLOCK)
  1458. WHERE ContactType=4
  1459. AND Openid=@OpenID
  1460. ORDER BY id DESC
  1461. ) WHERE ID=@ID
  1462. END
  1463. GO
  1464. /****** Object: StoredProcedure [dbo].[mblWXQrImageByIDUpdateNew] Script Date: 2018/12/13 19:08:00 ******/
  1465. SET ANSI_NULLS ON
  1466. GO
  1467. SET QUOTED_IDENTIFIER ON
  1468. GO
  1469. --#####################################################
  1470. --创建时间:2016.4.7
  1471. --创建人:Lucifer
  1472. --说明:根据ID修改WXQrImage
  1473. --#####################################################
  1474. CREATE PROCEDURE [dbo].[mblWXQrImageByIDUpdateNew]
  1475. (
  1476. @ID INT,
  1477. @Status INT,
  1478. @OpenID VARCHAR(50),
  1479. @ContactType INT
  1480. )
  1481. AS
  1482. BEGIN
  1483. UPDATE WXQrImage
  1484. SET Status = @Status,
  1485. paMainID = (
  1486. SELECT TOP 1 paMainID
  1487. FROM paLoginContact WITH(NOLOCK)
  1488. WHERE ContactType = @ContactType
  1489. AND Openid = @OpenID
  1490. ORDER BY id DESC)
  1491. WHERE ID = @ID
  1492. END
  1493. GO
  1494. /****** Object: StoredProcedure [dbo].[mblWXQRIMAGEByOpenIDSelect] Script Date: 2018/12/13 19:08:01 ******/
  1495. SET ANSI_NULLS ON
  1496. GO
  1497. SET QUOTED_IDENTIFIER ON
  1498. GO
  1499. --#####################################################
  1500. --创建时间:2014.11.7
  1501. --创建人:Nick
  1502. --说明:根据ID查询WXQRIMAGE
  1503. --#####################################################
  1504. CREATE PROCEDURE [dbo].[mblWXQRIMAGEByOpenIDSelect]
  1505. (
  1506. @OpenID VARCHAR(50)
  1507. )
  1508. AS
  1509. INSERT INTO ProcLog SELECT 'mblWXQRIMAGEByOpenIDSelect', '', GETDATE()
  1510. BEGIN
  1511. SELECT TOP 1 *
  1512. FROM WXQRIMAGE
  1513. WHERE openid=@OpenID
  1514. AND pamainid IS NULL
  1515. ORDER BY id DESC
  1516. END
  1517. GO
  1518. /****** Object: StoredProcedure [dbo].[mblWXQrImageStatusUpdate] Script Date: 2018/12/13 19:08:01 ******/
  1519. SET ANSI_NULLS ON
  1520. GO
  1521. SET QUOTED_IDENTIFIER ON
  1522. GO
  1523. --#####################################################
  1524. --创建时间:2014.11.7
  1525. --创建人:Nick
  1526. --说明:修改 WXQrImage 状态
  1527. --#####################################################
  1528. CREATE PROCEDURE [dbo].[mblWXQrImageStatusUpdate]
  1529. (
  1530. @ID INT,
  1531. @Status INT,
  1532. @OpenID VARCHAR(50)
  1533. )
  1534. AS
  1535. INSERT INTO ProcLog SELECT 'mblWXQrImageStatusUpdate', @OpenID, GETDATE()
  1536. BEGIN
  1537. UPDATE WXQrImage
  1538. SET status=@Status
  1539. WHERE ID=@ID
  1540. AND paMainID=(
  1541. SELECT TOP 1 paMainID
  1542. FROM palogincontact WITH(NOLOCK)
  1543. WHERE ContactType=4
  1544. AND Openid=@OpenID
  1545. )
  1546. END
  1547. GO
  1548. /****** Object: StoredProcedure [dbo].[p_killspid] Script Date: 2018/12/13 19:08:01 ******/
  1549. SET ANSI_NULLS ON
  1550. GO
  1551. SET QUOTED_IDENTIFIER ON
  1552. GO
  1553. CREATE procedure [dbo].[p_killspid]
  1554. (
  1555. @dbname varchar(200) --要关闭进程的数据库名
  1556. )
  1557. as
  1558. begin
  1559. declare @sql nvarchar(500)
  1560. declare @spid nvarchar(20)
  1561. declare #tb cursor for
  1562. select spid=cast(spid as varchar(20)) from master..sysprocesses where dbid=db_id(@dbname)
  1563. open #tb
  1564. fetch next from #tb into @spid
  1565. while @@fetch_status=0
  1566. begin
  1567. print 'exec(kill ' + @spid + ') '
  1568. exec('kill '+@spid)
  1569. fetch next from #tb into @spid
  1570. end
  1571. close #tb
  1572. deallocate #tb
  1573. end
  1574. GO
  1575. /****** Object: StoredProcedure [dbo].[paCvTagsByCvMainIDSelect] Script Date: 2018/12/13 19:08:01 ******/
  1576. SET ANSI_NULLS ON
  1577. GO
  1578. SET QUOTED_IDENTIFIER ON
  1579. GO
  1580. --个人标签查询 Peter 2017-1-13
  1581. CREATE PROCEDURE [dbo].[paCvTagsByCvMainIDSelect]
  1582. (
  1583. @paMainID INT,
  1584. @cvMainID INT
  1585. )
  1586. AS
  1587. BEGIN
  1588. SELECT *
  1589. FROM CvTags WITH(NOLOCK)
  1590. WHERE cvMainID = @cvMainID
  1591. AND EXISTS(
  1592. SELECT 'x'
  1593. FROM cvMain
  1594. WHERE paMainID = @paMainID
  1595. AND id = @cvMainID)
  1596. END
  1597. GO
  1598. /****** Object: StoredProcedure [dbo].[paCvTagsSave] Script Date: 2018/12/13 19:08:01 ******/
  1599. SET ANSI_NULLS ON
  1600. GO
  1601. SET QUOTED_IDENTIFIER ON
  1602. GO
  1603. --个人标签保存 Peter 2017-1-13
  1604. CREATE PROCEDURE [dbo].[paCvTagsSave]
  1605. (
  1606. @paMainID INT,
  1607. @cvMainID INT,
  1608. @Tags NVARCHAR(1000)
  1609. )
  1610. AS
  1611. BEGIN
  1612. IF NOT EXISTS(SELECT 'x' FROM cvMain WHERE paMainID = @paMainID AND id = @cvMainID)
  1613. BEGIN
  1614. RETURN -1
  1615. END
  1616. DECLARE @TagsCount INT
  1617. SELECT @TagsCount = COUNT(1)
  1618. FROM dbo.fnSplit(@Tags,'@')
  1619. IF @TagsCount > 10
  1620. BEGIN
  1621. RETURN 0
  1622. END
  1623. DELETE FROM cvTags WHERE cvMainID = @cvMainID
  1624. CREATE TABLE #T(
  1625. cvMainID INT,
  1626. Tag NVARCHAR(20),
  1627. VerifyDate SMALLDATETIME
  1628. )
  1629. INSERT INTO #T(cvMainID,Tag)
  1630. SELECT @cvMainID cvMainID,a Tag
  1631. FROM dbo.fnSplit(@Tags,'@')
  1632. UPDATE #T
  1633. SET VerifyDate = GETDATE()
  1634. WHERE EXISTS(SELECT 'x' FROM paTagsMain WHERE Tag = #T.Tag)
  1635. INSERT INTO cvTags(cvMainID,Tags,VerifyDate)
  1636. SELECT *
  1637. FROM #T
  1638. DROP TABLE #T
  1639. RETURN 1
  1640. END
  1641. GO
  1642. /****** Object: StoredProcedure [dbo].[paJobByWeixinSelect] Script Date: 2018/12/13 19:08:01 ******/
  1643. SET ANSI_NULLS ON
  1644. GO
  1645. SET QUOTED_IDENTIFIER ON
  1646. GO
  1647. CREATE PROCEDURE [dbo].[paJobByWeixinSelect]
  1648. (
  1649. @FromUserName VARCHAR(50)
  1650. )
  1651. AS
  1652. --return
  1653. SET NOCOUNT ON
  1654. BEGIN TRY
  1655. SET @FromUserName = dbo.SafeSql(@FromUserName)
  1656. DECLARE @dcRegionID INT,@KeyWord NVARCHAR(20),
  1657. @Lng DECIMAL(8,5),@Lat DECIMAL(8,5),@Distance INT,
  1658. @KeyType TINYINT, @ValidJobNumber INT, @PageNumber SMALLINT
  1659. SELECT @dcRegionID=dcRegionID,@KeyWord=KeyWord,
  1660. @Lng=Lng,@Lat=Lat,@PageNumber=PageNumber
  1661. FROM wxMessage WITH(NOLOCK) WHERE FromUserName=@FromUserName
  1662. UPDATE wxMessage SET PageNumber=PageNumber+1 WHERE FromUserName=@FromUserName
  1663. SELECT @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, '')),
  1664. @KeyType = 2,
  1665. @Distance = 5000,
  1666. @PageNumber = ISNULL(@PageNumber, 1),
  1667. @dcRegionID = ISNULL(@dcRegionID, 0),
  1668. @Lng = ISNULL(@Lng, 0),
  1669. @Lat = ISNULL(@Lat, 0)
  1670. IF @dcRegionID = 0 AND @Lng = 0 AND @Lat = 0
  1671. RETURN
  1672. DECLARE @paSearchConditionID AS INT,
  1673. @MinId AS INT,
  1674. @PageSize AS TINYINT,
  1675. @TableID AS TINYINT
  1676. SELECT @paSearchConditionID = 0, @PageSize = 8 --每页的行数
  1677. ----搜索60分钟前的数据
  1678. SELECT TOP 1 @paSearchConditionID=ID FROM SearchDB..paSearchCondition WITH(NOLOCK)
  1679. WHERE JobType=''
  1680. AND JobPlace=@dcRegionID AND ISNULL(Industry,'')='' AND ISNULL(Education,'')=''
  1681. AND ISNULL(Experience,'')='' AND ISNULL(Salary,'')='' AND ISNULL(IsNegotiable,'')=''
  1682. AND ISNULL(EmployType,'')='' AND KeyWord=@KeyWord AND KeyType=@KeyType
  1683. AND ISNULL(CompanySizeID,'')='' AND Lng=@Lng AND Lat=@Lat
  1684. ORDER BY ID DESC
  1685. IF ISNULL(@paSearchConditionID, 0) = 0
  1686. BEGIN
  1687. GOTO SelectReset --无数据,重新搜索
  1688. END
  1689. ELSE
  1690. BEGIN
  1691. SELECT @TableID = @paSearchConditionID % 4
  1692. GOTO GetRecordSet --从临时结果中提取数据
  1693. END
  1694. SelectReset:
  1695. --从job中搜索数据
  1696. BEGIN TRAN
  1697. DECLARE @SQL AS VARCHAR(8000)
  1698. DECLARE @WHERE AS VARCHAR(8000)
  1699. DECLARE @FROM AS VARCHAR(1000)
  1700. ----记录查询条件
  1701. INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
  1702. Salary, IsNegotiable, EmployType, CompanySizeID, KeyWord, KeyType, ReuseNumber, Lng, Lat, Distance)
  1703. VALUES(1, GETDATE(), '', @dcRegionID, '', '', '', '', '', '', '', @KeyWord, @KeyType, 0, @Lng, @Lat, @Distance)
  1704. SET @paSearchConditionID = @@IDENTITY
  1705. SELECT @TableID = @paSearchConditionID % 4
  1706. ----建立临时表
  1707. CREATE TABLE #Job(
  1708. RowID INT IDENTITY(1, 1),
  1709. ID INT NOT NULL,
  1710. dcJobTypeID SMALLINT NOT NULL,
  1711. dcJobTypeIDMinor SMALLINT NULL,
  1712. dcSalaryID TINYINT NOT NULL,
  1713. dcRegionID VARCHAR(6) NULL,
  1714. dcEducationID TINYINT NOT NULL,
  1715. MinExperience TINYINT NOT NULL,
  1716. RefreshDate SMALLDATETIME NULL
  1717. )
  1718. ------刷新时间,根据刷新时间编号计算
  1719. ----生成插入临时表的Sql语句
  1720. SET @SQL='
  1721. INSERT INTO #Job
  1722. SELECT a.ID, a.dcJobTypeID,
  1723. a.dcJobTypeIDMinor, a.dcSalaryID,
  1724. a.dcRegionID, a.dcEducationID, a.MinExperience,
  1725. a.IssueDate'
  1726. SET @FROM = '
  1727. FROM JobPublish a WITH(NOLOCK)
  1728. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  1729. ----职位有效,单位新有效
  1730. SET @WHERE = '
  1731. WHERE a.Valid = 1
  1732. AND b.Valid = 1'
  1733. ----需要增加全文索引的关键字查询
  1734. IF @KeyWord LIKE '% %'
  1735. BEGIN
  1736. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  1737. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  1738. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  1739. SET @KeyWord = '"' + REPLACE(@KeyWord, ' ', '" OR "') + '"'
  1740. END
  1741. IF LEN(@KeyWord) > 0
  1742. BEGIN
  1743. IF @KeyType = 2
  1744. SET @FROM = @FROM + '
  1745. INNER JOIN CONTAINSTABLE(JobPublish, *, ''' + @KeyWord + ''', 1000000) AS KeyJob
  1746. ON a.ID = KeyJob.[Key]'
  1747. END
  1748. ---地区
  1749. IF @dcRegionID > 0
  1750. SET @WHERE = @WHERE + '
  1751. AND a.dcRegionID Like ''' + CONVERT(VARCHAR(6),@dcRegionID) + '%'''
  1752. IF @Lng > 0 AND @Lat > 0
  1753. BEGIN
  1754. DECLARE @Degree AS DECIMAL(8,5),@LBLng AS DECIMAL(8,5),@LBLat AS DECIMAL(8,5),
  1755. @RTLng AS DECIMAL(8,5),@RTLat AS DECIMAL(8,5)
  1756. SET @Degree = @Distance / 100000.0;
  1757. SET @LBLng = @Lng - @Degree
  1758. SET @LBLat = @Lat - @Degree
  1759. SET @RTLng = @Lng + @Degree
  1760. SET @RTLat = @Lat + @Degree
  1761. SET @WHERE = @WHERE + '
  1762. AND a.Lng BETWEEN ' + CONVERT(VARCHAR,@LBLng) + ' AND ' + CONVERT(VARCHAR,@RTLng) + '
  1763. AND a.Lat BETWEEN ' + CONVERT(VARCHAR,@LBLat) + ' AND ' + CONVERT(VARCHAR,@RTLat)
  1764. END
  1765. SET @SQL = @SQL + @FROM + @WHERE
  1766. SET @SQL=@SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
  1767. ----把符合条件的职位全部列出
  1768. --PRINT @SQL
  1769. EXEC(@SQL)
  1770. SET @ValidJobNumber = @@ROWCOUNT
  1771. ----记录查询结果总数
  1772. UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@SQL WHERE ID=@paSearchConditionID
  1773. ----插入JobType数据
  1774. DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
  1775. IF (@TableID = 0)
  1776. BEGIN
  1777. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  1778. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  1779. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  1780. ----计算全部某职位类别,2, 4位的数据
  1781. UPDATE a SET a.TitleValue = b.TitleValue
  1782. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
  1783. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  1784. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  1785. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  1786. GROUP BY LEFT(TitleID, 2)) b
  1787. WHERE a.TitleId = b.TitleID
  1788. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  1789. ----写入TitleDesc
  1790. UPDATE a SET a.TitleDesc = b.Description
  1791. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  1792. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  1793. AND a.Title = 'JobType'
  1794. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  1795. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  1796. GROUP BY dcSalaryID ORDER BY dcSalaryID
  1797. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  1798. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  1799. GROUP BY dcRegionID ORDER BY dcRegionID
  1800. ----计算全部地区,2位的数据
  1801. UPDATE a SET a.TitleValue = b.TitleValue
  1802. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
  1803. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  1804. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  1805. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  1806. GROUP BY LEFT(TitleID, 2)) b
  1807. WHERE a.TitleId = b.TitleID
  1808. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  1809. ----计算全部地区,4位的数据
  1810. UPDATE a SET a.TitleValue = b.TitleValue
  1811. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), (
  1812. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  1813. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  1814. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  1815. AND LEN(TitleID) >3
  1816. GROUP BY LEFT(TitleID, 4)) b
  1817. WHERE a.TitleId = b.TitleID
  1818. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  1819. ----写入TitleDesc
  1820. UPDATE a SET a.TitleDesc = b.Description
  1821. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  1822. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  1823. AND a.Title = 'Region'
  1824. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  1825. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  1826. GROUP BY dcEducationID ORDER BY dcEducationID
  1827. --学历 高中、中专、中级合并
  1828. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  1829. WHERE paSearchConditionID = @paSearchConditionID
  1830. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  1831. IF @TitleValue IS NOT NULL
  1832. BEGIN
  1833. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  1834. UPDATE SearchDB..paSearchCount_0 SET TitleValue = @TitleValue
  1835. WHERE paSearchConditionID = @paSearchConditionID
  1836. AND Title = 'Education' AND TitleID = 2
  1837. ELSE
  1838. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  1839. (@paSearchConditionID, 'Education', 2, @TitleValue)
  1840. DELETE FROM SearchDB..paSearchCount_0
  1841. WHERE paSearchConditionID = @paSearchConditionID
  1842. AND Title = 'Education' AND TitleID IN(3, 4)
  1843. END
  1844. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  1845. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  1846. GROUP BY MinExperience ORDER BY MinExperience
  1847. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  1848. SELECT Top 3 @paSearchConditionID,Balance,1
  1849. FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  1850. WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
  1851. SET @TopRows = @@ROWCOUNT
  1852. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  1853. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  1854. SET @AllRows = @@ROWCOUNT
  1855. IF @TopRows = 0 AND @AllRows > 100
  1856. UPDATE SearchDB..paSearchJobID_0 SET IsTop = 1
  1857. WHERE paSearchConditionID = @paSearchConditionID
  1858. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  1859. END
  1860. ELSE IF (@TableId = 1)
  1861. BEGIN
  1862. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  1863. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  1864. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  1865. ----计算全部某职位类别,2, 4位的数据
  1866. UPDATE a SET a.TitleValue = b.TitleValue
  1867. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
  1868. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  1869. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  1870. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  1871. GROUP BY LEFT(TitleID, 2)) b
  1872. WHERE a.TitleId = b.TitleID
  1873. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  1874. ----写入TitleDesc
  1875. UPDATE a SET a.TitleDesc = b.Description
  1876. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  1877. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  1878. AND a.Title = 'JobType'
  1879. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  1880. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  1881. GROUP BY dcSalaryID ORDER BY dcSalaryID
  1882. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  1883. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  1884. GROUP BY dcRegionID ORDER BY dcRegionID
  1885. ----计算全部地区,2位的数据
  1886. UPDATE a SET a.TitleValue = b.TitleValue
  1887. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
  1888. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  1889. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  1890. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  1891. GROUP BY LEFT(TitleID, 2)) b
  1892. WHERE a.TitleId = b.TitleID
  1893. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  1894. ----计算全部地区,4位的数据
  1895. UPDATE a SET a.TitleValue = b.TitleValue
  1896. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), (
  1897. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  1898. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  1899. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  1900. AND LEN(TitleID) >3
  1901. GROUP BY LEFT(TitleID, 4)) b
  1902. WHERE a.TitleId = b.TitleID
  1903. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  1904. ----写入TitleDesc
  1905. UPDATE a SET a.TitleDesc = b.Description
  1906. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  1907. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  1908. AND a.Title = 'Region'
  1909. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  1910. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  1911. GROUP BY dcEducationID ORDER BY dcEducationID
  1912. --学历 高中、中专、中级合并
  1913. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  1914. WHERE paSearchConditionID = @paSearchConditionID
  1915. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  1916. IF @TitleValue IS NOT NULL
  1917. BEGIN
  1918. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  1919. UPDATE SearchDB..paSearchCount_1 SET TitleValue = @TitleValue
  1920. WHERE paSearchConditionID = @paSearchConditionID
  1921. AND Title = 'Education' AND TitleID = 2
  1922. ELSE
  1923. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  1924. (@paSearchConditionID, 'Education', 2, @TitleValue)
  1925. DELETE FROM SearchDB..paSearchCount_1
  1926. WHERE paSearchConditionID = @paSearchConditionID
  1927. AND Title = 'Education' AND TitleID IN(3, 4)
  1928. END
  1929. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  1930. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  1931. GROUP BY MinExperience ORDER BY MinExperience
  1932. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  1933. SELECT Top 3 @paSearchConditionID,Balance,1
  1934. FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  1935. WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
  1936. SET @TopRows = @@ROWCOUNT
  1937. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  1938. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  1939. SET @AllRows = @@ROWCOUNT
  1940. IF @TopRows = 0 AND @AllRows > 100
  1941. UPDATE SearchDB..paSearchJobID_1 SET IsTop = 1
  1942. WHERE paSearchConditionID = @paSearchConditionID
  1943. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  1944. END
  1945. ELSE IF (@TableId = 2)
  1946. BEGIN
  1947. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  1948. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  1949. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  1950. ----计算全部某职位类别,2, 4位的数据
  1951. UPDATE a SET a.TitleValue = b.TitleValue
  1952. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
  1953. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  1954. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  1955. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  1956. GROUP BY LEFT(TitleID, 2)) b
  1957. WHERE a.TitleId = b.TitleID
  1958. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  1959. ----写入TitleDesc
  1960. UPDATE a SET a.TitleDesc = b.Description
  1961. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  1962. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  1963. AND a.Title = 'JobType'
  1964. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  1965. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  1966. GROUP BY dcSalaryID ORDER BY dcSalaryID
  1967. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  1968. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  1969. GROUP BY dcRegionID ORDER BY dcRegionID
  1970. ----计算全部地区,2位的数据
  1971. UPDATE a SET a.TitleValue = b.TitleValue
  1972. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
  1973. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  1974. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  1975. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  1976. GROUP BY LEFT(TitleID, 2)) b
  1977. WHERE a.TitleId = b.TitleID
  1978. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  1979. ----计算全部地区,4位的数据
  1980. UPDATE a SET a.TitleValue = b.TitleValue
  1981. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), (
  1982. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  1983. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  1984. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  1985. AND LEN(TitleID) >3
  1986. GROUP BY LEFT(TitleID, 4)) b
  1987. WHERE a.TitleId = b.TitleID
  1988. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  1989. ----写入TitleDesc
  1990. UPDATE a SET a.TitleDesc = b.Description
  1991. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  1992. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  1993. AND a.Title = 'Region'
  1994. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  1995. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  1996. GROUP BY dcEducationID ORDER BY dcEducationID
  1997. --学历 高中、中专、中级合并
  1998. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  1999. WHERE paSearchConditionID = @paSearchConditionID
  2000. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  2001. IF @TitleValue IS NOT NULL
  2002. BEGIN
  2003. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  2004. UPDATE SearchDB..paSearchCount_2 SET TitleValue = @TitleValue
  2005. WHERE paSearchConditionID = @paSearchConditionID
  2006. AND Title = 'Education' AND TitleID = 2
  2007. ELSE
  2008. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  2009. (@paSearchConditionID, 'Education', 2, @TitleValue)
  2010. DELETE FROM SearchDB..paSearchCount_2
  2011. WHERE paSearchConditionID = @paSearchConditionID
  2012. AND Title = 'Education' AND TitleID IN(3, 4)
  2013. END
  2014. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  2015. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  2016. GROUP BY MinExperience ORDER BY MinExperience
  2017. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  2018. SELECT Top 3 @paSearchConditionID,Balance,1
  2019. FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  2020. WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
  2021. SET @TopRows = @@ROWCOUNT
  2022. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  2023. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  2024. SET @AllRows = @@ROWCOUNT
  2025. IF @TopRows = 0 AND @AllRows > 100
  2026. UPDATE SearchDB..paSearchJobID_2 SET IsTop = 1
  2027. WHERE paSearchConditionID = @paSearchConditionID
  2028. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  2029. END
  2030. ELSE IF (@TableId = 3)
  2031. BEGIN
  2032. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  2033. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  2034. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  2035. ----计算全部某职位类别,2, 4位的数据
  2036. UPDATE a SET a.TitleValue = b.TitleValue
  2037. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
  2038. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  2039. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  2040. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  2041. GROUP BY LEFT(TitleID, 2)) b
  2042. WHERE a.TitleId = b.TitleID
  2043. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  2044. ----写入TitleDesc
  2045. UPDATE a SET a.TitleDesc = b.Description
  2046. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  2047. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  2048. AND a.Title = 'JobType'
  2049. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  2050. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  2051. GROUP BY dcSalaryID ORDER BY dcSalaryID
  2052. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  2053. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  2054. GROUP BY dcRegionID ORDER BY dcRegionID
  2055. ----计算全部地区,2位的数据
  2056. UPDATE a SET a.TitleValue = b.TitleValue
  2057. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
  2058. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  2059. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  2060. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  2061. GROUP BY LEFT(TitleID, 2)) b
  2062. WHERE a.TitleId = b.TitleID
  2063. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  2064. ----计算全部地区,4位的数据
  2065. UPDATE a SET a.TitleValue = b.TitleValue
  2066. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), (
  2067. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  2068. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  2069. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  2070. AND LEN(TitleID) >3
  2071. GROUP BY LEFT(TitleID, 4)) b
  2072. WHERE a.TitleId = b.TitleID
  2073. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  2074. ----写入TitleDesc
  2075. UPDATE a SET a.TitleDesc = b.Description
  2076. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  2077. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  2078. AND a.Title = 'Region'
  2079. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  2080. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  2081. GROUP BY dcEducationID ORDER BY dcEducationID
  2082. --学历 高中、中专、中级合并
  2083. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  2084. WHERE paSearchConditionID = @paSearchConditionID
  2085. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  2086. IF @TitleValue IS NOT NULL
  2087. BEGIN
  2088. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  2089. UPDATE SearchDB..paSearchCount_3 SET TitleValue = @TitleValue
  2090. WHERE paSearchConditionID = @paSearchConditionID
  2091. AND Title = 'Education' AND TitleID = 2
  2092. ELSE
  2093. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  2094. (@paSearchConditionID, 'Education', 2, @TitleValue)
  2095. DELETE FROM SearchDB..paSearchCount_3
  2096. WHERE paSearchConditionID = @paSearchConditionID
  2097. AND Title = 'Education' AND TitleID IN(3, 4)
  2098. END
  2099. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  2100. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  2101. GROUP BY MinExperience ORDER BY MinExperience
  2102. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  2103. SELECT Top 3 @paSearchConditionID,Balance,1
  2104. FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  2105. WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
  2106. SET @TopRows = @@ROWCOUNT
  2107. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  2108. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  2109. SET @AllRows = @@ROWCOUNT
  2110. IF @TopRows = 0 AND @AllRows > 100
  2111. UPDATE SearchDB..paSearchJobID_3 SET IsTop = 1
  2112. WHERE paSearchConditionID = @paSearchConditionID
  2113. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  2114. END
  2115. DROP TABLE #Job
  2116. COMMIT
  2117. GetRecordSet:
  2118. BEGIN
  2119. ----返回查询数量
  2120. SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
  2121. UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
  2122. ----返回20行查询结果
  2123. IF (@TableID = 0)
  2124. BEGIN
  2125. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  2126. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  2127. SELECT TOP 8 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  2128. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  2129. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  2130. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  2131. a.IsDelete, a.AddDate, a.RefreshDate,
  2132. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  2133. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  2134. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  2135. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  2136. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  2137. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
  2138. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_0 c WITH(NOLOCK)
  2139. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  2140. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  2141. END
  2142. ELSE IF (@TableID = 1)
  2143. BEGIN
  2144. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  2145. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  2146. SELECT TOP 8 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  2147. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  2148. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  2149. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  2150. a.IsDelete, a.AddDate, a.RefreshDate,
  2151. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  2152. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  2153. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  2154. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  2155. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  2156. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
  2157. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_1 c WITH(NOLOCK)
  2158. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  2159. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  2160. END
  2161. ELSE IF (@TableID = 2)
  2162. BEGIN
  2163. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  2164. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  2165. SELECT TOP 8 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  2166. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  2167. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  2168. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  2169. a.IsDelete, a.AddDate, a.RefreshDate,
  2170. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  2171. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  2172. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  2173. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  2174. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  2175. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
  2176. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_2 c WITH(NOLOCK)
  2177. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  2178. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  2179. END
  2180. ELSE IF (@TableID = 3)
  2181. BEGIN
  2182. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  2183. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  2184. SELECT TOP 8 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  2185. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  2186. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  2187. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  2188. a.IsDelete, a.AddDate, a.RefreshDate,
  2189. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  2190. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  2191. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  2192. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  2193. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  2194. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
  2195. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_3 c WITH(NOLOCK)
  2196. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  2197. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  2198. END
  2199. RETURN
  2200. END
  2201. END TRY
  2202. BEGIN CATCH
  2203. ---检查是否已经建立临时表,已经建立则删除
  2204. PRINT 'error'
  2205. PRINT error_Message()
  2206. PRINT error_number()
  2207. PRINT error_line()
  2208. END CATCH
  2209. GO
  2210. /****** Object: StoredProcedure [dbo].[paJobByWeixinSelect1] Script Date: 2018/12/13 19:08:02 ******/
  2211. SET ANSI_NULLS ON
  2212. GO
  2213. SET QUOTED_IDENTIFIER ON
  2214. GO
  2215. CREATE PROCEDURE [dbo].[paJobByWeixinSelect1]
  2216. (
  2217. @FromUserName VARCHAR(50),
  2218. @Type INT --0:订阅号关键词查询;10:服务号的关键词查询;11:服务号的周边职位
  2219. )
  2220. AS
  2221. --return
  2222. SET NOCOUNT ON
  2223. BEGIN TRY
  2224. DECLARE @dcRegionID INT,@KeyWord NVARCHAR(20),
  2225. @Lng DECIMAL(8,5),@Lat DECIMAL(8,5),@Distance INT,
  2226. @KeyType TINYINT, @ValidJobNumber INT, @PageNumber SMALLINT
  2227. IF @Type =11
  2228. BEGIN
  2229. SELECT @dcRegionID=dcRegionID,@KeyWord=KeyWord,
  2230. @Lng=Lng,@Lat=Lat,@PageNumber=PageNumber
  2231. FROM wxMessage WITH(NOLOCK) WHERE FromUserName=@FromUserName AND CONTENT='推荐职位'
  2232. END
  2233. ELSE
  2234. BEGIN
  2235. SELECT @dcRegionID=dcRegionID,@KeyWord=KeyWord,
  2236. @Lng=Lng,@Lat=Lat,@PageNumber=PageNumber
  2237. FROM wxMessage WITH(NOLOCK) WHERE FromUserName=@FromUserName
  2238. END
  2239. IF @Type =11 OR @Type = 10
  2240. BEGIN
  2241. UPDATE wxMessage SET PageNumber = 2 WHERE FromUserName=@FromUserName
  2242. END
  2243. ELSE
  2244. BEGIN
  2245. UPDATE wxMessage SET PageNumber=PageNumber+1 WHERE FromUserName=@FromUserName
  2246. END
  2247. --UPDATE wxMessage SET PageNumber=PageNumber+1 WHERE FromUserName=@FromUserName
  2248. SELECT @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, '')),
  2249. @KeyType = 2,
  2250. @Distance = 5000,
  2251. @PageNumber = ISNULL(@PageNumber, 1),
  2252. @dcRegionID = ISNULL(@dcRegionID, 0),
  2253. @Lng = ISNULL(@Lng, 0),
  2254. @Lat = ISNULL(@Lat, 0)
  2255. IF @dcRegionID = 0 AND @Lng = 0 AND @Lat = 0
  2256. RETURN
  2257. DECLARE @paSearchConditionID AS INT,
  2258. @MinId AS INT,
  2259. @PageSize AS TINYINT,
  2260. @TableID AS TINYINT
  2261. IF @Type =11 OR @Type =10
  2262. BEGIN
  2263. SELECT @paSearchConditionID = 0, @PageSize = 5 --每页的行数
  2264. END
  2265. ELSE
  2266. BEGIN
  2267. SELECT @paSearchConditionID = 0, @PageSize = 8 --每页的行数
  2268. END
  2269. --SELECT @paSearchConditionID = 0, @PageSize = 8 --每页的行数
  2270. ----搜索60分钟前的数据
  2271. SELECT TOP 1 @paSearchConditionID=ID FROM SearchDB..paSearchCondition WITH(NOLOCK)
  2272. WHERE JobType=''
  2273. AND JobPlace=@dcRegionID AND ISNULL(Industry,'')='' AND ISNULL(Education,'')=''
  2274. AND ISNULL(Experience,'')='' AND ISNULL(Salary,'')='' AND ISNULL(IsNegotiable,'')=''
  2275. AND ISNULL(EmployType,'')='' AND KeyWord=@KeyWord AND KeyType=@KeyType
  2276. AND ISNULL(CompanySizeID,'')='' AND Lng=@Lng AND Lat=@Lat
  2277. ORDER BY ID DESC
  2278. IF ISNULL(@paSearchConditionID, 0) = 0
  2279. BEGIN
  2280. GOTO SelectReset --无数据,重新搜索
  2281. END
  2282. ELSE
  2283. BEGIN
  2284. SELECT @TableID = @paSearchConditionID % 4
  2285. GOTO GetRecordSet --从临时结果中提取数据
  2286. END
  2287. SelectReset:
  2288. --从job中搜索数据
  2289. BEGIN TRAN
  2290. DECLARE @SQL AS VARCHAR(8000)
  2291. DECLARE @WHERE AS VARCHAR(8000)
  2292. DECLARE @FROM AS VARCHAR(1000)
  2293. ----记录查询条件
  2294. INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
  2295. Salary, IsNegotiable, EmployType, CompanySizeID, KeyWord, KeyType, ReuseNumber, Lng, Lat, Distance)
  2296. VALUES(1, GETDATE(), '', @dcRegionID, '', '', '', '', '', '', '', @KeyWord, @KeyType, 0, @Lng, @Lat, @Distance)
  2297. SET @paSearchConditionID = @@IDENTITY
  2298. SELECT @TableID = @paSearchConditionID % 4
  2299. ----建立临时表
  2300. CREATE TABLE #Job(
  2301. RowID INT IDENTITY(1, 1),
  2302. ID INT NOT NULL,
  2303. dcJobTypeID SMALLINT NOT NULL,
  2304. dcJobTypeIDMinor SMALLINT NULL,
  2305. dcSalaryID TINYINT NOT NULL,
  2306. dcRegionID VARCHAR(6) NULL,
  2307. dcEducationID TINYINT NOT NULL,
  2308. MinExperience TINYINT NOT NULL,
  2309. RefreshDate SMALLDATETIME NULL
  2310. )
  2311. ------刷新时间,根据刷新时间编号计算
  2312. ----生成插入临时表的Sql语句
  2313. SET @SQL='
  2314. INSERT INTO #Job
  2315. SELECT a.ID, a.dcJobTypeID,
  2316. a.dcJobTypeIDMinor, a.dcSalaryID,
  2317. a.dcRegionID, a.dcEducationID, a.MinExperience,
  2318. a.IssueDate'
  2319. SET @FROM = '
  2320. FROM JobPublish a WITH(NOLOCK)
  2321. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  2322. ----职位有效,单位新有效
  2323. SET @WHERE = '
  2324. WHERE a.Valid = 1
  2325. AND b.Valid = 1'
  2326. ----需要增加全文索引的关键字查询
  2327. IF @KeyWord LIKE '% %'
  2328. BEGIN
  2329. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  2330. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  2331. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  2332. SET @KeyWord = '"' + REPLACE(@KeyWord, ' ', '" OR "') + '"'
  2333. END
  2334. IF LEN(@KeyWord) > 0
  2335. BEGIN
  2336. IF @KeyType = 2
  2337. SET @FROM = @FROM + '
  2338. INNER JOIN CONTAINSTABLE(JobPublish, *, ''' + @KeyWord + ''', 1000000) AS KeyJob
  2339. ON a.ID = KeyJob.[Key]'
  2340. END
  2341. ---地区
  2342. IF @dcRegionID > 0
  2343. SET @WHERE = @WHERE + '
  2344. AND a.dcRegionID Like ''' + CONVERT(VARCHAR(6),@dcRegionID) + '%'''
  2345. IF @Lng > 0 AND @Lat > 0
  2346. BEGIN
  2347. DECLARE @Degree AS DECIMAL(8,5),@LBLng AS DECIMAL(8,5),@LBLat AS DECIMAL(8,5),
  2348. @RTLng AS DECIMAL(8,5),@RTLat AS DECIMAL(8,5)
  2349. SET @Degree = @Distance / 100000.0;
  2350. SET @LBLng = @Lng - @Degree
  2351. SET @LBLat = @Lat - @Degree
  2352. SET @RTLng = @Lng + @Degree
  2353. SET @RTLat = @Lat + @Degree
  2354. SET @WHERE = @WHERE + '
  2355. AND a.Lng BETWEEN ' + CONVERT(VARCHAR,@LBLng) + ' AND ' + CONVERT(VARCHAR,@RTLng) + '
  2356. AND a.Lat BETWEEN ' + CONVERT(VARCHAR,@LBLat) + ' AND ' + CONVERT(VARCHAR,@RTLat)
  2357. END
  2358. SET @SQL = @SQL + @FROM + @WHERE
  2359. SET @SQL=@SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
  2360. ----把符合条件的职位全部列出
  2361. --PRINT @SQL
  2362. EXEC(@SQL)
  2363. SET @ValidJobNumber = @@ROWCOUNT
  2364. ----记录查询结果总数
  2365. UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@SQL WHERE ID=@paSearchConditionID
  2366. ----插入JobType数据
  2367. DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
  2368. IF (@TableID = 0)
  2369. BEGIN
  2370. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  2371. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  2372. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  2373. ----计算全部某职位类别,2, 4位的数据
  2374. UPDATE a SET a.TitleValue = b.TitleValue
  2375. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
  2376. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  2377. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  2378. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  2379. GROUP BY LEFT(TitleID, 2)) b
  2380. WHERE a.TitleId = b.TitleID
  2381. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  2382. ----写入TitleDesc
  2383. UPDATE a SET a.TitleDesc = b.Description
  2384. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  2385. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  2386. AND a.Title = 'JobType'
  2387. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  2388. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  2389. GROUP BY dcSalaryID ORDER BY dcSalaryID
  2390. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  2391. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  2392. GROUP BY dcRegionID ORDER BY dcRegionID
  2393. ----计算全部地区,2位的数据
  2394. UPDATE a SET a.TitleValue = b.TitleValue
  2395. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
  2396. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  2397. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  2398. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  2399. GROUP BY LEFT(TitleID, 2)) b
  2400. WHERE a.TitleId = b.TitleID
  2401. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  2402. ----计算全部地区,4位的数据
  2403. UPDATE a SET a.TitleValue = b.TitleValue
  2404. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), (
  2405. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  2406. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  2407. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  2408. AND LEN(TitleID) >3
  2409. GROUP BY LEFT(TitleID, 4)) b
  2410. WHERE a.TitleId = b.TitleID
  2411. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  2412. ----写入TitleDesc
  2413. UPDATE a SET a.TitleDesc = b.Description
  2414. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  2415. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  2416. AND a.Title = 'Region'
  2417. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  2418. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  2419. GROUP BY dcEducationID ORDER BY dcEducationID
  2420. --学历 高中、中专、中级合并
  2421. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  2422. WHERE paSearchConditionID = @paSearchConditionID
  2423. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  2424. IF @TitleValue IS NOT NULL
  2425. BEGIN
  2426. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  2427. UPDATE SearchDB..paSearchCount_0 SET TitleValue = @TitleValue
  2428. WHERE paSearchConditionID = @paSearchConditionID
  2429. AND Title = 'Education' AND TitleID = 2
  2430. ELSE
  2431. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  2432. (@paSearchConditionID, 'Education', 2, @TitleValue)
  2433. DELETE FROM SearchDB..paSearchCount_0
  2434. WHERE paSearchConditionID = @paSearchConditionID
  2435. AND Title = 'Education' AND TitleID IN(3, 4)
  2436. END
  2437. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  2438. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  2439. GROUP BY MinExperience ORDER BY MinExperience
  2440. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  2441. SELECT Top 3 @paSearchConditionID,Balance,1
  2442. FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  2443. WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
  2444. SET @TopRows = @@ROWCOUNT
  2445. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  2446. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  2447. SET @AllRows = @@ROWCOUNT
  2448. IF @TopRows = 0 AND @AllRows > 100
  2449. UPDATE SearchDB..paSearchJobID_0 SET IsTop = 1
  2450. WHERE paSearchConditionID = @paSearchConditionID
  2451. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  2452. END
  2453. ELSE IF (@TableId = 1)
  2454. BEGIN
  2455. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  2456. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  2457. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  2458. ----计算全部某职位类别,2, 4位的数据
  2459. UPDATE a SET a.TitleValue = b.TitleValue
  2460. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
  2461. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  2462. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  2463. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  2464. GROUP BY LEFT(TitleID, 2)) b
  2465. WHERE a.TitleId = b.TitleID
  2466. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  2467. ----写入TitleDesc
  2468. UPDATE a SET a.TitleDesc = b.Description
  2469. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  2470. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  2471. AND a.Title = 'JobType'
  2472. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  2473. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  2474. GROUP BY dcSalaryID ORDER BY dcSalaryID
  2475. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  2476. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  2477. GROUP BY dcRegionID ORDER BY dcRegionID
  2478. ----计算全部地区,2位的数据
  2479. UPDATE a SET a.TitleValue = b.TitleValue
  2480. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
  2481. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  2482. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  2483. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  2484. GROUP BY LEFT(TitleID, 2)) b
  2485. WHERE a.TitleId = b.TitleID
  2486. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  2487. ----计算全部地区,4位的数据
  2488. UPDATE a SET a.TitleValue = b.TitleValue
  2489. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), (
  2490. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  2491. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  2492. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  2493. AND LEN(TitleID) >3
  2494. GROUP BY LEFT(TitleID, 4)) b
  2495. WHERE a.TitleId = b.TitleID
  2496. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  2497. ----写入TitleDesc
  2498. UPDATE a SET a.TitleDesc = b.Description
  2499. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  2500. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  2501. AND a.Title = 'Region'
  2502. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  2503. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  2504. GROUP BY dcEducationID ORDER BY dcEducationID
  2505. --学历 高中、中专、中级合并
  2506. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  2507. WHERE paSearchConditionID = @paSearchConditionID
  2508. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  2509. IF @TitleValue IS NOT NULL
  2510. BEGIN
  2511. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  2512. UPDATE SearchDB..paSearchCount_1 SET TitleValue = @TitleValue
  2513. WHERE paSearchConditionID = @paSearchConditionID
  2514. AND Title = 'Education' AND TitleID = 2
  2515. ELSE
  2516. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  2517. (@paSearchConditionID, 'Education', 2, @TitleValue)
  2518. DELETE FROM SearchDB..paSearchCount_1
  2519. WHERE paSearchConditionID = @paSearchConditionID
  2520. AND Title = 'Education' AND TitleID IN(3, 4)
  2521. END
  2522. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  2523. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  2524. GROUP BY MinExperience ORDER BY MinExperience
  2525. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  2526. SELECT Top 3 @paSearchConditionID,Balance,1
  2527. FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  2528. WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
  2529. SET @TopRows = @@ROWCOUNT
  2530. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  2531. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  2532. SET @AllRows = @@ROWCOUNT
  2533. IF @TopRows = 0 AND @AllRows > 100
  2534. UPDATE SearchDB..paSearchJobID_1 SET IsTop = 1
  2535. WHERE paSearchConditionID = @paSearchConditionID
  2536. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  2537. END
  2538. ELSE IF (@TableId = 2)
  2539. BEGIN
  2540. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  2541. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  2542. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  2543. ----计算全部某职位类别,2, 4位的数据
  2544. UPDATE a SET a.TitleValue = b.TitleValue
  2545. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
  2546. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  2547. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  2548. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  2549. GROUP BY LEFT(TitleID, 2)) b
  2550. WHERE a.TitleId = b.TitleID
  2551. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  2552. ----写入TitleDesc
  2553. UPDATE a SET a.TitleDesc = b.Description
  2554. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  2555. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  2556. AND a.Title = 'JobType'
  2557. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  2558. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  2559. GROUP BY dcSalaryID ORDER BY dcSalaryID
  2560. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  2561. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  2562. GROUP BY dcRegionID ORDER BY dcRegionID
  2563. ----计算全部地区,2位的数据
  2564. UPDATE a SET a.TitleValue = b.TitleValue
  2565. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
  2566. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  2567. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  2568. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  2569. GROUP BY LEFT(TitleID, 2)) b
  2570. WHERE a.TitleId = b.TitleID
  2571. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  2572. ----计算全部地区,4位的数据
  2573. UPDATE a SET a.TitleValue = b.TitleValue
  2574. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), (
  2575. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  2576. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  2577. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  2578. AND LEN(TitleID) >3
  2579. GROUP BY LEFT(TitleID, 4)) b
  2580. WHERE a.TitleId = b.TitleID
  2581. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  2582. ----写入TitleDesc
  2583. UPDATE a SET a.TitleDesc = b.Description
  2584. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  2585. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  2586. AND a.Title = 'Region'
  2587. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  2588. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  2589. GROUP BY dcEducationID ORDER BY dcEducationID
  2590. --学历 高中、中专、中级合并
  2591. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  2592. WHERE paSearchConditionID = @paSearchConditionID
  2593. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  2594. IF @TitleValue IS NOT NULL
  2595. BEGIN
  2596. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  2597. UPDATE SearchDB..paSearchCount_2 SET TitleValue = @TitleValue
  2598. WHERE paSearchConditionID = @paSearchConditionID
  2599. AND Title = 'Education' AND TitleID = 2
  2600. ELSE
  2601. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  2602. (@paSearchConditionID, 'Education', 2, @TitleValue)
  2603. DELETE FROM SearchDB..paSearchCount_2
  2604. WHERE paSearchConditionID = @paSearchConditionID
  2605. AND Title = 'Education' AND TitleID IN(3, 4)
  2606. END
  2607. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  2608. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  2609. GROUP BY MinExperience ORDER BY MinExperience
  2610. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  2611. SELECT Top 3 @paSearchConditionID,Balance,1
  2612. FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  2613. WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
  2614. SET @TopRows = @@ROWCOUNT
  2615. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  2616. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  2617. SET @AllRows = @@ROWCOUNT
  2618. IF @TopRows = 0 AND @AllRows > 100
  2619. UPDATE SearchDB..paSearchJobID_2 SET IsTop = 1
  2620. WHERE paSearchConditionID = @paSearchConditionID
  2621. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  2622. END
  2623. ELSE IF (@TableId = 3)
  2624. BEGIN
  2625. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  2626. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  2627. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  2628. ----计算全部某职位类别,2, 4位的数据
  2629. UPDATE a SET a.TitleValue = b.TitleValue
  2630. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
  2631. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  2632. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  2633. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  2634. GROUP BY LEFT(TitleID, 2)) b
  2635. WHERE a.TitleId = b.TitleID
  2636. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  2637. ----写入TitleDesc
  2638. UPDATE a SET a.TitleDesc = b.Description
  2639. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  2640. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  2641. AND a.Title = 'JobType'
  2642. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  2643. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  2644. GROUP BY dcSalaryID ORDER BY dcSalaryID
  2645. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  2646. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  2647. GROUP BY dcRegionID ORDER BY dcRegionID
  2648. ----计算全部地区,2位的数据
  2649. UPDATE a SET a.TitleValue = b.TitleValue
  2650. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
  2651. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  2652. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  2653. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  2654. GROUP BY LEFT(TitleID, 2)) b
  2655. WHERE a.TitleId = b.TitleID
  2656. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  2657. ----计算全部地区,4位的数据
  2658. UPDATE a SET a.TitleValue = b.TitleValue
  2659. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), (
  2660. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  2661. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  2662. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  2663. AND LEN(TitleID) >3
  2664. GROUP BY LEFT(TitleID, 4)) b
  2665. WHERE a.TitleId = b.TitleID
  2666. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  2667. ----写入TitleDesc
  2668. UPDATE a SET a.TitleDesc = b.Description
  2669. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  2670. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  2671. AND a.Title = 'Region'
  2672. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  2673. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  2674. GROUP BY dcEducationID ORDER BY dcEducationID
  2675. --学历 高中、中专、中级合并
  2676. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  2677. WHERE paSearchConditionID = @paSearchConditionID
  2678. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  2679. IF @TitleValue IS NOT NULL
  2680. BEGIN
  2681. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  2682. UPDATE SearchDB..paSearchCount_3 SET TitleValue = @TitleValue
  2683. WHERE paSearchConditionID = @paSearchConditionID
  2684. AND Title = 'Education' AND TitleID = 2
  2685. ELSE
  2686. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  2687. (@paSearchConditionID, 'Education', 2, @TitleValue)
  2688. DELETE FROM SearchDB..paSearchCount_3
  2689. WHERE paSearchConditionID = @paSearchConditionID
  2690. AND Title = 'Education' AND TitleID IN(3, 4)
  2691. END
  2692. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  2693. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  2694. GROUP BY MinExperience ORDER BY MinExperience
  2695. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  2696. SELECT Top 3 @paSearchConditionID,Balance,1
  2697. FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  2698. WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
  2699. SET @TopRows = @@ROWCOUNT
  2700. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  2701. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  2702. SET @AllRows = @@ROWCOUNT
  2703. IF @TopRows = 0 AND @AllRows > 100
  2704. UPDATE SearchDB..paSearchJobID_3 SET IsTop = 1
  2705. WHERE paSearchConditionID = @paSearchConditionID
  2706. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  2707. END
  2708. DROP TABLE #Job
  2709. COMMIT
  2710. GetRecordSet:
  2711. BEGIN
  2712. ----返回查询数量
  2713. SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
  2714. UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
  2715. ----返回20行查询结果
  2716. IF (@TableID = 0)
  2717. BEGIN
  2718. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  2719. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  2720. SELECT TOP 8 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  2721. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  2722. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  2723. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  2724. a.IsDelete, a.AddDate, a.RefreshDate,
  2725. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  2726. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  2727. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  2728. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  2729. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  2730. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
  2731. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_0 c WITH(NOLOCK)
  2732. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  2733. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  2734. END
  2735. ELSE IF (@TableID = 1)
  2736. BEGIN
  2737. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  2738. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  2739. SELECT TOP 8 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  2740. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  2741. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  2742. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  2743. a.IsDelete, a.AddDate, a.RefreshDate,
  2744. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  2745. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  2746. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  2747. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  2748. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  2749. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
  2750. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_1 c WITH(NOLOCK)
  2751. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  2752. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  2753. END
  2754. ELSE IF (@TableID = 2)
  2755. BEGIN
  2756. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  2757. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  2758. SELECT TOP 8 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  2759. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  2760. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  2761. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  2762. a.IsDelete, a.AddDate, a.RefreshDate,
  2763. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  2764. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  2765. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  2766. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  2767. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  2768. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
  2769. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_2 c WITH(NOLOCK)
  2770. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  2771. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  2772. END
  2773. ELSE IF (@TableID = 3)
  2774. BEGIN
  2775. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  2776. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  2777. SELECT TOP 8 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  2778. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  2779. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  2780. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  2781. a.IsDelete, a.AddDate, a.RefreshDate,
  2782. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  2783. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  2784. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  2785. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  2786. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  2787. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
  2788. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_3 c WITH(NOLOCK)
  2789. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  2790. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  2791. END
  2792. RETURN
  2793. END
  2794. END TRY
  2795. BEGIN CATCH
  2796. ---检查是否已经建立临时表,已经建立则删除
  2797. PRINT 'error'
  2798. PRINT error_Message()
  2799. PRINT error_number()
  2800. PRINT error_line()
  2801. END CATCH
  2802. GO
  2803. /****** Object: StoredProcedure [dbo].[paPaRemindLogSelectByIndex] Script Date: 2018/12/13 19:08:04 ******/
  2804. SET ANSI_NULLS ON
  2805. GO
  2806. SET QUOTED_IDENTIFIER ON
  2807. GO
  2808. CREATE PROCEDURE [dbo].[paPaRemindLogSelectByIndex]
  2809. (
  2810. @paMainID INT
  2811. )
  2812. AS
  2813. BEGIN
  2814. SET NOCOUNT ON
  2815. SELECT TOP 0 * FROM paRemindLog
  2816. -- DECLARE @LastLoginDate SMALLDATETIME
  2817. -- SELECT @LastLoginDate = ISNULL(AddDate,GETDATE()) FROM(
  2818. -- SELECT TOP 2 AddDate,ROW_NUMBER() OVER(ORDER BY AddDate DESC) row FROM paLoginLog WHERE paMainID = @paMainID
  2819. -- ) a WHERE row = 2
  2820. -- SELECT * FROM paRemindLog WHERE AddDate > ISNULL(@LastLoginDate,GETDATE()) AND PaMainID = @paMainID
  2821. SET NOCOUNT OFF
  2822. END
  2823. GO
  2824. /****** Object: StoredProcedure [dbo].[paTagsMainByJobTypeSelect] Script Date: 2018/12/13 19:08:04 ******/
  2825. SET ANSI_NULLS ON
  2826. GO
  2827. SET QUOTED_IDENTIFIER ON
  2828. GO
  2829. --根据职位类别获取该职位类别下关键字信息 Peter 2017-1-13
  2830. CREATE PROCEDURE [dbo].[paTagsMainByJobTypeSelect]
  2831. (
  2832. @JobType VARCHAR(50)
  2833. )
  2834. AS
  2835. BEGIN
  2836. SELECT TOP 100 Tag
  2837. FROM (
  2838. SELECT DISTINCT Tag
  2839. FROM paTagsMain WITH(NOLOCK)
  2840. WHERE dcJobTypeID IN (
  2841. SELECT a FROM dbo.fnSplit(@JobType, ',')
  2842. )) a
  2843. ORDER BY NEWID()
  2844. END
  2845. GO
  2846. /****** Object: StoredProcedure [dbo].[paWeixinSave] Script Date: 2018/12/13 19:08:04 ******/
  2847. SET ANSI_NULLS ON
  2848. GO
  2849. SET QUOTED_IDENTIFIER ON
  2850. GO
  2851. CREATE PROCEDURE [dbo].[paWeixinSave]
  2852. (
  2853. @Content NVARCHAR(50),
  2854. @Lat VARCHAR(20),
  2855. @Lng VARCHAR(20),
  2856. @FromUserName VARCHAR(50)
  2857. )
  2858. AS
  2859. BEGIN TRY
  2860. SET @Content = dbo.SafeSql(@Content)
  2861. DELETE FROM wxMessage WHERE FromUserName=@FromUserName
  2862. IF ISNULL(@Content,'')=''
  2863. BEGIN
  2864. INSERT INTO wxMessage(FromUserName,Lat,Lng,Content) VALUES
  2865. (@FromUserName,@Lat,@Lng,@Content)
  2866. END
  2867. ELSE
  2868. BEGIN
  2869. DECLARE @dcRegionID INT, @KeyWord NVARCHAR(20), @c NVARCHAR(50)
  2870. IF @Content LIKE '% %'
  2871. SET @c = LEFT(@Content, CHARINDEX(' ', @Content) - 1)
  2872. ELSE
  2873. SET @c = @Content
  2874. SELECT TOP 1 @dcRegionID = ID FROM dcRegion WITH(NOLOCK)
  2875. WHERE CHARINDEX(Abbr, @c)>0
  2876. ORDER BY ID DESC
  2877. IF ISNULL(@dcRegionID,0)=0
  2878. RETURN 0
  2879. SELECT @KeyWord=REPLACE(REPLACE(@Content,MapbarName,''),REPLACE(MapbarName,'市',''),'') FROM dcRegion WITH(NOLOCK) WHERE ID=@dcRegionID
  2880. SELECT @KeyWord=REPLACE(REPLACE(REPLACE(@KeyWord,Description,''),REPLACE(Description,'市',''),''),REPLACE(Description,'区',''),'') FROM dcRegion WITH(NOLOCK) WHERE ID=@dcRegionID
  2881. SELECT @KeyWord=REPLACE(REPLACE(@KeyWord,LEFT(FullName,CHARINDEX('省',FullName)),''),REPLACE(LEFT(FullName,CHARINDEX('省',FullName)),'省',''),'') FROM dcRegion WITH(NOLOCK) WHERE ID=@dcRegionID
  2882. SELECT @KeyWord=REPLACE(@KeyWord,' ','')
  2883. SELECT @KeyWord=REPLACE(@KeyWord,'+','')
  2884. INSERT INTO wxMessage(FromUserName,dcRegionID,KeyWord,Content) VALUES
  2885. (@FromUserName,@dcRegionID,@KeyWord,@Content)
  2886. END
  2887. RETURN 1
  2888. END TRY
  2889. BEGIN CATCH
  2890. RETURN 0
  2891. END CATCH
  2892. GO
  2893. /****** Object: StoredProcedure [dbo].[pcAdvantageAnalysisByExJobApplySelect] Script Date: 2018/12/13 19:08:05 ******/
  2894. SET ANSI_NULLS ON
  2895. GO
  2896. SET QUOTED_IDENTIFIER ON
  2897. GO
  2898. CREATE PROCEDURE [dbo].[pcAdvantageAnalysisByExJobApplySelect]
  2899. (
  2900. @JobID INT
  2901. )
  2902. AS
  2903. --Lucifer 添加
  2904. --2013-11-4 应聘优势分析
  2905. BEGIN
  2906. SELECT b.dcSalaryID,COUNT(1) Cnt FROM exJobApply a WITH(NOLOCK),cvMain b WITH(NOLOCK) WHERE a.cvMainID=b.ID
  2907. AND a.JobID=@JobID AND b.dcSalaryID IS NOT NULL GROUP BY b.dcSalaryID
  2908. SELECT b.RelatedWorkYears,COUNT(1) Cnt FROM exJobApply a WITH(NOLOCK),cvMain b WITH(NOLOCK) WHERE a.cvMainID=b.ID
  2909. AND a.JobID=@JobID AND b.RelatedWorkYears IS NOT NULL GROUP BY b.RelatedWorkYears
  2910. SELECT b.Degree,COUNT(1) Cnt FROM exJobApply a WITH(NOLOCK),cvMain b WITH(NOLOCK) WHERE a.cvMainID=b.ID
  2911. AND a.JobID=@JobID AND b.Degree IS NOT NULL GROUP BY b.Degree
  2912. END
  2913. GO
  2914. /****** Object: StoredProcedure [dbo].[pcbsCvModifySelect] Script Date: 2018/12/13 19:08:05 ******/
  2915. SET ANSI_NULLS ON
  2916. GO
  2917. SET QUOTED_IDENTIFIER ON
  2918. GO
  2919. --#####################################################
  2920. --创建时间:2014.10.31
  2921. --创建人:Nick
  2922. --说明:获取简历所有的审核信息
  2923. --#####################################################
  2924. CREATE PROCEDURE [dbo].[pcbsCvModifySelect]
  2925. (
  2926. @PamainID INT,
  2927. @CvMainID INT
  2928. )
  2929. AS
  2930. BEGIN TRY
  2931. SELECT * FROM bsCvModify WITH(NOLOCK)
  2932. WHERE VerifyInfo Is NOT NULL
  2933. AND paMainID=@PamainID
  2934. And cvMainID=@CvMainID
  2935. And VerifyInfo<>(Select Top 1 VerifyInfo From bsCvVerify Where cvMainID=@CvMainID
  2936. Order By VerifyDate Desc
  2937. )
  2938. END TRY
  2939. BEGIN CATCH
  2940. RETURN 0
  2941. END CATCH
  2942. GO
  2943. /****** Object: StoredProcedure [dbo].[pcBsPaStatusInsert] Script Date: 2018/12/13 19:08:05 ******/
  2944. SET ANSI_NULLS ON
  2945. GO
  2946. SET QUOTED_IDENTIFIER ON
  2947. GO
  2948. -- =============================================
  2949. -- Author: <Author,,Name>
  2950. -- Create date: <Create Date,,>
  2951. -- Description: <Description,,>
  2952. -- =============================================
  2953. CREATE PROCEDURE [dbo].[pcBsPaStatusInsert]
  2954. (
  2955. @paMainID INT,
  2956. @cvMainID INT,
  2957. @StatusID INT,
  2958. @ApplyInfo VARCHAR(400)
  2959. )
  2960. AS
  2961. BEGIN TRY
  2962. DECLARE @MaxID AS INT
  2963. INSERT INTO bsPaStatus (paMainID,cvMainID,StatusID,ApplyInfo) VALUES(@paMainID,@cvMainID,@StatusID,@ApplyInfo)
  2964. SET @MaxID = @@IDENTITY
  2965. END TRY
  2966. BEGIN CATCH
  2967. GOTO ERR
  2968. END CATCH
  2969. RETURN @MaxID
  2970. ERR:
  2971. BEGIN
  2972. RETURN 0
  2973. END
  2974. GO
  2975. /****** Object: StoredProcedure [dbo].[pcCaCvIntentionBatchDelete] Script Date: 2018/12/13 19:08:05 ******/
  2976. SET ANSI_NULLS ON
  2977. GO
  2978. SET QUOTED_IDENTIFIER ON
  2979. GO
  2980. CREATE PROCEDURE [dbo].[pcCaCvIntentionBatchDelete]
  2981. (
  2982. @AllID VARCHAR(1000),
  2983. @paMainID INT
  2984. )
  2985. AS
  2986. SET NOCOUNT ON
  2987. BEGIN TRAN
  2988. BEGIN TRY
  2989. --生成临时表
  2990. DECLARE @t AS TABLE(
  2991. ID INT
  2992. )
  2993. DECLARE @i INT
  2994. SET @i=CHARINDEX(',',@AllID)
  2995. WHILE @i>=1
  2996. BEGIN
  2997. IF LEFT(@AllID,@i-1) > ''
  2998. INSERT @t VALUES(LEFT(@AllID,@i-1))
  2999. SET @AllID=SUBSTRING(@AllID,@i+1,LEN(@AllID)-@i)
  3000. SET @i=CHARINDEX(',',@AllID)
  3001. END
  3002. IF @AllID > ''
  3003. INSERT @t VALUES(@AllID)
  3004. IF EXISTS(SELECT 'X' FROM caCvIntention a WITH(NOLOCK),@t b,cvMain c WITH(NOLOCK)
  3005. WHERE a.id=b.id AND a.cvMainID=c.ID AND c.paMainID<>@paMainID)
  3006. GOTO Err
  3007. DELETE FROM caCvIntention WHERE CompanyDeleted=1 AND ID IN(SELECT ID FROM @t)
  3008. UPDATE CaCvIntention SET PersonDeleted=1 WHERE ID IN(SELECT ID FROM @t)
  3009. UPDATE CaCvIntention SET Reply=2,ReplyDate=GETDATE() WHERE ID IN(SELECT ID FROM @t) AND PersonDeleted=1
  3010. AND Reply IS NULL
  3011. END TRY
  3012. BEGIN CATCH
  3013. GOTO ERR
  3014. END CATCH
  3015. COMMIT TRAN
  3016. RETURN 1
  3017. ERR:
  3018. BEGIN
  3019. ROLLBACK TRAN
  3020. RETURN 0
  3021. END
  3022. GO
  3023. /****** Object: StoredProcedure [dbo].[pcCaCvIntentionByBaiduPushSelect] Script Date: 2018/12/13 19:08:05 ******/
  3024. SET ANSI_NULLS ON
  3025. GO
  3026. SET QUOTED_IDENTIFIER ON
  3027. GO
  3028. --====================================
  3029. --创建: Andy Yin
  3030. --获得所有PaMainID简历浏览记录个数,用于给app推送数据。
  3031. --====================================
  3032. CREATE PROCEDURE [dbo].[pcCaCvIntentionByBaiduPushSelect]
  3033. (
  3034. @WHERE VARCHAR(1000)
  3035. )
  3036. AS
  3037. BEGIN
  3038. BEGIN TRY
  3039. SET @WHERE = REPLACE(dbo.SafeSQL(@WHERE), '''', '')
  3040. DECLARE @SQL AS VARCHAR(2000)
  3041. SET @SQL = 'SELECT d.paMainID, count(*) as Count
  3042. FROM caCvIntention a WITH(NOLOCK)
  3043. inner join Job b WITH(NOLOCK) On a.JobID = b.ID
  3044. inner join cpMain c WITH(NOLOCK) On b.cpMainID = c.ID
  3045. inner join cvMain d WITH(NOLOCK) On a.cvMainID = d.ID
  3046. WHERE PersonDeleted=0'
  3047. IF LEN(@WHERE)>0
  3048. SET @SQL = @SQL + ' ' + @WHERE
  3049. SET @SQL=@SQL + ' GROUP BY d.pamainiD '
  3050. EXEC(@SQL)
  3051. END TRY
  3052. BEGIN CATCH
  3053. END CATCH
  3054. END
  3055. GO
  3056. /****** Object: StoredProcedure [dbo].[pcCaCvIntentionSelect] Script Date: 2018/12/13 19:08:05 ******/
  3057. SET ANSI_NULLS ON
  3058. GO
  3059. SET QUOTED_IDENTIFIER ON
  3060. GO
  3061. --lucifer 2018-3-22
  3062. CREATE PROCEDURE [dbo].[pcCaCvIntentionSelect]
  3063. (
  3064. @WHERE VARCHAR(1000),
  3065. @Order VARCHAR(100)
  3066. )
  3067. AS
  3068. SET NOCOUNT ON
  3069. BEGIN
  3070. SET @WHERE = dbo.SafeSQL(@WHERE)
  3071. SET @ORDER = dbo.SafeSQL(@ORDER)
  3072. DECLARE @SQL AS VARCHAR(2000)
  3073. SET @SQL = 'SELECT JobID,cvMainID,a.AddDate,b.Name as JobName,b.IssueDate,b.IssueEnd,Reply,ReplyDate,d.Name cvName,
  3074. b.dcRegionID,b.IsDelete,c.Name as cpName,c.ID as cpID,c.HasLicence, c.IsAgent, c.MemberType,a.ID,
  3075. b.dcSalaryId, b.dcSalaryIdMax, b.SecondId EnJobID, c.SecondId EnCpMainID,ISNULL((SELECT IsOnline FROM caOnline WHERE caMainId =b.caMainID), 0) AS IsOnline,b.CaMainID,b.Valid JobValid,
  3076. b.Welfare1,b.Welfare2,b.Welfare3,b.Welfare4,b.Welfare5,b.Welfare6,b.Welfare7,b.Welfare8,
  3077. b.Welfare9,b.Welfare10,b.Welfare11,b.Welfare12,b.Welfare13,b.Welfare14,b.Welfare15,b.Welfare16,
  3078. b.Welfare17,b.Welfare18,b.Welfare19,c.ReplyRate, c.LogoFile LogoUrl, e.DescriptionCp SalaryMin, f.DescriptionCp SalaryMax
  3079. FROM caCvIntention a WITH(NOLOCK)
  3080. inner join Job b WITH(NOLOCK) On a.JobID = b.ID
  3081. inner join cpMain c WITH(NOLOCK) On b.cpMainID = c.ID
  3082. inner join cvMain d WITH(NOLOCK) On a.cvMainID = d.ID
  3083. inner join dcSalary e WITH(NOLOCK) On b.dcSalaryId = e.ID
  3084. inner join dcSalary f WITH(NOLOCK) On b.dcSalaryIdMax = f.ID
  3085. WHERE PersonDeleted=0'
  3086. IF LEN(@WHERE) > 0
  3087. SET @SQL=@SQL + ' ' + @WHERE
  3088. IF LEN(@ORDER) > 0
  3089. SET @SQL=@SQL + ' ORDER BY '+@ORDER
  3090. --PRINT @SQL
  3091. EXEC(@SQL)
  3092. END
  3093. GO
  3094. /****** Object: StoredProcedure [dbo].[pcCaCvIntentionUpdate] Script Date: 2018/12/13 19:08:05 ******/
  3095. SET ANSI_NULLS ON
  3096. GO
  3097. SET QUOTED_IDENTIFIER ON
  3098. GO
  3099. CREATE PROCEDURE [dbo].[pcCaCvIntentionUpdate]
  3100. (
  3101. @ID INT,
  3102. @Reply TINYINT,
  3103. @paMainID INT
  3104. )
  3105. AS
  3106. BEGIN TRY
  3107. IF NOT EXISTS(SELECT 'x' FROM caCvIntention a WITH(NOLOCK),cvMain b WITH(NOLOCK) WHERE a.id=@ID AND a.cvMainID=b.ID AND b.paMainID=@paMainID)
  3108. GOTO ERR
  3109. UPDATE caCvIntention
  3110. SET Reply=@Reply,ReplyDate=GETDATE()
  3111. WHERE ID=@ID
  3112. RETURN 1
  3113. END TRY
  3114. BEGIN CATCH
  3115. GOTO ERR
  3116. END CATCH
  3117. ERR:
  3118. BEGIN
  3119. RETURN 0
  3120. END
  3121. GO
  3122. /****** Object: StoredProcedure [dbo].[pcCaCvViewLogByBaiduPushSelect] Script Date: 2018/12/13 19:08:06 ******/
  3123. SET ANSI_NULLS ON
  3124. GO
  3125. SET QUOTED_IDENTIFIER ON
  3126. GO
  3127. --====================================
  3128. --创建: Andy Yin
  3129. --获得半小时内所有的简历浏览记录个数,按照个人PamainID查找。用于给app推送数据。
  3130. --====================================
  3131. CREATE PROCEDURE [dbo].[pcCaCvViewLogByBaiduPushSelect]
  3132. AS
  3133. BEGIN
  3134. SELECT e.paMainID, COUNT(a.camainid) AS Count
  3135. FROM caCvviewLog a WITH(NOLOCK)
  3136. inner join camain b WITH(NOLOCK) on a.camainid=b.id
  3137. inner join cpmain c with(nolock) on c.id=b.cpmainid
  3138. inner join cvmain e WITH(NOLOCK) on a.cvmainid=e.id
  3139. inner join job d with(nolock) on a.camainid=d.camainid
  3140. WHERE a.AddDate>DATEADD(hour,-0.5,GetDate()) --当前日期加一周后的日期()
  3141. Group by e.paMainID
  3142. END
  3143. GO
  3144. /****** Object: StoredProcedure [dbo].[pcCaCvViewLogSelect] Script Date: 2018/12/13 19:08:06 ******/
  3145. SET ANSI_NULLS ON
  3146. GO
  3147. SET QUOTED_IDENTIFIER ON
  3148. GO
  3149. --====================================
  3150. --创建: lucifer
  3151. --检查: Sean 2010-10-14
  3152. --企业浏览记录
  3153. --====================================
  3154. CREATE PROCEDURE [dbo].[pcCaCvViewLogSelect]
  3155. (
  3156. @AllJobID VARCHAR(1000),
  3157. @AllCvMainID VARCHAR(1000),
  3158. @ORDER VARCHAR(200)
  3159. )
  3160. AS
  3161. SET NOCOUNT ON
  3162. BEGIN
  3163. SET @AllJobID = dbo.FormatIDS(@AllJobID)
  3164. SET @AllCvMainID = dbo.FormatIDS(@AllCvMainID)
  3165. SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '')
  3166. SELECT * ,0 AS IsApply INTO #t FROM caCvviewLog WITH(NOLOCK)
  3167. WHERE cvMainId in(SELECT * FROM dbo.fnSplit(@AllCvMainID, ','))
  3168. UPDATE #t SET IsApply=1
  3169. FROM #t a,exjobapply b, job c,caMain d
  3170. WHERE b.jobid=c.id and a.caMainid = d.id and c.cpMainID=d.cpMainID
  3171. DECLARE @SQL VARCHAR(2000)
  3172. SET @SQL = 'SELECT DISTINCT a.camainid,a.cvmainid,a.adddate,b.Name as caName,
  3173. b.Email,b.Mobile,b.Telephone,b.Gender,b.IsPhoneHide,b.IsNameHide,
  3174. b.IsMobileHide,c.Name as cpName,c.Address,c.ID as cpID,c.HasLicence,
  3175. c.IsAgent,e.Name cvName, c.Membertype, c.dcRegionId, c.SecondId EnCpMainID, c.LogoFile LogoUrl
  3176. from #t a WITH(NOLOCK)
  3177. inner join camain b WITH(NOLOCK) on a.camainid=b.id
  3178. inner join cpmain c with(nolock) on c.id=b.cpmainid
  3179. inner join cvmain e WITH(NOLOCK) on a.cvmainid=e.id'
  3180. IF LEN(@AllJobID) > 0
  3181. SET @SQL = @SQL + ' inner join job d with(nolock) on a.camainid=d.camainid'
  3182. SET @SQL = @SQL + ' WHERE a.cvMainId in(' + @AllCvMainID +')'
  3183. IF LEN(@AllJobID) > 0
  3184. SET @SQL = @SQL + ' AND d.id in(' + @AllJobID +')'
  3185. IF LEN(@ORDER) > 0
  3186. SET @SQL = @SQL + ' ORDER BY ' + @ORDER
  3187. EXEC(@SQL)
  3188. END
  3189. SET NOCOUNT OFF
  3190. GO
  3191. /****** Object: StoredProcedure [dbo].[pcCaCvViewLogSelect20171218] Script Date: 2018/12/13 19:08:06 ******/
  3192. SET ANSI_NULLS ON
  3193. GO
  3194. SET QUOTED_IDENTIFIER ON
  3195. GO
  3196. CREATE PROCEDURE [dbo].[pcCaCvViewLogSelect20171218]
  3197. (
  3198. @AllCvMainID VARCHAR(1000),
  3199. @Page SMALLINT
  3200. )
  3201. AS
  3202. SET NOCOUNT ON
  3203. BEGIN
  3204. IF @AllCvMainID = ''
  3205. RETURN
  3206. SET @AllCvMainID = dbo.FormatIDS(@AllCvMainID)
  3207. SELECT ROW_NUMBER() OVER(ORDER BY AddDate DESC) TitleID, caMainId, cvMainId, AddDate, NULL JobId ,0 IsApply
  3208. INTO #1
  3209. FROM caCvviewLog WITH(NOLOCK INDEX(IX_caCvViewLog_cvMainID))
  3210. WHERE cvMainId IN(SELECT a FROM dbo.fnSplit(@AllCvMainID, ','))
  3211. AND EXISTS(SELECT TOP 1 'X' FROM JobPublish WITH(NOLOCK) WHERE caMainID = caCvviewLog.caMainID)
  3212. SELECT * INTO #T
  3213. FROM #1
  3214. WHERE TitleID > (@Page - 1) * 20 AND TitleID <= @Page * 20
  3215. -- SELECT * INTO #T FROM (
  3216. -- SELECT ROW_NUMBER() OVER(ORDER BY AddDate DESC) TitleID, caMainId, cvMainId, AddDate, NULL JobId ,0 IsApply
  3217. -- FROM caCvviewLog WITH(NOLOCK INDEX(IX_caCvViewLog_cvMainID))
  3218. -- WHERE cvMainId IN(SELECT a FROM dbo.fnSplit(@AllCvMainID, ','))
  3219. -- AND EXISTS(SELECT TOP 1 'X' FROM JobPublish WITH(NOLOCK) WHERE caMainID = caCvviewLog.caMainID)
  3220. -- ) a WHERE TitleID > (@Page - 1) * 20 AND TitleID <= @Page * 20
  3221. UPDATE #T SET IsApply = 1
  3222. WHERE EXISTS(
  3223. SELECT TOP 1 'X' FROM exJobApply a WITH(NOLOCK), JobPublish b WITH(NOLOCK)
  3224. WHERE a.JobID = b.ID AND a.cvMainID = #T.cvMainID AND b.caMainID = #T.caMainID
  3225. )
  3226. UPDATE #T SET JobId = (SELECT TOP 1 a.ID FROM JobPublish a WITH(NOLOCK), caMain b WITH(NOLOCK), cpMainPublish c WITH(NOLOCK)
  3227. WHERE a.cpMainId = b.cpMainID AND b.cpMainID = c.ID AND a.dcJobTypeId IN(SELECT dcJobTypeID FROM cvJobType WITH(NOLOCK) WHERE cvMainId = #T.cvMainId)
  3228. AND b.Id = #T.caMainID ORDER BY a.RefreshDate DESC)
  3229. UPDATE #T SET JobId = (SELECT TOP 1 a.ID FROM JobPublish a WITH(NOLOCK), caMain b WITH(NOLOCK), cpMainPublish c WITH(NOLOCK)
  3230. WHERE a.cpMainId = b.cpMainID AND b.cpMainID = c.ID AND LEFT(a.dcJobTypeId, 2) IN(SELECT dcJobTypeID FROM cvJobType WITH(NOLOCK) WHERE cvMainId = #T.cvMainId)
  3231. AND b.Id = #T.caMainID ORDER BY a.RefreshDate DESC) WHERE JobId IS NULL
  3232. UPDATE #T SET JobId = (SELECT TOP 1 a.ID FROM JobPublish a WITH(NOLOCK), caMain b WITH(NOLOCK), cpMainPublish c WITH(NOLOCK)
  3233. WHERE a.cpMainId = b.cpMainID AND b.cpMainID = c.ID
  3234. AND b.Id = #T.caMainID ORDER BY a.RefreshDate DESC) WHERE JobId IS NULL
  3235. SELECT a.caMainId,a.cvMainId,a.AddDate adddate,b.Name as caName,d.Id jobId,d.Name jobName,
  3236. d.SecondId EnJobId,d.NeedNumber,d.dcSalaryID, d.dcSalaryIDMax,
  3237. b.Email,b.Mobile,b.Telephone,b.Gender,b.IsPhoneHide,b.IsNameHide,b.IsMobileHide,
  3238. c.Name as cpName,c.Address,c.ID as cpID,c.HasLicence,c.IsAgent,e.Name cvName,
  3239. c.Membertype, c.dcRegionId, c.SecondId EnCpMainID, c.LogoFile LogoUrl
  3240. FROM #T a WITH(NOLOCK)
  3241. INNER JOIN caMain b WITH(NOLOCK) ON a.caMainID = b.ID
  3242. INNER JOIN cpMain c WITH(NOLOCK) ON c.ID = b.cpMainId
  3243. INNER JOIN cvMain e WITH(NOLOCK) ON a.cvMainId = e.Id
  3244. INNER JOIN JobPublish d WITH(NOLOCK) ON a.JobId = d.Id
  3245. SELECT COUNT(1)
  3246. FROM #1
  3247. END
  3248. SET NOCOUNT OFF
  3249. GO
  3250. /****** Object: StoredProcedure [dbo].[pcCaCvViewLogSelectBak] Script Date: 2018/12/13 19:08:07 ******/
  3251. SET ANSI_NULLS ON
  3252. GO
  3253. SET QUOTED_IDENTIFIER ON
  3254. GO
  3255. --====================================
  3256. --创建: lucifer
  3257. --检查: Sean 2010-10-14
  3258. --企业浏览记录
  3259. --====================================
  3260. CREATE PROCEDURE [dbo].[pcCaCvViewLogSelectBak]
  3261. (
  3262. @AllJobID VARCHAR(1000),
  3263. @AllCvMainID VARCHAR(1000),
  3264. @ORDER VARCHAR(200)
  3265. )
  3266. AS
  3267. BEGIN
  3268. SET @AllJobID = dbo.FormatIDS(@AllJobID)
  3269. SET @AllCvMainID = dbo.FormatIDS(@AllCvMainID)
  3270. SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '')
  3271. DECLARE @SQL VARCHAR(2000)
  3272. SET @SQL='SELECT DISTINCT a.camainid,a.cvmainid,a.adddate,b.Name as caName,
  3273. b.Email,b.Mobile,b.Telephone,b.Gender,b.IsPhoneHide,b.IsNameHide,
  3274. b.IsMobileHide,c.Name as cpName,c.Address,c.ID as cpID,c.HasLicence,
  3275. c.IsAgent,e.Name cvName, c.Membertype
  3276. from cacvviewlog a WITH(NOLOCK)
  3277. inner join camain b WITH(NOLOCK) on a.camainid=b.id
  3278. inner join cpmain c with(nolock) on c.id=b.cpmainid
  3279. inner join cvmain e WITH(NOLOCK) on a.cvmainid=e.id'
  3280. IF LEN(@AllJobID)>0
  3281. SET @SQL=@SQL+' inner join job d with(nolock) on a.camainid=d.camainid'
  3282. SET @SQL=@SQL+' WHERE a.cvMainId in(' + @AllCvMainID +')'
  3283. IF LEN(@AllJobID)>0
  3284. SET @SQL=@SQL+' AND d.id in(' + @AllJobID +')'
  3285. IF LEN(@ORDER)>0
  3286. SET @SQL=@SQL+' ORDER BY '+@ORDER
  3287. EXEC(@SQL)
  3288. END
  3289. GO
  3290. /****** Object: StoredProcedure [dbo].[PcCaMainByIsShowEmailContactSelect] Script Date: 2018/12/13 19:08:07 ******/
  3291. SET ANSI_NULLS ON
  3292. GO
  3293. SET QUOTED_IDENTIFIER ON
  3294. GO
  3295. create PROCEDURE [dbo].[PcCaMainByIsShowEmailContactSelect]
  3296. (
  3297. @JobId INT
  3298. )
  3299. AS
  3300. BEGIN
  3301. SELECT 'x' FROM caMain WHERE id IN(SELECT caMainId FROM Job WHERE Id = @JobId) AND IsShowEmailContact = 1
  3302. END
  3303. GO
  3304. /****** Object: StoredProcedure [dbo].[pcCaPlaintByIDSelect_old] Script Date: 2018/12/13 19:08:07 ******/
  3305. SET ANSI_NULLS ON
  3306. GO
  3307. SET QUOTED_IDENTIFIER ON
  3308. GO
  3309. --============
  3310. --应该没有用了
  3311. --============
  3312. CREATE PROCEDURE [dbo].[pcCaPlaintByIDSelect_old]
  3313. (
  3314. @ID INT
  3315. )
  3316. AS
  3317. BEGIN
  3318. SELECT *
  3319. FROM CaPlaint WITH(NOLOCK)
  3320. WHERE ID = @ID
  3321. END
  3322. GO
  3323. /****** Object: StoredProcedure [dbo].[pccaplaintIsViewedUpdate] Script Date: 2018/12/13 19:08:07 ******/
  3324. SET ANSI_NULLS ON
  3325. GO
  3326. SET QUOTED_IDENTIFIER ON
  3327. GO
  3328. --========================================
  3329. --asp中取所有IsViewed = false的id
  3330. --检查 sean 2010-10-10
  3331. --========================================
  3332. CREATE PROCEDURE [dbo].[pccaplaintIsViewedUpdate]
  3333. (
  3334. @AllID VARCHAR(200)
  3335. )
  3336. AS
  3337. BEGIN TRY
  3338. SET @AllID = dbo.FormatIDS(@AllID)
  3339. DECLARE @T AS TABLE(ID INT)
  3340. INSERT INTO @T SELECT * FROM dbo.fnSplit(@AllID, ',')
  3341. UPDATE caplaint SET IsViewed=1 WHERE ID IN(SELECT ID FROM @T)
  3342. RETURN 1
  3343. END TRY
  3344. BEGIN CATCH
  3345. RETURN 0
  3346. END CATCH
  3347. GO
  3348. /****** Object: StoredProcedure [dbo].[pcCaPlaintNoViewSelect] Script Date: 2018/12/13 19:08:07 ******/
  3349. SET ANSI_NULLS ON
  3350. GO
  3351. SET QUOTED_IDENTIFIER ON
  3352. GO
  3353. --========================================
  3354. --asp中取所有IsViewed = false的id
  3355. --检查 sean 2010-10-10
  3356. --个人首页用,未查看的企业投诉
  3357. --========================================
  3358. CREATE PROCEDURE [dbo].[pcCaPlaintNoViewSelect]
  3359. (
  3360. @PaMainID INT
  3361. )
  3362. AS
  3363. BEGIN
  3364. SELECT a.*
  3365. FROM CaPlaint a WITH(NOLOCK INDEX(IX_caPlaint_cvMainID)), cvMain b WITH(NOLOCK INDEX(IX_cvMain_paMainID)), caMain c WITH(NOLOCK)
  3366. WHERE a.cvMainID = b.ID
  3367. AND b.PaMainID = @PaMainID
  3368. AND a.caMainID = c.ID
  3369. AND c.IsDelete = 0
  3370. AND a.IsViewed = 0
  3371. AND a.ReplyType = 1
  3372. ORDER BY a.ID DESC
  3373. END
  3374. GO
  3375. /****** Object: StoredProcedure [dbo].[pcCaPlaintSelect] Script Date: 2018/12/13 19:08:07 ******/
  3376. SET ANSI_NULLS ON
  3377. GO
  3378. SET QUOTED_IDENTIFIER ON
  3379. GO
  3380. CREATE PROCEDURE [dbo].[pcCaPlaintSelect]
  3381. (
  3382. @PaMainID INT
  3383. )
  3384. AS
  3385. BEGIN
  3386. SELECT a.*,d.ID cpMainID ,d.name CompanyName
  3387. FROM CaPlaint a WITH(NOLOCK INDEX(IX_caPlaint_cvMainID))
  3388. INNER JOIN cvMain b WITH(NOLOCK INDEX(IX_cvMain_paMainID))
  3389. ON a.cvMainID = b.ID
  3390. LEFT JOIN caMain c WITH(NOLOCK)
  3391. ON a.caMainID = c.ID
  3392. LEFT JOIN cpMain d WITH(NOLOCK)
  3393. ON c.cpMainID = d.ID
  3394. WHERE b.PaMainID = @PaMainID
  3395. AND (c.IsDelete = 0 OR c.IsDelete IS NULL)
  3396. AND a.ReplyType = 1
  3397. ORDER BY a.ID DESC
  3398. END
  3399. GO
  3400. /****** Object: StoredProcedure [dbo].[pcChatOnLineByPaMainIDSelect] Script Date: 2018/12/13 19:08:08 ******/
  3401. SET ANSI_NULLS ON
  3402. GO
  3403. SET QUOTED_IDENTIFIER ON
  3404. GO
  3405. CREATE PROCEDURE [dbo].[pcChatOnLineByPaMainIDSelect]
  3406. (
  3407. @PaMainID INT --求职者的ID
  3408. )
  3409. AS
  3410. SET NOCOUNT ON
  3411. --INSERT INTO procLog SELECT 'pcChatOnLineByPaMainIDSelect', @PaMainID, GETDATE()
  3412. BEGIN
  3413. CREATE TABLE #UserList
  3414. (
  3415. ChatOnlineID INT,
  3416. CaMainID INT,
  3417. CvMainID INT,
  3418. EndDate SMALLDATETIME,
  3419. LastChatDate SMALLDATETIME,
  3420. SumUnRead INT,
  3421. IsHidden BIT
  3422. )
  3423. UPDATE ChatOnline
  3424. SET paUnViewed = 0
  3425. WHERE paUnViewed > 0
  3426. AND cvMainId IN(SELECT ID FROM cvMain WHERE paMainId = @PaMainId)
  3427. UPDATE a
  3428. SET a.paUnViewed = b.Cnt
  3429. FROM ChatOnline a, (
  3430. SELECT MAX(a.ID) Id, COUNT(*) Cnt
  3431. FROM ChatOnline a, ChatOnlineLog b
  3432. WHERE a.id = b.ChatOnlineID
  3433. AND b.IsViewed = 0
  3434. AND b.SenderType <> 2 --不是个人发送的
  3435. AND a.cvMainId IN(SELECT ID FROM cvMain WHERE paMainId = @PaMainId)
  3436. GROUP BY a.CaMainId, a.CvMainID
  3437. ) b
  3438. WHERE a.Id = b.Id
  3439. --个人的联系人列表,有留言的
  3440. INSERT INTO #UserList
  3441. SELECT MAX(ID), CaMainID, CvMainID, MAX(EndDate), MAX(StartDate), SUM(paUnViewed), 0
  3442. FROM ChatOnline
  3443. WHERE cvMainId IN(SELECT ID FROM cvMain WHERE paMainId = @PaMainId) --当前个人
  3444. AND (paUnViewed > 0 OR StartDate > GETDATE() - 15)
  3445. GROUP BY CaMainID, cvMainId
  3446. --个人联系列表,15之外曾有联系的,隐藏不显示
  3447. INSERT INTO #UserList
  3448. SELECT MAX(ID), CaMainID, CvMainID, MAX(EndDate), MAX(StartDate), 0, 1
  3449. FROM ChatOnline
  3450. WHERE cvMainId IN (SELECT ID FROM CvMain WHERE PaMainID = @PaMainID) --当前个人用户
  3451. AND CaMainID NOT IN(SELECT CaMainID FROM #UserList)
  3452. GROUP BY caMainId, CvMainID
  3453. SELECT a.*, b.Name CpName, b.SecondID, c.Name UserName,
  3454. c.cpMainID, ISNULL(d.IsOnline, 0) IsOnline
  3455. FROM #UserList a
  3456. INNER JOIN caMain c ON a.caMainID = c.ID
  3457. INNER JOIN cpMain b ON b.ID = c.cpMainID
  3458. LEFT JOIN caOnline d ON c.Id = d.caMainId
  3459. ORDER BY a.LastChatDate DESC
  3460. DROP TABLE #UserList
  3461. END
  3462. GO
  3463. /****** Object: StoredProcedure [dbo].[pcChatOnLineListByCaMainIDSelect] Script Date: 2018/12/13 19:08:08 ******/
  3464. SET ANSI_NULLS ON
  3465. GO
  3466. SET QUOTED_IDENTIFIER ON
  3467. GO
  3468. -----创建人:Nick
  3469. -----创建时间:2014-9-9
  3470. -----用途:根据企业用户ID获取聊天列表
  3471. CREATE PROCEDURE [dbo].[pcChatOnLineListByCaMainIDSelect]
  3472. (
  3473. @CaMainID INT --企业用户ID
  3474. )
  3475. AS
  3476. --INSERT INTO procLog SELECT 'pcChatOnLineListByCaMainIDSelect', @caMainID, GETDATE()
  3477. BEGIN
  3478. DECLARE @ChatList1 AS TABLE
  3479. (
  3480. CvMainID INT,
  3481. CaMainID INT,
  3482. ManagerUserID SMALLINT,
  3483. Name VARCHAR(100),
  3484. Message NVARCHAR(200),
  3485. SendDate DATETIME,
  3486. NoViewedNum INT,
  3487. OnlineStatus INT,
  3488. Photo VARCHAR(50),
  3489. OpenName INT
  3490. )
  3491. DECLARE @ChatList2 AS TABLE
  3492. (
  3493. CvMainID INT,
  3494. CaMainID INT,
  3495. ManagerUserID SMALLINT,
  3496. Name VARCHAR(100),
  3497. Message NVARCHAR(200),
  3498. SendDate DATETIME,
  3499. NoViewedNum INT,
  3500. OnlineStatus INT,
  3501. Photo VARCHAR(50),
  3502. HasPhoto INT
  3503. )
  3504. --客服或顾问聊天列表
  3505. INSERT INTO @ChatList1(CvMainID,CaMainID,ManagerUserID,Name,OnlineStatus)
  3506. SELECT DISTINCT a.cvMainID,a.caMainID ,a.ManagerUserID,'客服' as Name,0
  3507. FROM ChatOnline a
  3508. WHERE a.caMainID = @CaMainID
  3509. AND (a.AddDate > GETDATE() - 15 OR ID IN (
  3510. SELECT ChatOnlineID FROM ChatOnlineLog WHERE IsViewed = 0 ))
  3511. AND (a.cvMainID IS NULL or a.cvMainID = 0)
  3512. UPDATE a SET
  3513. Message = (
  3514. SELECT TOP 1 MESSAGE
  3515. FROM ChatOnlineLog
  3516. WHERE ChatOnlineID IN (SELECT ID FROM CHATONLINE WHERE CaMainID = a.CaMainID AND ManagerUserID = a.ManagerUserID)
  3517. Order BY AddDate DESC
  3518. ),
  3519. SendDate = (
  3520. SELECT TOP 1 AddDate
  3521. FROM ChatOnlineLog
  3522. WHERE ChatOnlineID IN (SELECT ID FROM CHATONLINE WHERE CaMainID = a.CaMainID AND ManagerUserID = a.ManagerUserID)
  3523. Order BY AddDate DESC),
  3524. NoViewedNum = (
  3525. SELECT COUNT(*)
  3526. FROM ChatOnlineLog
  3527. WHERE ChatOnlineID IN (SELECT ID FROM CHATONLINE WHERE CaMainID = a.CaMainID AND ManagerUserID = a.ManagerUserID)
  3528. AND IsViewed = 0
  3529. ),
  3530. Photo = (
  3531. SELECT TOP 1 Photo FROM ManagerUser WHERE ID = a.ManagerUserID
  3532. ),
  3533. OnlineStatus = (
  3534. SELECT TOP 1 SOLStatus FROM ManagerUser WHERE ID = a.ManagerUserID
  3535. ),
  3536. OpenName = (
  3537. SELECT TOP 1 OpenName FROM ManagerUser WHERE ID = a.ManagerUserID
  3538. )
  3539. FROM @ChatList1 a
  3540. UPDATE @ChatList1 SET Photo = '' WHERE OpenName <> 1
  3541. --跟个人聊天列表
  3542. INSERT INTO @ChatList2(CvMainID,CaMainID,ManagerUserID,Name,OnlineStatus)
  3543. SELECT DISTINCT a.cvMainID,a.caMainID ,a.ManagerUserID,c.Name,dbo.GetPaOnlineStatus(c.ID)
  3544. FROM ChatOnline a , cvMain b,PaMain c
  3545. WHERE a.caMainID = @CaMainID
  3546. AND a.cvMainID = b.ID
  3547. AND b.PaMainID = c.ID
  3548. AND (a.AddDate > GETDATE() - 15 OR a.ID IN (
  3549. SELECT ChatOnlineID FROM ChatOnlineLog WHERE IsViewed = 0 AND SenderType = 2))
  3550. AND (a.ManagerUserID IS NULL or a.ManagerUserID = 0)
  3551. UPDATE a SET
  3552. Message = (
  3553. SELECT TOP 1 MESSAGE
  3554. FROM ChatOnlineLog
  3555. WHERE ChatOnlineID IN (SELECT ID FROM CHATONLINE WHERE CvMainID = a.CvMainID AND CaMainID = a.CaMainID)
  3556. Order BY AddDate DESC
  3557. ),
  3558. SendDate = (
  3559. SELECT TOP 1 AddDate
  3560. FROM ChatOnlineLog
  3561. WHERE ChatOnlineID IN (SELECT ID FROM CHATONLINE WHERE CvMainID = a.CvMainID AND CaMainID = a.CaMainID)
  3562. Order BY AddDate DESC),
  3563. NoViewedNum = (
  3564. SELECT COUNT(*)
  3565. FROM ChatOnlineLog
  3566. WHERE ChatOnlineID IN (SELECT ID FROM CHATONLINE WHERE CvMainID = a.CvMainID AND CaMainID = a.CaMainID)
  3567. AND IsViewed = 0
  3568. AND SenderType = 2
  3569. ),
  3570. Photo = (
  3571. SELECT PhotoProcessed FROM paPhoto WHERE paMainID = (
  3572. SELECT PaMainID FROM CvMain WHERE ID = a.CvMainID
  3573. )
  3574. ),
  3575. HasPhoto = (
  3576. SELECT HasPhoto FROM paMain WHERE ID = (
  3577. SELECT PaMainID FROM CvMain WHERE ID = a.CvMainID
  3578. )
  3579. )
  3580. FROM @ChatList2 a
  3581. SELECT * FROM @ChatList1
  3582. SELECT * FROM @ChatList2
  3583. END
  3584. GO
  3585. /****** Object: StoredProcedure [dbo].[pcChatOnLineListByPaMainIDSelect] Script Date: 2018/12/13 19:08:08 ******/
  3586. SET ANSI_NULLS ON
  3587. GO
  3588. SET QUOTED_IDENTIFIER ON
  3589. GO
  3590. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  3591. --修改人: Nick
  3592. --修改日期:2014-10-09
  3593. --修改内容:未查看消息数量问题
  3594. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  3595. CREATE PROCEDURE [dbo].[pcChatOnLineListByPaMainIDSelect]
  3596. (
  3597. @PaMainID INT --求职者的ID
  3598. )
  3599. AS
  3600. --INSERT INTO procLog SELECT 'pcChatOnlineListByPaMainIDSelect', @PaMainID, GETDATE()
  3601. BEGIN
  3602. CREATE TABLE #ChatList1
  3603. (
  3604. CvMainID INT,
  3605. CaMainID INT,
  3606. ManagerUserID SMALLINT,
  3607. Name VARCHAR(100),
  3608. Message NVARCHAR(200),
  3609. SendDate DATETIME,
  3610. NoViewedNum INT,
  3611. OnlineStatus INT,
  3612. LogoUrl VARCHAR(300)
  3613. )
  3614. CREATE TABLE #ChatList2
  3615. (
  3616. CvMainID INT,
  3617. CaMainID INT,
  3618. ManagerUserID SMALLINT,
  3619. Name VARCHAR(100),
  3620. Message NVARCHAR(200),
  3621. SendDate DATETIME,
  3622. NoViewedNum INT,
  3623. OnlineStatus INT,
  3624. LogoUrl VARCHAR(300)
  3625. )
  3626. --客服聊天列表
  3627. INSERT INTO #ChatList1(CvMainID, CaMainID, ManagerUserID, Name, OnlineStatus, LogoUrl)
  3628. SELECT DISTINCT a.cvMainID, a.caMainID, a.ManagerUserID, '客服' as Name, 0, ''
  3629. FROM ChatOnline a, caMain b
  3630. WHERE a.caMainID = b.ID AND a.cvMainID In (SELECT ID FROM CVMAIN WHERE PaMainID = @PaMainID)
  3631. AND (a.AddDate > GETDATE() - 15 OR a.ID IN (
  3632. SELECT ChatOnlineID FROM ChatOnlineLog WHERE IsViewed = 0 ))
  3633. AND (a.caMainID IS NULL or a.caMainID = 0)
  3634. UPDATE a SET
  3635. Message = (
  3636. SELECT TOP 1 MESSAGE
  3637. FROM ChatOnlinelog
  3638. WHERE ChatOnlineID IN (SELECT ID FROM ChatOnline WHERE CvMainID = a.CvMainID AND ManagerUserID = a.ManagerUserID)
  3639. Order BY AddDate DESC
  3640. ),
  3641. SendDate = (
  3642. SELECT TOP 1 AddDate
  3643. FROM ChatOnlinelog
  3644. WHERE ChatOnlineID IN (SELECT ID FROM ChatOnline WHERE CvMainID = a.CvMainID AND ManagerUserID = a.ManagerUserID)
  3645. Order BY AddDate DESC),
  3646. NoViewedNum = (
  3647. SELECT COUNT(*)
  3648. FROM ChatOnlinelog
  3649. WHERE ChatOnlineID IN (SELECT ID FROM ChatOnline WHERE CvMainID = a.CvMainID AND ManagerUserID = a.ManagerUserID)
  3650. AND IsViewed = 0
  3651. AND SenderType = 3
  3652. )
  3653. FROM #ChatList1 a
  3654. --跟企业聊天列表
  3655. INSERT INTO #ChatList2(CvMainID, CaMainID, ManagerUserID, Name, OnlineStatus, LogoUrl)
  3656. SELECT DISTINCT a.cvMainID, a.caMainID, a.ManagerUserID, c.Name, dbo.GetCaOnlineStatus(a.caMainID), c.LogoFile
  3657. FROM ChatOnline a, caMain b, CpMain c
  3658. WHERE a.cvMainID In (SELECT ID FROM CVMAIN WHERE PaMainID = @PaMainID)
  3659. AND a.caMainID = b.ID
  3660. AND b.CpMainID = c.ID
  3661. AND (a.AddDate > GETDATE() - 15 OR a.ID IN (
  3662. SELECT ChatOnlineID FROM ChatOnlineLog WHERE IsViewed = 0 ))
  3663. AND (a.ManagerUserID IS NULL or a.ManagerUserID = 0)
  3664. UPDATE a SET
  3665. Message = (
  3666. SELECT TOP 1 MESSAGE
  3667. FROM ChatOnlinelog
  3668. WHERE ChatOnlineID IN (SELECT ID FROM ChatOnline WHERE CvMainID = a.CvMainID AND CaMainID = a.CaMainID)
  3669. Order BY AddDate DESC
  3670. ),
  3671. SendDate = (
  3672. SELECT TOP 1 AddDate
  3673. FROM ChatOnlinelog
  3674. WHERE ChatOnlineID IN (SELECT ID FROM ChatOnline WHERE CvMainID = a.CvMainID AND CaMainID = a.CaMainID)
  3675. Order BY AddDate DESC),
  3676. NoViewedNum = (
  3677. SELECT COUNT(*)
  3678. FROM ChatOnlinelog
  3679. WHERE ChatOnlineID IN (SELECT ID FROM ChatOnline WHERE CvMainID = a.CvMainID AND CaMainID = a.CaMainID)
  3680. AND IsViewed = 0
  3681. AND SenderType = 1
  3682. )
  3683. FROM #ChatList2 a
  3684. SELECT * FROM #ChatList1 UNION SELECT * FROM #ChatList2
  3685. END
  3686. GO
  3687. /****** Object: StoredProcedure [dbo].[PcChatOnlineLogByPaMainIdForServiceSelect] Script Date: 2018/12/13 19:08:08 ******/
  3688. SET ANSI_NULLS ON
  3689. GO
  3690. SET QUOTED_IDENTIFIER ON
  3691. GO
  3692. create PROCEDURE [dbo].[PcChatOnlineLogByPaMainIdForServiceSelect]
  3693. (
  3694. @Id INT
  3695. )
  3696. AS
  3697. BEGIN
  3698. SELECT b.AddDate, a.ManagerUserID, b.Message, c.Name AS ManagerUserName, e.Name AS PaName, b.senderType
  3699. FROM ChatOnline a, ChatOnlineLog b, ManagerUser c, cvMain d, paMain e
  3700. WHERE a.ID = b.ChatOnlineID AND a.cvMainID=d.ID AND d.paMainID=e.ID AND a.ManagerUserID=c.ID
  3701. AND e.ID = @Id
  3702. AND ManagerUserID != 0
  3703. ORDER BY b.AddDate
  3704. END
  3705. GO
  3706. /****** Object: StoredProcedure [dbo].[pcChatOnLineLogByPaMainIDSelect] Script Date: 2018/12/13 19:08:09 ******/
  3707. SET ANSI_NULLS ON
  3708. GO
  3709. SET QUOTED_IDENTIFIER ON
  3710. GO
  3711. CREATE PROCEDURE [dbo].[pcChatOnLineLogByPaMainIDSelect]
  3712. (
  3713. @PaMainID INT --求职者的ID
  3714. )
  3715. AS
  3716. SET NOCOUNT ON
  3717. --INSERT INTO procLog SELECT 'pcChatOnLineLogByPaMainIDSelect', @PaMainID, GETDATE()
  3718. BEGIN
  3719. CREATE TABLE #ChatLog
  3720. (
  3721. CaMainID INT,
  3722. CvMainID INT,
  3723. LastMessage VARCHAR(MAX),
  3724. LastReceiverDate SMALLDATETIME,
  3725. Initiative TINYINT
  3726. )
  3727. INSERT INTO #ChatLog
  3728. SELECT
  3729. a.CaMainID,
  3730. a.CvMainID,
  3731. (SELECT TOP 1 Message FROM ChatOnlineLog WHERE ChatOnlineID = MAX(a.ID) ORDER BY AddDate DESC),
  3732. MAX(b.Adddate),
  3733. (SELECT Initiative FROM ChatOnline WHERE ID = MIN(a.ID))
  3734. FROM ChatOnline a, ChatOnlineLog b
  3735. WHERE a.id = b.ChatOnlineID
  3736. AND a.cvMainId IN (SELECT ID FROM CvMain WHERE PaMainID = @PaMainID) --当前个人用户
  3737. GROUP BY a.CaMainID,a.CvMainID
  3738. SELECT
  3739. a.*,
  3740. dbo.GetCaName(b.ID) CaName,
  3741. c.Name CpName,
  3742. d.Name CvName,
  3743. c.SecondID EnCpMainID,
  3744. c.HasLicence,
  3745. c.MemberType,
  3746. c.IsAgent,
  3747. Initiative
  3748. FROM #ChatLog a,caMain b,cpMain c,cvMain d
  3749. WHERE a.caMainID = b.id AND b.cpMainID = c.ID AND a.cvMainID = d.ID
  3750. ORDER BY LastReceiverDate DESC
  3751. END
  3752. GO
  3753. /****** Object: StoredProcedure [dbo].[pcChatOnlineSelect] Script Date: 2018/12/13 19:08:09 ******/
  3754. SET ANSI_NULLS ON
  3755. GO
  3756. SET QUOTED_IDENTIFIER ON
  3757. GO
  3758. CREATE PROCEDURE [dbo].[pcChatOnlineSelect]
  3759. (
  3760. @caMainId INT,
  3761. @paMainId INT
  3762. )
  3763. AS
  3764. SET NOCOUNT ON
  3765. BEGIN
  3766. CREATE TABLE #ChatList
  3767. (
  3768. cvMainID INT,
  3769. caMainID INT,
  3770. [Name] VARCHAR(100),
  3771. NoViewedNum INT,
  3772. OnlineStatus INT,
  3773. paMainId INT,
  3774. SecondId VARCHAR(10)
  3775. )
  3776. IF @paMainId > 0
  3777. BEGIN
  3778. DELETE FROM ChatOnlineExchange WHERE UserID = @paMainId AND UserType = 2
  3779. INSERT INTO #ChatList(cvMainID, caMainID, OnlineStatus)
  3780. SELECT TOP 100 cvMainID, caMainID, dbo.GetCaOnlineStatus(caMainID)
  3781. FROM ChatOnline WITH(NOLOCK)
  3782. WHERE caMainID > 0 AND cvMainID IN(
  3783. SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID = @paMainId
  3784. )
  3785. ORDER BY AddDate DESC
  3786. UPDATE #ChatList SET NoViewedNum = (
  3787. SELECT COUNT(1)
  3788. FROM ChatOnlineLog WITH(NOLOCK)
  3789. WHERE ChatOnlineID IN (
  3790. SELECT ID FROM ChatOnline WITH(NOLOCK)
  3791. WHERE cvMainID = #ChatList.cvMainID AND caMainID = #ChatList.caMainID
  3792. )
  3793. AND IsViewed = 0 AND SenderType = 1 AND MessageType NOT IN(6, 7)
  3794. )
  3795. UPDATE a SET a.[Name] = c.[Name] + ' ' + b.[Name]
  3796. FROM #ChatList a, cpMain b WITH(NOLOCK), caMain c WITH(NOLOCK)
  3797. WHERE b.ID = c.cpMainID AND c.ID = a.caMainID
  3798. END
  3799. ELSE IF @caMainID > 0
  3800. BEGIN
  3801. DELETE FROM ChatOnlineExchange WHERE UserID = @caMainID AND UserType = 1
  3802. INSERT INTO #ChatList(cvMainID, caMainID)
  3803. SELECT TOP 100 cvMainID, caMainID
  3804. FROM ChatOnline
  3805. WHERE caMainID = @caMainId AND cvMainID > 0
  3806. ORDER BY AddDate DESC
  3807. UPDATE #ChatList SET NoViewedNum = (
  3808. SELECT COUNT(1)
  3809. FROM ChatOnlineLog WITH(NOLOCK)
  3810. WHERE ChatOnlineID IN (
  3811. SELECT ID FROM ChatOnline WITH(NOLOCK)
  3812. WHERE cvMainID = #ChatList.cvMainID AND caMainID = #ChatList.caMainID
  3813. )
  3814. AND IsViewed = 0 AND SenderType = 2 AND MessageType NOT IN(6, 7)
  3815. )
  3816. UPDATE #ChatList SET OnlineStatus = (
  3817. SELECT TOP 1 dbo.GetPaOnlineStatus(paMainID)
  3818. FROM cvMain WITH(NOLOCK)
  3819. WHERE ID = #ChatList.cvMainID
  3820. )
  3821. UPDATE #ChatList SET [Name] = (
  3822. SELECT TOP 1 dbo.GetPaName(#ChatList.cvMainId, cpMainId)
  3823. FROM caMain WITH(NOLOCK)
  3824. WHERE ID = #ChatList.caMainId
  3825. )
  3826. UPDATE a SET a.paMainId = b.paMainId, a.SecondId = b.SecondId FROM #ChatList a, cvMain b WHERE a.cvMainId = b.Id
  3827. END
  3828. SELECT * FROM #ChatList
  3829. END
  3830. GO
  3831. /****** Object: StoredProcedure [dbo].[pcChatOnLineStatusUpdate] Script Date: 2018/12/13 19:08:09 ******/
  3832. SET ANSI_NULLS ON
  3833. GO
  3834. SET QUOTED_IDENTIFIER ON
  3835. GO
  3836. -----创建人:Nick
  3837. -----创建时间:2014-9-11
  3838. -----用途:用于修改个人或企业的在线状态
  3839. CREATE PROCEDURE [dbo].[pcChatOnLineStatusUpdate]
  3840. (
  3841. @CaMainID INT, --企业用户ID
  3842. @PaMainID INT --个人用户ID
  3843. )
  3844. AS
  3845. SET NOCOUNT ON
  3846. --INSERT INTO _1 SELECT @caMainID, @paMainId, GETDATE()
  3847. BEGIN
  3848. IF(@CaMainID !=0) --修改企业用户在线状态
  3849. BEGIN
  3850. IF NOT EXISTS(SELECT 'x' FROM caOnline WITH(NOLOCK)
  3851. WHERE caMainID = @CaMainID)
  3852. INSERT INTO caOnline (CaMainID,IsOnline,IsVi,RefreshDate)
  3853. VALUES (@CaMainID,1,0,GETDATE())
  3854. ELSE
  3855. UPDATE caOnline SET RefreshDate=GETDATE(),IsOnline=1 where caMainID=@caMainID
  3856. END
  3857. ELSE --修改个人用户在线状态
  3858. BEGIN
  3859. IF NOT EXISTS(SELECT 'x' FROM paOnline WITH(NOLOCK)
  3860. WHERE paMainID = @PaMainID)
  3861. INSERT INTO paOnline (paMainID,IsOnline,RefreshDate)
  3862. VALUES (@PaMainID,1,GETDATE())
  3863. ELSE
  3864. UPDATE paOnline SET RefreshDate=GETDATE(),IsOnline=1 where PaMainID=@PaMainID
  3865. END
  3866. END
  3867. GO
  3868. /****** Object: StoredProcedure [dbo].[pccpImageSelect] Script Date: 2018/12/13 19:08:09 ******/
  3869. SET ANSI_NULLS ON
  3870. GO
  3871. SET QUOTED_IDENTIFIER ON
  3872. GO
  3873. --=============================================
  3874. CREATE PROCEDURE [dbo].[pccpImageSelect]
  3875. @cpMainID INT
  3876. AS
  3877. BEGIN
  3878. SET NOCOUNT ON
  3879. SELECT a.*,b.HasLogo
  3880. FROM cpImage a WITH(NOLOCK ),cpMain b with(NOLOCK)
  3881. WHERE a.cpMainID= b.ID and a.ImgType=1 AND a.cpMainID=@cpMainID
  3882. SET NOCOUNT OFF
  3883. END
  3884. GO
  3885. /****** Object: StoredProcedure [dbo].[pcCpMainBycaMainIdSelect] Script Date: 2018/12/13 19:08:09 ******/
  3886. SET ANSI_NULLS ON
  3887. GO
  3888. SET QUOTED_IDENTIFIER ON
  3889. GO
  3890. /**********************8
  3891. sean 2014-10-29
  3892. ***********************/
  3893. CREATE PROCEDURE [dbo].[pcCpMainBycaMainIdSelect]
  3894. (
  3895. @caMainID INT
  3896. )
  3897. AS
  3898. --INSERT INTO procLog SELECT 'pcCpMainBycaMainIdSelect', @caMainID, GETDATE()
  3899. BEGIN
  3900. SELECT a.ID, a.Name ShowName, a.SecondID ShowID, dbo.GetCaName(b.ID) UserName, a.RegDate,
  3901. ISNULL((SELECT IsOnline FROM caOnline WITH(NOLOCK) WHERE caMainId = @caMainID), 0) IsOnline
  3902. FROM cpMain a, caMain b
  3903. WHERE a.ID = b.cpMainID
  3904. AND b.ID = @caMainID
  3905. END
  3906. GO
  3907. /****** Object: StoredProcedure [dbo].[pcCpMainByNameSelect] Script Date: 2018/12/13 19:08:10 ******/
  3908. SET ANSI_NULLS ON
  3909. GO
  3910. SET QUOTED_IDENTIFIER ON
  3911. GO
  3912. CREATE PROCEDURE [dbo].[pcCpMainByNameSelect]
  3913. (
  3914. @Name VARCHAR(25)
  3915. )
  3916. AS
  3917. --INSERT INTO procLog SELECT 'pcCpMainByNameSelect', @Name, GETDATE()
  3918. BEGIN
  3919. DECLARE @t AS TABLE(ID INT,
  3920. SecondId VARCHAR(12),
  3921. ProvinceName NVARCHAR(10),
  3922. Name NVARCHAR(50)
  3923. )
  3924. INSERT INTO @t
  3925. SELECT TOP 50 a.ID, a.SecondId,
  3926. (SELECT ProvinceName
  3927. FROM dcProvince WITH(NOLOCK)
  3928. WHERE dcProvince.ID = LEFT(a.dcRegionID, 2)) ProvinceName,
  3929. a.Name
  3930. FROM cpMainPublish a WITH(NOLOCK),
  3931. CONTAINSTABLE(cpMainPublish, Name, @Name, 100) AS b
  3932. WHERE a.Id = b.[Key]
  3933. IF NOT EXISTS(SELECT 'x' FROM @t)
  3934. BEGIN
  3935. INSERT @t
  3936. SELECT TOP 50 ID,SecondId,
  3937. (SELECT ProvinceName
  3938. FROM dcProvince WITH(NOLOCK)
  3939. WHERE dcProvince.ID = LEFT(cpMainPublish.dcRegionID, 2)) ProvinceName,
  3940. Name
  3941. FROM cpMainPublish WITH(NOLOCK INDEX(IX_cpMainPublish_Name))
  3942. WHERE Name LIKE @Name + '%'
  3943. ORDER BY RefreshDate DESC
  3944. END
  3945. SELECT * FROM @t
  3946. /*
  3947. IF (@Name LIKE '%公司%' AND LEN(@Name) > 6) OR LEN(@Name) > 10
  3948. BEGIN
  3949. SELECT TOP 50 ID,SecondId,
  3950. (SELECT ProvinceName
  3951. FROM dcProvince WITH(NOLOCK)
  3952. WHERE dcProvince.ID = cpMain.dcProvinceID)
  3953. ProvinceName,
  3954. Name
  3955. FROM cpMain WITH(NOLOCK INDEX(IX_cpmain_Name))
  3956. WHERE Name LIKE @Name + '%'
  3957. ORDER BY RefreshDate DESC
  3958. END
  3959. ELSE
  3960. BEGIN
  3961. SELECT TOP 50 ID, SecondId,
  3962. (SELECT ProvinceName
  3963. FROM dcProvince WITH(NOLOCK)
  3964. WHERE dcProvince.ID = cpMain.dcProvinceID) ProvinceName,
  3965. Name
  3966. FROM cpMain WITH(NOLOCK)
  3967. WHERE Name LIKE '%' + @Name + '%'
  3968. ORDER BY RefreshDate DESC
  3969. END
  3970. */
  3971. END
  3972. GO
  3973. /****** Object: StoredProcedure [dbo].[pcCvAppendixByIDSelect] Script Date: 2018/12/13 19:08:10 ******/
  3974. SET ANSI_NULLS ON
  3975. GO
  3976. SET QUOTED_IDENTIFIER ON
  3977. GO
  3978. --=============================================
  3979. -- 创建: sean
  3980. -- 检查: 2010-9-27
  3981. -- 说明: 取消各字段,改为*
  3982. --=============================================
  3983. CREATE PROCEDURE [dbo].[pcCvAppendixByIDSelect]
  3984. @ID INT
  3985. AS
  3986. BEGIN
  3987. SELECT *
  3988. FROM CvAppendix WITH(NOLOCK INDEX(PK_cvAppendix))
  3989. WHERE ID = @ID
  3990. END
  3991. GO
  3992. /****** Object: StoredProcedure [dbo].[pcCvAppendixDelete] Script Date: 2018/12/13 19:08:10 ******/
  3993. SET ANSI_NULLS ON
  3994. GO
  3995. SET QUOTED_IDENTIFIER ON
  3996. GO
  3997. --=============================================
  3998. -- 创建: sean
  3999. -- 检查: 2010-9-27
  4000. -- 说明: 取消pcCvMainByCvLevelUpdate,取消pcCvMainVerifyResultCheck
  4001. -- 修改:Lambo,2010-11-25
  4002. -- 描述:增加了paMainID参数,判断是否是本人的
  4003. --=============================================
  4004. CREATE PROCEDURE [dbo].[pcCvAppendixDelete]
  4005. @ID INT,
  4006. @paMainID INT
  4007. AS
  4008. BEGIN TRAN
  4009. BEGIN TRY
  4010. DECLARE @cvMainID AS INT
  4011. DECLARE @RETURN AS VARCHAR(2)
  4012. SELECT @cvMainID = cvMainID FROM CvAppendix WITH(NOLOCK) WHERE ID = @ID
  4013. IF @cvMainID IS NULL
  4014. GOTO ERR
  4015. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK)
  4016. WHERE ID = @cvMainID AND paMainID = @paMainID)
  4017. GOTO ERR
  4018. DELETE FROM bsCvModify WHERE SubID = @ID AND Location LIKE 'c%'
  4019. DELETE FROM CvAppendix WHERE ID=@ID
  4020. EXEC @RETURN = pcCvMainByCvLevelCheck @cvMainID, 10
  4021. END TRY
  4022. BEGIN CATCH
  4023. GOTO ERR
  4024. END CATCH
  4025. COMMIT TRAN
  4026. RETURN @RETURN
  4027. ERR:
  4028. BEGIN
  4029. ROLLBACK TRAN
  4030. RETURN 3
  4031. END
  4032. GO
  4033. /****** Object: StoredProcedure [dbo].[pcCvAppendixSave] Script Date: 2018/12/13 19:08:10 ******/
  4034. SET ANSI_NULLS ON
  4035. GO
  4036. SET QUOTED_IDENTIFIER ON
  4037. GO
  4038. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  4039. -- 创建: Sean
  4040. -- 检查: 2010-9-27 未完成,原先隐藏了对bsCvModify的操作
  4041. -- 修改:Lambo,2010-11-25
  4042. -- 描述:增加了paMainID参数,判断是否是本人的
  4043. -- 修改:harry 重复证书 增加描述时间判断是否重复 2018-1-4
  4044. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  4045. CREATE PROCEDURE [dbo].[pcCvAppendixSave]
  4046. (
  4047. @Type INT,
  4048. @ID INT,
  4049. @cvMainID INT,
  4050. @dcAppendixID SMALLINT,
  4051. @Name VARCHAR(250),
  4052. @Description VARCHAR(1000),
  4053. @AccessDate SMALLINT,
  4054. @paMainID INT
  4055. )
  4056. AS
  4057. SET NOCOUNT ON
  4058. IF CHARINDEX('<', @Name) > 0
  4059. SET @Name = REPLACE(@Name, '<', '')
  4060. IF CHARINDEX('<', @Description) > 0
  4061. SET @Description = REPLACE(@Description, '<', '')
  4062. BEGIN TRAN
  4063. ----检查是否是该账号的简历
  4064. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID AND paMainID = @paMainID)
  4065. GOTO ERR1
  4066. ----检查是否是该简历的证书
  4067. IF @ID > 0
  4068. IF NOT EXISTS(SELECT 'x' FROM cvAppendix WITH(NOLOCK) WHERE ID = @ID AND cvMainID = @cvMainID)
  4069. GOTO ERR2
  4070. ----不能有重复的证件
  4071. IF EXISTS(SELECT 'x' FROM cvAppendix WITH(NOLOCK)
  4072. WHERE cvMainID = @cvMainID AND dcAppendixID = @dcAppendixID
  4073. AND ID <> @ID AND dcAppendixID < 999 AND Description = @Description AND AccessDate = @AccessDate)
  4074. GOTO ERR3
  4075. SELECT @Description = dbo.SafeSql(dbo.TextTrim(@Description)),
  4076. @Name = dbo.SafeSql(dbo.TextTrim(@Name))
  4077. IF @dcAppendixID IS NULL
  4078. GOTO ERR4
  4079. IF @dcAppendixID = 999 AND @Name IS NULL
  4080. GOTO ERR5
  4081. IF @dcAppendixID < 999
  4082. SELECT @Name = Description FROM dcAppendix WITH(NOLOCK) WHERE ID = @dcAppendixID
  4083. DECLARE @MaxId AS INT
  4084. DECLARE @NameOld AS VARCHAR(250)
  4085. DECLARE @DescriptionOld AS VARCHAR(1000)
  4086. DECLARE @CNT AS INT
  4087. BEGIN TRY
  4088. IF @Type = 0 --中文
  4089. BEGIN
  4090. DECLARE @N AS NVARCHAR(50)
  4091. DECLARE @D AS NVARCHAR(200)
  4092. SET @N = @Name
  4093. SET @D = @Description
  4094. IF @ID>0 --修改证书
  4095. BEGIN
  4096. SELECT @NameOld = dbo.TextTrim(Name), @DescriptionOld = dbo.TextTrim(Description)
  4097. FROM cvAppendix WITH(NOLOCK)
  4098. WHERE ID = @ID
  4099. UPDATE CvAppendix SET
  4100. Name = @N,
  4101. dcAppendixID = @dcAppendixID,
  4102. Description = @D,
  4103. AccessDate = @AccessDate
  4104. WHERE ID = @ID
  4105. SET @MaxID = @ID
  4106. IF @dcAppendixID = 999
  4107. BEGIN
  4108. IF ISNULL(@NameOld, '') <> ISNULL(@N, '')
  4109. BEGIN
  4110. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'cc1'
  4111. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'cc1',@N)
  4112. END
  4113. END
  4114. ELSE
  4115. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'cc1'
  4116. IF @D IS NULL
  4117. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'cc2'
  4118. ELSE
  4119. IF ISNULL(LTRIM(@DescriptionOld), '') <> @D
  4120. BEGIN
  4121. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'cc2'
  4122. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'cc2',@D)
  4123. END
  4124. END
  4125. ELSE --新增证书
  4126. BEGIN
  4127. SELECT @CNT=COUNT(*) FROM CvAppendix WITH(NOLOCK) WHERE cvMainID = @cvMainID
  4128. IF @CNT<10
  4129. BEGIN
  4130. INSERT INTO CvAppendix(cvMainID, Name, AccessDate, dcAppendixID, Description)
  4131. VALUES(@cvMainID, @N, @AccessDate, @dcAppendixID, @D)
  4132. SET @MaxID = @@IDENTITY
  4133. IF @dcAppendixID = 999
  4134. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'cc1',@Name)
  4135. IF LTRIM(@Description) >''
  4136. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'cc2',@Description)
  4137. END
  4138. END
  4139. END
  4140. ELSE --英文
  4141. BEGIN
  4142. IF @ID>0 --修改证书
  4143. BEGIN
  4144. SELECT @NameOld = dbo.TextTrim(NameEng), @DescriptionOld = dbo.TextTrim(DescriptionEng)
  4145. FROM cvAppendix WITH(NOLOCK)
  4146. WHERE ID = @ID
  4147. UPDATE CvAppendix SET
  4148. NameEng = @Name,
  4149. AccessDate = @AccessDate,
  4150. dcAppendixID = @dcAppendixID,
  4151. DescriptionEng = @Description
  4152. WHERE ID = @ID
  4153. SET @MaxID = @ID
  4154. IF @dcAppendixID = 999
  4155. BEGIN
  4156. IF ISNULL(@NameOld, '') <> ISNULL(@Name, '')
  4157. BEGIN
  4158. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'ce1'
  4159. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ce1',@Name)
  4160. END
  4161. END
  4162. ELSE
  4163. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'ce1'
  4164. IF @Description IS NULL
  4165. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'ce2'
  4166. ELSE
  4167. IF ISNULL(@DescriptionOld, '') <> @Description
  4168. BEGIN
  4169. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'ce2'
  4170. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ce2',@Description)
  4171. END
  4172. END
  4173. ELSE --新增证书
  4174. BEGIN
  4175. SELECT @CNT=COUNT(*) FROM CvAppendix WITH(NOLOCK) WHERE cvMainID = @cvMainID
  4176. IF @CNT<5
  4177. BEGIN
  4178. INSERT INTO CvAppendix(cvMainID, NameEng, dcAppendixID, AccessDate, DescriptionEng)
  4179. VALUES(@cvMainID, @Name, @dcAppendixID, @AccessDate, @Description)
  4180. SET @MaxID = @@IDENTITY
  4181. IF @dcAppendixID = 999
  4182. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ce1',@Name)
  4183. IF @Description IS NOT NULL
  4184. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ce2',@Description)
  4185. END
  4186. END
  4187. END
  4188. --修改cvLevel
  4189. DECLARE @SQL AS VARCHAR(100)
  4190. SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew ' + CONVERT(CHAR(1), @Type) + ',' + CONVERT(VARCHAR(10), @cvMainID) + ',10,1'
  4191. EXEC(@SQL)
  4192. EXEC pcCvMainByCvLevelCheck @cvMainID, 10
  4193. END TRY
  4194. BEGIN CATCH
  4195. GOTO ERR
  4196. END CATCH
  4197. COMMIT TRAN
  4198. RETURN @MaxID
  4199. ERR:
  4200. BEGIN
  4201. ROLLBACK TRAN
  4202. RETURN 0
  4203. END
  4204. ERR1:
  4205. BEGIN
  4206. ROLLBACK TRAN
  4207. RETURN -1
  4208. END
  4209. ERR2:
  4210. BEGIN
  4211. ROLLBACK TRAN
  4212. RETURN -2
  4213. END
  4214. ERR3:
  4215. BEGIN
  4216. ROLLBACK TRAN
  4217. RETURN -3
  4218. END
  4219. ERR4:
  4220. BEGIN
  4221. ROLLBACK TRAN
  4222. RETURN -4
  4223. END
  4224. ERR5:
  4225. BEGIN
  4226. ROLLBACK TRAN
  4227. RETURN -5
  4228. END
  4229. GO
  4230. /****** Object: StoredProcedure [dbo].[pcCvAppendixSelect] Script Date: 2018/12/13 19:08:11 ******/
  4231. SET ANSI_NULLS ON
  4232. GO
  4233. SET QUOTED_IDENTIFIER ON
  4234. GO
  4235. /*############################################
  4236. 创建: sean
  4237. 检查: 2010-10-5
  4238. 说明: 取消各字段,改为*
  4239. ############################################*/
  4240. CREATE PROCEDURE [dbo].[pcCvAppendixSelect]
  4241. (
  4242. @cvMainID INT,
  4243. @lan INT
  4244. )
  4245. AS
  4246. BEGIN
  4247. SELECT *
  4248. FROM CvAppendix WITH(NOLOCK INDEX(IX_cvAppendix_cvMainID))
  4249. WHERE cvMainID = @cvMainID
  4250. ORDER BY AccessDate DESC, ID
  4251. /*
  4252. IF @lan>0
  4253. SELECT *
  4254. FROM CvAppendix WITH(NOLOCK INDEX(IX_cvAppendix_cvMainID))
  4255. WHERE cvMainID = @cvMainID
  4256. AND (dcAppendixID<999 OR name>'')
  4257. ELSE IF @lan=0
  4258. SELECT *
  4259. FROM CvAppendix WITH(NOLOCK INDEX(IX_cvAppendix_cvMainID))
  4260. WHERE cvMainID = @cvMainID
  4261. AND (dcAppendixID<999 OR nameEng>'')
  4262. ELSE 用于个人后台修改页面
  4263. SELECT *
  4264. FROM CvAppendix WITH(NOLOCK INDEX(IX_cvAppendix_cvMainID))
  4265. WHERE cvMainID = @cvMainID
  4266. */
  4267. END
  4268. GO
  4269. /****** Object: StoredProcedure [dbo].[pcCvAttachmentBySaveInsert] Script Date: 2018/12/13 19:08:12 ******/
  4270. SET ANSI_NULLS ON
  4271. GO
  4272. SET QUOTED_IDENTIFIER ON
  4273. GO
  4274. --新版的附件简历上传简历
  4275. CREATE PROCEDURE [dbo].[pcCvAttachmentBySaveInsert]
  4276. (
  4277. @ID INT,
  4278. @Attachment VARCHAR(50),
  4279. @FileName VARCHAR(50),
  4280. @paMainID INT
  4281. )
  4282. AS
  4283. SET NOCOUNT ON
  4284. IF CHARINDEX('<', @Attachment) > 0
  4285. SET @Attachment = REPLACE(@Attachment, '<', '&lt;')
  4286. IF CHARINDEX('<', @FileName) > 0
  4287. SET @FileName = REPLACE(@FileName, '<', '&lt;')
  4288. BEGIN TRY
  4289. DECLARE @paID AS INT
  4290. SELECT @paID = paMainID FROM cvMain WITH(NOLOCK) WHERE ID = @ID
  4291. IF @paMainID = 0
  4292. BEGIN
  4293. --无账号
  4294. IF @paID IS NULL
  4295. RETURN 0
  4296. END
  4297. ELSE
  4298. IF @paID <> @paMainID --cvMainID.paMainID <> paMain.ID,简历和账号不对应
  4299. RETURN 0
  4300. IF (SELECT COUNT(1) FROM cvAttachment WITH(NOLOCK) WHERE cvMainID = @ID AND VerifyResult <> 0) >= 3 --一份简历的附件不能超过3份
  4301. RETURN -1
  4302. INSERT INTO cvAttachment(cvMainID,FilePath,[FileName])
  4303. VALUES(@ID,@Attachment,@FileName)
  4304. UPDATE CvMain SET Attachment = 'X' WHERE id = @ID
  4305. IF(SELECT RefreshDate FROM cvMain WITH(NOLOCK) WHERE ID = @ID) > DATEADD(HOUR, -1, GETDATE())
  4306. UPDATE cvMain SET RefreshDate = GETDATE() WHERE ID = @ID
  4307. RETURN 1
  4308. END TRY
  4309. BEGIN CATCH
  4310. print 0
  4311. RETURN 0
  4312. END CATCH
  4313. GO
  4314. /****** Object: StoredProcedure [dbo].[pccvEducationByCvMainIDSelect] Script Date: 2018/12/13 19:08:12 ******/
  4315. SET ANSI_NULLS ON
  4316. GO
  4317. SET QUOTED_IDENTIFIER ON
  4318. GO
  4319. --#####################################################
  4320. --创建时间:2014.10.31
  4321. --创建人:Nick
  4322. --说明:得到毕业院校信息
  4323. --#####################################################
  4324. CREATE PROCEDURE [dbo].[pccvEducationByCvMainIDSelect]
  4325. (
  4326. @CvMainID INT,
  4327. @Degree INT
  4328. )
  4329. AS
  4330. BEGIN TRY
  4331. SELECT TOP 1 GraduateCollage, MajorName, Graduation
  4332. FROM cvEducation WITH(NOLOCK)
  4333. WHERE cvMainID=@CvMainID
  4334. AND Degree=@Degree
  4335. ORDER BY Graduation DESC
  4336. END TRY
  4337. BEGIN CATCH
  4338. RETURN 0
  4339. END CATCH
  4340. GO
  4341. /****** Object: StoredProcedure [dbo].[pcCvEducationByIDSelect] Script Date: 2018/12/13 19:08:12 ******/
  4342. SET ANSI_NULLS ON
  4343. GO
  4344. SET QUOTED_IDENTIFIER ON
  4345. GO
  4346. -- =============================================
  4347. -- Author: Sean
  4348. -- Create date: 2010-9-27
  4349. -- Description:
  4350. -- =============================================
  4351. CREATE PROCEDURE [dbo].[pcCvEducationByIDSelect]
  4352. @ID int
  4353. AS
  4354. BEGIN
  4355. SELECT
  4356. *
  4357. FROM cvEducation WITH(NOLOCK INDEX(PK_cvEducation))
  4358. WHERE ID=@ID
  4359. END
  4360. GO
  4361. /****** Object: StoredProcedure [dbo].[pcCvEducationDelete] Script Date: 2018/12/13 19:08:12 ******/
  4362. SET ANSI_NULLS ON
  4363. GO
  4364. SET QUOTED_IDENTIFIER ON
  4365. GO
  4366. -----------------------------------------------------------
  4367. --修改:Sean,2010-9-27
  4368. --描述:取消执行pcCvMainByCvLevelUpdate,因为js执行了cvLevelProc.asp,这个应该上线后调整
  4369. --取消pcCvMainVerifyResultCheck
  4370. --修改:Lambo,2010-11-25
  4371. --描述:增加了paMainID参数,判断是否是本人的
  4372. -----------------------------------------------------------
  4373. --[pcCvEducationDelete] 7424951,12222868
  4374. CREATE PROCEDURE [dbo].[pcCvEducationDelete]
  4375. @ID INT,
  4376. @paMainID INT
  4377. AS
  4378. BEGIN TRAN
  4379. BEGIN TRY
  4380. DECLARE @cvMainId AS INT
  4381. DECLARE @RETURN AS VARCHAR(2)
  4382. SELECT @cvMainId = cvMainId FROM cvEducation WITH(NOLOCK) WHERE ID=@ID
  4383. IF @cvMainId IS NULL
  4384. GOTO ERR
  4385. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK)
  4386. WHERE paMainID = @paMainID AND ID = @cvMainID)
  4387. GOTO ERR
  4388. DELETE FROM bsCvModify WHERE SubID = @ID AND Location LIKE 'd%'
  4389. DELETE FROM cvEducation WHERE ID=@ID
  4390. ----重新计算最高学位和专业
  4391. DECLARE @dcMajorID AS SMALLINT
  4392. DECLARE @Degree AS TINYINT
  4393. SELECT TOP 1 @dcMajorID = dcMajorID, @Degree = Degree FROM cvEducation WITH(NOLOCK) WHERE cvMainID = @cvMainID ORDER BY Degree DESC
  4394. UPDATE cvMain SET Degree = @Degree, dcMajorID = @dcMajorID WHERE ID = @cvMainID
  4395. EXEC @RETURN = pcCvMainByCvLevelCheck @cvMainID, 3
  4396. END TRY
  4397. BEGIN CATCH
  4398. GOTO ERR
  4399. END CATCH
  4400. COMMIT TRAN
  4401. RETURN @RETURN
  4402. ERR:
  4403. BEGIN
  4404. ROLLBACK TRAN
  4405. RETURN 3
  4406. END
  4407. GO
  4408. /****** Object: StoredProcedure [dbo].[pcCvEducationSave] Script Date: 2018/12/13 19:08:13 ******/
  4409. SET ANSI_NULLS ON
  4410. GO
  4411. SET QUOTED_IDENTIFIER ON
  4412. GO
  4413. -----------------------------------------------------------
  4414. --修改:Sean,2010-9-25
  4415. --描述:LastModifyDate=GETDATE(),不再调用存储过程
  4416. --取消执行pcCvMainByCvLevelUpdate,因为js执行了cvLevelProc.asp,这个应该上线后调整
  4417. -- 修改:Lambo,2010-11-25
  4418. -- 描述:增加了paMainID参数,判断是否是本人的
  4419. -----------------------------------------------------------
  4420. CREATE PROCEDURE [dbo].[pcCvEducationSave]
  4421. (
  4422. @Type INT,
  4423. @ID INT,
  4424. @cvMainID INT,
  4425. @GraduateCollage VARCHAR(250),
  4426. @Graduation INT,
  4427. @dcMajorID SMALLINT,
  4428. @MajorName VARCHAR(100),
  4429. @Degree TINYINT,
  4430. @EduType TINYINT,
  4431. @Details VARCHAR(2000),
  4432. @paMainID INT
  4433. )
  4434. AS
  4435. SET NOCOUNT ON
  4436. IF CHARINDEX('<', @GraduateCollage) > 0
  4437. SET @GraduateCollage = REPLACE(@GraduateCollage, '<', '&lt;')
  4438. IF CHARINDEX('<', @MajorName) > 0
  4439. SET @MajorName = REPLACE(@MajorName, '<', '&lt;')
  4440. IF CHARINDEX('<', @Details) > 0
  4441. SET @Details = REPLACE(@Details, '<', '&lt;')
  4442. BEGIN TRAN
  4443. ----检查是否是该账号的简历
  4444. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID AND paMainID = @paMainID)
  4445. GOTO ERR
  4446. ----检查是否是该简历的教育背景
  4447. IF @ID > 0
  4448. IF NOT EXISTS(SELECT 'x' FROM cvEducation WITH(NOLOCK) WHERE ID = @ID AND cvMainID = @cvMainID)
  4449. GOTO ERR
  4450. SELECT @GraduateCollage = dbo.SafeSql(dbo.TextTrim(@GraduateCollage)),
  4451. @MajorName = dbo.SafeSql(dbo.TextTrim(@MajorName)),
  4452. @Details = dbo.SafeSql(dbo.TextTrim(@Details))
  4453. DECLARE @MaxId AS INT
  4454. DECLARE @CNT AS INT
  4455. DECLARE @GraduateCollageOld AS VARCHAR(250)
  4456. DECLARE @MajorNameOld AS VARCHAR(100)
  4457. DECLARE @DetailsOld AS VARCHAR(2000)
  4458. DECLARE @cvdcMajorID AS SMALLINT
  4459. DECLARE @Modify AS INT
  4460. SET @Modify=-1
  4461. BEGIN TRY
  4462. IF @Type=0
  4463. BEGIN
  4464. DECLARE @GC AS NVARCHAR(50)
  4465. DECLARE @MN AS NVARCHAR(20)
  4466. DECLARE @D AS NVARCHAR(400)
  4467. SET @GC = @GraduateCollage
  4468. SET @MN = @MajorName
  4469. SET @D = @Details
  4470. IF @ID>0
  4471. BEGIN
  4472. SELECT @GraduateCollageOld = dbo.TextTrim(GraduateCollage),
  4473. @MajorNameOld = dbo.TextTrim(MajorName),
  4474. @DetailsOld = dbo.TextTrim(Details)
  4475. FROM cvEducation WITH(NOLOCK INDEX(PK_cvEducation)) WHERE ID=@ID
  4476. UPDATE cvEducation SET
  4477. GraduateCollage = @GC,
  4478. Graduation = @Graduation,
  4479. dcMajorID = @dcMajorID,
  4480. MajorName =@MN,
  4481. Degree = @Degree,
  4482. EduType = @EduType,
  4483. Details = @D
  4484. WHERE ID=@ID
  4485. SET @MaxID=@ID
  4486. IF ISNULL(@GraduateCollageOld, '') <> ISNULL(@GC, '')
  4487. BEGIN
  4488. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'dc1'
  4489. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'dc1',@GC)
  4490. SET @Modify=0
  4491. END
  4492. IF ISNULL(@MajorNameOld, '') <> ISNULL(@MN, '')
  4493. BEGIN
  4494. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'dc2'
  4495. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'dc2',@MN)
  4496. SET @Modify=0
  4497. END
  4498. IF @D IS NULL
  4499. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'dc3'
  4500. ELSE
  4501. IF ISNULL(@DetailsOld, '') <> @D
  4502. BEGIN
  4503. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'dc3'
  4504. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'dc3',@D)
  4505. SET @Modify=0
  4506. END
  4507. END
  4508. ELSE
  4509. BEGIN
  4510. SELECT @CNT=COUNT(*) FROM cvEducation WITH(NOLOCK INDEX(PK_cvEducation)) WHERE cvMainID = @cvMAinID
  4511. IF @CNT<5
  4512. BEGIN
  4513. INSERT INTO cvEducation(cvMainID,GraduateCollage,Graduation,dcMajorID,MajorName,Degree,EduType,Details)
  4514. VALUES(@cvMainID,@GC,@Graduation,@dcMajorID,@MN,@Degree,@EduType,@D)
  4515. SET @MaxID = @@IDENTITY
  4516. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'dc1',@GC)
  4517. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'dc2',@MN)
  4518. SET @Modify=0
  4519. IF @D > ''
  4520. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'dc3',@D)
  4521. END
  4522. ELSE
  4523. GOTO ERR
  4524. END
  4525. END
  4526. ELSE
  4527. BEGIN
  4528. IF @ID>0
  4529. BEGIN
  4530. SELECT @GraduateCollageOld = dbo.TextTrim(GraduateCollageEng),
  4531. @MajorNameOld = dbo.TextTrim(MajorNameEng),
  4532. @DetailsOld = dbo.TextTrim(DetailsEng)
  4533. FROM cvEducation WITH(NOLOCK INDEX(PK_cvEducation)) WHERE ID=@ID
  4534. UPDATE cvEducation SET
  4535. GraduateCollageENG = @GraduateCollage,
  4536. Graduation = @Graduation,
  4537. dcMajorID = @dcMajorID,
  4538. MajorNameEng =@MajorName,
  4539. Degree = @Degree,
  4540. EduType = @EduType,
  4541. DetailsEng = @Details
  4542. WHERE ID=@ID
  4543. SET @MaxID=@ID
  4544. IF ISNULL(@GraduateCollageOld, '') <> ISNULL(@GraduateCollage, '')
  4545. BEGIN
  4546. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'de1'
  4547. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'de1',@GraduateCollage)
  4548. SET @Modify=1
  4549. END
  4550. IF ISNULL(@MajorNameOld, '') <> ISNULL(@MajorName, '')
  4551. BEGIN
  4552. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'de2'
  4553. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'de2',@MajorName)
  4554. SET @Modify=1
  4555. END
  4556. IF @Details IS NULL
  4557. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'de3'
  4558. ELSE
  4559. IF ISNULL(@DetailsOld, '') <> @Details
  4560. BEGIN
  4561. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'de3'
  4562. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'de3',@Details)
  4563. SET @Modify=1
  4564. END
  4565. END
  4566. ELSE
  4567. BEGIN
  4568. SELECT @CNT=COUNT(*) FROM cvEducation WITH(NOLOCK INDEX(PK_cvEducation)) WHERE cvMainID = @cvMainID
  4569. IF @CNT<5
  4570. BEGIN
  4571. INSERT INTO cvEducation(cvMainID,GraduateCollageEng,Graduation,dcMajorID,MajorNameEng,Degree,EduType,DetailsEng)
  4572. VALUES(@cvMainID,@GraduateCollage,@Graduation,@dcMajorID,@MajorName,@Degree,@EduType,@Details)
  4573. SET @MaxID = @@IDENTITY
  4574. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'de1',@GraduateCollage)
  4575. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'de2',@MajorName)
  4576. SET @Modify=1
  4577. IF @Details > ''
  4578. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'de3',@Details)
  4579. END
  4580. ELSE
  4581. GOTO ERR
  4582. END
  4583. END
  4584. SELECT @Degree = MAX(DEGREE) FROM cvEducation WITH(NOLOCK) WHERE cvMainID = @cvMainID
  4585. UPDATE cvMain SET Degree=@Degree, dcMajorID=@dcMajorID WHERE ID=@cvMainID
  4586. --修改cvLevel
  4587. DECLARE @SQL AS VARCHAR(100)
  4588. SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew ' + CONVERT(CHAR(1), @Type) + ',' + CONVERT(VARCHAR(10), @cvMainID) + ',3,1'
  4589. EXEC(@SQL)
  4590. IF EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE Id = @cvMainId AND cvType = 1 AND SUBSTRING(cvLevel, 4, 1) = '0')
  4591. BEGIN
  4592. SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew ' + CONVERT(CHAR(1), @Type) + ',' + CONVERT(VARCHAR(10), @cvMainID) + ',4,1'
  4593. EXEC(@SQL)
  4594. END
  4595. END TRY
  4596. BEGIN CATCH
  4597. GOTO ERR
  4598. END CATCH
  4599. COMMIT TRAN
  4600. RETURN @MaxID
  4601. ERR:
  4602. BEGIN
  4603. ROLLBACK TRAN
  4604. RETURN 0
  4605. END
  4606. GO
  4607. /****** Object: StoredProcedure [dbo].[pcCvEducationSelect] Script Date: 2018/12/13 19:08:13 ******/
  4608. SET ANSI_NULLS ON
  4609. GO
  4610. SET QUOTED_IDENTIFIER ON
  4611. GO
  4612. -- =============================================
  4613. -- Author: Sean
  4614. -- Create date: 2010-9-27
  4615. -- Description:
  4616. -- =============================================
  4617. CREATE PROCEDURE [dbo].[pcCvEducationSelect]
  4618. @cvMainID int
  4619. AS
  4620. BEGIN
  4621. SELECT *,
  4622. (SELECT Description FROM DcMajor WITH(NOLOCK) WHERE ID = cvEducation.dcMajorID ) dcMajorName
  4623. FROM cvEducation WITH(NOLOCK INDEX(IX_cvEducation_CvMainID))
  4624. WHERE cvMainID=@cvMainID
  4625. ORDER BY Degree DESC,Graduation Desc
  4626. END
  4627. GO
  4628. /****** Object: StoredProcedure [dbo].[pcCvEducationSelectByPhone] Script Date: 2018/12/13 19:08:14 ******/
  4629. SET ANSI_NULLS ON
  4630. GO
  4631. SET QUOTED_IDENTIFIER ON
  4632. GO
  4633. CREATE PROCEDURE [dbo].[pcCvEducationSelectByPhone]
  4634. @cvMainID int
  4635. AS
  4636. BEGIN
  4637. SELECT a.*,b.Description Major,c.Description EduTypeName,d.Description Education
  4638. FROM cvEducation a WITH(NOLOCK INDEX(IX_cvEducation_CvMainID)),dcMajor b WITH(NOLOCK),dcEduType c WITH(NOLOCK),dcEducation d WITH(NOLOCK)
  4639. WHERE a.dcMajorID=b.ID AND a.EduType=c.ID AND a.Degree=d.ID AND a.cvMainID=@cvMainID
  4640. ORDER BY a.Degree DESC,a.Graduation Desc
  4641. END
  4642. GO
  4643. /****** Object: StoredProcedure [dbo].[pcCvExperienceByIDSelect] Script Date: 2018/12/13 19:08:14 ******/
  4644. SET ANSI_NULLS ON
  4645. GO
  4646. SET QUOTED_IDENTIFIER ON
  4647. GO
  4648. ---------------------------------------------------
  4649. --创建 Sean
  4650. -- 2010-9-27
  4651. -- 各字段改为*
  4652. ---------------------------------------------------
  4653. CREATE PROCEDURE [dbo].[pcCvExperienceByIDSelect]
  4654. @ID INT
  4655. AS
  4656. BEGIN
  4657. SELECT *
  4658. FROM cvExperience WITH(NOLOCK INDEX(PK_cvExperience))
  4659. WHERE ID = @ID
  4660. END
  4661. GO
  4662. /****** Object: StoredProcedure [dbo].[pcCvExperienceDelete] Script Date: 2018/12/13 19:08:14 ******/
  4663. SET ANSI_NULLS ON
  4664. GO
  4665. SET QUOTED_IDENTIFIER ON
  4666. GO
  4667. -----------------------------------------------
  4668. --创建Sean
  4669. --检查时间 2010-9-27
  4670. --修改了有无工作经验的判断, 取消pcCvMainVerifyResultCheck
  4671. --修改:Lambo,2010-11-25
  4672. --描述:增加了paMainID参数,判断是否是本人的
  4673. -----------------------------------------------
  4674. CREATE PROCEDURE [dbo].[pcCvExperienceDelete]
  4675. (
  4676. @ID INT,
  4677. @paMainID INT
  4678. )
  4679. AS
  4680. SET NOCOUNT ON
  4681. BEGIN TRAN
  4682. BEGIN TRY
  4683. DECLARE @cvMainId AS INT
  4684. DECLARE @RETURN AS VARCHAR(2)
  4685. SELECT @cvMainId = cvMainId FROM cvExperience WITH(NOLOCK) WHERE ID=@ID
  4686. IF @cvMainId IS NULL
  4687. GOTO ERR
  4688. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE paMainID = @paMainID AND ID = @cvMainID)
  4689. GOTO ERR
  4690. DELETE FROM bsCvModify WHERE SubID = @ID AND Location LIKE 'e%'
  4691. DELETE FROM cvExperience WHERE ID=@ID
  4692. END TRY
  4693. BEGIN CATCH
  4694. GOTO ERR
  4695. END CATCH
  4696. COMMIT TRAN
  4697. RETURN @RETURN
  4698. ERR:
  4699. BEGIN
  4700. ROLLBACK TRAN
  4701. RETURN 3
  4702. END
  4703. GO
  4704. /****** Object: StoredProcedure [dbo].[pcCvExperienceSave] Script Date: 2018/12/13 19:08:14 ******/
  4705. SET ANSI_NULLS ON
  4706. GO
  4707. SET QUOTED_IDENTIFIER ON
  4708. GO
  4709. -----------------------------------------------------------
  4710. --修改:Sean,2010-9-26
  4711. --描述:LastModifyDate = GETDATE(),不再调用存储过程
  4712. --屏蔽了@Modify,上线后在调整
  4713. --修改:Lambo,2010-11-25
  4714. --描述:增加了paMainID参数,判断是否是本人的
  4715. -----------------------------------------------------------
  4716. CREATE PROCEDURE [dbo].[pcCvExperienceSave]
  4717. (
  4718. @Type INT,
  4719. @ID INT,
  4720. @cvMainID INT,
  4721. @CompanyName VARCHAR(100),
  4722. @dcIndustryID INT,
  4723. @dcCompanySizeID INT,
  4724. @dcJobtypeID INT,
  4725. @JobName VARCHAR(100),
  4726. @BeginDate INT,
  4727. @EndDate INT,
  4728. @SubNodeNum INT,
  4729. @Description VARCHAR(Max),
  4730. @dcCompanyKindID INT = NULL,
  4731. @WorkPlace VARCHAR(6) = NULL,
  4732. @Dept VARCHAR(100) = NULL,
  4733. @UpperPost VARCHAR(100) = NULL,
  4734. @dcLeaveResonID INT = NULL,
  4735. @paMainID INT
  4736. )
  4737. AS
  4738. SET NOCOUNT ON
  4739. IF CHARINDEX('<', @CompanyName) > 0
  4740. SET @CompanyName = REPLACE(@CompanyName, '<', '')
  4741. IF CHARINDEX('<', @JobName) > 0
  4742. SET @JobName = REPLACE(@JobName, '<', '')
  4743. IF CHARINDEX('<', @Description) > 0
  4744. SET @Description = REPLACE(@Description, '<', '')
  4745. IF CHARINDEX('<', @Dept) > 0
  4746. SET @Dept = REPLACE(@Dept, '<', '')
  4747. IF CHARINDEX('<', @UpperPost) > 0
  4748. SET @UpperPost = REPLACE(@UpperPost, '<', '')
  4749. BEGIN TRAN
  4750. ----检查是否是该账号的简历
  4751. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID AND paMainID = @paMainID)
  4752. GOTO ERR
  4753. ----检查是否是该简历的工作经验
  4754. IF @ID > 0
  4755. IF NOT EXISTS(SELECT 'x' FROM cvExperience WITH(NOLOCK) WHERE ID = @ID AND cvMainID = @cvMainID)
  4756. GOTO ERR
  4757. SELECT @CompanyName = dbo.SafeSQL(dbo.TextTrim(@CompanyName)),
  4758. @JobName = dbo.SafeSQL(dbo.TextTrim(@JobName)),
  4759. @Description = dbo.SafeSQL(dbo.TextTrim(@Description)),
  4760. @WorkPlace = dbo.TextTrim(@WorkPlace),
  4761. @Dept = dbo.SafeSQL(dbo.TextTrim(@Dept)),
  4762. @UpperPost = dbo.SafeSQL(dbo.TextTrim(@UpperPost))
  4763. IF CHARINDEX(',', @JobName) > 0
  4764. SELECT @JobName = dbo.SafeSql(REPLACE(@JobName, ',', ','))
  4765. DECLARE @MaxId AS INT
  4766. DECLARE @CNT AS INT
  4767. DECLARE @CompanyNameOld AS VARCHAR(100)
  4768. DECLARE @JobNameOld AS VARCHAR(100)
  4769. DECLARE @DescriptionOld AS VARCHAR(Max)
  4770. DECLARE @DeptOld AS VARCHAR(100)
  4771. DECLARE @UpperPostOld AS VARCHAR(100)
  4772. DECLARE @Modify AS INT
  4773. SET @Modify = -1
  4774. BEGIN TRY
  4775. IF @Type = 0
  4776. BEGIN
  4777. DECLARE @C_CompanyName AS NVARCHAR(30)
  4778. DECLARE @C_JobName AS NVARCHAR(50)
  4779. DECLARE @C_Description AS NVARCHAR(2000)
  4780. DECLARE @C_Dept AS NVARCHAR(20)
  4781. DECLARE @C_UpperPost AS NVARCHAR(20)
  4782. SET @C_CompanyName = dbo.TextTrim(@CompanyName)
  4783. SET @C_JobName = dbo.TextTrim(@JobName)
  4784. SET @C_Description = dbo.TextTrim(@Description)
  4785. SET @C_Dept = dbo.TextTrim(@Dept)
  4786. SET @C_UpperPost = dbo.TextTrim(@UpperPost)
  4787. IF @ID>0
  4788. BEGIN
  4789. SELECT @CompanyNameOld = dbo.TextTrim(ISNULL(CompanyName, '')),
  4790. @JobNameOld = dbo.TextTrim(ISNULL(JobName, '')),
  4791. @DescriptionOld = dbo.TextTrim(ISNULL(Description, '')),
  4792. @DeptOld = dbo.TextTrim(ISNULL(Dept, '')),
  4793. @UpperPostOld = dbo.TextTrim(ISNULL(UpperPost, ''))
  4794. FROM cvExperience WITH(NOLOCK INDEX(PK_cvExperience)) WHERE ID = @ID
  4795. UPDATE cvExperience SET
  4796. CompanyName = @C_CompanyName,
  4797. dcIndustryID = @dcIndustryID,
  4798. dcCompanySizeID = @dcCompanySizeID,
  4799. dcJobtypeID = @dcJobtypeID,
  4800. JobName = @C_JobName,
  4801. BeginDate = @BeginDate,
  4802. EndDate = @EndDate,
  4803. SubNodeNum = @SubNodeNum,
  4804. Description = @C_Description,
  4805. dcCompanyKindID = @dcCompanyKindID,
  4806. WorkPlace = @WorkPlace,
  4807. Dept = @C_Dept,
  4808. UpperPost = @C_UpperPost,
  4809. dcLeaveResonID = @dcLeaveResonID
  4810. WHERE ID = @ID
  4811. SET @MaxID = @ID
  4812. IF ISNULL(@CompanyNameOld, '') <> ISNULL(@C_CompanyName, '')
  4813. BEGIN
  4814. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'ec1'
  4815. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec1',@CompanyName)
  4816. SET @Modify = 0
  4817. END
  4818. IF ISNULL(@JobNameOld, '') <> ISNULL(@C_JobName, '')
  4819. BEGIN
  4820. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND cvMainID = @cvMainID AND SubID = @ID AND Location = 'ec2'
  4821. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec2',@C_JobName)
  4822. SET @Modify = 0
  4823. END
  4824. IF ISNULL(@DescriptionOld, '') <> ISNULL(@C_Description, '')
  4825. BEGIN
  4826. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND cvMainID = @cvMainID AND SubID = @ID AND Location = 'ec3'
  4827. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec3',@C_Description)
  4828. SET @Modify = 0
  4829. END
  4830. IF @C_Dept IS NULL
  4831. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND cvMainID = @cvMainID AND SubID = @ID AND Location = 'ec4'
  4832. ELSE
  4833. IF ISNULL(@DeptOld, '') <> @C_Dept
  4834. BEGIN
  4835. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND cvMainID = @cvMainID AND SubID = @ID AND Location = 'ec4'
  4836. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec4',@C_Dept)
  4837. SET @Modify = 0
  4838. END
  4839. IF @UpperPost IS NULL
  4840. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND cvMainID = @cvMainID AND SubID = @ID AND Location = 'ec5'
  4841. ELSE
  4842. IF ISNULL(@UpperPostOld, '') <> @C_UpperPost
  4843. BEGIN
  4844. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND cvMainID = @cvMainID AND SubID = @ID AND Location = 'ec5'
  4845. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec5',@C_UpperPost)
  4846. SET @Modify = 0
  4847. END
  4848. END
  4849. ELSE
  4850. BEGIN
  4851. SELECT @CNT = COUNT(*) FROM cvExperience WITH(NOLOCK INDEX(IX_cvExperience_cvMainID)) WHERE cvMainID = @cvMainID
  4852. IF @CNT<20
  4853. BEGIN
  4854. INSERT INTO cvExperience
  4855. (cvMainID,CompanyName,dcIndustryID,dcCompanySizeID,dcJobtypeID,JobName,
  4856. BeginDate,EndDate,SubNodeNum,Description,dcCompanyKindID,WorkPlace,Dept,
  4857. UpperPost,dcLeaveResonID)
  4858. VALUES
  4859. (@cvMainID,@CompanyName,@dcIndustryID,@dcCompanySizeID,@dcJobtypeID,@JobName,
  4860. @BeginDate,@EndDate,@SubNodeNum,@Description,@dcCompanyKindID,@WorkPlace,@Dept,
  4861. @UpperPost,@dcLeaveResonID)
  4862. SET @MaxID = @@IDENTITY
  4863. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec1',@C_CompanyName)
  4864. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec2',@C_JobName)
  4865. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec3',@C_Description)
  4866. IF @Dept > ''
  4867. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec4',@C_Dept)
  4868. IF @UpperPost > ''
  4869. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec5',@C_UpperPost)
  4870. SET @Modify = 0
  4871. END
  4872. ELSE
  4873. GOTO ERR
  4874. END
  4875. END
  4876. ELSE
  4877. BEGIN
  4878. IF @ID>0
  4879. BEGIN
  4880. SELECT @CompanyNameOld = dbo.TextTrim(ISNULL(CompanyNameEng, '')),
  4881. @JobNameOld = dbo.TextTrim(iSNULL(JobNameEng, '')),
  4882. @DescriptionOld = dbo.TextTrim(ISNULL(DescriptionEng, '')),
  4883. @DeptOld = dbo.TextTrim(ISNULL(DeptEng, '')),
  4884. @UpperPostOld = dbo.TextTrim(ISNULL(UpperPostEng, ''))
  4885. FROM cvExperience WITH(NOLOCK INDEX(PK_cvExperience))
  4886. WHERE ID = @ID
  4887. UPDATE cvExperience SET
  4888. CompanyNameEng = @CompanyName,
  4889. dcIndustryID = @dcIndustryID,
  4890. dcCompanySizeID = @dcCompanySizeID,
  4891. dcJobtypeID = @dcJobtypeID,
  4892. JobNameEng = @JobName,
  4893. BeginDate = @BeginDate,
  4894. EndDate = @EndDate,
  4895. SubNodeNum = @SubNodeNum,
  4896. DescriptionEng = @Description,
  4897. dcCompanyKindID = @dcCompanyKindID,
  4898. WorkPlace = @WorkPlace,
  4899. DeptEng = @Dept,
  4900. UpperPostEng = @UpperPost,
  4901. dcLeaveResonID = @dcLeaveResonID
  4902. WHERE ID = @ID
  4903. SET @MaxID = @ID
  4904. IF ISNULL(@CompanyNameOld, '') <> ISNULL(@CompanyName, '')
  4905. BEGIN
  4906. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'ee1'
  4907. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ee1',@CompanyName)
  4908. SET @Modify = 1
  4909. END
  4910. IF ISNULL(@JobNameOld, '') <> ISNULL(@JobName, '')
  4911. BEGIN
  4912. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND cvMainID = @cvMainID AND SubID = @ID AND Location = 'ee2'
  4913. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ee2',@JobName)
  4914. SET @Modify = 1
  4915. END
  4916. IF ISNULL(@DescriptionOld, '') <> ISNULL(@Description, '')
  4917. BEGIN
  4918. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND cvMainID = @cvMainID AND SubID = @ID AND Location = 'ee3'
  4919. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ee3',@Description)
  4920. SET @Modify = 1
  4921. END
  4922. IF @Dept IS NULL
  4923. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND cvMainID = @cvMainID AND SubID = @ID AND Location = 'ee4'
  4924. ELSE
  4925. IF ISNULL(@DeptOld, '') <> @Dept
  4926. BEGIN
  4927. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND cvMainID = @cvMainID AND SubID = @ID AND Location = 'ee4'
  4928. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ee4',@Dept)
  4929. SET @Modify = 1
  4930. END
  4931. IF @UpperPost IS NULL
  4932. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND cvMainID = @cvMainID AND SubID = @ID AND Location = 'ee5'
  4933. ELSE
  4934. IF ISNULL(@UpperPostOld, '') <> @UpperPost
  4935. BEGIN
  4936. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND cvMainID = @cvMainID AND SubID = @ID AND Location = 'ee5'
  4937. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ee5',@UpperPost)
  4938. SET @Modify = 1
  4939. END
  4940. END
  4941. ELSE
  4942. BEGIN
  4943. INSERT INTO cvExperience
  4944. (cvMainID,CompanyNameEng,dcIndustryID,dcCompanySizeID,dcJobtypeID,JobNameEng,
  4945. BeginDate,EndDate,SubNodeNum,DescriptionEng,dcCompanyKindID,WorkPlace,DeptEng,
  4946. UpperPostEng,dcLeaveResonID)
  4947. VALUES
  4948. (@cvMainID,@CompanyName,@dcIndustryID,@dcCompanySizeID,@dcJobtypeID,@JobName,
  4949. @BeginDate,@EndDate,@SubNodeNum,@Description,@dcCompanyKindID,@WorkPlace,@Dept,
  4950. @UpperPost,@dcLeaveResonID)
  4951. SET @MaxID = @@IDENTITY
  4952. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ee1',@CompanyName)
  4953. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ee2',@JobName)
  4954. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ee3',@Description)
  4955. SET @Modify = 1
  4956. IF @Dept > ''
  4957. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ee4',@Dept)
  4958. IF @UpperPost > ''
  4959. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ee5',@UpperPost)
  4960. END
  4961. END
  4962. UPDATE cvMain SET cvType = 0 WHERE Id = @CvMainId AND cvType = 1
  4963. --修改cvLevel
  4964. DECLARE @SQL AS VARCHAR(100)
  4965. SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew ' + CONVERT(CHAR(1), @Type) + ',' + CONVERT(VARCHAR(10), @cvMainID) + ',4,1'
  4966. EXEC(@SQL)
  4967. END TRY
  4968. BEGIN CATCH
  4969. GOTO ERR
  4970. END CATCH
  4971. COMMIT TRAN
  4972. RETURN @MaxID
  4973. ERR:
  4974. BEGIN
  4975. ROLLBACK TRAN
  4976. RETURN 0
  4977. END
  4978. GO
  4979. /****** Object: StoredProcedure [dbo].[pcCvExperienceSelect] Script Date: 2018/12/13 19:08:14 ******/
  4980. SET ANSI_NULLS ON
  4981. GO
  4982. SET QUOTED_IDENTIFIER ON
  4983. GO
  4984. ----------------------------------
  4985. --创建: Sean
  4986. --检查: 2010-9-27
  4987. ----------------------------------
  4988. CREATE PROCEDURE [dbo].[pcCvExperienceSelect]
  4989. @cvMainID INT
  4990. AS
  4991. BEGIN
  4992. SELECT *
  4993. FROM cvExperience WITH(NOLOCK INDEX(IX_cvExperience_cvMainID))
  4994. WHERE cvMainID = @cvMainID
  4995. ORDER BY BeginDate DESC
  4996. END
  4997. GO
  4998. /****** Object: StoredProcedure [dbo].[pcCvExperienceSelectByPhone] Script Date: 2018/12/13 19:08:14 ******/
  4999. SET ANSI_NULLS ON
  5000. GO
  5001. SET QUOTED_IDENTIFIER ON
  5002. GO
  5003. CREATE PROCEDURE [dbo].[pcCvExperienceSelectByPhone]
  5004. @cvMainID INT
  5005. AS
  5006. BEGIN
  5007. SELECT a.*,b.Description JobType,c.Description CpmpanySize,d.Description Industry,
  5008. g.Description LowerNumber,e.Description CompanyKind,f.Description LeaveReson,h.FullName Region
  5009. FROM cvExperience a WITH(NOLOCK INDEX(IX_cvExperience_cvMainID))
  5010. INNER JOIN dcJobType b WITH(NOLOCK) ON a.dcJobTypeID=b.ID
  5011. INNER JOIN dcCompanySize c WITH(NOLOCK) ON a.dcCompanySizeID=c.ID
  5012. INNER JOIN dcIndustry d WITH(NOLOCK) ON a.dcIndustryID=d.ID
  5013. INNER JOIN dcLowerNumber g WITH(NOLOCK) ON a.SubNodeNum=g.ID
  5014. LEFT JOIN dcCompanyKind e WITH(NOLOCK) ON a.dcCompanyKindID=e.ID
  5015. LEFT JOIN dcLeaveReson f WITH(NOLOCK) ON a.dcLeaveResonID=f.ID
  5016. LEFT JOIN dcRegion h WITH(NOLOCK) ON a.WorkPlace=h.ID
  5017. WHERE cvMainID=@cvMainID
  5018. ORDER BY a.BeginDate DESC
  5019. END
  5020. GO
  5021. /****** Object: StoredProcedure [dbo].[pccvImportPrevByPaMainIDSelect] Script Date: 2018/12/13 19:08:15 ******/
  5022. SET ANSI_NULLS ON
  5023. GO
  5024. SET QUOTED_IDENTIFIER ON
  5025. GO
  5026. --#####################################################
  5027. --创建时间:2014.10.31
  5028. --创建人:Nick
  5029. --说明:获取该简历在简历导入的认证信息
  5030. --#####################################################
  5031. CREATE PROCEDURE [dbo].[pccvImportPrevByPaMainIDSelect]
  5032. (
  5033. @paMainID VARCHAR(20)
  5034. )
  5035. AS
  5036. BEGIN TRY
  5037. SELECT TOP 1 EntryDate,ContactResult
  5038. FROM marketdb..cvImportPrev WITH(NOLOCK)
  5039. WHERE pamainid = @paMainID
  5040. AND EntryDate IS NOT NULL
  5041. END TRY
  5042. BEGIN CATCH
  5043. RETURN 0
  5044. END CATCH
  5045. GO
  5046. /****** Object: StoredProcedure [dbo].[pcCvLanguageByIDSelect] Script Date: 2018/12/13 19:08:15 ******/
  5047. SET ANSI_NULLS ON
  5048. GO
  5049. SET QUOTED_IDENTIFIER ON
  5050. GO
  5051. ----------------------------
  5052. --创建: Sean
  5053. --检查: 2010-9-27
  5054. ----------------------------
  5055. CREATE PROCEDURE [dbo].[pcCvLanguageByIDSelect]
  5056. @ID INT
  5057. AS
  5058. BEGIN
  5059. SELECT *
  5060. FROM CvLanguage WITH(NOLOCK INDEX(PK_cvLanguage))
  5061. WHERE ID = @ID
  5062. END
  5063. GO
  5064. /****** Object: StoredProcedure [dbo].[pcCvLanguageDelete] Script Date: 2018/12/13 19:08:15 ******/
  5065. SET ANSI_NULLS ON
  5066. GO
  5067. SET QUOTED_IDENTIFIER ON
  5068. GO
  5069. -----------------------------------------------------------
  5070. --修改:Sean,2010-9-27
  5071. --描述:取消执行pcCvMainByCvLevelUpdate,因为js执行了cvLevelProc.asp,这个应该上线后调整
  5072. -- 取消pcCvMainVerifyResultCheck的执行,因为与审核状态无关
  5073. --修改:Lambo,2010-11-25
  5074. --描述:增加了paMainID参数,判断是否是本人的
  5075. -----------------------------------------------------------
  5076. CREATE PROCEDURE [dbo].[pcCvLanguageDelete]
  5077. @ID INT,
  5078. @paMainID INT
  5079. AS
  5080. BEGIN TRAN
  5081. BEGIN TRY
  5082. DECLARE @cvMainId AS INT
  5083. DECLARE @RETURN AS VARCHAR(2)
  5084. SELECT @cvMainId = cvMainId FROM cvLanguage WITH(NOLOCK) WHERE ID=@ID
  5085. IF @cvMainId IS NULL
  5086. GOTO ERR
  5087. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK)
  5088. WHERE paMainID = @paMainID AND ID = @cvMainID)
  5089. GOTO ERR
  5090. DELETE FROM bsCvModify WHERE SubID = @ID AND Location LIKE 'h%'
  5091. DELETE FROM cvLanguage WHERE ID=@ID
  5092. EXEC @RETURN = pcCvMainByCvLevelCheck @cvMainID, 7
  5093. END TRY
  5094. BEGIN CATCH
  5095. GOTO ERR
  5096. END CATCH
  5097. COMMIT TRAN
  5098. RETURN @RETURN
  5099. ERR:
  5100. BEGIN
  5101. ROLLBACK TRAN
  5102. RETURN 3
  5103. END
  5104. GO
  5105. /****** Object: StoredProcedure [dbo].[pcCvLanguageSave] Script Date: 2018/12/13 19:08:15 ******/
  5106. SET ANSI_NULLS ON
  5107. GO
  5108. SET QUOTED_IDENTIFIER ON
  5109. GO
  5110. -----------------------------------------------------------
  5111. --修改: Sean
  5112. --检查: 2010-9-27
  5113. --描述: 取消执行pcCvMainByCvLevelUpdate,因为js执行了cvLevelProc.asp,这个应该上线后调整
  5114. -- 取消pcCvMainVerifyResultUpdate
  5115. --修改:Lambo,2010-11-25
  5116. --描述:增加了paMainID参数,判断是否是本人的
  5117. -----------------------------------------------------------
  5118. CREATE PROCEDURE [dbo].[pcCvLanguageSave]
  5119. (
  5120. @Type INT,
  5121. @ID INT,
  5122. @cvMainID INT,
  5123. @LanguageType INT,
  5124. @Mastery INT,
  5125. @ReadWrite INT,
  5126. @Spoken INT,
  5127. @Score VARCHAR(100),
  5128. @paMainID INT
  5129. )
  5130. AS
  5131. SET NOCOUNT ON
  5132. IF CHARINDEX('<', @Score) > 0
  5133. SET @Score = REPLACE(@Score, '<', '')
  5134. BEGIN TRAN
  5135. ----检查是否是该账号的简历
  5136. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID AND paMainID = @paMainID)
  5137. GOTO ERR
  5138. ----检查是否是该简历的语言能力
  5139. IF @ID > 0
  5140. IF NOT EXISTS(SELECT 'x' FROM cvLanguage WITH(NOLOCK) WHERE ID = @ID AND cvMainID = @cvMainID)
  5141. GOTO ERR
  5142. SET @Score = dbo.SafeSql(dbo.TextTrim(@Score))
  5143. DECLARE @MaxId AS INT
  5144. DECLARE @ScoreOld AS VARCHAR(100)
  5145. DECLARE @Modify AS INT
  5146. SET @Modify=-1
  5147. BEGIN TRY
  5148. IF @Type=0
  5149. BEGIN
  5150. DECLARE @S AS NVARCHAR(30)
  5151. SET @S = @Score
  5152. SELECT @ScoreOld = dbo.TextTrim(ISNULL(Score, '')) FROM cvLanguage WITH(NOLOCK INDEX(PK_cvLanguage)) WHERE ID = @ID
  5153. IF @ID>0
  5154. BEGIN
  5155. --DELETE FROM CvLanguage WHERE LanguageType = @LanguageType AND cvMainID=@cvMainID
  5156. UPDATE CvLanguage SET
  5157. LanguageType = @LanguageType,
  5158. Mastery = @Mastery,
  5159. ReadWrite = @ReadWrite,
  5160. Spoken = @Spoken,
  5161. Score = @S
  5162. WHERE ID=@ID
  5163. SET @MaxID = @ID
  5164. IF @S IS NULL
  5165. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'hc1'
  5166. ELSE
  5167. IF @S <> ISNULL(@ScoreOld, '')
  5168. BEGIN
  5169. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'hc1'
  5170. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'hc1',@S)
  5171. SET @Modify=0
  5172. END
  5173. END
  5174. ELSE
  5175. BEGIN
  5176. INSERT INTO CvLanguage(cvMainID,LanguageType,Mastery,ReadWrite,Spoken,Score)
  5177. VALUES(@cvMainID,@LanguageType,@Mastery,@ReadWrite,@Spoken,@Score)
  5178. SET @MaxID = @@IDENTITY
  5179. IF @S > ''
  5180. BEGIN
  5181. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'hc1',@S)
  5182. SET @Modify=0
  5183. END
  5184. END
  5185. END
  5186. ELSE
  5187. BEGIN
  5188. IF @ID>0
  5189. BEGIN
  5190. --DELETE FROM CvLanguage WHERE LanguageType = @LanguageType AND cvMainID=@cvMainID
  5191. SELECT @ScoreOld = dbo.TextTrim(ISNULL(Score, '')) FROM cvLanguage WITH(NOLOCK INDEX(PK_cvLanguage)) WHERE ID = @ID
  5192. UPDATE CvLanguage SET
  5193. LanguageType = @LanguageType,
  5194. Mastery = @Mastery,
  5195. ReadWrite = @ReadWrite,
  5196. Spoken = @Spoken,
  5197. ScoreEng = @Score
  5198. WHERE ID=@ID
  5199. SET @MaxID = @ID
  5200. IF @Score IS NULL
  5201. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'he1'
  5202. ELSE
  5203. IF @Score <> ISNULL(@ScoreOld, '')
  5204. BEGIN
  5205. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'he1'
  5206. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location) VALUES(@paMainID,@cvMainID,@MaxID,'he1')
  5207. SET @Modify=1
  5208. END
  5209. END
  5210. ELSE
  5211. BEGIN
  5212. INSERT INTO CvLanguage(cvMainID,LanguageType,Mastery,ReadWrite,Spoken,ScoreEng)
  5213. VALUES(@cvMainID,@LanguageType,@Mastery,@ReadWrite,@Spoken,@Score)
  5214. SET @MaxID = @@IDENTITY
  5215. IF @Score > ''
  5216. BEGIN
  5217. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location) VALUES(@paMainID,@cvMainID,@MaxID,'he1')
  5218. SET @Modify=1
  5219. END
  5220. END
  5221. END
  5222. --修改cvLevel
  5223. DECLARE @SQL AS VARCHAR(100)
  5224. SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew ' + CONVERT(CHAR(1), @Type) + ',' + CONVERT(VARCHAR(10), @cvMainID) + ',7,1'
  5225. EXEC(@SQL)
  5226. END TRY
  5227. BEGIN CATCH
  5228. GOTO ERR
  5229. END CATCH
  5230. COMMIT TRAN
  5231. RETURN @MaxID
  5232. ERR:
  5233. BEGIN
  5234. ROLLBACK TRAN
  5235. RETURN 0
  5236. END
  5237. GO
  5238. /****** Object: StoredProcedure [dbo].[pcCvLanguageSelect] Script Date: 2018/12/13 19:08:16 ******/
  5239. SET ANSI_NULLS ON
  5240. GO
  5241. SET QUOTED_IDENTIFIER ON
  5242. GO
  5243. -----------------------------------------------------------
  5244. --修改: Sean
  5245. --检查: 2010-9-27
  5246. -----------------------------------------------------------
  5247. CREATE PROCEDURE [dbo].[pcCvLanguageSelect]
  5248. @cvMainID INT
  5249. AS
  5250. BEGIN
  5251. SELECT *
  5252. FROM CvLanguage WITH(NOLOCK INDEX(IX_cvLanguage_cvMainID))
  5253. WHERE cvMainID = @cvMainID
  5254. END
  5255. GO
  5256. /****** Object: StoredProcedure [dbo].[pcCvMainByApplySelect] Script Date: 2018/12/13 19:08:16 ******/
  5257. SET ANSI_NULLS ON
  5258. GO
  5259. SET QUOTED_IDENTIFIER ON
  5260. GO
  5261. CREATE PROCEDURE [dbo].[pcCvMainByApplySelect]
  5262. @paMainID INT
  5263. AS
  5264. BEGIN
  5265. SELECT
  5266. ID,
  5267. paMainID,
  5268. Name,
  5269. EmployType,
  5270. dcSalaryID,
  5271. Attachment,
  5272. WordFileNAme,
  5273. cvType,
  5274. IsNameHidden,
  5275. IscvHidden,
  5276. isOpen,
  5277. cvLevel,
  5278. cvLevelEng,
  5279. VerifyResult,
  5280. VerifyResultEng,
  5281. Valid,
  5282. ViewNumber,
  5283. RefreshDate,
  5284. Degree
  5285. FROM cvMain WITH(NOLOCK)
  5286. WHERE paMainID=@paMainID
  5287. AND ((cvLevel like '111__1%' AND VerifyResult=1) OR (cvLevelEng like '111__1%' AND VerifyResultEng=1))
  5288. ORDER BY RefreshDate DESC
  5289. END
  5290. GO
  5291. /****** Object: StoredProcedure [dbo].[pcCvMainByAttachmentClear] Script Date: 2018/12/13 19:08:16 ******/
  5292. SET ANSI_NULLS ON
  5293. GO
  5294. SET QUOTED_IDENTIFIER ON
  5295. GO
  5296. --=============================================
  5297. --修改: Sean
  5298. --检查: 2010-10-5
  5299. --=============================================
  5300. CREATE PROCEDURE [dbo].[pcCvMainByAttachmentClear]
  5301. @ID INT, --cvMain.ID
  5302. @paMainID INT
  5303. AS
  5304. BEGIN TRY
  5305. ----检查是否是该账号的简历
  5306. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID = @ID AND paMainID = @paMainID)
  5307. RETURN 0
  5308. UPDATE CvMain SET Attachment = NULL, WordFilename = NULL WHERE ID = @ID
  5309. IF(SELECT RefreshDate FROM cvMain WITH(NOLOCK) WHERE ID = @ID) > DATEADD(HOUR, -1, GETDATE())
  5310. UPDATE cvMain SET RefreshDate = GETDATE() WHERE ID = @ID
  5311. DELETE FROM bsCvModify WHERE Location = 'ac5' AND cvMainID = @ID
  5312. RETURN 1
  5313. END TRY
  5314. BEGIN CATCH
  5315. RETURN 0
  5316. END CATCH
  5317. GO
  5318. /****** Object: StoredProcedure [dbo].[pcCvMainByAttachmentUpdate] Script Date: 2018/12/13 19:08:16 ******/
  5319. SET ANSI_NULLS ON
  5320. GO
  5321. SET QUOTED_IDENTIFIER ON
  5322. GO
  5323. --=============================================
  5324. --检查: Sean,2010-10-5
  5325. --
  5326. --=============================================
  5327. CREATE PROCEDURE [dbo].[pcCvMainByAttachmentUpdate]
  5328. (
  5329. @ID INT,
  5330. @Attachment VARCHAR(50),
  5331. @WordFileName VARCHAR(50),
  5332. @paMainID INT
  5333. )
  5334. AS
  5335. SET NOCOUNT ON
  5336. IF CHARINDEX('<', @Attachment) > 0
  5337. SET @Attachment = REPLACE(@Attachment, '<', '&lt;')
  5338. IF CHARINDEX('<', @WordFileName) > 0
  5339. SET @WordFileName = REPLACE(@WordFileName, '<', '&lt;')
  5340. BEGIN TRY
  5341. DECLARE @paID AS INT
  5342. SELECT @paID = paMainID FROM cvMain WITH(NOLOCK) WHERE ID = @ID
  5343. IF @paMainID = 0
  5344. BEGIN
  5345. --无账号
  5346. IF @paID IS NULL
  5347. RETURN 0
  5348. --账号不是附件上传建立的,附件上传新建的账号密码=123456
  5349. IF NOT EXISTS(SELECT 'x' FROM paMain WITH(NOLOCK) WHERE ID = @paID AND Password = '123456')
  5350. RETURN 0
  5351. END
  5352. ELSE
  5353. IF @paID <> @paMainID --cvMainID.paMainID <> paMain.ID,简历和账号不对应
  5354. RETURN 0
  5355. UPDATE CvMain SET Attachment = dbo.SafeSql(@Attachment), WordFileNAme=dbo.SafeSql(@WordFileName) WHERE ID = @ID
  5356. DELETE FROM bsCvModify WHERE cvMainID = @ID AND Location = 'ac5'
  5357. INSERT INTO bsCvModify(paMainID,cvMainID,Location,colvalue) VALUES(@paID, @ID, 'ac5', @Attachment)
  5358. IF(SELECT RefreshDate FROM cvMain WITH(NOLOCK) WHERE ID = @ID) > DATEADD(HOUR, -1, GETDATE())
  5359. UPDATE cvMain SET RefreshDate = GETDATE() WHERE ID = @ID
  5360. RETURN 1
  5361. END TRY
  5362. BEGIN CATCH
  5363. print 0
  5364. RETURN 0
  5365. END CATCH
  5366. GO
  5367. /****** Object: StoredProcedure [dbo].[pcCvMainByCvJobTypeSelect] Script Date: 2018/12/13 19:08:16 ******/
  5368. SET ANSI_NULLS ON
  5369. GO
  5370. SET QUOTED_IDENTIFIER ON
  5371. GO
  5372. CREATE PROCEDURE [dbo].[pcCvMainByCvJobTypeSelect]
  5373. (
  5374. @strJobType VARCHAR(10)
  5375. )
  5376. AS
  5377. BEGIN
  5378. SELECT a.MajorName, a.dcMajorId, a.PinYin, a.jianPin, b.*
  5379. FROM dcJobTypeMajorMap a WITH(NOLOCK) LEFT JOIN dcMajor b WITH(NOLOCK) ON b.id = a.dcMajorID
  5380. WHERE a.dcJobTypeid= @strJobType
  5381. AND a.dcMajorId = b.Id
  5382. END
  5383. GO
  5384. /****** Object: StoredProcedure [dbo].[pcCvMainByCvLevelCheck] Script Date: 2018/12/13 19:08:16 ******/
  5385. SET ANSI_NULLS ON
  5386. GO
  5387. SET QUOTED_IDENTIFIER ON
  5388. GO
  5389. --[pcCvMainByCvLevelCheck] 12222868,3
  5390. CREATE PROCEDURE [dbo].[pcCvMainByCvLevelCheck]
  5391. (
  5392. @cvMainID INT,
  5393. @Pos INT
  5394. )
  5395. AS
  5396. SET NOCOUNT ON
  5397. BEGIN TRAN
  5398. BEGIN TRY
  5399. DECLARE @Chs AS INT
  5400. DECLARE @Eng AS INT
  5401. DECLARE @paID AS INT
  5402. DECLARE @Return AS VARCHAR(2)
  5403. SELECT @paID = paMainID FROM cvMain WHERE ID = @cvMainID
  5404. --教育背景
  5405. IF @Pos = 3
  5406. BEGIN
  5407. SELECT @Chs = COUNT(1) FROM cvEducation WITH(NOLOCK) WHERE cvMainID = @cvMainID AND GraduateCollage > ''
  5408. SELECT @Eng = COUNT(1) FROM cvEducation WITH(NOLOCK) WHERE cvMainID = @cvMainID AND GraduateCollageEng > ''
  5409. END
  5410. --工作经历
  5411. IF @Pos = 4
  5412. BEGIN
  5413. SELECT @Chs = COUNT(1) FROM cvExperience WITH(NOLOCK) WHERE cvMainID = @cvMainID AND CompanyName > ''
  5414. SELECT @Eng = COUNT(1) FROM cvExperience WITH(NOLOCK) WHERE cvMainID = @cvMainID AND CompanyNameEng > ''
  5415. END
  5416. --求职意向
  5417. IF @Pos = 6
  5418. BEGIN
  5419. SELECT @Chs = COUNT(1) FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID AND dcSalaryID > 0
  5420. SELECT @Eng = @Chs
  5421. END
  5422. --工作能力
  5423. IF @Pos = 5
  5424. BEGIN
  5425. SELECT @Chs = COUNT(1) FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID AND Speciality IS NOT NULL
  5426. SELECT @Eng = COUNT(1) FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID AND SpecialityEng IS NOT NULL
  5427. END
  5428. -- 7 语言能力
  5429. IF @Pos = 7
  5430. BEGIN
  5431. SELECT @Chs = COUNT(1) FROM cvLanguage WITH(NOLOCK) WHERE cvMainID = @cvMainID
  5432. SELECT @Eng = @Chs
  5433. END
  5434. -- 8 培训经历
  5435. IF @Pos = 8
  5436. BEGIN
  5437. SELECT @Chs = COUNT(1) FROM cvTraining WITH(NOLOCK) WHERE cvMainID = @cvMainID AND Institution IS NOT NULL
  5438. SELECT @Eng = COUNT(1) FROM cvTraining WITH(NOLOCK) WHERE cvMainID = @cvMainID AND InstitutionEng IS NOT NULL
  5439. END
  5440. -- 9 项目经历
  5441. IF @Pos = 9
  5442. BEGIN
  5443. SELECT @Chs = COUNT(1) FROM cvProject WITH(NOLOCK) WHERE cvMainID = @cvMainID AND Name IS NOT NULL
  5444. SELECT @Eng = COUNT(1) FROM cvProject WITH(NOLOCK) WHERE cvMainID = @cvMainID AND NameEng IS NOT NULL
  5445. END
  5446. -- 10 证书附件
  5447. IF @Pos = 10
  5448. BEGIN
  5449. SELECT @Chs = COUNT(1) FROM cvAppendix WITH(NOLOCK) WHERE cvMainID = @cvMainID AND (dcAppendixID < 999 OR (dcAppendixID = 999 AND Name > ''))
  5450. SELECT @Eng = COUNT(1) FROM cvAppendix WITH(NOLOCK) WHERE cvMainID = @cvMainID AND (dcAppendixID < 999 OR (dcAppendixID = 999 AND NameEng > ''))
  5451. END
  5452. SET @Chs = ISNULL(@Chs, 0)
  5453. SET @Eng = ISNULL(@Eng, 0)
  5454. IF @Chs > 0
  5455. SET @Chs = 1
  5456. IF @Eng > 0
  5457. SET @Eng = 1
  5458. EXEC pcCvMainByCvLevelUpdateNew 0, @cvMainID, @Pos, @Chs
  5459. EXEC pcCvMainByCvLevelUpdateNew 1, @cvMainID, @Pos, @Eng
  5460. END TRY
  5461. BEGIN CATCH
  5462. GOTO ERR
  5463. END CATCH
  5464. SET @Return = LTRIM(STR(@Chs)) + LTRIM(STR(@Eng))
  5465. COMMIT TRAN
  5466. RETURN @Return
  5467. ERR:
  5468. BEGIN
  5469. ROLLBACK TRAN
  5470. RETURN 3
  5471. END
  5472. GO
  5473. /****** Object: StoredProcedure [dbo].[pcCvMainByCvLevelUpdate] Script Date: 2018/12/13 19:08:17 ******/
  5474. SET ANSI_NULLS ON
  5475. GO
  5476. SET QUOTED_IDENTIFIER ON
  5477. GO
  5478. -- =============================================
  5479. -- Author: Sean
  5480. -- Create date: 2010-10-5
  5481. -- Description: <Description,,>
  5482. -- 1 存在简历
  5483. -- 2 基本信息
  5484. -- 3 教育背景
  5485. -- 4 工作经历
  5486. -- 5 工作能力
  5487. -- 6 求职意向
  5488. -- 7 语言能力
  5489. -- 8 培训经历
  5490. -- 9 项目经历
  5491. -- 10 证书附件
  5492. -- 修改cvmain的lastmodifydate和refreshdate
  5493. --检查:sean 2010-9-27
  5494. -- =============================================
  5495. CREATE PROCEDURE [dbo].[pcCvMainByCvLevelUpdate]
  5496. (
  5497. @Type INT,
  5498. @cvMainID INT,
  5499. @pos INT,
  5500. @cvLevel CHAR(1),
  5501. @PamainID INT
  5502. )
  5503. AS
  5504. BEGIN TRAN
  5505. BEGIN TRY
  5506. DECLARE @Level AS VARCHAR(10),
  5507. @cvName AS VARCHAR(100),
  5508. @c AS CHAR(1)
  5509. IF @Type = 0
  5510. BEGIN
  5511. SELECT @c = SUBSTRING(cvLevel, @pos, 1) FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
  5512. IF(@c <> @cvLevel)
  5513. UPDATE cvmain SET cvLevel = dbo.ComputeCvLevel(cvLevel, @Pos, @cvLevel) WHERE ID = @cvMainID
  5514. END
  5515. ELSE
  5516. BEGIN
  5517. SELECT @c = SUBSTRING(cvLevelEng, @pos, 1) FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
  5518. IF(@c <> @cvLevel)
  5519. UPDATE cvmain SET cvLevelEng = dbo.ComputeCvLevel(cvLevelEng, @Pos, @cvLevel) WHERE ID = @cvMainID
  5520. END
  5521. --SELECT @Level = cvLevel, @cvName = Name FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
  5522. --IF @cvName Is NULL
  5523. -- UPDATE cvMain SET Name = '未完成简历' WHERE ID = @cvMainID
  5524. UPDATE cvmain SET RefreshDate = GETDATE() WHERE ID = @cvMainID AND DATEADD(HOUR, 1, RefreshDate) < GETDATE()
  5525. END TRY
  5526. BEGIN CATCH
  5527. GOTO ERR
  5528. END CATCH
  5529. COMMIT TRAN
  5530. RETURN 1
  5531. ERR:
  5532. BEGIN
  5533. ROLLBACK TRAN
  5534. RETURN 0
  5535. END
  5536. GO
  5537. /****** Object: StoredProcedure [dbo].[pcCvMainByCvLevelUpdateNew] Script Date: 2018/12/13 19:08:17 ******/
  5538. SET ANSI_NULLS ON
  5539. GO
  5540. SET QUOTED_IDENTIFIER ON
  5541. GO
  5542. CREATE PROCEDURE [dbo].[pcCvMainByCvLevelUpdateNew]
  5543. (
  5544. @Type INT,
  5545. @cvMainID INT,
  5546. @pos INT,
  5547. @cvLevel CHAR(1)
  5548. )
  5549. AS
  5550. BEGIN TRAN
  5551. BEGIN TRY
  5552. DECLARE @Level AS VARCHAR(10),
  5553. @cvName AS VARCHAR(100),
  5554. @c AS CHAR(1)
  5555. IF @Type = 0
  5556. BEGIN
  5557. SELECT @c = SUBSTRING(cvLevel, @pos, 1) FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
  5558. IF(@c <> @cvLevel)
  5559. UPDATE cvmain SET cvLevel = dbo.ComputeCvLevel(cvLevel, @Pos, @cvLevel) WHERE ID = @cvMainID
  5560. END
  5561. ELSE
  5562. BEGIN
  5563. SELECT @c = SUBSTRING(cvLevelEng, @pos, 1) FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
  5564. IF(@c <> @cvLevel)
  5565. UPDATE cvmain SET cvLevelEng = dbo.ComputeCvLevel(cvLevelEng, @Pos, @cvLevel) WHERE ID = @cvMainID
  5566. END
  5567. UPDATE cvmain SET RefreshDate = GETDATE() WHERE ID = @cvMainID AND DATEADD(HOUR, 1, RefreshDate) < GETDATE()
  5568. END TRY
  5569. BEGIN CATCH
  5570. GOTO ERR
  5571. END CATCH
  5572. COMMIT TRAN
  5573. RETURN 1
  5574. ERR:
  5575. BEGIN
  5576. ROLLBACK TRAN
  5577. RETURN 0
  5578. END
  5579. GO
  5580. /****** Object: StoredProcedure [dbo].[pcCvMainByEngClearUpdate] Script Date: 2018/12/13 19:08:17 ******/
  5581. SET ANSI_NULLS ON
  5582. GO
  5583. SET QUOTED_IDENTIFIER ON
  5584. GO
  5585. /**创建时间:2013-12-09 13:22
  5586. *创建人:Peter
  5587. *功能:清空英文简历
  5588. */
  5589. CREATE PROCEDURE [dbo].[pcCvMainByEngClearUpdate]
  5590. (
  5591. @cvMainID INT,
  5592. @paMainID INT
  5593. )
  5594. AS
  5595. BEGIN TRAN
  5596. BEGIN TRY
  5597. --判断cvMainID是否属于该paMain
  5598. DECLARE @CountTemp AS INT
  5599. SELECT @CountTemp = COUNT(*)
  5600. FROM cvMain
  5601. WHERE id = @cvMainID AND paMainID = @paMainID
  5602. IF @CountTemp = 1
  5603. BEGIN
  5604. --清空证书信息
  5605. UPDATE cvAppendix
  5606. SET NameEng = NULL, DescriptionEng = NULL
  5607. WHERE cvMainID = @cvMainID
  5608. --清空教育信息
  5609. UPDATE cvEducation
  5610. SET GraduateCollageEng = NULL, MajorNameEng = NULL, DetailsEng = NULL
  5611. WHERE cvMainID = @cvMainID
  5612. --清空工作经历信息
  5613. UPDATE cvExperience
  5614. SET CompanyNameEng = NULL, JobNameEng = NULL, DescriptionEng = NULL, DeptEng = NULL, UpperPostEng = NULL
  5615. WHERE cvMainID = @cvMainID
  5616. --清空语言信息
  5617. UPDATE cvLanguage
  5618. SET ScoreEng = NULL
  5619. WHERE cvMainID = @cvMainID
  5620. --清空项目经历信息
  5621. UPDATE cvProject
  5622. SET NameEng = NULL, DescriptionEng = NULL, ResponsibilitiesEng = NULL
  5623. WHERE cvMainID = @cvMainID
  5624. --清空培训经历信息
  5625. UPDATE cvTraining
  5626. SET InstitutionEng = NULL, CourseEng = NULL, CityEng = NULL, CertificateEng = NULL, DetailsEng = NULL
  5627. WHERE cvMainID = @cvMainID
  5628. --清空paMain中的英文名称
  5629. UPDATE paMain
  5630. SET NameEng = NULL
  5631. WHERE ID = @paMainID
  5632. --清空CvMain中的信息
  5633. UPDATE cvMain
  5634. SET SpecialityEng = NULL, VerifyResultEng = 0, cvLevelEng = '1000000000'
  5635. WHERE ID = @cvMainID
  5636. --删除修改日志里该简历的数据
  5637. DELETE FROM bsCvModify
  5638. WHERE cvMainID = @cvMainID
  5639. AND paMainID = @paMainID
  5640. AND Location LIKE '_e_'
  5641. END
  5642. ELSE
  5643. BEGIN
  5644. RETURN -1
  5645. END
  5646. END TRY
  5647. BEGIN CATCH
  5648. GOTO ERR
  5649. END CATCH
  5650. COMMIT TRAN
  5651. RETURN 1
  5652. ERR:
  5653. BEGIN
  5654. ROLLBACK TRAN
  5655. RETURN 0
  5656. END
  5657. GO
  5658. /****** Object: StoredProcedure [dbo].[pcCvMainByIscvHiddenUpdate] Script Date: 2018/12/13 19:08:18 ******/
  5659. SET ANSI_NULLS ON
  5660. GO
  5661. SET QUOTED_IDENTIFIER ON
  5662. GO
  5663. --====================================
  5664. --检查: Sean,2010-10-5
  5665. --说明: 隐藏简历
  5666. --在ajax文件中判断caMain.paMainID = pa.ID
  5667. --====================================
  5668. CREATE PROCEDURE [dbo].[pcCvMainByIscvHiddenUpdate]
  5669. @ID INT,
  5670. @IscvHidden INT, ----0:不隐藏;1:隐藏
  5671. @paMainID INT
  5672. AS
  5673. BEGIN
  5674. BEGIN TRY
  5675. UPDATE CvMain SET IscvHidden = @IscvHidden WHERE ID = @ID AND paMainID = @paMainID
  5676. RETURN 1
  5677. END TRY
  5678. BEGIN CATCH
  5679. RETURN 0
  5680. END CATCH
  5681. END
  5682. GO
  5683. /****** Object: StoredProcedure [dbo].[pcCvMainByIsNameHiddenUpdate] Script Date: 2018/12/13 19:08:18 ******/
  5684. SET ANSI_NULLS ON
  5685. GO
  5686. SET QUOTED_IDENTIFIER ON
  5687. GO
  5688. -- =============================================
  5689. --检查: Sean,2010-12-9
  5690. --说明: 隐藏姓名
  5691. --在ajax文件中判断caMain.paMainID = pa.ID
  5692. -- =============================================
  5693. CREATE PROCEDURE [dbo].[pcCvMainByIsNameHiddenUpdate]
  5694. @ID INT,
  5695. @IsNameHidden INT, ----0:不隐藏;1:隐藏
  5696. @paMainID INT
  5697. AS
  5698. BEGIN TRY
  5699. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID = @ID AND paMainID = @paMainID)
  5700. RETURN 0
  5701. UPDATE CvMain SET IsNameHidden = @IsNameHidden WHERE ID = @ID
  5702. RETURN 1
  5703. END TRY
  5704. BEGIN CATCH
  5705. RETURN 0
  5706. END CATCH
  5707. GO
  5708. /****** Object: StoredProcedure [dbo].[pcCvMainByNameUpdate] Script Date: 2018/12/13 19:08:18 ******/
  5709. SET ANSI_NULLS ON
  5710. GO
  5711. SET QUOTED_IDENTIFIER ON
  5712. GO
  5713. --=============================================
  5714. -- 检查: Sean
  5715. -- 时间: 2010-9-28
  5716. -- 描述: 取消了对简历名称的审核,取消了对cvlevel的修改,cvlevel做第一位一直是1。
  5717. --修改:Lambo,2010-11-25
  5718. --描述:增加了paMainID参数,判断是否是本人的
  5719. --=============================================
  5720. CREATE PROCEDURE [dbo].[pcCvMainByNameUpdate]
  5721. (
  5722. @Type INT,
  5723. @ID INT,
  5724. @paMainID INT,
  5725. @Name VARCHAR(100)
  5726. )
  5727. AS
  5728. SET NOCOUNT ON
  5729. IF LEN(ISNULL(@Name, '')) = 0
  5730. RETURN 0
  5731. IF CHARINDEX('<', @Name) > 0
  5732. SET @Name = REPLACE(@Name, '<', '')
  5733. BEGIN TRAN
  5734. BEGIN TRY
  5735. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID = @ID AND paMainID = @paMainID)
  5736. GOTO ERR
  5737. SET @Name = dbo.SafeSql(@Name)
  5738. DECLARE @N NVARCHAR(20)
  5739. SET @N = @Name
  5740. IF @Type = 0
  5741. UPDATE CvMain SET Name = @N WHERE ID = @ID
  5742. ELSE
  5743. UPDATE CvMain SET Name = @Name WHERE ID = @ID
  5744. END TRY
  5745. BEGIN CATCH
  5746. GOTO ERR
  5747. END CATCH
  5748. COMMIT TRAN
  5749. RETURN 1
  5750. ERR:
  5751. BEGIN
  5752. ROLLBACK TRAN
  5753. RETURN 0
  5754. END
  5755. GO
  5756. /****** Object: StoredProcedure [dbo].[pcCvMainByNoExpCreate] Script Date: 2018/12/13 19:08:18 ******/
  5757. SET ANSI_NULLS ON
  5758. GO
  5759. SET QUOTED_IDENTIFIER ON
  5760. GO
  5761. CREATE PROCEDURE [dbo].[pcCvMainByNoExpCreate]
  5762. (
  5763. @paMainID INT,
  5764. @IP VARCHAR(39)
  5765. )
  5766. AS
  5767. BEGIN TRY
  5768. DECLARE @Count INT
  5769. SELECT @Count=COUNT(*) FROM cvMain WITH(NOLOCK INDEX(IX_cvMain_paMainID)) WHERE paMainID=@paMainID
  5770. --已经有3份简历
  5771. IF @Count>2
  5772. RETURN 0
  5773. ELSE
  5774. BEGIN
  5775. DECLARE @Mobile VARCHAR(13), @Name VARCHAR(20), @cvLevel AS CHAR(10), @cvLevelEng AS CHAR(10)
  5776. SELECT @cvLevel = '1000000000', @cvLevelEng = '1000000000'
  5777. SELECT @Name = ISNULL(Name, ''), @Mobile = ISNULL(Mobile, '') FROM paMain WITH(NOLOCK INDEX(PK_paMain)) WHERE ID = @paMainID
  5778. IF (LEN(@Mobile) > 0 AND LEN(@Name) > 0)
  5779. BEGIN
  5780. SELECT @cvLevel = '1100000000', @cvLevelEng = '1100000000'
  5781. END
  5782. BEGIN TRAN
  5783. DECLARE @cvMainID AS INT
  5784. INSERT INTO cvMain(paMainID, Name, cvLevel, cvLevelEng, cvType)
  5785. VALUES(@paMainID, '未完成简历', @cvLevel, @cvLevelEng,1)
  5786. SET @cvMainID = @@IDENTITY
  5787. INSERT INTO paOperationLog (paMainID,Operation,Details,IP)
  5788. VALUES(@paMainID, 14, '创建简历,编号' + RTRIM(CONVERT(VARCHAR(10),@cvMainID)), @IP)
  5789. COMMIT
  5790. RETURN @cvMainID
  5791. END
  5792. END TRY
  5793. BEGIN CATCH
  5794. PRINT ''
  5795. ROLLBACK TRAN
  5796. RETURN 0
  5797. END CATCH
  5798. GO
  5799. /****** Object: StoredProcedure [dbo].[pcCvMainByPaMainIDBaseSelect] Script Date: 2018/12/13 19:08:18 ******/
  5800. SET ANSI_NULLS ON
  5801. GO
  5802. SET QUOTED_IDENTIFIER ON
  5803. GO
  5804. CREATE PROCEDURE [dbo].[pcCvMainByPaMainIDBaseSelect]
  5805. (
  5806. @paMainID INT
  5807. )
  5808. AS
  5809. BEGIN
  5810. SELECT ID,
  5811. paMainID,
  5812. Name,
  5813. IsNameHidden,
  5814. IscvHidden,
  5815. isOpen,
  5816. cvLevel,
  5817. cvLevelEng,
  5818. VerifyResult,
  5819. VerifyResultEng,
  5820. Valid,
  5821. ViewNumber,
  5822. RefreshDate,
  5823. Attachment,
  5824. cvType,
  5825. JobName
  5826. FROM cvMain WITH(NOLOCK)
  5827. WHERE paMainID=@paMainID
  5828. ORDER BY RefreshDate DESC, ID
  5829. END
  5830. GO
  5831. /****** Object: StoredProcedure [dbo].[pcCvMainByPaMainIDMinSelect] Script Date: 2018/12/13 19:08:19 ******/
  5832. SET ANSI_NULLS ON
  5833. GO
  5834. SET QUOTED_IDENTIFIER ON
  5835. GO
  5836. --====================================
  5837. --Creatoe: sean,2011-8-4
  5838. --主要用于个人用户自己的查看,而不是搜索,所以不加valid>0条件
  5839. --====================================
  5840. CREATE PROCEDURE [dbo].[pcCvMainByPaMainIDMinSelect]
  5841. (
  5842. @paMainID INT
  5843. )
  5844. AS
  5845. BEGIN
  5846. SELECT ID, Name
  5847. FROM cvMain WITH(NOLOCK)
  5848. WHERE paMainID=@paMainID
  5849. ORDER BY RefreshDate DESC, ID
  5850. END
  5851. GO
  5852. /****** Object: StoredProcedure [dbo].[pcCvMainByPaMainIDSelect] Script Date: 2018/12/13 19:08:19 ******/
  5853. SET ANSI_NULLS ON
  5854. GO
  5855. SET QUOTED_IDENTIFIER ON
  5856. GO
  5857. --====================================
  5858. --检查: sean,2010-10-5
  5859. --主要用于个人用户自己的查看,而不是搜索,所以不加valid>0条件
  5860. --====================================
  5861. CREATE PROCEDURE [dbo].[pcCvMainByPaMainIDSelect]
  5862. (
  5863. @paMainID INT
  5864. )
  5865. AS
  5866. BEGIN
  5867. SELECT *
  5868. FROM cvMain WITH(NOLOCK)
  5869. WHERE paMainID=@paMainID
  5870. ORDER BY RefreshDate DESC, ID
  5871. END
  5872. GO
  5873. /****** Object: StoredProcedure [dbo].[pcCvMainByRecommendSelect] Script Date: 2018/12/13 19:08:19 ******/
  5874. SET ANSI_NULLS ON
  5875. GO
  5876. SET QUOTED_IDENTIFIER ON
  5877. GO
  5878. CREATE PROCEDURE [dbo].[pcCvMainByRecommendSelect]
  5879. @paMainID INT
  5880. AS
  5881. BEGIN
  5882. SELECT
  5883. ID,
  5884. paMainID,
  5885. Name,
  5886. EmployType,
  5887. dcSalaryID,
  5888. Attachment,
  5889. WordFileNAme,
  5890. cvType,
  5891. IsNameHidden,
  5892. IscvHidden,
  5893. isOpen,
  5894. cvLevel,
  5895. cvLevelEng,
  5896. VerifyResult,
  5897. VerifyResultEng,
  5898. Valid,
  5899. ViewNumber,
  5900. RefreshDate,
  5901. Degree
  5902. FROM cvMain WITH(NOLOCK)
  5903. WHERE paMainID=@paMainID
  5904. AND ((cvLevel like '1111_1%' AND VerifyResult=1) OR (cvLevelEng like '1111_1%' AND VerifyResultEng=1))
  5905. END
  5906. GO
  5907. /****** Object: StoredProcedure [dbo].[pcCvMainBySpecialitySelect] Script Date: 2018/12/13 19:08:19 ******/
  5908. SET ANSI_NULLS ON
  5909. GO
  5910. SET QUOTED_IDENTIFIER ON
  5911. GO
  5912. -- =============================================
  5913. -- 创建: Sean
  5914. -- 检查: 2010-9-27
  5915. -- 说明: 提取工作能力
  5916. -- =============================================
  5917. CREATE PROCEDURE [dbo].[pcCvMainBySpecialitySelect]
  5918. @Type INT,
  5919. @ID INT,
  5920. @Speciality NVARCHAR(Max) OutPut
  5921. AS
  5922. BEGIN
  5923. IF @Type=0
  5924. SELECT @Speciality=Speciality FROM cvMain WITH(NOLOCK) WHERE ID = @ID
  5925. ELSE
  5926. SELECT @Speciality=SpecialityEng FROM cvMain WITH(NOLOCK) WHERE ID = @ID
  5927. END
  5928. GO
  5929. /****** Object: StoredProcedure [dbo].[pcCvMainBySpecialityUpdate] Script Date: 2018/12/13 19:08:19 ******/
  5930. SET ANSI_NULLS ON
  5931. GO
  5932. SET QUOTED_IDENTIFIER ON
  5933. GO
  5934. CREATE PROCEDURE [dbo].[pcCvMainBySpecialityUpdate]
  5935. (
  5936. @Type INT,
  5937. @ID INT,
  5938. @Speciality VARCHAR(MAX),
  5939. @paMainID INT
  5940. )
  5941. AS
  5942. SET NOCOUNT ON
  5943. IF CHARINDEX('<', @Speciality) > 0
  5944. SET @Speciality = REPLACE(@Speciality, '<', '&lt;')
  5945. BEGIN TRAN
  5946. BEGIN TRY
  5947. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID = @ID AND paMainID = @paMainID)
  5948. GOTO err
  5949. SET @Speciality = dbo.SafeSql(dbo.TextTrim(@Speciality))
  5950. DECLARE @SpecialityOld VARCHAR(MAX)
  5951. DECLARE @S NVARCHAR(2000)
  5952. IF @Type=0
  5953. BEGIN
  5954. SELECT @SpecialityOld = dbo.TextTrim(Speciality) FROM cvMain WHERE ID = @ID
  5955. SET @S=@Speciality
  5956. IF ISNULL(@SpecialityOld, '') <> ISNULL(@S, '')
  5957. BEGIN
  5958. UPDATE cvMain SET Speciality = @S WHERE ID = @ID
  5959. DELETE FROM bsCvModify WHERE cvMainID=@ID AND Location = 'bc2'
  5960. IF @S IS NOT NULL
  5961. INSERT INTO bsCvModify(paMainID,cvMainID,Location,ColValue) VALUES(@paMainID,@ID,'bc2',@S)
  5962. END
  5963. END
  5964. ELSE
  5965. BEGIN
  5966. SELECT @SpecialityOld = dbo.TextTrim(SpecialityEng) FROM cvMain WHERE ID = @ID
  5967. IF ISNULL(@SpecialityOld, '') <> ISNULL(@Speciality, '')
  5968. BEGIN
  5969. UPDATE cvMain SET SpecialityEng = @Speciality WHERE ID = @ID
  5970. DELETE FROM bsCvModify WHERE cvMainID=@ID AND Location = 'be2'
  5971. IF @Speciality IS NOT NULL
  5972. INSERT INTO bsCvModify(paMainID,cvMainID,Location,ColValue) VALUES(@paMainID,@ID,'be2',@Speciality)
  5973. END
  5974. END
  5975. --修改cvLevel
  5976. DECLARE @SQL AS VARCHAR(100)
  5977. IF @Speciality >''
  5978. SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew ' + CONVERT(CHAR(1), @Type) + ',' + CONVERT(VARCHAR(10), @ID) + ',5,1'
  5979. ELSE
  5980. SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew ' + CONVERT(CHAR(1), @Type) + ',' + CONVERT(VARCHAR(10), @ID) + ',5,0'
  5981. EXEC(@SQL)
  5982. END TRY
  5983. BEGIN CATCH
  5984. GOTO ERR
  5985. END CATCH
  5986. COMMIT TRAN
  5987. RETURN 1
  5988. ERR:
  5989. BEGIN
  5990. ROLLBACK TRAN
  5991. RETURN 0
  5992. END
  5993. GO
  5994. /****** Object: StoredProcedure [dbo].[pcCvMainByWordCreate] Script Date: 2018/12/13 19:08:20 ******/
  5995. SET ANSI_NULLS ON
  5996. GO
  5997. SET QUOTED_IDENTIFIER ON
  5998. GO
  5999. -- =============================================
  6000. -- Author: Sean
  6001. -- Create date: 2010-10-5
  6002. -- Description: <Description,,>
  6003. -- =============================================
  6004. CREATE PROCEDURE [dbo].[pcCvMainByWordCreate]
  6005. (
  6006. @paMainID INT,
  6007. @IP VARCHAR(39)
  6008. )
  6009. AS
  6010. BEGIN TRY
  6011. DECLARE @Count INT
  6012. SELECT @Count = COUNT(*) FROM cvMain WITH(NOLOCK INDEX(IX_cvMain_paMainID)) WHERE paMainID = @paMainID
  6013. --已经有3份简历
  6014. IF @Count>2
  6015. RETURN 0
  6016. ELSE
  6017. BEGIN
  6018. DECLARE @Mobile VARCHAR(13), @Name VARCHAR(20), @cvLevel AS CHAR(10), @cvLevelEng AS CHAR(10)
  6019. SELECT @cvLevel = '1000000000', @cvLevelEng = '1000000000'
  6020. SELECT @Name = ISNULL(Name, ''), @Mobile = ISNULL(Mobile, '') FROM paMain WITH(NOLOCK INDEX(PK_paMain)) WHERE ID = @paMainID
  6021. IF (LEN(@Mobile) > 0 AND LEN(@Name) > 0)
  6022. BEGIN
  6023. SELECT @cvLevel = '1100000000', @cvLevelEng = '1100000000'
  6024. END
  6025. BEGIN TRAN
  6026. DECLARE @cvMainID AS INT
  6027. INSERT INTO cvMain(paMainID, Name, cvLevel, cvLevelEng, JobName)
  6028. VALUES(@paMainID, '未完成简历', @cvLevel, @cvLevelEng, '附件简历')
  6029. SET @cvMainID = @@IDENTITY
  6030. INSERT INTO paOperationLog (paMainID,Operation,Details,IP)
  6031. VALUES(@paMainID, 14, '创建简历,编号' + RTRIM(CONVERT(VARCHAR(10),@cvMainID)), @IP)
  6032. COMMIT
  6033. RETURN @cvMainID
  6034. END
  6035. END TRY
  6036. BEGIN CATCH
  6037. PRINT ''
  6038. ROLLBACK TRAN
  6039. RETURN 0
  6040. END CATCH
  6041. GO
  6042. /****** Object: StoredProcedure [dbo].[pcCvMainCreate] Script Date: 2018/12/13 19:08:20 ******/
  6043. SET ANSI_NULLS ON
  6044. GO
  6045. SET QUOTED_IDENTIFIER ON
  6046. GO
  6047. -- =============================================
  6048. -- Author: Sean
  6049. -- Create date: 2010-10-5
  6050. -- Description: <Description,,>
  6051. -- =============================================
  6052. CREATE PROCEDURE [dbo].[pcCvMainCreate]
  6053. (
  6054. @paMainID INT,
  6055. @IP VARCHAR(39)
  6056. )
  6057. AS
  6058. SET NOCOUNT ON
  6059. BEGIN TRY
  6060. DECLARE @Count INT
  6061. SELECT @Count=COUNT(*) FROM cvMain WITH(NOLOCK INDEX(IX_cvMain_paMainID)) WHERE paMainID = @paMainID
  6062. --已经有3份简历
  6063. IF @Count>2
  6064. BEGIN
  6065. DELETE FROM cvMain WHERE paMainid = @paMainID AND cvLevel = '1100000000' AND Name = '未完成简历'
  6066. SELECT @Count=COUNT(*) FROM cvMain WITH(NOLOCK INDEX(IX_cvMain_paMainID)) WHERE paMainID = @paMainID
  6067. --已经有3份简历
  6068. IF @Count>2
  6069. RETURN 0
  6070. END
  6071. ELSE
  6072. BEGIN
  6073. DECLARE @Mobile VARCHAR(13), @Name VARCHAR(20), @cvLevel AS CHAR(10), @cvLevelEng AS CHAR(10)
  6074. SELECT @cvLevel = '1000000000', @cvLevelEng = '1000000000'
  6075. SELECT @Name = ISNULL(Name, ''), @Mobile = ISNULL(Mobile, '') FROM paMain WITH(NOLOCK INDEX(PK_paMain)) WHERE ID = @paMainID
  6076. IF (LEN(@Mobile) > 0 AND LEN(@Name) > 0)
  6077. BEGIN
  6078. SELECT @cvLevel = '1100000000', @cvLevelEng = '1100000000'
  6079. END
  6080. BEGIN TRAN
  6081. DECLARE @cvMainID AS INT
  6082. INSERT INTO cvMain(paMainID, Name, cvLevel, cvLevelEng)
  6083. VALUES(@paMainID, '未完成简历', @cvLevel, @cvLevelEng)
  6084. SET @cvMainID = @@IDENTITY
  6085. INSERT INTO paOperationLog (paMainID,Operation,Details,IP)
  6086. VALUES(@paMainID, 14, '创建简历,编号' + RTRIM(CONVERT(VARCHAR(10),@cvMainID)), @IP)
  6087. UPDATE dcSystemData SET Value = Value + RAND() * 5.4 WHERE ID = 1
  6088. COMMIT
  6089. --PRINT @cvMainID
  6090. RETURN @cvMainID
  6091. END
  6092. END TRY
  6093. BEGIN CATCH
  6094. PRINT ''
  6095. ROLLBACK TRAN
  6096. RETURN 0
  6097. END CATCH
  6098. GO
  6099. /****** Object: StoredProcedure [dbo].[pcCvMainCvTypeUpdate] Script Date: 2018/12/13 19:08:20 ******/
  6100. SET ANSI_NULLS ON
  6101. GO
  6102. SET QUOTED_IDENTIFIER ON
  6103. GO
  6104. --===================================
  6105. --检查: Sean,2010-10-5
  6106. --修改:Lambo,2010-11-25
  6107. --描述:增加了paMainID参数,判断是否是本人的
  6108. --===================================
  6109. CREATE PROCEDURE [dbo].[pcCvMainCvTypeUpdate]
  6110. (
  6111. @ID INT,
  6112. @cvType TINYINT,
  6113. @paMainID INT
  6114. )
  6115. AS
  6116. BEGIN
  6117. BEGIN TRY
  6118. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID = @ID AND paMainID = @paMainID)
  6119. RETURN 0
  6120. UPDATE CvMain SET cvType = @cvType WHERE ID = @ID
  6121. DECLARE @SQL AS VARCHAR(100)
  6122. IF @cvType = 1
  6123. BEGIN
  6124. SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew 0,' + CONVERT(VARCHAR(10),@ID) + ',4,1'
  6125. EXEC(@SQL)
  6126. SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew 1,' + CONVERT(VARCHAR(10),@ID) + ',4,1'
  6127. EXEC(@SQL)
  6128. END
  6129. ELSE
  6130. BEGIN
  6131. IF NOT EXISTS(SELECT ID FROM cvExperience WITH(NOLOCK INDEX(IX_cvExperience_cvMainID)) WHERE cvMainID = @ID AND CompanyName>'')
  6132. BEGIN
  6133. SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew 0,' + CONVERT(VARCHAR(10),@ID) + ',4,0'
  6134. EXEC(@SQL)
  6135. END
  6136. IF NOT EXISTS(SELECT ID FROM cvExperience WITH(NOLOCK INDEX(IX_cvExperience_cvMainID)) WHERE cvMainID = @ID AND CompanyNameEng>'')
  6137. BEGIN
  6138. SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew 1,' + CONVERT(VARCHAR(10),@ID) + ',4,0'
  6139. EXEC(@SQL)
  6140. END
  6141. END
  6142. RETURN 1
  6143. END TRY
  6144. BEGIN CATCH
  6145. RETURN 0
  6146. END CATCH
  6147. END
  6148. GO
  6149. /****** Object: StoredProcedure [dbo].[pcCvMainDelete] Script Date: 2018/12/13 19:08:21 ******/
  6150. SET ANSI_NULLS ON
  6151. GO
  6152. SET QUOTED_IDENTIFIER ON
  6153. GO
  6154. --====================================
  6155. --检查: Sean,2010-10-5
  6156. --说明: 假删改为真删
  6157. --====================================
  6158. CREATE PROCEDURE [dbo].[pcCvMainDelete]
  6159. @ID INT,
  6160. @paMainID INT,
  6161. @IP VARCHAR(30)
  6162. AS
  6163. SET NOCOUNT ON
  6164. BEGIN TRAN
  6165. BEGIN TRY
  6166. DECLARE @paID AS INT
  6167. SELECT @paID = paMainID FROM cvMain WITH(NOLOCK INDEX(PK_cvMain)) WHERE ID = @ID
  6168. IF @paMainID <> @paID
  6169. GOTO Err
  6170. INSERT INTO paOperationLog (paMainID,Operation,Details,IP)
  6171. VALUES(@paID, 15, '删除简历,编号'+RTRIM(CONVERT(VARCHAR(10),@ID)), @IP)
  6172. DELETE FROM cvMain WHERE ID=@ID
  6173. END TRY
  6174. BEGIN CATCH
  6175. PRINT '错误编号' + CONVERT(VARCHAR(10),ERROR_NUMBER()) + '错误发生的行号' + CONVERT(VARCHAR(10),ERROR_LINE()) +'错误信息' + ERROR_MESSAGE()
  6176. GOTO ERR
  6177. END CATCH
  6178. COMMIT TRAN
  6179. RETURN 1
  6180. ERR:
  6181. BEGIN
  6182. ROLLBACK TRAN
  6183. RETURN 0
  6184. END
  6185. GO
  6186. /****** Object: StoredProcedure [dbo].[pcCvMainDetailByIDSelect] Script Date: 2018/12/13 19:08:21 ******/
  6187. SET ANSI_NULLS ON
  6188. GO
  6189. SET QUOTED_IDENTIFIER ON
  6190. GO
  6191. --#####################################################
  6192. --创建时间:2014.10.31
  6193. --创建人:Nick
  6194. --说明:获取简历对应的年龄、学历、工作年限、性别、工作地点
  6195. --#####################################################
  6196. CREATE PROCEDURE [dbo].[pcCvMainDetailByIDSelect]
  6197. (
  6198. @CvMainID INT
  6199. )
  6200. AS
  6201. BEGIN TRY
  6202. SELECT b.LivePlace,b.gender,dbo.BirthToAge(b.birthday) AS age,a.dcMajorID,
  6203. a.RelatedWorkYears,c.dcRegionID, a.Degree, a.Attachment
  6204. FROM cvmain a,pamain b,cvjobPlace c
  6205. WHERE a.id=@CvMainID
  6206. AND a.pamainID=b.ID
  6207. AND a.id=c.cvMainID
  6208. END TRY
  6209. BEGIN CATCH
  6210. RETURN 0
  6211. END CATCH
  6212. GO
  6213. /****** Object: StoredProcedure [dbo].[pcCvMainIDByJobApplyIDSelect] Script Date: 2018/12/13 19:08:21 ******/
  6214. SET ANSI_NULLS ON
  6215. GO
  6216. SET QUOTED_IDENTIFIER ON
  6217. GO
  6218. --#####################################################
  6219. --创建时间:2014.11.4
  6220. --创建人:John
  6221. --说明:根据JobApplyID取得CvMainID
  6222. --#####################################################
  6223. CREATE PROCEDURE [dbo].[pcCvMainIDByJobApplyIDSelect]
  6224. (
  6225. @PaMainID INT
  6226. )
  6227. AS
  6228. BEGIN
  6229. DECLARE @CvMainID INT
  6230. SET @CvMainID = 0
  6231. SELECT @CvMainID = cvMainID FROM
  6232. (
  6233. SELECT TOP 1 cvMainID
  6234. FROM exJobApply WITH(NOLOCK)
  6235. WHERE cvMainID IN ( SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID = @PaMainID )
  6236. ORDER BY AddDate DESC
  6237. ) TEMP1
  6238. IF @CvMainID = 0
  6239. BEGIN
  6240. SELECT @CvMainID = ID FROM
  6241. (
  6242. SELECT TOP 1 ID
  6243. FROM cvMain WITH(NOLOCK)
  6244. WHERE paMainID = @PaMainID
  6245. ORDER BY RefreshDate DESC
  6246. ) TEMP2
  6247. END
  6248. RETURN @CvMainID
  6249. END
  6250. GO
  6251. /****** Object: StoredProcedure [dbo].[pcCvMainIDByPaMainIDSelect] Script Date: 2018/12/13 19:08:21 ******/
  6252. SET ANSI_NULLS ON
  6253. GO
  6254. SET QUOTED_IDENTIFIER ON
  6255. GO
  6256. --#####################################################
  6257. --创建时间:2014.11.10
  6258. --创建人:Nick
  6259. --说明:
  6260. --#####################################################
  6261. CREATE PROCEDURE [dbo].[pcCvMainIDByPaMainIDSelect]
  6262. (
  6263. @cvMainID INT,
  6264. @paMainID INT
  6265. )
  6266. AS
  6267. BEGIN TRY
  6268. IF @cvMainID = 0
  6269. BEGIN
  6270. SELECT TOP 1 ID
  6271. FROM cvMain WITH(NOLOCK)
  6272. WHERE (
  6273. cvLevel like '111111%'
  6274. OR cvLevelEng LIKE '111111%'
  6275. OR cvLevel like '111101%'
  6276. OR cvLevelEng LIKE '111101%'
  6277. ) AND paMainID = @paMainID ORDER BY ID DESC
  6278. END
  6279. ELSE
  6280. BEGIN
  6281. SELECT TOP 1 ID
  6282. FROM cvMain WITH(NOLOCK)
  6283. WHERE (
  6284. cvLevel like '111111%'
  6285. OR cvLevelEng LIKE '111111%'
  6286. OR cvLevel like '111101%'
  6287. OR cvLevelEng LIKE '111101%'
  6288. ) AND paMainID = @paMainID And ID = @cvMainID
  6289. END
  6290. END TRY
  6291. BEGIN CATCH
  6292. RETURN 0
  6293. END CATCH
  6294. GO
  6295. /****** Object: StoredProcedure [dbo].[pcCvMainNameByIDSelect] Script Date: 2018/12/13 19:08:22 ******/
  6296. SET ANSI_NULLS ON
  6297. GO
  6298. SET QUOTED_IDENTIFIER ON
  6299. GO
  6300. --#####################################################
  6301. --创建时间:2014.10.31
  6302. --创建人:Nick
  6303. --说明:获取简历名称
  6304. --#####################################################
  6305. CREATE PROCEDURE [dbo].[pcCvMainNameByIDSelect]
  6306. (
  6307. @ID INT
  6308. )
  6309. AS
  6310. BEGIN TRY
  6311. SELECT Name FROM cvMain WHERE ID = @ID
  6312. END TRY
  6313. BEGIN CATCH
  6314. RETURN 0
  6315. END CATCH
  6316. GO
  6317. /****** Object: StoredProcedure [dbo].[pcCvMainNameByPamainIDSelect] Script Date: 2018/12/13 19:08:22 ******/
  6318. SET ANSI_NULLS ON
  6319. GO
  6320. SET QUOTED_IDENTIFIER ON
  6321. GO
  6322. --#####################################################
  6323. --创建时间:2014.10.31
  6324. --创建人:Nick
  6325. --说明:获取简历名称
  6326. --#####################################################
  6327. CREATE PROCEDURE [dbo].[pcCvMainNameByPamainIDSelect]
  6328. (
  6329. @paMainID INT
  6330. )
  6331. AS
  6332. BEGIN TRY
  6333. SELECT ID, Name FROM cvMain WITH(NOLOCK) Where VerifyResult=10 And paMainID=@paMainID ORDER BY ID
  6334. END TRY
  6335. BEGIN CATCH
  6336. RETURN 0
  6337. END CATCH
  6338. GO
  6339. /****** Object: StoredProcedure [dbo].[pcCvMainResultByPaMainIDSelect] Script Date: 2018/12/13 19:08:22 ******/
  6340. SET ANSI_NULLS ON
  6341. GO
  6342. SET QUOTED_IDENTIFIER ON
  6343. GO
  6344. --#####################################################
  6345. --创建时间:2014.10.31
  6346. --创建人:Nick
  6347. --说明:获取CVMAIN
  6348. --#####################################################
  6349. CREATE PROCEDURE [dbo].[pcCvMainResultByPaMainIDSelect]
  6350. (
  6351. @PamainID INT
  6352. )
  6353. AS
  6354. BEGIN TRY
  6355. SELECT * FROM cvMain WITH(NOLOCK)
  6356. WHERE paMainID = @PamainID
  6357. AND (AttachMent <> '' OR((cvLevel LIKE '111111%' OR cvLevel LIKE '111101%') AND VerifyResult = 1)
  6358. OR((cvLevelEng LIKE '111111%' OR cvLevelEng LIKE '111101%') AND VerifyResultEng = 1))
  6359. END TRY
  6360. BEGIN CATCH
  6361. RETURN 0
  6362. END CATCH
  6363. GO
  6364. /****** Object: StoredProcedure [dbo].[pcCvMainSelect] Script Date: 2018/12/13 19:08:22 ******/
  6365. SET ANSI_NULLS ON
  6366. GO
  6367. SET QUOTED_IDENTIFIER ON
  6368. GO
  6369. CREATE PROCEDURE [dbo].[pcCvMainSelect]
  6370. @ID INT
  6371. AS
  6372. BEGIN
  6373. SELECT *,dbo.GetPaOnlineStatus(paMainID) IsOnline
  6374. FROM cvMain WITH(NOLOCK INDEX(PK_cvMain))
  6375. WHERE ID=@ID
  6376. END
  6377. GO
  6378. /****** Object: StoredProcedure [dbo].[pcCvMainSelectTest] Script Date: 2018/12/13 19:08:22 ******/
  6379. SET ANSI_NULLS ON
  6380. GO
  6381. SET QUOTED_IDENTIFIER ON
  6382. GO
  6383. CREATE PROCEDURE [dbo].[pcCvMainSelectTest]
  6384. (
  6385. @ID INT
  6386. )
  6387. AS
  6388. BEGIN
  6389. SELECT *,dbo.GetPaOnlineStatus(paMainID) IsOnline
  6390. FROM cvMain WITH(NOLOCK INDEX(PK_cvMain))
  6391. WHERE ID=@ID
  6392. END
  6393. GO
  6394. /****** Object: StoredProcedure [dbo].[pcCvMainVerifyResultCheck_OLD] Script Date: 2018/12/13 19:08:22 ******/
  6395. SET ANSI_NULLS ON
  6396. GO
  6397. SET QUOTED_IDENTIFIER ON
  6398. GO
  6399. --==============================================
  6400. -- 名称: pcCvMainVerifyResultCheck
  6401. -- 删除: Sean
  6402. -- 时间: 2010-9-29
  6403. -- 原因: VerifyResult修改后不变,只有审核时变化,审核时列表不从cvMain提取,所以该存储过程应该无用了
  6404. --==============================================
  6405. CREATE PROCEDURE [dbo].[pcCvMainVerifyResultCheck_OLD]
  6406. @cvMainID INT
  6407. AS
  6408. BEGIN TRAN
  6409. BEGIN TRY
  6410. IF EXISTS(SELECT ID FROM bsCvModify WITH(NOLOCK)WHERE cvMainID=@cvMainID AND SUBSTRING(Location,2,1)='c' AND SUBSTRING(Location,1,1)<>'a')
  6411. UPDATE cvMain SET VerifyResult=11 WHERE ID=@cvMainID
  6412. ELSE
  6413. UPDATE cvMain SET VerifyResult=100 WHERE ID=@cvMainID
  6414. IF EXISTS(SELECT ID FROM bsCvModify WITH(NOLOCK)WHERE cvMainID=@cvMainID AND SUBSTRING(Location,2,1)='e' AND SUBSTRING(Location,1,1)<>'a')
  6415. UPDATE cvMain SET VerifyResultEng=11 WHERE ID=@cvMainID
  6416. ELSE
  6417. UPDATE cvMain SET VerifyResultEng=100 WHERE ID=@cvMainID
  6418. END TRY
  6419. BEGIN CATCH
  6420. GOTO ERR
  6421. END CATCH
  6422. COMMIT TRAN
  6423. RETURN 1
  6424. ERR:
  6425. BEGIN
  6426. ROLLBACK TRAN
  6427. RETURN 0
  6428. END
  6429. GO
  6430. /****** Object: StoredProcedure [dbo].[pcCvProjectByIDSelect] Script Date: 2018/12/13 19:08:23 ******/
  6431. SET ANSI_NULLS ON
  6432. GO
  6433. SET QUOTED_IDENTIFIER ON
  6434. GO
  6435. -------===========================
  6436. -- 检查: sean
  6437. -- 时间: 2010-9-29
  6438. -- 描述: 提取项目信息
  6439. -------===========================
  6440. CREATE PROCEDURE [dbo].[pcCvProjectByIDSelect]
  6441. @ID INT
  6442. AS
  6443. BEGIN
  6444. SELECT *
  6445. FROM CvProject WITH(NOLOCK INDEX(PK_cvProject))
  6446. WHERE ID = @ID
  6447. END
  6448. GO
  6449. /****** Object: StoredProcedure [dbo].[pcCvProjectDelete] Script Date: 2018/12/13 19:08:23 ******/
  6450. SET ANSI_NULLS ON
  6451. GO
  6452. SET QUOTED_IDENTIFIER ON
  6453. GO
  6454. -------===========================
  6455. -- 检查: sean
  6456. -- 时间: 2010-9-29
  6457. -- 描述: 删除项目信息 取消pcCvMainByCvLevelUpdate,取消pcCvMainVerifyResultCheck
  6458. -- 修改:Lambo,2010-11-25
  6459. -- 描述:增加了paMainID参数,判断是否是本人的
  6460. -------===========================
  6461. CREATE PROCEDURE [dbo].[pcCvProjectDelete]
  6462. @ID INT,
  6463. @paMainID INT
  6464. AS
  6465. BEGIN TRAN
  6466. BEGIN TRY
  6467. DECLARE @cvMainId AS INT
  6468. DECLARE @RETURN AS VARCHAR(2)
  6469. SELECT @cvMainId = cvMainId FROM cvProject WITH(NOLOCK) WHERE ID=@ID
  6470. IF @cvMainId IS NULL
  6471. GOTO ERR
  6472. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK)
  6473. WHERE paMainID = @paMainID AND ID = @cvMainID)
  6474. GOTO ERR
  6475. DELETE FROM bsCvModify WHERE SubID = @ID AND Location LIKE 'f%'
  6476. DELETE FROM cvProject WHERE ID=@ID
  6477. EXEC @RETURN = pcCvMainByCvLevelCheck @cvMainID, 9
  6478. END TRY
  6479. BEGIN CATCH
  6480. GOTO ERR
  6481. END CATCH
  6482. COMMIT TRAN
  6483. RETURN @RETURN
  6484. ERR:
  6485. BEGIN
  6486. ROLLBACK TRAN
  6487. RETURN 3
  6488. END
  6489. GO
  6490. /****** Object: StoredProcedure [dbo].[pcCvProjectSave] Script Date: 2018/12/13 19:08:23 ******/
  6491. SET ANSI_NULLS ON
  6492. GO
  6493. SET QUOTED_IDENTIFIER ON
  6494. GO
  6495. --===============================
  6496. -- 检查: sean
  6497. -- 时间: 2010-9-29
  6498. -- 描述: 取消pcCvMainByCvLevelUpdate, pcCvMainVerifyResultUpdate
  6499. -- 修改:Lambo,2010-11-25
  6500. -- 描述:增加了paMainID参数,判断是否是本人的
  6501. --===============================
  6502. CREATE PROCEDURE [dbo].[pcCvProjectSave]
  6503. (
  6504. @Type INT,
  6505. @ID INT,
  6506. @cvMainID INT,
  6507. @Name VARCHAR(250),
  6508. @StartDate INT,
  6509. @ENDDate INT,
  6510. @Description VARCHAR(MAX),
  6511. @Responsibilities VARCHAR(1000),
  6512. @paMainID INT
  6513. )
  6514. AS
  6515. SET NOCOUNT ON
  6516. IF CHARINDEX('<', @Description) > 0
  6517. SET @Description = REPLACE(@Description, '<', '')
  6518. IF CHARINDEX('<', @Responsibilities) > 0
  6519. SET @Responsibilities = REPLACE(@Responsibilities, '<', '')
  6520. IF CHARINDEX('<', @Name) > 0
  6521. SET @Name = REPLACE(@Name, '<', '')
  6522. BEGIN TRAN
  6523. ----检查是否是该账号的简历
  6524. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID AND paMainID = @paMainID)
  6525. GOTO ERR
  6526. ----检查是否是该简历的工作经验
  6527. IF @ID > 0
  6528. IF NOT EXISTS(SELECT 'x' FROM cvProject WITH(NOLOCK) WHERE ID = @ID AND cvMainID = @cvMainID)
  6529. GOTO ERR
  6530. SELECT @Name = dbo.SafeSql(dbo.TextTrim(@Name)),
  6531. @Description = dbo.SafeSql(dbo.TextTrim(@Description)),
  6532. @Responsibilities = dbo.SafeSql(dbo.TextTrim(@Responsibilities))
  6533. DECLARE @MaxId AS INT
  6534. DECLARE @NameOld AS VARCHAR(250)
  6535. DECLARE @DescriptionOld AS VARCHAR(MAX)
  6536. DECLARE @ResponsibilitiesOld AS VARCHAR(1000)
  6537. DECLARE @Modify AS INT
  6538. SET @Modify=-1
  6539. BEGIN TRY
  6540. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID =@cvMainID AND paMainID = @paMainID)
  6541. GOTO ERR
  6542. IF @Type=0
  6543. BEGIN
  6544. DECLARE @N AS NVARCHAR(50)
  6545. DECLARE @R AS NVARCHAR(200)
  6546. DECLARE @D AS NVARCHAR(2000)
  6547. SET @N = @Name
  6548. SET @D = @Description
  6549. SET @R = @Responsibilities
  6550. IF @ID>0
  6551. BEGIN
  6552. IF NOT EXISTS(SELECT 'x' FROM CvProject WITH(NOLOCK) WHERE ID =@ID AND cvMainID = @cvMainID)
  6553. GOTO ERR
  6554. SELECT @NameOld = dbo.TextTrim(ISNULL(Name, '')),
  6555. @DescriptionOld = dbo.TextTrim(ISNULL(Description, '')),
  6556. @ResponsibilitiesOld = dbo.TextTrim(ISNULL(Responsibilities, ''))
  6557. FROM CvProject WITH(NOLOCK) WHERE ID = @ID
  6558. UPDATE CvProject SET
  6559. Name = @N,
  6560. StartDate = @StartDate,
  6561. ENDDate = @ENDDate,
  6562. Description = @D,
  6563. Responsibilities = @R
  6564. WHERE ID=@ID
  6565. SET @MaxID = @ID
  6566. IF ISNULL(@NameOld, '') <> ISNULL(@N, '')
  6567. BEGIN
  6568. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'fc1'
  6569. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'fc1',@N)
  6570. SET @Modify=0
  6571. END
  6572. IF @D IS NULL
  6573. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'fc2'
  6574. ELSE
  6575. IF ISNULL(@DescriptionOld, '') <> @D
  6576. BEGIN
  6577. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'fc2'
  6578. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'fc2',@D)
  6579. SET @Modify=0
  6580. END
  6581. IF @R IS NULL
  6582. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'fc3'
  6583. ELSE
  6584. IF ISNULL(@ResponsibilitiesOld, '') <> @R
  6585. BEGIN
  6586. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'fc3'
  6587. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'fc3',@R)
  6588. SET @Modify=0
  6589. END
  6590. END
  6591. ELSE
  6592. BEGIN
  6593. INSERT INTO CvProject
  6594. (cvMainID,Name,StartDate,ENDDate,Description,Responsibilities)
  6595. VALUES(@cvMainID,@Name,@StartDate,@ENDDate,@D,@R)
  6596. SET @MaxID = @@IDENTITY
  6597. SET @Modify=0
  6598. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'fc1',@N)
  6599. IF @D > ''
  6600. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'fc2',@D)
  6601. IF @R > ''
  6602. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'fc3',@R)
  6603. END
  6604. END
  6605. ELSE
  6606. BEGIN
  6607. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID =@cvMainID AND paMainID = @paMainID)
  6608. GOTO ERR
  6609. IF @ID>0
  6610. BEGIN
  6611. IF NOT EXISTS(SELECT 'x' FROM CvProject WITH(NOLOCK) WHERE ID =@ID AND cvMainID = @cvMainID)
  6612. GOTO ERR
  6613. SELECT @NameOld = dbo.TextTrim(ISNULL(NameEng, '')),
  6614. @DescriptionOld = dbo.TextTrim(ISNULL(DescriptionEng, '')),
  6615. @ResponsibilitiesOld = dbo.TextTrim(ISNULL(ResponsibilitiesEng, ''))
  6616. FROM CvProject WITH(NOLOCK) WHERE ID = @ID
  6617. UPDATE CvProject SET
  6618. NameEng = @Name,
  6619. StartDate = @StartDate,
  6620. ENDDate = @ENDDate,
  6621. DescriptionEng = @Description,
  6622. ResponsibilitiesEng = @Responsibilities
  6623. WHERE ID=@ID
  6624. SET @MaxID = @ID
  6625. IF ISNULL(@NameOld, '') <> ISNULL(@Name, '')
  6626. BEGIN
  6627. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'fe1'
  6628. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'fe1',@Name)
  6629. SET @Modify=1
  6630. END
  6631. IF @Description IS NULL
  6632. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'fe2'
  6633. ELSE
  6634. IF ISNULL(@DescriptionOld, '') <> @Description
  6635. BEGIN
  6636. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'fe2'
  6637. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'fe2',@Description)
  6638. SET @Modify=1
  6639. END
  6640. IF @Responsibilities IS NULL
  6641. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'fe3'
  6642. ELSE
  6643. IF ISNULL(@ResponsibilitiesOld, '') <> @Responsibilities
  6644. BEGIN
  6645. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'fe3'
  6646. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'fe3',@Responsibilities)
  6647. SET @Modify=1
  6648. END
  6649. END
  6650. ELSE
  6651. BEGIN
  6652. INSERT INTO CvProject
  6653. (cvMainID,NameEng,StartDate,ENDDate,DescriptionEng,ResponsibilitiesEng)
  6654. VALUES(@cvMainID,@Name,@StartDate,@ENDDate,@Description,@Responsibilities)
  6655. SET @MaxID = @@IDENTITY
  6656. SET @Modify=1
  6657. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'fe1',@Name)
  6658. IF @Description > ''
  6659. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'fe2',@Description)
  6660. IF @Responsibilities > ''
  6661. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'fe3',@Responsibilities)
  6662. END
  6663. END
  6664. --修改cvLevel
  6665. DECLARE @SQL AS VARCHAR(100)
  6666. SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew ' + CONVERT(CHAR(1), @Type) + ',' + CONVERT(VARCHAR(10), @cvMainID) + ',9,1'
  6667. EXEC(@SQL)
  6668. END TRY
  6669. BEGIN cATCH
  6670. GOTO ERR
  6671. END CATCH
  6672. COMMIT TRAN
  6673. RETURN @MaxID
  6674. ERR:
  6675. BEGIN
  6676. ROLLBACK TRAN
  6677. RETURN 0
  6678. END
  6679. GO
  6680. /****** Object: StoredProcedure [dbo].[pcCvProjectSelect] Script Date: 2018/12/13 19:08:23 ******/
  6681. SET ANSI_NULLS ON
  6682. GO
  6683. SET QUOTED_IDENTIFIER ON
  6684. GO
  6685. -- =============================================
  6686. -- Author: Sean
  6687. -- Create date: 2010-10-5
  6688. -- Description: 选择项目信息
  6689. -- =============================================
  6690. CREATE PROCEDURE [dbo].[pcCvProjectSelect]
  6691. @cvMainID INT
  6692. AS
  6693. BEGIN
  6694. SELECT *
  6695. FROM CvProject WITH(NOLOCK INDEX(IX_cvProject_cvMainID))
  6696. WHERE cvMainID = @cvMainID
  6697. ORDER BY StartDate DESC
  6698. END
  6699. GO
  6700. /****** Object: StoredProcedure [dbo].[pcCvrExchangeInsert] Script Date: 2018/12/13 19:08:23 ******/
  6701. SET ANSI_NULLS ON
  6702. GO
  6703. SET QUOTED_IDENTIFIER ON
  6704. GO
  6705. CREATE PROCEDURE [dbo].[pcCvrExchangeInsert]
  6706. (
  6707. @RecommendID INT,
  6708. @dcSubSiteId INT,
  6709. @ExchangeNumber INT,
  6710. @cvrGift INT,
  6711. @Recipient VARCHAR(50),
  6712. @RecipientMobile VARCHAR(15),
  6713. @RecipientAddress VARCHAR(100),
  6714. @Remark VARCHAR(MAX)
  6715. )
  6716. AS
  6717. BEGIN TRY
  6718. DECLARE @Amount INT
  6719. DECLARE @lastIntegral INT
  6720. IF NOT EXISTS(SELECT 'x' FROM marketDB..cvrGift WITH(NOLOCK) WHERE ID = @cvrGift AND isonline=1 AND remainder >= @ExchangeNumber)
  6721. RETURN -1
  6722. SELECT @Amount = Cost * @ExchangeNumber FROM marketDB..cvrGift WHERE ID = @cvrGift
  6723. SELECT @lastIntegral = (SELECT COUNT(*) FROM marketdb..cvrRecommend WITH(NOLOCK)
  6724. WHERE RecommendID=@RecommendID
  6725. AND HasValid=3 AND HasReply=1) -
  6726. ISNULL((SELECT SUM(Amount) FROM marketdb..cvrExchange WITH(NOLOCK)
  6727. WHERE RecommendID=@RecommendID
  6728. AND HasVerify<>2), 0)
  6729. IF @lastIntegral<@Amount
  6730. RETURN -2
  6731. INSERT INTO marketDB..cvrExchange(RecommendID, dcSubSiteId, ExchangeNumber, cvrGift, Amount, ApplyTime, Recipient, RecipientMobile, RecipientAddress, Remark)
  6732. SELECT @RecommendID, @dcSubSiteId, @ExchangeNumber, @cvrGift, @Amount, GETDATE(), dbo.SafeSQL(@Recipient),
  6733. dbo.SafeSQL(@RecipientMobile), dbo.SafeSQL(@RecipientAddress), dbo.SafeSQL(@Remark)
  6734. UPDATE marketDB..cvrGift SET Remainder = Remainder - @ExchangeNumber WHERE ID = @cvrGift
  6735. RETURN 1
  6736. END TRY
  6737. BEGIN CATCH
  6738. RETURN 0
  6739. END CATCH
  6740. GO
  6741. /****** Object: StoredProcedure [dbo].[pcCvTrainingByIDSelect] Script Date: 2018/12/13 19:08:24 ******/
  6742. SET ANSI_NULLS ON
  6743. GO
  6744. SET QUOTED_IDENTIFIER ON
  6745. GO
  6746. -- =============================================
  6747. -- 检查: Sean
  6748. -- 日期: 2010-10-5
  6749. -- 描述: 提取培训经历
  6750. -- =============================================
  6751. CREATE PROCEDURE [dbo].[pcCvTrainingByIDSelect]
  6752. @ID INT
  6753. AS
  6754. BEGIN
  6755. SELECT *
  6756. FROM CvTraining WITH(NOLOCK INDEX(PK_cvTraining))
  6757. WHERE ID = @ID
  6758. END
  6759. GO
  6760. /****** Object: StoredProcedure [dbo].[pcCvTrainingDelete] Script Date: 2018/12/13 19:08:24 ******/
  6761. SET ANSI_NULLS ON
  6762. GO
  6763. SET QUOTED_IDENTIFIER ON
  6764. GO
  6765. --===============================
  6766. -- 检查: sean
  6767. -- 时间: 2010-9-29
  6768. -- 描述: 删除培训经历 取消pcCvMainByCvLevelUpdate,pcCvMainVerifyResultCheck
  6769. -- 修改:Lambo,2010-11-25
  6770. -- 描述:增加了paMainID参数,判断是否是本人的
  6771. --===============================
  6772. CREATE PROCEDURE [dbo].[pcCvTrainingDelete]
  6773. (
  6774. @ID INT,
  6775. @paMainID INT
  6776. )
  6777. AS
  6778. BEGIN TRAN
  6779. BEGIN TRY
  6780. DECLARE @cvMainId AS INT
  6781. DECLARE @RETURN AS VARCHAR(2)
  6782. SELECT @cvMainId = cvMainId FROM CvTraining WITH(NOLOCK) WHERE ID=@ID
  6783. IF @cvMainId IS NULL
  6784. GOTO ERR
  6785. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK)
  6786. WHERE paMainID = @paMainID AND ID = @cvMainID)
  6787. GOTO ERR
  6788. DELETE FROM CvTraining WHERE ID=@ID
  6789. DELETE FROM bsCvModify WHERE SubID = @ID AND Location LIKE 'g%'
  6790. EXEC @RETURN = pcCvMainByCvLevelCheck @cvMainID, 8
  6791. END TRY
  6792. BEGIN CATCH
  6793. GOTO ERR
  6794. END CATCH
  6795. COMMIT TRAN
  6796. RETURN @RETURN
  6797. ERR:
  6798. BEGIN
  6799. ROLLBACK TRAN
  6800. RETURN 3
  6801. END
  6802. GO
  6803. /****** Object: StoredProcedure [dbo].[pcCvTrainingSave] Script Date: 2018/12/13 19:08:24 ******/
  6804. SET ANSI_NULLS ON
  6805. GO
  6806. SET QUOTED_IDENTIFIER ON
  6807. GO
  6808. --==================================================
  6809. -- 检查: sean
  6810. -- 时间: 2010-9-29
  6811. -- 说明: 保存培训信息 取消pcCvMainByCvLevelUpdate pcCvMainVerifyResultUpdate
  6812. ----------------
  6813. CREATE PROCEDURE [dbo].[pcCvTrainingSave]
  6814. (
  6815. @Type INT,
  6816. @ID INT,
  6817. @cvMainID INT,
  6818. @StartDate INT,
  6819. @TimeLength INT,
  6820. @TimeUnit INT,
  6821. @Institution VARCHAR(150),
  6822. @Course VARCHAR(250),
  6823. @City VARCHAR(50),
  6824. @Certificate VARCHAR(250),
  6825. @Details VARCHAR(2500),
  6826. @paMainID INT
  6827. )
  6828. AS
  6829. SET NOCOUNT ON
  6830. IF CHARINDEX('<', @Institution) > 0
  6831. SET @Institution = REPLACE(@Institution, '<', '')
  6832. IF CHARINDEX('<', @Course) > 0
  6833. SET @Course = REPLACE(@Course, '<', '')
  6834. IF CHARINDEX('<', @City) > 0
  6835. SET @City = REPLACE(@City, '<', '')
  6836. IF CHARINDEX('<', @Certificate) > 0
  6837. SET @Certificate = REPLACE(@Certificate, '<', '')
  6838. IF CHARINDEX('<', @Details) > 0
  6839. SET @Details = REPLACE(@Details, '<', '')
  6840. BEGIN TRAN
  6841. ----检查是否是该账号的简历
  6842. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID AND paMainID = @paMainID)
  6843. GOTO ERR
  6844. ----检查是否是该简历的培训信息
  6845. IF @ID > 0
  6846. IF NOT EXISTS(SELECT 'x' FROM CvTraining WITH(NOLOCK) WHERE ID = @ID AND cvMainID = @cvMainID)
  6847. GOTO ERR
  6848. SELECT @Institution = dbo.SafeSql(dbo.TextTrim(@Institution)),
  6849. @Course = dbo.SafeSql(dbo.TextTrim(@Course)),
  6850. @City = dbo.SafeSql(dbo.TextTrim(@City)),
  6851. @Certificate = dbo.SafeSql(dbo.TextTrim(@Certificate)),
  6852. @Details = dbo.SafeSql(dbo.TextTrim(@Details))
  6853. BEGIN TRY
  6854. DECLARE @MaxId AS INT
  6855. DECLARE @InstitutionOld AS VARCHAR(150)
  6856. DECLARE @CourseOld AS VARCHAR(250)
  6857. DECLARE @CityOld AS VARCHAR(50)
  6858. DECLARE @CertificateOld AS VARCHAR(250)
  6859. DECLARE @DetailsOld AS VARCHAR(2500)
  6860. DECLARE @Modify AS INT
  6861. SET @Modify=-1
  6862. IF @Type=0
  6863. BEGIN
  6864. DECLARE @I AS NVARCHAR(30)
  6865. DECLARE @C AS NVARCHAR(50)
  6866. DECLARE @Ci AS NVARCHAR(10)
  6867. DECLARE @Ce AS NVARCHAR(50)
  6868. DECLARE @D AS NVARCHAR(500)
  6869. SET @I = @Institution
  6870. SET @C = @Course
  6871. SET @Ci = @City
  6872. SET @Ce = @Certificate
  6873. SET @D = @Details
  6874. IF @ID>0
  6875. BEGIN
  6876. SELECT @InstitutionOld=dbo.TextTrim(ISNULL(Institution, '')),
  6877. @CourseOld=dbo.TextTrim(ISNULL(Course, '')),
  6878. @CityOld=dbo.TextTrim(ISNULL(City, '')),
  6879. @CertificateOld=dbo.TextTrim(ISNULL(Certificate, '')),
  6880. @DetailsOld=dbo.TextTrim(ISNULL(Details, ''))
  6881. FROM CvTraining WITH(NOLOCK INDEX(PK_cvTraining))
  6882. WHERE ID =@ID
  6883. UPDATE CvTraining SET
  6884. StartDate = @StartDate,
  6885. TimeLength = @TimeLength,
  6886. TimeUnit = @TimeUnit,
  6887. Institution = @I,
  6888. Course = @C,
  6889. City = @Ci,
  6890. Certificate = @Ce,
  6891. Details = @D
  6892. WHERE ID=@ID
  6893. SET @MaxID = @ID
  6894. IF ISNULL(@InstitutionOld, '') <> ISNULL(@I, '')
  6895. BEGIN
  6896. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'gc1'
  6897. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'gc1',@I)
  6898. SET @Modify=0
  6899. END
  6900. IF ISNULL(@CourseOld, '') <> ISNULL(@C, '')
  6901. BEGIN
  6902. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'gc2'
  6903. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'gc2',@C)
  6904. SET @Modify=0
  6905. END
  6906. IF @Ci IS NULL
  6907. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'gc3'
  6908. ELSE
  6909. IF ISNULL(@CityOld, '') <> ISNULL(@Ci, '')
  6910. BEGIN
  6911. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'gc3'
  6912. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'gc3',@ci)
  6913. SET @Modify=0
  6914. END
  6915. IF @Ce IS NULL
  6916. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'gc4'
  6917. ELSE
  6918. IF ISNULL(@CertificateOld, '') <> ISNULL(@Ce, '')
  6919. BEGIN
  6920. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'gc4'
  6921. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'gc4',@ce)
  6922. SET @Modify=0
  6923. END
  6924. IF @D IS NULL
  6925. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'gc5'
  6926. ELSE
  6927. IF ISNULL(@DetailsOld, '') <> ISNULL(@D, '')
  6928. BEGIN
  6929. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'gc5'
  6930. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'gc5',@D)
  6931. SET @Modify=0
  6932. END
  6933. END
  6934. ELSE
  6935. BEGIN
  6936. INSERT INTO CvTraining
  6937. (cvMainID,StartDate,TimeLength,TimeUnit,Institution,
  6938. Course,City,Certificate,Details)
  6939. VALUES(@cvMainID,@StartDate,@TimeLength,@TimeUnit,@I,
  6940. @c,@Ci,@Ce,@D)
  6941. SET @MaxID = @@IDENTITY
  6942. SET @Modify=0
  6943. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'gc1',@I)
  6944. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'gc2',@C)
  6945. IF @ci > ''
  6946. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'gc3',@ci)
  6947. IF @Ce > ''
  6948. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'gc4',@ce)
  6949. IF @D > ''
  6950. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'gc5',@D)
  6951. END
  6952. END
  6953. ELSE
  6954. BEGIN
  6955. IF @ID>0
  6956. BEGIN
  6957. SELECT @InstitutionOld=dbo.TextTrim(ISNULL(InstitutionEng, '')),
  6958. @CourseOld=dbo.TextTrim(ISNULL(CourseEng, '')),
  6959. @CityOld=dbo.TextTrim(ISNULL(CityEng, '')),
  6960. @CertificateOld=dbo.TextTrim(ISNULL(CertificateEng, '')),
  6961. @DetailsOld=dbo.TextTrim(ISNULL(DetailsEng, ''))
  6962. FROM CvTraining WITH(NOLOCK INDEX(PK_cvTraining)) WHERE ID =@ID
  6963. UPDATE CvTraining SET
  6964. StartDate = @StartDate,
  6965. TimeLength = @TimeLength,
  6966. TimeUnit = @TimeUnit,
  6967. InstitutionEng = @Institution,
  6968. CourseEng = @Course,
  6969. CityEng = @City,
  6970. CertificateEng = @Certificate,
  6971. DetailsEng = @Details
  6972. WHERE ID=@ID
  6973. SET @MaxID = @ID
  6974. IF ISNULL(@InstitutionOld, '') <> ISNULL(@Institution, '')
  6975. BEGIN
  6976. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'ge1'
  6977. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ge1',@Institution)
  6978. SET @Modify=1
  6979. END
  6980. IF ISNULL(@CourseOld, '') <> ISNULL(@Course, '')
  6981. BEGIN
  6982. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'ge2'
  6983. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ge2',@Course)
  6984. SET @Modify=1
  6985. END
  6986. IF @City IS NULL
  6987. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'ge3'
  6988. ELSE
  6989. IF ISNULL(@CityOld, '') <> ISNULL(@City, '')
  6990. BEGIN
  6991. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'ge3'
  6992. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ge3',@City)
  6993. SET @Modify=1
  6994. END
  6995. IF @Certificate IS NULL
  6996. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'ge4'
  6997. ELSE
  6998. IF ISNULL(@CertificateOld, '') <> ISNULL(@Certificate, '')
  6999. BEGIN
  7000. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'ge4'
  7001. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ge4',@Certificate)
  7002. SET @Modify=1
  7003. END
  7004. IF @Details IS NULL
  7005. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'ge5'
  7006. ELSE
  7007. IF ISNULL(@DetailsOld, '') <> ISNULL(@Details, '')
  7008. BEGIN
  7009. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'ge5'
  7010. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ge5',@Details)
  7011. SET @Modify=1
  7012. END
  7013. END
  7014. ELSE
  7015. BEGIN
  7016. INSERT INTO CvTraining
  7017. (cvMainID,StartDate,TimeLength,TimeUnit,InstitutionEng,
  7018. CourseEng,CityEng,CertificateEng,DetailsEng)
  7019. VALUES(@cvMainID,@StartDate,@TimeLength,@TimeUnit,@Institution,
  7020. @Course,@City,@Certificate,@Details)
  7021. SET @MaxID = @@IDENTITY
  7022. SET @Modify=1
  7023. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ge1',@Institution)
  7024. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ge2',@Course)
  7025. IF @City > ''
  7026. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ge3',@City)
  7027. IF @Certificate > ''
  7028. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ge4',@Certificate)
  7029. IF @Details > ''
  7030. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ge5',@Details)
  7031. END
  7032. END
  7033. --修改cvLevel
  7034. DECLARE @SQL AS VARCHAR(100)
  7035. SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew ' + CONVERT(CHAR(1), @Type) + ',' + CONVERT(VARCHAR(10), @cvMainID) + ',8,1'
  7036. EXEC(@SQL)
  7037. END TRY
  7038. BEGIN cATCH
  7039. GOTO ERR
  7040. END CATCH
  7041. COMMIT TRAN
  7042. RETURN @MaxID
  7043. ERR:
  7044. BEGIN
  7045. ROLLBACK TRAN
  7046. RETURN 0
  7047. END
  7048. GO
  7049. /****** Object: StoredProcedure [dbo].[pcCvTrainingSelect] Script Date: 2018/12/13 19:08:25 ******/
  7050. SET ANSI_NULLS ON
  7051. GO
  7052. SET QUOTED_IDENTIFIER ON
  7053. GO
  7054. -- =============================================
  7055. -- 检查: Sean
  7056. -- 日期: 2010-10-5
  7057. -- 描述: 选择培训信息
  7058. -- =============================================
  7059. CREATE PROCEDURE [dbo].[pcCvTrainingSelect]
  7060. @cvMainID INT
  7061. AS
  7062. BEGIN
  7063. SELECT *
  7064. FROM CvTraining WITH(NOLOCK INDEX(IX_cvTraining_cvMainID))
  7065. WHERE cvMainID = @cvMainID
  7066. ORDER BY StartDate DESC
  7067. END
  7068. GO
  7069. /****** Object: StoredProcedure [dbo].[pcDcAutoEmailByWordSelect] Script Date: 2018/12/13 19:08:25 ******/
  7070. SET ANSI_NULLS ON
  7071. GO
  7072. SET QUOTED_IDENTIFIER ON
  7073. GO
  7074. CREATE PROCEDURE [dbo].[pcDcAutoEmailByWordSelect]
  7075. AS
  7076. SET NOCOUNT ON
  7077. BEGIN
  7078. DECLARE @Id INT, @Email VARCHAR(50)
  7079. IF NOT EXISTS(SELECT TOP 1 'X' FROM dcAutoEmail)
  7080. BEGIN
  7081. EXEC ProcDcAutoEmailInsert
  7082. END
  7083. SELECT TOP 1 @Id = id,@Email=Email FROM dcAutoEmail ORDER BY id
  7084. DELETE FROM dcAutoEmail WHERE id= @Id
  7085. SELECT @Email Email
  7086. END
  7087. GO
  7088. /****** Object: StoredProcedure [dbo].[pcDcAutoEmailDelete] Script Date: 2018/12/13 19:08:25 ******/
  7089. SET ANSI_NULLS ON
  7090. GO
  7091. SET QUOTED_IDENTIFIER ON
  7092. GO
  7093. --#####################################################
  7094. --创建时间:2014.11.4
  7095. --创建人:John
  7096. --说明:删除记录
  7097. --#####################################################
  7098. CREATE PROCEDURE [dbo].[pcDcAutoEmailDelete]
  7099. (
  7100. @id INT
  7101. )
  7102. AS
  7103. BEGIN
  7104. DELETE FROM dcAutoEmail WHERE id= @id
  7105. END
  7106. GO
  7107. /****** Object: StoredProcedure [dbo].[pcDcAutoEmailSelect] Script Date: 2018/12/13 19:08:25 ******/
  7108. SET ANSI_NULLS ON
  7109. GO
  7110. SET QUOTED_IDENTIFIER ON
  7111. GO
  7112. --#####################################################
  7113. --创建时间:2014.11.4
  7114. --创建人:John
  7115. --说明:获取第一条记录
  7116. --#####################################################
  7117. CREATE PROCEDURE [dbo].[pcDcAutoEmailSelect]
  7118. AS
  7119. BEGIN
  7120. SELECT TOP 1 * FROM dcAutoEmail ORDER BY id
  7121. END
  7122. GO
  7123. /****** Object: StoredProcedure [dbo].[pcdcFeeDelete] Script Date: 2018/12/13 19:08:25 ******/
  7124. SET ANSI_NULLS ON
  7125. GO
  7126. SET QUOTED_IDENTIFIER ON
  7127. GO
  7128. CREATE PROCEDURE [dbo].[pcdcFeeDelete]
  7129. (
  7130. @ID INT
  7131. )
  7132. AS
  7133. BEGIN TRAN
  7134. BEGIN TRY
  7135. UPDATE dcFee SET EndDate = GETDATE() WHERE ID = @ID
  7136. --INSERT INTO dcFeeLog SELECT * FROM dcFee WITH(NOLOCK) WHERE ID=@ID
  7137. DELETE FROM dcFee WHERE ID = @ID
  7138. END TRY
  7139. BEGIN CATCH
  7140. GOTO ERR
  7141. END CATCH
  7142. COMMIT TRAN
  7143. RETURN 1
  7144. ERR:
  7145. BEGIN
  7146. ROLLBACK TRAN
  7147. RETURN 0
  7148. END
  7149. GO
  7150. /****** Object: StoredProcedure [dbo].[pcdcVipDelete] Script Date: 2018/12/13 19:08:25 ******/
  7151. SET ANSI_NULLS ON
  7152. GO
  7153. SET QUOTED_IDENTIFIER ON
  7154. GO
  7155. CREATE PROCEDURE [dbo].[pcdcVipDelete]
  7156. (
  7157. @ID INT
  7158. )
  7159. AS
  7160. BEGIN TRAN
  7161. BEGIN TRY
  7162. UPDATE dcVip SET EndDate = GETDATE() WHERE ID = @ID
  7163. --INSERT INTO dcVipLog SELECT * FROM dcVip WITH(NOLOCK) WHERE ID=@ID
  7164. DELETE FROM dcVip WHERE ID = @ID
  7165. END TRY
  7166. BEGIN CATCH
  7167. GOTO ERR
  7168. END CATCH
  7169. COMMIT TRAN
  7170. RETURN 1
  7171. ERR:
  7172. BEGIN
  7173. ROLLBACK TRAN
  7174. RETURN 0
  7175. END
  7176. GO
  7177. /****** Object: StoredProcedure [dbo].[pcexImageInsert] Script Date: 2018/12/13 19:08:26 ******/
  7178. SET ANSI_NULLS ON
  7179. GO
  7180. SET QUOTED_IDENTIFIER ON
  7181. GO
  7182. CREATE PROCEDURE [dbo].[pcexImageInsert]
  7183. (
  7184. @OutID INT,
  7185. @OutType INT,
  7186. @UID VARCHAR(20) OUTPUT
  7187. )
  7188. AS
  7189. BEGIN
  7190. DECLARE @T AS VARCHAR(20)
  7191. SET @T = CONVERT(VARCHAR(20), CONVERT(DECIMAL(18,12),GETDATE()))
  7192. SET @T = RTRIM(CONVERT(VARCHAR(12), @OutID)) + '_' + RIGHT(@T,8)
  7193. Insert Into exImage(OutID,OutType,UniqueID)
  7194. Values(@OutID,@OutType,@T)
  7195. SET @UID = @T
  7196. END
  7197. GO
  7198. /****** Object: StoredProcedure [dbo].[pcExInterViewByBaiduPushSelect] Script Date: 2018/12/13 19:08:26 ******/
  7199. SET ANSI_NULLS ON
  7200. GO
  7201. SET QUOTED_IDENTIFIER ON
  7202. GO
  7203. --===================================
  7204. --创建: Andy
  7205. --描述: 获取所有paMainID面试通知个数,
  7206. --===================================
  7207. CREATE PROCEDURE [dbo].[pcExInterViewByBaiduPushSelect]
  7208. (
  7209. @WHERE VARCHAR(1000)
  7210. )
  7211. AS
  7212. BEGIN
  7213. SET @WHERE = dbo.SafeSql(@Where)
  7214. DECLARE @SQL AS VARCHAR(2000)
  7215. SET @SQL='SELECT d.paMainID, count(*) as Count
  7216. FROM exInterView a WITH(NOLOCK)
  7217. Inner Join Job b WITH(NOLOCK) On b.ID=a.JobID
  7218. Inner Join cpMain c WITH(NOLOCK) ON b.cpMainID=c.ID
  7219. Inner Join cvMain d WITH(NOLOCK) ON a.cvMainID=d.ID
  7220. WHERE PersonDeleted=0 '
  7221. IF LEN(@WHERE)>0
  7222. SET @SQL=@SQL + ' AND '+@WHERE
  7223. SET @SQL=@SQL + ' GROUP BY d.pamainiD '
  7224. EXEC(@SQL)
  7225. END
  7226. GO
  7227. /****** Object: StoredProcedure [dbo].[pcexInterViewByMailUpdate] Script Date: 2018/12/13 19:08:26 ******/
  7228. SET ANSI_NULLS ON
  7229. GO
  7230. SET QUOTED_IDENTIFIER ON
  7231. GO
  7232. --===================================
  7233. --创建: lucifer
  7234. --检查: Sean
  7235. --描述: 回复面试通知 ,增加paMainID
  7236. --===================================
  7237. CREATE PROCEDURE [dbo].[pcexInterViewByMailUpdate]
  7238. (
  7239. @ID INT,
  7240. @Reply TINYINT,
  7241. @ReplyMessage VARCHAR(500),
  7242. @paMainID INT
  7243. )
  7244. AS
  7245. SET NOCOUNT ON
  7246. IF CHARINDEX('<', @ReplyMessage) > 0
  7247. SET @ReplyMessage = REPLACE(@ReplyMessage, '<', '')
  7248. BEGIN TRY
  7249. IF NOT EXISTS(SELECT 'x' FROM exInterview a WITH(NOLOCK), cvMain b WITH(NOLOCK) WHERE a.id=@ID AND a.cvMainID=b.ID AND b.paMainID=@paMainID)
  7250. GOTO ERR1
  7251. UPDATE exInterView
  7252. SET Reply = @Reply, ReplyMessage = dbo.SafeSql(@ReplyMessage), ReplyDate=GETDATE()
  7253. WHERE ID = @ID
  7254. DECLARE @Str AS VARCHAR(3000),
  7255. @CompanyName AS NVARCHAR(50),
  7256. @JobName AS VARCHAR(50),
  7257. @ConsultantId AS INT,
  7258. @ConsultantName AS VARCHAR(100),
  7259. @JobId AS INT,
  7260. @cvMainId AS INT
  7261. SELECT @JobId = JobId, @cvMainId = cvMainId FROM exInterView WITH(NOLOCK) WHERE ID = @ID
  7262. SELECT @CompanyName = a.Name, @JobName = b.Name, @ConsultantId = a.ConsultantId
  7263. FROM cpMain a WITH(NOLOCK)
  7264. INNER JOIN Job b WITH(NOLOCK) ON a.ID = b.cpMainId
  7265. WHERE b.Id = @JobId
  7266. SET @str = '<html><body><font style="font-family:''宋体'';font-size:14px">'
  7267. SET @Str = @Str + @CompanyName
  7268. SET @Str = @Str + ',您好:<br>&nbsp;&nbsp;您曾在::WebSite'
  7269. SET @Str = @Str + '(<a href=''http://::EmailSite'' target=''_blank''>http://::EmailSite</a>)上通知求职者<b>::paName'
  7270. SET @Str = @Str + '[简历编号:' + LTRIM(STR(@cvMainId)) + ']</b>参加['
  7271. SET @Str = @Str + @JobName
  7272. SET @Str = @Str + ']的面试,'
  7273. IF @Reply = 1
  7274. SET @Str = @Str + '对方表示能够赴约'
  7275. ELSE
  7276. SET @Str = @Str + '对方表示不能够赴约'
  7277. SET @Str = @Str + '。详细情况请登录::WebSite(<a href=''http://::EmailSite'' target=''_blank''>http://::EmailSite</a>)查看。'
  7278. IF @ConsultantId > 0
  7279. BEGIN
  7280. SELECT @ConsultantName = Name FROM ManagerUser WITH(NOLOCK) WHERE ID = @ConsultantId
  7281. SET @Str = @Str + '您的招聘顾问是'
  7282. SET @Str = @Str + LTRIM(STR(@ConsultantId))
  7283. SET @Str = @Str + '号'
  7284. SET @Str = @Str + @ConsultantName
  7285. SET @Str = @Str + '。'
  7286. END
  7287. SET @Str = @Str + '<br>&nbsp;&nbsp;此通知信委托网站发送,请不要直接回复该邮件,该求职者无法收到。为保证您的权益,请使用正确的网址http://::EmailSite访问,建议将该网址添加到浏览器收藏夹。</font></body></html>'
  7288. SELECT @Str
  7289. RETURN
  7290. END TRY
  7291. BEGIN CATCH
  7292. GOTO ERR
  7293. END CATCH
  7294. ERR:
  7295. BEGIN
  7296. SELECT 0
  7297. RETURN
  7298. END
  7299. ERR1:
  7300. BEGIN
  7301. SELECT -1
  7302. END
  7303. GO
  7304. /****** Object: StoredProcedure [dbo].[pcexInterViewByMailUpdateNew] Script Date: 2018/12/13 19:08:26 ******/
  7305. SET ANSI_NULLS ON
  7306. GO
  7307. SET QUOTED_IDENTIFIER ON
  7308. GO
  7309. --===================================
  7310. --创建: Nick 2012-12-7
  7311. --描述: 回复面试通知
  7312. --修改: Nick 2013-1-24
  7313. --修改:Alen 2018-10-19 添加paPushLog取第一条数据
  7314. --描述: 查询企业Email
  7315. ---20160411 Lucifer 添加企业微信提醒
  7316. --===================================
  7317. CREATE PROCEDURE [dbo].[pcexInterViewByMailUpdateNew]
  7318. (
  7319. @ID INT,
  7320. @Reply TINYINT,
  7321. @ReplyMessage VARCHAR(500),
  7322. @paMainID INT
  7323. )
  7324. AS
  7325. SET NOCOUNT ON
  7326. IF CHARINDEX('<', @ReplyMessage) > 0
  7327. SET @ReplyMessage = REPLACE(@ReplyMessage, '<', '')
  7328. BEGIN TRY
  7329. IF NOT EXISTS(SELECT 'x' FROM exInterview a WITH(NOLOCK), cvMain b WITH(NOLOCK) WHERE a.id=@ID AND a.cvMainID=b.ID AND b.paMainID=@paMainID)
  7330. GOTO ERR1
  7331. UPDATE exInterView
  7332. SET Reply = @Reply, ReplyMessage = dbo.SafeSQL(@ReplyMessage), ReplyDate=GETDATE()
  7333. WHERE ID = @ID
  7334. DECLARE @Str AS VARCHAR(3000),
  7335. @CompanyName AS NVARCHAR(50),
  7336. @JobName AS VARCHAR(50),
  7337. @ConsultantId AS INT,
  7338. @ConsultantName AS VARCHAR(100),
  7339. @JobId AS INT,
  7340. @cvMainId AS INT,
  7341. @ReplyInfo AS NVARCHAR(100),
  7342. @CompanyEmail AS VARCHAR(200),
  7343. @cpMainID AS INT
  7344. SELECT @JobId = JobId, @cvMainId = cvMainId FROM exInterView WITH(NOLOCK) WHERE ID = @ID
  7345. SELECT @CompanyName = a.Name, @JobName = b.Name, @ConsultantId = a.ConsultantId ,@CompanyEmail = c.Email, @cpMainID = a.ID
  7346. FROM cpMain a WITH(NOLOCK), Job b WITH(NOLOCK) , CaMain c WITH(NOLOCK)
  7347. WHERE a.ID = b.cpMainId
  7348. AND b.Id = @JobId
  7349. AND b.CaMainID = c.ID
  7350. ---是否能够赴约
  7351. IF @Reply = 1
  7352. SET @ReplyInfo = '对方表示能够赴约'
  7353. ELSE
  7354. SET @ReplyInfo = '对方表示不能够赴约'
  7355. SELECT @ReplyInfo AS Reply, @CompanyName AS CompanyName, @cvMainId AS cvMainId,
  7356. @CompanyName AS CompanyName, @JobName AS JobName, @ConsultantId AS ConsultantId,
  7357. @CompanyEmail AS CompanyEmail, @cpMainID AS cpMainId
  7358. INSERT wxMessageSend2(Templatetype, WxFansID, PaMainId, CvMainId, CpMainID, CaMainId, JobId, AddDate)
  7359. SELECT 15, b.ID, @paMainID, d.cvMainID, c.cpMainID, c.caMainID, c.ID, GETDATE()
  7360. FROM paLoginContact a WITH(NOLOCK), wxFans b WITH(NOLOCK), Job c WITH(NOLOCK), exInterview d WITH(NOLOCK)
  7361. WHERE a.OpenID = b.OpenID AND c.caMainID = a.paMainID AND d.JobID = c.ID AND a.ContactType = 101 AND d.ID = @ID
  7362. INSERT INTO paPushLog(paMainID, PushMessage, PushType)
  7363. SELECT TOP 1 a.caMainID, e.name+'回复'+ REPLACE(@ReplyInfo,'对方表示',''), 13
  7364. FROM caIOSBind a WITH(NOLOCK),Job b WITH(NOLOCK), exInterview c WITH(NOLOCK),cvMain d WITH(NOLOCK),paMain e WITH(NOLOCK)
  7365. WHERE a.caMainID = b.caMainID AND b.ID = c.JobID AND c.cvMainId= d.id AND d.paMainId= e.id AND c.id = @ID
  7366. END TRY
  7367. BEGIN CATCH
  7368. GOTO ERR
  7369. END CATCH
  7370. ERR:
  7371. BEGIN
  7372. SELECT 0
  7373. RETURN
  7374. END
  7375. ERR1:
  7376. BEGIN
  7377. SELECT -1
  7378. END
  7379. GO
  7380. /****** Object: StoredProcedure [dbo].[pcExInterViewDelete] Script Date: 2018/12/13 19:08:26 ******/
  7381. SET ANSI_NULLS ON
  7382. GO
  7383. SET QUOTED_IDENTIFIER ON
  7384. GO
  7385. --===============================
  7386. --创建: lucifer
  7387. --检查: sean,2010-10-13
  7388. --返回值: 0:未知错误
  7389. -- -1:该留言不存在
  7390. -- -2:您没有权限查看该留言,该留言不是你写的
  7391. -- 如果企业已经删除了该面试通知,个人删除
  7392. CREATE PROCEDURE [dbo].[pcExInterViewDelete]
  7393. (
  7394. @ID INT,
  7395. @paMainID INT
  7396. )
  7397. AS
  7398. BEGIN TRY
  7399. DECLARE @CompanyDeleted AS BIT
  7400. DECLARE @cvMainID AS INT
  7401. DECLARE @paID AS INT
  7402. SELECT @CompanyDeleted=CompanyDeleted,@cvMainID=cvMainID FROM ExInterView WITH(NOLOCK) WHERE ID=@ID
  7403. IF @cvMainID IS NULL
  7404. GOTO Err1
  7405. ELSE
  7406. SELECT @paID=paMainID FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
  7407. IF @paMainID = @paID
  7408. IF @CompanyDeleted=1
  7409. DELETE FROM ExInterView WHERE CompanyDeleted=1 AND ID = @ID
  7410. ELSE
  7411. UPDATE ExInterView SET PersonDeleted=1, PersonDeleteDate=GETDATE() WHERE ID = @ID
  7412. ELSE
  7413. GOTO Err2
  7414. END TRY
  7415. BEGIN CATCH
  7416. GOTO ERR
  7417. END CATCH
  7418. RETURN 1
  7419. ERR:
  7420. BEGIN
  7421. RETURN 0
  7422. END
  7423. ERR1:
  7424. BEGIN
  7425. RETURN -1
  7426. END
  7427. ERR2:
  7428. BEGIN
  7429. RETURN -2
  7430. END
  7431. GO
  7432. /****** Object: StoredProcedure [dbo].[pcExInterViewSelect] Script Date: 2018/12/13 19:08:27 ******/
  7433. SET ANSI_NULLS ON
  7434. GO
  7435. SET QUOTED_IDENTIFIER ON
  7436. GO
  7437. --===================================
  7438. --创建: lucifer
  7439. --检查: Sean
  7440. --描述: 个人用户查看面试通知,面试通知选择
  7441. --修改: Harry 2015-6-24
  7442. --修改内容: dcregionID改为dcregionId
  7443. --===================================
  7444. CREATE PROCEDURE [dbo].[pcExInterViewSelect]
  7445. (
  7446. @WHERE VARCHAR(1000),
  7447. @Order VARCHAR(100)
  7448. )
  7449. AS
  7450. BEGIN
  7451. SELECT @WHERE = dbo.SafeSQL(@WHERE),
  7452. @ORDER = dbo.SafeSQL(@ORDER)
  7453. DECLARE @SQL AS VARCHAR(2000)
  7454. SET @SQL='SELECT a.ID,a.JobID,a.cvMainID,a.InterviewDate,a.InterViewPlace,a.LinkMan,a.Telephone,a.Remark,a.AddDate,a.Reply,a.ReplyMessage,a.Replydate,a.CompanyDeleted,a.CompanyDeleteDate,a.PersonDeleted,a.PersonDeleteDate,a.ViewDate,
  7455. b.Name as JobName,b.dcRegionId,c.Name as cpName,c.ID as cpID,c.HasLicence,c.IsAgent,b.IssueDate,b.IssueEND,b.IsDelete,d.Name cvName, c.Membertype, b.SecondId EnJobID, c.SecondId EnCpMainID,ISNULL((SELECT IsOnline FROM caOnline WHERE caMainId =b.caMainID), 0) AS IsOnline,b.CaMainID, c.LogoFile LogoUrl, b.Valid JobValid'
  7456. SET @SQL=@SQl+' FROM exInterView a WITH(NOLOCK) inner join Job b WITH(NOLOCK) On
  7457. b.ID=a.JobID Inner Join cpMain c WITH(NOLOCK) ON b.cpMainID=c.ID Inner Join cvMain d WITH(NOLOCK) ON a.cvMainID=d.ID'
  7458. SET @SQL=@SQl+' WHERE PersonDeleted=0 '
  7459. IF LEN(@WHERE) > 0
  7460. SET @SQL = @SQL + ' AND ' + @WHERE
  7461. IF LEN(@ORDER) > 0
  7462. SET @SQL = @SQL + ' ORDER BY ' + @ORDER
  7463. EXEC(@SQL)
  7464. END
  7465. GO
  7466. /****** Object: StoredProcedure [dbo].[pcexInterViewUpdate] Script Date: 2018/12/13 19:08:27 ******/
  7467. SET ANSI_NULLS ON
  7468. GO
  7469. SET QUOTED_IDENTIFIER ON
  7470. GO
  7471. --===================================
  7472. --创建: lucifer
  7473. --检查: Sean
  7474. --描述: 回复面试通知 ,增加paMainID
  7475. --===================================
  7476. CREATE PROCEDURE [dbo].[pcexInterViewUpdate]
  7477. (
  7478. @ID INT,
  7479. @Reply TINYINT,
  7480. @ReplyMessage VARCHAR(500),
  7481. @paMainID INT
  7482. )
  7483. AS
  7484. SET NOCOUNT ON
  7485. IF CHARINDEX('<', @ReplyMessage) > 0
  7486. SET @ReplyMessage = REPLACE(@ReplyMessage, '<', '')
  7487. BEGIN TRY
  7488. IF NOT EXISTS(SELECT 'x' FROM exInterview a WITH(NOLOCK),cvMain b WITH(NOLOCK) WHERE a.id=@ID AND a.cvMainID=b.ID AND b.paMainID=@paMainID)
  7489. GOTO ERR1
  7490. UPDATE exInterView
  7491. SET Reply=@Reply, ReplyMessage = dbo.SafeSql(@ReplyMessage), ReplyDate=GETDATE()
  7492. WHERE ID=@ID
  7493. RETURN 1
  7494. END TRY
  7495. BEGIN CATCH
  7496. GOTO ERR
  7497. END CATCH
  7498. ERR:
  7499. BEGIN
  7500. RETURN 0
  7501. END
  7502. ERR1:
  7503. BEGIN
  7504. RETURN -1
  7505. END
  7506. GO
  7507. /****** Object: StoredProcedure [dbo].[pcexInterViewViewDateUpdate] Script Date: 2018/12/13 19:08:27 ******/
  7508. SET ANSI_NULLS ON
  7509. GO
  7510. SET QUOTED_IDENTIFIER ON
  7511. GO
  7512. --===================================
  7513. --创建: lucifer
  7514. --检查: Sean
  7515. --描述: 面试通知查看时间修改 ,增加了pamainid
  7516. --===================================
  7517. CREATE PROCEDURE [dbo].[pcexInterViewViewDateUpdate]
  7518. (
  7519. @ID INT,
  7520. @paMainID INT
  7521. )
  7522. AS
  7523. BEGIN TRY
  7524. UPDATE a SET a.ViewDate=GETDATE()
  7525. FROM exInterView a, cvMain b
  7526. WHERE a.ID=@ID
  7527. AND a.cvMainID = b.ID
  7528. AND b.paMainID = @paMainID
  7529. END TRY
  7530. BEGIN CATCH
  7531. GOTO ERR
  7532. END CATCH
  7533. RETURN 1
  7534. ERR:
  7535. BEGIN
  7536. RETURN 0
  7537. END
  7538. GO
  7539. /****** Object: StoredProcedure [dbo].[pcExJobApplyApplyMessageByCvMainIDSelect] Script Date: 2018/12/13 19:08:27 ******/
  7540. SET ANSI_NULLS ON
  7541. GO
  7542. SET QUOTED_IDENTIFIER ON
  7543. GO
  7544. CREATE PROCEDURE [dbo].[pcExJobApplyApplyMessageByCvMainIDSelect]
  7545. (
  7546. @CvMainID INT
  7547. )
  7548. AS
  7549. BEGIN
  7550. SELECT TOP 1 ApplyMessage FROM exJobApply WITH(NOLOCK) WHERE cvMainID = @CvMainID ORDER BY ID DESC
  7551. END
  7552. GO
  7553. /****** Object: StoredProcedure [dbo].[pcExJobApplyBatchDelete] Script Date: 2018/12/13 19:08:28 ******/
  7554. SET ANSI_NULLS ON
  7555. GO
  7556. SET QUOTED_IDENTIFIER ON
  7557. GO
  7558. --====================================
  7559. --返回值:-1:不是你的求职申请
  7560. --创建: luicifer
  7561. --检查: sean 2010-10-13
  7562. --====================================
  7563. CREATE PROCEDURE [dbo].[pcExJobApplyBatchDelete]
  7564. (
  7565. @AllID VARCHAR(1000),
  7566. @paMainID INT
  7567. )
  7568. AS
  7569. SET NOCOUNT ON
  7570. BEGIN TRAN
  7571. BEGIN TRY
  7572. IF LEN(ISNULL(@AllID, '')) < 2
  7573. GOTO Err2
  7574. --生成临时表
  7575. DECLARE @t AS TABLE(
  7576. ID INT
  7577. )
  7578. DECLARE @i INT
  7579. SET @i=CHARINDEX(',',@AllID)
  7580. WHILE @i>=1
  7581. BEGIN
  7582. IF LEFT(@AllID,@i-1) > ''
  7583. INSERT @t VALUES(LEFT(@AllID,@i-1))
  7584. SET @AllID=SUBSTRING(@AllID,@i+1,LEN(@AllID)-@i)
  7585. SET @i=CHARINDEX(',',@AllID)
  7586. END
  7587. IF @AllID > ''
  7588. INSERT @t VALUES(@AllID)
  7589. ----判断是否这些id是同一个paMainID
  7590. IF EXISTS(SELECT 'X' FROM ExJobApply a WITH(NOLOCK),@t b,cvMain c WITH(NOLOCK)
  7591. WHERE a.id=b.id AND a.cvMainID=c.ID AND c.paMainID<>@paMainID)
  7592. GOTO Err1
  7593. DELETE FROM ExJobApply WHERE CompanyDeleted=1 AND ID IN(SELECT ID FROM @t)
  7594. UPDATE ExJobApply SET PersonDeleted=1 WHERE ID IN(SELECT ID FROM @t)
  7595. END TRY
  7596. BEGIN CATCH
  7597. GOTO ERR
  7598. END CATCH
  7599. COMMIT TRAN
  7600. --PRINT -1
  7601. RETURN 1
  7602. ERR:
  7603. BEGIN
  7604. --PRINT 0
  7605. ROLLBACK TRAN
  7606. RETURN 0
  7607. END
  7608. ERR1:
  7609. BEGIN
  7610. --PRINT -1
  7611. ROLLBACK TRAN
  7612. RETURN -1
  7613. END
  7614. ERR2:
  7615. BEGIN
  7616. --PRINT 2
  7617. ROLLBACK TRAN
  7618. RETURN -2
  7619. END
  7620. GO
  7621. /****** Object: StoredProcedure [dbo].[pcExjobApplyByAddDateSelect] Script Date: 2018/12/13 19:08:28 ******/
  7622. SET ANSI_NULLS ON
  7623. GO
  7624. SET QUOTED_IDENTIFIER ON
  7625. GO
  7626. --harry 2018-6-21
  7627. --14天内是否申请过职位
  7628. CREATE PROCEDURE [dbo].[pcExjobApplyByAddDateSelect]
  7629. (
  7630. @paMainId INT
  7631. )
  7632. AS
  7633. BEGIN
  7634. SET NOCOUNT ON
  7635. SELECT * FROM exjobapply
  7636. WHERE cvMainId IN(select id FROM cvmain WHERE valid=1 AND paMainId = @paMainId)
  7637. AND AddDate>GETDATE()-14
  7638. SET NOCOUNT OFF
  7639. END
  7640. GO
  7641. /****** Object: StoredProcedure [dbo].[pcExJobApplyByApplyMessageUpdate] Script Date: 2018/12/13 19:08:28 ******/
  7642. SET ANSI_NULLS ON
  7643. GO
  7644. SET QUOTED_IDENTIFIER ON
  7645. GO
  7646. CREATE PROCEDURE [dbo].[pcExJobApplyByApplyMessageUpdate]
  7647. (
  7648. @ApplyIds VARCHAR(2000),
  7649. @ApplyMessage VARCHAR(3000),
  7650. @cvMainID INT
  7651. )
  7652. AS
  7653. SET NOCOUNT ON
  7654. IF CHARINDEX('<', @ApplyMessage) > 0
  7655. SET @ApplyMessage = REPLACE(@ApplyMessage, '<', '')
  7656. BEGIN
  7657. UPDATE exJobApply SET ApplyMessage = @ApplyMessage WHERE ID IN(SELECT a FROM dbo.FnSplit(@ApplyIds, ',')) AND cvMainID = @cvMainID
  7658. RETURN 1
  7659. END
  7660. SET NOCOUNT ON
  7661. GO
  7662. /****** Object: StoredProcedure [dbo].[pcExJobApplyByBaiduPushSelect] Script Date: 2018/12/13 19:08:28 ******/
  7663. SET ANSI_NULLS ON
  7664. GO
  7665. SET QUOTED_IDENTIFIER ON
  7666. GO
  7667. --====================================
  7668. --创建: Andy Yin
  7669. --获取所有PaMainID对应的职位邀请数据个数。用于给app推送数据。
  7670. --====================================
  7671. CREATE PROCEDURE [dbo].[pcExJobApplyByBaiduPushSelect]
  7672. (
  7673. @WHERE VARCHAR(1000)
  7674. )
  7675. AS
  7676. BEGIN
  7677. BEGIN TRY
  7678. SET @WHERE = REPLACE(dbo.SafeSQL(@WHERE), '''', '')
  7679. DECLARE @SQL AS VARCHAR(2000)
  7680. SET @SQL='SELECT d.paMainID, COUNT(*) as Count
  7681. FROM exJobApply a WITH(NOLOCK)
  7682. INNER JOIN Job b WITH(NOLOCK) On b.ID=a.JobID
  7683. INNER JOIN cpMain c WITH(NOLOCK) ON b.cpMainID=c.ID
  7684. INNER JOIN cvMain d WITH(NOLOCK) ON a.cvMainID = d.ID WHERE PersonDeleted=0'
  7685. IF LEN(@WHERE)>0
  7686. SET @SQL=@SQL + ' AND '+@WHERE
  7687. SET @SQL=@SQL + ' GROUP BY d.pamainid '
  7688. EXEC(@SQL)
  7689. END TRY
  7690. BEGIN CATCH
  7691. END CATCH
  7692. END
  7693. GO
  7694. /****** Object: StoredProcedure [dbo].[pcExJobApplyByCpMainIDSelect] Script Date: 2018/12/13 19:08:28 ******/
  7695. SET ANSI_NULLS ON
  7696. GO
  7697. SET QUOTED_IDENTIFIER ON
  7698. GO
  7699. --#####################################################
  7700. --创建时间:2014.10.31
  7701. --创建人:Nick
  7702. --说明:向企业申请的职位
  7703. --#####################################################
  7704. CREATE PROCEDURE [dbo].[pcExJobApplyByCpMainIDSelect]
  7705. (
  7706. @cpmainID INT,
  7707. @cvMainID INT
  7708. )
  7709. AS
  7710. BEGIN TRY
  7711. SELECT b.id, b.Name
  7712. FROM ExJobApply a WITH(NOLOCK),Job b
  7713. WHERE a.JobID = b.ID
  7714. AND a.cvMainID = @cvMainID
  7715. AND b.cpMainID = @cpMainID
  7716. AND CompanyDeleted = 0
  7717. AND PersonDeleted = 0
  7718. ORDER BY a.IsFilter,
  7719. a.ID DESC
  7720. END TRY
  7721. BEGIN CATCH
  7722. RETURN 0
  7723. END CATCH
  7724. GO
  7725. /****** Object: StoredProcedure [dbo].[pcExJobApplyByIDsDelete] Script Date: 2018/12/13 19:08:29 ******/
  7726. SET ANSI_NULLS ON
  7727. GO
  7728. SET QUOTED_IDENTIFIER ON
  7729. GO
  7730. --#####################################################
  7731. --创建时间:2014.11.4
  7732. --创建人:John
  7733. --说明:删除职位信息
  7734. --#####################################################
  7735. CREATE PROCEDURE [dbo].[pcExJobApplyByIDsDelete]
  7736. (
  7737. @ApplyIDs VARCHAR(MAX)
  7738. )
  7739. AS
  7740. BEGIN
  7741. SET @ApplyIDs = dbo.FormatIDS(@ApplyIDs)
  7742. DECLARE @SQL AS VARCHAR(MAX)
  7743. SET @SQL = 'DELETE FROM exJobApply WHERE ID IN(' + @ApplyIDs + ')'
  7744. EXEC(@SQL)
  7745. END
  7746. GO
  7747. /****** Object: StoredProcedure [dbo].[pcExJobApplyByIDUpdate] Script Date: 2018/12/13 19:08:29 ******/
  7748. SET ANSI_NULLS ON
  7749. GO
  7750. SET QUOTED_IDENTIFIER ON
  7751. GO
  7752. --创建:Nick
  7753. --创建日期:2015-11-09
  7754. --个人中心,还原职位
  7755. --------------------------------------------------
  7756. CREATE PROCEDURE [dbo].[pcExJobApplyByIDUpdate]
  7757. (
  7758. @ID INT,
  7759. @PaMainID INT
  7760. )
  7761. AS
  7762. BEGIN
  7763. SET NOCOUNT ON
  7764. UPDATE ExJobApply SET PersonDeleted=0
  7765. WHERE CvMainID IN(SELECT ID FROM CVMAIN WITH(NOLOCK) WHERE PaMainID = @PaMainID)
  7766. AND ID = @ID
  7767. AND PersonDeleted = 1
  7768. SET NOCOUNT OFF
  7769. END
  7770. GO
  7771. /****** Object: StoredProcedure [dbo].[pcExJobApplyByIsDeletedSelect] Script Date: 2018/12/13 19:08:30 ******/
  7772. SET ANSI_NULLS ON
  7773. GO
  7774. SET QUOTED_IDENTIFIER ON
  7775. GO
  7776. --创建:Nick
  7777. --创建日期:2015-11-09
  7778. --个人中心,职位回收站
  7779. --------------------------------------------------
  7780. CREATE PROCEDURE [dbo].[pcExJobApplyByIsDeletedSelect]
  7781. (
  7782. @WHERE VARCHAR(1000),
  7783. @Order VARCHAR(100)
  7784. )
  7785. AS
  7786. SET NOCOUNT ON
  7787. BEGIN
  7788. SET @WHERE = REPLACE(dbo.SafeSQL(@WHERE), '''', '')
  7789. SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '')
  7790. SET @Where = REPLACE(@Where, 'LIKE %', 'LIKE ''%')
  7791. SET @Where = REPLACE(@Where, '% OR ', '%'' OR ')
  7792. SET @Where = REPLACE(@Where, '%)', '%'')')
  7793. DECLARE @SQL AS VARCHAR(2000)
  7794. SET @SQL='SELECT a.ID, a.JobID, b.SecondId EnJobID, c.SecondId EnCpMainID, a.cvMainID, a.ApplyMessage, a.AddDate, a.CompanyDeleted, a.CompanyDeleteDate,
  7795. a.PersonDeleted, a.Reply, a.ReplyDate, a.ViewDate, b.Name as JobName, b.caMainID, b.dcRegionID, c.Name as cpName, c.ID as cpID,
  7796. c.HasLicence, c.IsAgent, c.MemberType, b.IssueDate, b.IssueEND, b.IsDelete, d.Name cvName, dbo.GetCvMatch(a.cvMainID,a.JobID) cvMatch, dbo.GetCaOnlineStatus(b.caMainID) AS IsOnline,a.RemindDate
  7797. FROM exJobApply a WITH(NOLOCK)
  7798. inner join Job b WITH(NOLOCK) On b.ID=a.JobID
  7799. Inner Join cpMain c WITH(NOLOCK) ON b.cpMainID=c.ID
  7800. INNER JOIN cvMain d WITH(NOLOCK) ON a.cvMainID = d.ID
  7801. WHERE PersonDeleted=1 AND IsDeleted = 0'
  7802. IF LEN(@WHERE)>0
  7803. SET @SQL=@SQL + ' AND '+@WHERE
  7804. IF LEN(@ORDER)>0
  7805. SET @SQL=@SQL + ' ORDER BY '+@ORDER
  7806. EXEC(@SQL)
  7807. END
  7808. GO
  7809. /****** Object: StoredProcedure [dbo].[pcExJobApplyByJobIDSelect] Script Date: 2018/12/13 19:08:30 ******/
  7810. SET ANSI_NULLS ON
  7811. GO
  7812. SET QUOTED_IDENTIFIER ON
  7813. GO
  7814. --#####################################################
  7815. --创建时间:2014.10.31
  7816. --创建人:Nick
  7817. --说明:根据职位ID获取一条申请记录
  7818. --修改:harry2017-5-4提升企业答复率,按照申请时间显示最早的申请记录,未答复的
  7819. --#####################################################
  7820. CREATE PROCEDURE [dbo].[pcExJobApplyByJobIDSelect]
  7821. (
  7822. @CvMainID INT,
  7823. @JobID INT
  7824. )
  7825. AS
  7826. BEGIN TRY
  7827. SELECT TOP 1 a.ID,a.reply,a.AddDate,b.ID jobID,b.name,a.*,b.CaMainID
  7828. FROM exjobapply a,job b
  7829. WHERE a.jobid = b.id
  7830. AND a.cvMainID = @CvMainID
  7831. AND b.id =@JobID
  7832. ORDER BY a.reply asc ,a.adddate asc
  7833. END TRY
  7834. BEGIN CATCH
  7835. RETURN 0
  7836. END CATCH
  7837. GO
  7838. /****** Object: StoredProcedure [dbo].[pcExJobApplyByPaMainIDDelete] Script Date: 2018/12/13 19:08:30 ******/
  7839. SET ANSI_NULLS ON
  7840. GO
  7841. SET QUOTED_IDENTIFIER ON
  7842. GO
  7843. --====================================
  7844. --返回值:-1:个人彻底删除职申请位
  7845. --创建: Nick 20151110
  7846. --====================================
  7847. CREATE PROCEDURE [dbo].[pcExJobApplyByPaMainIDDelete]
  7848. (
  7849. @AllID VARCHAR(1000),
  7850. @paMainID INT
  7851. )
  7852. AS
  7853. SET NOCOUNT ON
  7854. BEGIN TRAN
  7855. IF LEN(ISNULL(@AllID, '')) < 2
  7856. GOTO Err2
  7857. --生成临时表
  7858. DECLARE @t AS TABLE(
  7859. ID INT
  7860. )
  7861. DECLARE @i INT
  7862. SET @i=CHARINDEX(',',@AllID)
  7863. WHILE @i>=1
  7864. BEGIN
  7865. IF LEFT(@AllID,@i-1) > ''
  7866. INSERT @t VALUES(LEFT(@AllID,@i-1))
  7867. SET @AllID=SUBSTRING(@AllID,@i+1,LEN(@AllID)-@i)
  7868. SET @i=CHARINDEX(',',@AllID)
  7869. END
  7870. IF @AllID > ''
  7871. INSERT @t VALUES(@AllID)
  7872. ----判断是否这些id是同一个paMainID
  7873. IF EXISTS(SELECT 'X' FROM ExJobApply a WITH(NOLOCK),@t b,cvMain c WITH(NOLOCK)
  7874. WHERE a.id=b.id AND a.cvMainID=c.ID AND c.paMainID<>@paMainID)
  7875. GOTO Err1
  7876. DELETE FROM ExJobApply WHERE CompanyDeleted=1 AND ID IN(SELECT ID FROM @t)
  7877. UPDATE ExJobApply SET IsDeleted = 1 WHERE ID IN(SELECT ID FROM @t) AND PersonDeleted=1
  7878. COMMIT TRAN
  7879. --PRINT -1
  7880. RETURN 1
  7881. ERR:
  7882. BEGIN
  7883. --PRINT 0
  7884. ROLLBACK TRAN
  7885. RETURN 0
  7886. END
  7887. ERR1:
  7888. BEGIN
  7889. --PRINT -1
  7890. ROLLBACK TRAN
  7891. RETURN -1
  7892. END
  7893. ERR2:
  7894. BEGIN
  7895. --PRINT 2
  7896. ROLLBACK TRAN
  7897. RETURN -2
  7898. END
  7899. GO
  7900. /****** Object: StoredProcedure [dbo].[pcExJobApplyByPaMainIDUpdate] Script Date: 2018/12/13 19:08:30 ******/
  7901. SET ANSI_NULLS ON
  7902. GO
  7903. SET QUOTED_IDENTIFIER ON
  7904. GO
  7905. --创建:Nick
  7906. --创建日期:2015-11-09
  7907. --个人中心,提醒企业
  7908. --harry 2018-06-13 增加推送
  7909. --修改:Alen 2018-10-19 添加paPushLog取第一条数据
  7910. --------------------------------------------------
  7911. CREATE PROCEDURE [dbo].[pcExJobApplyByPaMainIDUpdate]
  7912. (
  7913. @ID VARCHAR(200),
  7914. @PaMainID INT
  7915. )
  7916. AS
  7917. BEGIN
  7918. SET NOCOUNT ON
  7919. UPDATE ExJobApply
  7920. SET RemindDate = GETDATE()
  7921. WHERE CvMainID IN (SELECT ID FROM CVMAIN WITH(NOLOCK) WHERE PaMainID = @PaMainID)
  7922. AND ID IN (SELECT * FROM dbo.fnSplit(@ID,','))
  7923. SELECT DISTINCT b.caMainid INTO #t
  7924. FROM exjobapply a WITH(NOLOCK), job b WITH(NOLOCK)
  7925. WHERE a.ID IN (SELECT * FROM dbo.fnSplit(@ID,','))
  7926. AND a.jobId=b.id
  7927. DECLARE @name VARCHAR(20)
  7928. SELECT @name=name FROM paMain WHERE id= @PaMainID
  7929. INSERT INTO paPushLog(paMainID, PushMessage, PushType)
  7930. SELECT TOP 1 a.caMainid, @name+'求答复&#10084;',10
  7931. FROM caIOSBind a WITH(NOLOCK), #t b WITH(NOLOCK)
  7932. WHERE a.caMainId= b.caMainId
  7933. DROP TABLE #t
  7934. SET NOCOUNT OFF
  7935. END
  7936. GO
  7937. /****** Object: StoredProcedure [dbo].[pcExJobApplyByTempDelete] Script Date: 2018/12/13 19:08:30 ******/
  7938. SET ANSI_NULLS ON
  7939. GO
  7940. SET QUOTED_IDENTIFIER ON
  7941. GO
  7942. CREATE PROCEDURE [dbo].[pcExJobApplyByTempDelete]
  7943. (
  7944. @JobIDs VARCHAR(1000),
  7945. @paMainID INT
  7946. )
  7947. AS
  7948. BEGIN
  7949. SET @JobIDs = dbo.FormatIDS(@JobIDs)
  7950. DECLARE @Sql AS VARCHAR(1000)
  7951. SET @Sql = 'DELETE FROM exJobApply WHERE JobId IN(' + @JobIDS + ')
  7952. AND cvMainID IN(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainId = ' + LTRIM(STR(@PaMainID)) + ')
  7953. AND ISTempInsert = 1'
  7954. EXEC(@SQL)
  7955. END
  7956. GO
  7957. /****** Object: StoredProcedure [dbo].[pcExJobApplyByTempInsert] Script Date: 2018/12/13 19:08:30 ******/
  7958. SET ANSI_NULLS ON
  7959. GO
  7960. SET QUOTED_IDENTIFIER ON
  7961. GO
  7962. --修改harry 增加企业app提醒2018-6-11
  7963. CREATE PROCEDURE [dbo].[pcExJobApplyByTempInsert]
  7964. (
  7965. @JobID INT,
  7966. @cvMainID INT,
  7967. @ApplyMessage VARCHAR(4000),
  7968. @paMainID INT,
  7969. @IsFilter bit
  7970. )
  7971. AS
  7972. SET NOCOUNT ON
  7973. IF CHARINDEX('<', @ApplyMessage) > 0
  7974. SET @ApplyMessage = REPLACE(@ApplyMessage, '<', '')
  7975. BEGIN
  7976. SET @ApplyMessage = dbo.SafeSql(@ApplyMessage)
  7977. DECLARE @MaxID AS INT
  7978. SET @IsFilter = dbo.IsJobApplyFilter(@JobID, @cvMainID)
  7979. BEGIN TRY
  7980. IF EXISTS(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID = @paMainID AND ID = @cvMainID)
  7981. IF EXISTS(SELECT ID FROM ExJobApply WITH(NOLOCK) WHERE JobID = @JobID AND cvMainID = @cvMainID AND AddDate > GETDATE()-30)
  7982. SET @MaxID = 0
  7983. ELSE
  7984. BEGIN
  7985. IF EXISTS(SELECT ID FROM JOB WITH(NOLOCK) WHERE ID=@JobID AND Valid = 0)
  7986. SET @MaxID = 0
  7987. ELSE
  7988. BEGIN
  7989. INSERT INTO ExJobApply(JobID,cvMainID,ApplyMessage,IsTempInsert,IsFilter) VALUES(@JobID,@cvMainID,@ApplyMessage, 1,@IsFilter)
  7990. SET @MaxID=@@IDENTITY
  7991. INSERT INTO paPushLog(paMainID, PushMessage, PushType)
  7992. SELECT a.caMainId, b.Name+'应聘:'+a.Name+','+CASE b.Gender WHEN 0 THEN '男' WHEN 1 THEN '女' END+'|'
  7993. + CONVERT(VARCHAR(5), dbo.BirthToAge(b.BirthDay)) + '岁|'
  7994. +LTRIM(STR(ISNULL(RelatedWorkYears, 0))) + '年工作经验|'+f.Description, 9
  7995. FROM exJobApply c LEFT JOIN job a ON a.id= c.jobId
  7996. LEFT JOIN cvMain d ON c.cvMainID= d.id
  7997. LEFT JOIN paMain b ON d.paMainId= b.id
  7998. LEFT JOIN dceducation e ON e.id= d.degree
  7999. LEFT JOIN dcRegion f ON f.id=b.AccountPlace
  8000. WHERE c.Id= @MaxID
  8001. AND EXISTS(SELECT 'X' FROM caIOSBind WHERE caMainID IN(SELECT caMainId FROM Job WITH(NOLOCK) WHERE ID = @JobId))
  8002. IF NOT EXISTS(SELECT 'x' FROM paJobViewLog WITH(NOLOCK) WHERE paMainId = @PaMainId AND JobId = @JobId)
  8003. BEGIN
  8004. INSERT INTO paJobViewLog(JobId, paMainId, AddDate) VALUES(@JobId, @paMainId, GETDATE())
  8005. UPDATE Job SET ViewNumber = ViewNumber + 1 WHERE ID = @JobId
  8006. END
  8007. IF EXISTS(SELECT 'x' FROM caCvIntention WITH(NOLOCK) WHERE cvMainID = @cvMainId AND JobId = @JobId)
  8008. UPDATE caCvIntention SET Reply = 1, ReplyDate = GETDATE() WHERE cvMainID = @cvMainId AND JobId = @JobId
  8009. END
  8010. INSERT wxMessageSend2(Templatetype, WxFansID, PaMainId, CvMainId, CpMainID, CaMainId, JobId, AddDate)
  8011. SELECT 14, b.ID, @paMainID, @cvMainID, c.cpMainID, c.caMainID, c.ID, GETDATE()
  8012. FROM paLoginContact a WITH(NOLOCK), wxFans b WITH(NOLOCK), Job c WITH(NOLOCK)
  8013. WHERE a.OpenID = b.OpenID AND c.caMainID = a.paMainID AND a.ContactType = 101 AND c.ID = @JobID
  8014. END
  8015. END TRY
  8016. BEGIN cATCH
  8017. GOTO ERR
  8018. END CATCH
  8019. RETURN @MaxID
  8020. END
  8021. ERR:
  8022. BEGIN
  8023. RETURN 0
  8024. END
  8025. GO
  8026. /****** Object: StoredProcedure [dbo].[pcExJobApplyByTempInsertNew] Script Date: 2018/12/13 19:08:31 ******/
  8027. SET ANSI_NULLS ON
  8028. GO
  8029. SET QUOTED_IDENTIFIER ON
  8030. GO
  8031. CREATE PROCEDURE [dbo].[pcExJobApplyByTempInsertNew]
  8032. (
  8033. @JobID INT,
  8034. @cvMainID INT,
  8035. @ApplyMessage VARCHAR(4000),
  8036. @paMainID INT,
  8037. @IsFilter bit
  8038. )
  8039. AS
  8040. BEGIN
  8041. SET @ApplyMessage = dbo.SafeSql(@ApplyMessage)
  8042. DECLARE @MaxID AS INT
  8043. SET @IsFilter = dbo.IsJobApplyFilter(@JobID, @cvMainID)
  8044. BEGIN TRY
  8045. IF EXISTS(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID = @paMainID AND ID = @cvMainID)
  8046. IF EXISTS(SELECT ID FROM ExJobApply WITH(NOLOCK) WHERE JobID=@JobID AND cvMainID=@cvMainID AND AddDate>GETDATE()-30)
  8047. SET @MaxID = 0
  8048. ELSE
  8049. IF EXISTS(SELECT ID FROM JOB WITH(NOLOCK) WHERE ID=@JobID AND Valid = 0)
  8050. SET @MaxID = 0
  8051. ELSE
  8052. BEGIN
  8053. INSERT INTO ExJobApply(JobID,cvMainID,ApplyMessage,IsTempInsert,IsFilter) VALUES(@JobID,@cvMainID,@ApplyMessage, 1,@IsFilter)
  8054. SET @MaxID=@@IDENTITY
  8055. IF NOT EXISTS(SELECT 'x' FROM paJobViewLog WITH(NOLOCK) WHERE paMainId = @PaMainId AND JobId = @JobId)
  8056. BEGIN
  8057. INSERT INTO paJobViewLog(JobId, paMainId, AddDate) VALUES(@JobId, @paMainId, GETDATE())
  8058. UPDATE Job SET ViewNumber = ViewNumber + 1 WHERE ID = @JobId
  8059. END
  8060. END
  8061. END TRY
  8062. BEGIN cATCH
  8063. GOTO ERR
  8064. END CATCH
  8065. RETURN @MaxID
  8066. END
  8067. ERR:
  8068. BEGIN
  8069. RETURN 0
  8070. END
  8071. GO
  8072. /****** Object: StoredProcedure [dbo].[pcExJobApplyInsert] Script Date: 2018/12/13 19:08:31 ******/
  8073. SET ANSI_NULLS ON
  8074. GO
  8075. SET QUOTED_IDENTIFIER ON
  8076. GO
  8077. --修改harry 增加企业app提醒2018-6-11
  8078. CREATE PROCEDURE [dbo].[pcExJobApplyInsert]
  8079. (
  8080. @JobID INT,
  8081. @cvMainID INT,
  8082. @ApplyMessage VARCHAR(4000),
  8083. @paMainID INT,
  8084. @IsFilter BIT
  8085. )
  8086. AS
  8087. SET NOCOUNT ON
  8088. --IF CHARINDEX('<', @ApplyMessage) > 0
  8089. -- SET @ApplyMessage = REPLACE(@ApplyMessage, '<', '')
  8090. SET @ApplyMessage = ''
  8091. BEGIN
  8092. SET @ApplyMessage = dbo.SafeSql(@ApplyMessage)
  8093. SET @IsFilter = dbo.IsJobApplyFilter(@JobID, @cvMainID)
  8094. DECLARE @MaxID AS INT
  8095. BEGIN TRY
  8096. IF EXISTS(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID = @paMainID AND ID = @cvMainID) --是否是有效简历
  8097. IF EXISTS(SELECT ID FROM ExJobApply WITH(NOLOCK) WHERE JobID=@JobID AND cvMainID = @cvMainID AND AddDate > GETDATE()-30) --是否在30天申请过
  8098. SET @MaxID = 0
  8099. ELSE
  8100. BEGIN
  8101. IF EXISTS(SELECT ID FROM JOB WITH(NOLOCK) WHERE ID = @JobID AND Valid = 0) --是否是有效职位
  8102. SET @MaxID = 0
  8103. ELSE
  8104. BEGIN
  8105. INSERT INTO ExJobApply(JobID,cvMainID,ApplyMessage,IsFilter) VALUES(@JobID,@cvMainID,@ApplyMessage,@IsFilter)
  8106. SET @MaxID = @@IDENTITY
  8107. UPDATE Job SET ApplyNumber = ApplyNumber + 1 WHERE ID = @JobID
  8108. INSERT INTO paPushLog(paMainID, PushMessage, PushType)
  8109. SELECT a.caMainId, b.Name+'应聘:'+a.Name+','+CASE b.Gender WHEN 0 THEN '男' WHEN 1 THEN '女' END+'|'
  8110. + CONVERT(VARCHAR(5), dbo.BirthToAge(b.BirthDay)) + '岁|'
  8111. +LTRIM(STR(ISNULL(RelatedWorkYears, 0))) + '年工作经验|'+f.Description, 9
  8112. FROM exJobApply c LEFT JOIN job a ON c.jobId =a.id
  8113. LEFT JOIN cvMain d ON c.cvMainID= d.id
  8114. LEFT JOIN paMain b ON d.paMainId= b.id
  8115. LEFT JOIN dceducation e ON e.id= d.degree
  8116. LEFT JOIN dcRegion f ON f.id=b.AccountPlace
  8117. WHERE c.Id= @MaxID
  8118. AND EXISTS(SELECT 'X' FROM caIOSBind WHERE caMainID IN(SELECT caMainId FROM Job WITH(NOLOCK) WHERE ID = @JobId))
  8119. IF EXISTS(SELECT 'x' FROM caCvIntention WITH(NOLOCK) WHERE cvMainID = @cvMainId AND JobId = @JobId)
  8120. UPDATE caCvIntention SET Reply = 1, ReplyDate = GETDATE() WHERE cvMainID = @cvMainId AND JobId = @JobId
  8121. INSERT INTO wxMessageSend2(Templatetype, WxFansID, PaMainId, CvMainId, CpMainID, CaMainId, JobId, AddDate)
  8122. SELECT 14, b.ID, @paMainID, @cvMainID, c.cpMainID, c.caMainID, c.ID, GETDATE()
  8123. FROM paLoginContact a WITH(NOLOCK), wxFans b WITH(NOLOCK), Job c WITH(NOLOCK)
  8124. WHERE a.OpenID = b.OpenID AND c.caMainID = a.paMainID AND a.ContactType = 101 AND c.ID = @JobID
  8125. END
  8126. END
  8127. END TRY
  8128. BEGIN CATCH
  8129. GOTO ERR
  8130. END CATCH
  8131. RETURN @MaxID
  8132. END
  8133. ERR:
  8134. BEGIN
  8135. RETURN 0
  8136. END
  8137. GO
  8138. /****** Object: StoredProcedure [dbo].[pcExJobApplyInsertNew] Script Date: 2018/12/13 19:08:31 ******/
  8139. SET ANSI_NULLS ON
  8140. GO
  8141. SET QUOTED_IDENTIFIER ON
  8142. GO
  8143. CREATE PROCEDURE [dbo].[pcExJobApplyInsertNew]
  8144. (
  8145. @JobID INT,
  8146. @cvMainID INT,
  8147. @ApplyMessage VARCHAR(4000),
  8148. @paMainID INT,
  8149. @IsFilter BIT
  8150. )
  8151. AS
  8152. SET NOCOUNT ON
  8153. IF CHARINDEX('<', @ApplyMessage) > 0
  8154. SET @ApplyMessage = REPLACE(@ApplyMessage, '<', '')
  8155. BEGIN
  8156. SET @ApplyMessage = dbo.SafeSql(@ApplyMessage)
  8157. SET @IsFilter = dbo.IsJobApplyFilter(@JobID, @cvMainID)
  8158. DECLARE @MaxID AS INT
  8159. BEGIN TRY
  8160. IF EXISTS(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID = @paMainID AND ID = @cvMainID) --是否是有效简历
  8161. IF EXISTS(SELECT ID FROM ExJobApply WITH(NOLOCK) WHERE JobID=@JobID AND cvMainID = @cvMainID AND AddDate > GETDATE()-30) --是否在30天申请过
  8162. SET @MaxID = 0
  8163. ELSE
  8164. IF EXISTS(SELECT ID FROM JOB WITH(NOLOCK) WHERE ID = @JobID AND Valid = 0) --是否是有效职位
  8165. SET @MaxID = 0
  8166. ELSE
  8167. BEGIN
  8168. INSERT INTO ExJobApply(JobID,cvMainID,ApplyMessage,IsFilter) VALUES(@JobID,@cvMainID,@ApplyMessage,@IsFilter)
  8169. SET @MaxID = @@IDENTITY
  8170. UPDATE Job SET ApplyNumber = ApplyNumber + 1 WHERE ID = @JobID
  8171. END
  8172. END TRY
  8173. BEGIN cATCH
  8174. GOTO ERR
  8175. END CATCH
  8176. RETURN @MaxID
  8177. END
  8178. ERR:
  8179. BEGIN
  8180. RETURN 0
  8181. END
  8182. GO
  8183. /****** Object: StoredProcedure [dbo].[pcExJobApplyInsertOld] Script Date: 2018/12/13 19:08:31 ******/
  8184. SET ANSI_NULLS ON
  8185. GO
  8186. SET QUOTED_IDENTIFIER ON
  8187. GO
  8188. CREATE PROCEDURE [dbo].[pcExJobApplyInsertOld]
  8189. (
  8190. @JobID INT,
  8191. @cvMainID INT,
  8192. @ApplyMessage VARCHAR(4000),
  8193. @paMainID INT
  8194. )
  8195. AS
  8196. BEGIN
  8197. DECLARE @MaxID AS INT, @IsFilter AS BIT
  8198. SET @IsFilter = dbo.IsJobApplyFilter(@JobID, @cvMainID)
  8199. BEGIN TRY
  8200. IF EXISTS(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID = @paMainID AND ID = @cvMainID) --是否是有效简历
  8201. IF EXISTS(SELECT ID FROM ExJobApply WITH(NOLOCK) WHERE JobID=@JobID AND cvMainID = @cvMainID AND AddDate > GETDATE()-30) --是否在30天申请过
  8202. SET @MaxID = 0
  8203. ELSE
  8204. IF EXISTS(SELECT ID FROM JOB WITH(NOLOCK) WHERE ID = @JobID AND Valid = 0) --是否是有效职位
  8205. SET @MaxID = 0
  8206. ELSE
  8207. BEGIN
  8208. INSERT INTO ExJobApply(JobID,cvMainID,ApplyMessage,IsFilter) VALUES(@JobID,@cvMainID,@ApplyMessage, @IsFilter)
  8209. SET @MaxID = @@IDENTITY
  8210. UPDATE Job SET ApplyNumber = ApplyNumber + 1 WHERE ID = @JobID
  8211. END
  8212. END TRY
  8213. BEGIN cATCH
  8214. GOTO ERR
  8215. END CATCH
  8216. RETURN @MaxID
  8217. END
  8218. ERR:
  8219. BEGIN
  8220. RETURN 0
  8221. END
  8222. GO
  8223. /****** Object: StoredProcedure [dbo].[pcExJobApplySelect] Script Date: 2018/12/13 19:08:31 ******/
  8224. SET ANSI_NULLS ON
  8225. GO
  8226. SET QUOTED_IDENTIFIER ON
  8227. GO
  8228. CREATE PROCEDURE [dbo].[pcExJobApplySelect]
  8229. (
  8230. @WHERE VARCHAR(1000),
  8231. @Order VARCHAR(100)
  8232. )
  8233. AS
  8234. SET NOCOUNT ON
  8235. BEGIN
  8236. SET @WHERE = REPLACE(dbo.SafeSQL(@WHERE), '''', '')
  8237. SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '')
  8238. SET @Where = REPLACE(@Where, 'LIKE %', 'LIKE ''%')
  8239. SET @Where = REPLACE(@Where, '% OR ', '%'' OR ')
  8240. SET @Where = REPLACE(@Where, '%)', '%'')')
  8241. DECLARE @SQL AS VARCHAR(2000)
  8242. SET @SQL='SELECT a.ID, a.JobID, b.SecondId EnJobID, c.SecondId EnCpMainID, a.cvMainID, a.ApplyMessage, a.AddDate, a.CompanyDeleted, a.CompanyDeleteDate,
  8243. a.PersonDeleted, a.Reply, a.ReplyDate, a.ViewDate, b.Name as JobName, b.caMainID, b.dcRegionID, c.Name as cpName, c.ID as cpID,
  8244. b.Welfare1,b.Welfare2,b.Welfare3,b.Welfare4,b.Welfare5,b.Welfare6,b.Welfare7,b.Welfare8,
  8245. b.Welfare9,b.Welfare10,b.Welfare11,b.Welfare12,b.Welfare13,b.Welfare14,b.Welfare15,b.Welfare16,
  8246. b.Welfare17,b.Welfare18,b.Welfare19,b.Valid JobValid, c.LogoFile LogoUrl,
  8247. c.HasLicence, c.IsAgent, c.MemberType, b.IssueDate, b.IssueEND, b.IsDelete, d.Name cvName, dbo.GetCvMatch(a.cvMainID,a.JobID) cvMatch, dbo.GetCaOnlineStatus(b.caMainID) AS IsOnline,a.RemindDate,a.ReplyReason, c.ReplyRate
  8248. FROM exJobApply a WITH(NOLOCK)
  8249. inner join Job b WITH(NOLOCK) On b.ID=a.JobID
  8250. Inner Join cpMain c WITH(NOLOCK) ON b.cpMainID=c.ID
  8251. INNER JOIN cvMain d WITH(NOLOCK) ON a.cvMainID = d.ID
  8252. WHERE PersonDeleted=0 AND IsDeleted = 0'
  8253. IF LEN(@WHERE) > 0
  8254. SET @SQL = @SQL + ' AND ' + @WHERE
  8255. IF LEN(@ORDER) > 0
  8256. SET @SQL = @SQL + ' ORDER BY ' + @ORDER
  8257. EXEC(@SQL)
  8258. END
  8259. GO
  8260. /****** Object: StoredProcedure [dbo].[pcExMessageByCaMainIdDelete] Script Date: 2018/12/13 19:08:31 ******/
  8261. SET ANSI_NULLS ON
  8262. GO
  8263. SET QUOTED_IDENTIFIER ON
  8264. GO
  8265. --===============================
  8266. --返回值: 0:未知错误
  8267. --返回值: 1:正常删除
  8268. --用于个人删除留言,2013-08个人会员中心改版,删除留言就删除整个会话
  8269. --如果企业已经删除了该留言,个人删除时就真删除,否则只增加个人删除标签
  8270. --创建: Peter
  8271. --===============================
  8272. CREATE PROCEDURE [dbo].[pcExMessageByCaMainIdDelete]
  8273. (
  8274. @caMainID INT,
  8275. @paMainID INT
  8276. )
  8277. AS
  8278. BEGIN TRY
  8279. DELETE FROM ExMessageC2P
  8280. WHERE CompanyDeleted = 1
  8281. AND caMainID = @caMainID
  8282. AND cvMainID IN (SELECT ID FROM CvMain WITH(NOLOCK) WHERE paMainID = @paMainID)
  8283. UPDATE ExMessageC2P
  8284. SET PersonDeleted=1
  8285. WHERE CompanyDeleted = 0
  8286. AND caMainID = @caMainID
  8287. AND cvMainID IN (SELECT ID FROM CvMain WITH(NOLOCK) WHERE paMainID = @paMainID)
  8288. DELETE FROM ExMessageP2C
  8289. WHERE CompanyDeleted = 1
  8290. AND caMainID = @caMainID
  8291. AND cvMainID IN (SELECT ID FROM CvMain WITH(NOLOCK) WHERE paMainID = @paMainID)
  8292. UPDATE ExMessageP2C
  8293. SET PersonDeleted=1
  8294. WHERE CompanyDeleted = 0
  8295. AND caMainID = @caMainID
  8296. AND cvMainID IN (SELECT ID FROM CvMain WITH(NOLOCK) WHERE paMainID = @paMainID)
  8297. END TRY
  8298. BEGIN CATCH
  8299. GOTO ERR
  8300. END CATCH
  8301. RETURN 1
  8302. ERR:
  8303. BEGIN
  8304. RETURN 0
  8305. END
  8306. GO
  8307. /****** Object: StoredProcedure [dbo].[pcExMessageC2PDelete] Script Date: 2018/12/13 19:08:31 ******/
  8308. SET ANSI_NULLS ON
  8309. GO
  8310. SET QUOTED_IDENTIFIER ON
  8311. GO
  8312. --===============================
  8313. --返回值: 0:未知错误
  8314. -- -1:该留言不存在
  8315. -- -2:您没有权限查看该留言
  8316. --如果企业已经删除了该留言,个人删除时就真删除,否则只增加删除标签
  8317. --收到的留言删除
  8318. --创建: lucifer
  8319. --检查: sean,2010-10-13
  8320. --===============================
  8321. CREATE PROCEDURE [dbo].[pcExMessageC2PDelete]
  8322. (
  8323. @ID INT,
  8324. @paMainID INT
  8325. )
  8326. AS
  8327. BEGIN TRY
  8328. DECLARE @CompanyDeleted AS BIT
  8329. DECLARE @cvMainID AS INT
  8330. DECLARE @paID AS INT
  8331. SELECT @CompanyDeleted=CompanyDeleted,@cvMainID=cvMainID FROM ExMessageC2P WITH(NOLOCK) WHERE ID=@ID
  8332. IF @cvMainID IS NULL
  8333. GOTO Err1
  8334. ELSE
  8335. SELECT @paID=paMainID FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
  8336. IF @paMainID = @paID
  8337. IF @CompanyDeleted=1
  8338. DELETE FROM ExMessageC2P WHERE CompanyDeleted=1 AND ID = @ID
  8339. ELSE
  8340. UPDATE ExMessageC2P SET PersonDeleted=1 WHERE ID = @ID
  8341. ELSE
  8342. GOTO Err2
  8343. END TRY
  8344. BEGIN CATCH
  8345. GOTO ERR
  8346. END CATCH
  8347. RETURN 1
  8348. ERR:
  8349. BEGIN
  8350. RETURN 0
  8351. END
  8352. ERR1:
  8353. BEGIN
  8354. RETURN -1
  8355. END
  8356. ERR2:
  8357. BEGIN
  8358. RETURN -2
  8359. END
  8360. GO
  8361. /****** Object: StoredProcedure [dbo].[pcexMessageC2PIsViewedUpdate] Script Date: 2018/12/13 19:08:32 ******/
  8362. SET ANSI_NULLS ON
  8363. GO
  8364. SET QUOTED_IDENTIFIER ON
  8365. GO
  8366. --==========================
  8367. --创建:lucifer
  8368. --检查:sean,2010-10-14
  8369. --记录个人查看单位留言时间
  8370. --==========================
  8371. CREATE PROCEDURE [dbo].[pcexMessageC2PIsViewedUpdate]
  8372. (
  8373. @ID INT,
  8374. @paMainID INT
  8375. )
  8376. AS
  8377. BEGIN TRY
  8378. IF NOT EXISTS(SELECT 'x' FROM exMessageC2P a WITH(NOLOCK), cvMain b WITH(NOLOCK) WHERE a.ID=@ID AND b.paMainID=@paMainID AND a.cvMainID = b.ID)
  8379. GOTO ERR
  8380. UPDATE exMessageC2P SET IsViewed=1 WHERE ID=@ID
  8381. END TRY
  8382. BEGIN CATCH
  8383. GOTO ERR
  8384. END CATCH
  8385. RETURN 1
  8386. ERR:
  8387. BEGIN
  8388. RETURN 0
  8389. END
  8390. GO
  8391. /****** Object: StoredProcedure [dbo].[pcExMessageC2PSelect] Script Date: 2018/12/13 19:08:32 ******/
  8392. SET ANSI_NULLS ON
  8393. GO
  8394. SET QUOTED_IDENTIFIER ON
  8395. GO
  8396. --=======================================
  8397. --创建: lucifer
  8398. --检查: Sean,2010-10-13
  8399. --=======================================
  8400. CREATE PROCEDURE [dbo].[pcExMessageC2PSelect]
  8401. (
  8402. @WHERE VARCHAR(1000),
  8403. @Order VARCHAR(100)
  8404. )
  8405. AS
  8406. BEGIN
  8407. BEGIN TRY
  8408. SET @WHERE = REPLACE(dbo.SafeSQL(@WHERE), '''', '')
  8409. SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '')
  8410. DECLARE @SQL AS VARCHAR(2000)
  8411. SET @SQL='SELECT a.ID,a.caMainID,a.cvMainID,a.Message,a.AddDate,a.IsViewed,a.IsReply,a.CompanyDeleted,a.PersonDeleted,
  8412. b.Name as caName,b.Title,b.Email,b.Mobile,b.Telephone,b.Dept,b.GENDer,b.IsPhoneHide,b.IsNameHide,b.IsMobileHide,c.Name as cpName,c.ID as cpID,c.HasLicence,c.IsAgent,d.Name cvName, c.Membertype'
  8413. SET @SQL=@SQl+' FROM exMessageC2P a WITH(NOLOCK) inner join caMain b WITH(NOLOCK) On
  8414. b.ID=a.caMainID Inner Join cpMain c WITH(NOLOCK) ON b.cpMainID=c.ID Inner Join cvMain d WITH(NOLOCK) ON a.cvMainID=d.ID'
  8415. SET @SQL=@SQl+' WHERE PersonDeleted=0'
  8416. IF LEN(@WHERE)>0
  8417. SET @SQL=@SQL + ' AND ' + @WHERE
  8418. IF LEN(@ORDER)>0
  8419. SET @SQL=@SQL + ' ORDER BY ' + @ORDER
  8420. EXEC(@SQL)
  8421. END TRY
  8422. BEGIN CATCH
  8423. END CATCH
  8424. END
  8425. GO
  8426. /****** Object: StoredProcedure [dbo].[pcexMessageP2CByC2PInsert] Script Date: 2018/12/13 19:08:32 ******/
  8427. SET ANSI_NULLS ON
  8428. GO
  8429. SET QUOTED_IDENTIFIER ON
  8430. GO
  8431. CREATE PROCEDURE [dbo].[pcexMessageP2CByC2PInsert]
  8432. (
  8433. @ID INT,
  8434. @caMainID INT,
  8435. @cvMainID INT,
  8436. @Message VARCHAR(200),
  8437. @paMainID INT
  8438. )
  8439. AS
  8440. BEGIN
  8441. IF EXISTS(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID = @paMainID AND ID=@cvMainID)
  8442. BEGIN
  8443. SET @Message = dbo.SafeSQL(LTRIM(RTRIM(@Message)))
  8444. INSERT exMessageP2C(caMainID,cvMainID,Message) VALUES(@caMainID,@cvMainID,@Message)
  8445. IF @ID > 0
  8446. Update exMessageC2P Set IsReply=1 WHERE ID=@ID
  8447. END
  8448. END
  8449. GO
  8450. /****** Object: StoredProcedure [dbo].[pcExMessageP2CDelete] Script Date: 2018/12/13 19:08:32 ******/
  8451. SET ANSI_NULLS ON
  8452. GO
  8453. SET QUOTED_IDENTIFIER ON
  8454. GO
  8455. --===============================
  8456. --返回值: 0:未知错误
  8457. -- -1:该留言不存在
  8458. -- -2:您没有权限查看该留言,该留言不是你写的
  8459. -- 如果企业已经删除了该留言,个人删除时就真删除,否则只增加删除标签
  8460. --创建: Lucifer
  8461. --检查: Sean,2010-10-13
  8462. --===============================
  8463. CREATE PROCEDURE [dbo].[pcExMessageP2CDelete]
  8464. (
  8465. @ID INT,
  8466. @paMainID INT
  8467. )
  8468. AS
  8469. BEGIN TRY
  8470. DECLARE @CompanyDeleted AS BIT
  8471. DECLARE @cvMainID AS INT
  8472. DECLARE @paID AS INT
  8473. SELECT @CompanyDeleted=CompanyDeleted,@cvMainID=cvMainID FROM ExMessageP2C WITH(NOLOCK) WHERE ID=@ID
  8474. IF @cvMainID IS NULL
  8475. GOTO Err1
  8476. SELECT @paID=paMainID FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
  8477. IF @paMainID = @paID
  8478. IF @CompanyDeleted=1
  8479. DELETE FROM ExMessageP2C WHERE CompanyDeleted=1 AND ID = @ID
  8480. ELSE
  8481. UPDATE ExMessageP2C SET PersonDeleted=1 WHERE ID = @ID
  8482. ELSE
  8483. GOTO Err2
  8484. END TRY
  8485. BEGIN CATCH
  8486. GOTO ERR
  8487. END CATCH
  8488. RETURN 1
  8489. ERR:
  8490. BEGIN
  8491. RETURN 0
  8492. END
  8493. ERR1:
  8494. BEGIN
  8495. RETURN -1
  8496. END
  8497. ERR2:
  8498. BEGIN
  8499. RETURN -2
  8500. END
  8501. GO
  8502. /****** Object: StoredProcedure [dbo].[pcexMessageP2CInsert] Script Date: 2018/12/13 19:08:33 ******/
  8503. SET ANSI_NULLS ON
  8504. GO
  8505. SET QUOTED_IDENTIFIER ON
  8506. GO
  8507. CREATE PROCEDURE [dbo].[pcexMessageP2CInsert]
  8508. (
  8509. @caMainID INT,
  8510. @cvMainID INT,
  8511. @Message VARCHAR(200),
  8512. @paMainID INT
  8513. )
  8514. AS
  8515. BEGIN
  8516. IF EXISTS(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID = @paMainID AND ID=@cvMainID)
  8517. BEGIN
  8518. SET @Message = dbo.SafeSql(LTRIM(RTRIM(@Message)))
  8519. INSERT exMessageP2C(caMainID,cvMainID,Message) VALUES(@caMainID,@cvMainID,@Message)
  8520. END
  8521. END
  8522. GO
  8523. /****** Object: StoredProcedure [dbo].[pcExMessageP2CSelect] Script Date: 2018/12/13 19:08:33 ******/
  8524. SET ANSI_NULLS ON
  8525. GO
  8526. SET QUOTED_IDENTIFIER ON
  8527. GO
  8528. --=================================
  8529. --创建: lucifer
  8530. --检查: sean,2010-10-13
  8531. --描述: 发出的留言列表
  8532. --=================================
  8533. CREATE PROCEDURE [dbo].[pcExMessageP2CSelect]
  8534. (
  8535. @WHERE VARCHAR(1000),
  8536. @Order VARCHAR(100)
  8537. )
  8538. AS
  8539. BEGIN
  8540. SET @WHERE = REPLACE(dbo.SafeSQL(@WHERE), '''', '')
  8541. SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '')
  8542. BEGIN TRY
  8543. DECLARE @SQL AS VARCHAR(2000)
  8544. SET @SQL='SELECT a.ID,a.caMainID,a.cvMainID,a.Message,a.AddDate,a.IsViewed,a.IsReply,a.CompanyDeleted,a.PersonDeleted,
  8545. b.Name as caName,b.Title,b.Dept,b.GENDer,b.IsNameHide,c.Name as cpName,c.ID as cpID,c.HasLicence,c.IsAgent,d.Name as cvName, c.MemberType'
  8546. SET @SQL=@SQl+' FROM exMessageP2C a WITH(NOLOCK) inner join caMain b WITH(NOLOCK) On
  8547. b.ID=a.caMainID Inner Join cpMain c WITH(NOLOCK) ON b.cpMainID=c.ID Inner Join cvMain d WITH(NOLOCK) ON a.cvMainID=d.ID'
  8548. SET @SQL=@SQl+' WHERE PersonDeleted=0'
  8549. IF LEN(@WHERE)>0
  8550. SET @SQL=@SQL + ' AND '+@WHERE
  8551. IF LEN(@ORDER)>0
  8552. SET @SQL=@SQL + ' ORDER BY '+@ORDER
  8553. EXEC(@SQL)
  8554. END TRY
  8555. BEGIN CATCH
  8556. END CATCH
  8557. END
  8558. GO
  8559. /****** Object: StoredProcedure [dbo].[pcFaqSelect] Script Date: 2018/12/13 19:08:34 ******/
  8560. SET ANSI_NULLS ON
  8561. GO
  8562. SET QUOTED_IDENTIFIER ON
  8563. GO
  8564. CREATE PROCEDURE [dbo].[pcFaqSelect]
  8565. AS
  8566. BEGIN
  8567. SELECT ID, Question
  8568. FROM Faq WITH(NOLOCK)
  8569. WHERE Type=2
  8570. ORDER BY Power
  8571. END
  8572. GO
  8573. /****** Object: StoredProcedure [dbo].[pcGetCvMainByCvIDsSelect] Script Date: 2018/12/13 19:08:34 ******/
  8574. SET ANSI_NULLS ON
  8575. GO
  8576. SET QUOTED_IDENTIFIER ON
  8577. GO
  8578. --#####################################################
  8579. --创建时间:2014.10.31
  8580. --创建人:Nick
  8581. --说明:根据 Id1,Id2获取简历信息
  8582. --#####################################################
  8583. CREATE PROCEDURE [dbo].[pcGetCvMainByCvIDsSelect]
  8584. (
  8585. @CvIds VARCHAR(200)
  8586. )
  8587. AS
  8588. BEGIN
  8589. SELECT a.Id, a.Name AS cvName, b.Name AS paName, a.paMainId, a.SecondId
  8590. FROM cvMain a, paMain b
  8591. WHERE a.paMainId = b.Id
  8592. AND a.Id IN(SELECT * FROM dbo.fnSplit(@CvIds, ','))
  8593. END
  8594. GO
  8595. /****** Object: StoredProcedure [dbo].[pcGovNewsListByPhone] Script Date: 2018/12/13 19:08:34 ******/
  8596. SET ANSI_NULLS ON
  8597. GO
  8598. SET QUOTED_IDENTIFIER ON
  8599. GO
  8600. CREATE PROCEDURE [dbo].[pcGovNewsListByPhone]
  8601. (
  8602. @dcProvinceID AS SMALLINT,
  8603. @PageNum AS INT,
  8604. @PageSize AS INT
  8605. )
  8606. AS
  8607. BEGIN
  8608. DECLARE @COUNT INT
  8609. SELECT @COUNT=COUNT(1)
  8610. FROM QlrcNews WITH(NOLOCK) WHERE (
  8611. EXISTS(SELECT 'x' FROM fnSplit(DetailType,',') b,dcNewsType c WITH(NOLOCK) WHERE b.a=c.ID AND c.Category=1) OR DetailType IS NULL)
  8612. AND (VersionID=@dcProvinceID OR VersionID=0) AND NewsType = 2 AND DetailType like '%,2,%'
  8613. IF @COUNT > 200
  8614. SET @COUNT = 200
  8615. SELECT *,@COUNT FROM(
  8616. SELECT TOP 200 ROW_NUMBER() OVER(ORDER BY RefreshDate DESC) AS Rows,ID,Title,RefreshDate,Author
  8617. FROM QlrcNews WITH(NOLOCK) WHERE (
  8618. EXISTS(SELECT 'x' FROM fnSplit(DetailType,',') b,dcNewsType c WITH(NOLOCK) WHERE b.a=c.ID AND c.Category=1) OR DetailType IS NULL)
  8619. AND (VersionID=@dcProvinceID OR VersionID=0) AND NewsType = 2 AND DetailType like '%,2,%'
  8620. ) AS a
  8621. WHERE a.Rows BETWEEN (@PageNum-1)*@PageSize+1 AND @PageNum*@PageSize ORDER BY Rows
  8622. END
  8623. GO
  8624. /****** Object: StoredProcedure [dbo].[pcHasCvByCvMainIDPaMainIDSelect] Script Date: 2018/12/13 19:08:34 ******/
  8625. SET ANSI_NULLS ON
  8626. GO
  8627. SET QUOTED_IDENTIFIER ON
  8628. GO
  8629. --#####################################################
  8630. --创建时间:2014.10.30
  8631. --创建人:John
  8632. --说明:检查简历是否属于当前用户
  8633. --#####################################################
  8634. CREATE PROCEDURE [dbo].[pcHasCvByCvMainIDPaMainIDSelect]
  8635. (
  8636. @cvMainID INT,
  8637. @paMainID INT
  8638. )
  8639. AS
  8640. BEGIN
  8641. SELECT TOP 1 * FROM cvMain WITH(NOLOCK) WHERE id=@cvMainID AND paMainID=@paMainID
  8642. END
  8643. GO
  8644. /****** Object: StoredProcedure [dbo].[pcHasExJobApplyByCvMainIDSelect] Script Date: 2018/12/13 19:08:34 ******/
  8645. SET ANSI_NULLS ON
  8646. GO
  8647. SET QUOTED_IDENTIFIER ON
  8648. GO
  8649. --#####################################################
  8650. --创建时间:2014.10.31
  8651. --创建人:John
  8652. --说明:判断简历是否申请过职位
  8653. --#####################################################
  8654. CREATE PROCEDURE [dbo].[pcHasExJobApplyByCvMainIDSelect]
  8655. (
  8656. @cvMainID INT,
  8657. @jobID INT
  8658. )
  8659. AS
  8660. BEGIN
  8661. IF EXISTS (
  8662. SELECT TOP 1 'x'
  8663. FROM exjobapply WITH(NOLOCK)
  8664. WHERE cvMainID = @cvMainID AND AddDate > GETDATE()-30 AND jobID = @jobID
  8665. )
  8666. BEGIN
  8667. RETURN 1
  8668. END
  8669. ELSE
  8670. BEGIN
  8671. RETURN 0
  8672. END
  8673. END
  8674. GO
  8675. /****** Object: StoredProcedure [dbo].[pcIndexPageSelect] Script Date: 2018/12/13 19:08:34 ******/
  8676. SET ANSI_NULLS ON
  8677. GO
  8678. SET QUOTED_IDENTIFIER ON
  8679. GO
  8680. --修改Harry 调查增加exLink 2017-8-3
  8681. CREATE PROCEDURE [dbo].[pcIndexPageSelect]
  8682. (
  8683. @paMainID INT,
  8684. @ProvinceID INT
  8685. )
  8686. AS
  8687. SET NOCOUNT ON
  8688. BEGIN
  8689. DECLARE @t AS TABLE(
  8690. ID INT,
  8691. type INT,
  8692. iCount INT NULL,
  8693. Title NVARCHAR(100) NULL,
  8694. Link NVARCHAR(200) NULL,
  8695. ContentText NVARCHAR(MAX) NULL,
  8696. AddDate SMALLDATETIME NULL
  8697. )
  8698. --取未答复的面试通知
  8699. INSERT INTO @T(ID,type,iCount)
  8700. SELECT @paMainID,1,Count(a.ID) FROM exInterView a WITH(NOLOCK)
  8701. INNER JOIN cvMain d WITH(NOLOCK) ON a.cvMainID=d.ID
  8702. WHERE PersonDeleted=0 AND paMainID=@paMainID AND Reply=0
  8703. --取未查看的留言
  8704. INSERT INTO @T(ID,type,iCount)
  8705. SELECT @paMainID,2,Count(a.ID) FROM exMessageC2P a WITH(NOLOCK)
  8706. INNER JOIN cvMain d WITH(NOLOCK) ON a.cvMainID=d.ID
  8707. WHERE PersonDeleted=0 AND paMainID=@paMainID AND IsViewed=0
  8708. --取未答复的应聘邀请
  8709. INSERT INTO @T(ID,type,iCount)
  8710. SELECT @paMainID,8,Count(a.ID) FROM caCvIntention a WITH(NOLOCK)
  8711. INNER JOIN cvMain d WITH(NOLOCK) ON a.cvMainID=d.ID
  8712. WHERE PersonDeleted=0 AND paMainID=@paMainID AND Reply IS NULL
  8713. --取未查看的反馈
  8714. INSERT INTO @T(ID,type, ContentText,AddDate)
  8715. SELECT Top 1 ID,3, LEFT(ReplyMessage, 300), ReplyDate
  8716. FROM paFeedBack WITH(NOLOCK INDEX(IX_paFeedBack_paMainID))
  8717. WHERE paMainID = @paMainID AND IsReply = 1 AND ViewDate IS NULL
  8718. ORDER BY ID DESC
  8719. --取未查看的网站消息
  8720. INSERT INTO @T(ID,type,ContentText,AddDate)
  8721. SELECT TOP 2 ID,4,LEFT(Message, 300), AddDate
  8722. FROM PaNotify WITH(NOLOCK)
  8723. WHERE paMainID = @paMainID
  8724. AND (
  8725. (NotifyType = 1 AND IsViewed = 0) --一次性消息,看过就不再通知了
  8726. OR (NotifyType=2 AND ENDDate > GETDATE()) --即时消息,到期前(ENDdate)一直通知
  8727. )
  8728. ORDER BY ID DESC
  8729. --取未查看的网站分类通知
  8730. INSERT INTO @T(ID,type,Title,ContentText,link,iCount)
  8731. SELECT TOP 2 ID,5, Title,LEFT(Content, 300), link,Type
  8732. FROM ResumeInform WITH(NOLOCK)
  8733. WHERE Status=1
  8734. AND Province like '%' + LTRIM(str(@ProvinceID)) + '%'
  8735. AND EndDate > GETDATE()
  8736. ORDER BY ID DESC
  8737. --取未查看的投诉
  8738. INSERT INTO @T(ID,type,ContentText,AddDate)
  8739. SELECT TOP 1 a.ID,6,LEFT(a.Plaint, 300),a.AddDate
  8740. FROM CaPlaint a WITH(NOLOCK INDEX(IX_caPlaint_cvMainID)), cvMain b WITH(NOLOCK INDEX(IX_cvMain_paMainID))
  8741. WHERE a.cvMainID = b.ID AND b.PaMainID = @PaMainID AND a.IsViewed = 0 AND a.ReplyType = 1
  8742. ORDER BY a.ID DESC
  8743. --取当前调查
  8744. DECLARE @Reg AS INT
  8745. SET @Reg = 0
  8746. IF @ProvinceID=32
  8747. BEGIN
  8748. IF EXISTS(SELECT 'x' FROM paMain WITH(NOLOCK) WHERE ID=@paMainId AND AddDate > '2012-1-26')
  8749. SET @Reg = 1
  8750. END
  8751. IF @Reg = 1
  8752. INSERT INTO @T(ID,type,ContentText,Link)
  8753. SELECT TOP 1 ID, 7, Title,exLink FROM Ivgt_Investigation WITH(NOLOCK)
  8754. WHERE ENDDate > GETDATE() AND Province LIKE '%' + LTRIM(str(@ProvinceID))+'%' AND Type=2
  8755. ORDER BY ID DESC
  8756. ELSE
  8757. INSERT INTO @T(ID,type,ContentText,Link)
  8758. SELECT TOP 1 ID, 7, Title,exLink FROM Ivgt_Investigation WITH(NOLOCK)
  8759. WHERE ENDDate > GETDATE() AND Province LIKE '%' + LTRIM(str(@ProvinceID))+'%' AND Type=2
  8760. AND ID <> 276
  8761. ORDER BY ID DESC
  8762. SELECT * FROM @T
  8763. END
  8764. GO
  8765. /****** Object: StoredProcedure [dbo].[pcInterviewRecordByPaMainIDSelect] Script Date: 2018/12/13 19:08:35 ******/
  8766. SET ANSI_NULLS ON
  8767. GO
  8768. SET QUOTED_IDENTIFIER ON
  8769. GO
  8770. --#####################################################
  8771. --创建时间:2014.10.30
  8772. --创建人:John
  8773. --说明:个人获取面试记录
  8774. --#####################################################
  8775. CREATE PROCEDURE [dbo].[pcInterviewRecordByPaMainIDSelect]
  8776. (
  8777. @paMainID INT
  8778. )
  8779. AS
  8780. BEGIN
  8781. SELECT a.*,c.Name caName,d.Name cpName,ISNULL(d.SecondId ,d.ID) cpMainID
  8782. FROM viInterviewRecord a
  8783. LEFT JOIN viRoom b ON b.ID=a.viRoomID
  8784. LEFT JOIN caMain c ON c.ID=b.caMainID
  8785. LEFT JOIN cpMain d ON d.ID=c.cpMainID
  8786. WHERE a.Begindate IS NOT NULL
  8787. AND a.cvMainID IN
  8788. (
  8789. SELECT ID
  8790. FROM cvMain
  8791. WHERE paMainID=@paMainID
  8792. )
  8793. ORDER BY a.ID DESC
  8794. END
  8795. GO
  8796. /****** Object: StoredProcedure [dbo].[pcJobByCountySearchSelect] Script Date: 2018/12/13 19:08:35 ******/
  8797. SET ANSI_NULLS ON
  8798. GO
  8799. SET QUOTED_IDENTIFIER ON
  8800. GO
  8801. CREATE PROCEDURE [dbo].[pcJobByCountySearchSelect]
  8802. (
  8803. @dcJobTypeID VARCHAR(100), --职位类别
  8804. @dcRegionID VARCHAR(6), --求职地区
  8805. @PageNumber INT --翻页页码
  8806. )
  8807. AS
  8808. SELECT 0 JobNumber
  8809. SELECT TOP 0 * FROM SearchDb..CountyJob WITH(NOLOCK)
  8810. RETURN
  8811. BEGIN
  8812. DECLARE @crDate DATETIME
  8813. SELECT TOP 1 @crDate = crDate FROM SearchDb..CountyJob WITH(NOLOCK) WHERE JobPlaceId = @dcRegionID
  8814. IF DATEADD(HOUR, -2, GETDATE()) > ISNULL(@crDate, GETDATE() - 1)
  8815. BEGIN
  8816. EXEC procCountyJobInsert @dcRegionID
  8817. END
  8818. IF ISNULL(@PageNumber, 0) = 0
  8819. SET @PageNumber = 1
  8820. IF @PageNumber > 67
  8821. SET @PageNumber = 67
  8822. SELECT JobNumber FROM SearchDb..CountyJobNumber WHERE ProvinceId = LEFT(@dcRegionID, 2)
  8823. SELECT * FROM SearchDb..CountyJob WITH(NOLOCK)
  8824. WHERE JobPlaceId = @dcRegionID
  8825. AND PageID = @PageNumber
  8826. ORDER BY RowID
  8827. END
  8828. GO
  8829. /****** Object: StoredProcedure [dbo].[pcJobByHighSalarySelect] Script Date: 2018/12/13 19:08:35 ******/
  8830. SET ANSI_NULLS ON
  8831. GO
  8832. SET QUOTED_IDENTIFIER ON
  8833. GO
  8834. --lambo 2014-9-17
  8835. --前台校园招聘 取靠普高薪职位 山东北京上海取5000以上的 ,其它地区取4000以上的
  8836. --Mice 2014-9-26 添加 with(nolock)
  8837. CREATE PROCEDURE [dbo].[pcJobByHighSalarySelect]
  8838. (
  8839. @dcProvinceID INT
  8840. )
  8841. AS
  8842. BEGIN
  8843. SELECT * FROM HighJob WITH(NOLOCK) WHERE ProvinceId = @dcProvinceId
  8844. END
  8845. GO
  8846. /****** Object: StoredProcedure [dbo].[pcJobByIntentionSelect] Script Date: 2018/12/13 19:08:35 ******/
  8847. SET ANSI_NULLS ON
  8848. GO
  8849. SET QUOTED_IDENTIFIER ON
  8850. GO
  8851. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  8852. -- 检查: Sean
  8853. -- 日期: 2010-10-5
  8854. -- 描述: 提取求职意向
  8855. --peter 2018-3-27
  8856. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  8857. CREATE PROCEDURE [dbo].[pcJobByIntentionSelect]
  8858. (
  8859. @cvMainID INT
  8860. )
  8861. AS
  8862. SET NOCOUNT ON
  8863. BEGIN
  8864. DECLARE @JobType AS VARCHAR(30),
  8865. @JobTypeName AS VARCHAR(1000),
  8866. @JobPlace AS VARCHAR(40),
  8867. @JobPlaceName AS VARCHAR(100),
  8868. @Industry AS VARCHAR(30),
  8869. @IndustryName AS VARCHAR(100)
  8870. SELECT @JobType = '',@JobTypeName= '' , @JobPlace = '',@JobPlaceName = '', @Industry = '',@IndustryName = ''
  8871. SELECT @JobType = @JobType + LTRIM(STR(dcJobTypeID)) + ' ',
  8872. @JobTypeName =@JobTypeName + (SELECT TOP 1 Description+' ' FROM dcJobType WITH(NOLOCK) WHERE ID = dcJobTypeID)
  8873. FROM cvJobType WITH(NOLOCK)
  8874. WHERE cvMainID = @cvMainID ORDER BY dcJobTypeID
  8875. SELECT @JobPlace = @JobPlace + LTRIM(STR(dcRegionID)) + ' ',
  8876. @JobPlaceName = @JobPlaceName + (SELECT TOP 1 Description+' ' FROM dcRegion WITH(NOLOCK) WHERE ID = dcRegionID)
  8877. FROM cvJobPlace WITH(NOLOCK)
  8878. WHERE cvMainID = @cvMainID ORDER BY dcRegionID
  8879. SELECT @Industry = @Industry + LTRIM(STR(dcIndustryID)) + ' ',
  8880. @IndustryName = @IndustryName + (SELECT TOP 1 Description+' ' FROM dcIndustry WITH(NOLOCK) WHERE ID = dcIndustryID)
  8881. FROM cvIndustry WITH(NOLOCK)
  8882. WHERE cvMainID = @cvMainID ORDER BY dcIndustryID
  8883. SELECT RelatedWorkYears,
  8884. EmployType,
  8885. dcSalaryID,
  8886. IsNegotiable,
  8887. RTRIM(@JobType) AS JobType,
  8888. RTRIM(@JobTypeName) AS JobTypeName,
  8889. RTRIM(@JobPlace) AS JobPlace,
  8890. RTRIM(@JobPlaceName) AS JobPlaceName,
  8891. RTRIM(@Industry) AS Industry,
  8892. RTRIM(@IndustryName) AS IndustryName
  8893. FROM cvMain WITH(NOLOCK)
  8894. WHERE id = @cvMainID
  8895. END
  8896. GO
  8897. /****** Object: StoredProcedure [dbo].[pcJobByIntentionSelectByPhone] Script Date: 2018/12/13 19:08:35 ******/
  8898. SET ANSI_NULLS ON
  8899. GO
  8900. SET QUOTED_IDENTIFIER ON
  8901. GO
  8902. CREATE PROCEDURE [dbo].[pcJobByIntentionSelectByPhone]
  8903. @cvMainID INT
  8904. AS
  8905. BEGIN
  8906. DECLARE @JobType AS VARCHAR(100)
  8907. DECLARE @JobTypeName AS VARCHAR(1000)
  8908. DECLARE @JobPlace AS VARCHAR(100)
  8909. DECLARE @JobPlaceName AS VARCHAR(100)
  8910. DECLARE @Industry AS VARCHAR(100)
  8911. DECLARE @IndustryName AS VARCHAR(100)
  8912. DECLARE @INTTemp AS INT
  8913. DECLARE @STRTemp AS VARCHAR(20)
  8914. DECLARE #JobType CURSOR FOR SELECT a.dcJobTypeID,b.Description JobType FROM cvJobType a WITH(NOLOCK),dcJobType b WITH(NOLOCK) WHERE a.dcJobTypeID=b.ID AND a.cvMainID=@cvMainID ORDER BY a.dcJobTypeID
  8915. DECLARE #JobPlace CURSOR FOR SELECT a.dcRegionID,b.FullName Region FROM cvJobPlace a WITH(NOLOCK),dcRegion b WITH(NOLOCK) WHERE a.dcRegionID=b.ID AND a.cvMainID=@cvMainID ORDER BY a.dcRegionID
  8916. DECLARE #Industry CURSOR FOR SELECT a.dcIndustryID,b.Description Industry FROM cvIndustry a WITH(NOLOCK),dcIndustry b WITH(NOLOCK) WHERE a.dcIndustryID=b.ID AND a.cvMainID=@cvMainID ORDER BY dcIndustryID
  8917. --取得JobType
  8918. OPEN #JobType
  8919. FETCH NEXT FROM #JobType INTO @INTTemp,@STRTemp
  8920. WHILE @@FETCH_STATUS = 0
  8921. BEGIN
  8922. IF Len(@JobType) > 0
  8923. BEGIN
  8924. SET @JobType = @JobType + ' ' + Rtrim(CONVERT(CHAR(10),@INTTemp))
  8925. SET @JobTypeName = @JobTypeName + ' ' + @STRTemp
  8926. END
  8927. ELSE
  8928. BEGIN
  8929. SET @JobType = Rtrim(CONVERT(CHAR(10),@INTTemp))
  8930. SET @JobTypeName = @STRTemp
  8931. END
  8932. FETCH NEXT FROM #JobType INTO @INTTemp,@STRTemp
  8933. END
  8934. CLOSE #JobType
  8935. DEALLOCATE #JobType
  8936. --取得JobPlace
  8937. OPEN #JobPlace
  8938. FETCH NEXT FROM #JobPlace INTO @INTTemp,@STRTemp
  8939. WHILE @@FETCH_STATUS = 0
  8940. BEGIN
  8941. IF Len(@JobPlace) > 0
  8942. BEGIN
  8943. SET @JobPlace = @JobPlace + ' ' + Rtrim(CONVERT(CHAR(10),@INTTemp))
  8944. SET @JobPlaceName = @JobPlaceName + ' ' + @STRTemp
  8945. END
  8946. ELSE
  8947. BEGIN
  8948. SET @JobPlace = Rtrim(CONVERT(CHAR(10),@INTTemp))
  8949. SET @JobPlaceName = @STRTemp
  8950. END
  8951. FETCH NEXT FROM #JobPlace INTO @INTTemp,@STRTemp
  8952. END
  8953. CLOSE #JobPlace
  8954. DEALLOCATE #JobPlace
  8955. --取得Industry
  8956. OPEN #Industry
  8957. FETCH NEXT FROM #Industry INTO @INTTemp,@STRTemp
  8958. WHILE @@FETCH_STATUS = 0
  8959. BEGIN
  8960. IF Len(@Industry) > 0
  8961. BEGIN
  8962. SET @Industry = @Industry + ' ' + Rtrim(CONVERT(CHAR(10),@INTTemp))
  8963. SET @IndustryName = @IndustryName + ' ' + @STRTemp
  8964. END
  8965. ELSE
  8966. BEGIN
  8967. SET @Industry = Rtrim(CONVERT(CHAR(10),@INTTemp))
  8968. SET @IndustryName = @STRTemp
  8969. END
  8970. FETCH NEXT FROM #Industry INTO @INTTemp,@STRTemp
  8971. END
  8972. CLOSE #Industry
  8973. DEALLOCATE #Industry
  8974. SELECT
  8975. RelatedWorkYears,
  8976. EmployType,
  8977. dcSalaryID,
  8978. IsNegotiable,
  8979. b.Description Salary,
  8980. @JobType AS JobType,
  8981. @JobPlace AS JobPlace,
  8982. @Industry AS Industry,
  8983. @JobTypeName AS JobTypeName,
  8984. @JobPlaceName AS JobPlaceName,
  8985. @IndustryName AS IndustryName
  8986. From cvMain a WITH(NOLOCK)
  8987. LEFT JOIN dcSalary b WITH(NOLOCK) ON a.dcSalaryID=b.ID
  8988. WHERE a.id=@cvMainID
  8989. END
  8990. GO
  8991. /****** Object: StoredProcedure [dbo].[pcJobByJobApplyCount] Script Date: 2018/12/13 19:08:35 ******/
  8992. SET ANSI_NULLS ON
  8993. GO
  8994. SET QUOTED_IDENTIFIER ON
  8995. GO
  8996. CREATE PROCEDURE [dbo].[pcJobByJobApplyCount]
  8997. (
  8998. @JobID INT
  8999. )
  9000. AS
  9001. BEGIN
  9002. DECLARE @ApplyCount AS INT
  9003. SELECT @ApplyCount = COUNT(ID) FROM exJobApply WITH(NOLOCK) WHERE JobID = @JobID
  9004. RETURN @ApplyCount
  9005. END
  9006. GO
  9007. /****** Object: StoredProcedure [dbo].[pcJobByJobIDsSelect] Script Date: 2018/12/13 19:08:36 ******/
  9008. SET ANSI_NULLS ON
  9009. GO
  9010. SET QUOTED_IDENTIFIER ON
  9011. GO
  9012. CREATE PROCEDURE [dbo].[pcJobByJobIDsSelect]
  9013. (
  9014. @JobIDs VARCHAR(300)
  9015. )
  9016. AS
  9017. BEGIN
  9018. SELECT * FROM Job WITH(NOLOCK) WHERE ID IN (SELECT A FROM dbo.fnsplit(@JobIDs ,','))
  9019. END
  9020. GO
  9021. /****** Object: StoredProcedure [dbo].[pcJobByListSelect] Script Date: 2018/12/13 19:08:36 ******/
  9022. SET ANSI_NULLS ON
  9023. GO
  9024. SET QUOTED_IDENTIFIER ON
  9025. GO
  9026. CREATE PROCEDURE [dbo].[pcJobByListSelect]
  9027. (
  9028. @AllJobID VARCHAR(1000)
  9029. )
  9030. AS
  9031. BEGIN
  9032. SET @AllJobID = dbo.FormatIDS(@AllJobID)
  9033. DECLARE @T AS TABLE(ID INT)
  9034. INSERT INTO @T SELECT * FROM dbo.fnSplit(@AllJobID, ',')
  9035. SELECT c.ID,c.cpMainID,c.caMainID,c.Name AS JobName,c.dcJobTypeID,c.dcJobTypeIDMinor,
  9036. c.NeedNumber,c.dcSalaryID,c.EmployType,c.dcRegionID,c.dcEducationID,c.MinExperience,
  9037. c.IssueDate,c.IssueEND,c.IsDelete,b.AccountType,b.Name AS caName,b.GENDer,
  9038. b.Title,b.Dept,b.TelePhone,b.Mobile,b.Fax,
  9039. b.IsPhoneHide,b.IsNameHide,b.IsMobileHide,a.Name AS cpName,
  9040. a.ShortName,a.dcCompanyKindID,a.dcCompanySizeID,
  9041. a.dcRegionID AS cpDcRegionID,a.Address,a.Zip,c.SecondID EnJobID,a.SecondID EnCpMainID
  9042. FROM cpMain a WITH(NOLOCK)
  9043. INNER JOIN caMain b WITH(NOLOCK) ON a.ID = b.cpMainID
  9044. INNER JOIN Job c WITH(NOLOCK) ON b.ID = c.caMainID
  9045. WHERE c.ID IN (SELECT ID FROM @t)
  9046. END
  9047. GO
  9048. /****** Object: StoredProcedure [dbo].[pcJobByMapSearchSelect] Script Date: 2018/12/13 19:08:36 ******/
  9049. SET ANSI_NULLS ON
  9050. GO
  9051. SET QUOTED_IDENTIFIER ON
  9052. GO
  9053. CREATE PROCEDURE [dbo].[pcJobByMapSearchSelect]
  9054. (
  9055. @dcJobTypeID VARCHAR(100), --职位类别
  9056. @dcIndustryID VARCHAR(100), --求职行业
  9057. @KeyWord NVARCHAR(50), --关键词
  9058. @KeyType TINYINT, --关键词类别,0无;1-全文;2-职位;3-公司
  9059. @Type INT, --1:主动搜索 点击搜索按钮 10分钟,翻页60分钟有效;0:翻页搜索,不刷新
  9060. @PageNumber INT, --翻页页码
  9061. @Distance INT, --距离范围
  9062. @Lng DECIMAL(8,5), --经度
  9063. @Lat DECIMAL(8,5), --纬度
  9064. @dcSalaryID TINYINT, --月薪
  9065. @MinExperience TINYINT, --工作经验,100为未选择
  9066. @dcEducationID TINYINT, --最低学历
  9067. @EmployType VARCHAR(10), --是否在线 -----工作性质,1全职;3兼职;4实习,
  9068. @CompanySizeID VARCHAR(2) --dcprovinceid --fei 是否环境照片 --企业规模
  9069. )
  9070. AS
  9071. --return
  9072. SET NOCOUNT ON
  9073. IF @Lng IS NULL OR @Lat IS NULL
  9074. RETURN
  9075. BEGIN TRY
  9076. BEGIN
  9077. ----给null值变量赋默认值
  9078. SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
  9079. @dcIndustryID = RTRIM(dbo.FormatIDS(@dcIndustryID)),
  9080. @Type = ISNULL(@Type, 0),
  9081. @dcSalaryID = 0,
  9082. @MinExperience = 0,
  9083. @dcEducationID = 0,
  9084. @PageNumber = ISNULL(@PageNumber, 0),
  9085. @CompanySizeID = ISNULL(@CompanySizeID, '0'),
  9086. @EmployType = ISNULL(@EmployType, '')
  9087. IF RIGHT(@dcJobTypeID, 1) = ','
  9088. SET @dcJobTypeID = LEFT(@dcJobTypeID, LEN(@dcJobTypeID) - 1)
  9089. IF RIGHT(@dcIndustryID, 1) = ','
  9090. SET @dcIndustryID = LEFT(@dcIndustryID, LEN(@dcIndustryID) - 1)
  9091. DECLARE @paSearchConditionID AS INT,
  9092. @MinId AS INT,
  9093. @PageSize AS TINYINT,
  9094. @TableID AS TINYINT
  9095. SELECT @paSearchConditionID = 0, @PageSize = 30 --每页的行数
  9096. ----搜索60分钟前的数据
  9097. SELECT TOP 1 @paSearchConditionID=ID FROM SearchDB..paSearchCondition WITH(NOLOCK)
  9098. WHERE IsDelete = 0 AND JobType = @dcJobTypeID
  9099. AND Industry = @dcIndustryID AND Lng = @Lng
  9100. AND Distance = @Distance AND Lat = @Lat
  9101. AND Education = @dcEducationID AND EmployType = @EmployType
  9102. AND Experience = @MinExperience AND Salary = @dcSalaryID
  9103. AND CompanySizeID = 0 AND dcProvinceId = @CompanySizeID
  9104. ORDER BY ID DESC
  9105. IF ISNULL(@paSearchConditionID, 0) = 0
  9106. BEGIN
  9107. SET @Type =1
  9108. GOTO SelectReset --无数据,重新搜索
  9109. END
  9110. ELSE
  9111. BEGIN
  9112. SELECT @TableID = @paSearchConditionID % 4
  9113. GOTO GetRecordSet --从临时结果中提取数据
  9114. END
  9115. END
  9116. SelectReset: --从job中搜索数据
  9117. BEGIN TRAN
  9118. DECLARE @SQL AS VARCHAR(8000)
  9119. DECLARE @WHERE AS VARCHAR(8000)
  9120. DECLARE @FROM AS VARCHAR(1000)
  9121. ----记录查询条件
  9122. INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, Industry,
  9123. Lng, Lat, Distance, ReuseNumber, Education, Experience,
  9124. Salary, EmployType, CompanySizeID, dcProvinceId, Keyword)
  9125. VALUES(51, GETDATE(), @dcJobTypeID, @dcIndustryID, @Lng, @Lat,
  9126. @Distance, 0, @dcEducationID, @MinExperience,
  9127. @dcSalaryID, @EmployType, 0, @CompanySizeID, '')
  9128. SET @paSearchConditionID = @@IDENTITY
  9129. SELECT @TableID = @paSearchConditionID % 4
  9130. ------生成职位类别的表变量,因为职位类别有包含(父子)关系
  9131. DECLARE @T_JobType AS TABLE(ID INT)
  9132. DECLARE @JobType AS VARCHAR(3000)
  9133. DECLARE @ValidJobNumber AS INT
  9134. SET @JobType=''
  9135. ----生成求聘职位的表变量
  9136. IF LEN(@dcJobTypeID) > 0
  9137. BEGIN
  9138. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  9139. INSERT INTO @T_Temp
  9140. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  9141. INSERT INTO @T_JobType
  9142. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  9143. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  9144. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  9145. OR ID IN(SELECT ID FROM @T_TEMP)
  9146. ----生成in字符串
  9147. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  9148. IF RIGHT(@JobType, 1) = ','
  9149. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  9150. END
  9151. ----建立临时表
  9152. CREATE TABLE #Job(
  9153. RowID INT IDENTITY(1, 1),
  9154. ID INT NOT NULL,
  9155. dcJobTypeID SMALLINT NOT NULL,
  9156. dcJobTypeIDMinor SMALLINT NULL,
  9157. dcSalaryID TINYINT NOT NULL,
  9158. dcRegionID VARCHAR(6) NULL,
  9159. dcEducationID TINYINT NOT NULL,
  9160. MinExperience TINYINT NOT NULL,
  9161. RefreshDate SMALLDATETIME NULL,
  9162. EmployType TINYINT NULL,
  9163. dcCompanySizeID SMALLINT NULL
  9164. )
  9165. ------刷新时间,根据刷新时间编号计算
  9166. ----生成插入临时表的Sql语句
  9167. SET @SQL='
  9168. INSERT INTO #Job
  9169. SELECT a.ID, a.dcJobTypeID,
  9170. a.dcJobTypeIDMinor, a.dcSalaryID,
  9171. a.dcRegionID, a.dcEducationID, a.MinExperience,
  9172. a.IssueDate,a.EmployType,b.dcCompanySizeID'
  9173. SET @FROM = '
  9174. FROM JobPublish a WITH(NOLOCK)
  9175. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  9176. ----职位有效,单位新有效
  9177. IF LEN(@dcIndustryID) > 0
  9178. SET @WHERE = '
  9179. WHERE b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @dcIndustryID + '))
  9180. AND a.Valid = 1
  9181. AND b.Valid = 1'
  9182. ELSE
  9183. SET @WHERE = '
  9184. WHERE a.Valid = 1
  9185. AND b.Valid = 1'
  9186. IF LEN(@CompanySizeId) = 2
  9187. SET @WHERE = @WHERE + '
  9188. AND b.dcProvinceID = ' + @CompanySizeId
  9189. ----职位类别
  9190. IF LEN(@dcJobTypeID) > 0
  9191. SET @WHERE = @WHERE + '
  9192. AND (a.dcJobTypeID IN(' + @JobType +')
  9193. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  9194. ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
  9195. IF LEN(@EmployType) = '1'
  9196. SET @WHERE = @WHERE + '
  9197. AND a.caMainId IN(SELECT caMainId FROM caOnline WITH(NOLOCK) WHERE IsOnline = 1)'
  9198. DECLARE @Degree AS DECIMAL(8,5),@LBLng AS DECIMAL(8,5),@LBLat AS DECIMAL(8,5),
  9199. @RTLng AS DECIMAL(8,5),@RTLat AS DECIMAL(8,5)
  9200. SET @Degree = @Distance / 100000.0;
  9201. SET @LBLng = @Lng - @Degree
  9202. SET @LBLat = @Lat - @Degree
  9203. SET @RTLng = @Lng + @Degree
  9204. SET @RTLat = @Lat + @Degree
  9205. SET @WHERE = @WHERE + '
  9206. AND a.Lng BETWEEN ' + CONVERT(VARCHAR,@LBLng) + ' AND ' + CONVERT(VARCHAR,@RTLng) + '
  9207. AND a.Lat BETWEEN ' + CONVERT(VARCHAR,@LBLat) + ' AND ' + CONVERT(VARCHAR,@RTLat) + '
  9208. AND (a.Lng-' + CONVERT(VARCHAR,@Lng) + ')*(a.Lng-' + CONVERT(VARCHAR,@Lng) + ')+
  9209. (a.Lat-' + CONVERT(VARCHAR,@Lat) + ')*(a.Lat-' + CONVERT(VARCHAR,@Lat) + ')<' + CONVERT(VARCHAR,@Degree*@Degree)
  9210. SET @SQL = @SQL + @FROM + @WHERE
  9211. --IF LEN(@ORDER)>0
  9212. SET @SQL=@SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
  9213. --原来是ORDER BY a.IssueDate DESC, a.ID,Richard 2011年11月23日17:06分修改
  9214. ----把符合条件的职位全部列出
  9215. --PRINT @SQL
  9216. EXEC(@SQL)
  9217. SET @ValidJobNumber = @@ROWCOUNT
  9218. ----记录查询结果总数
  9219. UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@SQL WHERE ID=@paSearchConditionID
  9220. ----插入JobType数据
  9221. DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
  9222. IF (@TableID = 0)
  9223. BEGIN
  9224. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  9225. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  9226. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  9227. ----计算全部某职位类别,2, 4位的数据
  9228. UPDATE a SET a.TitleValue = b.TitleValue
  9229. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
  9230. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  9231. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  9232. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  9233. GROUP BY LEFT(TitleID, 2)) b
  9234. WHERE a.TitleId = b.TitleID
  9235. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  9236. ----写入TitleDesc
  9237. UPDATE a SET a.TitleDesc = b.Description
  9238. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  9239. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  9240. AND a.Title = 'JobType'
  9241. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  9242. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  9243. GROUP BY dcSalaryID ORDER BY dcSalaryID
  9244. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  9245. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  9246. GROUP BY dcRegionID ORDER BY dcRegionID
  9247. ----计算全部地区,2位的数据
  9248. UPDATE a SET a.TitleValue = b.TitleValue
  9249. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
  9250. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  9251. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  9252. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  9253. GROUP BY LEFT(TitleID, 2)) b
  9254. WHERE a.TitleId = b.TitleID
  9255. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  9256. ----计算全部地区,4位的数据
  9257. UPDATE a SET a.TitleValue = b.TitleValue
  9258. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), (
  9259. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  9260. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  9261. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  9262. AND LEN(TitleID) >3
  9263. GROUP BY LEFT(TitleID, 4)) b
  9264. WHERE a.TitleId = b.TitleID
  9265. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  9266. ----写入TitleDesc
  9267. UPDATE a SET a.TitleDesc = b.Description
  9268. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  9269. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  9270. AND a.Title = 'Region'
  9271. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  9272. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*) FROM #Job WITH(NOLOCK)
  9273. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  9274. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  9275. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  9276. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  9277. GROUP BY MinExperience ORDER BY MinExperience
  9278. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  9279. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  9280. GROUP BY EmployType ORDER BY EmployType
  9281. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  9282. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  9283. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  9284. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  9285. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  9286. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  9287. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  9288. SET @TopRows = @@ROWCOUNT
  9289. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  9290. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  9291. SET @AllRows = @@ROWCOUNT
  9292. IF @TopRows = 0 AND @AllRows > 100
  9293. UPDATE SearchDB..paSearchJobID_0 SET IsTop = 1
  9294. WHERE paSearchConditionID = @paSearchConditionID
  9295. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  9296. END
  9297. ELSE IF (@TableId = 1)
  9298. BEGIN
  9299. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  9300. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  9301. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  9302. ----计算全部某职位类别,2, 4位的数据
  9303. UPDATE a SET a.TitleValue = b.TitleValue
  9304. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
  9305. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  9306. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  9307. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  9308. GROUP BY LEFT(TitleID, 2)) b
  9309. WHERE a.TitleId = b.TitleID
  9310. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  9311. ----写入TitleDesc
  9312. UPDATE a SET a.TitleDesc = b.Description
  9313. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  9314. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  9315. AND a.Title = 'JobType'
  9316. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  9317. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  9318. GROUP BY dcSalaryID ORDER BY dcSalaryID
  9319. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  9320. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  9321. GROUP BY dcRegionID ORDER BY dcRegionID
  9322. ----计算全部地区,2位的数据
  9323. UPDATE a SET a.TitleValue = b.TitleValue
  9324. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
  9325. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  9326. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  9327. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  9328. GROUP BY LEFT(TitleID, 2)) b
  9329. WHERE a.TitleId = b.TitleID
  9330. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  9331. ----计算全部地区,4位的数据
  9332. UPDATE a SET a.TitleValue = b.TitleValue
  9333. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), (
  9334. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  9335. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  9336. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  9337. AND LEN(TitleID) >3
  9338. GROUP BY LEFT(TitleID, 4)) b
  9339. WHERE a.TitleId = b.TitleID
  9340. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  9341. ----写入TitleDesc
  9342. UPDATE a SET a.TitleDesc = b.Description
  9343. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  9344. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  9345. AND a.Title = 'Region'
  9346. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  9347. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*) FROM #Job WITH(NOLOCK)
  9348. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  9349. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  9350. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  9351. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  9352. GROUP BY MinExperience ORDER BY MinExperience
  9353. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  9354. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  9355. GROUP BY EmployType ORDER BY EmployType
  9356. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  9357. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  9358. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  9359. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  9360. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  9361. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  9362. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  9363. SET @TopRows = @@ROWCOUNT
  9364. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  9365. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  9366. SET @AllRows = @@ROWCOUNT
  9367. IF @TopRows = 0 AND @AllRows > 100
  9368. UPDATE SearchDB..paSearchJobID_1 SET IsTop = 1
  9369. WHERE paSearchConditionID = @paSearchConditionID
  9370. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  9371. END
  9372. ELSE IF (@TableId = 2)
  9373. BEGIN
  9374. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  9375. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  9376. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  9377. ----计算全部某职位类别,2, 4位的数据
  9378. UPDATE a SET a.TitleValue = b.TitleValue
  9379. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
  9380. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  9381. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  9382. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  9383. GROUP BY LEFT(TitleID, 2)) b
  9384. WHERE a.TitleId = b.TitleID
  9385. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  9386. ----写入TitleDesc
  9387. UPDATE a SET a.TitleDesc = b.Description
  9388. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  9389. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  9390. AND a.Title = 'JobType'
  9391. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  9392. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  9393. GROUP BY dcSalaryID ORDER BY dcSalaryID
  9394. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  9395. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  9396. GROUP BY dcRegionID ORDER BY dcRegionID
  9397. ----计算全部地区,2位的数据
  9398. UPDATE a SET a.TitleValue = b.TitleValue
  9399. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
  9400. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  9401. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  9402. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  9403. GROUP BY LEFT(TitleID, 2)) b
  9404. WHERE a.TitleId = b.TitleID
  9405. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  9406. ----计算全部地区,4位的数据
  9407. UPDATE a SET a.TitleValue = b.TitleValue
  9408. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), (
  9409. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  9410. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  9411. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  9412. AND LEN(TitleID) >3
  9413. GROUP BY LEFT(TitleID, 4)) b
  9414. WHERE a.TitleId = b.TitleID
  9415. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  9416. ----写入TitleDesc
  9417. UPDATE a SET a.TitleDesc = b.Description
  9418. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  9419. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  9420. AND a.Title = 'Region'
  9421. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  9422. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*) FROM #Job WITH(NOLOCK)
  9423. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  9424. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  9425. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  9426. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  9427. GROUP BY MinExperience ORDER BY MinExperience
  9428. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  9429. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  9430. GROUP BY EmployType ORDER BY EmployType
  9431. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  9432. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  9433. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  9434. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  9435. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  9436. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  9437. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  9438. SET @TopRows = @@ROWCOUNT
  9439. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  9440. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  9441. SET @AllRows = @@ROWCOUNT
  9442. IF @TopRows = 0 AND @AllRows > 100
  9443. UPDATE SearchDB..paSearchJobID_2 SET IsTop = 1
  9444. WHERE paSearchConditionID = @paSearchConditionID
  9445. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  9446. END
  9447. ELSE IF (@TableId = 3)
  9448. BEGIN
  9449. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  9450. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  9451. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  9452. ----计算全部某职位类别,2, 4位的数据
  9453. UPDATE a SET a.TitleValue = b.TitleValue
  9454. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
  9455. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  9456. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  9457. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  9458. GROUP BY LEFT(TitleID, 2)) b
  9459. WHERE a.TitleId = b.TitleID
  9460. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  9461. ----写入TitleDesc
  9462. UPDATE a SET a.TitleDesc = b.Description
  9463. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  9464. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  9465. AND a.Title = 'JobType'
  9466. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  9467. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  9468. GROUP BY dcSalaryID ORDER BY dcSalaryID
  9469. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  9470. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  9471. GROUP BY dcRegionID ORDER BY dcRegionID
  9472. ----计算全部地区,2位的数据
  9473. UPDATE a SET a.TitleValue = b.TitleValue
  9474. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
  9475. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  9476. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  9477. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  9478. GROUP BY LEFT(TitleID, 2)) b
  9479. WHERE a.TitleId = b.TitleID
  9480. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  9481. ----计算全部地区,4位的数据
  9482. UPDATE a SET a.TitleValue = b.TitleValue
  9483. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), (
  9484. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  9485. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  9486. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  9487. AND LEN(TitleID) >3
  9488. GROUP BY LEFT(TitleID, 4)) b
  9489. WHERE a.TitleId = b.TitleID
  9490. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  9491. ----写入TitleDesc
  9492. UPDATE a SET a.TitleDesc = b.Description
  9493. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  9494. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  9495. AND a.Title = 'Region'
  9496. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  9497. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*) FROM #Job WITH(NOLOCK)
  9498. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  9499. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  9500. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  9501. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  9502. GROUP BY MinExperience ORDER BY MinExperience
  9503. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  9504. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  9505. GROUP BY EmployType ORDER BY EmployType
  9506. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  9507. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  9508. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  9509. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  9510. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  9511. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  9512. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  9513. SET @TopRows = @@ROWCOUNT
  9514. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  9515. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  9516. SET @AllRows = @@ROWCOUNT
  9517. IF @TopRows = 0 AND @AllRows > 100
  9518. UPDATE SearchDB..paSearchJobID_3 SET IsTop = 1
  9519. WHERE paSearchConditionID = @paSearchConditionID
  9520. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  9521. END
  9522. DROP TABLE #Job
  9523. --PRINT 'DROP #JOB ' + CONVERT(VARCHAR(30), GETDATE(), 121)
  9524. COMMIT
  9525. --GOTO GetRecordSet
  9526. GetRecordSet:
  9527. BEGIN
  9528. ----返回查询数量
  9529. SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
  9530. UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
  9531. ----返回20行查询结果
  9532. IF (@TableID = 0)
  9533. BEGIN
  9534. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  9535. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  9536. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  9537. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  9538. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  9539. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  9540. a.IsDelete, a.AddDate, a.RefreshDate, a.Lng, a.Lat,
  9541. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  9542. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  9543. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  9544. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  9545. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  9546. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID, a.Welfare1,a.Welfare2,
  9547. a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
  9548. a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,a.Welfare19, dbo.GetCaOnlineStatus(a.caMainID) AS IsOnline,
  9549. CASE WHEN b.ReplyRate >= 0.6 THEN b.ReplyRate ELSE NULL END Replyrate, b.RealName
  9550. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_0 c WITH(NOLOCK)
  9551. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  9552. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  9553. END
  9554. ELSE IF (@TableID = 1)
  9555. BEGIN
  9556. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  9557. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  9558. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  9559. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  9560. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  9561. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  9562. a.IsDelete, a.AddDate, a.RefreshDate, a.Lng, a.Lat,
  9563. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  9564. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  9565. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  9566. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  9567. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  9568. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID, a.Welfare1,a.Welfare2,
  9569. a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
  9570. a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,a.Welfare19, dbo.GetCaOnlineStatus(a.caMainID) AS IsOnline,
  9571. CASE WHEN b.ReplyRate >= 0.6 THEN b.ReplyRate ELSE NULL END Replyrate, b.RealName
  9572. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_1 c WITH(NOLOCK)
  9573. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  9574. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  9575. END
  9576. ELSE IF (@TableID = 2)
  9577. BEGIN
  9578. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  9579. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  9580. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  9581. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  9582. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  9583. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  9584. a.IsDelete, a.AddDate, a.RefreshDate, a.Lng, a.Lat,
  9585. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  9586. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  9587. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  9588. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  9589. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  9590. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID, a.Welfare1,a.Welfare2,
  9591. a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
  9592. a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,a.Welfare19, dbo.GetCaOnlineStatus(a.caMainID) AS IsOnline,
  9593. CASE WHEN b.ReplyRate >= 0.6 THEN b.ReplyRate ELSE NULL END Replyrate, b.RealName
  9594. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_2 c WITH(NOLOCK)
  9595. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  9596. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  9597. END
  9598. ELSE IF (@TableID = 3)
  9599. BEGIN
  9600. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  9601. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  9602. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  9603. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  9604. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  9605. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  9606. a.IsDelete, a.AddDate, a.RefreshDate, a.Lng, a.Lat,
  9607. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  9608. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  9609. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  9610. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  9611. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  9612. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID, a.Welfare1,a.Welfare2,
  9613. a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
  9614. a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,a.Welfare19, dbo.GetCaOnlineStatus(a.caMainID) AS IsOnline,
  9615. CASE WHEN b.ReplyRate >= 0.6 THEN b.ReplyRate ELSE NULL END Replyrate, b.RealName
  9616. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_3 c WITH(NOLOCK)
  9617. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  9618. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  9619. END
  9620. --RICHARD 2011-7-23 16:51分修改
  9621. ----返回统计数量
  9622. IF @Type=1
  9623. BEGIN
  9624. IF (@TableID = 0)
  9625. BEGIN
  9626. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  9627. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  9628. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9629. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9630. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9631. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9632. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9633. END
  9634. IF (@TableID = 1)
  9635. BEGIN
  9636. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  9637. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  9638. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9639. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9640. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9641. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9642. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9643. END
  9644. IF (@TableID = 2)
  9645. BEGIN
  9646. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  9647. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  9648. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9649. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9650. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9651. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9652. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9653. END
  9654. IF (@TableID = 3)
  9655. BEGIN
  9656. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  9657. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  9658. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9659. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9660. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9661. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9662. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  9663. END
  9664. END
  9665. RETURN
  9666. END
  9667. END TRY
  9668. BEGIN CATCH
  9669. ---检查是否已经建立临时表,已经建立则删除
  9670. DECLARE @para VARCHAR(MAX)
  9671. SET @para = '@dcJobTypeID=' + ISNULL(@dcJobTypeID, '') + '|' +
  9672. '@dcIndustryID=' + ISNULL(@dcIndustryID, '') + '|' +
  9673. '@EmployType=' + ISNULL(@EmployType, '') + '|' +
  9674. '@KeyWord=' + ISNULL(@KeyWord, '')
  9675. INSERT INTO ErrorLog
  9676. SELECT 'p3 ' +ISNULL(error_Message(), ' no msg')+ ' para=' + ISNULL(@Para, 'no para ') + ISNULL(@SQL, ' no sql'), error_number(), error_line(), GETDATE()
  9677. END CATCH
  9678. GO
  9679. /****** Object: StoredProcedure [dbo].[pcJobByNewstSelect] Script Date: 2018/12/13 19:08:38 ******/
  9680. SET ANSI_NULLS ON
  9681. GO
  9682. SET QUOTED_IDENTIFIER ON
  9683. GO
  9684. CREATE PROCEDURE [dbo].[pcJobByNewstSelect]
  9685. (
  9686. @dcProvinceID INT
  9687. )
  9688. AS
  9689. SET NOCOUNT ON
  9690. --insert proclog select 'pcJobByNewstSelect', @dcProvinceID, getdate()
  9691. BEGIN
  9692. IF NOT EXISTS(SELECT 'x' FROM SearchDb..JobNewst WHERE AddDate > DATEADD(MINUTE, -3, GETDATE()) AND ProvinceId = @dcProvinceID)
  9693. BEGIN
  9694. DELETE FROM SearchDb..JobNewst WHERE ProvinceId = @dcProvinceID
  9695. INSERT INTO SearchDb..JobNewst(cpMainName, JobName, JobId, CpMainID, cpId, JId, ProvinceID, AddDate)
  9696. SELECT TOP 10 a.Name, b.Name, b.ID, a.Id, a.SecondId, b.SecondId, @dcProvinceID, GETDATE()
  9697. FROM cpMainPublish a WITH(NOLOCK)
  9698. INNER JOIN JobPublish b WITH(NOLOCK) ON a.ID = b.cpMainId
  9699. WHERE b.dcRegionID LIKE LTRIM(STR(@dcProvinceID)) + '%'
  9700. AND a.Valid = 1
  9701. AND b.Valid = 1
  9702. AND a.MemberType > 1
  9703. AND a.dcProvinceId = LEFT(@dcProvinceId, 2)
  9704. ORDER BY b.ID DESC
  9705. END
  9706. SELECT cpMainName, JobName, JobId, CpMainID, cpId, JId FROM SearchDb..JobNewst WITH(NOLOCK) WHERE ProvinceId = @dcProvinceID
  9707. END
  9708. GO
  9709. /****** Object: StoredProcedure [dbo].[pcJobByRecommendSelect] Script Date: 2018/12/13 19:08:38 ******/
  9710. SET ANSI_NULLS ON
  9711. GO
  9712. SET QUOTED_IDENTIFIER ON
  9713. GO
  9714. CREATE PROCEDURE [dbo].[pcJobByRecommendSelect]
  9715. (
  9716. @dcJobTypeID VARCHAR(100), --职位类别
  9717. @dcRegionID VARCHAR(100), --求职地区
  9718. @dcIndustryID VARCHAR(100), --求职行业
  9719. @dcSalaryID TINYINT, --月薪
  9720. @MinExperience TINYINT, --工作经验,100为未选择
  9721. @dcEducationID TINYINT, --最低学历
  9722. @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习
  9723. @RowCount SMALLINT --需要显示的行数
  9724. )
  9725. AS
  9726. SET NOCOUNT ON
  9727. BEGIN
  9728. SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
  9729. @dcRegionID = RTRIM(dbo.FormatIDS(@dcRegionID)),
  9730. @dcIndustryID = RTRIM(dbo.FormatIDS(@dcIndustryID)),
  9731. @dcSalaryID = ISNULL(@dcSalaryID, 0),
  9732. @MinExperience = ISNULL(@MinExperience, 100),
  9733. @dcEducationID = ISNULL(@dcEducationID, 0),
  9734. @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END
  9735. IF @dcJobTypeID LIKE '%,%,%,%,%,%'
  9736. SET @dcJobTypeID = LEFT(@dcJobTypeID, 2)
  9737. IF @dcRegionID LIKE '%,%,%,%,%,%'
  9738. SET @dcRegionID = LEFT(@dcRegionID, 2)
  9739. IF RIGHT(@dcJobTypeID, 1) = ','
  9740. SET @dcJobTypeID = LEFT(@dcJobTypeID, LEN(@dcJobTypeID) - 1)
  9741. IF RIGHT(@dcRegionID, 1) = ','
  9742. SET @dcRegionID = LEFT(@dcRegionID, LEN(@dcRegionID) - 1)
  9743. IF RIGHT(@dcIndustryID, 1) = ','
  9744. SET @dcIndustryID = LEFT(@dcIndustryID, LEN(@dcIndustryID) - 1)
  9745. ------生成职位类别的表变量,因为职位类别有包含(父子)关系
  9746. DECLARE @T_JobPlace AS TABLE(ID INT)
  9747. DECLARE @T_JobType AS TABLE(ID INT)
  9748. DECLARE @JobType AS VARCHAR(3000)
  9749. DECLARE @JobPlace AS VARCHAR(2000)
  9750. DECLARE @SQL AS NVARCHAR(MAX)
  9751. DECLARE @WHERE AS VARCHAR(8000)
  9752. DECLARE @FROM AS VARCHAR(1000)
  9753. SET @JobPlace = ''
  9754. SET @JobType=''
  9755. ----生成工作地点的表变量
  9756. IF LEN(@dcRegionID) > 0
  9757. BEGIN
  9758. INSERT INTO @T_JobPlace
  9759. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  9760. SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  9761. IF LEN(@JobPlace) > 0
  9762. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  9763. END
  9764. ----生成求聘职位的表变量
  9765. IF LEN(@dcJobTypeID) > 0
  9766. BEGIN
  9767. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  9768. INSERT INTO @T_Temp
  9769. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  9770. INSERT INTO @T_JobType
  9771. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  9772. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  9773. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  9774. OR ID IN(SELECT ID FROM @T_TEMP)
  9775. ----生成in字符串
  9776. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  9777. IF RIGHT(@JobType, 1) = ','
  9778. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  9779. END
  9780. ----建立临时表
  9781. CREATE TABLE #Job(
  9782. RowID INT IDENTITY(1, 1),
  9783. ID INT NOT NULL,
  9784. dcJobTypeID SMALLINT NOT NULL,
  9785. dcJobTypeIDMinor SMALLINT NULL,
  9786. dcSalaryID TINYINT NOT NULL,
  9787. dcRegionID VARCHAR(6) NULL,
  9788. dcEducationID TINYINT NOT NULL,
  9789. MinExperience TINYINT NOT NULL,
  9790. RefreshDate SMALLDATETIME NULL
  9791. )
  9792. ----生成插入临时表的Sql语句
  9793. SET @SQL = '
  9794. INSERT INTO #Job
  9795. SELECT TOP ' + CONVERT(VARCHAR(3),@RowCount) + ' a.ID, a.dcJobTypeID,
  9796. a.dcJobTypeIDMinor, a.dcSalaryID,
  9797. a.dcRegionID, a.dcEducationID, a.MinExperience,
  9798. a.IssueDate'
  9799. SET @FROM = '
  9800. FROM JobPublish a WITH(NOLOCK)
  9801. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  9802. ----职位有效,单位新有效
  9803. IF LEN(@dcIndustryID) > 0
  9804. SET @WHERE = '
  9805. WHERE b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @dcIndustryID + '))
  9806. AND a.Valid = 1
  9807. AND b.Valid = 1'
  9808. ELSE
  9809. SET @WHERE = '
  9810. WHERE a.Valid = 1
  9811. AND b.Valid = 1'
  9812. ----职位类别
  9813. IF LEN(@dcJobTypeID) > 0
  9814. SET @WHERE = @WHERE + '
  9815. AND (a.dcJobTypeID IN(' + @JobType +')
  9816. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  9817. IF LEN(@JobPlace) > 0
  9818. SET @WHERE = @WHERE + '
  9819. AND (' + @JobPlace + ')'
  9820. IF @dcSalaryID > 0
  9821. BEGIN
  9822. IF @dcSalaryID < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
  9823. BEGIN
  9824. SET @WHERE = @WHERE + '
  9825. AND a.dcSalaryID IN(' + LTRIM(STR(@dcSalaryID)) + ',' + LTRIM(STR(@dcSalaryID + 1))
  9826. SET @WHERE = @WHERE + ')'
  9827. END
  9828. IF @dcSalaryID = 100 ----从筛选结果中点击面议,值是100
  9829. BEGIN
  9830. SET @WHERE = @WHERE + '
  9831. AND a.dcSalaryID = 100'
  9832. END
  9833. IF @dcSalaryID > 100 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  9834. SET @WHERE = @WHERE + '
  9835. AND a.dcSalaryID=' + LTRIM(STR(@dcSalaryID-100))
  9836. END
  9837. ----工作经验要求
  9838. IF @MinExperience < 100
  9839. SET @WHERE = @WHERE + '
  9840. AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
  9841. ----学历要求
  9842. ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
  9843. IF @dcEducationID > 0
  9844. IF @dcEducationID = 2
  9845. SET @WHERE = @WHERE + '
  9846. AND a.dcEducationID IN(2, 3, 4)'
  9847. ELSE
  9848. SET @WHERE = @WHERE + '
  9849. AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
  9850. ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
  9851. IF LEN(@EmployType) > 0
  9852. SET @WHERE = @WHERE + '
  9853. AND a.EmployType IN (' + @EmployType + ')'
  9854. SET @SQL = @SQL + @FROM + @WHERE
  9855. SET @SQL = @SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
  9856. EXEC(@SQL)
  9857. DECLARE @CurrentCount AS SMALLINT
  9858. DECLARE @NeedCount AS SMALLINT
  9859. SELECT @CurrentCount = COUNT(*) FROM #Job
  9860. IF @CurrentCount < @RowCount
  9861. BEGIN
  9862. SET @NeedCount = @RowCount - @CurrentCount
  9863. ----生成插入临时表的Sql语句
  9864. SET @SQL = '
  9865. INSERT INTO #Job
  9866. SELECT TOP ' + CONVERT(VARCHAR(3),@NeedCount) + ' a.ID, a.dcJobTypeID,
  9867. a.dcJobTypeIDMinor, a.dcSalaryID,
  9868. a.dcRegionID, a.dcEducationID, a.MinExperience,
  9869. a.IssueDate'
  9870. SET @FROM = '
  9871. FROM JobPublish a WITH(NOLOCK)
  9872. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  9873. ----职位有效,单位新有效
  9874. SET @WHERE = '
  9875. WHERE a.Valid = 1
  9876. AND b.Valid = 1 AND a.ID NOT IN(SELECT ID FROM #Job)'
  9877. ----职位类别
  9878. IF LEN(@dcJobTypeID) > 0
  9879. SET @WHERE = @WHERE + '
  9880. AND (a.dcJobTypeID IN(' + @JobType +')
  9881. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  9882. IF LEN(@JobPlace) > 0
  9883. SET @WHERE = @WHERE + '
  9884. AND (' + @JobPlace + ')'
  9885. SET @SQL = @SQL + @FROM + @WHERE
  9886. SET @SQL = @SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
  9887. EXEC(@SQL)
  9888. SELECT @CurrentCount = COUNT(*) FROM #Job
  9889. IF @CurrentCount < @RowCount
  9890. BEGIN
  9891. SET @NeedCount = @RowCount - @CurrentCount
  9892. --将工作地点扩大一级
  9893. DECLARE @T_JobPlaceDistinct AS TABLE(ID INT)
  9894. UPDATE @T_JobPlace SET ID = LEFT(ID,LEN(ID)-2) WHERE LEN(ID) > 2
  9895. INSERT INTO @T_JobPlaceDistinct SELECT DISTINCT ID FROM @T_JobPlace
  9896. SELECT @JobPlace = ''
  9897. SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlaceDistinct
  9898. IF LEN(@JobPlace) > 0
  9899. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  9900. --将职位类别扩大一级
  9901. UPDATE @T_TEMP SET ID = LEFT(ID,LEN(ID)-2) WHERE LEN(ID) > 2
  9902. DELETE FROM @T_JobType
  9903. INSERT INTO @T_JobType
  9904. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  9905. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  9906. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  9907. OR ID IN(SELECT ID FROM @T_TEMP)
  9908. SELECT @JobType = ''
  9909. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  9910. IF RIGHT(@JobType, 1) = ','
  9911. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  9912. ----生成插入临时表的Sql语句
  9913. SET @SQL = '
  9914. INSERT INTO #Job
  9915. SELECT TOP ' + CONVERT(VARCHAR(3),@NeedCount) + ' a.ID, a.dcJobTypeID,
  9916. a.dcJobTypeIDMinor, a.dcSalaryID,
  9917. a.dcRegionID, a.dcEducationID, a.MinExperience,
  9918. a.IssueDate'
  9919. SET @FROM = '
  9920. FROM JobPublish a WITH(NOLOCK)
  9921. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  9922. ----职位有效,单位新有效
  9923. SET @WHERE = '
  9924. WHERE a.Valid = 1
  9925. AND b.Valid = 1 AND a.ID NOT IN(SELECT ID FROM #Job)'
  9926. ----职位类别
  9927. IF LEN(@dcJobTypeID) > 0
  9928. SET @WHERE = @WHERE + '
  9929. AND (a.dcJobTypeID IN(' + @JobType +')
  9930. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  9931. IF LEN(@JobPlace) > 0
  9932. SET @WHERE = @WHERE + '
  9933. AND (' + @JobPlace + ')'
  9934. SET @SQL = @SQL + @FROM + @WHERE
  9935. SET @SQL = @SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
  9936. EXEC(@SQL)
  9937. END
  9938. END
  9939. SELECT TOP 20 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  9940. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  9941. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  9942. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  9943. a.IsDelete, a.AddDate, a.RefreshDate, a.SecondId EnJobID, b.SecondId EnCpMainID,
  9944. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  9945. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  9946. ISNULL((SELECT IsOnline FROM caOnline WHERE caMainId =a.caMainID), 0) AS IsOnline,
  9947. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  9948. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  9949. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry, b.IsRefreshed,
  9950. dbo.GetCaOnlineStatus(a.caMainID) AS IsOnline, CASE WHEN b.ReplyRate >= 0.6 THEN b.ReplyRate ELSE NULL END Replyrate
  9951. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), #Job c WITH(NOLOCK)
  9952. WHERE a.cpMainID = b.ID AND a.ID = c.ID ORDER BY c.RowID
  9953. END
  9954. GO
  9955. /****** Object: StoredProcedure [dbo].[pcJobByRecommendSelectNew] Script Date: 2018/12/13 19:08:38 ******/
  9956. SET ANSI_NULLS ON
  9957. GO
  9958. SET QUOTED_IDENTIFIER ON
  9959. GO
  9960. CREATE PROCEDURE [dbo].[pcJobByRecommendSelectNew]
  9961. (
  9962. @dcJobTypeID VARCHAR(100), --职位类别
  9963. @dcRegionID VARCHAR(100), --求职地区
  9964. @dcIndustryID VARCHAR(100), --求职行业
  9965. @dcSalaryID TINYINT, --月薪
  9966. @MinExperience TINYINT, --工作经验,100为未选择
  9967. @dcEducationID TINYINT, --最低学历
  9968. @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习
  9969. @RowCount SMALLINT --需要显示的行数
  9970. )
  9971. AS
  9972. --INSERT INTO procLog SELECT 'pcJobByRecommendSelectNew', '', GETDATE()
  9973. BEGIN
  9974. SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
  9975. @dcRegionID = RTRIM(dbo.FormatIDS(@dcRegionID)),
  9976. @dcIndustryID = RTRIM(dbo.FormatIDS(@dcIndustryID)),
  9977. @dcSalaryID = ISNULL(@dcSalaryID, 0),
  9978. @MinExperience = ISNULL(@MinExperience, 100),
  9979. @dcEducationID = ISNULL(@dcEducationID, 0),
  9980. @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END
  9981. IF @dcJobTypeID LIKE '%,%,%,%,%,%'
  9982. SET @dcJobTypeID = LEFT(@dcJobTypeID, 2)
  9983. IF @dcRegionID LIKE '%,%,%,%,%,%'
  9984. SET @dcRegionID = LEFT(@dcRegionID, 2)
  9985. IF RIGHT(@dcJobTypeID, 1) = ','
  9986. SET @dcJobTypeID = LEFT(@dcJobTypeID, LEN(@dcJobTypeID) - 1)
  9987. IF RIGHT(@dcRegionID, 1) = ','
  9988. SET @dcRegionID = LEFT(@dcRegionID, LEN(@dcRegionID) - 1)
  9989. IF RIGHT(@dcIndustryID, 1) = ','
  9990. SET @dcIndustryID = LEFT(@dcIndustryID, LEN(@dcIndustryID) - 1)
  9991. ------生成职位类别的表变量,因为职位类别有包含(父子)关系
  9992. DECLARE @T_JobPlace AS TABLE(ID INT)
  9993. DECLARE @T_JobType AS TABLE(ID INT)
  9994. DECLARE @JobType AS VARCHAR(3000)
  9995. DECLARE @JobPlace AS VARCHAR(2000)
  9996. DECLARE @SQL AS NVARCHAR(MAX)
  9997. DECLARE @WHERE AS VARCHAR(8000)
  9998. DECLARE @FROM AS VARCHAR(1000)
  9999. SET @JobPlace = ''
  10000. SET @JobType=''
  10001. ----生成工作地点的表变量
  10002. IF LEN(@dcRegionID) > 0
  10003. BEGIN
  10004. INSERT INTO @T_JobPlace
  10005. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  10006. SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  10007. IF LEN(@JobPlace) > 0
  10008. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  10009. END
  10010. ----生成求聘职位的表变量
  10011. IF LEN(@dcJobTypeID) > 0
  10012. BEGIN
  10013. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  10014. INSERT INTO @T_Temp
  10015. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  10016. INSERT INTO @T_JobType
  10017. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  10018. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  10019. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  10020. OR ID IN(SELECT ID FROM @T_TEMP)
  10021. ----生成in字符串
  10022. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  10023. IF RIGHT(@JobType, 1) = ','
  10024. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  10025. END
  10026. ----建立临时表
  10027. CREATE TABLE #Job(
  10028. RowID INT IDENTITY(1, 1),
  10029. ID INT NOT NULL,
  10030. dcJobTypeID SMALLINT NOT NULL,
  10031. dcJobTypeIDMinor SMALLINT NULL,
  10032. dcSalaryID TINYINT NOT NULL,
  10033. dcRegionID VARCHAR(6) NULL,
  10034. dcEducationID TINYINT NOT NULL,
  10035. MinExperience TINYINT NOT NULL,
  10036. RefreshDate SMALLDATETIME NULL
  10037. )
  10038. ----生成插入临时表的Sql语句
  10039. SET @SQL = '
  10040. INSERT INTO #Job
  10041. SELECT TOP ' + CONVERT(VARCHAR(3),@RowCount) + ' a.ID, a.dcJobTypeID,
  10042. a.dcJobTypeIDMinor, a.dcSalaryID,
  10043. a.dcRegionID, a.dcEducationID, a.MinExperience,
  10044. a.IssueDate'
  10045. SET @FROM = '
  10046. FROM JobPublish a WITH(NOLOCK)
  10047. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  10048. ----职位有效,单位新有效
  10049. IF LEN(@dcIndustryID) > 0
  10050. SET @WHERE = '
  10051. WHERE b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @dcIndustryID + '))
  10052. AND a.Valid = 1
  10053. AND b.Valid = 1'
  10054. ELSE
  10055. SET @WHERE = '
  10056. WHERE a.Valid = 1
  10057. AND b.Valid = 1'
  10058. ----职位类别
  10059. IF LEN(@dcJobTypeID) > 0
  10060. SET @WHERE = @WHERE + '
  10061. AND (a.dcJobTypeID IN(' + @JobType +')
  10062. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  10063. IF LEN(@JobPlace) > 0
  10064. SET @WHERE = @WHERE + '
  10065. AND (' + @JobPlace + ')'
  10066. IF @dcSalaryID > 0
  10067. BEGIN
  10068. IF @dcSalaryID < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
  10069. BEGIN
  10070. SET @WHERE = @WHERE + '
  10071. AND a.dcSalaryID IN(' + LTRIM(STR(@dcSalaryID)) + ',' + LTRIM(STR(@dcSalaryID + 1))
  10072. SET @WHERE = @WHERE + ')'
  10073. END
  10074. IF @dcSalaryID = 100 ----从筛选结果中点击面议,值是100
  10075. BEGIN
  10076. SET @WHERE = @WHERE + '
  10077. AND a.dcSalaryID = 100'
  10078. END
  10079. IF @dcSalaryID > 100 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  10080. SET @WHERE = @WHERE + '
  10081. AND a.dcSalaryID=' + LTRIM(STR(@dcSalaryID-100))
  10082. END
  10083. ----工作经验要求
  10084. IF @MinExperience < 100
  10085. SET @WHERE = @WHERE + '
  10086. AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
  10087. ----学历要求
  10088. ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
  10089. IF @dcEducationID > 0
  10090. IF @dcEducationID = 2
  10091. SET @WHERE = @WHERE + '
  10092. AND a.dcEducationID IN(2, 3, 4)'
  10093. ELSE
  10094. SET @WHERE = @WHERE + '
  10095. AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
  10096. ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
  10097. IF LEN(@EmployType) > 0
  10098. SET @WHERE = @WHERE + '
  10099. AND a.EmployType IN (' + @EmployType + ')'
  10100. SET @SQL = @SQL + @FROM + @WHERE
  10101. SET @SQL = @SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
  10102. EXEC(@SQL)
  10103. DECLARE @CurrentCount AS SMALLINT
  10104. DECLARE @NeedCount AS SMALLINT
  10105. SELECT @CurrentCount = COUNT(*) FROM #Job
  10106. IF @CurrentCount < @RowCount
  10107. BEGIN
  10108. SET @NeedCount = @RowCount - @CurrentCount
  10109. ----生成插入临时表的Sql语句
  10110. SET @SQL = '
  10111. INSERT INTO #Job
  10112. SELECT TOP ' + CONVERT(VARCHAR(3),@NeedCount) + ' a.ID, a.dcJobTypeID,
  10113. a.dcJobTypeIDMinor, a.dcSalaryID,
  10114. a.dcRegionID, a.dcEducationID, a.MinExperience,
  10115. a.IssueDate'
  10116. SET @FROM = '
  10117. FROM JobPublish a WITH(NOLOCK)
  10118. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  10119. ----职位有效,单位新有效
  10120. SET @WHERE = '
  10121. WHERE a.Valid = 1
  10122. AND b.Valid = 1 AND a.ID NOT IN(SELECT ID FROM #Job)'
  10123. ----职位类别
  10124. IF LEN(@dcJobTypeID) > 0
  10125. SET @WHERE = @WHERE + '
  10126. AND (a.dcJobTypeID IN(' + @JobType +')
  10127. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  10128. IF LEN(@JobPlace) > 0
  10129. SET @WHERE = @WHERE + '
  10130. AND (' + @JobPlace + ')'
  10131. SET @SQL = @SQL + @FROM + @WHERE
  10132. SET @SQL = @SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
  10133. EXEC(@SQL)
  10134. SELECT @CurrentCount = COUNT(*) FROM #Job
  10135. IF @CurrentCount < @RowCount
  10136. BEGIN
  10137. SET @NeedCount = @RowCount - @CurrentCount
  10138. --将工作地点扩大一级
  10139. DECLARE @T_JobPlaceDistinct AS TABLE(ID INT)
  10140. UPDATE @T_JobPlace SET ID = LEFT(ID,LEN(ID)-2) WHERE LEN(ID) > 2
  10141. INSERT INTO @T_JobPlaceDistinct SELECT DISTINCT ID FROM @T_JobPlace
  10142. SELECT @JobPlace = ''
  10143. SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlaceDistinct
  10144. IF LEN(@JobPlace) > 0
  10145. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  10146. --将职位类别扩大一级
  10147. UPDATE @T_TEMP SET ID = LEFT(ID,LEN(ID)-2) WHERE LEN(ID) > 2
  10148. DELETE FROM @T_JobType
  10149. INSERT INTO @T_JobType
  10150. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  10151. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  10152. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  10153. OR ID IN(SELECT ID FROM @T_TEMP)
  10154. SELECT @JobType = ''
  10155. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  10156. IF RIGHT(@JobType, 1) = ','
  10157. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  10158. ----生成插入临时表的Sql语句
  10159. SET @SQL = '
  10160. INSERT INTO #Job
  10161. SELECT TOP ' + CONVERT(VARCHAR(3),@NeedCount) + ' a.ID, a.dcJobTypeID,
  10162. a.dcJobTypeIDMinor, a.dcSalaryID,
  10163. a.dcRegionID, a.dcEducationID, a.MinExperience,
  10164. a.IssueDate'
  10165. SET @FROM = '
  10166. FROM JobPublish a WITH(NOLOCK)
  10167. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  10168. ----职位有效,单位新有效
  10169. SET @WHERE = '
  10170. WHERE a.Valid = 1
  10171. AND b.Valid = 1 AND a.ID NOT IN(SELECT ID FROM #Job)'
  10172. ----职位类别
  10173. IF LEN(@dcJobTypeID) > 0
  10174. SET @WHERE = @WHERE + '
  10175. AND (a.dcJobTypeID IN(' + @JobType +')
  10176. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  10177. IF LEN(@JobPlace) > 0
  10178. SET @WHERE = @WHERE + '
  10179. AND (' + @JobPlace + ')'
  10180. SET @SQL = @SQL + @FROM + @WHERE
  10181. SET @SQL = @SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
  10182. EXEC(@SQL)
  10183. END
  10184. END
  10185. SELECT TOP 20 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  10186. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  10187. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  10188. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  10189. a.IsDelete, a.AddDate, a.RefreshDate, a.SecondId EnJobID, b.SecondId EnCpMainID,
  10190. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  10191. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  10192. ISNULL((SELECT IsOnline FROM caOnline WHERE caMainId =a.caMainID), 0) AS IsOnline,
  10193. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  10194. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  10195. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry, b.IsRefreshed,
  10196. dbo.GetCaOnlineStatus(a.caMainID) AS IsOnline
  10197. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), #Job c WITH(NOLOCK)
  10198. WHERE a.cpMainID = b.ID AND a.ID = c.ID ORDER BY c.RowID
  10199. END
  10200. GO
  10201. /****** Object: StoredProcedure [dbo].[pcJobBySearchSelect] Script Date: 2018/12/13 19:08:38 ******/
  10202. SET ANSI_NULLS ON
  10203. GO
  10204. SET QUOTED_IDENTIFIER ON
  10205. GO
  10206. CREATE proCEDURE [dbo].[pcJobBySearchSelect]
  10207. (
  10208. @dcJobTypeID VARCHAR(100), --职位类别
  10209. @dcRegionID VARCHAR(100), --求职地区
  10210. @dcIndustryID VARCHAR(100), --求职行业
  10211. @dcSalaryID TINYINT, --月薪
  10212. @IsNegotiable BIT, --1允许面议,不面议
  10213. @MinExperience TINYINT, --工作经验,100为未选择
  10214. @dcEducationID TINYINT, --最低学历
  10215. @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习,
  10216. @KeyWord NVARCHAR(50), --关键词
  10217. @KeyType TINYINT, --搜索类别,0无;1-全文;2-职位;3-公司
  10218. @ORDER VARCHAR(100), --显示顺序,没有用
  10219. @RefreshNo INT, --1, 1天内;2, 3天内;3,一周内;4,15天内;5,一个月内;6超过一个月
  10220. @Type INT, --1:主动搜索 点击搜索按钮 10分钟,翻页60分钟有效;0:翻页搜索,不刷新
  10221. @PageNumber INT, --翻页页码
  10222. @SessionID varchar(50),
  10223. @CompanySizeID VARCHAR(1), --企业规模
  10224. @JobId INT,
  10225. @Welfare VARCHAR(50),
  10226. @IsOnline BIT --是否在线
  10227. )
  10228. AS
  10229. SET NOCOUNT ON
  10230. INSERT INTO SearchIp(Ip, Source) SELECT @SessionId, 'r'
  10231. DECLARE @CanReturn BIT
  10232. SET @CanReturn = 0
  10233. IF EXISTS(SELECT 'x' FROM RefuseIp WITH(NOLOCK) WHERE CHARINDEX(Ip,@SessionId) > 0)
  10234. SET @CanReturn = 1
  10235. IF CHARINDEX(',0', @dcRegionID) > 0 OR CHARINDEX(',0', @dcJobTypeID) > 0
  10236. OR CHARINDEX(',,', @dcRegionID) > 0 OR CHARINDEX(',,', @dcJobTypeID) > 0
  10237. OR LEN(@dcRegionID) > 35 OR LEN(@dcJobTypeID) > 25
  10238. SET @CanReturn = 1
  10239. IF @CanReturn = 1
  10240. BEGIN
  10241. SELECT 0 ValidJobNumber
  10242. SELECT TOP 0 * FROM JobTemp
  10243. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  10244. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  10245. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  10246. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  10247. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  10248. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  10249. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  10250. --insert into _0 select @SessionId, getdate()
  10251. RETURN
  10252. END
  10253. IF Rand() * 10 > 5 AND (@SessionId LIKE '123.125.71%' OR @SessionId LIKE '220.181.108%')
  10254. BEGIN
  10255. SELECT 0 ValidJobNumber
  10256. SELECT TOP 0 * FROM JobTemp
  10257. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  10258. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  10259. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  10260. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  10261. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  10262. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  10263. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  10264. RETURN
  10265. END
  10266. INSERT INTO SearchDB..paSearchLog(ProcType, SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
  10267. Salary, IsNegotiable, EmployType, CompanySizeID, KeyWord, KeyType, ReuseNumber, Welfare, IsOnline, RefreshNo)
  10268. VALUES('pcJobBySearchSelect', @SessionId, GETDATE(), @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcEducationID, @MinExperience,
  10269. @dcSalaryID, 0, @EmployType, @CompanySizeID, @KeyWord, @KeyType, 0, @Welfare, @IsOnline, @RefreshNo)
  10270. SET @SessionId = 20
  10271. ----------------------20160126 nick 得到 省份、排序
  10272. DECLARE @paMainId INT, @SQL AS VARCHAR(8000)
  10273. SET @paMainId = 0
  10274. BEGIN TRY
  10275. IF @Order LIKE 'r=%'
  10276. SET @KeyType = CONVERT(DECIMAL(4, 2), RIGHT(LEFT(@Order, 5), 3)) * 100
  10277. ELSE
  10278. SET @KeyType = 0
  10279. IF @Order LIKE '%p=%'
  10280. SET @paMainId = RIGHT(@Order, LEN(@Order) - CHARINDEX('p=', @Order) - 1)
  10281. END TRY
  10282. BEGIN CATCH
  10283. SET @KeyType = 0
  10284. END CATCH
  10285. BEGIN TRY
  10286. BEGIN
  10287. IF CHARINDEX('请填写', @Keyword) > 0
  10288. SET @Keyword = ''
  10289. DECLARE @ReuseNumber AS INT, @dcProvinceId INT
  10290. ----给null值变量赋默认值
  10291. IF NOT LEFT(@dcRegionID, 1) = 'p'
  10292. SELECT @dcRegionID = RTRIM(dbo.FormatIDS(@dcRegionID))
  10293. IF @EmployType NOT IN('1', '2', '3', '4')
  10294. SET @EmployType = ''
  10295. SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
  10296. @dcIndustryID = RTRIM(dbo.FormatIDS(@dcIndustryID)),
  10297. @dcSalaryID = ISNULL(@dcSalaryID, 0),
  10298. @MinExperience = ISNULL(@MinExperience, 100),
  10299. @dcEducationID = ISNULL(@dcEducationID, 0),
  10300. @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END,
  10301. @CompanySizeID = ISNULL(@CompanySizeID, '0'),
  10302. @KeyWord = LTRIM(RTRIM(dbo.SafeSQL(ISNULL(@KeyWord, '')))),
  10303. @ORDER = ' ORDER BY a.RefreshDate DESC, a.SecondID DESC',
  10304. @Type = ISNULL(@Type, 0),
  10305. @PageNumber = ISNULL(@PageNumber, 0),
  10306. @Welfare = RTRIM(dbo.FormatIDS(@Welfare)),
  10307. @IsOnline = ISNULL(@IsOnline, 0),
  10308. @ReuseNumber = 0
  10309. IF LEN(@Welfare) > 1
  10310. BEGIN
  10311. DECLARE @wf VARCHAR(50)
  10312. SET @wf = ''
  10313. SELECT @wf = @wf + a + ',' FROM dbo.fnSplit(@Welfare, ',') WHERE a <= 19 AND LEN(a) < 3
  10314. IF LEN(@wf) > 1
  10315. SET @wf = LEFT(@wf, LEN(@wf) - 1)
  10316. SET @Welfare = @wf
  10317. END
  10318. --@RefreshNo = 0选择全部数据,不限制时间
  10319. IF ISNULL(@RefreshNo, 0) > 100
  10320. SELECT @dcProvinceId = @RefreshNo - 100
  10321. ELSE IF ISNULL(@RefreshNo, 0) > 9
  10322. SELECT @dcProvinceId = @RefreshNo
  10323. ELSE
  10324. SELECT @dcProvinceId = 0
  10325. IF RIGHT(@KeyWord, 2) = '公司'
  10326. SET @KeyWord = LEFT(@KeyWord, LEN(@KeyWord) - 2)
  10327. IF RIGHT(@dcJobTypeID, 1) = ','
  10328. SET @dcJobTypeID = LEFT(@dcJobTypeID, LEN(@dcJobTypeID) - 1)
  10329. IF RIGHT(@dcRegionID, 1) = ','
  10330. SET @dcRegionID = LEFT(@dcRegionID, LEN(@dcRegionID) - 1)
  10331. IF RIGHT(@dcIndustryID, 1) = ','
  10332. SET @dcIndustryID = LEFT(@dcIndustryID, LEN(@dcIndustryID) - 1)
  10333. DECLARE @paSearchConditionID AS INT, @MinId AS INT, @PageSize AS TINYINT, @TableID AS TINYINT
  10334. SELECT @paSearchConditionID = 0, @PageSize = 30
  10335. ----搜索1分钟前的数据
  10336. SELECT TOP 1 @paSearchConditionID = ID, @ReuseNumber = ReuseNumber
  10337. FROM SearchDB..paSearchCondition WITH(NOLOCK)
  10338. WHERE JobType = @dcJobTypeID AND IsOnline = @IsOnline AND JobPlace = @dcRegionID
  10339. AND Industry = @dcIndustryID AND Education = @dcEducationID AND Experience = @MinExperience
  10340. AND Salary = @dcSalaryID AND EmployType = @EmployType AND ISNULL(KeyWord, '') = @KeyWord
  10341. AND CompanySizeID = @CompanySizeID AND Welfare = @Welfare AND IsOnline = @IsOnline
  10342. AND LogTime > DATEADD(MINUTE, -1, GETDATE()) AND ReuseNumber > 0
  10343. AND RefreshNo = @RefreshNo AND KeyType = @KeyType AND dcProvinceId = @dcProvinceId
  10344. IF ISNULL(@paSearchConditionID, 0) = 0
  10345. BEGIN
  10346. SET @Type = 1
  10347. GOTO SelectReset --无数据,重新搜索
  10348. END
  10349. ELSE
  10350. BEGIN
  10351. SELECT @TableID = @paSearchConditionID % 4
  10352. GOTO GetRecordSet --从临时结果中提取数据
  10353. END
  10354. END
  10355. SelectReset:
  10356. --从job中搜索数据
  10357. --BEGIN TRAN
  10358. DECLARE @WHERE AS VARCHAR(8000)
  10359. DECLARE @FROM AS VARCHAR(1000)
  10360. ----记录查询条件
  10361. INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
  10362. Salary, IsNegotiable, EmployType, CompanySizeID, KeyWord, KeyType, ReuseNumber, Welfare, IsOnline, RefreshNo, dcProvinceId)
  10363. VALUES(@SessionId, GETDATE(), @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcEducationID, @MinExperience,
  10364. @dcSalaryID, 0, @EmployType, @CompanySizeID, @KeyWord, @KeyType, 0, @Welfare, @IsOnline, @RefreshNo, @dcProvinceId)
  10365. SET @paSearchConditionID = @@IDENTITY
  10366. SELECT @TableID = @paSearchConditionID % 4
  10367. ------生成职位类别的表变量,因为职位类别有包含(父子)关系
  10368. DECLARE @T_JobPlace AS TABLE(ID INT)
  10369. DECLARE @T_JobType AS TABLE(ID INT)
  10370. DECLARE @JobPlaceLen AS INT, @JobTypeLen AS INT
  10371. IF CHARINDEX(',', @dcJobTypeID) > 0
  10372. SET @JobTypeLen = -1
  10373. ELSE
  10374. SET @JobTypeLen = LEN(@dcJobTypeID)
  10375. DECLARE @JobType AS VARCHAR(3000), @JobPlace AS VARCHAR(2000), @ValidJobNumber AS INT
  10376. SELECT @JobPlace = '', @JobType=''
  10377. ----生成工作地点的表变量
  10378. IF LEN(@dcRegionID) > 0
  10379. BEGIN
  10380. IF LEFT(@dcRegionID, 1) = 'p'
  10381. BEGIN
  10382. DECLARE @Degree AS DECIMAL(8,5),@LBLng AS DECIMAL(8,5),@LBLat AS DECIMAL(8,5),
  10383. @RTLng AS DECIMAL(8,5),@RTLat AS DECIMAL(8,5),@Lat AS DECIMAL(8,5),@Lng AS DECIMAL(8,5)
  10384. SELECT @Lat = Lat,@Lng = Lng FROM dcMapPlace WITH(NOLOCK) WHERE ID = RIGHT(@dcRegionID,LEN(@dcRegionID)-1)
  10385. IF @dcRegionID LIKE '3201%'
  10386. SET @Degree = 1000 / 100000.0
  10387. ELSE
  10388. SET @Degree = 2000 / 100000.0
  10389. SET @LBLng = @Lng - @Degree
  10390. SET @LBLat = @Lat - @Degree
  10391. SET @RTLng = @Lng + @Degree
  10392. SET @RTLat = @Lat + @Degree
  10393. SET @JobPlace = 'a.Lng BETWEEN ' + CONVERT(VARCHAR,@LBLng) + ' AND ' + CONVERT(VARCHAR,@RTLng) + '
  10394. AND a.Lat BETWEEN ' + CONVERT(VARCHAR,@LBLat) + ' AND ' + CONVERT(VARCHAR,@RTLat) + '
  10395. AND (a.Lng-' + CONVERT(VARCHAR,@Lng) + ')*(a.Lng-' + CONVERT(VARCHAR,@Lng) + ')+
  10396. (a.Lat-' + CONVERT(VARCHAR,@Lat) + ')*(a.Lat-' + CONVERT(VARCHAR,@Lat) + ')<' + CONVERT(VARCHAR,@Degree*@Degree)
  10397. SELECT @JobPlaceLen = 8
  10398. END
  10399. ELSE IF LEN(@dcRegionID) > 1
  10400. BEGIN
  10401. INSERT INTO @T_JobPlace
  10402. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  10403. WHERE LEN(a) IN(2, 4, 6)
  10404. SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  10405. IF LEN(@JobPlace) > 0
  10406. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  10407. IF (SELECT COUNT(*) FROM @T_JobPlace) > 1
  10408. SET @JobPlaceLen = -1
  10409. ELSE
  10410. SET @JobPlaceLen = LEN(@dcRegionID)
  10411. END
  10412. END
  10413. ELSE
  10414. SELECT @JobPlaceLen = 0
  10415. ----生成求聘职位的表变量
  10416. IF LEN(@dcJobTypeID) > 0
  10417. BEGIN
  10418. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  10419. INSERT INTO @T_Temp
  10420. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  10421. WHERE LEN(a) IN(2, 4)
  10422. INSERT INTO @T_JobType
  10423. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  10424. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  10425. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  10426. OR ID IN(SELECT ID FROM @T_TEMP)
  10427. ----生成in字符串
  10428. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  10429. IF RIGHT(@JobType, 1) = ','
  10430. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  10431. END
  10432. ----建立临时表
  10433. CREATE TABLE #Job(
  10434. RowID INT IDENTITY(1, 1),
  10435. ID INT NOT NULL,
  10436. cpMainId INT,
  10437. dcJobTypeID SMALLINT NOT NULL,
  10438. dcJobTypeIDMinor SMALLINT NULL,
  10439. dcSalaryID TINYINT NOT NULL,
  10440. dcRegionID VARCHAR(6) NULL,
  10441. dcEducationID TINYINT NOT NULL,
  10442. MinExperience TINYINT NOT NULL,
  10443. RefreshDate SMALLDATETIME NULL,
  10444. EmployType TINYINT NULL,
  10445. dcCompanySizeID SMALLINT NULL
  10446. )
  10447. CREATE TABLE #FullText(
  10448. Id INT IDENTITY(1, 1),
  10449. Priority INT,
  10450. JobId INT NOT NULL
  10451. )
  10452. ------刷新时间,根据刷新时间编号计算
  10453. ----生成插入临时表的Sql语句
  10454. SET @SQL='
  10455. INSERT INTO #Job
  10456. SELECT a.ID, a.cpMainId, a.dcJobTypeID, a.dcJobTypeIDMinor, a.dcSalaryID,
  10457. a.dcRegionID, a.dcEducationID, a.MinExperience, a.IssueDate,a.EmployType,b.dcCompanySizeID'
  10458. SET @FROM = '
  10459. FROM JobPublish a WITH(NOLOCK)
  10460. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  10461. ----职位有效,单位新有效
  10462. IF LEN(@dcIndustryID) > 0
  10463. SET @WHERE = '
  10464. WHERE b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @dcIndustryID + '))
  10465. AND a.Valid = 1
  10466. AND b.Valid = 1'
  10467. ELSE
  10468. SET @WHERE = '
  10469. WHERE a.Valid = 1
  10470. AND b.Valid = 1'
  10471. IF @dcProvinceId > 0
  10472. SET @WHERE = @WHERE + ' AND b.dcProvinceId = ' + LTRIM(STR(@dcProvinceId))
  10473. IF @KeyType IN(60, 70, 80, 90, 100)
  10474. SET @WHERE = @WHERE + '
  10475. AND b.ReplyRate >= ' + LEFT(@KeyType / 100.0, 3)
  10476. IF @RefreshNo > 100
  10477. SET @WHERE = @WHERE + '
  10478. AND b.HasEnvironment = 1'
  10479. ----需要增加全文索引的关键字查询
  10480. --SET @KeyWord = dbo.CutWord(@KeyWord)
  10481. ----职位类别
  10482. IF LEN(@dcJobTypeID) > 0 AND @JobType > ''
  10483. BEGIN
  10484. SET @WHERE = @WHERE + '
  10485. AND (a.dcJobTypeID IN(' + @JobType +')
  10486. OR a.dcJobTypeIDMinor IN(' +@JobType + ')'
  10487. IF LEN(@dcJobTypeID) IN(2, 4)
  10488. BEGIN
  10489. DECLARE @JobtypeName NVARCHAR(50)
  10490. SELECT @JobtypeName = Description FROM dcJobType WITH(NOLOCK) WHERE Id = @dcJobTypeID
  10491. IF CHARINDEX('/', @JobtypeName) = 0
  10492. SET @WHERE = @WHERE + '
  10493. OR a.Name LIKE ''%' + @JobtypeName + '%'''
  10494. ELSE
  10495. SET @WHERE = @WHERE + '
  10496. OR a.Name LIKE ''%' + LEFT(@JobtypeName, CHARINDEX('/', @JobtypeName) - 1) + '%'''
  10497. END
  10498. SET @WHERE = @WHERE + ')'
  10499. END
  10500. IF LEN(@JobPlace) > 0
  10501. SET @WHERE = @WHERE + '
  10502. AND (' + @JobPlace + ')'
  10503. IF @dcSalaryID > 0
  10504. BEGIN
  10505. IF @dcSalaryID < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
  10506. SET @WHERE = @WHERE + '
  10507. AND a.dcSalaryID IN(' + LTRIM(STR(@dcSalaryID)) + ',' + LTRIM(STR(@dcSalaryID + 1)) + ')'
  10508. ELSE IF @dcSalaryID = 100 ----从筛选结果中点击面议,值是100
  10509. SET @WHERE = @WHERE + '
  10510. AND a.dcSalaryID = 100'
  10511. ELSE IF @dcSalaryID BETWEEN 101 AND 106 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  10512. SET @WHERE = @WHERE + '
  10513. AND a.dcSalaryID <= ' + LTRIM(STR(@dcSalaryID-99)) + ' AND a.dcSalaryIDMax > ' + LTRIM(STR(@dcSalaryID-100))
  10514. ELSE IF @dcSalaryID BETWEEN 107 AND 113 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  10515. SET @WHERE = @WHERE + '
  10516. AND a.dcSalaryID <= ' + LTRIM(STR(@dcSalaryID - 100)) + ' AND a.dcSalaryIDMax > ' + LTRIM(STR(@dcSalaryID-100))
  10517. ELSE IF @dcSalaryID BETWEEN 114 AND 120
  10518. SET @WHERE = @WHERE + '
  10519. AND a.dcSalaryID < 100 AND a.dcSalaryIDMax > ' + LTRIM(STR(@dcSalaryID - 100))
  10520. END
  10521. ----工作经验要求
  10522. IF @MinExperience < 100
  10523. SET @WHERE = @WHERE + '
  10524. AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
  10525. ----学历要求
  10526. ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
  10527. IF @dcEducationID > 0
  10528. IF @dcEducationID = 2
  10529. SET @WHERE = @WHERE + '
  10530. AND a.dcEducationID IN(2, 3, 4)'
  10531. ELSE
  10532. SET @WHERE = @WHERE + '
  10533. AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
  10534. ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
  10535. IF LEN(@EmployType) > 0
  10536. SET @WHERE = @WHERE + '
  10537. AND a.EmployType IN (' + @EmployType + ')'
  10538. IF @CompanySizeID BETWEEN 1 AND 6
  10539. SET @WHERE = @WHERE + '
  10540. AND b.dcCompanySizeID = ' + LTRIM(STR(@CompanySizeID))
  10541. IF LEN(@Welfare) > 0
  10542. SET @WHERE = @WHERE + '
  10543. AND a.Welfare' + REPLACE(@Welfare, ',', ' = 1 AND a.Welfare') + ' = 1'
  10544. IF @IsOnline = 1
  10545. SET @WHERE = @WHERE + '
  10546. AND a.caMainId IN(SELECT caMainId FROM caOnline WITH(NOLOCK) WHERE IsOnline = 1)'
  10547. IF LEN(@KeyWord) > 1 ----使用全文搜索job和cpmain2个表,经过测试发现union最快
  10548. BEGIN
  10549. IF EXISTS(SELECT TOP 1 'x' FROM cpMainPublish WITH(NOLOCK) WHERE Name = @KeyWord)
  10550. BEGIN
  10551. SET @WHERE = @WHERE + '
  10552. AND b.Name = ''' + @KeyWord + ''''
  10553. SET @SQL = @SQL + @FROM + @WHERE
  10554. END
  10555. ELSE
  10556. BEGIN
  10557. DECLARE @KeyWordTemp NVARCHAR(50)
  10558. SET @KeyWordTemp = REPLACE(@KeyWord, ' ', '%')
  10559. SET @KeyWordTemp = REPLACE(REPLACE(@KeyWordTemp, '(', ''), ')', '')
  10560. IF LEN(@KeyWordTemp) > 1
  10561. BEGIN
  10562. IF @dcProvinceId > 0
  10563. BEGIN
  10564. IF @dcRegionId > '' AND @dcRegionId NOT LIKE '%,%'
  10565. INSERT #FullText
  10566. SELECT TOP 2000 1, b.ID
  10567. FROM cpMainPublish a WITH(NOLOCK),
  10568. JobPublish b WITH(NOLOCK)
  10569. WHERE a.Id = b.cpMainId
  10570. AND CHARINDEX(@KeyWord, b.Name) > 0
  10571. AND a.dcProvinceId = @dcprovinceId
  10572. AND b.dcRegionID LIKE @dcRegionId + '%'
  10573. ORDER BY b.RefreshDate DESC
  10574. ELSE
  10575. INSERT #FullText
  10576. SELECT TOP 2000 1, b.ID
  10577. FROM cpMainPublish a WITH(NOLOCK),
  10578. JobPublish b WITH(NOLOCK)
  10579. WHERE a.Id = b.cpMainId
  10580. AND CHARINDEX(@KeyWord, b.Name) > 0
  10581. AND a.dcProvinceId = @dcprovinceId
  10582. ORDER BY b.RefreshDate DESC
  10583. INSERT #FullText
  10584. SELECT TOP 2000 2, b.ID
  10585. FROM cpMainPublish a WITH(NOLOCK),
  10586. JobPublish b WITH(NOLOCK)
  10587. WHERE a.Id = b.cpMainId
  10588. AND CHARINDEX(@KeyWord, a.Name) > 0
  10589. AND a.dcProvinceId = @dcprovinceId
  10590. ORDER BY b.RefreshDate DESC
  10591. END
  10592. ELSE
  10593. BEGIN
  10594. INSERT #FullText
  10595. SELECT TOP 2000 2, b.ID
  10596. FROM cpMainPublish a WITH(NOLOCK),
  10597. JobPublish b WITH(NOLOCK)
  10598. WHERE a.Id = b.cpMainId
  10599. AND CHARINDEX(@KeyWord, a.Name) > 0
  10600. ORDER BY b.RefreshDate DESC
  10601. INSERT #FullText
  10602. SELECT TOP 2000 1, b.ID
  10603. FROM cpMainPublish a WITH(NOLOCK),
  10604. JobPublish b WITH(NOLOCK)
  10605. WHERE a.Id = b.cpMainId
  10606. AND CHARINDEX(@KeyWord, b.Name) > 0
  10607. ORDER BY b.RefreshDate DESC
  10608. END
  10609. END
  10610. IF (SELECT COUNT(*) FROM #FullText) < 2000
  10611. BEGIN
  10612. INSERT #FullText
  10613. SELECT TOP 5000 3 + RANK, [Key]
  10614. FROM FREETEXTTABLE(cpMainJob, JobName, @KeyWordTemp, 100000) AS KeyJob ORDER BY RANK DESC
  10615. END
  10616. IF (SELECT COUNT(*) FROM #FullText) < 2000
  10617. BEGIN
  10618. INSERT #FullText
  10619. SELECT TOP 5000 3000 + RANK, [Key]
  10620. FROM FREETEXTTABLE(cpMainJob, *, @KeyWordTemp, 100000) AS KeyJob ORDER BY RANK DESC
  10621. END
  10622. DELETE a FROM #FullText a, #FullText b WHERE a.JobId = b.JobId AND a.Priority > b.Priority
  10623. DELETE a FROM #FullText a, #FullText b WHERE a.JobId = b.JobId AND a.Id > b.Id
  10624. --------------------
  10625. SELECT @FROM = @FROM + '
  10626. INNER JOIN #FullText ON a.ID = #FullText.JobId',
  10627. @ORDER = ' ORDER BY #FullText.Priority, a.RefreshDate DESC, a.SecondId DESC'
  10628. SET @SQL = @SQL + @FROM + @WHERE
  10629. END
  10630. END
  10631. ELSE
  10632. SET @SQL = @SQL + @FROM + @WHERE
  10633. SET @SQL = @SQL + @ORDER --' ORDER BY a.RefreshDate DESC, a.ID'
  10634. --原来是ORDER BY a.IssueDate DESC, a.ID,Richard 2011年11月23日17:06分修改
  10635. ----把符合条件的职位全部列出
  10636. --PRINT @SQL
  10637. EXEC(@SQL)
  10638. SET @ValidJobNumber = @@ROWCOUNT
  10639. ----记录查询结果总数
  10640. UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl = @SQL
  10641. WHERE ID=@paSearchConditionID
  10642. IF LEN(@dcJobTypeID) > 0 --IN(2, 4)
  10643. UPDATE #Job SET dcJobTypeId = dcJobTypeIDMinor
  10644. WHERE dcJobTypeID NOT IN(SELECT a FROM dbo.fnSplit(@JobType, ','))
  10645. AND dcJobTypeIDMinor> 0
  10646. ----插入JobType数据
  10647. DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
  10648. DECLARE @sc AS TABLE (
  10649. paSearchConditionID int,
  10650. Title varchar(20),
  10651. TitleID varchar(10),
  10652. TitleValue int
  10653. )
  10654. DECLARE @sc2 AS TABLE (
  10655. paSearchConditionID int,
  10656. Title varchar(20),
  10657. TitleID varchar(10),
  10658. TitleValue int
  10659. )
  10660. IF (@TableID = 0)
  10661. BEGIN
  10662. ----------------------------jobtype
  10663. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  10664. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  10665. FROM #Job WITH(NOLOCK)
  10666. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  10667. ----计算全部某职位类别,2, 4位的数据
  10668. IF @JobTypeLen NOT IN(2, 4)
  10669. BEGIN
  10670. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  10671. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  10672. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  10673. END
  10674. IF @JobTypeLen NOT IN(0, 4)
  10675. BEGIN
  10676. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  10677. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  10678. FROM @sc2 WHERE LEN(TitleId) = 4
  10679. END
  10680. IF @JobTypeLen = -1
  10681. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  10682. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  10683. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  10684. DELETE @sc
  10685. DELETE @sc2
  10686. --------------------------region
  10687. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  10688. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  10689. GROUP BY dcRegionID ORDER BY dcRegionID
  10690. ----计算全部地区,2位的数据
  10691. IF @JobPlaceLen IN(-1, 0)
  10692. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  10693. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  10694. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  10695. IF @JobPlaceLen IN(-1, 2)
  10696. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  10697. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  10698. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  10699. IF @JobPlaceLen IN(-1, 4)
  10700. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  10701. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  10702. FROM @sc2 WHERE LEN(TitleID) = 6
  10703. IF @JobPlaceLen = -1
  10704. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  10705. ELSE
  10706. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  10707. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  10708. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  10709. ----------------------------
  10710. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  10711. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  10712. GROUP BY EmployType ORDER BY EmployType
  10713. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  10714. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*) FROM #Job WITH(NOLOCK)
  10715. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  10716. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  10717. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  10718. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  10719. GROUP BY MinExperience ORDER BY MinExperience
  10720. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  10721. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  10722. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  10723. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  10724. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  10725. GROUP BY dcSalaryID ORDER BY dcSalaryID
  10726. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  10727. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  10728. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  10729. WHERE a.cpMainId = b.cpMainId
  10730. GROUP BY b.dcIndustryId ORDER BY b.dcIndustryId
  10731. IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
  10732. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  10733. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  10734. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  10735. WHERE b.ID = a.JobId
  10736. AND CHARINDEX(@KeyWord, a.JobName) > 0
  10737. ORDER BY a.OrderType, a.OpenDate DESC
  10738. ELSE
  10739. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  10740. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  10741. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  10742. WHERE b.ID = a.JobId
  10743. ORDER BY a.OrderType, a.OpenDate DESC
  10744. SET @TopRows = @@ROWCOUNT
  10745. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  10746. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowId
  10747. SET @AllRows = @@ROWCOUNT
  10748. IF @TopRows = 0 AND @AllRows > 100
  10749. UPDATE SearchDB..paSearchJobID_0 SET IsTop = 1
  10750. WHERE paSearchConditionID = @paSearchConditionID
  10751. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
  10752. END
  10753. ELSE IF (@TableId = 1)
  10754. BEGIN
  10755. ----------------------------jobtype
  10756. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  10757. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  10758. FROM #Job WITH(NOLOCK)
  10759. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  10760. ----计算全部某职位类别,2, 4位的数据
  10761. IF @JobTypeLen NOT IN(2, 4)
  10762. BEGIN
  10763. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  10764. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  10765. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  10766. END
  10767. IF @JobTypeLen NOT IN(0, 4)
  10768. BEGIN
  10769. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  10770. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  10771. FROM @sc2 WHERE LEN(TitleId) = 4
  10772. END
  10773. IF @JobTypeLen = -1
  10774. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  10775. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  10776. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  10777. DELETE @sc
  10778. DELETE @sc2
  10779. --------------------------region
  10780. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  10781. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  10782. GROUP BY dcRegionID ORDER BY dcRegionID
  10783. ----计算全部地区,2位的数据
  10784. IF @JobPlaceLen IN(-1, 0)
  10785. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  10786. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  10787. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  10788. IF @JobPlaceLen IN(-1, 2)
  10789. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  10790. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  10791. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  10792. IF @JobPlaceLen IN(-1, 4)
  10793. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  10794. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  10795. FROM @sc2 WHERE LEN(TitleID) = 6
  10796. IF @JobPlaceLen = -1
  10797. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  10798. ELSE
  10799. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  10800. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  10801. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  10802. ----------------------------
  10803. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  10804. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  10805. GROUP BY dcSalaryID ORDER BY dcSalaryID
  10806. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  10807. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*) FROM #Job WITH(NOLOCK)
  10808. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  10809. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  10810. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  10811. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  10812. GROUP BY MinExperience ORDER BY MinExperience
  10813. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  10814. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  10815. GROUP BY EmployType ORDER BY EmployType
  10816. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  10817. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  10818. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  10819. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  10820. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  10821. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  10822. WHERE a.cpMainId = b.cpMainId
  10823. GROUP BY dcIndustryID ORDER BY dcIndustryID
  10824. IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
  10825. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  10826. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  10827. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  10828. WHERE b.ID = a.JobId
  10829. AND CHARINDEX(@KeyWord, a.JobName) > 0
  10830. ORDER BY a.OrderType, a.OpenDate DESC
  10831. ELSE
  10832. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  10833. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  10834. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  10835. WHERE b.ID = a.JobId
  10836. ORDER BY a.OrderType, a.OpenDate DESC
  10837. SET @TopRows = @@ROWCOUNT
  10838. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  10839. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowId
  10840. SET @AllRows = @@ROWCOUNT
  10841. IF @TopRows = 0 AND @AllRows > 100
  10842. UPDATE SearchDB..paSearchJobID_1 SET IsTop = 1
  10843. WHERE paSearchConditionID = @paSearchConditionID
  10844. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
  10845. END
  10846. ELSE IF (@TableId = 2)
  10847. BEGIN
  10848. ----------------------------jobtype
  10849. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  10850. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  10851. FROM #Job WITH(NOLOCK)
  10852. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  10853. ----计算全部某职位类别,2, 4位的数据
  10854. IF @JobTypeLen NOT IN(2, 4)
  10855. BEGIN
  10856. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  10857. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  10858. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  10859. END
  10860. IF @JobTypeLen NOT IN(0, 4)
  10861. BEGIN
  10862. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  10863. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  10864. FROM @sc2 WHERE LEN(TitleId) = 4
  10865. END
  10866. IF @JobTypeLen = -1
  10867. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  10868. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  10869. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  10870. DELETE @sc
  10871. DELETE @sc2
  10872. --------------------------region
  10873. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  10874. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  10875. GROUP BY dcRegionID ORDER BY dcRegionID
  10876. ----计算全部地区,2位的数据
  10877. IF @JobPlaceLen IN(-1, 0)
  10878. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  10879. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  10880. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  10881. IF @JobPlaceLen IN(-1, 2)
  10882. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  10883. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  10884. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  10885. IF @JobPlaceLen IN(-1, 4)
  10886. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  10887. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  10888. FROM @sc2 WHERE LEN(TitleID) = 6
  10889. IF @JobPlaceLen = -1
  10890. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  10891. ELSE
  10892. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  10893. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  10894. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  10895. ----------------------------
  10896. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  10897. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  10898. GROUP BY dcSalaryID ORDER BY dcSalaryID
  10899. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  10900. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*) FROM #Job WITH(NOLOCK)
  10901. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  10902. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  10903. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  10904. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  10905. GROUP BY MinExperience ORDER BY MinExperience
  10906. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  10907. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  10908. GROUP BY EmployType ORDER BY EmployType
  10909. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  10910. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  10911. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  10912. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  10913. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  10914. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  10915. WHERE a.cpMainId = b.cpMainId
  10916. GROUP BY dcIndustryID ORDER BY dcIndustryID
  10917. IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
  10918. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  10919. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  10920. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  10921. WHERE b.ID = a.JobId
  10922. AND CHARINDEX(@KeyWord, a.JobName) > 0
  10923. ORDER BY a.OrderType, a.OpenDate DESC
  10924. ELSE
  10925. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  10926. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  10927. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  10928. WHERE b.ID = a.JobId
  10929. ORDER BY a.OrderType, a.OpenDate DESC
  10930. SET @TopRows = @@ROWCOUNT
  10931. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  10932. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowId
  10933. SET @AllRows = @@ROWCOUNT
  10934. IF @TopRows = 0 AND @AllRows > 100
  10935. UPDATE SearchDB..paSearchJobID_2 SET IsTop = 1
  10936. WHERE paSearchConditionID = @paSearchConditionID
  10937. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
  10938. END
  10939. ELSE IF (@TableId = 3)
  10940. BEGIN
  10941. ----------------------------jobtype
  10942. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  10943. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  10944. FROM #Job WITH(NOLOCK)
  10945. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  10946. ----计算全部某职位类别,2, 4位的数据
  10947. IF @JobTypeLen NOT IN(2, 4)
  10948. BEGIN
  10949. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  10950. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  10951. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  10952. END
  10953. IF @JobTypeLen NOT IN(0, 4)
  10954. BEGIN
  10955. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  10956. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  10957. FROM @sc2 WHERE LEN(TitleId) = 4
  10958. END
  10959. IF @JobTypeLen = -1
  10960. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  10961. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  10962. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  10963. DELETE @sc
  10964. DELETE @sc2
  10965. --------------------------region
  10966. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  10967. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  10968. GROUP BY dcRegionID ORDER BY dcRegionID
  10969. ----计算全部地区,2位的数据
  10970. IF @JobPlaceLen IN(-1, 0)
  10971. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  10972. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  10973. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  10974. IF @JobPlaceLen IN(-1, 2)
  10975. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  10976. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  10977. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  10978. IF @JobPlaceLen IN(-1, 4)
  10979. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  10980. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  10981. FROM @sc2 WHERE LEN(TitleID) = 6
  10982. IF @JobPlaceLen = -1
  10983. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  10984. ELSE
  10985. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  10986. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  10987. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  10988. ----------------------------
  10989. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  10990. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  10991. GROUP BY dcSalaryID ORDER BY dcSalaryID
  10992. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  10993. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*) FROM #Job WITH(NOLOCK)
  10994. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  10995. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  10996. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  10997. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  10998. GROUP BY MinExperience ORDER BY MinExperience
  10999. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  11000. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  11001. GROUP BY EmployType ORDER BY EmployType
  11002. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  11003. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  11004. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  11005. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  11006. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  11007. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  11008. WHERE a.cpMainId = b.cpMainId
  11009. GROUP BY dcIndustryID ORDER BY dcIndustryID
  11010. IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
  11011. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  11012. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  11013. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  11014. WHERE b.ID = a.JobId
  11015. AND CHARINDEX(@KeyWord, a.JobName) > 0
  11016. ORDER BY a.OrderType, a.OpenDate DESC
  11017. ELSE
  11018. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  11019. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  11020. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  11021. WHERE b.ID = a.JobId
  11022. ORDER BY a.OrderType, a.OpenDate DESC
  11023. SET @TopRows = @@ROWCOUNT
  11024. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  11025. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowId
  11026. SET @AllRows = @@ROWCOUNT
  11027. IF @TopRows = 0 AND @AllRows > 100
  11028. UPDATE SearchDB..paSearchJobID_3 SET IsTop = 1
  11029. WHERE paSearchConditionID = @paSearchConditionID
  11030. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
  11031. END
  11032. DROP TABLE #Job
  11033. DROP TABLE #FullText
  11034. --PRINT 'DROP #JOB ' + CONVERT(VARCHAR(30), GETDATE(), 121)
  11035. --COMMIT
  11036. --GOTO GetRecordSet
  11037. GetRecordSet:
  11038. BEGIN
  11039. ----返回查询数量
  11040. SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
  11041. UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
  11042. ----返回20行查询结果
  11043. IF (@TableID = 0)
  11044. BEGIN
  11045. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  11046. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  11047. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  11048. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  11049. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  11050. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  11051. a.IsDelete, a.AddDate, a.RefreshDate, a.Welfare1, a.Welfare2, a.Welfare3,
  11052. a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8,
  11053. a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13,
  11054. a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18,
  11055. a.Welfare19, a.SecondId EnJobID, b.SecondId EnCpMainID,
  11056. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  11057. b.HasLicence, b.RealName, b.UnLimitedDate, b.BalanceDate, b.Balance,
  11058. 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,
  11059. 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,
  11060. (SELECT TOP 1 ID from paAttention WITH(NOLOCK) WHERE AttentionType=2 AND AttentionID=a.ID AND paMainId = @paMainId) AttentionId
  11061. FROM JobPublish a WITH(NOLOCK)
  11062. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  11063. INNER JOIN SearchDB..paSearchJobID_0 c WITH(NOLOCK) ON a.id = c.JobID
  11064. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  11065. WHERE paSearchConditionID=@paSearchConditionID
  11066. AND c.ID >= @MinId
  11067. ORDER BY c.ID, a.ID DESC
  11068. END
  11069. ELSE IF (@TableID = 1)
  11070. BEGIN
  11071. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  11072. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  11073. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  11074. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  11075. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  11076. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  11077. a.IsDelete, a.AddDate, a.RefreshDate, a.Welfare1, a.Welfare2, a.Welfare3,
  11078. a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8,
  11079. a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13,
  11080. a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18, a.Welfare19,
  11081. a.SecondId EnJobID, b.SecondId EnCpMainID,
  11082. a.LastModifyDate, b.Name cpName, b.dcCompanySizeID,
  11083. b.HasLicence, b.RealName, b.UnLimitedDate, b.BalanceDate, b.Balance,
  11084. 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,
  11085. 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,
  11086. (SELECT TOP 1 ID from paAttention WITH(NOLOCK) WHERE AttentionType=2 AND AttentionID=a.ID AND paMainId = @paMainId) AttentionId
  11087. FROM JobPublish a WITH(NOLOCK)
  11088. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  11089. INNER JOIN SearchDB..paSearchJobID_1 c WITH(NOLOCK) ON a.id = c.JobID
  11090. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  11091. WHERE paSearchConditionID=@paSearchConditionID
  11092. AND c.ID >= @MinId
  11093. ORDER BY c.ID, a.ID DESC
  11094. END
  11095. ELSE IF (@TableID = 2)
  11096. BEGIN
  11097. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  11098. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  11099. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  11100. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  11101. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  11102. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  11103. a.IsDelete, a.AddDate, a.RefreshDate, a.Welfare1, a.Welfare2, a.Welfare3,
  11104. a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8,
  11105. a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13,
  11106. a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18, a.Welfare19,
  11107. a.SecondId EnJobID, b.SecondId EnCpMainID,
  11108. a.LastModifyDate, b.Name cpName, b.dcCompanySizeID,
  11109. b.HasLicence, b.RealName, b.UnLimitedDate, b.BalanceDate, b.Balance,
  11110. 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,
  11111. 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,
  11112. (SELECT TOP 1 ID from paAttention WITH(NOLOCK) WHERE AttentionType=2 AND AttentionID=a.ID AND paMainId = @paMainId) AttentionId
  11113. FROM JobPublish a WITH(NOLOCK)
  11114. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  11115. INNER JOIN SearchDB..paSearchJobID_2 c WITH(NOLOCK) ON a.id = c.JobID
  11116. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  11117. WHERE paSearchConditionID=@paSearchConditionID
  11118. AND c.ID >= @MinId
  11119. ORDER BY c.ID, a.ID DESC
  11120. END
  11121. ELSE IF (@TableID = 3)
  11122. BEGIN
  11123. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  11124. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  11125. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  11126. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  11127. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  11128. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  11129. a.IsDelete, a.AddDate, a.RefreshDate, a.Welfare1, a.Welfare2, a.Welfare3,
  11130. a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8,
  11131. a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13,
  11132. a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18, a.Welfare19,
  11133. a.SecondId EnJobID, b.SecondId EnCpMainID,
  11134. a.LastModifyDate, b.Name cpName, b.dcCompanySizeID,
  11135. b.HasLicence, b.RealName, b.UnLimitedDate, b.BalanceDate, b.Balance,
  11136. 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,
  11137. 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,
  11138. (SELECT TOP 1 ID from paAttention WITH(NOLOCK) WHERE AttentionType=2 AND AttentionID=a.ID AND paMainId = @paMainId) AttentionId
  11139. FROM JobPublish a WITH(NOLOCK)
  11140. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  11141. INNER JOIN SearchDB..paSearchJobID_3 c WITH(NOLOCK) ON a.id = c.JobID
  11142. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  11143. WHERE paSearchConditionID=@paSearchConditionID
  11144. AND c.ID >= @MinId
  11145. ORDER BY c.ID, a.ID DESC
  11146. END
  11147. --RICHARD 2011-7-23 16:51分修改
  11148. ----返回统计数量
  11149. IF @Type=1
  11150. BEGIN
  11151. DECLARE @RegionCount AS INT
  11152. SELECT @RegionCount = -1
  11153. IF CHARINDEX(',', @dcRegionID) = 0 AND LEN(@dcRegionID) > 0
  11154. BEGIN
  11155. IF NOT LEFT(@dcRegionID, 1) = 'p'
  11156. SELECT @RegionCount = COUNT(*) FROM dcRegion WHERE ParentID = @dcRegionID
  11157. END
  11158. IF (@TableID = 0)
  11159. BEGIN
  11160. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  11161. IF @RegionCount = 0
  11162. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  11163. ELSE
  11164. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  11165. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11166. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11167. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11168. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11169. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11170. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Industry' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11171. END
  11172. IF (@TableID = 1)
  11173. BEGIN
  11174. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  11175. IF @RegionCount = 0
  11176. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  11177. ELSE
  11178. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  11179. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11180. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11181. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11182. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11183. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11184. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Industry' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11185. END
  11186. IF (@TableID = 2)
  11187. BEGIN
  11188. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  11189. IF @RegionCount = 0
  11190. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  11191. ELSE
  11192. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  11193. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11194. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11195. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11196. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11197. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11198. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Industry' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11199. END
  11200. IF (@TableID = 3)
  11201. BEGIN
  11202. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  11203. IF @RegionCount = 0
  11204. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  11205. ELSE
  11206. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  11207. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11208. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11209. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11210. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11211. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11212. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Industry' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  11213. END
  11214. END
  11215. --UPDATE SearchDB..paSearchCondition SET SQl=@JobPlaceLen WHERE ID=@paSearchConditionID
  11216. RETURN
  11217. END
  11218. END TRY
  11219. BEGIN CATCH
  11220. ---检查是否已经建立临时表,已经建立则删除
  11221. DECLARE @para VARCHAR(MAX)
  11222. SET @para = '@dcJobTypeID=' + ISNULL(@dcJobTypeID, '') + '|' +
  11223. '@dcRegionID=' + ISNULL(@dcRegionID, '') + '|' +
  11224. '@dcIndustryID=' + ISNULL(@dcIndustryID, '') + '|' +
  11225. '@EmployType=' + ISNULL(@EmployType, '') + '|' +
  11226. '@KeyWord=' + ISNULL(@KeyWord, '') + '|' +
  11227. '@ORDER=' + ISNULL(@ORDER, '') + '|' +
  11228. '@SessionID=' + ISNULL(@SessionID, '') + '|' +
  11229. '@Welfare=' + ISNULL(@Welfare, '')
  11230. INSERT INTO ErrorLog
  11231. SELECT 'p1 ' +ISNULL(error_Message(), ' no msg')+ ' para=' + ISNULL(@Para, 'no para ') + ISNULL(@SQL, ' no sql'), error_number(), error_line(), GETDATE()
  11232. END CATCH
  11233. GO
  11234. /****** Object: StoredProcedure [dbo].[pcJobBySearchSelectHotPlace] Script Date: 2018/12/13 19:08:40 ******/
  11235. SET ANSI_NULLS ON
  11236. GO
  11237. SET QUOTED_IDENTIFIER ON
  11238. GO
  11239. CREATE PROCEDURE [dbo].[pcJobBySearchSelectHotPlace]
  11240. (
  11241. @dcJobTypeID VARCHAR(100), --职位类别
  11242. @dcRegionID VARCHAR(100), --求职地区
  11243. @dcIndustryID VARCHAR(100), --求职行业
  11244. @dcSalaryID TINYINT, --月薪
  11245. @IsNegotiable BIT, --1允许面议,不面议
  11246. @MinExperience TINYINT, --工作经验,100为未选择
  11247. @dcEducationID TINYINT, --最低学历
  11248. @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习,
  11249. @KeyWord NVARCHAR(50), --关键词
  11250. @KeyType TINYINT, --搜索类别,0无;1-全文;2-职位;3-公司
  11251. @ORDER VARCHAR(100), --显示顺序,没有用
  11252. @RefreshNo INT, --1, 1天内;2, 3天内;3,一周内;4,15天内;5,一个月内;6超过一个月
  11253. @Type INT, --1:主动搜索 点击搜索按钮 10分钟,翻页60分钟有效;0:翻页搜索,不刷新
  11254. @PageNumber INT, --翻页页码
  11255. @SessionID INT,
  11256. @CompanySizeID VARCHAR(1), --企业规模
  11257. @JobId INT,
  11258. @Welfare VARCHAR(50) --
  11259. --sessionid,没有采用全部人员共享方式,因为10分钟内,搜索相同条件的可能性很大,
  11260. --而10分钟搜索的用户翻到第二页时内容可能会和第一页一样。这样让用户很难理解。
  11261. --使用SessionID, 可以保证60分钟内查询结果一致。出现不一致的几率很小
  11262. )
  11263. AS
  11264. INSERT proclog SELECT 'pcJobBySearchSelectHotPlace', @dcRegionID, GETDATE()
  11265. --return @SessionId = 15
  11266. SET NOCOUNT ON
  11267. BEGIN TRY
  11268. IF @JobID > 0
  11269. BEGIN
  11270. IF EXISTS(SELECT 'x' FROM JobPublish WITH(NOLOCK) WHERE ID = @JobId AND Valid = 1)
  11271. BEGIN
  11272. SELECT 1
  11273. SELECT a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  11274. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  11275. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  11276. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  11277. a.IsDelete, a.AddDate, a.RefreshDate,
  11278. a.LastModifyDate,a.Welfare1,a.Welfare2,a.Welfare3,
  11279. a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8,
  11280. a.Welfare9,a.Welfare10,a.Welfare11,a.Welfare12,a.Welfare13,
  11281. a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,a.SecondId EnJobID,b.SecondId EnCpMainID,
  11282. b.Name as cpName, b.dcCompanySizeID,
  11283. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance, b.MemberType,
  11284. '' 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,
  11285. 0 IsTop, 0 IsRefreshed, c.IsOnline, c.IsVi, c.ViPlanId, c.InterviewDate
  11286. FROM JobPublish a WITH(NOLOCK)
  11287. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  11288. LEFT Join caOnline c WITH(NOLOCK) ON a.caMainId = c.caMainId
  11289. WHERE a.id = @JobID AND a.Valid = 1 AND b.Valid = 1
  11290. END
  11291. ELSE
  11292. BEGIN
  11293. SELECT 0
  11294. SELECT TOP 0 NULL
  11295. END
  11296. SELECT TOP 0 * FROM SearchDB..paSearchCount WITH(NOLOCK)
  11297. SELECT TOP 0 * FROM SearchDB..paSearchCount WITH(NOLOCK)
  11298. SELECT TOP 0 * FROM SearchDB..paSearchCount WITH(NOLOCK)
  11299. SELECT TOP 0 * FROM SearchDB..paSearchCount WITH(NOLOCK)
  11300. SELECT TOP 0 * FROM SearchDB..paSearchCount WITH(NOLOCK)
  11301. RETURN
  11302. END
  11303. ELSE
  11304. BEGIN
  11305. DECLARE @KeyWordTemp AS NVARCHAR(50), @KeyTypeTemp AS INT, @ReuseNumber AS INT
  11306. ----给null值变量赋默认值
  11307. IF NOT LEFT(@dcRegionID,1) = 'p'
  11308. SELECT @dcRegionID = RTRIM(dbo.FormatIDS(@dcRegionID))
  11309. SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
  11310. @dcIndustryID = RTRIM(dbo.FormatIDS(@dcIndustryID)),
  11311. @dcSalaryID = ISNULL(@dcSalaryID, 0),
  11312. @IsNegotiable = ISNULL(@IsNegotiable, 0),
  11313. @MinExperience = ISNULL(@MinExperience, 100),
  11314. @dcEducationID = ISNULL(@dcEducationID, 0),
  11315. @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END,
  11316. @CompanySizeID = ISNULL(@CompanySizeID, '0'),
  11317. @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, '')),
  11318. @ORDER = ' ORDER BY a.RefreshDate DESC, a.ID', --@ORDER = dbo.SafeSQL(ISNULL(@ORDER, '')),
  11319. @Type = ISNULL(@Type, 0),
  11320. @PageNumber = ISNULL(@PageNumber, 0),
  11321. @KeyType = CASE @KeyWord WHEN NULL THEN 0 ELSE 1 END,
  11322. @Welfare = RTRIM(dbo.FormatIDS(@Welfare))
  11323. IF @dcSalaryID = 0
  11324. SET @IsNegotiable = 0
  11325. --@RefreshNo = 0选择全部数据,不限制时间
  11326. SET @RefreshNo = 0
  11327. IF(@KeyType = 0 AND ISNULL(@dcJobTypeID, '') = '' AND ISNULL(@dcRegionID, '') = '' AND ISNULL(@dcIndustryID, '') = '')
  11328. RETURN
  11329. --如果关键词不为空 查询关键词对应的搜索类型 max 2012-12-25
  11330. IF (@KeyWord IS NOT NULL)
  11331. BEGIN
  11332. SELECT @KeyTypeTemp = @KeyType
  11333. SELECT @KeyType = KeyType
  11334. FROM Searchdb..SearchKeyword WITH(NOLOCK)
  11335. WHERE Keyword = @KeyWord
  11336. -- 如果搜索类型不是职位类别 按照原搜索类型搜索 max 2012-12-25
  11337. IF @KeyType <> 4
  11338. SET @KeyType = @KeyTypeTemp
  11339. IF @KeyWord = ''
  11340. SET @KeyType = 0
  11341. END
  11342. -- 搜索类型4为职业类别
  11343. IF(@KeyType = 4)
  11344. BEGIN
  11345. IF ISNULL(@dcJobTypeID, '') = ''
  11346. BEGIN
  11347. SELECT @dcJobTypeID = ID
  11348. FROM dcJobType WITH(NOLOCK)
  11349. WHERE Description = @KeyWord
  11350. OR DescriptionEng = @KeyWord
  11351. SELECT @KeyWord = '', @KeyType = 0
  11352. END
  11353. ELSE
  11354. SET @KeyType = @KeyTypeTemp
  11355. END
  11356. IF (@KeyWord IS NOT NULL)
  11357. BEGIN
  11358. SET @KeyWordTemp = @KeyWord
  11359. END
  11360. IF LEN(@KeyWordTemp) > 2
  11361. BEGIN
  11362. SET @KeyWordTemp = REPLACE(@KeyWordTemp, '公司', '')
  11363. END
  11364. IF ISNULL(@KeyType, 0) NOT IN (1, 2, 3, 4, 5)
  11365. BEGIN
  11366. SET @KeyType = 0
  11367. SET @KeyWord = ''
  11368. END
  11369. IF RIGHT(@dcJobTypeID, 1) = ','
  11370. SET @dcJobTypeID = LEFT(@dcJobTypeID, LEN(@dcJobTypeID) - 1)
  11371. IF RIGHT(@dcRegionID, 1) = ','
  11372. SET @dcRegionID = LEFT(@dcRegionID, LEN(@dcRegionID) - 1)
  11373. IF RIGHT(@dcIndustryID, 1) = ','
  11374. SET @dcIndustryID = LEFT(@dcIndustryID, LEN(@dcIndustryID) - 1)
  11375. DECLARE @paSearchConditionID AS INT,
  11376. @MinId AS INT,
  11377. @PageSize AS TINYINT,
  11378. @TableID AS TINYINT
  11379. SELECT @paSearchConditionID = 0, @PageSize = 30
  11380. /*, @SessionId = ISNULL(@SessionId, 9908) --每页的行数
  11381. IF @SessionId = 0
  11382. SET @SessionId = 9920
  11383. IF @SessionId = 1
  11384. SET @SessionId = 9921
  11385. IF @SessionId = 11
  11386. SET @SessionId = 9922
  11387. IF @SessionId = 111
  11388. SET @SessionId = 9923
  11389. */
  11390. SET @SessionId = 15
  11391. ----搜索1分钟前的数据
  11392. SELECT TOP 1 @paSearchConditionID = ID,
  11393. @ReuseNumber = ReuseNumber
  11394. FROM SearchDB..paSearchCondition WITH(NOLOCK)
  11395. WHERE JobType=@dcJobTypeID
  11396. AND JobPlace=@dcRegionID AND Industry=@dcIndustryID AND Education=@dcEducationID
  11397. AND Experience=@MinExperience AND Salary=@dcSalaryID AND IsNegotiable=@IsNegotiable
  11398. AND EmployType=@EmployType AND KeyWord=@KeyWord AND KeyType=@KeyType
  11399. AND CompanySizeID = @CompanySizeID AND Welfare = @Welfare
  11400. AND LogTime > DATEADD(MINUTE, -1, GETDATE()) AND ReuseNumber > 0
  11401. AND RefreshNo = 0
  11402. ORDER BY ID DESC
  11403. IF @ReuseNumber = 0
  11404. BEGIN
  11405. SELECT TOP 1 @paSearchConditionID = ID
  11406. FROM SearchDB..paSearchCondition WITH(NOLOCK)
  11407. WHERE JobType=@dcJobTypeID
  11408. AND JobPlace=@dcRegionID AND Industry=@dcIndustryID AND Education=@dcEducationID
  11409. AND Experience=@MinExperience AND Salary=@dcSalaryID AND IsNegotiable=@IsNegotiable
  11410. AND EmployType=@EmployType AND KeyWord=@KeyWord AND KeyType=@KeyType
  11411. AND CompanySizeID = @CompanySizeID AND Welfare = @Welfare
  11412. AND ReuseNumber > 0 AND LogTime > DATEADD(MINUTE, -2, GETDATE())
  11413. AND RefreshNo = 0
  11414. ORDER BY ID DESC
  11415. END
  11416. IF ISNULL(@paSearchConditionID, 0) = 0
  11417. BEGIN
  11418. SET @Type =1
  11419. GOTO SelectReset --无数据,重新搜索
  11420. END
  11421. ELSE
  11422. BEGIN
  11423. SELECT @TableID = @paSearchConditionID % 4
  11424. GOTO GetRecordSet --从临时结果中提取数据
  11425. END
  11426. END
  11427. SelectReset:
  11428. --从job中搜索数据
  11429. BEGIN TRAN
  11430. DECLARE @SQL AS VARCHAR(8000)
  11431. DECLARE @WHERE AS VARCHAR(8000)
  11432. DECLARE @FROM AS VARCHAR(1000)
  11433. ----记录查询条件
  11434. INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
  11435. Salary, IsNegotiable, EmployType, CompanySizeID, KeyWord, KeyType, ReuseNumber, Welfare)
  11436. VALUES(
  11437. @SessionId, GETDATE(), @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcEducationID, @MinExperience,
  11438. @dcSalaryID, @IsNegotiable, @EmployType, @CompanySizeID, @KeyWord, @KeyType, 0, @Welfare)
  11439. SET @paSearchConditionID = @@IDENTITY
  11440. SELECT @TableID = @paSearchConditionID % 4
  11441. ------生成职位类别的表变量,因为职位类别有包含(父子)关系
  11442. DECLARE @T_JobPlace AS TABLE(ID INT)
  11443. DECLARE @T_JobType AS TABLE(ID INT)
  11444. DECLARE @JobType AS VARCHAR(3000), @JobPlace AS VARCHAR(2000), @ValidJobNumber AS INT
  11445. SELECT @JobPlace = '', @JobType=''
  11446. ----生成工作地点的表变量
  11447. IF LEN(@dcRegionID) > 0
  11448. BEGIN
  11449. IF LEFT(@dcRegionID,1) = 'p'
  11450. BEGIN
  11451. DECLARE @Degree AS DECIMAL(8,5),@LBLng AS DECIMAL(8,5),@LBLat AS DECIMAL(8,5),
  11452. @RTLng AS DECIMAL(8,5),@RTLat AS DECIMAL(8,5),@Lat AS DECIMAL(8,5),@Lng AS DECIMAL(8,5)
  11453. SELECT @Lat = Lat,@Lng = Lng FROM dcMapPlace WITH(NOLOCK) WHERE ID = RIGHT(@dcRegionID,LEN(@dcRegionID)-1)
  11454. IF @dcRegionID LIKE '3201%'
  11455. SET @Degree = 1000 / 100000.0
  11456. ELSE
  11457. SET @Degree = 2000 / 100000.0
  11458. SET @LBLng = @Lng - @Degree
  11459. SET @LBLat = @Lat - @Degree
  11460. SET @RTLng = @Lng + @Degree
  11461. SET @RTLat = @Lat + @Degree
  11462. SET @JobPlace = 'a.Lng BETWEEN ' + CONVERT(VARCHAR,@LBLng) + ' AND ' + CONVERT(VARCHAR,@RTLng) + '
  11463. AND a.Lat BETWEEN ' + CONVERT(VARCHAR,@LBLat) + ' AND ' + CONVERT(VARCHAR,@RTLat) + '
  11464. AND (a.Lng-' + CONVERT(VARCHAR,@Lng) + ')*(a.Lng-' + CONVERT(VARCHAR,@Lng) + ')+
  11465. (a.Lat-' + CONVERT(VARCHAR,@Lat) + ')*(a.Lat-' + CONVERT(VARCHAR,@Lat) + ')<' + CONVERT(VARCHAR,@Degree*@Degree)
  11466. END
  11467. ELSE
  11468. BEGIN
  11469. INSERT INTO @T_JobPlace
  11470. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  11471. SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  11472. IF LEN(@JobPlace) > 0
  11473. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  11474. END
  11475. END
  11476. ----生成求聘职位的表变量
  11477. IF LEN(@dcJobTypeID) > 0
  11478. BEGIN
  11479. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  11480. INSERT INTO @T_Temp
  11481. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  11482. INSERT INTO @T_JobType
  11483. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  11484. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  11485. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  11486. OR ID IN(SELECT ID FROM @T_TEMP)
  11487. ----生成in字符串
  11488. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  11489. IF RIGHT(@JobType, 1) = ','
  11490. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  11491. END
  11492. ----建立临时表
  11493. CREATE TABLE #Job(
  11494. RowID INT IDENTITY(1, 1),
  11495. ID INT NOT NULL,
  11496. dcJobTypeID SMALLINT NOT NULL,
  11497. dcJobTypeIDMinor SMALLINT NULL,
  11498. dcSalaryID TINYINT NOT NULL,
  11499. dcRegionID VARCHAR(6) NULL,
  11500. dcEducationID TINYINT NOT NULL,
  11501. MinExperience TINYINT NOT NULL,
  11502. RefreshDate SMALLDATETIME NULL,
  11503. EmployType TINYINT NULL,
  11504. dcCompanySizeID SMALLINT NULL
  11505. )
  11506. CREATE TABLE #FullText(
  11507. Priority INT,
  11508. JobId INT NOT NULL
  11509. )
  11510. ------刷新时间,根据刷新时间编号计算
  11511. ----生成插入临时表的Sql语句
  11512. SET @SQL='
  11513. INSERT INTO #Job
  11514. SELECT a.ID, a.dcJobTypeID,
  11515. a.dcJobTypeIDMinor, a.dcSalaryID,
  11516. a.dcRegionID, a.dcEducationID, a.MinExperience,
  11517. a.IssueDate,a.EmployType,b.dcCompanySizeID'
  11518. SET @FROM = '
  11519. FROM JobPublish a WITH(NOLOCK)
  11520. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  11521. ----职位有效,单位新有效
  11522. IF LEN(@dcIndustryID) > 0
  11523. SET @WHERE = '
  11524. WHERE b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @dcIndustryID + '))
  11525. AND a.Valid = 1
  11526. AND b.Valid = 1'
  11527. ELSE
  11528. SET @WHERE = '
  11529. WHERE a.Valid = 1
  11530. AND b.Valid = 1'
  11531. ----需要增加全文索引的关键字查询
  11532. IF @KeyWord LIKE '% %'
  11533. BEGIN
  11534. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  11535. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  11536. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  11537. SET @KeyWord = '"' + REPLACE(@KeyWord, ' ', '" OR "') + '"'
  11538. END
  11539. IF @KeyWordTemp LIKE '% %'
  11540. BEGIN
  11541. SET @KeyWordTemp = REPLACE(@KeyWordTemp, ' ', ' ')
  11542. SET @KeyWordTemp = REPLACE(@KeyWordTemp, ' ', ' ')
  11543. SET @KeyWordTemp = REPLACE(@KeyWordTemp, ' ', ' ')
  11544. SET @KeyWordTemp = '"' + REPLACE(@KeyWordTemp, ' ', '" OR "') + '"'
  11545. END
  11546. ----职位类别
  11547. IF LEN(@dcJobTypeID) > 0
  11548. SET @WHERE = @WHERE + '
  11549. AND (a.dcJobTypeID IN(' + @JobType +')
  11550. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  11551. IF LEN(@JobPlace) > 0
  11552. SET @WHERE = @WHERE + '
  11553. AND (' + @JobPlace + ')'
  11554. IF @dcSalaryID > 0
  11555. BEGIN
  11556. IF @dcSalaryID < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
  11557. BEGIN
  11558. SET @WHERE = @WHERE + '
  11559. AND a.dcSalaryID IN(' + LTRIM(STR(@dcSalaryID)) + ',' + LTRIM(STR(@dcSalaryID + 1))
  11560. IF @IsNegotiable = 1 --包括面议
  11561. SET @WHERE = @WHERE + ', 100'
  11562. SET @WHERE = @WHERE + ')'
  11563. END
  11564. IF @dcSalaryID = 100 ----从筛选结果中点击面议,值是100
  11565. BEGIN
  11566. SET @WHERE = @WHERE + '
  11567. AND a.dcSalaryID = 100'
  11568. END
  11569. IF @dcSalaryID > 100 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  11570. SET @WHERE = @WHERE + '
  11571. AND a.dcSalaryID=' + LTRIM(STR(@dcSalaryID-100))
  11572. END
  11573. ----工作经验要求
  11574. IF @MinExperience < 100
  11575. SET @WHERE = @WHERE + '
  11576. AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
  11577. ----学历要求
  11578. ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
  11579. IF @dcEducationID > 0
  11580. IF @dcEducationID = 2
  11581. SET @WHERE = @WHERE + '
  11582. AND a.dcEducationID IN(2, 3, 4)'
  11583. ELSE
  11584. SET @WHERE = @WHERE + '
  11585. AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
  11586. ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
  11587. IF LEN(@EmployType) > 0
  11588. SET @WHERE = @WHERE + '
  11589. AND a.EmployType IN (' + @EmployType + ')'
  11590. IF @CompanySizeID BETWEEN 1 AND 6
  11591. SET @WHERE = @WHERE + '
  11592. AND b.dcCompanySizeID = ' + LTRIM(STR(@CompanySizeID))
  11593. IF LEN(@Welfare) > 0
  11594. SET @WHERE = @WHERE + '
  11595. AND a.Welfare' + REPLACE(@Welfare, ',', ' = 1 AND a.Welfare') + ' = 1'
  11596. IF LEN(@KeyWord) > 0 AND @KeyType > 0 ----使用全文搜索job和cpmain2个表,经过测试发现union最快
  11597. BEGIN
  11598. IF EXISTS(SELECT TOP 1 'x' FROM cpMainPublish WITH(NOLOCK) WHERE Name = @KeyWord)
  11599. BEGIN
  11600. SET @WHERE = @WHERE + '
  11601. AND b.Name = ''' + @KeyWord + ''''
  11602. SET @SQL = @SQL + @FROM + @WHERE
  11603. END
  11604. ELSE
  11605. BEGIN
  11606. INSERT #FullText
  11607. SELECT 1, [Key]
  11608. FROM CONTAINSTABLE(JobPublish, Name, @KeyWord, 100000) AS KeyJob
  11609. INSERT #FullText
  11610. SELECT 2, a.ID
  11611. FROM JobPublish a WITH(NOLOCK),
  11612. CONTAINSTABLE(cpMainPublish, Name, @KeyWord, 100000) AS b
  11613. WHERE a.cpMainId = b.[Key]
  11614. DELETE #FullText WHERE Priority = 2 AND JobId IN(SELECT JobId FROM #FullText WHERE Priority = 1)
  11615. IF (SELECT COUNT(*) FROM #FullText) < 5000
  11616. BEGIN
  11617. INSERT #FullText
  11618. SELECT 3, [Key]
  11619. FROM CONTAINSTABLE(JobPublish, *, @KeyWord, 100000) AS KeyJob
  11620. DELETE #FullText WHERE Priority = 3 AND JobId IN(SELECT JobId FROM #FullText WHERE Priority < 3)
  11621. IF (SELECT COUNT(*) FROM #FullText) < 5000
  11622. BEGIN
  11623. INSERT #FullText
  11624. SELECT 4, a.ID
  11625. FROM JobPublish a WITH(NOLOCK),
  11626. CONTAINSTABLE(cpMainPublish, *, @KeyWord, 100000) AS b
  11627. WHERE a.cpMainId = b.[Key]
  11628. DELETE #FullText WHERE Priority = 4 AND JobId IN(SELECT JobId FROM #FullText WHERE Priority < 4)
  11629. END
  11630. END
  11631. --------------------
  11632. SELECT @FROM = @FROM + '
  11633. INNER JOIN #FullText ON a.ID = #FullText.JobId',
  11634. @ORDER = ' ORDER BY #FullText.Priority, a.RefreshDate DESC, a.ID'
  11635. SET @SQL = @SQL + @FROM + @WHERE
  11636. END
  11637. END
  11638. ELSE
  11639. SET @SQL = @SQL + @FROM + @WHERE
  11640. SET @SQL = @SQL + @ORDER --' ORDER BY a.RefreshDate DESC, a.ID'
  11641. --原来是ORDER BY a.IssueDate DESC, a.ID,Richard 2011年11月23日17:06分修改
  11642. ----把符合条件的职位全部列出
  11643. --PRINT @SQL
  11644. EXEC(@SQL)
  11645. SET @ValidJobNumber = @@ROWCOUNT
  11646. ----记录查询结果总数
  11647. UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@SQL WHERE ID=@paSearchConditionID
  11648. IF LEN(@dcJobTypeID) > 0 --IN(2, 4)
  11649. UPDATE #Job SET dcJobTypeId = dcJobTypeIDMinor
  11650. WHERE dcJobTypeID NOT IN(SELECT a FROM dbo.fnSplit(@JobType, ','))
  11651. ----插入JobType数据
  11652. DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
  11653. IF (@TableID = 0)
  11654. BEGIN
  11655. --IF LEN(@dcJobTypeID) IN(2, 4)
  11656. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  11657. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  11658. -- WHERE dcJobTypeID LIKE @dcJobTypeID + '%'
  11659. -- OR dcJobTypeIDMinor LIKE @dcJobTypeID + '%'
  11660. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  11661. --ELSE
  11662. -- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  11663. -- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  11664. -- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  11665. ----计算全部某职位类别,2, 4位的数据
  11666. UPDATE a SET a.TitleValue = b.TitleValue
  11667. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
  11668. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  11669. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  11670. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  11671. GROUP BY LEFT(TitleID, 2)) b
  11672. WHERE a.TitleId = b.TitleID
  11673. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  11674. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  11675. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  11676. GROUP BY EmployType ORDER BY EmployType
  11677. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  11678. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  11679. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  11680. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  11681. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  11682. GROUP BY dcSalaryID ORDER BY dcSalaryID
  11683. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  11684. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  11685. GROUP BY dcRegionID ORDER BY dcRegionID
  11686. ----计算全部地区,2位的数据
  11687. UPDATE a SET a.TitleValue = b.TitleValue
  11688. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
  11689. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  11690. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  11691. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  11692. GROUP BY LEFT(TitleID, 2)) b
  11693. WHERE a.TitleId = b.TitleID
  11694. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  11695. ----计算全部地区,4位的数据
  11696. UPDATE a SET a.TitleValue = b.TitleValue
  11697. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), (
  11698. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  11699. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  11700. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  11701. AND LEN(TitleID) >3
  11702. GROUP BY LEFT(TitleID, 4)) b
  11703. WHERE a.TitleId = b.TitleID
  11704. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  11705. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  11706. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  11707. GROUP BY dcEducationID ORDER BY dcEducationID
  11708. --学历 高中、中专、中级合并
  11709. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  11710. WHERE paSearchConditionID = @paSearchConditionID
  11711. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  11712. IF @TitleValue IS NOT NULL
  11713. BEGIN
  11714. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  11715. UPDATE SearchDB..paSearchCount_0 SET TitleValue = @TitleValue
  11716. WHERE paSearchConditionID = @paSearchConditionID
  11717. AND Title = 'Education' AND TitleID = 2
  11718. ELSE
  11719. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  11720. (@paSearchConditionID, 'Education', 2, @TitleValue)
  11721. DELETE FROM SearchDB..paSearchCount_0
  11722. WHERE paSearchConditionID = @paSearchConditionID
  11723. AND Title = 'Education' AND TitleID IN(3, 4)
  11724. END
  11725. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  11726. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  11727. GROUP BY MinExperience ORDER BY MinExperience
  11728. /* ----写入TitleDesc
  11729. UPDATE a SET a.TitleDesc = b.Description
  11730. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcEducation b WITH(NOLOCK)
  11731. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  11732. AND a.Title = 'Education'
  11733. UPDATE a SET a.TitleDesc = b.Description
  11734. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  11735. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  11736. AND a.Title = 'Region'
  11737. UPDATE a SET a.TitleDesc = b.Description
  11738. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  11739. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  11740. AND a.Title = 'JobType'
  11741. UPDATE a SET a.TitleDesc = b.Description
  11742. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcSalary b WITH(NOLOCK)
  11743. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  11744. AND a.Title = 'Salary'
  11745. UPDATE a SET a.TitleDesc = b.Description
  11746. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcCompanySize b WITH(NOLOCK)
  11747. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  11748. AND a.Title = 'CompanySize'
  11749. UPDATE a SET a.TitleDesc = b.Description
  11750. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcCompanySize b WITH(NOLOCK)
  11751. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  11752. AND a.Title = 'CompanySize'
  11753. UPDATE SearchDB..paSearchCount_0 SET TitleDesc =
  11754. CASE TitleID
  11755. WHEN 0 THEN '不限'
  11756. WHEN 1 THEN '1~2年'
  11757. WHEN 2 THEN '3~5年'
  11758. WHEN 3 THEN '6~10年'
  11759. WHEN 4 THEN '10年以上'
  11760. WHEN 5 THEN '应届毕业生'
  11761. END
  11762. WHERE paSearchConditionID = @paSearchConditionID
  11763. AND Title = 'Experience'
  11764. UPDATE SearchDB..paSearchCount_0 SET TitleDesc =
  11765. CASE TitleID
  11766. WHEN 1 THEN '全职'
  11767. WHEN 3 THEN '兼职'
  11768. WHEN 4 THEN '实习'
  11769. END
  11770. WHERE paSearchConditionID = @paSearchConditionID
  11771. AND Title = 'EmployType'
  11772. */
  11773. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  11774. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  11775. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  11776. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  11777. SET @TopRows = @@ROWCOUNT
  11778. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  11779. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  11780. SET @AllRows = @@ROWCOUNT
  11781. IF @TopRows = 0 AND @AllRows > 100
  11782. UPDATE SearchDB..paSearchJobID_0 SET IsTop = 1
  11783. WHERE paSearchConditionID = @paSearchConditionID
  11784. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  11785. END
  11786. ELSE IF (@TableId = 1)
  11787. BEGIN
  11788. --IF LEN(@dcJobTypeID) IN(2, 4)
  11789. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  11790. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  11791. -- WHERE dcJobTypeID LIKE @dcJobTypeID + '%'
  11792. -- OR dcJobTypeIDMinor LIKE @dcJobTypeID + '%'
  11793. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  11794. --ELSE
  11795. -- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  11796. -- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  11797. -- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  11798. ----计算全部某职位类别,2, 4位的数据
  11799. UPDATE a SET a.TitleValue = b.TitleValue
  11800. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
  11801. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  11802. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  11803. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  11804. GROUP BY LEFT(TitleID, 2)) b
  11805. WHERE a.TitleId = b.TitleID
  11806. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  11807. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  11808. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  11809. GROUP BY dcSalaryID ORDER BY dcSalaryID
  11810. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  11811. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  11812. GROUP BY dcRegionID ORDER BY dcRegionID
  11813. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  11814. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  11815. GROUP BY EmployType ORDER BY EmployType
  11816. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  11817. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  11818. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  11819. ----计算全部地区,2位的数据
  11820. UPDATE a SET a.TitleValue = b.TitleValue
  11821. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
  11822. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  11823. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  11824. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  11825. GROUP BY LEFT(TitleID, 2)) b
  11826. WHERE a.TitleId = b.TitleID
  11827. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  11828. ----计算全部地区,4位的数据
  11829. UPDATE a SET a.TitleValue = b.TitleValue
  11830. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), (
  11831. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  11832. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  11833. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  11834. AND LEN(TitleID) >3
  11835. GROUP BY LEFT(TitleID, 4)) b
  11836. WHERE a.TitleId = b.TitleID
  11837. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  11838. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  11839. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  11840. GROUP BY dcEducationID ORDER BY dcEducationID
  11841. --学历 高中、中专、中级合并
  11842. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  11843. WHERE paSearchConditionID = @paSearchConditionID
  11844. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  11845. IF @TitleValue IS NOT NULL
  11846. BEGIN
  11847. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  11848. UPDATE SearchDB..paSearchCount_1 SET TitleValue = @TitleValue
  11849. WHERE paSearchConditionID = @paSearchConditionID
  11850. AND Title = 'Education' AND TitleID = 2
  11851. ELSE
  11852. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  11853. (@paSearchConditionID, 'Education', 2, @TitleValue)
  11854. DELETE FROM SearchDB..paSearchCount_1
  11855. WHERE paSearchConditionID = @paSearchConditionID
  11856. AND Title = 'Education' AND TitleID IN(3, 4)
  11857. END
  11858. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  11859. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  11860. GROUP BY MinExperience ORDER BY MinExperience
  11861. /* ----写入TitleDesc
  11862. UPDATE a SET a.TitleDesc = b.Description
  11863. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcEducation b WITH(NOLOCK)
  11864. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  11865. AND a.Title = 'Education'
  11866. UPDATE a SET a.TitleDesc = b.Description
  11867. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  11868. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  11869. AND a.Title = 'Region'
  11870. UPDATE a SET a.TitleDesc = b.Description
  11871. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  11872. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  11873. AND a.Title = 'JobType'
  11874. UPDATE a SET a.TitleDesc = b.Description
  11875. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcSalary b WITH(NOLOCK)
  11876. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  11877. AND a.Title = 'Salary'
  11878. UPDATE a SET a.TitleDesc = b.Description
  11879. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcCompanySize b WITH(NOLOCK)
  11880. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  11881. AND a.Title = 'CompanySize'
  11882. UPDATE a SET a.TitleDesc = b.Description
  11883. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcCompanySize b WITH(NOLOCK)
  11884. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  11885. AND a.Title = 'CompanySize'
  11886. UPDATE SearchDB..paSearchCount_1 SET TitleDesc =
  11887. CASE TitleID
  11888. WHEN 0 THEN '不限'
  11889. WHEN 1 THEN '1~2年'
  11890. WHEN 2 THEN '3~5年'
  11891. WHEN 3 THEN '6~10年'
  11892. WHEN 4 THEN '10年以上'
  11893. WHEN 5 THEN '应届毕业生'
  11894. END
  11895. WHERE paSearchConditionID = @paSearchConditionID
  11896. AND Title = 'Experience'
  11897. UPDATE SearchDB..paSearchCount_1 SET TitleDesc =
  11898. CASE TitleID
  11899. WHEN 1 THEN '全职'
  11900. WHEN 3 THEN '兼职'
  11901. WHEN 4 THEN '实习'
  11902. END
  11903. WHERE paSearchConditionID = @paSearchConditionID
  11904. AND Title = 'EmployType'
  11905. */
  11906. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  11907. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  11908. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  11909. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  11910. SET @TopRows = @@ROWCOUNT
  11911. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  11912. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  11913. SET @AllRows = @@ROWCOUNT
  11914. IF @TopRows = 0 AND @AllRows > 100
  11915. UPDATE SearchDB..paSearchJobID_1 SET IsTop = 1
  11916. WHERE paSearchConditionID = @paSearchConditionID
  11917. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  11918. END
  11919. ELSE IF (@TableId = 2)
  11920. BEGIN
  11921. --IF LEN(@dcJobTypeID) IN(2, 4)
  11922. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  11923. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  11924. -- WHERE dcJobTypeID LIKE @dcJobTypeID + '%'
  11925. -- OR dcJobTypeIDMinor LIKE @dcJobTypeID + '%'
  11926. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  11927. --ELSE
  11928. -- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  11929. -- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  11930. -- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  11931. ----计算全部某职位类别,2, 4位的数据
  11932. UPDATE a SET a.TitleValue = b.TitleValue
  11933. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
  11934. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  11935. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  11936. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  11937. GROUP BY LEFT(TitleID, 2)) b
  11938. WHERE a.TitleId = b.TitleID
  11939. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  11940. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  11941. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  11942. GROUP BY dcSalaryID ORDER BY dcSalaryID
  11943. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  11944. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  11945. GROUP BY EmployType ORDER BY EmployType
  11946. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  11947. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  11948. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  11949. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  11950. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  11951. GROUP BY dcRegionID ORDER BY dcRegionID
  11952. ----计算全部地区,2位的数据
  11953. UPDATE a SET a.TitleValue = b.TitleValue
  11954. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
  11955. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  11956. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  11957. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  11958. GROUP BY LEFT(TitleID, 2)) b
  11959. WHERE a.TitleId = b.TitleID
  11960. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  11961. ----计算全部地区,4位的数据
  11962. UPDATE a SET a.TitleValue = b.TitleValue
  11963. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), (
  11964. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  11965. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  11966. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  11967. AND LEN(TitleID) >3
  11968. GROUP BY LEFT(TitleID, 4)) b
  11969. WHERE a.TitleId = b.TitleID
  11970. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  11971. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  11972. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  11973. GROUP BY dcEducationID ORDER BY dcEducationID
  11974. --学历 高中、中专、中级合并
  11975. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  11976. WHERE paSearchConditionID = @paSearchConditionID
  11977. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  11978. IF @TitleValue IS NOT NULL
  11979. BEGIN
  11980. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  11981. UPDATE SearchDB..paSearchCount_2 SET TitleValue = @TitleValue
  11982. WHERE paSearchConditionID = @paSearchConditionID
  11983. AND Title = 'Education' AND TitleID = 2
  11984. ELSE
  11985. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  11986. (@paSearchConditionID, 'Education', 2, @TitleValue)
  11987. DELETE FROM SearchDB..paSearchCount_2
  11988. WHERE paSearchConditionID = @paSearchConditionID
  11989. AND Title = 'Education' AND TitleID IN(3, 4)
  11990. END
  11991. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  11992. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  11993. GROUP BY MinExperience ORDER BY MinExperience
  11994. /* ----写入TitleDesc
  11995. UPDATE a SET a.TitleDesc = b.Description
  11996. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcEducation b WITH(NOLOCK)
  11997. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  11998. AND a.Title = 'Education'
  11999. UPDATE a SET a.TitleDesc = b.Description
  12000. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  12001. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  12002. AND a.Title = 'Region'
  12003. UPDATE a SET a.TitleDesc = b.Description
  12004. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  12005. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  12006. AND a.Title = 'JobType'
  12007. UPDATE a SET a.TitleDesc = b.Description
  12008. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcSalary b WITH(NOLOCK)
  12009. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  12010. AND a.Title = 'Salary'
  12011. UPDATE a SET a.TitleDesc = b.Description
  12012. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcCompanySize b WITH(NOLOCK)
  12013. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  12014. AND a.Title = 'CompanySize'
  12015. UPDATE a SET a.TitleDesc = b.Description
  12016. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcCompanySize b WITH(NOLOCK)
  12017. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  12018. AND a.Title = 'CompanySize'
  12019. UPDATE SearchDB..paSearchCount_2 SET TitleDesc =
  12020. CASE TitleID
  12021. WHEN 0 THEN '不限'
  12022. WHEN 1 THEN '1~2年'
  12023. WHEN 2 THEN '3~5年'
  12024. WHEN 3 THEN '6~10年'
  12025. WHEN 4 THEN '10年以上'
  12026. WHEN 5 THEN '应届毕业生'
  12027. END
  12028. WHERE paSearchConditionID = @paSearchConditionID
  12029. AND Title = 'Experience'
  12030. UPDATE SearchDB..paSearchCount_2 SET TitleDesc =
  12031. CASE TitleID
  12032. WHEN 1 THEN '全职'
  12033. WHEN 3 THEN '兼职'
  12034. WHEN 4 THEN '实习'
  12035. END
  12036. WHERE paSearchConditionID = @paSearchConditionID
  12037. AND Title = 'EmployType'
  12038. */
  12039. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  12040. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  12041. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  12042. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  12043. SET @TopRows = @@ROWCOUNT
  12044. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  12045. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  12046. SET @AllRows = @@ROWCOUNT
  12047. IF @TopRows = 0 AND @AllRows > 100
  12048. UPDATE SearchDB..paSearchJobID_2 SET IsTop = 1
  12049. WHERE paSearchConditionID = @paSearchConditionID
  12050. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  12051. END
  12052. ELSE IF (@TableId = 3)
  12053. BEGIN
  12054. --IF LEN(@dcJobTypeID) IN(2, 4)
  12055. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12056. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  12057. -- WHERE dcJobTypeID LIKE @dcJobTypeID + '%'
  12058. -- OR dcJobTypeIDMinor LIKE @dcJobTypeID + '%'
  12059. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  12060. --ELSE
  12061. -- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12062. -- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  12063. -- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  12064. ----计算全部某职位类别,2, 4位的数据
  12065. UPDATE a SET a.TitleValue = b.TitleValue
  12066. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
  12067. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  12068. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  12069. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  12070. GROUP BY LEFT(TitleID, 2)) b
  12071. WHERE a.TitleId = b.TitleID
  12072. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  12073. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12074. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  12075. GROUP BY dcSalaryID ORDER BY dcSalaryID
  12076. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12077. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  12078. GROUP BY EmployType ORDER BY EmployType
  12079. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12080. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  12081. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  12082. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12083. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  12084. GROUP BY dcRegionID ORDER BY dcRegionID
  12085. ----计算全部地区,2位的数据
  12086. UPDATE a SET a.TitleValue = b.TitleValue
  12087. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
  12088. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  12089. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  12090. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  12091. GROUP BY LEFT(TitleID, 2)) b
  12092. WHERE a.TitleId = b.TitleID
  12093. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  12094. ----计算全部地区,4位的数据
  12095. UPDATE a SET a.TitleValue = b.TitleValue
  12096. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), (
  12097. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  12098. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  12099. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  12100. AND LEN(TitleID) >3
  12101. GROUP BY LEFT(TitleID, 4)) b
  12102. WHERE a.TitleId = b.TitleID
  12103. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  12104. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12105. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  12106. GROUP BY dcEducationID ORDER BY dcEducationID
  12107. --学历 高中、中专、中级合并
  12108. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  12109. WHERE paSearchConditionID = @paSearchConditionID
  12110. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  12111. IF @TitleValue IS NOT NULL
  12112. BEGIN
  12113. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  12114. UPDATE SearchDB..paSearchCount_3 SET TitleValue = @TitleValue
  12115. WHERE paSearchConditionID = @paSearchConditionID
  12116. AND Title = 'Education' AND TitleID = 2
  12117. ELSE
  12118. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  12119. (@paSearchConditionID, 'Education', 2, @TitleValue)
  12120. DELETE FROM SearchDB..paSearchCount_3
  12121. WHERE paSearchConditionID = @paSearchConditionID
  12122. AND Title = 'Education' AND TitleID IN(3, 4)
  12123. END
  12124. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12125. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  12126. GROUP BY MinExperience ORDER BY MinExperience
  12127. /* ----写入TitleDesc
  12128. UPDATE a SET a.TitleDesc = b.Description
  12129. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcEducation b WITH(NOLOCK)
  12130. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  12131. AND a.Title = 'Education'
  12132. UPDATE a SET a.TitleDesc = b.Description
  12133. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  12134. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  12135. AND a.Title = 'Region'
  12136. UPDATE a SET a.TitleDesc = b.Description
  12137. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  12138. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  12139. AND a.Title = 'JobType'
  12140. UPDATE a SET a.TitleDesc = b.Description
  12141. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcSalary b WITH(NOLOCK)
  12142. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  12143. AND a.Title = 'Salary'
  12144. UPDATE a SET a.TitleDesc = b.Description
  12145. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcCompanySize b WITH(NOLOCK)
  12146. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  12147. AND a.Title = 'CompanySize'
  12148. UPDATE a SET a.TitleDesc = b.Description
  12149. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcCompanySize b WITH(NOLOCK)
  12150. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  12151. AND a.Title = 'CompanySize'
  12152. UPDATE SearchDB..paSearchCount_3 SET TitleDesc =
  12153. CASE TitleID
  12154. WHEN 0 THEN '不限'
  12155. WHEN 1 THEN '1~2年'
  12156. WHEN 2 THEN '3~5年'
  12157. WHEN 3 THEN '6~10年'
  12158. WHEN 4 THEN '10年以上'
  12159. WHEN 5 THEN '应届毕业生'
  12160. END
  12161. WHERE paSearchConditionID = @paSearchConditionID
  12162. AND Title = 'Experience'
  12163. UPDATE SearchDB..paSearchCount_3 SET TitleDesc =
  12164. CASE TitleID
  12165. WHEN 1 THEN '全职'
  12166. WHEN 3 THEN '兼职'
  12167. WHEN 4 THEN '实习'
  12168. END
  12169. WHERE paSearchConditionID = @paSearchConditionID
  12170. AND Title = 'EmployType'
  12171. */
  12172. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  12173. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  12174. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  12175. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  12176. SET @TopRows = @@ROWCOUNT
  12177. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  12178. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  12179. SET @AllRows = @@ROWCOUNT
  12180. IF @TopRows = 0 AND @AllRows > 100
  12181. UPDATE SearchDB..paSearchJobID_3 SET IsTop = 1
  12182. WHERE paSearchConditionID = @paSearchConditionID
  12183. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  12184. END
  12185. DROP TABLE #Job
  12186. --PRINT 'DROP #JOB ' + CONVERT(VARCHAR(30), GETDATE(), 121)
  12187. COMMIT
  12188. --GOTO GetRecordSet
  12189. GetRecordSet:
  12190. BEGIN
  12191. ----返回查询数量
  12192. SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
  12193. UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
  12194. ----返回20行查询结果
  12195. IF (@TableID = 0)
  12196. BEGIN
  12197. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  12198. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  12199. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  12200. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  12201. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  12202. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  12203. a.IsDelete, a.AddDate, a.RefreshDate, a.Welfare1,a.Welfare2,a.Welfare3,
  12204. a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8,
  12205. a.Welfare9,a.Welfare10,a.Welfare11,a.Welfare12,a.Welfare13,
  12206. a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,a.SecondId EnJobID,b.SecondId EnCpMainID,
  12207. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  12208. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  12209. 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,
  12210. c.IsTop, b.IsRefreshed, d.IsOnline, d.IsVi, d.ViPlanId, d.InterviewDate
  12211. FROM JobPublish a WITH(NOLOCK)
  12212. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  12213. INNER JOIN SearchDB..paSearchJobID_0 c WITH(NOLOCK) ON a.id = c.JobID
  12214. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  12215. WHERE paSearchConditionID=@paSearchConditionID
  12216. AND c.ID >= @MinId
  12217. ORDER BY c.ID, a.ID DESC
  12218. END
  12219. ELSE IF (@TableID = 1)
  12220. BEGIN
  12221. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  12222. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  12223. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  12224. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  12225. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  12226. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  12227. a.IsDelete, a.AddDate, a.RefreshDate, a.Welfare1, a.Welfare2, a.Welfare3,
  12228. a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8,
  12229. a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13,
  12230. a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18,
  12231. a.SecondId EnJobID, b.SecondId EnCpMainID,
  12232. a.LastModifyDate, b.Name cpName, b.dcCompanySizeID,
  12233. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  12234. 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,
  12235. c.IsTop, b.IsRefreshed, d.IsOnline, d.IsVi, d.ViPlanId, d.InterviewDate
  12236. FROM JobPublish a WITH(NOLOCK)
  12237. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  12238. INNER JOIN SearchDB..paSearchJobID_1 c WITH(NOLOCK) ON a.id = c.JobID
  12239. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  12240. WHERE paSearchConditionID=@paSearchConditionID
  12241. AND c.ID >= @MinId
  12242. ORDER BY c.ID, a.ID DESC
  12243. END
  12244. ELSE IF (@TableID = 2)
  12245. BEGIN
  12246. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  12247. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  12248. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  12249. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  12250. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  12251. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  12252. a.IsDelete, a.AddDate, a.RefreshDate, a.Welfare1, a.Welfare2, a.Welfare3,
  12253. a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8,
  12254. a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13,
  12255. a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18,
  12256. a.SecondId EnJobID, b.SecondId EnCpMainID,
  12257. a.LastModifyDate, b.Name cpName, b.dcCompanySizeID,
  12258. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  12259. 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,
  12260. c.IsTop, b.IsRefreshed, d.IsOnline, d.IsVi, d.ViPlanId, d.InterviewDate
  12261. FROM JobPublish a WITH(NOLOCK)
  12262. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  12263. INNER JOIN SearchDB..paSearchJobID_2 c WITH(NOLOCK) ON a.id = c.JobID
  12264. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  12265. WHERE paSearchConditionID=@paSearchConditionID
  12266. AND c.ID >= @MinId
  12267. ORDER BY c.ID, a.ID DESC
  12268. END
  12269. ELSE IF (@TableID = 3)
  12270. BEGIN
  12271. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  12272. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  12273. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  12274. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  12275. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  12276. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  12277. a.IsDelete, a.AddDate, a.RefreshDate, a.Welfare1, a.Welfare2, a.Welfare3,
  12278. a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8,
  12279. a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13,
  12280. a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18,
  12281. a.SecondId EnJobID, b.SecondId EnCpMainID,
  12282. a.LastModifyDate, b.Name cpName, b.dcCompanySizeID,
  12283. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  12284. 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,
  12285. c.IsTop, b.IsRefreshed, d.IsOnline, d.IsVi, d.ViPlanId, d.InterviewDate
  12286. FROM JobPublish a WITH(NOLOCK)
  12287. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  12288. INNER JOIN SearchDB..paSearchJobID_3 c WITH(NOLOCK) ON a.id = c.JobID
  12289. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  12290. WHERE paSearchConditionID=@paSearchConditionID
  12291. AND c.ID >= @MinId
  12292. ORDER BY c.ID, a.ID DESC
  12293. END
  12294. --RICHARD 2011-7-23 16:51分修改
  12295. ----返回统计数量
  12296. IF @Type=1
  12297. BEGIN
  12298. DECLARE @RegionCount AS INT
  12299. SELECT @RegionCount = -1
  12300. IF CHARINDEX(',', @dcRegionID) = 0 AND LEN(@dcRegionID) > 0
  12301. BEGIN
  12302. IF NOT LEFT(@dcRegionID,1) = 'p'
  12303. SELECT @RegionCount = COUNT(*) FROM dcRegion WHERE ParentID = @dcRegionID
  12304. END
  12305. IF (@TableID = 0)
  12306. BEGIN
  12307. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  12308. IF @RegionCount = 0
  12309. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  12310. ELSE
  12311. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  12312. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12313. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12314. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12315. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12316. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12317. END
  12318. IF (@TableID = 1)
  12319. BEGIN
  12320. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  12321. IF @RegionCount = 0
  12322. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  12323. ELSE
  12324. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  12325. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12326. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12327. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12328. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12329. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12330. END
  12331. IF (@TableID = 2)
  12332. BEGIN
  12333. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  12334. IF @RegionCount = 0
  12335. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  12336. ELSE
  12337. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  12338. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12339. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12340. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12341. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12342. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12343. END
  12344. IF (@TableID = 3)
  12345. BEGIN
  12346. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  12347. IF @RegionCount = 0
  12348. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  12349. ELSE
  12350. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  12351. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12352. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12353. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12354. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12355. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  12356. END
  12357. END
  12358. RETURN
  12359. END
  12360. END TRY
  12361. BEGIN CATCH
  12362. ---检查是否已经建立临时表,已经建立则删除
  12363. PRINT 'error'
  12364. PRINT error_Message()
  12365. PRINT error_number()
  12366. PRINT error_line()
  12367. END CATCH
  12368. GO
  12369. /****** Object: StoredProcedure [dbo].[pcJobBySimilarSelect] Script Date: 2018/12/13 19:08:41 ******/
  12370. SET ANSI_NULLS ON
  12371. GO
  12372. SET QUOTED_IDENTIFIER ON
  12373. GO
  12374. CREATE PROCEDURE [dbo].[pcJobBySimilarSelect]
  12375. (
  12376. @dcJobTypeID VARCHAR(6),
  12377. @dcRegionID VARCHAR(6),
  12378. @JobId INT
  12379. )
  12380. AS
  12381. SET NOCOUNT ON
  12382. BEGIN
  12383. DECLARE @SecondId VARCHAR(12)
  12384. SELECT @SecondId = SecondId
  12385. FROM JobPublish WITH(NOLOCK)
  12386. WHERE ID = @JobID
  12387. IF @SecondId IS NULL
  12388. SELECT @SecondId = ''
  12389. IF @dcRegionID LIKE '32%'
  12390. SET @dcRegionID = '30'
  12391. SELECT TOP 10 *
  12392. FROM (
  12393. SELECT TOP 50 NeedNumber, JobName, a.ID, cpMainID, cpName, SubSiteUrl,
  12394. b.FullName, dcSalaryID, dcSalaryIDMax, LastLoginDate
  12395. FROM JobSimilar a WITH(NOLOCK INDEX(IX_JobSimilar_Complex)),
  12396. dcRegion b WITH(NOLOCK)
  12397. WHERE a.dcRegionID = b.ID
  12398. AND dcJobTypeID LIKE @dcJobTypeID + '%'
  12399. AND dcRegionID LIKE @dcRegionID + '%'
  12400. ) a
  12401. WHERE ID <> @SecondId
  12402. ORDER BY NEWID()
  12403. END
  12404. GO
  12405. /****** Object: StoredProcedure [dbo].[pcJobByZhaopinSelect] Script Date: 2018/12/13 19:08:42 ******/
  12406. SET ANSI_NULLS ON
  12407. GO
  12408. SET QUOTED_IDENTIFIER ON
  12409. GO
  12410. CREATE PROCEDURE [dbo].[pcJobByZhaopinSelect]
  12411. (
  12412. @dcJobTypeID VARCHAR(100), --职位类别
  12413. @dcRegionID VARCHAR(100), --求职地区
  12414. @dcIndustryID VARCHAR(100), --求职行业
  12415. @dcSalaryID TINYINT, --月薪
  12416. @IsNegotiable BIT, --1允许面议,不面议
  12417. @MinExperience TINYINT, --工作经验,100为未选择
  12418. @dcEducationID TINYINT, --最低学历
  12419. @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习,
  12420. @KeyWord NVARCHAR(10), --关键词
  12421. @KeyType TINYINT, --关键词类别,0无;1-全文;2-职位;3-公司
  12422. @ORDER VARCHAR(100), --显示顺序,没有用
  12423. @RefreshNo INT, --1,1天内;2,3天内;3,一周内;4,15天内;5,一个月内;6超过一个月
  12424. @Type INT, --1:主动搜索 点击搜索按钮 10分钟,翻页60分钟有效;0:翻页搜索,不刷新
  12425. @PageNumber INT, --翻页页码
  12426. @SessionID VARCHAR(50)
  12427. )
  12428. AS
  12429. --return @SessionId = 16
  12430. SET NOCOUNT ON
  12431. INSERT INTO SearchIp(Ip, Source) SELECT @SessionId, 'z'
  12432. IF EXISTS(SELECT 'x' FROM RefuseIp WITH(NOLOCK) WHERE CHARINDEX(Ip,@SessionId) > 0)
  12433. BEGIN
  12434. SELECT 0 ValidJobNumber
  12435. SELECT TOP 0 * FROM JobTemp
  12436. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  12437. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  12438. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  12439. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  12440. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  12441. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  12442. SELECT TOP 0 * FROM SearchDB..paSearchCount_0
  12443. RETURN
  12444. END
  12445. SET @SessionId = 30
  12446. BEGIN TRY
  12447. BEGIN
  12448. ----给null值变量赋默认值
  12449. SELECT @dcJobTypeID = dbo.FormatIDS(@dcJobTypeID),
  12450. @dcRegionID = dbo.FormatIDS(@dcRegionID),
  12451. @dcIndustryID = dbo.FormatIDS(@dcIndustryID)
  12452. IF @dcSalaryID IS NULL
  12453. SET @dcSalaryID = 0
  12454. IF @MinExperience IS NULL
  12455. SET @MinExperience = 100
  12456. IF @dcEducationID IS NULL
  12457. SET @dcEducationID = 0
  12458. IF @EmployType IS NULL
  12459. SET @EmployType = ''
  12460. IF @EmployType = '2'
  12461. SET @EmployType = '1,3'
  12462. IF @ORDER IS NULL
  12463. SET @ORDER = ''
  12464. SET @ORDER = dbo.SafeSQL(@ORDER)
  12465. --@RefreshNo = 0选择全部数据,不限制时间
  12466. DECLARE @dcProvinceId INT
  12467. IF ISNULL(@RefreshNo, 0) > 9
  12468. SELECT @dcProvinceId = @RefreshNo
  12469. ELSE
  12470. SELECT @dcProvinceId = 0
  12471. IF @Type IS NULL
  12472. SET @Type = 0
  12473. IF @PageNumber IS NULL
  12474. SET @PageNumber = 0
  12475. IF(ISNULL(@dcJobTypeID, '') = '' AND ISNULL(@dcRegionID, '') = '' AND ISNULL(@dcIndustryID, '') = '')
  12476. RETURN
  12477. DECLARE @paSearchConditionID AS INT, @MinId AS INT, @PageSize AS TINYINT, @TableID AS TINYINT
  12478. SELECT @paSearchConditionID = 0, @PageSize = 50
  12479. ----搜索2分钟的数据
  12480. SELECT TOP 1 @paSearchConditionID = ID
  12481. FROM SearchDB..paSearchCondition WITH(NOLOCK)
  12482. WHERE JobType=@dcJobTypeID AND JobPlace=@dcRegionID AND Industry=@dcIndustryID
  12483. AND Education=@dcEducationID AND Experience=@MinExperience AND Salary=@dcSalaryID
  12484. AND EmployType=@EmployType AND KeyWord='' AND CompanySizeID = 0
  12485. AND Welfare = '' AND IsOnline=0 AND dcProvinceId = @dcProvinceId
  12486. AND LogTime > DATEADD(MINUTE, -1, GETDATE()) AND ReuseNumber > 0
  12487. ORDER BY ID DESC
  12488. IF ISNULL(@paSearchConditionID, 0) = 0
  12489. BEGIN
  12490. SET @Type =1
  12491. GOTO SelectReset --无数据,重新搜索
  12492. END
  12493. ELSE
  12494. BEGIN
  12495. SELECT @TableID = @paSearchConditionID % 4
  12496. GOTO GetRecordSet --从临时结果中提取数据
  12497. END
  12498. END
  12499. SelectReset: --从job中搜索数据
  12500. BEGIN TRAN
  12501. DECLARE @SQL AS VARCHAR(8000)
  12502. DECLARE @WHERE AS VARCHAR(8000)
  12503. DECLARE @FROM AS VARCHAR(1000)
  12504. ----记录查询条件
  12505. INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
  12506. Salary, IsNegotiable, EmployType, KeyWord, KeyType, ReuseNumber, CompanySizeID, dcProvinceId)
  12507. SELECT @SessionId, GETDATE(), @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcEducationID, @MinExperience,
  12508. @dcSalaryID, @IsNegotiable, @EmployType, '', 0, 0, 0, @dcProvinceId
  12509. SET @paSearchConditionID = @@IDENTITY
  12510. SELECT @TableID = @paSearchConditionID % 4
  12511. ------生成职位类别的表变量,因为职位类别有包含(父子)关系
  12512. DECLARE @T_JobPlace AS TABLE(ID INT)
  12513. DECLARE @T_JobType AS TABLE(ID INT)
  12514. DECLARE @JobType AS VARCHAR(3000)
  12515. DECLARE @JobPlace AS VARCHAR(2000)
  12516. DECLARE @ValidJobNumber AS INT
  12517. DECLARE @JobPlaceLen AS INT, @JobTypeLen AS INT
  12518. IF CHARINDEX(',', @dcJobTypeID) > 0
  12519. SET @JobTypeLen = -1
  12520. ELSE
  12521. SET @JobTypeLen = LEN(@dcJobTypeID)
  12522. SELECT @JobPlace = '', @JobType=''
  12523. ----生成工作地点的表变量
  12524. IF LEN(@dcRegionID) > 0
  12525. BEGIN
  12526. INSERT INTO @T_JobPlace
  12527. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  12528. SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  12529. IF LEN(@JobPlace) > 0
  12530. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  12531. IF (SELECT COUNT(*) FROM @T_JobPlace) > 1
  12532. SET @JobPlaceLen = -1
  12533. ELSE
  12534. SET @JobPlaceLen = LEN(@dcRegionID)
  12535. END
  12536. ----生成求聘职位的表变量
  12537. IF LEN(@dcJobTypeID) > 0
  12538. BEGIN
  12539. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  12540. INSERT INTO @T_Temp
  12541. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  12542. INSERT INTO @T_JobType
  12543. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  12544. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  12545. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  12546. OR ID IN(SELECT ID FROM @T_TEMP)
  12547. ----生成in字符串
  12548. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  12549. IF RIGHT(@JobType, 1) = ','
  12550. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  12551. END
  12552. ----建立临时表
  12553. CREATE TABLE #Job(
  12554. RowID INT IDENTITY(1, 1),
  12555. ID INT NOT NULL,
  12556. cpMainId INT,
  12557. dcJobTypeID SMALLINT NOT NULL,
  12558. dcJobTypeIDMinor SMALLINT NULL,
  12559. dcSalaryID TINYINT NOT NULL,
  12560. dcRegionID VARCHAR(6) NULL,
  12561. dcEducationID TINYINT NOT NULL,
  12562. MinExperience TINYINT NOT NULL,
  12563. RefreshDate SMALLDATETIME NULL,
  12564. EmployType TINYINT NULL,
  12565. dcCompanySizeID SMALLINT NULL
  12566. )
  12567. ------刷新时间,根据刷新时间编号计算
  12568. ----生成插入临时表的Sql语句
  12569. SET @SQL='
  12570. INSERT INTO #Job
  12571. SELECT a.ID, a.cpMainId, a.dcJobTypeID, a.dcJobTypeIDMinor, a.dcSalaryID,
  12572. a.dcRegionID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID'
  12573. SET @FROM = '
  12574. FROM JobPublish a WITH(NOLOCK)
  12575. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  12576. ----职位有效,单位新有效
  12577. IF LEN(@dcIndustryID) > 0
  12578. SET @WHERE = '
  12579. WHERE b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @dcIndustryID + '))
  12580. AND a.Valid = 1
  12581. AND b.Valid = 1'
  12582. ELSE
  12583. SET @WHERE = '
  12584. WHERE a.Valid = 1
  12585. AND b.Valid = 1'
  12586. IF @dcProvinceId > 0
  12587. SET @WHERE = @WHERE + ' AND b.dcProvinceId = ' + LTRIM(STR(@dcProvinceId))
  12588. ----职位类别
  12589. IF LEN(@dcJobTypeID) > 0
  12590. SET @WHERE = @WHERE + '
  12591. AND (a.dcJobTypeID IN(' + @JobType +')
  12592. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  12593. IF LEN(@JobPlace) > 0
  12594. SET @WHERE = @WHERE + '
  12595. AND (' + @JobPlace + ')'
  12596. IF @dcSalaryID > 0
  12597. BEGIN
  12598. IF @dcSalaryID < 100 ----从form中搜索,月薪跨2个级别,是本级和上级别的薪金
  12599. BEGIN
  12600. SET @WHERE = @WHERE + '
  12601. AND a.dcSalaryID IN(' + LTRIM(STR(@dcSalaryID)) + ', ' + LTRIM(STR(@dcSalaryID + 1))
  12602. IF @IsNegotiable = 1 --包括面议
  12603. SET @WHERE = @WHERE + ', 100'
  12604. SET @WHERE = @WHERE + ')'
  12605. END
  12606. IF @dcSalaryID = 100 ----从筛选结果中点击面议,值是100
  12607. BEGIN
  12608. SET @WHERE = @WHERE + '
  12609. AND a.dcSalaryID = 100'
  12610. END
  12611. IF @dcSalaryID > 100 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  12612. SET @WHERE = @WHERE + '
  12613. AND a.dcSalaryID=' + LTRIM(STR(@dcSalaryID-100))
  12614. END
  12615. ----工作经验要求
  12616. IF @MinExperience < 100
  12617. SET @WHERE = @WHERE + '
  12618. AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
  12619. ----学历要求
  12620. ----'1初中','2\3\4高中、中技、中专','5大专','6本科','7硕士','8博士
  12621. IF @dcEducationID > 0
  12622. IF @dcEducationID = 2
  12623. SET @WHERE = @WHERE + '
  12624. AND a.dcEducationID IN(2,3,4)'
  12625. ELSE
  12626. SET @WHERE = @WHERE + '
  12627. AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
  12628. ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
  12629. IF LEN(@EmployType) > 0
  12630. SET @WHERE = @WHERE + '
  12631. AND a.EmployType IN (' + @EmployType + ')'
  12632. SET @SQL = @SQL + @FROM + @WHERE
  12633. --IF LEN(@ORDER)>0
  12634. SET @SQL=@SQL + ' ORDER BY a.RefreshDate DESC, a.SecondID'
  12635. --原来是ORDER BY a.IssueDate DESC, a.ID,Richard 2011年11月23日17:06分修改
  12636. ----把符合条件的职位全部列出
  12637. --PRINT @SQL
  12638. EXEC(@SQL)
  12639. SET @ValidJobNumber = @@ROWCOUNT
  12640. ----记录查询结果总数
  12641. UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@SQL WHERE ID=@paSearchConditionID
  12642. DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
  12643. DECLARE @sc AS TABLE (
  12644. paSearchConditionID int,
  12645. Title varchar(20),
  12646. TitleID varchar(10),
  12647. TitleValue int
  12648. )
  12649. DECLARE @sc2 AS TABLE (
  12650. paSearchConditionID int,
  12651. Title varchar(20),
  12652. TitleID varchar(10),
  12653. TitleValue int
  12654. )
  12655. ----插入JobType数据
  12656. IF (@TableID = 0)
  12657. BEGIN
  12658. ----------------------------jobtype
  12659. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  12660. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  12661. FROM #Job WITH(NOLOCK)
  12662. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  12663. ----计算全部某职位类别,2, 4位的数据
  12664. IF @JobTypeLen NOT IN(2, 4)
  12665. BEGIN
  12666. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  12667. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  12668. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  12669. END
  12670. IF @JobTypeLen NOT IN(0, 4)
  12671. BEGIN
  12672. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  12673. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  12674. FROM @sc2 WHERE LEN(TitleId) = 4
  12675. END
  12676. IF @JobTypeLen = -1
  12677. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  12678. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  12679. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  12680. DELETE @sc
  12681. DELETE @sc2
  12682. --------------------------region
  12683. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  12684. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  12685. GROUP BY dcRegionID ORDER BY dcRegionID
  12686. ----计算全部地区,2位的数据
  12687. IF @JobPlaceLen IN(-1, 0)
  12688. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12689. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  12690. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  12691. IF @JobPlaceLen IN(-1, 2)
  12692. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12693. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  12694. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  12695. IF @JobPlaceLen IN(-1, 4)
  12696. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12697. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  12698. FROM @sc2 WHERE LEN(TitleID) = 6
  12699. IF @JobPlaceLen = -1
  12700. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  12701. ELSE
  12702. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  12703. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  12704. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  12705. ----------------------------
  12706. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  12707. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  12708. GROUP BY EmployType ORDER BY EmployType
  12709. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  12710. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*) FROM #Job WITH(NOLOCK)
  12711. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  12712. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  12713. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  12714. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  12715. GROUP BY MinExperience ORDER BY MinExperience
  12716. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  12717. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  12718. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  12719. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  12720. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  12721. GROUP BY dcSalaryID ORDER BY dcSalaryID
  12722. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  12723. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  12724. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  12725. WHERE a.cpMainId = b.cpMainId
  12726. GROUP BY b.dcIndustryId ORDER BY b.dcIndustryId
  12727. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionId, JobId)
  12728. SELECT TOP 2000 @paSearchConditionID, ID FROM #Job WITH(NOLOCK) ORDER BY RowId
  12729. END
  12730. ELSE IF (@TableId = 1)
  12731. BEGIN
  12732. ----------------------------jobtype
  12733. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  12734. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  12735. FROM #Job WITH(NOLOCK)
  12736. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  12737. ----计算全部某职位类别,2, 4位的数据
  12738. IF @JobTypeLen NOT IN(2, 4)
  12739. BEGIN
  12740. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  12741. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  12742. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  12743. END
  12744. IF @JobTypeLen NOT IN(0, 4)
  12745. BEGIN
  12746. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  12747. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  12748. FROM @sc2 WHERE LEN(TitleId) = 4
  12749. END
  12750. IF @JobTypeLen = -1
  12751. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  12752. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  12753. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  12754. DELETE @sc
  12755. DELETE @sc2
  12756. --------------------------region
  12757. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  12758. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  12759. GROUP BY dcRegionID ORDER BY dcRegionID
  12760. ----计算全部地区,2位的数据
  12761. IF @JobPlaceLen IN(-1, 0)
  12762. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12763. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  12764. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  12765. IF @JobPlaceLen IN(-1, 2)
  12766. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12767. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  12768. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  12769. IF @JobPlaceLen IN(-1, 4)
  12770. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12771. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  12772. FROM @sc2 WHERE LEN(TitleID) = 6
  12773. IF @JobPlaceLen = -1
  12774. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  12775. ELSE
  12776. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  12777. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  12778. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  12779. ----------------------------
  12780. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  12781. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  12782. GROUP BY dcSalaryID ORDER BY dcSalaryID
  12783. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  12784. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*) FROM #Job WITH(NOLOCK)
  12785. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  12786. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  12787. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  12788. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  12789. GROUP BY MinExperience ORDER BY MinExperience
  12790. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  12791. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  12792. GROUP BY EmployType ORDER BY EmployType
  12793. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  12794. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  12795. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  12796. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  12797. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  12798. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  12799. WHERE a.cpMainId = b.cpMainId
  12800. GROUP BY dcIndustryID ORDER BY dcIndustryID
  12801. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionId, JobId)
  12802. SELECT TOP 2000 @paSearchConditionID, ID FROM #Job WITH(NOLOCK) ORDER BY RowId
  12803. END
  12804. ELSE IF (@TableId = 2)
  12805. BEGIN
  12806. ----------------------------jobtype
  12807. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  12808. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  12809. FROM #Job WITH(NOLOCK)
  12810. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  12811. ----计算全部某职位类别,2, 4位的数据
  12812. IF @JobTypeLen NOT IN(2, 4)
  12813. BEGIN
  12814. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  12815. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  12816. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  12817. END
  12818. IF @JobTypeLen NOT IN(0, 4)
  12819. BEGIN
  12820. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  12821. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  12822. FROM @sc2 WHERE LEN(TitleId) = 4
  12823. END
  12824. IF @JobTypeLen = -1
  12825. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  12826. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  12827. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  12828. DELETE @sc
  12829. DELETE @sc2
  12830. --------------------------region
  12831. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  12832. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  12833. GROUP BY dcRegionID ORDER BY dcRegionID
  12834. ----计算全部地区,2位的数据
  12835. IF @JobPlaceLen IN(-1, 0)
  12836. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12837. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  12838. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  12839. IF @JobPlaceLen IN(-1, 2)
  12840. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12841. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  12842. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  12843. IF @JobPlaceLen IN(-1, 4)
  12844. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12845. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  12846. FROM @sc2 WHERE LEN(TitleID) = 6
  12847. IF @JobPlaceLen = -1
  12848. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  12849. ELSE
  12850. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  12851. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  12852. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  12853. ----------------------------
  12854. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  12855. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  12856. GROUP BY dcSalaryID ORDER BY dcSalaryID
  12857. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  12858. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*) FROM #Job WITH(NOLOCK)
  12859. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  12860. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  12861. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  12862. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  12863. GROUP BY MinExperience ORDER BY MinExperience
  12864. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  12865. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  12866. GROUP BY EmployType ORDER BY EmployType
  12867. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  12868. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  12869. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  12870. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  12871. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  12872. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  12873. WHERE a.cpMainId = b.cpMainId
  12874. GROUP BY dcIndustryID ORDER BY dcIndustryID
  12875. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionId, JobId)
  12876. SELECT TOP 2000 @paSearchConditionID, ID FROM #Job WITH(NOLOCK) ORDER BY RowId
  12877. END
  12878. ELSE IF (@TableId = 3)
  12879. BEGIN
  12880. ----------------------------jobtype
  12881. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  12882. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  12883. FROM #Job WITH(NOLOCK)
  12884. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  12885. ----计算全部某职位类别,2, 4位的数据
  12886. IF @JobTypeLen NOT IN(2, 4)
  12887. BEGIN
  12888. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  12889. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  12890. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  12891. END
  12892. IF @JobTypeLen NOT IN(0, 4)
  12893. BEGIN
  12894. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  12895. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  12896. FROM @sc2 WHERE LEN(TitleId) = 4
  12897. END
  12898. IF @JobTypeLen = -1
  12899. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  12900. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12901. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  12902. DELETE @sc
  12903. DELETE @sc2
  12904. --------------------------region
  12905. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  12906. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  12907. GROUP BY dcRegionID ORDER BY dcRegionID
  12908. ----计算全部地区,2位的数据
  12909. IF @JobPlaceLen IN(-1, 0)
  12910. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12911. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  12912. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  12913. IF @JobPlaceLen IN(-1, 2)
  12914. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12915. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  12916. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  12917. IF @JobPlaceLen IN(-1, 4)
  12918. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12919. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  12920. FROM @sc2 WHERE LEN(TitleID) = 6
  12921. IF @JobPlaceLen = -1
  12922. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  12923. ELSE
  12924. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  12925. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12926. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  12927. ----------------------------
  12928. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12929. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  12930. GROUP BY dcSalaryID ORDER BY dcSalaryID
  12931. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12932. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*) FROM #Job WITH(NOLOCK)
  12933. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  12934. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  12935. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12936. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  12937. GROUP BY MinExperience ORDER BY MinExperience
  12938. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12939. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  12940. GROUP BY EmployType ORDER BY EmployType
  12941. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12942. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  12943. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  12944. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12945. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  12946. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  12947. WHERE a.cpMainId = b.cpMainId
  12948. GROUP BY dcIndustryID ORDER BY dcIndustryID
  12949. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionId, JobId)
  12950. SELECT TOP 2000 @paSearchConditionID, ID FROM #Job WITH(NOLOCK) ORDER BY RowId
  12951. END
  12952. DROP TABLE #Job
  12953. --PRINT 'DROP #Job ' + CONVERT(VARCHAR(30), GETDATE(), 121)
  12954. COMMIT
  12955. --GOTO GetRecordSet
  12956. GetRecordSet:
  12957. BEGIN
  12958. ----返回查询数量
  12959. SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
  12960. UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
  12961. ----返回20行查询结果
  12962. IF (@TableID = 0)
  12963. BEGIN
  12964. SELECT @MinId = MIN(ID)FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  12965. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  12966. SELECT top 50 a.ID,a.cpMainID,a.caMainID,a.Name as JobName,a.dcJobTypeID,
  12967. a.dcJobTypeIDMinor,a.NeedNumber,a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  12968. a.dcRegionID,a.Responsibility,a.Demand,a.dcEducationID,
  12969. a.MinExperience,a.MinAge,a.MaxAge,a.IssueDate,a.IssueEND,
  12970. a.IsDelete,a.AddDate,a.RefreshDate,
  12971. a.LastModifyDate,b.Name as cpName, b.dcCompanySizeID,
  12972. b.HasLicence,b.UnLimitedDate,b.BalanceDate,b.Balance,
  12973. b.MemberType, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,a.Welfare3,
  12974. a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8,
  12975. a.Welfare9,a.Welfare10,a.Welfare11,a.Welfare12,a.Welfare13,
  12976. a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,a.Welfare19,
  12977. dbo.GetCaOnlineStatus(a.caMainID) IsOnline, CASE WHEN b.ReplyRate >= 0.6 THEN b.ReplyRate ELSE NULL END Replyrate, b.RealName
  12978. FROM JobPublish a WITH(NOLOCK),cpMainPublish b WITH(NOLOCK),SearchDB..paSearchJobID_0 c WITH(NOLOCK)
  12979. WHERE a.cpMainID = b.ID and a.id=c.JobID and c.paSearchConditionID=@paSearchConditionID
  12980. AND c.ID>=@MinId ORDER BY c.ID,a.ID DESC
  12981. END
  12982. ELSE IF (@TableID = 1)
  12983. BEGIN
  12984. SELECT @MinId = MIN(ID)FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  12985. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  12986. SELECT top 50 a.ID,a.cpMainID,a.caMainID,a.Name as JobName,a.dcJobTypeID,
  12987. a.dcJobTypeIDMinor,a.NeedNumber,a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  12988. a.dcRegionID,a.Responsibility,a.Demand,a.dcEducationID,
  12989. a.MinExperience,a.MinAge,a.MaxAge,a.IssueDate,a.IssueEND,
  12990. a.IsDelete, a.AddDate,a.RefreshDate,
  12991. a.LastModifyDate,b.Name as cpName,b.dcCompanySizeID,
  12992. b.HasLicence,b.UnLimitedDate,b.BalanceDate,b.Balance,
  12993. b.MemberType, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,a.Welfare3,
  12994. a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8,
  12995. a.Welfare9,a.Welfare10,a.Welfare11,a.Welfare12,a.Welfare13,
  12996. a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,a.Welfare19,
  12997. dbo.GetCaOnlineStatus(a.caMainID) IsOnline, CASE WHEN b.ReplyRate >= 0.6 THEN b.ReplyRate ELSE NULL END Replyrate, b.RealName
  12998. FROM JobPublish a WITH(NOLOCK),cpMainPublish b WITH(NOLOCK),SearchDB..paSearchJobID_1 c WITH(NOLOCK)
  12999. WHERE a.cpMainID = b.ID and a.id=c.JobID and c.paSearchConditionID=@paSearchConditionID
  13000. AND c.ID>=@MinId ORDER BY c.ID,a.ID DESC
  13001. END
  13002. ELSE IF (@TableID = 2)
  13003. BEGIN
  13004. SELECT @MinId = MIN(ID)FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  13005. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  13006. SELECT top 50 a.ID,a.cpMainID,a.caMainID,a.Name as JobName,a.dcJobTypeID,
  13007. a.dcJobTypeIDMinor,a.NeedNumber,a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  13008. a.dcRegionID,a.Responsibility,a.Demand,a.dcEducationID,
  13009. a.MinExperience,a.MinAge,a.MaxAge,a.IssueDate,a.IssueEND,
  13010. a.IsDelete, a.AddDate,a.RefreshDate,
  13011. a.LastModifyDate,b.Name as cpName,b.dcCompanySizeID,
  13012. b.HasLicence,b.UnLimitedDate,b.BalanceDate,b.Balance,
  13013. b.MemberType, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,a.Welfare3,
  13014. a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8,
  13015. a.Welfare9,a.Welfare10,a.Welfare11,a.Welfare12,a.Welfare13,
  13016. a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,a.Welfare19,
  13017. dbo.GetCaOnlineStatus(a.caMainID) IsOnline, CASE WHEN b.ReplyRate >= 0.6 THEN b.ReplyRate ELSE NULL END Replyrate, b.RealName
  13018. FROM JobPublish a WITH(NOLOCK),cpMainPublish b WITH(NOLOCK),SearchDB..paSearchJobID_2 c WITH(NOLOCK)
  13019. WHERE a.cpMainID = b.ID and a.id=c.JobID and c.paSearchConditionID=@paSearchConditionID
  13020. AND c.ID>=@MinId ORDER BY c.ID,a.ID DESC
  13021. END
  13022. ELSE IF (@TableID = 3)
  13023. BEGIN
  13024. SELECT @MinId = MIN(ID)FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  13025. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  13026. SELECT top 50 a.ID,a.cpMainID,a.caMainID,a.Name as JobName,a.dcJobTypeID,
  13027. a.dcJobTypeIDMinor,a.NeedNumber,a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  13028. a.dcRegionID,a.Responsibility,a.Demand,a.dcEducationID,
  13029. a.MinExperience,a.MinAge,a.MaxAge,a.IssueDate,a.IssueEND,
  13030. a.IsDelete, a.AddDate,a.RefreshDate,
  13031. a.LastModifyDate,b.Name as cpName,b.dcCompanySizeID,
  13032. b.HasLicence,b.UnLimitedDate,b.BalanceDate,b.Balance,
  13033. b.MemberType, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,a.Welfare3,
  13034. a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8,
  13035. a.Welfare9,a.Welfare10,a.Welfare11,a.Welfare12,a.Welfare13,
  13036. a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,a.Welfare19,
  13037. dbo.GetCaOnlineStatus(a.caMainID) IsOnline, CASE WHEN b.ReplyRate >= 0.6 THEN b.ReplyRate ELSE NULL END Replyrate, b.RealName
  13038. FROM JobPublish a WITH(NOLOCK),cpMainPublish b WITH(NOLOCK),SearchDB..paSearchJobID_3 c WITH(NOLOCK)
  13039. WHERE a.cpMainID = b.ID and a.id=c.JobID and c.paSearchConditionID=@paSearchConditionID
  13040. AND c.ID>=@MinId ORDER BY c.ID,a.ID DESC
  13041. END
  13042. --RICHARD 2011-7-23 16:51分修改
  13043. ----返回统计数量
  13044. IF @Type=1
  13045. IF (@TableID = 0)
  13046. BEGIN
  13047. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  13048. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  13049. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13050. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13051. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13052. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13053. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13054. END
  13055. IF (@TableID = 1)
  13056. BEGIN
  13057. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  13058. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  13059. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13060. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13061. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13062. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13063. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13064. END
  13065. IF (@TableID = 2)
  13066. BEGIN
  13067. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  13068. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  13069. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13070. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13071. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13072. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13073. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13074. END
  13075. IF (@TableID = 3)
  13076. BEGIN
  13077. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  13078. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  13079. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13080. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13081. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13082. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13083. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13084. END
  13085. RETURN
  13086. END
  13087. END TRY
  13088. BEGIN CATCH
  13089. ---检查是否已经建立临时表,已经建立则删除
  13090. DECLARE @para VARCHAR(MAX)
  13091. SET @para = '@dcJobTypeID=' + ISNULL(@dcJobTypeID, '') + '|' +
  13092. '@dcRegionID=' + ISNULL(@dcRegionID, '') + '|' +
  13093. '@dcIndustryID=' + ISNULL(@dcIndustryID, '') + '|' +
  13094. '@EmployType=' + ISNULL(@EmployType, '') + '|' +
  13095. '@KeyWord=' + ISNULL(@KeyWord, '') + '|' +
  13096. '@ORDER=' + ISNULL(@ORDER, '') + '|' +
  13097. '@SessionID=' + ISNULL(@SessionID, '')
  13098. INSERT INTO ErrorLog
  13099. SELECT 'p2 ' +ISNULL(error_Message(), ' no msg')+ ' para=' + ISNULL(@Para, 'no para ') + ISNULL(@SQL, ' no sql'), error_number(), error_line(), GETDATE()
  13100. END CATCH
  13101. GO
  13102. /****** Object: StoredProcedure [dbo].[pcJobIntentionSave] Script Date: 2018/12/13 19:08:42 ******/
  13103. SET ANSI_NULLS ON
  13104. GO
  13105. SET QUOTED_IDENTIFIER ON
  13106. GO
  13107. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  13108. -- 检查: Sean
  13109. -- 日期: 2010-9-29
  13110. -- 描述: 保存求职意向 执行pcCvMainByCvLevelUpdate,取消中英文判断
  13111. -- 修改:Lambo,2010-11-25
  13112. -- 描述:增加了paMainID参数,判断是否是本人的
  13113. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  13114. CREATE PROCEDURE [dbo].[pcJobIntentionSave]
  13115. (
  13116. @cvMainID INT,
  13117. @RelatedWorkYears TINYINT,
  13118. @EmployType TINYINT,
  13119. @dcSalaryID TINYINT,
  13120. @IsNegotiable TINYINT,
  13121. @JobType VARCHAR(100),
  13122. @JobPlace VARCHAR(100),
  13123. @Industry VARCHAR(100),
  13124. @paMainID INT
  13125. )
  13126. AS
  13127. SET NOCOUNT ON
  13128. BEGIN
  13129. IF @cvMainID IS NULL
  13130. RETURN 0
  13131. IF @paMainID IS NULL
  13132. RETURN 0
  13133. IF @RelatedWorkYears IS NULL
  13134. RETURN 0
  13135. IF @EmployType IS NULL
  13136. RETURN 0
  13137. IF @dcSalaryID IS NULL
  13138. RETURN 0
  13139. IF @JobType IS NULL
  13140. RETURN 0
  13141. IF @JobPlace IS NULL
  13142. RETURN 0
  13143. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID AND paMainID = @paMainID)
  13144. RETURN 0
  13145. DECLARE @i INT, @Name AS VARCHAR(100), @JobType1 AS VARCHAR(10), @JobPlace1 AS VARCHAR(10)
  13146. DELETE FROM cvJobType WHERE cvMainID = @cvMainID
  13147. SET @i = CHARINDEX(' ', @JobType)
  13148. WHILE @i >= 1
  13149. BEGIN
  13150. IF LEFT(@JobType, @i-1) > ''
  13151. BEGIN
  13152. INSERT cvJobType(cvMainID, dcJobTypeID) VALUES(@cvMainID, LEFT(@JobType, @i-1))
  13153. IF @JobType1 IS NULL
  13154. SET @JobType1 = LEFT(@JobType, @i-1)
  13155. END
  13156. SET @JobType = SUBSTRING(@JobType, @i+1, LEN(@JobType)-@i)
  13157. SET @i = CHARINDEX(' ', @JobType)
  13158. END
  13159. IF @JobType > ''
  13160. BEGIN
  13161. INSERT cvJobType(cvMainID, dcJobTypeID) VALUES(@cvMainID, @JobType)
  13162. IF @JobType1 IS NULL
  13163. SET @JobType1 = @JobType
  13164. END
  13165. DELETE FROM cvJobPlace WHERE cvMainID = @cvMainID
  13166. SET @i = CHARINDEX(' ', @JobPlace)
  13167. WHILE @i >= 1
  13168. BEGIN
  13169. IF LEFT(@JobPlace, @i-1) > ''
  13170. BEGIN
  13171. INSERT cvJobPlace(cvMainID, dcRegionID) VALUES(@cvMainID, LEFT(@JobPlace, @i-1))
  13172. IF @JobPlace1 IS NULL
  13173. SET @JobPlace1 = LEFT(@JobPlace, @i-1)
  13174. END
  13175. SET @JobPlace = SUBSTRING(@JobPlace, @i+1, LEN(@JobPlace)-@i)
  13176. SET @i = CHARINDEX(' ', @JobPlace)
  13177. END
  13178. IF @JobPlace > ''
  13179. BEGIN
  13180. INSERT cvJobPlace(cvMainID, dcRegionID) VALUES(@cvMainID, @JobPlace)
  13181. IF @JobPlace1 IS NULL
  13182. SET @JobPlace1 = @JobPlace
  13183. END
  13184. DELETE FROM cvIndustry WHERE cvMainID = @cvMainID
  13185. SET @i = CHARINDEX(' ', @Industry)
  13186. WHILE @i >= 1
  13187. BEGIN
  13188. IF LEFT(@Industry, @i-1) > ''
  13189. INSERT cvIndustry(cvMainID, dcIndustryID) VALUES(@cvMainID, LEFT(@Industry, @i-1))
  13190. SET @Industry = SUBSTRING(@Industry, @i+1, LEN(@Industry)-@i)
  13191. SET @i = CHARINDEX(' ', @Industry)
  13192. END
  13193. IF @Industry > ''
  13194. INSERT cvIndustry(cvMainID, dcIndustryID) VALUES(@cvMainID, @Industry)
  13195. SELECT @Name = Name FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
  13196. IF(ISNULL(@Name, '未完成简历') = '未完成简历')
  13197. BEGIN
  13198. SELECT @Name = Description FROM dcRegion WITH(NOLOCK) WHERE ID = @JobPlace1
  13199. SELECT @Name = @Name + '+' + Description FROM dcJobType WITH(NOLOCK) WHERE ID = @JobType1
  13200. IF (@RelatedWorkYears = 0 AND NOT EXISTS(SELECT 'x' FROM cvExperience WITH(NOLOCK) WHERE cvMainId = @cvMainId))
  13201. BEGIN
  13202. UPDATE cvMain SET Name = @Name,
  13203. RelatedWorkYears = @RelatedWorkYears,
  13204. EmployType = @EmployType,
  13205. dcSalaryID = @dcSalaryID,
  13206. IsNegotiable = @IsNegotiable,
  13207. cvType = 1
  13208. WHERE ID = @cvMainID
  13209. DECLARE @EXECSQL AS VARCHAR(100)
  13210. SET @EXECSQL = 'EXEC pcCvMainByCvLevelUpdateNew 0, ' + LTRIM(STR(@cvMainID)) + ', 4, 1'
  13211. EXEC(@EXECSQL)
  13212. SET @EXECSQL = 'EXEC pcCvMainByCvLevelUpdateNew 1, ' + LTRIM(STR(@cvMainID)) + ', 4, 1'
  13213. EXEC(@EXECSQL)
  13214. END
  13215. ELSE
  13216. UPDATE cvMain SET Name = @Name,
  13217. RelatedWorkYears = @RelatedWorkYears,
  13218. EmployType = @EmployType,
  13219. dcSalaryID = @dcSalaryID,
  13220. IsNegotiable = @IsNegotiable
  13221. WHERE ID = @cvMainID
  13222. END
  13223. ELSE
  13224. BEGIN
  13225. UPDATE cvMain SET RelatedWorkYears = @RelatedWorkYears,
  13226. EmployType = @EmployType,
  13227. dcSalaryID = @dcSalaryID, IsNegotiable = @IsNegotiable
  13228. WHERE ID = @cvMainID
  13229. END
  13230. DECLARE @SQL AS VARCHAR(100)
  13231. SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew 0, ' + LTRIM(STR(@cvMainID)) + ', 6, 1'
  13232. EXEC(@SQL)
  13233. SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew 1, ' + LTRIM(STR(@cvMainID)) + ', 6, 1'
  13234. EXEC(@SQL)
  13235. RETURN 1
  13236. END
  13237. GO
  13238. /****** Object: StoredProcedure [dbo].[pcJobSelect] Script Date: 2018/12/13 19:08:43 ******/
  13239. SET ANSI_NULLS ON
  13240. GO
  13241. SET QUOTED_IDENTIFIER ON
  13242. GO
  13243. CREATE PROCEDURE [dbo].[pcJobSelect]
  13244. @ID INT
  13245. AS
  13246. BEGIN
  13247. SELECT *
  13248. FROM Job WITH(NOLOCK)
  13249. WHERE ID = @ID And Valid = 1
  13250. END
  13251. GO
  13252. /****** Object: StoredProcedure [dbo].[pcMapPlaceSelectByRegionID] Script Date: 2018/12/13 19:08:43 ******/
  13253. SET ANSI_NULLS ON
  13254. GO
  13255. SET QUOTED_IDENTIFIER ON
  13256. GO
  13257. CREATE PROCEDURE [dbo].[pcMapPlaceSelectByRegionID]
  13258. (
  13259. @dcRegionID VARCHAR(6)
  13260. )
  13261. AS
  13262. BEGIN
  13263. IF LEN(@dcRegionID) = 6
  13264. BEGIN
  13265. IF EXISTS(SELECT TOP 1 'X' FROM dcMapPlace WHERE dcRegionID = @dcRegionID)
  13266. SELECT * FROM dcMapPlace WHERE dcRegionID = @dcRegionID ORDER BY OrderNo
  13267. ELSE
  13268. SELECT * FROM dcMapPlace WHERE dcRegionID = LEFT(@dcRegionID,4) ORDER BY OrderNo
  13269. END
  13270. ELSE IF LEN(@dcRegionID) = 4
  13271. BEGIN
  13272. IF EXISTS(SELECT TOP 1 'X' FROM dcMapPlace WHERE dcRegionID = @dcRegionID)
  13273. SELECT * FROM dcMapPlace WHERE dcRegionID = @dcRegionID ORDER BY OrderNo
  13274. ELSE IF EXISTS(SELECT TOP 1 'X' FROM dcMapPlace WHERE dcRegionID LIKE @dcRegionID + '%' AND IsHot = 1)
  13275. SELECT * FROM dcMapPlace WHERE dcRegionID LIKE @dcRegionID + '%' AND IsHot = 1
  13276. ELSE
  13277. SELECT * FROM dcMapPlace WHERE dcRegionID = LEFT(@dcRegionID,2) ORDER BY OrderNo
  13278. END
  13279. ELSE
  13280. BEGIN
  13281. IF EXISTS(SELECT TOP 1 'X' FROM dcMapPlace WHERE dcRegionID = @dcRegionID)
  13282. SELECT * FROM dcMapPlace WHERE dcRegionID = @dcRegionID ORDER BY OrderNo
  13283. ELSE
  13284. SELECT * FROM dcMapPlace WHERE dcRegionID LIKE @dcRegionID + '%' AND LEN(dcRegionID) = 4 AND IsHot = 1
  13285. END
  13286. END
  13287. GO
  13288. /****** Object: StoredProcedure [dbo].[pcNewsListByPhone] Script Date: 2018/12/13 19:08:43 ******/
  13289. SET ANSI_NULLS ON
  13290. GO
  13291. SET QUOTED_IDENTIFIER ON
  13292. GO
  13293. CREATE PROCEDURE [dbo].[pcNewsListByPhone]
  13294. (
  13295. @dcProvinceID AS SMALLINT,
  13296. @PageNum AS INT,
  13297. @PageSize AS INT
  13298. )
  13299. AS
  13300. BEGIN
  13301. DECLARE @COUNT INT
  13302. SELECT @COUNT=COUNT(1)
  13303. FROM QlrcNews WITH(NOLOCK) WHERE (
  13304. EXISTS(SELECT 'x' FROM fnSplit(DetailType,',') b,dcNewsType c WITH(NOLOCK) WHERE b.a=c.ID AND c.Category=1) OR DetailType IS NULL)
  13305. AND (VersionID=@dcProvinceID OR VersionID=0) AND NewsType = 2 AND DetailType NOT LIKE '%,2,%'
  13306. IF @COUNT > 200
  13307. SET @COUNT = 200
  13308. SELECT *,@COUNT AS cnt FROM(
  13309. SELECT TOP 200 ROW_NUMBER() OVER(ORDER BY RefreshDate DESC) AS Rows,ID,Title,RefreshDate,Author
  13310. FROM QlrcNews WITH(NOLOCK) WHERE (
  13311. EXISTS(SELECT 'x' FROM fnSplit(DetailType,',') b,dcNewsType c WITH(NOLOCK) WHERE b.a=c.ID AND c.Category=1) OR DetailType IS NULL)
  13312. AND (VersionID=@dcProvinceID OR VersionID=0) AND NewsType = 2 AND DetailType NOT LIKE '%,2,%'
  13313. ) AS a
  13314. WHERE a.Rows BETWEEN (@PageNum-1)*@PageSize+1 AND @PageNum*@PageSize ORDER BY Rows
  13315. END
  13316. GO
  13317. /****** Object: StoredProcedure [dbo].[pcNoViewViPlanInviteByPaMainIDSelect] Script Date: 2018/12/13 19:08:43 ******/
  13318. SET ANSI_NULLS ON
  13319. GO
  13320. SET QUOTED_IDENTIFIER ON
  13321. GO
  13322. --#####################################################
  13323. --创建时间:2014.10.30
  13324. --创建人:John
  13325. --说明:个人获取没有查看过的面试邀请
  13326. --#####################################################
  13327. CREATE PROCEDURE [dbo].[pcNoViewViPlanInviteByPaMainIDSelect]
  13328. (
  13329. @paMainID INT
  13330. )
  13331. AS
  13332. BEGIN
  13333. SELECT a.*,b.interviewdate,c.Name JobName ,ISNULL(c.SecondId,c.id) jobSecondId,d.Name CompanyName,ISNULL(d.SecondId ,d.id) cpMainID,e.Name caName
  13334. FROM viplaninvitelog a,viplan b,job c ,cpMain d ,caMain e
  13335. WHERE c.caMainID=e.id
  13336. AND a.viplanid=b.id
  13337. AND a.jobid=c.id
  13338. AND c.cpMainid=d.id
  13339. AND addtype=1
  13340. AND viewdate IS NULL
  13341. AND cvMainID IN ( SELECT id FROM cvMain WHERE pamainid = @paMainID )
  13342. END
  13343. GO
  13344. /****** Object: StoredProcedure [dbo].[pcNoViewViRoomInviteByPaMainIDSelect] Script Date: 2018/12/13 19:08:44 ******/
  13345. SET ANSI_NULLS ON
  13346. GO
  13347. SET QUOTED_IDENTIFIER ON
  13348. GO
  13349. --#####################################################
  13350. --创建时间:2014.10.30
  13351. --创建人:John
  13352. --说明:个人获取没有查看过的面试室邀请
  13353. --#####################################################
  13354. CREATE PROCEDURE [dbo].[pcNoViewViRoomInviteByPaMainIDSelect]
  13355. (
  13356. @paMainID INT
  13357. )
  13358. AS
  13359. BEGIN
  13360. SELECT TOP 1 a.*,b.BeginDate interviewdate,c.Name JobName ,ISNULL(c.SecondId,c.id) jobSecondId,d.Name CompanyName,ISNULL(d.SecondId ,d.id) cpMainID,e.Name caName
  13361. FROM viinterviewrecord a,viroom b,job c ,cpMain d,caMain e
  13362. WHERE c.camainid = e.id
  13363. AND a.viroomid = b.id
  13364. AND a.jobid = c.id
  13365. AND c.cpMainid = d.id
  13366. AND Applytype = 1
  13367. AND b.enddate IS NULL
  13368. AND a.viewdate IS NULL
  13369. AND cvMainID IN ( SELECT id FROM cvMain WHERE pamainid = @paMainID )
  13370. END
  13371. GO
  13372. /****** Object: StoredProcedure [dbo].[pcNoViewViRoomInviteReplyByPaMainIDSelect] Script Date: 2018/12/13 19:08:44 ******/
  13373. SET ANSI_NULLS ON
  13374. GO
  13375. SET QUOTED_IDENTIFIER ON
  13376. GO
  13377. --#####################################################
  13378. --创建时间:2014.10.30
  13379. --创建人:John
  13380. --说明:个人获取没有查看过的面试室邀请回复
  13381. --#####################################################
  13382. CREATE PROCEDURE [dbo].[pcNoViewViRoomInviteReplyByPaMainIDSelect]
  13383. (
  13384. @paMainID INT
  13385. )
  13386. AS
  13387. BEGIN
  13388. SELECT TOP 1 a.*,b.BeginDate interviewdate,c.Name JobName ,ISNULL(c.SecondId,c.id) jobSecondId,d.Name CompanyName,ISNULL(d.SecondId ,d.id) cpMainID,e.Name caName
  13389. FROM viinterviewrecord a,viroom b,job c ,cpMain d,caMain e
  13390. WHERE c.camainid = e.id
  13391. AND a.viroomid = b.id
  13392. AND a.jobid = c.id
  13393. AND c.cpMainid = d.id
  13394. AND Applytype = 0
  13395. AND b.enddate IS NULL
  13396. AND a.ReplyDate IS NOT NULL
  13397. AND a.ReplyViewDate IS NULL
  13398. AND cvMainID IN ( SELECT id FROM cvMain WHERE pamainid = @paMainID )
  13399. END
  13400. GO
  13401. /****** Object: StoredProcedure [dbo].[pcNVCaMainByexMessageC2PPaMainIdSelect] Script Date: 2018/12/13 19:08:44 ******/
  13402. SET ANSI_NULLS ON
  13403. GO
  13404. SET QUOTED_IDENTIFIER ON
  13405. GO
  13406. CREATE PROCEDURE [dbo].[pcNVCaMainByexMessageC2PPaMainIdSelect]
  13407. (
  13408. @paMainID INT,
  13409. @Where VARCHAR(100)
  13410. )
  13411. AS
  13412. BEGIN
  13413. DECLARE @SQL AS VARCHAR(MAX)
  13414. SET @SQL = '
  13415. SELECT a.caMainID,b.Name,b.Gender,b.Dept,b.Telephone,b.Mobile,b.IsPhoneHide,
  13416. b.IsNameHide,b.IsMobileHide,c.Name CompanyName,c.ID cpMainID, c.SecondId EnCpMainID FROM
  13417. (
  13418. SELECT caMainID,AddDate,ROW_NUMBER() OVER(PARTITION BY caMainID ORDER BY AddDate DESC) RowNumber FROM
  13419. (
  13420. SELECT caMainID,ID,addDate,Message,1 IsCompany,IsViewed FROM exMessageC2p WITH(NOLOCK)
  13421. WHERE cvMainID IN(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID='+CONVERT(VARCHAR,@paMainID)+'
  13422. ) AND PersonDeleted=0
  13423. UNION
  13424. SELECT caMainID,ID,addDate,Message,0 IsCompany,1 FROM exMessageP2C WITH(NOLOCK) WHERE cvMainID IN
  13425. (
  13426. SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID='+CONVERT(VARCHAR,@paMainID)+') AND PersonDeleted=0
  13427. ) t
  13428. ) a,caMain b WITH(NOLOCK),cpMain c WITH(NOLOCK)
  13429. WHERE a.RowNumber=1 AND a.caMainID=b.ID AND b.cpMainID=c.ID'
  13430. IF LEN(@Where) > 0
  13431. BEGIN
  13432. SET @Where = dbo.SafeSql(@Where)
  13433. SET @SQL = @SQL + @Where
  13434. END
  13435. SET @SQL = @SQL + ' ORDER BY AddDate DESC'
  13436. EXEC(@SQL)
  13437. END
  13438. GO
  13439. /****** Object: StoredProcedure [dbo].[pcNVexMessageLogSelect] Script Date: 2018/12/13 19:08:44 ******/
  13440. SET ANSI_NULLS ON
  13441. GO
  13442. SET QUOTED_IDENTIFIER ON
  13443. GO
  13444. --==================================
  13445. --添加人:Lucifer(个人会员中心改版)
  13446. --添加时间:2013-7-19
  13447. --==================================
  13448. CREATE PROCEDURE [dbo].[pcNVexMessageLogSelect]
  13449. (
  13450. @paMainID INT,
  13451. @caMainID INT
  13452. )
  13453. AS
  13454. BEGIN
  13455. SELECT * FROM (
  13456. SELECT cvMainID,ID,addDate,Message,1 IsCompany,IsViewed FROM exMessageC2p WITH(NOLOCK)
  13457. WHERE cvMainID IN(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID=@paMainID) AND caMainID=@caMainID
  13458. AND PersonDeleted=0
  13459. UNION
  13460. SELECT cvMainID,ID,addDate,Message,0 IsCompany,1 FROM exMessageP2C WITH(NOLOCK)
  13461. WHERE cvMainID IN(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID=@paMainID) AND caMainID=@caMainID
  13462. AND PersonDeleted=0
  13463. ) a ORDER BY a.AddDate
  13464. END
  13465. GO
  13466. /****** Object: StoredProcedure [dbo].[pcNVexMessageP2CByReplyInsert] Script Date: 2018/12/13 19:08:44 ******/
  13467. SET ANSI_NULLS ON
  13468. GO
  13469. SET QUOTED_IDENTIFIER ON
  13470. GO
  13471. --================================
  13472. --添加人:Lucifer(个人会员中心改版)
  13473. --添加时间:2013-7-19
  13474. --================================
  13475. CREATE PROCEDURE [dbo].[pcNVexMessageP2CByReplyInsert]
  13476. (
  13477. @caMainID INT,
  13478. @cvMainID INT,
  13479. @Message VARCHAR(200),
  13480. @paMainID INT
  13481. )
  13482. AS
  13483. BEGIN
  13484. IF EXISTS(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID=@paMainID AND ID=@cvMainID)
  13485. BEGIN
  13486. DECLARE @MaxID INT
  13487. SET @Message = dbo.SafeSQL(LTRIM(RTRIM(@Message)))
  13488. INSERT exMessageP2C(caMainID,cvMainID,Message) VALUES(@caMainID,@cvMainID,@Message)
  13489. SET @MaxID = @@IDENTITY
  13490. Update exMessageC2P Set IsReply=1 WHERE cvMainID=@cvMainID AND caMainID=@caMainID AND AddDate<GETDATE()
  13491. RETURN @MaxID
  13492. END
  13493. ELSE
  13494. RETURN 0
  13495. END
  13496. GO
  13497. /****** Object: StoredProcedure [dbo].[pcNVPaMainByPaVerifySelect] Script Date: 2018/12/13 19:08:45 ******/
  13498. SET ANSI_NULLS ON
  13499. GO
  13500. SET QUOTED_IDENTIFIER ON
  13501. GO
  13502. CREATE PROCEDURE [dbo].[pcNVPaMainByPaVerifySelect]
  13503. (
  13504. @paMainID INT,
  13505. @Mobile VARCHAR(11),
  13506. @Email VARCHAR(50)
  13507. )
  13508. AS
  13509. SET NOCOUNT ON
  13510. BEGIN
  13511. DECLARE @VerifyCount SMALLINT
  13512. IF EXISTS(SELECT 'x' FROM paVerifyLog WITH(NOLOCK) WHERE AddDate > DATEADD(Second, -150, GETDATE()) AND (paMainId = @paMainId OR Mobile = @Mobile))
  13513. RETURN -2
  13514. SELECT @VerifyCount=COUNT(1) FROM paVerifyLog WHERE paMainID = @paMainID AND Mobile=@Mobile AND Email=@Email AND AddDate>CONVERT(VARCHAR(10),GETDATE(),120)
  13515. IF @VerifyCount > 4
  13516. RETURN 0
  13517. DECLARE @MobileVerifyDate SMALLDATETIME,@EmailVerifyDate SMALLDATETIME,@MobileOld VARCHAR(11)
  13518. SELECT @MobileVerifyDate = MobileVerifyDate,@EmailVerifyDate = EmailVerifyDate,@MobileOld = ISNULL(Mobile,'')
  13519. FROM paMain WHERE ID=@paMainID
  13520. IF LEN(@Mobile)=0 AND ISNULL(@EmailVerifyDate,'')<>''
  13521. RETURN -1
  13522. IF LEN(@Email)=0 AND ISNULL(@MobileVerifyDate,'')<>'' AND @MobileOld = @Mobile
  13523. RETURN -1
  13524. DECLARE @VerifyCode AS VARCHAR(6)
  13525. SELECT @VerifyCode = RAND() * 899999 + 100000
  13526. INSERT INTO paVerifyLog(paMainID, Email, Mobile, VerifyCode, VerifyDate, AddDate)
  13527. VALUES(@paMainID,@Email,@Mobile,@VerifyCode,NULL,GETDATE())
  13528. RETURN @VerifyCode
  13529. END
  13530. GO
  13531. /****** Object: StoredProcedure [dbo].[pcNVPaMainByVerifyUpdate] Script Date: 2018/12/13 19:08:45 ******/
  13532. SET ANSI_NULLS ON
  13533. GO
  13534. SET QUOTED_IDENTIFIER ON
  13535. GO
  13536. CREATE PROCEDURE [dbo].[pcNVPaMainByVerifyUpdate]
  13537. (
  13538. @paMainID INT,
  13539. @Mobile VARCHAR(11),
  13540. @Email VARCHAR(50),
  13541. @VerifyCode VARCHAR(6)
  13542. )
  13543. AS
  13544. BEGIN
  13545. DECLARE @MobileVerifyDate SMALLDATETIME, @EmailVerifyDate SMALLDATETIME, @MobileOld VARCHAR(11)
  13546. SELECT @MobileVerifyDate = MobileVerifyDate, @EmailVerifyDate = EmailVerifyDate, @MobileOld = ISNULL(Mobile, '') FROM paMain WHERE ID = @paMainID
  13547. IF LEN(@Mobile) = 0 AND ISNULL(@EmailVerifyDate, '') <> ''
  13548. RETURN -1
  13549. IF LEN(@Email) = 0 AND ISNULL(@MobileVerifyDate, '') <> '' AND @MobileOld = @Mobile
  13550. RETURN -1
  13551. DECLARE @paVerifyLogID AS INT
  13552. SET @paVerifyLogID = 0
  13553. SELECT @paVerifyLogID = ID FROM paVerifyLog WHERE paMainID = @paMainID AND Mobile = @Mobile AND Email = @Email
  13554. AND VerifyCode = @VerifyCode AND AddDate>DATEADD(HOUR, -1, GETDATE())
  13555. IF @paVerifyLogID = 0
  13556. RETURN 0
  13557. UPDATE paVerifyLog SET VerifyDate = GETDATE() WHERE paMainID = @paMainID AND Mobile = @Mobile AND Email = @Email
  13558. AND VerifyCode = @VerifyCode AND AddDate>DATEADD(HOUR, -1, GETDATE())
  13559. IF LEN(@Mobile) = 0
  13560. UPDATE paMain SET EmailVerifyDate = GETDATE() WHERE ID = @paMainID
  13561. IF LEN(@Email) = 0
  13562. BEGIN
  13563. UPDATE paMain SET Mobile = @Mobile WHERE ID = @paMainID
  13564. --修改本手机号对应的其他帐号的认证状态
  13565. UPDATE paMain SET MobileVerifyDate = NULL WHERE Mobile = @Mobile
  13566. UPDATE paMain SET MobileVerifyDate = GETDATE() WHERE ID = @paMainID AND Mobile = @Mobile
  13567. END
  13568. RETURN 1
  13569. END
  13570. GO
  13571. /****** Object: StoredProcedure [dbo].[pcPaActstatusInsert] Script Date: 2018/12/13 19:08:45 ******/
  13572. SET ANSI_NULLS ON
  13573. GO
  13574. SET QUOTED_IDENTIFIER ON
  13575. GO
  13576. create PROCEDURE [dbo].[pcPaActstatusInsert]
  13577. (
  13578. @paMainId INT,
  13579. @ActStatus INt
  13580. )
  13581. AS
  13582. SET NOCOUNT ON
  13583. BEGIN
  13584. INSERT INTO ShortDb..paActStatus(paMainId, ActStatus, AddDate)
  13585. SELECT @paMainId, @ActStatus, GETDATE()
  13586. END
  13587. GO
  13588. /****** Object: StoredProcedure [dbo].[pcPaAttentionByCpMainIDSelect] Script Date: 2018/12/13 19:08:45 ******/
  13589. SET ANSI_NULLS ON
  13590. GO
  13591. SET QUOTED_IDENTIFIER ON
  13592. GO
  13593. --创建时间:2015.11.09
  13594. --创建人:nick
  13595. --说明:企业关注详情
  13596. --harry 增加logourl
  13597. --#####################################################
  13598. CREATE PROCEDURE [dbo].[pcPaAttentionByCpMainIDSelect]
  13599. (
  13600. @CpMainID INT,
  13601. @AttentionDate DATETIME,
  13602. @PaMainID INT
  13603. )
  13604. AS
  13605. BEGIN
  13606. SET NOCOUNT ON
  13607. --行业信息
  13608. SELECT a.CpMainiD,b.Description
  13609. FROM CpIndustry a WITH(NOLOCK),dcIndustry b WITH(NOLOCK)
  13610. WHERE a.CpMainiD = @CpMainID
  13611. AND a.DcIndustryID = b.ID
  13612. --职位数量
  13613. SELECT TOP 5 a.ID,a.SecondID ,a.Name,a.AddDate,a.IssueEnd,a.IsDelete,b.FullName,c.Description AS SalaryName,a.NeedNumber,a.RefreshDate,0 AS ISApply,
  13614. a.dcSalaryID, c.DescriptionCp Salary, d.DescriptionCp SalaryMax, e.Description Education, f.Description Experience, g.Description NeedNuberDesc, b.MapBarName Region, h.LogoFile LogoUrl
  13615. INTO #TJob
  13616. FROM Job a WITH(NOLOCK),DcRegion b WITH(NOLOCK),dcSalary c WITH(NOLOCK),dcSalary d WITH(NOLOCK),dcEducation e WITH(NOLOCK),dcOthers f WITH(NOLOCK),dcOthers g WITH(NOLOCK), cpMainPublish h WITH(NOLOCK)
  13617. WHERE CpMainID = @CpMainID
  13618. AND a.cpMainId= h.id
  13619. AND a.DcRegionID = b.ID
  13620. AND a.DcSalaryID = c.ID
  13621. AND a.dcSalaryIDMax = d.ID
  13622. AND a.dcEducationID = e.ID
  13623. AND a.MinExperience = f.DetailID AND f.Category = '职位要求工作经验'
  13624. AND a.NeedNumber = g.DetailID AND g.Category = '招聘人数'
  13625. AND a.AddDate > @AttentionDate
  13626. AND a.Valid = 1
  13627. ORDER BY a.AddDate DESC
  13628. UPDATE #TJob
  13629. SET ISApply = 1
  13630. WHERE ID IN(
  13631. SELECT ID
  13632. FROM exJobApply WITH(NOLOCK)
  13633. WHERE CvMainiD in (
  13634. SELECT ID FROM CvMain WITH(NOLOCK)
  13635. WHERE PaMainID = @paMainID
  13636. ) AND PersonDeleted = 0
  13637. )
  13638. SELECT * FROM #TJob
  13639. --面经数量
  13640. SELECT COUNT(*) FROM Comments WITH(NOLOCK)
  13641. WHERE CommentType IN(1,2)
  13642. AND CpMainID = @CpMainID
  13643. AND AddDate > @AttentionDate
  13644. --点评数量
  13645. SELECT COUNT(*) FROM InterView WITH(NOLOCK)
  13646. WHERE InterViewType IN(1,2)
  13647. AND CpMainID = @CpMainID
  13648. AND AddDate > @AttentionDate
  13649. --环境照片数量
  13650. SELECT COUNT(*) FROM cpImage WHERE cpMainID = @CpMainID AND ImgType = 3 AND AddDate > @AttentionDate AND HasPassed = 1
  13651. SET NOCOUNT OFF
  13652. END
  13653. GO
  13654. /****** Object: StoredProcedure [dbo].[pcPaAttentionByIDDelete] Script Date: 2018/12/13 19:08:46 ******/
  13655. SET ANSI_NULLS ON
  13656. GO
  13657. SET QUOTED_IDENTIFIER ON
  13658. GO
  13659. --创建:Nick
  13660. --创建日期:2015-11-09
  13661. --个人中心,取消关注
  13662. --------------------------------------------------
  13663. CREATE PROCEDURE [dbo].[pcPaAttentionByIDDelete]
  13664. (
  13665. @ID VARCHAR(200),
  13666. @PaMainID INT
  13667. )
  13668. AS
  13669. BEGIN
  13670. SET NOCOUNT ON
  13671. DELETE FROM PaAttention WHERE ID IN (SELECT * FROM dbo.fnSplit(@ID,','))
  13672. AND PaMainID = @PaMainID
  13673. SET NOCOUNT OFF
  13674. END
  13675. GO
  13676. /****** Object: StoredProcedure [dbo].[pcPaAttentionByPaMainIDAPPSelect] Script Date: 2018/12/13 19:08:46 ******/
  13677. SET ANSI_NULLS ON
  13678. GO
  13679. SET QUOTED_IDENTIFIER ON
  13680. GO
  13681. --创建时间:2016.1.1
  13682. --创建人:Lucifer
  13683. --说明:个人关注详情
  13684. --#####################################################
  13685. CREATE PROCEDURE [dbo].[pcPaAttentionByPaMainIDAPPSelect]
  13686. (
  13687. @paMainID INT,
  13688. @AttentionType INT --1.企业 2.职位
  13689. )
  13690. AS
  13691. BEGIN
  13692. SET NOCOUNT ON
  13693. IF @AttentionType=1 --企业
  13694. BEGIN
  13695. SELECT a.PaMainID,a.ID,a.AddDate,b.ID AS CpMainID,b.SecondID CpSecondID,b.Name,b.DcCompanyKindID,
  13696. c.Description AS DcCompanyKindName,d.Description AS CompanySizeName,a.AddDate AS SortDate,
  13697. (SELECT COUNT(1) FROM Comments e WHERE e.cpMainID = b.ID AND e.CommentType IN(1,2) AND e.AddDate > a.AddDate) commentCount,
  13698. (SELECT COUNT(1) FROM Interview f WHERE f.cpMainID = b.ID AND f.InterviewType IN(1,2) AND f.AddDate > a.AddDate) interviewCount,
  13699. (SELECT COUNT(1) FROM cpImage g WHERE g.cpMainID = b.ID AND g.ImgType = 3 AND g.HasPassed = 1 AND g.AddDate > a.AddDate) environmentCount
  13700. INTO #tcp
  13701. FROM PaAttention a WITH(NOLOCK), CpMain b WITH(NOLOCK),DcCompanyKind c WITH(NOLOCK),dcCompanySize d WITH(NOLOCK)
  13702. WHERE a.AttentionType=1
  13703. AND a.AttentionID = b.ID
  13704. AND a.PaMainID = @paMainID
  13705. AND b.DcCompanyKindID = C.ID
  13706. AND b.DcCompanySizeID = d.ID
  13707. AND b.IsDelete = 0
  13708. ORDER BY a.AddDate DESC
  13709. --企业职位最近更新时间
  13710. UPDATE d SET d.SortDate = c.JobAddDate
  13711. FROM #tcp d,
  13712. (SELECT a.CpMainID, MAX(a.LastModifyDate) AS JobAddDate
  13713. FROM Job a WITH(NOLOCK)
  13714. WHERE a.CpMainID IN (SELECT CpMainID FROM #tcp)
  13715. GROUP BY a.CpMainID) c
  13716. WHERE d.CpMainID = c.CpMainID AND d.SortDate < c.JobAddDate
  13717. --企业点评、面经最近更新时间
  13718. UPDATE d SET d.SortDate = c.PreachAddDate
  13719. FROM #tcp d,
  13720. (SELECT a.CpMainID, MAX(a.AddDate) AS PreachAddDate
  13721. FROM Comments a WITH(NOLOCK)
  13722. WHERE a.CpMainID IN (SELECT CpMainID FROM #tcp)
  13723. AND a.CommentType IN(1,2)
  13724. GROUP BY a.CpMainID) c
  13725. WHERE d.CpMainID = c.CpMainID AND d.SortDate < c.PreachAddDate
  13726. --企业点评、面经最近更新时间
  13727. UPDATE d SET d.SortDate = c.PreachAddDate
  13728. FROM #tcp d,
  13729. (SELECT a.CpMainID, MAX(a.AddDate) AS PreachAddDate
  13730. FROM InterView a WITH(NOLOCK)
  13731. WHERE a.CpMainID IN (SELECT CpMainID FROM #tcp)
  13732. AND a.InterViewType IN(1,2)
  13733. GROUP BY a.CpMainID) c
  13734. WHERE d.CpMainID = c.CpMainID AND d.SortDate < c.PreachAddDate
  13735. SELECT * FROM #tcp ORDER BY SortDate DESC
  13736. --行业信息
  13737. SELECT a.CpMainiD,b.Description
  13738. FROM CpIndustry a WITH(NOLOCK),dcIndustry b WITH(NOLOCK)
  13739. WHERE a.CpMainiD IN(SELECT cpMainID FROM #tcp)
  13740. AND a.DcIndustryID = b.ID
  13741. --职位数量
  13742. SELECT a.ID,a.cpMainID,a.SecondID ,a.Name,a.AddDate,a.IssueEnd,a.IsDelete,b.FullName,c.Description AS SalaryName,e.Description NeedNumber,a.RefreshDate,0 AS ISApply INTO #TJob
  13743. FROM Job a WITH(NOLOCK),DcRegion b WITH(NOLOCK),dcsalary c WITH(NOLOCK),#tcp d WITH(NOLOCK),dcOthers e WITH(NOLOCK)
  13744. WHERE a.DcRegionID = b.ID
  13745. AND a.DcSalaryID = c.ID
  13746. AND a.cpMainID = d.cpMainID
  13747. AND a.AddDate > d.AddDate
  13748. AND a.Valid = 1
  13749. AND a.NeedNumber = e.DetailID
  13750. AND e.Category = '招聘人数'
  13751. ORDER BY a.AddDate DESC
  13752. --SELECT a.ID,a.SecondID ,a.Name,a.AddDate,a.IssueEnd,a.IsDelete,b.FullName,c.Description AS SalaryName,a.NeedNumber,a.RefreshDate,0 AS ISApply INTO #TJob
  13753. --FROM Job a WITH(NOLOCK),DcRegion b WITH(NOLOCK),dcsalary c WITH(NOLOCK),#tcp d WITH(NOLOCK)
  13754. --WHERE a.DcRegionID = b.ID
  13755. --AND a.DcSalaryID = c.ID
  13756. --AND a.cpMainID = d.cpMainID
  13757. --AND a.AddDate > d.AddDate
  13758. --AND a.Valid = 1
  13759. --ORDER BY a.AddDate DESC
  13760. UPDATE #TJob
  13761. SET ISApply = 1
  13762. WHERE ID IN(
  13763. SELECT ID
  13764. FROM exJobApply WITH(NOLOCK)
  13765. WHERE CvMainiD in (
  13766. SELECT ID FROM CvMain WITH(NOLOCK)
  13767. WHERE PaMainID = @paMainID
  13768. )
  13769. AND PersonDeleted = 0
  13770. )
  13771. SELECT * FROM #TJob
  13772. END
  13773. ELSE IF @AttentionType=2 --职位
  13774. BEGIN
  13775. SELECT a.PaMainID,a.ID,a.AddDate,b.ID AS JobID ,b.SecondID JobSecondID,b.Name AS JobName,c.FullName,f. Description NeedNumber,
  13776. d.ID as CpMainiD,d.SecondID CpSecondID,d.Name AS CpName,b.IsDelete,0 AS ISApply,IssueEnd,e.Description AS SalaryName,b.RefreshDate
  13777. INTO #TJob2
  13778. FROM PaAttention a WITH(NOLOCK),Job b WITH(NOLOCK),DcRegion c WITH(NOLOCK),CpMain d WITH(NOLOCK),dcSalary e WITH(NOLOCK),dcOthers f WITH(NOLOCK)
  13779. WHERE a.AttentionType=2
  13780. AND a.AttentionID = b.ID
  13781. AND a.PaMainID = @paMainID
  13782. AND b.CpMainID = d.ID
  13783. AND b.DcRegionID = c.ID
  13784. AND b.DcSalaryID = e.ID
  13785. AND b.NeedNumber = f.DetailID
  13786. AND f.Category = '招聘人数'
  13787. ORDER BY a.AddDate DESC
  13788. UPDATE #TJob2 SET ISApply = 1
  13789. WHERE JobID IN(
  13790. SELECT JobID
  13791. FROM exJobApply WITH(NOLOCK)
  13792. WHERE CvMainiD in (
  13793. SELECT ID FROM CvMain WITH(NOLOCK)
  13794. WHERE PaMainID = @paMainID
  13795. ) AND PersonDeleted = 0
  13796. )
  13797. --职位
  13798. SELECT * FROM #TJob2
  13799. END
  13800. SET NOCOUNT OFF
  13801. END
  13802. GO
  13803. /****** Object: StoredProcedure [dbo].[pcPaAttentionByPaMainIDSelect] Script Date: 2018/12/13 19:08:46 ******/
  13804. SET ANSI_NULLS ON
  13805. GO
  13806. SET QUOTED_IDENTIFIER ON
  13807. GO
  13808. --====================================
  13809. --返回值:获取个人关注列表
  13810. --创建:Nick 20151109
  13811. --====================================
  13812. CREATE PROCEDURE [dbo].[pcPaAttentionByPaMainIDSelect]
  13813. (
  13814. @paMainID INT,
  13815. @AttentionType INT --1.企业 2.职位
  13816. )
  13817. AS
  13818. BEGIN
  13819. SET NOCOUNT ON
  13820. IF @AttentionType=1 --企业
  13821. BEGIN
  13822. SELECT a.PaMainID,a.ID,a.AddDate,b.ID AS CpMainID,b.SecondID CpSecondID,b.Name,b.DcCompanyKindID,
  13823. c.Description AS DcCompanyKindName,d.Description AS CompanySizeName,a.AddDate AS SortDate, dbo.GetCpIndustry(b.ID) Industry, b.LogoFile LogoUrl INTO #tcp
  13824. FROM PaAttention a WITH(NOLOCK), CpMain b WITH(NOLOCK),DcCompanyKind c WITH(NOLOCK),dcCompanySize d WITH(NOLOCK)
  13825. WHERE a.AttentionType=1
  13826. AND a.AttentionID = b.ID
  13827. AND a.PaMainID = @paMainID
  13828. AND b.DcCompanyKindID = C.ID
  13829. AND b.DcCompanySizeID = d.ID
  13830. AND b.IsDelete = 0
  13831. ORDER BY a.AddDate DESC
  13832. --企业职位最近更新时间
  13833. UPDATE d SET d.SortDate = c.JobAddDate
  13834. FROM #tcp d,
  13835. (SELECT a.CpMainID, MAX(a.LastModifyDate) AS JobAddDate
  13836. FROM Job a WITH(NOLOCK)
  13837. WHERE a.CpMainID IN (SELECT CpMainID FROM #tcp)
  13838. GROUP BY a.CpMainID) c
  13839. WHERE d.CpMainID = c.CpMainID AND d.SortDate < c.JobAddDate
  13840. --企业点评、面经最近更新时间
  13841. UPDATE d SET d.SortDate = c.PreachAddDate
  13842. FROM #tcp d,
  13843. (SELECT a.CpMainID, MAX(a.AddDate) AS PreachAddDate
  13844. FROM Comments a WITH(NOLOCK)
  13845. WHERE a.CpMainID IN (SELECT CpMainID FROM #tcp)
  13846. AND a.CommentType IN(1,2)
  13847. GROUP BY a.CpMainID) c
  13848. WHERE d.CpMainID = c.CpMainID AND d.SortDate < c.PreachAddDate
  13849. --企业点评、面经最近更新时间
  13850. UPDATE d SET d.SortDate = c.PreachAddDate
  13851. FROM #tcp d,
  13852. (SELECT a.CpMainID, MAX(a.AddDate) AS PreachAddDate
  13853. FROM InterView a WITH(NOLOCK)
  13854. WHERE a.CpMainID IN (SELECT CpMainID FROM #tcp)
  13855. AND a.InterViewType IN(1,2)
  13856. GROUP BY a.CpMainID) c
  13857. WHERE d.CpMainID = c.CpMainID AND d.SortDate < c.PreachAddDate
  13858. SELECT * FROM #tcp ORDER BY SortDate DESC
  13859. END
  13860. ELSE IF @AttentionType=2 --职位
  13861. BEGIN
  13862. SELECT a.PaMainID,a.ID,a.AddDate,b.ID AS JobID ,b.SecondID JobSecondID,b.Name AS JobName,c.FullName,b.NeedNumber,
  13863. d.ID as CpMainiD,d.SecondID CpSecondID,d.Name AS CpName,b.IsDelete,0 AS IsApply,IssueEnd,e.Description AS SalaryName,b.RefreshDate, e.DescriptionCp SalaryMin,f.DescriptionCp SalaryMax, g.Description Experience, c.MapBarName Region, b.dcSalaryID, b.dcSalaryIDMax, b.Valid, dbo.GetCaOnlineStatus(b.caMainID) IsOnline
  13864. INTO #TJob
  13865. FROM PaAttention a WITH(NOLOCK),Job b WITH(NOLOCK),DcRegion c WITH(NOLOCK),CpMain d WITH(NOLOCK),dcSalary e WITH(NOLOCK),dcSalary f WITH(NOLOCK),dcOthers g WITH(NOLOCK)
  13866. WHERE a.AttentionType=2
  13867. AND a.AttentionID = b.ID
  13868. AND a.PaMainID = @paMainID
  13869. AND b.CpMainID = d.ID
  13870. AND b.dcRegionID = c.ID
  13871. AND b.dcSalaryID = e.ID
  13872. AND b.dcSalaryIdMax = f.ID
  13873. AND b.MinExperience = g.DetailID AND g.Category = '职位要求工作经验'
  13874. ORDER BY a.AddDate DESC
  13875. UPDATE #TJob
  13876. SET IsApply = 1
  13877. WHERE JobID IN(
  13878. SELECT JobID
  13879. FROM exJobApply WITH(NOLOCK)
  13880. WHERE CvMainiD in (
  13881. SELECT ID FROM CvMain WITH(NOLOCK)
  13882. WHERE PaMainID = @paMainID
  13883. ) AND PersonDeleted = 0
  13884. )
  13885. --职位
  13886. SELECT * FROM #TJob
  13887. END
  13888. SET NOCOUNT OFF
  13889. END
  13890. GO
  13891. /****** Object: StoredProcedure [dbo].[pcPaAttentionInsert] Script Date: 2018/12/13 19:08:47 ******/
  13892. SET ANSI_NULLS ON
  13893. GO
  13894. SET QUOTED_IDENTIFIER ON
  13895. GO
  13896. --个人关注
  13897. --20151123 nick
  13898. CREATE PROCEDURE [dbo].[pcPaAttentionInsert]
  13899. (
  13900. @paMainID INT,
  13901. @AttentionType INT,
  13902. @AttentionID INT
  13903. )
  13904. AS
  13905. BEGIN
  13906. SET NOCOUNT ON
  13907. IF NOT EXISTS( --判断是否已关注
  13908. SELECT TOP 1 'x' FROM PaAttention
  13909. WHERE PaMainID = @paMainID
  13910. AND AttentionType = @AttentionType
  13911. AND AttentionID = @AttentionID
  13912. )
  13913. BEGIN
  13914. INSERT INTO PaAttention (paMainID,AttentionType,AttentionID,AddDate)
  13915. VALUES(@paMainID,@AttentionType,@AttentionID,GETDATE())
  13916. RETURN 1
  13917. END
  13918. ELSE
  13919. BEGIN
  13920. RETURN 0
  13921. END
  13922. SET NOCOUNT OFF
  13923. END
  13924. GO
  13925. /****** Object: StoredProcedure [dbo].[pcPaCoverLetterByIsDefaultUpdate] Script Date: 2018/12/13 19:08:47 ******/
  13926. SET ANSI_NULLS ON
  13927. GO
  13928. SET QUOTED_IDENTIFIER ON
  13929. GO
  13930. --=============================================
  13931. -- 创建: sean
  13932. -- 检查: 2010-10-6
  13933. -- 说明: 求职信默认值修改 ,改名
  13934. --=============================================
  13935. CREATE PROCEDURE [dbo].[pcPaCoverLetterByIsDefaultUpdate]
  13936. @paMainID INT,
  13937. @ID INT
  13938. AS
  13939. BEGIN TRY
  13940. IF NOT EXISTS(SELECT 'X' FROM paCoverLetter WITH(NOLOCK INDEX(IX_paCoverLetter_paMainID)) WHERE paMainID = @paMainID AND ID = @ID)
  13941. RETURN 0
  13942. UPDATE paCoverLetter SET IsDefault = 0 WHERE paMainID = @paMainID AND ID <> @ID
  13943. UPDATE paCoverLetter SET IsDefault = IsDefault - 1 WHERE ID=@ID
  13944. END TRY
  13945. BEGIN CATCH
  13946. GOTO ERR
  13947. END CATCH
  13948. RETURN 1
  13949. ERR:
  13950. BEGIN
  13951. RETURN 0
  13952. END
  13953. GO
  13954. /****** Object: StoredProcedure [dbo].[pcPaCoverLetterByPaMainIDSelect] Script Date: 2018/12/13 19:08:47 ******/
  13955. SET ANSI_NULLS ON
  13956. GO
  13957. SET QUOTED_IDENTIFIER ON
  13958. GO
  13959. --=============================================
  13960. -- 创建: sean
  13961. -- 检查: 2010-10-6
  13962. -- 说明: 求职信列表
  13963. --=============================================
  13964. CREATE PROCEDURE [dbo].[pcPaCoverLetterByPaMainIDSelect]
  13965. @paMainID INT
  13966. AS
  13967. BEGIN TRY
  13968. SELECT *
  13969. FROM paCoverLetter WITH(NOLOCK INDEX(IX_paCoverLetter_paMainID))
  13970. WHERE paMainID = @paMainID
  13971. ORDER BY IsDefault DESC,ID DESC
  13972. END TRY
  13973. BEGIN CATCH
  13974. END CATCH
  13975. GO
  13976. /****** Object: StoredProcedure [dbo].[pcPaCoverLetterDelete] Script Date: 2018/12/13 19:08:47 ******/
  13977. SET ANSI_NULLS ON
  13978. GO
  13979. SET QUOTED_IDENTIFIER ON
  13980. GO
  13981. --=============================================
  13982. -- 创建: sean
  13983. -- 检查: 2010-10-6
  13984. -- 说明: 求职信删除
  13985. --=============================================
  13986. CREATE PROCEDURE [dbo].[pcPaCoverLetterDelete]
  13987. @paMainID INT,
  13988. @ID INT
  13989. AS
  13990. BEGIN TRY
  13991. IF NOT EXISTS(SELECT 'X' FROM paCoverLetter WITH(NOLOCK) WHERE paMainID = @paMainID AND ID = @ID)
  13992. RETURN 0
  13993. DELETE FROM paCoverLetter WHERE ID = @ID
  13994. RETURN 1
  13995. END TRY
  13996. BEGIN CATCH
  13997. RETURN 0
  13998. END CATCH
  13999. GO
  14000. /****** Object: StoredProcedure [dbo].[pcPaCoverLetterMainTextByIDSelect] Script Date: 2018/12/13 19:08:47 ******/
  14001. SET ANSI_NULLS ON
  14002. GO
  14003. SET QUOTED_IDENTIFIER ON
  14004. GO
  14005. --#####################################################
  14006. --创建时间:2014.11.4
  14007. --创建人:John
  14008. --说明:根据ID 从 PaCoverLetter中得到MainText
  14009. --#####################################################
  14010. CREATE PROCEDURE [dbo].[pcPaCoverLetterMainTextByIDSelect]
  14011. (
  14012. @ID INT
  14013. )
  14014. AS
  14015. BEGIN
  14016. SELECT MainText FROM PaCoverLetter WHERE id = @ID
  14017. END
  14018. GO
  14019. /****** Object: StoredProcedure [dbo].[pcPaCoverLetterMainTextByPaMainIDSelect] Script Date: 2018/12/13 19:08:47 ******/
  14020. SET ANSI_NULLS ON
  14021. GO
  14022. SET QUOTED_IDENTIFIER ON
  14023. GO
  14024. --#####################################################
  14025. --创建时间:2014.11.4
  14026. --创建人:John
  14027. --说明:从 PaCoverLetter中得到MainText
  14028. --#####################################################
  14029. CREATE PROCEDURE [dbo].[pcPaCoverLetterMainTextByPaMainIDSelect]
  14030. (
  14031. @PaMainID INT
  14032. )
  14033. AS
  14034. BEGIN
  14035. SELECT MainText FROM PaCoverLetter WHERE paMainID = @PaMainID AND IsDefault = 1
  14036. END
  14037. GO
  14038. /****** Object: StoredProcedure [dbo].[pcPaCoverLetterSave] Script Date: 2018/12/13 19:08:48 ******/
  14039. SET ANSI_NULLS ON
  14040. GO
  14041. SET QUOTED_IDENTIFIER ON
  14042. GO
  14043. --=============================================
  14044. -- 创建: sean
  14045. -- 检查: 2010-10-6
  14046. -- 说明: 求职信保存 ,改名
  14047. --=============================================
  14048. CREATE PROCEDURE [dbo].[pcPaCoverLetterSave]
  14049. (
  14050. @ID INT,
  14051. @paMainID INT,
  14052. @IsDefault BIT,
  14053. @Title NVARCHAR(20),
  14054. @MainText NVARCHAR(2000)
  14055. )
  14056. AS
  14057. SELECT @MainText = dbo.SafeSQL(dbo.TextTrim(@MainText)), @Title = dbo.SafeSQL(@Title)
  14058. DECLARE @MaxID AS INT
  14059. BEGIN TRY
  14060. IF @ID>0
  14061. BEGIN
  14062. IF NOT EXISTS(SELECT 'x' FROM paCoverLetter WITH(NOLOCK INDEX(PK_paCoverLetter)) WHERE paMainID=@paMainID AND ID = @ID)
  14063. GOTO Err
  14064. UPDATE paCoverLetter
  14065. SET Title = @Title,MainText = @MainText,AddDate=GETDATE()
  14066. WHERE ID=@ID
  14067. AND paMainID = @paMainID
  14068. SET @MaxID = @ID
  14069. END
  14070. ELSE
  14071. BEGIN
  14072. IF EXISTS(SELECT 'x' FROM paCoverLetter WITH(NOLOCK INDEX(IX_paCoverLetter_paMainID)) WHERE paMainID=@paMainID)
  14073. INSERT INTO paCoverLetter(paMainID, IsDefault, Title, MainText)
  14074. VALUES(@paMainID, 0, @Title, @MainText)
  14075. ELSE
  14076. INSERT INTO paCoverLetter(paMainID, IsDefault, Title, MainText)
  14077. VALUES(@paMainID, 1, @Title, @MainText)
  14078. SET @MaxID = @@IDENTITY
  14079. END
  14080. END TRY
  14081. BEGIN CATCH
  14082. GOTO ERR
  14083. END CATCH
  14084. RETURN @MaxID
  14085. ERR:
  14086. BEGIN
  14087. RETURN 0
  14088. END
  14089. GO
  14090. /****** Object: StoredProcedure [dbo].[pcPaCoverLetterSelect] Script Date: 2018/12/13 19:08:48 ******/
  14091. SET ANSI_NULLS ON
  14092. GO
  14093. SET QUOTED_IDENTIFIER ON
  14094. GO
  14095. --=============================================
  14096. -- 创建: sean
  14097. -- 检查: 2010-10-6
  14098. -- 说明: 求职信新提取
  14099. --=============================================
  14100. CREATE PROCEDURE [dbo].[pcPaCoverLetterSelect]
  14101. (
  14102. @ID INT,
  14103. @paMainID INT OUTPUT,
  14104. @IsDefault Bit OUTPUT,
  14105. @Title VARCHAR(40) OUTPUT,
  14106. @MainText VARCHAR(MAX) OUTPUT,
  14107. @AddDate DateTime OUTPUT
  14108. )
  14109. AS
  14110. SELECT @paMainID=paMainID,@IsDefault=IsDefault,@Title=Title,@MainText=MainText,@AddDate=AddDate
  14111. FROM PaCoverLetter WITH(NOLOCK)
  14112. WHERE ID=@ID AND paMainID = @paMainID
  14113. GO
  14114. /****** Object: StoredProcedure [dbo].[pcpaCvImportLogByCvMainIDUpdate] Script Date: 2018/12/13 19:08:48 ******/
  14115. SET ANSI_NULLS ON
  14116. GO
  14117. SET QUOTED_IDENTIFIER ON
  14118. GO
  14119. --#####################################################
  14120. --创建时间:2014.10.31
  14121. --创建人:Nick
  14122. --说明:修改 paCvImportLog
  14123. --#####################################################
  14124. CREATE PROCEDURE [dbo].[pcpaCvImportLogByCvMainIDUpdate]
  14125. (
  14126. @cvMainID INT
  14127. )
  14128. AS
  14129. BEGIN TRY
  14130. UPDATE paCvImportLog SET isSuccess = 1 WHERE cvMainID=@cvMainID
  14131. END TRY
  14132. BEGIN CATCH
  14133. RETURN 0
  14134. END CATCH
  14135. GO
  14136. /****** Object: StoredProcedure [dbo].[pcpaCvImportLogInsert] Script Date: 2018/12/13 19:08:48 ******/
  14137. SET ANSI_NULLS ON
  14138. GO
  14139. SET QUOTED_IDENTIFIER ON
  14140. GO
  14141. --#####################################################
  14142. --创建时间:2014.10.31
  14143. --创建人:Nick
  14144. --说明:插入 paCvImportLog
  14145. --#####################################################
  14146. CREATE PROCEDURE [dbo].[pcpaCvImportLogInsert]
  14147. (
  14148. @cvMainID INT,
  14149. @cvFrom VARCHAR(200)
  14150. )
  14151. AS
  14152. BEGIN TRY
  14153. INSERT INTO paCvImportLog VALUES(@cvMainID,@cvFrom,0,GETDATE())
  14154. END TRY
  14155. BEGIN CATCH
  14156. RETURN 0
  14157. END CATCH
  14158. GO
  14159. /****** Object: StoredProcedure [dbo].[pcPaCvMainByIDSelect] Script Date: 2018/12/13 19:08:48 ******/
  14160. SET ANSI_NULLS ON
  14161. GO
  14162. SET QUOTED_IDENTIFIER ON
  14163. GO
  14164. --#####################################################
  14165. --创建时间:2014.11.4
  14166. --创建人:John
  14167. --说明:根据PaMain的id获取PaMain,CvMain
  14168. --#####################################################
  14169. CREATE PROCEDURE [dbo].[pcPaCvMainByIDSelect]
  14170. (
  14171. @ID INT
  14172. )
  14173. AS
  14174. BEGIN
  14175. SELECT a.ID,a.NAME,a.UserName,a.Email,b.ID cvMainID,b.Name cvName,Adddate
  14176. FROM paMain a WITH(NOLOCK)
  14177. LEFT JOIN cvMain b WITH(NOLOCK) ON a.ID = b.paMainID
  14178. WHERE a.ID = @ID
  14179. END
  14180. GO
  14181. /****** Object: StoredProcedure [dbo].[pcPaCvviewCountSelect] Script Date: 2018/12/13 19:08:48 ******/
  14182. SET ANSI_NULLS ON
  14183. GO
  14184. SET QUOTED_IDENTIFIER ON
  14185. GO
  14186. CREATE PROCEDURE [dbo].[pcPaCvviewCountSelect]
  14187. (
  14188. @paMainId INT
  14189. )
  14190. AS
  14191. SET NOCOUNT ON
  14192. BEGIN
  14193. IF ISNULL(@paMainId, 0) = 0
  14194. BEGIN
  14195. SELECT 0 ViewNumber
  14196. RETURN
  14197. END
  14198. DECLARE @ViewNumber INT, @Cnt INT, @AddDate DateTime
  14199. SELECT @ViewNumber = ViewNumber, @AddDate = AddDate
  14200. FROM paCvViewCount
  14201. WHERE paMainId = @paMainId
  14202. IF ISNULL(@AddDate, GETDATE() - 1) < DATEADD(MINUTE, -120, GETDATE())
  14203. BEGIN
  14204. SELECT @Cnt = COUNT(1)
  14205. FROM caCvviewLog WITH(NOLOCK)
  14206. WHERE cvMainId IN(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainId = @paMainId)
  14207. AND EXISTS(SELECT TOP 1 'X' FROM JobPublish WITH(NOLOCK) WHERE caMainID = caCvviewLog.caMainID)
  14208. IF @ViewNumber IS NOT NULL
  14209. DELETE FROM paCvViewCount WHERE paMainId = @paMainId
  14210. INSERT INTO paCvViewCount(paMainId, ViewNumber, AddDate) SELECT @paMainId, @Cnt, GETDATE()
  14211. SET @ViewNumber = @Cnt
  14212. END
  14213. SELECT @ViewNumber ViewNumber
  14214. END
  14215. SET NOCOUNT OFF
  14216. GO
  14217. /****** Object: StoredProcedure [dbo].[pcPaFavorateBatchDelete] Script Date: 2018/12/13 19:08:48 ******/
  14218. SET ANSI_NULLS ON
  14219. GO
  14220. SET QUOTED_IDENTIFIER ON
  14221. GO
  14222. --====================================
  14223. --返回值:-1:不是你的收藏职位
  14224. --创建: lucifer
  14225. --检查: Sean 2010-10-14
  14226. --删除收藏的职位
  14227. --====================================
  14228. CREATE PROCEDURE [dbo].[pcPaFavorateBatchDelete]
  14229. (
  14230. @AllID VARCHAR(1000),
  14231. @paMainID INT
  14232. )
  14233. AS
  14234. BEGIN TRY
  14235. --生成临时表
  14236. DECLARE @t AS TABLE(ID INT)
  14237. /*
  14238. DECLARE @i INT
  14239. SET @i=CHARINDEX(',',@AllID)
  14240. WHILE @i>=1
  14241. BEGIN
  14242. IF LEFT(@AllID,@i-1) > ''
  14243. INSERT @t VALUES(LEFT(@AllID,@i-1))
  14244. SET @AllID=SUBSTRING(@AllID,@i+1,LEN(@AllID)-@i)
  14245. SET @i=CHARINDEX(',',@AllID)
  14246. END
  14247. IF @AllID > ''
  14248. INSERT @t VALUES(@AllID)
  14249. */
  14250. INSERT INTO @t
  14251. SELECT * FROM dbo.fnSplit(@AllID, ',')
  14252. ----判断是否这些id是同一个paMainID
  14253. IF EXISTS(SELECT 'X' FROM paFavorate a WITH(NOLOCK), @t b
  14254. WHERE a.id=b.id AND a.paMainID<>@paMainID)
  14255. GOTO Err1
  14256. DELETE FROM paFavorate WHERE ID IN(SELECT ID FROM @t)
  14257. END TRY
  14258. BEGIN CATCH
  14259. GOTO ERR
  14260. END CATCH
  14261. RETURN 1
  14262. ERR:
  14263. BEGIN
  14264. RETURN 0
  14265. END
  14266. ERR1:
  14267. BEGIN
  14268. RETURN -1
  14269. END
  14270. GO
  14271. /****** Object: StoredProcedure [dbo].[pcPaFavorateInsert] Script Date: 2018/12/13 19:08:49 ******/
  14272. SET ANSI_NULLS ON
  14273. GO
  14274. SET QUOTED_IDENTIFIER ON
  14275. GO
  14276. --====================================
  14277. --返回值:-1:不是你的收藏职位
  14278. --创建: lucifer
  14279. --检查: Sean 2010-10-14
  14280. --保存收藏的职位 ,先删除、再添加
  14281. --====================================
  14282. CREATE PROCEDURE [dbo].[pcPaFavorateInsert]
  14283. (
  14284. @paMainID INT,
  14285. @JobId INT,
  14286. @Remark VARCHAR(200)
  14287. )
  14288. AS
  14289. BEGIN
  14290. SET @Remark = dbo.SafeSQL(dbo.TRIM(@Remark))
  14291. DECLARE @cnt AS INT
  14292. SELECT @cnt = COUNT(1) FROM paFavorate WITH(NOLOCK) WHERE paMainID = @paMainID
  14293. IF @cnt > 199
  14294. RETURN 0
  14295. IF LEN(@Remark) = 0
  14296. SET @Remark = NULL
  14297. INSERT INTO paFavorate(paMainID,JobId,Remark) VALUES(@paMainID,@JobId,@Remark)
  14298. RETURN 1
  14299. END
  14300. GO
  14301. /****** Object: StoredProcedure [dbo].[pcPaFavorateSelect] Script Date: 2018/12/13 19:08:49 ******/
  14302. SET ANSI_NULLS ON
  14303. GO
  14304. SET QUOTED_IDENTIFIER ON
  14305. GO
  14306. CREATE PROCEDURE [dbo].[pcPaFavorateSelect]
  14307. (
  14308. @WHERE VARCHAR(1000),
  14309. @Order VARCHAR(100)
  14310. )
  14311. AS
  14312. BEGIN
  14313. BEGIN TRY
  14314. SET @Where = dbo.SafeSql(@Where)
  14315. SET @Order = dbo.SafeSql(@Order)
  14316. DECLARE @SQL AS VARCHAR(2000)
  14317. SET @SQL='SELECT a.ID,a.paMainID,a.JobID,a.AddDate,a.Remark,b.Name as JobName,b.IssueDate,
  14318. b.IssueEND,b.dcRegionID,b.IsDelete,c.Name as cpName,c.ID as cpID,c.HasLicence,
  14319. c.IsAgent, c.Membertype, b.dcSalaryID, b.SecondId EnJobID, c.SecondId EnCpMainID,
  14320. b.caMainID, dbo.GetCaOnlineStatus(b.caMainID) AS IsOnline
  14321. FROM paFavorate a WITH(NOLOCK)
  14322. Inner Join Job b WITH(NOLOCK) ON a.JobID=b.ID
  14323. Inner Join cpMain c WITH(NOLOCK) ON b.cpMainID=c.ID'
  14324. IF LEN(@WHERE)>0
  14325. SET @SQL=@SQL + ' WHERE '+ @WHERE
  14326. IF LEN(@ORDER)>0
  14327. SET @SQL=@SQL + ' ORDER BY '+@ORDER
  14328. EXEC(@SQL)
  14329. END TRY
  14330. BEGIN CATCH
  14331. END CATCH
  14332. END
  14333. GO
  14334. /****** Object: StoredProcedure [dbo].[pcpaFavorateUpdate] Script Date: 2018/12/13 19:08:50 ******/
  14335. SET ANSI_NULLS ON
  14336. GO
  14337. SET QUOTED_IDENTIFIER ON
  14338. GO
  14339. --====================================
  14340. --创建: lucifer
  14341. --检查: Sean 2010-10-14
  14342. --修改备注
  14343. --====================================
  14344. CREATE PROCEDURE [dbo].[pcpaFavorateUpdate]
  14345. (
  14346. @ID INT,
  14347. @Remark VARCHAR(200),
  14348. @paMainId INT
  14349. )
  14350. AS
  14351. BEGIN TRAN
  14352. BEGIN TRY
  14353. UPDATE paFavorate SET Remark=dbo.SafeSQL(@Remark) WHERE ID=@ID AND paMainID = @paMainID
  14354. END TRY
  14355. BEGIN CATCH
  14356. GOTO ERR
  14357. END CATCH
  14358. COMMIT TRAN
  14359. RETURN 1
  14360. ERR:
  14361. BEGIN
  14362. ROLLBACK TRAN
  14363. RETURN 0
  14364. END
  14365. GO
  14366. /****** Object: StoredProcedure [dbo].[pcpaFeedBackInsert] Script Date: 2018/12/13 19:08:50 ******/
  14367. SET ANSI_NULLS ON
  14368. GO
  14369. SET QUOTED_IDENTIFIER ON
  14370. GO
  14371. --==================================================
  14372. --检查 sean 2010-10-8
  14373. --描述 新增个人用户反馈
  14374. --==================================================
  14375. CREATE PROCEDURE [dbo].[pcpaFeedBackInsert]
  14376. (
  14377. @paMainID INT,
  14378. @dcProvinceID INT,
  14379. @IP VARCHAR(31),
  14380. @Name VARCHAR(100),
  14381. @Telephone VARCHAR(50),
  14382. @Email VARCHAR(100),
  14383. @Message VARCHAR(4000)
  14384. )
  14385. AS
  14386. BEGIN TRY
  14387. INSERT INTO PaFeedBack(paMainID,dcProvinceID,IP,Name,Telephone,Email,Message,AddDate)
  14388. VALUES(@paMainID,@dcProvinceID,@IP,dbo.SafeSQL(@Name),dbo.SafeSQL(@Telephone),dbo.SafeSQL(@Email),dbo.SafeSQL(@Message),GETDATE())
  14389. RETURN 1
  14390. END TRY
  14391. BEGIN CATCH
  14392. RETURN 0
  14393. END CATCH
  14394. GO
  14395. /****** Object: StoredProcedure [dbo].[pcpaFeedBackNoViewSelect] Script Date: 2018/12/13 19:08:50 ******/
  14396. SET ANSI_NULLS ON
  14397. GO
  14398. SET QUOTED_IDENTIFIER ON
  14399. GO
  14400. --==================================================
  14401. --检查 sean 2010-10-8
  14402. --描述 选择未查看的个人用户反馈
  14403. --==================================================
  14404. CREATE PROCEDURE [dbo].[pcpaFeedBackNoViewSelect]
  14405. (
  14406. @paMainID INT
  14407. )
  14408. AS
  14409. BEGIN
  14410. SELECT *
  14411. FROM paFeedBack WITH(NOLOCK INDEX(IX_paFeedBack_paMainID))
  14412. WHERE paMainID = @paMainID
  14413. AND IsReply = 1
  14414. AND ViewDate IS NULL
  14415. ORDER BY ID DESC
  14416. END
  14417. GO
  14418. /****** Object: StoredProcedure [dbo].[pcpaFeedBackSelect] Script Date: 2018/12/13 19:08:50 ******/
  14419. SET ANSI_NULLS ON
  14420. GO
  14421. SET QUOTED_IDENTIFIER ON
  14422. GO
  14423. --==================================================
  14424. --检查 sean 2010-10-8
  14425. --描述 选择个人用户反馈
  14426. --==================================================
  14427. CREATE PROCEDURE [dbo].[pcpaFeedBackSelect]
  14428. @paMainID INT
  14429. AS
  14430. BEGIN
  14431. SELECT *
  14432. FROM paFeedBack WITH(NOLOCK INDEX(IX_paFeedBack_paMainID))
  14433. WHERE paMainID = @paMainID
  14434. ORDER BY ID DESC
  14435. END
  14436. GO
  14437. /****** Object: StoredProcedure [dbo].[pcPaFeedbackViewDateUpdate] Script Date: 2018/12/13 19:08:51 ******/
  14438. SET ANSI_NULLS ON
  14439. GO
  14440. SET QUOTED_IDENTIFIER ON
  14441. GO
  14442. --==================================================
  14443. --检查 sean 2010-10-8
  14444. --描述asp中取所有viewDate is null的id
  14445. --==================================================
  14446. CREATE PROCEDURE [dbo].[pcPaFeedbackViewDateUpdate]
  14447. @AllID VARCHAR(200),
  14448. @paMainID INT
  14449. AS
  14450. BEGIN TRY
  14451. SET @AllID = dbo.FormatIDS(@AllID)
  14452. DECLARE @T AS TABLE(ID INT)
  14453. INSERT INTO @T SELECT * FROM dbo.fnSplit(@AllID, ',')
  14454. UPDATE paFeedback SET ViewDate=GETDATE() WHERE ID IN(SELECT ID FROM @T) AND paMainID = @paMainID
  14455. RETURN 1
  14456. END TRY
  14457. BEGIN CATCH
  14458. RETURN 0
  14459. END CATCH
  14460. GO
  14461. /****** Object: StoredProcedure [dbo].[pcPaGetPasswordLogByMailSelect] Script Date: 2018/12/13 19:08:51 ******/
  14462. SET ANSI_NULLS ON
  14463. GO
  14464. SET QUOTED_IDENTIFIER ON
  14465. GO
  14466. --======================================
  14467. --一天之内一个账号不能查询超过5次
  14468. --一天之内一个ip不能超过20次
  14469. --======================================
  14470. CREATE PROCEDURE [dbo].[pcPaGetPasswordLogByMailSelect]
  14471. @paMainID INT,
  14472. @IP VARCHAR(31)
  14473. AS
  14474. BEGIN
  14475. DECLARE @d AS DATETIME
  14476. DECLARE @C AS INT
  14477. SET @d = CONVERT(DATETIME,(FLOOR(CONVERT(FLOAT,GETDATE()))))
  14478. SELECT @C = COUNT(1) FROM paGetPasswordLog WITH(NOLOCK) WHERE paMainID = @paMainID AND AddDate>=@d
  14479. IF @c >4
  14480. GOTO Err1
  14481. SELECT @C = COUNT(1) FROM paGetPasswordLog WITH(NOLOCK) WHERE IP = @IP AND AddDate>=@d
  14482. IF @c > 20
  14483. GOTO Err2
  14484. RETURN 1
  14485. END
  14486. Err1:
  14487. BEGIN
  14488. RETURN -1
  14489. END
  14490. Err2:
  14491. BEGIN
  14492. RETURN -2
  14493. END
  14494. GO
  14495. /****** Object: StoredProcedure [dbo].[pcPaJobClickLogByIpSelect] Script Date: 2018/12/13 19:08:51 ******/
  14496. SET ANSI_NULLS ON
  14497. GO
  14498. SET QUOTED_IDENTIFIER ON
  14499. GO
  14500. --#####################################################
  14501. --创建时间:2014.10.30
  14502. --创建人:Nick
  14503. --说明:得到点击次数
  14504. --#####################################################
  14505. CREATE PROCEDURE [dbo].[pcPaJobClickLogByIpSelect]
  14506. (
  14507. @Ip VARCHAR(50),
  14508. @PaMainID INT
  14509. )
  14510. AS
  14511. SET NOCOUNT ON
  14512. --insert proclog select 'pcPaJobClickLogByIpSelect', @ip, getdate()
  14513. BEGIN
  14514. DECLARE @canview TINYINT
  14515. IF EXISTS(SELECT 'x' FROM paJobClickCount WITH(NOLOCK) WHERE Ip = @Ip)
  14516. SET @canview = '0'
  14517. ELSE
  14518. SET @canview = '1'
  14519. SELECT @canview canview
  14520. /*
  14521. DECLARE @Cnt1 INT, @Cnt2 INT
  14522. IF ISNULL(@PaMainID, 0) > 0
  14523. SELECT @Cnt2 = COUNT(1)
  14524. FROM paJobClickLog WITH(NOLOCK)
  14525. WHERE paMainID = @PaMainID
  14526. ELSE
  14527. SET @Cnt2 = 0
  14528. IF @Cnt2 > 9
  14529. BEGIN
  14530. SELECT '0' canview
  14531. RETURN
  14532. END
  14533. SELECT @Cnt1 = COUNT(1)
  14534. FROM paJobClickLog WITH(NOLOCK)
  14535. WHERE Ip = @ip
  14536. DECLARE @canview VARCHAR(1)
  14537. SET @canview = ''
  14538. IF @Cnt1 > 9
  14539. BEGIN
  14540. IF EXISTS(SELECT 'x' FROM Ip_White WHERE CHARINDEX(ip, @ip) > 0)
  14541. BEGIN
  14542. IF @Cnt1 > 99
  14543. SET @canview = '0'
  14544. END
  14545. ELSE
  14546. SET @canview = '0'
  14547. END
  14548. IF @canview = ''
  14549. SET @canview = '1'
  14550. SELECT @canview canview
  14551. */
  14552. END
  14553. GO
  14554. /****** Object: StoredProcedure [dbo].[pcPaJobClickLogCountSelect] Script Date: 2018/12/13 19:08:51 ******/
  14555. SET ANSI_NULLS ON
  14556. GO
  14557. SET QUOTED_IDENTIFIER ON
  14558. GO
  14559. --#####################################################
  14560. --创建时间:2014.10.30
  14561. --创建人:Nick
  14562. --说明:得到点击次数
  14563. --#####################################################
  14564. CREATE PROCEDURE [dbo].[pcPaJobClickLogCountSelect]
  14565. (
  14566. @PaMainID INT
  14567. )
  14568. AS
  14569. BEGIN
  14570. SELECT COUNT(1) cnt
  14571. FROM paJobClickLog WITH(NOLOCK)
  14572. WHERE paMainID = @PaMainID
  14573. --AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 112)
  14574. END
  14575. GO
  14576. /****** Object: StoredProcedure [dbo].[pcPaJobClickLogSelect] Script Date: 2018/12/13 19:08:52 ******/
  14577. SET ANSI_NULLS ON
  14578. GO
  14579. SET QUOTED_IDENTIFIER ON
  14580. GO
  14581. --#####################################################
  14582. --创建时间:2014.10.30
  14583. --创建人:Nick
  14584. --说明:根据职位ID,个人ID 判断是否点击过
  14585. --#####################################################
  14586. CREATE PROCEDURE [dbo].[pcPaJobClickLogSelect]
  14587. (
  14588. @JobID INT,
  14589. @PaMainID INT
  14590. )
  14591. AS
  14592. BEGIN
  14593. SELECT 'x'
  14594. FROM paJobClickLog WITH(NOLOCK)
  14595. WHERE AddDate > CONVERT(VARCHAR(10), GETDATE(), 112)
  14596. AND JobID = @JobID
  14597. AND paMainID = @PaMainID
  14598. END
  14599. GO
  14600. /****** Object: StoredProcedure [dbo].[pcPaJobCompareByHomePageSelect] Script Date: 2018/12/13 19:08:52 ******/
  14601. SET ANSI_NULLS ON
  14602. GO
  14603. SET QUOTED_IDENTIFIER ON
  14604. GO
  14605. --修改harry 过期的职位不显示2017-10-23
  14606. CREATE PROCEDURE [dbo].[pcPaJobCompareByHomePageSelect]
  14607. (
  14608. @PaMainID INT
  14609. )
  14610. AS
  14611. SET NOCOUNT ON
  14612. BEGIN
  14613. SELECT TOP 9 b.ID JobID, b.SecondID EnJobID, b.Name JobName,b.dcSalaryIdMax,b.Negotiable, c.Name CpName,c.HasLicence, c.SecondID EnCpMainID,
  14614. (SELECT CASE WHEN LEN(e.Id) = 6
  14615. THEN RIGHT(e.FullName, LEN(e.FullName) - CHARINDEX(LEFT(e.MapBarName, 2), e.FullName) + 1)
  14616. ELSE e.Abbr
  14617. END
  14618. FROM dcRegion e WITH(NOLOCK) WHERE e.Id = b.dcRegionId) WorkPlace,
  14619. ISNULL((SELECT Description FROM dcEducation WHERE id = b.dcEducationId), '不限') Education,
  14620. b.dcSalaryID,
  14621. (SELECT Description FROM dcOthers WHERE Category = '招聘人数' AND DetailId = b.NeedNumber) NeedNumber,
  14622. 'http://down.51rc.com/imagefolder/Logo/L' + CASE WHEN c.Id < 90000 THEN '0' ELSE '' END + LTRIM(STR(c.Id / 10000 + 1)) + '0000/' + d.ImgFile ImgFile
  14623. FROM PaJobCompare a WITH(NOLOCK)
  14624. INNER JOIN Job b WITH(NOLOCK) ON b.ID = a.CompareJobID
  14625. INNER JOIN CpMain c WITH(NOLOCK) ON c.ID = b.CpMainID
  14626. INNER Join cpImage d WITH(NOLOCK) ON d.cpMainId = c.Id
  14627. WHERE PaMainID = @PaMainID
  14628. AND b.valid = 1
  14629. AND c.HasLogo = 1
  14630. AND d.Imgtype = 1
  14631. ORDER BY a.AddDate DESC
  14632. END
  14633. GO
  14634. /****** Object: StoredProcedure [dbo].[pcPaJobCompareByPaMainIDSelect] Script Date: 2018/12/13 19:08:52 ******/
  14635. SET ANSI_NULLS ON
  14636. GO
  14637. SET QUOTED_IDENTIFIER ON
  14638. GO
  14639. --Harry过期职位不显示2017-10-23
  14640. CREATE PROCEDURE [dbo].[pcPaJobCompareByPaMainIDSelect]
  14641. (
  14642. @PaMainID INT,
  14643. @IsLastBatch BIT,
  14644. @BatchNo SMALLINT
  14645. )
  14646. AS
  14647. SET NOCOUNT ON
  14648. BEGIN
  14649. IF @BatchNo > 0
  14650. BEGIN
  14651. SELECT a.*,b.*,c.Name CpName,c.HasLicence,c.SecondID EnCpMainID,b.ID JobID,b.SecondID EnJobID,
  14652. b.Name JobName,a.AddDate RecommenedDate,c.RealName,
  14653. ISNULL((SELECT IsOnline FROM caOnline WHERE caMainId =b.caMainID), 0) AS IsOnline, c.LogoFile LogoUrl
  14654. FROM PaJobCompare a WITH(NOLOCK)
  14655. LEFT JOIN Job b WITH(NOLOCK) ON b.ID = a.CompareJobID
  14656. LEFT JOIN CpMain c WITH(NOLOCK) ON c.ID = b.CpMainID
  14657. WHERE PaMainID = @PaMainID
  14658. AND BatchNo = @BatchNo
  14659. ORDER BY a.AddDate DESC
  14660. END
  14661. ELSE IF @IsLastBatch = 1
  14662. BEGIN
  14663. SELECT a.*,b.*,c.Name CpName,c.HasLicence,c.SecondID EnCpMainID,b.ID JobID,b.SecondID EnJobID,
  14664. b.Name JobName,a.AddDate RecommenedDate, ISNULL((SELECT IsOnline FROM caOnline WHERE caMainId =b.caMainID), 0) AS IsOnline,
  14665. c.LogoFile LogoUrl, c.RealName
  14666. FROM PaJobCompare a WITH(NOLOCK)
  14667. LEFT JOIN Job b WITH(NOLOCK) ON b.ID = a.CompareJobID
  14668. LEFT JOIN CpMain c WITH(NOLOCK) ON c.ID = b.CpMainID
  14669. WHERE PaMainID = @PaMainID
  14670. AND b.valid = 1
  14671. AND BatchNo = (
  14672. SELECT MAX(BatchNo)
  14673. FROM PaJobCompare WITH(NOLOCK)
  14674. WHERE PaMainID = @PaMainID
  14675. )
  14676. ORDER BY a.AddDate DESC
  14677. END
  14678. ELSE
  14679. BEGIN
  14680. SELECT a.*,b.*,c.Name CpName,c.HasLicence,c.SecondID EnCpMainID,b.ID JobID,b.SecondID EnJobID,
  14681. b.Name JobName,a.AddDate RecommenedDate,ISNULL((SELECT IsOnline FROM caOnline WHERE caMainId =b.caMainID), 0) AS IsOnline,
  14682. c.LogoFile LogoUrl,c.RealName, d.DescriptionCp Salary, e.DescriptionCp SalaryMax, f.MapBarName Region, g.Description Education, h.Description Experience
  14683. FROM PaJobCompare a WITH(NOLOCK)
  14684. LEFT JOIN Job b WITH(NOLOCK) ON b.ID = a.CompareJobID
  14685. LEFT JOIN CpMain c WITH(NOLOCK) ON c.ID = b.CpMainID
  14686. LEFT JOIN dcSalary d WITH(NOLOCK) ON b.dcSalaryId = d.ID
  14687. LEFT JOIN dcSalary e WITH(NOLOCK) ON b.dcSalaryIdMax = e.ID
  14688. LEFT JOIN dcRegion f WITH(NOLOCK) ON b.dcRegionId = f.ID
  14689. LEFT JOIN dcEducation g WITH(NOLOCK) ON b.dcEducationId = g.ID
  14690. LEFT JOIN dcOthers h WITH(NOLOCK) ON b.MinExperience = h.DetailID AND Category = '职位要求工作经验'
  14691. WHERE PaMainID = @PaMainID
  14692. AND b.valid = 1
  14693. ORDER BY a.AddDate DESC
  14694. END
  14695. END
  14696. GO
  14697. /****** Object: StoredProcedure [dbo].[pcpaJobFinderByEmailUpdate] Script Date: 2018/12/13 19:08:53 ******/
  14698. SET ANSI_NULLS ON
  14699. GO
  14700. SET QUOTED_IDENTIFIER ON
  14701. GO
  14702. --增加人:LAMBO 20110104
  14703. --作用:修改搜索器的订阅信息,用于我的搜索器页面
  14704. CREATE PROCEDURE [dbo].[pcpaJobFinderByEmailUpdate]
  14705. @ID INT,
  14706. @paMainID INT,
  14707. @EmailSent SMALLINT,
  14708. @EmailEndDate VARCHAR(20),
  14709. @Email VARCHAR(50),
  14710. @EmailNumber INT
  14711. AS
  14712. BEGIN TRY
  14713. UPDATE paJobFinder SET
  14714. EmailSent=@EmailSent,
  14715. EmailEndDate=dbo.SafeSQL(@EmailEndDate),
  14716. EmailNumber=@EmailNumber,
  14717. Email=dbo.SafeSQL(@Email)
  14718. WHERE ID=@ID
  14719. AND paMainID = @paMainID
  14720. RETURN 1
  14721. END TRY
  14722. BEGIN CATCH
  14723. RETURN 0
  14724. END CATCH
  14725. GO
  14726. /****** Object: StoredProcedure [dbo].[pcPaJobFinderByIDUpdate] Script Date: 2018/12/13 19:08:53 ******/
  14727. SET ANSI_NULLS ON
  14728. GO
  14729. SET QUOTED_IDENTIFIER ON
  14730. GO
  14731. --修改订阅接收频次
  14732. --nick 20151118
  14733. create PROCEDURE [dbo].[pcPaJobFinderByIDUpdate]
  14734. (
  14735. @ID INT,
  14736. @PaMainID INT,
  14737. @EmailSent INT
  14738. )
  14739. AS
  14740. BEGIN
  14741. SET NOCOUNT ON
  14742. UPDATE PaJobFinder
  14743. SET EmailSent = @EmailSent
  14744. WHERE ID = @ID
  14745. AND PaMainID = @PaMainID
  14746. SET NOCOUNT OFF
  14747. END
  14748. GO
  14749. /****** Object: StoredProcedure [dbo].[pcpaJobFinderBypaMainIDSelect] Script Date: 2018/12/13 19:08:53 ******/
  14750. SET ANSI_NULLS ON
  14751. GO
  14752. SET QUOTED_IDENTIFIER ON
  14753. GO
  14754. CREATE PROCEDURE [dbo].[pcpaJobFinderBypaMainIDSelect]
  14755. @paMainID INT
  14756. AS
  14757. BEGIN
  14758. SELECT * FROM paJobFinder WITH(NOLOCK) WHERE paMainID=@paMainID
  14759. END
  14760. GO
  14761. /****** Object: StoredProcedure [dbo].[pcpaJobFinderDelete] Script Date: 2018/12/13 19:08:53 ******/
  14762. SET ANSI_NULLS ON
  14763. GO
  14764. SET QUOTED_IDENTIFIER ON
  14765. GO
  14766. ----###############################
  14767. --删除职位搜索器
  14768. ----###############################
  14769. CREATE PROCEDURE [dbo].[pcpaJobFinderDelete]
  14770. (
  14771. @ID INT,
  14772. @paMainID INT
  14773. )
  14774. AS
  14775. BEGIN
  14776. DELETE FROM paJobFinder WHERE ID = @ID AND paMainID = @paMainID
  14777. IF @@ROWCOUNT = 0
  14778. RETURN 0
  14779. ELSE
  14780. RETURN 1
  14781. END
  14782. GO
  14783. /****** Object: StoredProcedure [dbo].[pcpaJobFinderSave] Script Date: 2018/12/13 19:08:53 ******/
  14784. SET ANSI_NULLS ON
  14785. GO
  14786. SET QUOTED_IDENTIFIER ON
  14787. GO
  14788. --LAMBO 20101125 修改
  14789. --增加对搜索器个数的判断
  14790. CREATE PROCEDURE [dbo].[pcpaJobFinderSave]
  14791. (
  14792. @ID INT,
  14793. @paMainID INT,
  14794. @Name VARCHAR(50),
  14795. @dcJobTypeID VARCHAR(50),
  14796. @dcIndustryID VARCHAR(50),
  14797. @dcRegionID VARCHAR(50),
  14798. @KeyType TINYINT,
  14799. @KeyWord VARCHAR(50),
  14800. @Education TINYINT,
  14801. @EmployType VARCHAR(50),
  14802. @MinExperience VARCHAR(50),
  14803. @Salary VARCHAR(50),
  14804. @EmailSent SMALLINT,
  14805. @EmailEndDate VARCHAR(20),
  14806. @Email VARCHAR(50),
  14807. @EmailNumber INT
  14808. )
  14809. AS
  14810. DECLARE @MaxId AS INT
  14811. BEGIN TRY
  14812. IF @dcJobTypeID = ''
  14813. SET @dcJobTypeID = NULL
  14814. IF @dcIndustryID = ''
  14815. SET @dcIndustryID = NULL
  14816. IF @dcRegionID = ''
  14817. SET @dcRegionID = NULL
  14818. IF @Education = ''
  14819. SET @Education = NULL
  14820. IF @EmployType = ''
  14821. SET @EmployType = NULL
  14822. IF @MinExperience = ''
  14823. SET @MinExperience = NULL
  14824. IF @Salary = ''
  14825. SET @Salary = NULL
  14826. IF @EmailSent = 0
  14827. BEGIN
  14828. SET @EmailEndDate = NUll
  14829. SET @Email = NUll
  14830. SET @EmailNumber = NULL
  14831. END
  14832. ELSE
  14833. SET @EmailEndDate = CONVERT(VARCHAR(10), CONVERT(DATETIME, @EmailEndDate), 120) + ' 23:59:00'
  14834. --PRINT @EmailEndDate
  14835. IF @ID>0
  14836. BEGIN
  14837. UPDATE paJobFinder SET
  14838. dcJobTypeID=@dcJobTypeID,
  14839. dcIndustryID=@dcIndustryID,
  14840. dcRegionID=@dcRegionID,
  14841. KeyType=@KeyType,
  14842. KeyWord=@KeyWord,
  14843. Education=@Education,
  14844. EmployType=@EmployType,
  14845. MinExperience=@MinExperience,
  14846. Salary=@Salary,
  14847. EmailSent=@EmailSent,
  14848. EmailEndDate=@EmailEndDate,
  14849. EmailNumber=@EmailNumber,
  14850. Email=@Email
  14851. WHERE ID=@ID
  14852. AND paMainID = @paMainID
  14853. SET @MaxID=@ID
  14854. END
  14855. ELSE
  14856. BEGIN
  14857. DECLARE @FinderCount INT
  14858. SELECT @FinderCount = COUNT(1) FROM paJobFinder WHERE paMainID = @paMainID
  14859. IF @FinderCount >= 6
  14860. RETURN -1
  14861. INSERT INTO paJobFinder
  14862. (paMainID,Name,dcJobTypeID,dcIndustryID,
  14863. dcRegionID,KeyType,KeyWord,Education,
  14864. EmployType,MinExperience,Salary,
  14865. EmailSent,EmailEndDate,EmailNumber,Email)
  14866. VALUES
  14867. (@paMainID,@Name,@dcJobTypeID,@dcIndustryID,
  14868. @dcRegionID,@KeyType,@KeyWord,@Education,
  14869. @EmployType,@MinExperience,@Salary,
  14870. @EmailSent,@EmailEndDate,@EmailNumber,@Email)
  14871. SET @MaxID = @@IDENTITY
  14872. END
  14873. END TRY
  14874. BEGIN CATCH
  14875. GOTO ERR
  14876. END CATCH
  14877. RETURN @MaxID
  14878. ERR:
  14879. BEGIN
  14880. RETURN 0
  14881. END
  14882. GO
  14883. /****** Object: StoredProcedure [dbo].[pcpaJobFinderSave2] Script Date: 2018/12/13 19:08:53 ******/
  14884. SET ANSI_NULLS ON
  14885. GO
  14886. SET QUOTED_IDENTIFIER ON
  14887. GO
  14888. CREATE PROCEDURE [dbo].[pcpaJobFinderSave2]
  14889. (
  14890. @ID INT,
  14891. @paMainID INT,
  14892. @Name VARCHAR(50),
  14893. @dcJobTypeID VARCHAR(50),
  14894. @dcIndustryID VARCHAR(50),
  14895. @dcRegionID VARCHAR(50),
  14896. @KeyType TINYINT,
  14897. @KeyWord VARCHAR(50),
  14898. @Education TINYINT,
  14899. @EmployType VARCHAR(50),
  14900. @MinExperience VARCHAR(50),
  14901. @Salary VARCHAR(50),
  14902. @EmailSent SMALLINT,
  14903. @EmailEndDate VARCHAR(20),
  14904. @Email VARCHAR(50),
  14905. @EmailNumber INT,
  14906. @IsNegotiable BIT,
  14907. @dcCompanySizeID TINYINT
  14908. )
  14909. AS
  14910. DECLARE @MaxId AS INT
  14911. BEGIN TRY
  14912. IF @dcJobTypeID = ''
  14913. SET @dcJobTypeID = NULL
  14914. IF @dcIndustryID = ''
  14915. SET @dcIndustryID = NULL
  14916. IF @dcRegionID = ''
  14917. SET @dcRegionID = NULL
  14918. IF @Education = ''
  14919. SET @Education = NULL
  14920. IF @EmployType = ''
  14921. SET @EmployType = NULL
  14922. IF @MinExperience = ''
  14923. SET @MinExperience = NULL
  14924. IF @Salary = ''
  14925. SET @Salary = NULL
  14926. IF @IsNegotiable IS NULL
  14927. SET @IsNegotiable = 0
  14928. IF @EmailSent = 0
  14929. BEGIN
  14930. SET @EmailEndDate = NUll
  14931. SET @Email = NUll
  14932. SET @EmailNumber = NULL
  14933. END
  14934. ELSE
  14935. SET @EmailEndDate = CONVERT(VARCHAR(10), CONVERT(DATETIME, @EmailEndDate), 120) + ' 23:59:00'
  14936. ----PRINT @EmailEndDate
  14937. IF @ID>0
  14938. BEGIN
  14939. UPDATE paJobFinder
  14940. SET Name = @Name,
  14941. dcJobTypeID=@dcJobTypeID,
  14942. dcIndustryID=@dcIndustryID,
  14943. dcRegionID=@dcRegionID,
  14944. KeyType=@KeyType,
  14945. KeyWord=@KeyWord,
  14946. Education=@Education,
  14947. EmployType=@EmployType,
  14948. MinExperience=@MinExperience,
  14949. Salary=@Salary,
  14950. EmailSent=@EmailSent,
  14951. EmailEndDate=@EmailEndDate,
  14952. EmailNumber=@EmailNumber,
  14953. Email=@Email,
  14954. IsNegotiable = @IsNegotiable,
  14955. dcCompanySizeID = @dcCompanySizeID
  14956. WHERE ID=@ID
  14957. AND paMainID = @paMainID
  14958. SET @MaxID=@ID
  14959. END
  14960. ELSE
  14961. BEGIN
  14962. DECLARE @FinderCount INT
  14963. SELECT @FinderCount = COUNT(1) FROM paJobFinder WHERE paMainID = @paMainID
  14964. IF @FinderCount >= 6
  14965. BEGIN
  14966. --大于6个将第一个删除 再进行添加
  14967. DELETE FROM paJobFinder WHERE paMainID = @paMainID
  14968. AND ID IN (
  14969. SELECT TOP 1 ID FROM paJobFinder WHERE paMainID = @paMainID
  14970. ORDER BY ID
  14971. )
  14972. --RETURN -1
  14973. END
  14974. INSERT INTO paJobFinder
  14975. (paMainID,Name,dcJobTypeID,dcIndustryID,
  14976. dcRegionID,KeyType,KeyWord,Education,
  14977. EmployType,MinExperience,Salary,
  14978. EmailSent,EmailEndDate,EmailNumber,Email, IsNegotiable, dcCompanySizeID)
  14979. VALUES
  14980. (@paMainID,@Name,@dcJobTypeID,@dcIndustryID,
  14981. @dcRegionID,@KeyType,@KeyWord,@Education,
  14982. @EmployType,@MinExperience,@Salary,
  14983. @EmailSent,@EmailEndDate,@EmailNumber,@Email, @IsNegotiable, @dcCompanySizeID)
  14984. SET @MaxID = @@IDENTITY
  14985. END
  14986. END TRY
  14987. BEGIN CATCH
  14988. GOTO ERR
  14989. END CATCH
  14990. RETURN @MaxID
  14991. ERR:
  14992. BEGIN
  14993. RETURN 0
  14994. END
  14995. GO
  14996. /****** Object: StoredProcedure [dbo].[pcpaJobFinderSelect] Script Date: 2018/12/13 19:08:54 ******/
  14997. SET ANSI_NULLS ON
  14998. GO
  14999. SET QUOTED_IDENTIFIER ON
  15000. GO
  15001. CREATE PROCEDURE [dbo].[pcpaJobFinderSelect]
  15002. @ID INT
  15003. AS
  15004. SELECT * FROM paJobFinder WITH(NOLOCK) WHERE ID=@ID
  15005. GO
  15006. /****** Object: StoredProcedure [dbo].[pcPaJobViewLogBatchSave] Script Date: 2018/12/13 19:08:54 ******/
  15007. SET ANSI_NULLS ON
  15008. GO
  15009. SET QUOTED_IDENTIFIER ON
  15010. GO
  15011. CREATE PROCEDURE [dbo].[pcPaJobViewLogBatchSave]
  15012. (
  15013. @JobIDs VARCHAR(500),
  15014. @paMainID INT
  15015. )
  15016. AS
  15017. BEGIN
  15018. SET @JobIDs = dbo.FormatIDS(@JobIDs)
  15019. IF @paMainID <> 0
  15020. BEGIN
  15021. UPDATE PaJobViewLog SET AddDate=GETDATE()
  15022. WHERE paMainID = @paMainID AND JobID IN (SELECT * FROM dbo.fnSplit(@JobIDs, ','))
  15023. INSERT PaJobViewLog(paMainID,JobID)
  15024. SELECT @paMainID,a FROM dbo.fnSplit(@JobIDs, ',')
  15025. WHERE a NOT IN (SELECT JobID FROM paJobViewLog WITH(NOLOCK) WHERE paMainID = @paMainID)
  15026. END
  15027. UPDATE Job SET ViewNumber = ViewNumber + 1 WHERE ID IN (SELECT * FROM dbo.fnSplit(@JobIDs, ','))
  15028. END
  15029. GO
  15030. /****** Object: StoredProcedure [dbo].[pcPaJobViewLogSave] Script Date: 2018/12/13 19:08:54 ******/
  15031. SET ANSI_NULLS ON
  15032. GO
  15033. SET QUOTED_IDENTIFIER ON
  15034. GO
  15035. --====================================
  15036. --创建: lucifer
  15037. --检查: Sean 2010-10-14
  15038. --职位查看记录
  15039. --====================================
  15040. CREATE PROCEDURE [dbo].[pcPaJobViewLogSave]
  15041. (
  15042. @paMainID INT,
  15043. @JobID INT
  15044. )
  15045. AS
  15046. SET NOCOUNT ON
  15047. BEGIN TRY
  15048. IF @paMainID > 0
  15049. IF EXISTS(SELECT 'x' FROM PaJobViewLog WITH(NOLOCK) WHERE paMainID=@paMainID AND JobID=@JobID)
  15050. UPDATE PaJobViewLog SET AddDate = GETDATE() WHERE paMainID = @paMainID AND JobID = @JobID
  15051. ELSE
  15052. INSERT PaJobViewLog(paMainID, JobID) VALUES(@paMainID, @JobID)
  15053. UPDATE Job SET ViewNumber = ViewNumber + 1 WHERE ID = @JobID
  15054. END TRY
  15055. BEGIN CATCH
  15056. END CATCH
  15057. GO
  15058. /****** Object: StoredProcedure [dbo].[pcPaJobViewLogSelect] Script Date: 2018/12/13 19:08:54 ******/
  15059. SET ANSI_NULLS ON
  15060. GO
  15061. SET QUOTED_IDENTIFIER ON
  15062. GO
  15063. CREATE PROCEDURE [dbo].[pcPaJobViewLogSelect]
  15064. (
  15065. @WHERE VARCHAR(1000),
  15066. @Order VARCHAR(100)
  15067. )
  15068. AS
  15069. BEGIN
  15070. BEGIN TRY
  15071. SET @Where = dbo.SafeSql(@Where)
  15072. SET @Order = dbo.SafeSql(@Order)
  15073. DECLARE @SQL AS VARCHAR(2000)
  15074. SET @SQL = 'SELECT JobID,paMainID,a.AddDate,b.Name as JobName,b.IssueDate,b.IssueEND, b.SecondId EnJobID, c.SecondId EnCpMainID,
  15075. b.dcRegionID,b.IsDelete,c.Name as cpName,c.ID as cpID,c.HasLicence, c.IsAgent, c.MemberType, b.dcSalaryId,b.caMainID,
  15076. dbo.GetCaOnlineStatus(b.caMainID) AS IsOnline
  15077. FROM paJobViewLog a WITH(NOLOCK)
  15078. inner join Job b WITH(NOLOCK) On a.JobID = b.ID
  15079. inner join cpMain c WITH(NOLOCK) On b.cpMainID = c.ID'
  15080. IF LEN(@WHERE)>0
  15081. SET @SQL=@SQL + ' WHERE '+@WHERE
  15082. IF LEN(@ORDER)>0
  15083. SET @SQL=@SQL + ' ORDER BY '+@ORDER
  15084. EXEC(@SQL)
  15085. END TRY
  15086. BEGIN CATCH
  15087. END CATCH
  15088. END
  15089. GO
  15090. /****** Object: StoredProcedure [dbo].[pcPaLoginLogSelect] Script Date: 2018/12/13 19:08:54 ******/
  15091. SET ANSI_NULLS ON
  15092. GO
  15093. SET QUOTED_IDENTIFIER ON
  15094. GO
  15095. CREATE PROCEDURE [dbo].[pcPaLoginLogSelect]
  15096. (
  15097. @paMainID INT
  15098. )
  15099. AS
  15100. BEGIN
  15101. SELECT Top 100 a.*,b.Name
  15102. FROM PaLoginLog a WITH(NOLOCK),paMain b WITH(NOLOCK)
  15103. WHERE a.paMainID = @paMainID
  15104. AND a.paMainID = b.ID
  15105. ORDER BY a.Adddate DESC
  15106. END
  15107. GO
  15108. /****** Object: StoredProcedure [dbo].[pcPaLoginRegCountByDcSubSiteIdUpdate] Script Date: 2018/12/13 19:08:55 ******/
  15109. SET ANSI_NULLS ON
  15110. GO
  15111. SET QUOTED_IDENTIFIER ON
  15112. GO
  15113. /*++++++++++++++++++++++++++++++++++++
  15114. sean 2014-2-17
  15115. ++++++++++++++++++++++++++++++++++++*/
  15116. CREATE PROCEDURE [dbo].[pcPaLoginRegCountByDcSubSiteIdUpdate]
  15117. (
  15118. @dcSubSiteId INT,
  15119. @Col VARCHAR(20)
  15120. )
  15121. AS
  15122. BEGIN
  15123. IF @Col = 'oneminuteload'
  15124. UPDATE PaLoginRegCount SET OneMinuteLoad = OneMinuteLoad + 1 WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112) AND dcSubSiteId = @dcSubSiteId
  15125. ELSE IF @Col = 'OneMinuteCreate'
  15126. UPDATE PaLoginRegCount SET OneMinuteCreate = OneMinuteCreate + 1 WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112) AND dcSubSiteId = @dcSubSiteId
  15127. ELSE IF @Col = 'OneMinuteLogin'
  15128. UPDATE PaLoginRegCount SET OneMinuteLogin = OneMinuteLogin + 1 WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112) AND dcSubSiteId = @dcSubSiteId
  15129. ELSE IF @Col = 'LoginPageLogin'
  15130. UPDATE PaLoginRegCount SET LoginPageLogin = LoginPageLogin + 1 WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112) AND dcSubSiteId = @dcSubSiteId
  15131. ELSE IF @Col = 'LoginPageReg'
  15132. UPDATE PaLoginRegCount SET LoginPageReg = LoginPageReg + 1 WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112) AND dcSubSiteId = @dcSubSiteId
  15133. END
  15134. GO
  15135. /****** Object: StoredProcedure [dbo].[pcPaLoginRegCountUpdate] Script Date: 2018/12/13 19:08:55 ******/
  15136. SET ANSI_NULLS ON
  15137. GO
  15138. SET QUOTED_IDENTIFIER ON
  15139. GO
  15140. /*++++++++++++++++++++++++++++++++++++
  15141. sean 2014-2-13
  15142. ++++++++++++++++++++++++++++++++++++*/
  15143. CREATE PROCEDURE [dbo].[pcPaLoginRegCountUpdate]
  15144. (
  15145. @Col VARCHAR(20)
  15146. )
  15147. AS
  15148. BEGIN
  15149. IF @Col = 'oneminuteload'
  15150. UPDATE PaLoginRegCount SET OneMinuteLoad = OneMinuteLoad + 1 WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112) AND dcSubSiteId = 0
  15151. ELSE IF @Col = 'OneMinuteCreate'
  15152. UPDATE PaLoginRegCount SET OneMinuteCreate = OneMinuteCreate + 1 WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112) AND dcSubSiteId = 0
  15153. ELSE IF @Col = 'OneMinuteLogin'
  15154. UPDATE PaLoginRegCount SET OneMinuteLogin = OneMinuteLogin + 1 WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112) AND dcSubSiteId = 0
  15155. ELSE IF @Col = 'LoginPageLogin'
  15156. UPDATE PaLoginRegCount SET LoginPageLogin = LoginPageLogin + 1 WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112) AND dcSubSiteId = 0
  15157. ELSE IF @Col = 'LoginPageReg'
  15158. UPDATE PaLoginRegCount SET LoginPageReg = LoginPageReg + 1 WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112) AND dcSubSiteId = 0
  15159. END
  15160. GO
  15161. /****** Object: StoredProcedure [dbo].[pcPaMailLogRegisterInsert] Script Date: 2018/12/13 19:08:55 ******/
  15162. SET ANSI_NULLS ON
  15163. GO
  15164. SET QUOTED_IDENTIFIER ON
  15165. GO
  15166. CREATE PROCEDURE [dbo].[pcPaMailLogRegisterInsert]
  15167. @paMainID INT,
  15168. @Email VARCHAR(50),
  15169. @Subject VARCHAR(50),
  15170. @Remark VARCHAR(500)
  15171. AS
  15172. BEGIN
  15173. BEGIN TRY
  15174. INSERT INTO paMailLog(paMainID,Email,Subject,Remark) VALUES(@paMainID,dbo.SafeSQL(@Email),dbo.SafeSQL(@Subject),dbo.SafeSQL(@Remark))
  15175. RETURN @@IDENTITY
  15176. END TRY
  15177. BEGIN CATCH
  15178. RETURN 0
  15179. END CATCH
  15180. END
  15181. GO
  15182. /****** Object: StoredProcedure [dbo].[pcPaMainByAllSelect] Script Date: 2018/12/13 19:08:55 ******/
  15183. SET ANSI_NULLS ON
  15184. GO
  15185. SET QUOTED_IDENTIFIER ON
  15186. GO
  15187. CREATE PROCEDURE [dbo].[pcPaMainByAllSelect]
  15188. @ID INT
  15189. AS
  15190. BEGIN
  15191. SELECT *,
  15192. (SELECT TOP 1 LoginIP FROM paLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = paMain.ID ORDER BY ID DESC) AS LastLoginIP,
  15193. (SELECT COUNT(1) FROM paLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = paMain.ID AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)) AS TodayLoginNum
  15194. FROM paMain WITH(NOLOCK INDEX(PK_paMain))
  15195. WHERE ID=@ID
  15196. END
  15197. GO
  15198. /****** Object: StoredProcedure [dbo].[pcPaMainByBackLogin] Script Date: 2018/12/13 19:08:56 ******/
  15199. SET ANSI_NULLS ON
  15200. GO
  15201. SET QUOTED_IDENTIFIER ON
  15202. GO
  15203. --***********************************************************
  15204. --返回值:
  15205. -- 0:未定义错误
  15206. -- -1:用户名、密码不正确
  15207. -- -2:验证码不正确
  15208. -- 正整数:正确的ID
  15209. --后台登陆用
  15210. --***********************************************************
  15211. CREATE PROCEDURE [dbo].[pcPaMainByBackLogin]
  15212. (
  15213. @UID VARCHAR(20),
  15214. @PaMainID INT
  15215. )
  15216. AS
  15217. BEGIN TRY
  15218. DECLARE @ID AS INT
  15219. SELECT TOP 1 @ID = ID
  15220. FROM BsPaBackLogin WITH(NOLOCK)
  15221. WHERE UnqueID=@UID
  15222. AND HasLogin = 0
  15223. AND PaMainID=@PaMainID
  15224. IF @ID IS NOT NULL
  15225. BEGIN
  15226. UPDATE BsPaBackLogin SET HasLogin = 1 WHERE ID = @ID
  15227. --DELETE FROM BsPaBackLogin WHERE AddDate < GETDATE()-0.2
  15228. IF EXISTS(SELECT 'X' FROM paMain WITH(NOLOCK)
  15229. WHERE ID=@PaMainID
  15230. )
  15231. RETURN 1
  15232. ELSE
  15233. RETURN 0
  15234. END
  15235. END TRY
  15236. BEGIN CATCH
  15237. RETURN -1
  15238. END CATCH
  15239. GO
  15240. /****** Object: StoredProcedure [dbo].[pcPaMainByCareerStatusUpdate] Script Date: 2018/12/13 19:08:56 ******/
  15241. SET ANSI_NULLS ON
  15242. GO
  15243. SET QUOTED_IDENTIFIER ON
  15244. GO
  15245. --####################################
  15246. --更新求职状态
  15247. --返回值:
  15248. -- -2 求职状态为空
  15249. --####################################
  15250. CREATE PROCEDURE [dbo].[pcPaMainByCareerStatusUpdate]
  15251. (
  15252. @PaMainID INT,
  15253. @dcCareerStatus TINYINT,
  15254. @IP VARCHAR(39)
  15255. )
  15256. AS
  15257. SET NOCOUNT ON
  15258. BEGIN
  15259. SET NOCOUNT ON
  15260. IF @dcCareerStatus IS NULL
  15261. RETURN -2 --求职状态为空
  15262. UPDATE paMain
  15263. SET dcCareerStatus = @dcCareerStatus,
  15264. LastModifyDate = GETDATE()
  15265. WHERE ID = @PaMainID
  15266. UPDATE CvMain SET RefreshDate = GETDATE() WHERE paMainID = @paMainID
  15267. SET NOCOUNT OFF
  15268. END
  15269. GO
  15270. /****** Object: StoredProcedure [dbo].[pcPaMainByCvMainIDSelect] Script Date: 2018/12/13 19:08:56 ******/
  15271. SET ANSI_NULLS ON
  15272. GO
  15273. SET QUOTED_IDENTIFIER ON
  15274. GO
  15275. --#####################################################
  15276. --创建时间:2014.10.31
  15277. --创建人:Nick
  15278. --说明:
  15279. --#####################################################
  15280. CREATE PROCEDURE [dbo].[pcPaMainByCvMainIDSelect]
  15281. (
  15282. @CvMainID INT,
  15283. @CpMainID INT
  15284. )
  15285. AS
  15286. BEGIN TRY
  15287. SELECT a.ID paMainID,a.Name,UserName,Email,dbo.GetPaName(b.ID,@CpMainID) AS paName,b.ID
  15288. FROM paMain a WITH(NOLOCK),cvMain b WITH(NOLOCK)
  15289. WHERE a.ID=b.paMainID AND b.ID=@CvMainID
  15290. END TRY
  15291. BEGIN CATCH
  15292. RETURN 0
  15293. END CATCH
  15294. GO
  15295. /****** Object: StoredProcedure [dbo].[pcPaMainByGetPasswordSelect] Script Date: 2018/12/13 19:08:56 ******/
  15296. SET ANSI_NULLS ON
  15297. GO
  15298. SET QUOTED_IDENTIFIER ON
  15299. GO
  15300. -- =============================================
  15301. -- Author: Sean
  15302. -- Create date: 2012-3-6
  15303. -- Description: 取回密码 先检查用户名是否在pamain,Resume_Xixni。如果没有结果则检查是否有邮箱
  15304. --2012.3.6 和取回前、取回后的验证、插入一起
  15305. -- =============================================
  15306. CREATE PROCEDURE [dbo].[pcPaMainByGetPasswordSelect]
  15307. (
  15308. @Username VARCHAR(50),
  15309. @Email VARCHAR(50),
  15310. @Mobile VARCHAR(11),
  15311. @IP VARCHAR(15),
  15312. @VerifyCode VARCHAR(10),
  15313. @SubSiteName VARCHAR(40)
  15314. )
  15315. AS
  15316. BEGIN
  15317. DECLARE @Cnt AS INT, @Type AS VARCHAR(10), @ToDay AS DATETIME, @QueryMobile AS INT
  15318. ----如果用户名、邮箱、手机号都为空则返回
  15319. IF LEN(ISNULL(@Username, '')) = 0 AND LEN(ISNULL(@Email, '')) = 0 AND LEN(ISNULL(@Mobile, '')) = 0
  15320. GOTO Err3
  15321. --SET @Mobile = ''
  15322. ----@t是返回结果临时表
  15323. DECLARE @t AS TABLE(
  15324. ID INT,
  15325. Name NVARCHAR(50) NOT NULL,
  15326. UserName VARCHAR(50) NOT NULL,
  15327. Email VARCHAR(50) NOT NULL,
  15328. Gender NVARCHAR(10),
  15329. Mobile VARCHAR(13),
  15330. ReturnType VARCHAR(10),
  15331. UniqueId VARCHAR(40),
  15332. ActivateCode VARCHAR(6),
  15333. AskNo VARCHAR(40)
  15334. )
  15335. SELECT @Type = 'Email', @QueryMobile = 0
  15336. IF dbo.IsMobile(@Mobile) = 1 ----手机号是否合法
  15337. BEGIN
  15338. SET @QueryMobile = 1 ----手机号合法,则优先使用手机查询
  15339. ----一天内手机取回密码次数
  15340. SELECT @Cnt = COUNT(DISTINCT AskNo) FROM paGetPasswordLog WITH(NOLOCK) WHERE Mobile = @Mobile AND AddDate > GETDATE() - 1
  15341. IF @Cnt >= 3 ----总数=0,按手机号取回
  15342. GOTO Err4
  15343. SET @Type = 'Mobile'
  15344. END
  15345. IF @Type = 'Email' ----按油箱、用户名取回次数
  15346. BEGIN
  15347. SET @ToDay = CONVERT(DATETIME, CONVERT(VARCHAR(8), GETDATE(), 112))
  15348. IF LEN(ISNULL(@Username, '')) > 0 ----用户名
  15349. BEGIN
  15350. SELECT @Cnt = COUNT(1) FROM paGetPasswordLog WITH(NOLOCK) WHERE Username = @Username AND AddDate > @Today
  15351. SET @Type='Username'
  15352. END
  15353. ELSE ----其次Email
  15354. SELECT @Cnt = COUNT(1) FROM paGetPasswordLog WITH(NOLOCK) WHERE Email = @Email AND AddDate > @Today
  15355. IF @Cnt > 4 ----一天之内一个账号最多取回5次
  15356. GOTO Err1
  15357. SELECT @Cnt = COUNT(1) FROM paGetPasswordLog WITH(NOLOCK) WHERE IP = @IP AND AddDate >= @Today
  15358. IF @Cnt > 20 ----一天之内一个ip不能超过20次,很多手机是一个ip,所以不管手机了
  15359. GOTO Err2
  15360. END
  15361. SELECT @Cnt = 0
  15362. IF @QueryMobile = 1 ----按照手机号查询
  15363. BEGIN
  15364. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15365. SELECT TOP 10 ID,
  15366. ISNULL(ISNULL(CONVERT(VARCHAR(50), Name), CONVERT(VARCHAR(50), NameEng)), UserName) Name,
  15367. Username,
  15368. Email,
  15369. CASE Gender WHEN 0 THEN '先生' WHEN 1 THEN '女士' ELSE NULL END Gender,
  15370. Mobile
  15371. FROM paMain WITH(NOLOCK INDEX(IX_PaMain_Mobile))
  15372. WHERE Mobile = @Mobile
  15373. AND MobileVerifyDate IS NOT NULL
  15374. ORDER BY Lastlogindate DESC
  15375. IF NOT EXISTS(SELECT 'x' FROM @t)
  15376. GOTO Err3
  15377. END
  15378. ELSE IF LEN(ISNULL(@Username, '')) > 0 --如果有用户名则以用户名为主
  15379. BEGIN
  15380. SET @Type='Username'
  15381. --先查询paMain.UserName = @UserName 区分大小写
  15382. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15383. SELECT TOP 1 ID,
  15384. ISNULL(ISNULL(CONVERT(VARCHAR(50), Name), CONVERT(VARCHAR(50), NameEng)), UserName) COLLATE Chinese_PRC_CI_AS Name,
  15385. Username COLLATE Chinese_PRC_CI_AS,
  15386. Email,
  15387. CASE Gender WHEN 0 THEN '先生' WHEN 1 THEN '女士' ELSE NULL END Gender,
  15388. Mobile
  15389. FROM paMain WITH(NOLOCK INDEX(IX_PaMain_UserName))
  15390. WHERE UserName = @Username
  15391. IF (SELECT COUNT(*) FROM @t) > 0 --有值则返回
  15392. GOTO Retu
  15393. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15394. SELECT top 1 0 ID,
  15395. Username COLLATE Chinese_PRC_CI_AS Name,
  15396. Username COLLATE Chinese_PRC_CI_AS,
  15397. Email,
  15398. NULL Gender,
  15399. NULL Mobile
  15400. FROM Resume_Xinxi WITH(NOLOCK INDEX(IX_Resume_Xinxi_UserName))
  15401. WHERE UserName = @Username
  15402. IF (SELECT COUNT(*) FROM @t) > 0 --有值则返回
  15403. GOTO Retu
  15404. --先查询paMain.UserName = @UserName 不区分大小写
  15405. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15406. SELECT TOP 1 ID,
  15407. ISNULL(ISNULL(CONVERT(VARCHAR(50), Name), CONVERT(VARCHAR(50), NameEng)), UserName) COLLATE Chinese_PRC_CI_AS Name,
  15408. Username COLLATE Chinese_PRC_CI_AS,
  15409. Email,
  15410. CASE Gender WHEN 0 THEN '先生' WHEN 1 THEN '女士' ELSE NULL END Gender,
  15411. Mobile
  15412. FROM paMain WITH(NOLOCK INDEX(IX_PaMain_UserNameLower))
  15413. WHERE UserNameLower = @Username
  15414. ORDER BY Lastlogindate DESC
  15415. IF (SELECT COUNT(*) FROM @t) > 0 --有值则返回
  15416. GOTO Retu
  15417. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15418. SELECT top 1 0 ID,
  15419. Username COLLATE Chinese_PRC_CI_AS Name,
  15420. Username COLLATE Chinese_PRC_CI_AS,
  15421. Email,
  15422. NULL Gender,
  15423. NULL Mobile
  15424. FROM Resume_Xinxi WITH(NOLOCK INDEX(IX_Resume_Xinxi_UserNameLower))
  15425. WHERE UserNameLower = @Username
  15426. IF NOT EXISTS(SELECT 'x' FROM @t)
  15427. GOTO Err3
  15428. END
  15429. ELSE IF LEN(ISNULL(@Email, '')) > 0 ----查询paMain.Email
  15430. BEGIN
  15431. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15432. SELECT top 10 ID,
  15433. ISNULL(ISNULL(Name, NameEng), UserName) Name,
  15434. Username,
  15435. Email,
  15436. CASE Gender WHEN 0 THEN '先生' WHEN 1 THEN '女士' ELSE NULL END Gender,
  15437. Mobile
  15438. FROM paMain WITH(NOLOCK INDEX(IX_paMain_Email))
  15439. WHERE Email = @Email
  15440. --IF (SELECT COUNT(*) FROM @t) > 0 --有值则返回
  15441. -- GOTO Retu
  15442. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15443. SELECT 0 ID,
  15444. Username Name,
  15445. Username,
  15446. Email,
  15447. NULL Gender,
  15448. NULL Mobile
  15449. FROM Resume_Xinxi WITH(NOLOCK INDEX(IX_Resume_Xinxi_Email))
  15450. WHERE Email = @Email
  15451. IF NOT EXISTS(SELECT 'x' FROM @t)
  15452. GOTO Err3
  15453. END
  15454. END
  15455. Retu: ----正确返回,有数据
  15456. BEGIN
  15457. DECLARE @AskNo AS VARCHAR(40),@ActivateCode AS VARCHAR(6)
  15458. SELECT @AskNo = REPLACE(NEWID(), '-', ''), @ActivateCode = RAND() * 899999 + 100000
  15459. UPDATE @t SET ReturnType = @Type, UniqueId = REPLACE(NEWID(), '-', ''), ActivateCode = @ActivateCode, AskNo=@AskNo ----修改返回类型,用于前台显示结果
  15460. ----记录取回纪录
  15461. INSERT INTO PaGetPasswordLog(paMainID, UserNameIn, EmailIn, VerifyCode, IP, UserName, Email, Mobile,UniqueId,ActivateCode,AskNo)
  15462. SELECT ID, @UserName, @Email, @VerifyCode, @IP, UserName, Email, Mobile,UniqueId, ActivateCode,@AskNo FROM @t
  15463. IF @Type = 'Mobile'
  15464. BEGIN
  15465. DECLARE @curUserName AS VARCHAR(50),@curActivateCode AS VARCHAR(10),@Msg AS VARCHAR(200),@Index AS INT
  15466. INSERT SmsMessageLog(SendMan, ManagerUSerId, paMainId, caMainId, Mobile, MsgType, IsCat, Msg)
  15467. SELECT TOP 1 0, NULL, a.ID, NULL, a.Mobile, 104, 0,
  15468. '您好,您在' + REPLACE(@SubSiteName, 'http://', '') + '的激活码是:' + d.ActivateCode
  15469. FROM paMain a WITH(NOLOCK), (SELECT TOP 1 ID, ActivateCode FROM @t ORDER BY ID DESC) d
  15470. WHERE a.ID = d.Id
  15471. AND a.Mobile > ''
  15472. ORDER BY ID DESC
  15473. END
  15474. UPDATE @t SET ReturnType = @Type ----修改返回类型,用于前台显示结果
  15475. SELECT * FROM @t ORDER BY ID DESC
  15476. RETURN
  15477. END
  15478. Err1: ----一个账号一天取回超过5次
  15479. BEGIN
  15480. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 1 ReturnType
  15481. RETURN
  15482. END
  15483. Err2: ----一个ip一天取回超过20次
  15484. BEGIN
  15485. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 2 ReturnType
  15486. RETURN
  15487. END
  15488. Err3: ----没有取回数据
  15489. BEGIN
  15490. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 3 ReturnType
  15491. RETURN
  15492. END
  15493. Err4: ----手机号一天取回超过3次
  15494. BEGIN
  15495. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 4 ReturnType
  15496. RETURN
  15497. END
  15498. GO
  15499. /****** Object: StoredProcedure [dbo].[pcPaMainByGetPasswordSelectNew] Script Date: 2018/12/13 19:08:56 ******/
  15500. SET ANSI_NULLS ON
  15501. GO
  15502. SET QUOTED_IDENTIFIER ON
  15503. GO
  15504. CREATE PROCEDURE [dbo].[pcPaMainByGetPasswordSelectNew]
  15505. (
  15506. @Username VARCHAR(50),
  15507. @Email VARCHAR(50),
  15508. @Mobile VARCHAR(11),
  15509. @IP VARCHAR(15),
  15510. @VerifyCode VARCHAR(10),
  15511. @SubSiteName VARCHAR(40),
  15512. @txtRealName NVARCHAR(10)
  15513. )
  15514. AS
  15515. BEGIN
  15516. DECLARE @Cnt AS INT, @Type AS VARCHAR(10), @ToDay AS DATETIME, @QueryMobile AS INT
  15517. ----如果用户名、邮箱、手机号都为空则返回
  15518. IF LEN(ISNULL(@Username, '')) = 0 AND LEN(ISNULL(@Email, '')) = 0 AND LEN(ISNULL(@Mobile, '')) = 0
  15519. GOTO Err3
  15520. --SET @Mobile = ''
  15521. ----@t是返回结果临时表
  15522. DECLARE @t AS TABLE(
  15523. ID INT,
  15524. Name NVARCHAR(50) NOT NULL,
  15525. UserName VARCHAR(50) NOT NULL,
  15526. Email VARCHAR(50) NOT NULL,
  15527. Gender NVARCHAR(10),
  15528. Mobile VARCHAR(13),
  15529. ReturnType VARCHAR(10),
  15530. UniqueId VARCHAR(40),
  15531. ActivateCode VARCHAR(6),
  15532. AskNo VARCHAR(40)
  15533. )
  15534. SELECT @Type = 'Email', @QueryMobile = 0
  15535. IF dbo.IsMobile(@Mobile) = 1 ----手机号是否合法
  15536. BEGIN
  15537. SET @QueryMobile = 1 ----手机号合法,则优先使用手机查询
  15538. ----一天内手机取回密码次数
  15539. SELECT @Cnt = COUNT(DISTINCT AskNo) FROM paGetPasswordLog WITH(NOLOCK) WHERE Mobile = @Mobile AND AddDate > GETDATE() - 1
  15540. IF @Cnt >= 3 ----总数=0,按手机号取回
  15541. GOTO Err4
  15542. SET @Type = 'Mobile'
  15543. END
  15544. IF @Type = 'Email' ----按油箱、用户名取回次数
  15545. BEGIN
  15546. SET @ToDay = CONVERT(DATETIME, CONVERT(VARCHAR(8), GETDATE(), 112))
  15547. IF LEN(ISNULL(@Username, '')) > 0 ----用户名
  15548. BEGIN
  15549. SELECT @Cnt = COUNT(1) FROM paGetPasswordLog WITH(NOLOCK) WHERE Username = @Username AND AddDate > @Today
  15550. SET @Type='Username'
  15551. END
  15552. ELSE ----其次Email
  15553. SELECT @Cnt = COUNT(1) FROM paGetPasswordLog WITH(NOLOCK) WHERE Email = @Email AND AddDate > @Today
  15554. IF @Cnt > 4 ----一天之内一个账号最多取回5次
  15555. GOTO Err1
  15556. SELECT @Cnt = COUNT(1) FROM paGetPasswordLog WITH(NOLOCK) WHERE IP = @IP AND AddDate >= @Today
  15557. IF @Cnt > 20 ----一天之内一个ip不能超过20次,很多手机是一个ip,所以不管手机了
  15558. GOTO Err2
  15559. END
  15560. SELECT @Cnt = 0
  15561. IF @QueryMobile = 1 ----按照手机号查询
  15562. BEGIN
  15563. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15564. SELECT TOP 10 ID,
  15565. ISNULL(ISNULL(CONVERT(VARCHAR(50), Name), CONVERT(VARCHAR(50), NameEng)), UserName) Name,
  15566. Username,
  15567. Email,
  15568. CASE Gender WHEN 0 THEN '先生' WHEN 1 THEN '女士' ELSE NULL END Gender,
  15569. Mobile
  15570. FROM paMain WITH(NOLOCK INDEX(IX_PaMain_Mobile))
  15571. WHERE Mobile = @Mobile
  15572. AND MobileVerifyDate IS NOT NULL
  15573. ORDER BY Lastlogindate DESC
  15574. IF NOT EXISTS(SELECT 'x' FROM @t)
  15575. GOTO Err3
  15576. IF LEN(ISNULL(@txtRealName, '')) > 0
  15577. BEGIN
  15578. IF NOT EXISTS(SELECT 'x' FROM @t WHERE Name = @txtRealName) --姓名不一致
  15579. BEGIN
  15580. GOTO Err5
  15581. END
  15582. ELSE
  15583. BEGIN
  15584. DELETE FROM @t WHERE Name <> @txtRealName --手机号取回的 需要姓名一致
  15585. END
  15586. END
  15587. END
  15588. ELSE IF LEN(ISNULL(@Username, '')) > 0 --如果有用户名则以用户名为主
  15589. BEGIN
  15590. SET @Type='Username'
  15591. --先查询paMain.UserName = @UserName 区分大小写
  15592. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15593. SELECT TOP 1 ID,
  15594. ISNULL(ISNULL(CONVERT(VARCHAR(50), Name), CONVERT(VARCHAR(50), NameEng)), UserName) COLLATE Chinese_PRC_CI_AS Name,
  15595. Username COLLATE Chinese_PRC_CI_AS,
  15596. Email,
  15597. CASE Gender WHEN 0 THEN '先生' WHEN 1 THEN '女士' ELSE NULL END Gender,
  15598. Mobile
  15599. FROM paMain WITH(NOLOCK INDEX(IX_PaMain_UserName))
  15600. WHERE UserName = @Username
  15601. IF (SELECT COUNT(*) FROM @t) > 0 --有值则返回
  15602. GOTO Retu
  15603. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15604. SELECT top 1 0 ID,
  15605. Username COLLATE Chinese_PRC_CI_AS Name,
  15606. Username COLLATE Chinese_PRC_CI_AS,
  15607. Email,
  15608. NULL Gender,
  15609. NULL Mobile
  15610. FROM Resume_Xinxi WITH(NOLOCK INDEX(IX_Resume_Xinxi_UserName))
  15611. WHERE UserName = @Username
  15612. IF (SELECT COUNT(*) FROM @t) > 0 --有值则返回
  15613. GOTO Retu
  15614. --先查询paMain.UserName = @UserName 不区分大小写
  15615. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15616. SELECT TOP 1 ID,
  15617. ISNULL(ISNULL(CONVERT(VARCHAR(50), Name), CONVERT(VARCHAR(50), NameEng)), UserName) COLLATE Chinese_PRC_CI_AS Name,
  15618. Username COLLATE Chinese_PRC_CI_AS,
  15619. Email,
  15620. CASE Gender WHEN 0 THEN '先生' WHEN 1 THEN '女士' ELSE NULL END Gender,
  15621. Mobile
  15622. FROM paMain WITH(NOLOCK INDEX(IX_PaMain_UserNameLower))
  15623. WHERE UserNameLower = @Username
  15624. ORDER BY Lastlogindate DESC
  15625. IF (SELECT COUNT(*) FROM @t) > 0 --有值则返回
  15626. GOTO Retu
  15627. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15628. SELECT top 1 0 ID,
  15629. Username COLLATE Chinese_PRC_CI_AS Name,
  15630. Username COLLATE Chinese_PRC_CI_AS,
  15631. Email,
  15632. NULL Gender,
  15633. NULL Mobile
  15634. FROM Resume_Xinxi WITH(NOLOCK INDEX(IX_Resume_Xinxi_UserNameLower))
  15635. WHERE UserNameLower = @Username
  15636. IF NOT EXISTS(SELECT 'x' FROM @t)
  15637. GOTO Err3
  15638. END
  15639. ELSE IF LEN(ISNULL(@Email, '')) > 0 ----查询paMain.Email
  15640. BEGIN
  15641. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15642. SELECT top 10 ID,
  15643. ISNULL(ISNULL(Name, NameEng), UserName) Name,
  15644. Username,
  15645. Email,
  15646. CASE Gender WHEN 0 THEN '先生' WHEN 1 THEN '女士' ELSE NULL END Gender,
  15647. Mobile
  15648. FROM paMain WITH(NOLOCK INDEX(IX_paMain_Email))
  15649. WHERE Email = @Email
  15650. --IF (SELECT COUNT(*) FROM @t) > 0 --有值则返回
  15651. -- GOTO Retu
  15652. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15653. SELECT 0 ID,
  15654. Username Name,
  15655. Username,
  15656. Email,
  15657. NULL Gender,
  15658. NULL Mobile
  15659. FROM Resume_Xinxi WITH(NOLOCK INDEX(IX_Resume_Xinxi_Email))
  15660. WHERE Email = @Email
  15661. IF NOT EXISTS(SELECT 'x' FROM @t)
  15662. GOTO Err3
  15663. END
  15664. END
  15665. Retu: ----正确返回,有数据
  15666. BEGIN
  15667. DECLARE @AskNo AS VARCHAR(40),@ActivateCode AS VARCHAR(6)
  15668. SELECT @AskNo = REPLACE(NEWID(), '-', ''), @ActivateCode = RAND() * 899999 + 100000
  15669. UPDATE @t SET ReturnType = @Type, UniqueId = REPLACE(NEWID(), '-', ''), ActivateCode = @ActivateCode, AskNo=@AskNo ----修改返回类型,用于前台显示结果
  15670. ----记录取回纪录
  15671. INSERT INTO PaGetPasswordLog(paMainID, UserNameIn, EmailIn, VerifyCode, IP, UserName, Email, Mobile,UniqueId,ActivateCode,AskNo)
  15672. SELECT ID, @UserName, @Email, @VerifyCode, @IP, UserName, Email, Mobile,UniqueId, ActivateCode,@AskNo FROM @t
  15673. IF @Type = 'Mobile'
  15674. BEGIN
  15675. DECLARE @curUserName AS VARCHAR(50),@curActivateCode AS VARCHAR(10),@Msg AS VARCHAR(200),@Index AS INT
  15676. INSERT SmsMessageLog(SendMan, ManagerUSerId, paMainId, caMainId, Mobile, MsgType, IsCat, Msg)
  15677. SELECT TOP 1 0, NULL, a.ID, NULL, a.Mobile, 104, 0,
  15678. '您好,您在' + REPLACE(@SubSiteName, 'http://', '') + '的激活码是:' + d.ActivateCode
  15679. FROM paMain a WITH(NOLOCK), (SELECT TOP 1 ID, ActivateCode FROM @t ORDER BY ID DESC) d
  15680. WHERE a.ID = d.Id
  15681. AND a.Mobile > ''
  15682. ORDER BY ID DESC
  15683. END
  15684. UPDATE @t SET ReturnType = @Type ----修改返回类型,用于前台显示结果
  15685. SELECT * FROM @t ORDER BY ID DESC
  15686. RETURN
  15687. END
  15688. Err1: ----一个账号一天取回超过5次
  15689. BEGIN
  15690. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 1 ReturnType
  15691. RETURN
  15692. END
  15693. Err2: ----一个ip一天取回超过20次
  15694. BEGIN
  15695. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 2 ReturnType
  15696. RETURN
  15697. END
  15698. Err3: ----没有取回数据
  15699. BEGIN
  15700. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 3 ReturnType
  15701. RETURN
  15702. END
  15703. Err4: ----手机号一天取回超过3次
  15704. BEGIN
  15705. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 4 ReturnType
  15706. RETURN
  15707. END
  15708. Err5: ----认证手机号 姓名对应出现问题
  15709. BEGIN
  15710. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 5 ReturnType
  15711. RETURN
  15712. END
  15713. GO
  15714. /****** Object: StoredProcedure [dbo].[pcPaMainByGetPasswordSelectNew1] Script Date: 2018/12/13 19:08:57 ******/
  15715. SET ANSI_NULLS ON
  15716. GO
  15717. SET QUOTED_IDENTIFIER ON
  15718. GO
  15719. --个人取回密码
  15720. --harry
  15721. --2018-4-27
  15722. --修改短信激活码为实时发送
  15723. CREATE PROCEDURE [dbo].[pcPaMainByGetPasswordSelectNew1]
  15724. (
  15725. @Username VARCHAR(50),
  15726. @Email VARCHAR(50),
  15727. @Mobile VARCHAR(11),
  15728. @IP VARCHAR(15),
  15729. @VerifyCode VARCHAR(10),
  15730. @SubSiteName VARCHAR(40),
  15731. @txtRealName NVARCHAR(10)
  15732. )
  15733. AS
  15734. BEGIN
  15735. DECLARE @Cnt AS INT, @Type AS VARCHAR(10), @ToDay AS DATETIME, @QueryMobile AS INT
  15736. ----如果用户名、邮箱、手机号都为空则返回
  15737. IF LEN(ISNULL(@Username, '')) = 0 AND LEN(ISNULL(@Email, '')) = 0 AND LEN(ISNULL(@Mobile, '')) = 0
  15738. GOTO Err3
  15739. --SET @Mobile = ''
  15740. ----@t是返回结果临时表
  15741. DECLARE @t AS TABLE(
  15742. ID INT,
  15743. Name NVARCHAR(50) NOT NULL,
  15744. UserName VARCHAR(50) NOT NULL,
  15745. Email VARCHAR(50) NOT NULL,
  15746. Gender NVARCHAR(10),
  15747. Mobile VARCHAR(13),
  15748. ReturnType VARCHAR(10),
  15749. UniqueId VARCHAR(40),
  15750. ActivateCode VARCHAR(6),
  15751. AskNo VARCHAR(40)
  15752. )
  15753. SELECT @Type = 'Email', @QueryMobile = 0
  15754. IF dbo.IsMobile(@Mobile) = 1 ----手机号是否合法
  15755. BEGIN
  15756. SET @QueryMobile = 1 ----手机号合法,则优先使用手机查询
  15757. ----一天内手机取回密码次数
  15758. SELECT @Cnt = COUNT(DISTINCT AskNo) FROM paGetPasswordLog WITH(NOLOCK) WHERE Mobile = @Mobile AND AddDate > GETDATE() - 1
  15759. IF @Cnt >= 3 ----总数=0,按手机号取回
  15760. GOTO Err4
  15761. SET @Type = 'Mobile'
  15762. END
  15763. IF @Type = 'Email' ----按油箱、用户名取回次数
  15764. BEGIN
  15765. SET @ToDay = CONVERT(DATETIME, CONVERT(VARCHAR(8), GETDATE(), 112))
  15766. IF LEN(ISNULL(@Username, '')) > 0 ----用户名
  15767. BEGIN
  15768. SELECT @Cnt = COUNT(1) FROM paGetPasswordLog WITH(NOLOCK) WHERE Username = @Username AND AddDate > @Today
  15769. SET @Type='Username'
  15770. END
  15771. ELSE ----其次Email
  15772. SELECT @Cnt = COUNT(1) FROM paGetPasswordLog WITH(NOLOCK) WHERE Email = @Email AND AddDate > @Today
  15773. IF @Cnt > 4 ----一天之内一个账号最多取回5次
  15774. GOTO Err1
  15775. SELECT @Cnt = COUNT(1) FROM paGetPasswordLog WITH(NOLOCK) WHERE IP = @IP AND AddDate >= @Today
  15776. IF @Cnt > 20 ----一天之内一个ip不能超过20次,很多手机是一个ip,所以不管手机了
  15777. GOTO Err2
  15778. END
  15779. SELECT @Cnt = 0
  15780. IF @QueryMobile = 1 ----按照手机号查询
  15781. BEGIN
  15782. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15783. SELECT TOP 10 ID,
  15784. ISNULL(ISNULL(CONVERT(VARCHAR(50), Name), CONVERT(VARCHAR(50), NameEng)), UserName) Name,
  15785. Username,
  15786. Email,
  15787. CASE Gender WHEN 0 THEN '先生' WHEN 1 THEN '女士' ELSE NULL END Gender,
  15788. Mobile
  15789. FROM paMain WITH(NOLOCK INDEX(IX_PaMain_Mobile))
  15790. WHERE Mobile = @Mobile
  15791. AND MobileVerifyDate IS NOT NULL
  15792. ORDER BY Lastlogindate DESC
  15793. IF NOT EXISTS(SELECT 'x' FROM @t)
  15794. GOTO Err3
  15795. IF LEN(ISNULL(@txtRealName, '')) > 0
  15796. BEGIN
  15797. IF NOT EXISTS(SELECT 'x' FROM @t WHERE Name = @txtRealName) --姓名不一致
  15798. BEGIN
  15799. GOTO Err5
  15800. END
  15801. ELSE
  15802. BEGIN
  15803. DELETE FROM @t WHERE Name <> @txtRealName --手机号取回的 需要姓名一致
  15804. END
  15805. END
  15806. END
  15807. ELSE IF LEN(ISNULL(@Username, '')) > 0 --如果有用户名则以用户名为主
  15808. BEGIN
  15809. SET @Type='Username'
  15810. --先查询paMain.UserName = @UserName 区分大小写
  15811. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15812. SELECT TOP 1 ID,
  15813. ISNULL(ISNULL(CONVERT(VARCHAR(50), Name), CONVERT(VARCHAR(50), NameEng)), UserName) COLLATE Chinese_PRC_CI_AS Name,
  15814. Username COLLATE Chinese_PRC_CI_AS,
  15815. Email,
  15816. CASE Gender WHEN 0 THEN '先生' WHEN 1 THEN '女士' ELSE NULL END Gender,
  15817. Mobile
  15818. FROM paMain WITH(NOLOCK INDEX(IX_PaMain_UserName))
  15819. WHERE UserName = @Username
  15820. IF (SELECT COUNT(*) FROM @t) > 0 --有值则返回
  15821. GOTO Retu
  15822. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15823. SELECT top 1 0 ID,
  15824. Username COLLATE Chinese_PRC_CI_AS Name,
  15825. Username COLLATE Chinese_PRC_CI_AS,
  15826. Email,
  15827. NULL Gender,
  15828. NULL Mobile
  15829. FROM Resume_Xinxi WITH(NOLOCK INDEX(IX_Resume_Xinxi_UserName))
  15830. WHERE UserName = @Username
  15831. IF (SELECT COUNT(*) FROM @t) > 0 --有值则返回
  15832. GOTO Retu
  15833. --先查询paMain.UserName = @UserName 不区分大小写
  15834. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15835. SELECT TOP 1 ID,
  15836. ISNULL(ISNULL(CONVERT(VARCHAR(50), Name), CONVERT(VARCHAR(50), NameEng)), UserName) COLLATE Chinese_PRC_CI_AS Name,
  15837. Username COLLATE Chinese_PRC_CI_AS,
  15838. Email,
  15839. CASE Gender WHEN 0 THEN '先生' WHEN 1 THEN '女士' ELSE NULL END Gender,
  15840. Mobile
  15841. FROM paMain WITH(NOLOCK INDEX(IX_PaMain_UserNameLower))
  15842. WHERE UserNameLower = @Username
  15843. ORDER BY Lastlogindate DESC
  15844. IF (SELECT COUNT(*) FROM @t) > 0 --有值则返回
  15845. GOTO Retu
  15846. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15847. SELECT top 1 0 ID,
  15848. Username COLLATE Chinese_PRC_CI_AS Name,
  15849. Username COLLATE Chinese_PRC_CI_AS,
  15850. Email,
  15851. NULL Gender,
  15852. NULL Mobile
  15853. FROM Resume_Xinxi WITH(NOLOCK INDEX(IX_Resume_Xinxi_UserNameLower))
  15854. WHERE UserNameLower = @Username
  15855. IF NOT EXISTS(SELECT 'x' FROM @t)
  15856. GOTO Err3
  15857. END
  15858. ELSE IF LEN(ISNULL(@Email, '')) > 0 ----查询paMain.Email
  15859. BEGIN
  15860. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15861. SELECT top 10 ID,
  15862. ISNULL(ISNULL(Name, NameEng), UserName) Name,
  15863. Username,
  15864. Email,
  15865. CASE Gender WHEN 0 THEN '先生' WHEN 1 THEN '女士' ELSE NULL END Gender,
  15866. Mobile
  15867. FROM paMain WITH(NOLOCK INDEX(IX_paMain_Email))
  15868. WHERE Email = @Email
  15869. --IF (SELECT COUNT(*) FROM @t) > 0 --有值则返回
  15870. -- GOTO Retu
  15871. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  15872. SELECT 0 ID,
  15873. Username Name,
  15874. Username,
  15875. Email,
  15876. NULL Gender,
  15877. NULL Mobile
  15878. FROM Resume_Xinxi WITH(NOLOCK INDEX(IX_Resume_Xinxi_Email))
  15879. WHERE Email = @Email
  15880. IF NOT EXISTS(SELECT 'x' FROM @t)
  15881. GOTO Err3
  15882. END
  15883. END
  15884. Retu: ----正确返回,有数据
  15885. BEGIN
  15886. DECLARE @AskNo AS VARCHAR(40),@ActivateCode AS VARCHAR(6)
  15887. SELECT @AskNo = REPLACE(NEWID(), '-', ''), @ActivateCode = RAND() * 899999 + 100000
  15888. UPDATE @t SET ReturnType = @Type, UniqueId = REPLACE(NEWID(), '-', ''), ActivateCode = @ActivateCode, AskNo=@AskNo ----修改返回类型,用于前台显示结果
  15889. ----记录取回纪录
  15890. INSERT INTO PaGetPasswordLog(paMainID, UserNameIn, EmailIn, VerifyCode, IP, UserName, Email, Mobile,UniqueId,ActivateCode,AskNo)
  15891. SELECT ID, @UserName, @Email, @VerifyCode, @IP, UserName, Email, Mobile,UniqueId, ActivateCode,@AskNo FROM @t
  15892. UPDATE @t SET ReturnType = @Type ----修改返回类型,用于前台显示结果
  15893. SELECT * FROM @t ORDER BY ID DESC
  15894. IF @Type = 'Mobile'
  15895. BEGIN
  15896. SELECT TOP 1 a.ID AS paMainId, a.Mobile, 104 AS MsgType,
  15897. '您好,您在' + REPLACE(@SubSiteName, 'http://', '') + '的激活码是:' + d.ActivateCode AS Msg
  15898. FROM paMain a WITH(NOLOCK), (SELECT TOP 1 ID, ActivateCode FROM @t ORDER BY ID DESC) d
  15899. WHERE a.ID = d.Id
  15900. AND a.Mobile > ''
  15901. ORDER BY a.ID DESC
  15902. END
  15903. RETURN
  15904. END
  15905. Err1: ----一个账号一天取回超过5次
  15906. BEGIN
  15907. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 1 ReturnType
  15908. RETURN
  15909. END
  15910. Err2: ----一个ip一天取回超过20次
  15911. BEGIN
  15912. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 2 ReturnType
  15913. RETURN
  15914. END
  15915. Err3: ----没有取回数据
  15916. BEGIN
  15917. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 3 ReturnType
  15918. RETURN
  15919. END
  15920. Err4: ----手机号一天取回超过3次
  15921. BEGIN
  15922. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 4 ReturnType
  15923. RETURN
  15924. END
  15925. Err5: ----认证手机号 姓名对应出现问题
  15926. BEGIN
  15927. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 5 ReturnType
  15928. RETURN
  15929. END
  15930. GO
  15931. /****** Object: StoredProcedure [dbo].[pcPaMainByHideConditionsDelete] Script Date: 2018/12/13 19:08:57 ******/
  15932. SET ANSI_NULLS ON
  15933. GO
  15934. SET QUOTED_IDENTIFIER ON
  15935. GO
  15936. --=============================================
  15937. -- 创建: sean
  15938. -- 检查: 2010-10-6
  15939. -- 说明: 隐藏条件删除
  15940. --=============================================
  15941. CREATE PROCEDURE [dbo].[pcPaMainByHideConditionsDelete]
  15942. @ID INT,
  15943. @Shield NVARCHAR(60),
  15944. @IP VARCHAR(30)
  15945. AS
  15946. BEGIN TRY
  15947. DECLARE @HideConditions AS NVARCHAR(500)
  15948. SELECT @HideConditions = ISNULL(HideConditions, '') FROM PaMain WITH(NOLOCK) WHERE ID = @ID
  15949. SET @Shield = '<' + @Shield + '>'
  15950. IF CHARINDEX(@Shield, @HideConditions) = 0
  15951. RETURN 2
  15952. ELSE
  15953. BEGIN
  15954. SET @HideConditions = Replace(@HideConditions, @Shield, '')
  15955. IF @HideConditions = ''
  15956. SET @HideConditions = NULL
  15957. UPDATE PaMain SET HideConditions = @HideConditions WHERE ID=@ID
  15958. INSERT INTO paOperationLog (paMainID,Operation,Details,IP)
  15959. VALUES(@ID,50,'更新屏蔽设置成功。',@IP)
  15960. RETURN 1
  15961. END
  15962. END TRY
  15963. BEGIN CATCH
  15964. RETURN 0
  15965. END CATCH
  15966. GO
  15967. /****** Object: StoredProcedure [dbo].[pcPaMainByHideConditionsSelect] Script Date: 2018/12/13 19:08:57 ******/
  15968. SET ANSI_NULLS ON
  15969. GO
  15970. SET QUOTED_IDENTIFIER ON
  15971. GO
  15972. --=============================================
  15973. -- 创建: sean
  15974. -- 检查: 2010-10-6
  15975. -- 说明: 隐藏条件提取
  15976. --=============================================
  15977. CREATE PROCEDURE [dbo].[pcPaMainByHideConditionsSelect]
  15978. @ID INT,
  15979. @HideConditions NVARCHAR(500) OUTPUT
  15980. AS
  15981. SELECT @HideConditions = ISNULL(HideConditions, '') FROM PaMain WITH(NOLOCK INDEX(PK_paMain)) WHERE ID = @ID
  15982. GO
  15983. /****** Object: StoredProcedure [dbo].[pcPaMainByHideConditionsUpdate] Script Date: 2018/12/13 19:08:58 ******/
  15984. SET ANSI_NULLS ON
  15985. GO
  15986. SET QUOTED_IDENTIFIER ON
  15987. GO
  15988. ----------------------------------------
  15989. --返回值:
  15990. -- 4 超过100条数据
  15991. -- 3超长
  15992. -- 2已经存在
  15993. -- 0保存出错
  15994. -- 1保存正确
  15995. ----------------------------------------
  15996. CREATE PROCEDURE [dbo].[pcPaMainByHideConditionsUpdate]
  15997. @ID INT,
  15998. @Shield NVARCHAR(60),
  15999. @IP VARCHAR(30)
  16000. AS
  16001. BEGIN TRY
  16002. DECLARE @HideConditions AS NVARCHAR(500)
  16003. SELECT @HideConditions = ISNULL(HideConditions, '') FROM PaMain WITH(NOLOCK) WHERE ID = @ID
  16004. SET @Shield = '<' + @Shield + '>'
  16005. IF CHARINDEX(@Shield, @HideConditions) > 0
  16006. RETURN 2
  16007. ELSE
  16008. IF LEN(@HideConditions+@Shield)>500
  16009. RETURN 3
  16010. --判断已经插入了多少数据
  16011. DECLARE @temp AS NVARCHAR(500)
  16012. SET @temp=@HideConditions
  16013. IF len(@temp)-len(replace(@temp,'<',''))>100
  16014. BEGIN
  16015. RETURN 4
  16016. END
  16017. BEGIN
  16018. SET @HideConditions = @Shield + @HideConditions
  16019. UPDATE PaMain SET HideConditions = @HideConditions WHERE ID=@ID
  16020. INSERT INTO paOperationLog (paMainID,Operation,Details,IP)
  16021. VALUES(@ID,50,'更新屏蔽设置成功。',@IP)
  16022. RETURN 1
  16023. END
  16024. END TRY
  16025. BEGIN CATCH
  16026. RETURN 0
  16027. END CATCH
  16028. GO
  16029. /****** Object: StoredProcedure [dbo].[pcPaMainByIDSelect] Script Date: 2018/12/13 19:08:58 ******/
  16030. SET ANSI_NULLS ON
  16031. GO
  16032. SET QUOTED_IDENTIFIER ON
  16033. GO
  16034. --#####################################################
  16035. --创建时间:2014.11.4
  16036. --创建人:John
  16037. --说明:根据id获取PaMain
  16038. --#####################################################
  16039. CREATE PROCEDURE [dbo].[pcPaMainByIDSelect]
  16040. (
  16041. @ID INT
  16042. )
  16043. AS
  16044. BEGIN
  16045. SELECT TOP 1 * FROM paMain WITH(NOLOCK) WHERE id=@ID
  16046. END
  16047. GO
  16048. /****** Object: StoredProcedure [dbo].[pcpaMainByIDUpdate] Script Date: 2018/12/13 19:08:58 ******/
  16049. SET ANSI_NULLS ON
  16050. GO
  16051. SET QUOTED_IDENTIFIER ON
  16052. GO
  16053. --------------------------------------------------
  16054. --修改:Nick
  16055. --修改日期:2106-3-17
  16056. --根据百度修改pamain
  16057. --------------------------------------------------
  16058. create PROCEDURE [dbo].[pcpaMainByIDUpdate]
  16059. (
  16060. @ID INT,
  16061. @Name VARCHAR(50),
  16062. @Mobile VARCHAR(11),
  16063. @BirthDay INT,
  16064. @LivePlace VARCHAR(6),
  16065. @AccountPlace VARCHAR(6),
  16066. @GrowPlace VARCHAR(6),
  16067. @Gender BIT
  16068. )
  16069. AS
  16070. BEGIN
  16071. UPDATE PaMain
  16072. SET Name = @Name,
  16073. BirthDay = @BirthDay,
  16074. Mobile = @Mobile,
  16075. LivePlace = @LivePlace,
  16076. AccountPlace = @AccountPlace,
  16077. GrowPlace = @GrowPlace,
  16078. Gender = @Gender
  16079. WHERE ID = @ID
  16080. END
  16081. GO
  16082. /****** Object: StoredProcedure [dbo].[pcPaMainByImportUpdate] Script Date: 2018/12/13 19:08:58 ******/
  16083. SET ANSI_NULLS ON
  16084. GO
  16085. SET QUOTED_IDENTIFIER ON
  16086. GO
  16087. -- =============================================
  16088. -- Author: Sean
  16089. -- Check date: 2013-6-21
  16090. -- Description: 修改账号信息,cvMainID为0时不修改cvmain信息 Mobile Can be null.
  16091. -- Data imported from zhaopin.com,51job.com
  16092. --修改harry 2018-7-5 处理liveplace等
  16093. -- =============================================
  16094. CREATE PROCEDURE [dbo].[pcPaMainByImportUpdate]
  16095. (
  16096. @Type INT,
  16097. @paMainID INT,
  16098. @cvMainID INT,
  16099. @Name VARCHAR(30),
  16100. @Gender BIT,
  16101. @BirthDay INT,
  16102. @LivePlace VARCHAR(6),
  16103. @AccountPlace VARCHAR(6),
  16104. @GrowPlace VARCHAR(6),
  16105. @Mobile VARCHAR(13),
  16106. @OnlineContact TINYINT,
  16107. @OnlineContactNo VARCHAR(50),
  16108. @Homepage VARCHAR(200),
  16109. @Marriage TINYINT,
  16110. @Nation TINYINT,
  16111. @Height TINYINT,
  16112. @dcCareerStatus TINYINT,
  16113. @IP VARCHAR(39)
  16114. )
  16115. AS
  16116. IF ISNULL(@paMainID, 0) = 0
  16117. RETURN -1
  16118. IF dbo.TrimNULL(@Name) IS NULL
  16119. RETURN -1
  16120. --IF dbo.TrimNULL(@Mobile) IS NULL
  16121. -- RETURN -1
  16122. IF @Marriage = 0
  16123. SET @Marriage = NULL
  16124. IF @Height = 0
  16125. SET @Height = NULL
  16126. IF EXISTS(SELECT 'x' FROM Person_BLACK WITH(NOLOCK) WHERE Mobile = @Mobile AND Mobile > '')
  16127. BEGIN
  16128. ----有黑名单,则增加拒绝次数
  16129. UPDATE Person_Black SET RefuseCount = RefuseCount + 1 WHERE Mobile = @Mobile
  16130. RETURN -1
  16131. END
  16132. BEGIN TRAN
  16133. BEGIN TRY
  16134. IF CHARINDEX(' ', @LivePlace) >2
  16135. BEGIN
  16136. SET @LivePlace=substring(@LivePlace,1,charindex(' ',@LivePlace)-1)
  16137. END
  16138. IF CHARINDEX(' ', @AccountPlace) >2
  16139. BEGIN
  16140. SET @AccountPlace=substring(@AccountPlace,1,charindex(' ',@AccountPlace)-1)
  16141. END
  16142. IF CHARINDEX(' ', @GrowPlace) >2
  16143. BEGIN
  16144. SET @GrowPlace=substring(@GrowPlace,1,charindex(' ',@GrowPlace)-1)
  16145. END
  16146. DECLARE @NameEngOld AS VARCHAR(30)
  16147. DECLARE @NameOld AS VARCHAR(12)
  16148. DECLARE @OnlineContactNoOld AS VARCHAR(50)
  16149. DECLARE @HomepageOld AS VARCHAR(200)
  16150. DECLARE @MobileOld AS VARCHAR(13)
  16151. DECLARE @Modify AS INT
  16152. -- @Modify=-1未修改需审核项, @Modify=0修改中文项目; @Modify=1修改了英文项目
  16153. SET @Modify=-1
  16154. --检查在线联系方式和号码
  16155. IF @OnlineContact IS NULL
  16156. SET @OnlineContactNo = ''
  16157. ELSE
  16158. SET @OnlineContactNo = dbo.SafeSQL(@OnlineContactNo)
  16159. --取消不正确的主页格式
  16160. SET @Homepage=REPLACE(@Homepage,'http%3A//','http://')
  16161. SET @Homepage=REPLACE(@Homepage,'http://','')
  16162. IF LTRIM(RTRIM(@Homepage)) = 'http://'
  16163. SET @Homepage = null
  16164. IF ISNULL(@Homepage, '') = ''
  16165. SET @Homepage = null
  16166. IF ISNULL(@OnlineContactNo, '') = ''
  16167. SET @OnlineContactNo = null
  16168. --获得原始数据
  16169. SELECT @NameOld=Name,@NameEngOld=NameEng,@OnlineContactNoOld=OnlineContactNo,@HomepageOld=Homepage,@MobileOld=Mobile
  16170. FROM paMain WITH(NOLOCK INDEX(PK_paMain))
  16171. WHERE ID = @paMainID
  16172. --0中文,1英文,只有姓名不同
  16173. IF @TYPE=0
  16174. BEGIN
  16175. DECLARE @CNAME AS VARCHAR(12)
  16176. SET @CNAME = @Name
  16177. UPDATE paMain
  16178. SET Name=@CNAME,
  16179. Gender=@Gender,
  16180. BirthDay=@BirthDay,
  16181. LivePlace=@LivePlace,
  16182. AccountPlace=@AccountPlace,
  16183. GrowPlace=@GrowPlace,
  16184. Mobile=@Mobile,
  16185. OnlineContact=@OnlineContact,
  16186. OnlineContactNo=@OnlineContactNo,
  16187. Homepage=@Homepage,
  16188. Marriage=@Marriage,
  16189. Nation=@Nation,
  16190. Height=@Height,
  16191. --dcCareerStatus#@dcCareerStatus,
  16192. LastModifyDate=GETDATE()
  16193. WHERE ID=@paMainID
  16194. END
  16195. ELSE
  16196. UPDATE paMain
  16197. SET NameENG=@Name,
  16198. Gender=@Gender,
  16199. BirthDay=@BirthDay,
  16200. LivePlace=@LivePlace,
  16201. AccountPlace=@AccountPlace,
  16202. GrowPlace=@GrowPlace,
  16203. Mobile=@Mobile,
  16204. OnlineContact=@OnlineContact,
  16205. OnlineContactNo=@OnlineContactNo,
  16206. Homepage=@Homepage,
  16207. Marriage=@Marriage,
  16208. Nation=@Nation,
  16209. Height=@Height,
  16210. --dcCareerStatus#@dcCareerStatus,
  16211. LastModifyDate=GETDATE()
  16212. WHERE ID=@paMainID
  16213. --保存到bsCvModify,姓名
  16214. IF @TYPE=0
  16215. BEGIN
  16216. IF ISNULL(@NameOld, '') <> @CNAME
  16217. BEGIN
  16218. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac1'
  16219. INSERT INTO bsCvModify(paMainID,Location,ColValue) VALUES(@paMainID,'ac1',@CNAME)
  16220. SET @Modify=0
  16221. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  16222. VALUES(@paMainID, 30,'更新姓名,原姓名:<' + ISNULL(@NameOld, '') + '>;新姓名:<' + @CName + '>', @IP)
  16223. END
  16224. END
  16225. ELSE
  16226. IF ISNULL(@NameOld, '') <> @Name
  16227. BEGIN
  16228. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ae1'
  16229. INSERT INTO bsCvModify(paMainID,Location,ColValue) VALUES(@paMainID,'ae1',@CNAME)
  16230. SET @Modify=1
  16231. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  16232. VALUES(@paMainID, 31,'更新英文名,原英文名:<' + ISNULL(@NameOld, '') + '>;新英文名:<' + @Name + '>', @IP)
  16233. END
  16234. --在线联系号码
  16235. IF @OnlineContactNo IS NULL
  16236. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac2'
  16237. ELSE
  16238. IF @OnlineContactNo <> ISNULL(@OnlineContactNoOld, '')
  16239. BEGIN
  16240. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac2'
  16241. INSERT INTO bsCvModify(paMainID,Location,ColValue) VALUES(@paMainID,'ac2',@OnlineContactNo)
  16242. SET @Modify=0
  16243. END
  16244. --主页
  16245. IF @Homepage IS NULL
  16246. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac3'
  16247. ELSE
  16248. IF @Homepage <> ISNULL(@HomepageOld, '')
  16249. BEGIN
  16250. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac3'
  16251. INSERT INTO bsCvModify(paMainID,Location,ColValue) VALUES(@paMainID,'ac3',@Homepage)
  16252. SET @Modify=0
  16253. END
  16254. --手机号码
  16255. IF ISNULL(@MobileOld, '') <> @Mobile
  16256. BEGIN
  16257. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac4'
  16258. --INSERT INTO bsCvModify(paMainID,Location,ColValue) VALUES(@paMainID,'ac4',@Mobile)
  16259. --SET @Modify=0
  16260. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  16261. VALUES(@paMainID, 35,'更新手机号,原手机号:<' + ISNULL(@MobileOld, '') + '>;新手机号:<' + @Mobile + '>', @IP)
  16262. END
  16263. ----修改cvMain.cvLevel
  16264. IF @TYPE=0
  16265. BEGIN
  16266. IF dbo.IsMobile(@Mobile) = 1
  16267. UPDATE cvMain SET cvLevel='11' + RIGHT(cvLevel,8) WHERE paMainID = @paMainID
  16268. ELSE
  16269. UPDATE cvMain SET cvLevelEng='10' + RIGHT(cvLevelEng,8) WHERE paMainID = @paMainID
  16270. END
  16271. ELSE
  16272. BEGIN
  16273. IF dbo.IsMobile(@Mobile) = 1
  16274. UPDATE cvMain SET cvLevel='11' + RIGHT(cvLevel,8) WHERE paMainID = @paMainID
  16275. ELSE
  16276. UPDATE cvMain SET cvLevelEng='10' + RIGHT(cvLevelEng,8) WHERE paMainID = @paMainID
  16277. END
  16278. --1小时内不重复刷新,防止刷新排名
  16279. UPDATE cvmain SET RefreshDate = GETDATE() WHERE ID=@cvMainID AND DATEADD(HOUR, 1, RefreshDate) < GETDATE() AND paMainID = @paMainID
  16280. ----12小时内只保留一次修改记录
  16281. DELETE FROM paOperationLog WHERE paMainID=@paMainID AND Operation=11 AND AddDate>GETDATE()-0.5
  16282. INSERT INTO paOperationLog (paMainID,Operation,Details,IP) VALUES(@paMainID,11,'更新基本信息成功。',@IP)
  16283. END TRY
  16284. BEGIN CATCH
  16285. GOTO ERR
  16286. END CATCH
  16287. COMMIT TRAN
  16288. RETURN 1
  16289. ERR:
  16290. BEGIN
  16291. ROLLBACK TRAN
  16292. RETURN 0
  16293. END
  16294. GO
  16295. /****** Object: StoredProcedure [dbo].[pcPaMainByIsReceiveSmsUpdate] Script Date: 2018/12/13 19:08:59 ******/
  16296. SET ANSI_NULLS ON
  16297. GO
  16298. SET QUOTED_IDENTIFIER ON
  16299. GO
  16300. -- =============================================
  16301. -- Author: Sean
  16302. -- Check date: 2010-9-17
  16303. -- Description: 修改账号信息 ,cvMainID为0时不修改cvmain信息
  16304. -- =============================================
  16305. CREATE PROCEDURE [dbo].[pcPaMainByIsReceiveSmsUpdate]
  16306. (
  16307. @paMainID INT,
  16308. @IsReceiveSms BIT,
  16309. @IP VARCHAR(15)
  16310. )
  16311. AS
  16312. IF ISNULL(@paMainID, 0) = 0
  16313. RETURN -1
  16314. BEGIN TRAN
  16315. BEGIN TRY
  16316. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  16317. VALUES(@paMainID, 60,'更改接收短信设置为' + CASE @IsReceiveSms WHEN 1 THEN '<接收短信>' ELSE '<不接收短信>' END, @IP)
  16318. UPDATE paMain SET IsReceiveSMS = @IsReceiveSMS WHERE ID = @paMainId
  16319. END TRY
  16320. BEGIN CATCH
  16321. GOTO ERR
  16322. END CATCH
  16323. COMMIT TRAN
  16324. RETURN 1
  16325. ERR:
  16326. BEGIN
  16327. ROLLBACK TRAN
  16328. RETURN 0
  16329. END
  16330. GO
  16331. /****** Object: StoredProcedure [dbo].[pcPaMainByIsUseYourFoodSelect] Script Date: 2018/12/13 19:08:59 ******/
  16332. SET ANSI_NULLS ON
  16333. GO
  16334. SET QUOTED_IDENTIFIER ON
  16335. GO
  16336. CREATE PROCEDURE [dbo].[pcPaMainByIsUseYourFoodSelect]
  16337. (
  16338. @Id INT
  16339. )
  16340. AS
  16341. SET NOCOUNT ON
  16342. BEGIN
  16343. IF EXISTS(SELECT 'x' FROM ShortDb..paActStatus WITH(NOLOCK) WHERE paMainId = @id AND ActStatus = 1 AND AddDate > DATEADD(MINUTe, -5, GETDATE()))
  16344. IF EXISTS(SELECT 'x' FROM WxFans WITH(NOLOCK) WHERE paMainId = @id AND Status = 2)
  16345. BEGIN
  16346. DELETE ShortDb..paActStatus WHERE paMainId = @id AND ActStatus = 1 AND AddDate > DATEADD(MINUTe, -5, GETDATE())
  16347. UPDATE paMain SET IsUseYourFood = 1 WHERE Id = @Id
  16348. END
  16349. SELECT 'x' FROM paMain WHERE Id = @Id AND IsUseYourFood = 1
  16350. END
  16351. GO
  16352. /****** Object: StoredProcedure [dbo].[pcPaMainByIsUseYourFoodUpdate] Script Date: 2018/12/13 19:08:59 ******/
  16353. SET ANSI_NULLS ON
  16354. GO
  16355. SET QUOTED_IDENTIFIER ON
  16356. GO
  16357. create PROCEDURE [dbo].[pcPaMainByIsUseYourFoodUpdate]
  16358. (
  16359. @Id INT,
  16360. @State INT
  16361. )
  16362. AS
  16363. BEGIN
  16364. UPDATE paMain SET IsUseYourFood = @State WHERE Id = @Id
  16365. END
  16366. GO
  16367. /****** Object: StoredProcedure [dbo].[PcpaMainByLastLoginDateCheckUpdate] Script Date: 2018/12/13 19:08:59 ******/
  16368. SET ANSI_NULLS ON
  16369. GO
  16370. SET QUOTED_IDENTIFIER ON
  16371. GO
  16372. CREATE PROCEDURE [dbo].[PcpaMainByLastLoginDateCheckUpdate]
  16373. (
  16374. @PaMainId INT
  16375. )
  16376. AS
  16377. SET NOCOUNT ON
  16378. BEGIN
  16379. IF NOT EXISTS(SELECT 'x' FROM paMain WITH(NOLOCK) WHERE id = @paMainId AND LastLoginDate > CONVERT(VARCHAR(10), GETDATE(), 120))
  16380. UPDATE paMain SET LastLoginDate = GETDATE() WHERE Id = @paMAinId
  16381. END
  16382. GO
  16383. /****** Object: StoredProcedure [dbo].[pcPaMainByLastLoginDateUpdate] Script Date: 2018/12/13 19:09:00 ******/
  16384. SET ANSI_NULLS ON
  16385. GO
  16386. SET QUOTED_IDENTIFIER ON
  16387. GO
  16388. CREATE PROCEDURE [dbo].[pcPaMainByLastLoginDateUpdate]
  16389. (
  16390. @PaMainId INT,
  16391. @dcSubSiteID INT,
  16392. @Ip VARCHAR(31),
  16393. @browser VARCHAR(500)
  16394. )
  16395. AS
  16396. SET NOCOUNT ON
  16397. BEGIN
  16398. DECLARE @LoginFrom AS TINYINT
  16399. IF LEFT(@Browser, 3) = 'fm='
  16400. SELECT @LoginFrom = 42 --, @Browser = REPLACE(@Browser, 'ismobile:', '')
  16401. ELSE IF LEFT(@Browser, 3) = 'fp=' AND @LoginFrom IS NULL
  16402. SET @LoginFrom = 19
  16403. ELSE
  16404. SET @LoginFrom = 43 --1
  16405. UPDATE PaMain Set LastLoginDate=GETDATE() WHERE ID = @PaMainId
  16406. IF NOT EXISTS(SELECT 'x' FROM paLoginLog WITH(NOLOCK) WHERE paMainID = @PaMainId AND AddDate >= CONVERT(VARCHAR(10), GETDATE(), 120))
  16407. BEGIN
  16408. UPDATE DateReport
  16409. SET PersonLoginNum_Net = PersonLoginNum_Net + 1
  16410. WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  16411. AND Province_Id = @dcSubSiteID
  16412. --INSERT INTO PaMainDateReport SELECT @PaMainId, 11, GETDATE() --sean 20130708
  16413. INSERT INTO paLoginLog(paMainID, LoginIP, Browser, LoginFrom) VALUES(@PaMainId, @IP, ISNULL(@browser, 'Null'), @LoginFrom)
  16414. END
  16415. END
  16416. GO
  16417. /****** Object: StoredProcedure [dbo].[pcpaMainByLoginSELECT] Script Date: 2018/12/13 19:09:00 ******/
  16418. SET ANSI_NULLS ON
  16419. GO
  16420. SET QUOTED_IDENTIFIER ON
  16421. GO
  16422. --lambo 20140904
  16423. --个人登陆查询账号列表
  16424. CREATE PROCEDURE [dbo].[pcpaMainByLoginSELECT]
  16425. (
  16426. @UserName VARCHAR(50)
  16427. )
  16428. AS
  16429. SET NOCOUNT ON
  16430. --INSERT INTO a1 SELECT @UserName, GETDATE()
  16431. BEGIN
  16432. DECLARE @T TABLE(
  16433. ID INT,
  16434. Password VARCHAR(60),
  16435. UserName VARCHAR(50),
  16436. UserNameLower VARCHAR(50),
  16437. Mobile VARCHAR(13),
  16438. LoginType TINYINT
  16439. )
  16440. IF dbo.ISMobile(@UserName)=1
  16441. BEGIN
  16442. INSERT INTO @T(ID, Password, UserName, UserNameLower, Mobile, LoginType)
  16443. SELECT ID, Password, UserName, UserNameLower,Mobile,1
  16444. FROM PaMain WITH(INDEX(IX_paMain_Mobile))
  16445. WHERE Mobile = @UserName
  16446. AND MobileVerifyDate IS NOT NULL
  16447. END
  16448. INSERT INTO @T(ID, Password, UserName, UserNameLower, Mobile, LoginType)
  16449. SELECT ID, Password, UserName, UserNameLower,Mobile,2
  16450. FROM PaMain WITH(NOLOCK)
  16451. WHERE UserNameLower = @UserName
  16452. SELECT * FROM @T
  16453. END
  16454. GO
  16455. /****** Object: StoredProcedure [dbo].[pcpaMainByLoginUpdate] Script Date: 2018/12/13 19:09:00 ******/
  16456. SET ANSI_NULLS ON
  16457. GO
  16458. SET QUOTED_IDENTIFIER ON
  16459. GO
  16460. --------------------------------------------------
  16461. --修改:sean
  16462. --修改日期:2010-9-15
  16463. --说明:个人用户登陆 增加从Resume_Xinxi导数据的步骤
  16464. --2010-12-27 sean 修改个人第一次登录时 注册时间改为信息员推广时间
  16465. --密码加密后登录,2012-09-05修改 NIck
  16466. --------------------------------------------------
  16467. CREATE PROCEDURE [dbo].[pcpaMainByLoginUpdate]
  16468. (
  16469. @UserName VARCHAR(50),
  16470. @PlainPassword VARCHAR(50),
  16471. @Password VARCHAR(60),
  16472. @IP VARCHAR(31),
  16473. @dcSubSiteId SMALLINT,
  16474. @AutoLogin TINYINT,
  16475. @browser VARCHAR(500),
  16476. @ID INT,
  16477. @IDType INT
  16478. )
  16479. AS
  16480. SET NOCOUNT ON
  16481. BEGIN TRY
  16482. BEGIN TRAN
  16483. DECLARE
  16484. @Resume_XinxiID AS INT,
  16485. @AddMan AS INT,
  16486. @AddDate AS DATETIME,
  16487. @Email AS VARCHAR(50),
  16488. @CountDate AS INT,
  16489. @dcProvinceID AS TINYINT,
  16490. @TotalLoginNum AS INT,
  16491. @LastLoginDate AS SMALLDATETIME,
  16492. @LoginFrom AS TINYINT,
  16493. @PaType INT
  16494. IF LEFT(@Browser, 9) = 'ismobile:'
  16495. SELECT @LoginFrom = 5, @Browser = REPLACE(@Browser, 'ismobile:', '')
  16496. ELSE
  16497. SELECT @LoginFrom = 1, @Browser = '53:' + @Browser
  16498. SET @UserName = REPLACE(@UserName, ' ', '')
  16499. SELECT @CountDate = CONVERT(VARCHAR(8), GETDATE(), 112), @dcProvinceID = LEFT(@dcSubSiteId, 2)
  16500. SET @PaType = @IDType
  16501. BEGIN TRY
  16502. IF @PaType = 3
  16503. BEGIN
  16504. SELECT @Resume_XinxiID = ID, @AddMan =AddMan, @AddDate = RegDate, @Email = Email
  16505. FROM Resume_Xinxi WITH(NOLOCK INDEX(IX_Resume_Xinxi_UserName))
  16506. WHERE UserName = @UserName AND Password = @PlainPassword
  16507. IF @Resume_XinxiID IS NOT NULL
  16508. SET @PaType = 2
  16509. END
  16510. ELSE IF @PaType=0
  16511. BEGIN
  16512. SELECT TOP 1 @Resume_XinxiID = ID, @AddMan =AddMan, @AddDate = RegDate, @Email = Email
  16513. FROM Resume_Xinxi WITH(NOLOCK INDEX(IX_Resume_Xinxi_UserNameLower))
  16514. WHERE UserNameLower = @UserName AND Password = @PlainPassword
  16515. ORDER BY ID DESC
  16516. IF @Resume_XinxiID IS NOT NULL
  16517. SET @PaType = 4
  16518. END
  16519. IF @PaType = 0
  16520. GOTO Err1
  16521. IF @Resume_XinxiID > 0 ----账号在Resume_xinxi
  16522. BEGIN
  16523. --lucifer添加,添加新的注册模式
  16524. DECLARE @RegisterFrom AS TINYINT
  16525. SELECT @RegisterFrom = 1
  16526. IF CHARINDEX('ios',LOWER(@browser)) > 0
  16527. SELECT @RegisterFrom = 3
  16528. ELSE IF CHARINDEX('android',LOWER(@browser)) > 0
  16529. SELECT @RegisterFrom = 2
  16530. --把数据从Resume_Xini转换到paMain
  16531. INSERT INTO paMain(RegisterMode, AddMan, UserName, Password, Email, dcProvinceID, dcSubSiteId, RegisterIP, IsDefaultPassword, AddDate, RegisterFrom, RegisterType, SpreadDate)
  16532. VALUES(1, @AddMan, @UserName, @Password, @Email, @dcProvinceID, @dcSubSiteId, @IP, 1, GETDATE(), @RegisterFrom, 101, @AddDate)
  16533. SET @ID = @@IDENTITY
  16534. INSERT INTO paOperationLog (paMainID, Operation, Details, IP) VALUES(@ID, 10, '导入个人账号成功。', @IP)
  16535. --记录日报
  16536. UPDATE DateReport SET ValidResume = ValidResume + 1
  16537. WHERE province_id = @dcSubSiteID AND CountDate = @CountDate
  16538. INSERT INTO pamainDatereport SELECT @ID, 9, GETDATE() -- SEAN 20130911
  16539. --统计信息员注册数据
  16540. SELECT TOP 1 CountDate
  16541. FROM Info_Datereport WITH(NOLOCK)
  16542. WHERE CountDate = @CountDate
  16543. AND province_id = @dcProvinceID
  16544. AND InfoManager_ID = @AddMan
  16545. IF (@@ROWCOUNT=0)
  16546. INSERT INTO Info_DateReport(province_id,infomanager_id,countdate)
  16547. VALUES(@dcProvinceID, @AddMan, @CountDate)
  16548. UPDATE Info_Datereport
  16549. SET ValidResume=ValidResume + 1
  16550. WHERE CountDate=@CountDate
  16551. AND province_id=@dcProvinceID
  16552. AND InfoManager_ID = @AddMan
  16553. END
  16554. --超过登陆次数,每天限制登录次数位20次
  16555. IF (SELECT COUNT(1) FROM paLoginLog WITH(NOLOCK) WHERE paMainID = @ID AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)) > 19
  16556. GOTO ERR2
  16557. --登陆日志
  16558. SELECT @LastLoginDate = LastLoginDate, @TotalLoginNum = TotalLoginNum FROM paMain WITH(NOLOCK) WHERE ID = @Id
  16559. IF CONVERT(VARCHAR(8), @LastLoginDate, 112) = CONVERT(VARCHAR(8), GETDATE(), 112) --今天已经登陆过
  16560. BEGIN
  16561. IF @AutoLogin = 0 --首页的自动登录不计算在每日登陆次数
  16562. BEGIN
  16563. IF NOT EXISTS(SELECT 'x' FROM paLoginLog WITH(NOLOCK) WHERE paMainID = @ID AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120))
  16564. BEGIN
  16565. UPDATE DateReport
  16566. SET PersonLoginNum_Net = PersonLoginNum_Net + 1
  16567. WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  16568. AND Province_Id = @dcSubSiteID
  16569. SELECT @TotalLoginNum = @TotalLoginNum + 1
  16570. END
  16571. INSERT INTO paLoginLog(paMainID, LoginIP, Browser, LoginFrom) VALUES(@ID, @IP, '1:' + ISNULL(@browser, 'Null'), @LoginFrom)
  16572. END
  16573. ELSE
  16574. SELECT @TotalLoginNum = @TotalLoginNum + 1
  16575. IF @LastLoginDate < DATEADD(HOUR, -1, GETDATE()) --登录间隔>1小时更新登录时间
  16576. UPDATE paMain SET LastLoginDate = GETDATE(), TotalLoginNum = @TotalLoginNum WHERE ID = @ID
  16577. ELSE
  16578. UPDATE paMain SET TotalLoginNum = @TotalLoginNum WHERE ID = @ID
  16579. END
  16580. ELSE
  16581. BEGIN
  16582. ----今天第一次登录
  16583. INSERT INTO paLoginLog(paMainID, LoginIP, Browser, LoginFrom) VALUES(@ID, @IP, '2:' + ISNULL(@browser, 'Null'), @LoginFrom)
  16584. SELECT @TotalLoginNum = @TotalLoginNum + 1
  16585. UPDATE paMain SET TotalLoginNum = @TotalLoginNum, LastLoginDate = GETDATE() WHERE ID = @ID
  16586. UPDATE DateReport
  16587. SET PersonLoginNum_Net = PersonLoginNum_Net + 1
  16588. WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  16589. AND Province_Id = @dcSubSiteID
  16590. --INSERT INTO PaMainDateReport SELECT @Id, 11, GETDATE() --sean 20130708
  16591. END
  16592. END TRY
  16593. BEGIN CATCH
  16594. GOTO Err3
  16595. END CATCH
  16596. COMMIT
  16597. RETURN @ID
  16598. ERR1:
  16599. BEGIN
  16600. ROLLBACK TRAN
  16601. INSERT INTO LogDb..RegisterErrorLog SELECT @ID, '0|' + LTRIM(STR(@IDType)) + '|' + @IP, @UserName + ' ' + @PlainPassword, GETDATE()
  16602. RETURN 0
  16603. END
  16604. ERR2:
  16605. BEGIN
  16606. ROLLBACK TRAN
  16607. INSERT INTO LogDb..RegisterErrorLog SELECT @ID, '-1|' + LTRIM(STR(@IDType)) + '|' + @IP, @UserName + ' ' + @PlainPassword, GETDATE()
  16608. RETURN -1
  16609. END
  16610. ERR3:
  16611. BEGIN
  16612. ROLLBACK TRAN
  16613. INSERT INTO LogDb..RegisterErrorLog SELECT @ID, '-2|' + LTRIM(STR(@IDType)) + '|' + @IP, @UserName + ' ' + @PlainPassword, GETDATE()
  16614. RETURN -2
  16615. END
  16616. END TRY
  16617. BEGIN CATCH
  16618. ROLLBACK TRAN
  16619. INSERT INTO LogDb..RegisterErrorLog
  16620. SELECT @ID, '9|' + LTRIM(STR(@IDType)) + '|' + @IP, @UserName + ' ' + @PlainPassword, GETDATE()
  16621. END CATCH
  16622. GO
  16623. /****** Object: StoredProcedure [dbo].[pcpaMainByLoginUpdateNew] Script Date: 2018/12/13 19:09:01 ******/
  16624. SET ANSI_NULLS ON
  16625. GO
  16626. SET QUOTED_IDENTIFIER ON
  16627. GO
  16628. --------------------------------------------------
  16629. --修改:sean
  16630. --修改日期:2010-9-15
  16631. --说明:个人用户登陆 增加从Resume_Xinxi导数据的步骤
  16632. --2010-12-27 sean 修改个人第一次登录时 注册时间改为信息员推广时间
  16633. --密码加密后登录,2012-09-05修改 NIck
  16634. --修改:Peter 提取LoginFrom 以便统计登录来源,删掉Broser前缀
  16635. --修改:Carl 来源于毕业生信息网的账号 第一次登录时 简历状态改为公开
  16636. --lucifer 2018-2-24
  16637. --------------------------------------------------
  16638. CREATE PROCEDURE [dbo].[pcpaMainByLoginUpdateNew]
  16639. (
  16640. @UserName VARCHAR(50),
  16641. @PlainPassword VARCHAR(50),
  16642. @Password VARCHAR(60),
  16643. @IP VARCHAR(31),
  16644. @dcSubSiteId SMALLINT,
  16645. @AutoLogin TINYINT,
  16646. @browser VARCHAR(500),
  16647. @ID INT,
  16648. @IDType INT,
  16649. @LoginFrom TINYINT
  16650. )
  16651. AS
  16652. SET NOCOUNT ON
  16653. BEGIN TRY
  16654. BEGIN TRAN
  16655. DECLARE
  16656. @Resume_XinxiID AS INT,
  16657. @AddMan AS INT,
  16658. @AddDate AS DATETIME,
  16659. @Email AS VARCHAR(50),
  16660. @CountDate AS INT,
  16661. @dcProvinceID AS TINYINT,
  16662. @TotalLoginNum AS INT,
  16663. @LastLoginDate AS SMALLDATETIME,
  16664. @PaType INT
  16665. --SELECT @LoginFrom = 1, @Browser = '54:' + @Browser
  16666. SET @UserName = REPLACE(@UserName, ' ', '')
  16667. SELECT @CountDate = CONVERT(VARCHAR(8), GETDATE(), 112), @dcProvinceID = LEFT(@dcSubSiteId, 2)
  16668. SET @PaType = @IDType
  16669. BEGIN TRY
  16670. --第一次登录Carl
  16671. IF EXISTS (SELECT 'X' FROM paMain WITH(NOLOCK) WHERE RegisterType=200 AND Id=@ID AND TotalLoginNum=1)
  16672. UPDATE cvMain SET IscvHidden=0 WHERE paMainId=@ID
  16673. IF @PaType = 3
  16674. BEGIN
  16675. SELECT @Resume_XinxiID = ID, @AddMan =AddMan, @AddDate = RegDate, @Email = Email
  16676. FROM Resume_Xinxi WITH(NOLOCK INDEX(IX_Resume_Xinxi_UserName))
  16677. WHERE UserName = @UserName AND Password = @PlainPassword
  16678. IF @Resume_XinxiID IS NOT NULL
  16679. SET @PaType = 2
  16680. END
  16681. ELSE IF @PaType=0
  16682. BEGIN
  16683. SELECT TOP 1 @Resume_XinxiID = ID, @AddMan =AddMan, @AddDate = RegDate, @Email = Email
  16684. FROM Resume_Xinxi WITH(NOLOCK INDEX(IX_Resume_Xinxi_UserNameLower))
  16685. WHERE UserNameLower = @UserName AND Password = @PlainPassword
  16686. ORDER BY ID DESC
  16687. IF @Resume_XinxiID IS NOT NULL
  16688. SET @PaType = 4
  16689. END
  16690. IF @PaType = 0
  16691. GOTO Err1
  16692. IF @Resume_XinxiID > 0 ----账号在Resume_xinxi
  16693. BEGIN
  16694. --lucifer添加,添加新的注册模式
  16695. DECLARE @RegisterFrom AS TINYINT
  16696. SELECT @RegisterFrom = 1
  16697. IF CHARINDEX('ios',LOWER(@browser)) > 0
  16698. SELECT @RegisterFrom = 3
  16699. ELSE IF CHARINDEX('android',LOWER(@browser)) > 0
  16700. SELECT @RegisterFrom = 2
  16701. --把数据从Resume_Xini转换到paMain
  16702. INSERT INTO paMain(RegisterMode, AddMan, UserName, Password, Email, dcProvinceID, dcSubSiteId, RegisterIP, IsDefaultPassword, AddDate, RegisterFrom, RegisterType, SpreadDate)
  16703. VALUES(1, @AddMan, @UserName, @Password, @Email, @dcProvinceID, @dcSubSiteId, @IP, 1, GETDATE(), @RegisterFrom, 101, @AddDate)
  16704. SET @ID = @@IDENTITY
  16705. INSERT INTO paOperationLog (paMainID, Operation, Details, IP) VALUES(@ID, 10, '导入个人账号成功。', @IP)
  16706. --记录日报
  16707. UPDATE DateReport SET ValidResume = ValidResume + 1
  16708. WHERE province_id = @dcSubSiteID AND CountDate = @CountDate
  16709. INSERT INTO pamainDatereport SELECT @ID, 9, GETDATE() -- SEAN 20130911
  16710. --统计信息员注册数据
  16711. SELECT TOP 1 CountDate
  16712. FROM Info_Datereport WITH(NOLOCK)
  16713. WHERE CountDate = @CountDate
  16714. AND province_id = @dcProvinceID
  16715. AND InfoManager_ID = @AddMan
  16716. IF (@@ROWCOUNT=0)
  16717. INSERT INTO Info_DateReport(province_id,infomanager_id,countdate)
  16718. VALUES(@dcProvinceID, @AddMan, @CountDate)
  16719. UPDATE Info_Datereport
  16720. SET ValidResume=ValidResume + 1
  16721. WHERE CountDate=@CountDate
  16722. AND province_id=@dcProvinceID
  16723. AND InfoManager_ID = @AddMan
  16724. END
  16725. --超过登陆次数,每天限制登录次数位20次
  16726. IF (SELECT COUNT(1) FROM paLoginLog WITH(NOLOCK) WHERE paMainID = @ID AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)) > 19
  16727. GOTO ERR2
  16728. --登陆日志
  16729. SELECT @LastLoginDate = LastLoginDate, @TotalLoginNum = TotalLoginNum FROM paMain WITH(NOLOCK) WHERE ID = @Id
  16730. IF CONVERT(VARCHAR(8), @LastLoginDate, 112) = CONVERT(VARCHAR(8), GETDATE(), 112) --今天已经登陆过
  16731. BEGIN
  16732. IF @AutoLogin = 0 --首页的自动登录不计算在每日登陆次数
  16733. BEGIN
  16734. IF NOT EXISTS(SELECT 'x' FROM paLoginLog WITH(NOLOCK) WHERE paMainID = @ID AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120))
  16735. BEGIN
  16736. UPDATE DateReport
  16737. SET PersonLoginNum_Net = PersonLoginNum_Net + 1
  16738. WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  16739. AND Province_Id = @dcSubSiteID
  16740. SELECT @TotalLoginNum = @TotalLoginNum + 1
  16741. END
  16742. INSERT INTO paLoginLog(paMainID, LoginIP, Browser, LoginFrom) VALUES(@ID, @IP, ISNULL(@browser, 'Null'), @LoginFrom)
  16743. END
  16744. ELSE
  16745. SELECT @TotalLoginNum = @TotalLoginNum + 1
  16746. IF @LastLoginDate < DATEADD(HOUR, -1, GETDATE()) --登录间隔>1小时更新登录时间
  16747. UPDATE paMain SET LastLoginDate = GETDATE(), TotalLoginNum = @TotalLoginNum WHERE ID = @ID
  16748. ELSE
  16749. UPDATE paMain SET TotalLoginNum = @TotalLoginNum WHERE ID = @ID
  16750. END
  16751. ELSE
  16752. BEGIN
  16753. ----今天第一次登录
  16754. INSERT INTO paLoginLog(paMainID, LoginIP, Browser, LoginFrom) VALUES(@ID, @IP, ISNULL(@browser, 'Null'), @LoginFrom)
  16755. SELECT @TotalLoginNum = @TotalLoginNum + 1
  16756. UPDATE paMain SET TotalLoginNum = @TotalLoginNum, LastLoginDate = GETDATE() WHERE ID = @ID
  16757. UPDATE DateReport
  16758. SET PersonLoginNum_Net = PersonLoginNum_Net + 1
  16759. WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  16760. AND Province_Id = @dcSubSiteID
  16761. --INSERT INTO PaMainDateReport SELECT @Id, 11, GETDATE() --sean 20130708
  16762. END
  16763. END TRY
  16764. BEGIN CATCH
  16765. GOTO Err3
  16766. END CATCH
  16767. COMMIT
  16768. RETURN @ID
  16769. ERR1:
  16770. BEGIN
  16771. ROLLBACK TRAN
  16772. INSERT INTO LogDb..RegisterErrorLog SELECT @ID, 'a|' + LTRIM(STR(@IDType)) + '|' + @IP, @UserName + ' ' + @PlainPassword, GETDATE()
  16773. RETURN 0
  16774. END
  16775. ERR2:
  16776. BEGIN
  16777. ROLLBACK TRAN
  16778. INSERT INTO LogDb..RegisterErrorLog SELECT @ID, 'b|' + LTRIM(STR(@IDType)) + '|' + @IP, @UserName + ' ' + @PlainPassword, GETDATE()
  16779. RETURN -1
  16780. END
  16781. ERR3:
  16782. BEGIN
  16783. ROLLBACK TRAN
  16784. INSERT INTO LogDb..RegisterErrorLog SELECT @ID, 'c|' + LTRIM(STR(@IDType)) + '|' + @IP, @UserName + ' ' + @PlainPassword, GETDATE()
  16785. RETURN -2
  16786. END
  16787. END TRY
  16788. BEGIN CATCH
  16789. ROLLBACK TRAN
  16790. INSERT INTO LogDb..RegisterErrorLog
  16791. SELECT @ID, 'd|' + LTRIM(STR(@IDType)) + '|' + @IP, @UserName + ' ' + @PlainPassword, GETDATE()
  16792. END CATCH
  16793. GO
  16794. /****** Object: StoredProcedure [dbo].[pcPaMainByMobileExist] Script Date: 2018/12/13 19:09:01 ******/
  16795. SET ANSI_NULLS ON
  16796. GO
  16797. SET QUOTED_IDENTIFIER ON
  16798. GO
  16799. -- =============================================
  16800. -- Author: Sean
  16801. -- Create date: 2012-2-6
  16802. -- Description: 根据手机号取回密码,取回最新的5条
  16803. -- =============================================
  16804. CREATE PROCEDURE [dbo].[pcPaMainByMobileExist]
  16805. (
  16806. @Mobile VARCHAR(11)
  16807. )
  16808. AS
  16809. BEGIN
  16810. IF(dbo.IsMobile(@Mobile) = 0)
  16811. RETURN -1
  16812. IF EXISTS(SELECT 'x' FROM paMain WITH(NOLOCK) WHERE Mobile = @Mobile)
  16813. RETURN 1
  16814. ELSE
  16815. RETURN 0
  16816. END
  16817. GO
  16818. /****** Object: StoredProcedure [dbo].[pcPaMainByMobileSelect] Script Date: 2018/12/13 19:09:01 ******/
  16819. SET ANSI_NULLS ON
  16820. GO
  16821. SET QUOTED_IDENTIFIER ON
  16822. GO
  16823. -- =============================================
  16824. -- Lambo 20140909
  16825. -- 根据手机号取回个人用户,用于验证是否认证过手机号
  16826. -- =============================================
  16827. CREATE PROCEDURE [dbo].[pcPaMainByMobileSelect]
  16828. (
  16829. @Mobile VARCHAR(11)
  16830. )
  16831. AS
  16832. BEGIN
  16833. IF(dbo.IsMobile(@Mobile) = 0)
  16834. RETURN -1
  16835. SELECT Id, MobileVerifyDate FROM paMain WITH(INDEX(IX_paMain_Mobile))
  16836. WHERE Mobile = @Mobile
  16837. AND MobileVerifyDate IS NOT NULL
  16838. END
  16839. GO
  16840. /****** Object: StoredProcedure [dbo].[pcPaMainByMobileUpdate] Script Date: 2018/12/13 19:09:01 ******/
  16841. SET ANSI_NULLS ON
  16842. GO
  16843. SET QUOTED_IDENTIFIER ON
  16844. GO
  16845. -- =============================================
  16846. -- 检查: Sean
  16847. -- 日期: 2010-10-5
  16848. -- 描述: 修改手机号,首先检查是否在手机黑名单
  16849. -- =============================================
  16850. CREATE PROCEDURE [dbo].[pcPaMainByMobileUpdate]
  16851. (
  16852. @ID INT,
  16853. @Mobile VARCHAR(13),
  16854. @IP VARCHAR(31)
  16855. )
  16856. AS
  16857. IF EXISTS(SELECT 'x' FROM Person_BLACK WITH(NOLOCK) WHERE Mobile = @Mobile)
  16858. BEGIN
  16859. ----有黑名单,则增加拒绝次数
  16860. UPDATE Person_Black SET RefuseCount = RefuseCount + 1 WHERE Mobile = @Mobile
  16861. RETURN -1
  16862. END
  16863. BEGIN TRAN
  16864. DECLARE @MobileOld VARCHAR(13)
  16865. SELECT @MobileOld = ISNULL(Mobile ,'') FROM paMain WITH(NOLOCK INDEX(PK_paMain)) WHERE ID=@ID
  16866. IF @MobileOld <> @Mobile
  16867. BEGIN
  16868. UPDATE paMain SET Mobile = @Mobile, LastModifyDate=GETDATE() WHERE ID =@ID
  16869. INSERT INTO paOperationLog (paMainID,Operation,Details,IP)
  16870. VALUES(@ID,35,'更新手机号码,原号码:<'+@MobileOld +'>;新手机号码:<'+@Mobile+'>', @IP)
  16871. END
  16872. COMMIT
  16873. RETURN 1
  16874. ERR1:
  16875. BEGIN
  16876. ROLLBACK TRAN
  16877. RETURN 0
  16878. END
  16879. GO
  16880. /****** Object: StoredProcedure [dbo].[pcPaMainByMobileUpdateNew] Script Date: 2018/12/13 19:09:01 ******/
  16881. SET ANSI_NULLS ON
  16882. GO
  16883. SET QUOTED_IDENTIFIER ON
  16884. GO
  16885. CREATE PROCEDURE [dbo].[pcPaMainByMobileUpdateNew]
  16886. (
  16887. @ID INT,
  16888. @Mobile VARCHAR(13),
  16889. @IP VARCHAR(31),
  16890. @VerifyCode VARCHAR(6)
  16891. )
  16892. AS
  16893. BEGIN
  16894. IF EXISTS(SELECT 'x' FROM Person_BLACK WITH(NOLOCK) WHERE Mobile = @Mobile)
  16895. BEGIN
  16896. ----有黑名单,则增加拒绝次数
  16897. UPDATE Person_Black SET RefuseCount = RefuseCount + 1 WHERE Mobile = @Mobile
  16898. RETURN -1
  16899. END
  16900. BEGIN
  16901. ----验证验证码是否正确
  16902. DECLARE @paVerifyLogID AS INT
  16903. SET @paVerifyLogID = 0
  16904. SELECT @paVerifyLogID = ID FROM paVerifyLog WHERE Mobile = @Mobile AND VerifyCode = @VerifyCode AND AddDate>DATEADD(HOUR, -1, GETDATE())
  16905. IF @paVerifyLogID = 0
  16906. RETURN 0
  16907. END
  16908. BEGIN TRY
  16909. DECLARE @MobileOld VARCHAR(13)
  16910. SELECT @MobileOld = ISNULL(Mobile ,'') FROM paMain WITH(NOLOCK INDEX(PK_paMain)) WHERE ID=@ID AND MobileVerifyDate IS NOT NULL
  16911. IF NOT EXISTS(SELECT 'x' FROM PaMain WITH(NOLOCK) WHERE ID = @ID AND MobileVerifyDate IS NOT NULL AND Mobile = @Mobile)
  16912. BEGIN
  16913. UPDATE paMain SET Mobile = @Mobile, LastModifyDate=GETDATE() WHERE ID = @ID
  16914. ---- 把该手机号的其他账号状态修改为未认证
  16915. UPDATE paMain SET MobileVerifyDate = NULL WHERE mobile = @Mobile
  16916. UPDATE paMain SET MobileVerifyDate=GETDATE() WHERE ID =@ID
  16917. INSERT INTO paOperationLog (paMainID,Operation,Details,[IP])
  16918. VALUES(28404611,35,'更新手机号码,原号码:<'+ISNULL(@MobileOld,'')+'>;新手机号码:<'+@Mobile+'>', @IP)
  16919. END
  16920. RETURN 1
  16921. END TRY
  16922. BEGIN CATCH
  16923. RETURN 0
  16924. END CATCH
  16925. END
  16926. GO
  16927. /****** Object: StoredProcedure [dbo].[pcPaMainByMobileVerifyDateUpdate] Script Date: 2018/12/13 19:09:02 ******/
  16928. SET ANSI_NULLS ON
  16929. GO
  16930. SET QUOTED_IDENTIFIER ON
  16931. GO
  16932. CREATE PROCEDURE [dbo].[pcPaMainByMobileVerifyDateUpdate]
  16933. (
  16934. @ID INT,
  16935. @PaMainID INT,
  16936. @Mobile VARCHAR(13),
  16937. @dcCareerStatus TINYINT,
  16938. @IP VARCHAR(39),
  16939. @VerifyCode VARCHAR(6)
  16940. )
  16941. AS
  16942. SET NOCOUNT ON
  16943. SET @Mobile = dbo.TextTrim(@Mobile)
  16944. IF @Mobile IS NULL OR @dcCareerStatus IS NULL
  16945. RETURN -2 --手机号或求职状态为空
  16946. IF EXISTS(SELECT 'x' FROM Person_BLACK WITH(NOLOCK) WHERE Mobile = @Mobile)
  16947. BEGIN
  16948. ----有黑名单,则增加拒绝次数
  16949. UPDATE Person_Black SET RefuseCount = RefuseCount + 1 WHERE Mobile = @Mobile
  16950. RETURN -1
  16951. END
  16952. IF @ID > 0
  16953. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID = @ID AND paMainID = @paMainID)
  16954. RETURN -3
  16955. ----验证验证码是否正确
  16956. DECLARE @paVerifyLogID AS INT
  16957. SET @paVerifyLogID = 0
  16958. SELECT @paVerifyLogID = ID FROM paVerifyLog WHERE Mobile = @Mobile AND VerifyCode = @VerifyCode AND AddDate>DATEADD(HOUR, -1, GETDATE())
  16959. IF @paVerifyLogID = 0
  16960. RETURN 0
  16961. BEGIN TRAN
  16962. BEGIN TRY
  16963. --如果新旧日志不相同,记录更新手机号的操作
  16964. DECLARE @MobileOld AS VARCHAR(13)
  16965. SELECT @MobileOld = Mobile FROM paMain WITH(NOLOCK) WHERE ID = @paMAinID
  16966. IF ISNULL(@MobileOld, '') <> @Mobile
  16967. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  16968. VALUES(@paMainID, 35,'更新手机号,原手机号:<' + ISNULL(@MobileOld, '') + '>;新手机号:<' + @Mobile + '>', @IP)
  16969. UPDATE paMain SET Mobile = @mobile, dcCareerStatus = @dcCareerStatus,
  16970. LastModifyDate = GETDATE() WHERE ID = @PaMainID
  16971. UPDATE paMain SET MobileVerifyDate = GETDATE() WHERE ID = @PaMainID
  16972. UPDATE paMain SET MobileVerifyDate = null WHERE Mobile = @mobile AND ID <> @PaMainID
  16973. IF @ID > 0
  16974. UPDATE CvMain SET RefreshDate = GETDATE() WHERE paMainID = @paMainID AND ID = @ID
  16975. ELSe
  16976. UPDATE CvMain SET RefreshDate = GETDATE() WHERE paMainID = @paMainID
  16977. END TRY
  16978. BEGIN CATCH
  16979. GOTO Err
  16980. END CATCH
  16981. COMMIT TRAN
  16982. RETURN 1
  16983. Err:
  16984. BEGIN
  16985. ROLLBACK TRAN
  16986. RETURN 0
  16987. END
  16988. GO
  16989. /****** Object: StoredProcedure [dbo].[pcPaMainByNoticeUpdate] Script Date: 2018/12/13 19:09:02 ******/
  16990. SET ANSI_NULLS ON
  16991. GO
  16992. SET QUOTED_IDENTIFIER ON
  16993. GO
  16994. --创建时间:2015.11.09
  16995. --创建人:nick
  16996. --说明:修改是否提醒
  16997. --#####################################################
  16998. CREATE PROCEDURE [dbo].[pcPaMainByNoticeUpdate]
  16999. (
  17000. @PaMainID INT,
  17001. @Type INT ,--1是否app 2是否邮件 3是否微信
  17002. @IsNotice INT
  17003. )
  17004. AS
  17005. BEGIN
  17006. IF @Type = 1
  17007. BEGIN
  17008. UPDATE Pamain SET IsAppNotice = @IsNotice WHERE ID = @PaMainID
  17009. END
  17010. ELSE IF @Type = 2
  17011. BEGIN
  17012. UPDATE Pamain SET IsEmailNotice = @IsNotice WHERE ID = @PaMainID
  17013. END
  17014. ELSE IF @Type = 3
  17015. BEGIN
  17016. UPDATE Pamain SET IsWeixinNotice = @IsNotice WHERE ID = @PaMainID
  17017. END
  17018. ELSE IF @Type = 4
  17019. BEGIN
  17020. UPDATE Pamain SET IsAppJobFinder = @IsNotice WHERE ID = @PaMainID
  17021. END
  17022. ELSE IF @Type = 5
  17023. BEGIN
  17024. UPDATE Pamain SET IsEmailJobFinder = @IsNotice WHERE ID = @PaMainID
  17025. END
  17026. ELSE IF @Type = 6
  17027. BEGIN
  17028. UPDATE Pamain SET IsWeixinJobFinder = @IsNotice WHERE ID = @PaMainID
  17029. END
  17030. END
  17031. GO
  17032. /****** Object: StoredProcedure [dbo].[pcPaMainByPasswordUpdate] Script Date: 2018/12/13 19:09:02 ******/
  17033. SET ANSI_NULLS ON
  17034. GO
  17035. SET QUOTED_IDENTIFIER ON
  17036. GO
  17037. -- =============================================
  17038. -- 检查: Sean
  17039. -- 日期: 2010-10-5
  17040. -- 描述: 修改密码
  17041. -- =============================================
  17042. CREATE PROCEDURE [dbo].[pcPaMainByPasswordUpdate]
  17043. @ID INT,
  17044. @Password VARCHAR(50),
  17045. @PasswordOld VARCHAR(50),
  17046. @IP VARCHAR(50)
  17047. AS
  17048. BEGIN TRY
  17049. UPDATE paMain SET Password = @Password, IsDefaultPassword = 0 WHERE ID=@ID AND Password = @PasswordOld
  17050. IF @@RowCount =0
  17051. RETURN 0
  17052. ELSE
  17053. INSERT INTO paOperationLog (paMainID,Operation,Details,IP) VALUES(@ID,21,'更新密码,原密码:<'+@PasswordOld +'>;新密码:<'+@Password+'>', @IP)
  17054. RETURN 1
  17055. END TRY
  17056. BEGIN CATCH
  17057. RETURN 0
  17058. END CATCH
  17059. GO
  17060. /****** Object: StoredProcedure [dbo].[pcPaMainByPtCvInvitationInsert] Script Date: 2018/12/13 19:09:02 ******/
  17061. SET ANSI_NULLS ON
  17062. GO
  17063. SET QUOTED_IDENTIFIER ON
  17064. GO
  17065. CREATE PROCEDURE [dbo].[pcPaMainByPtCvInvitationInsert]
  17066. (
  17067. @Email VARCHAR(50),
  17068. @Mobile VARCHAR(11),
  17069. @Password VARCHAR(60),
  17070. @dcSubSiteID SMALLINT,
  17071. @RegisterIP VARCHAR(50)
  17072. )
  17073. AS
  17074. SET NOCOUNT ON
  17075. BEGIN
  17076. DECLARE @RegisterFrom AS VARCHAR(5), @RegisterType AS VARCHAR(5)
  17077. SELECT @RegisterFrom = 1, @RegisterType = 151
  17078. ----在黑名单中则终止
  17079. IF LEN(@Email) > 6 AND EXISTS(SELECT 'X' FROM Person_Black WITH(NOLOCK) WHERE Email = @Email)
  17080. BEGIN
  17081. UPDATE Person_black SET refusecount = refusecount + 1 where email = @Email
  17082. RETURN -1
  17083. END
  17084. ----在paMain中邮件重复则终止,新注册的都要是新邮箱
  17085. IF EXISTS(SELECT 'X' FROM paMain WITH(NOLOCK) WHERE EMail = @Email)
  17086. RETURN -2
  17087. DECLARE @MaxId AS INT, @AddMan SMALLINT, @RegisterMode TINYINT, @dcProvinceID TINYINT, @RegDate DATETIME
  17088. SELECT @RegisterMode = 0, @dcProvinceID = LEFT(@dcSubSiteID, 2)
  17089. --160天内,是否推广邮件,IsHistory有计划任务保证
  17090. SELECT TOP 1 @AddMan = AddMan, @RegDate = RegDate FROM Resume_Xinxi WITH( INDEX(IX_Resume_Xinxi_Email) NOLOCK)
  17091. WHERE Email = @Email AND IsHistory = 0
  17092. AND Province_ID = @dcProvinceID
  17093. ORDER BY RegDate DESC
  17094. ----是160天内推广的
  17095. IF @AddMan > 0
  17096. SELECT @RegisterMode = 1, @RegisterType = 111
  17097. DECLARE @CountDate AS INT
  17098. SET @CountDate = YEAR(GETDATE()) * 10000 + MONTH(GETDATE()) * 100 + DAY(GETDATE())
  17099. IF @RegisterMode = 0 --非推广,自己注册的
  17100. BEGIN
  17101. INSERT INTO paMain(Username, Password, dcProvinceID, dcSubSiteID, Email, Mobile, RegisterIP, LastLoginDate, TotalLoginNum, RegisterFrom, RegisterType)
  17102. VALUES(@Email, @Password, @dcProvinceID, @dcSubSiteID, @Email, @Mobile, @RegisterIP, GETDATE(), 1, @RegisterFrom, @RegisterType)
  17103. SET @MaxId = @@IDENTITY
  17104. UPDATE DateReport SET PersonRegNum = PersonRegNum + 1, PersonLoginNum_Net = PersonLoginNum_Net + 1
  17105. WHERE province_id = @dcSubSiteID AND CountDate = @CountDate
  17106. --INSERT INTO PaMainDateReport SELECT @MaxId, 11, GETDATE() --sean 20130708
  17107. INSERT INTO PaMainDateReport SELECT @MaxId, 2, GETDATE() --sean 20130708
  17108. END
  17109. ELSE --推广的
  17110. BEGIN
  17111. INSERT INTO paMain(Username, Password, dcProvinceID, dcSubSiteID, Email, RegisterIP, AddMan, RegisterMode, LastLoginDate, TotalLoginNum, AddDate, SpreadDate, RegisterFrom, RegisterType)
  17112. VALUES(@Email, @Password, @dcProvinceID, @dcSubSiteID, @Email, @RegisterIP, @AddMan, @RegisterMode, GETDATE(), 1, GETDATE(), @RegDate, @RegisterFrom, @RegisterType)
  17113. SET @MaxId = @@IDENTITY
  17114. UPDATE DateReport SET ValidResume = ValidResume + 1, PersonLoginNum_Net = PersonLoginNum_Net + 1
  17115. WHERE province_id = @dcSubSiteID AND CountDate = @CountDate
  17116. INSERT INTO PaMainDateReport SELECT @MaxId, 9, GETDATE() --sean 20130708
  17117. --INSERT INTO PaMainDateReport SELECT @MaxId, 11, GETDATE() --sean 20130708
  17118. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK)
  17119. WHERE CountDate = @CountDate
  17120. AND Province_ID = @dcProvinceID
  17121. AND InfoManager_ID = @AddMan
  17122. )
  17123. INSERT INTO Info_DateReport(Province_ID, Infomanager_ID, CountDate)
  17124. VALUES(@dcProvinceID, @AddMan, @CountDate)
  17125. UPDATE Info_DateReport
  17126. SET ValidResume = ValidResume + 1
  17127. WHERE CountDate = @CountDate
  17128. AND Province_ID = @dcProvinceID
  17129. AND InfoManager_ID = @AddMan
  17130. --Lucifer添加,新的register模式
  17131. UPDATE paMain SET SpreadDate = @RegDate, RegisterType=101 WHERE ID=@MaxId
  17132. END
  17133. INSERT INTO paOperationLog (paMainID,Operation,Details,IP) VALUES(@MaxID,10,'注册个人账号成功。',@RegisterIP)
  17134. INSERT INTO paLoginLog (paMainID, LoginIP, AddDate, LoginFrom, Browser) VALUES(@MaxID, @RegisterIP, GETDATE(), 1, '52:From PtCvInvitation')
  17135. RETURN @MaxID
  17136. END
  17137. ERR:
  17138. BEGIN
  17139. INSERT INTO LogDb..RegisterErrorLog SELECT @MaxId, '12|' + @RegisterIP, @Email + ' ' + @Password, GETDATE()
  17140. RETURN -3
  17141. END
  17142. GO
  17143. /****** Object: StoredProcedure [dbo].[pcpaMainByQQLoginUpdate] Script Date: 2018/12/13 19:09:03 ******/
  17144. SET ANSI_NULLS ON
  17145. GO
  17146. SET QUOTED_IDENTIFIER ON
  17147. GO
  17148. --------------------------------------------------
  17149. --lambo 2012-11-12
  17150. --前台QQ登陆和人人网登陆相关的存储过程,用于登陆后增加登陆日志
  17151. --------------------------------------------------
  17152. CREATE PROCEDURE [dbo].[pcpaMainByQQLoginUpdate]
  17153. (
  17154. @ID INT,
  17155. @browser VARCHAR(500),
  17156. @ip VARCHAR(31),
  17157. @dcProvinceID INT
  17158. )
  17159. AS
  17160. SET NOCOUNT ON
  17161. BEGIN TRAN
  17162. BEGIN TRY
  17163. DECLARE @TotalLoginNum AS INT, @LastLoginDate AS SMALLDATETIME
  17164. --超过登陆次数,每天限制登录次数位20次
  17165. IF (SELECT COUNT(1) FROM paLoginLog WITH(NOLOCK) WHERE paMainID = @ID AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)) > 19
  17166. GOTO ERR2
  17167. --登陆日志
  17168. SELECT @LastLoginDate = LastLoginDate, @TotalLoginNum = TotalLoginNum FROM paMain WITH(NOLOCK) WHERE ID = @Id
  17169. IF CONVERT(VARCHAR(8), @LastLoginDate, 112) = CONVERT(VARCHAR(8), GETDATE(), 112) --今天已经登陆过
  17170. BEGIN
  17171. INSERT INTO paLoginLog(paMainID, LoginIP, browser) VALUES(@ID, @IP, '3:' + ISNULL(@browser, 'Null'))
  17172. SELECT @TotalLoginNum = @TotalLoginNum + 1
  17173. IF @LastLoginDate < DATEADD(HOUR, -1, GETDATE()) --登录间隔>1小时更新登录时间
  17174. UPDATE paMain SET LastLoginDate = GETDATE(), TotalLoginNum = @TotalLoginNum WHERE ID = @ID
  17175. ELSE
  17176. UPDATE paMain SET TotalLoginNum = @TotalLoginNum WHERE ID = @ID
  17177. END
  17178. ELSE
  17179. BEGIN
  17180. ----今天第一次登录
  17181. INSERT INTO paLoginLog(paMainID, LoginIP, browser, LoginFrom) VALUES(@ID, @IP, '4:' + ISNULL(@browser, 'Null'), 55)
  17182. SELECT @TotalLoginNum = @TotalLoginNum + 1
  17183. UPDATE paMain SET TotalLoginNum = @TotalLoginNum, LastLoginDate = GETDATE() WHERE ID = @ID
  17184. UPDATE DateReport
  17185. SET PersonLoginNum_Net = PersonLoginNum_Net + 1
  17186. WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  17187. AND Province_Id = @dcProvinceID
  17188. --INSERT INTO PaMainDateReport SELECT @Id, 11, GETDATE() --sean 20130708
  17189. END
  17190. END TRY
  17191. BEGIN CATCH
  17192. GOTO Err3
  17193. END CATCH
  17194. COMMIT
  17195. RETURN @ID
  17196. ERR1:
  17197. BEGIN
  17198. ROLLBACK TRAN
  17199. RETURN 0
  17200. END
  17201. ERR2:
  17202. BEGIN
  17203. ROLLBACK TRAN
  17204. RETURN -1
  17205. END
  17206. ERR3:
  17207. BEGIN
  17208. ROLLBACK TRAN
  17209. RETURN -2
  17210. END
  17211. GO
  17212. /****** Object: StoredProcedure [dbo].[pcpaMainByQQLoginUpdateNew] Script Date: 2018/12/13 19:09:03 ******/
  17213. SET ANSI_NULLS ON
  17214. GO
  17215. SET QUOTED_IDENTIFIER ON
  17216. GO
  17217. --------------------------------------------------
  17218. --lambo 2012-11-12
  17219. --前台QQ登陆和人人网登陆相关的存储过程,用于登陆后增加登陆日志
  17220. --修改Peter 提取LoginFrom 用来统计登录来源 2016-07-15
  17221. --------------------------------------------------
  17222. CREATE PROCEDURE [dbo].[pcpaMainByQQLoginUpdateNew]
  17223. (
  17224. @ID INT,
  17225. @browser VARCHAR(500),
  17226. @ip VARCHAR(31),
  17227. @dcProvinceID INT,
  17228. @LoginFrom TINYINT
  17229. )
  17230. AS
  17231. SET NOCOUNT ON
  17232. SET @LoginFrom = 56
  17233. BEGIN TRAN
  17234. BEGIN TRY
  17235. DECLARE @TotalLoginNum AS INT, @LastLoginDate AS SMALLDATETIME
  17236. --超过登陆次数,每天限制登录次数位20次
  17237. IF (SELECT COUNT(1) FROM paLoginLog WITH(NOLOCK) WHERE paMainID = @ID AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)) > 19
  17238. GOTO ERR2
  17239. --登陆日志
  17240. SELECT @LastLoginDate = LastLoginDate, @TotalLoginNum = TotalLoginNum FROM paMain WITH(NOLOCK) WHERE ID = @Id
  17241. IF CONVERT(VARCHAR(8), @LastLoginDate, 112) = CONVERT(VARCHAR(8), GETDATE(), 112) --今天已经登陆过
  17242. BEGIN
  17243. INSERT INTO paLoginLog(paMainID, LoginIP, browser,LoginFrom) VALUES(@ID, @IP, ISNULL(@browser, 'Null') , @LoginFrom)
  17244. SELECT @TotalLoginNum = @TotalLoginNum + 1
  17245. IF @LastLoginDate < DATEADD(HOUR, -1, GETDATE()) --登录间隔>1小时更新登录时间
  17246. UPDATE paMain SET LastLoginDate = GETDATE(), TotalLoginNum = @TotalLoginNum WHERE ID = @ID
  17247. ELSE
  17248. UPDATE paMain SET TotalLoginNum = @TotalLoginNum WHERE ID = @ID
  17249. END
  17250. ELSE
  17251. BEGIN
  17252. ----今天第一次登录
  17253. INSERT INTO paLoginLog(paMainID, LoginIP, browser, LoginFrom) VALUES(@ID, @IP, ISNULL(@browser, 'Null'), @LoginFrom)
  17254. SELECT @TotalLoginNum = @TotalLoginNum + 1
  17255. UPDATE paMain SET TotalLoginNum = @TotalLoginNum, LastLoginDate = GETDATE() WHERE ID = @ID
  17256. UPDATE DateReport
  17257. SET PersonLoginNum_Net = PersonLoginNum_Net + 1
  17258. WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  17259. AND Province_Id = @dcProvinceID
  17260. --INSERT INTO PaMainDateReport SELECT @Id, 11, GETDATE() --sean 20130708
  17261. END
  17262. END TRY
  17263. BEGIN CATCH
  17264. GOTO Err3
  17265. END CATCH
  17266. COMMIT
  17267. RETURN @ID
  17268. ERR1:
  17269. BEGIN
  17270. ROLLBACK TRAN
  17271. RETURN 0
  17272. END
  17273. ERR2:
  17274. BEGIN
  17275. ROLLBACK TRAN
  17276. RETURN -1
  17277. END
  17278. ERR3:
  17279. BEGIN
  17280. ROLLBACK TRAN
  17281. RETURN -2
  17282. END
  17283. GO
  17284. /****** Object: StoredProcedure [dbo].[pcPaMainByRefreshDateUpdate] Script Date: 2018/12/13 19:09:03 ******/
  17285. SET ANSI_NULLS ON
  17286. GO
  17287. SET QUOTED_IDENTIFIER ON
  17288. GO
  17289. --####################################33
  17290. --更新求职状态,简历列表中使用
  17291. --@ID=cvmainID
  17292. --@ID=0 则更新全部简历
  17293. --返回值:
  17294. -- 0 数据库错误
  17295. -- -1 手机号已经列入黑名单
  17296. -- -2 手机号或求职状态为空
  17297. -- -3 该简历不属于该账号
  17298. --####################################33
  17299. CREATE PROCEDURE [dbo].[pcPaMainByRefreshDateUpdate]
  17300. (
  17301. @ID INT,
  17302. @PaMainID INT,
  17303. @Mobile VARCHAR(13),
  17304. @dcCareerStatus TINYINT,
  17305. @IP VARCHAR(39)
  17306. )
  17307. AS
  17308. SET NOCOUNT ON
  17309. SET @Mobile = dbo.TextTrim(@Mobile)
  17310. IF @Mobile IS NULL OR @dcCareerStatus IS NULL
  17311. RETURN -2 --手机号或求职状态为空
  17312. IF EXISTS(SELECT 'x' FROM Person_BLACK WITH(NOLOCK) WHERE Mobile = @Mobile)
  17313. BEGIN
  17314. ----有黑名单,则增加拒绝次数
  17315. UPDATE Person_Black SET RefuseCount = RefuseCount + 1 WHERE Mobile = @Mobile
  17316. RETURN -1
  17317. END
  17318. IF @ID > 0
  17319. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID = @ID AND paMainID = @paMainID)
  17320. RETURN -3
  17321. BEGIN TRAN
  17322. BEGIN TRY
  17323. --如果新旧日志不相同,记录更新手机号的操作
  17324. DECLARE @MobileOld AS VARCHAR(13)
  17325. SELECT @MobileOld = Mobile FROM paMain WITH(NOLOCK) WHERE ID = @paMAinID
  17326. IF ISNULL(@MobileOld, '') <> @Mobile
  17327. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  17328. VALUES(@paMainID, 35,'更新手机号,原手机号:<' + ISNULL(@MobileOld, '') + '>;新手机号:<' + @Mobile + '>', @IP)
  17329. UPDATE paMain SET Mobile = @mobile, dcCareerStatus = @dcCareerStatus,
  17330. LastModifyDate = GETDATE() WHERE ID = @PaMainID
  17331. IF @ID > 0
  17332. UPDATE CvMain SET RefreshDate = GETDATE() WHERE paMainID = @paMainID AND ID = @ID
  17333. ELSe
  17334. UPDATE CvMain SET RefreshDate = GETDATE() WHERE paMainID = @paMainID
  17335. END TRY
  17336. BEGIN CATCH
  17337. GOTO Err
  17338. END CATCH
  17339. COMMIT TRAN
  17340. RETURN 1
  17341. Err:
  17342. BEGIN
  17343. ROLLBACK TRAN
  17344. RETURN 0
  17345. END
  17346. GO
  17347. /****** Object: StoredProcedure [dbo].[pcPaMainByResetPasswordUpdate] Script Date: 2018/12/13 19:09:03 ******/
  17348. SET ANSI_NULLS ON
  17349. GO
  17350. SET QUOTED_IDENTIFIER ON
  17351. GO
  17352. ---*******************
  17353. --lambo 2012-11-9
  17354. --peter 2018-4-20
  17355. ---*******************
  17356. CREATE PROCEDURE [dbo].[pcPaMainByResetPasswordUpdate]
  17357. (
  17358. @ID INT,
  17359. @Password VARCHAR(80),
  17360. @PlainPassword VARCHAR(40),
  17361. @IP VARCHAR(50)
  17362. )
  17363. AS
  17364. BEGIN
  17365. IF NOT (dbo.ISAccount(@PlainPassword) = 1)
  17366. BEGIN
  17367. RETURN -2
  17368. END
  17369. ELSE
  17370. BEGIN
  17371. UPDATE paMain SET Password = @Password, IsDefaultPassword = 0 WHERE ID = @ID
  17372. IF @@RowCount =0
  17373. RETURN -3
  17374. ELSE
  17375. INSERT INTO paOperationLog (paMainID, Operation, Details, IP) VALUES(@ID, 21, '重置密码,新密码:<' + LEFT(@PlainPassword, 3) + '****>', @IP)
  17376. RETURN 1
  17377. END
  17378. END
  17379. GO
  17380. /****** Object: StoredProcedure [dbo].[pcPaMainByUserNameExist] Script Date: 2018/12/13 19:09:04 ******/
  17381. SET ANSI_NULLS ON
  17382. GO
  17383. SET QUOTED_IDENTIFIER ON
  17384. GO
  17385. -- =============================================
  17386. -- 检查: Sean
  17387. -- 日期: 2010-10-5
  17388. -- 描述: 检查Email是否存在
  17389. -- =============================================
  17390. CREATE PROCEDURE [dbo].[pcPaMainByUserNameExist]
  17391. (
  17392. @UserName VARCHAR(50)
  17393. )
  17394. AS
  17395. BEGIN
  17396. IF EXISTS(SELECT ID FROM paMain WITH(NOLOCK) WHERE UserNameLower = @UserName)
  17397. RETURN 1
  17398. ELSE
  17399. RETURN 0
  17400. END
  17401. GO
  17402. /****** Object: StoredProcedure [dbo].[pcPaMainByUsernameUpdate] Script Date: 2018/12/13 19:09:04 ******/
  17403. SET ANSI_NULLS ON
  17404. GO
  17405. SET QUOTED_IDENTIFIER ON
  17406. GO
  17407. -- =============================================
  17408. -- Author: Sean
  17409. -- Create date: 2010-9-15
  17410. -- Description: 修改用户名 ,EMail邮触发器联动修改
  17411. --lambo 20121109
  17412. -- =============================================
  17413. CREATE PROCEDURE [dbo].[pcPaMainByUsernameUpdate]
  17414. (
  17415. @ID INT,
  17416. @Username VARCHAR(50),
  17417. @IP VARCHAR(31)
  17418. )
  17419. AS
  17420. set nocount off
  17421. IF EXISTS(SELECT 'x' FROM Person_BLACK WITH(NOLOCK) WHERE EMail = @Username)
  17422. BEGIN
  17423. ----有黑名单,则增加拒绝次数
  17424. UPDATE Person_Black SET RefuseCount = RefuseCount + 1 WHERE EMail = @Username
  17425. RETURN 20
  17426. END
  17427. SET @Username = dbo.TextTrim(@Username)
  17428. BEGIN TRAN
  17429. BEGIN TRY
  17430. ----用户名不是邮箱格式
  17431. IF dbo.IsEmail(@Username) = 0
  17432. GOTO Err10
  17433. DECLARE @UsernameOld AS VARCHAR(50), @dcProvinceID INT, @AddMan INT,
  17434. @RegDate SMALLDATETIME, @RegisterMode INT, @RegisterType INT,
  17435. @CountDate VARCHAR(8)
  17436. SELECT @UsernameOld = UsernameLower, @dcProvinceID = dcProvinceID
  17437. FROM paMain WITH(NOLOCK INDEX(PK_paMain)) WHERE ID = @ID
  17438. --用户名重复验证,必须与原用户名不同
  17439. IF EXISTS(SELECT 'x' FROM paMain WITH(NOLOCK INDEX(IX_paMain_UserNameLower)) WHERE UserNameLower = @Username)
  17440. GOTO ERR11
  17441. --resume_xinxi的处理,这是删除
  17442. IF @UserNameOld LIKE '%@your_email.com'
  17443. BEGIN
  17444. --160天内,是否推广邮件,IsHistory有计划任务保证
  17445. SELECT TOP 1 @AddMan = AddMan, @RegDate = RegDate FROM Resume_Xinxi WITH( INDEX(IX_Resume_Xinxi_Email) NOLOCK)
  17446. WHERE Email = @UserName AND IsHistory = 0
  17447. AND Province_ID = @dcProvinceID
  17448. ORDER BY RegDate DESC
  17449. ----是160天内推广的
  17450. IF @AddMan > 0
  17451. BEGIN
  17452. SET @CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  17453. SELECT @RegisterMode = 1, @RegisterType = 111
  17454. UPDATE DateReport SET ValidResume = ValidResume + 1
  17455. WHERE province_id = @dcProvinceID AND CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  17456. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK)
  17457. WHERE CountDate = @CountDate
  17458. AND Province_ID = @dcProvinceID
  17459. AND InfoManager_ID = @AddMan
  17460. )
  17461. INSERT INTO Info_DateReport(Province_ID, Infomanager_ID, CountDate)
  17462. VALUES(@dcProvinceID, @AddMan, @CountDate)
  17463. UPDATE Info_DateReport
  17464. SET ValidResume = ValidResume + 1
  17465. WHERE CountDate = @CountDate
  17466. AND Province_ID = @dcProvinceID
  17467. AND InfoManager_ID = @AddMan
  17468. --Lucifer添加,新的register模式
  17469. UPDATE paMain SET AddMan = @AddMan, SpreadDate = @RegDate, RegisterType=101 WHERE ID=@Id
  17470. END
  17471. END
  17472. IF EXISTS(SELECT 'x' FROM Resume_Xinxi WITH(NOLOCK INDEX(IX_Resume_Xinxi_Email)) WHERE EMail = @Username)
  17473. DELETE FROM Resume_Xinxi WHERE EMail = @Username
  17474. UPDATE paMain SET Username = @Username WHERE ID = @ID
  17475. IF @@RowCount = 0
  17476. GOTO ERR
  17477. ELSE
  17478. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  17479. VALUES(@ID, 20, '更新用户名,原用户名:<' + @UsernameOld + '>;新用户名:<' + @Username + '>', @IP)
  17480. END TRY
  17481. BEGIN CATCH
  17482. GOTO ERR
  17483. END CATCH
  17484. COMMIT TRAN
  17485. RETURN 1
  17486. ERR:
  17487. BEGIN
  17488. ROLLBACK TRAN
  17489. RETURN 0
  17490. END
  17491. ERR10:
  17492. BEGIN
  17493. ROLLBACK TRAN
  17494. RETURN 10
  17495. END
  17496. ERR11:
  17497. BEGIN
  17498. ROLLBACK TRAN
  17499. RETURN 11
  17500. END
  17501. ERR21:
  17502. BEGIN
  17503. ROLLBACK TRAN
  17504. RETURN 21
  17505. END
  17506. GO
  17507. /****** Object: StoredProcedure [dbo].[pcPaMainByUsernameUpdate0320] Script Date: 2018/12/13 19:09:04 ******/
  17508. SET ANSI_NULLS ON
  17509. GO
  17510. SET QUOTED_IDENTIFIER ON
  17511. GO
  17512. -- =============================================
  17513. -- Author: Sean
  17514. -- Create date: 2010-9-15
  17515. -- Description: 修改用户名 ,EMail邮触发器联动修改
  17516. --lambo 20121109
  17517. -- =============================================
  17518. create PROCEDURE [dbo].[pcPaMainByUsernameUpdate0320]
  17519. (
  17520. @ID INT,
  17521. @Username VARCHAR(50),
  17522. @IP VARCHAR(31)
  17523. )
  17524. AS
  17525. IF EXISTS(SELECT 'x' FROM Person_BLACK WITH(NOLOCK) WHERE EMail = @Username)
  17526. BEGIN
  17527. ----有黑名单,则增加拒绝次数
  17528. UPDATE Person_Black SET RefuseCount = RefuseCount + 1 WHERE EMail = @Username
  17529. RETURN 20
  17530. END
  17531. SET @Username = dbo.TextTrim(@Username)
  17532. BEGIN TRAN
  17533. BEGIN TRY
  17534. ----用户名不是邮箱格式
  17535. IF dbo.IsEmail(@Username) = 0
  17536. GOTO Err10
  17537. DECLARE @UsernameOld AS VARCHAR(50)
  17538. SELECT @UsernameOld = Username FROM paMain WITH(NOLOCK INDEX(PK_paMain)) WHERE ID = @ID
  17539. --用户名重复验证,必须与原用户名不同
  17540. IF EXISTS(SELECT 'x' FROM paMain WITH(NOLOCK INDEX(IX_paMain_UserNameLower))
  17541. WHERE UserNameLower = @Username)
  17542. GOTO ERR11
  17543. --resume_xinxi的处理,这是删除
  17544. IF EXISTS(SELECT 'x' FROM Resume_Xinxi WITH(NOLOCK INDEX(IX_Resume_Xinxi_Email)) WHERE EMail = @Username)
  17545. DELETE FROM Resume_Xinxi WHERE EMail = @Username
  17546. UPDATE paMain SET Username = @Username WHERE ID = @ID
  17547. IF @@RowCount = 0
  17548. GOTO ERR
  17549. ELSE
  17550. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  17551. VALUES(@ID, 20, '更新用户名,原用户名:<' + @UsernameOld + '>;新用户名:<' + @Username + '>', @IP)
  17552. END TRY
  17553. BEGIN CATCH
  17554. GOTO ERR
  17555. END CATCH
  17556. COMMIT TRAN
  17557. RETURN 1
  17558. ERR:
  17559. BEGIN
  17560. ROLLBACK TRAN
  17561. RETURN 0
  17562. END
  17563. ERR10:
  17564. BEGIN
  17565. ROLLBACK TRAN
  17566. RETURN 10
  17567. END
  17568. ERR11:
  17569. BEGIN
  17570. ROLLBACK TRAN
  17571. RETURN 11
  17572. END
  17573. ERR21:
  17574. BEGIN
  17575. ROLLBACK TRAN
  17576. RETURN 21
  17577. END
  17578. GO
  17579. /****** Object: StoredProcedure [dbo].[pcPaMainByUsernameUpdate2] Script Date: 2018/12/13 19:09:04 ******/
  17580. SET ANSI_NULLS ON
  17581. GO
  17582. SET QUOTED_IDENTIFIER ON
  17583. GO
  17584. -- =============================================
  17585. -- Author: Sean
  17586. -- Create date: 2010-9-15
  17587. -- Description: 修改用户名 ,EMail邮触发器联动修改
  17588. --lambo 20121109
  17589. -- =============================================
  17590. CREATE PROCEDURE [dbo].[pcPaMainByUsernameUpdate2]
  17591. (
  17592. @ID INT,
  17593. @Username VARCHAR(50),
  17594. @IP VARCHAR(31)
  17595. )
  17596. AS
  17597. set nocount off
  17598. IF EXISTS(SELECT 'x' FROM Person_BLACK WITH(NOLOCK) WHERE EMail = @Username)
  17599. BEGIN
  17600. ----有黑名单,则增加拒绝次数
  17601. UPDATE Person_Black SET RefuseCount = RefuseCount + 1 WHERE EMail = @Username
  17602. RETURN 20
  17603. END
  17604. SET @Username = dbo.TextTrim(@Username)
  17605. BEGIN TRAN
  17606. BEGIN TRY
  17607. ----用户名不是邮箱格式
  17608. IF dbo.IsEmail(@Username) = 0
  17609. GOTO Err10
  17610. DECLARE @UsernameOld AS VARCHAR(50), @dcProvinceID INT, @AddMan INT,
  17611. @RegDate SMALLDATETIME, @RegisterMode INT, @RegisterType INT,
  17612. @CountDate VARCHAR(8)
  17613. SELECT @UsernameOld = UsernameLower, @dcProvinceID = dcProvinceID
  17614. FROM paMain WITH(NOLOCK INDEX(PK_paMain)) WHERE ID = @ID
  17615. --用户名重复验证,必须与原用户名不同
  17616. IF EXISTS(SELECT 'x' FROM paMain WITH(NOLOCK INDEX(IX_paMain_UserNameLower)) WHERE UserNameLower = @Username)
  17617. GOTO ERR11
  17618. --resume_xinxi的处理,这是删除
  17619. IF @UserNameOld LIKE '%@your_email.com'
  17620. BEGIN
  17621. --160天内,是否推广邮件,IsHistory有计划任务保证
  17622. SELECT TOP 1 @AddMan = AddMan, @RegDate = RegDate FROM Resume_Xinxi WITH( INDEX(IX_Resume_Xinxi_Email) NOLOCK)
  17623. WHERE Email = @UserName AND IsHistory = 0
  17624. AND Province_ID = @dcProvinceID
  17625. ORDER BY RegDate DESC
  17626. ----是160天内推广的
  17627. IF @AddMan > 0
  17628. BEGIN
  17629. SET @CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  17630. SELECT @RegisterMode = 1, @RegisterType = 111
  17631. UPDATE DateReport SET ValidResume = ValidResume + 1
  17632. WHERE province_id = @dcProvinceID AND CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  17633. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK)
  17634. WHERE CountDate = @CountDate
  17635. AND Province_ID = @dcProvinceID
  17636. AND InfoManager_ID = @AddMan
  17637. )
  17638. INSERT INTO Info_DateReport(Province_ID, Infomanager_ID, CountDate)
  17639. VALUES(@dcProvinceID, @AddMan, @CountDate)
  17640. UPDATE Info_DateReport
  17641. SET ValidResume = ValidResume + 1
  17642. WHERE CountDate = @CountDate
  17643. AND Province_ID = @dcProvinceID
  17644. AND InfoManager_ID = @AddMan
  17645. --Lucifer添加,新的register模式
  17646. UPDATE paMain SET AddMan = @AddMan, SpreadDate = @RegDate, RegisterType=101 WHERE ID=@Id
  17647. END
  17648. END
  17649. IF EXISTS(SELECT 'x' FROM Resume_Xinxi WITH(NOLOCK INDEX(IX_Resume_Xinxi_Email)) WHERE EMail = @Username)
  17650. DELETE FROM Resume_Xinxi WHERE EMail = @Username
  17651. UPDATE paMain SET Username = @Username WHERE ID = @ID
  17652. IF @@RowCount = 0
  17653. GOTO ERR
  17654. ELSE
  17655. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  17656. VALUES(@ID, 20, '更新用户名,原用户名:<' + @UsernameOld + '>;新用户名:<' + @Username + '>', @IP)
  17657. END TRY
  17658. BEGIN CATCH
  17659. GOTO ERR
  17660. END CATCH
  17661. COMMIT TRAN
  17662. RETURN 1
  17663. ERR:
  17664. BEGIN
  17665. ROLLBACK TRAN
  17666. RETURN 0
  17667. END
  17668. ERR10:
  17669. BEGIN
  17670. ROLLBACK TRAN
  17671. RETURN 10
  17672. END
  17673. ERR11:
  17674. BEGIN
  17675. ROLLBACK TRAN
  17676. RETURN 11
  17677. END
  17678. ERR21:
  17679. BEGIN
  17680. ROLLBACK TRAN
  17681. RETURN 21
  17682. END
  17683. GO
  17684. /****** Object: StoredProcedure [dbo].[pcPaMainByValidCvNumberSelect] Script Date: 2018/12/13 19:09:04 ******/
  17685. SET ANSI_NULLS ON
  17686. GO
  17687. SET QUOTED_IDENTIFIER ON
  17688. GO
  17689. CREATE PROCEDURE [dbo].[pcPaMainByValidCvNumberSelect]
  17690. (
  17691. @paMainID INT
  17692. )
  17693. AS
  17694. BEGIN
  17695. DECLARE @Cnt AS INT
  17696. SELECT @Cnt = COUNT(*) FROM cvMain WITH(NOLOCK)
  17697. WHERE paMainID = @paMainID
  17698. AND (
  17699. AttachMent > ''
  17700. OR(
  17701. cvLevel LIKE '1111_1%'
  17702. AND VerifyResult = 1
  17703. )
  17704. OR(
  17705. cvLevelEng LIKE '1111_1%'
  17706. AND VerifyResultEng = 1
  17707. )
  17708. )
  17709. RETURN @Cnt
  17710. END
  17711. GO
  17712. /****** Object: StoredProcedure [dbo].[pcPaMainByVerifyUpdate] Script Date: 2018/12/13 19:09:04 ******/
  17713. SET ANSI_NULLS ON
  17714. GO
  17715. SET QUOTED_IDENTIFIER ON
  17716. GO
  17717. --20180322 Carl 修改
  17718. CREATE PROCEDURE [dbo].[pcPaMainByVerifyUpdate]
  17719. (
  17720. @paMainID INT,
  17721. @Mobile VARCHAR(11),
  17722. @Email VARCHAR(50),
  17723. @VerifyCode VARCHAR(6)
  17724. )
  17725. AS
  17726. SET NOCOUNT ON
  17727. BEGIN
  17728. DECLARE @MobileVerifyDate SMALLDATETIME,@EmailVerifyDate SMALLDATETIME
  17729. SELECT @MobileVerifyDate = MobileVerifyDate,@EmailVerifyDate=EmailVerifyDate FROM paMain WHERE ID=@paMainID
  17730. IF LEN(@Mobile)=0 AND ISNULL(@EmailVerifyDate,'')<>''
  17731. RETURN -1
  17732. DECLARE @paVerifyLogID AS INT
  17733. SET @paVerifyLogID=0
  17734. SELECT @paVerifyLogID=ID FROM paVerifyLog WHERE paMainID=@paMainID AND ISNULL(Mobile,'')=@Mobile AND ISNULL(Email,'')=@Email
  17735. AND VerifyCode=@VerifyCode AND AddDate>DATEADD(HOUR,-1,GETDATE())
  17736. IF @paVerifyLogID=0
  17737. RETURN 0
  17738. UPDATE paVerifyLog SET VerifyDate=GETDATE() WHERE paMainID=@paMainID AND ISNULL(Mobile,'')=@Mobile AND ISNULL(Email,'')=@Email
  17739. AND VerifyCode=@VerifyCode AND AddDate>DATEADD(HOUR,-1,GETDATE())
  17740. IF LEN(@Mobile)=0
  17741. UPDATE paMain SET EmailVerifyDate=GETDATE() WHERE ID=@paMainID
  17742. IF LEN(@Email)=0
  17743. BEGIN
  17744. UPDATE paMain SET Mobile = @Mobile WHERE ID = @paMainID
  17745. --修改本手机号对应的其他帐号的认证状态
  17746. UPDATE paMain SET MobileVerifyDate = NULL WHERE Mobile = @Mobile
  17747. UPDATE paMain SET MobileVerifyDate = GETDATE() WHERE ID = @paMainID
  17748. IF @@ROWCOUNT > 0
  17749. DELETE FROM paMain WHERE ID IN(SELECT ID FROM paMain WITH(INDEX(IX_paMain_Mobile)) WHERE Mobile = @Mobile AND ID < @paMainID AND AddDate > DATEADD(MINUTE, -3, GETDATE()))
  17750. IF EXISTS(SELECT 'X' FROM paMobileFollowUp WHERE ISNULL(ContactDate,0)>DATEADD(hh,-1,GETDATE()) AND Mobile = @Mobile)
  17751. UPDATE paMobileFollowUp SET PaMainId=@paMainID WHERE Mobile = @Mobile
  17752. ELSE
  17753. DELETE FROM paMobileFollowUp WHERE Mobile = @Mobile
  17754. END
  17755. RETURN 1
  17756. END
  17757. GO
  17758. /****** Object: StoredProcedure [dbo].[pcPaMainByWordInsert] Script Date: 2018/12/13 19:09:05 ******/
  17759. SET ANSI_NULLS ON
  17760. GO
  17761. SET QUOTED_IDENTIFIER ON
  17762. GO
  17763. CREATE PROCEDURE [dbo].[pcPaMainByWordInsert]
  17764. (
  17765. @Username VARCHAR(50),
  17766. @Name NVARCHAR(6),
  17767. @Gender BIT,
  17768. @dcSubSiteID SMALLINT,
  17769. @RegisterIP VARCHAR(31),
  17770. @R VARCHAR(50) OUT
  17771. )
  17772. AS
  17773. BEGIN
  17774. DECLARE @paMainID AS INT
  17775. DECLARE @cvMainID AS INT
  17776. EXEC @paMainID = pcPaMainInsert @Username, '$2a$08$wCjRdWcKgup74i.L3sk6OOlCAQ/qAPmAWE4ZMzpJL7K85N0.x/WIu', @dcSubSiteID, @RegisterIP, 0, 0
  17777. UPDATE paMain SET Name = @Name, Gender = @Gender, IsDefaultPassword = 1 WHERE ID = @paMainID
  17778. EXEC @cvMainID = pcCvMainCreate @paMainID, @RegisterIP
  17779. UPDATE cvMain SET IsOpen = 0 WHERE Id = @cvMainId
  17780. --INSERT INTO cvJobPlace(cvMainId, dcRegionId) SELECT @cvMainId, @dcSubSiteID
  17781. SET @R = CAST(@cvMainID AS VARCHAR(10)) + ',' + CAST(@paMainID AS VARCHAR(10))
  17782. END
  17783. GO
  17784. /****** Object: StoredProcedure [dbo].[pcPaMainByWordInsertNew] Script Date: 2018/12/13 19:09:05 ******/
  17785. SET ANSI_NULLS ON
  17786. GO
  17787. SET QUOTED_IDENTIFIER ON
  17788. GO
  17789. CREATE PROCEDURE [dbo].[pcPaMainByWordInsertNew]
  17790. (
  17791. @Username VARCHAR(50),
  17792. @Name NVARCHAR(6),
  17793. @Gender BIT,
  17794. @dcSubSiteID SMALLINT,
  17795. @RegisterIP VARCHAR(31),
  17796. @Mobile VARCHAR(11),
  17797. @txtVeriyCode VARCHAR(6),
  17798. @R VARCHAR(50) OUT
  17799. )
  17800. AS
  17801. SET NOCOUNT ON
  17802. BEGIN
  17803. DECLARE @paMainID AS INT
  17804. DECLARE @cvMainID AS INT
  17805. EXEC @paMainID = pcPaMainInsert @Username, '$2a$08$wCjRdWcKgup74i.L3sk6OOlCAQ/qAPmAWE4ZMzpJL7K85N0.x/WIu', @dcSubSiteID, @RegisterIP, 0, 0
  17806. UPDATE paMain SET Name = @Name, Gender = @Gender, IsDefaultPassword = 1 WHERE ID = @paMainID
  17807. IF CHARINDEX('$', @RegisterIP) > 0
  17808. SET @RegisterIP = REPLACE(@RegisterIP,'|1$10', '')
  17809. EXEC pcPaVerifyLogUpdate @paMainID, @Mobile, @RegisterIP
  17810. EXEC pcPaMainByVerifyUpdate @paMainID, @Mobile, '', @txtVeriyCode
  17811. EXEC @cvMainID = pcCvMainCreate @paMainID, @RegisterIP
  17812. UPDATE cvMain SET IsOpen = 0 WHERE Id = @cvMainId
  17813. SET @R = CAST(@cvMainID AS VARCHAR(10)) + ','+ CAST(@paMainID AS VARCHAR(10))
  17814. END
  17815. GO
  17816. /****** Object: StoredProcedure [dbo].[pcPaMainEmailExist] Script Date: 2018/12/13 19:09:05 ******/
  17817. SET ANSI_NULLS ON
  17818. GO
  17819. SET QUOTED_IDENTIFIER ON
  17820. GO
  17821. -- =============================================
  17822. -- 检查: Sean
  17823. -- 日期: 2010-10-5
  17824. -- 描述: 检查Email是否存在
  17825. -- =============================================
  17826. CREATE PROCEDURE [dbo].[pcPaMainEmailExist]
  17827. (
  17828. @Email VARCHAR(50)
  17829. )
  17830. AS
  17831. BEGIN
  17832. IF EXISTS(SELECT ID FROM paMain WITH(NOLOCK) WHERE Email = @Email)
  17833. RETURN 1
  17834. ELSE
  17835. RETURN 0
  17836. END
  17837. GO
  17838. /****** Object: StoredProcedure [dbo].[pcPaMainImport] Script Date: 2018/12/13 19:09:05 ******/
  17839. SET ANSI_NULLS ON
  17840. GO
  17841. SET QUOTED_IDENTIFIER ON
  17842. GO
  17843. --创建:Max 2013-8-14
  17844. --说明:北大青鸟简历导入注册个人存储过程。没有IP限制。
  17845. --注册新用户,记录到dateReport
  17846. --过程:
  17847. --检查是否在黑名单 -1
  17848. --检查是否在paMain -2
  17849. --检查是否在推广表
  17850. -- 在推广表,并且160天内推广过的
  17851. -- 认为是推广有效,记录Addman,registermode=1
  17852. --删除推广表中的该邮件
  17853. --检查发帖来源
  17854. --检查连接来源
  17855. --保存错误 -3
  17856. --加密后的注册 暂时保留明文PlainPassword
  17857. ---------------------------------------------------
  17858. CREATE PROCEDURE [dbo].[pcPaMainImport]
  17859. (
  17860. @Email VARCHAR(50),
  17861. @Password VARCHAR(60),
  17862. @dcSubSiteID SMALLINT,
  17863. @RegisterIP VARCHAR(31),
  17864. @UrlID INT,
  17865. @InfoID INT
  17866. )
  17867. AS
  17868. SET NOCOUNT ON
  17869. IF (@RegisterIP = '180.129.225.52' OR @RegisterIP = '180.129.225.50' OR @RegisterIP = '220.164.162.215') AND LEN(@Email) > 30
  17870. RETURN 1
  17871. BEGIN TRAN
  17872. ----在黑名单中则终止
  17873. IF EXISTS(SELECT 'X' FROM Person_Black WITH(NOLOCK) WHERE Email = @Email)
  17874. BEGIN
  17875. UPDATE Person_black SET refusecount=refusecount+1 where email = @Email
  17876. COMMIT
  17877. RETURN -1
  17878. END
  17879. ----在paMain中邮件重复则终止,新注册的都要是新邮箱
  17880. IF EXISTS(SELECT 'X' FROM paMain WITH(NOLOCK) WHERE EMail = @Email)
  17881. BEGIN
  17882. ROLLBACK TRAN
  17883. RETURN -2
  17884. END
  17885. DECLARE @MaxId AS INT
  17886. DECLARE @AddMan SMALLINT
  17887. DECLARE @RegisterMode TINYINT
  17888. DECLARE @dcProvinceID TINYINT
  17889. SELECT @RegisterMode = 0, @dcProvinceID = LEFT(@dcSubSiteID, 2)
  17890. SET @Email = REPLACE(@Email, ' ', '')
  17891. --160天内,是否推广邮件,IsHistory有计划任务保证
  17892. SELECT TOP 1 @AddMan = AddMan FROM Resume_Xinxi WITH( INDEX(IX_Resume_Xinxi_Email) NOLOCK)
  17893. WHERE Email = @Email AND IsHistory = 0
  17894. AND Province_ID = @dcProvinceID
  17895. ORDER BY RegDate DESC
  17896. ----是160天内推广的
  17897. IF @AddMan > 0
  17898. SET @RegisterMode = 1
  17899. DECLARE @CountDate AS INT
  17900. SET @CountDate = YEAR(GETDATE())*10000+MONTH(GETDATE())*100+DAY(GETDATE())
  17901. IF @RegisterMode = 0 --非推广,自己注册的
  17902. BEGIN
  17903. INSERT INTO paMain(Username, Password, dcProvinceID, dcSubSiteID, Email, RegisterIP, LastLoginDate, TotalLoginNum)
  17904. VALUES(@Email, @Password, @dcProvinceID, @dcSubSiteID, @Email, @RegisterIP, GETDATE(), 1)
  17905. SET @MaxId = @@IDENTITY
  17906. UPDATE DateReport SET PersonRegNum = PersonRegNum + 1, PersonLoginNum_Net = PersonLoginNum_Net + 1
  17907. WHERE province_id = @dcSubSiteID AND CountDate = @CountDate
  17908. --INSERT INTO PaMainDateReport SELECT @MaxId, 11, GETDATE() --sean 20130708
  17909. INSERT INTO PaMainDateReport SELECT @MaxId, 2, GETDATE() --sean 20130708
  17910. END
  17911. ELSE --推广的
  17912. BEGIN
  17913. INSERT INTO paMain(Username, Password, dcProvinceID, dcSubSiteID, Email, RegisterIP, AddMan, RegisterMode, LastLoginDate, TotalLoginNum)
  17914. VALUES(@Email, @Password, @dcProvinceID, @dcSubSiteID, @Email, @RegisterIP, @AddMan, @RegisterMode, GETDATE(), 1)
  17915. SET @MaxId = @@IDENTITY
  17916. UPDATE DateReport SET ValidResume = ValidResume + 1, PersonLoginNum_Net = PersonLoginNum_Net + 1
  17917. WHERE province_id = @dcSubSiteID AND CountDate = @CountDate
  17918. INSERT INTO PaMainDateReport SELECT @MaxId, 9, GETDATE() --sean 20130708
  17919. --INSERT INTO PaMainDateReport SELECT @MaxId, 11, GETDATE() --sean 20130708
  17920. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK)
  17921. WHERE CountDate = @CountDate
  17922. AND Province_ID = @dcProvinceID
  17923. AND InfoManager_ID = @AddMan
  17924. )
  17925. INSERT INTO Info_DateReport(Province_ID, Infomanager_ID, CountDate)
  17926. VALUES(@dcProvinceID, @AddMan, @CountDate)
  17927. UPDATE Info_DateReport
  17928. SET ValidResume = ValidResume + 1
  17929. WHERE CountDate = @CountDate
  17930. AND Province_ID = @dcProvinceID
  17931. AND InfoManager_ID = @AddMan
  17932. END
  17933. INSERT INTO paOperationLog (paMainID,Operation,Details,IP) VALUES(@MaxID,10,'注册个人账号成功。',@RegisterIP)
  17934. INSERT INTO paLoginLog (paMainID, LoginIP, AddDate, LoginFrom, Browser) VALUES(@MaxID, @RegisterIP, GETDATE(), 1, '50:From Import')
  17935. COMMIT
  17936. BEGIN TRY
  17937. IF @UrlID>0
  17938. UPDATE Url SET AllResume=AllResume+1,TodayResume=TodayResume+1 WHERE ID=@UrlID
  17939. IF @InfoID>0
  17940. BEGIN
  17941. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK)
  17942. WHERE CountDate = @CountDate
  17943. AND Province_ID = @dcProvinceID
  17944. AND InfoManager_ID = @InfoID
  17945. )
  17946. INSERT INTO Info_DateReport(Province_ID, Infomanager_ID, CountDate)
  17947. VALUES(@dcProvinceID, @InfoID, @CountDate)
  17948. UPDATE Info_DateReport
  17949. SET AllResume = AllResume + 1
  17950. WHERE CountDate = @CountDate
  17951. AND Province_ID = @dcSubSiteID
  17952. AND InfoManager_ID = @InfoID
  17953. END
  17954. END TRY
  17955. BEGIN CATCH
  17956. RETURN -4
  17957. END CATCH
  17958. RETURN @MaxID
  17959. ERR:
  17960. BEGIN
  17961. ROLLBACK TRAN
  17962. RETURN -3
  17963. END
  17964. GO
  17965. /****** Object: StoredProcedure [dbo].[pcPaMainInsert] Script Date: 2018/12/13 19:09:06 ******/
  17966. SET ANSI_NULLS ON
  17967. GO
  17968. SET QUOTED_IDENTIFIER ON
  17969. GO
  17970. ---------------------------------------------------
  17971. --修改:Sean 2010-9-14
  17972. --说明:这是用户自己注册的主要存储过程
  17973. --注册新用户,记录到dateReport
  17974. --过程:
  17975. --检查是否在黑名单 -1
  17976. --检查是否在paMain -2
  17977. --检查是否在推广表
  17978. -- 在推广表,并且160天内推广过的
  17979. -- 认为是推广有效,记录Addman,registermode=1
  17980. --删除推广表中的该邮件
  17981. --检查发帖来源
  17982. --检查连接来源
  17983. --保存错误 -3
  17984. --加密后的注册 暂时保留明文PlainPassword
  17985. --Lucifer添加 修改registermode,将注册的类型和方式放到@RegisterIP传过来,举例192.168.1.1|1$120
  17986. --20180228 Carl 如果RegisterType=200,不进行时间限制
  17987. ---------------------------------------------------
  17988. CREATE PROCEDURE [dbo].[pcPaMainInsert]
  17989. (
  17990. @Email VARCHAR(50),
  17991. @Password VARCHAR(60),
  17992. @dcSubSiteID SMALLINT,
  17993. @RegisterIP VARCHAR(50),
  17994. @UrlID INT,
  17995. @InfoID INT
  17996. )
  17997. AS
  17998. SET NOCOUNT ON
  17999. IF EXISTS(SELECT 'x' FROM Ip_Black WITH(NOLOCK) WHERE Ip = @RegisterIP)
  18000. RETURN 0
  18001. BEGIN TRY
  18002. --Lucifer添加,拆解@RegisterIP
  18003. DECLARE @RegisterParam AS VARCHAR(20), @RegisterFrom AS VARCHAR(5), @RegisterType AS VARCHAR(5), @RegFrom AS VARCHAR(5)
  18004. SELECT @RegisterFrom = 1, @RegFrom = ''
  18005. IF CHARINDEX('|', @RegisterIP) > 0
  18006. BEGIN
  18007. SET @RegisterParam = SUBSTRING(@RegisterIP, CHARINDEX('|', @RegisterIP) + 1, LEN(@RegisterIP) - CHARINDEX('|', @RegisterIP))
  18008. SET @RegisterIP = SUBSTRING(@RegisterIP, 1, CHARINDEX('|', @RegisterIP) - 1)
  18009. IF (LEN(@RegisterIP) > 31)
  18010. SET @RegisterIp = LEFT(@RegisterIp, 31)
  18011. --Lucifer添加,拆解@RegisterIP
  18012. IF LEN(ISNULL(@RegisterParam, '')) > 0
  18013. BEGIN
  18014. SELECT @RegisterFrom = SUBSTRING(@RegisterParam, 1, CHARINDEX('$',@RegisterParam) - 1),
  18015. @RegisterType = SUBSTRING(@RegisterParam, CHARINDEX('$', @RegisterParam) + 1, LEN(@RegisterParam) - CHARINDEX('$', @RegisterParam))
  18016. IF @RegisterFrom = 'a'
  18017. SELECT @RegisterFrom = 1, @RegFrom = 'a'
  18018. END
  18019. END
  18020. --ELSE
  18021. --BEGIN
  18022. -- SELECT @RegisterFrom = 9, @RegisterType = 9
  18023. --END
  18024. IF @RegisterType = 0
  18025. SELECT @RegisterType = NULL
  18026. --IF (@RegisterIP = '180.129.225.52' OR @RegisterIP = '180.129.225.50' OR @RegisterIP = '220.164.162.215') AND LEN(@Email) > 30
  18027. -- RETURN 1
  18028. IF (SELECT COUNT(*) FROM paMain WITH(NOLOCK) WHERE RegisterIp = @RegisterIp AND AddDate > DATEADD(MINUTE, -10, GETDATE())) > 10 AND @RegisterType<>200
  18029. RETURN 1
  18030. -- IF NOT EXISTS(SELECT 'x' FROM Ip_White WHERE CHARINDEX(ip, @RegisterIp) > 0)
  18031. -- BEGIN
  18032. -- IF (SELECT COUNT(*) FROM paMain WITH(NOLOCK) WHERE RegisterIp = @RegisterIp AND AddDate > DATEADD(MINUTE, -30, GETDATE())) > 10
  18033. -- RETURN -1
  18034. -- --IF EXISTS(SELECT 'x' FROM tmp_limitip2 WHERE ip = @RegisterIP)
  18035. -- -- RETURN -1
  18036. -- END
  18037. BEGIN TRAN
  18038. ----在黑名单中则终止
  18039. IF LEN(@Email) > 6 AND EXISTS(SELECT 'X' FROM Person_Black WITH(NOLOCK) WHERE Email = @Email)
  18040. BEGIN
  18041. UPDATE Person_black SET refusecount = refusecount + 1 where email = @Email
  18042. COMMIT
  18043. RETURN -1
  18044. END
  18045. ----在paMain中邮件重复则终止,新注册的都要是新邮箱
  18046. IF EXISTS(SELECT 'X' FROM paMain WITH(NOLOCK) WHERE EMail = @Email)
  18047. BEGIN
  18048. ROLLBACK TRAN
  18049. RETURN -2
  18050. END
  18051. DECLARE @MaxId AS INT, @AddMan SMALLINT, @RegisterMode TINYINT, @dcProvinceID TINYINT, @RegDate DATETIME
  18052. SELECT @RegisterMode = 0, @dcProvinceID = LEFT(@dcSubSiteID, 2)
  18053. IF @RegisterType NOT IN(101)
  18054. BEGIN
  18055. SET @Email = dbo.SafeSQL(REPLACE(@Email, ' ', ''))
  18056. --160天内,是否推广邮件,IsHistory有计划任务保证
  18057. SELECT TOP 1 @AddMan = AddMan, @RegDate = RegDate FROM Resume_Xinxi WITH( INDEX(IX_Resume_Xinxi_Email) NOLOCK)
  18058. WHERE Email = @Email AND IsHistory = 0
  18059. AND Province_ID = @dcProvinceID AND @RegisterType<>200
  18060. ORDER BY RegDate DESC
  18061. ----是160天内推广的
  18062. IF @AddMan > 0
  18063. SELECT @RegisterMode = 1, @RegisterType = 111
  18064. END
  18065. IF @RegisterMode = 0 AND @InfoID BETWEEN 201 AND 499
  18066. BEGIN
  18067. SELECT @RegisterMode = 1, @RegisterType = 111, @AddMan = @InfoID
  18068. END
  18069. DECLARE @CountDate AS INT
  18070. SET @CountDate = YEAR(GETDATE()) * 10000 + MONTH(GETDATE()) * 100 + DAY(GETDATE())
  18071. IF @RegisterMode = 0 --非推广,自己注册的
  18072. BEGIN
  18073. INSERT INTO paMain(Username, Password, dcProvinceID, dcSubSiteID, Email, RegisterIP, LastLoginDate, TotalLoginNum, RegisterFrom, RegisterType)
  18074. VALUES(@Email, @Password, @dcProvinceID, @dcSubSiteID, @Email, @RegisterIP, GETDATE(), 1, @RegisterFrom, @RegisterType)
  18075. SET @MaxId = @@IDENTITY
  18076. IF @RegisterType <> 200
  18077. BEGIN
  18078. UPDATE DateReport SET PersonRegNum = PersonRegNum + 1, PersonLoginNum_Net = PersonLoginNum_Net + 1
  18079. WHERE province_id = @dcSubSiteID AND CountDate = @CountDate
  18080. INSERT INTO PaMainDateReport SELECT @MaxId, 2, GETDATE() --sean 20130708
  18081. END
  18082. ELSE
  18083. INSERT INTO PaMainDateReport SELECT @MaxId, 3, GETDATE() --sean 20130708
  18084. END
  18085. ELSE --推广的
  18086. BEGIN
  18087. INSERT INTO paMain(Username, Password, dcProvinceID, dcSubSiteID, Email, RegisterIP, AddMan, RegisterMode, LastLoginDate, TotalLoginNum, AddDate, SpreadDate, RegisterFrom, RegisterType)
  18088. VALUES(@Email, @Password, @dcProvinceID, @dcSubSiteID, @Email, @RegisterIP, @AddMan, @RegisterMode, GETDATE(), 1, GETDATE(), @RegDate, @RegisterFrom, @RegisterType)
  18089. SET @MaxId = @@IDENTITY
  18090. UPDATE DateReport SET ValidResume = ValidResume + 1, PersonLoginNum_Net = PersonLoginNum_Net + 1
  18091. WHERE province_id = @dcSubSiteID AND CountDate = @CountDate
  18092. INSERT INTO PaMainDateReport SELECT @MaxId, 9, GETDATE() --sean 20130708
  18093. --INSERT INTO PaMainDateReport SELECT @MaxId, 11, GETDATE() --sean 20130708
  18094. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK)
  18095. WHERE CountDate = @CountDate
  18096. AND Province_ID = @dcProvinceID
  18097. AND InfoManager_ID = @AddMan
  18098. )
  18099. INSERT INTO Info_DateReport(Province_ID, Infomanager_ID, CountDate)
  18100. VALUES(@dcProvinceID, @AddMan, @CountDate)
  18101. UPDATE Info_DateReport
  18102. SET ValidResume = ValidResume + 1
  18103. WHERE CountDate = @CountDate
  18104. AND Province_ID = @dcProvinceID
  18105. AND InfoManager_ID = @AddMan
  18106. --Lucifer添加,新的register模式
  18107. UPDATE paMain SET SpreadDate = @RegDate, RegisterType=101 WHERE ID=@MaxId
  18108. END
  18109. INSERT INTO paOperationLog (paMainID,Operation,Details,IP) VALUES(@MaxID,10,'注册个人账号成功。',@RegisterIP)
  18110. INSERT INTO paLoginLog (paMainID, LoginIP, AddDate, LoginFrom, Browser) VALUES(@MaxID, @RegisterIP, GETDATE(), 60, '51:From Register')
  18111. COMMIT
  18112. END TRY
  18113. BEGIN CATCH
  18114. ROLLBACK TRAN
  18115. INSERT INTO LogDb..RegisterErrorLog SELECT @MaxId, '10|' + @RegisterIP+'|'+@RegisterFrom, @Email + ' ' + @Password, GETDATE()
  18116. END CATCH
  18117. BEGIN TRY
  18118. IF @UrlID>0
  18119. BEGIN
  18120. UPDATE Url SET AllResume=AllResume+1,TodayResume=TodayResume+1 WHERE ID=@UrlID
  18121. --Lucifer添加,如果是百度竞价
  18122. IF EXISTS(SELECT 'X' FROM Url WHERE ID=@UrlID AND DescrIption LIKE '%百度竞价%')
  18123. INSERT INTO UrlAccount VALUES(@UrlID,@MaxID,NULL,GETDATE())
  18124. END
  18125. IF @InfoID > 0
  18126. BEGIN
  18127. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK)
  18128. WHERE CountDate = @CountDate
  18129. AND Province_ID = @dcProvinceID
  18130. AND InfoManager_ID = @InfoID
  18131. )
  18132. INSERT INTO Info_DateReport(Province_ID, Infomanager_ID, CountDate)
  18133. VALUES(@dcProvinceID, @InfoID, @CountDate)
  18134. UPDATE Info_DateReport
  18135. SET AllResume = AllResume + 1
  18136. WHERE CountDate = @CountDate
  18137. AND Province_ID = @dcSubSiteID
  18138. AND InfoManager_ID = @InfoID
  18139. INSERT INTO InfoLog(InfoManager_Id, Ip, Referer, paMainId)
  18140. VALUES(@InfoID, @RegisterIp, '', @MaxID)
  18141. END
  18142. IF @RegFrom = 'a'
  18143. INSERT INTO paFromSeoLog SELECT @MaxId, GETDATE()
  18144. END TRY
  18145. BEGIN CATCH
  18146. INSERT INTO LogDb..RegisterErrorLog SELECT @MaxId, '11|' + @RegisterIP, @Email + ' ' + @Password, GETDATE()
  18147. RETURN -4
  18148. END CATCH
  18149. RETURN @MaxID
  18150. ERR:
  18151. BEGIN
  18152. ROLLBACK TRAN
  18153. INSERT INTO LogDb..RegisterErrorLog SELECT @MaxId, '12|' + @RegisterIP, @Email + ' ' + @Password, GETDATE()
  18154. RETURN -3
  18155. END
  18156. GO
  18157. /****** Object: StoredProcedure [dbo].[pcPaMainSelect] Script Date: 2018/12/13 19:09:06 ******/
  18158. SET ANSI_NULLS ON
  18159. GO
  18160. SET QUOTED_IDENTIFIER ON
  18161. GO
  18162. CREATE PROCEDURE [dbo].[pcPaMainSelect]
  18163. (
  18164. @ID INT
  18165. )
  18166. AS
  18167. BEGIN
  18168. SELECT a.*, b.Name AS MapPlaceName,c.Description LiveRegion,d.Description AccountRegion,e.Description GrowRegion,dbo.BirthToAge(a.BirthDay) Age,
  18169. (SELECT COUNT(1) FROM paMain WITH(NOLOCK) WHERE Mobile = a.Mobile) AS MobileCount,
  18170. (SELECT TOP 1 LoginIP FROM paLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = a.ID ORDER BY ID DESC) AS LastLoginIP,
  18171. (SELECT COUNT(1) FROM paLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = a.ID AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)) AS TodayLoginNum,
  18172. (SELECT TOP 1 AddDate FROM PaLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = a.ID AND paLoginLog.AddDate < DATEADD(MINUTE, -2, a.LastLoginDate) ORDER BY Adddate DESC) AS PrevLoginDate,
  18173. (SELECT COUNT(1) FROM MainDB..WxFans WHERE PaMainID = a.ID AND Status = 2) WechatBind,
  18174. (SELECT TOP 1 PhotoProcessed FROM paPhoto WITH(NOLOCK INDEX(IX_paPhoto_paMainId)) WHERE paMainID = a.ID AND a.HasPhoto <> 2) AS PhotoProcessed,
  18175. (SELECT TOP 1 Description FROM dcCareerStatus WITH(NOLOCK) WHERE ID = a.dcCareerStatus) AS CareerStatus
  18176. FROM paMain a WITH(NOLOCK INDEX(PK_paMain)) LEFT JOIN dcMapPlace b WITH(NOLOCK) ON a.dcMapPlaceID = b.ID
  18177. LEFT JOIN dcRegion c WITH(NOLOCK) ON c.ID = a.LivePlace
  18178. LEFT JOIN dcRegion d WITH(NOLOCK) ON d.ID = a.AccountPlace
  18179. LEFT JOIN dcRegion e WITH(NOLOCK) ON e.ID = a.GrowPlace
  18180. WHERE a.ID = @ID
  18181. END
  18182. GO
  18183. /****** Object: StoredProcedure [dbo].[pcPaMainSelect1] Script Date: 2018/12/13 19:09:06 ******/
  18184. SET ANSI_NULLS ON
  18185. GO
  18186. SET QUOTED_IDENTIFIER ON
  18187. GO
  18188. -- =============================================
  18189. -- 检查: Sean
  18190. -- 日期: 2010-10-5
  18191. -- 描述: 提取个人账号信息
  18192. -- =============================================
  18193. -- =============================================
  18194. -- 修改: Peter
  18195. -- 日期: 2013-9-5
  18196. -- 描述: 添加获取上一次登录的登录时间
  18197. -- =============================================
  18198. CREATE PROCEDURE [dbo].[pcPaMainSelect1]
  18199. @ID INT
  18200. AS
  18201. BEGIN
  18202. SELECT *
  18203. ,(SELECT TOP 1 LoginIP FROM paLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = paMain.ID ORDER BY ID DESC) AS LastLoginIP
  18204. ,(SELECT COUNT(1) FROM paLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = paMain.ID AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)) AS TodayLoginNum
  18205. ,(SELECT TOP 1 AddDate FROM PaLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = paMain.ID AND paLoginLog.AddDate < DATEADD(MINUTE, -2, paMain.LastLoginDate) ORDER BY Adddate DESC) AS PrevLoginDate
  18206. FROM paMain WITH(NOLOCK INDEX(PK_paMain))
  18207. WHERE ID=@ID
  18208. END
  18209. GO
  18210. /****** Object: StoredProcedure [dbo].[pcPaMainSelectByPhone] Script Date: 2018/12/13 19:09:06 ******/
  18211. SET ANSI_NULLS ON
  18212. GO
  18213. SET QUOTED_IDENTIFIER ON
  18214. GO
  18215. CREATE PROCEDURE [dbo].[pcPaMainSelectByPhone]
  18216. @ID INT
  18217. AS
  18218. BEGIN
  18219. SELECT a.*,b.FullName LiveRegion,c.FullName GrowRegion,d.FullName AccountRegion,e.Description CareerStatus
  18220. ,(SELECT TOP 1 LoginIP FROM paLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = a.ID ORDER BY ID DESC) AS LastLoginIP,
  18221. (SELECT COUNT(1) FROM paLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = a.ID AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)) AS TodayLoginNum
  18222. FROM paMain a WITH(NOLOCK INDEX(PK_paMain))
  18223. INNER JOIN dcRegion b WITH(NOLOCK) ON a.LivePlace=b.ID
  18224. INNER JOIN dcRegion c WITH(NOLOCK) ON a.GrowPlace=c.ID
  18225. INNER JOIN dcRegion d WITH(NOLOCK) ON a.AccountPlace=d.ID
  18226. INNER JOIN dcCareerStatus e WITH(NOLOCK) ON a.dcCareerStatus=e.ID
  18227. WHERE a.ID=@ID
  18228. END
  18229. GO
  18230. /****** Object: StoredProcedure [dbo].[pcPaMainUpdate] Script Date: 2018/12/13 19:09:06 ******/
  18231. SET ANSI_NULLS ON
  18232. GO
  18233. SET QUOTED_IDENTIFIER ON
  18234. GO
  18235. -- =============================================
  18236. -- Author: Sean
  18237. -- Check date: 2010-9-17
  18238. -- Description: 修改账号信息 ,cvMainID为0时不修改cvmain信息
  18239. --修改:Peter 2016-03-30 一分钟填写简历同时修改求职状态
  18240. --修改harry 2018-7-5 处理liveplace等
  18241. -- =============================================
  18242. CREATE PROCEDURE [dbo].[pcPaMainUpdate]
  18243. (
  18244. @Type INT,
  18245. @paMainID INT,
  18246. @cvMainID INT,
  18247. @Name VARCHAR(30),
  18248. @Gender BIT,
  18249. @BirthDay INT,
  18250. @LivePlace VARCHAR(6),
  18251. @AccountPlace VARCHAR(6),
  18252. @GrowPlace VARCHAR(6),
  18253. @Mobile VARCHAR(13),
  18254. @OnlineContact TINYINT,
  18255. @OnlineContactNo VARCHAR(50),
  18256. @Homepage VARCHAR(200),
  18257. @Marriage TINYINT,
  18258. @Nation TINYINT,
  18259. @Height TINYINT,
  18260. @dcCareerStatus TINYINT,
  18261. @IP VARCHAR(39)
  18262. )
  18263. AS
  18264. SET NOCOUNT ON
  18265. IF CHARINDEX('<', @Name) > 0
  18266. SET @Name = REPLACE(@Name, '<', '')
  18267. IF CHARINDEX('<', @OnlineContactNo) > 0
  18268. SET @OnlineContactNo = REPLACE(@OnlineContactNo, '<', '')
  18269. IF CHARINDEX('<', @Homepage) > 0
  18270. SET @Homepage = REPLACE(@Homepage, '<', '')
  18271. IF ISNULL(@paMainID, 0) = 0
  18272. RETURN -9
  18273. IF dbo.TrimNULL(@Name) IS NULL
  18274. RETURN -8
  18275. IF dbo.TrimNULL(@Mobile) IS NULL
  18276. RETURN -7
  18277. IF @dcCareerStatus = 0
  18278. SET @dcCareerStatus = NULL
  18279. IF @Marriage = 0
  18280. SET @Marriage = NULL
  18281. IF @Nation = 0
  18282. SET @Nation = NULL
  18283. IF EXISTS(SELECT 'x' FROM Person_BLACK WITH(NOLOCK) WHERE Mobile = @Mobile)
  18284. BEGIN
  18285. ----有黑名单,则增加拒绝次数
  18286. UPDATE Person_Black SET RefuseCount = RefuseCount + 1 WHERE Mobile = @Mobile
  18287. RETURN -1
  18288. END
  18289. BEGIN TRAN
  18290. BEGIN TRY
  18291. IF CHARINDEX(' ', @LivePlace) >2
  18292. BEGIN
  18293. SET @LivePlace=substring(@LivePlace,1,charindex(' ',@LivePlace)-1)
  18294. END
  18295. IF CHARINDEX(' ', @AccountPlace) >2
  18296. BEGIN
  18297. SET @AccountPlace=substring(@AccountPlace,1,charindex(' ',@AccountPlace)-1)
  18298. END
  18299. IF CHARINDEX(' ', @GrowPlace) >2
  18300. BEGIN
  18301. SET @GrowPlace=substring(@GrowPlace,1,charindex(' ',@GrowPlace)-1)
  18302. END
  18303. DECLARE @NameEngOld AS VARCHAR(30)
  18304. DECLARE @NameOld AS VARCHAR(12)
  18305. DECLARE @OnlineContactNoOld AS VARCHAR(50)
  18306. DECLARE @HomepageOld AS VARCHAR(200)
  18307. DECLARE @MobileOld AS VARCHAR(13)
  18308. DECLARE @Modify AS INT
  18309. -- @Modify=-1未修改需审核项, @Modify=0修改中文项目; @Modify=1修改了英文项目
  18310. SET @Modify=-1
  18311. --检查在线联系方式和号码
  18312. IF @OnlineContact IS NULL
  18313. SET @OnlineContactNo = ''
  18314. ELSE
  18315. SET @OnlineContactNo = dbo.SafeSql(@OnlineContactNo)
  18316. --取消不正确的主页格式
  18317. SET @Homepage=REPLACE(@Homepage,'http%3A//','http://')
  18318. SET @Homepage=REPLACE(@Homepage,'http://','')
  18319. IF LTRIM(RTRIM(@Homepage)) = 'http://'
  18320. SET @Homepage = null
  18321. IF ISNULL(@Homepage, '') = ''
  18322. SET @Homepage = null
  18323. IF ISNULL(@OnlineContactNo, '') = ''
  18324. SET @OnlineContactNo = null
  18325. --获得原始数据
  18326. SELECT @NameOld=Name,@NameEngOld=NameEng,@OnlineContactNoOld=OnlineContactNo,@HomepageOld=Homepage,@MobileOld=Mobile
  18327. FROM paMain WITH(NOLOCK INDEX(PK_paMain))
  18328. WHERE ID = @paMainID
  18329. --0中文,1英文,只有姓名不同
  18330. IF @TYPE=0
  18331. BEGIN
  18332. DECLARE @CNAME AS VARCHAR(12)
  18333. SET @CNAME = @Name
  18334. UPDATE paMain
  18335. SET Name=@CNAME,
  18336. Gender=@Gender,
  18337. BirthDay=@BirthDay,
  18338. LivePlace=@LivePlace,
  18339. AccountPlace=@AccountPlace,
  18340. GrowPlace=@GrowPlace,
  18341. Mobile=@Mobile,
  18342. OnlineContact=@OnlineContact,
  18343. OnlineContactNo=@OnlineContactNo,
  18344. Homepage=@Homepage,
  18345. Marriage=@Marriage,
  18346. Nation=@Nation,
  18347. Height=@Height,
  18348. dcCareerStatus=@dcCareerStatus,
  18349. LastModifyDate=GETDATE()
  18350. WHERE ID=@paMainID
  18351. END
  18352. ELSE
  18353. UPDATE paMain
  18354. SET NameENG=@Name,
  18355. Gender=@Gender,
  18356. BirthDay=@BirthDay,
  18357. LivePlace=@LivePlace,
  18358. AccountPlace=@AccountPlace,
  18359. GrowPlace=@GrowPlace,
  18360. Mobile=@Mobile,
  18361. OnlineContact=@OnlineContact,
  18362. OnlineContactNo=@OnlineContactNo,
  18363. Homepage=@Homepage,
  18364. Marriage=@Marriage,
  18365. Nation=@Nation,
  18366. Height=@Height,
  18367. dcCareerStatus=@dcCareerStatus,
  18368. LastModifyDate=GETDATE()
  18369. WHERE ID=@paMainID
  18370. --保存到bsCvModify,姓名
  18371. IF @TYPE=0
  18372. BEGIN
  18373. IF ISNULL(@NameOld, '') <> @CNAME
  18374. BEGIN
  18375. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac1'
  18376. INSERT INTO bsCvModify(paMainID,Location,ColValue) VALUES(@paMainID,'ac1',@CNAME)
  18377. SET @Modify=0
  18378. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  18379. VALUES(@paMainID, 30,'更新姓名,原姓名:<' + ISNULL(@NameOld, '') + '>;新姓名:<' + @CName + '>', @IP)
  18380. END
  18381. END
  18382. ELSE
  18383. IF ISNULL(@NameOld, '') <> @Name
  18384. BEGIN
  18385. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ae1'
  18386. INSERT INTO bsCvModify(paMainID,Location,ColValue) VALUES(@paMainID,'ae1',@CNAME)
  18387. SET @Modify=1
  18388. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  18389. VALUES(@paMainID, 31,'更新英文名,原英文名:<' + ISNULL(@NameOld, '') + '>;新英文名:<' + @Name + '>', @IP)
  18390. END
  18391. --在线联系号码
  18392. IF @OnlineContactNo IS NULL
  18393. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac2'
  18394. ELSE
  18395. IF @OnlineContactNo <> ISNULL(@OnlineContactNoOld, '')
  18396. BEGIN
  18397. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac2'
  18398. INSERT INTO bsCvModify(paMainID,Location,ColValue) VALUES(@paMainID,'ac2',@OnlineContactNo)
  18399. SET @Modify=0
  18400. END
  18401. --主页
  18402. IF @Homepage IS NULL
  18403. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac3'
  18404. ELSE
  18405. IF @Homepage <> ISNULL(@HomepageOld, '')
  18406. BEGIN
  18407. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac3'
  18408. INSERT INTO bsCvModify(paMainID,Location,ColValue) VALUES(@paMainID,'ac3',@Homepage)
  18409. SET @Modify=0
  18410. END
  18411. --手机号码
  18412. IF ISNULL(@MobileOld, '') <> @Mobile
  18413. BEGIN
  18414. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac4'
  18415. --INSERT INTO bsCvModify(paMainID,Location,ColValue) VALUES(@paMainID,'ac4',@Mobile)
  18416. --SET @Modify=0
  18417. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  18418. VALUES(@paMainID, 35,'更新手机号,原手机号:<' + ISNULL(@MobileOld, '') + '>;新手机号:<' + @Mobile + '>', @IP)
  18419. END
  18420. ----修改cvMain.cvLevel
  18421. IF @TYPE=0
  18422. UPDATE cvMain SET cvLevel='11' + RIGHT(cvLevel,8) WHERE paMainID = @paMainID
  18423. ELSE
  18424. UPDATE cvMain SET cvLevelEng='11' + RIGHT(cvLevelEng,8) WHERE paMainID = @paMainID
  18425. --1小时内不重复刷新,防止刷新排名
  18426. UPDATE cvmain SET RefreshDate = GETDATE() WHERE ID=@cvMainID AND DATEADD(HOUR, 1, RefreshDate) < GETDATE() AND paMainID = @paMainID
  18427. ----12小时内只保留一次修改记录
  18428. DELETE FROM paOperationLog WHERE paMainID=@paMainID AND Operation=11 AND AddDate>GETDATE()-0.5
  18429. INSERT INTO paOperationLog (paMainID,Operation,Details,IP) VALUES(@paMainID,11,'更新基本信息成功。',@IP)
  18430. END TRY
  18431. BEGIN CATCH
  18432. GOTO ERR
  18433. END CATCH
  18434. COMMIT TRAN
  18435. RETURN 1
  18436. ERR:
  18437. BEGIN
  18438. ROLLBACK TRAN
  18439. RETURN 0
  18440. END
  18441. GO
  18442. /****** Object: StoredProcedure [dbo].[pcPaMainUpdate20171108] Script Date: 2018/12/13 19:09:08 ******/
  18443. SET ANSI_NULLS ON
  18444. GO
  18445. SET QUOTED_IDENTIFIER ON
  18446. GO
  18447. -- =============================================
  18448. -- Author: Sean
  18449. -- Check date: 2010-9-17
  18450. -- Description: 修改账号信息 ,cvMainID为0时不修改cvmain信息
  18451. --修改:Peter 2016-03-30 一分钟填写简历同时修改求职状态
  18452. --修改harry 2018-7-5 处理liveplace等
  18453. -- =============================================
  18454. CREATE PROCEDURE [dbo].[pcPaMainUpdate20171108]
  18455. (
  18456. @Type INT,
  18457. @paMainID INT,
  18458. @cvMainID INT,
  18459. @Name VARCHAR(30),
  18460. @Gender BIT,
  18461. @BirthDay INT,
  18462. @LivePlace VARCHAR(6),
  18463. @AccountPlace VARCHAR(6),
  18464. @GrowPlace VARCHAR(6),
  18465. @Mobile VARCHAR(13),
  18466. @OnlineContact TINYINT,
  18467. @OnlineContactNo VARCHAR(50),
  18468. @Homepage VARCHAR(200),
  18469. @Marriage TINYINT,
  18470. @Nation TINYINT,
  18471. @Height TINYINT,
  18472. @dcCareerStatus TINYINT,
  18473. @IP VARCHAR(39),
  18474. @dcMapPlaceId INT
  18475. )
  18476. AS
  18477. SET NOCOUNT ON
  18478. IF CHARINDEX('<', @Name) > 0
  18479. SET @Name = REPLACE(@Name, '<', '')
  18480. IF CHARINDEX('<', @OnlineContactNo) > 0
  18481. SET @OnlineContactNo = REPLACE(@OnlineContactNo, '<', '')
  18482. IF CHARINDEX('<', @Homepage) > 0
  18483. SET @Homepage = REPLACE(@Homepage, '<', '')
  18484. IF ISNULL(@paMainID, 0) = 0
  18485. RETURN -9
  18486. IF dbo.TrimNULL(@Name) IS NULL
  18487. RETURN -8
  18488. IF dbo.TrimNULL(@Mobile) IS NULL
  18489. RETURN -7
  18490. IF @dcCareerStatus = 0
  18491. SET @dcCareerStatus = NULL
  18492. IF @Marriage = 0
  18493. SET @Marriage = NULL
  18494. IF @Nation = 0
  18495. SET @Nation = NULL
  18496. IF EXISTS(SELECT 'x' FROM Person_BLACK WITH(NOLOCK) WHERE Mobile = @Mobile)
  18497. BEGIN
  18498. ----有黑名单,则增加拒绝次数
  18499. UPDATE Person_Black SET RefuseCount = RefuseCount + 1 WHERE Mobile = @Mobile
  18500. RETURN -1
  18501. END
  18502. BEGIN TRAN
  18503. BEGIN TRY
  18504. IF CHARINDEX(' ', @LivePlace) >2
  18505. BEGIN
  18506. SET @LivePlace=substring(@LivePlace,1,charindex(' ',@LivePlace)-1)
  18507. END
  18508. IF CHARINDEX(' ', @AccountPlace) >2
  18509. BEGIN
  18510. SET @AccountPlace=substring(@AccountPlace,1,charindex(' ',@AccountPlace)-1)
  18511. END
  18512. IF CHARINDEX(' ', @GrowPlace) >2
  18513. BEGIN
  18514. SET @GrowPlace=substring(@GrowPlace,1,charindex(' ',@GrowPlace)-1)
  18515. END
  18516. DECLARE @NameEngOld AS VARCHAR(30)
  18517. DECLARE @NameOld AS VARCHAR(12)
  18518. DECLARE @OnlineContactNoOld AS VARCHAR(50)
  18519. DECLARE @HomepageOld AS VARCHAR(200)
  18520. DECLARE @MobileOld AS VARCHAR(13)
  18521. DECLARE @Modify AS INT
  18522. -- @Modify=-1未修改需审核项, @Modify=0修改中文项目; @Modify=1修改了英文项目
  18523. SET @Modify=-1
  18524. --检查在线联系方式和号码
  18525. IF @OnlineContact IS NULL
  18526. SET @OnlineContactNo = ''
  18527. ELSE
  18528. SET @OnlineContactNo = dbo.SafeSql(@OnlineContactNo)
  18529. --取消不正确的主页格式
  18530. SET @Homepage=REPLACE(@Homepage,'http%3A//','http://')
  18531. SET @Homepage=REPLACE(@Homepage,'http://','')
  18532. IF LTRIM(RTRIM(@Homepage)) = 'http://'
  18533. SET @Homepage = null
  18534. IF ISNULL(@Homepage, '') = ''
  18535. SET @Homepage = null
  18536. IF ISNULL(@OnlineContactNo, '') = ''
  18537. SET @OnlineContactNo = null
  18538. --获得原始数据
  18539. SELECT @NameOld=Name,@NameEngOld=NameEng,@OnlineContactNoOld=OnlineContactNo,@HomepageOld=Homepage,@MobileOld=Mobile
  18540. FROM paMain WITH(NOLOCK INDEX(PK_paMain))
  18541. WHERE ID = @paMainID
  18542. --0中文,1英文,只有姓名不同
  18543. IF @TYPE=0
  18544. BEGIN
  18545. DECLARE @CNAME AS VARCHAR(12)
  18546. SET @CNAME = @Name
  18547. UPDATE paMain
  18548. SET Name=@CNAME,
  18549. Gender=@Gender,
  18550. BirthDay=@BirthDay,
  18551. LivePlace=@LivePlace,
  18552. AccountPlace=@AccountPlace,
  18553. GrowPlace=@GrowPlace,
  18554. Mobile=@Mobile,
  18555. OnlineContact=@OnlineContact,
  18556. OnlineContactNo=@OnlineContactNo,
  18557. Homepage=@Homepage,
  18558. Marriage=@Marriage,
  18559. Nation=@Nation,
  18560. Height=@Height,
  18561. dcCareerStatus=@dcCareerStatus,
  18562. dcMapPlaceId = @dcMapPlaceId,
  18563. LastModifyDate=GETDATE()
  18564. WHERE ID=@paMainID
  18565. END
  18566. ELSE
  18567. UPDATE paMain
  18568. SET NameENG=@Name,
  18569. Gender=@Gender,
  18570. BirthDay=@BirthDay,
  18571. LivePlace=@LivePlace,
  18572. AccountPlace=@AccountPlace,
  18573. GrowPlace=@GrowPlace,
  18574. Mobile=@Mobile,
  18575. OnlineContact=@OnlineContact,
  18576. OnlineContactNo=@OnlineContactNo,
  18577. Homepage=@Homepage,
  18578. Marriage=@Marriage,
  18579. Nation=@Nation,
  18580. Height=@Height,
  18581. dcCareerStatus=@dcCareerStatus,
  18582. dcMapPlaceId = @dcMapPlaceId,
  18583. LastModifyDate=GETDATE()
  18584. WHERE ID=@paMainID
  18585. --保存到bsCvModify,姓名
  18586. IF @TYPE=0
  18587. BEGIN
  18588. IF ISNULL(@NameOld, '') <> @CNAME
  18589. BEGIN
  18590. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac1'
  18591. INSERT INTO bsCvModify(paMainID,Location,ColValue) VALUES(@paMainID,'ac1',@CNAME)
  18592. SET @Modify=0
  18593. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  18594. VALUES(@paMainID, 30,'更新姓名,原姓名:<' + ISNULL(@NameOld, '') + '>;新姓名:<' + @CName + '>', @IP)
  18595. END
  18596. END
  18597. ELSE
  18598. IF ISNULL(@NameOld, '') <> @Name
  18599. BEGIN
  18600. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ae1'
  18601. INSERT INTO bsCvModify(paMainID,Location,ColValue) VALUES(@paMainID,'ae1',@CNAME)
  18602. SET @Modify=1
  18603. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  18604. VALUES(@paMainID, 31,'更新英文名,原英文名:<' + ISNULL(@NameOld, '') + '>;新英文名:<' + @Name + '>', @IP)
  18605. END
  18606. --在线联系号码
  18607. IF @OnlineContactNo IS NULL
  18608. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac2'
  18609. ELSE
  18610. IF @OnlineContactNo <> ISNULL(@OnlineContactNoOld, '')
  18611. BEGIN
  18612. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac2'
  18613. INSERT INTO bsCvModify(paMainID,Location,ColValue) VALUES(@paMainID,'ac2',@OnlineContactNo)
  18614. SET @Modify=0
  18615. END
  18616. --主页
  18617. IF @Homepage IS NULL
  18618. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac3'
  18619. ELSE
  18620. IF @Homepage <> ISNULL(@HomepageOld, '')
  18621. BEGIN
  18622. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac3'
  18623. INSERT INTO bsCvModify(paMainID,Location,ColValue) VALUES(@paMainID,'ac3',@Homepage)
  18624. SET @Modify=0
  18625. END
  18626. --手机号码
  18627. IF ISNULL(@MobileOld, '') <> @Mobile
  18628. BEGIN
  18629. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND Location = 'ac4'
  18630. --INSERT INTO bsCvModify(paMainID,Location,ColValue) VALUES(@paMainID,'ac4',@Mobile)
  18631. --SET @Modify=0
  18632. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  18633. VALUES(@paMainID, 35,'更新手机号,原手机号:<' + ISNULL(@MobileOld, '') + '>;新手机号:<' + @Mobile + '>', @IP)
  18634. END
  18635. ----修改cvMain.cvLevel
  18636. IF @TYPE=0
  18637. UPDATE cvMain SET cvLevel='11' + RIGHT(cvLevel,8) WHERE paMainID = @paMainID
  18638. ELSE
  18639. UPDATE cvMain SET cvLevelEng='11' + RIGHT(cvLevelEng,8) WHERE paMainID = @paMainID
  18640. --1小时内不重复刷新,防止刷新排名
  18641. UPDATE cvmain SET RefreshDate = GETDATE() WHERE ID=@cvMainID AND DATEADD(HOUR, 1, RefreshDate) < GETDATE() AND paMainID = @paMainID
  18642. ----12小时内只保留一次修改记录
  18643. DELETE FROM paOperationLog WHERE paMainID=@paMainID AND Operation=11 AND AddDate>GETDATE()-0.5
  18644. INSERT INTO paOperationLog (paMainID,Operation,Details,IP) VALUES(@paMainID,11,'更新基本信息成功。',@IP)
  18645. END TRY
  18646. BEGIN CATCH
  18647. GOTO ERR
  18648. END CATCH
  18649. COMMIT TRAN
  18650. RETURN 1
  18651. ERR:
  18652. BEGIN
  18653. ROLLBACK TRAN
  18654. RETURN 0
  18655. END
  18656. GO
  18657. /****** Object: StoredProcedure [dbo].[pcPaNotifyByIsViewedUpdate] Script Date: 2018/12/13 19:09:08 ******/
  18658. SET ANSI_NULLS ON
  18659. GO
  18660. SET QUOTED_IDENTIFIER ON
  18661. GO
  18662. -----------------
  18663. --个人会员中心首页,修改网站消息是否查看
  18664. -----------------
  18665. CREATE PROCEDURE [dbo].[pcPaNotifyByIsViewedUpdate]
  18666. (
  18667. @paNotifyID INT,
  18668. @paMainID INT
  18669. )
  18670. AS
  18671. BEGIN
  18672. IF EXISTS(SELECT 'x' FROM paNotify WITH(NOLOCK)
  18673. WHERE ID = @paNotifyID
  18674. AND paMainID = @paMainID
  18675. AND IsViewed = 0)
  18676. UPDATE paNotify SET IsViewed = 1
  18677. WHERE ID = @paNotifyID
  18678. AND paMainID = @paMainID
  18679. END
  18680. GO
  18681. /****** Object: StoredProcedure [dbo].[pcPaNotifyByPaMainIDSelect] Script Date: 2018/12/13 19:09:08 ******/
  18682. SET ANSI_NULLS ON
  18683. GO
  18684. SET QUOTED_IDENTIFIER ON
  18685. GO
  18686. -----------------
  18687. --网站消息列表
  18688. -----------------
  18689. CREATE PROCEDURE [dbo].[pcPaNotifyByPaMainIDSelect]
  18690. (
  18691. @paMainID INT
  18692. )
  18693. AS
  18694. BEGIN
  18695. SELECT ID, AddDate, NotifyType, Substring(Message, 0 ,20) Message, IsViewed, ENDDate
  18696. FROM PaNotify WITH(NOLOCK)
  18697. WHERE paMainID = @paMainID
  18698. ORDER BY ID DESC
  18699. END
  18700. GO
  18701. /****** Object: StoredProcedure [dbo].[pcPaNotifySelect] Script Date: 2018/12/13 19:09:08 ******/
  18702. SET ANSI_NULLS ON
  18703. GO
  18704. SET QUOTED_IDENTIFIER ON
  18705. GO
  18706. -----------------
  18707. --个人会员中心首页,显示网站消息通知
  18708. -----------------
  18709. CREATE PROCEDURE [dbo].[pcPaNotifySelect]
  18710. (
  18711. @paMainID INT
  18712. )
  18713. AS
  18714. BEGIN
  18715. SELECT ID, AddDate, NotifyType, Message
  18716. FROM PaNotify WITH(NOLOCK)
  18717. WHERE paMainID = @paMainID
  18718. AND (
  18719. (NotifyType = 1 AND IsViewed = 0) --一次性消息,看过就不再通知了
  18720. OR (NotifyType=2 AND ENDDate > GETDATE()) --即时消息,到期前(ENDdate)一直通知
  18721. )
  18722. ORDER BY ID DESC
  18723. END
  18724. GO
  18725. /****** Object: StoredProcedure [dbo].[pcpaOperationLogSelect] Script Date: 2018/12/13 19:09:08 ******/
  18726. SET ANSI_NULLS ON
  18727. GO
  18728. SET QUOTED_IDENTIFIER ON
  18729. GO
  18730. --=============================================
  18731. -- 创建: sean
  18732. -- 检查: 2010-10-6
  18733. -- 说明: 操作记录列表
  18734. --=============================================
  18735. CREATE PROCEDURE [dbo].[pcpaOperationLogSelect]
  18736. (
  18737. @paMainID INT
  18738. )
  18739. AS
  18740. BEGIN
  18741. SELECT TOP 1000 * FROM paOperationLog WITH(NOLOCK INDEX(IX_paOperationLog_paMainID))
  18742. WHERE paMainID = @paMainID
  18743. ORDER BY ID DESC
  18744. END
  18745. GO
  18746. /****** Object: StoredProcedure [dbo].[pcpaPhoto_beforeInsert] Script Date: 2018/12/13 19:09:09 ******/
  18747. SET ANSI_NULLS ON
  18748. GO
  18749. SET QUOTED_IDENTIFIER ON
  18750. GO
  18751. -- lambo
  18752. -- 2011-05-24
  18753. -- 将上传照片的信息先放在paPhoto_before中
  18754. CREATE PROCEDURE [dbo].[pcpaPhoto_beforeInsert]
  18755. @paMainID INT,
  18756. @Photo VARCHAR(50)
  18757. AS
  18758. DECLARE @MaxId AS INT
  18759. INSERT INTO paPhoto_before (paMainID,FileUrl)
  18760. VALUES(@paMainID,dbo.SafeSQL(@Photo))
  18761. SET @MaxID = @@IDENTITY
  18762. RETURN @MaxID
  18763. GO
  18764. /****** Object: StoredProcedure [dbo].[pcpaPhotoDelete] Script Date: 2018/12/13 19:09:09 ******/
  18765. SET ANSI_NULLS ON
  18766. GO
  18767. SET QUOTED_IDENTIFIER ON
  18768. GO
  18769. --=============================================
  18770. -- 创建: sean
  18771. -- 检查: 2010-10-6
  18772. -- 说明: 照片删除
  18773. --=============================================
  18774. CREATE PROCEDURE [dbo].[pcpaPhotoDelete]
  18775. (
  18776. @paMainID INT,
  18777. @IP VARCHAR(39)
  18778. )
  18779. AS
  18780. BEGIN TRAN
  18781. BEGIN TRY
  18782. DELETE FROM paPhoto WHERE paMainID=@paMainID
  18783. UPDATE paMain SET HasPhoto=NULL WHERE ID=@paMainID
  18784. INSERT INTO paOperationLog (paMainID, Operation, Details, IP)
  18785. VALUES(@paMainID, 41, '删除照片', @IP)
  18786. END TRY
  18787. BEGIN CATCH
  18788. GOTO ERR
  18789. END CATCH
  18790. COMMIT TRAN
  18791. RETURN 1
  18792. ERR:
  18793. BEGIN
  18794. ROLLBACK TRAN
  18795. RETURN 0
  18796. END
  18797. GO
  18798. /****** Object: StoredProcedure [dbo].[pcpaPhotoInsert] Script Date: 2018/12/13 19:09:09 ******/
  18799. SET ANSI_NULLS ON
  18800. GO
  18801. SET QUOTED_IDENTIFIER ON
  18802. GO
  18803. --=============================================
  18804. -- 创建: sean
  18805. -- 检查: 2010-10-6
  18806. -- 说明: 照片上传
  18807. --=============================================
  18808. CREATE PROCEDURE [dbo].[pcpaPhotoInsert]
  18809. @paMainID INT
  18810. AS
  18811. BEGIN TRAN
  18812. DECLARE @MaxId AS INT
  18813. BEGIN TRY
  18814. DELETE FROM paPhoto WHERE paMainID=@paMainID
  18815. UPDATE paMain SET HasPhoto=0 WHERE ID=@paMainID
  18816. INSERT INTO paPhoto (paMainID,Photo,PhotoProcessed)
  18817. SELECT TOP 1 paMainID , FileUrl,FileUrl FROM paPhoto_before WHERE paMainID = @paMainID ORDER BY ID DESC
  18818. DELETE FROM paPhoto_before WHERE ID = (SELECT TOP 1 ID FROM paPhoto_before WHERE paMainID = @paMainID ORDER BY ID DESC)
  18819. INSERT INTO paOperationLog (paMainID,Operation,Details,IP)
  18820. VALUES(@paMainID,40,'更新照片', '')
  18821. SET @MaxID = @@IDENTITY
  18822. END TRY
  18823. BEGIN cATCH
  18824. GOTO ERR
  18825. END CATCH
  18826. COMMIT TRAN
  18827. RETURN @MaxID
  18828. ERR:
  18829. BEGIN
  18830. ROLLBACK TRAN
  18831. RETURN 0
  18832. END
  18833. GO
  18834. /****** Object: StoredProcedure [dbo].[pcpaPhotoSelect] Script Date: 2018/12/13 19:09:09 ******/
  18835. SET ANSI_NULLS ON
  18836. GO
  18837. SET QUOTED_IDENTIFIER ON
  18838. GO
  18839. --=============================================
  18840. -- 创建: sean
  18841. -- 检查: 2010-10-6
  18842. -- 说明: 照片信息提取
  18843. --=============================================
  18844. CREATE PROCEDURE [dbo].[pcpaPhotoSelect]
  18845. @paMainID INT
  18846. AS
  18847. BEGIN
  18848. SELECT a.*,b.HasPhoto
  18849. FROM paPhoto a WITH(NOLOCK INDEX(IX_paPhoto_paMainId)),paMain b with(NOLOCK) WHERE a.paMainID = b.ID AND a.paMainID=@paMainID
  18850. END
  18851. GO
  18852. /****** Object: StoredProcedure [dbo].[pcPaPlaintByIsViewedUpdate] Script Date: 2018/12/13 19:09:09 ******/
  18853. SET ANSI_NULLS ON
  18854. GO
  18855. SET QUOTED_IDENTIFIER ON
  18856. GO
  18857. --==================================================
  18858. --检查 Alen 2017-9-15
  18859. --描述 修改投诉记录为已查看
  18860. --==================================================
  18861. CREATE PROCEDURE [dbo].[pcPaPlaintByIsViewedUpdate]
  18862. (
  18863. @paMainID INT
  18864. )
  18865. AS
  18866. BEGIN
  18867. UPDATE MainDB..paplaint
  18868. SET IsViewed = 1
  18869. WHERE paMainID = @paMainID
  18870. AND IsViewed = 0
  18871. AND ReplyType > 0
  18872. END
  18873. GO
  18874. /****** Object: StoredProcedure [dbo].[pcPaPlaintByNameInsert] Script Date: 2018/12/13 19:09:09 ******/
  18875. SET ANSI_NULLS ON
  18876. GO
  18877. SET QUOTED_IDENTIFIER ON
  18878. GO
  18879. --修改harry,增加顾问提醒2017-9-26
  18880. --修改harry 无顾问的提醒给客服
  18881. --修改 Sunshine 顾问为空号的提醒给上级
  18882. CREATE PROCEDURE [dbo].[pcPaPlaintByNameInsert]
  18883. (
  18884. @paMainID INT,
  18885. @caMainID INT,
  18886. @jobID INT,
  18887. @IP VARCHAR(50),
  18888. @Name NVARCHAR(50),
  18889. @Telephone VARCHAR(11),
  18890. @Email VARCHAR(50),
  18891. @Plaint NVARCHAR(200)
  18892. )
  18893. AS
  18894. SET NOCOUNT ON
  18895. BEGIN
  18896. INSERT INTO mainDB..paPlaint(paMainID, caMainID, jobID, IP, Name, Telephone, Email, Plaint, AddDate, ReplyType)
  18897. VALUES(@paMainID, @caMainID, @jobID, @IP, @Name, @Telephone, @Email, @Plaint, GETDATE(), 0)
  18898. IF EXISTS (SELECT 'x' FROM caMain a, cpMain b, managerUser c
  18899. WHERE a.cpMainId = b.Id
  18900. AND b.ConsultantId > 0 AND a.id =@caMainID AND c.id=b.ConsultantId AND c.status<3)
  18901. BEGIN
  18902. INSERT INTO RtxNotifyLog(Receiver, RtxTitle, RtxMessage, SendType, DelayTime, ShowType)
  18903. SELECT ConsultantId, '个人投诉企业通知','投诉内容:'+@Plaint+ ' http://sysback.51rc.com/newoa/operate/complaint/paPlaint?isReply=3&selType=2&selOption=0&txtSearch='+CONVERT(CHAR(10),@caMainID), 1, 0, 0
  18904. FROM caMain a, cpMain b WHERE a.cpMainId = b.Id AND b.ConsultantId > 0 AND a.id =@caMainID
  18905. END
  18906. ELSE IF EXISTS(SELECT 'x' FROM caMain a, cpMain b, managerUser c --20181108 Sunshine 添加 顾问为空号的提醒给上级
  18907. WHERE a.cpMainId = b.Id
  18908. AND b.ConsultantId > 0 AND a.id =@caMainID AND c.id=b.ConsultantId AND c.status >= 3)
  18909. BEGIN
  18910. INSERT INTO RtxNotifyLog(Receiver, RtxTitle, RtxMessage, SendType, DelayTime, ShowType)
  18911. SELECT (SELECT superior FROM managerUser WHERE id = b.ConsultantId), '个人投诉企业通知','投诉内容:'+@Plaint+ ' http://sysback.51rc.com/newoa/operate/complaint/paPlaint?isReply=3&selType=2&selOption=0&txtSearch='+CONVERT(CHAR(10),@caMainID), 1, 0, 0
  18912. FROM caMain a, cpMain b WHERE a.cpMainId = b.Id AND b.ConsultantId > 0 AND a.id =@caMainID
  18913. END
  18914. ELSE --20181108 Sunshine 添加 顾问为空号的提醒给上级
  18915. BEGIN
  18916. INSERT INTO RtxNotifyLog(Receiver, RtxTitle, RtxMessage, SendType, DelayTime, ShowType)
  18917. SELECT '180,182,222,223,216,155', '个人投诉企业通知','投诉内容:'+@Plaint+ ' http://sysback.51rc.com/newoa/operate/complaint/paPlaint?isReply=3&selType=2&selOption=0&txtSearch='+CONVERT(CHAR(10),@caMainID), 1, 0, 0
  18918. FROM caMain a, cpMain b WHERE a.cpMainId = b.Id AND a.id =@caMainID
  18919. END
  18920. END
  18921. SET NOCOUNT OFF
  18922. GO
  18923. /****** Object: StoredProcedure [dbo].[pcPaPlaintInsert] Script Date: 2018/12/13 19:09:10 ******/
  18924. SET ANSI_NULLS ON
  18925. GO
  18926. SET QUOTED_IDENTIFIER ON
  18927. GO
  18928. CREATE PROCEDURE [dbo].[pcPaPlaintInsert]
  18929. (
  18930. @paMainID INT,
  18931. @caMainID INT,
  18932. @Plaint VARCHAR(1000),
  18933. @JobID INT,
  18934. @ConsultantId INT OUTPUT
  18935. )
  18936. AS
  18937. BEGIN TRY
  18938. IF NOT EXISTS(SELECT 'X' FROM paPlaint
  18939. WHERE paMainID = @paMainID AND JobID = @JobID AND AddDate > GETDATE() - 30)
  18940. BEGIN
  18941. INSERT INTO paPlaint(paMainID, caMainID, PlaINT, JobID)
  18942. VALUES(@paMainID, @caMainID, dbo.SafeSQL(@PlaINT), @JobID)
  18943. SELECT @ConsultantId = ConsultantID FROM cpMain a WITH(NOLOCK), caMain b WITH(NOLOCK)
  18944. WHERE a.Id = b.cpMainId
  18945. AND b.Id = @caMainId
  18946. RETURN 1
  18947. END
  18948. ELSE
  18949. BEGIN
  18950. SELECT @ConsultantId = 0
  18951. RETURN 0
  18952. END
  18953. END TRY
  18954. BEGIN CATCH
  18955. RETURN 0
  18956. END CATCH
  18957. GO
  18958. /****** Object: StoredProcedure [dbo].[pcPaPlaintSelect] Script Date: 2018/12/13 19:09:10 ******/
  18959. SET ANSI_NULLS ON
  18960. GO
  18961. SET QUOTED_IDENTIFIER ON
  18962. GO
  18963. --=================================
  18964. --检查 sean 2010-10-9
  18965. --描述 个人查看自己的投诉记录
  18966. --修改 Alen 个人投诉二次改版 2017-9-15
  18967. --=================================
  18968. CREATE PROCEDURE [dbo].[pcPaPlaintSelect]
  18969. (
  18970. @paMainID INT,
  18971. @isIndex TINYINT
  18972. )
  18973. AS
  18974. BEGIN
  18975. IF @isIndex = 0
  18976. BEGIN
  18977. SELECT a.*,c.ID cpMainID,c.Name CompanyName,c.secondID
  18978. FROM PaPlaint a WITH(NOLOCK)
  18979. LEFT JOIN caMain b WITH(NOLOCK) ON a.caMainID = b.ID
  18980. LEFT JOIN cpMain c WITH(NOLOCK) ON b.cpMainID = c.ID
  18981. WHERE paMainID = @paMainID
  18982. ORDER BY ID DESC
  18983. END
  18984. ELSE
  18985. BEGIN
  18986. SELECT a.*,c.ID cpMainID,c.Name CompanyName,c.secondID
  18987. FROM PaPlaint a WITH(NOLOCK)
  18988. LEFT JOIN caMain b WITH(NOLOCK) ON a.caMainID = b.ID
  18989. LEFT JOIN cpMain c WITH(NOLOCK) ON b.cpMainID = c.ID
  18990. WHERE paMainID = @paMainID
  18991. AND IsViewed = 0
  18992. AND ReplyType > 0
  18993. ORDER BY ID DESC
  18994. END
  18995. END
  18996. GO
  18997. /****** Object: StoredProcedure [dbo].[PcPaRefererInsert] Script Date: 2018/12/13 19:09:11 ******/
  18998. SET ANSI_NULLS ON
  18999. GO
  19000. SET QUOTED_IDENTIFIER ON
  19001. GO
  19002. CREATE PROCEDURE [dbo].[PcPaRefererInsert]
  19003. (
  19004. @PaMainId INT,
  19005. @Referer VARCHAR(500)
  19006. )
  19007. AS
  19008. SET NOCOUNT ON
  19009. BEGIN TRY
  19010. --IF EXISTS(SELECT 'x' FROM paMain WITH(NOLOCK)
  19011. -- WHERE Id = @paMainId AND AddDate > DATEADD(MINUTE, -2, GETDATE()))
  19012. INSERT INTO paReferer(paMainId, Referer)
  19013. SELECT @paMainId, @Referer
  19014. END TRY
  19015. BEGIN CATCH
  19016. END CATCH
  19017. GO
  19018. /****** Object: StoredProcedure [dbo].[pcPaVerifyLogByLoginInsert] Script Date: 2018/12/13 19:09:11 ******/
  19019. SET ANSI_NULLS ON
  19020. GO
  19021. SET QUOTED_IDENTIFIER ON
  19022. GO
  19023. --个人手机号登录验证码插入
  19024. --peter 2018-2-28
  19025. CREATE PROCEDURE [dbo].[pcPaVerifyLogByLoginInsert]
  19026. (
  19027. @Mobile VARCHAR(11),
  19028. @IP VARCHAR(31),
  19029. @PaMainID INT
  19030. )
  19031. AS
  19032. SET NOCOUNT ON
  19033. BEGIN
  19034. IF CHARINDEX(', ', @Ip) > 0
  19035. SET @Ip = RIGHT(@ip, LEN(@ip) - CHARINDEX(', ', @ip))
  19036. DECLARE @VerifyCount SMALLINT
  19037. SELECT @VerifyCount = COUNT(1) FROM paVerifyLog WITH(NOLOCK)
  19038. WHERE IP = @IP
  19039. AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)
  19040. IF @VerifyCount > 10 --一天同一IP验证超过三次
  19041. RETURN -2
  19042. SELECT @VerifyCount = COUNT(1) FROM paVerifyLog WITH(NOLOCK)
  19043. WHERE Mobile = @Mobile
  19044. AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)
  19045. IF @VerifyCount > 5 --一天同一手机号验证超过两次
  19046. RETURN -3
  19047. SELECT @VerifyCount = COUNT(1) FROM paVerifyLog WITH(NOLOCK)
  19048. WHERE Mobile = @Mobile
  19049. AND AddDate > DATEADD(MINUTE, -5, GETDATE()) --五分钟内同一手机号超过三次
  19050. IF @VerifyCount > 3
  19051. RETURN -4
  19052. DECLARE @VerifyCode AS VARCHAR(6)
  19053. SELECT @VerifyCode = RAND() * 899999 + 100000
  19054. INSERT INTO paVerifyLog(paMainID, Email, Mobile, VerifyCode, VerifyDate, AddDate, ip)
  19055. VALUES(@PaMainID, '', @Mobile, @VerifyCode, NULL, GETDATE(), @IP)
  19056. RETURN @VerifyCode
  19057. END
  19058. GO
  19059. /****** Object: StoredProcedure [dbo].[pcPaVerifyLogByMobileIpSelect] Script Date: 2018/12/13 19:09:11 ******/
  19060. SET ANSI_NULLS ON
  19061. GO
  19062. SET QUOTED_IDENTIFIER ON
  19063. GO
  19064. --#####################################################
  19065. --创建时间:2014.11.4
  19066. --创建人:John
  19067. --说明:获取个人手机/邮件验证日志
  19068. --#####################################################
  19069. CREATE PROCEDURE [dbo].[pcPaVerifyLogByMobileIpSelect]
  19070. (
  19071. @Mobile VARCHAR(11),
  19072. @ip VARCHAR(31)
  19073. )
  19074. AS
  19075. BEGIN
  19076. SELECT TOP 1 * FROM paVerifyLog WITH(NOLOCK)
  19077. WHERE Mobile = @Mobile AND AddDate > DATEADD(HOUR,-1,GETDATE()) ORDER BY id DESC
  19078. END
  19079. GO
  19080. /****** Object: StoredProcedure [dbo].[pcPaVerifyLogInsert] Script Date: 2018/12/13 19:09:11 ******/
  19081. SET ANSI_NULLS ON
  19082. GO
  19083. SET QUOTED_IDENTIFIER ON
  19084. GO
  19085. --lambo 20140909
  19086. --手机号注册,前台发送验证码
  19087. --20180327 Carl 修改 增加个人黑名单
  19088. CREATE PROCEDURE [dbo].[pcPaVerifyLogInsert]
  19089. (
  19090. @Mobile VARCHAR(11),
  19091. @IP VARCHAR(31)
  19092. )
  19093. AS
  19094. SET NOCOUNT ON
  19095. BEGIN
  19096. IF EXISTS(SELECT 'X' FROM Person_Black WITH(NOLOCK) WHERE Mobile = @Mobile)
  19097. RETURN -5
  19098. IF EXISTS(SELECT 'x' FROM tmp_limitmobile WITH(NOLOCK) WHERE Mobile = @Mobile)
  19099. RETURN -1
  19100. IF DATEPART(HOUR, GETDATE()) > 22 OR DATEPART(HOUR, GETDATE()) < 7
  19101. RETURN -1
  19102. --IF CHARINDEX(', ', @Ip) > 0
  19103. -- RETURN -1
  19104. IF CHARINDEX(', ', @Ip) > 0
  19105. SET @Ip = RIGHT(@ip, LEN(@ip) - CHARINDEX(', ', @ip))
  19106. DECLARE @MobileVerifyDate DATETIME
  19107. SELECT @MobileVerifyDate = MobileVerifyDate FROM paMain WITH(NOLOCK INDEX(IX_paMain_Mobile))
  19108. WHERE Mobile = @Mobile
  19109. AND MobileVerifyDate IS NOT NULL
  19110. IF @MobileVerifyDate IS NOT NULL
  19111. IF DATEDIFF(DAY, @MobileVerifyDate, GETDATE()) < 60
  19112. RETURN -2
  19113. DECLARE @VerifyCount SMALLINT
  19114. SELECT @VerifyCount = COUNT(1) FROM paVerifyLog WITH(NOLOCK)
  19115. WHERE IP = @IP
  19116. AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)
  19117. IF @VerifyCount > 3 --IF @VerifyCount > 3
  19118. RETURN -1
  19119. SELECT @VerifyCount = COUNT(1) FROM paVerifyLog WITH(NOLOCK)
  19120. WHERE Mobile = @Mobile
  19121. AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)
  19122. IF @VerifyCount > 2 --IF @VerifyCount > 2
  19123. RETURN 0
  19124. SELECT @VerifyCount = COUNT(1) FROM paVerifyLog WITH(NOLOCK)
  19125. WHERE Mobile = @Mobile
  19126. AND AddDate > DATEADD(MINUTE, -5, GETDATE())
  19127. IF @VerifyCount > 3 --IF @VerifyCount > 3
  19128. RETURN 0
  19129. DECLARE @VerifyCode AS VARCHAR(6)
  19130. SELECT @VerifyCode = RAND() * 899999 + 100000
  19131. INSERT INTO paVerifyLog(paMainID, Email, Mobile, VerifyCode, VerifyDate, AddDate, ip)
  19132. VALUES(0, '', @Mobile, @VerifyCode, NULL, GETDATE(), @IP)
  19133. RETURN @VerifyCode
  19134. END
  19135. GO
  19136. /****** Object: StoredProcedure [dbo].[pcPaVerifyLogPaMainIDSelect] Script Date: 2018/12/13 19:09:11 ******/
  19137. SET ANSI_NULLS ON
  19138. GO
  19139. SET QUOTED_IDENTIFIER ON
  19140. GO
  19141. --#####################################################
  19142. --创建时间:2014.11.4
  19143. --创建人:John
  19144. --说明:获取1小时内是否发送过认证请求
  19145. --#####################################################
  19146. CREATE PROCEDURE [dbo].[pcPaVerifyLogPaMainIDSelect]
  19147. (
  19148. @Mobile VARCHAR(11),
  19149. @paMainID INT,
  19150. @Email VARCHAR(50)
  19151. )
  19152. AS
  19153. BEGIN
  19154. IF @Mobile <> ''
  19155. BEGIN
  19156. SELECT paMainID FROM paVerifyLog WITH(NOLOCK)
  19157. WHERE paMainID = @paMainID AND Mobile = @Mobile AND AddDate > DATEADD(HOUR,-1,GETDATE()) AND VerifyDate IS NULL
  19158. END
  19159. ELSE
  19160. BEGIN
  19161. SELECT paMainID FROM paVerifyLog WITH(NOLOCK)
  19162. WHERE paMainID = @paMainID AND Email = @Email AND AddDate> DATEADD(HOUR,-1,GETDATE())
  19163. END
  19164. END
  19165. GO
  19166. /****** Object: StoredProcedure [dbo].[pcPaVerifyLogUpdate] Script Date: 2018/12/13 19:09:12 ******/
  19167. SET ANSI_NULLS ON
  19168. GO
  19169. SET QUOTED_IDENTIFIER ON
  19170. GO
  19171. --#####################################################
  19172. --创建时间:2014.11.4
  19173. --创建人:John
  19174. --说明:更新个人手机/邮件验证日志
  19175. --#####################################################
  19176. CREATE PROCEDURE [dbo].[pcPaVerifyLogUpdate]
  19177. (
  19178. @paMainID INT,
  19179. @Mobile VARCHAR(11),
  19180. @ip VARCHAR(31)
  19181. )
  19182. AS
  19183. BEGIN
  19184. UPDATE paVerifyLog SET paMainID = @paMainID
  19185. WHERE id = (
  19186. SELECT TOP 1 id FROM paVerifyLog WITH(NOLOCK)
  19187. WHERE Mobile = @Mobile AND AddDate > DATEADD(HOUR,-1,GETDATE()) AND ip = @ip
  19188. ORDER BY id DESC
  19189. )
  19190. END
  19191. GO
  19192. /****** Object: StoredProcedure [dbo].[pcPaYourFoodSelect] Script Date: 2018/12/13 19:09:12 ******/
  19193. SET ANSI_NULLS ON
  19194. GO
  19195. SET QUOTED_IDENTIFIER ON
  19196. GO
  19197. CREATE PROCEDURE [dbo].[pcPaYourFoodSelect]
  19198. (
  19199. @paMainId INT
  19200. )
  19201. AS
  19202. SET NOCOUNT ON
  19203. BEGIN
  19204. SELECT a.Id, a.paMainID, a.cvMainId, a.JobId,b.camainid, b.Name JobName,
  19205. c.Name cpName, d.Description Region,
  19206. (SELECT Description FROM dcSalary WHERE Id = dcSalaryId) Salary,
  19207. dbo.GetCvMatch(a.cvMainId, a.JobId) MatvhRate ,
  19208. (
  19209. SELECT COUNT(1) FROM ExJobApply WITH(NOLOCK)
  19210. WHERE cvMainId IN(
  19211. SELECT Id FROM cvMain WITH(NOLOCK)
  19212. WHERE paMainId = @paMainId)
  19213. AND JobId = a.JobId
  19214. ) HasApply,
  19215. a.AddDate, b.RefreshDate, b.SecondID EnJobID , c.SecondID EnCpMainID ,
  19216. b.Welfare1,b.Welfare2,b.Welfare3,b.Welfare4,b.Welfare5,b.Welfare6,b.Welfare7,b.Welfare8,
  19217. b.Welfare9,b.Welfare10,b.Welfare11,b.Welfare12,b.Welfare13,b.Welfare14,b.Welfare15,b.Welfare16,
  19218. b.Welfare17,b.Welfare18,b.Welfare19,ISNULL((SELECT IsOnline FROM caOnline WHERE caMainId =b.caMainID), 0) AS IsOnline,
  19219. c.HasLicence, c.ReplyRate
  19220. FROM paYourFood a WITH(NOLOCK),
  19221. Job b WITH(NOLOCK),
  19222. cpMain c WITH(NOLOCK),
  19223. dcRegion d WITH(NOLOCK)
  19224. WHERE a.paMainId = @paMainId
  19225. AND a.JobId = b.Id
  19226. AND b.cpMainId = c.Id
  19227. AND b.dcRegionId = d.ID
  19228. ORDER BY a.AddDate DESC
  19229. END
  19230. GO
  19231. /****** Object: StoredProcedure [dbo].[pcPerson_BlackEmailExist] Script Date: 2018/12/13 19:09:12 ******/
  19232. SET ANSI_NULLS ON
  19233. GO
  19234. SET QUOTED_IDENTIFIER ON
  19235. GO
  19236. CREATE PROCEDURE [dbo].[pcPerson_BlackEmailExist]
  19237. (
  19238. @Email VARCHAR(50)
  19239. )
  19240. AS
  19241. BEGIN
  19242. IF EXISTS(SELECT 'X' FROM Person_Black WITH(NOLOCK) WHERE Email=@Email)
  19243. RETURN 1
  19244. ELSE
  19245. RETURN 0
  19246. END
  19247. GO
  19248. /****** Object: StoredProcedure [dbo].[pcRecruitmentCpMainByRmIDSelect] Script Date: 2018/12/13 19:09:12 ******/
  19249. SET ANSI_NULLS ON
  19250. GO
  19251. SET QUOTED_IDENTIFIER ON
  19252. GO
  19253. --#####################################################
  19254. --创建时间:2014.11.4
  19255. --创建人:John
  19256. --说明:得到谁在关注我列表
  19257. --#####################################################
  19258. CREATE PROCEDURE [dbo].[pcRecruitmentCpMainByRmIDSelect]
  19259. (
  19260. @RecruitmentID INT
  19261. )
  19262. AS
  19263. BEGIN
  19264. SELECT d.RecruitmentName,a.AddDate,a.cpMainID,b.Name AS caName,b.Email,b.Mobile,b.Telephone,b.Gender,b.IsPhoneHide,b.IsNameHide,
  19265. b.IsMobileHide,c.Name as cpName,c.Address,c.HasLicence,c.SecondId,c.IsAgent,c.Membertype
  19266. FROM RecruitmentCpMain a WITH(NOLOCK) INNER JOIN caMain b WITH(NOLOCK) ON a.cpMainID = b.cpMainID
  19267. INNER JOIN cpMain c WITH(NOLOCK) ON c.ID = b.cpMainID JOIN Recruitment d on a.RecruitmentID = d.id
  19268. WHERE a.RecruitmentID = @RecruitmentID
  19269. END
  19270. GO
  19271. /****** Object: StoredProcedure [dbo].[pcRecruitmentListByPhone] Script Date: 2018/12/13 19:09:12 ******/
  19272. SET ANSI_NULLS ON
  19273. GO
  19274. SET QUOTED_IDENTIFIER ON
  19275. GO
  19276. CREATE PROCEDURE [dbo].[pcRecruitmentListByPhone]
  19277. (
  19278. @dcProvinceID AS SMALLINT,
  19279. @PageNum AS INT,
  19280. @PageSize AS INT
  19281. )
  19282. AS
  19283. BEGIN
  19284. DECLARE @COUNT INT
  19285. SELECT @COUNT=COUNT(*)
  19286. FROM Recruitment a,dcRegion b,RecruitmentPlace c,RecruitmentDept d
  19287. WHERE d.ID=a.RecruitmentDeptID AND d.ID<>1767 AND b.ID=c.dcRegionID AND a.RecruitmentPlaceId=c.id
  19288. AND LEFT(c.dcRegionID,2)=@dcProvinceID AND EndDate>GetDate() AND a.IsPause=0 AND Len(ManagerUserID)>0
  19289. IF @COUNT > 200
  19290. SET @COUNT = 200
  19291. SELECT *,@COUNT AS cnt FROM(
  19292. SELECT TOP 200 ROW_NUMBER() OVER(ORDER BY OrderBy,a.EndDate DESC) AS Rows,a.ID,a.RecruitmentName,a.EndDate,a.BeginDate,c.PlaceName,c.Address,b.Description City
  19293. FROM Recruitment a,dcRegion b,RecruitmentPlace c,RecruitmentDept d
  19294. WHERE d.ID=a.RecruitmentDeptID AND d.ID<>1767 AND b.ID=c.dcRegionID AND a.RecruitmentPlaceId=c.id
  19295. AND LEFT(c.dcRegionID,2)=@dcProvinceID AND EndDate>GetDate() AND a.IsPause=0 AND Len(ManagerUserID)>0
  19296. ) AS a
  19297. WHERE a.Rows BETWEEN (@PageNum-1)*@PageSize+1 AND @PageNum*@PageSize ORDER BY Rows
  19298. END
  19299. GO
  19300. /****** Object: StoredProcedure [dbo].[pcResumeInformSelect] Script Date: 2018/12/13 19:09:13 ******/
  19301. SET ANSI_NULLS ON
  19302. GO
  19303. SET QUOTED_IDENTIFIER ON
  19304. GO
  19305. -----------------
  19306. --个人会员中心首页,网站分类通知
  19307. -----------------
  19308. CREATE PROCEDURE [dbo].[pcResumeInformSelect]
  19309. (
  19310. @ProvinceID INT
  19311. )
  19312. AS
  19313. BEGIN
  19314. SELECT TOP 1 ID, Title,Content,link,Type
  19315. FROM ResumeInform WITH(NOLOCK)
  19316. WHERE Status=1
  19317. AND Province like '%' + LTRIM(str(@ProvinceID)) + '%'
  19318. AND EndDate > GETDATE()
  19319. ORDER BY ID DESC
  19320. END
  19321. GO
  19322. /****** Object: StoredProcedure [dbo].[pcResumeXinxiPasswordUpdate] Script Date: 2018/12/13 19:09:13 ******/
  19323. SET ANSI_NULLS ON
  19324. GO
  19325. SET QUOTED_IDENTIFIER ON
  19326. GO
  19327. --#####################################################
  19328. --创建时间:2014.11.4
  19329. --创建人:John
  19330. --说明:重置resume_xinxi里的密碼
  19331. --#####################################################
  19332. CREATE PROCEDURE [dbo].[pcResumeXinxiPasswordUpdate]
  19333. (
  19334. @username VARCHAR(50),
  19335. @password VARCHAR(50),
  19336. @email VARCHAR(50)
  19337. )
  19338. AS
  19339. BEGIN
  19340. UPDATE resume_xinxi SET password = @password WHERE username = @username AND email = @email
  19341. END
  19342. GO
  19343. /****** Object: StoredProcedure [dbo].[pcRmInvitationCodeByPaMainIDSelect] Script Date: 2018/12/13 19:09:13 ******/
  19344. SET ANSI_NULLS ON
  19345. GO
  19346. SET QUOTED_IDENTIFIER ON
  19347. GO
  19348. --#####################################################
  19349. --创建时间:2014.10.31
  19350. --创建人:Nick
  19351. --说明:获取RmInvitationCode
  19352. --#####################################################
  19353. CREATE PROCEDURE [dbo].[pcRmInvitationCodeByPaMainIDSelect]
  19354. (
  19355. @PamainID INT
  19356. )
  19357. AS
  19358. BEGIN TRY
  19359. SELECT AddDate
  19360. FROM marketdb..RmInvitationCode WITH(NOLOCK)
  19361. WHERE pamainid=@PamainID
  19362. AND valid = 1
  19363. AND rmprojectid = 1
  19364. AND adddate > GETDATE()-90
  19365. END TRY
  19366. BEGIN CATCH
  19367. RETURN 0
  19368. END CATCH
  19369. GO
  19370. /****** Object: StoredProcedure [dbo].[pcViInterviewRecordReplyViewDateUpdate] Script Date: 2018/12/13 19:09:13 ******/
  19371. SET ANSI_NULLS ON
  19372. GO
  19373. SET QUOTED_IDENTIFIER ON
  19374. GO
  19375. --#####################################################
  19376. --创建时间:2014.10.30
  19377. --创建人:John
  19378. --说明:修改未查看面试记录的回复时间-个人
  19379. --#####################################################
  19380. CREATE PROCEDURE [dbo].[pcViInterviewRecordReplyViewDateUpdate]
  19381. (
  19382. @paMainID INT
  19383. )
  19384. AS
  19385. BEGIN
  19386. UPDATE a SET ReplyViewDate = GETDATE()
  19387. FROM viinterviewrecord a,viroom b,job c ,cpMain d,caMain e
  19388. WHERE c.camainid = e.id
  19389. AND a.viroomid = b.id
  19390. AND a.jobid = c.id
  19391. AND c.cpMainid = d.id
  19392. AND Applytype = 0
  19393. AND b.enddate IS NULL
  19394. AND a.ReplyDate IS NOT NULL
  19395. AND a.ReplyViewDate IS NULL
  19396. AND cvMainID IN ( SELECT id FROM cvMain WHERE pamainid = @paMainID)
  19397. END
  19398. GO
  19399. /****** Object: StoredProcedure [dbo].[pcViInterviewRecordViewDateUpdate] Script Date: 2018/12/13 19:09:14 ******/
  19400. SET ANSI_NULLS ON
  19401. GO
  19402. SET QUOTED_IDENTIFIER ON
  19403. GO
  19404. --#####################################################
  19405. --创建时间:2014.10.30
  19406. --创建人:John
  19407. --说明:修改未查看面试记录的查看时间-个人
  19408. --#####################################################
  19409. CREATE PROCEDURE [dbo].[pcViInterviewRecordViewDateUpdate]
  19410. (
  19411. @paMainID INT
  19412. )
  19413. AS
  19414. BEGIN
  19415. UPDATE a SET viewdate = GETDATE()
  19416. FROM viinterviewrecord a,viroom b,job c ,cpMain d,caMain e
  19417. WHERE c.camainid = e.id
  19418. AND a.viroomid = b.id
  19419. AND a.jobid = c.id
  19420. AND c.cpMainid = d.id
  19421. AND Applytype = 1
  19422. AND b.enddate IS NULL
  19423. AND a.viewdate IS NULL
  19424. AND cvMainID IN ( SELECT id FROM cvMain WHERE pamainid = @paMainID)
  19425. END
  19426. GO
  19427. /****** Object: StoredProcedure [dbo].[pcViInterviewStatusSelect] Script Date: 2018/12/13 19:09:14 ******/
  19428. SET ANSI_NULLS ON
  19429. GO
  19430. SET QUOTED_IDENTIFIER ON
  19431. GO
  19432. --#####################################################
  19433. --创建时间:2014.10.31
  19434. --创建人:John
  19435. --说明:个人面试状态 2正在排队或正在面试 3已经申请过 4已经申请过职位
  19436. --#####################################################
  19437. CREATE PROCEDURE [dbo].[pcViInterviewStatusSelect]
  19438. (
  19439. @cvMainID INT,
  19440. @jobID INT,
  19441. @viRoomID INT
  19442. )
  19443. AS
  19444. BEGIN
  19445. IF EXISTS (
  19446. SELECT TOP 1 'x'
  19447. FROM ViInterviewRecord WITH(NOLOCK)
  19448. WHERE ((WaitBeginDate IS NOT NULL AND WaitEndDate IS NULL)
  19449. OR (BeginDate IS NOT NULL AND EndDate IS NULL))
  19450. AND cvMainid = @cvMainID
  19451. )
  19452. BEGIN
  19453. RETURN 2
  19454. END
  19455. ELSE IF EXISTS (
  19456. SELECT TOP 1 'x'
  19457. FROM ViInterviewRecord WITH(NOLOCK)
  19458. WHERE cvMainid = @cvMainID AND viRoomID = @viRoomID
  19459. )
  19460. BEGIN
  19461. RETURN 3
  19462. END
  19463. ELSE IF EXISTS (
  19464. SELECT TOP 1 'x'
  19465. FROM exjobapply WITH(NOLOCK)
  19466. WHERE cvMainID = @cvMainID AND AddDate > GETDATE()-30 AND jobID = @jobID
  19467. )
  19468. BEGIN
  19469. RETURN 4
  19470. END
  19471. ELSE
  19472. BEGIN
  19473. RETURN 0
  19474. END
  19475. END
  19476. GO
  19477. /****** Object: StoredProcedure [dbo].[pcViPlanInviteLogExpiredSelect] Script Date: 2018/12/13 19:09:14 ******/
  19478. SET ANSI_NULLS ON
  19479. GO
  19480. SET QUOTED_IDENTIFIER ON
  19481. GO
  19482. --#####################################################
  19483. --创建时间:2014.10.30
  19484. --创建人:John
  19485. --说明:获取已过期的预约邀请记录
  19486. --#####################################################
  19487. CREATE PROCEDURE [dbo].[pcViPlanInviteLogExpiredSelect]
  19488. (
  19489. @paMainID INT,
  19490. @cvMainID INT,
  19491. @addType INT,
  19492. @companyName VARCHAR(100)
  19493. )
  19494. AS
  19495. BEGIN
  19496. DECLARE @SQL VARCHAR(2000)
  19497. SET @SQL = ' SELECT TOP 500 e.interviewdate,a.adddate,a.addtype,ISNULL(b.secondid,b.id) jobid,b.name jobName,ISNULL(c.secondid,c.ID) cpMainID,c.Name CompanyName,d.name cvName '
  19498. SET @SQL = @SQL +' FROM viplaninvitelog a WITH(NOLOCK),job b ,cpmain c WITH(NOLOCK),cvmain d WITH(NOLOCK),viplan e WITH(NOLOCK) '
  19499. SET @SQL = @SQL +' WHERE a.jobid = b.id AND b.cpmainid = c.id AND a.cvmainid = d.id AND a.viplanid = e.id AND e.interviewdate <= GETDATE() AND d.pamainid = ' + CONVERT(VARCHAR(20),@paMainID)
  19500. IF(@cvMainID > 0)
  19501. BEGIN
  19502. SET @SQL = @SQL + ' AND a.cvMainID = ' + CONVERT(VARCHAR(20),@cvMainID)
  19503. END
  19504. IF(@addType <= 1)
  19505. BEGIN
  19506. SET @SQL = @SQL + ' AND a.AddType= ' + CONVERT(VARCHAR(20),@addType)
  19507. END
  19508. SET @SQL = @SQL +' AND c.Name LIKE ''' + @companyName + ''' ORDER BY interviewdate DESC'
  19509. EXEC(@SQL)
  19510. END
  19511. GO
  19512. /****** Object: StoredProcedure [dbo].[pcViPlanInviteLogSelect] Script Date: 2018/12/13 19:09:14 ******/
  19513. SET ANSI_NULLS ON
  19514. GO
  19515. SET QUOTED_IDENTIFIER ON
  19516. GO
  19517. --#####################################################
  19518. --创建时间:2014.10.30
  19519. --创建人:John
  19520. --说明:获取未过期预约邀请记录
  19521. --#####################################################
  19522. CREATE PROCEDURE [dbo].[pcViPlanInviteLogSelect]
  19523. (
  19524. @paMainID INT,
  19525. @cvMainID INT,
  19526. @addType INT,
  19527. @companyName VARCHAR(100)
  19528. )
  19529. AS
  19530. BEGIN
  19531. DECLARE @SQL VARCHAR(2000)
  19532. SET @SQL = ' SELECT TOP 500 e.interviewdate,a.adddate,a.addtype,ISNULL(b.secondid,b.ID) jobid,b.name jobName,ISNULL(c.secondid,c.ID) cpMainID,c.Name CompanyName,d.name cvName '
  19533. SET @SQL = @SQL +' FROM viplaninvitelog a WITH(NOLOCK),job b ,cpmain c WITH(NOLOCK),cvmain d WITH(NOLOCK),viplan e WITH(NOLOCK) '
  19534. SET @SQL = @SQL +' WHERE a.jobid = b.id AND b.cpmainid = c.id AND a.cvmainid = d.id AND a.viplanid = e.id AND e.interviewdate > GETDATE() AND d.pamainid = ' + CONVERT(VARCHAR(20),@paMainID)
  19535. IF(@cvMainID > 0)
  19536. BEGIN
  19537. SET @SQL = @SQL + ' AND a.cvMainID = ' + CONVERT(VARCHAR(20),@cvMainID)
  19538. END
  19539. IF(@addType <= 1)
  19540. BEGIN
  19541. SET @SQL = @SQL + ' AND a.AddType= ' + CONVERT(VARCHAR(20),@addType)
  19542. END
  19543. SET @SQL = @SQL +' AND c.Name LIKE ''' + @companyName + ''' ORDER BY interviewdate '
  19544. EXEC(@SQL)
  19545. END
  19546. GO
  19547. /****** Object: StoredProcedure [dbo].[pcViPlanInviteLogViewDateUpdate] Script Date: 2018/12/13 19:09:14 ******/
  19548. SET ANSI_NULLS ON
  19549. GO
  19550. SET QUOTED_IDENTIFIER ON
  19551. GO
  19552. --#####################################################
  19553. --创建时间:2014.10.30
  19554. --创建人:John
  19555. --说明:修改未查看面试计划邀请记录的查看时间-个人
  19556. --#####################################################
  19557. CREATE PROCEDURE [dbo].[pcViPlanInviteLogViewDateUpdate]
  19558. (
  19559. @paMainID INT
  19560. )
  19561. AS
  19562. BEGIN
  19563. UPDATE a SET viewdate = GETDATE()
  19564. FROM viplaninvitelog a,viplan b
  19565. WHERE a.viplanid = b.id
  19566. AND addtype = 1
  19567. AND viewdate IS NULL
  19568. AND cvMainID IN (SELECT id FROM cvMain WHERE pamainid = @paMainID)
  19569. END
  19570. GO
  19571. /****** Object: StoredProcedure [dbo].[pcViRoomByJobIDCpMainIDSelect] Script Date: 2018/12/13 19:09:15 ******/
  19572. SET ANSI_NULLS ON
  19573. GO
  19574. SET QUOTED_IDENTIFIER ON
  19575. GO
  19576. --#####################################################
  19577. --创建时间:2014.10.30
  19578. --创建人:John
  19579. --说明:获取企业当前的面试室
  19580. --#####################################################
  19581. CREATE PROCEDURE [dbo].[pcViRoomByJobIDCpMainIDSelect]
  19582. (
  19583. @jobID INT,
  19584. @cpMainID INT
  19585. )
  19586. AS
  19587. BEGIN
  19588. DECLARE @SQL VARCHAR(1000)
  19589. IF(@jobID > 0)
  19590. BEGIN
  19591. SET @SQL = ' SELECT TOP 1 * FROM viroom WHERE camainid = ( SELECT camainid FROM job WHERE id= ' + CONVERT(VARCHAR(20),@jobID) + ' ) AND enddate IS NULL AND LastRefreshTime > GETDATE()-0.1 ORDER BY id DESC '
  19592. END
  19593. ELSE
  19594. BEGIN
  19595. SET @SQL = ' SELECT TOP 1 * FROM viroom WHERE camainid = ( SELECT TOP 1 id FROM camain WHERE cpMainid = ' + CONVERT(VARCHAR(20),@cpMainID) + ' ) AND enddate IS NULL AND LastRefreshTime > GETDATE()-0.1 ORDER BY id DESC '
  19596. END
  19597. EXEC(@SQL)
  19598. END
  19599. GO
  19600. /****** Object: StoredProcedure [dbo].[pcViWaitingHallByPaMainEnterInsert] Script Date: 2018/12/13 19:09:15 ******/
  19601. SET ANSI_NULLS ON
  19602. GO
  19603. SET QUOTED_IDENTIFIER ON
  19604. GO
  19605. ----Peter 2014-04-15 个人进入视频面试等待大厅
  19606. ----Lambo 2014-05-26 修改表结构
  19607. CREATE PROCEDURE [dbo].[pcViWaitingHallByPaMainEnterInsert]
  19608. (
  19609. @ViRoomID INT,
  19610. @cvMainID INT
  19611. )
  19612. AS
  19613. BEGIN TRY
  19614. DECLARE @ViWaitingHallID INT
  19615. SELECT @ViWaitingHallID = ID FROM ViWaitingHall WHERE cvMainID = @cvMainID AND viRoomID = @ViRoomID
  19616. IF @ViWaitingHallID IS NOT NULL
  19617. UPDATE ViWaitingHall SET BeginDate = GETDATE(),
  19618. LastRefreshTime = GETDATE(),
  19619. EndDate = NULL,
  19620. Status = 1
  19621. WHERE ID = @ViWaitingHallID
  19622. ELSE
  19623. INSERT INTO ViWaitingHall(viRoomID,cvMainID,LastRefreshTime,BeginDate,Status)
  19624. VALUES(@viRoomID,@cvMainID,GETDATE(),GETDATE(),1)
  19625. DECLARE @BeginDate DATETIME
  19626. ---下面的是新的 系统上线后 将上面的删除
  19627. SELECT top 1 @ViWaitingHallID = ID,@BeginDate=WaitBeginDate FROM viinterviewrecord WHERE cvMainID = @cvMainID AND viRoomID = @ViRoomID ORDER BY ID DESC
  19628. IF @BeginDate IS NOT NULL
  19629. UPDATE viinterviewrecord SET
  19630. WaitLastRefreshTime = GETDATE(),
  19631. Status = 1
  19632. WHERE ID = @ViWaitingHallID
  19633. ELSE
  19634. UPDATE viinterviewrecord SET WaitBeginDate= GETDATE(),
  19635. WaitLastRefreshTime = GETDATE(),
  19636. Status = 1
  19637. WHERE ID = @ViWaitingHallID
  19638. END TRY
  19639. BEGIN CATCH
  19640. END CATCH
  19641. GO
  19642. /****** Object: StoredProcedure [dbo].[pcViWaitingHallByPaMainRefreshUpDate] Script Date: 2018/12/13 19:09:15 ******/
  19643. SET ANSI_NULLS ON
  19644. GO
  19645. SET QUOTED_IDENTIFIER ON
  19646. GO
  19647. ----Peter 2014-04-15 个人刷新视频面试等待大厅
  19648. CREATE PROCEDURE [dbo].[pcViWaitingHallByPaMainRefreshUpDate]
  19649. (
  19650. @ViRoomID INT,
  19651. @cvMainID INT
  19652. )
  19653. AS
  19654. BEGIN TRY
  19655. CREATE TABLE #T(
  19656. WaitingNum INT,
  19657. BeforeNum INT,
  19658. WaitingStatus INT,--1.等待,2.自己退出,3.拒绝邀请,4.邀请成功,5.被邀请无响应,6.被踢出
  19659. ViRoomStatus INT,--1.正常面试中,2.面试官离线
  19660. )
  19661. INSERT INTO #T VALUES(0,0,0,0)
  19662. UPDATE ViWaitingHall SET LastRefreshTime = GETDATE()
  19663. WHERE viRoomID = @viRoomID AND cvMainID = @cvMainID
  19664. DECLARE @BeginDateTemp DateTime
  19665. DECLARE @WaitingStatus INT
  19666. SELECT @BeginDateTemp = BeginDate,@WaitingStatus = Status FROM viWaitingHall WHERE viRoomID = @viRoomID AND cvMainID = @cvMainID
  19667. DECLARE @ViRoomStatus INT
  19668. SELECT @ViRoomStatus = CASE EndDate WHEN NULL THEN 1 ELSE 2 END FROM ViRoom WHERE ID = @viRoomID
  19669. UPDATE #T SET
  19670. WaitingNum =
  19671. (SELECT COUNT(1) FROM viWaitingHall
  19672. WHERE viRoomID = @viRoomID AND Status = 1),
  19673. BeforeNum =
  19674. (SELECT COUNT(1) FROM viWaitingHall
  19675. WHERE viRoomID = @viRoomID AND Status = 1 AND BeginDate < @BeginDateTemp),
  19676. WaitingStatus = @WaitingStatus,
  19677. ViRoomStatus = @ViRoomStatus
  19678. SELECT TOP 1 * FROM #T
  19679. DROP TABLE #T
  19680. END TRY
  19681. BEGIN CATCH
  19682. END CATCH
  19683. GO
  19684. /****** Object: StoredProcedure [dbo].[pcViWaitingHallByPaMainRefreshUpDateNew] Script Date: 2018/12/13 19:09:15 ******/
  19685. SET ANSI_NULLS ON
  19686. GO
  19687. SET QUOTED_IDENTIFIER ON
  19688. GO
  19689. ----Peter 2014-04-15 个人刷新视频面试等待大厅
  19690. --Lambo 2014-5-26 修改表结构
  19691. CREATE PROCEDURE [dbo].[pcViWaitingHallByPaMainRefreshUpDateNew]
  19692. (
  19693. @ViRoomID INT,
  19694. @cvMainID INT
  19695. )
  19696. AS
  19697. BEGIN TRY
  19698. CREATE TABLE #T(
  19699. WaitingNum INT,
  19700. BeforeNum INT,
  19701. WaitingStatus INT,--1.等待,2.自己退出,3.拒绝邀请,4.邀请成功,5.被邀请无响应,6.被踢出
  19702. ViRoomStatus INT,--1.正常面试中,2.面试官离线,
  19703. InterViewStatus int,
  19704. paNames NVARCHAR(100)
  19705. )
  19706. INSERT INTO #T VALUES(0,0,0,0,0,'')
  19707. UPDATE viinterviewrecord SET WaitLastRefreshTime = GETDATE()
  19708. WHERE viRoomID = @viRoomID AND cvMainID = @cvMainID
  19709. DECLARE @BeginDateTemp DateTime
  19710. DECLARE @WaitingStatus INT
  19711. SELECT TOP 1 @BeginDateTemp = WaitBeginDate,@WaitingStatus = Status FROM viinterviewrecord WHERE viRoomID = @viRoomID AND cvMainID = @cvMainID order by id DESC
  19712. DECLARE @ViRoomStatus INT
  19713. SELECT @ViRoomStatus = CASE EndDate WHEN NULL THEN 1 ELSE 2 END FROM ViRoom WHERE ID = @viRoomID
  19714. UPDATE #T SET
  19715. WaitingNum =
  19716. (SELECT COUNT(1) FROM viinterviewrecord
  19717. WHERE viRoomID = @viRoomID AND Status = 1 and WaitEndDate is null ),
  19718. BeforeNum =
  19719. (SELECT COUNT(1) FROM viinterviewrecord
  19720. WHERE viRoomID = @viRoomID AND Status = 1 AND WaitEndDate is null and WaitBeginDate< @BeginDateTemp),
  19721. paNames = STUFF((SELECT top 6 ','+c.name FROM viinterviewrecord a,cvMain b,paMain c where a.cvmainid=b.id and b.paMainid=c.id and viRoomID = @viRoomID AND Status = 1 and WaitEndDate is null order by waitbegindate FOR XML PATH('')),1,1,''),
  19722. InterViewStatus = (SELECT COUNT(1) FROM viinterviewrecord
  19723. WHERE viRoomID = @viRoomID AND begindate is not null and enddate is null),
  19724. WaitingStatus = @WaitingStatus,
  19725. ViRoomStatus = @ViRoomStatus
  19726. SELECT TOP 1 * FROM #T
  19727. DROP TABLE #T
  19728. END TRY
  19729. BEGIN CATCH
  19730. END CATCH
  19731. GO
  19732. /****** Object: StoredProcedure [dbo].[pcViWaitingHallRejectInviteUpdate] Script Date: 2018/12/13 19:09:15 ******/
  19733. SET ANSI_NULLS ON
  19734. GO
  19735. SET QUOTED_IDENTIFIER ON
  19736. GO
  19737. --#####################################################
  19738. --创建时间:2014.10.30
  19739. --创建人:John
  19740. --说明:求职者拒绝邀请
  19741. --#####################################################
  19742. CREATE PROCEDURE [dbo].[pcViWaitingHallRejectInviteUpdate]
  19743. (
  19744. @cvMainID INT
  19745. )
  19746. AS
  19747. BEGIN
  19748. UPDATE ViWaitingHall SET Status = 3, [enddate] = GETDATE()
  19749. WHERE ID =
  19750. (
  19751. SELECT TOP 1 ID
  19752. FROM ViWaitingHall
  19753. WHERE cvMainID = @cvMainID
  19754. ORDER BY id DESC
  19755. )
  19756. END
  19757. GO
  19758. /****** Object: StoredProcedure [dbo].[pcWXQrImageByIdSelect] Script Date: 2018/12/13 19:09:16 ******/
  19759. SET ANSI_NULLS ON
  19760. GO
  19761. SET QUOTED_IDENTIFIER ON
  19762. GO
  19763. --lambo 20140904
  19764. --根据ID获取一条微信二维码记录
  19765. CREATE PROCEDURE [dbo].[pcWXQrImageByIdSelect]
  19766. (
  19767. @ID INT
  19768. )
  19769. AS
  19770. --INSERT INTO ProcLog SELECT 'pcWXQrImageByIdSelect', '', GETDATE()
  19771. SET NOCOUNT ON
  19772. BEGIN
  19773. SELECT * FROM WXQrImage WITH(NOLOCK) WHERE ID=@ID
  19774. END
  19775. GO
  19776. /****** Object: StoredProcedure [dbo].[pcWXQrImageInsert] Script Date: 2018/12/13 19:09:16 ******/
  19777. SET ANSI_NULLS ON
  19778. GO
  19779. SET QUOTED_IDENTIFIER ON
  19780. GO
  19781. --lambo 20140904
  19782. --lucifer 20160415 小于0的为企业用户绑定
  19783. --插入一条微信二维码生成记录
  19784. CREATE PROCEDURE [dbo].[pcWXQrImageInsert]
  19785. (
  19786. @PageType INT,
  19787. @ip varchar(31)
  19788. )
  19789. AS
  19790. BEGIN
  19791. DECLARE @paMainID INT
  19792. IF @PageType > 100
  19793. BEGIN
  19794. SET @paMainID = @PageType
  19795. SET @PageType = 3
  19796. END
  19797. ELSE IF @PageType < 0
  19798. BEGIN
  19799. SET @paMainID = @PageType
  19800. SET @PageType = 52
  19801. END
  19802. INSERT INTO WXQrImage (Ticket, PageType, ip, paMainid)
  19803. SELECT '', @PageType, @ip, @paMainID
  19804. RETURN @@IDENTITY
  19805. END
  19806. GO
  19807. /****** Object: StoredProcedure [dbo].[pcWXQrImageInsertNew] Script Date: 2018/12/13 19:09:16 ******/
  19808. SET ANSI_NULLS ON
  19809. GO
  19810. SET QUOTED_IDENTIFIER ON
  19811. GO
  19812. --Lucifer 20160901
  19813. --插入一条微信二维码生成记录
  19814. CREATE PROCEDURE [dbo].[pcWXQrImageInsertNew]
  19815. (
  19816. @PageType INT,
  19817. @Ip VARCHAR(31),
  19818. @TypeID INT
  19819. )
  19820. AS
  19821. BEGIN
  19822. INSERT INTO WXQrImage (Ticket, PageType, Ip, paMainID)
  19823. SELECT '', @PageType, @Ip, @TypeID
  19824. RETURN @@IDENTITY
  19825. END
  19826. GO
  19827. /****** Object: StoredProcedure [dbo].[pcWxTokenUpdate] Script Date: 2018/12/13 19:09:16 ******/
  19828. SET ANSI_NULLS ON
  19829. GO
  19830. SET QUOTED_IDENTIFIER ON
  19831. GO
  19832. --创建:Nick
  19833. --创建日期:2015-3-4
  19834. --获取token
  19835. --------------------------------------------------
  19836. CREATE PROCEDURE [dbo].[pcWxTokenUpdate]
  19837. (
  19838. @token VARCHAR(200),
  19839. @provinceID INT
  19840. )
  19841. AS
  19842. BEGIN
  19843. SET NOCOUNT ON
  19844. UPDATE dcWxToken SET Token=@token,AddDate=GETDATE()
  19845. WHERE dcProvinceId = @provinceID
  19846. SET NOCOUNT OFF
  19847. END
  19848. GO
  19849. /****** Object: StoredProcedure [dbo].[ppp] Script Date: 2018/12/13 19:09:17 ******/
  19850. SET ANSI_NULLS ON
  19851. GO
  19852. SET QUOTED_IDENTIFIER ON
  19853. GO
  19854. create proc [dbo].[ppp]
  19855. as
  19856. create table #t(id int,c1 varchar(100))
  19857. declare @id int
  19858. set @id = 0
  19859. while 1=1
  19860. begin
  19861. insert into #t
  19862. select @id, newid()
  19863. set @id = @id +1
  19864. end
  19865. GO
  19866. /****** Object: StoredProcedure [dbo].[probsCvModifyByPamainIDSelect] Script Date: 2018/12/13 19:09:17 ******/
  19867. SET ANSI_NULLS ON
  19868. GO
  19869. SET QUOTED_IDENTIFIER ON
  19870. GO
  19871. --#####################################################
  19872. --创建时间:2014.10.31
  19873. --创建人:Nick
  19874. --说明:
  19875. --#####################################################
  19876. CREATE PROCEDURE [dbo].[probsCvModifyByPamainIDSelect]
  19877. (
  19878. @PamainID INT
  19879. )
  19880. AS
  19881. BEGIN TRY
  19882. SELECT a.ID,cvMainID,a.Location,a.VerifyInfo,b.Name
  19883. FROM bsCvModify a WITH(NOLOCK),cvMain b WITH(NOLOCK)
  19884. WHERE a.cvMainID=b.ID And b.paMainID=@PamainID
  19885. ORDER BY cvMainID, Location
  19886. END TRY
  19887. BEGIN CATCH
  19888. RETURN 0
  19889. END CATCH
  19890. GO
  19891. /****** Object: StoredProcedure [dbo].[probsCvVerifyByPamainIDSelect] Script Date: 2018/12/13 19:09:17 ******/
  19892. SET ANSI_NULLS ON
  19893. GO
  19894. SET QUOTED_IDENTIFIER ON
  19895. GO
  19896. --#####################################################
  19897. --创建时间:2014.10.31
  19898. --创建人:Nick
  19899. --说明:
  19900. --#####################################################
  19901. CREATE PROCEDURE [dbo].[probsCvVerifyByPamainIDSelect]
  19902. (
  19903. @PamainID INT
  19904. )
  19905. AS
  19906. BEGIN TRY
  19907. SELECT TOP 1 VerifyResult, VerifyInfo
  19908. FROM bsCvVerify WITH(NOLOCK)
  19909. WHERE cvMainID In(
  19910. SELECT ID FROM cvMain WITH(NOLOCK)
  19911. WHERE paMainID=@PamainID)
  19912. ORDER BY ID DESC
  19913. END TRY
  19914. BEGIN CATCH
  19915. RETURN 0
  19916. END CATCH
  19917. GO
  19918. /****** Object: StoredProcedure [dbo].[proc51JobRegionToOurIDSelect] Script Date: 2018/12/13 19:09:17 ******/
  19919. SET ANSI_NULLS ON
  19920. GO
  19921. SET QUOTED_IDENTIFIER ON
  19922. GO
  19923. --#####################################################
  19924. --创建时间:2014.10.31
  19925. --创建人:Nick
  19926. --说明:由地区名称获取地区ID 51
  19927. --#####################################################
  19928. CREATE PROCEDURE [dbo].[proc51JobRegionToOurIDSelect]
  19929. (
  19930. @RegionName VARCHAR(20)
  19931. )
  19932. AS
  19933. BEGIN TRY
  19934. SELECT dbo._51JobRegionToOurID(@RegionName) ID
  19935. END TRY
  19936. BEGIN CATCH
  19937. RETURN 0
  19938. END CATCH
  19939. GO
  19940. /****** Object: StoredProcedure [dbo].[procA_TempCheckInsert] Script Date: 2018/12/13 19:09:18 ******/
  19941. SET ANSI_NULLS ON
  19942. GO
  19943. SET QUOTED_IDENTIFIER ON
  19944. GO
  19945. CREATE PROCEDURE [dbo].[procA_TempCheckInsert]
  19946. (
  19947. @province_id SMALLINT,
  19948. @VersionID SMALLINT,
  19949. @referer VARCHAR(190),
  19950. @ip VARCHAR(15),
  19951. @Url VARCHAR(max)
  19952. )
  19953. AS
  19954. RETURN
  19955. GO
  19956. /****** Object: StoredProcedure [dbo].[ProcActivationLogInsert] Script Date: 2018/12/13 19:09:18 ******/
  19957. SET ANSI_NULLS ON
  19958. GO
  19959. SET QUOTED_IDENTIFIER ON
  19960. GO
  19961. --创建:Max 2013-8-26
  19962. --说明:对推广邮件多长时间会登录、注册进行统计
  19963. ---------------------------------------------------
  19964. CREATE PROCEDURE [dbo].[ProcActivationLogInsert]
  19965. AS
  19966. BEGIN TRAN
  19967. IF EXISTS(
  19968. SELECT TOP 1 'x'
  19969. FROM LogDB..CpActivationLog
  19970. WHERE Countdate = CONVERT(VARCHAR(8),getdate()-1, 112)
  19971. )
  19972. GOTO ERR
  19973. DECLARE @MaxID AS INT
  19974. DECLARE @MaxID2 AS INT
  19975. DECLARE @Day1 AS INT
  19976. DECLARE @Day2 AS INT
  19977. DECLARE @Day3 AS INT
  19978. DECLARE @Day7 AS INT
  19979. DECLARE @Day15 AS INT
  19980. DECLARE @Day30 AS INT
  19981. DECLARE @DayOther AS INT
  19982. BEGIN TRY
  19983. SET @MaxID=0
  19984. -------------------------------个人统计------------------------------------
  19985. ---取前天正常注册的最大ID
  19986. SELECT @MaxID = MAX(ID)
  19987. FROM Pamain
  19988. WHERE Adddate > (CONVERT(VARCHAR(100), GETDATE()-2, 23) + ' 00:00:00')
  19989. AND Adddate < (CONVERT(VARCHAR(100), GETDATE()-1, 23) + ' 00:00:00')
  19990. AND RegisterMode NOT IN (1,11) AND RegisterType NOT IN (101,102)
  19991. ---取昨天正常注册的最大ID
  19992. SELECT @MaxID2 = MAX(ID)
  19993. FROM Pamain
  19994. WHERE Adddate > (CONVERT(VARCHAR(100), GETDATE()-1, 23) + ' 00:00:00')
  19995. AND Adddate < (CONVERT(VARCHAR(100), GETDATE(), 23) + ' 00:00:00')
  19996. AND RegisterMode NOT IN (1,11) AND RegisterType NOT IN (101,102)
  19997. --PRINT @MaxID
  19998. --PRINT @MaxID2
  19999. DECLARE @TempTable TABLE(ID INT IDENTITY(1,1), CountDate INT,AllCount INT)
  20000. INSERT @TempTable
  20001. SELECT CONVERT(VARCHAR(8),adddate, 112) CountDate,COUNT(*) AllCount
  20002. FROM pamain WHERE id > @MaxID AND id < @MaxID2
  20003. AND (registermode IN(1, 11) OR RegisterType IN (101,102))
  20004. GROUP BY CONVERT(VARCHAR(8),adddate, 112)
  20005. SELECT * FROM @TempTable ORDER BY countDate DESC
  20006. --取 day1
  20007. SELECT @Day1 = SUM(AllCount)
  20008. FROM @TempTable
  20009. WHERE CountDate > CONVERT(VARCHAR(8),getdate()-2, 112)
  20010. --PRINT @Day1
  20011. --取 day2
  20012. SELECT @Day2 = SUM(AllCount)
  20013. FROM @TempTable
  20014. WHERE CountDate > CONVERT(VARCHAR(8),getdate()-3, 112)
  20015. --PRINT @Day2
  20016. --取 day3
  20017. SELECT @Day3 = SUM(AllCount)
  20018. FROM @TempTable
  20019. WHERE CountDate > CONVERT(VARCHAR(8),getdate()-4, 112)
  20020. --PRINT @Day3
  20021. --取 day7
  20022. SELECT @Day7 = SUM(AllCount)
  20023. FROM @TempTable
  20024. WHERE CountDate > CONVERT(VARCHAR(8),getdate()-8, 112)
  20025. --PRINT @Day7
  20026. --取 day15
  20027. SELECT @Day15 = SUM(AllCount)
  20028. FROM @TempTable
  20029. WHERE CountDate > CONVERT(VARCHAR(8),getdate()-16, 112)
  20030. --PRINT @Day15
  20031. --取 day30
  20032. SELECT @Day30 = SUM(AllCount)
  20033. FROM @TempTable
  20034. WHERE CountDate > CONVERT(VARCHAR(8),getdate()-31, 112)
  20035. --PRINT @Day30
  20036. --取 dayOther
  20037. SELECT @DayOther = SUM(AllCount)
  20038. FROM @TempTable
  20039. WHERE CountDate <= CONVERT(VARCHAR(8),getdate()-31, 112)
  20040. --PRINT @DayOther
  20041. --插入日志表
  20042. INSERT INTO LogDB..CvActivationLog(countdate,day1,day2,day3,day7,day15,day30,dayOther)
  20043. VALUES(CONVERT(VARCHAR(8),getdate()-1, 112),@Day1,@Day2-@Day1,@Day3-@Day2,@Day7-@Day3,@Day15-@Day7,@Day30-@Day15,@DayOther)
  20044. -------------------------------企业统计------------------------------------
  20045. ---取前天正常注册的最大ID
  20046. SELECT @MaxID = MAX(ID)
  20047. FROM CpMain
  20048. WHERE Regdate > (CONVERT(VARCHAR(10), GETDATE()-2, 23) + ' 00:00:00')
  20049. AND Regdate < (CONVERT(VARCHAR(10), GETDATE()-1, 23) + ' 00:00:00')
  20050. AND RegisterMode NOT IN (1,11)
  20051. ---取昨天正常注册的最大ID
  20052. SELECT @MaxID2 = MAX(ID)
  20053. FROM CpMain
  20054. WHERE Regdate > (CONVERT(VARCHAR(10), GETDATE()-1, 23) + ' 00:00:00')
  20055. AND Regdate < (CONVERT(VARCHAR(10), GETDATE(), 23) + ' 00:00:00')
  20056. AND RegisterMode NOT IN (1,11)
  20057. --PRINT @MaxID
  20058. --PRINT @MaxID2
  20059. DELETE FROM @TempTable
  20060. INSERT @TempTable
  20061. SELECT CONVERT(VARCHAR(8),Regdate, 112) CountDate,COUNT(*) AllCount
  20062. FROM CpMain WHERE id > @MaxID AND id < @MaxID2
  20063. AND Registermode IN(1, 11)
  20064. GROUP BY CONVERT(VARCHAR(8),Regdate, 112)
  20065. SELECT * FROM @TempTable ORDER BY CountDate DESC
  20066. --取day1
  20067. SELECT @Day1 = SUM(AllCount)
  20068. FROM @TempTable
  20069. WHERE CountDate > CONVERT(VARCHAR(8),getdate()-2, 112)
  20070. --PRINT @Day1
  20071. --取 day2
  20072. SELECT @Day2 = SUM(AllCount)
  20073. FROM @TempTable
  20074. WHERE CountDate > CONVERT(VARCHAR(8),getdate()-3, 112)
  20075. --PRINT @Day2
  20076. --取 day3
  20077. SELECT @Day3 = SUM(AllCount)
  20078. FROM @TempTable
  20079. WHERE CountDate > CONVERT(VARCHAR(8),getdate()-4, 112)
  20080. --PRINT @Day3
  20081. --取 day7
  20082. SELECT @Day7 = SUM(AllCount)
  20083. FROM @TempTable
  20084. WHERE CountDate > CONVERT(VARCHAR(8),getdate()-8, 112)
  20085. --PRINT @Day7
  20086. --取 day15
  20087. SELECT @Day15 = SUM(AllCount)
  20088. FROM @TempTable
  20089. WHERE CountDate > CONVERT(VARCHAR(8),getdate()-16, 112)
  20090. --PRINT @Day15
  20091. --取 day30
  20092. SELECT @Day30 = SUM(AllCount)
  20093. FROM @TempTable
  20094. WHERE CountDate > CONVERT(VARCHAR(8),getdate()-31, 112)
  20095. --PRINT @Day30
  20096. --取 dayOther
  20097. SELECT @DayOther = SUM(AllCount)
  20098. FROM @TempTable
  20099. WHERE CountDate <= CONVERT(VARCHAR(8),getdate()-31, 112)
  20100. --PRINT @DayOther
  20101. --插入日志表
  20102. INSERT INTO LogDB..CpActivationLog(countdate,day1,day2,day3,day7,day15,day30,dayOther)
  20103. VALUES(CONVERT(VARCHAR(8),getdate()-1, 112),@Day1,@Day2-@Day1,@Day3-@Day2,@Day7-@Day3,@Day15-@Day7,@Day30-@Day15,@DayOther)
  20104. --统计推广员推广登录量
  20105. INSERT INTO Logdb..ActivationLog(AddMan,CountDate,CvCount,cpCount)
  20106. SELECT a.Addman,a.CountDate,a.cvCount,b.cpCount
  20107. FROM (
  20108. SELECT Addmannew Addman,CONVERT(VARCHAR(8),Regdatenew, 112) CountDate,count(*) cvCount
  20109. FROM logdb..ActivationCvDetail
  20110. WHERE Regdatenew > (CONVERT(VARCHAR(100), GETDATE()-1, 23) + ' 00:00:00')
  20111. AND Regdatenew < (CONVERT(VARCHAR(100), GETDATE(), 23) + ' 00:00:00')
  20112. GROUP BY Addmannew,CONVERT(VARCHAR(8),Regdatenew, 112)
  20113. ) a
  20114. JOIN (
  20115. SELECT Addmannew Addman,CONVERT(VARCHAR(8),Regdatenew, 112) CountDate,count(*) cpCount
  20116. FROM logdb..ActivationCpDetail
  20117. WHERE Regdatenew > (CONVERT(VARCHAR(100), GETDATE()-1, 23) + ' 00:00:00')
  20118. AND Regdatenew < (CONVERT(VARCHAR(100), GETDATE(), 23) + ' 00:00:00')
  20119. GROUP BY Addmannew,CONVERT(VARCHAR(8),Regdatenew, 112)
  20120. ) b ON a.Addman = b.Addman AND a.CountDate=b.CountDate
  20121. END TRY
  20122. BEGIN CATCH
  20123. GOTO ERR
  20124. END CATCH
  20125. COMMIT TRAN
  20126. RETURN 1
  20127. ERR:
  20128. BEGIN
  20129. ROLLBACK TRAN
  20130. RETURN 0
  20131. END
  20132. GO
  20133. /****** Object: StoredProcedure [dbo].[procAdverProjectAutoSort] Script Date: 2018/12/13 19:09:19 ******/
  20134. SET ANSI_NULLS ON
  20135. GO
  20136. SET QUOTED_IDENTIFIER ON
  20137. GO
  20138. --Carl 2018-04-23
  20139. --前台广告自动排序
  20140. CREATE PROCEDURE [dbo].[procAdverProjectAutoSort]
  20141. (
  20142. @Method INT, --0上线(新增,valid) 1手动暂停 2自动暂停,预备只替换下线的那一个
  20143. @ProvinceId INT,
  20144. @Type INT --限制 type<>10 不执行
  20145. )
  20146. AS
  20147. SET NOCOUNT OFF
  20148. BEGIN
  20149. IF @ProvinceId=0
  20150. BEGIN
  20151. --PRINT '51人才编辑自己操作'
  20152. RETURN
  20153. END
  20154. --IF @ProvinceId<>64 AND @ProvinceId<>83
  20155. --BEGIN
  20156. ----PRINT '不是西藏、新疆的不执行'
  20157. --RETURN
  20158. --END
  20159. IF @Type<>10
  20160. BEGIN
  20161. --PRINT '非首页横排广告不执行'
  20162. RETURN
  20163. END
  20164. DECLARE @Id INT
  20165. DECLARE @Width INT
  20166. DECLARE @LineNum3 INT
  20167. DECLARE @TotalWidth INT
  20168. DECLARE @IsSelf INT
  20169. DECLARE @RemainWidth INT
  20170. SET @LineNum3=0
  20171. SET @TotalWidth=0
  20172. --上下线时的操作,下线所有的自己的
  20173. UPDATE AdverProject SET Valid=0 WHERE ID IN (SELECT Id FROM AdverProject WHERE Province_ID = @ProvinceId
  20174. AND [Type] = 10
  20175. AND BeginTime <= CONVERT(SMALLDATETIME, GETDATE())
  20176. AND EndTime > CONVERT(SMALLDATETIME, GETDATE())
  20177. AND Valid = 1 AND IsSelf=1)
  20178. --查询目前该省份展示的广告,遍历获取 总行数
  20179. DECLARE CurrentInfo CURSOR FOR
  20180. SELECT Id,Width FROM AdverProject WHERE Province_ID = @ProvinceId
  20181. AND [Type] = 10
  20182. AND BeginTime <= CONVERT(SMALLDATETIME, GETDATE())
  20183. AND EndTime > CONVERT(SMALLDATETIME, GETDATE())
  20184. AND Valid = 1
  20185. OPEN CurrentInfo
  20186. FETCH NEXT FROM CurrentInfo INTO @Id,@Width
  20187. WHILE @@fetch_status<>-1
  20188. BEGIN
  20189. IF @Width=948 OR @Width=986 OR @Width=1100 OR @Width=1098
  20190. BEGIN
  20191. SET @Width=6
  20192. END
  20193. ELSE IF @Width=471 OR @Width=488 OR @Width=545 OR @Width=546
  20194. BEGIN
  20195. SET @Width=3
  20196. SET @LineNum3=@LineNum3+1
  20197. END
  20198. ELSE IF @Width=312 OR @Width=322 OR @Width=360 OR @Width=362
  20199. BEGIN
  20200. SET @Width=2
  20201. END
  20202. ELSE IF @Width=153 OR @Width=156 OR @Width=175 OR @Width=178
  20203. BEGIN
  20204. SET @Width=1
  20205. END
  20206. SET @TotalWidth=@TotalWidth+@Width
  20207. FETCH NEXT FROM CurrentInfo INTO @Id,@Width
  20208. END
  20209. CLOSE CurrentInfo
  20210. DEALLOCATE CurrentInfo
  20211. --PRINT '之前总宽度'
  20212. --PRINT @TotalWidth
  20213. IF @LineNum3%2<>0
  20214. BEGIN
  20215. --PRINT '3/6不为整行'
  20216. --PRINT '自动下线、手动下线或上线的补自己的'
  20217. UPDATE AdverProject SET Valid=1,BeginTime=GETDATE()-1,EndTime=DATEADD(YEAR,5,GETDATE())
  20218. WHERE ID IN (SELECT TOP 1 ID FROM AdverProject
  20219. WHERE Province_ID = @ProvinceId AND [Type] = 10
  20220. AND IsSelf=1 AND Valid=0 AND Width IN (471,488, 545, 546))
  20221. SET @TotalWidth=@TotalWidth+3
  20222. SET @LineNum3=@LineNum3+1
  20223. END
  20224. --PRINT '现在总宽度'
  20225. --PRINT @TotalWidth
  20226. SET @RemainWidth=6-(@TotalWidth%6)
  20227. --PRINT '遗留空位'
  20228. --PRINT @RemainWidth
  20229. --如果遗留空位 为 1 2 3 4 5
  20230. IF @RemainWidth>0 AND @RemainWidth<>6
  20231. BEGIN
  20232. --此时3/6的肯定是整行的了
  20233. --PRINT '遗留空位'
  20234. --PRINT @RemainWidth
  20235. --遍历 自己网站中的数据
  20236. DECLARE MySelfInfo CURSOR FOR
  20237. SELECT Id,Width FROM AdverProject WHERE Province_ID = @ProvinceId
  20238. AND [Type] = 10 AND IsSelf=1 AND Valid=0
  20239. AND Width IN (312,322,360,362,153,156,175,178) ORDER BY Width DESC
  20240. OPEN MySelfInfo
  20241. FETCH NEXT FROM MySelfInfo INTO @Id,@Width
  20242. WHILE @@fetch_status<>-1 AND @RemainWidth>0
  20243. BEGIN
  20244. IF @Width=312 OR @Width=322 OR @Width=360 OR @Width=362
  20245. BEGIN
  20246. SET @Width=2
  20247. END
  20248. ELSE IF @Width=153 OR @Width=156 OR @Width=175 OR @Width=178
  20249. BEGIN
  20250. SET @Width=1
  20251. END
  20252. IF (@RemainWidth-@Width)>=0
  20253. BEGIN
  20254. UPDATE AdverProject SET Valid=1,BeginTime=GETDATE()-1,
  20255. EndTime=DATEADD(YEAR,5,GETDATE()) WHERE ID=@Id
  20256. SET @RemainWidth=@RemainWidth-@Width
  20257. END
  20258. FETCH NEXT FROM MySelfInfo INTO @Id,@Width
  20259. END
  20260. CLOSE MySelfInfo
  20261. DEALLOCATE MySelfInfo
  20262. END
  20263. --重新排序
  20264. UPDATE AdverProject SET AdverProject.OrderBy=b.RowNum
  20265. FROM (SELECT id,ROW_NUMBER() OVER(ORDER BY Width DESC,EndTime) RowNum FROM AdverProject
  20266. WHERE Province_ID = @ProvinceId AND [Type] = 10
  20267. AND BeginTime <= CONVERT(SMALLDATETIME, GETDATE())
  20268. AND EndTime > CONVERT(SMALLDATETIME, GETDATE())
  20269. AND Valid = 1 ) b WHERE AdverProject.id=b.id
  20270. END
  20271. SET NOCOUNT ON
  20272. GO
  20273. /****** Object: StoredProcedure [dbo].[procAdverProjectByCampusSelect] Script Date: 2018/12/13 19:09:19 ******/
  20274. SET ANSI_NULLS ON
  20275. GO
  20276. SET QUOTED_IDENTIFIER ON
  20277. GO
  20278. --#####################################################
  20279. --创建时间:2015-10-19
  20280. --创建人:Lucifer
  20281. --说明:根据provincieid得到校园招聘首页图片
  20282. --#####################################################
  20283. CREATE PROCEDURE [dbo].[procAdverProjectByCampusSelect]
  20284. (
  20285. @ProvinceID INT,
  20286. @Type INT
  20287. )
  20288. AS
  20289. BEGIN
  20290. SELECT a.ID, a.ImageFile, a.Url, a.Width, a.Height, a.Remarks, b.SecondID CompanyId
  20291. FROM adverproject a WITH(NOLOCK) LEFT JOIN cpMain b WITH(NOLOCK) ON a.CompanyId = b.ID
  20292. WHERE a.Type=@Type
  20293. AND a.begintime<=CAST(GETDATE() AS SMALLDATETIME)
  20294. AND a.endtime>=CAST(GETDATE() AS SMALLDATETIME)
  20295. AND a.valid=1
  20296. AND a.province_id = @ProvinceID
  20297. ORDER BY a.Orderby
  20298. END
  20299. GO
  20300. /****** Object: StoredProcedure [dbo].[procAdverprojectByClickCountUpdate] Script Date: 2018/12/13 19:09:19 ******/
  20301. SET ANSI_NULLS ON
  20302. GO
  20303. SET QUOTED_IDENTIFIER ON
  20304. GO
  20305. CREATE PROCEDURE [dbo].[procAdverprojectByClickCountUpdate]
  20306. (
  20307. @Id INT,
  20308. @CompanyID INT
  20309. )
  20310. AS
  20311. BEGIN
  20312. UPDATE Adverproject SET ClickCount = ClickCount + 1
  20313. WHERE ID = @ID
  20314. AND CompanyID = @CompanyID
  20315. END
  20316. GO
  20317. /****** Object: StoredProcedure [dbo].[ProcAdverProjectByHomepageFloatSelect] Script Date: 2018/12/13 19:09:20 ******/
  20318. SET ANSI_NULLS ON
  20319. GO
  20320. SET QUOTED_IDENTIFIER ON
  20321. GO
  20322. CREATE PROCEDURE [dbo].[ProcAdverProjectByHomepageFloatSelect]
  20323. (
  20324. @ProvinceID INT
  20325. )
  20326. AS
  20327. BEGIN
  20328. SELECT * FROM AdverProject
  20329. WHERE Type IN (13, 14, 15)
  20330. AND BeginTime < GETDATE()
  20331. AND EndTime > GETDATE()
  20332. AND Province_ID = @ProvinceId
  20333. AND Valid = 1
  20334. END
  20335. GO
  20336. /****** Object: StoredProcedure [dbo].[procAdverProjectByOfflineUpdate] Script Date: 2018/12/13 19:09:20 ******/
  20337. SET ANSI_NULLS ON
  20338. GO
  20339. SET QUOTED_IDENTIFIER ON
  20340. GO
  20341. --Carl 2018-04-26
  20342. --Carl 2018-05-25
  20343. --定时任务存储过程 51编辑自己修改
  20344. CREATE PROCEDURE [dbo].[procAdverProjectByOfflineUpdate]
  20345. (
  20346. @Method INT --1、过期下线 2、自动暂停
  20347. )
  20348. AS
  20349. SET NOCOUNT ON
  20350. BEGIN
  20351. DECLARE @Id INT
  20352. DECLARE @Width INT
  20353. DECLARE @ProvinceId INT
  20354. DECLARE @LineNumNew6 INT --下线6/6的个数
  20355. DECLARE @LineNumNew3 INT --下线3/6的个数
  20356. DECLARE @RemainNum6 INT --剩余6/6的个数
  20357. DECLARE @TotalWidth INT --现有总宽度
  20358. DECLARE @WidthNew INT
  20359. DECLARE @IdNew INT
  20360. DECLARE @BeforeProvinceId INT
  20361. DECLARE @RemainCount INT --剩余空位数量
  20362. DECLARE @MaxLineNum INT --最大行数
  20363. DECLARE @MaxLineNumNew6 INT --6/6最大个数
  20364. DECLARE @MaxLineNumNew3 INT --3/6最大个数
  20365. DECLARE @ReadyWidth INT --预备宽度
  20366. DECLARE @ReadyId INT --预备Id
  20367. DECLARE @CompanyId INT --企业id
  20368. DECLARE @AddMan INT --添加人
  20369. DECLARE @SendList VARCHAR(100) --信息接收人员
  20370. DECLARE @Consultant INT --企业当前顾问
  20371. SET @SendList='153,158,212'
  20372. SET @BeforeProvinceId=0
  20373. SET @LineNumNew6=0
  20374. SET @LineNumNew3=0
  20375. SET @RemainNum6=0
  20376. SET @TotalWidth=0
  20377. SET @MaxLineNum=14
  20378. SET @MaxLineNumNew6=3
  20379. SET @MaxLineNumNew3=8
  20380. --定义游标
  20381. DECLARE @DownLineInfo CURSOR
  20382. --查询目前西藏省份过期的广告,遍历获取 总行数
  20383. IF @Method=1
  20384. BEGIN
  20385. --PRINT '过期下线'
  20386. SET @DownLineInfo=CURSOR FOR
  20387. SELECT Id,Width,Province_Id,CompanyId,AddMan FROM AdverProject WHERE Province_ID<>0 AND [Type] = 10
  20388. --AND EndTime = '2018-04-12 23:59:00'
  20389. AND EndTime = CONVERT(VARCHAR(100), GETDATE()-1, 23)+' 23:59:00'
  20390. --AND EndTime = CONVERT(SMALLDATETIME, GETDATE())
  20391. AND Valid = 1 ORDER BY Province_Id
  20392. END
  20393. ELSE IF @Method=2
  20394. BEGIN
  20395. SET @DownLineInfo = CURSOR FOR
  20396. SELECT Id,Width,Province_Id,CompanyId,AddMan FROM AdverProject WHERE
  20397. Province_ID<>0 AND [Type] = 10 AND BeginTime <= CONVERT(SMALLDATETIME, GETDATE())
  20398. AND EndTime > CONVERT(SMALLDATETIME, GETDATE())
  20399. AND Valid = 1 AND ISNULL(IsSelf,0)<>1
  20400. AND CompanyId IS NOT NULL
  20401. AND NOT EXISTS(SELECT 'X' FROM Job WITH(NOLOCK) WHERE cpMainID =AdverProject.CompanyId
  20402. AND IsDelete = 0 AND IssueEnd> GETDATE() AND IssueDate < GETDATE())
  20403. AND NOT EXISTS(SELECT 'X' FROM CaOrder WITH(NOLOCK) WHERE Id=AdverProject.CaOrderID AND Paid>0)
  20404. ORDER BY Province_Id
  20405. END
  20406. --PRINT '打开游标'
  20407. OPEN @DownLineInfo
  20408. FETCH NEXT FROM @DownLineInfo INTO @Id,@Width,@ProvinceId,@CompanyId,@AddMan
  20409. WHILE @@fetch_status<>-1
  20410. BEGIN
  20411. UPDATE AdverProject SET Valid=0 WHERE ID =@Id
  20412. IF @BeforeProvinceId=0
  20413. SET @BeforeProvinceId=@ProvinceId
  20414. IF @BeforeProvinceId<>@ProvinceId
  20415. BEGIN
  20416. --存储过程还需要再执行下(预备里无广告或6/6 3/6无法到前台的情况)
  20417. --PRINT '存储过程1'
  20418. EXEC procAdverProjectAutoSort 2,@BeforeProvinceId,10
  20419. SET @BeforeProvinceId=@ProvinceId
  20420. SET @LineNumNew6=0
  20421. SET @LineNumNew3=0
  20422. SET @TotalWidth=0
  20423. END
  20424. --获取总宽度
  20425. IF @TotalWidth=0
  20426. BEGIN
  20427. --查询目前该省份展示的广告,遍历获取 总行数
  20428. DECLARE TotalInfo CURSOR FOR
  20429. SELECT Width FROM AdverProject WHERE Province_ID = @ProvinceId
  20430. AND [Type] = 10
  20431. AND BeginTime <= CONVERT(SMALLDATETIME, GETDATE())
  20432. AND EndTime > CONVERT(SMALLDATETIME, GETDATE())
  20433. AND Valid = 1
  20434. OPEN TotalInfo
  20435. FETCH NEXT FROM TotalInfo INTO @WidthNew
  20436. WHILE @@fetch_status<>-1
  20437. BEGIN
  20438. IF @WidthNew=948 OR @WidthNew=986 OR @WidthNew=1100 OR @WidthNew=1098
  20439. BEGIN
  20440. SET @WidthNew=6
  20441. SET @LineNumNew6=@LineNumNew6+1
  20442. END
  20443. ELSE IF @WidthNew=471 OR @WidthNew=488 OR @WidthNew=545 OR @WidthNew=546
  20444. BEGIN
  20445. SET @WidthNew=3
  20446. SET @LineNumNew3=@LineNumNew3+1
  20447. END
  20448. ELSE IF @WidthNew=312 OR @WidthNew=322 OR @WidthNew=360 OR @WidthNew=362
  20449. BEGIN
  20450. SET @WidthNew=2
  20451. END
  20452. ELSE IF @WidthNew=153 OR @WidthNew=156 OR @WidthNew=175 OR @WidthNew=178
  20453. BEGIN
  20454. SET @WidthNew=1
  20455. END
  20456. SET @TotalWidth=@TotalWidth+@WidthNew
  20457. FETCH NEXT FROM TotalInfo INTO @WidthNew
  20458. END
  20459. CLOSE TotalInfo
  20460. DEALLOCATE TotalInfo
  20461. END
  20462. IF @Method=2
  20463. BEGIN
  20464. --检查企业广告是否 三天后全部过期
  20465. IF (SELECT CONVERT(VARCHAR,MAX(IssueEnd),23) FROM Job WITH(NOLOCK) WHERE cpMainID =@CompanyId AND IsDelete = 0
  20466. AND IssueEnd> GETDATE() AND IssueDate < GETDATE())<=CONVERT(VARCHAR,GETDATE()+3,23)
  20467. BEGIN
  20468. --PRINT '发送rtx提醒'
  20469. --获取企业当前顾问
  20470. SELECT @Consultant=ISNULL(ConsultantID,0) FROM cpMain WHERE ID=@CompanyId
  20471. INSERT oadb..RtxSend (Receiver, RtxTitle, RtxMessage, SendType, DelayTime, SendTime, AddTime)
  20472. VALUES (CONVERT(VARCHAR,@Consultant),
  20473. '广告通知', '公司id:'+CONVERT(VARCHAR,@CompanyId)+',该企业职位三天内即将全部过期,请联系用户及时发布',
  20474. 1, 0, null, getdate())
  20475. END
  20476. END
  20477. IF @TotalWidth/6>=@MaxLineNum
  20478. BEGIN
  20479. --如果总行数大于14 补自己的 继续下次循环
  20480. FETCH NEXT FROM @DownLineInfo INTO @Id,@Width,@ProvinceId,@CompanyId,@AddMan
  20481. CONTINUE
  20482. END
  20483. ELSE
  20484. BEGIN
  20485. --未到达最大行数
  20486. --PRINT '总行数未到达最大行数'
  20487. --获取遗留空位数,从预备中取,然后执行存储过程自动排序
  20488. SET @RemainCount=(6*@MaxLineNum)-@TotalWidth
  20489. --遍历预备中的广告,6/6 3/6需要单独判断下
  20490. --遍历该省份预备中的数据
  20491. DECLARE ReadyInfo CURSOR FOR
  20492. SELECT Id,Width FROM AdverProject WHERE Province_ID = @BeforeProvinceId
  20493. AND [Type] = 10 AND BeginTime>GETDATE() and Valid=1 ORDER BY OrderBy
  20494. OPEN ReadyInfo
  20495. FETCH NEXT FROM ReadyInfo INTO @ReadyId,@ReadyWidth
  20496. WHILE @@fetch_status<>-1 AND @RemainCount>0
  20497. BEGIN
  20498. IF @ReadyWidth=948 OR @ReadyWidth=986 OR @ReadyWidth=1100 OR @ReadyWidth=1098
  20499. BEGIN
  20500. SET @ReadyWidth=6
  20501. END
  20502. ELSE IF @ReadyWidth=471 OR @ReadyWidth=488 OR @ReadyWidth=545 OR @ReadyWidth=546
  20503. BEGIN
  20504. SET @ReadyWidth=3
  20505. END
  20506. ELSE IF @ReadyWidth=312 OR @ReadyWidth=322 OR @ReadyWidth=360 OR @ReadyWidth=362
  20507. BEGIN
  20508. SET @ReadyWidth=2
  20509. END
  20510. ELSE IF @ReadyWidth=153 OR @ReadyWidth=156 OR @ReadyWidth=175 OR @ReadyWidth=178
  20511. BEGIN
  20512. SET @ReadyWidth=1
  20513. END
  20514. IF @ReadyWidth=6
  20515. BEGIN
  20516. --查看6/6 是否到达总行数,若达到,预备进行下次循环
  20517. IF @LineNumNew6>=@MaxLineNumNew6
  20518. BEGIN
  20519. --PRINT '6/6到达最大行数'
  20520. FETCH NEXT FROM ReadyInfo INTO @ReadyId,@ReadyWidth
  20521. CONTINUE
  20522. END
  20523. ELSE
  20524. BEGIN
  20525. IF @RemainCount>=6
  20526. BEGIN
  20527. SET @LineNumNew6=@LineNumNew6+1
  20528. END
  20529. END
  20530. END
  20531. IF @ReadyWidth=3
  20532. BEGIN
  20533. IF @LineNumNew3>=@MaxLineNumNew3
  20534. BEGIN
  20535. --PRINT '3/6到达最大行数'
  20536. FETCH NEXT FROM ReadyInfo INTO @ReadyId,@ReadyWidth
  20537. CONTINUE
  20538. END
  20539. ELSE
  20540. BEGIN
  20541. IF @RemainCount>=3
  20542. BEGIN
  20543. SET @LineNumNew3=@LineNumNew3+1
  20544. END
  20545. END
  20546. END
  20547. IF (@RemainCount-@ReadyWidth)>=0
  20548. BEGIN
  20549. UPDATE AdverProject SET BeginTime=CONVERT(SMALLDATETIME,GETDATE()),
  20550. EndTime=CONVERT(VARCHAR,DATEADD(DAY,DATEDIFF(DD,BeginTime,EndTime),GETDATE()),23)+' 23:59:00' WHERE ID=@ReadyId
  20551. SET @RemainCount=@RemainCount-@ReadyWidth
  20552. SET @TotalWidth=@TotalWidth+@ReadyWidth
  20553. END
  20554. FETCH NEXT FROM ReadyInfo INTO @ReadyId,@ReadyWidth
  20555. END
  20556. CLOSE ReadyInfo
  20557. DEALLOCATE ReadyInfo
  20558. END
  20559. FETCH NEXT FROM @DownLineInfo INTO @Id,@Width,@ProvinceId,@CompanyId,@AddMan
  20560. END
  20561. --PRINT '存储过程2'
  20562. --PRINT @BeforeProvinceId
  20563. EXEC procAdverProjectAutoSort 2,@BeforeProvinceId,10
  20564. --PRINT @BeforeProvinceId
  20565. CLOSE @DownLineInfo
  20566. DEALLOCATE @DownLineInfo
  20567. IF @Method=2
  20568. BEGIN
  20569. --PRINT '自动暂停执行完,查下前台广告是否有小于三行的'
  20570. DECLARE @SubsiteName VARCHAR(1000)
  20571. SET @BeforeProvinceId=0
  20572. SET @TotalWidth=0
  20573. SET @SubsiteName=''
  20574. DECLARE TotalProvince CURSOR FOR
  20575. SELECT Province_Id FROM AdverProject WHERE Province_Id<>0 AND [Type] = 10
  20576. AND BeginTime <= CONVERT(SMALLDATETIME, GETDATE())
  20577. AND EndTime > CONVERT(SMALLDATETIME, GETDATE()) AND Valid = 1 GROUP BY Province_Id
  20578. OPEN TotalProvince
  20579. FETCH NEXT FROM TotalProvince INTO @ProvinceId
  20580. WHILE @@fetch_status<>-1
  20581. BEGIN
  20582. IF @BeforeProvinceId=0
  20583. SET @BeforeProvinceId=@ProvinceId
  20584. IF @BeforeProvinceId<>@ProvinceId
  20585. BEGIN
  20586. IF @TotalWidth/6<3
  20587. BEGIN
  20588. --根据省份id 获取 网站名称
  20589. SELECT @SubsiteName=SubSiteName FROM dcsubsite WHERE ProvinceID=@BeforeProvinceId
  20590. --PRINT '发送rtx提醒'
  20591. IF @SubsiteName<>''
  20592. BEGIN
  20593. INSERT INTO oadb..RtxSend (Receiver, RtxTitle, RtxMessage, SendType, DelayTime, SendTime, AddTime)
  20594. VALUES (@SendList,
  20595. '广告通知', @SubsiteName+',前台广告少于三行',
  20596. 1, 0, null, getdate())
  20597. END
  20598. END
  20599. SET @BeforeProvinceId=@ProvinceId
  20600. SET @TotalWidth=0
  20601. END
  20602. --获取总宽度
  20603. IF @TotalWidth=0
  20604. BEGIN
  20605. --查询目前该省份展示的广告,遍历获取 总行数
  20606. DECLARE TotalInfo CURSOR FOR
  20607. SELECT Width FROM AdverProject WHERE Province_ID = @ProvinceId
  20608. AND [Type] = 10
  20609. AND BeginTime <= CONVERT(SMALLDATETIME, GETDATE())
  20610. AND EndTime > CONVERT(SMALLDATETIME, GETDATE())
  20611. AND Valid = 1
  20612. OPEN TotalInfo
  20613. FETCH NEXT FROM TotalInfo INTO @WidthNew
  20614. WHILE @@fetch_status<>-1
  20615. BEGIN
  20616. IF @WidthNew=948 OR @WidthNew=986 OR @WidthNew=1100 OR @WidthNew=1098
  20617. BEGIN
  20618. SET @WidthNew=6
  20619. END
  20620. ELSE IF @WidthNew=471 OR @WidthNew=488 OR @WidthNew=545 OR @WidthNew=546
  20621. BEGIN
  20622. SET @WidthNew=3
  20623. END
  20624. ELSE IF @WidthNew=312 OR @WidthNew=322 OR @WidthNew=360 OR @WidthNew=362
  20625. BEGIN
  20626. SET @WidthNew=2
  20627. END
  20628. ELSE IF @WidthNew=153 OR @WidthNew=156 OR @WidthNew=175 OR @WidthNew=178
  20629. BEGIN
  20630. SET @WidthNew=1
  20631. END
  20632. SET @TotalWidth=@TotalWidth+@WidthNew
  20633. FETCH NEXT FROM TotalInfo INTO @WidthNew
  20634. END
  20635. CLOSE TotalInfo
  20636. DEALLOCATE TotalInfo
  20637. END
  20638. FETCH NEXT FROM TotalProvince INTO @ProvinceId
  20639. END
  20640. CLOSE TotalProvince
  20641. DEALLOCATE TotalProvince
  20642. IF @TotalWidth/6<3
  20643. BEGIN
  20644. --根据省份id 获取 网站名称
  20645. SELECT @SubsiteName=SubSiteName FROM dcsubsite WHERE ProvinceID=@BeforeProvinceId
  20646. --PRINT '发送rtx提醒'
  20647. IF @SubsiteName<>''
  20648. BEGIN
  20649. INSERT INTO oadb..RtxSend (Receiver, RtxTitle, RtxMessage, SendType, DelayTime, SendTime, AddTime)
  20650. VALUES (@SendList,
  20651. '广告通知', @SubsiteName+',前台广告少于三行',
  20652. 1, 0, null, getdate())
  20653. END
  20654. END
  20655. END
  20656. END
  20657. GO
  20658. /****** Object: StoredProcedure [dbo].[procAdverProjectByProvince_IDSelect] Script Date: 2018/12/13 19:09:21 ******/
  20659. SET ANSI_NULLS ON
  20660. GO
  20661. SET QUOTED_IDENTIFIER ON
  20662. GO
  20663. --#####################################################
  20664. --创建时间:2014.11.3
  20665. --创建人:NICK
  20666. --说明:根据provincieid得到adverproject
  20667. --#####################################################
  20668. CREATE PROCEDURE [dbo].[procAdverProjectByProvince_IDSelect]
  20669. (
  20670. @ProvinceID INT,
  20671. @Type INT
  20672. )
  20673. AS
  20674. BEGIN
  20675. SELECT top 1 id,imagefile,width,url,companyid,remarks
  20676. FROM adverproject WITH(NOLOCK) WHERE TYPE=@Type
  20677. AND begintime<=CAST(GETDATE() AS SMALLDATETIME)
  20678. AND endtime>=CAST(GETDATE() AS SMALLDATETIME)
  20679. AND valid=1
  20680. AND province_id = @ProvinceID
  20681. ORDER BY id DESC
  20682. END
  20683. GO
  20684. /****** Object: StoredProcedure [dbo].[procAdverProjectByProvinceID16Select] Script Date: 2018/12/13 19:09:21 ******/
  20685. SET ANSI_NULLS ON
  20686. GO
  20687. SET QUOTED_IDENTIFIER ON
  20688. GO
  20689. --#####################################################
  20690. --创建时间:2014.11.03
  20691. --创建人:Nick
  20692. --说明:取新职业指导切换图片的数据
  20693. --#####################################################
  20694. CREATE PROCEDURE [dbo].[procAdverProjectByProvinceID16Select]
  20695. (
  20696. @ProvinceID INT
  20697. )
  20698. AS
  20699. BEGIN TRY
  20700. SELECT id, imagefile, remarks, url, companyid
  20701. FROM adverproject WITH(NOLOCK)
  20702. WHERE type = 16
  20703. AND begintime <= CAST(GETDATE() AS SMALLDATETIME)
  20704. AND endtime >= CAST(GETDATE() AS SMALLDATETIME)
  20705. AND valid = 1
  20706. AND province_id = @ProvinceID
  20707. AND inNews = 1
  20708. ORDER BY orderby
  20709. END TRY
  20710. BEGIN CATCH
  20711. RETURN 0
  20712. END CATCH
  20713. GO
  20714. /****** Object: StoredProcedure [dbo].[procAdverprojectChangeadSelect] Script Date: 2018/12/13 19:09:21 ******/
  20715. SET ANSI_NULLS ON
  20716. GO
  20717. SET QUOTED_IDENTIFIER ON
  20718. GO
  20719. --创建人 Lambo 20101010
  20720. --用于首页查询切换的广告图片
  20721. CREATE PROCEDURE [dbo].[procAdverprojectChangeadSelect]
  20722. (
  20723. @province_id SMALLINT
  20724. )
  20725. AS
  20726. BEGIN
  20727. SELECT id, imagefile, remarks, url, companyid
  20728. FROM adverproject with(nolock)
  20729. WHERE type=9
  20730. AND begintime<=CAST(GETDATE() AS SMALLDATETIME)
  20731. AND endtime>=CAST(GETDATE() AS SMALLDATETIME)
  20732. AND valid=1
  20733. AND province_id=@province_id
  20734. ORDER BY orderby
  20735. END
  20736. GO
  20737. /****** Object: StoredProcedure [dbo].[procAdverprojectChangeadSelectNew] Script Date: 2018/12/13 19:09:21 ******/
  20738. SET ANSI_NULLS ON
  20739. GO
  20740. SET QUOTED_IDENTIFIER ON
  20741. GO
  20742. CREATE PROCEDURE [dbo].[procAdverprojectChangeadSelectNew]
  20743. (
  20744. @province_id SMALLINT
  20745. )
  20746. AS
  20747. BEGIN
  20748. SELECT id, imagefile, remarks, url, companyid
  20749. FROM adverproject with(nolock)
  20750. WHERE type=16
  20751. AND begintime<=CAST(GETDATE() AS SMALLDATETIME)
  20752. AND endtime>=CAST(GETDATE() AS SMALLDATETIME)
  20753. AND valid=1
  20754. AND province_id=@province_id
  20755. ORDER BY orderby
  20756. END
  20757. GO
  20758. /****** Object: StoredProcedure [dbo].[procAdverprojectClickCountByIDUpdate] Script Date: 2018/12/13 19:09:21 ******/
  20759. SET ANSI_NULLS ON
  20760. GO
  20761. SET QUOTED_IDENTIFIER ON
  20762. GO
  20763. --#####################################################
  20764. --创建时间:2014.11.03
  20765. --创建人:Nick
  20766. --说明:修改点击次数
  20767. --#####################################################
  20768. CREATE PROCEDURE [dbo].[procAdverprojectClickCountByIDUpdate]
  20769. (
  20770. @ID INT
  20771. )
  20772. AS
  20773. BEGIN TRY
  20774. UPDATE adverproject SET clickcount=clickcount+1 WHERE id = @ID
  20775. RETURN 1
  20776. END TRY
  20777. BEGIN CATCH
  20778. RETURN 0
  20779. END CATCH
  20780. GO
  20781. /****** Object: StoredProcedure [dbo].[ProcAdverProjectErrorLogInsert] Script Date: 2018/12/13 19:09:22 ******/
  20782. SET ANSI_NULLS ON
  20783. GO
  20784. SET QUOTED_IDENTIFIER ON
  20785. GO
  20786. --#####################################################
  20787. --创建时间:2014.10.28
  20788. --创建人:Nick
  20789. --说明:插入 广告日志
  20790. --#####################################################
  20791. CREATE PROCEDURE [dbo].[ProcAdverProjectErrorLogInsert]
  20792. @Log VARCHAR(500)
  20793. AS
  20794. BEGIN TRY
  20795. INSERT INTO AdverProject_Errorlog (errorlog)
  20796. VALUES (@Log)
  20797. END TRY
  20798. BEGIN CATCH
  20799. RETURN 0
  20800. END CATCH
  20801. GO
  20802. /****** Object: StoredProcedure [dbo].[ProcAdverProjectHWSelect] Script Date: 2018/12/13 19:09:22 ******/
  20803. SET ANSI_NULLS ON
  20804. GO
  20805. SET QUOTED_IDENTIFIER ON
  20806. GO
  20807. --#####################################################
  20808. --创建时间:2014.10.28
  20809. --创建人:Nick
  20810. --说明:获取首页横排广告的宽度信息
  20811. --#####################################################
  20812. CREATE PROCEDURE [dbo].[ProcAdverProjectHWSelect]
  20813. (
  20814. @dcProvinceId VARCHAR(10),
  20815. @Date VARCHAR(50)
  20816. )
  20817. AS
  20818. BEGIN
  20819. SELECT width, height
  20820. FROM AdverProject WITH(Nolock)
  20821. WHERE Province_ID = @dcProvinceId
  20822. AND Type = 10
  20823. AND BeginTime <= CONVERT(SMALLDATETIME, @Date)
  20824. AND EndTime > CONVERT(SMALLDATETIME, @Date)
  20825. AND Valid = 1
  20826. ORDER BY OrderBy
  20827. END
  20828. GO
  20829. /****** Object: StoredProcedure [dbo].[procAdverprojectLogoSelect] Script Date: 2018/12/13 19:09:22 ******/
  20830. SET ANSI_NULLS ON
  20831. GO
  20832. SET QUOTED_IDENTIFIER ON
  20833. GO
  20834. CREATE PROCEDURE [dbo].[procAdverprojectLogoSelect]
  20835. (
  20836. @province_id SMALLINT
  20837. )
  20838. AS
  20839. BEGIN
  20840. SELECT id, imagefile, remarks, url, companyid
  20841. FROM adverproject with(nolock)
  20842. WHERE type=17
  20843. AND begintime<=CAST(GETDATE() AS SMALLDATETIME)
  20844. AND endtime>=CAST(GETDATE() AS SMALLDATETIME)
  20845. AND valid=1
  20846. AND province_id=@province_id
  20847. ORDER BY orderby
  20848. END
  20849. GO
  20850. /****** Object: StoredProcedure [dbo].[ProcAdverprojectRowad] Script Date: 2018/12/13 19:09:23 ******/
  20851. SET ANSI_NULLS ON
  20852. GO
  20853. SET QUOTED_IDENTIFIER ON
  20854. GO
  20855. --######################################################33
  20856. --创建人 Lambo
  20857. --20101009
  20858. --用于首页查询六分之一模块的广告图片
  20859. --修改 sean 2011-10-11 增加每个企业的职位和简介
  20860. --sean 2014-01-10
  20861. --######################################################33
  20862. CREATE PROCEDURE [dbo].[ProcAdverprojectRowad]
  20863. (
  20864. @Province_Id SMALLINT
  20865. )
  20866. AS
  20867. BEGIN
  20868. IF @Province_Id < 99 OR @Province_Id LIKE '32%'
  20869. BEGIN
  20870. SELECT Id, Type,Province_Id,ImageFile,Url,Width,Height,Remarks,NoFollow + CompanyId CompanyId,Orderby,JobID,JobName,CompanyBiref
  20871. FROM SearchDb..AdverProjectShot WITH(NOLOCK)
  20872. WHERE Type=10
  20873. AND Province_Id = @Province_Id
  20874. ORDER BY OrderBy
  20875. END
  20876. ELSE
  20877. BEGIN
  20878. DECLARE @t AS TABLE(
  20879. oId INT identity(1, 1),
  20880. id INT,
  20881. Type Int,
  20882. Province_Id int,
  20883. ImageFile VARCHAR(100),
  20884. Url VARCHAR(200),
  20885. Width int,
  20886. Height int,
  20887. Remarks NVARCHAR(200),
  20888. CompanyId VARCHAR(20),
  20889. OrderBy INT,
  20890. JobId VARCHAR(200),
  20891. JobName NVARCHAR(1000),
  20892. CompanyBiref NVARCHAR(200)
  20893. )
  20894. INSERT @t(Id, Type, Province_Id, ImageFile, Url, Width, Height, Remarks, CompanyId, Orderby, JobID, JobName, CompanyBiref)
  20895. SELECT Id, Type, Province_Id, ImageFile, Url, Width, Height, Remarks, NoFollow + CompanyId CompanyId, Orderby, JobID, JobName, CompanyBiref
  20896. FROM SearchDb..AdverProjectShot WITH(NOLOCK)
  20897. WHERE Type=10
  20898. AND Province_Id = @Province_Id
  20899. ORDER BY OrderBy
  20900. INSERT @t(Id, Type, Province_Id, ImageFile, Url, Width, Height, Remarks, CompanyId, Orderby, JobID, JobName, CompanyBiref)
  20901. SELECT Id, Type, Province_Id, ImageFile, Url, Width, Height, Remarks, NoFollow + CompanyId CompanyId, Orderby, JobID, JobName, CompanyBiref
  20902. FROM SearchDb..AdverProjectShot WITH(NOLOCK)
  20903. WHERE Type=10
  20904. AND Province_Id = LEFT(@Province_Id, 2)
  20905. ORDER BY OrderBy
  20906. SELECT Id, Type, Province_Id, ImageFile, Url, Width, Height, Remarks, CompanyId, Orderby, JobID, JobName, CompanyBiref FROM @t ORDER BY Oid
  20907. END
  20908. END
  20909. GO
  20910. /****** Object: StoredProcedure [dbo].[procAdverprojectRowTopadSelect] Script Date: 2018/12/13 19:09:23 ******/
  20911. SET ANSI_NULLS ON
  20912. GO
  20913. SET QUOTED_IDENTIFIER ON
  20914. GO
  20915. --创建人 Lambo
  20916. --时间 20101009
  20917. --用于网站首页查询网站头部广告
  20918. CREATE PROCEDURE [dbo].[procAdverprojectRowTopadSelect]
  20919. (
  20920. @province_id int
  20921. )
  20922. AS
  20923. BEGIN
  20924. SELECT id,imagefile,width,url,companyid,remarks
  20925. FROM adverproject WITH(NOLOCK)
  20926. WHERE TYPE=11
  20927. AND begintime<=CAST(GETDATE() AS SMALLDATETIME)
  20928. AND endtime>=CAST(GETDATE()-7 AS SMALLDATETIME)
  20929. AND valid=1
  20930. AND province_id=@province_id
  20931. ORDER BY orderby
  20932. END
  20933. GO
  20934. /****** Object: StoredProcedure [dbo].[procAdverProjectShotByProvinceIDSelect] Script Date: 2018/12/13 19:09:24 ******/
  20935. SET ANSI_NULLS ON
  20936. GO
  20937. SET QUOTED_IDENTIFIER ON
  20938. GO
  20939. --#####################################################
  20940. --创建时间:2014.11.10
  20941. --创建人:Nick
  20942. --说明:首页广告
  20943. --#####################################################
  20944. CREATE PROCEDURE [dbo].[procAdverProjectShotByProvinceIDSelect]
  20945. AS
  20946. BEGIN TRY
  20947. SELECT *,b.dcProvinceID
  20948. FROM SearchDb..AdverProjectShot a WITH(NOLOCK)
  20949. left join cpMain b WITH(NOLOCK) on a.CompanyID=b.SecondID
  20950. WHERE type=10
  20951. AND Province_Id = 0
  20952. ORDER BY OrderBy
  20953. END TRY
  20954. BEGIN CATCH
  20955. RETURN 0
  20956. END CATCH
  20957. GO
  20958. /****** Object: StoredProcedure [dbo].[ProcAdverProjectShotRebuild] Script Date: 2018/12/13 19:09:24 ******/
  20959. SET ANSI_NULLS ON
  20960. GO
  20961. SET QUOTED_IDENTIFIER ON
  20962. GO
  20963. CREATE PROCEDURE [dbo].[ProcAdverProjectShotRebuild]
  20964. AS
  20965. BEGIN
  20966. SET NOCOUNT ON
  20967. DECLARE @t AS TABLE(
  20968. [Id] [int] NOT NULL,
  20969. [Type] [smallint] NOT NULL,
  20970. [Province_Id] [int] NOT NULL,
  20971. [ImageFile] [varchar](100) NULL,
  20972. [Url] [varchar](200) NULL,
  20973. [Width] [smallint] NULL,
  20974. Height SmallINT NULL,
  20975. [Remarks] [nvarchar](200) NULL,
  20976. [CompanyId] varchar(12) NULL,
  20977. [Orderby] [smallint] NULL,
  20978. [JobID] [varchar](300) NULL,
  20979. [JobName] [nvarchar](1000) NULL,
  20980. [CompanyBiref] [nvarchar](200) NULL,
  20981. RealCpMainID INT,
  20982. NoFollow VARCHAR(1)
  20983. )
  20984. -- DECLARE @OrderBy1 AS INT
  20985. -- DECLARE @OrderBy2 AS INT
  20986. -- SELECT @ORderBy1 = OrderBy FROM AdverProject WITH(NOLOCK) WHERE ID = 28078 AND Valid = 1
  20987. -- SELECT @ORderBy2 = OrderBy FROM AdverProject WITH(NOLOCK) WHERE ID = 31536 AND Valid = 1
  20988. -- IF @OrderBy1 > 0 AND @OrderBy2 > 0
  20989. -- BEGIN
  20990. -- UPDATE AdverProject SET OrderBy = @OrderBy1 WHERE ID = 31536
  20991. -- UPDATE AdverProject SET OrderBy = @OrderBy2 WHERE ID = 28078
  20992. -- END
  20993. INSERT INTO @t(Id, Imagefile, Width, Height, Url, Companyid, Remarks, Province_Id, Type, ORderBy, RealCpMainID, NoFollow)
  20994. SELECT Id, Imagefile, Width, Height, Url, Companyid, Remarks, Province_Id, Type, ORderBy, Companyid, '_'
  20995. FROM AdverProject WITH(NOLOCK)
  20996. WHERE Type=10
  20997. AND BeginTime <= CAST(GETDATE() AS SMALLDATETIME)
  20998. AND EndTime > CAST(GETDATE() AS SMALLDATETIME)
  20999. AND Valid = 1
  21000. DECLARE @RUN AS INT
  21001. SET @Run = 0
  21002. UPDATE @t SET JobID = dbo.GetJobSecondIds(Companyid), JobName = dbo.GetJobNames(Companyid)
  21003. UPDATE a SET a.Companyid = b.SecondId
  21004. FROM @t a, cpMain b WITH(NOLOCK)
  21005. WHERE a.RealCpMainID = b.Id
  21006. UPDATE a
  21007. SET a.CompanyBiref = LEFT(ISNULL(b.Brief, ''), 200)
  21008. FROM @t a,
  21009. cpMain b WITH(NOLOCK)
  21010. WHERE b.ID = a.RealCpMainID
  21011. UPDATE @t SET NoFollow = ''
  21012. --WHERE CompanyID IN(SELECT PageId FROM MarketDb..PageBaiduInclude WHERE PageType = 1 AND IncludeDate IS Null)
  21013. TRUNCATE TABLE SearchDB..AdverProjectShot
  21014. INSERT INTO SearchDB..AdverProjectShot
  21015. SELECT * FROM @t
  21016. END
  21017. GO
  21018. /****** Object: StoredProcedure [dbo].[procAgent_BlackSelect] Script Date: 2018/12/13 19:09:24 ******/
  21019. SET ANSI_NULLS ON
  21020. GO
  21021. SET QUOTED_IDENTIFIER ON
  21022. GO
  21023. --#####################################################
  21024. --创建时间:2014.11.03
  21025. --创建人:Nick
  21026. --说明:Agent黑名单
  21027. --#####################################################
  21028. CREATE PROCEDURE [dbo].[procAgent_BlackSelect]
  21029. AS
  21030. BEGIN TRY
  21031. SELECT * FROM agent_Black With(Nolock) ORDER BY ID
  21032. END TRY
  21033. BEGIN CATCH
  21034. RETURN 0
  21035. END CATCH
  21036. GO
  21037. /****** Object: StoredProcedure [dbo].[procAgent_WhiteSelect] Script Date: 2018/12/13 19:09:24 ******/
  21038. SET ANSI_NULLS ON
  21039. GO
  21040. SET QUOTED_IDENTIFIER ON
  21041. GO
  21042. --#####################################################
  21043. --创建时间:2014.11.03
  21044. --创建人:Nick
  21045. --说明:Agent白名单
  21046. --#####################################################
  21047. CREATE PROCEDURE [dbo].[procAgent_WhiteSelect]
  21048. AS
  21049. BEGIN TRY
  21050. SELECT * FROM agent_White With(Nolock) ORDER BY ID
  21051. END TRY
  21052. BEGIN CATCH
  21053. RETURN 0
  21054. END CATCH
  21055. GO
  21056. /****** Object: StoredProcedure [dbo].[procAssessCpInviteByOverUpdate] Script Date: 2018/12/13 19:09:24 ******/
  21057. SET ANSI_NULLS ON
  21058. GO
  21059. SET QUOTED_IDENTIFIER ON
  21060. GO
  21061. --#####################################################
  21062. --创建时间:20181119
  21063. --创建人:Peter
  21064. --修改过期的邀请并返还
  21065. --#####################################################
  21066. CREATE PROCEDURE [dbo].[procAssessCpInviteByOverUpdate]
  21067. AS
  21068. SET NOCOUNT ON
  21069. BEGIN
  21070. SELECT ROW_NUMBER() OVER(ORDER BY a.AddDate) RowNo,b.CaOrderID,1 UseCnt,a.ID RelateID,3 RelateType,b.CaMainID,b.IP,CONVERT(INT,0) RemainCnt
  21071. INTO #T
  21072. FROM AssessCpInvite a WITH(NOLOCK)
  21073. INNER JOIN AssessOrderUselog b WITH(NOLOCK) ON b.RelateID = a.ID AND b.RelateType = 2
  21074. WHERE a.EndDate < GETDATE()
  21075. AND NOT EXISTS(SELECT 'x' FROM AssessOrderUselog WHERE RelateType = 3 AND RelateID = a.ID)
  21076. DECLARE cur_OrderInfo CURSOR FOR
  21077. SELECT RowNo,CaOrderID,UseCnt,CaMainID
  21078. FROM #T
  21079. DECLARE @RowNo INT,@CaOrderID INT,@UseCnt INT,@CaMainID INT
  21080. OPEN cur_OrderInfo
  21081. FETCH NEXT FROM cur_OrderInfo INTO @RowNo,@CaOrderID, @UseCnt, @CaMainID
  21082. WHILE @@FETCH_STATUS = 0
  21083. BEGIN
  21084. UPDATE CaOrder
  21085. SET RemainAssessReportQuota = RemainAssessReportQuota + @UseCnt
  21086. WHERE ID = @CaOrderID
  21087. UPDATE #T
  21088. SET RemainCnt = (
  21089. SELECT SUM(RemainAssessReportQuota)
  21090. FROM CaOrder WITH(NOLOCK)
  21091. WHERE cpMainID = (SELECT TOP 1 CpMainID FROM CaMain WITH(NOLOCK) WHERE ID = @CaMainID)
  21092. AND RemainAssessReportQuota > 0
  21093. AND BeginDate < GETDATE()
  21094. AND EndDate > GETDATE()
  21095. AND IsDeleted = 0
  21096. )
  21097. WHERE RowNo = @RowNo
  21098. FETCH NEXT FROM cur_OrderInfo INTO @RowNo,@CaOrderID, @UseCnt, @CaMainID
  21099. END
  21100. CLOSE cur_OrderInfo
  21101. DEALLOCATE cur_OrderInfo
  21102. INSERT INTO AssessOrderUseLog(CaOrderID,UseCnt,RelateID,RelateType,CaMainID,IP,RemainCnt)
  21103. SELECT CaOrderID,UseCnt,RelateID,RelateType,CaMainID,IP,RemainCnt
  21104. FROM #T
  21105. ORDER BY RemainCnt DESC
  21106. DROP TABLE #T
  21107. END
  21108. GO
  21109. /****** Object: StoredProcedure [dbo].[procAvgSalarySelect] Script Date: 2018/12/13 19:09:25 ******/
  21110. SET ANSI_NULLS ON
  21111. GO
  21112. SET QUOTED_IDENTIFIER ON
  21113. GO
  21114. --#####################################################
  21115. --创建时间:2014.11.03
  21116. --创建人:Nick
  21117. --说明:得到平均工资信息
  21118. --#####################################################
  21119. CREATE PROCEDURE [dbo].[procAvgSalarySelect]
  21120. (
  21121. @RegionID INT,
  21122. @JobTypeID INT,
  21123. @Cnt INT
  21124. )
  21125. AS
  21126. BEGIN TRY
  21127. SELECT dcsalaryid,d.description,CONVERT(decimal(18,1),count(*)/CONVERT(DECIMAL(18,1),@Cnt)*100) pct,count(*) cnt
  21128. FROM job a WITH(NOLOCK),dcsalary d WITH(NOLOCK)
  21129. WHERE d.id=a.dcsalaryid
  21130. AND a.dcjobtypeid = @JobTypeID
  21131. AND a.dcregionid like ''+CONVERT(VARCHAR(6),@RegionID)+'%'
  21132. AND a.dcSalaryID<>100
  21133. AND a.Valid > 0
  21134. AND a.dcSalaryID IS NOT NULL AND a.RefreshDate>GetDate()-365
  21135. GROUP BY a.dcsalaryid, d.description
  21136. ORDER BY a.dcsalaryid
  21137. END TRY
  21138. BEGIN CATCH
  21139. RETURN 0
  21140. END CATCH
  21141. GO
  21142. /****** Object: StoredProcedure [dbo].[ProcBaiduLinkLogSelect] Script Date: 2018/12/13 19:09:25 ******/
  21143. SET ANSI_NULLS ON
  21144. GO
  21145. SET QUOTED_IDENTIFIER ON
  21146. GO
  21147. CREATE PROCEDURE [dbo].[ProcBaiduLinkLogSelect]
  21148. (
  21149. @ProvinceId TINYINT
  21150. )
  21151. AS
  21152. BEGIN
  21153. SELECT TOP 480 *, SPACE(200) Url INTO #T FROM LogDb..BaiduLinkLog WHERE AddSubmitDate IS NULL AND ProvinceID = @ProvinceId
  21154. DECLARE @Site VARCHAR(50)
  21155. SELECT @Site = ProvinceDomain FROM dcProvince WHERE ID = @ProvinceId
  21156. UPDATE #t
  21157. SET Url = 'http://www.' + @Site + '/personal/cp' + SecondId + '.html'
  21158. WHERE cpMainId > 0
  21159. UPDATE #t
  21160. SET Url = 'http://www.' + @Site + '/personal/jb' + SecondId + '.html'
  21161. WHERE JobId > 0
  21162. SELECT Url FROM #t
  21163. UPDATE LogDb..BaiduLinkLog SET AddSubmitDate = GETDATE() WHERE Id IN(SELECT Id FROM #t)
  21164. DROP TABLE #T
  21165. END
  21166. GO
  21167. /****** Object: StoredProcedure [dbo].[procBaiduMapLogByJobIDSelect] Script Date: 2018/12/13 19:09:25 ******/
  21168. SET ANSI_NULLS ON
  21169. GO
  21170. SET QUOTED_IDENTIFIER ON
  21171. GO
  21172. --#####################################################
  21173. --创建时间:2014.11.04
  21174. --创建人:Nick
  21175. --说明:获取职位标注地点
  21176. --#####################################################
  21177. CREATE PROCEDURE [dbo].[procBaiduMapLogByJobIDSelect]
  21178. (
  21179. @JobID VARCHAR(20)
  21180. )
  21181. AS
  21182. BEGIN TRY
  21183. SELECT FullName FROM LogDB..BaiduMapLog WITH(NOLOCK) WHERE JobID=@JobID
  21184. END TRY
  21185. BEGIN CATCH
  21186. RETURN 0
  21187. END CATCH
  21188. GO
  21189. /****** Object: StoredProcedure [dbo].[procBaiduMapLogSelect] Script Date: 2018/12/13 19:09:25 ******/
  21190. SET ANSI_NULLS ON
  21191. GO
  21192. SET QUOTED_IDENTIFIER ON
  21193. GO
  21194. --#####################################################
  21195. --创建时间:2014.11.10
  21196. --创建人:John
  21197. --说明:获取待同步的地图信息
  21198. --#####################################################
  21199. CREATE PROCEDURE [dbo].[procBaiduMapLogSelect]
  21200. AS
  21201. BEGIN
  21202. SELECT TOP 30000 JobId, JobName, Address, cpMainName, Lng, Lat, Salary, JobUrl, cpMainUrl, Status
  21203. FROM BaiduMapLog WITH(NOLOCK) WHERE Status IN(1, 2, 3)
  21204. END
  21205. GO
  21206. /****** Object: StoredProcedure [dbo].[procBaiduMapLogUpdate] Script Date: 2018/12/13 19:09:25 ******/
  21207. SET ANSI_NULLS ON
  21208. GO
  21209. SET QUOTED_IDENTIFIER ON
  21210. GO
  21211. --#####################################################
  21212. --创建时间:2014.11.10
  21213. --创建人:John
  21214. --说明:更新地图信息
  21215. --#####################################################
  21216. CREATE PROCEDURE [dbo].[procBaiduMapLogUpdate]
  21217. (
  21218. @JobID INT
  21219. )
  21220. AS
  21221. BEGIN
  21222. UPDATE BaiduMapLog SET [Status] = 0, UploadDate = GETDATE() WHERE Status IN(1, 2) AND JobID = @JobID
  21223. DELETE BaiduMapLog WHERE Status = 3 AND JobID = @JobID
  21224. END
  21225. GO
  21226. /****** Object: StoredProcedure [dbo].[ProcBaiduSiteFileByExpiredCpMainSelect] Script Date: 2018/12/13 19:09:26 ******/
  21227. SET ANSI_NULLS ON
  21228. GO
  21229. SET QUOTED_IDENTIFIER ON
  21230. GO
  21231. ------------------
  21232. --sean 2013-12-12
  21233. CREATE PROCEDURE [dbo].[ProcBaiduSiteFileByExpiredCpMainSelect]
  21234. (
  21235. @ProvinceId INT
  21236. )
  21237. AS
  21238. BEGIN
  21239. DECLARE @i INT, @Sd DATETIME
  21240. SELECT @i = DATEDIFF(DAY, '2013-12-11', GETDATE()),
  21241. @sd = CONVERT(VARCHAR(10), GETDATE() - @i* 2, 120)
  21242. DELETE BaiduExpiredCpMain WHERE cpMainId IN(SELECT ID FROM cpMain WITH(NOLOCK) WHERE Valid = 1)
  21243. SELECT TOP 0 cpMainId, SecondId INTO #t FROM BaiduExpiredCpMain
  21244. --------7天内受限制的职位
  21245. INSERT #t
  21246. SELECT ID, SecondId
  21247. FROM cpMain WITH(NOLOCK)
  21248. WHERE isLimitlogin = 9
  21249. AND Id in(SELECT cpMainid FROM bsCpstatus WHERE statusId=9 AND AddDate > GETDATE() - 7)
  21250. AND dcProvinceId = @ProvinceID
  21251. -------2天内删除的职位
  21252. INSERT INTO #t
  21253. SELECT Id, SecondID
  21254. FROM company_deleted
  21255. WHERE AddDate > GETDATE() - 2
  21256. AND Province_ID = @ProvinceID
  21257. -------不在CpMain表中的职位
  21258. INSERT INTO #t
  21259. SELECT Id, SecondId
  21260. FROM LogDb..AllCpMainLog
  21261. WHERE Id NOT IN(SELECT Id FROM cpMain WITH(NOLOCK))
  21262. DELETE #t WHERE cpMainId IN (SELECT cpMainId FROM BaiduExpiredCpMain WHERE AddDate < GETDATE() - 1)
  21263. SELECT DISTINCT * INTO #t1 FROM #t
  21264. INSERT BaiduExpiredCpMain
  21265. SELECT DISTINCT *, GETDATE()
  21266. FROM #t
  21267. WHERE cpMainID NOT IN(SELECT cpMainId FROM BaiduExpiredCpMain)
  21268. ORDER BY cpMainId
  21269. SELECT '/personal/cp' + CONVERT(VARCHAR, SecondID) + '.html' Link
  21270. FROM #t1 order by SecondID desc
  21271. END
  21272. GO
  21273. /****** Object: StoredProcedure [dbo].[ProcBaiduSiteFileByExpiredJobSelect] Script Date: 2018/12/13 19:09:26 ******/
  21274. SET ANSI_NULLS ON
  21275. GO
  21276. SET QUOTED_IDENTIFIER ON
  21277. GO
  21278. --sean 2013-12-12
  21279. CREATE PROCEDURE [dbo].[ProcBaiduSiteFileByExpiredJobSelect]
  21280. (
  21281. @ProvinceId INT
  21282. )
  21283. AS
  21284. BEGIN
  21285. DECLARE @i INT, @Sd DATETIME
  21286. SELECT @i = DATEDIFF(DAY, '2013-12-11', GETDATE()),
  21287. @sd = CONVERT(VARCHAR(10), GETDATE() - @i* 2, 120)
  21288. DELETE BaiduExpiredJob WHERE JobId IN(
  21289. SELECT a.ID FROM Job a WITH(NOLOCK), cpMain b WITH(NOLOCK)
  21290. WHERE a.cpMainId = b.Id
  21291. AND a.Valid = 1 AND b.Valid = 1)
  21292. SELECT TOP 0 * INTO #t FROM BaiduExpiredJob
  21293. --------7天内受限制的职位
  21294. INSERT #t
  21295. SELECT a.ID, a.SecondId, GETDATE()
  21296. FROM Job a WITH(NOLOCK),
  21297. cpMain b WITH(NOLOCK)
  21298. WHERE a.cpMainid = b.id
  21299. AND b.isLimitlogin = 9
  21300. AND b.Id in(SELECT cpMainid FROM bsCpstatus WHERE statusId=9 AND AddDate > GETDATE() - 7)
  21301. AND b.dcProvinceId = @ProvinceID
  21302. -------2天内删除的职位
  21303. INSERT INTO #t
  21304. SELECT JobId, SecondID, GETDATE()
  21305. FROM JobDeleted
  21306. WHERE DeleteDate > @sd
  21307. AND ProvinceID = @ProvinceID
  21308. -------不在Job表中的职位
  21309. INSERT INTO #t
  21310. SELECT JobId, JobSecondId, GETDATE() FROM LogDb..AllJobLog WHERE JobId NOT IN(SELECT Id FROM Job WITH(NOLOCK))
  21311. DELETE #t WHERE JobId IN (SELECT JobId FROM BaiduExpiredJob WHERE AddDate < GETDATE() - 1)
  21312. SELECT DISTINCT * INTO #t1 FROM #t
  21313. INSERT BaiduExpiredJob
  21314. SELECT DISTINCT * FROM #t
  21315. WHERE JobId NOT IN(SELECT JobId FROM BaiduExpiredJob)
  21316. ORDER BY JobId
  21317. DELETE LogDb..AllJobLog WHERE JobId IN(SELECT JobId FROM #t)
  21318. SELECT '/personal/jb' + CONVERT(VARCHAR, SecondID) + '.html' Link
  21319. FROM #t order by SecondID desc
  21320. END
  21321. GO
  21322. /****** Object: StoredProcedure [dbo].[ProcBaiduSiteFileByExpiredSelect] Script Date: 2018/12/13 19:09:26 ******/
  21323. SET ANSI_NULLS ON
  21324. GO
  21325. SET QUOTED_IDENTIFIER ON
  21326. GO
  21327. --sean 2013-12-12
  21328. CREATE PROCEDURE [dbo].[ProcBaiduSiteFileByExpiredSelect]
  21329. (
  21330. @ProvinceId INT
  21331. )
  21332. AS
  21333. BEGIN
  21334. --SELECT TOP 0 NULL Link
  21335. --RETURN
  21336. DECLARE @i INT, @Sd DATETIME
  21337. SELECT @i = DATEDIFF(DAY, '2013-12-11', GETDATE()),
  21338. @sd = CONVERT(VARCHAR(10), GETDATE() - @i* 2, 120)
  21339. DELETE BaiduExpiredJob WHERE JobId IN(
  21340. SELECT a.ID FROM Job a WITH(NOLOCK), cpMain b WITH(NOLOCK)
  21341. WHERE a.cpMainId = b.Id
  21342. AND a.Valid = 1 AND b.Valid = 1)
  21343. SELECT TOP 0 * INTO #t FROM BaiduExpiredJob
  21344. --------7天内受限制的职位
  21345. INSERT #t
  21346. SELECT a.ID, a.SecondId, GETDATE()
  21347. FROM Job a WITH(NOLOCK),
  21348. cpMain b WITH(NOLOCK)
  21349. WHERE a.cpMainid = b.id
  21350. AND b.isLimitlogin = 9
  21351. AND b.Id in(SELECT cpMainid FROM bsCpstatus WHERE statusId=9 AND AddDate > GETDATE() - 7)
  21352. AND b.dcProvinceId = @ProvinceID
  21353. -------2天内删除的职位
  21354. INSERT INTO #t
  21355. SELECT JobId, SecondID, GETDATE()
  21356. FROM JobDeleted
  21357. WHERE DeleteDate > @sd
  21358. AND ProvinceID = @ProvinceID
  21359. -------不在Job表中的职位
  21360. INSERT INTO #t
  21361. SELECT JobId, JobSecondId, GETDATE() FROM LogDb..AllJobLog WHERE JobId NOT IN(SELECT Id FROM Job WITH(NOLOCK))
  21362. DELETE #t WHERE JobId IN (SELECT JobId FROM BaiduExpiredJob WHERE AddDate < GETDATE() - 1)
  21363. SELECT DISTINCT * INTO #t1 FROM #t
  21364. INSERT BaiduExpiredJob
  21365. SELECT DISTINCT * FROM #t
  21366. WHERE JobId NOT IN(SELECT JobId FROM BaiduExpiredJob)
  21367. ORDER BY JobId
  21368. DELETE LogDb..AllJobLog WHERE JobId IN(SELECT JobId FROM #t)
  21369. SELECT '/personal/jb' + CONVERT(VARCHAR, SecondID) + '.html' Link
  21370. FROM #t order by SecondID desc
  21371. END
  21372. GO
  21373. /****** Object: StoredProcedure [dbo].[ProcBaiduSiteFileCompanySelect] Script Date: 2018/12/13 19:09:26 ******/
  21374. SET ANSI_NULLS ON
  21375. GO
  21376. SET QUOTED_IDENTIFIER ON
  21377. GO
  21378. --++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  21379. --sean 2014-2-27 update,modify secondid
  21380. --++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  21381. CREATE PROCEDURE [dbo].[ProcBaiduSiteFileCompanySelect]
  21382. (
  21383. @SiteId INT
  21384. )
  21385. AS
  21386. BEGIN
  21387. IF EXISTS(SELECT 'x' FROM dcSubSite WHERE IsMainSite = 1 AND ID = @SiteId)
  21388. BEGIN
  21389. IF @SiteId < 99
  21390. BEGIN
  21391. SELECT TOP 50000 '/personal/cp' + SecondId + '.html' link FROM CpMainPublish WITH(NOLOCK)
  21392. WHERE Valid>0 --AND RefreshDate > CONVERT(varchar(10),GetDate(),120)
  21393. AND dcRegionID LIKE LTRIM(STR(@SiteId)) + '%'
  21394. AND SecondId IN(SELECT PageId FROM MarketDb..PageBaiduInclude WITH(NOLOCK) WHERE IncludeDate IS NULL)
  21395. END
  21396. ELSE
  21397. BEGIN
  21398. SELECT TOP 50000 '/personal/cp' + SecondId + '.html' link FROM CpMainPublish WITH(NOLOCK)
  21399. WHERE Valid>0 --AND RefreshDate > CONVERT(varchar(10),GetDate(),120)
  21400. AND dcRegionID LIKE LTRIM(STR(@SiteId)) + '%'
  21401. AND SecondId IN(SELECT PageId FROM MarketDb..PageBaiduInclude WITH(NOLOCK) WHERE IncludeDate IS NULL)
  21402. END
  21403. END
  21404. ELSE
  21405. BEGIN
  21406. IF @SiteId LIKE '35__'
  21407. BEGIN
  21408. SELECT TOP 50000 '/personal/cp' + SecondId + '.html' link FROM CpMain WITH(NOLOCK)
  21409. WHERE Valid>0 AND RefreshDate > CONVERT(varchar(10), GetDate(),120) AND dcProvinceID=LEFT(@SiteId, 2)
  21410. AND SecondId IN(SELECT PageId FROM MarketDb..PageBaiduInclude WITH(NOLOCK) WHERE IncludeDate IS NULL)
  21411. UNION
  21412. SELECT TOP 50000 '/corp/cp-' + SecondId + '.html' link FROM CpMain WITH(NOLOCK)
  21413. WHERE Valid>0 AND RefreshDate > CONVERT(varchar(10), GetDate(),120) AND dcProvinceID=LEFT(@SiteId, 2)
  21414. AND SecondId IN(SELECT PageId FROM MarketDb..PageBaiduInclude WITH(NOLOCK) WHERE IncludeDate IS NULL)
  21415. END
  21416. ELSE
  21417. BEGIN
  21418. SELECT TOP 50000 '/personal/cp' + SecondId + '.html' link FROM CpMainPublish WITH(NOLOCK)
  21419. WHERE Valid>0 --AND RefreshDate>CONVERT(varchar(10),GetDate(),120) AND dcProvinceID=LEFT(@SiteId, 2)
  21420. AND dcRegionID LIKE LTRIM(STR(@SiteId)) + '%'
  21421. AND SecondId IN(SELECT PageId FROM MarketDb..PageBaiduInclude WITH(NOLOCK) WHERE IncludeDate IS NULL)
  21422. END
  21423. END
  21424. END
  21425. GO
  21426. /****** Object: StoredProcedure [dbo].[ProcBaiduSiteFileCpJobSelect] Script Date: 2018/12/13 19:09:26 ******/
  21427. SET ANSI_NULLS ON
  21428. GO
  21429. SET QUOTED_IDENTIFIER ON
  21430. GO
  21431. --++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  21432. --sean 2014-2-27 update,modify secondid
  21433. --++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  21434. CREATE PROCEDURE [dbo].[ProcBaiduSiteFileCpJobSelect]
  21435. (
  21436. @SiteId INT
  21437. )
  21438. AS
  21439. BEGIN
  21440. IF EXISTS(SELECT 'x' FROM dcSubSite WHERE IsMainSite = 1 AND ID = @SiteId)
  21441. BEGIN
  21442. IF @SiteId < 99
  21443. BEGIN
  21444. SELECT TOP 50000 '/personal/cpjob' + SecondId + '.html' link
  21445. FROM CpMainPublish WITH(NOLOCK)
  21446. WHERE Valid > 0 --AND RefreshDate > CONVERT(varchar(10),GetDate(),120)
  21447. AND dcRegionID LIKE LTRIM(STR(@SiteId)) + '%'
  21448. AND SecondId IN(SELECT PageId FROM MarketDb..PageBaiduInclude WITH(NOLOCK) WHERE IncludeDate IS NULL)
  21449. END
  21450. ELSE
  21451. BEGIN
  21452. SELECT TOP 50000 '/personal/cpJob' + SecondId + '.html' link FROM CpMainPublish WITH(NOLOCK)
  21453. WHERE Valid > 0 --AND RefreshDate > CONVERT(varchar(10),GetDate(),120)
  21454. AND dcRegionID LIKE LTRIM(STR(@SiteId)) + '%'
  21455. AND SecondId IN(SELECT PageId FROM MarketDb..PageBaiduInclude WITH(NOLOCK) WHERE IncludeDate IS NULL)
  21456. END
  21457. END
  21458. ELSE
  21459. BEGIN
  21460. SELECT TOP 50000 '/personal/cpjob' + SecondId + '.html' link FROM CpMainPublish WITH(NOLOCK)
  21461. WHERE Valid > 0 --AND RefreshDate>CONVERT(varchar(10),GetDate(),120) AND dcProvinceID=LEFT(@SiteId, 2)
  21462. AND dcRegionID LIKE LTRIM(STR(@SiteId)) + '%'
  21463. AND SecondId IN(SELECT PageId FROM MarketDb..PageBaiduInclude WITH(NOLOCK) WHERE IncludeDate IS NULL)
  21464. END
  21465. END
  21466. GO
  21467. /****** Object: StoredProcedure [dbo].[ProcBaiduSiteFileJobSelect] Script Date: 2018/12/13 19:09:27 ******/
  21468. SET ANSI_NULLS ON
  21469. GO
  21470. SET QUOTED_IDENTIFIER ON
  21471. GO
  21472. CREATE PROCEDURE [dbo].[ProcBaiduSiteFileJobSelect]
  21473. (
  21474. @SiteId INT
  21475. )
  21476. AS
  21477. BEGIN
  21478. CREATE TABLE #t(ID INT, SecondId VARCHAR(12))
  21479. IF EXISTS(SELECT 'x' FROM dcSubSite WHERE IsMainSite = 1 AND ID = @SiteId)
  21480. BEGIN
  21481. IF @SiteId < 99
  21482. BEGIN
  21483. INSERT INTO #t
  21484. SELECT a.Id, a.SecondId
  21485. FROM Job a, cpMain b
  21486. WHERE a.cpMainID = b.ID
  21487. AND a.Valid>0 AND a.RefreshDate > CONVERT(VARCHAR(10), GETDATE(), 120)
  21488. AND b.dcProvinceID = @SiteId
  21489. DELETE #t WHERE SecondId IN(SELECT PageId FROM MarketDb..PageBaiduInclude WITH(NOLOCK) WHERE IncludeDate IS NOT NULL)
  21490. SELECT TOP 50000 '/personal/jb' + SecondID + '.html' link
  21491. FROM Job
  21492. WHERE ID IN(SELECT ID FROM #t)
  21493. END
  21494. ELSE
  21495. BEGIN
  21496. INSERT INTO #t
  21497. SELECT a.Id, a.SecondId
  21498. FROM Job a, cpMain b
  21499. WHERE a.cpMainID = b.ID
  21500. AND a.Valid>0 AND a.RefreshDate > CONVERT(VARCHAR(10), GETDATE(), 120)
  21501. AND b.dcSubSiteID = @SiteId
  21502. DELETE #t WHERE SecondId IN(SELECT PageId FROM MarketDb..PageBaiduInclude WITH(NOLOCK) WHERE IncludeDate IS NOT NULL)
  21503. SELECT TOP 50000 '/personal/jb' + SecondID + '.html' link
  21504. FROM Job
  21505. WHERE ID IN(SELECT ID FROM #t)
  21506. END
  21507. END
  21508. ELSE
  21509. BEGIN
  21510. IF @SiteId LIKE '35__'
  21511. BEGIN
  21512. INSERT INTO #t
  21513. SELECT a.Id, a.SecondId
  21514. FROM Job a, cpMain b
  21515. WHERE a.cpMainID = b.ID
  21516. AND a.Valid > 0 AND a.RefreshDate > CONVERT(VARCHAR(10), GETDATE(), 120)
  21517. AND b.dcProvinceID = LEFT(@SiteId, 2)
  21518. DELETE #t WHERE SecondId IN(SELECT PageId FROM MarketDb..PageBaiduInclude WITH(NOLOCK) WHERE IncludeDate IS NOT NULL)
  21519. SELECT TOP 50000 '/personal/jb' + SecondID + '.html' link
  21520. FROM Job
  21521. WHERE ID IN(SELECT ID FROM #t)
  21522. UNION
  21523. SELECT TOP 50000 '/Job/jb-' + SecondID + '.html' link
  21524. FROM Job
  21525. WHERE ID IN(SELECT ID FROM #t)
  21526. END
  21527. ELSE
  21528. BEGIN
  21529. INSERT INTO #t
  21530. SELECT a.Id, a.SecondId
  21531. FROM Job a, cpMain b
  21532. WHERE a.cpMainID = b.ID
  21533. AND a.Valid>0 AND a.RefreshDate > CONVERT(VARCHAR(10), GETDATE(), 120)
  21534. AND b.dcProvinceID = LEFT(@SiteId, 2)
  21535. DELETE #t WHERE SecondId IN(SELECT PageId FROM MarketDb..PageBaiduInclude WITH(NOLOCK) WHERE IncludeDate IS NOT NULL)
  21536. SELECT TOP 50000 '/personal/jb' + SecondID + '.html' link
  21537. FROM Job
  21538. WHERE ID IN(SELECT ID FROM #t)
  21539. END
  21540. END
  21541. END
  21542. GO
  21543. /****** Object: StoredProcedure [dbo].[ProcBaiduSubSiteByUrlSelect] Script Date: 2018/12/13 19:09:27 ******/
  21544. SET ANSI_NULLS ON
  21545. GO
  21546. SET QUOTED_IDENTIFIER ON
  21547. GO
  21548. --#####################################################
  21549. --创建时间:2014.10.28
  21550. --创建人:John
  21551. --说明:获取网站站点数据 用于百度数据
  21552. --@subSiteUrl 网站Url
  21553. --#####################################################
  21554. CREATE PROCEDURE [dbo].[ProcBaiduSubSiteByUrlSelect]
  21555. (
  21556. @subSiteUrl VARCHAR(50)
  21557. )
  21558. AS
  21559. BEGIN TRY
  21560. SELECT id, SecondSiteName WebSite, SubSiteUrl Domain
  21561. FROM dcSubSite WITH(NOLOCK)
  21562. WHERE SubSiteUrl = @subSiteUrl
  21563. END TRY
  21564. BEGIN CATCH
  21565. RETURN 0
  21566. END CATCH
  21567. GO
  21568. /****** Object: StoredProcedure [dbo].[ProcBaiduXmlBy51rcSelect] Script Date: 2018/12/13 19:09:27 ******/
  21569. SET ANSI_NULLS ON
  21570. GO
  21571. SET QUOTED_IDENTIFIER ON
  21572. GO
  21573. CREATE PROCEDURE [dbo].[ProcBaiduXmlBy51rcSelect]
  21574. AS
  21575. SET NOCOUNT ON
  21576. BEGIN
  21577. SELECT * FROM ShortDb..BaiduXmlJob51rcOut ORDER By RefreshDate DESC
  21578. END
  21579. GO
  21580. /****** Object: StoredProcedure [dbo].[ProcBaiduXMLByAllSelect] Script Date: 2018/12/13 19:09:27 ******/
  21581. SET ANSI_NULLS ON
  21582. GO
  21583. SET QUOTED_IDENTIFIER ON
  21584. GO
  21585. --------------------------------------------------
  21586. --创建人:SEAN
  21587. --创建日期:2016-09-06
  21588. --功能说明:查询生成百度XML全部数据
  21589. --------------------------------------------------
  21590. CREATE PROCEDURE [dbo].[ProcBaiduXMLByAllSelect]
  21591. (
  21592. @dcProvinceID SMALLINT,
  21593. @ServerId SMALLINT
  21594. )
  21595. AS
  21596. SET NOCOUNT ON
  21597. IF @ServerId IS NULL
  21598. SET @ServerId = 99
  21599. IF @dcProvinceID IS NULL
  21600. RETURN
  21601. BEGIN
  21602. DECLARE @PageNo SMALLINT, @GetRows INT, @BeginJobId INT, @PageCount INT,
  21603. @AddDate DATETIME, @Id INT, @CurrentStatus TINYINT, @MaxJobId INT,
  21604. @PageRows INT
  21605. SELECT @PageRows = 1500
  21606. SELECT @Id = Id, @PageNo = PageNo, @BeginJobId = BeginJobId, @PageCount = [PageCount],
  21607. @AddDate = AddDate, @CurrentStatus = CurrentStatus, @GetRows = GetRows
  21608. FROM LogDb..BaiduXmlRunLog WITH(NOLOCK)
  21609. WHERE ServerID = @ServerID
  21610. AND dcProvinceID = @dcProvinceID
  21611. IF @PageNo IS NULL OR @AddDate < DATEADD(HOUR, -4, GETDATE())
  21612. BEGIN
  21613. DELETE FROM LogDb..BaiduXmlRunLog WHERE Id = @Id
  21614. SELECT TOP 1 @MaxJobId = RowNo + 10 FROM Shortdb..BaiduXMLJobOut WITH(NOLOCK) ORDER BY RowNo DESC
  21615. SELECT @PageNo = 1, @CurrentStatus = 0, @BeginJobId = @MaxJobId, @CurrentStatus = 0, @GetRows = NULL
  21616. INSERT INTO Logdb..BaiduXmlRunLog(ServerId, dcProvinceId, PageNo, BeginJobId, CurrentStatus, AddDate)
  21617. SELECT @ServerId, @dcProvinceID, @PageNo, @BeginJobId, @CurrentStatus, GETDATE()
  21618. END
  21619. IF @CurrentStatus = 10
  21620. BEGIN
  21621. SELECT TOP 0 * FROM LogDb..BaiduXmlRunLog
  21622. RETURN
  21623. END
  21624. IF @CurrentStatus = 2
  21625. BEGIN
  21626. SELECT * FROM LogDb..BaiduXmlRunLog WHERE Id = @Id
  21627. RETURN
  21628. END
  21629. --判断最后一次是否成功
  21630. IF @CurrentStatus = 1
  21631. BEGIN
  21632. IF @GetRows = @PageRows
  21633. UPDATE LogDb..BaiduXmlRunLog
  21634. SET CurrentStatus = 0, GetRows = 0, PageNo = PageNo + 1
  21635. WHERE Id = @Id
  21636. ELSE
  21637. UPDATE LogDb..BaiduXmlRunLog
  21638. SET CurrentStatus = 0, GetRows = 0
  21639. WHERE Id = @Id
  21640. END
  21641. SELECT @Id = Id, @PageNo = PageNo, @BeginJobId = BeginJobId,
  21642. @AddDate = AddDate, @CurrentStatus = CurrentStatus, @PageCount = [PageCount]
  21643. FROM LogDb..BaiduXmlRunLog WITH(NOLOCK)
  21644. WHERE ServerID = @ServerID
  21645. AND dcProvinceID = @dcProvinceID
  21646. --------------------------------------
  21647. CREATE TABLE #t
  21648. (
  21649. id int,
  21650. jobname nvarchar(80),
  21651. JobDESC varchar(max),
  21652. JobDemand varchar(max),
  21653. jobregion varchar(6),
  21654. companyname varchar(100),
  21655. edulevel tinyint,
  21656. IsDelete bit,
  21657. experiencelevel tinyint,
  21658. AnnounceDate datetime,
  21659. dcSalaryID tinyint,
  21660. dcjobtypeID smallint,
  21661. ShortName varchar(40),
  21662. Address nvarchar(100),
  21663. dcCompanySizeID tinyint,
  21664. Brief varchar(6000),
  21665. EmployType tinyint,
  21666. adddate smalldatetime,
  21667. dcCompanyKindID smallint,
  21668. enddate smalldatetime,
  21669. email varchar(50),
  21670. EnJobID varchar(12),
  21671. EnCpMainID varchar(10),
  21672. IndustryId smallint,
  21673. SubSiteUrl varchar(50),
  21674. SubSiteName varchar(50),
  21675. NeedNumber nvarchar(10),
  21676. Welfare1 bit,
  21677. Welfare2 bit,
  21678. Welfare3 bit,
  21679. Welfare4 bit,
  21680. Welfare5 bit,
  21681. Welfare6 bit,
  21682. Welfare7 bit,
  21683. Welfare8 bit,
  21684. Welfare9 bit,
  21685. Welfare10 bit,
  21686. Welfare11 bit,
  21687. Welfare12 bit,
  21688. Welfare13 bit,
  21689. Welfare14 bit,
  21690. Welfare15 bit,
  21691. Welfare16 bit,
  21692. Welfare17 bit,
  21693. Welfare18 bit,
  21694. RowNo int,
  21695. IsVip BIt
  21696. )
  21697. IF @dcProvinceID = 32 AND @ServerId > 900
  21698. BEGIN
  21699. IF @PageCount = 0
  21700. BEGIN
  21701. SELECT @PageCount = (COUNT(*) - 1) / @PageRows + 1
  21702. FROM ShortDb..BaiduXMLJobOut WITH(NOLOCK)
  21703. WHERE SiteId = @dcProvinceID AND RowNo > 0
  21704. UPDATE LogDb..BaiduXmlRunLog SET PageCount = @PageCount WHERE Id = @Id
  21705. END
  21706. INSERT INTO #t
  21707. SELECT TOP (@PageRows) id, jobname, JobDESC, JobDemand, jobregion, companyname, edulevel, IsDelete,
  21708. experiencelevel, AnnounceDate, dcSalaryID, dcjobtypeID, ShortName, Address, dcCompanySizeID, Brief,
  21709. EmployType, adddate, dcCompanyKindID, enddate, email, EnJobID, EnCpMainID,
  21710. IndustryId, SubSiteUrl, SubSiteName, NeedNumber, Welfare1, Welfare2, Welfare3, Welfare4, Welfare5,
  21711. Welfare6, Welfare7, Welfare8, Welfare9, Welfare10, Welfare11, Welfare12, Welfare13, Welfare14,
  21712. Welfare15, Welfare16, Welfare17, Welfare18, RowNo
  21713. FROM ShortDb..BaiduXMLJobOut WITH(NOLOCK)
  21714. WHERE SiteId = @dcProvinceID
  21715. AND RowNo < @BeginJobId
  21716. ORDER BY RowNo DESC
  21717. END
  21718. ELSE
  21719. BEGIN
  21720. IF @PageCount = 0
  21721. BEGIN
  21722. SELECT @PageCount = (COUNT(*) - 1) / @PageRows + 1
  21723. FROM ShortDb..BaiduXMLJobOut WITH(NOLOCK)
  21724. WHERE SiteId = @dcProvinceID AND RowNo > 0
  21725. UPDATE LogDb..BaiduXmlRunLog SET [PageCount] = @PageCount WHERE Id = @Id
  21726. END
  21727. INSERT INTO #t
  21728. SELECT TOP (@PageRows) id, jobname, JobDESC, JobDemand, jobregion, companyname, edulevel, IsDelete,
  21729. experiencelevel, AnnounceDate, dcSalaryID, dcjobtypeID, ShortName, Address, dcCompanySizeID, Brief,
  21730. EmployType, adddate, dcCompanyKindID, enddate, email, EnJobID, EnCpMainID,
  21731. IndustryId, SubSiteUrl, SubSiteName, NeedNumber, Welfare1, Welfare2, Welfare3, Welfare4, Welfare5,
  21732. Welfare6, Welfare7, Welfare8, Welfare9, Welfare10, Welfare11, Welfare12, Welfare13, Welfare14,
  21733. Welfare15, Welfare16, Welfare17, Welfare18, RowNo, IsVip
  21734. FROM ShortDb..BaiduXMLJobOut WITH(NOLOCK)
  21735. WHERE SiteId = @dcProvinceID
  21736. AND RowNo < @BeginJobId
  21737. ORDER BY RowNo DESC
  21738. END
  21739. UPDATE #t SET EndDate = GETDATE() + 10 WHERE EndDate < GETDATE() + 1
  21740. DECLARE @JobCount INT
  21741. SELECT @JobCount = COUNT(1) FROM #T
  21742. IF @JobCount > 0
  21743. BEGIN
  21744. DECLARE @MinJobID INT
  21745. SELECT @MinJobID = MIN(RowNo) FROM #T
  21746. UPDATE LogDb..BaiduXmlRunLog
  21747. SET EndJobId = @MinJobID, GetRows = @JobCount, LastRunDate = GETDATE()
  21748. WHERE Id = @Id
  21749. SELECT *
  21750. FROM Logdb..BaiduXmlRunLog WITH(NOLOCK)
  21751. WHERE id = @id
  21752. SELECT * FROM #T
  21753. END
  21754. ELSE
  21755. BEGIN
  21756. UPDATE LogDb..BaiduXmlRunLog
  21757. SET CurrentStatus = 2, LastRunDate = GETDATE()
  21758. WHERE Id = @Id
  21759. SELECT *
  21760. FROM LogDb..BaiduXmlRunLog WITH(NOLOCK)
  21761. WHERE Id = @Id
  21762. END
  21763. DROP TABLE #T
  21764. END
  21765. GO
  21766. /****** Object: StoredProcedure [dbo].[ProcBaiduXmlByNewstSelect] Script Date: 2018/12/13 19:09:28 ******/
  21767. SET ANSI_NULLS ON
  21768. GO
  21769. SET QUOTED_IDENTIFIER ON
  21770. GO
  21771. --获取10分钟内的数据
  21772. CREATE PROCEDURE [dbo].[ProcBaiduXmlByNewstSelect]
  21773. (
  21774. @SiteId INT
  21775. )
  21776. AS
  21777. SET NOCOUNT ON
  21778. BEGIN
  21779. CREATE TABLE #t
  21780. (
  21781. RowNo INT IDENTITY(1, 1),
  21782. [Id] [int] NOT NULL,
  21783. [JobName] [nvarchar](80) NOT NULL,
  21784. [JobDESC] [varchar](max) NOT NULL,
  21785. [JobDemand] [varchar](max) NOT NULL,
  21786. [JobRegion] [varchar](6) NULL,
  21787. [CompanyName] [varchar](100) NOT NULL,
  21788. [EduLevel] [tinyint] NOT NULL,
  21789. [IsDelete] [bit] NOT NULL,
  21790. [ExperienceLevel] [tinyint] NOT NULL,
  21791. [Announcedate] [datetime] NOT NULL,
  21792. [dcSalaryID] [tinyint] NOT NULL,
  21793. [dcJobtypeID] [smallint] NOT NULL,
  21794. [ShortName] [varchar](40) NULL,
  21795. [Address] [nvarchar](100) NULL,
  21796. [dcCompanySizeID] [tinyint] NULL,
  21797. [Brief] [varchar](6000) NULL,
  21798. [EmployType] [tinyint] NOT NULL,
  21799. [AddDate] [smalldatetime] NOT NULL,
  21800. [dcCompanyKindID] [smallint] NULL,
  21801. [EndDate] [smalldatetime] NULL,
  21802. [Email] [varchar](50) NOT NULL,
  21803. [EnJobID] [varchar](12) NULL,
  21804. [EnCpMainID] [varchar](10) NULL,
  21805. [IndustryId] [smallint] NULL,
  21806. [SubSiteUrl] [varchar](50) NOT NULL,
  21807. [SubSiteName] [varchar](50) NOT NULL,
  21808. NeedNumber VARCHAR(10),
  21809. [Welfare1] [bit] NULL,
  21810. [Welfare2] [bit] NULL,
  21811. [Welfare3] [bit] NULL,
  21812. [Welfare4] [bit] NULL,
  21813. [Welfare5] [bit] NULL,
  21814. [Welfare6] [bit] NULL,
  21815. [Welfare7] [bit] NULL,
  21816. [Welfare8] [bit] NULL,
  21817. [Welfare9] [bit] NULL,
  21818. [Welfare10] [bit] NULL,
  21819. [Welfare11] [bit] NULL,
  21820. [Welfare12] [bit] NULL,
  21821. [Welfare13] [bit] NULL,
  21822. [Welfare14] [bit] NULL,
  21823. [Welfare15] [bit] NULL,
  21824. [Welfare16] [bit] NULL,
  21825. [Welfare17] [bit] NULL,
  21826. [Welfare18] [bit] NULL,
  21827. RegionDesc NVARCHAR(50),
  21828. CompanyRegionId VARCHAR(6),
  21829. IsVip BIT
  21830. )
  21831. DECLARE @SubSiteUrl VARCHAR(100), @SubSiteName VARCHAR(100)
  21832. SELECT @SubSiteUrl = SubSiteUrl, @SubSiteName = SubSiteName
  21833. FROM dcsubsite WITH(NOLOCK)
  21834. WHERE Id = LEFT(@SiteId, 2)
  21835. IF @SiteId > 99
  21836. INSERT INTO #t
  21837. SELECT a.Id, a.Name JobName, a.Responsibility JobDESC, a.Demand JobDemand,
  21838. a.dcRegionId JobRegion, b.Name CompanyName, a.dcEducationID EduLevel, a.IsDelete,
  21839. a.MinExperience ExperienceLevel, GETDATE() Announcedate, --a.RefreshDate Announcedate,
  21840. a.dcSalaryID, a.dcJobtypeID, ISNULL(b.ShortName, b.Name) ShortName, b.Address, dcCompanySizeID, Brief,
  21841. a.EmployType, a.AddDate, b.dcCompanyKindID, a.IssueEnd EndDate, c.Email, a.SecondId EnJobID, b.SecondId EnCpMainID,
  21842. (SELECT TOP 1 dcIndustryId FROM cpIndustry WITH(NOLOCK) WHERE cpIndustry.cpMainID = b.ID) IndustryId,
  21843. @SubSiteUrl SubSiteUrl, @SubSiteName SubSiteName, a.NeedNumber, a.Welfare1, a.Welfare2, a.Welfare3, a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8, a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13, a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18, '',
  21844. b.dcRegionId, CASE WHEN b.MemberType = 3 THEN 1 ELSE 0 END IsVip
  21845. FROM job a WITH(NOLOCK), cpmain b WITH(NOLOCK), camain c WITH(NOLOCK)
  21846. WHERE c.Id = a.caMainId AND a.cpMainId = b.Id
  21847. AND a.Valid = 1 AND b.Valid = 1
  21848. AND IssueEnd > CONVERT(VARCHAR(10), GETDATE() + 1, 120) AND b.VerifyCount > 0
  21849. AND b.dcProvinceID = LEFT(@SiteId, 2)
  21850. AND a.dcRegionId LIKE LTRIM(STR(@SiteId)) + '%'
  21851. AND LEN(RTRIM(a.Name)) > 1
  21852. AND a.LastModifyDate > DATEADD(MINUTe, -10, GETDATE())
  21853. ORDER BY a.RefreshDate DESC
  21854. ELSE
  21855. BEGIN
  21856. IF EXISTS(SELECT 'x' FROM Job WITH(NOLOCK) WHERE dcRegionId LIKE LTRIM(STR(@SiteId)) + '%' AND Valid = 1 AND LastModifyDate > DATEADD(MINUTe, -10, GETDATE()))
  21857. INSERT INTO #t
  21858. SELECT a.id, a.name jobname, a.responsibility JobDESC, a.Demand JobDemand,
  21859. a.dcregionid jobregion, b.name companyname, a.dcEducationID edulevel, a.IsDelete,
  21860. a.MinExperience experiencelevel, GETDATE() announcedate,
  21861. a.dcSalaryID, a.dcjobtypeID, ISNULL(b.ShortName, b.Name) ShortName, b.Address, dcCompanySizeID, Brief,
  21862. a.EmployType, a.adddate, b.dcCompanyKindID, a.IssueEnd enddate, c.email, a.SecondId EnJobID, b.SecondId EnCpMainID,
  21863. (SELECT TOP 1 dcIndustryId FROM cpindustry WITH(NOLOCK) WHERE cpindustry.cpMainID = b.ID) IndustryId,
  21864. @SubSiteUrl SubSiteUrl, @SubSiteName SubSiteName, a.NeedNumber, a.Welfare1, a.Welfare2, a.Welfare3, a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8, a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13, a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18, '',
  21865. b.dcREgionId, CASE WHEN b.MemberType = 3 THEN 1 ELSE 0 END IsVip
  21866. FROM job a WITH(NOLOCK), cpmain b WITH(NOLOCK), camain c
  21867. WHERE a.camainid=c.id AND a.cpmainid=b.id AND a.valid=1
  21868. AND issueend>CONVERT(VARCHAR(10), GETDATE()+1, 120)
  21869. AND b.valid=1 AND b.VerifyCount > 0
  21870. AND b.dcprovinceid = @SiteId
  21871. AND LEN(RTRIM(a.name)) > 1
  21872. AND a.dcRegionId LIKE LTRIM(STR(@SiteId)) + '%'
  21873. AND a.LastModifyDate > DATEADD(MINUTe, -15, GETDATE())
  21874. ORDER BY a.RefreshDate DESC
  21875. ELSE
  21876. INSERT INTO #t
  21877. SELECT TOP 20 a.id, a.name jobname, a.responsibility JobDESC, a.Demand JobDemand,
  21878. a.dcregionid jobregion, b.name companyname, a.dcEducationID edulevel, a.IsDelete,
  21879. a.MinExperience experiencelevel, GETDATE() announcedate,
  21880. a.dcSalaryID, a.dcjobtypeID, ISNULL(b.ShortName, b.Name) ShortName, b.Address, dcCompanySizeID, Brief,
  21881. a.EmployType, a.adddate, b.dcCompanyKindID, a.IssueEnd enddate, c.email, a.SecondId EnJobID, b.SecondId EnCpMainID,
  21882. (SELECT TOP 1 dcIndustryId FROM cpindustry WITH(NOLOCK) WHERE cpindustry.cpMainID = b.ID) IndustryId,
  21883. @SubSiteUrl SubSiteUrl, @SubSiteName SubSiteName, a.NeedNumber, a.Welfare1, a.Welfare2, a.Welfare3, a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8, a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13, a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18, '',
  21884. b.dcREgionId, CASE WHEN b.MemberType = 3 THEN 1 ELSE 0 END IsVip
  21885. FROM job a WITH(NOLOCK), cpmain b WITH(NOLOCK), camain c
  21886. WHERE a.camainid=c.id AND a.cpmainid=b.id AND a.valid=1
  21887. AND issueend>CONVERT(VARCHAR(10), GETDATE()+1, 120)
  21888. AND b.valid=1 AND b.VerifyCount > 0
  21889. AND b.dcprovinceid = @SiteId
  21890. AND LEN(RTRIM(a.name)) > 1
  21891. AND a.dcRegionId LIKE LTRIM(STR(@SiteId)) + '%'
  21892. --AND a.LastModifyDate > DATEADD(MINUTe, -10, GETDATE())
  21893. ORDER BY a.LastModifyDate DESC
  21894. END
  21895. ALTER TABLE #t ADD RegionName VARCHAR(50)
  21896. ALTER TABLE #t ADD RegionName2 VARCHAR(50)
  21897. UPDATE a SET a.RegionName = b.Description FROM #t a, dcRegion b WHERE LEFT(a.JobRegion, 4) = b.Id
  21898. UPDATE #t SET RegionName2 = LEFT(RegionName, LEN(RegionName) - 1) WHERE LEN(RegionName) > 2
  21899. UPDATE #t SET JobName = RegionName + JobName WHERE CHARINDEX(RegionName2, JobName) = 0
  21900. UPDATE #t SET JobName = JobName + '招聘' WHERE CHARINDEX('聘', JobName) = 0
  21901. DECLARE @t AS TABLE(Id INT, Description NVARCHAR(110))
  21902. INSERT INTO @t SELECT DetailId, REPLACE(Description, '以上', '') FROM dcOthers WHERE Category = '招聘人数' AND Description NOT LIKE '%~%'
  21903. INSERT INTO @t SELECT DetailId, LEFT(Description, CHARINDEX('~', Description) - 1) + '人' FROM dcOthers WHERE Category = '招聘人数' AND Description LIKE '%~%'
  21904. UPDATE a SET NeedNumber = b.Description FROM #t a, @t b WHERE a.NeedNumber = b.Id
  21905. UPDATE #t
  21906. SET JobDesc = REPLACE(JobDesc, ' ', ''),
  21907. JobDemand = REPLACE(JobDemand, ' ', ''),
  21908. Brief = REPLACE(Brief, ' ', '')
  21909. WHERE CHARINDEX(' ', JobDesc) > 0
  21910. OR CHARINDEX(' ', JobDemand) > 0
  21911. OR CHARINDEX(' ', Brief) > 0
  21912. UPDATE a
  21913. SET a.RegionDesc = b.FullName
  21914. FROM #t a, MainDb..dcRegion b
  21915. WHERE a.CompanyRegionId = b.Id
  21916. UPDATE #t SET RegionDesc = '' WHERE CHARINDEX(RegionDesc, Address) > 0
  21917. UPDATE #t
  21918. SET Address = RIGHT(Address, LEN(Address) - 3)
  21919. WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
  21920. AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
  21921. UPDATE #t
  21922. SET Address = RIGHT(Address, LEN(Address) - 3)
  21923. WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
  21924. AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
  21925. UPDATE #t
  21926. SET Address = RIGHT(Address, LEN(Address) - 3)
  21927. WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
  21928. AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
  21929. UPDATE #t SET Address = '' WHERE CHARINDEX(Address, RegionDesc) > 0 AND LEN(RegionDesc) > 0
  21930. UPDATE #t SET Address = RegionDesc + Address WHERE LEN(RegionDesc) > 0
  21931. SELECT id, jobname, JobDESC, JobDemand, jobregion, companyname, edulevel, IsDelete,
  21932. experiencelevel, AnnounceDate, dcSalaryID, dcjobtypeID, ShortName, Address, dcCompanySizeID, Brief,
  21933. EmployType, adddate, dcCompanyKindID, enddate, email, EnJobID, EnCpMainID,
  21934. IndustryId, SubSiteUrl, SubSiteName, NeedNumber, Welfare1, Welfare2, Welfare3, Welfare4, Welfare5,
  21935. Welfare6, Welfare7, Welfare8, Welfare9, Welfare10, Welfare11, Welfare12, Welfare13, Welfare14,
  21936. Welfare15, Welfare16, Welfare17, Welfare18, IsVip
  21937. FROM #t ORDER BY RowNo
  21938. END
  21939. GO
  21940. /****** Object: StoredProcedure [dbo].[ProcBaiduXmlJob51rcOutSave] Script Date: 2018/12/13 19:09:29 ******/
  21941. SET ANSI_NULLS ON
  21942. GO
  21943. SET QUOTED_IDENTIFIER ON
  21944. GO
  21945. CREATE PROCEDURE [dbo].[ProcBaiduXmlJob51rcOutSave]
  21946. AS
  21947. SET NOCOUNT ON
  21948. BEGIN
  21949. IF EXISTS(SELECT 'x' FROM ShortDb..BaiduXmlJob51rcOut WHERE crDate > DATEADD(MINUTE, -480, GETDATE()))
  21950. RETURN
  21951. SELECT a.id, a.name jobname, a.responsibility JobDESC, a.Demand JobDemand,
  21952. LEFT(a.dcregionid,4) jobregion, b.name companyname, b.shortName, b.[Address], b.dcCompanySizeID, a.dcEducationID edulevel,
  21953. a.MinExperience experiencelevel, a.IsDelete, a.EmployType, a.adddate,
  21954. a.IssueDate AnnounceDate,
  21955. a.dcSalaryID, a.dcjobtypeID, b.dcCompanyKindID, b.Brief,
  21956. a.IssueEnd enddate, c.email, a.SecondId EnJobID, b.SecondId EnCpMainID,
  21957. (SELECT TOP 1 dcIndustryId FROM cpindustry WITH(NOLOCK) WHERE cpindustry.cpMainID = b.ID) industryid,
  21958. 'www.51rc.com' SubSiteUrl, '伍亿人才网' SubSiteName,
  21959. ISNULL((SELECT PinYin FROM dcRegion WITH(NOLOCK) WHERE dcRegion.id= LEFT(a.dcRegionId, 2)), 'shandong') pinyin,
  21960. SPACE(50) RegionName, SPACE(50) RegionName2, a.Refreshdate
  21961. --ISNULL((SELECT SubSiteUrl FROM dcsubsite WITH(NOLOCK) WHERE dcsubsite.id= LEFT(a.dcregionid, 2)),'www.qlrc.com') SubSiteUrl,
  21962. --ISNULL((SELECT SubSiteName FROM dcsubsite WITH(NOLOCK) WHERE dcsubsite.id= LEFT(a.dcregionid, 2)),'齐鲁人才网') SubSiteName
  21963. INTO #t
  21964. FROM job a WITH(NOLOCK), cpmain b WITH(NOLOCK),camain c
  21965. WHERE a.camainid=c.id AND a.cpmainid=b.id AND a.valid=1
  21966. AND issueend>CONVERT(VARCHAR(10),GETDATE()+1,120) AND b.valid=1 AND b.VerifyCount > 0
  21967. AND LEN(RTRIM(a.name)) > 2
  21968. AND a.Refreshdate > CONVERT(VARCHAR(10), GETDATE() -1, 120)
  21969. AND LEFT(a.dcRegionId, 2) = b.dcProvinceId
  21970. ORDER BY a.RefreshDate DESC
  21971. UPDATE a SET a.RegionName = b.Description FROM #t a, dcRegion b WHERE LEFT(a.JobRegion, 4) = b.Id
  21972. UPDATE #t SET RegionName2 = LEFT(RegionName, LEN(RegionName) - 1) WHERE LEN(RegionName) > 2
  21973. UPDATE #t SET JobName = LEFT(RegionName + JobName, 50) WHERE CHARINDEX(RegionName2, JobName) = 0
  21974. UPDATE #t SET JobName = LEFT(JobName + '招聘', 50) WHERE CHARINDEX('聘', JobName) = 0
  21975. UPDATE #t
  21976. SET Brief = REPLACE(REPLACE(REPLACE(REPLACE(Brief, '&nbsp;', ''), '&lt;', ''), '&gt;', ''), '&#', '')
  21977. WHERE Brief LIKE '%&%'
  21978. UPDATE #t SET Brief = REPLACE(Brief, ' ', '') WHERE Brief LIKE '% %'
  21979. TRUNCATE TABLE ShortDb..BaiduXmlJob51rcOut
  21980. INSERT INTO ShortDb..BaiduXmlJob51rcOut
  21981. SELECT *, GETDATE() FROM #t ORDER By RefreshDate DESC
  21982. END
  21983. GO
  21984. /****** Object: StoredProcedure [dbo].[ProcBaiduXmlOutByAllSave] Script Date: 2018/12/13 19:09:29 ******/
  21985. SET ANSI_NULLS ON
  21986. GO
  21987. SET QUOTED_IDENTIFIER ON
  21988. GO
  21989. CREATE PROCEDURE [dbo].[ProcBaiduXmlOutByAllSave]
  21990. AS
  21991. BEGIN
  21992. TRUNCATE TABLE ShortDb..BaiduXMLJobTemp
  21993. DECLARE @MinId INT
  21994. SELECT TOP 1 @MinId = Id FROM ShortDb..BaiduXMLJobOut WITH(NOLOCK) ORDER BY Id DESC
  21995. INSERT INTO ShortDb..BaiduXMLJobTemp
  21996. SELECT TOP 10000 b.dcProvinceId, a.id, a.Name JobName, a.responsibility JobDESC, a.Demand JobDemand,
  21997. a.dcregionid Jobregion, b.Name companyName, a.dcEducationID eduLevel,
  21998. a.MinExperience experienceLevel, a.IsDELETE, a.EmployType, a.adddate,
  21999. a.IssueDate AnnounceDate,
  22000. a.dcSalaryID, a.dcJobtypeID, b.dcCompanyKindID, ISNULL(b.ShortName, b.Name) ShortName,
  22001. b.Address, dcCompanySizeID, Brief,
  22002. a.IssueEnd enddate, c.email, a.SecondId EnJobID, b.SecondId EncpMainID,
  22003. (SELECT TOP 1 dcIndustryId FROM cpindustry WITH(NOLOCK) WHERE cpindustry.cpMainID = b.ID) IndustryId,
  22004. d.SubSiteUrl, d.SubSiteName, a.RefreshDate RDate, a.NeedNumber, a.Welfare1,
  22005. a.Welfare2, a.Welfare3, a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8, a.Welfare9,
  22006. a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13, a.Welfare14, a.Welfare15, a.Welfare16,
  22007. a.Welfare17, a.Welfare18, '', '', '', b.dcRegionId
  22008. FROM Job a WITH(NOLOCK),
  22009. cpMain b WITH(NOLOCK),
  22010. caMain c WITH(NOLOCK),
  22011. dcSubSite d WITH(NOLOCK)
  22012. WHERE b.dcProvinceId = d.Id
  22013. AND a.caMainid = c.id
  22014. AND a.cpMainid = b.id
  22015. AND LEN(RTRIM(a.Name)) > 1
  22016. AND b.IsDELETE = 0
  22017. AND a.IsDELETE = 0
  22018. AND b.IsLimitLogin < 9
  22019. --AND a.Id > ISNULL(@MinId, 0)
  22020. AND LEFT(a.dcRegionId, 2) = b.dcProvinceId
  22021. AND a.Id NOT IN(SELECT ID FROM ShortDb..BaiduXMLJobOut WITH(NOLOCK))
  22022. AND a.Valid = 1
  22023. AND b.Valid = 1
  22024. ORDER BY a.RefreshDate
  22025. UPDATE ShortDb..BaiduXMLJobTemp
  22026. SET Brief = REPLACE(REPLACE(REPLACE(REPLACE(Brief, '&nbsp;', ''), '&lt;', ''), '&gt;', ''), '&#', '')
  22027. WHERE Brief LIKE '%&%'
  22028. UPDATE ShortDb..BaiduXMLJobTemp SET Brief = REPLACE(Brief, ' ', '') WHERE Brief LIKE '% %'
  22029. UPDATE ShortDb..BaiduXMLJobTemp
  22030. SET JobDesc = REPLACE(JobDesc, ' ', ''),
  22031. JobDemand = REPLACE(JobDemand, ' ', ''),
  22032. Brief = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(Brief, '&nbsp;', ''), ' ', ''), '&lt;', ''), '&gt;', ''), '&#', ''), ' ', '')
  22033. WHERE CHARINDEX(' ', JobDesc) > 0
  22034. OR CHARINDEX(' ', JobDemand) > 0
  22035. OR CHARINDEX(' ', Brief) > 0
  22036. UPDATE a
  22037. SET a.RegionDesc = b.FullName
  22038. FROM ShortDb..BaiduXMLJobTemp a, MainDb..dcRegion b
  22039. WHERE a.CompanyRegionId = b.Id
  22040. UPDATE ShortDb..BaiduXMLJobTemp SET RegionDesc = '' WHERE CHARINDEX(RegionDesc, Address) > 0
  22041. UPDATE ShortDb..BaiduXMLJobTemp
  22042. SET Address = RIGHT(Address, LEN(Address) - 3)
  22043. WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
  22044. AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
  22045. UPDATE ShortDb..BaiduXMLJobTemp
  22046. SET Address = RIGHT(Address, LEN(Address) - 3)
  22047. WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
  22048. AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
  22049. UPDATE ShortDb..BaiduXMLJobTemp
  22050. SET Address = RIGHT(Address, LEN(Address) - 3)
  22051. WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
  22052. AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
  22053. UPDATE ShortDb..BaiduXMLJobTemp SET Address = '' WHERE CHARINDEX(Address, RegionDesc) > 0 AND LEN(RegionDesc) > 0
  22054. UPDATE ShortDb..BaiduXMLJobTemp SET Address = RegionDesc + Address WHERE LEN(RegionDesc) > 0
  22055. UPDATE a SET a.RegionName = b.Description FROM ShortDb..BaiduXMLJobTemp a, dcRegion b WHERE LEFT(a.JobRegion, 4) = b.Id
  22056. UPDATE ShortDb..BaiduXMLJobTemp SET RegionName2 = LEFT(RegionName, LEN(RegionName) - 1) WHERE LEN(RegionName) > 2
  22057. UPDATE ShortDb..BaiduXMLJobTemp SET JobName = LEFT(RegionName + JobName, 50) WHERE CHARINDEX(RegionName2, JobName) = 0
  22058. UPDATE ShortDb..BaiduXMLJobTemp SET JobName = LEFT(JobName + '招聘', 50) WHERE CHARINDEX('聘', JobName) = 0
  22059. DECLARE @t AS TABLE(Id INT, Description NVARCHAR(110))
  22060. INSERT INTO @t SELECT DetailId, REPLACE(Description, '以上', '') FROM dcOthers WHERE Category = '招聘人数' AND Description NOT LIKE '%~%'
  22061. INSERT INTO @t SELECT DetailId, LEFT(Description, CHARINDEX('~', Description) - 1) + '人' FROM dcOthers WHERE Category = '招聘人数' AND Description LIKE '%~%'
  22062. UPDATE a SET NeedNumber = b.Description FROM ShortDb..BaiduXMLJobTemp a, @t b WHERE a.NeedNumber = b.Id
  22063. --TRUNCATE TABLE ShortDb..BaiduXMLJobOut
  22064. DECLARE @Mr INT
  22065. SELECT @Mr = MAX(RowNo) FROM ShortDb..BaiduXMLJobOut
  22066. INSERT INTO ShortDb..BaiduXMLJobOut(SiteId, id, JobName, JobDESC, JobDemand, Jobregion, companyName, eduLevel, IsDELETE,
  22067. experienceLevel, AnnounceDate, dcSalaryID, dcJobtypeID, ShortName, Address, dcCompanySizeID, Brief,
  22068. EmployType, adddate, dcCompanyKindID, enddate, email, EnJobID, EncpMainID,
  22069. IndustryId, SubSiteUrl, SubSiteName, NeedNumber, Welfare1, Welfare2, Welfare3, Welfare4, Welfare5,
  22070. Welfare6, Welfare7, Welfare8, Welfare9, Welfare10, Welfare11, Welfare12, Welfare13, Welfare14,
  22071. Welfare15, Welfare16, Welfare17, Welfare18, crDate, RowNo)
  22072. SELECT SiteId, id, JobName, JobDESC, JobDemand, Jobregion, companyName, eduLevel, IsDELETE,
  22073. experienceLevel, AnnounceDate, dcSalaryID, dcJobtypeID, ShortName, Address, dcCompanySizeID, Brief,
  22074. EmployType, adddate, dcCompanyKindID, enddate, email, EnJobID, EncpMainID,
  22075. IndustryId, SubSiteUrl, SubSiteName, NeedNumber, Welfare1, Welfare2, Welfare3, Welfare4, Welfare5,
  22076. Welfare6, Welfare7, Welfare8, Welfare9, Welfare10, Welfare11, Welfare12, Welfare13, Welfare14,
  22077. Welfare15, Welfare16, Welfare17, Welfare18, GETDATE(), @Mr + RowNo
  22078. FROM ShortDb..BaiduXMLJobTemp
  22079. ORDER BY RDate DESC, id DESC
  22080. DELETE FROM ShortDb..BaiduXMLJobOut WHERE Id IN(SELECT ID FROM Job WITH(NOLOCK) WHERE Id IN(SELECT SubId FROM bsCvModify WHERE AddDate < GETDATE() - 15) AND Valid = 0)
  22081. SELECT id INTO #t FROM ShortDb..BaiduXMLJobOut
  22082. DELETE #t WHERE id in(SELECT id FROM maindb..Job WHERE IsDelete = 0)
  22083. DELETE ShortDb..BaiduXMLJobOut WHERE id IN(SELECT id FROM #t)
  22084. SELECT id INTO #c FROM MainDb..cpMain WHERE (IsDelete = 1 OR islimitlogin = 9 OR Valid = 0)
  22085. SELECT id INTO #j FROM MainDb..Job WHERE cpMainid IN(SELECT id FROM #c)
  22086. DELETE ShortDb..BaiduXMLJobOut WHERE id IN(SELECT id FROM #j)
  22087. -----------==============================
  22088. DELETE FROM ShortDb..BaiduXMLJobOut WHERE Id IN(SELECT Id FROM Job WHERE Issueend < GETDATE() AND cpMainId IN(SELECT cpMainId FROM noshowoldjob))
  22089. SELECT a.id INTO #vj FROM JobPublish a, cpMainPubLish b WHERE a.cpMainId = b.Id AND a.Valid = 1 AND b.Valid = 1
  22090. UPDATE Shortdb..BaiduXMLJobOut
  22091. SET RowNo = Id + 80000000
  22092. WHERE RowNo < 80000000
  22093. AND Id IN(SELECT id FROM #vj)
  22094. CREATE TABLE #JobOrder(id INT, RowNo INT IDENTITY(1, 1))
  22095. INSERT INTO #JobOrder
  22096. SELECT Id FROM Shortdb..BaiduXMLJobOut
  22097. WHERE RowNo > 80000000
  22098. AND Id NOT IN(SELECT id FROM #vj)
  22099. DECLARE @MaxRowNo INT
  22100. SELECT TOP 1 @MaxRowNo = RowNo FROM Shortdb..BaiduXMLJobOut WHERE RowNo < 80000000 ORDER BY ROwNo DESC
  22101. IF @MaxRowNo < 70000000
  22102. BEGIN
  22103. UPDATE a
  22104. SET a.RowNo = @MaxRowNo + b.RowNo
  22105. FROM Shortdb..BaiduXMLJobOut a, #JobOrder b
  22106. WHERE a.Id = b.Id
  22107. END
  22108. ELSE
  22109. BEGIN
  22110. UPDATE a
  22111. SET a.RowNo = @MaxRowNo + b.RowNo
  22112. FROM Shortdb..BaiduXMLJobOut a, #JobOrder b
  22113. WHERE a.Id = b.Id
  22114. TRUNCATE TABLE #JobOrder
  22115. INSERT INTO #JobOrder
  22116. SELECT a.id
  22117. FROM Shortdb..BaiduXMLJobOut a, Job b
  22118. WHERE a.RowNo < 80000000
  22119. AND a.Id = b.Id
  22120. ORDER BY IssueEnd, Id Desc
  22121. --INSERT INTO #JobOrder
  22122. --SELECT Id FROM Shortdb..BaiduXMLJobOut WHERE RowNo < 80000000 ORDER BY ROwNo DESC
  22123. UPDATE a
  22124. SET a.RowNo = b.RowNo
  22125. FROM Shortdb..BaiduXMLJobOut a, #JobOrder b
  22126. WHERE a.Id = b.Id
  22127. END
  22128. /*
  22129. CREATE TABLE #tb(JobId INT, RowNo INT IDENTITY(1, 1))
  22130. CREATE TABLE #tb1(JobId INT, RowNo INT IDENTITY(1, 1))
  22131. INSERT INTO #tb1
  22132. SELECT a.Id
  22133. FROM MainDB..Job a, MainDb..cpMain b, Shortdb..BaiduXMLJobOut c
  22134. WHERE a.Id = c.Id
  22135. AND a.CpMainId = b.Id
  22136. AND a.Valid = 1
  22137. AND b.Valid = 1
  22138. ORDER BY a.IssueDate, a.Id
  22139. INSERT INTO #tb
  22140. SELECT a.Id
  22141. FROM MainDB..Job a, MainDb..cpMain b, Shortdb..BaiduXMLJobOut c
  22142. WHERE a.Id = c.Id
  22143. AND a.CpMainId = b.Id
  22144. AND a.Id NOT IN(SELECT JobId FROM #tb1)
  22145. ORDER BY a.IssueDate, a.Id
  22146. INSERT INTO #tb SELECT JobID FROM #tb1 ORDER BY RowNo
  22147. UPDATE a SET a.RowNo = b.RowNo FROM Shortdb..BaiduXMLJobOut a, #tb b WHERE a.Id = b.JobId
  22148. */
  22149. END
  22150. GO
  22151. /****** Object: StoredProcedure [dbo].[ProcBaiduXmlOutByNewstSave] Script Date: 2018/12/13 19:09:30 ******/
  22152. SET ANSI_NULLS ON
  22153. GO
  22154. SET QUOTED_IDENTIFIER ON
  22155. GO
  22156. CREATE PROCEDURE [dbo].[ProcBaiduXmlOutByNewstSave]
  22157. AS
  22158. SET NOCOUNT ON
  22159. IF (DATEPART(HOUR, GETDATE()) - 7) % 4 > 0
  22160. RETURN
  22161. BEGIN
  22162. SELECT TOP 0 * INTO #t FROM ShortDb..BaiduXMLJobTemp
  22163. INSERT INTO #t
  22164. SELECT b.dcProvinceId, a.id, a.Name JobName, a.responsibility JobDESC, a.Demand JobDemand,
  22165. a.dcregionid Jobregion, b.Name companyName, a.dcEducationID eduLevel,
  22166. a.MinExperience experienceLevel, a.IsDelete, a.EmployType, a.adddate,
  22167. a.IssueDate AnnounceDate,
  22168. a.dcSalaryID, a.dcJobtypeID, b.dcCompanyKindID, ISNULL(b.ShortName, b.Name) ShortName,
  22169. b.Address, dcCompanySizeID, Brief,
  22170. a.IssueEnd enddate, c.email, a.SecondId EnJobID, b.SecondId EncpMainID,
  22171. (SELECT TOP 1 dcIndustryId FROM cpindustry WITH(NOLOCK) WHERE cpindustry.cpMainID = b.ID) IndustryId,
  22172. d.SubSiteUrl, d.SubSiteName, a.RefreshDate RDate, a.NeedNumber, a.Welfare1,
  22173. a.Welfare2, a.Welfare3, a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8, a.Welfare9,
  22174. a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13, a.Welfare14, a.Welfare15, a.Welfare16,
  22175. a.Welfare17, a.Welfare18, '', '', '', b.dcRegionId
  22176. FROM Job a WITH(NOLOCK),
  22177. cpMain b WITH(NOLOCK),
  22178. caMain c WITH(NOLOCK),
  22179. dcSubSite d WITH(NOLOCK)
  22180. WHERE b.dcProvinceId = d.Id
  22181. AND a.caMainid = c.id
  22182. AND a.cpMainid = b.id
  22183. AND LEN(RTRIM(a.Name)) > 1
  22184. AND b.IsDelete = 0
  22185. AND a.IsDelete = 0
  22186. AND b.IsLimitLogin < 9
  22187. AND LEFT(a.dcRegionId, 2) = b.dcProvinceId
  22188. AND (a.LastModifyDate > CONVERT(VARCHAR(10), GETDATE() - 1, 120)
  22189. OR a.IssueEnd BETWEEN CONVERT(VARCHAR(10), GETDATE() - 1, 120) AND GETDATE() + 0.2
  22190. OR a.IssueDate > CONVERT(VARCHAR(10), GETDATE() - 1, 120))
  22191. ORDER BY a.Refreshdate
  22192. UPDATE #t
  22193. SET Brief = REPLACE(REPLACE(REPLACE(REPLACE(Brief, '&nbsp;', ''), '&lt;', ''), '&gt;', ''), '&#', '')
  22194. WHERE Brief LIKE '%&%'
  22195. UPDATE #t SET Brief = REPLACE(Brief, ' ', '') WHERE Brief LIKE '% %'
  22196. UPDATE #t
  22197. SET JobDesc = REPLACE(JobDesc, ' ', ''),
  22198. JobDemand = REPLACE(JobDemand, ' ', ''),
  22199. Brief = REPLACE(Brief, ' ', '')
  22200. WHERE CHARINDEX(' ', JobDesc) > 0
  22201. OR CHARINDEX(' ', JobDemand) > 0
  22202. OR CHARINDEX(' ', Brief) > 0
  22203. UPDATE a
  22204. SET a.RegionDesc = b.FullName
  22205. FROM #t a, MainDb..dcRegion b
  22206. WHERE a.CompanyRegionId = b.Id
  22207. UPDATE #t SET RegionDesc = '' WHERE CHARINDEX(RegionDesc, Address) > 0
  22208. UPDATE #t
  22209. SET Address = RIGHT(Address, LEN(Address) - 3)
  22210. WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
  22211. AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
  22212. UPDATE #t
  22213. SET Address = RIGHT(Address, LEN(Address) - 3)
  22214. WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
  22215. AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
  22216. UPDATE #t
  22217. SET Address = RIGHT(Address, LEN(Address) - 3)
  22218. WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
  22219. AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
  22220. UPDATE #t SET Address = '' WHERE CHARINDEX(Address, RegionDesc) > 0 AND LEN(RegionDesc) > 0
  22221. UPDATE #t SET Address = RegionDesc + Address WHERE LEN(RegionDesc) > 0
  22222. UPDATE a SET a.RegionName = b.Description FROM #t a, dcRegion b WHERE LEFT(a.JobRegion, 4) = b.Id
  22223. UPDATE #t SET RegionName2 = LEFT(RegionName, LEN(RegionName) - 1) WHERE LEN(RegionName) > 2
  22224. UPDATE #t SET JobName = LEFT(RegionName + JobName, 50) WHERE CHARINDEX(RegionName2, JobName) = 0
  22225. UPDATE #t SET JobName = LEFT(JobName + '招聘', 50) WHERE CHARINDEX('聘', JobName) = 0
  22226. DECLARE @t AS TABLE(Id INT, Description NVARCHAR(110))
  22227. INSERT INTO @t SELECT DetailId, REPLACE(Description, '以上', '') FROM dcOthers WHERE Category = '招聘人数' AND Description NOT LIKE '%~%'
  22228. INSERT INTO @t SELECT DetailId, LEFT(Description, CHARINDEX('~', Description) - 1) + '人' FROM dcOthers WHERE Category = '招聘人数' AND Description LIKE '%~%'
  22229. UPDATE a SET NeedNumber = b.Description FROM #t a, @t b WHERE a.NeedNumber = b.Id
  22230. UPDATE #t SET EndDate = DATEADD(MONTH, DATEDIFF(MONTH, EndDate, GETDATE()) + 3, EndDate) WHERE EndDate < CONVERT(VARCHAR(10), GETDATE() + 2, 120)
  22231. UPDATE #t SET EndDate = DATEADD(MONTH, 3, EndDate) WHERE EndDate < CONVERT(VARCHAR(10), GETDATE() + 2, 120)
  22232. UPDATE #t SET EndDate = DATEADD(MONTH, 3, EndDate) WHERE EndDate < CONVERT(VARCHAR(10), GETDATE() + 2, 120)
  22233. UPDATE #t SET AnnounceDate = DATEADD(MONTH, -3, AnnounceDate) WHERE AnnounceDate > GETDATE()
  22234. UPDATE #t SET AnnounceDate = DATEADD(MONTH, -3, AnnounceDate) WHERE AnnounceDate > GETDATE()
  22235. UPDATE #t SET AnnounceDate = DATEADD(MONTH, -3, AnnounceDate) WHERE AnnounceDate > GETDATE()
  22236. DELETE FROM ShortDb..BaiduXMLJobOut WHERE Id IN(SELECT ID FROM #t WITH(NOLOCK))
  22237. DECLARE @Mr INT
  22238. SELECT @Mr = MAX(RowNo) FROM ShortDb..BaiduXMLJobOut
  22239. INSERT INTO ShortDb..BaiduXMLJobOut(SiteId, id, JobName, JobDESC, JobDemand, Jobregion, companyName, eduLevel, IsDelete,
  22240. experienceLevel, AnnounceDate, dcSalaryID, dcJobtypeID, ShortName, Address, dcCompanySizeID, Brief,
  22241. EmployType, adddate, dcCompanyKindID, enddate, email, EnJobID, EncpMainID,
  22242. IndustryId, SubSiteUrl, SubSiteName, NeedNumber, Welfare1, Welfare2, Welfare3, Welfare4, Welfare5,
  22243. Welfare6, Welfare7, Welfare8, Welfare9, Welfare10, Welfare11, Welfare12, Welfare13, Welfare14,
  22244. Welfare15, Welfare16, Welfare17, Welfare18, crDate, RowNo)
  22245. SELECT SiteId, id, JobName, JobDESC, JobDemand, Jobregion, companyName, eduLevel, IsDelete,
  22246. experienceLevel, AnnounceDate, dcSalaryID, dcJobtypeID, ShortName, Address, dcCompanySizeID, Brief,
  22247. EmployType, adddate, dcCompanyKindID, enddate, email, EnJobID, EncpMainID,
  22248. IndustryId, SubSiteUrl, SubSiteName, NeedNumber, Welfare1, Welfare2, Welfare3, Welfare4, Welfare5,
  22249. Welfare6, Welfare7, Welfare8, Welfare9, Welfare10, Welfare11, Welfare12, Welfare13, Welfare14,
  22250. Welfare15, Welfare16, Welfare17, Welfare18, GETDATE(), @Mr + RowNo
  22251. FROM #t
  22252. ORDER BY RowNo
  22253. END
  22254. GO
  22255. /****** Object: StoredProcedure [dbo].[ProcBaiduXmlOutByQlrcSave] Script Date: 2018/12/13 19:09:31 ******/
  22256. SET ANSI_NULLS ON
  22257. GO
  22258. SET QUOTED_IDENTIFIER ON
  22259. GO
  22260. CREATE PROCEDURE [dbo].[ProcBaiduXmlOutByQlrcSave]
  22261. AS
  22262. SET NOCOUNT ON
  22263. IF (DATEPART(HOUR, GETDATE()) - 7) % 4 > 0
  22264. RETURN
  22265. BEGIN
  22266. DECLARE @SiteId INT
  22267. SET @SiteId = 32
  22268. SELECT TOP 0 * INTO #t FROM ShortDb..BaiduXMLJobTemp
  22269. DECLARE @SubSiteUrl VARCHAR(100), @SubSiteName VARCHAR(100)
  22270. SELECT @SubSiteUrl = SubSiteUrl, @SubSiteName = SubSiteName
  22271. FROM dcsubsite WITH(NOLOCK)
  22272. WHERE Id = @SiteId
  22273. INSERT INTO #t
  22274. SELECT @SiteId, a.id, a.name jobname, a.responsibility JobDESC, a.Demand JobDemand,
  22275. a.dcregionid jobregion, b.name companyname, a.dcEducationID edulevel,
  22276. a.MinExperience experiencelevel, a.IsDelete, a.EmployType, a.adddate,
  22277. a.IssueDate AnnounceDate,
  22278. a.dcSalaryID, a.dcjobtypeID, b.dcCompanyKindID, ISNULL(b.ShortName, b.Name) ShortName, b.Address, dcCompanySizeID, Brief,
  22279. a.IssueEnd enddate, c.email, a.SecondId EnJobID, b.SecondId EnCpMainID,
  22280. (SELECT TOP 1 dcIndustryId FROM cpindustry WITH(NOLOCK) WHERE cpindustry.cpMainID = b.ID) IndustryId,
  22281. @SubSiteUrl SubSiteUrl, @SubSiteName SubSiteName, a.RefreshDate RDate, a.NeedNumber, a.Welfare1,
  22282. a.Welfare2, a.Welfare3, a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8, a.Welfare9,
  22283. a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13, a.Welfare14, a.Welfare15, a.Welfare16,
  22284. a.Welfare17, a.Welfare18, '', '', '', b.dcRegionId
  22285. FROM job a WITH(NOLOCK), cpmain b WITH(NOLOCK), camain c
  22286. WHERE a.camainid = c.id AND a.cpmainid = b.id AND a.valid = 1
  22287. AND issueend>CONVERT(VARCHAR(10), GETDATE() + 1, 120)
  22288. AND b.valid = 1 AND b.VerifyCount > 0
  22289. AND b.dcprovinceid = 32
  22290. AND LEN(RTRIM(a.name)) > 1
  22291. AND LEFT(a.dcRegionId, 2) = b.dcProvinceId
  22292. ORDER BY a.Refreshdate DESC
  22293. UPDATE #t
  22294. SET Brief = REPLACE(REPLACE(REPLACE(REPLACE(Brief, '&nbsp;', ''), '&lt;', ''), '&gt;', ''), '&#', '')
  22295. WHERE Brief LIKE '%&%'
  22296. UPDATE #t SET Brief = REPLACE(Brief, ' ', '') WHERE Brief LIKE '% %'
  22297. UPDATE #t
  22298. SET JobDesc = REPLACE(JobDesc, ' ', ''),
  22299. JobDemand = REPLACE(JobDemand, ' ', ''),
  22300. Brief = REPLACE(Brief, ' ', '')
  22301. WHERE CHARINDEX(' ', JobDesc) > 0
  22302. OR CHARINDEX(' ', JobDemand) > 0
  22303. OR CHARINDEX(' ', Brief) > 0
  22304. UPDATE a
  22305. SET a.RegionDesc = b.FullName
  22306. FROM #t a, MainDb..dcRegion b
  22307. WHERE a.CompanyRegionId = b.Id
  22308. UPDATE #t SET RegionDesc = '' WHERE CHARINDEX(RegionDesc, Address) > 0
  22309. UPDATE #t
  22310. SET Address = RIGHT(Address, LEN(Address) - 3)
  22311. WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
  22312. AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
  22313. UPDATE #t
  22314. SET Address = RIGHT(Address, LEN(Address) - 3)
  22315. WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
  22316. AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
  22317. UPDATE #t
  22318. SET Address = RIGHT(Address, LEN(Address) - 3)
  22319. WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
  22320. AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
  22321. UPDATE #t SET Address = '' WHERE CHARINDEX(Address, RegionDesc) > 0 AND LEN(RegionDesc) > 0
  22322. UPDATE #t SET Address = RegionDesc + Address WHERE LEN(RegionDesc) > 0
  22323. UPDATE a SET a.RegionName = b.Description FROM #t a, dcRegion b WHERE LEFT(a.JobRegion, 4) = b.Id
  22324. UPDATE #t SET RegionName2 = LEFT(RegionName, LEN(RegionName) - 1) WHERE LEN(RegionName) > 2
  22325. UPDATE #t SET JobName = LEFT(RegionName + JobName, 50) WHERE CHARINDEX(RegionName2, JobName) = 0
  22326. UPDATE #t SET JobName = LEFT(JobName + '招聘', 50) WHERE CHARINDEX('聘', JobName) = 0
  22327. DECLARE @t AS TABLE(Id INT, Description NVARCHAR(110))
  22328. INSERT INTO @t SELECT DetailId, REPLACE(Description, '以上', '') FROM dcOthers WHERE Category = '招聘人数' AND Description NOT LIKE '%~%'
  22329. INSERT INTO @t SELECT DetailId, LEFT(Description, CHARINDEX('~', Description) - 1) + '人' FROM dcOthers WHERE Category = '招聘人数' AND Description LIKE '%~%'
  22330. UPDATE a SET NeedNumber = b.Description FROM #t a, @t b WHERE a.NeedNumber = b.Id
  22331. TRUNCATE TABLE ShortDb..BaiduXMLJobQlrcOut
  22332. INSERT INTO ShortDb..BaiduXMLJobQlrcOut(SiteId, id, jobname, JobDESC, JobDemand, jobregion, companyname, edulevel, IsDelete,
  22333. experiencelevel, AnnounceDate, dcSalaryID, dcjobtypeID, ShortName, Address, dcCompanySizeID, Brief,
  22334. EmployType, adddate, dcCompanyKindID, enddate, email, EnJobID, EnCpMainID,
  22335. IndustryId, SubSiteUrl, SubSiteName, NeedNumber, Welfare1, Welfare2, Welfare3, Welfare4, Welfare5,
  22336. Welfare6, Welfare7, Welfare8, Welfare9, Welfare10, Welfare11, Welfare12, Welfare13, Welfare14,
  22337. Welfare15, Welfare16, Welfare17, Welfare18, crDate)
  22338. SELECT @SiteId, id, jobname, JobDESC, JobDemand, jobregion, companyname, edulevel, IsDelete,
  22339. experiencelevel, AnnounceDate, dcSalaryID, dcjobtypeID, ShortName, Address, dcCompanySizeID, Brief,
  22340. EmployType, adddate, dcCompanyKindID, enddate, email, EnJobID, EnCpMainID,
  22341. IndustryId, SubSiteUrl, SubSiteName, NeedNumber, Welfare1, Welfare2, Welfare3, Welfare4, Welfare5,
  22342. Welfare6, Welfare7, Welfare8, Welfare9, Welfare10, Welfare11, Welfare12, Welfare13, Welfare14,
  22343. Welfare15, Welfare16, Welfare17, Welfare18, GETDATE()
  22344. FROM #t
  22345. ORDER BY RDate DESC, Id DESC
  22346. END
  22347. GO
  22348. /****** Object: StoredProcedure [dbo].[ProcBaiduXmlOutSave1026] Script Date: 2018/12/13 19:09:31 ******/
  22349. SET ANSI_NULLS ON
  22350. GO
  22351. SET QUOTED_IDENTIFIER ON
  22352. GO
  22353. CREATE PROCEDURE [dbo].[ProcBaiduXmlOutSave1026]
  22354. (
  22355. @SiteId INT
  22356. )
  22357. AS
  22358. RETURN
  22359. SET NOCOUNT ON
  22360. BEGIN
  22361. DECLARE @crDate DATETIME
  22362. CREATE TABLE #t
  22363. (
  22364. RowNo INT IDENTITY(1, 1),
  22365. [Id] [int] NOT NULL,
  22366. [JobName] [nvarchar](80) NOT NULL,
  22367. [JobDESC] [varchar](max) NOT NULL,
  22368. [JobDemand] [varchar](max) NOT NULL,
  22369. [JobRegion] [varchar](6) NULL,
  22370. [CompanyName] [varchar](100) NOT NULL,
  22371. [EduLevel] [tinyint] NOT NULL,
  22372. [IsDelete] [bit] NOT NULL,
  22373. [ExperienceLevel] [tinyint] NOT NULL,
  22374. [Announcedate] [datetime] NOT NULL,
  22375. [dcSalaryID] [tinyint] NOT NULL,
  22376. [dcJobtypeID] [smallint] NOT NULL,
  22377. [ShortName] [varchar](40) NULL,
  22378. [Address] [nvarchar](100) NULL,
  22379. [dcCompanySizeID] [tinyint] NULL,
  22380. [Brief] [varchar](6000) NULL,
  22381. [EmployType] [tinyint] NOT NULL,
  22382. [AddDate] [smalldatetime] NOT NULL,
  22383. [dcCompanyKindID] [smallint] NULL,
  22384. [EndDate] [smalldatetime] NULL,
  22385. [Email] [varchar](50) NOT NULL,
  22386. [EnJobID] [varchar](12) NULL,
  22387. [EnCpMainID] [varchar](10) NULL,
  22388. [IndustryId] [smallint] NULL,
  22389. [SubSiteUrl] [varchar](50) NOT NULL,
  22390. [SubSiteName] [varchar](50) NOT NULL,
  22391. NeedNumber VARCHAR(10),
  22392. [Welfare1] [bit] NULL,
  22393. [Welfare2] [bit] NULL,
  22394. [Welfare3] [bit] NULL,
  22395. [Welfare4] [bit] NULL,
  22396. [Welfare5] [bit] NULL,
  22397. [Welfare6] [bit] NULL,
  22398. [Welfare7] [bit] NULL,
  22399. [Welfare8] [bit] NULL,
  22400. [Welfare9] [bit] NULL,
  22401. [Welfare10] [bit] NULL,
  22402. [Welfare11] [bit] NULL,
  22403. [Welfare12] [bit] NULL,
  22404. [Welfare13] [bit] NULL,
  22405. [Welfare14] [bit] NULL,
  22406. [Welfare15] [bit] NULL,
  22407. [Welfare16] [bit] NULL,
  22408. [Welfare17] [bit] NULL,
  22409. [Welfare18] [bit] NULL,
  22410. RegionDesc NVARCHAR(50)
  22411. )
  22412. DECLARE @SubSiteUrl VARCHAR(100), @SubSiteName VARCHAR(100)
  22413. SELECT @SubSiteUrl = SubSiteUrl, @SubSiteName = SubSiteName
  22414. FROM dcsubsite WITH(NOLOCK)
  22415. WHERE Id = @SiteId
  22416. TRUNCATE TABLE ShortDb..BaiduXMLJobTemp
  22417. IF @SiteId = 32
  22418. INSERT INTO ShortDb..BaiduXMLJobTemp
  22419. SELECT @SiteId, a.id, a.name jobname, a.responsibility JobDESC, a.Demand JobDemand,
  22420. a.dcregionid jobregion, b.name companyname, a.dcEducationID edulevel,
  22421. a.MinExperience experiencelevel, a.IsDelete, a.EmployType, a.adddate,
  22422. a.IssueDate AnnounceDate,
  22423. a.dcSalaryID, a.dcjobtypeID, b.dcCompanyKindID, ISNULL(b.ShortName, b.Name) ShortName, b.Address, dcCompanySizeID, Brief,
  22424. a.IssueEnd enddate, c.email, a.SecondId EnJobID, b.SecondId EnCpMainID,
  22425. (SELECT TOP 1 dcIndustryId FROM cpindustry WITH(NOLOCK) WHERE cpindustry.cpMainID = b.ID) IndustryId,
  22426. @SubSiteUrl SubSiteUrl, @SubSiteName SubSiteName, a.RefreshDate RDate, a.NeedNumber, a.Welfare1,
  22427. a.Welfare2, a.Welfare3, a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8, a.Welfare9,
  22428. a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13, a.Welfare14, a.Welfare15, a.Welfare16,
  22429. a.Welfare17, a.Welfare18, '', '', ''
  22430. FROM job a WITH(NOLOCK), cpmain b WITH(NOLOCK), camain c
  22431. WHERE a.camainid = c.id AND a.cpmainid = b.id AND a.valid = 1
  22432. AND issueend>CONVERT(VARCHAR(10), GETDATE()+1, 120)
  22433. AND b.valid = 1 AND b.VerifyCount > 0
  22434. AND b.dcprovinceid = @SiteId
  22435. AND LEN(RTRIM(a.name)) > 1
  22436. AND a.dcRegionId LIKE LTRIM(STR(@SiteId)) + '%'
  22437. --AND a.Refreshdate>CONVERT(VARCHAR(10), GETDATE() - 1, 120)
  22438. ORDER BY a.Refreshdate DESC
  22439. ELSE
  22440. INSERT INTO ShortDb..BaiduXMLJobTemp
  22441. SELECT @SiteId, a.id, a.name jobname, a.responsibility JobDESC, a.Demand JobDemand,
  22442. a.dcregionid jobregion, b.name companyname, a.dcEducationID edulevel,
  22443. a.MinExperience experiencelevel, a.IsDelete, a.EmployType, a.adddate,
  22444. a.IssueDate AnnounceDate,
  22445. a.dcSalaryID, a.dcjobtypeID, b.dcCompanyKindID, ISNULL(b.ShortName, b.Name) ShortName, b.Address, dcCompanySizeID, Brief,
  22446. a.IssueEnd enddate, c.email, a.SecondId EnJobID, b.SecondId EnCpMainID,
  22447. (SELECT TOP 1 dcIndustryId FROM cpindustry WITH(NOLOCK) WHERE cpindustry.cpMainID = b.ID) IndustryId,
  22448. @SubSiteUrl SubSiteUrl, @SubSiteName SubSiteName, a.RefreshDate RDate, a.NeedNumber, a.Welfare1,
  22449. a.Welfare2, a.Welfare3, a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8, a.Welfare9,
  22450. a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13, a.Welfare14, a.Welfare15, a.Welfare16,
  22451. a.Welfare17, a.Welfare18, '', '', ''
  22452. FROM job a WITH(NOLOCK), cpmain b WITH(NOLOCK), camain c
  22453. WHERE a.camainid = c.id
  22454. AND a.cpmainid = b.id
  22455. AND b.dcprovinceid = @SiteId
  22456. AND LEN(RTRIM(a.name)) > 1
  22457. AND a.dcRegionId LIKE LTRIM(STR(@SiteId)) + '%'
  22458. --AND a.Refreshdate>CONVERT(VARCHAR(10), GETDATE() - 1, 120)
  22459. ORDER BY a.Refreshdate DESC
  22460. UPDATE ShortDb..BaiduXMLJobTemp
  22461. SET Brief = REPLACE(REPLACE(REPLACE(REPLACE(Brief, '&nbsp;', ''), '&lt;', ''), '&gt;', ''), '&#', '')
  22462. WHERE Brief LIKE '%&%'
  22463. UPDATE ShortDb..BaiduXMLJobTemp SET Brief = REPLACE(Brief, ' ', '') WHERE Brief LIKE '% %'
  22464. UPDATE ShortDb..BaiduXMLJobTemp
  22465. SET JobDesc = REPLACE(JobDesc, ' ', ''),
  22466. JobDemand = REPLACE(JobDemand, ' ', ''),
  22467. Brief = REPLACE(Brief, ' ', '')
  22468. WHERE CHARINDEX(' ', JobDesc) > 0
  22469. OR CHARINDEX(' ', JobDemand) > 0
  22470. OR CHARINDEX(' ', Brief) > 0
  22471. UPDATE a
  22472. SET a.RegionDesc = b.FullName
  22473. FROM ShortDb..BaiduXMLJobTemp a, MainDb..dcRegion b
  22474. WHERE a.JobREgion = b.Id
  22475. UPDATE ShortDb..BaiduXMLJobTemp SET RegionDesc = '' WHERE CHARINDEX(RegionDesc, Address) > 0
  22476. UPDATE ShortDb..BaiduXMLJobTemp
  22477. SET Address = RIGHT(Address, LEN(Address) - 3)
  22478. WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
  22479. AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
  22480. UPDATE ShortDb..BaiduXMLJobTemp
  22481. SET Address = RIGHT(Address, LEN(Address) - 3)
  22482. WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
  22483. AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
  22484. UPDATE ShortDb..BaiduXMLJobTemp
  22485. SET Address = RIGHT(Address, LEN(Address) - 3)
  22486. WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
  22487. AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
  22488. UPDATE ShortDb..BaiduXMLJobTemp SET Address = '' WHERE CHARINDEX(Address, RegionDesc) > 0 AND LEN(RegionDesc) > 0
  22489. UPDATE ShortDb..BaiduXMLJobTemp SET Address = RegionDesc + Address WHERE LEN(RegionDesc) > 0
  22490. UPDATE a SET a.RegionName = b.Description FROM ShortDb..BaiduXMLJobTemp a, dcRegion b WHERE LEFT(a.JobRegion, 4) = b.Id
  22491. UPDATE ShortDb..BaiduXMLJobTemp SET RegionName2 = LEFT(RegionName, LEN(RegionName) - 1) WHERE LEN(RegionName) > 2
  22492. UPDATE ShortDb..BaiduXMLJobTemp SET JobName = LEFT(RegionName + JobName, 50) WHERE CHARINDEX(RegionName2, JobName) = 0
  22493. UPDATE ShortDb..BaiduXMLJobTemp SET JobName = LEFT(JobName + '招聘', 50) WHERE CHARINDEX('聘', JobName) = 0
  22494. DECLARE @t AS TABLE(Id INT, Description NVARCHAR(110))
  22495. INSERT INTO @t SELECT DetailId, REPLACE(Description, '以上', '') FROM dcOthers WHERE Category = '招聘人数' AND Description NOT LIKE '%~%'
  22496. INSERT INTO @t SELECT DetailId, LEFT(Description, CHARINDEX('~', Description) - 1) + '人' FROM dcOthers WHERE Category = '招聘人数' AND Description LIKE '%~%'
  22497. UPDATE a SET NeedNumber = b.Description FROM ShortDb..BaiduXMLJobTemp a, @t b WHERE a.NeedNumber = b.Id
  22498. INSERT INTO #t
  22499. SELECT id, jobname, JobDESC, JobDemand, jobregion, companyname, edulevel, IsDelete,
  22500. experiencelevel, AnnounceDate, dcSalaryID, dcjobtypeID, ShortName, Address, dcCompanySizeID, Brief,
  22501. EmployType, adddate, dcCompanyKindID, enddate, email, EnJobID, EnCpMainID,
  22502. IndustryId, SubSiteUrl, SubSiteName, NeedNumber, Welfare1, Welfare2, Welfare3, Welfare4, Welfare5,
  22503. Welfare6, Welfare7, Welfare8, Welfare9, Welfare10, Welfare11, Welfare12, Welfare13, Welfare14,
  22504. Welfare15, Welfare16, Welfare17, Welfare18, ''
  22505. FROM ShortDb..BaiduXMLJobTemp ORDER BY RDate DESC, id
  22506. IF (SELECT COUNT(*) FROM #t) % 500 = 0
  22507. DELETE #t WHERE ID IN(SELECT TOP 2 ID FROM #t ORDER BY Announcedate)
  22508. DELETE ShortDb..BaiduXMLJobOut WHERE SiteId = @SiteId
  22509. INSERT INTO ShortDb..BaiduXMLJobOut(SiteId, id, jobname, JobDESC, JobDemand, jobregion, companyname, edulevel, IsDelete,
  22510. experiencelevel, AnnounceDate, dcSalaryID, dcjobtypeID, ShortName, Address, dcCompanySizeID, Brief,
  22511. EmployType, adddate, dcCompanyKindID, enddate, email, EnJobID, EnCpMainID,
  22512. IndustryId, SubSiteUrl, SubSiteName, NeedNumber, Welfare1, Welfare2, Welfare3, Welfare4, Welfare5,
  22513. Welfare6, Welfare7, Welfare8, Welfare9, Welfare10, Welfare11, Welfare12, Welfare13, Welfare14,
  22514. Welfare15, Welfare16, Welfare17, Welfare18, crDate)
  22515. SELECT @SiteId, id, jobname, JobDESC, JobDemand, jobregion, companyname, edulevel, IsDelete,
  22516. experiencelevel, AnnounceDate, dcSalaryID, dcjobtypeID, ShortName, Address, dcCompanySizeID, Brief,
  22517. EmployType, adddate, dcCompanyKindID, enddate, email, EnJobID, EnCpMainID,
  22518. IndustryId, SubSiteUrl, SubSiteName, NeedNumber, Welfare1, Welfare2, Welfare3, Welfare4, Welfare5,
  22519. Welfare6, Welfare7, Welfare8, Welfare9, Welfare10, Welfare11, Welfare12, Welfare13, Welfare14,
  22520. Welfare15, Welfare16, Welfare17, Welfare18, GETDATE()
  22521. FROM #t
  22522. ORDER BY RowNo
  22523. END
  22524. GO
  22525. /****** Object: StoredProcedure [dbo].[ProcBaiduXmlRunLogBySuccesssUpdate] Script Date: 2018/12/13 19:09:31 ******/
  22526. SET ANSI_NULLS ON
  22527. GO
  22528. SET QUOTED_IDENTIFIER ON
  22529. GO
  22530. CREATE PROCEDURE [dbo].[ProcBaiduXmlRunLogBySuccesssUpdate]
  22531. (
  22532. @ID INT
  22533. )
  22534. AS
  22535. SET NOCOUNT ON
  22536. BEGIN
  22537. IF (SELECT CurrentStatus FROM LogDb..BaiduXmlRunLog WHERE Id = @Id) < 2
  22538. UPDATE LogDb..BaiduXmlRunLog
  22539. SET CurrentStatus = 1,
  22540. BeginJobId = EndJobId
  22541. WHERE Id = @Id
  22542. ELSE
  22543. UPDATE LogDb..BaiduXmlRunLog
  22544. SET CurrentStatus = 10,
  22545. BeginJobId = EndJobId
  22546. WHERE Id = @Id
  22547. END
  22548. GO