maindb-procedure-4.sql 756 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791
  1. /****** Object: StoredProcedure [dbo].[ccExInterViewByJobIDSendSmsInsert] Script Date: 2018/12/13 19:06:46 ******/
  2. SET ANSI_NULLS ON
  3. GO
  4. SET QUOTED_IDENTIFIER ON
  5. GO
  6. /*#######################################
  7. ---面试通知(是否发送短信)
  8. ---创建人harry
  9. #######################################*/
  10. CREATE PROCEDURE [dbo].[ccExInterViewByJobIDSendSmsInsert]
  11. (
  12. @JobID INT,
  13. @cpMainID INT,
  14. @cvMainID INT,
  15. @InterviewDate VARCHAR(100),
  16. @InterViewPlace VARCHAR(200),
  17. @LinkMan VARCHAR(12),
  18. @Telephone VARCHAR(20),
  19. @Remark VARCHAR(1000),
  20. @SendSms INT--发送短信
  21. )
  22. AS
  23. SET NOCOUNT ON
  24. BEGIN
  25. SET NOCOUNT ON
  26. DECLARE @InterviewPoint INT --直接发送面试通知 赠送积分
  27. DECLARE @ReplyInterviewPoint INT --答复后 发送面试通知 赠送积分
  28. SET @InterviewPoint =7
  29. SET @ReplyInterviewPoint = 10
  30. DECLARE @caMainID INT, @paMainId INT, @ExInterViewID INT, @wxFansId INT,@JobName NVARCHAR(50)
  31. SELECT @caMainID = caMainId, @JobName = Name FROM Job WITH(NOLOCK) WHERE ID = @JobID AND cpMainID = @cpMainID
  32. IF ISNULL(@caMainID, 0) = 0
  33. RETURN -1
  34. SELECT @Remark = dbo.TrimNull(@Remark),
  35. @InterviewDate = dbo.Trim(@InterviewDate),
  36. @InterViewPlace = dbo.Trim(@InterViewPlace),
  37. @Telephone = dbo.Trim(@Telephone)
  38. INSERT INTO ExInterView(JobID, cvMainID, InterviewDate, InterViewPlace, LinkMan, Telephone, Remark)
  39. VALUES(@JobID, @cvMainID, @InterviewDate, @InterViewPlace, @LinkMan, @Telephone, @Remark)
  40. SET @ExInterViewID = @@IDENTITY
  41. --未答复的修改答复状态
  42. UPDATE exJobApply SET Reply =1,ReplyDate=GETDATE() WHERE JobID = @JobID AND CvMainID = @cvMainID
  43. BEGIN TRY
  44. SELECT @paMainId = paMainId FROM cvMain WITH(NOLOCK) WHERE Id = @cvMainId
  45. SELECT @wxFansId = id FROM wxFans WITH(NOLOCK) WHERE paMainId = @paMainId AND [Status] = 2
  46. IF @wxFansId IS NOT NULL--关注的用户发送微信消息提醒
  47. BEGIN
  48. --插入到wxMessageSend表中
  49. INSERT INTO WxMessageSend2(Templatetype, WxFansID, PaMainId, MainTableId, CpMainID, CvMainID, JobId, CaMainId, AddDate)
  50. SELECT 1, @wxFansId, @paMainId, @ExInterViewID, @cpMainId, @cvMainID, @JobId, @caMainID, GETDATE()
  51. END
  52. IF @SendSms > 0 --发送短信
  53. BEGIN
  54. --获取剩余可用短信量
  55. --优先取主订单id
  56. DECLARE @orderId INT --订单id
  57. SELECT TOP 1 @orderId = id
  58. FROM caOrder
  59. WHERE cpMainId = @cpMainId
  60. AND RemainSmsQuota > 0
  61. AND OrderType IN (8,14)
  62. AND OpenDate IS NOT NULL
  63. AND BeginDate< GETDATE()
  64. AND EndDate > GETDATE()
  65. AND IsDeleted = 0
  66. ORDER BY ID
  67. IF ISNULL(@orderId, 0)>0
  68. BEGIN
  69. DECLARE @smsLogId INT, @msg VARCHAR(400), @mobile CHAR(11)
  70. SELECT @mobile = Mobile, @msg = ISNULL(Name, '')
  71. FROM paMain WITH(NOLOCK)
  72. WHERE ID = @paMainId
  73. AND Mobile > ''
  74. AND IsReceiveSms = 1
  75. IF ISNULL(@mobile, '') <> ''
  76. BEGIN
  77. SELECT @msg = @msg +'你好,' + d.Name +'在' + c.SubSiteName + c.EmailSite + '给您发了面试通知,面试职位:'+ @JobName +',面试时间:' + @InterviewDate +
  78. ',地点:' + @InterViewPlace + ',联系电话:' + @Telephone + '。'
  79. FROM dcSubSite c WITH(NOLOCK), cpMain d WITH(NOLOCK)
  80. WHERE d.dcProvinceID = c.ID
  81. AND d.ID = @cpMainID
  82. INSERT SmsMessageLog(SendMan, ManagerUSerId, paMainId, caMainId, Mobile, MsgType, IsCat, Msg)
  83. SELECT 0, NULL, @paMainId, @caMainID, @mobile, 101, 0, @msg
  84. SET @smsLogId = @@IDENTITY
  85. --短信-1
  86. UPDATE caOrder set RemainSmsQuota = RemainSmsQuota-1 WHERE id = @orderId
  87. --插入消耗记录
  88. INSERT INTO casmslog(caOrderId, cvMainId, caMainId, Mobile, MsgType, RelationId, SmsMessageLogId, SendStatus, SendDate, Msg, AddDate)
  89. SELECT @orderId, @cvMainID, @caMainID, @mobile, 101, @ExInterViewID, @smsLogId, NULL, NULL, @msg,GETDATE()
  90. UPDATE ExInterView SET SmsNumber = ISNULL(SmsNumber, 0) + 1 WHERE ID = @ExInterViewID
  91. END
  92. END
  93. END
  94. INSERT INTO paPushLog(paMainID, PushMessage, PushType)
  95. SELECT @paMainId, '亲,收到一份面试通知!', 2 WHERE EXISTS(SELECT 'X' FROM paIOSBind WHERE paMainID = @paMainId)
  96. END TRY
  97. BEGIN CATCH
  98. END CATCH
  99. --插入积分记录
  100. BEGIN TRY
  101. --插入积分记录
  102. DECLARE @TodayPoint AS INT, @TodayID AS INT, @JobApplyID INT,@Reply INT
  103. SELECT @TodayPoint = 0, @TodayID = 0
  104. SELECT TOP 1 @TodayPoint = ISNULL(Point,0),@TodayID = ISNULL(ID,0) FROM cpPoint WITH(NOLOCK) WHERE changeID = 4 AND LastModifyDate > CONVERT(VARCHAR(10), GETDATE(),120) AND cpMainID = @cpMainID
  105. -- --判断是否是应聘的简历
  106. -- SELECT @JobApplyID = 0, @Reply = 0
  107. --
  108. -- SELECT @JobApplyID = ID, @Reply = Reply
  109. -- FROM ExJobApply WITH(NOLOCK)
  110. -- WHERE JobID = @JobID
  111. -- AND CvMainID = @cvMainID
  112. -- IF @JobApplyID = 0 --未应聘
  113. -- BEGIN
  114. -- SET @TodayPoint = @ReplyInterviewPoint
  115. -- END
  116. -- ELSE
  117. -- BEGIN
  118. -- IF @Reply = 0
  119. -- BEGIN
  120. -- UPDATE ExJobApply
  121. -- SET Reply = 1
  122. -- WHERE ID = @JobApplyID
  123. --
  124. -- SET @TodayPoint = @InterviewPoint
  125. -- END
  126. -- ELSE
  127. -- BEGIN
  128. -- SET @TodayPoint = @ReplyInterviewPoint
  129. -- END
  130. -- END
  131. SET @TodayPoint = @TodayPoint + @ReplyInterviewPoint
  132. IF @TodayPoint <= 200
  133. BEGIN
  134. IF @TodayID = 0
  135. BEGIN
  136. INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@cpMainID,4,@TodayPoint,GETDATE())
  137. END
  138. ELSE
  139. BEGIN
  140. UPDATE cpPoint SET Point = Point + @TodayPoint,LastModifyDate = GETDATE() WHERE ID = @TodayID
  141. END
  142. END
  143. END TRY
  144. BEGIN CATCH
  145. END CATCH
  146. END
  147. SET NOCOUNT OFF
  148. GO
  149. /****** Object: StoredProcedure [dbo].[ccExInterViewByOneWeekSelect] Script Date: 2018/12/13 19:06:47 ******/
  150. SET ANSI_NULLS ON
  151. GO
  152. SET QUOTED_IDENTIFIER ON
  153. GO
  154. CREATE PROCEDURE [dbo].[ccExInterViewByOneWeekSelect]
  155. (
  156. @caMainID INT
  157. )
  158. AS
  159. BEGIN
  160. BEGIN TRY
  161. DECLARE @return INT
  162. SELECT @return = COUNT(1) FROM exInterView WITH(NOLOCK)
  163. WHERE AddDate > DATEADD(week,-1,GETDATE())
  164. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE caMainID = @caMainID)
  165. RETURN @return
  166. END TRY
  167. BEGIN CATCH
  168. RETURN 0
  169. END CATCH
  170. END
  171. GO
  172. /****** Object: StoredProcedure [dbo].[ccExInterViewInsert] Script Date: 2018/12/13 19:06:47 ******/
  173. SET ANSI_NULLS ON
  174. GO
  175. SET QUOTED_IDENTIFIER ON
  176. GO
  177. /*#######################################
  178. ---面试通知
  179. 2012-10-23 sean
  180. update msgcount from smsmessagelog
  181. 2014-08-25 Peter
  182. 添加积分记录
  183. ---2015-8-27 Harry
  184. ---增加将绑定关注微信的,插入到wxsendmessage表中
  185. --修改Harry2017-4-17
  186. #######################################*/
  187. CREATE PROCEDURE [dbo].[ccExInterViewInsert]
  188. (
  189. @JobID INT,
  190. @cpMainID INT,
  191. @cvMainID INT,
  192. @InterviewDate VARCHAR(100),
  193. @InterViewPlace VARCHAR(200),
  194. @LinkMan VARCHAR(12),
  195. @Telephone VARCHAR(20),
  196. @Remark VARCHAR(1000)
  197. )
  198. AS
  199. SET NOCOUNT ON
  200. BEGIN
  201. SET NOCOUNT ON
  202. DECLARE @caMainID INT, @paMainId INT, @ExInterViewID INT, @wxFansId INT, @MsgCount INT
  203. SELECT @caMainID = caMainId FROM Job WITH(NOLOCK) WHERE ID = @JobID AND cpMainID = @cpMainID
  204. IF ISNULL(@caMainID, 0) = 0
  205. RETURN -1
  206. SELECT @Remark = dbo.TrimNull(@Remark),
  207. @InterviewDate = dbo.Trim(@InterviewDate),
  208. @InterViewPlace = dbo.Trim(@InterViewPlace),
  209. @Telephone = dbo.Trim(@Telephone)
  210. INSERT INTO ExInterView(JobID, cvMainID, InterviewDate, InterViewPlace, LinkMan, Telephone, Remark)
  211. VALUES(@JobID, @cvMainID, @InterviewDate, @InterViewPlace, @LinkMan, @Telephone, @Remark)
  212. SET @ExInterViewID = @@IDENTITY
  213. BEGIN TRY
  214. SELECT @paMainId = paMainId FROM cvMain WITH(NOLOCK) WHERE Id = @cvMainId
  215. SELECT @MsgCount = SUM(smsNumber) FROM ExInterView WITH(NOLOCK)
  216. WHERE JobId IN(SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainId = @cpMainID)
  217. AND AddDate > CONVERT(VARCHAR(10), GETDATE() - 29, 120)
  218. IF @MsgCount < 45
  219. BEGIN
  220. INSERT SmsMessageLog(SendMan, ManagerUSerId, paMainId, caMainId, Mobile, MsgType, IsCat, Msg)
  221. SELECT 0, NULL, b.ID, @caMainID, b.Mobile, 101, 0,
  222. ISNULL(b.Name,'') +','+ d.Name +'在'+ c.SubSiteName + c.EmailSite +'上邀请您面试,请登录网站查看'
  223. FROM cvMain a WITH(NOLOCK), paMain b WITH(NOLOCK), dcSubSite c WITH(NOLOCK),cpMain d WITH(NOLOCK)
  224. WHERE a.paMainID = b.ID
  225. AND b.dcSubSiteID = c.ID
  226. AND d.ID = @cpMainID
  227. AND b.Mobile > ''
  228. AND a.ID = @cvMainID
  229. AND b.IsReceiveSms = 1
  230. UPDATE ExInterView SET SmsNumber = ISNULL(SmsNumber, 0) + 1 WHERE ID = @ExInterViewID
  231. END
  232. ELSE --关注的用户发送微信消息提醒
  233. BEGIN
  234. SELECT @wxFansId = id FROM wxFans WITH(NOLOCK) WHERE paMainId = @paMainId AND [Status] = 2
  235. IF @wxFansId > 0
  236. --插入到wxMessageSend表中
  237. INSERT WxMessageSend2(Templatetype, WxFansID, PaMainId, MainTableId, CpMainID, CvMainID, JobId, CaMainId, AddDate)
  238. SELECT 1, @wxFansId, @paMainId, @ExInterViewID, @cpMainId, @cvMainID, @JobId, @caMainID, GETDATE()
  239. END
  240. END TRY
  241. BEGIN CATCH
  242. END CATCH
  243. --插入积分记录
  244. BEGIN TRY
  245. --插入积分记录
  246. DECLARE @TodayPoint AS INT
  247. DECLARE @TodayID AS INT
  248. SET @TodayPoint = 0
  249. SET @TodayID = 0
  250. SELECT TOP 1 @TodayPoint = ISNULL(Point,0),@TodayID = ISNULL(ID,0) FROM cpPoint WITH(NOLOCK) WHERE changeID = 4 AND LastModifyDate > CONVERT(VARCHAR(10), GETDATE(),120) AND cpMainID = @cpMainID
  251. SET @TodayPoint = @TodayPoint + 10
  252. IF @TodayPoint <= 200
  253. BEGIN
  254. IF @TodayID = 0
  255. BEGIN
  256. INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@cpMainID,4,2,GETDATE())
  257. END
  258. ELSE
  259. BEGIN
  260. UPDATE cpPoint SET Point = @TodayPoint,LastModifyDate = GETDATE() WHERE ID = @TodayID
  261. END
  262. END
  263. END TRY
  264. BEGIN CATCH
  265. END CATCH
  266. -- RETURN @Return
  267. RETURN ISNULL(@MsgCount, 0)
  268. END
  269. GO
  270. /****** Object: StoredProcedure [dbo].[ccExInterviewSelect] Script Date: 2018/12/13 19:06:47 ******/
  271. SET ANSI_NULLS ON
  272. GO
  273. SET QUOTED_IDENTIFIER ON
  274. GO
  275. ---修改Harry 2017-6-7 增加显示短信订单内容
  276. CREATE PROCEDURE [dbo].[ccExInterviewSelect]
  277. (
  278. @WHERE VARCHAR(1000),
  279. @Order VARCHAR(100),
  280. @page SMALLINT,
  281. @caMainID INT,
  282. @cpMainID INT
  283. )
  284. AS
  285. SET NOCOUNT ON
  286. BEGIN
  287. SET @WHERE = dbo.SafeSQL(@WHERE)
  288. SET @ORDER = dbo.SafeSQL(@ORDER)
  289. CREATE TABLE #T(
  290. TitleID BIGINT,
  291. ID INT,
  292. JobID INT,
  293. JobName NVARCHAR(50) COLLATE Chinese_PRC_CI_AS NULL,
  294. JobRegion VARCHAR(6) NULL,
  295. IsJobDelete BIT NULL,
  296. cvMainID INT,
  297. InterviewDate VARCHAR(100) COLLATE Chinese_PRC_CI_AS NULL,
  298. InterviewPlace NVARCHAR(200),
  299. LinkMan NVARCHAR(40),
  300. Telephone VARCHAR(30) COLLATE Chinese_PRC_CI_AS NULL,
  301. Remark VARCHAR(1000) COLLATE Chinese_PRC_CI_AS NULL,
  302. AddDate SMALLDATETIME,
  303. Reply TINYINT,
  304. ReplyMessage VARCHAR(500) COLLATE Chinese_PRC_CI_AS NULL,
  305. Degree TINYINT,
  306. RelatedWorkYears TINYINT,
  307. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS NULL,
  308. IsNameHidden BIT,
  309. LivePlace VARCHAR(6) COLLATE Chinese_PRC_CI_AS NULL,
  310. Gender BIT,
  311. paName NVARCHAR(20),
  312. BirthDay INT,
  313. HasPhoto TINYINT,
  314. Valid TINYINT,
  315. IsViewed BIT,
  316. HasJobApply BIT,
  317. HasFavorate BIT,
  318. HasRemark BIT,
  319. Result BIT,
  320. ResultDate SMALLDATETIME,
  321. MobileVerifyDate SMALLDATETIME,
  322. IsOnline BIT,
  323. SmsMsg NVARCHAR(210) NULL, --短信内容
  324. paMainID INT,
  325. SecondId VARCHAR(10)
  326. )
  327. DECLARE @SQL AS VARCHAR(2000)
  328. SET @SQL='
  329. INSERT INTO #T(TitleID, ID, JobID, cvMainID, InterviewDate, InterviewPlace, LinkMan,
  330. Telephone, Remark, AddDate, Reply, ReplyMessage, Result, ResultDate, IsOnline, paMainId, SecondId)
  331. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, a.JobID, a.cvMainID,
  332. a.InterviewDate, a.InterviewPlace, a.LinkMan, a.Telephone, a.Remark, a.AddDate, a.Reply, a.ReplyMessage,
  333. a.Result, a.ResultDate, dbo.GetPaOnlineStatus(c.ID), b.paMainId, b.SecondId
  334. FROM exInterview a WITH(NOLOCK)
  335. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  336. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  337. WHERE a.JobID IN(SELECT id FROM Job WITH(NOLOCK) WHERE cpMainID = ' + CONVERT(VARCHAR,@cpMainID) + ') '
  338. SET @SQL = @SQL + ' AND CompanyDeleted=0'
  339. IF LEN(@WHERE) > 0
  340. BEGIN
  341. SET @Where = dbo.SafeSql(@Where)
  342. SET @SQL = @SQL + @WHERE
  343. END
  344. --PRINT @SQL
  345. EXEC(@SQL)
  346. IF(@Page < 1)
  347. SET @Page = 1
  348. UPDATE #T SET Degree = a.Degree, RelatedWorkYears = a.RelatedWorkYears, Attachment = a.Attachment,
  349. IsNameHidden = a.IsNameHidden, LivePlace = b.LivePlace, Gender = b.Gender, paName = b.Name,
  350. BirthDay = b.BirthDay, HasPhoto = b.HasPhoto, Valid = a.Valid, MobileVerifyDate = b.MobileVerifyDate
  351. FROM cvMain a WITH(NOLOCK) INNER JOIN paMain b WITH(NOLOCK) ON a.paMainID = b.ID
  352. WHERE a.ID = #T.cvMainID AND TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  353. UPDATE #T SET paName = LEFT(dbo.GetPersonName(cvMainID, @cpMainID), 20),
  354. IsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID),
  355. HasJobApply = (SELECT TOP 1 '1' FROM exJobApply a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  356. HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  357. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  358. SmsMsg = (SELECT TOP 1 Msg FROM casmslog WITH(NOLOCK) WHERE MsgType = 101 AND RelationId = #T.ID)
  359. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  360. UPDATE #T SET JobName = a.Name, JobRegion= a.dcRegionID, IsJobDelete = IsDelete
  361. FROM Job a WITH(NOLOCK)
  362. WHERE #T.JobID = a.ID
  363. --修改查看状态
  364. UPDATE exInterview
  365. SET CpResultViewDate = GETDATE()
  366. WHERE JobID IN
  367. (
  368. SELECT ID FROM Job WITH(NOLOCK)
  369. WHERE CpMainID = @cpMainID
  370. AND CaMainID = @caMainID
  371. )
  372. AND CpResultViewDate IS NULL
  373. AND Replydate IS NOT NULL
  374. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  375. SELECT a.*, dbo.BirthToAge(a.BirthDay) Age, b.Description DegreeName, c.MapBarName LivePlaceName, d.Description JobRegionName
  376. FROM #T a WITH(NOLOCK)
  377. LEFT JOIN dcEducation b WITH(NOLOCK) ON b.ID = a.Degree
  378. LEFT JOIN dcRegion c WITH(NOLOCK) ON c.ID = a.LivePlace
  379. LEFT JOIN dcRegion d WITH(NOLOCK) ON d.ID = a.JobRegion
  380. WHERE a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
  381. DROP TABLE #T
  382. END
  383. SET NOCOUNT OFF
  384. GO
  385. /****** Object: StoredProcedure [dbo].[ccExJobApplyBatchDelete] Script Date: 2018/12/13 19:06:48 ******/
  386. SET ANSI_NULLS ON
  387. GO
  388. SET QUOTED_IDENTIFIER ON
  389. GO
  390. --Lambo 20101130 修改
  391. -- 增加cpMainID 参数,只能删除本公司的
  392. CREATE PROCEDURE [dbo].[ccExJobApplyBatchDelete]
  393. (
  394. @AllID VARCHAR(1000),
  395. @cpMainID INT
  396. )
  397. AS
  398. BEGIN TRAN
  399. BEGIN TRY
  400. SET @AllID = dbo.FormatIDS(@AllID)
  401. DECLARE @T AS TABLE(ID INT)
  402. INSERT INTO @T SELECT * FROM dbo.fnSplit(@AllID, ',')
  403. INSERT INTO CaCvApplyDeleted(JobID,JobName,CvMainId,ApplyDate,AddDate,Reply)
  404. SELECT b.ID,b.Name,a.cvMainid,a.AddDate,GETDATE(),ISNULL(Reply,0)
  405. FROM exjobapply a,job b
  406. WHERE a.jobid = b.id
  407. AND a.id in (SELECT id FROM @t)
  408. DELETE FROM ExJobApply WHERE PersonDeleted=1 AND ID IN(SELECT ID FROM @T)
  409. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  410. UPDATE ExJobApply SET CompanyDeleted = 1, CompanyDeleteDate = GETDATE(),ReplyDate=GETDATE()
  411. WHERE Reply <> 0 AND ID IN(SELECT ID FROM @T)
  412. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  413. UPDATE ExJobApply SET CompanyDeleted = 1, CompanyDeleteDate = GETDATE(), Reply = 4,ReplyDate=GETDATE()
  414. WHERE Reply = 0 AND ID IN(SELECT ID FROM @T)
  415. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  416. END TRY
  417. BEGIN CATCH
  418. GOTO ERR
  419. END CATCH
  420. COMMIT TRAN
  421. RETURN 1
  422. ERR:
  423. BEGIN
  424. ROLLBACK TRAN
  425. RETURN 0
  426. END
  427. GO
  428. /****** Object: StoredProcedure [dbo].[ccExJobApplyByApplyCountSelect] Script Date: 2018/12/13 19:06:49 ******/
  429. SET ANSI_NULLS ON
  430. GO
  431. SET QUOTED_IDENTIFIER ON
  432. GO
  433. -------------------------------------------------------
  434. --创建时间:2015.7.14
  435. --创建人:Mice
  436. --说明:查询申请数量(包括过滤和未过滤)
  437. -------------------------------------------------------
  438. CREATE PROCEDURE [dbo].[ccExJobApplyByApplyCountSelect]
  439. (
  440. @JobID INT
  441. )
  442. AS
  443. BEGIN
  444. SET NOCOUNT ON
  445. SELECT COUNT(ID) AS ApplyCount
  446. FROM exJobApply WITH(NOLOCK)
  447. WHERE JobID = @JobID
  448. SET NOCOUNT OFF
  449. END
  450. GO
  451. /****** Object: StoredProcedure [dbo].[ccExJobApplyByAssessReportSelect] Script Date: 2018/12/13 19:06:49 ******/
  452. SET ANSI_NULLS ON
  453. GO
  454. SET QUOTED_IDENTIFIER ON
  455. GO
  456. --#####################################################
  457. --创建时间:20181123
  458. --创建人:Peter
  459. --查询已查看的测评报告
  460. --#####################################################
  461. CREATE PROCEDURE [dbo].[ccExJobApplyByAssessReportSelect]
  462. (
  463. @WHERE VARCHAR(1000),
  464. @Order VARCHAR(100),
  465. @Page SMALLINT,
  466. @caMainID INT,
  467. @ReplyType INT
  468. )
  469. AS
  470. SET NOCOUNT ON
  471. BEGIN
  472. DECLARE @WHERE2 VARCHAR(MAX)
  473. IF @ReplyType = 5
  474. BEGIN
  475. SET @WHERE2 = ' And IsFilter = 0 AND Reply = 0 AND ViewDate IS NULL'
  476. END
  477. ELSE IF @ReplyType = 1
  478. BEGIN
  479. SET @WHERE2 = ' And IsFilter = 0 AND Reply = 0 AND ViewDate IS NOT NULL'
  480. END
  481. ELSE IF @ReplyType = 2
  482. BEGIN
  483. SET @WHERE2 = ' And IsFilter = 0 AND Reply = 1 AND ViewDate IS NOT NULL'
  484. END
  485. ELSE IF @ReplyType = 3
  486. BEGIN
  487. SET @WHERE2 = ' And IsFilter = 0 AND (Reply = 2 OR Reply = 5) AND ViewDate IS NOT NULL'
  488. END
  489. ELSE IF @ReplyType = 4
  490. BEGIN
  491. SET @WHERE2 = ' And IsFilter = 1 ' --AND ViewDate is null'
  492. END
  493. ELSE
  494. SET @WHERE2 = ' And IsFilter = 0'
  495. SET @Where = dbo.SafeSql(@Where)
  496. SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '''''')
  497. DECLARE @SQL AS VARCHAR(2000)
  498. CREATE TABLE #T(
  499. TitleID BIGINT,
  500. ID INT,
  501. JobID INT,
  502. paMainID INT,
  503. cvMainID INT,
  504. AddDate SMALLDATETIME,
  505. Reply TINYINT,
  506. ReplyDate SMALLDATETIME,
  507. IsMatched BIT,
  508. Degree TINYINT,
  509. RelatedWorkYears TINYINT,
  510. LivePlace NVARCHAR(50),
  511. Gender BIT,
  512. paName NVARCHAR(20),
  513. BirthDay INT,
  514. HasPhoto TINYINT,
  515. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  516. IsNameHidden BIT,
  517. Valid TINYINT,
  518. ApplyMessage NVARCHAR(1),
  519. IsViewed BIT,
  520. HasInterview BIT,
  521. HasRemark BIT,
  522. HasFavorate BIT,
  523. cvEducationID INT,
  524. College NVARCHAR(50),
  525. EduType TINYINT,
  526. MajorName NVARCHAR(20),
  527. Graduation INT,
  528. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  529. Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  530. cvMatch INT,
  531. RecruitmentID INT,
  532. RecruitmentName NVARCHAR(100),
  533. RecruitmentDate SMALLDATETIME,
  534. MobileVerifyDate SMALLDATETIME,
  535. IsOnline BIT,
  536. RemindDate DATETIME,
  537. HasWeiXin BIT,
  538. ReplyReason VARCHAR(200),
  539. Accept BIT,
  540. NoAccept BIT,
  541. SecondId VARCHAR(10),
  542. Mobile VARCHAR(15),
  543. Email VARCHAR(100),
  544. ContactPrivi BIT,
  545. AssessCnt INT,
  546. CpViewDate SMALLDATETIME,
  547. AssessTestLogID INT,
  548. AssessTypeName VARCHAR(100)
  549. )
  550. SET @SQL='
  551. INSERT INTO #T(TitleID, ID, JobID, paMainID, cvMainID, AddDate, Reply, ReplyDate, IsMatched,
  552. ApplyMessage, Degree, RelatedWorkYears, Attachment, IsNameHidden, LivePlace, Gender, BirthDay,
  553. HasPhoto, Valid, RecruitmentID, MobileVerifyDate, IsOnline, RemindDate, ReplyReason, SecondId,
  554. CpViewDate,AssessTestLogID,AssessTypeName)
  555. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, a.JobID, c.ID, a.cvMainID,
  556. a.AddDate, a.Reply, a.ReplyDate, a.IsMatched, LEFT(a.ApplyMessage, 1) ApplyMessage, b.Degree,
  557. b.RelatedWorkYears, b.Attachment, b.IsNameHidden, c.LivePlace, c.Gender, c.BirthDay, c.HasPhoto,
  558. b.Valid, a.RecruitmentID, c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID), a.RemindDate,
  559. a.ReplyReason, b.SecondId ,e.CpViewDate,e.AssessTestLogID,g.Name
  560. FROM exJobApply a WITH(NOLOCK)
  561. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  562. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  563. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  564. RIGHT JOIN AssessJobapply e WITH(NOLOCK) ON e.ExJobApplyID = a.ID
  565. INNER JOIN AssessTestLog f WITH(NOLOCK) ON f.id = e.AssessTestLogID
  566. INNER JOIN AssessType g WITH(NOLOCK) ON g.id = f.AssessTypeID
  567. WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0 AND e.CpViewDate IS NOT NULL '
  568. IF LEN(@WHERE) > 0
  569. SET @SQL = @SQL + ' AND ' + @WHERE + @WHERE2
  570. --PRINT @SQL
  571. EXEC(@SQL)
  572. DECLARE @cpMainID AS INT
  573. SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
  574. --删除在cpCvShield中的简历
  575. DELETE FROM #t
  576. WHERE cvMainId IN(select cvMainId FROM cpCvShield WHERE cpMainID=@cpMainID)
  577. IF(@Page < 1)
  578. SET @Page = 1
  579. IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
  580. SET @Page = 1
  581. UPDATE #T SET paName = LEFT(dbo.GetPersonName(cvMainID, @cpMainID), 20), IsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID),
  582. HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  583. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  584. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
  585. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  586. IF EXISTS(SELECT TOP 1 'X' FROM caMain WHERE ID = @caMainID AND AccountType = 1)
  587. BEGIN
  588. UPDATE #T SET
  589. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.cpMainID=@cpMainID AND cvMainID=#T.cvMainID)
  590. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  591. END
  592. UPDATE #T
  593. SET Accept = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) WHERE a.CompanyDeleted=0 AND a.JobID = #t.JobId AND a.cvMainID = #T.cvMainID AND a.Reply = 1),
  594. NoAccept = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) WHERE a.CompanyDeleted=0 AND a.JobID = #t.JobId AND a.cvMainID = #T.cvMainID AND a.Reply > 1)
  595. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  596. AND HasInterview = 1
  597. UPDATE #T SET Speciality = (
  598. SELECT Speciality FROM cvMain WITH(NOLOCK)
  599. WHERE cvMain.ID = #T.cvMainID)
  600. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  601. UPDATE #T SET Experience = (
  602. SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
  603. WHERE cvExperience.cvMainID = #T.cvMainID
  604. ORDER BY BeginDate DESC)
  605. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  606. UPDATE #T SET cvEducationID = (
  607. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  608. WHERE cvEducation.cvMainID = #T.cvMainID
  609. AND #T.Degree = cvEducation.Degree
  610. ORDER BY Graduation DESC)
  611. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  612. --修改是否绑定微信
  613. UPDATE a SET HasWeiXin = 1
  614. FROM #T a, WxFans b WITH(NOLOCK)
  615. WHERE a.paMainID = b.PaMainID
  616. AND b.Status = 2
  617. AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  618. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  619. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  620. FROM #T a, cvEducation b WITH(NOLOCK)
  621. WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  622. UPDATE a SET a.RecruitmentName = b.RecruitmentName, a.RecruitmentDate = b.EndDate
  623. FROM #T a, Recruitment b WITH(NOLOCK)
  624. WHERE b.ID = a.RecruitmentID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  625. UPDATE a SET Email = b.Email,Mobile = b.Mobile,ContactPrivi = dbo.CheckCvPrivi(a.cvMainID,@cpMainID)
  626. FROM #T a,PaMain b WITH(NOLOCK)
  627. WHERE b.id = a.paMainID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  628. UPDATE #T
  629. SET AssessCnt = (SELECT COUNT(1) FROM AssessJobApply WITH(NOLOCK) WHERE ExJobApplyID = #T.ID)
  630. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  631. UPDATE #T SET cvMatch = dbo.GetCvMatch(cvMainID, JobID) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  632. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  633. SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  634. DECLARE @NoViewCnt INT, @NoReply INT, @ReplyYes INT, @ReplyNo INT, @SQL2 NVARCHAR(4000), @Filter INT
  635. --计算匹配度
  636. SELECT @NoViewCnt AS NoViewCnt, @NoReply AS NoReply, @ReplyYes AS ReplyYes, @ReplyNo AS ReplyNo, @Filter AS FilterCnt
  637. --修改 已查看提醒时间
  638. UPDATE ExJobApply
  639. SET CpRemindViewDate = GETDATE()
  640. WHERE JobID IN (
  641. SELECT ID FROM JOB WITH(NOLOCK)
  642. WHERE CaMainID = @caMainID
  643. ) AND RemindDate IS NOT NULL
  644. AND CpRemindViewDate IS NULL
  645. DROP TABLE #T
  646. END
  647. GO
  648. /****** Object: StoredProcedure [dbo].[ccExJobApplyByCaMainIDSelect] Script Date: 2018/12/13 19:06:49 ******/
  649. SET ANSI_NULLS ON
  650. GO
  651. SET QUOTED_IDENTIFIER ON
  652. GO
  653. --Nick 20140821 修改
  654. -- 加入修改应聘简历的查看日期viewdate
  655. --20160107
  656. --加入是否绑定微信
  657. --Carl 修改 自动答复的 应放到储备下面而不是 待答复下面
  658. --carl 2018-2-26
  659. --harry 2018-6-11 cpCvShield中的不显示
  660. --alen 2018-9-28 添加标签功能
  661. --Peter 2018-10-15 添加个人联系方式以及权限
  662. CREATE PROCEDURE [dbo].[ccExJobApplyByCaMainIDSelect]
  663. (
  664. @WHERE VARCHAR(1000),
  665. @Order VARCHAR(100),
  666. @Page SMALLINT,
  667. @caMainID INT,
  668. @ReplyType INT
  669. )
  670. AS
  671. SET NOCOUNT ON
  672. BEGIN
  673. DECLARE @WHERE2 VARCHAR(MAX)
  674. IF @ReplyType = 5
  675. BEGIN
  676. SET @WHERE2 = ' And IsFilter = 0 AND Reply = 0 AND ViewDate IS NULL'
  677. END
  678. ELSE IF @ReplyType = 1
  679. BEGIN
  680. SET @WHERE2 = ' And IsFilter = 0 AND Reply = 0 AND ViewDate IS NOT NULL'
  681. END
  682. ELSE IF @ReplyType = 2
  683. BEGIN
  684. SET @WHERE2 = ' And IsFilter = 0 AND Reply = 1 AND ViewDate IS NOT NULL'
  685. END
  686. ELSE IF @ReplyType = 3
  687. BEGIN
  688. SET @WHERE2 = ' And IsFilter = 0 AND (Reply = 2 OR Reply = 5) AND ViewDate IS NOT NULL'
  689. END
  690. ELSE IF @ReplyType = 4
  691. BEGIN
  692. SET @WHERE2 = ' And IsFilter = 1 ' --AND ViewDate is null'
  693. END
  694. ELSE
  695. SET @WHERE2 = ' And IsFilter = 0'
  696. SET @Where = dbo.SafeSql(@Where)
  697. SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '''''')
  698. DECLARE @SQL AS VARCHAR(2000)
  699. CREATE TABLE #T(
  700. TitleID BIGINT,
  701. ID INT,
  702. JobID INT,
  703. paMainID INT,
  704. cvMainID INT,
  705. AddDate SMALLDATETIME,
  706. Reply TINYINT,
  707. ReplyDate SMALLDATETIME,
  708. IsMatched BIT,
  709. Degree TINYINT,
  710. RelatedWorkYears TINYINT,
  711. LivePlace NVARCHAR(50),
  712. Gender BIT,
  713. paName NVARCHAR(20),
  714. BirthDay INT,
  715. HasPhoto TINYINT,
  716. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  717. IsNameHidden BIT,
  718. Valid TINYINT,
  719. ApplyMessage NVARCHAR(1),
  720. IsViewed BIT,
  721. HasInterview BIT,
  722. HasRemark BIT,
  723. HasFavorate BIT,
  724. cvEducationID INT,
  725. College NVARCHAR(50),
  726. EduType TINYINT,
  727. MajorName NVARCHAR(20),
  728. Graduation INT,
  729. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  730. Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  731. cvMatch INT,
  732. RecruitmentID INT,
  733. RecruitmentName NVARCHAR(100),
  734. RecruitmentDate SMALLDATETIME,
  735. MobileVerifyDate SMALLDATETIME,
  736. IsOnline BIT,
  737. RemindDate DATETIME,
  738. HasWeiXin BIT,
  739. ReplyReason VARCHAR(200),
  740. Accept BIT,
  741. NoAccept BIT,
  742. SecondId VARCHAR(10),
  743. Mobile VARCHAR(15),
  744. Email VARCHAR(100),
  745. ContactPrivi BIT,
  746. AssessCnt INT
  747. )
  748. SET @SQL='
  749. INSERT INTO #T(TitleID, ID, JobID, paMainID, cvMainID, AddDate, Reply, ReplyDate, IsMatched,
  750. ApplyMessage, Degree, RelatedWorkYears, Attachment, IsNameHidden, LivePlace, Gender, BirthDay,
  751. HasPhoto, Valid, RecruitmentID, MobileVerifyDate, IsOnline, RemindDate, ReplyReason, SecondId)
  752. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, a.JobID, c.ID, a.cvMainID,
  753. a.AddDate, a.Reply, a.ReplyDate, a.IsMatched, LEFT(a.ApplyMessage, 1) ApplyMessage, b.Degree,
  754. b.RelatedWorkYears, b.Attachment, b.IsNameHidden, c.LivePlace, c.Gender, c.BirthDay, c.HasPhoto,
  755. b.Valid, a.RecruitmentID, c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID), a.RemindDate,
  756. a.ReplyReason, b.SecondId
  757. FROM exJobApply a WITH(NOLOCK)
  758. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  759. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  760. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  761. WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0 '
  762. IF LEN(@WHERE) > 0
  763. SET @SQL = @SQL + ' AND ' + @WHERE + @WHERE2
  764. --PRINT @SQL
  765. EXEC(@SQL)
  766. DECLARE @cpMainID AS INT
  767. SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
  768. --删除在cpCvShield中的简历
  769. DELETE FROM #t
  770. WHERE cvMainId IN(select cvMainId FROM cpCvShield WHERE cpMainID=@cpMainID)
  771. IF(@Page < 1)
  772. SET @Page = 1
  773. IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
  774. SET @Page = 1
  775. UPDATE #T SET paName = LEFT(dbo.GetPersonName(cvMainID, @cpMainID), 20), IsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID),
  776. HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  777. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  778. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
  779. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  780. IF EXISTS(SELECT TOP 1 'X' FROM caMain WHERE ID = @caMainID AND AccountType = 1)
  781. BEGIN
  782. UPDATE #T SET
  783. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.cpMainID=@cpMainID AND cvMainID=#T.cvMainID)
  784. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  785. END
  786. UPDATE #T
  787. SET Accept = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) WHERE a.CompanyDeleted=0 AND a.JobID = #t.JobId AND a.cvMainID = #T.cvMainID AND a.Reply = 1),
  788. NoAccept = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) WHERE a.CompanyDeleted=0 AND a.JobID = #t.JobId AND a.cvMainID = #T.cvMainID AND a.Reply > 1)
  789. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  790. AND HasInterview = 1
  791. UPDATE #T SET Speciality = (
  792. SELECT Speciality FROM cvMain WITH(NOLOCK)
  793. WHERE cvMain.ID = #T.cvMainID)
  794. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  795. UPDATE #T SET Experience = (
  796. SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
  797. WHERE cvExperience.cvMainID = #T.cvMainID
  798. ORDER BY BeginDate DESC)
  799. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  800. UPDATE #T SET cvEducationID = (
  801. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  802. WHERE cvEducation.cvMainID = #T.cvMainID
  803. AND #T.Degree = cvEducation.Degree
  804. ORDER BY Graduation DESC)
  805. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  806. --修改是否绑定微信
  807. UPDATE a SET HasWeiXin = 1
  808. FROM #T a, WxFans b WITH(NOLOCK)
  809. WHERE a.paMainID = b.PaMainID
  810. AND b.Status = 2
  811. AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  812. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  813. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  814. FROM #T a, cvEducation b WITH(NOLOCK)
  815. WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  816. UPDATE a SET a.RecruitmentName = b.RecruitmentName, a.RecruitmentDate = b.EndDate
  817. FROM #T a, Recruitment b WITH(NOLOCK)
  818. WHERE b.ID = a.RecruitmentID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  819. UPDATE a SET Email = b.Email,Mobile = b.Mobile,ContactPrivi = dbo.CheckCvPrivi(a.cvMainID,@cpMainID)
  820. FROM #T a,PaMain b WITH(NOLOCK)
  821. WHERE b.id = a.paMainID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  822. UPDATE #T
  823. SET AssessCnt = (SELECT COUNT(1) FROM AssessJobApply WITH(NOLOCK) WHERE ExJobApplyID = #T.ID)
  824. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  825. UPDATE #T SET cvMatch = dbo.GetCvMatch(cvMainID, JobID) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  826. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  827. SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  828. DECLARE @NoViewCnt INT, @NoReply INT, @ReplyYes INT, @ReplyNo INT, @SQL2 NVARCHAR(4000), @Filter INT
  829. --未查看数量
  830. SET @SQL2 = '
  831. SELECT @NoViewCnt1 = COUNT(*)
  832. FROM exJobApply a WITH(NOLOCK)
  833. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  834. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  835. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  836. WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0
  837. And a.IsFilter = 0
  838. AND a.Reply=0
  839. AND a.ViewDate is null AND ' + @WHERE
  840. EXEC SP_EXECUTESQL @SQL2, N'@NoViewCnt1 int OUTPUT', @NoViewCnt OUTPUT
  841. --待答复数量
  842. SET @SQL2 = '
  843. SELECT @NoReply1 = COUNT(*)
  844. FROM exJobApply a WITH(NOLOCK)
  845. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  846. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  847. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  848. WHERE a.CompanyDeleted = 0
  849. AND d.IsDelete = 0
  850. And a.IsFilter = 0
  851. AND Reply=0
  852. AND ViewDate IS NOT NULL
  853. AND ' + @WHERE
  854. EXEC SP_EXECUTESQL @SQL2, N'@NoReply1 int OUTPUT', @NoReply OUTPUT
  855. --符合要求数量
  856. SET @SQL2 = '
  857. SELECT @ReplyYes1 = COUNT(*)
  858. FROM exJobApply a WITH(NOLOCK)
  859. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  860. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  861. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  862. WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0
  863. And a.IsFilter = 0
  864. AND Reply=1
  865. AND ' + @WHERE
  866. EXEC SP_EXECUTESQL @SQL2, N'@ReplyYes1 int OUTPUT', @ReplyYes OUTPUT
  867. --不符合要求数量
  868. SET @SQL2 = ' SELECT @ReplyNo1 = COUNT(*)
  869. FROM exJobApply a WITH(NOLOCK)
  870. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  871. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  872. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  873. WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0
  874. And a.IsFilter = 0
  875. AND Reply IN(2, 5) AND ' + @WHERE
  876. EXEC SP_EXECUTESQL @SQL2, N'@ReplyNo1 int OUTPUT', @ReplyNo OUTPUT
  877. --未查看数量
  878. SET @SQL2 = '
  879. SELECT @Filter1 = COUNT(*)
  880. FROM exJobApply a WITH(NOLOCK)
  881. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  882. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  883. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  884. WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0
  885. And a.IsFilter = 1
  886. AND ' + @WHERE
  887. EXEC SP_EXECUTESQL @SQL2, N'@Filter1 int OUTPUT', @Filter OUTPUT
  888. --计算匹配度
  889. SELECT @NoViewCnt AS NoViewCnt, @NoReply AS NoReply, @ReplyYes AS ReplyYes, @ReplyNo AS ReplyNo, @Filter AS FilterCnt
  890. --修改 已查看提醒时间
  891. UPDATE ExJobApply
  892. SET CpRemindViewDate = GETDATE()
  893. WHERE JobID IN (
  894. SELECT ID FROM JOB WITH(NOLOCK)
  895. WHERE CaMainID = @caMainID
  896. ) AND RemindDate IS NOT NULL
  897. AND CpRemindViewDate IS NULL
  898. DROP TABLE #T
  899. END
  900. GO
  901. /****** Object: StoredProcedure [dbo].[ccExJobApplyByCaMainIDSelect2] Script Date: 2018/12/13 19:06:49 ******/
  902. SET ANSI_NULLS ON
  903. GO
  904. SET QUOTED_IDENTIFIER ON
  905. GO
  906. --Nick 20140821 修改
  907. -- 加入修改应聘简历的查看日期viewdate
  908. --20160107
  909. --加入是否绑定微信
  910. CREATE PROCEDURE [dbo].[ccExJobApplyByCaMainIDSelect2]
  911. (
  912. @WHERE VARCHAR(1000),
  913. @Order VARCHAR(100),
  914. @Page SMALLINT,
  915. @caMainID INT,
  916. @ReplyType INT
  917. )
  918. AS
  919. SET NOCOUNT ON
  920. BEGIN
  921. DECLARE @WHERE2 VARCHAR(MAX)
  922. IF @ReplyType = 5
  923. BEGIN
  924. SET @WHERE2 = ' And IsFilter = 0 AND Reply = 0 AND ViewDate IS NULL'
  925. END
  926. ELSE IF @ReplyType = 1
  927. BEGIN
  928. SET @WHERE2 = ' And IsFilter = 0 AND (Reply = 0 OR Reply = 5) AND ViewDate IS NOT NULL'
  929. END
  930. ELSE IF @ReplyType = 2
  931. BEGIN
  932. SET @WHERE2 = ' And IsFilter = 0 AND Reply = 1 AND ViewDate IS NOT NULL'
  933. END
  934. ELSE IF @ReplyType = 3
  935. BEGIN
  936. SET @WHERE2 = ' And IsFilter = 0 AND Reply = 2 AND ViewDate IS NOT NULL'
  937. END
  938. ELSE IF @ReplyType = 4
  939. BEGIN
  940. SET @WHERE2 = ' And IsFilter = 1 ' --AND ViewDate is null'
  941. END
  942. ELSE
  943. SET @WHERE2 = ' And IsFilter = 0'
  944. SET @Where = dbo.SafeSql(@Where)
  945. SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '''''')
  946. DECLARE @SQL AS VARCHAR(2000)
  947. CREATE TABLE #T(
  948. TitleID BIGINT,
  949. ID INT,
  950. JobID INT,
  951. paMainID INT,
  952. cvMainID INT,
  953. AddDate SMALLDATETIME,
  954. Reply TINYINT,
  955. ReplyDate SMALLDATETIME,
  956. IsMatched BIT,
  957. Degree TINYINT,
  958. RelatedWorkYears TINYINT,
  959. LivePlace NVARCHAR(50),
  960. Gender BIT,
  961. paName NVARCHAR(20),
  962. BirthDay INT,
  963. HasPhoto TINYINT,
  964. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  965. IsNameHidden BIT,
  966. Valid TINYINT,
  967. ApplyMessage NVARCHAR(1),
  968. IsViewed BIT,
  969. HasInterview BIT,
  970. HasRemark BIT,
  971. HasFavorate BIT,
  972. cvEducationID INT,
  973. College NVARCHAR(50),
  974. EduType TINYINT,
  975. MajorName NVARCHAR(20),
  976. Graduation INT,
  977. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  978. Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  979. cvMatch INT,
  980. RecruitmentID INT,
  981. RecruitmentName NVARCHAR(100),
  982. RecruitmentDate SMALLDATETIME,
  983. MobileVerifyDate SMALLDATETIME,
  984. IsOnline BIT,
  985. RemindDate DATETIME,
  986. HasWeiXin BIT,
  987. ReplyReason VARCHAR(200),
  988. Accept BIT,
  989. NoAccept BIT,
  990. SecondId VARCHAR(10)
  991. )
  992. SET @SQL='
  993. INSERT INTO #T(TitleID, ID, JobID, paMainID, cvMainID, AddDate, Reply, ReplyDate, IsMatched,
  994. ApplyMessage, Degree, RelatedWorkYears, Attachment, IsNameHidden, LivePlace, Gender, BirthDay,
  995. HasPhoto, Valid, RecruitmentID, MobileVerifyDate, IsOnline, RemindDate, ReplyReason, SecondId)
  996. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, a.JobID, c.ID, a.cvMainID,
  997. a.AddDate, a.Reply, a.ReplyDate, a.IsMatched, LEFT(a.ApplyMessage, 1) ApplyMessage, b.Degree,
  998. b.RelatedWorkYears, b.Attachment, b.IsNameHidden, c.LivePlace, c.Gender, c.BirthDay, c.HasPhoto,
  999. b.Valid, a.RecruitmentID, c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID), a.RemindDate,
  1000. a.ReplyReason, b.SecondId
  1001. FROM exJobApply a WITH(NOLOCK)
  1002. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  1003. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  1004. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  1005. WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0'
  1006. IF LEN(@WHERE) > 0
  1007. SET @SQL = @SQL + ' AND ' + @WHERE + @WHERE2
  1008. EXEC(@SQL)
  1009. IF(@Page < 1)
  1010. SET @Page = 1
  1011. IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
  1012. SET @Page = 1
  1013. DECLARE @cpMainID AS INT
  1014. SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
  1015. UPDATE #T SET paName = LEFT(dbo.GetPersonName(cvMainID, @cpMainID), 20), IsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID),
  1016. HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  1017. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  1018. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
  1019. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  1020. IF EXISTS(SELECT TOP 1 'X' FROM caMain WHERE ID = @caMainID AND AccountType = 1)
  1021. BEGIN
  1022. UPDATE #T SET
  1023. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.cpMainID=@cpMainID AND cvMainID=#T.cvMainID)
  1024. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  1025. END
  1026. UPDATE #T
  1027. SET Accept = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) WHERE a.CompanyDeleted=0 AND a.JobID = #t.JobId AND a.cvMainID = #T.cvMainID AND a.Reply = 1),
  1028. NoAccept = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) WHERE a.CompanyDeleted=0 AND a.JobID = #t.JobId AND a.cvMainID = #T.cvMainID AND a.Reply > 1)
  1029. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  1030. AND HasInterview = 1
  1031. UPDATE #T SET Speciality = (
  1032. SELECT Speciality FROM cvMain WITH(NOLOCK)
  1033. WHERE cvMain.ID = #T.cvMainID)
  1034. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  1035. UPDATE #T SET Experience = (
  1036. SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
  1037. WHERE cvExperience.cvMainID = #T.cvMainID
  1038. ORDER BY BeginDate DESC)
  1039. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  1040. UPDATE #T SET cvEducationID = (
  1041. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  1042. WHERE cvEducation.cvMainID = #T.cvMainID
  1043. AND #T.Degree = cvEducation.Degree
  1044. ORDER BY Graduation DESC)
  1045. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  1046. --修改是否绑定微信
  1047. UPDATE a SET HasWeiXin = 1
  1048. FROM #T a, WxFans b WITH(NOLOCK)
  1049. WHERE a.paMainID = b.PaMainID
  1050. AND b.Status = 2
  1051. AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  1052. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  1053. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  1054. FROM #T a, cvEducation b WITH(NOLOCK)
  1055. WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  1056. UPDATE a SET a.RecruitmentName = b.RecruitmentName, a.RecruitmentDate = b.EndDate
  1057. FROM #T a, Recruitment b WITH(NOLOCK)
  1058. WHERE b.ID = a.RecruitmentID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  1059. UPDATE #T SET cvMatch = dbo.GetCvMatch(cvMainID, JobID) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  1060. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  1061. SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  1062. DECLARE @NoViewCnt INT, @NoReply INT, @ReplyYes INT, @ReplyNo INT, @SQL2 NVARCHAR(4000), @Filter INT
  1063. --未查看数量
  1064. SET @SQL2 = '
  1065. SELECT @NoViewCnt1 = COUNT(*)
  1066. FROM exJobApply a WITH(NOLOCK)
  1067. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  1068. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  1069. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  1070. WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0
  1071. And a.IsFilter = 0
  1072. AND a.Reply=0
  1073. AND a.ViewDate is null AND ' + @WHERE
  1074. EXEC SP_EXECUTESQL @SQL2, N'@NoViewCnt1 int OUTPUT', @NoViewCnt OUTPUT
  1075. --待答复数量
  1076. SET @SQL2 = '
  1077. SELECT @NoReply1 = COUNT(*)
  1078. FROM exJobApply a WITH(NOLOCK)
  1079. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  1080. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  1081. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  1082. WHERE a.CompanyDeleted = 0
  1083. AND d.IsDelete = 0
  1084. And a.IsFilter = 0
  1085. AND (Reply=0 OR Reply = 5)
  1086. AND ViewDate IS NOT NULL
  1087. AND ' + @WHERE
  1088. EXEC SP_EXECUTESQL @SQL2, N'@NoReply1 int OUTPUT', @NoReply OUTPUT
  1089. --符合要求数量
  1090. SET @SQL2 = '
  1091. SELECT @ReplyYes1 = COUNT(*)
  1092. FROM exJobApply a WITH(NOLOCK)
  1093. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  1094. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  1095. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  1096. WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0
  1097. And a.IsFilter = 0
  1098. AND Reply=1
  1099. AND ' + @WHERE
  1100. EXEC SP_EXECUTESQL @SQL2, N'@ReplyYes1 int OUTPUT', @ReplyYes OUTPUT
  1101. --不符合要求数量
  1102. SET @SQL2 = '
  1103. SELECT @ReplyNo1 = COUNT(*)
  1104. FROM exJobApply a WITH(NOLOCK)
  1105. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  1106. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  1107. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  1108. WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0
  1109. And a.IsFilter = 0
  1110. AND Reply = 2 AND ' + @WHERE
  1111. EXEC SP_EXECUTESQL @SQL2, N'@ReplyNo1 int OUTPUT', @ReplyNo OUTPUT
  1112. --未查看数量
  1113. SET @SQL2 = '
  1114. SELECT @Filter1 = COUNT(*)
  1115. FROM exJobApply a WITH(NOLOCK)
  1116. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  1117. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  1118. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  1119. WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0
  1120. And a.IsFilter = 1
  1121. AND ' + @WHERE
  1122. EXEC SP_EXECUTESQL @SQL2, N'@Filter1 int OUTPUT', @Filter OUTPUT
  1123. --计算匹配度
  1124. SELECT @NoViewCnt AS NoViewCnt, @NoReply AS NoReply, @ReplyYes AS ReplyYes, @ReplyNo AS ReplyNo, @Filter AS FilterCnt
  1125. --修改 已查看提醒时间
  1126. UPDATE ExJobApply
  1127. SET CpRemindViewDate = GETDATE()
  1128. WHERE JobID IN (
  1129. SELECT ID FROM JOB WITH(NOLOCK)
  1130. WHERE CaMainID = @caMainID
  1131. ) AND RemindDate IS NOT NULL
  1132. AND CpRemindViewDate IS NULL
  1133. DROP TABLE #T
  1134. END
  1135. GO
  1136. /****** Object: StoredProcedure [dbo].[ccExJobApplyByCpMainIDReplyUpdate] Script Date: 2018/12/13 19:06:50 ******/
  1137. SET ANSI_NULLS ON
  1138. GO
  1139. SET QUOTED_IDENTIFIER ON
  1140. GO
  1141. --答复后修改答复状态(无积分)
  1142. --2017-5-25harry
  1143. CREATE PROCEDURE [dbo].[ccExJobApplyByCpMainIDReplyUpdate]
  1144. (
  1145. @AllID VARCHAR(1000),
  1146. @Reply INT,
  1147. @cpMainID INT
  1148. )
  1149. AS
  1150. SET NOCOUNT ON
  1151. BEGIN
  1152. SET @AllID = dbo.FormatIDS(@AllID)
  1153. DECLARE @T AS TABLE(ID INT)
  1154. INSERT INTO @T SELECT * FROM dbo.fnSplit(@AllID, ',')
  1155. --SELECT TOP 20 * FROM EXJOBAPPLY
  1156. SELECT ID,Reply,RemindDate FROM EXJOBAPPLY WHERE ID IN (SELECT ID FROM @t)
  1157. --未提醒答复数量
  1158. DECLARE @CNT1 INT,@CNT2 INT,@CNT3 INT
  1159. SELECT @CNT1 = COUNT(*)
  1160. FROM exJobApply
  1161. WHERE ID IN (SELECT ID FROM @T)
  1162. AND Reply = 0
  1163. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  1164. AND RemindDate IS NULL
  1165. --提醒答复72小时内回复的
  1166. SELECT @CNT2 = COUNT(*)
  1167. FROM exJobApply
  1168. WHERE ID IN (SELECT ID FROM @T)
  1169. AND Reply = 0
  1170. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  1171. AND DATEADD(DAY,3,RemindDate)>GETDATE()
  1172. --提醒答复72小时内未回复的
  1173. SELECT @CNT3 = COUNT(*)
  1174. FROM exJobApply
  1175. WHERE ID IN (SELECT ID FROM @T)
  1176. AND Reply = 0
  1177. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  1178. AND DATEADD(DAY,3,RemindDate)<=GETDATE()
  1179. UPDATE exJobApply SET Reply = @Reply, ReplyDate = GETDATE(),IsDeleted = 0,PersonDeleted = 0
  1180. WHERE ID IN(SELECT ID FROM @T)
  1181. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK)
  1182. WHERE cpMainID = @cpMainID)
  1183. --修改查看时间
  1184. UPDATE exJobApply SET ViewDate = GETDATE()
  1185. WHERE ID IN(SELECT ID FROM @T)
  1186. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK)
  1187. WHERE cpMainID = @cpMainID)
  1188. AND ViewDate IS NULL
  1189. --Harry Begin
  1190. IF @Reply IN(1, 2, 3, 4)
  1191. BEGIN
  1192. INSERT WxMessageSend2(Templatetype, WxFansID, PaMainId, MainTableId, CpMainID, CvMainID, JobId, AddDate)
  1193. SELECT 9, b.Id, c.paMainId, a.Id, @cpMainId, c.Id, a.JobId, GETDATE()
  1194. FROM exJobApply a WITH(NOLOCK),
  1195. wxFans b WITH(NOLOCK),
  1196. cvMain c WITH(NOLOCK)
  1197. WHERE a.ID IN(SELECT ID FROM @T)
  1198. AND a.cvMainID = c.ID
  1199. AND b.PaMainId = c.PaMainId
  1200. AND b.[Status] = 2
  1201. INSERT INTO paPushLog(paMainID, PushMessage, PushType)
  1202. SELECT b.paMainID, '亲,有企业回复了您的职位申请!', 1
  1203. FROM exJobApply a WITH(NOLOCK),
  1204. cvMain b WITH(NOLOCK)
  1205. WHERE a.ID IN(SELECT ID FROM @T)
  1206. AND a.cvMainID = b.ID
  1207. AND b.paMainID IN(SELECT paMainID FROM paIOSBind WITH(NOLOCK))
  1208. END
  1209. --Harry End
  1210. END
  1211. GO
  1212. /****** Object: StoredProcedure [dbo].[ccExJobApplyByCpMainIDUpdate] Script Date: 2018/12/13 19:06:50 ******/
  1213. SET ANSI_NULLS ON
  1214. GO
  1215. SET QUOTED_IDENTIFIER ON
  1216. GO
  1217. --添加积分记录
  1218. --答复后修改答复状态
  1219. --20151124 nick
  1220. --20160215 Lucifer 添加推送内容
  1221. --修改Harry2017-5-25 增加自动答复的答复率计算
  1222. --20180223 Carl 自动答复之后再手动答复也送积分
  1223. CREATE PROCEDURE [dbo].[ccExJobApplyByCpMainIDUpdate]
  1224. (
  1225. @AllID VARCHAR(1000),
  1226. @Reply INT,
  1227. @cpMainID INT
  1228. )
  1229. AS
  1230. SET NOCOUNT ON
  1231. BEGIN
  1232. DECLARE @Reply72Point INT --72小时内答复简历 赠送积分
  1233. DECLARE @ReplyPoint INT --答复应聘简历 赠送积分
  1234. SET @Reply72Point = 15
  1235. SET @ReplyPoint = 10
  1236. SET @AllID = dbo.FormatIDS(@AllID)
  1237. DECLARE @T AS TABLE(ID INT)
  1238. INSERT INTO @T SELECT * FROM dbo.fnSplit(@AllID, ',')
  1239. --SELECT TOP 20 * FROM EXJOBAPPLY
  1240. SELECT ID,Reply,RemindDate FROM EXJOBAPPLY WHERE ID IN (SELECT ID FROM @t)
  1241. --查询7天之内应聘的数量
  1242. --DECLARE @ExJobApplyNum AS INT
  1243. --SELECT @ExJobApplyNum = COUNT(1)
  1244. --FROM exJobApply
  1245. --WHERE ID IN(SELECT ID FROM @T)
  1246. -- AND Reply = 0
  1247. -- AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  1248. -- AND Adddate > (CONVERT(VARCHAR(10),GETDATE()-7,120))
  1249. --插入积分记录 Peter 2014-08-25
  1250. DECLARE @TodayPoint AS INT, @TodayID AS INT
  1251. SELECT @TodayPoint = 0, @TodayID = 0
  1252. SELECT TOP 1 @TodayPoint = ISNULL(Point, 0), @TodayID = ISNULL(ID,0)
  1253. FROM cpPoint WITH(NOLOCK)
  1254. WHERE changeID = 14
  1255. AND LastModifyDate > CONVERT(VARCHAR(10), GETDATE(),120)
  1256. AND cpMainID = @cpMainID
  1257. --未提醒答复数量
  1258. DECLARE @CNT1 INT,@CNT2 INT,@CNT3 INT
  1259. SELECT @CNT1 = COUNT(*)
  1260. FROM exJobApply
  1261. WHERE ID IN (SELECT ID FROM @T)
  1262. AND Reply in (0,5)
  1263. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  1264. AND RemindDate IS NULL
  1265. --提醒答复72小时内回复的
  1266. SELECT @CNT2 = COUNT(*)
  1267. FROM exJobApply
  1268. WHERE ID IN (SELECT ID FROM @T)
  1269. AND Reply in (0,5)
  1270. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  1271. AND DATEADD(DAY,3,RemindDate)>GETDATE()
  1272. --提醒答复72小时内未回复的
  1273. SELECT @CNT3 = COUNT(*)
  1274. FROM exJobApply
  1275. WHERE ID IN (SELECT ID FROM @T)
  1276. AND Reply in (0,5)
  1277. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  1278. AND DATEADD(DAY,3,RemindDate)<=GETDATE()
  1279. SET @TodayPoint = @TodayPoint + @CNT1*@ReplyPoint+@CNT2*@Reply72Point+@CNT3*(@Reply72Point-@ReplyPoint)
  1280. IF @TodayPoint > 100
  1281. BEGIN
  1282. SET @TodayPoint = 100
  1283. UPDATE cpPoint SET Point = @TodayPoint,LastModifyDate = GETDATE() WHERE ID = @TodayID
  1284. END
  1285. ELSE
  1286. BEGIN
  1287. IF @TodayID = 0
  1288. BEGIN
  1289. INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate)
  1290. VALUES(@cpMainID,14,@CNT1*@ReplyPoint+@CNT2*@Reply72Point+@CNT3*(@Reply72Point-@ReplyPoint),GETDATE())
  1291. END
  1292. ELSE
  1293. BEGIN
  1294. UPDATE cpPoint SET Point = @TodayPoint+@CNT1*@ReplyPoint+@CNT2*@Reply72Point+@CNT3*(@Reply72Point-@ReplyPoint),LastModifyDate = GETDATE() WHERE ID = @TodayID
  1295. END
  1296. END
  1297. UPDATE exJobApply SET Reply = @Reply, ReplyDate = GETDATE(),IsDeleted = 0,PersonDeleted = 0
  1298. WHERE ID IN(SELECT ID FROM @T)
  1299. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK)
  1300. WHERE cpMainID = @cpMainID)
  1301. --修改查看时间
  1302. UPDATE exJobApply SET ViewDate = GETDATE()
  1303. WHERE ID IN(SELECT ID FROM @T)
  1304. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK)
  1305. WHERE cpMainID = @cpMainID)
  1306. AND ViewDate IS NULL
  1307. --Harry Begin
  1308. IF @Reply IN(1, 2, 3, 4)
  1309. BEGIN
  1310. INSERT WxMessageSend2(Templatetype, WxFansID, PaMainId, MainTableId, CpMainID, CvMainID, JobId, AddDate)
  1311. SELECT 9, b.Id, c.paMainId, a.Id, @cpMainId, c.Id, a.JobId, GETDATE()
  1312. FROM exJobApply a WITH(NOLOCK),
  1313. wxFans b WITH(NOLOCK),
  1314. cvMain c WITH(NOLOCK)
  1315. WHERE a.ID IN(SELECT ID FROM @T)
  1316. AND a.cvMainID = c.ID
  1317. AND b.PaMainId = c.PaMainId
  1318. AND b.[Status] = 2
  1319. INSERT INTO paPushLog(paMainID, PushMessage, PushType)
  1320. SELECT b.paMainID, '亲,有企业回复了您的职位申请!', 1
  1321. FROM exJobApply a WITH (NOLOCK),
  1322. cvMain b WITH(NOLOCK)
  1323. WHERE a.ID IN(SELECT ID FROM @T)
  1324. AND a.cvMainID = b.ID
  1325. AND b.paMainID IN(SELECT paMainID FROM paIOSBind WITH(NOLOCK))
  1326. END
  1327. --Harry End
  1328. END
  1329. GO
  1330. /****** Object: StoredProcedure [dbo].[ccExJobApplyBycvMainIDDelete] Script Date: 2018/12/13 19:06:50 ******/
  1331. SET ANSI_NULLS ON
  1332. GO
  1333. SET QUOTED_IDENTIFIER ON
  1334. GO
  1335. --lambo 20101122
  1336. --删除该简历所有对本企业的申请记录
  1337. --用于发送面试通知页面
  1338. CREATE PROCEDURE [dbo].[ccExJobApplyBycvMainIDDelete]
  1339. (
  1340. @cvMainID INT,
  1341. @cpMainID INT
  1342. )
  1343. AS
  1344. BEGIN
  1345. BEGIN TRY
  1346. DELETE FROM exJobApply
  1347. WHERE cvMainID = @cvMainID
  1348. AND JobID IN
  1349. (
  1350. SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID
  1351. )
  1352. RETURN 1
  1353. END TRY
  1354. BEGIN CATCH
  1355. RETURN 0
  1356. END CATCH
  1357. END
  1358. GO
  1359. /****** Object: StoredProcedure [dbo].[ccExJobApplyByCvMainIDSelect] Script Date: 2018/12/13 19:06:51 ******/
  1360. SET ANSI_NULLS ON
  1361. GO
  1362. SET QUOTED_IDENTIFIER ON
  1363. GO
  1364. --#####################################################
  1365. --修改:Andy 2015-01-13 添加职位的regionid
  1366. --修改:harry 提升企业答复率,企业删除的也需要答复2017-5-4
  1367. --#####################################################
  1368. CREATE PROCEDURE [dbo].[ccExJobApplyByCvMainIDSelect]
  1369. (
  1370. @caMainID INT,
  1371. @cvMainID INT,
  1372. @cpMainID INT
  1373. )
  1374. AS
  1375. BEGIN
  1376. IF @cpMainID > 0
  1377. SELECT a.ID,a.JobID,b.dcRegionID,a.cvMainID,a.ApplyMessage,a.AddDate,c.Name caName,
  1378. a.CompanyDeleted,a.CompanyDeleteDate,a.PersonDeleted,
  1379. a.Reply,a.ReplyDate,a.IsPassed,
  1380. b.Name JobName,b.caMainID, a.RemindDate
  1381. FROM exJobApply a WITH(NOLOCK)
  1382. INNER JOIN Job b WITH(NOLOCK) ON b.ID=a.JobID
  1383. INNER JOIN caMain c WITH(NOLOCK) ON b.caMainID=c.ID
  1384. WHERE cvMainID=@cvMainID
  1385. AND c.cpMainID=@cpMainID
  1386. --AND CompanyDeleted=0
  1387. ORDER BY a.adddate asc
  1388. IF @cpMainID = 0
  1389. SELECT a.ID,a.JobID,b.dcRegionID,a.cvMainID,a.ApplyMessage,a.AddDate,
  1390. a.CompanyDeleted,a.CompanyDeleteDate,a.PersonDeleted,
  1391. a.Reply,a.ReplyDate,a.IsPassed,
  1392. b.Name as JobName,b.caMainID, a.RemindDate
  1393. FROM exJobApply a WITH(NOLOCK)
  1394. inner join Job b WITH(NOLOCK) On b.ID=a.JobID
  1395. inner join cpMain c WITH(NOLOCK) On b.cpMainID=c.ID
  1396. WHERE caMainID=@caMainID
  1397. AND cvMainID=@cvMainID
  1398. --AND CompanyDeleted=0
  1399. ORDER BY a.adddate asc
  1400. END
  1401. GO
  1402. /****** Object: StoredProcedure [dbo].[ccExJobApplyByExcelSelect] Script Date: 2018/12/13 19:06:51 ******/
  1403. SET ANSI_NULLS ON
  1404. GO
  1405. SET QUOTED_IDENTIFIER ON
  1406. GO
  1407. --alen 2018-3-28
  1408. CREATE PROCEDURE [dbo].[ccExJobApplyByExcelSelect]
  1409. (
  1410. @cpMainID INT,
  1411. @WHERE VARCHAR(2000),
  1412. @Order VARCHAR(100)
  1413. )
  1414. AS
  1415. SET NOCOUNT ON
  1416. BEGIN
  1417. DECLARE @SQL AS VARCHAR(2000)
  1418. SET @SQL = 'SELECT a.ID, a.JobID, dbo.ShowContact(a.cvMainID, ' + LTRIM(STR(@cpMainID)) + ') AS ShowContact, b.paMainId, b.SecondId,
  1419. a.cvMainID, a.AddDate, a.Reply, a.ReplyDate, c.Mobile, b.Degree, b.RelatedWorkYears, c.Email, d.Name JobName,
  1420. c.LivePlace, c.Gender, c.Name AS paName, c.BirthDay, c.HasPhoto, b.Attachment, b.IsNameHidden, b.JobName JobNameRece
  1421. FROM exJobApply a WITH(NOLOCK)
  1422. inner join cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  1423. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  1424. INNER JOIN Job d WITH(NOLOCK) ON a.JobID = d.ID
  1425. WHERE CompanyDeleted = 0'
  1426. IF LEN(@WHERE)> 0
  1427. BEGIN
  1428. SET @Where = dbo.SafeSql(@Where)
  1429. SET @SQL=@SQL + ' AND ' + @WHERE
  1430. END
  1431. IF LEN(@ORDER)> 0
  1432. BEGIN
  1433. SET @ORDER = REPLACE(dbo.SafeSQLBack(@ORDER), '''', '''')
  1434. SET @SQL=@SQL + ' ORDER BY ' + @ORDER
  1435. END
  1436. EXEC(@SQL)
  1437. END
  1438. GO
  1439. /****** Object: StoredProcedure [dbo].[ccExJobApplyByFilterNoRepliedCountSelect] Script Date: 2018/12/13 19:06:51 ******/
  1440. SET ANSI_NULLS ON
  1441. GO
  1442. SET QUOTED_IDENTIFIER ON
  1443. GO
  1444. CREATE PROCEDURE [dbo].[ccExJobApplyByFilterNoRepliedCountSelect]
  1445. (
  1446. @caMainID INT
  1447. )
  1448. AS
  1449. BEGIN
  1450. SELECT COUNT(1) Cnt
  1451. FROM exJobApply a WITH(NOLOCK), Job b WITH(NOLOCK), CvMain c WITH(NOLOCK)
  1452. WHERE a.Reply = 0
  1453. And a.CompanyDeleted = 0
  1454. AND a.JobID =b.ID
  1455. AND b.caMainID = @caMainID
  1456. AND b.IsDelete = 0
  1457. AND a.IsFilter = 1
  1458. AND a.cvMainID= c.ID
  1459. END
  1460. GO
  1461. /****** Object: StoredProcedure [dbo].[ccExJobApplyByHasAppliedSelect] Script Date: 2018/12/13 19:06:51 ******/
  1462. SET ANSI_NULLS ON
  1463. GO
  1464. SET QUOTED_IDENTIFIER ON
  1465. GO
  1466. --Lambo 20101022
  1467. --查询该简历是否向本公司申请过
  1468. --用于简历显示页面
  1469. CREATE PROCEDURE [dbo].[ccExJobApplyByHasAppliedSelect]
  1470. (
  1471. @cpMainID INT,
  1472. @cvMainID INT
  1473. )
  1474. AS
  1475. BEGIN
  1476. IF EXISTS (
  1477. SELECT 'x' FROM ExJobApply a WITH(NOLOCK),Job b
  1478. WHERE a.JobID = b.ID
  1479. AND a.cvMainID = @cvMainID
  1480. AND b.cpMainID = @cpMainID
  1481. )
  1482. RETURN 1
  1483. ELSE
  1484. RETURN 0
  1485. END
  1486. GO
  1487. /****** Object: StoredProcedure [dbo].[ccExJobApplyByIDUpdate] Script Date: 2018/12/13 19:06:52 ******/
  1488. SET ANSI_NULLS ON
  1489. GO
  1490. SET QUOTED_IDENTIFIER ON
  1491. GO
  1492. --#####################################################
  1493. --创建时间:20160105
  1494. --创建人:Nick
  1495. --说明:根据ID修改答复原因
  1496. --修改harry,@point>0的才进行积分计算
  1497. --#####################################################
  1498. CREATE PROCEDURE [dbo].[ccExJobApplyByIDUpdate]
  1499. (
  1500. @ID INT,
  1501. @ReplyReason NVARCHAR(100),
  1502. @JobID INT,
  1503. @CpMainID INT,
  1504. @Point INT
  1505. )
  1506. AS
  1507. BEGIN
  1508. UPDATE ExJobApply
  1509. SET ReplyReason = @ReplyReason
  1510. WHERE ID = @ID
  1511. AND JobID = @JobID
  1512. IF @Point >0
  1513. BEGIN
  1514. --修改积分
  1515. DECLARE @TodayPoint AS INT
  1516. DECLARE @TodayID AS INT
  1517. SET @TodayPoint = 0
  1518. SET @TodayID = 0
  1519. SELECT TOP 1 @TodayPoint = ISNULL(Point,0),@TodayID = ISNULL(ID,0)
  1520. FROM cpPoint WITH(NOLOCK)
  1521. WHERE changeID = 14
  1522. AND LastModifyDate > CONVERT(VARCHAR(10), GETDATE(),120)
  1523. AND cpMainID = @CpMainID
  1524. IF @TodayID = 0
  1525. BEGIN
  1526. INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@CpMainID,14,@Point,GETDATE())
  1527. END
  1528. ELSE
  1529. BEGIN
  1530. SET @TodayPoint = @TodayPoint + @Point
  1531. IF @TodayPoint > 100
  1532. BEGIN
  1533. SET @TodayPoint = 100
  1534. END
  1535. UPDATE cpPoint SET Point = @TodayPoint,LastModifyDate = GETDATE() WHERE ID = @TodayID
  1536. END
  1537. END
  1538. END
  1539. GO
  1540. /****** Object: StoredProcedure [dbo].[ccExJobApplyByJobIDCountSelect] Script Date: 2018/12/13 19:06:52 ******/
  1541. SET ANSI_NULLS ON
  1542. GO
  1543. SET QUOTED_IDENTIFIER ON
  1544. GO
  1545. CREATE PROCEDURE [dbo].[ccExJobApplyByJobIDCountSelect]
  1546. (
  1547. @JobID INT
  1548. )
  1549. AS
  1550. BEGIN
  1551. SELECT COUNT(ID) AS ApplyCount FROM exJobApply WITH(NOLOCK) WHERE CompanyDeleted=0 AND JobID=@JobID AND (IsFilter IS NULL OR IsFilter=0)
  1552. END
  1553. GO
  1554. /****** Object: StoredProcedure [dbo].[ccExJobApplyByJobIDSelect] Script Date: 2018/12/13 19:06:52 ******/
  1555. SET ANSI_NULLS ON
  1556. GO
  1557. SET QUOTED_IDENTIFIER ON
  1558. GO
  1559. --nick 20160125
  1560. --根据简历 职位查询 应聘信息
  1561. create PROCEDURE [dbo].[ccExJobApplyByJobIDSelect]
  1562. (
  1563. @JobID INT,
  1564. @CvMainID INT
  1565. )
  1566. AS
  1567. BEGIN
  1568. SELECT TOP 1 * FROM ExJobApply WITH(NOLOCK) WHERE JobID = @JobID AND CvMainID = @CvMainID ORDER BY ID DESC
  1569. END
  1570. GO
  1571. /****** Object: StoredProcedure [dbo].[ccExJobApplyByOneWeekSelect] Script Date: 2018/12/13 19:06:53 ******/
  1572. SET ANSI_NULLS ON
  1573. GO
  1574. SET QUOTED_IDENTIFIER ON
  1575. GO
  1576. CREATE PROCEDURE [dbo].[ccExJobApplyByOneWeekSelect]
  1577. (
  1578. @caMainID INT
  1579. )
  1580. AS
  1581. BEGIN
  1582. BEGIN TRY
  1583. DECLARE @return INT
  1584. SELECT @return = COUNT(1) FROM exJobApply WITH(index(IX_exJobApply_JobId) NOLOCK)
  1585. WHERE AddDate > GETDATE() - 7
  1586. AND CompanyDeleted = 0
  1587. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE caMainID = @caMainID AND IsDelete = 0)
  1588. --AND (IsFilter IS NULL OR IsFilter=0)
  1589. RETURN @return
  1590. END TRY
  1591. BEGIN CATCH
  1592. RETURN 0
  1593. END CATCH
  1594. END
  1595. GO
  1596. /****** Object: StoredProcedure [dbo].[ccExjobApplyByRecoverUpdate] Script Date: 2018/12/13 19:06:53 ******/
  1597. SET ANSI_NULLS ON
  1598. GO
  1599. SET QUOTED_IDENTIFIER ON
  1600. GO
  1601. CREATE PROCEDURE [dbo].[ccExjobApplyByRecoverUpdate]
  1602. (
  1603. @cpMainId INT,
  1604. @Ids VARCHAR(200)
  1605. )
  1606. AS
  1607. SET NOCOUNT ON
  1608. BEGIN
  1609. DECLARE @t AS TABLE(Id INT)
  1610. INSERT INTO @t SELECT a FROM dbo.FnSplit(@Ids, ',')
  1611. DECLARE @Num INT
  1612. IF EXISTS(
  1613. SELECT 'x' FROM Job
  1614. WHERE Id IN(SELECT jobId FROM CaCvApplyDeleted WITH(NOLOCK) WHERE ID IN(SELECT ID FROM @t))
  1615. AND cpMainId != @cpMainId
  1616. )
  1617. BEGIN
  1618. SELECT -1 NUM
  1619. RETURN
  1620. END
  1621. INSERT INTO ExjobApply(JobId, cvMainId, AddDate, IsFilter, Reply, ReplyDate)
  1622. SELECT JobId, cvMainId, GETDATE(), 0, Reply, GETDATE()
  1623. FROM CaCvApplyDeleted WITH(NOLOCK)
  1624. WHERE ID IN(SELECT ID FROM @t)
  1625. AND cvDeleted = 0
  1626. AND JobDeleted = 0
  1627. SET @Num = @@RowCount
  1628. IF @Num > 0
  1629. DELETE FROM CaCvApplyDeleted
  1630. WHERE ID IN(SELECT ID FROM @t)
  1631. AND cvDeleted = 0
  1632. AND JobDeleted = 0
  1633. SELECT @Num AS Num
  1634. END
  1635. GO
  1636. /****** Object: StoredProcedure [dbo].[ccExJobApplyByViewDateUpdate] Script Date: 2018/12/13 19:06:53 ******/
  1637. SET ANSI_NULLS ON
  1638. GO
  1639. SET QUOTED_IDENTIFIER ON
  1640. GO
  1641. --2016-1-6 nick
  1642. --修改简历状态为已查看
  1643. CREATE PROCEDURE [dbo].[ccExJobApplyByViewDateUpdate]
  1644. (
  1645. @CvMainID INT,
  1646. @JobID INT
  1647. )
  1648. AS
  1649. BEGIN
  1650. UPDATE ExJobApply
  1651. SET ViewDate = GETDATE() --,isFilter = 0
  1652. WHERE CvMainID = @CvMainID
  1653. AND JobID = @JobID
  1654. AND ViewDate IS NULL
  1655. END
  1656. GO
  1657. /****** Object: StoredProcedure [dbo].[ccExJobApplyForJobIdSelect] Script Date: 2018/12/13 19:06:54 ******/
  1658. SET ANSI_NULLS ON
  1659. GO
  1660. SET QUOTED_IDENTIFIER ON
  1661. GO
  1662. --Sean 20160127
  1663. --修改harry 2017-6-14 按照申请的时间,优先显示最新申请的
  1664. CREATE PROCEDURE [dbo].[ccExJobApplyForJobIdSelect]
  1665. (
  1666. @cpMainID INT,
  1667. @cvMainID INT
  1668. )
  1669. AS
  1670. BEGIN
  1671. DECLARE @JobId VARCHAR(10)
  1672. SELECT TOP 1 @JobId = b.Id
  1673. FROM ExJobApply a WITH(NOLOCK),
  1674. Job b WITH(NOLOCK)
  1675. WHERE a.JobID = b.ID
  1676. AND a.cvMainID = @cvMainID
  1677. AND b.cpMainID = @cpMainID
  1678. ORDER BY a.Id DESC
  1679. RETURN ISNULL(@JobId, '0')
  1680. END
  1681. GO
  1682. /****** Object: StoredProcedure [dbo].[ccExJobApplySelect] Script Date: 2018/12/13 19:06:54 ******/
  1683. SET ANSI_NULLS ON
  1684. GO
  1685. SET QUOTED_IDENTIFIER ON
  1686. GO
  1687. CREATE PROCEDURE [dbo].[ccExJobApplySelect]
  1688. (
  1689. @WHERE VARCHAR(1000),
  1690. @Order VARCHAR(100),
  1691. @Page SMALLINT,
  1692. @caMainID INT
  1693. )
  1694. AS
  1695. SET NOCOUNT ON
  1696. BEGIN
  1697. BEGIN TRY
  1698. SET @Where = dbo.SafeSql(@Where)
  1699. SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '''''')
  1700. DECLARE @SQL AS VARCHAR(2000)
  1701. CREATE TABLE #T(
  1702. TitleID BIGINT,
  1703. ID INT,
  1704. JobID INT,
  1705. paMainID INT,
  1706. cvMainID INT,
  1707. AddDate SMALLDATETIME,
  1708. Reply TINYINT,
  1709. ReplyDate SMALLDATETIME,
  1710. IsMatched BIT,
  1711. Degree TINYINT,
  1712. RelatedWorkYears TINYINT,
  1713. LivePlace NVARCHAR(50),
  1714. Gender BIT,
  1715. paName NVARCHAR(20),
  1716. BirthDay INT,
  1717. HasPhoto TINYINT,
  1718. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  1719. IsNameHidden BIT,
  1720. Valid TINYINT,
  1721. ApplyMessage NVARCHAR(1),
  1722. IsViewed BIT,
  1723. HasInterview BIT,
  1724. HasRemark BIT,
  1725. HasFavorate BIT,
  1726. cvEducationID INT,
  1727. College NVARCHAR(50),
  1728. EduType TINYINT,
  1729. MajorName NVARCHAR(20),
  1730. Graduation INT,
  1731. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  1732. Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  1733. cvMatch INT,
  1734. RecruitmentID INT,
  1735. RecruitmentName NVARCHAR(100),
  1736. RecruitmentDate SMALLDATETIME,
  1737. MobileVerifyDate SMALLDATETIME,
  1738. IsOnline BIT,
  1739. RemindDate DATETIME,
  1740. HasWeiXin BIT,
  1741. HasAccept BIT,
  1742. HsaNoAccept BIT
  1743. )
  1744. SET @SQL='
  1745. INSERT INTO #T
  1746. (TitleID, ID, JobID, paMainID, cvMainID, AddDate, Reply, ReplyDate, IsMatched, ApplyMessage,
  1747. Degree,RelatedWorkYears,Attachment,IsNameHidden,LivePlace,Gender,
  1748. BirthDay,HasPhoto,Valid,RecruitmentID,MobileVerifyDate,IsOnline,RemindDate)
  1749. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, a.JobID, c.ID, a.cvMainID,
  1750. a.AddDate, a.Reply, a.ReplyDate, a.IsMatched, LEFT(a.ApplyMessage, 1) ApplyMessage,
  1751. b.Degree,b.RelatedWorkYears,b.Attachment,b.IsNameHidden,c.LivePlace,
  1752. c.Gender,c.BirthDay,c.HasPhoto,b.Valid,a.RecruitmentID,c.MobileVerifyDate,dbo.GetPaOnlineStatus(c.ID),a.RemindDate
  1753. FROM exJobApply a WITH(NOLOCK)
  1754. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  1755. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  1756. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  1757. WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0'
  1758. IF LEN(@WHERE) > 0
  1759. SET @SQL = @SQL + ' AND '+@WHERE
  1760. --PRINT @SQL
  1761. EXEC(@SQL)
  1762. IF(@Page < 1)
  1763. SET @Page = 1
  1764. IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
  1765. SET @Page = 1
  1766. DECLARE @cpMainID AS INT
  1767. SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
  1768. UPDATE #T SET paName = LEFT(dbo.GetPersonName(cvMainID, @cpMainID), 20), IsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID),
  1769. HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  1770. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  1771. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  1772. HasAccept = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID AND a.Result = 1),
  1773. HsaNoAccept = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID AND a.Result > 1)
  1774. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  1775. UPDATE #T SET Speciality = (
  1776. SELECT Speciality FROM cvMain WITH(NOLOCK)
  1777. WHERE cvMain.ID = #T.cvMainID)
  1778. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  1779. UPDATE #T SET Experience = (
  1780. SELECT TOP 1 ISNULL(Description,DescriptionEng) FROM cvExperience WITH(NOLOCK)
  1781. WHERE cvExperience.cvMainID = #T.cvMainID
  1782. ORDER BY BeginDate DESC)
  1783. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  1784. UPDATE #T SET cvEducationID = (
  1785. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  1786. WHERE cvEducation.cvMainID = #T.cvMainID
  1787. AND #T.Degree = cvEducation.Degree
  1788. ORDER BY Graduation DESC)
  1789. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  1790. --修改是否绑定微信
  1791. UPDATE a SET HasWeiXin = 1
  1792. FROM #T a,WxFans b WITH(NOLOCK)
  1793. WHERE a.paMainID = b.PaMainID
  1794. AND b.Status = 2
  1795. AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  1796. UPDATE a SET a.College = ISNULL(b.GraduateCollage,b.GraduateCollageEng),a.EduType = b.EduType,
  1797. a.MajorName = ISNULL(b.MajorName,b.MajorNameEng), a.Graduation = b.Graduation
  1798. FROM #T a, cvEducation b WITH(NOLOCK)
  1799. WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  1800. UPDATE a SET a.RecruitmentName = b.RecruitmentName, a.RecruitmentDate = b.EndDate
  1801. FROM #T a, Recruitment b WITH(NOLOCK)
  1802. WHERE b.ID = a.RecruitmentID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  1803. UPDATE #T SET cvMatch = dbo.GetCvMatch(cvMainID,JobID) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  1804. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  1805. SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  1806. --计算匹配度
  1807. DROP TABLE #T
  1808. END TRY
  1809. BEGIN CATCH
  1810. DROP TABLE #T
  1811. END CATCH
  1812. END
  1813. GO
  1814. /****** Object: StoredProcedure [dbo].[ccExJobApplyUpdate] Script Date: 2018/12/13 19:06:54 ******/
  1815. SET ANSI_NULLS ON
  1816. GO
  1817. SET QUOTED_IDENTIFIER ON
  1818. GO
  1819. --Lambo 20101130 修改
  1820. -- 增加cpMainID 参数,只能删除本公司的
  1821. --Peter 20140825修改
  1822. --添加积分记录
  1823. --答复后修改答复状态
  1824. --20151124 nick
  1825. --修改Harry2017-4-17
  1826. CREATE PROCEDURE [dbo].[ccExJobApplyUpdate]
  1827. (
  1828. @AllID VARCHAR(1000),
  1829. @Reply INT,
  1830. @cpMainID INT
  1831. )
  1832. AS
  1833. SET NOCOUNT ON
  1834. BEGIN
  1835. SET @AllID = dbo.FormatIDS(@AllID)
  1836. DECLARE @T AS TABLE(ID INT)
  1837. INSERT INTO @T SELECT * FROM dbo.fnSplit(@AllID, ',')
  1838. --查询7天之内应聘的数量
  1839. DECLARE @ExJobApplyNum AS INT
  1840. SELECT @ExJobApplyNum = COUNT(1)
  1841. FROM exJobApply
  1842. WHERE ID IN(SELECT ID FROM @T)
  1843. AND Reply = 0
  1844. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  1845. AND Adddate > (CONVERT(VARCHAR(10),GETDATE()-7,120))
  1846. --插入积分记录 Peter 2014-08-25
  1847. DECLARE @TodayPoint AS INT, @TodayID AS INT
  1848. SELECT @TodayPoint = 0, @TodayID = 0
  1849. SELECT TOP 1 @TodayPoint = ISNULL(Point, 0), @TodayID = ISNULL(ID,0)
  1850. FROM cpPoint WITH(NOLOCK)
  1851. WHERE changeID = 14
  1852. AND LastModifyDate > CONVERT(VARCHAR(10), GETDATE(),120)
  1853. AND cpMainID = @cpMainID
  1854. SET @TodayPoint = @TodayPoint + (@ExJobApplyNum * 2)
  1855. IF @TodayPoint > 100
  1856. SET @TodayPoint = 100
  1857. IF @TodayID = 0
  1858. INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@cpMainID,14,@TodayPoint,GETDATE())
  1859. ELSE
  1860. UPDATE cpPoint SET Point = @TodayPoint,LastModifyDate = GETDATE() WHERE ID = @TodayID
  1861. UPDATE exJobApply SET Reply = @Reply, ReplyDate = GETDATE(),IsDeleted = 0,PersonDeleted = 0
  1862. WHERE ID IN(SELECT ID FROM @T) AND Reply = 0
  1863. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK)
  1864. WHERE cpMainID = @cpMainID)
  1865. --Harry Begin 2017-5-23
  1866. IF @Reply IN(1, 2, 3, 4)--4企业删除
  1867. BEGIN
  1868. INSERT WxMessageSend2(Templatetype, WxFansID, PaMainId, MainTableId, CpMainID, CvMainID, JobId, AddDate)
  1869. SELECT 9, b.Id, c.paMainId, a.Id, @cpMainId, c.Id, a.JobId, GETDATE()
  1870. FROM exJobApply a WITH(NOLOCK),
  1871. wxFans b WITH(NOLOCK),
  1872. cvMain c WITH(NOLOCK)
  1873. WHERE a.ID IN(SELECT ID FROM @T)
  1874. AND a.cvMainID = c.ID
  1875. AND b.PaMainId = c.PaMainId
  1876. AND b.[Status] = 2
  1877. END
  1878. DECLARE @Cnt INT, @ReplyCnt INT, @ReplyRate DECIMAL(9, 3)
  1879. --是否同意自动答复
  1880. IF EXISTS(SELECT 'x' FROM cpMain WHERE id=@cpMainID AND AutoReplyConfirm is NULL)
  1881. BEGIN
  1882. SELECT @Cnt = COUNT(*), @ReplyCnt = COUNT(ReplyDate)
  1883. FROM ExjobApply
  1884. WHERE JobId IN(SELECT Id FROM Job WHERE cpMainId = @cpMainId)
  1885. AND AddDate > GETDATE() - 183
  1886. IF @Cnt > 0
  1887. SELECT @ReplyRate = @ReplyCnt * 1.0 / @Cnt
  1888. --WHERE @ReplyCnt * 1.0 / @Cnt >= 0.1
  1889. ELSE
  1890. SELECT @ReplyRate =1
  1891. END
  1892. ELSE
  1893. BEGIN
  1894. DECLARE @AutoReplyConfirm DATETIME
  1895. SELECT @AutoReplyConfirm=AutoReplyConfirm
  1896. FROM CpMain WITH(NOLOCK)
  1897. WHERE Id = @cpMainId
  1898. SELECT @ReplyCnt = SUM(CASE WHEN reply<>5 THEN 1 ELSE 0 END), @Cnt= COUNT(ReplyDate)
  1899. FROM ExjobApply
  1900. WHERE JobId IN(SELECT Id FROM Job WHERE cpMainId = @cpMainId)
  1901. AND reply!=0
  1902. AND adddate>@AutoReplyConfirm
  1903. IF @Cnt > 0
  1904. SELECT @ReplyRate = @ReplyCnt * 1.0 / @Cnt
  1905. ELSE
  1906. SELECT @ReplyRate =1
  1907. END
  1908. UPDATE cpMain SET ReplyRate = @ReplyRate WHERE Id = @cpMainId
  1909. UPDATE a SET a.replyrate = b.ReplyRate FROM cpMainPublish a, cpMain b WHERE a.Id = b.Id AND ISNULL(a.replyrate, 0) <> ISNULL(b.replyrate, 0)
  1910. --Harry end
  1911. END
  1912. GO
  1913. /****** Object: StoredProcedure [dbo].[ccExMessageC2PDelete] Script Date: 2018/12/13 19:06:55 ******/
  1914. SET ANSI_NULLS ON
  1915. GO
  1916. SET QUOTED_IDENTIFIER ON
  1917. GO
  1918. --Lambo 20101130 修改
  1919. -- 增加cpMainID 参数,只能删除本公司的
  1920. CREATE PROCEDURE [dbo].[ccExMessageC2PDelete]
  1921. (
  1922. @ID INT,
  1923. @cpMainID INT
  1924. )
  1925. AS
  1926. BEGIN TRY
  1927. IF EXISTS(SELECT ID FROM ExMessageC2P WITH(NOLOCK)
  1928. WHERE PersonDeleted = 1
  1929. AND ID = @ID
  1930. AND caMainID IN (SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID))
  1931. DELETE FROM ExMessageC2P WHERE PersonDeleted = 1 AND ID = @ID
  1932. ELSE
  1933. UPDATE ExMessageC2P SET CompanyDeleted = 1
  1934. WHERE ID = @ID AND caMainID IN (SELECT ID FROM caMain WITH(NOLOCK)
  1935. WHERE cpMainID = @cpMainID)
  1936. END TRY
  1937. BEGIN CATCH
  1938. GOTO ERR
  1939. END CATCH
  1940. RETURN 1
  1941. ERR:
  1942. BEGIN
  1943. RETURN 0
  1944. END
  1945. GO
  1946. /****** Object: StoredProcedure [dbo].[ccexMessageC2PInsert] Script Date: 2018/12/13 19:06:55 ******/
  1947. SET ANSI_NULLS ON
  1948. GO
  1949. SET QUOTED_IDENTIFIER ON
  1950. GO
  1951. --ccexMessageC2PInsert 0,371108,14792626,'sssssssssss'
  1952. --#########################################
  1953. --修改:sean
  1954. --增加了非收费会员不能超过100条的判断
  1955. --@ID 是个人留言的id,>0:回复个人留言,=0:主动留言
  1956. --#########################################
  1957. CREATE PROCEDURE [dbo].[ccexMessageC2PInsert]
  1958. (
  1959. @ID INT,
  1960. @caMainID INT,
  1961. @cvMainID INT,
  1962. @Message NVARCHAR(200)
  1963. )
  1964. AS
  1965. BEGIN
  1966. DECLARE @cpMainID AS INT, @MemberType AS TINYINT, @cnt AS INT
  1967. SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
  1968. SELECT @MemberType = MemberType FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
  1969. IF @MemberType < 3 --费收费用户
  1970. BEGIN
  1971. SELECT @cnt = COUNT(1) FROM exMessageC2P WITH(NOLOCK)
  1972. WHERE caMainID = @caMainID
  1973. IF @cnt >= 100 --最多100条留言
  1974. GOTO Err1
  1975. END
  1976. SET @Message = LTRIM(RTRIM(@Message))
  1977. INSERT exMessageC2P(caMainID, cvMainID, Message)
  1978. VALUES(@caMainID, @cvMainID, @Message)
  1979. IF @ID > 0
  1980. Update exMessageP2C Set IsReply=1 WHERE ID = @ID
  1981. RETURN
  1982. END
  1983. ERR1:
  1984. BEGIN
  1985. RETURN -1
  1986. END
  1987. GO
  1988. /****** Object: StoredProcedure [dbo].[ccExMessageC2PSelect] Script Date: 2018/12/13 19:06:55 ******/
  1989. SET ANSI_NULLS ON
  1990. GO
  1991. SET QUOTED_IDENTIFIER ON
  1992. GO
  1993. --[ccExMessageC2PSelect] 'And caMainID =371108 And c.Name=''杨''','a.id desc',1,371108,371108
  1994. CREATE PROCEDURE [dbo].[ccExMessageC2PSelect]
  1995. (
  1996. @WHERE VARCHAR(1000),
  1997. @Order VARCHAR(100),
  1998. @Page SMALLINT,
  1999. @cpMainID INT,
  2000. @caMainID INT
  2001. )
  2002. AS
  2003. BEGIN
  2004. BEGIN TRY
  2005. SET @Where = dbo.SafeSql(@Where)
  2006. SET @ORDER = dbo.SafeSql(@Order)
  2007. CREATE TABLE #T(
  2008. TitleID BIGINT,
  2009. ID INT,
  2010. caMainID INT,
  2011. cvMainID INT,
  2012. Message VARCHAR(1000) COLLATE Chinese_PRC_CI_AS,
  2013. AddDate SMALLDATETIME,
  2014. IsViewed BIT,
  2015. IsReply BIT,
  2016. Degree TINYINT,
  2017. RelatedWorkYears TINYINT,
  2018. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  2019. IsNameHidden BIT,
  2020. LivePlace VARCHAR(6),
  2021. Gender BIT,
  2022. paName NVARCHAR(20),
  2023. BirthDay INT,
  2024. HasPhoto TINYINT,
  2025. Valid TINYINT,
  2026. HasJobApply BIT,
  2027. HasInterview BIT,
  2028. HasRemark BIT,
  2029. HasFavorate BIT,
  2030. CvIsViewed BIT
  2031. )
  2032. DECLARE @SQL AS VARCHAR(2000)
  2033. SET @SQL='
  2034. INSERT INTO #T(TitleID,
  2035. ID,caMainID,cvMainID,Message,AddDate,IsViewed,IsReply)
  2036. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID,
  2037. a.ID,a.caMainID,a.cvMainID,a.Message,a.AddDate,a.IsViewed,a.IsReply
  2038. FROM exMessageC2P a WITH(NOLOCK)'
  2039. IF CHARINDEX('c.',@WHERE) > 0
  2040. SET @SQL=@SQL + '
  2041. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  2042. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID'
  2043. SET @SQL=@SQL + '
  2044. WHERE CompanyDeleted=0'
  2045. IF @caMainId > 0
  2046. SET @SQL=@SQL + '
  2047. AND a.caMainId = ' + LTRIM(STR(@caMainID))
  2048. IF LEN(@WHERE) > 0
  2049. SET @SQL = @SQL + @WHERE
  2050. --PRINT @SQL
  2051. EXEC(@SQL)
  2052. IF(@Page < 1)
  2053. SET @Page = 1
  2054. IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
  2055. SET @Page = 1
  2056. UPDATE #T SET Degree = a.Degree,RelatedWorkYears = a.RelatedWorkYears,Attachment = a.Attachment,
  2057. IsNameHidden = a.IsNameHidden,LivePlace = b.LivePlace,Gender = b.Gender,paName = b.Name,
  2058. BirthDay = b.BirthDay,HasPhoto = b.HasPhoto,Valid = a.Valid
  2059. FROM cvMain a WITH(NOLOCK) INNER JOIN paMain b WITH(NOLOCK) ON a.paMainID = b.ID
  2060. WHERE a.ID = #T.cvMainID AND TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  2061. UPDATE #T SET paName = LEFT(dbo.GetPaName(cvMainID, @cpMainID), 20),
  2062. CvIsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID),
  2063. HasJobApply = (SELECT TOP 1 '1' FROM exJobApply a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  2064. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  2065. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  2066. HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
  2067. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  2068. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  2069. SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  2070. DROP TABLE #T
  2071. END TRY
  2072. BEGIN CATCH
  2073. DROP TABLE #T
  2074. END CATCH
  2075. END
  2076. GO
  2077. /****** Object: StoredProcedure [dbo].[ccExMessageLogSelect] Script Date: 2018/12/13 19:06:56 ******/
  2078. SET ANSI_NULLS ON
  2079. GO
  2080. SET QUOTED_IDENTIFIER ON
  2081. GO
  2082. CREATE PROCEDURE [dbo].[ccExMessageLogSelect]
  2083. @caMainID INT,
  2084. @cvMainID INT
  2085. AS
  2086. BEGIN
  2087. SELECT * FROM (
  2088. SELECT addDate,Message,1 IsCompany FROM exMessageC2p WITH(NOLOCK) WHERE cvMainID = @cvMainID AND caMainID = @caMainID AND CompanyDeleted=0
  2089. UNION
  2090. SELECT addDate,Message,0 IsCompany FROM exMessageP2C WITH(NOLOCK) WHERE cvMainID = @cvMainID AND caMainID = @caMainID AND CompanyDeleted=0
  2091. ) a ORDER BY a.AddDate DESC
  2092. END
  2093. GO
  2094. /****** Object: StoredProcedure [dbo].[ccExMessageP2CByHasMessageSelect] Script Date: 2018/12/13 19:06:56 ******/
  2095. SET ANSI_NULLS ON
  2096. GO
  2097. SET QUOTED_IDENTIFIER ON
  2098. GO
  2099. --Nick 20130716
  2100. --查询该简历是否向本公司留言过
  2101. --用于简历显示页面
  2102. CREATE PROCEDURE [dbo].[ccExMessageP2CByHasMessageSelect]
  2103. (
  2104. @cpMainID INT,
  2105. @cvMainID INT
  2106. )
  2107. AS
  2108. BEGIN
  2109. IF EXISTS (
  2110. SELECT 'x' FROM ExMessageP2C WITH(NOLOCK)
  2111. WHERE cvMainID = @cvMainID
  2112. AND caMainID IN(SELECT ID FROM CaMain WITH(NOLOCK) WHERE CpMainID = @cpMainID)
  2113. AND CompanyDeleted = 0
  2114. )
  2115. RETURN 1
  2116. ELSE
  2117. RETURN 0
  2118. END
  2119. GO
  2120. /****** Object: StoredProcedure [dbo].[ccExMessageP2CDelete] Script Date: 2018/12/13 19:06:56 ******/
  2121. SET ANSI_NULLS ON
  2122. GO
  2123. SET QUOTED_IDENTIFIER ON
  2124. GO
  2125. --Lambo 20101130 修改
  2126. -- 增加cpMainID 参数,只能删除本公司的
  2127. CREATE PROCEDURE [dbo].[ccExMessageP2CDelete]
  2128. (
  2129. @ID INT,
  2130. @cpMainID INT
  2131. )
  2132. AS
  2133. BEGIN TRY
  2134. IF EXISTS(SELECT ID FROM ExMessageP2C WITH(NOLOCK)
  2135. WHERE PersonDeleted = 1
  2136. AND ID = @ID
  2137. AND caMainID IN (SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID))
  2138. DELETE FROM ExMessageP2C WHERE PersonDeleted = 1 AND ID = @ID
  2139. ELSE
  2140. UPDATE ExMessageP2C SET CompanyDeleted = 1
  2141. WHERE ID = @ID AND caMainID IN (SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  2142. END TRY
  2143. BEGIN CATCH
  2144. GOTO ERR
  2145. END CATCH
  2146. RETURN 1
  2147. ERR:
  2148. BEGIN
  2149. RETURN 0
  2150. END
  2151. GO
  2152. /****** Object: StoredProcedure [dbo].[ccExMessageP2CIsViewedUpdate] Script Date: 2018/12/13 19:06:56 ******/
  2153. SET ANSI_NULLS ON
  2154. GO
  2155. SET QUOTED_IDENTIFIER ON
  2156. GO
  2157. CREATE PROCEDURE [dbo].[ccExMessageP2CIsViewedUpdate]
  2158. (
  2159. @ID INT,
  2160. @caMainID INT
  2161. )
  2162. AS
  2163. BEGIN TRY
  2164. UPDATE exMessageP2C SET IsViewed = 1
  2165. WHERE ID = @ID
  2166. AND caMainID = @caMainID
  2167. END TRY
  2168. BEGIN CATCH
  2169. GOTO ERR
  2170. END CATCH
  2171. RETURN 1
  2172. ERR:
  2173. BEGIN
  2174. ROLLBACK TRAN
  2175. RETURN 0
  2176. END
  2177. GO
  2178. /****** Object: StoredProcedure [dbo].[ccExMessageP2CSelect] Script Date: 2018/12/13 19:06:56 ******/
  2179. SET ANSI_NULLS ON
  2180. GO
  2181. SET QUOTED_IDENTIFIER ON
  2182. GO
  2183. --[ccExMessageP2CSelect] 'caMainID =1002941','a.id desc'
  2184. CREATE PROCEDURE [dbo].[ccExMessageP2CSelect]
  2185. (
  2186. @WHERE VARCHAR(1000),
  2187. @Order VARCHAR(100),
  2188. @Page SMALLINT,
  2189. @cpMainID INT,
  2190. @caMainID INT
  2191. )
  2192. AS
  2193. BEGIN
  2194. BEGIN TRY
  2195. SET @Where = dbo.SafeSql(@Where)
  2196. SET @ORDER = dbo.SafeSql(@Order)
  2197. CREATE TABLE #T(
  2198. TitleID BIGINT,
  2199. ID INT,
  2200. caMainID INT,
  2201. cvMainID INT,
  2202. Message VARCHAR(200) COLLATE Chinese_PRC_CI_AS,
  2203. AddDate SMALLDATETIME,
  2204. IsViewed BIT,
  2205. IsReply BIT,
  2206. Degree TINYINT,
  2207. RelatedWorkYears TINYINT,
  2208. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  2209. IsNameHidden BIT,
  2210. LivePlace VARCHAR(6),
  2211. Gender BIT,
  2212. paName NVARCHAR(20),
  2213. BirthDay INT,
  2214. HasPhoto TINYINT,
  2215. IsOpen BIT,
  2216. Valid TINYINT,
  2217. HasJobApply BIT,
  2218. HasInterview BIT,
  2219. HasRemark BIT,
  2220. HasFavorate BIT,
  2221. CvIsViewed BIT
  2222. )
  2223. DECLARE @SQL AS VARCHAR(2000)
  2224. SET @SQL='
  2225. INSERT INTO #T(TitleID,ID,caMainID,cvMainID,Message,AddDate,IsViewed,IsReply)
  2226. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID,
  2227. a.ID,a.caMainID,a.cvMainID,a.Message,a.AddDate,a.IsViewed,a.IsReply
  2228. FROM exMessageP2C a WITH(NOLOCK)'
  2229. IF CHARINDEX('c.',@WHERE) > 0
  2230. SET @SQL=@SQL + '
  2231. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  2232. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID'
  2233. SET @SQL=@SQL + '
  2234. WHERE CompanyDeleted=0'
  2235. IF @caMainId > 0
  2236. SET @SQL=@SQL + '
  2237. AND a.caMainId = ' + LTRIM(STR(@caMainID))
  2238. IF LEN(@WHERE)>0
  2239. SET @SQL=@SQL + @WHERE
  2240. --PRINT @SQL
  2241. EXEC(@SQL)
  2242. IF(@Page < 1)
  2243. SET @Page = 1
  2244. IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
  2245. SET @Page = 1
  2246. UPDATE #T SET Degree = a.Degree,RelatedWorkYears = a.RelatedWorkYears,Attachment = a.Attachment,
  2247. IsNameHidden = a.IsNameHidden,LivePlace = b.LivePlace,Gender = b.Gender,paName = b.Name,
  2248. BirthDay = b.BirthDay,HasPhoto = b.HasPhoto,Valid = a.Valid
  2249. FROM cvMain a WITH(NOLOCK) INNER JOIN paMain b WITH(NOLOCK) ON a.paMainID = b.ID
  2250. WHERE a.ID = #T.cvMainID AND TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  2251. UPDATE #T SET paName = LEFT(dbo.GetPaName(cvMainID, @cpMainID), 20),
  2252. CvIsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID),
  2253. HasJobApply = (SELECT TOP 1 '1' FROM exJobApply a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  2254. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  2255. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  2256. HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
  2257. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  2258. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  2259. SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  2260. DROP TABLE #T
  2261. END TRY
  2262. BEGIN CATCH
  2263. DROP TABLE #T
  2264. END CATCH
  2265. END
  2266. GO
  2267. /****** Object: StoredProcedure [dbo].[ccExtendLinkByCpMainIDUpdate] Script Date: 2018/12/13 19:06:57 ******/
  2268. SET ANSI_NULLS ON
  2269. GO
  2270. SET QUOTED_IDENTIFIER ON
  2271. GO
  2272. --创建时间:2015.7.13
  2273. --创建人:Mice
  2274. --说明:更新状态
  2275. -------------------------------------------------------
  2276. CREATE PROCEDURE [dbo].[ccExtendLinkByCpMainIDUpdate]
  2277. (
  2278. @cpMainID INT
  2279. )
  2280. AS
  2281. BEGIN
  2282. UPDATE ExtendLink
  2283. SET LinkStatus = 4, RunStatus = 0
  2284. WHERE CpMainID = @cpMainID AND RunStatus = 1
  2285. END
  2286. GO
  2287. /****** Object: StoredProcedure [dbo].[ccExtendLinkByCustomLinkSelect] Script Date: 2018/12/13 19:06:57 ******/
  2288. SET ANSI_NULLS ON
  2289. GO
  2290. SET QUOTED_IDENTIFIER ON
  2291. GO
  2292. CREATE PROC [dbo].[ccExtendLinkByCustomLinkSelect]
  2293. (
  2294. @cpMainId INT,
  2295. @CustomLink VARCHAR(300)
  2296. )
  2297. AS
  2298. SET NOCOUNT ON
  2299. BEGIN
  2300. SELECT TOP 100 * FROM ExtendLink WITH(NOLOCK)
  2301. WHERE cpMainId <> @cpMainId
  2302. AND CustomLink LIKE '%' + LTRIM(RTRIM(@CustomLink)) + '%'
  2303. --AND LinkStatus <> 3
  2304. END
  2305. GO
  2306. /****** Object: StoredProcedure [dbo].[ccExtendLinkByEditSelect] Script Date: 2018/12/13 19:06:57 ******/
  2307. SET ANSI_NULLS ON
  2308. GO
  2309. SET QUOTED_IDENTIFIER ON
  2310. GO
  2311. CREATE PROCEDURE [dbo].[ccExtendLinkByEditSelect]
  2312. (
  2313. @cpMainId INT
  2314. )
  2315. AS
  2316. BEGIN
  2317. SELECT TOP 1 *, SPACE(50) jobName, GETDATE() SelectDate
  2318. INTO #t
  2319. FROM ExtendLink
  2320. WHERE cpMainID = @cpMainID
  2321. ORDER BY id DESC
  2322. UPDATE #t SET JobName = (SELECT Name FROM Job WITH(NOLOCK) WHERE Job.Id = #t.Ids)
  2323. DECLARE @SelectDate DATETIME
  2324. SELECT TOP 1 @SelectDate = DATEADD(MONTH, 1, Begindate) FROM ExtendLinkRunLog
  2325. WHERE cpMainId = @cpMainId
  2326. ORDER BY ID DESC
  2327. IF ISNULL(@SelectDate, GETDATE() - 1) < GETDATE()
  2328. SET @SelectDate = CONVERT(VARCHAR(10), GETDATE() + 1, 120)
  2329. UPDATE #t SET SelectDate = @SelectDate
  2330. SELECT * FROM #t
  2331. END
  2332. GO
  2333. /****** Object: StoredProcedure [dbo].[ccExtendLinkRunLogSelect] Script Date: 2018/12/13 19:06:57 ******/
  2334. SET ANSI_NULLS ON
  2335. GO
  2336. SET QUOTED_IDENTIFIER ON
  2337. GO
  2338. CREATE PROCEDURE [dbo].[ccExtendLinkRunLogSelect]
  2339. (
  2340. @cpMainId INT
  2341. )
  2342. AS
  2343. BEGIN
  2344. SELECT a.*, CASE a.ShowType WHEN 1 THEN b.Name ELSE '' END as jobName
  2345. FROM ExtendLinkRunLog a
  2346. LEFT JOIN Job b on b.id = a.IDs
  2347. WHERE a.cpMainID = @cpMainID
  2348. ORDER BY a.id DESC
  2349. END
  2350. GO
  2351. /****** Object: StoredProcedure [dbo].[ccExtendLinkSave] Script Date: 2018/12/13 19:06:58 ******/
  2352. SET ANSI_NULLS ON
  2353. GO
  2354. SET QUOTED_IDENTIFIER ON
  2355. GO
  2356. CREATE PROCEDURE [dbo].[ccExtendLinkSave]
  2357. (
  2358. @cpMainID INT,
  2359. @keyword NVARCHAR(20),
  2360. @keywordUrl VARCHAR(300),
  2361. @CustomLink VARCHAR(300),
  2362. @showType INT,
  2363. @ids INT,
  2364. @NextRunDate DATETIME
  2365. )
  2366. AS
  2367. SET NOCOUNT ON
  2368. BEGIN
  2369. IF EXISTS(SELECT 'x' FROM ExtendLink WITH(NOLOCK)
  2370. WHERE cpMainID = @cpMainID
  2371. AND keyword = @keyword
  2372. AND keywordUrl = @keywordUrl
  2373. AND CustomLink = @CustomLink
  2374. AND showType = @showType
  2375. AND ids = @ids
  2376. AND ShowDay = DATEPART(DAY, @NextRunDate)
  2377. AND RunStatus IN(1, 2)
  2378. )
  2379. RETURN
  2380. DECLARE @BeginDate DATETIME, @IsAdd INT, @AddDate DATETIME, @LinkId INT, @LinkStatus INT,
  2381. @keywordUrlOld VARCHAR(300), @CustomLinkOld VARCHAR(300), @ShowDay INT,
  2382. @ManagerUserId INT
  2383. SELECT @IsAdd = 1, @LinkStatus = 1, @ShowDay = DATEPART(DAY, @NextRunDate)
  2384. SELECT TOP 1 @AddDate = AddDate, @LinkId = ID, @LinkStatus = LinkStatus,
  2385. @keywordUrlOld = KeywordUrl, @CustomLinkOld = CustomLink
  2386. FROM ExtendLink WITH(NOLOCK)
  2387. WHERE cpMainId = @cpMainId
  2388. ORDER BY ID DESC
  2389. IF @showType <> 1
  2390. SET @ids = 0
  2391. IF @AddDate IS NOT NULL
  2392. BEGIN
  2393. SELECT TOP 1 @BeginDate = BeginDate FROM ExtendLinkRunLog WITH(NOLOCK) WHERE cpMainId = @cpMainId ORDER BY ID DESC
  2394. IF ISNULL(@BeginDate, '2000-1-1') < @AddDate
  2395. SET @IsAdd = 0
  2396. END
  2397. SELECT @ManagerUserId = ConsultantId FROM cpMain WITH(NOLOCK) WHERE id = @cpMainId
  2398. UPDATE ExtendLink SET ManagerUserID = @ManagerUserId WHERE CpMainID=@cpMainId
  2399. IF @IsAdd = 1
  2400. BEGIN
  2401. IF @keywordUrlOld <> @keywordUrl OR @CustomLinkOld <> @CustomLink
  2402. SELECT @LinkStatus = 1
  2403. SELECT @ManagerUserId = ConsultantId FROM cpMain WITH(NOLOCK) WHERE id = @cpMainId
  2404. INSERT INTO ExtendLink(CpMainID, AddDate, KeyWord, KeywordUrl, CustomLink, RunStatus, LinkStatus, ShowType, IDs, ShowDay, NextRunDate,LinkStatusPre, ManagerUserId)
  2405. SELECT @CpMainID, GETDATE(), @Keyword, @KeywordUrl, @CustomLink, 0, @LinkStatus, @ShowType, @IDs, @ShowDay, @NextRunDate , @LinkStatus, @ManagerUserId
  2406. SET @linkId = @@IDENTITY
  2407. END
  2408. ELSE
  2409. BEGIN
  2410. IF @keywordUrlOld = @keywordUrl AND @CustomLinkOld = @CustomLink
  2411. UPDATE ExtendLink
  2412. SET CpMainID = @CpMainID,
  2413. ShowType = @ShowType,
  2414. IDs = @ids,
  2415. ShowDay = @ShowDay,
  2416. NextRunDate=@NextRunDate,
  2417. AddDate = GETDATE()
  2418. Where Id = @linkId
  2419. ELSE
  2420. UPDATE ExtendLink
  2421. SET CpMainID = @CpMainID,
  2422. KeyWord = @Keyword,
  2423. KeywordUrl = @KeywordUrl,
  2424. CustomLink = @CustomLink,
  2425. ShowType = @ShowType,
  2426. RunStatus = 0,
  2427. LinkStatus = 1,
  2428. IDs = @ids,
  2429. ShowDay = @ShowDay,
  2430. NextRunDate=@NextRunDate,
  2431. LinkStatusPre = 1,
  2432. AddDate = GETDATE()
  2433. Where Id = @linkId
  2434. END
  2435. UPDATE ExtendLink SET RunStatus = 4 WHERE RunStatus < 3 AND cpMainId = @cpMainId AND ID < @linkId
  2436. END
  2437. GO
  2438. /****** Object: StoredProcedure [dbo].[ccExtendLinkSelect] Script Date: 2018/12/13 19:06:58 ******/
  2439. SET ANSI_NULLS ON
  2440. GO
  2441. SET QUOTED_IDENTIFIER ON
  2442. GO
  2443. CREATE PROCEDURE [dbo].[ccExtendLinkSelect]
  2444. (
  2445. @cpMainId INT
  2446. )
  2447. AS
  2448. BEGIN
  2449. SELECT TOP 12 a.*, CASE a.ShowType WHEN 1 THEN b.Name ELSE '' END as jobName
  2450. FROM ExtendLink a
  2451. LEFT JOIN Job b ON b.id = a.IDs
  2452. WHERE a.cpMainID = @cpMainID
  2453. ORDER BY a.id DESC
  2454. END
  2455. GO
  2456. /****** Object: StoredProcedure [dbo].[ccFaqByCategoryIDSelect] Script Date: 2018/12/13 19:06:58 ******/
  2457. SET ANSI_NULLS ON
  2458. GO
  2459. SET QUOTED_IDENTIFIER ON
  2460. GO
  2461. --#####################################################
  2462. --创建时间:2014.10.30
  2463. --创建人:Nick
  2464. --说明://根据类别获取常见问题信息
  2465. --#####################################################
  2466. CREATE PROCEDURE [dbo].[ccFaqByCategoryIDSelect]
  2467. (
  2468. @CategoryID INT
  2469. )
  2470. AS
  2471. BEGIN TRY
  2472. SELECT ID, Question,answer,CategoryID
  2473. FROM Faq WITH(NOLOCK)
  2474. WHERE Type=1 AND CategoryID =@CategoryID
  2475. ORDER BY Power
  2476. END TRY
  2477. BEGIN CATCH
  2478. RETURN 0
  2479. END CATCH
  2480. GO
  2481. /****** Object: StoredProcedure [dbo].[ccFaqSelect] Script Date: 2018/12/13 19:06:58 ******/
  2482. SET ANSI_NULLS ON
  2483. GO
  2484. SET QUOTED_IDENTIFIER ON
  2485. GO
  2486. CREATE PROCEDURE [dbo].[ccFaqSelect]
  2487. AS
  2488. BEGIN
  2489. SELECT ID, Question,CategoryID
  2490. FROM Faq WITH(NOLOCK)
  2491. WHERE Type=1
  2492. ORDER BY Power
  2493. END
  2494. GO
  2495. /****** Object: StoredProcedure [dbo].[ccFeeLogSelect] Script Date: 2018/12/13 19:06:58 ******/
  2496. SET ANSI_NULLS ON
  2497. GO
  2498. SET QUOTED_IDENTIFIER ON
  2499. GO
  2500. --Lambo 20110125
  2501. --查询单位的交费记录
  2502. CREATE PROCEDURE [dbo].[ccFeeLogSelect]
  2503. (
  2504. @cpMainID INT
  2505. )
  2506. AS
  2507. BEGIN
  2508. SELECT * FROM FeeLog WITH(NOLOCK) WHERE company_id = @cpMainID
  2509. END
  2510. GO
  2511. /****** Object: StoredProcedure [dbo].[ccFnInvoiceByOrderIDSelect] Script Date: 2018/12/13 19:06:59 ******/
  2512. SET ANSI_NULLS ON
  2513. GO
  2514. SET QUOTED_IDENTIFIER ON
  2515. GO
  2516. --#####################################################
  2517. --创建时间:2014.11.6
  2518. --创建人:John
  2519. --说明:根据订单ID获取发出发票的信息
  2520. --#####################################################
  2521. CREATE PROCEDURE [dbo].[ccFnInvoiceByOrderIDSelect]
  2522. (
  2523. @OrderID INT
  2524. )
  2525. AS
  2526. BEGIN
  2527. SELECT * FROM FnInvoice WITH(NOLOCK) WHERE Status = 1 AND OrderID = @OrderID
  2528. END
  2529. GO
  2530. /****** Object: StoredProcedure [dbo].[ccFnLetterByInvoiceIDSelect] Script Date: 2018/12/13 19:06:59 ******/
  2531. SET ANSI_NULLS ON
  2532. GO
  2533. SET QUOTED_IDENTIFIER ON
  2534. GO
  2535. --#####################################################
  2536. --创建时间:2014.11.6
  2537. --创建人:John
  2538. --说明:根据发票ID获取邮寄发票的信息
  2539. --#####################################################
  2540. CREATE PROCEDURE [dbo].[ccFnLetterByInvoiceIDSelect]
  2541. (
  2542. @invoiceID INT
  2543. )
  2544. AS
  2545. BEGIN
  2546. SELECT * FROM FnLetter WITH(NOLOCK) WHERE status <> 4 AND status <> 3 AND FnInvoiceID = @invoiceID
  2547. END
  2548. GO
  2549. /****** Object: StoredProcedure [dbo].[ccFnLetterByOrderIDUpdate] Script Date: 2018/12/13 19:06:59 ******/
  2550. SET ANSI_NULLS ON
  2551. GO
  2552. SET QUOTED_IDENTIFIER ON
  2553. GO
  2554. /*********************
  2555. SEAN 2014-10-29
  2556. **********************/
  2557. CREATE PROCEDURE [dbo].[ccFnLetterByOrderIDUpdate]
  2558. (
  2559. @ID INT,
  2560. @CpName NVARCHAR(100)
  2561. )
  2562. AS
  2563. --INSERT INTO procLog SELECT 'ccFnLetterByOrderIDUpdate', '', GETDATE()
  2564. BEGIN
  2565. UPDATE FnLetter
  2566. SET Status = 2, ReceivedDate = GETDATE(), ReceivedManName = @CpName
  2567. FROM FnInvoice
  2568. WHERE FnInvoice.OrderID = @ID
  2569. AND FnLetter.FnInvoiceID = FnInvoice.ID
  2570. AND FnLetter.Status = 1
  2571. END
  2572. GO
  2573. /****** Object: StoredProcedure [dbo].[ccFnLetterReceiveByInvoiceIDSelect] Script Date: 2018/12/13 19:06:59 ******/
  2574. SET ANSI_NULLS ON
  2575. GO
  2576. SET QUOTED_IDENTIFIER ON
  2577. GO
  2578. --#####################################################
  2579. --创建时间:2014.11.6
  2580. --创建人:John
  2581. --说明:根据发票ID获取邮寄发票收到的信息
  2582. --#####################################################
  2583. CREATE PROCEDURE [dbo].[ccFnLetterReceiveByInvoiceIDSelect]
  2584. (
  2585. @invoiceID INT
  2586. )
  2587. AS
  2588. BEGIN
  2589. SELECT * FROM FnLetter WITH(NOLOCK) WHERE Status = 2 AND FnInvoiceID = @invoiceID
  2590. END
  2591. GO
  2592. /****** Object: StoredProcedure [dbo].[ccIndexPageByMSiteSelect] Script Date: 2018/12/13 19:06:59 ******/
  2593. SET ANSI_NULLS ON
  2594. GO
  2595. SET QUOTED_IDENTIFIER ON
  2596. GO
  2597. create PROCEDURE [dbo].[ccIndexPageByMSiteSelect]
  2598. (
  2599. @cpMainID INT,
  2600. @caMainID INT,
  2601. @ProvinceID INT,
  2602. @IsManager BIT,
  2603. @Object VARCHAR(10)
  2604. )
  2605. AS
  2606. BEGIN
  2607. DECLARE @t AS TABLE(
  2608. ID INT,
  2609. type INT,
  2610. iCount INT NULL,
  2611. Title NVARCHAR(100) NULL,
  2612. Link NVARCHAR(200) NULL,
  2613. ContentText NVARCHAR(500) NULL,
  2614. AddDate SMALLDATETIME NULL
  2615. )
  2616. --取未付款订单
  2617. INSERT INTO @T(ID,type,iCount) SELECT @cpMainID,0,count(1) FROM caOrder a WITH(NOLOCK) WHERE (a.IsDeleted=0 OR a.IsDeleted IS NULL) AND a.cpMainID = @cpMainID AND OrderStatus = 0 AND AddDate > DATEADD(Month,-2,GETDATE())
  2618. --取未查看的网站消息
  2619. INSERT INTO @T(ID,type,ContentText,AddDate,iCount) SELECT ID,1,Content,AddDate,type FROM CompanyNotify WITH(NOLOCK) WHERE CompanyID = @cpMainID AND ((Type=1 AND Received=0) Or (Type=2 AND EndDate>GETDATE())) ORDER BY AddDate DESC
  2620. --取未查看的反馈
  2621. INSERT INTO @T(ID,type,ContentText,AddDate) SELECT Top 1 ID,2,ReplyMessage,ReplyDate FROM CaFeedBack WITH(NOLOCK) WHERE caMainID = @caMainID AND IsReply = 1 AND ViewDate IS NULL ORDER BY ID DESC
  2622. --取未查看的投诉
  2623. IF @ISManager=1
  2624. INSERT INTO @T(ID,type,ContentText,AddDate) SELECT TOP 1 a.ID,3,a.Plaint,a.AddDate FROM PaPlaint a WITH(NOLOCK INDEX(IX_paPlaint_caMainID)), caMain b WITH( NOLOCK INDEX(IX_caMain_cpMainID)) WHERE a.caMainID = b.ID AND b.cpMainID = @cpMainID AND IsViewed=0 AND ReplyType =1 ORDER BY a.CaMainID,a.ID DESC
  2625. ELSE
  2626. INSERT INTO @T(ID,type,ContentText,AddDate) SELECT TOP 1 ID,3,Plaint,AddDate FROM PaPlaint WITH(NOLOCK INDEX(IX_paPlaint_caMainID)) WHERE caMainID = @caMainID AND IsViewed=0 AND ReplyType =1 ORDER BY ID DESC
  2627. --取未查看的网站分类通知
  2628. INSERT INTO @T(ID, type, Title, ContentText, link, iCount)
  2629. SELECT TOP 1 ID, 4, Title, Content, link, Type
  2630. FROM CompanyInform WITH(NOLOCK)
  2631. WHERE Status = 1
  2632. AND Object LIKE '%' + @Object + '%'
  2633. AND Province LIKE '%' + LTRIM(STR(@ProvinceID)) + '%'
  2634. AND EndDate > GETDATE() ORDER BY AddDate DESC
  2635. --取当前调查
  2636. -- INSERT INTO @T(ID,type,ContentText)
  2637. -- SELECT TOP 1 ID, 5, Title FROM Ivgt_Investigation WITH(NOLOCK)
  2638. -- WHERE ENDdate > GETDATE()
  2639. -- AND province Like '%' + LTRIM(STR(@provinceid)) + '%'
  2640. -- AND type = 1
  2641. -- ORDER BY adddate
  2642. --如果有1个月内到期的职位,修改截止日期
  2643. BEGIN TRY
  2644. UPDATE Job SET IssueEnd = DATEADD(MINUTE,-1, CONVERT(VARCHAR(10), DATEADD(MONTH, 2, GETDATE()) + 1, 120))
  2645. WHERE caMainId = @caMainID
  2646. AND IssueEnd < DATEADD(MONTH, 1, GETDATE())
  2647. AND Valid = 1
  2648. AND @cpMainId <> 10371941
  2649. END TRY
  2650. BEGIN CATCH
  2651. END CATCH
  2652. IF @@ROWCOUNT > 0
  2653. BEGIN
  2654. INSERT INTO @T(ID, [Type], ContentText) VALUES(@caMainID, 6, '')
  2655. END
  2656. ----面试通知
  2657. --DECLARE @InterViewCnt INT
  2658. --SELECT @InterViewCnt = COUNT(*)
  2659. --FROM exInterview WITH(NOLOCK)
  2660. --WHERE JOBID IN (
  2661. -- SELECT ID FROM JOB WITH(NOLOCK)
  2662. -- WHERE CpMainID = @cpMainID
  2663. -- AND CaMainID = @caMainID
  2664. --) AND ResultDate IS NOT NULL
  2665. --AND CpResultViewDate IS NULL
  2666. --IF @InterViewCnt > 0
  2667. --BEGIN
  2668. -- INSERT INTO @T(ID, [Type], ContentText,AddDate) VALUES(@caMainID, 7, '有'+@InterViewCnt+'位求职者答复了面试通知',GETDATE())
  2669. --END
  2670. ----求答复提醒
  2671. --DECLARE @ReplyViewCnt INT
  2672. --SELECT @ReplyViewCnt = COUNT(*)
  2673. --FROM ExJobApply WITH(NOLOCK)
  2674. --WHERE JOBID IN (
  2675. -- SELECT ID FROM JOB WITH(NOLOCK)
  2676. -- WHERE CpMainID = @cpMainID
  2677. -- AND CaMainID = @caMainID
  2678. --) AND RemindDate IS NOT NULL
  2679. --AND CpRemindViewDate IS NULL
  2680. --IF @ReplyViewCnt > 0
  2681. --BEGIN
  2682. -- INSERT INTO @T(ID, [Type], ContentText,AddDate) VALUES(@caMainID, 8, @ReplyViewCnt,GETDATE())
  2683. --END
  2684. SELECT * FROM @T ORDER BY Type,ID
  2685. END
  2686. GO
  2687. /****** Object: StoredProcedure [dbo].[ccIndexPageSelect] Script Date: 2018/12/13 19:07:00 ******/
  2688. SET ANSI_NULLS ON
  2689. GO
  2690. SET QUOTED_IDENTIFIER ON
  2691. GO
  2692. CREATE PROCEDURE [dbo].[ccIndexPageSelect]
  2693. (
  2694. @cpMainID INT,
  2695. @caMainID INT,
  2696. @ProvinceID INT,
  2697. @IsManager BIT,
  2698. @Object VARCHAR(10)
  2699. )
  2700. AS
  2701. BEGIN
  2702. DECLARE @t AS TABLE(
  2703. ID INT,
  2704. type INT,
  2705. iCount INT NULL,
  2706. Title NVARCHAR(100) NULL,
  2707. Link NVARCHAR(200) NULL,
  2708. ContentText NVARCHAR(500) NULL,
  2709. AddDate SMALLDATETIME NULL
  2710. )
  2711. --取未付款订单
  2712. INSERT INTO @T(ID,type,iCount) SELECT @cpMainID,0,count(1) FROM caOrder a WITH(NOLOCK) WHERE (a.IsDeleted=0 OR a.IsDeleted IS NULL) AND a.cpMainID = @cpMainID AND OrderStatus = 0 AND AddDate > DATEADD(Month,-2,GETDATE())
  2713. --取未查看的网站消息
  2714. INSERT INTO @T(ID,type,ContentText,AddDate,iCount) SELECT ID,1,Content,AddDate,type FROM CompanyNotify WITH(NOLOCK) WHERE CompanyID = @cpMainID AND ((Type=1 AND Received=0) Or (Type=2 AND EndDate>GETDATE())) ORDER BY AddDate DESC
  2715. --取未查看的反馈
  2716. INSERT INTO @T(ID,type,ContentText,AddDate) SELECT Top 1 ID,2,ReplyMessage,ReplyDate FROM CaFeedBack WITH(NOLOCK) WHERE caMainID = @caMainID AND IsReply = 1 AND ViewDate IS NULL ORDER BY ID DESC
  2717. --取未查看的投诉
  2718. IF @ISManager=1
  2719. INSERT INTO @T(ID,type,ContentText,AddDate) SELECT TOP 1 a.ID,3,a.Plaint,a.AddDate FROM PaPlaint a WITH(NOLOCK INDEX(IX_paPlaint_caMainID)), caMain b WITH( NOLOCK INDEX(IX_caMain_cpMainID)) WHERE a.caMainID = b.ID AND b.cpMainID = @cpMainID AND IsViewed=0 AND ReplyType =1 ORDER BY a.CaMainID,a.ID DESC
  2720. ELSE
  2721. INSERT INTO @T(ID,type,ContentText,AddDate) SELECT TOP 1 ID,3,Plaint,AddDate FROM PaPlaint WITH(NOLOCK INDEX(IX_paPlaint_caMainID)) WHERE caMainID = @caMainID AND IsViewed=0 AND ReplyType =1 ORDER BY ID DESC
  2722. --取未查看的网站分类通知
  2723. INSERT INTO @T(ID, type, Title, ContentText, link, iCount)
  2724. SELECT TOP 1 ID, 4, Title, Content, link, Type
  2725. FROM CompanyInform WITH(NOLOCK)
  2726. WHERE Status = 1
  2727. AND Object LIKE '%' + @Object + '%'
  2728. AND Province LIKE '%' + LTRIM(STR(@ProvinceID)) + '%'
  2729. AND EndDate > GETDATE() ORDER BY AddDate DESC
  2730. --取当前调查
  2731. INSERT INTO @T(ID,type,ContentText)
  2732. SELECT TOP 1 ID,5,Title FROM Ivgt_Investigation WITH(NOLOCK)
  2733. WHERE ENDdate > GETDATE()
  2734. AND province Like '%' + LTRIM(STR(@provinceid)) + '%'
  2735. AND type=1
  2736. ORDER BY adddate
  2737. --如果有1个月内到期的职位,修改截止日期
  2738. BEGIN TRY
  2739. UPDATE Job SET IssueEnd = DATEADD(MINUTE,-1, CONVERT(VARCHAR(10), DATEADD(MONTH, 2, GETDATE()) + 1, 120))
  2740. WHERE caMainId = @caMainID
  2741. AND IssueEnd < DATEADD(MONTH, 1, GETDATE())
  2742. AND Valid = 1
  2743. AND @cpMainId <> 10371941
  2744. END TRY
  2745. BEGIN CATCH
  2746. END CATCH
  2747. IF @@ROWCOUNT > 0
  2748. BEGIN
  2749. INSERT INTO @T(ID, [Type], ContentText) VALUES(@caMainID, 6, '')
  2750. END
  2751. ----面试通知
  2752. --DECLARE @InterViewCnt INT
  2753. --SELECT @InterViewCnt = COUNT(*)
  2754. --FROM exInterview WITH(NOLOCK)
  2755. --WHERE JOBID IN (
  2756. -- SELECT ID FROM JOB WITH(NOLOCK)
  2757. -- WHERE CpMainID = @cpMainID
  2758. -- AND CaMainID = @caMainID
  2759. --) AND ResultDate IS NOT NULL
  2760. --AND CpResultViewDate IS NULL
  2761. --IF @InterViewCnt > 0
  2762. --BEGIN
  2763. -- INSERT INTO @T(ID, [Type], ContentText,AddDate) VALUES(@caMainID, 7, '有'+@InterViewCnt+'位求职者答复了面试通知',GETDATE())
  2764. --END
  2765. ----求答复提醒
  2766. --DECLARE @ReplyViewCnt INT
  2767. --SELECT @ReplyViewCnt = COUNT(*)
  2768. --FROM ExJobApply WITH(NOLOCK)
  2769. --WHERE JOBID IN (
  2770. -- SELECT ID FROM JOB WITH(NOLOCK)
  2771. -- WHERE CpMainID = @cpMainID
  2772. -- AND CaMainID = @caMainID
  2773. --) AND RemindDate IS NOT NULL
  2774. --AND CpRemindViewDate IS NULL
  2775. --IF @ReplyViewCnt > 0
  2776. --BEGIN
  2777. -- INSERT INTO @T(ID, [Type], ContentText,AddDate) VALUES(@caMainID, 8, @ReplyViewCnt,GETDATE())
  2778. --END
  2779. SELECT * FROM @T ORDER BY Type,ID
  2780. END
  2781. GO
  2782. /****** Object: StoredProcedure [dbo].[ccJobByCaMainIDIssuedSelect] Script Date: 2018/12/13 19:07:00 ******/
  2783. SET ANSI_NULLS ON
  2784. GO
  2785. SET QUOTED_IDENTIFIER ON
  2786. GO
  2787. --时间 2014-01-05
  2788. --查询某个企业用户发布的所有职位
  2789. CREATE PROCEDURE [dbo].[ccJobByCaMainIDIssuedSelect]
  2790. (
  2791. @caMainID INT
  2792. )
  2793. AS
  2794. BEGIN
  2795. SELECT a.ID,a.Name,a.IssueEnd,a.dcRegionID
  2796. FROM Job a WITH(NOLOCK)
  2797. WHERE a.caMainID = @caMainID AND a.IsDelete=0 AND a.IssueDate IS NOT NULL
  2798. GROUP BY a.ID,a.Valid,a.IssueEnd,a.Name,a.dcRegionID
  2799. ORDER BY a.Valid DESC,a.IssueEnd DESC
  2800. END
  2801. GO
  2802. /****** Object: StoredProcedure [dbo].[ccJobByCaMainIDSelect] Script Date: 2018/12/13 19:07:00 ******/
  2803. SET ANSI_NULLS ON
  2804. GO
  2805. SET QUOTED_IDENTIFIER ON
  2806. GO
  2807. --修改harry 2017-10-19 修改status=1的显示定制刷新状态jobrefreshIng
  2808. --a;en 2018-4-9
  2809. CREATE PROCEDURE [dbo].[ccJobByCaMainIDSelect]
  2810. (
  2811. @caMainID INT,
  2812. @Status INT
  2813. )
  2814. AS
  2815. BEGIN
  2816. IF @Status=0
  2817. SELECT *,(SELECT COUNT(ID) FROM exJobApply WITH(NOLOCK) WHERE CompanyDeleted=0 AND JobID=Job.ID AND (IsFilter IS NULL OR IsFilter=0)) ApplyCount
  2818. FROM Job WITH(NOLOCK)
  2819. WHERE caMainID = @caMainID AND IsDelete=0 AND IssueDate IS NULL
  2820. ORDER BY LastModifyDate DESC
  2821. IF @Status=1
  2822. SELECT *, CASE WHEN EXISTS(SELECT 'X' FROM jobRefreshLog WHERE jobId = job.id AND runDateTime is NULL) THEN 1 ELSE 0 END AS jobrefreshIng,
  2823. (SELECT COUNT(ID) FROM exJobApply WITH(NOLOCK) WHERE CompanyDeleted=0 AND JobID=Job.ID AND (IsFilter IS NULL OR IsFilter=0)) ApplyCount
  2824. FROM Job WITH(NOLOCK)
  2825. WHERE caMainID = @caMainID AND IsDelete=0 AND IssueEND > GETDATE()
  2826. ORDER BY DisplayNo, IssueEnd, ID DESC
  2827. IF @Status=2
  2828. SELECT *,(SELECT COUNT(ID) FROM exJobApply WITH(NOLOCK) WHERE CompanyDeleted=0 AND JobID=Job.ID AND (IsFilter IS NULL OR IsFilter=0)) ApplyCount
  2829. FROM Job WITH(NOLOCK)
  2830. WHERE caMainID = @caMainID AND IsDelete=0 AND IssueEND < GETDATE()
  2831. ORDER BY IssueEnd DESC
  2832. END
  2833. GO
  2834. /****** Object: StoredProcedure [dbo].[ccJobBycaMainIDSelectAll] Script Date: 2018/12/13 19:07:01 ******/
  2835. SET ANSI_NULLS ON
  2836. GO
  2837. SET QUOTED_IDENTIFIER ON
  2838. GO
  2839. CREATE PROCEDURE [dbo].[ccJobBycaMainIDSelectAll]
  2840. (
  2841. @caMainID INT
  2842. )
  2843. AS
  2844. BEGIN
  2845. SELECT *
  2846. FROM Job WITH(NOLOCK)
  2847. WHERE caMainID = @caMainID AND IsDelete=0
  2848. ORDER BY DisplayNo,LastModifyDate DESC
  2849. END
  2850. GO
  2851. /****** Object: StoredProcedure [dbo].[ccJobBycaMainIDSelectCount] Script Date: 2018/12/13 19:07:01 ******/
  2852. SET ANSI_NULLS ON
  2853. GO
  2854. SET QUOTED_IDENTIFIER ON
  2855. GO
  2856. CREATE PROCEDURE [dbo].[ccJobBycaMainIDSelectCount]
  2857. (
  2858. @caMainID INT
  2859. )
  2860. AS
  2861. BEGIN
  2862. SELECT COUNT(*) cnt
  2863. FROM Job WITH(NOLOCK)
  2864. WHERE caMainID = @caMainID AND IsDelete=0 AND IssueDate IS NOT NULL
  2865. AND IssueEnd > GETDATE()
  2866. END
  2867. GO
  2868. /****** Object: StoredProcedure [dbo].[ccJobBycaMainIDSelectFilter] Script Date: 2018/12/13 19:07:02 ******/
  2869. SET ANSI_NULLS ON
  2870. GO
  2871. SET QUOTED_IDENTIFIER ON
  2872. GO
  2873. CREATE PROCEDURE [dbo].[ccJobBycaMainIDSelectFilter]
  2874. (
  2875. @caMainID INT
  2876. )
  2877. AS
  2878. --INSERT INTO procLog select 'ccJobByCaMainIDSelectFilter', '', getdate()
  2879. BEGIN
  2880. SELECT a.ID,a.Name,a.IssueEnd
  2881. FROM Job a WITH(NOLOCK), exJobApply b WITH(NOLOCK)
  2882. WHERE a.ID=b.JobID AND a.caMainID = @caMainID AND a.IsDelete=0 AND a.IssueDate IS NOT NULL
  2883. GROUP BY a.ID,a.Valid,a.IssueEnd,a.Name
  2884. ORDER BY a.Valid DESC,a.IssueEnd DESC
  2885. END
  2886. GO
  2887. /****** Object: StoredProcedure [dbo].[ccJobBycaMainIDSelectHasIssued] Script Date: 2018/12/13 19:07:02 ******/
  2888. SET ANSI_NULLS ON
  2889. GO
  2890. SET QUOTED_IDENTIFIER ON
  2891. GO
  2892. --修改人:harry2015-8-28
  2893. --管理员用户可以查看所有的职位
  2894. CREATE PROCEDURE [dbo].[ccJobBycaMainIDSelectHasIssued]
  2895. (
  2896. @caMainID INT
  2897. )
  2898. AS
  2899. BEGIN
  2900. DECLARE @cpMainId INT,@accountType INT
  2901. SELECT @cpMainId=cpMainID, @accountType=AccountType
  2902. FROM caMain
  2903. WHERE ID=@caMainID
  2904. IF @accountType=1
  2905. BEGIN
  2906. SELECT *
  2907. FROM Job WITH(NOLOCK)
  2908. WHERE cpMainID = @cpMainId AND IsDelete=0 AND IssueDate IS NOT NULL
  2909. ORDER BY Valid DESC,DisplayNo,IssueEnd DESC,LastModifyDate DESC
  2910. END
  2911. ELSE
  2912. BEGIN
  2913. SELECT *
  2914. FROM Job WITH(NOLOCK)
  2915. WHERE caMainID = @caMainID AND IsDelete=0 AND IssueDate IS NOT NULL
  2916. ORDER BY Valid DESC,DisplayNo,IssueEnd DESC,LastModifyDate DESC
  2917. END
  2918. END
  2919. GO
  2920. /****** Object: StoredProcedure [dbo].[ccJobByCaMainIDUpdate] Script Date: 2018/12/13 19:07:02 ******/
  2921. SET ANSI_NULLS ON
  2922. GO
  2923. SET QUOTED_IDENTIFIER ON
  2924. GO
  2925. --lambo 20110616
  2926. --修改职位的所属用户
  2927. --[dbo].[ccJobByCaMainIDUpdate] 2458146,9041691,9041691
  2928. CREATE PROCEDURE [dbo].[ccJobByCaMainIDUpdate]
  2929. @ID INT,
  2930. @caMainID INT,
  2931. @cpMainID INT
  2932. AS
  2933. BEGIN TRAN
  2934. BEGIN TRY
  2935. IF EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK) WHERE ID = @caMainID AND cpMainID = @cpMainID)
  2936. BEGIN
  2937. UPDATE Job SET caMainID = @caMainID WHERE ID = @ID AND cpMainID = @cpMainID
  2938. UPDATE caFavorate SET caMainID = @caMainID WHERE JobID = @ID
  2939. UPDATE paPlaint SET caMainID = @caMainID WHERE JobID = @ID
  2940. END
  2941. ELSE
  2942. GOTO ERR
  2943. END TRY
  2944. BEGIN CATCH
  2945. GOTO ERR
  2946. END CATCH
  2947. COMMIT TRAN
  2948. RETURN 1
  2949. ERR:
  2950. BEGIN
  2951. ROLLBACK TRAN
  2952. RETURN 0
  2953. END
  2954. GO
  2955. /****** Object: StoredProcedure [dbo].[ccJobByCpMainIDIssuedSelect] Script Date: 2018/12/13 19:07:02 ******/
  2956. SET ANSI_NULLS ON
  2957. GO
  2958. SET QUOTED_IDENTIFIER ON
  2959. GO
  2960. --Edit By Andy 2014-12-05
  2961. --添加a.dcRegionID列
  2962. CREATE PROCEDURE [dbo].[ccJobByCpMainIDIssuedSelect]
  2963. (
  2964. @cpMainID INT
  2965. )
  2966. AS
  2967. BEGIN
  2968. SELECT a.ID, a.Name, a.IssueEnd, a.dcRegionID
  2969. FROM Job a WITH(NOLOCK)
  2970. WHERE a.cpMainID = @cpMainID
  2971. AND a.IsDelete=0
  2972. AND a.IssueDate IS NOT NULL
  2973. ORDER BY a.Valid DESC, a.IssueEnd DESC
  2974. END
  2975. GO
  2976. /****** Object: StoredProcedure [dbo].[ccJobBycpMainIDNewSelect] Script Date: 2018/12/13 19:07:02 ******/
  2977. SET ANSI_NULLS ON
  2978. GO
  2979. SET QUOTED_IDENTIFIER ON
  2980. GO
  2981. --根据企业ID查询职位 20151121
  2982. CREATE PROCEDURE [dbo].[ccJobBycpMainIDNewSelect]
  2983. (
  2984. @cpMainID INT,
  2985. @Status INT,
  2986. @PaMainID INT
  2987. )
  2988. AS
  2989. BEGIN
  2990. IF @Status=0
  2991. BEGIN
  2992. SELECT *, 0 IsOnline,0 IsAttention INTO #T1
  2993. FROM Job WITH(NOLOCK)
  2994. WHERE cpMainID = @cpMainID AND IsDelete = 0 AND IssueDate IS NULL
  2995. ORDER BY LastModifyDate DESC
  2996. IF @PaMainID<>0
  2997. BEGIN
  2998. UPDATE #T1 SET IsAttention = 1
  2999. WHERE ID IN(
  3000. SELECT AttentionID FROM PaAttention
  3001. WHERE AttentionType = 2 AND PaMainID = @paMainID
  3002. )
  3003. END
  3004. SELECT * FROM #T1
  3005. END
  3006. IF @Status=1
  3007. BEGIN
  3008. SELECT a.*, ISNULL(b.IsOnline, 0) IsOnline ,0 IsAttention INTO #T2
  3009. FROM Job a WITH(NOLOCK)
  3010. LEFT JOIN caOnline b WITH(NOLOCK) ON a.caMainId = b.caMainId
  3011. WHERE a.cpMainID = @cpMainID AND a.Valid = 1
  3012. ORDER BY a.DisplayNo, CONVERT(VARCHAR(4), a.dcJobtypeId)
  3013. IF @PaMainID<>0
  3014. BEGIN
  3015. UPDATE #T2 SET IsAttention = 1
  3016. WHERE ID IN(
  3017. SELECT AttentionID FROM PaAttention
  3018. WHERE AttentionType = 2 AND PaMainID = @paMainID
  3019. )
  3020. END
  3021. SELECT * FROM #2
  3022. END
  3023. IF @Status=2
  3024. BEGIN
  3025. SELECT *, 0 IsOnline,0 IsAttention INTO #T3
  3026. FROM Job WITH(NOLOCK)
  3027. WHERE cpMainID = @cpMainID AND IsDelete = 0 AND IssueEND < GETDATE()
  3028. ORDER BY IssueEnd DESC
  3029. IF @PaMainID<>0
  3030. BEGIN
  3031. UPDATE #T3 SET IsAttention = 1
  3032. WHERE ID IN(
  3033. SELECT AttentionID FROM PaAttention
  3034. WHERE AttentionType = 2 AND PaMainID = @paMainID
  3035. )
  3036. END
  3037. SELECT * FROM #T3
  3038. END
  3039. IF @Status=3
  3040. BEGIN
  3041. SELECT *, 0 IsOnline,0 IsAttention INTO #T4
  3042. FROM Job WITH(NOLOCK)
  3043. WHERE cpMainID = @cpMainID AND IsDelete = 1
  3044. ORDER BY DisplayNo, LastModifyDate DESC
  3045. IF @PaMainID<>0
  3046. BEGIN
  3047. UPDATE #T4 SET IsAttention = 1
  3048. WHERE ID IN(
  3049. SELECT AttentionID FROM PaAttention
  3050. WHERE AttentionType = 2 AND PaMainID = @paMainID
  3051. )
  3052. END
  3053. SELECT * FROM #T4
  3054. END
  3055. IF @Status=4
  3056. BEGIN
  3057. SELECT a.*, b.FullName Region, 0 IsOnline,0 IsAttention INTO #T5
  3058. FROM Job a WITH(NOLOCK)
  3059. LEFT JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionId = b.ID
  3060. WHERE cpMainID = @cpMainID AND IsDelete = 0
  3061. ORDER BY Valid DESC, DisplayNo, CONVERT(VARCHAR(4), dcJobtypeId)
  3062. IF @PaMainID<>0
  3063. BEGIN
  3064. UPDATE #T5 SET IsAttention = 1
  3065. WHERE ID IN(
  3066. SELECT AttentionID FROM PaAttention
  3067. WHERE AttentionType = 2 AND PaMainID = @paMainID
  3068. )
  3069. END
  3070. SELECT * FROM #T5
  3071. END
  3072. IF @Status=5
  3073. BEGIN
  3074. SELECT a.*, b.FullName Region,
  3075. (SELECT IsOnline FROM caOnline WHERE caOnline.caMainId = a.caMainId) IsOnline,0 IsAttention INTO #T6
  3076. FROM Job a WITH(NOLOCK)
  3077. LEFT JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionId = b.ID
  3078. WHERE cpMainID = @cpMainID AND IsDelete = 0
  3079. AND IssueEnd > GETDATE() AND IssueDate < GETDATE()
  3080. ORDER BY DisplayNo, CONVERT(VARCHAR(4), dcJobtypeId)
  3081. IF @PaMainID<>0
  3082. BEGIN
  3083. UPDATE #T6 SET IsAttention = 1
  3084. WHERE ID IN(
  3085. SELECT AttentionID FROM PaAttention
  3086. WHERE AttentionType = 2 AND PaMainID = @paMainID
  3087. )
  3088. END
  3089. SELECT * FROM #T6
  3090. END
  3091. END
  3092. GO
  3093. /****** Object: StoredProcedure [dbo].[ccJobByCpMainIDSelect] Script Date: 2018/12/13 19:07:03 ******/
  3094. SET ANSI_NULLS ON
  3095. GO
  3096. SET QUOTED_IDENTIFIER ON
  3097. GO
  3098. --修改harry 2017-10-19 修改status=1的显示定制刷新状态jobrefreshIng
  3099. --lucifer 2018-4-2
  3100. CREATE PROCEDURE [dbo].[ccJobByCpMainIDSelect]
  3101. (
  3102. @cpMainID INT,
  3103. @Status INT
  3104. )
  3105. AS
  3106. SET NOCOUNT ON
  3107. BEGIN
  3108. IF @Status=0
  3109. SELECT *, 0 IsOnline, '' LogoUrl --dbo.GetCpLogo(cpMainID) LogoUrl
  3110. FROM Job WITH(NOLOCK)
  3111. WHERE cpMainID = @cpMainID AND IsDelete = 0 AND IssueDate IS NULL
  3112. ORDER BY LastModifyDate DESC
  3113. IF @Status=1
  3114. SELECT a.*, ISNULL(b.IsOnline, 0) IsOnline, '' LogoUrl, CASE WHEN EXISTS(SELECT 'X' FROM jobRefreshLog WHERE jobId = a.id AND runDateTime is NULL) THEN 1 ELSE 0 END AS jobrefreshIng,
  3115. (SELECT COUNT(ID) FROM exJobApply WITH(NOLOCK) WHERE CompanyDeleted=0 AND JobID=a.ID AND (IsFilter IS NULL OR IsFilter=0)) ApplyCount
  3116. FROM Job a WITH(NOLOCK)
  3117. LEFT JOIN caOnline b WITH(NOLOCK) ON a.caMainId = b.caMainId
  3118. WHERE a.cpMainID = @cpMainID AND a.Valid = 1
  3119. ORDER BY a.DisplayNo, CONVERT(VARCHAR(4), a.dcJobtypeId)
  3120. IF @Status=2
  3121. SELECT *, 0 IsOnline, '' LogoUrl, --dbo.GetCpLogo(cpMainID) LogoUrl,
  3122. (SELECT COUNT(ID) FROM exJobApply WITH(NOLOCK) WHERE CompanyDeleted=0 AND JobID=Job.ID AND (IsFilter IS NULL OR IsFilter=0)) ApplyCount
  3123. FROM Job WITH(NOLOCK)
  3124. WHERE cpMainID = @cpMainID AND IsDelete = 0 AND IssueEND < GETDATE()
  3125. ORDER BY IssueEnd DESC
  3126. IF @Status=3
  3127. SELECT *, 0 IsOnline, '' LogoUrl --dbo.GetCpLogo(cpMainID) LogoUrl
  3128. FROM Job WITH(NOLOCK)
  3129. WHERE cpMainID = @cpMainID AND IsDelete = 1
  3130. ORDER BY DisplayNo, LastModifyDate DESC
  3131. IF @Status=4
  3132. SELECT a.*, b.FullName Region, 0 IsOnline, '' LogoUrl --dbo.GetCpLogo(a.cpMainID) LogoUrl
  3133. FROM Job a WITH(NOLOCK)
  3134. LEFT JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionId = b.ID
  3135. WHERE cpMainID = @cpMainID AND IsDelete = 0
  3136. ORDER BY Valid DESC, DisplayNo, CONVERT(VARCHAR(4), dcJobtypeId)
  3137. IF @Status=5
  3138. SELECT a.*, (b.MapBarName + (CASE LEN(dcRegionID) WHEN 6 THEN b.Description ELSE '' END)) Region, c.DescriptionCp Salary, d.DescriptionCp SalaryMax, e.Description Eudcation, f.Description Experience,
  3139. (SELECT IsOnline FROM caOnline WHERE caOnline.caMainId = a.caMainId) IsOnline, '' LogoUrl --dbo.GetCpLogo(a.cpMainID) LogoUrl
  3140. FROM Job a WITH(NOLOCK)
  3141. LEFT JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionId = b.ID
  3142. LEFT JOIN dcSalary c WITH(NOLOCK) ON a.dcSalaryID = c.ID
  3143. LEFT JOIN dcSalary d WITH(NOLOCK) ON a.dcSalaryIDMax = d.ID
  3144. LEFT JOIN dcEducation e WITH(NOLOCK) ON a.dcEducationID = e.ID
  3145. LEFT JOIN dcOthers f WITH(NOLOCK) ON a.MinExperience = f.DetailID AND f.Category = '职位要求工作经验'
  3146. WHERE cpMainID = @cpMainID AND IsDelete = 0
  3147. AND IssueEnd > GETDATE() AND IssueDate < GETDATE()
  3148. ORDER BY DisplayNo, CONVERT(VARCHAR(4), dcJobtypeId)
  3149. END
  3150. GO
  3151. /****** Object: StoredProcedure [dbo].[ccJobBycpMainIDSelectFilter] Script Date: 2018/12/13 19:07:03 ******/
  3152. SET ANSI_NULLS ON
  3153. GO
  3154. SET QUOTED_IDENTIFIER ON
  3155. GO
  3156. --Edit By Andy 2014-12-05
  3157. --添加a.dcRegionID列
  3158. CREATE PROCEDURE [dbo].[ccJobBycpMainIDSelectFilter]
  3159. (
  3160. @cpMainID INT
  3161. )
  3162. AS
  3163. --INSERT INTO procLog select 'ccJobBycpMainIDSelectFilter', '', getdate()
  3164. BEGIN
  3165. SELECT a.ID, a.Name, a.IssueEnd, a.dcRegionID
  3166. FROM Job a WITH(NOLOCK)
  3167. WHERE a.cpMainID = @cpMainID
  3168. AND a.IsDelete=0
  3169. AND a.IssueDate IS NOT NULL
  3170. ORDER BY a.Valid DESC, a.IssueEnd DESC
  3171. END
  3172. GO
  3173. /****** Object: StoredProcedure [dbo].[ccJobByEncryptViewSelect] Script Date: 2018/12/13 19:07:03 ******/
  3174. SET ANSI_NULLS ON
  3175. GO
  3176. SET QUOTED_IDENTIFIER ON
  3177. GO
  3178. --职位修改页面获取职位信息
  3179. CREATE PROCEDURE [dbo].[ccJobByEncryptViewSelect]
  3180. (
  3181. @ID VARCHAR(12)
  3182. )
  3183. AS
  3184. BEGIN
  3185. SELECT a.*, b.FullName Region, ISNULL(c.IsOnline, 0) IsOnline,
  3186. STUFF((SELECT '@' + Tags FROM jobTags WITH(NOLOCK) WHERE jobID = a.ID FOR XML PATH('')),1,1,'') JobTags
  3187. FROM Job a WITH(NOLOCK)
  3188. INNER JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionID = b.ID
  3189. LEFT JOIN caOnline c WITH(NOLOCK) ON a.caMainId = c.caMainId
  3190. WHERE a.SecondID = @ID
  3191. END
  3192. GO
  3193. /****** Object: StoredProcedure [dbo].[ccJobByIssueStopUpdate] Script Date: 2018/12/13 19:07:03 ******/
  3194. SET ANSI_NULLS ON
  3195. GO
  3196. SET QUOTED_IDENTIFIER ON
  3197. GO
  3198. --终止职位
  3199. --修改harry 增加职位刷新操作2017-11-8
  3200. CREATE PROCEDURE [dbo].[ccJobByIssueStopUpdate]
  3201. (
  3202. @ID INT,
  3203. @caMainID INT,
  3204. @cpMainID INT
  3205. )
  3206. AS
  3207. BEGIN TRAN
  3208. IF NOT EXISTS(SELECT 'x' FROM Job WHERE ID = @ID AND cpMainID = @cpMainID)
  3209. GOTO ERR
  3210. UPDATE JOB
  3211. SET IssueDate = (CASE WHEN IssueDate >= GETDATE() THEN CONVERT(VARCHAR(10), GETDATE(), 23) ELSE IssueDate END),
  3212. IssueEnd = DATEADD(MINUTE, -1, GETDATE())
  3213. WHERE ID = @ID
  3214. UPDATE jobrefreshSet
  3215. SET runState =0
  3216. WHERE runState =1
  3217. AND jobId = @ID
  3218. ----暂停职位
  3219. --DECLARE @JobNum AS INT, @JobName AS NVARCHAR(100), @Desc AS NVARCHAR(200)
  3220. --SELECT @JobName = LTRIM(RTRIM([Name])) FROM Job WITH(NOLOCK) WHERE ID = @ID
  3221. --SET @Desc = '停止职位:编号<' + LTRIM(STR(@ID)) + '>职位名称<' + @JobName +'>。'
  3222. --EXEC ccCaOperationLogInsert @caMainID, 41, @Desc
  3223. COMMIT TRAN
  3224. RETURN 1
  3225. ERR:
  3226. BEGIN
  3227. ROLLBACK TRAN
  3228. RETURN 0
  3229. END
  3230. GO
  3231. /****** Object: StoredProcedure [dbo].[ccJobByIssueUpdate] Script Date: 2018/12/13 19:07:03 ******/
  3232. SET ANSI_NULLS ON
  3233. GO
  3234. SET QUOTED_IDENTIFIER ON
  3235. GO
  3236. --##############################################################################
  3237. --Sean 2012-4-20
  3238. --Cancel 计划发布职位:编号
  3239. --Peter 2016-10-17修改
  3240. --harry 管理员操作暂停用户的职位时有效2018-4-23
  3241. --##############################################################################
  3242. CREATE PROCEDURE [dbo].[ccJobByIssueUpdate]
  3243. (
  3244. @ID INT,
  3245. @IssueDate SMALLDATETIME,
  3246. @IssueEnd SMALLDATETIME,
  3247. @maxJobNum INT,
  3248. @cpMainId INT
  3249. )
  3250. AS
  3251. SET NOCOUNT ON
  3252. DECLARE @JobNum AS INT, @JobName AS NVARCHAR(100), @Desc AS NVARCHAR(200), @caMainID AS INT
  3253. IF ISNULL(@cpMainId, 0) != 10880312
  3254. BEGIN
  3255. SET @IssueDate = DATEADD(MINUTE, -1, GETDATE())
  3256. IF @IssueEnd < GETDATE()
  3257. SET @IssueEnd = DATEADD(MONTH, 2, GETDATE())
  3258. SET @IssueEnd = CONVERT(VARCHAR(10), @IssueEnd, 120) + ' 23:59'
  3259. IF @IssueEnd < @IssueDate
  3260. SET @IssueEnd = CONVERT(VARCHAR(10), @IssueDate, 120) + ' 23:59'
  3261. BEGIN TRAN
  3262. BEGIN TRY
  3263. IF NOT EXISTS(SELECT 'x' FROM Job WITH(NOLOCK) WHERE ID = @ID AND cpMainID = @cpMainID)
  3264. GOTO ERR
  3265. SELECT @JobName = LTRIM(RTRIM([Name])), @caMainID = caMainID FROM Job WITH(NOLOCK) WHERE ID = @ID
  3266. IF @IssueEnd > GETDATE()
  3267. BEGIN
  3268. SELECT @JobNum = COUNT(*) FROM Job WITH(NOLOCK)
  3269. WHERE IsDelete = 0 AND IssueDate<GETDATE() AND IssueEnd>GETDATE()
  3270. AND cpMainID=@cpMainID AND ID <> @ID
  3271. SELECT @maxJobNum = MaxJobNumber FROM cpMain WITH(NOLOCK) WHERE Id = @cpMainId
  3272. IF @maxJobNum <= @JobNum
  3273. GOTO ERR1
  3274. END
  3275. IF EXISTS(SELECT 'X' FROM caMain WITH(NOLOCK) WHERE ID=@caMainID AND IsPause=1)
  3276. BEGIN
  3277. --GOTO ERR2
  3278. UPDATE job SET caMainId=(select TOP 1 id from caMain where cpmainid=@cpMainId AND accountType=1)
  3279. FROM Job WITH(NOLOCK) WHERE ID = @ID
  3280. END
  3281. UPDATE Job SET IssueDate = @IssueDate, IssueEnd = @IssueEnd WHERE ID=@ID
  3282. ----立即发布职位
  3283. --SET @Desc = '发布职位:编号<' + LTRIM(STR(@ID)) + '>职位名称<' + @JobName +'>,有效期至' + CONVERT(VARCHAR(19), @IssueEnd, 120) + '。'
  3284. --EXEC ccCaOperationLogInsert @caMainID, 40, @Desc
  3285. INSERT INTO paPushLog(paMainID, PushMessage, PushType, DetailID)
  3286. SELECT PaMainID, '亲,您关注的企业发布新职位啦!', 6, @ID FROM paAttention
  3287. WHERE AttentionType = 1 AND AttentionID = @cpMainId AND EXISTS(
  3288. SELECT 'X' FROM paIOSBind WHERE paMainID = paAttention.paMainID
  3289. )
  3290. --修改推送的相关信息
  3291. IF EXISTS(SELECT 'x' FROM caPushSet WITH(NOLOCK) WHERE caMainID = @caMainID)
  3292. BEGIN
  3293. UPDATE caPushSet
  3294. SET PushNo = 0
  3295. WHERE caMainID = @caMainID
  3296. END
  3297. ELSE
  3298. BEGIN
  3299. INSERT INTO caPushSet(caMainID,PushFrequency,PushNo)
  3300. VALUES (@CaMainID,99,0)
  3301. END
  3302. END TRY
  3303. BEGIN CATCH
  3304. RETURN -3
  3305. END CATCH
  3306. COMMIT TRAN
  3307. RETURN 1
  3308. END
  3309. ELSE
  3310. ------------------------------------------------------
  3311. BEGIN
  3312. SET @IssueDate = DATEADD(MINUTE, -1, GETDATE())
  3313. IF @IssueEnd < GETDATE()
  3314. SET @IssueEnd = DATEADD(MONTH, 2, GETDATE())
  3315. SET @IssueEnd = CONVERT(VARCHAR(10), @IssueEnd, 120) + ' 23:59'
  3316. IF @IssueEnd < @IssueDate
  3317. SET @IssueEnd = CONVERT(VARCHAR(10), @IssueDate, 120) + ' 23:59'
  3318. -- BEGIN TRAN
  3319. -- BEGIN TRY
  3320. IF NOT EXISTS(SELECT 'x' FROM Job WITH(NOLOCK) WHERE ID = @ID AND cpMainID = @cpMainID)
  3321. GOTO ERR
  3322. -- DECLARE @JobNum AS INT, @JobName AS NVARCHAR(100), @Desc AS NVARCHAR(200), @caMainID AS INT
  3323. SELECT @JobName = LTRIM(RTRIM([Name])), @caMainID = caMainID FROM Job WITH(NOLOCK) WHERE ID = @ID
  3324. IF @IssueEnd > GETDATE()
  3325. BEGIN
  3326. SELECT @JobNum = COUNT(*) FROM Job WITH(NOLOCK)
  3327. WHERE IsDelete = 0 AND IssueDate<GETDATE() AND IssueEnd>GETDATE()
  3328. AND cpMainID=@cpMainID AND ID <> @ID
  3329. SELECT @maxJobNum = MaxJobNumber FROM cpMain WITH(NOLOCK) WHERE Id = @cpMainId
  3330. IF @maxJobNum <= @JobNum
  3331. GOTO ERR1
  3332. END
  3333. IF EXISTS(SELECT 'X' FROM caMain WITH(NOLOCK) WHERE ID=@caMainID AND IsPause=1)
  3334. BEGIN
  3335. --GOTO ERR2
  3336. UPDATE job SET caMainId=(select TOP 1 id from caMain where cpmainid=@cpMainId AND accountType=1)
  3337. FROM Job WITH(NOLOCK) WHERE ID = @ID
  3338. END
  3339. UPDATE Job SET IssueDate = @IssueDate, IssueEnd = @IssueEnd WHERE ID=@ID
  3340. ----立即发布职位
  3341. --SET @Desc = '发布职位:编号<' + LTRIM(STR(@ID)) + '>职位名称<' + @JobName +'>,有效期至' + CONVERT(VARCHAR(19), @IssueEnd, 120) + '。'
  3342. --EXEC ccCaOperationLogInsert @caMainID, 40, @Desc
  3343. INSERT INTO paPushLog(paMainID, PushMessage, PushType, DetailID)
  3344. SELECT PaMainID, '亲,您关注的企业发布新职位啦!', 6, @ID FROM paAttention
  3345. WHERE AttentionType = 1 AND AttentionID = @cpMainId AND EXISTS(
  3346. SELECT 'X' FROM paIOSBind WHERE paMainID = paAttention.paMainID
  3347. )
  3348. --修改推送的相关信息
  3349. IF EXISTS(SELECT 'x' FROM caPushSet WITH(NOLOCK) WHERE caMainID = @caMainID)
  3350. BEGIN
  3351. UPDATE caPushSet
  3352. SET PushNo = 0
  3353. WHERE caMainID = @caMainID
  3354. END
  3355. ELSE
  3356. BEGIN
  3357. INSERT INTO caPushSet(caMainID,PushFrequency,PushNo)
  3358. VALUES (@CaMainID,99,0)
  3359. END
  3360. -- END TRY
  3361. -- BEGIN CATCH
  3362. -- GOTO ERR
  3363. -- END CATCH
  3364. -- COMMIT TRAN
  3365. RETURN 1
  3366. END
  3367. ---------------------------------------------------------------
  3368. ERR:
  3369. BEGIN
  3370. IF ISNULL(@cpMainId, 0) != 10880312
  3371. ROLLBACK TRAN
  3372. RETURN 0
  3373. END
  3374. ERR1:
  3375. BEGIN
  3376. IF ISNULL(@cpMainId, 0) != 10880312
  3377. ROLLBACK TRAN
  3378. RETURN -1
  3379. END
  3380. ERR2:
  3381. BEGIN
  3382. IF ISNULL(@cpMainId, 0) != 10880312
  3383. ROLLBACK TRAN
  3384. RETURN -2
  3385. END
  3386. GO
  3387. /****** Object: StoredProcedure [dbo].[ccJobByIssueUpdate2] Script Date: 2018/12/13 19:07:04 ******/
  3388. SET ANSI_NULLS ON
  3389. GO
  3390. SET QUOTED_IDENTIFIER ON
  3391. GO
  3392. --##############################################################################
  3393. --Sean 2012-4-20
  3394. --Cancel 计划发布职位:编号
  3395. --##############################################################################
  3396. CREATE PROCEDURE [dbo].[ccJobByIssueUpdate2]
  3397. (
  3398. @ID INT,
  3399. @IssueDate SMALLDATETIME,
  3400. @IssueEnd SMALLDATETIME,
  3401. @maxJobNum INT,
  3402. @cpMainId INT
  3403. )
  3404. AS
  3405. SET NOCOUNT ON
  3406. INSERT INTO aa SELECT @Id, @IssueDate, @IssueEnd, @MaxJobNum, @CpMainId
  3407. BEGIN
  3408. SET @IssueDate = DATEADD(MINUTE, -1, GETDATE())
  3409. SET @IssueEnd = CONVERT(VARCHAR(10), @IssueEnd, 120) + ' 23:59'
  3410. IF @IssueEnd < @IssueDate
  3411. SET @IssueEnd = CONVERT(VARCHAR(10), @IssueDate, 120) + ' 23:59'
  3412. BEGIN TRAN
  3413. BEGIN TRY
  3414. IF NOT EXISTS(SELECT 'x' FROM Job WITH(NOLOCK) WHERE ID = @ID AND cpMainID = @cpMainID)
  3415. GOTO ERR
  3416. DECLARE @JobNum AS INT, @JobName AS NVARCHAR(100), @Desc AS NVARCHAR(200), @caMainID AS INT
  3417. SELECT @JobName = LTRIM(RTRIM([Name])), @caMainID = caMainID FROM Job WITH(NOLOCK) WHERE ID = @ID
  3418. IF EXISTS(SELECT 'X' FROM caMain WITH(NOLOCK) WHERE ID=@caMainID AND IsPause=1)
  3419. GOTO ERR2
  3420. IF @IssueEnd > GETDATE()
  3421. BEGIN
  3422. SELECT @JobNum = COUNT(*) FROM Job WITH(NOLOCK)
  3423. WHERE IsDelete = 0 AND IssueDate<GETDATE() AND IssueEnd>GETDATE() AND cpMainID=@cpMainID
  3424. AND ID <> @ID
  3425. IF @maxJobNum <= @JobNum
  3426. GOTO ERR1
  3427. END
  3428. UPDATE Job SET IssueDate = @IssueDate, IssueEnd = @IssueEnd WHERE ID=@ID
  3429. ----立即发布职位
  3430. --SET @Desc = '发布职位:编号<' + LTRIM(STR(@ID)) + '>职位名称<' + @JobName +'>,有效期至' + CONVERT(VARCHAR(19), @IssueEnd, 120) + '。'
  3431. --EXEC ccCaOperationLogInsert @caMainID, 40, @Desc
  3432. END TRY
  3433. BEGIN CATCH
  3434. GOTO ERR
  3435. END CATCH
  3436. COMMIT TRAN
  3437. RETURN 1
  3438. END
  3439. ERR:
  3440. BEGIN
  3441. ROLLBACK TRAN
  3442. RETURN 0
  3443. END
  3444. ERR1:
  3445. BEGIN
  3446. ROLLBACK TRAN
  3447. RETURN -1
  3448. END
  3449. ERR2:
  3450. BEGIN
  3451. ROLLBACK TRAN
  3452. RETURN -2
  3453. END
  3454. GO
  3455. /****** Object: StoredProcedure [dbo].[ccJobByIssueUpdate3] Script Date: 2018/12/13 19:07:04 ******/
  3456. SET ANSI_NULLS ON
  3457. GO
  3458. SET QUOTED_IDENTIFIER ON
  3459. GO
  3460. --##############################################################################
  3461. --Sean 2012-4-20
  3462. --Cancel 计划发布职位:编号
  3463. --Peter 2016-10-17修改
  3464. --harry 管理员操作暂停用户的职位时有效2018-4-23
  3465. --##############################################################################
  3466. CREATE PROCEDURE [dbo].[ccJobByIssueUpdate3]
  3467. (
  3468. @ID INT,
  3469. @IssueDate SMALLDATETIME,
  3470. @IssueEnd SMALLDATETIME,
  3471. @maxJobNum INT,
  3472. @cpMainId INT
  3473. )
  3474. AS
  3475. SET NOCOUNT ON
  3476. BEGIN
  3477. SET @IssueDate = DATEADD(MINUTE, -1, GETDATE())
  3478. IF @IssueEnd < GETDATE()
  3479. SET @IssueEnd = DATEADD(MONTH, 2, GETDATE())
  3480. SET @IssueEnd = CONVERT(VARCHAR(10), @IssueEnd, 120) + ' 23:59'
  3481. IF @IssueEnd < @IssueDate
  3482. SET @IssueEnd = CONVERT(VARCHAR(10), @IssueDate, 120) + ' 23:59'
  3483. DECLARE @JobNum AS INT, @JobName AS NVARCHAR(100), @Desc AS NVARCHAR(200), @caMainID AS INT
  3484. SELECT @JobName = LTRIM(RTRIM([Name])), @caMainID = caMainID FROM Job WITH(NOLOCK) WHERE ID = @ID
  3485. IF @IssueEnd > GETDATE()
  3486. BEGIN
  3487. SELECT @JobNum = COUNT(*) FROM Job WITH(NOLOCK)
  3488. WHERE IsDelete = 0 AND IssueDate<GETDATE() AND IssueEnd>GETDATE()
  3489. AND cpMainID=@cpMainID AND ID <> @ID
  3490. SELECT @maxJobNum = MaxJobNumber FROM cpMain WITH(NOLOCK) WHERE Id = @cpMainId
  3491. IF @maxJobNum <= @JobNum
  3492. GOTO ERR1
  3493. END
  3494. IF EXISTS(SELECT 'X' FROM caMain WITH(NOLOCK) WHERE ID=@caMainID AND IsPause=1)
  3495. BEGIN
  3496. --GOTO ERR2
  3497. UPDATE job SET caMainId=(select TOP 1 id from caMain where cpmainid=@cpMainId AND accountType=1)
  3498. FROM Job WITH(NOLOCK) WHERE ID = @ID
  3499. END
  3500. UPDATE Job SET IssueDate = @IssueDate, IssueEnd = @IssueEnd WHERE ID=@ID
  3501. ----立即发布职位
  3502. --SET @Desc = '发布职位:编号<' + LTRIM(STR(@ID)) + '>职位名称<' + @JobName +'>,有效期至' + CONVERT(VARCHAR(19), @IssueEnd, 120) + '。'
  3503. --EXEC ccCaOperationLogInsert @caMainID, 40, @Desc
  3504. INSERT INTO paPushLog(paMainID, PushMessage, PushType, DetailID)
  3505. SELECT PaMainID, '亲,您关注的企业发布新职位啦!', 6, @ID FROM paAttention
  3506. WHERE AttentionType = 1 AND AttentionID = @cpMainId AND EXISTS(
  3507. SELECT 'X' FROM paIOSBind WHERE paMainID = paAttention.paMainID
  3508. )
  3509. --修改推送的相关信息
  3510. IF EXISTS(SELECT 'x' FROM caPushSet WITH(NOLOCK) WHERE caMainID = @caMainID)
  3511. BEGIN
  3512. UPDATE caPushSet
  3513. SET PushNo = 0
  3514. WHERE caMainID = @caMainID
  3515. END
  3516. ELSE
  3517. BEGIN
  3518. INSERT INTO caPushSet(caMainID,PushFrequency,PushNo)
  3519. VALUES (@CaMainID,99,0)
  3520. END
  3521. RETURN 1
  3522. END
  3523. ---------------------------------------------------------------
  3524. ERR:
  3525. BEGIN
  3526. print 'aaa'
  3527. RETURN 0
  3528. END
  3529. ERR1:
  3530. BEGIN
  3531. select @maxJobNum , @JobNum
  3532. print 'bbb'
  3533. RETURN -1
  3534. END
  3535. ERR2:
  3536. BEGIN
  3537. print 'ccc'
  3538. RETURN -2
  3539. END
  3540. GO
  3541. /****** Object: StoredProcedure [dbo].[ccJobByMapBarIDUpdate] Script Date: 2018/12/13 19:07:04 ******/
  3542. SET ANSI_NULLS ON
  3543. GO
  3544. SET QUOTED_IDENTIFIER ON
  3545. GO
  3546. -- =============================================
  3547. -- Author: <Author,,Name>
  3548. -- Create date: <Create Date,,>
  3549. -- Description: <Description,,>
  3550. -- =============================================
  3551. CREATE PROCEDURE [dbo].[ccJobByMapBarIDUpdate]
  3552. @ID INT,
  3553. @MapBarID VARCHAR(50),
  3554. @cpMainID INT
  3555. AS
  3556. BEGIN
  3557. UPDATE Job SET MapBarID=@MapBarID WHERE ID=@ID AND cpMainID = @cpMainID
  3558. END
  3559. GO
  3560. /****** Object: StoredProcedure [dbo].[ccJobByMapBarUpdate] Script Date: 2018/12/13 19:07:05 ******/
  3561. SET ANSI_NULLS ON
  3562. GO
  3563. SET QUOTED_IDENTIFIER ON
  3564. GO
  3565. CREATE PROCEDURE [dbo].[ccJobByMapBarUpdate]
  3566. @ID INT,
  3567. @Lng VARCHAR(20),
  3568. @Lat VARCHAR(20),
  3569. @Address NVARCHAR(50),
  3570. @cpMainID INT
  3571. AS
  3572. BEGIN
  3573. UPDATE Job SET Lng=@Lng,Lat=@Lat WHERE ID=@ID AND cpMainID = @cpMainID
  3574. END
  3575. GO
  3576. /****** Object: StoredProcedure [dbo].[ccJobByNameExist] Script Date: 2018/12/13 19:07:05 ******/
  3577. SET ANSI_NULLS ON
  3578. GO
  3579. SET QUOTED_IDENTIFIER ON
  3580. GO
  3581. --sean 2013-1-30
  3582. --update ccJobNameExist
  3583. --nick 2013-07-22
  3584. --update 判断 发布中还是过期 重名
  3585. CREATE PROCEDURE [dbo].[ccJobByNameExist]
  3586. (
  3587. @ID INT ,
  3588. @cpMainID INT,
  3589. @Name VARCHAR(100)
  3590. )
  3591. AS
  3592. SET NOCOUNT ON
  3593. INSERT INTO procLog select 'ccJobByNameExist', @ID, getdate()
  3594. BEGIN TRY
  3595. DECLARE @IssueEnd DATETIME --截止时间
  3596. SET @Name = LTRIM(RTRIM(@Name))
  3597. SELECT @IssueEnd = IssueEnd
  3598. FROM Job WITH(NOLOCK)
  3599. WHERE NAME=@Name
  3600. AND ID<>@ID
  3601. AND cpMainID = @cpMainID
  3602. AND IsDelete = 0
  3603. IF @IssueEND > GETDATE()
  3604. RETURN 1 --发布中
  3605. IF @IssueEND < GETDATE()
  3606. RETURN 2 --已过期
  3607. RETURN 0
  3608. END TRY
  3609. BEGIN CATCH
  3610. RETURN 0
  3611. END CATCH
  3612. GO
  3613. /****** Object: StoredProcedure [dbo].[ccJobByNameExist2] Script Date: 2018/12/13 19:07:05 ******/
  3614. SET ANSI_NULLS ON
  3615. GO
  3616. SET QUOTED_IDENTIFIER ON
  3617. GO
  3618. --sean 2013-1-30
  3619. --update ccJobNameExist
  3620. --nick 2013-07-22
  3621. --update 判断 发布中还是过期 重名
  3622. CREATE PROCEDURE [dbo].[ccJobByNameExist2]
  3623. (
  3624. @ID INT ,
  3625. @cpMainID INT,
  3626. @Name VARCHAR(100),
  3627. @dcRegionId VARCHAR(6)
  3628. )
  3629. AS
  3630. SET NOCOUNT ON
  3631. --INSERT INTO procLog select 'ccJobByNameExist2', @ID, getdate()
  3632. --this proc is valid
  3633. IF @cpMainID = 10576676
  3634. RETURN 0
  3635. BEGIN
  3636. DECLARE @IssueEnd DATETIME --截止时间
  3637. SET @Name = LTRIM(RTRIM(@Name))
  3638. SELECT @IssueEnd = IssueEnd
  3639. FROM Job WITH(NOLOCK)
  3640. WHERE cpMainID = @cpMainID
  3641. AND Name = @Name
  3642. AND dcREgionId = @dcRegionId
  3643. AND ID <> @ID
  3644. AND IsDelete = 0
  3645. IF @IssueEND > GETDATE()
  3646. RETURN 1 --发布中
  3647. IF @IssueEND < GETDATE()
  3648. RETURN 2 --已过期
  3649. RETURN 0
  3650. END
  3651. GO
  3652. /****** Object: StoredProcedure [dbo].[ccJobByRecentApplySelect] Script Date: 2018/12/13 19:07:05 ******/
  3653. SET ANSI_NULLS ON
  3654. GO
  3655. SET QUOTED_IDENTIFIER ON
  3656. GO
  3657. CREATE PROCEDURE [dbo].[ccJobByRecentApplySelect]
  3658. (
  3659. @dcRegionID VARCHAR(50), --求职地区
  3660. @dcJobTypeID VARCHAR(50), --期望职位类别
  3661. @RowCount INT
  3662. )
  3663. AS
  3664. SET NOCOUNT ON
  3665. BEGIN
  3666. SET @dcJobTypeID = dbo.FormatIDS(@dcJobTypeID)
  3667. DECLARE @T_JobType AS TABLE(ID INT)
  3668. DECLARE @JobTypeExpect AS VARCHAR(3000)
  3669. DECLARE @T_Temp1 AS TABLE(ID INT) --临时表,用于构建组合查询语句
  3670. INSERT INTO @T_Temp1
  3671. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  3672. INSERT INTO @T_JobType
  3673. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  3674. WHERE ParentId IN(SELECT ID FROM @T_TEMP1)
  3675. OR ParentId2 in(SELECT ID FROM @T_TEMP1)
  3676. OR ID IN(SELECT ID FROM @T_TEMP1)
  3677. ----生成in字符串
  3678. SELECT @JobTypeExpect = ''
  3679. SELECT @JobTypeExpect = (@JobTypeExpect + LTRIM(STR(ID) + ',')) FROM @T_JobType
  3680. IF RIGHT(@JobTypeExpect, 1) = ','
  3681. SET @JobTypeExpect = LEFT(@JobTypeExpect, LEN(@JobTypeExpect) - 1)
  3682. DECLARE @T_JobPlace AS TABLE(ID INT)
  3683. DECLARE @JobPlace AS VARCHAR(3000)
  3684. INSERT INTO @T_JobPlace
  3685. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  3686. SELECT @JobPlace = ''
  3687. SELECT @JobPlace = (@JobPlace + ' OR c.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  3688. SELECT @JobPlace = (@JobPlace + ' OR c.dcRegionID = ''' + LTRIM(STR(LEFT(ID,2)))+'''' )
  3689. FROM @T_JobPlace WHERE LEN(ID) > 2
  3690. SELECT @JobPlace = (@JobPlace + ' OR c.dcRegionID = ''' + LTRIM(STR(LEFT(ID,4)))+'''' )
  3691. FROM @T_JobPlace WHERE LEN(ID) > 4
  3692. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  3693. DECLARE @SQL AS VARCHAR(3000)
  3694. SET @SQL = 'SELECT TOP ' + CONVERT(VARCHAR, @RowCount) + ' b.SecondID EnJobID, b.Name JobName, c.Name CpName,
  3695. c.HasLicence, c.SecondID EnCpMainID, b.ID,dbo.GetCaOnlineStatus(b.caMainID) AS IsOnline,b.caMainID,
  3696. b.dcRegionID, b.dcSalaryID, b.Refreshdate, b.Responsibility, b.Demand, b.dcEducationID,
  3697. b.MinExperience, c.dcCompanySizeID, b.EmployType,b.Welfare1,b.Welfare2,b.Welfare3,b.Welfare4,b.Welfare5,b.Welfare6,b.Welfare7,b.Welfare8,
  3698. b.Welfare9,b.Welfare10,b.Welfare11,b.Welfare12,b.Welfare13,b.Welfare14,b.Welfare15,b.Welfare16,
  3699. b.Welfare17,b.Welfare18,b.Welfare19
  3700. FROM exJobApply a WITH(NOLOCK), JobPublish b WITH(NOLOCK), cpMainPublish c WITH(NOLOCK)
  3701. WHERE a.JobID = b.ID AND b.cpMainID = c.ID AND a.cvMainID IN(
  3702. SELECT a.ID FROM cvMainPublish a WITH(NOLOCK)
  3703. INNER JOIN paMainPublish b WITH(NOLOCK) ON a.paMainID = b.ID
  3704. INNER JOIN cvJobPlacePublish c ON a.ID = c.cvMainID
  3705. INNER JOIN cvJobTypePublish d ON a.ID = d.cvMainID
  3706. WHERE d.dcJobTypeID IN(' + @JobTypeExpect +') AND (' + @JobPlace + ')
  3707. ) ORDER BY a.AddDate DESC'
  3708. --PRINT(@SQL)
  3709. EXEC(@SQL)
  3710. END
  3711. GO
  3712. /****** Object: StoredProcedure [dbo].[ccJobByViewSelect] Script Date: 2018/12/13 19:07:05 ******/
  3713. SET ANSI_NULLS ON
  3714. GO
  3715. SET QUOTED_IDENTIFIER ON
  3716. GO
  3717. --Peter 2016-10-31修改读取职位订阅内容时区别
  3718. CREATE PROCEDURE [dbo].[ccJobByViewSelect]
  3719. (
  3720. @ID INT
  3721. )
  3722. AS
  3723. BEGIN
  3724. SELECT *, b.FullName Region, ISNULL(c.IsOnline, 0) IsOnline,dbo.Int2Bin(a.EMailSendFreq) PushFreq,
  3725. STUFF((SELECT '@' + Tags FROM jobTags WITH(NOLOCK) WHERE jobID = a.ID FOR XML PATH('')),1,1,'') JobTags,
  3726. ISNULL((SELECT Description FROM dcEducation WHERE Id = dcEducationId), '不限') Education, d.Name cpName,
  3727. e.Description JobTypeName,f.Description JobTypeMinorName,g.Description NeedNumName,h.Description EmployTypeName,
  3728. i.Description ExperienceName,j.DescriptionCp SalaryName,k.DescriptionCp SalaryMaxName
  3729. FROM Job a WITH(NOLOCK)
  3730. INNER JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionID = b.ID
  3731. LEFT JOIN caOnline c WITH(NOLOCK) ON a.caMainId = c.caMainId
  3732. INNER JOIN cpMain d WITH(NOLOCK) ON a.cpMainId = d.ID
  3733. LEFT JOIN dcJobType e WITH(NOLOCK) ON a.dcJobTypeId = e.ID
  3734. LEFT JOIN dcJobType f WITH(NOLOCK) ON a.dcJobTypeIdMinor = f.ID
  3735. LEFT JOIN dcOthers g WITH(NOLOCK) ON a.NeedNumber = g.DetailID AND g.Category = '招聘人数'
  3736. LEFT JOIN dcOthers h WITH(NOLOCK) ON a.EmployType = h.DetailID AND h.Category = '工作性质'
  3737. LEFT JOIN dcOthers i WITH(NOLOCK) ON a.MinExperience = i.DetailID AND i.Category = '职位要求工作经验'
  3738. LEFT JOIN dcSalary j WITH(NOLOCK) ON a.dcSalaryId = j.ID
  3739. LEFT JOIN dcSalary k WITH(NOLOCK) ON a.dcSalaryIdMax = k.ID
  3740. WHERE a.ID = @ID
  3741. END
  3742. GO
  3743. /****** Object: StoredProcedure [dbo].[ccJobDelete] Script Date: 2018/12/13 19:07:06 ******/
  3744. SET ANSI_NULLS ON
  3745. GO
  3746. SET QUOTED_IDENTIFIER ON
  3747. GO
  3748. CREATE PROCEDURE [dbo].[ccJobDelete]
  3749. (
  3750. @OperatorID INT,
  3751. @ID INT,
  3752. @caMainID INT
  3753. )
  3754. AS
  3755. BEGIN TRAN
  3756. DECLARE @JobName AS NVARCHAR(100)
  3757. DECLARE @caID AS INT
  3758. DECLARE @jobnumber AS INT
  3759. DECLARE @cpMainID AS INT
  3760. DECLARE @cpID AS INT
  3761. DECLARE @AccountType AS INT
  3762. SELECT @JobName = Name, @caID = caMainId, @cpID = cpMainID FROM Job WITH(NOLOCK) WHERE ID = @ID
  3763. SELECT @AccountType=AccountType,@cpMainID=cpMainID FROM caMain WITH(NOLOCK) WHERE id = @OperatorID
  3764. IF @JobName Is NUll
  3765. GOTO ERR1
  3766. IF @caID != @caMainID
  3767. BEGIN
  3768. IF @AccountType != 1
  3769. GOTO ERR2
  3770. IF @cpMainID != @cpID
  3771. GOTO ERR2
  3772. END
  3773. IF EXISTS(SELECT 'x' FROM caMain WHERE Id = @caMainId)
  3774. INSERT INTO caOperationLog(caMainId, Operation, Details, Ip)
  3775. VALUES(@caMainId, 42, '删除职位:编号<' + LTRIM(STR(@ID)) + '>职位名称<' + @JobName + '>。', ' ')
  3776. UPDATE Job SET isDelete = 1 WHERE id = @ID
  3777. INSERT INTO CaCvApplyDeleted(JobID, JobName, CvMainId, ApplyDate, AddDate, Reply)
  3778. SELECT b.ID, b.Name, a.cvMainid, a.AddDate, GETDATE(), ISNULL(Reply, 0)
  3779. FROM exjobapply a,job b
  3780. WHERE a.jobid = b.id
  3781. AND b.id=@ID
  3782. AND a.CompanyDeleted=0
  3783. IF @@ERROR <> 0
  3784. GOTO ERR
  3785. SELECT @JobNumber = COUNT(1) FROM Job WITH(NOLOCK)
  3786. WHERE IsDelete = 0
  3787. AND IssueDate < GETDATE()
  3788. AND IssueEnd > GETDATE()
  3789. AND cpMainID = @cpMainID
  3790. UPDATE cpMain SET jobNumber = @jobnumber WHERE ID = @cpMainID
  3791. DELETE FROM bsCpModify WHERE SubID = @ID AND Location Like 'c%'
  3792. COMMIT TRAN
  3793. RETURN 1
  3794. ERR:
  3795. BEGIN
  3796. ROLLBACK TRAN
  3797. RETURN 0
  3798. END
  3799. ERR1:
  3800. BEGIN
  3801. ROLLBACK TRAN
  3802. RETURN -1
  3803. END
  3804. ERR2:
  3805. BEGIN
  3806. ROLLBACK TRAN
  3807. RETURN -2
  3808. END
  3809. GO
  3810. /****** Object: StoredProcedure [dbo].[ccJobDeleteNew] Script Date: 2018/12/13 19:07:06 ******/
  3811. SET ANSI_NULLS ON
  3812. GO
  3813. SET QUOTED_IDENTIFIER ON
  3814. GO
  3815. Create PROCEDURE [dbo].[ccJobDeleteNew]
  3816. (
  3817. @OperatorID INT,
  3818. @ID INT,
  3819. @caMainID INT,
  3820. @Ip VARCHAR(15)
  3821. )
  3822. AS
  3823. BEGIN TRAN
  3824. DECLARE @JobName AS NVARCHAR(100)
  3825. DECLARE @caID AS INT
  3826. DECLARE @jobnumber AS INT
  3827. DECLARE @cpMainID AS INT
  3828. DECLARE @cpID AS INT
  3829. DECLARE @AccountType AS INT
  3830. SELECT @JobName = Name, @caID = caMainId, @cpID = cpMainID FROM Job WITH(NOLOCK) WHERE ID = @ID
  3831. SELECT @AccountType=AccountType,@cpMainID=cpMainID FROM caMain WITH(NOLOCK) WHERE id = @OperatorID
  3832. IF @JobName Is NUll
  3833. GOTO ERR1
  3834. IF @caID != @caMainID
  3835. BEGIN
  3836. IF @AccountType != 1
  3837. GOTO ERR2
  3838. IF @cpMainID != @cpID
  3839. GOTO ERR2
  3840. END
  3841. IF EXISTS(SELECT 'x' FROM caMain WHERE Id = @caMainId)
  3842. INSERT INTO caOperationLog(caMainId, Operation, Details, Ip)
  3843. VALUES(@caMainId, 42, '删除职位:编号<' + LTRIM(STR(@ID)) + '>职位名称<' + @JobName + '>。', @Ip)
  3844. UPDATE Job SET isDelete = 1 WHERE id = @ID
  3845. INSERT INTO CaCvApplyDeleted(JobID, JobName, CvMainId, ApplyDate, AddDate, Reply)
  3846. SELECT b.ID, b.Name, a.cvMainid, a.AddDate, GETDATE(), ISNULL(Reply, 0)
  3847. FROM exjobapply a,job b
  3848. WHERE a.jobid = b.id
  3849. AND b.id=@ID
  3850. AND a.CompanyDeleted=0
  3851. IF @@ERROR <> 0
  3852. GOTO ERR
  3853. SELECT @JobNumber = COUNT(1) FROM Job WITH(NOLOCK)
  3854. WHERE IsDelete = 0
  3855. AND IssueDate < GETDATE()
  3856. AND IssueEnd > GETDATE()
  3857. AND cpMainID = @cpMainID
  3858. UPDATE cpMain SET jobNumber = @jobnumber WHERE ID = @cpMainID
  3859. DELETE FROM bsCpModify WHERE SubID = @ID AND Location Like 'c%'
  3860. COMMIT TRAN
  3861. RETURN 1
  3862. ERR:
  3863. BEGIN
  3864. ROLLBACK TRAN
  3865. RETURN 0
  3866. END
  3867. ERR1:
  3868. BEGIN
  3869. ROLLBACK TRAN
  3870. RETURN -1
  3871. END
  3872. ERR2:
  3873. BEGIN
  3874. ROLLBACK TRAN
  3875. RETURN -2
  3876. END
  3877. GO
  3878. /****** Object: StoredProcedure [dbo].[ccJobDisplayNoByAutoSortUpdate] Script Date: 2018/12/13 19:07:06 ******/
  3879. SET ANSI_NULLS ON
  3880. GO
  3881. SET QUOTED_IDENTIFIER ON
  3882. GO
  3883. CREATE PROCEDURE [dbo].[ccJobDisplayNoByAutoSortUpdate]
  3884. (
  3885. @cpMainID INT,
  3886. @Type INT
  3887. )
  3888. AS
  3889. BEGIN
  3890. BEGIN TRY
  3891. DECLARE @SQL VARCHAR(400)
  3892. DECLARE @ColName VARCHAR(200)
  3893. IF @Type = 0
  3894. SET @ColName = 'c.LastModifyDate DESC'
  3895. IF @Type = 1
  3896. SET @ColName = 'c.IssueEnd'
  3897. IF @Type = 2
  3898. SET @ColName = '(SELECT count(1) FROM exJobApply WITH(NOLOCK) WHERE jobID = c.id),CONVERT(VARCHAR(4), c.dcJobtypeId)'
  3899. SET @SQL = 'UPDATE a SET displayno =b.num
  3900. FROM Job a ,
  3901. (SELECT ROW_NUMBER() OVER(ORDER BY ' + @ColName + ' ) num ,id
  3902. FROM Job c WITH(NOLOCK) WHERE c.cpMainID = ' + LTRIM(STR(@cpMainID)) + '
  3903. AND c.IsDelete=0 AND c.IssueEND>GETDATE() ) b
  3904. WHERE a.id = b.id AND a.IsDelete=0 AND a.IssueEND > GETDATE()
  3905. AND a.cpMainID = ' + LTRIM(STR(@cpMainID))
  3906. EXEC(@SQL)
  3907. RETURN 1
  3908. END TRY
  3909. BEGIN CATCH
  3910. RETURN 0
  3911. END CATCH
  3912. END
  3913. GO
  3914. /****** Object: StoredProcedure [dbo].[ccJobDisplayNoByPlusTenUpdate] Script Date: 2018/12/13 19:07:06 ******/
  3915. SET ANSI_NULLS ON
  3916. GO
  3917. SET QUOTED_IDENTIFIER ON
  3918. GO
  3919. CREATE PROCEDURE [dbo].[ccJobDisplayNoByPlusTenUpdate]
  3920. (
  3921. @cpMainID INT
  3922. )
  3923. AS
  3924. BEGIN
  3925. BEGIN TRY
  3926. UPDATE Job SET DisplayNO = DisplayNO + 10
  3927. WHERE cpMainID = @cpMainID
  3928. -- AND IssueDate < GETDATE()
  3929. AND IssueEND > GETDATE()
  3930. AND IsDelete = 0
  3931. UPDATE Job SET DisplayNO = 999
  3932. WHERE cpMainID = @cpMainID
  3933. AND DisplayNo > 999
  3934. RETURN 1
  3935. END TRY
  3936. BEGIN CATCH
  3937. RETURN 0
  3938. END CATCH
  3939. END
  3940. GO
  3941. /****** Object: StoredProcedure [dbo].[ccJobDisplayNoByResetUpdate] Script Date: 2018/12/13 19:07:06 ******/
  3942. SET ANSI_NULLS ON
  3943. GO
  3944. SET QUOTED_IDENTIFIER ON
  3945. GO
  3946. CREATE PROCEDURE [dbo].[ccJobDisplayNoByResetUpdate]
  3947. (
  3948. @cpMainID INT
  3949. )
  3950. AS
  3951. BEGIN
  3952. BEGIN TRY
  3953. UPDATE Job SET DisplayNO = 1
  3954. WHERE cpMainID = @cpMainID
  3955. -- AND IssueDate < GETDATE()
  3956. AND IssueEND > GETDATE()
  3957. AND IsDelete = 0
  3958. RETURN 1
  3959. END TRY
  3960. BEGIN CATCH
  3961. RETURN 0
  3962. END CATCH
  3963. END
  3964. GO
  3965. /****** Object: StoredProcedure [dbo].[ccJobDisplayNoUpdate] Script Date: 2018/12/13 19:07:06 ******/
  3966. SET ANSI_NULLS ON
  3967. GO
  3968. SET QUOTED_IDENTIFIER ON
  3969. GO
  3970. CREATE PROCEDURE [dbo].[ccJobDisplayNoUpdate]
  3971. (
  3972. @ID INT,
  3973. @DisplayNO SMALLINT ,
  3974. @cpMainID INT
  3975. )
  3976. AS
  3977. BEGIN
  3978. BEGIN TRY
  3979. UPDATE Job SET DisplayNo=@DisplayNO WHERE ID=@ID AND cpMainID = @cpMainID
  3980. RETURN 1
  3981. END TRY
  3982. BEGIN CATCH
  3983. RETURN 0
  3984. END CATCH
  3985. END
  3986. GO
  3987. /****** Object: StoredProcedure [dbo].[ccJobRefreshLogBypreRefreshDateTimeUpdate] Script Date: 2018/12/13 19:07:07 ******/
  3988. SET ANSI_NULLS ON
  3989. GO
  3990. SET QUOTED_IDENTIFIER ON
  3991. GO
  3992. --职位刷新数计划任务
  3993. --每分钟执行一次,执行后分配订单号,更新职位刷新时间,同时刷新数remainJobRefreshQuota-1
  3994. --harry 2017-11-9
  3995. --修改harry 2018-5-14 修改过期的刷新只刷过期时间不超过1h的
  3996. CREATE PROCEDURE [dbo].[ccJobRefreshLogBypreRefreshDateTimeUpdate]
  3997. AS
  3998. --return
  3999. BEGIN
  4000. SET NOCOUNT ON
  4001. --获取待执行的数据 preRefreshDateTime<DATEADD(minute,1,getdate()) AND refreshType=0 AND runDateTime IS NULL
  4002. SELECT * INTO #t
  4003. FROM JobRefreshLog
  4004. WHERE preRefreshDateTime<=DATEADD(minute,1,getdate()) AND preRefreshDateTime>=DATEADD(hour,-1,getdate()) AND refreshType=0 AND runDateTime IS NULL
  4005. --遍历#t
  4006. DECLARE @Id INT, @jobId INT, @cpMainId INT, @orderId INT, @preRefreshDateTime DATETIME --职位,jobrefrshid
  4007. --获取所有可用的订单
  4008. SELECT * INTO #tOrder FROM caOrder WITH(NOLOCK)
  4009. WHERE cpMainID IN(SELECT DISTINCT cpMainId FROM #t)
  4010. AND openDate is NOT NULL
  4011. AND endDate >GETDATE()
  4012. AND OrderType IN(8,15)
  4013. AND ISNULL(remainJobRefreshQuota,0) != 0
  4014. ORDER BY endDate
  4015. WHILE EXISTS (SELECT TOP 1 ID FROM #t)
  4016. BEGIN
  4017. SELECT TOP 1 @Id = ID, @jobId = jobid, @cpMainId =cpMainId, @preRefreshDateTime =preRefreshDateTime FROM #t
  4018. IF EXISTS(SELECT 'X' FROM #tOrder WHERE cpMainId = @cpMainId AND openDate is NOT NULL AND endDate >GETDATE() AND OrderType IN(8,15) AND ISNULL(remainJobRefreshQuota,0) != 0 )
  4019. BEGIN
  4020. SELECT TOP 1 @orderId = Id
  4021. FROM #tOrder
  4022. WHERE cpMainId = @cpMainId
  4023. AND openDate is NOT NULL
  4024. AND endDate >GETDATE()
  4025. AND OrderType IN(8,15)
  4026. AND ISNULL(remainJobRefreshQuota,0) != 0
  4027. ORDER BY endDate
  4028. --更新订单
  4029. UPDATE caorder SET remainJobRefreshQuota =remainJobRefreshQuota -1
  4030. WHERE id = @orderId
  4031. --更新jobrefreshlog,
  4032. UPDATE jobrefreshlog
  4033. SET runDateTime =GETDATE(), orderId = @orderId
  4034. WHERE ID =@Id
  4035. --更新job refrshdate
  4036. UPDATE job
  4037. SET RefreshDate= @preRefreshDateTime
  4038. WHERE id =@jobId
  4039. END
  4040. ELSE
  4041. BEGIN
  4042. DELETE FROM jobrefreshlog WHERE ID= @Id
  4043. END
  4044. DELETE FROM #t WHERE ID= @Id
  4045. END
  4046. DROP TABLE #tOrder
  4047. DROP TABLE #t
  4048. SET NOCOUNT OFF
  4049. END
  4050. GO
  4051. /****** Object: StoredProcedure [dbo].[ccJobRefreshLogBypreRefreshDateTimeUpdatetest] Script Date: 2018/12/13 19:07:07 ******/
  4052. SET ANSI_NULLS ON
  4053. GO
  4054. SET QUOTED_IDENTIFIER ON
  4055. GO
  4056. --职位刷新数计划任务
  4057. --每分钟执行一次,执行后分配订单号,更新职位刷新时间,同时刷新数remainJobRefreshQuota-1
  4058. --harry 2017-11-9
  4059. CREATE PROCEDURE [dbo].[ccJobRefreshLogBypreRefreshDateTimeUpdatetest]
  4060. AS
  4061. BEGIN
  4062. SET NOCOUNT ON
  4063. --获取待执行的数据 preRefreshDateTime<DATEADD(minute,1,getdate()) AND refreshType=0 AND runDateTime IS NULL
  4064. SELECT * INTO #t
  4065. FROM JobRefreshLog
  4066. WHERE preRefreshDateTime<=DATEADD(minute,1,getdate()) AND refreshType=0 AND runDateTime IS NULL
  4067. --遍历#t
  4068. DECLARE @Id INT, @jobId INT, @cpMainId INT, @orderId INT, @preRefreshDateTime DATETIME --职位,jobrefrshid
  4069. --获取所有可用的订单
  4070. SELECT * INTO #tOrder FROM caOrder WITH(NOLOCK)
  4071. WHERE cpMainID IN(SELECT DISTINCT cpMainId FROM #t)
  4072. AND openDate is NOT NULL
  4073. AND endDate >GETDATE()
  4074. AND OrderType IN(8,15)
  4075. AND ISNULL(remainJobRefreshQuota,0) != 0
  4076. ORDER BY endDate
  4077. WHILE EXISTS (SELECT TOP 1 ID FROM #t)
  4078. BEGIN
  4079. SELECT TOP 1 @Id = ID, @jobId = jobid, @cpMainId =cpMainId, @preRefreshDateTime =preRefreshDateTime FROM #t
  4080. IF EXISTS(SELECT 'X' FROM #tOrder WHERE cpMainId = @cpMainId AND openDate is NOT NULL AND endDate >GETDATE() AND OrderType IN(8,15) AND ISNULL(remainJobRefreshQuota,0) != 0 )
  4081. BEGIN
  4082. SELECT TOP 1 @orderId = Id
  4083. FROM #tOrder
  4084. WHERE cpMainId = @cpMainId
  4085. AND openDate is NOT NULL
  4086. AND endDate >GETDATE()
  4087. AND OrderType IN(8,15)
  4088. AND ISNULL(remainJobRefreshQuota,0) != 0
  4089. ORDER BY endDate
  4090. --更新订单
  4091. UPDATE caorder SET remainJobRefreshQuota =remainJobRefreshQuota -1
  4092. WHERE id = @orderId
  4093. --更新jobrefreshlog,
  4094. UPDATE jobrefreshlog
  4095. SET runDateTime =GETDATE(), orderId = @orderId
  4096. WHERE ID =@Id
  4097. --更新job refrshdate
  4098. UPDATE job
  4099. SET RefreshDate= @preRefreshDateTime
  4100. WHERE id =@jobId
  4101. END
  4102. ELSE
  4103. BEGIN
  4104. DELETE FROM jobrefreshlog WHERE ID= @Id
  4105. END
  4106. DELETE FROM #t WHERE ID= @Id
  4107. END
  4108. DROP TABLE #tOrder
  4109. DROP TABLE #t
  4110. SET NOCOUNT OFF
  4111. END
  4112. GO
  4113. /****** Object: StoredProcedure [dbo].[ccJobRefreshLogInsertByJobId] Script Date: 2018/12/13 19:07:07 ******/
  4114. SET ANSI_NULLS ON
  4115. GO
  4116. SET QUOTED_IDENTIFIER ON
  4117. GO
  4118. ---职位刷新数手动刷新
  4119. ---harry
  4120. ---返回值 -1 可用刷新数不够,其它为刷新成功数量
  4121. ---2017-11-2
  4122. CREATE PROCEDURE [dbo].[ccJobRefreshLogInsertByJobId]
  4123. (
  4124. @jobIds VARCHAR(200),
  4125. @caMainId INT,
  4126. @cpMainId INT
  4127. )
  4128. AS
  4129. BEGIN
  4130. --职位id
  4131. DECLARE @jobId INT
  4132. DECLARE @jobInfo NVARCHAR(200)
  4133. DECLARE @TjobId AS TABLE(jobId INT, jobInfo NVARCHAR(200))
  4134. INSERT INTO @TjobId (jobId)
  4135. SELECT * FROM dbo.fnSplit(@jobIds, ',')
  4136. --更新职位信息
  4137. UPDATE @TjobId
  4138. SET jobInfo= (SELECT name+','+ b.FullName FROM job a WITH(NOLOCK), dcregion b WITH(NOLOCK) WHERE a.id = jobId AND a.dcregionid = b.id)
  4139. --判断是否可用
  4140. CREATE TABLE #temp(availableNumber INT)
  4141. INSERT INTO #temp EXEC ccCaorderByremainJobRefreshQuotaSelect @cpMainId, @caMainId, @jobIds
  4142. DECLARE @availableNumber INT
  4143. SELECT TOP 1 @availableNumber = availableNumber FROM #temp
  4144. IF @availableNumber=0 OR @availableNumber< (SELECT COUNT(1) FROM @TjobId)
  4145. BEGIN
  4146. DROP TABLE #temp
  4147. SELECT -1 AS result
  4148. END
  4149. ELSE
  4150. BEGIN
  4151. --获取所有可用的订单
  4152. SELECT * INTO #tOrder FROM caOrder WITH(NOLOCK)
  4153. WHERE cpMainID = @cpMainID
  4154. AND openDate is NOT NULL
  4155. AND endDate >GETDATE()
  4156. AND OrderType IN(8,15)
  4157. AND ISNULL(remainJobRefreshQuota,0) != 0
  4158. AND IsDeleted !=1
  4159. ORDER BY endDate
  4160. DECLARE @successNum INT
  4161. SELECT @successNum = 0
  4162. DECLARE @caoderId INT, @remainJobRefreshQuota INT
  4163. WHILE EXISTS(SELECT TOP 1 id FROM #tOrder) AND EXISTS(SELECT 'x' FROM @TjobId)
  4164. BEGIN
  4165. SELECT TOP 1 @caoderId = id, @remainJobRefreshQuota = remainJobRefreshQuota FROM #tOrder ORDER BY endDate
  4166. WHILE @remainJobRefreshQuota > 0 AND EXISTS(SELECT 'x' FROM @TjobId)
  4167. BEGIN
  4168. SELECT TOP 1 @jobId =jobId, @jobInfo = jobInfo FROM @TjobId
  4169. ---插入刷新log
  4170. INSERT INTO jobRefreshLog(orderId, jobId, jobInfo, refreshType,preRefreshDateTime, runDateTime, operateMan, cpMainId)
  4171. SELECT @caoderId, @jobId, @jobInfo, 1, GETDATE(), GETDATE(), @caMainId,@cpMainId
  4172. ---更新刷新时间
  4173. UPDATE job SET refreshDate = GETDATE() WHERE id = @jobId
  4174. --刷新数减去1
  4175. UPDATE caorder SET remainJobRefreshQuota= remainJobRefreshQuota-1 WHERE id =@caoderId
  4176. SELECT @remainJobRefreshQuota=@remainJobRefreshQuota-1
  4177. DELETE FROM @TjobId WHERE jobId = @jobId
  4178. --成功数+1
  4179. SELECT @successNum = @successNum+1
  4180. END
  4181. DELETE FROM #tOrder WHERE id = @caoderId
  4182. END
  4183. DROP TABLE #temp
  4184. DROP TABLE #tOrder
  4185. SELECT @successNum AS result
  4186. END
  4187. END
  4188. GO
  4189. /****** Object: StoredProcedure [dbo].[ccJobRefreshSetByRunStateSelect] Script Date: 2018/12/13 19:07:08 ******/
  4190. SET ANSI_NULLS ON
  4191. GO
  4192. SET QUOTED_IDENTIFIER ON
  4193. GO
  4194. --过滤掉正在刷新数定制中的职位,返回未定制的职位信息
  4195. --harry
  4196. --2017-11-6
  4197. CREATE PROCEDURE [dbo].[ccJobRefreshSetByRunStateSelect]
  4198. (
  4199. @jobIds VARCHAR(200)
  4200. )
  4201. AS
  4202. BEGIN
  4203. --职位id
  4204. DECLARE @TjobId AS TABLE(jobId INT)
  4205. INSERT INTO @TjobId (jobId)
  4206. SELECT * FROM dbo.fnSplit(@jobIds, ',')
  4207. --校正定制刷新的状态
  4208. UPDATE a SET a.runState =0
  4209. FROM jobRefreshSet a
  4210. WHERE a.runState =1 AND a.jobId IN(SELECT jobId FROM @TjobId ) AND NOT EXISTS(SELECT 'x' FROM jobrefreshLog WITH(NOLOCK) WHERE jobid= a.jobId AND refreshType=0 and runDateTime is null )
  4211. DELETE FROM @TjobId WHERE jobId IN( SELECT jobId FROM JobRefreshSet WHERE jobId IN(SELECT jobId FROM @TjobId ) AND runState = 1)--删除定制中的jobid
  4212. SELECT jobId FROM @TjobId --返回非定制中的职位id,最大开始时间 最小结束时间
  4213. SELECT MAX(IssueDate) AS MaxIssueDate ,MIN(IssueEnd) AS MinIssueEnd
  4214. FROM job WHERE id in(select jobId FROM @TjobId) AND valid=1
  4215. END
  4216. GO
  4217. /****** Object: StoredProcedure [dbo].[ccJobRefreshSetInsert] Script Date: 2018/12/13 19:07:08 ******/
  4218. SET ANSI_NULLS ON
  4219. GO
  4220. SET QUOTED_IDENTIFIER ON
  4221. GO
  4222. --刷新数定制刷新设置
  4223. --harry
  4224. --2017-11-3
  4225. CREATE PROCEDURE [dbo].[ccJobRefreshSetInsert]
  4226. (
  4227. @beginDate SMALLDATETIME,
  4228. @endDate SMALLDATETIME,
  4229. @refreshType TINYINT, --1d 2week
  4230. @weekDays CHAR(13),
  4231. @hours VARCHAR(100),
  4232. @minute INT,
  4233. @jobIds VARCHAR(200),
  4234. @caMainId INT,
  4235. @cpMainId INT
  4236. )
  4237. AS
  4238. BEGIN
  4239. --职位id
  4240. DECLARE @jobId INT, @jobRefreshSetId INT
  4241. DECLARE @TjobId AS TABLE(jobId INT)
  4242. INSERT INTO @TjobId (jobId)
  4243. SELECT * FROM dbo.fnSplit(@jobIds, ',')
  4244. WHILE EXISTS (SELECT TOP 1 jobid FROM @TjobId)
  4245. BEGIN
  4246. SELECT TOP 1 @jobId = jobid FROM @TjobId
  4247. IF NOT EXISTS(SELECT 'x' FROM jobRefreshset WITH(NOLOCK) WHERE jobid = @jobId AND runState =1 )--排除定制中的职位
  4248. BEGIN
  4249. DELETE FROM jobRefreshset WHERE jobid = @jobId AND runState = 0
  4250. INSERT INTO jobRefreshset(beginDate, endDate, refreshType, weekDays,[hours],[minute], jobId, caMainId, runState, addDate)
  4251. SELECT @beginDate, @endDate, @refreshType, @weekDays, @hours, @minute, @jobId, @caMainId, 1, GETDATE()
  4252. SELECT @jobRefreshSetId =SCOPE_IDENTITY()
  4253. --选取jobrefreshlog_temp表中预插入的数据
  4254. INSERT INTO jobRefreshLog(jobRefreshSetId, jobId, jobInfo, refreshType, preRefreshDateTime, operateMan, cpMainId)
  4255. SELECT @jobRefreshSetId, @jobId, jobInfo,refreshType, preRefreshDateTime, @caMainId, @cpMainId
  4256. FROM jobRefreshLog_temp
  4257. WHERE jobid = @jobId AND operateMan = @caMainId AND cpMainId = @cpMainId AND ISNULL(jobRefreshSetId,0) = 0 AND preRefreshDateTime BETWEEN @beginDate AND DATEADD(DAY,1,@endDate) AND refreshType =0
  4258. --删除以插入的数据
  4259. DELETE FROM jobRefreshLog_temp
  4260. WHERE jobid = @jobId AND operateMan = @caMainId AND cpMainId = @cpMainId AND ISNULL(jobRefreshSetId,0) = 0 AND preRefreshDateTime BETWEEN @beginDate AND DATEADD(DAY,1,@endDate) AND refreshType =0
  4261. END
  4262. DELETE FROM @TjobId WHERE jobid = @jobId
  4263. END
  4264. END
  4265. GO
  4266. /****** Object: StoredProcedure [dbo].[ccJobRefreshSetSelect] Script Date: 2018/12/13 19:07:08 ******/
  4267. SET ANSI_NULLS ON
  4268. GO
  4269. SET QUOTED_IDENTIFIER ON
  4270. GO
  4271. --根据职位id获取职位的定制信息
  4272. --harry
  4273. --2017-11-6
  4274. CREATE PROCEDURE [dbo].[ccJobRefreshSetSelect]
  4275. (
  4276. @jobId INT
  4277. )
  4278. AS
  4279. SET NOCOUNT ON
  4280. BEGIN
  4281. CREATE TABLE #t
  4282. (
  4283. [refreshType] [tinyint] NULL,
  4284. [weekDays] [char](13) NULL,
  4285. [hours] [varchar](100) NULL,
  4286. [minute] [tinyint] NULL,
  4287. [jobId] [int] NOT NULL,
  4288. [runState] [tinyint] NULL,
  4289. [IssueDate] DATETIME NOT NULL,
  4290. [IssueEnd] DATETIME NOT NULL,
  4291. [beginDate] SMALLDATETIME NULL,
  4292. [endDate] SMALLDATETIME NULL
  4293. )
  4294. --校正定制刷新的状态
  4295. UPDATE a SET a.runState =0
  4296. FROM jobRefreshSet a
  4297. WHERE a.runState =1 AND a.jobId =@jobId AND NOT EXISTS(SELECT 'x' FROM jobrefreshLog WITH(NOLOCK) WHERE jobid= @jobId AND refreshType=0 and runDateTime is null )
  4298. INSERT INTO #t(jobId, IssueDate,IssueEnd)
  4299. SELECT id, IssueDate, IssueEnd FROM job WHERE id = @jobId
  4300. IF EXISTS( SELECT 'X' FROM jobRefreshset WHERE jobid = @jobId)
  4301. BEGIN
  4302. UPDATE a
  4303. SET a.beginDate = b.beginDate, a.endDate = b.endDate, a.refreshType =b.refreshType, a.weekDays= b.weekDays, a.[hours] = b.[hours], a.[minute]=b.[minute], a.runState= b.runState
  4304. FROM #t a, jobRefreshset b
  4305. WHERE a.jobId =b.jobId AND b.Id =(SELECT TOP 1 id FROM jobRefreshset WHERE jobid = @jobId ORDER BY addDate DESC,ID DESC)
  4306. END
  4307. SELECT * FROM #t
  4308. DROP TABLE #t
  4309. END
  4310. GO
  4311. /****** Object: StoredProcedure [dbo].[ccJobRefrshSetUpdate] Script Date: 2018/12/13 19:07:08 ******/
  4312. SET ANSI_NULLS ON
  4313. GO
  4314. SET QUOTED_IDENTIFIER ON
  4315. GO
  4316. --停止职位刷新的定制
  4317. --harry
  4318. --2017-11-3
  4319. CREATE PROCEDURE [dbo].[ccJobRefrshSetUpdate]
  4320. (
  4321. @jobIds VARCHAR(200),
  4322. @cpMainId INT
  4323. )
  4324. AS
  4325. BEGIN
  4326. --职位id
  4327. DECLARE @jobId INT, @usedRefreshNum INT , @setId INT
  4328. DECLARE @TjobId AS TABLE(jobId INT)
  4329. DECLARE @TsetId AS TABLE(setId INT)
  4330. INSERT INTO @TjobId (jobId)
  4331. SELECT * FROM dbo.fnSplit(@jobIds, ',')
  4332. INSERT INTO @TsetId(setId)
  4333. SELECT id FROM jobRefreshSet WHERE jobId IN(SELECT jobId FROM @TjobId) AND runState =1
  4334. --设置set runState =0
  4335. UPDATE jobRefreshSet SET runState = 0 WHERE id IN(select setId FROM @TsetId) AND runState =1
  4336. --删除未执行的定制刷新
  4337. DELETE FROM jobRefreshLog WHERE runDateTime IS NULL AND jobRefreshSetId IN(select setId FROM @TsetId) AND refreshType =0
  4338. --计算使用的刷新数
  4339. SELECT @usedRefreshNum = COUNT(1) FROM jobRefreshLog WHERE runDateTime IS NOT NULL AND cpMainId = @cpMainId AND jobId IN(SELECT jobId FROM @TjobId) AND refreshType =0 AND jobRefreshSetId IN (select setId FROM @TsetId)
  4340. --返回使用的刷新数
  4341. SELECT @usedRefreshNum AS usedRefreshNum
  4342. END
  4343. GO
  4344. /****** Object: StoredProcedure [dbo].[ccjobReportDataSelectByCpMainId] Script Date: 2018/12/13 19:07:08 ******/
  4345. SET ANSI_NULLS ON
  4346. GO
  4347. SET QUOTED_IDENTIFIER ON
  4348. GO
  4349. --职位发布效果统计
  4350. --harry
  4351. --2017-11-27
  4352. CREATE PROCEDURE [dbo].[ccjobReportDataSelectByCpMainId]
  4353. (
  4354. @cpMainId INT,
  4355. @beginDate INT,
  4356. @endDate INT,
  4357. @caMainId INT
  4358. )
  4359. AS
  4360. SET NOCOUNT ON
  4361. BEGIN
  4362. IF @caMainId = 0
  4363. BEGIN
  4364. SELECT b.name, a.jobid, a.countdate,SUM(applycount) applycount,SUM(viewcount) viewcount,SUM(interview) interview,
  4365. SUM(interviewreply) interviewreply,SUM(interviewresult) interviewresult
  4366. FROM ReportDB..jobReportData a WITH(NOLOCK),job b WITH(NOLOCK)
  4367. WHERE a.countdate>=@beginDate
  4368. AND a.countdate<= @endDate
  4369. AND a.jobid =b.id
  4370. AND a.jobid in (
  4371. (
  4372. SELECT id FROM Job with(nolock)
  4373. WHERE isdelete=0
  4374. AND cpmainid= @cpMainId
  4375. ) union (
  4376. SELECT jobid id
  4377. FROM JobDeleted WITH(NOLOCK)
  4378. WHERE cpmainid= @cpMainId
  4379. )
  4380. )
  4381. GROUP BY a.jobid,a.countdate,b.name
  4382. ORDER BY a.countdate
  4383. END
  4384. ELSE
  4385. BEGIN
  4386. SELECT b.name, a.jobid, a.countdate,SUM(applycount) applycount,SUM(viewcount) viewcount,SUM(interview) interview,
  4387. SUM(interviewreply) interviewreply,SUM(interviewresult) interviewresult
  4388. FROM ReportDB..jobReportData a WITH(NOLOCK),job b WITH(NOLOCK)
  4389. WHERE a.countdate>=@beginDate
  4390. AND a.countdate<= @endDate
  4391. AND a.jobid =b.id
  4392. AND a.jobid in (
  4393. (
  4394. SELECT id FROM Job with(nolock)
  4395. WHERE isdelete=0
  4396. AND camainid= @caMainId
  4397. ) union (
  4398. SELECT jobid id
  4399. FROM JobDeleted WITH(NOLOCK)
  4400. WHERE camainid= @caMainId
  4401. )
  4402. )
  4403. GROUP BY a.jobid,a.countdate,b.name
  4404. ORDER BY a.countdate
  4405. END
  4406. END
  4407. SET NOCOUNT OFF
  4408. GO
  4409. /****** Object: StoredProcedure [dbo].[ccJobSave] Script Date: 2018/12/13 19:07:08 ******/
  4410. SET ANSI_NULLS ON
  4411. GO
  4412. SET QUOTED_IDENTIFIER ON
  4413. GO
  4414. --nick 20130815 update
  4415. --去掉filtercvmainid相关内容
  4416. --Peter 2016-10-31修改 订阅方式的修改
  4417. -- 应该已经被ccjobsavenew取代了
  4418. CREATE PROCEDURE [dbo].[ccJobSave]
  4419. (
  4420. @OperatorID INT,
  4421. @ID INT,
  4422. @cpMainID INT,
  4423. @caMainID INT,
  4424. @Name VARCHAR(50),
  4425. @dcJobTypeID INT,
  4426. @dcJobTypeIDMinor INT,
  4427. @NeedNumber SMALLINT,
  4428. @dcSalaryID TINYINT,
  4429. @EmployType TINYINT,
  4430. @dcRegionID VARCHAR(6),
  4431. @Lng DECIMAL(8, 5),
  4432. @Lat DECIMAL(8, 5),
  4433. @Responsibility VARCHAR(MAX),
  4434. @Demand VARCHAR(MAX),
  4435. @dcEducationID TINYINT,
  4436. @MinExperience TINYINT,
  4437. @MinAge TINYINT,
  4438. @MaxAge TINYINT,
  4439. @EMailSendFreq VARCHAR(7),
  4440. @EMailSendNumber TINYINT,
  4441. --屏蔽简历相关
  4442. @FilterMaxDegree TINYINT,
  4443. @FilterMinDegree TINYINT,
  4444. @FilterMaxWorkYear TINYINT,
  4445. @FilterMinWorkYear TINYINT,
  4446. @FilterMaxAge TINYINT,
  4447. @FilterMinAge TINYINT,
  4448. @FilterGender VARCHAR(1),
  4449. @FilterJobRegion VARCHAR(6),
  4450. @ForwardEmail VARCHAR(100)
  4451. )
  4452. AS
  4453. return
  4454. SET NOCOUNT ON
  4455. IF @dcRegionID NOT LIKE '[0-9]%'
  4456. RETURN -1
  4457. IF ISNULL(@dcSalaryID, 0) = 0
  4458. SET @dcSalaryID = 100
  4459. IF ISNULL(@dcEducationID, 0) = 0
  4460. SET @dcEducationID = 100
  4461. BEGIN TRAN
  4462. BEGIN TRY
  4463. SET @Name = dbo.TrimNull(@Name)
  4464. IF @Name IS NULL
  4465. GOTO Err
  4466. -- Can Not Name Repeat
  4467. IF @cpMainID <> 10576676
  4468. BEGIN
  4469. IF EXISTS(SELECT 'x' FROM Job WITH(NOLOCK)
  4470. WHERE Name = @Name
  4471. AND dcRegionId = @dcRegionID
  4472. AND cpMainId = @CpMainId
  4473. AND ID <> ISNULL(@ID, 0)
  4474. AND IsDelete = 0)
  4475. GOTO Err1
  4476. END
  4477. SET @Responsibility = REPLACE(dbo.TextTrim(@Responsibility), ' ', '')
  4478. SET @Demand = REPLACE(dbo.TextTrim(@Demand), ' ', '')
  4479. IF CHARINDEX(', ', @Name) > 0
  4480. SELECT @Name = REPLACE(@Name, ',', ',')
  4481. DECLARE @MaxID AS INT
  4482. IF @ID>0
  4483. BEGIN
  4484. IF @OperatorID <> (SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID AND AccountType = 1) AND @OperatorID<>@caMainID
  4485. RETURN 0
  4486. DECLARE @NameOld AS NVARCHAR(60), @ResponsibilityOld AS VARCHAR(MAX),
  4487. @DemandOld AS VARCHAR(MAX), @IsVerify AS BIT
  4488. SELECT @NameOld = dbo.TextTrim(ISNULL(Name, '')), @ResponsibilityOld = ISNULL(Responsibility, ''),
  4489. @DemandOld = ISNULL(Demand, '')
  4490. FROM Job WITH(NOLOCK)
  4491. WHERE ID = @ID
  4492. UPDATE Job SET
  4493. Name = @Name,
  4494. dcJobTypeID = @dcJobTypeID,
  4495. dcJobTypeIDMinor = @dcJobTypeIDMinor,
  4496. NeedNumber = @NeedNumber,
  4497. dcSalaryID = @dcSalaryID,
  4498. EmployType = @EmployType,
  4499. dcRegionID = @dcRegionID,
  4500. Lng = @Lng,
  4501. Lat = @Lat,
  4502. Responsibility = @Responsibility,
  4503. Demand = @Demand,
  4504. dcEducationID = @dcEducationID,
  4505. MinExperience = @MinExperience,
  4506. MinAge = @MinAge,
  4507. MaxAge = @MaxAge,
  4508. EMailSendFreq = dbo.BinToINT(@EMailSendFreq),
  4509. RefreshDate = GETDATE(),
  4510. LastModifyDate = GETDATE(),
  4511. FilterMaxDegree = @FilterMaxDegree,
  4512. FilterMinDegree = @FilterMinDegree,
  4513. FilterMaxWorkYear = @FilterMaxWorkYear,
  4514. FilterMinWorkYear = @FilterMinWorkYear,
  4515. FilterMaxAge = @FilterMaxAge,
  4516. FilterMinAge = @FilterMinAge,
  4517. FilterGender = @FilterGender,
  4518. FilterJobRegion = @FilterJobRegion,
  4519. ForwardEmail = @ForwardEmail
  4520. WHERE ID = @ID
  4521. SET @MaxID = @ID
  4522. SET @IsVerify = 0
  4523. IF @NameOld <> dbo.TextTrim(@Name)
  4524. BEGIN
  4525. DELETE FROM bsCpModify WHERE SubId = @ID AND Location = 'c1'
  4526. INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @ID, 'c1', @Name)
  4527. SET @IsVerify = 1
  4528. END
  4529. IF @ResponsibilityOld <> @Responsibility
  4530. BEGIN
  4531. DELETE FROM bsCpModify WHERE SubId = @ID AND Location = 'c2'
  4532. INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @ID, 'c2', @Responsibility)
  4533. SET @IsVerify = 1
  4534. END
  4535. IF @DemandOld <> @Demand
  4536. BEGIN
  4537. DELETE FROM bsCpModify WHERE SubId = @ID AND Location = 'c3'
  4538. INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @ID, 'c3', @Demand)
  4539. SET @IsVerify = 1
  4540. END
  4541. END
  4542. ELSE
  4543. BEGIN
  4544. INSERT INTO Job
  4545. (
  4546. cpMainID, caMainID, Name, dcJobTypeID, dcJobTypeIDMinor,
  4547. NeedNumber, dcSalaryID, EmployType, dcRegionID, Lng, Lat,
  4548. Responsibility, Demand, dcEducationID, MinExperience,
  4549. MinAge, MaxAge, EMailSendFreq,
  4550. AddDate, LastModifyDate, RefreshDate, IssueDate, IssueEnd,
  4551. FilterMaxDegree, FilterMinDegree, FilterMaxWorkYear, FilterMinWorkYear,
  4552. FilterMaxAge, FilterMinAge, FilterGender, FilterJobRegion,
  4553. ForwardEmail
  4554. )
  4555. VALUES
  4556. (
  4557. @cpMainID, @caMainID, @Name, @dcJobTypeID, @dcJobTypeIDMinor,
  4558. @NeedNumber, @dcSalaryID, @EmployType, @dcRegionID, @Lng, @Lat,
  4559. @Responsibility, @Demand, @dcEducationID, @MinExperience,
  4560. @MinAge, @MaxAge, dbo.BinToINT(@EMailSendFreq),
  4561. GETDATE(), GETDATE(), GETDATE(), GETDATE(), DATEADD(MONTH, 2, GETDATE()),
  4562. @FilterMaxDegree, @FilterMinDegree, @FilterMaxWorkYear, @FilterMinWorkYear,
  4563. @FilterMaxAge, @FilterMinAge, @FilterGender, @FilterJobRegion,
  4564. @ForwardEmail
  4565. )
  4566. SET @MaxID = @@IDENTITY
  4567. INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @MaxID, 'c1', @Name)
  4568. INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @MaxID, 'c2', @Responsibility)
  4569. INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @MaxID, 'c3', @Demand)
  4570. SET @IsVerify = 1
  4571. END
  4572. END TRY
  4573. BEGIN CATCH
  4574. GOTO ERR
  4575. END CATCH
  4576. COMMIT TRAN
  4577. RETURN @MaxID
  4578. ERR:
  4579. BEGIN
  4580. --insert into a_tmp select ERROR_MESSAGE(), getdate()
  4581. ROLLBACK TRAN
  4582. RETURN 0
  4583. END
  4584. RETURN @MaxID
  4585. ERR1:
  4586. BEGIN
  4587. --insert into a_tmp select ERROR_MESSAGE(), getdate()
  4588. ROLLBACK TRAN
  4589. RETURN -1
  4590. END
  4591. SET NOCOUNT OFF
  4592. GO
  4593. /****** Object: StoredProcedure [dbo].[ccJobSaveNew] Script Date: 2018/12/13 19:07:09 ******/
  4594. SET ANSI_NULLS ON
  4595. GO
  4596. SET QUOTED_IDENTIFIER ON
  4597. GO
  4598. --nick 20130815 update
  4599. --去掉filtercvmainid相关内容
  4600. --Peter 2016-10-31修改 订阅方式的修改
  4601. --Lucifer 2017-3-21修改 月薪改为范围,添加可面议
  4602. CREATE PROCEDURE [dbo].[ccJobSaveNew]
  4603. (
  4604. @OperatorID INT,
  4605. @ID INT,
  4606. @cpMainID INT,
  4607. @caMainID INT,
  4608. @Name VARCHAR(50),
  4609. @dcJobTypeID INT,
  4610. @dcJobTypeIDMinor INT,
  4611. @NeedNumber SMALLINT,
  4612. @dcSalaryID TINYINT,
  4613. @EmployType TINYINT,
  4614. @dcRegionID VARCHAR(6),
  4615. @Lng DECIMAL(8, 5),
  4616. @Lat DECIMAL(8, 5),
  4617. @Responsibility VARCHAR(MAX),
  4618. @Demand VARCHAR(MAX),
  4619. @dcEducationID TINYINT,
  4620. @MinExperience TINYINT,
  4621. @MinAge TINYINT,
  4622. @MaxAge TINYINT,
  4623. @EMailSendFreq VARCHAR(7),
  4624. @EMailSendNumber TINYINT,
  4625. --屏蔽简历相关
  4626. @FilterMaxDegree TINYINT,
  4627. @FilterMinDegree TINYINT,
  4628. @FilterMaxWorkYear TINYINT,
  4629. @FilterMinWorkYear TINYINT,
  4630. @FilterMaxAge TINYINT,
  4631. @FilterMinAge TINYINT,
  4632. @FilterGender VARCHAR(1),
  4633. @FilterJobRegion VARCHAR(6),
  4634. @ForwardEmail VARCHAR(100),
  4635. @dcSalaryMaxID TINYINT,
  4636. @Negotiable BIT
  4637. )
  4638. AS
  4639. SET NOCOUNT ON
  4640. IF @dcRegionID NOT LIKE '[0-9]%'
  4641. RETURN -1
  4642. IF ISNULL(@dcSalaryID, 0) = 0
  4643. SET @dcSalaryID = 100
  4644. IF ISNULL(@dcEducationID, 0) = 0
  4645. SET @dcEducationID = 100
  4646. BEGIN TRAN
  4647. SET @Name = dbo.TrimNull(@Name)
  4648. IF @Name IS NULL
  4649. GOTO Err
  4650. -- Can Not Name Repeat
  4651. IF @cpMainID <> 10576676
  4652. BEGIN
  4653. IF EXISTS(SELECT 'x' FROM Job WITH(NOLOCK)
  4654. WHERE Name = @Name
  4655. AND dcRegionId = @dcRegionID
  4656. AND cpMainId = @CpMainId
  4657. AND ID <> ISNULL(@ID, 0)
  4658. AND IsDelete = 0)
  4659. GOTO Err1
  4660. END
  4661. SET @Responsibility = REPLACE(dbo.TextTrim(@Responsibility), ' ', '')
  4662. SET @Demand = REPLACE(dbo.TextTrim(@Demand), ' ', '')
  4663. IF CHARINDEX(', ', @Name) > 0
  4664. SELECT @Name = REPLACE(@Name, ',', ',')
  4665. DECLARE @MaxID AS INT
  4666. IF @ID>0
  4667. BEGIN
  4668. IF @OperatorID <> (SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID AND AccountType = 1) AND @OperatorID<>@caMainID
  4669. RETURN 0
  4670. DECLARE @NameOld AS NVARCHAR(60), @ResponsibilityOld AS VARCHAR(MAX),
  4671. @DemandOld AS VARCHAR(MAX), @IsVerify AS BIT
  4672. SELECT @NameOld = dbo.TextTrim(ISNULL(Name, '')), @ResponsibilityOld = ISNULL(Responsibility, ''),
  4673. @DemandOld = ISNULL(Demand, '')
  4674. FROM Job WITH(NOLOCK)
  4675. WHERE ID = @ID
  4676. UPDATE Job SET
  4677. Name = @Name,
  4678. dcJobTypeID = @dcJobTypeID,
  4679. dcJobTypeIDMinor = @dcJobTypeIDMinor,
  4680. NeedNumber = @NeedNumber,
  4681. dcSalaryID = @dcSalaryID,
  4682. EmployType = @EmployType,
  4683. dcRegionID = @dcRegionID,
  4684. Lng = @Lng,
  4685. Lat = @Lat,
  4686. Responsibility = @Responsibility,
  4687. Demand = @Demand,
  4688. dcEducationID = @dcEducationID,
  4689. MinExperience = @MinExperience,
  4690. MinAge = @MinAge,
  4691. MaxAge = @MaxAge,
  4692. EMailSendFreq = dbo.BinToINT(@EMailSendFreq),
  4693. RefreshDate = GETDATE(),
  4694. LastModifyDate = GETDATE(),
  4695. FilterMaxDegree = @FilterMaxDegree,
  4696. FilterMinDegree = @FilterMinDegree,
  4697. FilterMaxWorkYear = @FilterMaxWorkYear,
  4698. FilterMinWorkYear = @FilterMinWorkYear,
  4699. FilterMaxAge = @FilterMaxAge,
  4700. FilterMinAge = @FilterMinAge,
  4701. FilterGender = @FilterGender,
  4702. FilterJobRegion = @FilterJobRegion,
  4703. ForwardEmail = @ForwardEmail,
  4704. dcSalaryIdMax = @dcSalaryMaxID,
  4705. Negotiable = @Negotiable
  4706. WHERE ID = @ID
  4707. SET @MaxID = @ID
  4708. SET @IsVerify = 0
  4709. IF @NameOld <> dbo.TextTrim(@Name)
  4710. BEGIN
  4711. DELETE FROM bsCpModify WHERE SubId = @ID AND Location = 'c1'
  4712. INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @ID, 'c1', @Name)
  4713. SET @IsVerify = 1
  4714. END
  4715. IF @ResponsibilityOld <> @Responsibility
  4716. BEGIN
  4717. DELETE FROM bsCpModify WHERE SubId = @ID AND Location = 'c2'
  4718. INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @ID, 'c2', @Responsibility)
  4719. SET @IsVerify = 1
  4720. END
  4721. IF @DemandOld <> @Demand
  4722. BEGIN
  4723. DELETE FROM bsCpModify WHERE SubId = @ID AND Location = 'c3'
  4724. INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @ID, 'c3', @Demand)
  4725. SET @IsVerify = 1
  4726. END
  4727. END
  4728. ELSE
  4729. BEGIN
  4730. INSERT INTO Job
  4731. (
  4732. cpMainID, caMainID, Name, dcJobTypeID, dcJobTypeIDMinor,
  4733. NeedNumber, dcSalaryID, EmployType, dcRegionID, Lng, Lat,
  4734. Responsibility, Demand, dcEducationID, MinExperience,
  4735. MinAge, MaxAge, EMailSendFreq,
  4736. AddDate, LastModifyDate, RefreshDate, IssueDate, IssueEnd,
  4737. FilterMaxDegree, FilterMinDegree, FilterMaxWorkYear, FilterMinWorkYear,
  4738. FilterMaxAge, FilterMinAge, FilterGender, FilterJobRegion,
  4739. ForwardEmail, dcSalaryIdMax, Negotiable
  4740. )
  4741. VALUES
  4742. (
  4743. @cpMainID, @caMainID, @Name, @dcJobTypeID, @dcJobTypeIDMinor,
  4744. @NeedNumber, @dcSalaryID, @EmployType, @dcRegionID, @Lng, @Lat,
  4745. @Responsibility, @Demand, @dcEducationID, @MinExperience,
  4746. @MinAge, @MaxAge, dbo.BinToINT(@EMailSendFreq),
  4747. GETDATE(), GETDATE(), GETDATE(), GETDATE(), DATEADD(MONTH, 2, GETDATE()),
  4748. @FilterMaxDegree, @FilterMinDegree, @FilterMaxWorkYear, @FilterMinWorkYear,
  4749. @FilterMaxAge, @FilterMinAge, @FilterGender, @FilterJobRegion,
  4750. @ForwardEmail, @dcSalaryMaxID, @Negotiable
  4751. )
  4752. SET @MaxID = @@IDENTITY
  4753. INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @MaxID, 'c1', @Name)
  4754. INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @MaxID, 'c2', @Responsibility)
  4755. INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @MaxID, 'c3', @Demand)
  4756. SET @IsVerify = 1
  4757. END
  4758. COMMIT TRAN
  4759. RETURN @MaxID
  4760. ERR:
  4761. BEGIN
  4762. --insert into a_tmp select ERROR_MESSAGE(), getdate()
  4763. ROLLBACK TRAN
  4764. RETURN 0
  4765. END
  4766. RETURN @MaxID
  4767. ERR1:
  4768. BEGIN
  4769. --insert into a_tmp select ERROR_MESSAGE(), getdate()
  4770. ROLLBACK TRAN
  4771. RETURN -1
  4772. END
  4773. SET NOCOUNT OFF
  4774. GO
  4775. /****** Object: StoredProcedure [dbo].[ccJobSelect] Script Date: 2018/12/13 19:07:09 ******/
  4776. SET ANSI_NULLS ON
  4777. GO
  4778. SET QUOTED_IDENTIFIER ON
  4779. GO
  4780. CREATE PROCEDURE [dbo].[ccJobSelect]
  4781. (
  4782. @ID INT
  4783. )
  4784. AS
  4785. SET NOCOUNT ON
  4786. BEGIN
  4787. SELECT *
  4788. FROM Job WITH(NOLOCK)
  4789. WHERE ID = @ID
  4790. AND IsDelete = 0
  4791. END
  4792. GO
  4793. /****** Object: StoredProcedure [dbo].[ccJobTemplateBycaMainIDSelect] Script Date: 2018/12/13 19:07:10 ******/
  4794. SET ANSI_NULLS ON
  4795. GO
  4796. SET QUOTED_IDENTIFIER ON
  4797. GO
  4798. CREATE PROCEDURE [dbo].[ccJobTemplateBycaMainIDSelect]
  4799. @caMainID INT
  4800. AS
  4801. BEGIN
  4802. SELECT a.*, b.FullName Region,dbo.Int2Bin(EMailSendFreq) PushFreq,
  4803. ISNULL((SELECT Description FROM dcEducation WHERE Id = dcEducationId), '不限') Education,
  4804. e.Description JobTypeName,f.Description JobTypeMinorName,g.Description NeedNumName,h.Description EmployTypeName,
  4805. i.Description ExperienceName,j.DescriptionCp SalaryName,k.DescriptionCp SalaryMaxName
  4806. FROM JobTemplate a WITH(NOLOCK)
  4807. LEFT JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionID = b.ID
  4808. LEFT JOIN caOnline c WITH(NOLOCK) ON a.caMainId = c.caMainId
  4809. LEFT JOIN dcJobType e WITH(NOLOCK) ON a.dcJobTypeId = e.ID
  4810. LEFT JOIN dcJobType f WITH(NOLOCK) ON a.dcJobTypeIdMinor = f.ID
  4811. LEFT JOIN dcOthers g WITH(NOLOCK) ON a.NeedNumber = g.DetailID AND g.Category = '招聘人数'
  4812. LEFT JOIN dcOthers h WITH(NOLOCK) ON a.EmployType = h.DetailID AND h.Category = '工作性质'
  4813. LEFT JOIN dcOthers i WITH(NOLOCK) ON a.MinExperience = i.DetailID AND i.Category = '职位要求工作经验'
  4814. LEFT JOIN dcSalary j WITH(NOLOCK) ON a.dcSalaryId = j.ID
  4815. LEFT JOIN dcSalary k WITH(NOLOCK) ON a.dcSalaryIdMax = k.ID
  4816. WHERE a.caMainID = @caMainID
  4817. ORDER BY a.ID DESC
  4818. END
  4819. GO
  4820. /****** Object: StoredProcedure [dbo].[ccJobTemplateByMapBarUpdate] Script Date: 2018/12/13 19:07:10 ******/
  4821. SET ANSI_NULLS ON
  4822. GO
  4823. SET QUOTED_IDENTIFIER ON
  4824. GO
  4825. CREATE PROCEDURE [dbo].[ccJobTemplateByMapBarUpdate]
  4826. @ID INT,
  4827. @Lng VARCHAR(20),
  4828. @Lat VARCHAR(20),
  4829. @cpMainID INT
  4830. AS
  4831. BEGIN
  4832. UPDATE JobTemplate SET Lng=@Lng,Lat=@Lat WHERE ID=@ID AND cpMainID=@cpMainID
  4833. END
  4834. GO
  4835. /****** Object: StoredProcedure [dbo].[ccJobTemplateDelete] Script Date: 2018/12/13 19:07:10 ******/
  4836. SET ANSI_NULLS ON
  4837. GO
  4838. SET QUOTED_IDENTIFIER ON
  4839. GO
  4840. CREATE PROCEDURE [dbo].[ccJobTemplateDelete]
  4841. (
  4842. @ID INT,
  4843. @caMainID INT
  4844. )
  4845. AS
  4846. BEGIN TRAN
  4847. DECLARE @caID AS INT
  4848. DECLARE @AccountType AS INT
  4849. DECLARE @cpMainID AS INT
  4850. DECLARE @cpID AS INT
  4851. SELECT @caID=caMainId ,@cpID = cpMainID FROM JobTemplate WITH(NOLOCK) WHERE ID = @ID AND caMainID = @caMainID
  4852. SELECT @AccountType=AccountType,@cpMainID=cpMainID FROM caMain WITH(NOLOCK) WHERE id = @caMainID
  4853. IF @caID Is NUll
  4854. GOTO ERR1
  4855. IF @caID != @caMainID
  4856. BEGIN
  4857. IF @AccountType != 1
  4858. GOTO ERR2
  4859. IF @cpMainID != @cpID
  4860. GOTO ERR2
  4861. END
  4862. IF @caID Is NUll
  4863. GOTO ERR1
  4864. IF @caID != @caMainID
  4865. GOTO ERR2
  4866. DELETE FROM JobTemplate WHERE ID = @ID
  4867. IF @@ERROR <>0
  4868. GOTO ERR
  4869. COMMIT TRAN
  4870. RETURN 1
  4871. ERR:
  4872. BEGIN
  4873. ROLLBACK TRAN
  4874. RETURN 0
  4875. END
  4876. ERR1:
  4877. BEGIN
  4878. ROLLBACK TRAN
  4879. RETURN -1
  4880. END
  4881. ERR2:
  4882. BEGIN
  4883. ROLLBACK TRAN
  4884. RETURN -2
  4885. END
  4886. GO
  4887. /****** Object: StoredProcedure [dbo].[ccJobTemplateMapBarIDUpdate] Script Date: 2018/12/13 19:07:10 ******/
  4888. SET ANSI_NULLS ON
  4889. GO
  4890. SET QUOTED_IDENTIFIER ON
  4891. GO
  4892. -- =============================================
  4893. -- Author: <Author,,Name>
  4894. -- Create date: <Create Date,,>
  4895. -- Description: <Description,,>
  4896. -- =============================================
  4897. CREATE PROCEDURE [dbo].[ccJobTemplateMapBarIDUpdate]
  4898. @ID INT,
  4899. @MapBarID VARCHAR(50),
  4900. @cpMainID INT
  4901. AS
  4902. BEGIN
  4903. UPDATE JobTemplate SET MapBarID=@MapBarID WHERE ID=@ID AND cpMainID = @cpMainID
  4904. END
  4905. GO
  4906. /****** Object: StoredProcedure [dbo].[ccJobTemplateSave] Script Date: 2018/12/13 19:07:10 ******/
  4907. SET ANSI_NULLS ON
  4908. GO
  4909. SET QUOTED_IDENTIFIER ON
  4910. GO
  4911. --修改职位模板
  4912. --Peter 2016-10-31修改 修改职位订阅的订阅方式
  4913. CREATE PROCEDURE [dbo].[ccJobTemplateSave]
  4914. (
  4915. @ID INT,
  4916. @cpMainID INT,
  4917. @caMainID INT,
  4918. @Name VARCHAR(50),
  4919. @dcJobTypeID INT,
  4920. @dcJobTypeIDMinor INT,
  4921. @NeedNumber SMALLINT,
  4922. @dcSalaryID TINYINT,
  4923. @EmployType TINYINT,
  4924. @dcRegionID VARCHAR(6),
  4925. @Lng DECIMAL(8, 5),
  4926. @Lat DECIMAL(8, 5),
  4927. @Responsibility VARCHAR(MAX),
  4928. @DemAND VARCHAR(MAX),
  4929. @dcEducationID TINYINT,
  4930. @MinExperience TINYINT,
  4931. @MinAge TINYINT,
  4932. @MaxAge TINYINT,
  4933. @EMailSendFreq VARCHAR(7),
  4934. @EMailSendNumber TINYINT
  4935. )
  4936. AS
  4937. SELECT @Responsibility = dbo.SafeSql(@Responsibility), @Demand = dbo.SafeSql(@Demand)
  4938. BEGIN TRY
  4939. IF @ID>0
  4940. BEGIN
  4941. UPDATE JobTemplate SET
  4942. Name = @Name,
  4943. dcJobTypeID = @dcJobTypeID,
  4944. dcJobTypeIDMinor = @dcJobTypeIDMinor,
  4945. NeedNumber = @NeedNumber,
  4946. dcSalaryID = @dcSalaryID,
  4947. EmployType = @EmployType,
  4948. dcRegionID = @dcRegionID,
  4949. Lng = @Lng,
  4950. Lat = @Lat,
  4951. Responsibility = @Responsibility,
  4952. DemAND = @Demand,
  4953. dcEducationID = @dcEducationID,
  4954. MinExperience = @MinExperience,
  4955. MinAge = @MinAge,
  4956. MaxAge = @MaxAge,
  4957. EMailSendFreq = dbo.BinToINT(@EMailSendFreq),
  4958. LastModifyDate = GETDATE()
  4959. WHERE ID=@ID
  4960. AND caMainID = @caMainID
  4961. End
  4962. ELSE
  4963. BEGIN
  4964. INSERT INTO JobTemplate
  4965. (
  4966. cpMainID,caMainID,Name,dcJobTypeID,dcJobTypeIDMinor,
  4967. NeedNumber,dcSalaryID,EmployType,dcRegionID,Lng,Lat,
  4968. Responsibility,Demand,dcEducationID,MinExperience,
  4969. MinAge,MaxAge,EMailSendFreq,
  4970. AddDate,LastModifyDate
  4971. )
  4972. VALUES
  4973. (
  4974. @cpMainID,@caMainID,@Name,@dcJobTypeID,@dcJobTypeIDMinor,
  4975. @NeedNumber,@dcSalaryID,@EmployType,@dcRegionID,@Lng,@Lat,
  4976. @Responsibility,@Demand,@dcEducationID,@MinExperience,
  4977. @MinAge,@MaxAge,dbo.BinToINT(@EMailSendFreq),
  4978. GETDATE(),GETDATE()
  4979. )
  4980. END
  4981. END TRY
  4982. BEGIN CATCH
  4983. GOTO ERR
  4984. END CATCH
  4985. RETURN 1
  4986. ERR:
  4987. BEGIN
  4988. RETURN 0
  4989. END
  4990. GO
  4991. /****** Object: StoredProcedure [dbo].[ccJobTemplateSave2] Script Date: 2018/12/13 19:07:10 ******/
  4992. SET ANSI_NULLS ON
  4993. GO
  4994. SET QUOTED_IDENTIFIER ON
  4995. GO
  4996. --修改职位模板
  4997. --Peter 2016-10-31修改 修改职位订阅的订阅方式
  4998. --Peter 2017-2-7修改 添加职位标签保存
  4999. CREATE PROCEDURE [dbo].[ccJobTemplateSave2]
  5000. (
  5001. @ID INT,
  5002. @cpMainID INT,
  5003. @caMainID INT,
  5004. @Name VARCHAR(50),
  5005. @dcJobTypeID INT,
  5006. @dcJobTypeIDMinor INT,
  5007. @NeedNumber SMALLINT,
  5008. @dcSalaryID TINYINT,
  5009. @EmployType TINYINT,
  5010. @dcRegionID VARCHAR(6),
  5011. @Lng DECIMAL(8, 5),
  5012. @Lat DECIMAL(8, 5),
  5013. @Responsibility VARCHAR(MAX),
  5014. @DemAND VARCHAR(MAX),
  5015. @dcEducationID TINYINT,
  5016. @MinExperience TINYINT,
  5017. @MinAge TINYINT,
  5018. @MaxAge TINYINT,
  5019. @EMailSendFreq VARCHAR(7),
  5020. @EMailSendNumber TINYINT,
  5021. @JobTags NVARCHAR(100)
  5022. )
  5023. AS
  5024. SELECT @Responsibility = dbo.SafeSql(@Responsibility), @Demand = dbo.SafeSql(@Demand)
  5025. BEGIN TRY
  5026. IF @ID>0
  5027. BEGIN
  5028. UPDATE JobTemplate SET
  5029. Name = @Name,
  5030. dcJobTypeID = @dcJobTypeID,
  5031. dcJobTypeIDMinor = @dcJobTypeIDMinor,
  5032. NeedNumber = @NeedNumber,
  5033. dcSalaryID = @dcSalaryID,
  5034. EmployType = @EmployType,
  5035. dcRegionID = @dcRegionID,
  5036. Lng = @Lng,
  5037. Lat = @Lat,
  5038. Responsibility = @Responsibility,
  5039. DemAND = @Demand,
  5040. dcEducationID = @dcEducationID,
  5041. MinExperience = @MinExperience,
  5042. MinAge = @MinAge,
  5043. MaxAge = @MaxAge,
  5044. EMailSendFreq = dbo.BinToINT(@EMailSendFreq),
  5045. LastModifyDate = GETDATE(),
  5046. JobTags = @JobTags
  5047. WHERE ID=@ID
  5048. AND caMainID = @caMainID
  5049. End
  5050. ELSE
  5051. BEGIN
  5052. INSERT INTO JobTemplate
  5053. (
  5054. cpMainID,caMainID,Name,dcJobTypeID,dcJobTypeIDMinor,
  5055. NeedNumber,dcSalaryID,EmployType,dcRegionID,Lng,Lat,
  5056. Responsibility,Demand,dcEducationID,MinExperience,
  5057. MinAge,MaxAge,EMailSendFreq,
  5058. AddDate,LastModifyDate,JobTags
  5059. )
  5060. VALUES
  5061. (
  5062. @cpMainID,@caMainID,@Name,@dcJobTypeID,@dcJobTypeIDMinor,
  5063. @NeedNumber,@dcSalaryID,@EmployType,@dcRegionID,@Lng,@Lat,
  5064. @Responsibility,@Demand,@dcEducationID,@MinExperience,
  5065. @MinAge,@MaxAge,dbo.BinToINT(@EMailSendFreq),
  5066. GETDATE(),GETDATE(),@JobTags
  5067. )
  5068. END
  5069. END TRY
  5070. BEGIN CATCH
  5071. GOTO ERR
  5072. END CATCH
  5073. RETURN 1
  5074. ERR:
  5075. BEGIN
  5076. RETURN 0
  5077. END
  5078. GO
  5079. /****** Object: StoredProcedure [dbo].[ccJobTemplateSaveNew] Script Date: 2018/12/13 19:07:11 ******/
  5080. SET ANSI_NULLS ON
  5081. GO
  5082. SET QUOTED_IDENTIFIER ON
  5083. GO
  5084. --修改职位模板
  5085. --Peter 2016-10-31修改 修改职位订阅的订阅方式
  5086. --Peter 2017-2-7修改 添加职位标签保存
  5087. --Lucifer 2017-3-21修改 月薪改为范围,添加可面议
  5088. CREATE PROCEDURE [dbo].[ccJobTemplateSaveNew]
  5089. (
  5090. @ID INT,
  5091. @cpMainID INT,
  5092. @caMainID INT,
  5093. @Name VARCHAR(50),
  5094. @dcJobTypeID INT,
  5095. @dcJobTypeIDMinor INT,
  5096. @NeedNumber SMALLINT,
  5097. @dcSalaryID TINYINT,
  5098. @EmployType TINYINT,
  5099. @dcRegionID VARCHAR(6),
  5100. @Lng DECIMAL(8, 5),
  5101. @Lat DECIMAL(8, 5),
  5102. @Responsibility VARCHAR(MAX),
  5103. @DemAND VARCHAR(MAX),
  5104. @dcEducationID TINYINT,
  5105. @MinExperience TINYINT,
  5106. @MinAge TINYINT,
  5107. @MaxAge TINYINT,
  5108. @EMailSendFreq VARCHAR(7),
  5109. @EMailSendNumber TINYINT,
  5110. @JobTags NVARCHAR(100),
  5111. @dcSalaryMaxID TINYINT,
  5112. @Negotiable BIT
  5113. )
  5114. AS
  5115. SELECT @Responsibility = dbo.SafeSql(@Responsibility), @Demand = dbo.SafeSql(@Demand)
  5116. BEGIN TRY
  5117. IF @ID>0
  5118. BEGIN
  5119. UPDATE JobTemplate SET
  5120. Name = @Name,
  5121. dcJobTypeID = @dcJobTypeID,
  5122. dcJobTypeIDMinor = @dcJobTypeIDMinor,
  5123. NeedNumber = @NeedNumber,
  5124. dcSalaryID = @dcSalaryID,
  5125. EmployType = @EmployType,
  5126. dcRegionID = @dcRegionID,
  5127. Lng = @Lng,
  5128. Lat = @Lat,
  5129. Responsibility = @Responsibility,
  5130. DemAND = @Demand,
  5131. dcEducationID = @dcEducationID,
  5132. MinExperience = @MinExperience,
  5133. MinAge = @MinAge,
  5134. MaxAge = @MaxAge,
  5135. EMailSendFreq = dbo.BinToINT(@EMailSendFreq),
  5136. LastModifyDate = GETDATE(),
  5137. JobTags = @JobTags,
  5138. dcSalaryIDMax = @dcSalaryMaxID,
  5139. Negotiable = @Negotiable
  5140. WHERE ID=@ID
  5141. AND caMainID = @caMainID
  5142. End
  5143. ELSE
  5144. BEGIN
  5145. INSERT INTO JobTemplate
  5146. (
  5147. cpMainID,caMainID,Name,dcJobTypeID,dcJobTypeIDMinor,
  5148. NeedNumber,dcSalaryID,EmployType,dcRegionID,Lng,Lat,
  5149. Responsibility,Demand,dcEducationID,MinExperience,
  5150. MinAge,MaxAge,EMailSendFreq,
  5151. AddDate,LastModifyDate,JobTags,dcSalaryIDMax,Negotiable
  5152. )
  5153. VALUES
  5154. (
  5155. @cpMainID,@caMainID,@Name,@dcJobTypeID,@dcJobTypeIDMinor,
  5156. @NeedNumber,@dcSalaryID,@EmployType,@dcRegionID,@Lng,@Lat,
  5157. @Responsibility,@Demand,@dcEducationID,@MinExperience,
  5158. @MinAge,@MaxAge,dbo.BinToINT(@EMailSendFreq),
  5159. GETDATE(),GETDATE(),@JobTags,@dcSalaryMaxID,@Negotiable
  5160. )
  5161. END
  5162. END TRY
  5163. BEGIN CATCH
  5164. GOTO ERR
  5165. END CATCH
  5166. RETURN 1
  5167. ERR:
  5168. BEGIN
  5169. RETURN 0
  5170. END
  5171. GO
  5172. /****** Object: StoredProcedure [dbo].[ccJobTemplateSelect] Script Date: 2018/12/13 19:07:11 ******/
  5173. SET ANSI_NULLS ON
  5174. GO
  5175. SET QUOTED_IDENTIFIER ON
  5176. GO
  5177. --Peter 2016-10-31修改职位订阅内容展现
  5178. CREATE PROCEDURE [dbo].[ccJobTemplateSelect]
  5179. (
  5180. @ID INT
  5181. )
  5182. AS
  5183. BEGIN
  5184. SELECT a.*, b.FullName Region,dbo.Int2Bin(EMailSendFreq) PushFreq,
  5185. ISNULL((SELECT Description FROM dcEducation WHERE Id = dcEducationId), '不限') Education,
  5186. e.Description JobTypeName,f.Description JobTypeMinorName,g.Description NeedNumName,h.Description EmployTypeName,
  5187. i.Description ExperienceName,j.DescriptionCp SalaryName,k.DescriptionCp SalaryMaxName
  5188. FROM JobTemplate a WITH(NOLOCK)
  5189. LEFT JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionID = b.ID
  5190. LEFT JOIN caOnline c WITH(NOLOCK) ON a.caMainId = c.caMainId
  5191. LEFT JOIN dcJobType e WITH(NOLOCK) ON a.dcJobTypeId = e.ID
  5192. LEFT JOIN dcJobType f WITH(NOLOCK) ON a.dcJobTypeIdMinor = f.ID
  5193. LEFT JOIN dcOthers g WITH(NOLOCK) ON a.NeedNumber = g.DetailID AND g.Category = '招聘人数'
  5194. LEFT JOIN dcOthers h WITH(NOLOCK) ON a.EmployType = h.DetailID AND h.Category = '工作性质'
  5195. LEFT JOIN dcOthers i WITH(NOLOCK) ON a.MinExperience = i.DetailID AND i.Category = '职位要求工作经验'
  5196. LEFT JOIN dcSalary j WITH(NOLOCK) ON a.dcSalaryId = j.ID
  5197. LEFT JOIN dcSalary k WITH(NOLOCK) ON a.dcSalaryIdMax = k.ID
  5198. WHERE a.ID = @ID
  5199. END
  5200. GO
  5201. /****** Object: StoredProcedure [dbo].[ccLotteryCompany201310Update] Script Date: 2018/12/13 19:07:11 ******/
  5202. SET ANSI_NULLS ON
  5203. GO
  5204. SET QUOTED_IDENTIFIER ON
  5205. GO
  5206. --创建人:lambo
  5207. --创建时间:2013-9-29
  5208. --企业13周年抽奖
  5209. --奖项内容: 平时 10月8日、18日、28日
  5210. -- 10职位并发 20% 20%
  5211. -- 20份简历 30% 30%
  5212. -- 50份简历 10% 10%
  5213. -- 2周文字广告 5% 5%
  5214. -- 2周职位置顶 5% 5%
  5215. -- 2周职位自动刷新 10% 10%
  5216. -- Vip会员—季度 0% 5%(至少有一个)
  5217. -- 1:1的赠送 0% 5%(至少有一个)
  5218. -- 空奖 20% 10%
  5219. -- 保险公司,抽奖中奖概率调整为10%
  5220. CREATE PROCEDURE [dbo].[ccLotteryCompany201310Update]
  5221. (
  5222. @caMainID INT
  5223. )
  5224. AS
  5225. BEGIN
  5226. RETURN 9 --活动已结束
  5227. DECLARE @LotteryID INT
  5228. DECLARE @cpMainID INT
  5229. SELECT TOP 1 @LotteryID = ID,@cpMainID = cpMainID FROM LotteryCompany201310 WITH(NOLOCK) WHERE Used = 0 AND cpMainID = (select cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID AND AccountType=1)
  5230. IF @LotteryID IS NULL
  5231. RETURN -1 --没有抽奖次数
  5232. UPDATE LotteryCompany201310 SET Used = 1,LotteryDate=GETDATE() WHERE ID = @LotteryID --更新状态 防止重复抽奖
  5233. ------------------****************生成抽奖结果****************-----------------
  5234. DECLARE @IsAgent INT --是否是保险公司
  5235. SELECT top 1 @IsAgent = IsAgent FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
  5236. DECLARE @Today VARCHAR(4) --用于判断 是否是10月8日、18日、28日
  5237. SELECT @Today = RIGHT(CONVERT(VARCHAR(8) , GETDATE() , 112) , 4)
  5238. DECLARE @GiftNo INT
  5239. SELECT @GiftNo = CAST((RAND()*999+1) AS INT) --生成抽奖的数字
  5240. --奖品类型:1、10职位并发 2、20份简历 3、50份简历 4、2周文字广告 5、2周职位置顶 6、2周职位自动刷新 7、Vip会员—季度 8、1:1的赠送 9、空奖
  5241. DECLARE @GiftType INT
  5242. IF @IsAgent = 0
  5243. BEGIN
  5244. IF @GiftNo BETWEEN 51 AND 250 --51-250之间 职位并发 20%概率
  5245. SET @GiftType = 1
  5246. ELSE IF @GiftNo BETWEEN 251 AND 550 --251-550之间 20简历下载 30%概率
  5247. SET @GiftType = 2
  5248. ELSE IF @GiftNo BETWEEN 551 AND 650 --551-650之间 50简历下载 10%概率
  5249. SET @GiftType = 3
  5250. ELSE IF @GiftNo BETWEEN 651 AND 700 --651-700之间 两周文字广告 5%概率
  5251. SET @GiftType = 4
  5252. ELSE IF @GiftNo BETWEEN 701 AND 750 --701-750之间 两周职位置顶 5%概率
  5253. SET @GiftType = 5
  5254. ELSE IF @GiftNo BETWEEN 751 AND 850 --751-850之间 两周职位刷新 10%概率
  5255. SET @GiftType = 6
  5256. ELSE IF @GiftNo BETWEEN 0 AND 50 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' ) --0-50之间 Vip会员—季度 5%概率
  5257. SET @GiftType = 7
  5258. ELSE IF @GiftNo BETWEEN 951 AND 1000 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' ) --951-1000之间 1:1赠送 5%概率
  5259. SET @GiftType = 8
  5260. ELSE --空奖 20%概率
  5261. SET @GiftType = 9
  5262. END
  5263. ELSE -- 保险公司中奖概率10%
  5264. BEGIN
  5265. IF @GiftNo BETWEEN 61 AND 80 --61-80之间 职位并发 20%概率
  5266. SET @GiftType = 1
  5267. ELSE IF @GiftNo BETWEEN 281 AND 310 --281-310之间 20简历下载 30%概率
  5268. SET @GiftType = 2
  5269. ELSE IF @GiftNo BETWEEN 581 AND 590 --551-650之间 50简历下载 10%概率
  5270. SET @GiftType = 3
  5271. ELSE IF @GiftNo BETWEEN 661 AND 665 --651-700之间 两周文字广告 5%概率
  5272. SET @GiftType = 4
  5273. ELSE IF @GiftNo BETWEEN 731 AND 735 --701-750之间 两周职位置顶 5%概率
  5274. SET @GiftType = 5
  5275. ELSE IF @GiftNo BETWEEN 761 AND 770 --751-850之间 两周职位刷新 10%概率
  5276. SET @GiftType = 6
  5277. ELSE IF @GiftNo BETWEEN 31 AND 35 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' ) --0-50之间 Vip会员—季度 5%概率
  5278. SET @GiftType = 7
  5279. ELSE IF @GiftNo BETWEEN 981 AND 985 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' ) --951-1000之间 1:1赠送 5%概率
  5280. SET @GiftType = 8
  5281. ELSE --空奖 20%概率
  5282. SET @GiftType = 9
  5283. END
  5284. -- IF @GiftType =7 OR @GiftType = 8
  5285. -- SET @GiftType = 1
  5286. /*---------****************自动提交订单**************-------------*/
  5287. DECLARE @ProvinceID INT
  5288. DECLARE @PayMethod INT --取上次订单的付款方式
  5289. DECLARE @LinkMan NVARCHAR(50)
  5290. DECLARE @Telephone NVARCHAR(50)
  5291. DECLARE @CompanyName NVARCHAR(50)
  5292. DECLARE @Accounts NUMERIC(18,2)
  5293. DECLARE @dcFeeDetailsID INT
  5294. DECLARE @Manageruserid INT
  5295. DECLARE @MemberType INT
  5296. DECLARE @MainOrderID INT
  5297. DECLARE @InvoiceCompany NVARCHAR(50)
  5298. SELECT TOP 1
  5299. @ProvinceID = b.dcProvinceID,
  5300. @PayMethod = c.PayMethod,
  5301. @MemberType = MemberType,
  5302. @LinkMan = LinkMan,
  5303. @Telephone = Telephone,
  5304. @CompanyName = CompanyName,
  5305. @InvoiceCompany = InvoiceCompany,
  5306. @Manageruserid = ConsultantID
  5307. FROM LotteryCompany201310 a,cpMain b ,caOrder c
  5308. WHERE a.cpMainID = b.ID
  5309. AND a.caOrderID = c.ID
  5310. AND a.cpMainID = @cpMainID
  5311. ORDER BY a.ID
  5312. SET @PayMethod = 7
  5313. DECLARE @NewOrderID INT
  5314. IF @GiftType = 1 AND @MemberType=3 --自动提交职位并发订单
  5315. BEGIN
  5316. --取原价和对应的资费ID
  5317. SELECT TOP 1 @Accounts = b.Price * 10,
  5318. @dcFeeDetailsID = a.ID
  5319. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  5320. WHERE b.type = 10
  5321. AND a.dcFeeID = b.ID
  5322. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  5323. AND ((MinValue<=10 AND MaxValue>=10) OR (MinValue<=10 AND MaxValue=0))
  5324. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5325. SELECT TOP 1 @MainOrderID = ID FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND OpenDate IS NOT NULL AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
  5326. --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,0, 32, NULL,NULL,@PayMethod,10,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,10,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
  5327. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5328. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
  5329. VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
  5330. 10,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,10,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
  5331. SET @NewOrderID = @@IDENTITY
  5332. END
  5333. ELSE IF @GiftType = 2 AND @MemberType=3 --自动提交20简历下载订单
  5334. BEGIN
  5335. --取原价和对应的资费ID
  5336. SELECT TOP 1 @Accounts = b.Price * 20,
  5337. @dcFeeDetailsID = a.ID
  5338. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  5339. WHERE b.type = 9
  5340. AND a.dcFeeID = b.ID
  5341. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  5342. AND ((MinValue<=20 AND MaxValue>=20) OR (MinValue<=20 AND MaxValue=0))
  5343. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5344. IF @dcFeeDetailsID IS NULL
  5345. SELECT TOP 1 @Accounts = Price * 20
  5346. FROM dcFee WITH(NOLOCK)
  5347. WHERE type = 9
  5348. AND dcProvinceID = LEFT(@ProvinceID,2)
  5349. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5350. SELECT TOP 1 @MainOrderID = ID FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND OpenDate IS NOT NULL AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
  5351. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5352. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
  5353. VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
  5354. 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,20,20,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
  5355. SET @NewOrderID = @@IDENTITY
  5356. END
  5357. ELSE IF @GiftType = 3 AND @MemberType=3 --自动提交50简历下载订单
  5358. BEGIN
  5359. --取原价和对应的资费ID
  5360. SELECT TOP 1 @Accounts = b.Price * 50,
  5361. @dcFeeDetailsID = a.ID
  5362. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  5363. WHERE b.type = 9
  5364. AND a.dcFeeID = b.ID
  5365. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  5366. AND ((MinValue<=50 AND MaxValue>=50) OR (MinValue<=50 AND MaxValue=0))
  5367. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5368. IF @dcFeeDetailsID IS NULL
  5369. SELECT TOP 1 @Accounts = Price * 50
  5370. FROM dcFee WITH(NOLOCK)
  5371. WHERE type = 9
  5372. AND dcProvinceID = LEFT(@ProvinceID,2)
  5373. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5374. SELECT TOP 1 @MainOrderID = ID FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND OpenDate IS NOT NULL AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
  5375. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5376. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
  5377. VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
  5378. 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,50,50,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
  5379. SET @NewOrderID = @@IDENTITY
  5380. END
  5381. ELSE IF @GiftType = 4 --自动提交2周固定位置订单
  5382. BEGIN
  5383. --取原价和对应的资费ID
  5384. SELECT TOP 1 @Accounts = b.Price * 2,
  5385. @dcFeeDetailsID = a.ID
  5386. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  5387. WHERE b.type = 7
  5388. AND a.dcFeeID = b.ID
  5389. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  5390. AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
  5391. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5392. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5393. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
  5394. VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
  5395. 7,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
  5396. SET @NewOrderID = @@IDENTITY
  5397. --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,7,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
  5398. END
  5399. ELSE IF @GiftType = 5 --自动提交2周职位置顶订单,职位默认取最新发布的,前台企业选择后再修改
  5400. BEGIN
  5401. --取原价和对应的资费ID
  5402. SELECT TOP 1 @Accounts = b.Price * 2,
  5403. @dcFeeDetailsID = a.ID
  5404. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  5405. WHERE b.type = 22
  5406. AND a.dcFeeID = b.ID
  5407. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  5408. AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
  5409. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5410. DECLARE @JobID INT
  5411. SELECT @JobID = ID FROM Job WITH(NOLOCK) WHERE Valid = 1 AND cpMainID= @cpMainID AND ID NOT IN(SELECT Balance FROM caOrder WITH(NOLOCK) WHERE OrderType=12 AND BeginDate>GETDATE() AND EndDate<GETDATE() )
  5412. IF @JobID >0
  5413. BEGIN
  5414. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5415. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
  5416. VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
  5417. 12,@Accounts,0,@JobID,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
  5418. SET @NewOrderID = @@IDENTITY
  5419. --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,12,@Accounts,0,@JobID,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
  5420. END
  5421. END
  5422. ELSE IF @GiftType = 6 --自动提交2周职位刷新订单
  5423. BEGIN
  5424. --取原价和对应的资费ID
  5425. SELECT TOP 1 @Accounts = b.Price * 2,
  5426. @dcFeeDetailsID = a.ID
  5427. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  5428. WHERE b.type = 24
  5429. AND a.dcFeeID = b.ID
  5430. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  5431. AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
  5432. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5433. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5434. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
  5435. VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
  5436. 13,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
  5437. SET @NewOrderID = @@IDENTITY
  5438. --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,13,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
  5439. END
  5440. ELSE IF @GiftType = 7 --自动提交VIP订单
  5441. BEGIN
  5442. DECLARE @ActiveQuota INT
  5443. DECLARE @JobNumber INT
  5444. DECLARE @UserNumber INT
  5445. --取本省份价格最便宜的季度套餐
  5446. SELECT @dcFeeDetailsID = b.ID,
  5447. @Accounts = (a.PriceMonth * b.[Month]+b.ResumeNumber*a.PriceResume+JobNumber*a.PriceJob+UserNumber*a.PriceUser),
  5448. @ActiveQuota = b.ResumeNumber,
  5449. @JobNumber = b.JobNumber,
  5450. @UserNumber = b.UserNumber
  5451. FROM dcVip a WITH(NOLOCK),dcVipDetail b WITH(NOLOCK)
  5452. WHERE a.id = b.dcVipId
  5453. AND dcProvinceid=32
  5454. AND b.[Month]=3
  5455. AND startDate<GETDATE()
  5456. AND enddate > GETDATE()
  5457. ORDER BY Price
  5458. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5459. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
  5460. VALUES(@cpMainID,@ProvinceID,null,NULL,@PayMethod,@UserNumber,
  5461. 8,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,@ActiveQuota,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
  5462. SET @NewOrderID = @@IDENTITY
  5463. --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,0,@PayMethod,8,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,@UserNumber,@dcFeeDetailsID
  5464. END
  5465. ELSE IF @GiftType = 8 --自动提交 1:1赠送
  5466. BEGIN
  5467. ---取最新有赠送抽奖次数的订单
  5468. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5469. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
  5470. SELECT cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5471. OrderType,Accounts,0,0,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,ActiveQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID
  5472. FROM caOrder WITH(NOLOCK)
  5473. WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany201310 WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID ORDER BY ID DESC)
  5474. SET @NewOrderID = @@IDENTITY
  5475. END
  5476. BEGIN TRY
  5477. IF @GiftType<>9
  5478. BEGIN
  5479. IF @Manageruserid IS NULL
  5480. BEGIN
  5481. INSERT INTO rtxnotifylog
  5482. SELECT STUFF((SELECT ','+LTRIM(x.ID) FROM Manageruser x WHERE ID >= 180 and ID <190 FOR XML PATH('')),1,1,'')
  5483. ,'中奖通知',@CompanyName+'('+LTRIM(STR(@cpMainID))+')中奖了,请及时处理',1,0,0,null,getdate()
  5484. END
  5485. ELSE
  5486. BEGIN
  5487. INSERT INTO rtxnotifylog
  5488. SELECT @Manageruserid
  5489. ,'中奖通知',@CompanyName+'('+LTRIM(STR(@cpMainID))+')中奖了,请及时处理',1,0,0,null,getdate()
  5490. END
  5491. Update caOrder Set InvoiceConfirmDate=GetDate(),InvoiceConfirmMan=119,InvoiceAskDate=Null,NeedInvoice=0 Where ID=@NewOrderID
  5492. END
  5493. END TRY
  5494. BEGIN CATCH
  5495. END CATCH
  5496. --更新LotteryCompany201310,保存订单号和中奖类型
  5497. UPDATE LotteryCompany201310 SET GiftOrderID=@NewOrderID,[type]=@GiftType WHERE ID = @LotteryID
  5498. RETURN @GiftType
  5499. END
  5500. GO
  5501. /****** Object: StoredProcedure [dbo].[ccLotteryCompanyUpdate] Script Date: 2018/12/13 19:07:12 ******/
  5502. SET ANSI_NULLS ON
  5503. GO
  5504. SET QUOTED_IDENTIFIER ON
  5505. GO
  5506. --创建人:lambo
  5507. --创建时间:2014-9-29
  5508. --企业14周年抽奖
  5509. --奖项内容: 平时 10月8日、18日、28日
  5510. -- 50职位并发 15% 5%
  5511. -- 50份简历 15% 20%
  5512. -- 100份简历 15% 20%
  5513. -- 200份简历 10% 15%
  5514. -- 4周六分之一图片 10% 15%
  5515. -- 2周知名企业 10% 10%
  5516. -- 2周职位置顶 5% 5%
  5517. -- 2周职位自动刷新 15% 9%
  5518. -- 4周六分之二图片 0% 8%
  5519. -- Vip会员—季度 0% 2%(至少有一个,不能重复 )
  5520. -- 1:1的赠送 0% 1%(至少有一个,不能重复,如果是年度的不能抽到)
  5521. -- 保险公司,培训公司,代理招聘类公司仅能够中奖的范围:职位数、简历数、自动刷新。其他内容不允许抽中。需要在抽选中排除。
  5522. --修改人:nick
  5523. --修改时间:2014-10-10
  5524. --修改内容:发送rtx消息,加入奖品名称
  5525. CREATE PROCEDURE [dbo].[ccLotteryCompanyUpdate]
  5526. (
  5527. @caMainID INT
  5528. )
  5529. AS
  5530. BEGIN
  5531. DECLARE @LotteryID INT
  5532. DECLARE @cpMainID INT
  5533. SELECT TOP 1 @LotteryID = ID,@cpMainID = cpMainID FROM LotteryCompany WITH(NOLOCK) WHERE Used = 0 AND cpMainID = (select cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID AND AccountType=1)
  5534. IF @LotteryID IS NULL
  5535. RETURN -1 --没有抽奖次数
  5536. UPDATE LotteryCompany SET Used = 1,LotteryDate=GETDATE() WHERE ID = @LotteryID --更新状态 防止重复抽奖
  5537. ------------------****************生成抽奖结果****************-----------------
  5538. DECLARE @IsAgent INT --是否是保险公司
  5539. DECLARE @Name NVARCHAR(200)
  5540. SELECT top 1 @IsAgent = IsAgent,@Name = Name FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
  5541. IF @IsAgent=0
  5542. BEGIN
  5543. IF @Name LIKE '%人寿%' OR @Name LIKE '%保险%'
  5544. SET @IsAgent=1
  5545. END
  5546. DECLARE @Today VARCHAR(4) --用于判断 是否是10月8日、18日、28日
  5547. SELECT @Today = RIGHT(CONVERT(VARCHAR(8) , GETDATE() , 112) , 4)
  5548. DECLARE @GiftNo INT
  5549. SELECT @GiftNo = CAST((RAND()*999+1) AS INT) --生成抽奖的数字
  5550. --奖品类型:1、50职位并发 2、50份简历 3、100份简历 4、200份简历 5、4周六分之一图片 6、2周文字广告 7、2周职位置顶
  5551. --8、2周职位自动刷新 9、4周六分之二 10、Vip会员—季度 11、1:1的赠送
  5552. DECLARE @GiftType INT
  5553. IF @IsAgent = 0
  5554. BEGIN
  5555. IF (@Today = '1008' OR @Today = '1016' OR @Today = '1028' OR @Today = '1025' )
  5556. BEGIN
  5557. IF @GiftNo BETWEEN 51 AND 100 --51-100之间 职位并发 5%概率
  5558. SET @GiftType = 1
  5559. ELSE IF @GiftNo BETWEEN 101 AND 200 --101-200之间 50份简历 10%概率
  5560. SET @GiftType = 2
  5561. ELSE IF @GiftNo BETWEEN 201 AND 400 --201-400之间 100份简历 20%概率
  5562. SET @GiftType = 3
  5563. ELSE IF @GiftNo BETWEEN 401 AND 550 --401-500之间 200份简历 15%概率
  5564. SET @GiftType = 4
  5565. ELSE IF @GiftNo BETWEEN 551 AND 700 --401-500之间 六分之一广告 15%概率
  5566. SET @GiftType = 5
  5567. ELSE IF @GiftNo BETWEEN 701 AND 800 --701-750之间 2周文字广告 10%概率
  5568. SET @GiftType = 6
  5569. ELSE IF @GiftNo BETWEEN 801 AND 850 --801-850之间 两周职位置顶 5%概率
  5570. SET @GiftType = 7
  5571. ELSE IF @GiftNo BETWEEN 851 AND 940 --851-940之间 两周职位刷新 9%概率
  5572. SET @GiftType = 8
  5573. ELSE IF @GiftNo BETWEEN 941 AND 1000 OR @GiftNo BETWEEN 1 AND 20 --941-1000之间 1到20 六分之二广告 8%概率
  5574. SET @GiftType = 9
  5575. ELSE IF @GiftNo BETWEEN 21 AND 40 --21-40之间 Vip会员—季度 2%概率
  5576. SET @GiftType = 10
  5577. ELSE IF @GiftNo BETWEEN 41 AND 50 --41-50之间 1:1赠送 1%概率
  5578. SET @GiftType = 11
  5579. ELSE --空奖 0%概率
  5580. SET @GiftType = 12
  5581. END
  5582. ELSE
  5583. BEGIN
  5584. IF @GiftNo BETWEEN 51 AND 200 --51-200之间 职位并发 15%概率
  5585. SET @GiftType = 1
  5586. ELSE IF @GiftNo BETWEEN 201 AND 400 --201-400之间 50份简历 20%概率
  5587. SET @GiftType = 2
  5588. ELSE IF @GiftNo BETWEEN 401 AND 550 --201-400之间 100份简历 15%概率
  5589. SET @GiftType = 3
  5590. ELSE IF @GiftNo BETWEEN 551 AND 650 --401-500之间 200份简历 10%概率
  5591. SET @GiftType = 4
  5592. ELSE IF @GiftNo BETWEEN 651 AND 800 --401-500之间 六分之一广告 15%概率
  5593. SET @GiftType = 5
  5594. ELSE IF @GiftNo BETWEEN 801 AND 900 --701-750之间 2周文字广告 10%概率
  5595. SET @GiftType = 6
  5596. ELSE IF @GiftNo BETWEEN 901 AND 950 --801-850之间 两周职位置顶 5%概率
  5597. SET @GiftType = 7
  5598. ELSE IF @GiftNo BETWEEN 951 AND 1000 OR @GiftNo BETWEEN 1 AND 50 --851-940之间 两周职位刷新 15%概率
  5599. SET @GiftType = 8
  5600. ELSE --空奖 0%概率
  5601. SET @GiftType = 12
  5602. END
  5603. END
  5604. ELSE -- 保险公司中奖概率10%
  5605. BEGIN
  5606. IF @GiftNo BETWEEN 1 AND 200 --1-200之间 职位并发 15%概率
  5607. SET @GiftType = 1
  5608. ELSE IF @GiftNo BETWEEN 201 AND 450 --201-450之间 50份简历 25%概率
  5609. SET @GiftType = 2
  5610. ELSE IF @GiftNo BETWEEN 451 AND 650 --201-400之间 100份简历 20%概率
  5611. SET @GiftType = 3
  5612. ELSE IF @GiftNo BETWEEN 651 AND 800 --401-500之间 200份简历 15%概率
  5613. SET @GiftType = 4
  5614. ELSE IF @GiftNo BETWEEN 801 AND 1000 --851-940之间 两周职位刷新 20%概率
  5615. SET @GiftType = 8
  5616. ELSE --空奖 0%概率
  5617. SET @GiftType = 12
  5618. END
  5619. IF GETDATE()>'2015-11-1'
  5620. SET @GiftType = 9
  5621. /*---------****************抽奖结果处理,判断是否合理,重复 **************-------------*/
  5622. IF (@GiftType =9 OR @GiftType = 10 OR @GiftType = 11) AND NOT (@Today = '1008' OR @Today = '1016' OR @Today = '1028' OR @Today = '1025' ) --不是带8的日子不能抽到
  5623. SET @GiftType = 1
  5624. IF @Today = '1008' OR @Today = '1016' OR @Today = '1028' OR @Today = '1025'
  5625. BEGIN
  5626. IF EXISTS(SELECT TOP 1 'x' FROM LotteryCompany WHERE [Type]=@GiftType AND cpMainID=@cpMainID) --重复抽到了
  5627. SELECT TOP 1 @GiftType = s.a
  5628. FROM (SELECT a FROM dbo.FnSplit('1,2,3,4,5,6,7,8',',') x ) s where s.a not in(SELECT Type FROM LotteryCompany WHERE [Type]=@GiftType AND cpMainID=@cpMainID)
  5629. END
  5630. ELSE
  5631. BEGIN
  5632. IF (SELECT COUNT(1) FROM LotteryCompany WHERE [Type]=@GiftType AND cpMainID=@cpMainID)>1 --重复抽到了一次
  5633. SELECT TOP 1 @GiftType = s.a FROM (SELECT * FROM dbo.FnSplit('1,2,3,4,5,6,7,8',',') x ) s where s.a not in(SELECT Type FROM LotteryCompany WHERE [Type]=@GiftType AND cpMainID=@cpMainID)
  5634. END
  5635. IF @GiftType IN (10,11) AND EXISTS(SELECT TOP 1 'x' FROM LotteryCompany WHERE [Type]=@GiftType AND cpMainID=@cpMainID) --重复抽到了
  5636. SET @GiftType = 1
  5637. IF @GiftType IN (10,11) --本月开通的非年度的才赠送
  5638. IF NOT EXISTS(SELECT TOP 1 'x' FROM caOrder WITH(NOLOCK)
  5639. WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany WITH(NOLOCK)
  5640. WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID
  5641. ORDER BY ID DESC)
  5642. AND dcFeeDetailId in (SELECT id FROM dcVipDetail WITH(NOLOCK) WHERE [Month]<12)
  5643. AND orderType=8
  5644. AND OpenDate>'2015-10-1'
  5645. AND Paid>0
  5646. ) OR EXISTS(SELECT TOP 1 'x' FROM caOrder WITH(NOLOCK)
  5647. WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany WITH(NOLOCK)
  5648. WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID
  5649. ORDER BY ID DESC)
  5650. AND dcFeeDetailId in (SELECT id FROM dcVipDetail WITH(NOLOCK) WHERE [Month]>=12)
  5651. AND orderType=8
  5652. AND OpenDate>'2015-10-1'
  5653. )
  5654. SET @GiftType = 1
  5655. /*---------****************自动提交订单**************-------------*/
  5656. DECLARE @ProvinceID INT
  5657. DECLARE @PayMethod INT --取上次订单的付款方式
  5658. DECLARE @LinkMan NVARCHAR(50)
  5659. DECLARE @Telephone NVARCHAR(50)
  5660. DECLARE @CompanyName NVARCHAR(50)
  5661. DECLARE @Accounts NUMERIC(18,2)
  5662. DECLARE @dcFeeDetailsID INT
  5663. DECLARE @Manageruserid INT
  5664. DECLARE @MemberType INT
  5665. DECLARE @MainOrderID INT
  5666. DECLARE @MainEndDate SMALLDATETIME
  5667. DECLARE @InvoiceCompany NVARCHAR(50)
  5668. DECLARE @Hour INT
  5669. DECLARE @Minute INT
  5670. DECLARE @Code VARCHAR(10)
  5671. DECLARE @RegDate DATETIME
  5672. SELECT TOP 1
  5673. @ProvinceID = b.dcProvinceID,
  5674. @PayMethod = c.PayMethod,
  5675. @MemberType = MemberType,
  5676. @LinkMan = LinkMan,
  5677. @Telephone = Telephone,
  5678. @CompanyName = CompanyName,
  5679. @InvoiceCompany = InvoiceCompany,
  5680. @Manageruserid = ConsultantID,
  5681. @RegDate = RegDate
  5682. FROM cpMain b ,caOrder c
  5683. WHERE b.id =c.cpmainid
  5684. AND c.cpMainID = @cpMainID
  5685. AND Paid>0
  5686. ORDER BY c.ID DESC
  5687. SELECT @Hour = DATEPART(HOUR,@RegDate)
  5688. SELECT @Minute = DATEPART(Minute,@RegDate)
  5689. SET @Code = CONVERT(VARCHAR(10),@Hour*100+@Minute)
  5690. SET @PayMethod = 7
  5691. DECLARE @NewOrderID INT
  5692. IF @GiftType= 1 AND @MemberType=3 --自动提交50个职位并发数的订单
  5693. BEGIN
  5694. --取原价和对应的资费ID
  5695. SELECT TOP 1 @Accounts = b.Price * 50,
  5696. @dcFeeDetailsID = a.ID
  5697. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  5698. WHERE b.type = 10
  5699. AND a.dcFeeID = b.ID
  5700. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  5701. AND ((MinValue<=50 AND MaxValue>=50) OR (MinValue<=50 AND MaxValue=0))
  5702. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5703. SELECT TOP 1 @MainOrderID = ID ,@MainEndDate=EndDate FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND OpenDate IS NOT NULL AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
  5704. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5705. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
  5706. VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
  5707. 10,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,50,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,GETDATE(),@MainEndDate,GETDATE(),119,4)
  5708. SET @NewOrderID = @@IDENTITY
  5709. UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
  5710. END
  5711. ELSE IF @GiftType = 5 --自动提交4周1/6图片 广告
  5712. BEGIN
  5713. --取原价和对应的资费ID
  5714. SELECT TOP 1 @Accounts = b.Price * 4,
  5715. @dcFeeDetailsID = a.ID
  5716. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  5717. WHERE b.type = 4
  5718. AND a.dcFeeID = b.ID
  5719. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  5720. AND ((MinValue<=4 AND MaxValue>=4) OR (MinValue<=4 AND MaxValue=0))
  5721. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5722. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5723. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
  5724. VALUES(@cpMainID,@ProvinceID,6,4,@PayMethod,0,
  5725. 4,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
  5726. SET @NewOrderID = @@IDENTITY
  5727. END
  5728. ELSE IF @GiftType = 9 --自动提交4周2/6图片 广告
  5729. BEGIN
  5730. --取原价和对应的资费ID
  5731. SELECT TOP 1 @Accounts = b.Price * 4,
  5732. @dcFeeDetailsID = a.ID
  5733. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  5734. WHERE b.type = 4
  5735. AND a.dcFeeID = b.ID
  5736. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  5737. AND ((MinValue<=4 AND MaxValue>=4) OR (MinValue<=4 AND MaxValue=0))
  5738. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5739. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5740. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
  5741. VALUES(@cpMainID,@ProvinceID,7,4,@PayMethod,0,
  5742. 4,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
  5743. SET @NewOrderID = @@IDENTITY
  5744. END
  5745. ELSE IF @GiftType = 2 AND @MemberType=3 --自动提交50简历下载订单
  5746. BEGIN
  5747. --取原价和对应的资费ID
  5748. SELECT TOP 1 @Accounts = b.Price * 50,
  5749. @dcFeeDetailsID = a.ID
  5750. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  5751. WHERE b.type = 9
  5752. AND a.dcFeeID = b.ID
  5753. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  5754. AND ((MinValue<=50 AND MaxValue>=50) OR (MinValue<=50 AND MaxValue=0))
  5755. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5756. IF @dcFeeDetailsID IS NULL
  5757. SELECT TOP 1 @Accounts = Price * 50
  5758. FROM dcFee WITH(NOLOCK)
  5759. WHERE type = 9
  5760. AND dcProvinceID = LEFT(@ProvinceID,2)
  5761. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5762. SELECT TOP 1 @MainOrderID = ID,@MainEndDate=EndDate FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND OpenDate IS NOT NULL AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
  5763. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5764. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate)
  5765. VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
  5766. 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,50,50,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,GETDATE(),@MainEndDate)
  5767. SET @NewOrderID = @@IDENTITY
  5768. --UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
  5769. END
  5770. ELSE IF @GiftType = 3 AND @MemberType=3 --自动提交100简历下载订单
  5771. BEGIN
  5772. --取原价和对应的资费ID
  5773. SELECT TOP 1 @Accounts = b.Price * 100,
  5774. @dcFeeDetailsID = a.ID
  5775. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  5776. WHERE b.type = 9
  5777. AND a.dcFeeID = b.ID
  5778. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  5779. AND ((MinValue<=100 AND MaxValue>=100) OR (MinValue<=100 AND MaxValue=0))
  5780. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5781. IF @dcFeeDetailsID IS NULL
  5782. SELECT TOP 1 @Accounts = Price * 100
  5783. FROM dcFee WITH(NOLOCK)
  5784. WHERE type = 9
  5785. AND dcProvinceID = LEFT(@ProvinceID,2)
  5786. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5787. SELECT TOP 1 @MainOrderID = ID,@MainEndDate=EndDate FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND OpenDate IS NOT NULL AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
  5788. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5789. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate)
  5790. VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
  5791. 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,100,100,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,GETDATE(),@MainEndDate)
  5792. SET @NewOrderID = @@IDENTITY
  5793. --UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
  5794. END
  5795. ELSE IF @GiftType = 4 AND @MemberType=3 --自动提交200简历下载订单
  5796. BEGIN
  5797. --取原价和对应的资费ID
  5798. SELECT TOP 1 @Accounts = b.Price * 200,
  5799. @dcFeeDetailsID = a.ID
  5800. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  5801. WHERE b.type = 9
  5802. AND a.dcFeeID = b.ID
  5803. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  5804. AND ((MinValue<=50 AND MaxValue>=200) OR (MinValue<=200 AND MaxValue=0))
  5805. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5806. IF @dcFeeDetailsID IS NULL
  5807. SELECT TOP 1 @Accounts = Price * 200
  5808. FROM dcFee WITH(NOLOCK)
  5809. WHERE type = 9
  5810. AND dcProvinceID = LEFT(@ProvinceID,2)
  5811. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5812. SELECT TOP 1 @MainOrderID = ID,@MainEndDate=EndDate FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND OpenDate IS NOT NULL AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
  5813. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5814. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate)
  5815. VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
  5816. 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,200,200,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,GETDATE(),@MainEndDate)
  5817. SET @NewOrderID = @@IDENTITY
  5818. --UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
  5819. END
  5820. ELSE IF @GiftType =6 --自动提交2周固定位置订单
  5821. BEGIN
  5822. --取原价和对应的资费ID
  5823. SELECT TOP 1 @Accounts = b.Price * 2,
  5824. @dcFeeDetailsID = a.ID
  5825. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  5826. WHERE b.type = 7
  5827. AND a.dcFeeID = b.ID
  5828. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  5829. AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
  5830. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5831. DECLARE @FixBeginDate SMALLDATETIME
  5832. --取最后一个固定位置的订单
  5833. SELECT TOP 1 @FixBeginDate=EndDate FROM caOrder WHERE cpMainID=@cpMainID AND OrderType=7 AND OpenDate IS NOT NULL AND EndDate>GETDATE() ORDER BY ID DESC
  5834. SET @FixBeginDate=ISNULL(@FixBeginDate,GETDATE())
  5835. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5836. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
  5837. VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
  5838. 7,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,@FixBeginDate,DATEADD(day,14,@FixBeginDate),GETDATE(),119,4)
  5839. SET @NewOrderID = @@IDENTITY
  5840. UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
  5841. --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,7,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
  5842. END
  5843. ELSE IF @GiftType = 7 --自动提交2周职位置顶订单,职位默认取最新发布的,前台企业选择后再修改
  5844. BEGIN
  5845. --取原价和对应的资费ID
  5846. SELECT TOP 1 @Accounts = b.Price * 2,
  5847. @dcFeeDetailsID = a.ID
  5848. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  5849. WHERE b.type = 22
  5850. AND a.dcFeeID = b.ID
  5851. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  5852. AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
  5853. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5854. DECLARE @JobID INT
  5855. SELECT @JobID = ID FROM Job WITH(NOLOCK) WHERE Valid = 1 AND cpMainID= @cpMainID AND ID NOT IN(SELECT Balance FROM caOrder WITH(NOLOCK) WHERE OrderType=12 AND BeginDate>GETDATE() AND EndDate<GETDATE() )
  5856. IF @JobID >0
  5857. BEGIN
  5858. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5859. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
  5860. VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
  5861. 12,@Accounts,0,@JobID,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
  5862. SET @NewOrderID = @@IDENTITY
  5863. --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,12,@Accounts,0,@JobID,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
  5864. END
  5865. END
  5866. ELSE IF @GiftType = 8 --自动提交2周职位刷新订单
  5867. BEGIN
  5868. --取原价和对应的资费ID
  5869. SELECT TOP 1 @Accounts = b.Price * 2,
  5870. @dcFeeDetailsID = a.ID
  5871. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  5872. WHERE b.type = 24
  5873. AND a.dcFeeID = b.ID
  5874. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  5875. AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
  5876. AND StartDate < GETDATE() AND EndDate > GETDATE()
  5877. DECLARE @RefreshBeginDate SMALLDATETIME
  5878. --取最后一个固定位置的订单
  5879. SELECT TOP 1 @RefreshBeginDate=EndDate FROM caOrder WHERE cpMainID=@cpMainID AND OrderType=13 AND OpenDate IS NOT NULL AND EndDate>GETDATE() ORDER BY ID DESC
  5880. SET @RefreshBeginDate=ISNULL(@RefreshBeginDate,GETDATE())
  5881. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5882. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
  5883. VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
  5884. 13,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,@RefreshBeginDate,DATEADD(day,14,@RefreshBeginDate),GETDATE(),119,4)
  5885. SET @NewOrderID = @@IDENTITY
  5886. UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
  5887. --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,13,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
  5888. END
  5889. ELSE IF @GiftType = 10 --自动提交VIP订单
  5890. BEGIN
  5891. DECLARE @ActiveQuota INT
  5892. DECLARE @JobNumber INT
  5893. DECLARE @UserNumber INT
  5894. --取本省份价格最便宜的季度套餐
  5895. SELECT TOP 1 @dcFeeDetailsID = b.ID,
  5896. @Accounts = (a.PriceMonth * b.[Month]+b.ResumeNumber*a.PriceResume+JobNumber*a.PriceJob+UserNumber*a.PriceUser),
  5897. @ActiveQuota = b.ResumeNumber,
  5898. @JobNumber = b.JobNumber,
  5899. @UserNumber = b.UserNumber
  5900. FROM dcVip a WITH(NOLOCK),dcVipDetail b WITH(NOLOCK)
  5901. WHERE a.id = b.dcVipId
  5902. AND dcProvinceid=@ProvinceID
  5903. AND b.[Month]=3
  5904. AND startDate<GETDATE()
  5905. AND enddate > GETDATE()
  5906. ORDER BY Price
  5907. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5908. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
  5909. VALUES(@cpMainID,@ProvinceID,null,NULL,@PayMethod,@UserNumber,
  5910. 8,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,@ActiveQuota,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
  5911. SET @NewOrderID = @@IDENTITY
  5912. --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,0,@PayMethod,8,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,@UserNumber,@dcFeeDetailsID
  5913. END
  5914. ELSE IF @GiftType = 11 --自动提交 1:1赠送
  5915. BEGIN
  5916. ---取最新有赠送抽奖次数的订单
  5917. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5918. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
  5919. SELECT cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  5920. OrderType,Accounts,0,0,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,ActiveQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,0
  5921. FROM caOrder WITH(NOLOCK)
  5922. WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID ORDER BY ID DESC)
  5923. SET @NewOrderID = @@IDENTITY
  5924. END
  5925. BEGIN TRY
  5926. IF @GiftType<>12
  5927. BEGIN
  5928. --奖品类型:1、50职位并发 2、50份简历 3、100份简历 4、200份简历 5、4周六分之一图片 6、2周文字广告 7、2周职位置顶
  5929. --8、2周职位自动刷新 9、4周六分之二 10、Vip会员—季度 11、1:1的赠送
  5930. DECLARE @GiftName VARCHAR(50)
  5931. IF @GiftType =1
  5932. BEGIN
  5933. SET @GiftName = '50职位并发'
  5934. END
  5935. ELSE IF @GiftType =2
  5936. BEGIN
  5937. SET @GiftName = '50份简历'
  5938. END
  5939. ELSE IF @GiftType =3
  5940. BEGIN
  5941. SET @GiftName = '100份简历'
  5942. END
  5943. ELSE IF @GiftType =4
  5944. BEGIN
  5945. SET @GiftName = '200份简历 '
  5946. END
  5947. ELSE IF @GiftType =5
  5948. BEGIN
  5949. SET @GiftName = '4周六分之一图片广告'
  5950. END
  5951. ELSE IF @GiftType =6
  5952. BEGIN
  5953. SET @GiftName = '2周文字广告'
  5954. END
  5955. ELSE IF @GiftType =7
  5956. BEGIN
  5957. SET @GiftName = '2周职位置顶'
  5958. END
  5959. ELSE IF @GiftType =8
  5960. BEGIN
  5961. SET @GiftName = '2周职位自动刷新'
  5962. END
  5963. ELSE IF @GiftType =9
  5964. BEGIN
  5965. SET @GiftName = '4周六分之二'
  5966. END
  5967. ELSE IF @GiftType =10
  5968. BEGIN
  5969. SET @GiftName = 'Vip会员—季度'
  5970. END
  5971. ELSE
  5972. BEGIN
  5973. SET @GiftName = '1:1的赠送'
  5974. END
  5975. IF @Manageruserid IS NULL
  5976. BEGIN
  5977. INSERT INTO rtxnotifylog
  5978. SELECT STUFF((SELECT ','+LTRIM(x.ID) FROM Manageruser x WHERE ID IN (180,181,182) FOR XML PATH('')),1,1,'')
  5979. ,'中奖通知',@CompanyName+'('+LTRIM(STR(@cpMainID))+')中奖了,奖品为['+@GiftName+'],请及时处理http://sysback.51rc.com/yehgiiaovbjkaie871/cp/cpMainInfo.asp?id='+LTRIM(STR(@cpMainID))+'&code='+@Code,1,0,0,null,getdate()
  5980. END
  5981. ELSE
  5982. BEGIN
  5983. INSERT INTO rtxnotifylog
  5984. SELECT @Manageruserid
  5985. ,'中奖通知',@CompanyName+'('+LTRIM(STR(@cpMainID))+')中奖了,奖品为['+@GiftName+'],请及时处理http://sysback.51rc.com/yehgiiaovbjkaie871/cp/cpMainInfo.asp?id='+LTRIM(STR(@cpMainID))+'&code='+@Code,1,0,0,null,getdate()
  5986. END
  5987. Update caOrder Set InvoiceConfirmDate=GetDate(),InvoiceConfirmMan=119,InvoiceAskDate=Null,NeedInvoice=0 Where ID=@NewOrderID
  5988. END
  5989. END TRY
  5990. BEGIN CATCH
  5991. END CATCH
  5992. --更新LotteryCompany,保存订单号和中奖类型
  5993. UPDATE LotteryCompany SET GiftOrderID=@NewOrderID,[type]=@GiftType WHERE ID= @LotteryID
  5994. RETURN @GiftType
  5995. END
  5996. GO
  5997. /****** Object: StoredProcedure [dbo].[ccLotteryCompanyUpdate2014] Script Date: 2018/12/13 19:07:12 ******/
  5998. SET ANSI_NULLS ON
  5999. GO
  6000. SET QUOTED_IDENTIFIER ON
  6001. GO
  6002. --创建人:lambo
  6003. --创建时间:2014-9-29
  6004. --企业14周年抽奖
  6005. --奖项内容: 平时 10月8日、18日、28日
  6006. -- 20职位并发 15% 20%
  6007. -- 2周图片 10% 10%
  6008. -- 50份简历 30% 30%
  6009. -- 2周文字广告 5% 5%
  6010. -- 2周职位置顶 5% 5%
  6011. -- 2周职位自动刷新 10% 10%
  6012. -- Vip会员—季度 0% 5%(至少有一个,不能重复 )
  6013. -- 1:1的赠送 0% 1%(至少有一个,不能重复,如果是年度的不能抽到)
  6014. -- 学习卡 5% 4%(至少有一个,不能重复)
  6015. -- 空奖 20% 10%
  6016. -- 保险公司,抽奖中奖概率调整为10%
  6017. --修改人:nick
  6018. --修改时间:2014-10-10
  6019. --修改内容:发送rtx消息,加入奖品名称
  6020. CREATE PROCEDURE [dbo].[ccLotteryCompanyUpdate2014]
  6021. (
  6022. @caMainID INT
  6023. )
  6024. AS
  6025. BEGIN
  6026. DECLARE @LotteryID INT
  6027. DECLARE @cpMainID INT
  6028. SELECT TOP 1 @LotteryID = ID,@cpMainID = cpMainID FROM LotteryCompany WITH(NOLOCK) WHERE Used = 0 AND cpMainID = (select cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID AND AccountType=1)
  6029. IF @LotteryID IS NULL
  6030. RETURN -1 --没有抽奖次数
  6031. UPDATE LotteryCompany SET Used = 1,LotteryDate=GETDATE() WHERE ID = @LotteryID --更新状态 防止重复抽奖
  6032. ------------------****************生成抽奖结果****************-----------------
  6033. DECLARE @IsAgent INT --是否是保险公司
  6034. SELECT top 1 @IsAgent = IsAgent FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
  6035. DECLARE @Today VARCHAR(4) --用于判断 是否是10月8日、18日、28日
  6036. SELECT @Today = RIGHT(CONVERT(VARCHAR(8) , GETDATE() , 112) , 4)
  6037. DECLARE @GiftNo INT
  6038. SELECT @GiftNo = CAST((RAND()*999+1) AS INT) --生成抽奖的数字
  6039. --奖品类型:1、20职位并发 2、2周图片 3、50份简历 4、2周文字广告 5、2周职位置顶 6、2周职位自动刷新 7、Vip会员—季度 8、1:1的赠送 9、空奖 10、学习卡
  6040. DECLARE @GiftType INT
  6041. IF @IsAgent = 0
  6042. BEGIN
  6043. IF @GiftNo BETWEEN 51 AND 200 OR (@GiftNo BETWEEN 201 AND 250 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' )) --51-200之间 职位并发 15%概率
  6044. SET @GiftType = 1
  6045. ELSE IF @GiftNo BETWEEN 251 AND 350 --251-350之间 2周图片 10%概率
  6046. SET @GiftType = 2
  6047. ELSE IF @GiftNo BETWEEN 351 AND 650 --351-650之间 50简历下载 30%概率
  6048. SET @GiftType = 3
  6049. ELSE IF @GiftNo BETWEEN 651 AND 700 --651-700之间 两周文字广告 5%概率
  6050. SET @GiftType = 4
  6051. ELSE IF @GiftNo BETWEEN 701 AND 750 --701-750之间 两周职位置顶 5%概率
  6052. SET @GiftType = 5
  6053. ELSE IF @GiftNo BETWEEN 751 AND 850 --751-850之间 两周职位刷新 10%概率
  6054. SET @GiftType = 6
  6055. ELSE IF @GiftNo BETWEEN 851 AND 900 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' ) --0-50之间 Vip会员—季度 5%概率
  6056. SET @GiftType = 7
  6057. ELSE IF @GiftNo BETWEEN 951 AND 960 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' ) --951-1000之间 1:1赠送 1%概率
  6058. SET @GiftType = 8
  6059. ELSE IF @GiftNo BETWEEN 961 AND 1000 OR (@GiftNo BETWEEN 910 AND 920 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' )) --学习卡 4%概率
  6060. SET @GiftType = 10
  6061. ELSE --空奖 20%概率
  6062. SET @GiftType = 9
  6063. END
  6064. ELSE -- 保险公司中奖概率10%
  6065. BEGIN
  6066. IF @GiftNo BETWEEN 61 AND 81 --61-80之间 职位并发 15%概率
  6067. SET @GiftType = 1
  6068. ELSE IF @GiftNo BETWEEN 281 AND 310 --281-310之间 2周图片 不能被抽到
  6069. SET @GiftType = 9
  6070. ELSE IF @GiftNo BETWEEN 581 AND 590 --581-590之间 50简历下载 30%概率
  6071. SET @GiftType = 3
  6072. ELSE IF @GiftNo BETWEEN 661 AND 665 --661-665 两周文字广告 不能被抽到
  6073. SET @GiftType = 9
  6074. ELSE IF @GiftNo BETWEEN 731 AND 735 --731-735 两周职位置顶 5%概率
  6075. SET @GiftType = 5
  6076. ELSE IF @GiftNo BETWEEN 761 AND 770 --761-770 两周职位刷新 10%概率
  6077. SET @GiftType = 6
  6078. ELSE IF @GiftNo = 851 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' )
  6079. SET @GiftType = 7
  6080. ELSE IF @GiftNo = 951 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' )
  6081. SET @GiftType = 8
  6082. ELSE IF @GiftNo BETWEEN 961 AND 966
  6083. SET @GiftType = 10
  6084. ELSE --空奖 20%概率
  6085. SET @GiftType = 9
  6086. END
  6087. IF GETDATE()>'2014-11-1'
  6088. SET @GiftType = 9
  6089. /*---------****************抽奖结果处理,判断是否合理,重复 **************-------------*/
  6090. IF (@GiftType =7 OR @GiftType = 8) AND NOT (@Today = '1008' OR @Today = '1018' OR @Today = '1028' ) --不是带8的日子不能抽到
  6091. SET @GiftType = 1
  6092. IF @GiftType IN (7,8,10) AND EXISTS(SELECT TOP 1 'x' FROM LotteryCompany WHERE [Type]=@GiftType AND cpMainID=@cpMainID) --重复抽到了
  6093. SET @GiftType = 1
  6094. IF @GiftType =8 --本月开通的非年度的才赠送
  6095. IF NOT EXISTS(SELECT TOP 1 'x' FROM caOrder WITH(NOLOCK)
  6096. WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany WITH(NOLOCK)
  6097. WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID
  6098. ORDER BY ID DESC)
  6099. AND dcFeeDetailId in (SELECT id FROM dcVipDetail WITH(NOLOCK) WHERE [Month]<12)
  6100. AND orderType=8
  6101. AND OpenDate>'2014-10-1'
  6102. AND Paid>0
  6103. ) OR EXISTS(SELECT TOP 1 'x' FROM caOrder WITH(NOLOCK)
  6104. WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany WITH(NOLOCK)
  6105. WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID
  6106. ORDER BY ID DESC)
  6107. AND dcFeeDetailId in (SELECT id FROM dcVipDetail WITH(NOLOCK) WHERE [Month]>=12)
  6108. AND orderType=8
  6109. AND OpenDate>'2014-10-1'
  6110. )
  6111. SET @GiftType = 1
  6112. IF @GiftType =7 --本月开通的会员的才赠送
  6113. IF NOT EXISTS(SELECT TOP 1 'x' FROM caOrder WITH(NOLOCK)
  6114. WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany WITH(NOLOCK)
  6115. WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID
  6116. ORDER BY ID DESC)
  6117. AND orderType=8
  6118. AND OpenDate>'2014-10-1'
  6119. AND Paid>0
  6120. )
  6121. SET @GiftType = 1
  6122. DECLARE @GiftCount INT
  6123. SELECT @GiftCount = COUNT(*) FROM LotteryCompany WHERE cpMainID=@cpMainID and [type]<>9 and used=1
  6124. --年度、双年度以上最多中奖为8次,最多中8次奖。
  6125. IF @GiftCount>=8
  6126. BEGIN
  6127. SET @GiftType = 9
  6128. END
  6129. ELSE IF @GiftCount>=5 --季度、半年度最多中奖为5次。
  6130. BEGIN
  6131. IF NOT EXISTS(SELECT TOP 1 'x' FROM caOrder WITH(NOLOCK)
  6132. WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany WITH(NOLOCK)
  6133. WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID
  6134. ORDER BY ID DESC)
  6135. AND dcFeeDetailId in (SELECT id FROM dcVipDetail WITH(NOLOCK) WHERE [Month]>=12)
  6136. AND orderType=8)
  6137. BEGIN
  6138. SET @GiftType = 9
  6139. END
  6140. END
  6141. ELSE IF @GiftCount>=3 --如果当月没有购买会员,仅进行连续登陆,那么最多中奖为3次。
  6142. BEGIN
  6143. IF NOT EXISTS(SELECT TOP 1 'x' FROM caOrder WITH(NOLOCK)
  6144. WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany WITH(NOLOCK)
  6145. WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID
  6146. ORDER BY ID DESC)
  6147. AND dcFeeDetailId in (SELECT id FROM dcVipDetail WITH(NOLOCK) WHERE [Month]>=3)
  6148. AND orderType=8)
  6149. BEGIN
  6150. SET @GiftType = 9
  6151. END
  6152. END
  6153. IF @GiftType = 10
  6154. BEGIN
  6155. DECLARE @GiftCardCount INT
  6156. SELECT @GiftCardCount = COUNT(*) FROM LotteryCompany WHERE [type] =10 and used=1
  6157. IF @GiftCardCount>=80
  6158. SET @GiftType = 9
  6159. END
  6160. IF @cpMainID =371108
  6161. BEGIN
  6162. SET @GiftType = 6
  6163. END
  6164. /*---------****************自动提交订单**************-------------*/
  6165. DECLARE @ProvinceID INT
  6166. DECLARE @PayMethod INT --取上次订单的付款方式
  6167. DECLARE @LinkMan NVARCHAR(50)
  6168. DECLARE @Telephone NVARCHAR(50)
  6169. DECLARE @CompanyName NVARCHAR(50)
  6170. DECLARE @Accounts NUMERIC(18,2)
  6171. DECLARE @dcFeeDetailsID INT
  6172. DECLARE @Manageruserid INT
  6173. DECLARE @MemberType INT
  6174. DECLARE @MainOrderID INT
  6175. DECLARE @MainEndDate SMALLDATETIME
  6176. DECLARE @InvoiceCompany NVARCHAR(50)
  6177. DECLARE @Hour INT
  6178. DECLARE @Minute INT
  6179. DECLARE @Code VARCHAR(10)
  6180. DECLARE @RegDate DATETIME
  6181. SELECT TOP 1
  6182. @ProvinceID = b.dcProvinceID,
  6183. @PayMethod = c.PayMethod,
  6184. @MemberType = MemberType,
  6185. @LinkMan = LinkMan,
  6186. @Telephone = Telephone,
  6187. @CompanyName = CompanyName,
  6188. @InvoiceCompany = InvoiceCompany,
  6189. @Manageruserid = ConsultantID,
  6190. @RegDate = RegDate
  6191. FROM cpMain b ,caOrder c
  6192. WHERE b.id =c.cpmainid
  6193. AND c.cpMainID = @cpMainID
  6194. AND Paid>0
  6195. ORDER BY c.ID DESC
  6196. SELECT @Hour = DATEPART(HOUR,@RegDate)
  6197. SELECT @Minute = DATEPART(Minute,@RegDate)
  6198. SET @Code = CONVERT(VARCHAR(10),@Hour*100+@Minute)
  6199. SET @PayMethod = 7
  6200. DECLARE @NewOrderID INT
  6201. IF @GiftType= 1 AND @MemberType=3 --自动提交20个职位并发数的订单
  6202. BEGIN
  6203. --取原价和对应的资费ID
  6204. SELECT TOP 1 @Accounts = b.Price * 10,
  6205. @dcFeeDetailsID = a.ID
  6206. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  6207. WHERE b.type = 10
  6208. AND a.dcFeeID = b.ID
  6209. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  6210. AND ((MinValue<=20 AND MaxValue>=20) OR (MinValue<=20 AND MaxValue=0))
  6211. AND StartDate < GETDATE() AND EndDate > GETDATE()
  6212. SELECT TOP 1 @MainOrderID = ID ,@MainEndDate=EndDate FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND OpenDate IS NOT NULL AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
  6213. --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,0, 32, NULL,NULL,@PayMethod,10,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,10,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
  6214. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  6215. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
  6216. VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
  6217. 10,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,20,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,GETDATE(),@MainEndDate,GETDATE(),119,4)
  6218. SET @NewOrderID = @@IDENTITY
  6219. UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
  6220. END
  6221. ELSE IF @GiftType = 2 --自动提交2周1/6图片 广告
  6222. BEGIN
  6223. --取原价和对应的资费ID
  6224. SELECT TOP 1 @Accounts = b.Price * 2,
  6225. @dcFeeDetailsID = a.ID
  6226. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  6227. WHERE b.type = 4
  6228. AND a.dcFeeID = b.ID
  6229. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  6230. AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
  6231. AND StartDate < GETDATE() AND EndDate > GETDATE()
  6232. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  6233. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
  6234. VALUES(@cpMainID,@ProvinceID,6,2,@PayMethod,0,
  6235. 4,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
  6236. SET @NewOrderID = @@IDENTITY
  6237. --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,7,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
  6238. END
  6239. ELSE IF @GiftType = 3 AND @MemberType=3 --自动提交50简历下载订单
  6240. BEGIN
  6241. --取原价和对应的资费ID
  6242. SELECT TOP 1 @Accounts = b.Price * 50,
  6243. @dcFeeDetailsID = a.ID
  6244. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  6245. WHERE b.type = 9
  6246. AND a.dcFeeID = b.ID
  6247. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  6248. AND ((MinValue<=50 AND MaxValue>=50) OR (MinValue<=50 AND MaxValue=0))
  6249. AND StartDate < GETDATE() AND EndDate > GETDATE()
  6250. IF @dcFeeDetailsID IS NULL
  6251. SELECT TOP 1 @Accounts = Price * 50
  6252. FROM dcFee WITH(NOLOCK)
  6253. WHERE type = 9
  6254. AND dcProvinceID = LEFT(@ProvinceID,2)
  6255. AND StartDate < GETDATE() AND EndDate > GETDATE()
  6256. SELECT TOP 1 @MainOrderID = ID,@MainEndDate=EndDate FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND OpenDate IS NOT NULL AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
  6257. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  6258. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate)
  6259. VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
  6260. 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,50,50,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,GETDATE(),@MainEndDate)
  6261. SET @NewOrderID = @@IDENTITY
  6262. --UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
  6263. END
  6264. ELSE IF @GiftType = 4 --自动提交2周固定位置订单
  6265. BEGIN
  6266. --取原价和对应的资费ID
  6267. SELECT TOP 1 @Accounts = b.Price * 2,
  6268. @dcFeeDetailsID = a.ID
  6269. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  6270. WHERE b.type = 7
  6271. AND a.dcFeeID = b.ID
  6272. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  6273. AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
  6274. AND StartDate < GETDATE() AND EndDate > GETDATE()
  6275. DECLARE @FixBeginDate SMALLDATETIME
  6276. --取最后一个固定位置的订单
  6277. SELECT TOP 1 @FixBeginDate=EndDate FROM caOrder WHERE cpMainID=@cpMainID AND OrderType=7 AND OpenDate IS NOT NULL AND EndDate>GETDATE() ORDER BY ID DESC
  6278. SET @FixBeginDate=ISNULL(@FixBeginDate,GETDATE())
  6279. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  6280. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
  6281. VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
  6282. 7,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,@FixBeginDate,DATEADD(day,14,@FixBeginDate),GETDATE(),119,4)
  6283. SET @NewOrderID = @@IDENTITY
  6284. UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
  6285. --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,7,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
  6286. END
  6287. ELSE IF @GiftType = 5 --自动提交2周职位置顶订单,职位默认取最新发布的,前台企业选择后再修改
  6288. BEGIN
  6289. --取原价和对应的资费ID
  6290. SELECT TOP 1 @Accounts = b.Price * 2,
  6291. @dcFeeDetailsID = a.ID
  6292. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  6293. WHERE b.type = 22
  6294. AND a.dcFeeID = b.ID
  6295. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  6296. AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
  6297. AND StartDate < GETDATE() AND EndDate > GETDATE()
  6298. DECLARE @JobID INT
  6299. SELECT @JobID = ID FROM Job WITH(NOLOCK) WHERE Valid = 1 AND cpMainID= @cpMainID AND ID NOT IN(SELECT Balance FROM caOrder WITH(NOLOCK) WHERE OrderType=12 AND BeginDate>GETDATE() AND EndDate<GETDATE() )
  6300. IF @JobID >0
  6301. BEGIN
  6302. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  6303. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
  6304. VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
  6305. 12,@Accounts,0,@JobID,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
  6306. SET @NewOrderID = @@IDENTITY
  6307. --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,12,@Accounts,0,@JobID,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
  6308. END
  6309. END
  6310. ELSE IF @GiftType = 6 --自动提交2周职位刷新订单
  6311. BEGIN
  6312. --取原价和对应的资费ID
  6313. SELECT TOP 1 @Accounts = b.Price * 2,
  6314. @dcFeeDetailsID = a.ID
  6315. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  6316. WHERE b.type = 24
  6317. AND a.dcFeeID = b.ID
  6318. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  6319. AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
  6320. AND StartDate < GETDATE() AND EndDate > GETDATE()
  6321. DECLARE @RefreshBeginDate SMALLDATETIME
  6322. --取最后一个固定位置的订单
  6323. SELECT TOP 1 @RefreshBeginDate=EndDate FROM caOrder WHERE cpMainID=@cpMainID AND OrderType=13 AND OpenDate IS NOT NULL AND EndDate>GETDATE() ORDER BY ID DESC
  6324. SET @RefreshBeginDate=ISNULL(@RefreshBeginDate,GETDATE())
  6325. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  6326. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
  6327. VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
  6328. 13,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,@RefreshBeginDate,DATEADD(day,14,@RefreshBeginDate),GETDATE(),119,4)
  6329. SET @NewOrderID = @@IDENTITY
  6330. UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
  6331. --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,13,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
  6332. END
  6333. ELSE IF @GiftType = 7 --自动提交VIP订单
  6334. BEGIN
  6335. DECLARE @ActiveQuota INT
  6336. DECLARE @JobNumber INT
  6337. DECLARE @UserNumber INT
  6338. --取本省份价格最便宜的季度套餐
  6339. SELECT TOP 1 @dcFeeDetailsID = b.ID,
  6340. @Accounts = (a.PriceMonth * b.[Month]+b.ResumeNumber*a.PriceResume+JobNumber*a.PriceJob+UserNumber*a.PriceUser),
  6341. @ActiveQuota = b.ResumeNumber,
  6342. @JobNumber = b.JobNumber,
  6343. @UserNumber = b.UserNumber
  6344. FROM dcVip a WITH(NOLOCK),dcVipDetail b WITH(NOLOCK)
  6345. WHERE a.id = b.dcVipId
  6346. AND dcProvinceid=@ProvinceID
  6347. AND b.[Month]=3
  6348. AND startDate<GETDATE()
  6349. AND enddate > GETDATE()
  6350. ORDER BY Price
  6351. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  6352. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
  6353. VALUES(@cpMainID,@ProvinceID,null,NULL,@PayMethod,@UserNumber,
  6354. 8,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,@ActiveQuota,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
  6355. SET @NewOrderID = @@IDENTITY
  6356. --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,0,@PayMethod,8,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,@UserNumber,@dcFeeDetailsID
  6357. END
  6358. ELSE IF @GiftType = 8 --自动提交 1:1赠送
  6359. BEGIN
  6360. ---取最新有赠送抽奖次数的订单
  6361. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  6362. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
  6363. SELECT cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  6364. OrderType,Accounts,0,0,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,ActiveQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,0
  6365. FROM caOrder WITH(NOLOCK)
  6366. WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID ORDER BY ID DESC)
  6367. SET @NewOrderID = @@IDENTITY
  6368. END
  6369. BEGIN TRY
  6370. IF @GiftType<>9
  6371. BEGIN
  6372. --奖品类型:1、20职位并发 2、2周图片 3、50份简历 4、2周文字广告 5、2周职位置顶 6、2周职位自动刷新 7、Vip会员—季度 8、1:1的赠送 9、空奖 10、学习卡
  6373. DECLARE @GiftName VARCHAR(50)
  6374. IF @GiftType =1
  6375. BEGIN
  6376. SET @GiftName = '20职位并发'
  6377. END
  6378. ELSE IF @GiftType =2
  6379. BEGIN
  6380. SET @GiftName = '2周图片'
  6381. END
  6382. ELSE IF @GiftType =3
  6383. BEGIN
  6384. SET @GiftName = '50份简历'
  6385. END
  6386. ELSE IF @GiftType =4
  6387. BEGIN
  6388. SET @GiftName = '2周文字广告'
  6389. END
  6390. ELSE IF @GiftType =5
  6391. BEGIN
  6392. SET @GiftName = '2周职位置顶'
  6393. END
  6394. ELSE IF @GiftType =6
  6395. BEGIN
  6396. SET @GiftName = '2周职位自动刷新'
  6397. END
  6398. ELSE IF @GiftType =7
  6399. BEGIN
  6400. SET @GiftName = 'Vip会员—季度'
  6401. END
  6402. ELSE IF @GiftType =8
  6403. BEGIN
  6404. SET @GiftName = '1:1的赠送'
  6405. END
  6406. ELSE IF @GiftType =10
  6407. BEGIN
  6408. SET @GiftName = '学习卡'
  6409. END
  6410. ELSE
  6411. BEGIN
  6412. SET @GiftName = '空奖'
  6413. END
  6414. IF @Manageruserid IS NULL
  6415. BEGIN
  6416. INSERT INTO rtxnotifylog
  6417. SELECT STUFF((SELECT ','+LTRIM(x.ID) FROM Manageruser x WHERE ID IN (180,181,182) FOR XML PATH('')),1,1,'')
  6418. ,'中奖通知',@CompanyName+'('+LTRIM(STR(@cpMainID))+')中奖了,奖品为['+@GiftName+'],请及时处理http://115.182.8.38:81/yehgiiaovbjkaie871/cp/cpMainInfo.asp?id='+LTRIM(STR(@cpMainID))+'&code='+@Code,1,0,0,null,getdate()
  6419. END
  6420. ELSE
  6421. BEGIN
  6422. INSERT INTO rtxnotifylog
  6423. SELECT @Manageruserid
  6424. ,'中奖通知',@CompanyName+'('+LTRIM(STR(@cpMainID))+')中奖了,奖品为['+@GiftName+'],请及时处理http://115.182.8.38:81/yehgiiaovbjkaie871/cp/cpMainInfo.asp?id='+LTRIM(STR(@cpMainID))+'&code='+@Code,1,0,0,null,getdate()
  6425. END
  6426. Update caOrder Set InvoiceConfirmDate=GetDate(),InvoiceConfirmMan=119,InvoiceAskDate=Null,NeedInvoice=0 Where ID=@NewOrderID
  6427. END
  6428. END TRY
  6429. BEGIN CATCH
  6430. END CATCH
  6431. --更新LotteryCompany,保存订单号和中奖类型
  6432. UPDATE LotteryCompany SET GiftOrderID=@NewOrderID,[type]=@GiftType WHERE ID= @LotteryID
  6433. RETURN @GiftType
  6434. END
  6435. GO
  6436. /****** Object: StoredProcedure [dbo].[ccLotteryCompanyUpdate2016] Script Date: 2018/12/13 19:07:12 ******/
  6437. SET ANSI_NULLS ON
  6438. GO
  6439. SET QUOTED_IDENTIFIER ON
  6440. GO
  6441. --创建人:Lucifer
  6442. --创建时间:2016-9-20
  6443. --企业16周年抽奖
  6444. --奖项内容: 平时 10月8日、18日、25日、28日
  6445. --50职位并发 15% 5%
  6446. --50份简历 20% 10%
  6447. --100份简历 15% 20%
  6448. --200份简历 10% 15%
  6449. --4周六分之一图片 10% 15%
  6450. --2周知名企业 10% 10%
  6451. --2周职位置顶 5% 5%
  6452. --2周职位自动刷新 15% 10%
  6453. --4周六分之二图片 0% 8%
  6454. --Vip会员—季度 0% 2%(至少有一个,不能重复)
  6455. --保险公司,培训公司,代理招聘类公司仅能够中奖的范围:职位数、简历数、自动刷新。其他内容不允许抽中。需要在抽选中排除。
  6456. CREATE PROCEDURE [dbo].[ccLotteryCompanyUpdate2016]
  6457. (
  6458. @caMainID INT
  6459. )
  6460. AS
  6461. BEGIN
  6462. DECLARE @LotteryID INT
  6463. DECLARE @cpMainID INT
  6464. SELECT TOP 1 @LotteryID = ID,@cpMainID = cpMainID FROM LotteryCompany WITH(NOLOCK) WHERE Used = 0 AND cpMainID = (select cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID AND AccountType=1)
  6465. IF @LotteryID IS NULL
  6466. RETURN -1 --没有抽奖次数
  6467. UPDATE LotteryCompany SET Used = 1,LotteryDate = GETDATE() WHERE ID = @LotteryID --更新状态 防止重复抽奖
  6468. ------------------****************生成抽奖结果****************-----------------
  6469. DECLARE @IsAgent INT --是否是保险公司
  6470. DECLARE @Name NVARCHAR(200)
  6471. SELECT TOP 1 @IsAgent = IsAgent,@Name = Name FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
  6472. IF @IsAgent = 0
  6473. BEGIN
  6474. IF @Name LIKE '%人寿%' OR @Name LIKE '%保险%'
  6475. SET @IsAgent = 1
  6476. END
  6477. DECLARE @GiftNo INT, @GiftType INT, @LoopCount INT
  6478. SELECT @GiftNo = CAST((RAND()*999+1) AS INT) --生成抽奖的数字
  6479. SELECT @GiftType = dbo.GetLotteryGiftType(@IsAgent, @GiftNo)
  6480. SET @LoopCount = 0
  6481. WHILE EXISTS(SELECT 'X' FROM LotteryCompany WHERE [Type] = @GiftType AND cpMainID = @cpMainID) OR @LoopCount < 1000
  6482. BEGIN
  6483. SELECT @GiftNo = CAST((RAND()*999 + 1) AS INT) --生成抽奖的数字
  6484. SELECT @GiftType = dbo.GetLotteryGiftType(@IsAgent, @GiftNo)
  6485. SET @LoopCount = @LoopCount + 1
  6486. END
  6487. PRINT @GiftType
  6488. /*---------****************自动提交订单**************-------------*/
  6489. DECLARE @ProvinceID INT
  6490. DECLARE @PayMethod INT --取上次订单的付款方式
  6491. DECLARE @LinkMan NVARCHAR(50)
  6492. DECLARE @Telephone NVARCHAR(50)
  6493. DECLARE @CompanyName NVARCHAR(50)
  6494. DECLARE @Accounts NUMERIC(18,2)
  6495. DECLARE @dcFeeDetailsID INT
  6496. DECLARE @Manageruserid INT
  6497. DECLARE @MemberType INT
  6498. DECLARE @MainOrderID INT
  6499. DECLARE @InvoiceCompany NVARCHAR(50)
  6500. DECLARE @Hour INT
  6501. DECLARE @MainEndDate SMALLDATETIME
  6502. DECLARE @Minute INT
  6503. DECLARE @Code VARCHAR(10)
  6504. DECLARE @RegDate DATETIME
  6505. SELECT TOP 1
  6506. @ProvinceID = b.dcProvinceID,
  6507. @PayMethod = c.PayMethod,
  6508. @MemberType = MemberType,
  6509. @LinkMan = LinkMan,
  6510. @Telephone = Telephone,
  6511. @CompanyName = CompanyName,
  6512. @InvoiceCompany = InvoiceCompany,
  6513. @Manageruserid = ConsultantID,
  6514. @RegDate = RegDate
  6515. FROM cpMain b ,caOrder c
  6516. WHERE b.id =c.cpmainid
  6517. AND c.cpMainID = @cpMainID
  6518. AND Paid>0
  6519. ORDER BY c.ID DESC
  6520. SELECT @Hour = DATEPART(HOUR,@RegDate)
  6521. SELECT @Minute = DATEPART(Minute,@RegDate)
  6522. SET @Code = CONVERT(VARCHAR(10),@Hour*100+@Minute)
  6523. SET @PayMethod = 7
  6524. DECLARE @NewOrderID INT
  6525. IF @GiftType= 1 AND @MemberType=3 --自动提交50个职位并发数的订单
  6526. BEGIN
  6527. --取原价和对应的资费ID
  6528. SELECT TOP 1 @Accounts = b.Price * 50,
  6529. @dcFeeDetailsID = a.ID
  6530. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  6531. WHERE b.type = 10
  6532. AND a.dcFeeID = b.ID
  6533. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  6534. AND ((MinValue <= 50 AND MaxValue >= 50) OR (MinValue <= 50 AND MaxValue = 0))
  6535. AND StartDate < GETDATE() AND EndDate > GETDATE()
  6536. SELECT TOP 1 @MainOrderID = ID, @MainEndDate = EndDate FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND OpenDate IS NOT NULL AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
  6537. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  6538. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
  6539. VALUES(@cpMainID,@ProvinceID,NULL,NULL,@PayMethod,0,
  6540. 10,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,50,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,GETDATE(),@MainEndDate,GETDATE(),116,4)
  6541. SET @NewOrderID = @@IDENTITY
  6542. END
  6543. ELSE IF @GiftType = 5 --自动提交4周1/6图片 广告
  6544. BEGIN
  6545. --取原价和对应的资费ID
  6546. SELECT TOP 1 @Accounts = b.Price * 4,
  6547. @dcFeeDetailsID = a.ID
  6548. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  6549. WHERE b.type = 4
  6550. AND a.dcFeeID = b.ID
  6551. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  6552. AND ((MinValue<=4 AND MaxValue>=4) OR (MinValue<=4 AND MaxValue=0))
  6553. AND StartDate < GETDATE() AND EndDate > GETDATE()
  6554. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  6555. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
  6556. VALUES(@cpMainID,@ProvinceID,6,4,@PayMethod,0,
  6557. 4,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
  6558. SET @NewOrderID = @@IDENTITY
  6559. END
  6560. ELSE IF @GiftType = 9 --自动提交4周2/6图片 广告
  6561. BEGIN
  6562. --取原价和对应的资费ID
  6563. SELECT TOP 1 @Accounts = b.Price * 4,
  6564. @dcFeeDetailsID = a.ID
  6565. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  6566. WHERE b.type = 4
  6567. AND a.dcFeeID = b.ID
  6568. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  6569. AND ((MinValue<=4 AND MaxValue>=4) OR (MinValue<=4 AND MaxValue=0))
  6570. AND StartDate < GETDATE() AND EndDate > GETDATE()
  6571. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  6572. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
  6573. VALUES(@cpMainID,@ProvinceID,7,4,@PayMethod,0,
  6574. 4,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
  6575. SET @NewOrderID = @@IDENTITY
  6576. END
  6577. ELSE IF @GiftType = 2 AND @MemberType=3 --自动提交50简历下载订单
  6578. BEGIN
  6579. --取原价和对应的资费ID
  6580. SELECT TOP 1 @Accounts = b.Price * 50,
  6581. @dcFeeDetailsID = a.ID
  6582. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  6583. WHERE b.type = 9
  6584. AND a.dcFeeID = b.ID
  6585. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  6586. AND ((MinValue<=50 AND MaxValue>=50) OR (MinValue<=50 AND MaxValue=0))
  6587. AND StartDate < GETDATE() AND EndDate > GETDATE()
  6588. IF @dcFeeDetailsID IS NULL
  6589. SELECT TOP 1 @Accounts = Price * 50
  6590. FROM dcFee WITH(NOLOCK)
  6591. WHERE type = 9
  6592. AND dcProvinceID = LEFT(@ProvinceID,2)
  6593. AND StartDate < GETDATE() AND EndDate > GETDATE()
  6594. SELECT TOP 1 @MainOrderID = ID FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND OpenDate IS NOT NULL AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
  6595. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  6596. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
  6597. VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
  6598. 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,50,50,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
  6599. SET @NewOrderID = @@IDENTITY
  6600. END
  6601. ELSE IF @GiftType = 3 AND @MemberType=3 --自动提交100简历下载订单
  6602. BEGIN
  6603. --取原价和对应的资费ID
  6604. SELECT TOP 1 @Accounts = b.Price * 100,
  6605. @dcFeeDetailsID = a.ID
  6606. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  6607. WHERE b.type = 9
  6608. AND a.dcFeeID = b.ID
  6609. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  6610. AND ((MinValue<=100 AND MaxValue>=100) OR (MinValue<=100 AND MaxValue=0))
  6611. AND StartDate < GETDATE() AND EndDate > GETDATE()
  6612. IF @dcFeeDetailsID IS NULL
  6613. SELECT TOP 1 @Accounts = Price * 100
  6614. FROM dcFee WITH(NOLOCK)
  6615. WHERE type = 9
  6616. AND dcProvinceID = LEFT(@ProvinceID,2)
  6617. AND StartDate < GETDATE() AND EndDate > GETDATE()
  6618. SELECT TOP 1 @MainOrderID = ID FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND OpenDate IS NOT NULL AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
  6619. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  6620. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
  6621. VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
  6622. 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,100,100,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
  6623. SET @NewOrderID = @@IDENTITY
  6624. END
  6625. ELSE IF @GiftType = 4 AND @MemberType=3 --自动提交200简历下载订单
  6626. BEGIN
  6627. --取原价和对应的资费ID
  6628. SELECT TOP 1 @Accounts = b.Price * 200,
  6629. @dcFeeDetailsID = a.ID
  6630. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  6631. WHERE b.type = 9
  6632. AND a.dcFeeID = b.ID
  6633. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  6634. AND ((MinValue<=50 AND MaxValue>=200) OR (MinValue<=200 AND MaxValue=0))
  6635. AND StartDate < GETDATE() AND EndDate > GETDATE()
  6636. IF @dcFeeDetailsID IS NULL
  6637. SELECT TOP 1 @Accounts = Price * 200
  6638. FROM dcFee WITH(NOLOCK)
  6639. WHERE type = 9
  6640. AND dcProvinceID = LEFT(@ProvinceID,2)
  6641. AND StartDate < GETDATE() AND EndDate > GETDATE()
  6642. SELECT TOP 1 @MainOrderID = ID FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND OpenDate IS NOT NULL AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
  6643. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  6644. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
  6645. VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
  6646. 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,200,200,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
  6647. SET @NewOrderID = @@IDENTITY
  6648. END
  6649. ELSE IF @GiftType = 6 --自动提交2周固定位置订单
  6650. BEGIN
  6651. --取原价和对应的资费ID
  6652. SELECT TOP 1 @Accounts = b.Price * 2,
  6653. @dcFeeDetailsID = a.ID
  6654. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  6655. WHERE b.type = 7
  6656. AND a.dcFeeID = b.ID
  6657. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  6658. AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
  6659. AND StartDate < GETDATE() AND EndDate > GETDATE()
  6660. DECLARE @FixBeginDate SMALLDATETIME
  6661. --取最后一个固定位置的订单
  6662. SELECT TOP 1 @FixBeginDate=EndDate FROM caOrder WHERE cpMainID=@cpMainID AND OrderType=7 AND OpenDate IS NOT NULL AND EndDate>GETDATE() ORDER BY ID DESC
  6663. SET @FixBeginDate=ISNULL(@FixBeginDate,GETDATE())
  6664. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  6665. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
  6666. VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
  6667. 7,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,@FixBeginDate,DATEADD(DAY,14,@FixBeginDate),GETDATE(),116,4)
  6668. SET @NewOrderID = @@IDENTITY
  6669. END
  6670. ELSE IF @GiftType = 7 --自动提交2周职位置顶订单,职位默认取最新发布的,前台企业选择后再修改
  6671. BEGIN
  6672. --取原价和对应的资费ID
  6673. SELECT TOP 1 @Accounts = b.Price * 2,
  6674. @dcFeeDetailsID = a.ID
  6675. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  6676. WHERE b.type = 22
  6677. AND a.dcFeeID = b.ID
  6678. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  6679. AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
  6680. AND StartDate < GETDATE() AND EndDate > GETDATE()
  6681. DECLARE @JobID INT
  6682. SELECT @JobID = ID FROM Job WITH(NOLOCK) WHERE Valid = 1 AND cpMainID= @cpMainID AND ID NOT IN(SELECT Balance FROM caOrder WITH(NOLOCK) WHERE OrderType=12 AND BeginDate>GETDATE() AND EndDate<GETDATE())
  6683. IF @JobID >0
  6684. BEGIN
  6685. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  6686. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
  6687. VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
  6688. 12,@Accounts,0,@JobID,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
  6689. SET @NewOrderID = @@IDENTITY
  6690. END
  6691. END
  6692. ELSE IF @GiftType = 8 --自动提交2周职位刷新订单
  6693. BEGIN
  6694. --取原价和对应的资费ID
  6695. SELECT TOP 1 @Accounts = b.Price * 2,
  6696. @dcFeeDetailsID = a.ID
  6697. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  6698. WHERE b.type = 24
  6699. AND a.dcFeeID = b.ID
  6700. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  6701. AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
  6702. AND StartDate < GETDATE() AND EndDate > GETDATE()
  6703. DECLARE @RefreshBeginDate SMALLDATETIME
  6704. --取最后一个固定位置的订单
  6705. SELECT TOP 1 @RefreshBeginDate=EndDate FROM caOrder WHERE cpMainID=@cpMainID AND OrderType=13 AND OpenDate IS NOT NULL AND EndDate>GETDATE() ORDER BY ID DESC
  6706. SET @RefreshBeginDate=ISNULL(@RefreshBeginDate,GETDATE())
  6707. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  6708. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
  6709. VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
  6710. 13,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,@RefreshBeginDate,DATEADD(DAY,14,@RefreshBeginDate),GETDATE(),116,4)
  6711. SET @NewOrderID = @@IDENTITY
  6712. END
  6713. ELSE IF @GiftType = 10 --自动提交VIP订单
  6714. BEGIN
  6715. DECLARE @ActiveQuota INT
  6716. DECLARE @JobNumber INT
  6717. DECLARE @UserNumber INT
  6718. --取本省份价格最便宜的季度套餐
  6719. SELECT TOP 1 @dcFeeDetailsID = b.ID,
  6720. @Accounts = (a.PriceMonth * b.[Month]+b.ResumeNumber*a.PriceResume+JobNumber*a.PriceJob+UserNumber*a.PriceUser),
  6721. @ActiveQuota = b.ResumeNumber,
  6722. @JobNumber = b.JobNumber,
  6723. @UserNumber = b.UserNumber
  6724. FROM dcVip a WITH(NOLOCK),dcVipDetail b WITH(NOLOCK)
  6725. WHERE a.id = b.dcVipId
  6726. AND dcProvinceid=@ProvinceID
  6727. AND b.[Month]=3
  6728. AND startDate<GETDATE()
  6729. AND enddate > GETDATE()
  6730. ORDER BY Price
  6731. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  6732. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
  6733. VALUES(@cpMainID,@ProvinceID,NULL,NULL,@PayMethod,@UserNumber,
  6734. 8,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,@ActiveQuota,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
  6735. SET @NewOrderID = @@IDENTITY
  6736. END
  6737. BEGIN TRY
  6738. IF @GiftType<>12
  6739. BEGIN
  6740. --奖品类型:1、50职位并发 2、50份简历 3、100份简历 4、200份简历 5、4周六分之一图片 6、2周文字广告 7、2周职位置顶
  6741. --8、2周职位自动刷新 9、4周六分之二 10、Vip会员—季度
  6742. DECLARE @GiftName VARCHAR(50)
  6743. IF @GiftType =1
  6744. BEGIN
  6745. SET @GiftName = '50职位并发'
  6746. END
  6747. ELSE IF @GiftType =2
  6748. BEGIN
  6749. SET @GiftName = '50份简历'
  6750. END
  6751. ELSE IF @GiftType =3
  6752. BEGIN
  6753. SET @GiftName = '100份简历'
  6754. END
  6755. ELSE IF @GiftType =4
  6756. BEGIN
  6757. SET @GiftName = '200份简历 '
  6758. END
  6759. ELSE IF @GiftType =5
  6760. BEGIN
  6761. SET @GiftName = '4周六分之一图片广告'
  6762. END
  6763. ELSE IF @GiftType =6
  6764. BEGIN
  6765. SET @GiftName = '2周文字广告'
  6766. END
  6767. ELSE IF @GiftType =7
  6768. BEGIN
  6769. SET @GiftName = '2周职位置顶'
  6770. END
  6771. ELSE IF @GiftType =8
  6772. BEGIN
  6773. SET @GiftName = '2周职位自动刷新'
  6774. END
  6775. ELSE IF @GiftType =9
  6776. BEGIN
  6777. SET @GiftName = '4周六分之二'
  6778. END
  6779. ELSE IF @GiftType =10
  6780. BEGIN
  6781. SET @GiftName = 'Vip会员—季度'
  6782. END
  6783. IF @Manageruserid IS NULL
  6784. BEGIN
  6785. INSERT INTO rtxnotifylog
  6786. SELECT STUFF((SELECT ','+LTRIM(x.ID) FROM Manageruser x WHERE ID IN (180,181,182) FOR XML PATH('')),1,1,'')
  6787. ,'中奖通知',@CompanyName+'('+LTRIM(STR(@cpMainID))+')中奖了,奖品为['+@GiftName+'],请及时处理http://115.182.8.38:81/yehgiiaovbjkaie871/cp/cpMainInfo.asp?id='+LTRIM(STR(@cpMainID))+'&code='+@Code,1,0,0,null,getdate()
  6788. END
  6789. ELSE
  6790. BEGIN
  6791. INSERT INTO rtxnotifylog
  6792. SELECT @Manageruserid
  6793. ,'中奖通知',@CompanyName+'('+LTRIM(STR(@cpMainID))+')中奖了,奖品为['+@GiftName+'],请及时处理http://115.182.8.38:81/yehgiiaovbjkaie871/cp/cpMainInfo.asp?id='+LTRIM(STR(@cpMainID))+'&code='+@Code,1,0,0,null,getdate()
  6794. END
  6795. Update caOrder Set InvoiceConfirmDate=GetDate(),InvoiceConfirmMan=116,InvoiceAskDate=Null,NeedInvoice=0 Where ID=@NewOrderID
  6796. END
  6797. END TRY
  6798. BEGIN CATCH
  6799. END CATCH
  6800. --更新LotteryCompany,保存订单号和中奖类型
  6801. UPDATE LotteryCompany SET GiftOrderID=@NewOrderID,[type]=@GiftType WHERE ID= @LotteryID
  6802. RETURN @GiftType
  6803. END
  6804. GO
  6805. /****** Object: StoredProcedure [dbo].[ccLotteryCompanyUpdate2017] Script Date: 2018/12/13 19:07:13 ******/
  6806. SET ANSI_NULLS ON
  6807. GO
  6808. SET QUOTED_IDENTIFIER ON
  6809. GO
  6810. --创建人:Lucifer
  6811. --创建时间:2017-10-9
  6812. --企业17周年抽奖
  6813. --奖项内容: VIP会员 普通会员
  6814. --50职位并发 15% 0%
  6815. --50份简历 15% 0%
  6816. --100条短信数 13% 0%
  6817. --2周六分之一图片 10% 10%
  6818. --2周知名企业 10% 15%
  6819. --2周职位置顶 5% 5%
  6820. --200次职位刷新 20% 15%
  6821. --2周六分之二图片 10% 10%
  6822. --满1000-50优惠券 2% 45%
  6823. --Vip会员—三个月 特殊
  6824. --九阳煮蛋器 特殊
  6825. --小米充电宝 特殊
  6826. --小涴熊电热饭盒 特殊
  6827. --美的豆浆机 特殊
  6828. --九阳榨汁机 特殊
  6829. --特殊奖项时间定为:Vip会员—三个月:山东(2个)其他地区合计(2个)8号抽2个,美的豆浆机:山东(1个)其他地区合计(1个)8号抽1个,九阳煮蛋器:山东(2个)其他地区合计(2个)15号抽2个,九阳榨汁机:山东(1个)其他地区合计(1个)15号抽1个,小米充电宝:山东(2个)其他地区合计(2个)25号抽2个,小涴熊电热饭盒:山东(2个)其他地区合计(2个)25号抽2个。
  6830. --保险公司,培训公司,代理招聘类公司仅能够中奖的范围:职位数、简历数、短信数、自动刷新。其他内容不允许抽中。需要在抽选中排除。
  6831. --50职位并发 30%
  6832. --50份简历 20%
  6833. --100份短信数 10%
  6834. --100次自动刷新 40%
  6835. --奖品类型:1、50职位并发 2、50份简历 3、Vip会员—三个月 4、100条短信数 5、2周六分之一图片 6、2周知名企业 7、2周职位置顶 8、200次职位刷新 9、2周六分之二 10、九阳煮蛋器 11、满1000-50优惠券 12、小米充电宝 13、小涴熊电热饭盒 14、美的豆浆机 15、九阳榨汁机 99、没中奖
  6836. --lucifer 2018-2-23
  6837. CREATE PROCEDURE [dbo].[ccLotteryCompanyUpdate2017]
  6838. (
  6839. @caMainID INT
  6840. )
  6841. AS
  6842. BEGIN
  6843. DECLARE @LotteryID INT
  6844. DECLARE @cpMainID INT
  6845. SELECT TOP 1 @LotteryID = ID,@cpMainID = cpMainID FROM LotteryCompany WITH(NOLOCK) WHERE Used = 0 AND AddDate>'2018-09-26 00:00:00' AND cpMainID = (select cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID AND AccountType=1)
  6846. IF @LotteryID IS NULL
  6847. RETURN -1 --没有抽奖次数
  6848. UPDATE LotteryCompany SET Used = 1,LotteryDate = GETDATE() WHERE ID = @LotteryID --更新状态 防止重复抽奖
  6849. ------------------****************生成抽奖结果****************-----------------
  6850. DECLARE @IsAgent TINYINT --是否是保险公司
  6851. DECLARE @IsVip TINYINT --是否是VIP
  6852. DECLARE @ProvinceId SMALLINT
  6853. DECLARE @Name NVARCHAR(200)
  6854. SELECT TOP 1 @IsAgent = IsAgent, @ProvinceId = dcProvinceId, @Name = Name, @IsVip = (CASE MemberType WHEN 3 THEN 1 ELSE 0 END) FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
  6855. IF @IsAgent = 0
  6856. BEGIN
  6857. IF @Name LIKE '%人寿%' OR @Name LIKE '%保险%'
  6858. SET @IsAgent = 1
  6859. END
  6860. DECLARE @GiftNo INT, @GiftType INT, @LoopCount INT
  6861. SELECT @GiftNo = CAST((RAND()*999+1) AS INT) --生成抽奖的数字
  6862. SELECT @GiftType = dbo.GetLotteryGiftType(@IsAgent, @GiftNo, @IsVip)
  6863. SET @LoopCount = 0
  6864. WHILE EXISTS(SELECT 'X' FROM LotteryCompany WHERE [Type] = @GiftType AND cpMainID = @cpMainID) OR @LoopCount < 1000
  6865. BEGIN
  6866. SELECT @GiftNo = CAST((RAND()*999 + 1) AS INT) --生成抽奖的数字
  6867. SELECT @GiftType = dbo.GetLotteryGiftType(@IsAgent, @GiftNo, @IsVip)
  6868. SET @LoopCount = @LoopCount + 1
  6869. END
  6870. --特殊奖项时间定为:Vip会员—三个月:山东(2个)其他地区合计(2个)8号抽2个,美的豆浆机:山东(1个)其他地区合计(1个)8号抽1个,九阳煮蛋器:山东(2个)其他地区合计(2个)15号抽2个,九阳榨汁机:山东(1个)其他地区合计(1个)15号抽1个,小米充电宝:山东(2个)其他地区合计(2个)25号抽2个,小涴熊电热饭盒:山东(2个)其他地区合计(2个)25号抽2个。
  6871. DECLARE @Today VARCHAR(4)
  6872. SELECT @Today = RIGHT(CONVERT(VARCHAR(8), GETDATE(), 112), 4)
  6873. IF @IsVip = 1 AND @IsAgent = 0
  6874. BEGIN
  6875. IF @ProvinceId = 32
  6876. BEGIN
  6877. IF EXISTS(SELECT 'X' FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND ([type] = 3 OR [type] = 14 OR [type] = 10 OR [type] = 15 OR [type] = 12 OR [type] = 13) AND b.dcProvinceID = 32 AND a.cpMainID IN (SELECT cpMainID FROM caMain WHERE ID =@caMainID))
  6878. SET @Today='1234'
  6879. END
  6880. ELSE
  6881. BEGIN
  6882. IF EXISTS(SELECT 'X' FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND ([type] = 3 OR [type] = 14 OR [type] = 10 OR [type] = 15 OR [type] = 12 OR [type] = 13) AND b.dcProvinceID <> 32 AND a.cpMainID IN (SELECT cpMainID FROM caMain WHERE ID =@caMainID))
  6883. SET @Today='1234'
  6884. END
  6885. IF @Today = '1008'
  6886. BEGIN
  6887. IF @ProvinceId = 32
  6888. BEGIN
  6889. IF NOT EXISTS(SELECT 'X' FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 3 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID = 32 AND a.cpMainID IN (SELECT cpMainID FROM caMain WHERE ID =@caMainID))
  6890. BEGIN
  6891. IF (SELECT COUNT(1) FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 3 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID = 32)<2
  6892. SELECT @GiftType = 3
  6893. END
  6894. ELSE IF NOT EXISTS(SELECT 'X' FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 14 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID = 32)
  6895. SELECT @GiftType = 14
  6896. END
  6897. ELSE
  6898. BEGIN
  6899. IF NOT EXISTS(SELECT 'X' FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 3 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID <> 32 AND a.cpMainID IN (SELECT cpMainID FROM caMain WHERE ID =@caMainID))
  6900. BEGIN
  6901. IF (SELECT COUNT(1) FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 3 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID <> 32)<2
  6902. SELECT @GiftType = 3
  6903. END
  6904. ELSE IF NOT EXISTS(SELECT 'X' FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 14 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID <> 32)
  6905. SELECT @GiftType = 14
  6906. END
  6907. END
  6908. ELSE IF @Today = '1015'
  6909. BEGIN
  6910. IF @ProvinceId = 32
  6911. BEGIN
  6912. IF NOT EXISTS(SELECT 'X' FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 10 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID = 32 AND a.cpMainID IN (SELECT cpMainID FROM caMain WHERE ID =@caMainID))
  6913. BEGIN
  6914. IF (SELECT COUNT(1) FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 10 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID = 32)<2
  6915. SELECT @GiftType = 10
  6916. END
  6917. ELSE IF NOT EXISTS(SELECT 'X' FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 15 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID = 32)
  6918. SELECT @GiftType = 15
  6919. END
  6920. ELSE
  6921. BEGIN
  6922. IF NOT EXISTS(SELECT 'X' FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 10 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID <> 32 AND a.cpMainID IN (SELECT cpMainID FROM caMain WHERE ID =@caMainID))
  6923. BEGIN
  6924. IF (SELECT COUNT(1) FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 10 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID <> 32)<2
  6925. SELECT @GiftType = 10
  6926. END
  6927. ELSE IF NOT EXISTS(SELECT 'X' FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 15 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID <> 32)
  6928. SELECT @GiftType = 15
  6929. END
  6930. END
  6931. ELSE IF @Today = '1025'
  6932. BEGIN
  6933. IF @ProvinceId = 32
  6934. BEGIN
  6935. IF NOT EXISTS(SELECT 'X' FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 12 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID = 32 AND a.cpMainID IN (SELECT cpMainID FROM caMain WHERE ID =@caMainID))
  6936. BEGIN
  6937. IF (SELECT COUNT(1) FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 12 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID = 32)<2
  6938. SELECT @GiftType = 12
  6939. END
  6940. ELSE IF NOT EXISTS(SELECT 'X' FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 13 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID = 32 AND a.cpMainID IN (SELECT cpMainID FROM caMain WHERE ID =@caMainID))
  6941. BEGIN
  6942. IF (SELECT COUNT(1) FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 13 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID = 32)<2
  6943. SELECT @GiftType = 13
  6944. END
  6945. END
  6946. ELSE
  6947. BEGIN
  6948. IF NOT EXISTS(SELECT 'X' FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 12 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID <> 32 AND a.cpMainID IN (SELECT cpMainID FROM caMain WHERE ID =@caMainID))
  6949. BEGIN
  6950. IF (SELECT COUNT(1) FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 12 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID <> 32)<2
  6951. SELECT @GiftType = 12
  6952. END
  6953. ELSE IF NOT EXISTS(SELECT 'X' FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 13 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID <> 32 AND a.cpMainID IN (SELECT cpMainID FROM caMain WHERE ID =@caMainID))
  6954. BEGIN
  6955. IF (SELECT COUNT(1) FROM maindb..LotteryCompany a, cpMain b WHERE a.cpMainID = b.ID AND [type] = 13 AND RIGHT(CONVERT(VARCHAR(8), LotteryDate, 112), 4) = @Today AND b.dcProvinceID <> 32)<2
  6956. SELECT @GiftType = 13
  6957. END
  6958. END
  6959. END
  6960. END
  6961. -- IF @IsVip = 1
  6962. -- BEGIN
  6963. -- IF (SELECT COUNT(1) FROM LotteryCompany WHERE cpMainID=@cpMainID AND caOrderID IS NULL) >= 2
  6964. -- SELECT @GiftType = 99
  6965. -- END
  6966. -- ELSE
  6967. -- BEGIN
  6968. -- IF (SELECT COUNT(1) FROM LotteryCompany WHERE cpMainID=@cpMainID AND caOrderID IS NULL) >= 1
  6969. -- SELECT @GiftType = 99
  6970. -- END
  6971. --每个企业最多中奖3次
  6972. IF (SELECT COUNT(1) FROM maindb..LotteryCompany WHERE cpMainID = @cpMainID AND AddDate>'2018-09-26 00:00:00' AND LotteryDate IS NOT NULL) >= 4
  6973. SELECT @GiftType = 99
  6974. PRINT @GiftType
  6975. /*---------****************自动提交订单**************-------------*/
  6976. DECLARE @PayMethod INT --取上次订单的付款方式
  6977. DECLARE @LinkMan NVARCHAR(50)
  6978. DECLARE @Telephone NVARCHAR(50)
  6979. DECLARE @CompanyName NVARCHAR(50)
  6980. DECLARE @Accounts NUMERIC(18,2)
  6981. DECLARE @dcFeeDetailsID INT
  6982. DECLARE @Manageruserid INT
  6983. DECLARE @MemberType INT
  6984. DECLARE @MainOrderID INT
  6985. DECLARE @InvoiceCompany NVARCHAR(50)
  6986. DECLARE @Hour INT
  6987. DECLARE @MainEndDate SMALLDATETIME
  6988. DECLARE @Minute INT
  6989. DECLARE @Code VARCHAR(10)
  6990. DECLARE @RegDate DATETIME
  6991. SELECT TOP 1
  6992. @ProvinceID = b.dcProvinceID,
  6993. @PayMethod = c.PayMethod,
  6994. @MemberType = MemberType,
  6995. @LinkMan = LinkMan,
  6996. @Telephone = Telephone,
  6997. @CompanyName = b.[Name],
  6998. @InvoiceCompany = InvoiceCompany,
  6999. @Manageruserid = ConsultantID,
  7000. @RegDate = RegDate
  7001. FROM cpMain b ,caOrder c
  7002. WHERE b.id = c.cpmainid
  7003. AND c.cpMainID = @cpMainID
  7004. AND Paid > 0
  7005. ORDER BY c.ID DESC
  7006. IF @CompanyName IS NULL
  7007. BEGIN
  7008. SELECT TOP 1
  7009. @ProvinceID = dcProvinceID,
  7010. @PayMethod = 1,
  7011. @MemberType = MemberType,
  7012. @CompanyName = [Name],
  7013. @InvoiceCompany = 4,
  7014. @Manageruserid = ConsultantID,
  7015. @RegDate = RegDate
  7016. FROM cpMain
  7017. WHERE ID = @cpMainID
  7018. END
  7019. SELECT TOP 1
  7020. @LinkMan = LinkMan,
  7021. @Telephone = Mobile
  7022. FROM LotteryCompany WHERE cpMainID = @cpMainID AND AddDate>'2018-09-26 00:00:00' AND LinkMan IS NOT NULL
  7023. SELECT @Hour = DATEPART(HOUR,@RegDate)
  7024. SELECT @Minute = DATEPART(Minute,@RegDate)
  7025. SET @Code = CONVERT(VARCHAR(10),@Hour*100+@Minute)
  7026. SET @PayMethod = 7
  7027. DECLARE @NewOrderID INT
  7028. IF @GiftType = 1 AND @MemberType = 3 --自动提交50个职位并发数的订单
  7029. BEGIN
  7030. --取原价和对应的资费ID
  7031. SELECT TOP 1 @Accounts = b.Price * 50,
  7032. @dcFeeDetailsID = a.ID
  7033. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  7034. WHERE b.type = 10
  7035. AND a.dcFeeID = b.ID
  7036. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  7037. AND ((MinValue <= 50 AND MaxValue >= 50) OR (MinValue <= 50 AND MaxValue = 0))
  7038. AND StartDate < GETDATE() AND EndDate > GETDATE()
  7039. SELECT TOP 1 @MainOrderID = ID, @MainEndDate = EndDate FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
  7040. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  7041. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
  7042. VALUES(@cpMainID,@ProvinceID,NULL,NULL,@PayMethod,0,
  7043. 10,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,50,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,GETDATE(),@MainEndDate,GETDATE(),116,4)
  7044. SET @NewOrderID = @@IDENTITY
  7045. END
  7046. ELSE IF @GiftType = 5 --自动提交2周1/6图片 广告
  7047. BEGIN
  7048. --取原价和对应的资费ID
  7049. SELECT TOP 1 @Accounts = b.Price * 4,
  7050. @dcFeeDetailsID = a.ID
  7051. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  7052. WHERE b.type = 4
  7053. AND a.dcFeeID = b.ID
  7054. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  7055. AND ((MinValue<=4 AND MaxValue>=4) OR (MinValue<=4 AND MaxValue=0))
  7056. AND StartDate < GETDATE() AND EndDate > GETDATE()
  7057. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  7058. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
  7059. VALUES(@cpMainID,@ProvinceID,6,2,@PayMethod,0,
  7060. 4,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
  7061. SET @NewOrderID = @@IDENTITY
  7062. END
  7063. ELSE IF @GiftType = 9 --自动提交2周2/6图片 广告
  7064. BEGIN
  7065. --取原价和对应的资费ID
  7066. SELECT TOP 1 @Accounts = b.Price * 4,
  7067. @dcFeeDetailsID = a.ID
  7068. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  7069. WHERE b.type = 4
  7070. AND a.dcFeeID = b.ID
  7071. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  7072. AND ((MinValue<=4 AND MaxValue>=4) OR (MinValue<=4 AND MaxValue=0))
  7073. AND StartDate < GETDATE() AND EndDate > GETDATE()
  7074. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  7075. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
  7076. VALUES(@cpMainID,@ProvinceID,7,2,@PayMethod,0,
  7077. 4,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
  7078. SET @NewOrderID = @@IDENTITY
  7079. END
  7080. ELSE IF @GiftType = 2 AND @MemberType = 3 --自动提交50简历下载订单
  7081. BEGIN
  7082. --取原价和对应的资费ID
  7083. SELECT TOP 1 @Accounts = b.Price * 50,
  7084. @dcFeeDetailsID = a.ID
  7085. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  7086. WHERE b.type = 9
  7087. AND a.dcFeeID = b.ID
  7088. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  7089. AND ((MinValue<=50 AND MaxValue>=50) OR (MinValue<=50 AND MaxValue=0))
  7090. AND StartDate < GETDATE() AND EndDate > GETDATE()
  7091. IF @dcFeeDetailsID IS NULL
  7092. SELECT TOP 1 @Accounts = Price * 50
  7093. FROM dcFee WITH(NOLOCK)
  7094. WHERE type = 9
  7095. AND dcProvinceID = LEFT(@ProvinceID,2)
  7096. AND StartDate < GETDATE() AND EndDate > GETDATE()
  7097. SELECT TOP 1 @MainOrderID = ID FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND OpenDate IS NOT NULL AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
  7098. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  7099. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
  7100. VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
  7101. 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,50,50,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
  7102. SET @NewOrderID = @@IDENTITY
  7103. END
  7104. --ELSE IF @GiftType = 3 AND @MemberType = 3 --自动提交100简历下载订单
  7105. --BEGIN
  7106. -- --取原价和对应的资费ID
  7107. -- SELECT TOP 1 @Accounts = b.Price * 100,
  7108. -- @dcFeeDetailsID = a.ID
  7109. -- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  7110. -- WHERE b.type = 9
  7111. -- AND a.dcFeeID = b.ID
  7112. -- AND b.dcProvinceID = LEFT(@ProvinceID,2)
  7113. -- AND ((MinValue<=100 AND MaxValue>=100) OR (MinValue<=100 AND MaxValue=0))
  7114. -- AND StartDate < GETDATE() AND EndDate > GETDATE()
  7115. -- IF @dcFeeDetailsID IS NULL
  7116. -- SELECT TOP 1 @Accounts = Price * 100
  7117. -- FROM dcFee WITH(NOLOCK)
  7118. -- WHERE type = 9
  7119. -- AND dcProvinceID = LEFT(@ProvinceID,2)
  7120. -- AND StartDate < GETDATE() AND EndDate > GETDATE()
  7121. -- SELECT TOP 1 @MainOrderID = ID FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND OpenDate IS NOT NULL AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
  7122. -- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  7123. -- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
  7124. -- VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
  7125. -- 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,100,100,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
  7126. -- SET @NewOrderID = @@IDENTITY
  7127. --END
  7128. --ELSE IF @GiftType = 4 AND @MemberType = 3 --自动提交200简历下载订单
  7129. --BEGIN
  7130. -- --取原价和对应的资费ID
  7131. -- SELECT TOP 1 @Accounts = b.Price * 200,
  7132. -- @dcFeeDetailsID = a.ID
  7133. -- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  7134. -- WHERE b.type = 9
  7135. -- AND a.dcFeeID = b.ID
  7136. -- AND b.dcProvinceID = LEFT(@ProvinceID,2)
  7137. -- AND ((MinValue<=50 AND MaxValue>=200) OR (MinValue<=200 AND MaxValue=0))
  7138. -- AND StartDate < GETDATE() AND EndDate > GETDATE()
  7139. -- IF @dcFeeDetailsID IS NULL
  7140. -- SELECT TOP 1 @Accounts = Price * 200
  7141. -- FROM dcFee WITH(NOLOCK)
  7142. -- WHERE type = 9
  7143. -- AND dcProvinceID = LEFT(@ProvinceID,2)
  7144. -- AND StartDate < GETDATE() AND EndDate > GETDATE()
  7145. -- SELECT TOP 1 @MainOrderID = ID FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND OpenDate IS NOT NULL AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
  7146. -- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  7147. -- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
  7148. -- VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
  7149. -- 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,200,200,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
  7150. -- SET @NewOrderID = @@IDENTITY
  7151. --END
  7152. ELSE IF @GiftType = 4 --100条短信数
  7153. BEGIN
  7154. --取原价和对应的资费ID
  7155. SELECT TOP 1 @Accounts = b.Price * 200,
  7156. @dcFeeDetailsID = a.ID
  7157. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  7158. WHERE b.type = 14
  7159. AND a.dcFeeID = b.ID
  7160. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  7161. AND StartDate < GETDATE() AND EndDate > GETDATE()
  7162. --取最后一个固定位置的订单
  7163. SELECT TOP 1 @MainOrderID = ID, @MainEndDate = EndDate FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
  7164. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PayMethod,
  7165. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,EndDate,SmsQuota,RemainSmsQuota,OrderStatus)
  7166. VALUES(@cpMainID,@ProvinceID,null,@PayMethod,
  7167. 14,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,@MainEndDate,100,100,0)
  7168. SET @NewOrderID = @@IDENTITY
  7169. END
  7170. ELSE IF @GiftType = 6 --自动提交2周知名企业
  7171. BEGIN
  7172. --取原价和对应的资费ID
  7173. SELECT TOP 1 @Accounts = b.Price * 2,
  7174. @dcFeeDetailsID = a.ID
  7175. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  7176. WHERE b.type = 7
  7177. AND a.dcFeeID = b.ID
  7178. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  7179. AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
  7180. AND StartDate < GETDATE() AND EndDate > GETDATE()
  7181. DECLARE @FixBeginDate SMALLDATETIME
  7182. --取最后一个固定位置的订单
  7183. SELECT TOP 1 @FixBeginDate=EndDate FROM caOrder WHERE cpMainID=@cpMainID AND OrderType=7 AND OpenDate IS NOT NULL AND EndDate>GETDATE() ORDER BY ID DESC
  7184. SET @FixBeginDate=ISNULL(@FixBeginDate,GETDATE())
  7185. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  7186. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
  7187. VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
  7188. 7,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,@FixBeginDate,DATEADD(DAY,14,@FixBeginDate),GETDATE(),116,4)
  7189. SET @NewOrderID = @@IDENTITY
  7190. END
  7191. ELSE IF @GiftType = 7 --自动提交2周职位置顶订单,职位默认取最新发布的,前台企业选择后再修改
  7192. BEGIN
  7193. --取原价和对应的资费ID
  7194. SELECT TOP 1 @Accounts = b.Price * 2,
  7195. @dcFeeDetailsID = a.ID
  7196. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  7197. WHERE b.type = 22
  7198. AND a.dcFeeID = b.ID
  7199. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  7200. AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
  7201. AND StartDate < GETDATE() AND EndDate > GETDATE()
  7202. DECLARE @JobID INT
  7203. SELECT @JobID = ID FROM Job WITH(NOLOCK) WHERE Valid = 1 AND cpMainID= @cpMainID AND ID NOT IN(SELECT Balance FROM caOrder WITH(NOLOCK) WHERE OrderType=12 AND BeginDate>GETDATE() AND EndDate<GETDATE())
  7204. IF @JobID >0
  7205. BEGIN
  7206. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  7207. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
  7208. VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
  7209. 12,@Accounts,0,@JobID,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
  7210. SET @NewOrderID = @@IDENTITY
  7211. END
  7212. END
  7213. ELSE IF @GiftType = 8 --200次职位刷新
  7214. BEGIN
  7215. --取原价和对应的资费ID
  7216. SELECT TOP 1 @Accounts = b.Price * 200,
  7217. @dcFeeDetailsID = a.ID
  7218. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  7219. WHERE b.type = 15
  7220. AND a.dcFeeID = b.ID
  7221. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  7222. AND StartDate < GETDATE() AND EndDate > GETDATE()
  7223. DECLARE @RefreshBeginDate SMALLDATETIME
  7224. --取最后一个固定位置的订单
  7225. SELECT TOP 1 @RefreshBeginDate=EndDate FROM caOrder WHERE cpMainID=@cpMainID AND OrderType=15 AND OpenDate IS NOT NULL AND EndDate>GETDATE() ORDER BY ID DESC
  7226. SET @RefreshBeginDate=ISNULL(@RefreshBeginDate,GETDATE())
  7227. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PayMethod,
  7228. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,jobRefreshQuota,remainJobRefreshQuota,OrderStatus)
  7229. VALUES(@cpMainID,@ProvinceID,null,@PayMethod,
  7230. 15,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,200,200,0)
  7231. SET @NewOrderID = @@IDENTITY
  7232. END
  7233. ELSE IF @GiftType = 3 --自动提交VIP订单(3个月)
  7234. BEGIN
  7235. DECLARE @ActiveQuota INT
  7236. DECLARE @JobNumber INT
  7237. DECLARE @UserNumber INT
  7238. --取本省份价格最便宜的季度套餐
  7239. SELECT TOP 1 @dcFeeDetailsID = b.ID,
  7240. @Accounts = (a.PriceMonth * b.[Month]+b.ResumeNumber*a.PriceResume+JobNumber*a.PriceJob+UserNumber*a.PriceUser),
  7241. @ActiveQuota = b.ResumeNumber,
  7242. @JobNumber = b.JobNumber,
  7243. @UserNumber = b.UserNumber
  7244. FROM dcVip a WITH(NOLOCK),dcVipDetail b WITH(NOLOCK)
  7245. WHERE a.id = b.dcVipId
  7246. AND dcProvinceid=@ProvinceID
  7247. AND b.[Month]=3
  7248. AND startDate<GETDATE()
  7249. AND enddate > GETDATE()
  7250. ORDER BY Price
  7251. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
  7252. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
  7253. VALUES(@cpMainID,@ProvinceID,NULL,NULL,@PayMethod,@UserNumber,
  7254. 8,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,@ActiveQuota,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
  7255. SET @NewOrderID = @@IDENTITY
  7256. END
  7257. --奖品类型:1、50职位并发 2、50份简历 3、Vip会员—三个月 4、100条短信数 5、2周六分之一图片 6、2周知名企业 7、2周职位置顶 8、200次职位刷新 9、2周六分之二 10、九阳煮蛋器 11、满1000-50优惠券 12、小米充电宝 13、小涴熊电热饭盒 14、美的豆浆机 15、九阳榨汁机 99、没中奖
  7258. BEGIN TRY
  7259. IF @GiftType <> 99
  7260. BEGIN
  7261. DECLARE @GiftName VARCHAR(50)
  7262. IF @GiftType = 1
  7263. BEGIN
  7264. SET @GiftName = '50职位并发'
  7265. END
  7266. ELSE IF @GiftType = 2
  7267. BEGIN
  7268. SET @GiftName = '50份简历'
  7269. END
  7270. ELSE IF @GiftType = 3
  7271. BEGIN
  7272. SET @GiftName = 'Vip会员—三个月'
  7273. END
  7274. ELSE IF @GiftType = 4
  7275. BEGIN
  7276. SET @GiftName = '100条短信数'
  7277. END
  7278. ELSE IF @GiftType = 5
  7279. BEGIN
  7280. SET @GiftName = '2周六分之一图片广告'
  7281. END
  7282. ELSE IF @GiftType = 6
  7283. BEGIN
  7284. SET @GiftName = '2周知名企业'
  7285. END
  7286. ELSE IF @GiftType = 7
  7287. BEGIN
  7288. SET @GiftName = '2周职位置顶'
  7289. END
  7290. ELSE IF @GiftType = 8
  7291. BEGIN
  7292. SET @GiftName = '200次职位刷新'
  7293. END
  7294. ELSE IF @GiftType = 9
  7295. BEGIN
  7296. SET @GiftName = '2周六分之二'
  7297. END
  7298. ELSE IF @GiftType = 10
  7299. BEGIN
  7300. SET @GiftName = '九阳煮蛋器'
  7301. END
  7302. ELSE IF @GiftType = 11
  7303. BEGIN
  7304. SET @GiftName = '满1000-50优惠券'
  7305. END
  7306. ELSE IF @GiftType = 12
  7307. BEGIN
  7308. SET @GiftName = '小米充电宝'
  7309. END
  7310. ELSE IF @GiftType = 13
  7311. BEGIN
  7312. SET @GiftName = '小涴熊电热饭盒'
  7313. END
  7314. ELSE IF @GiftType = 14
  7315. BEGIN
  7316. SET @GiftName = '美的豆浆机'
  7317. END
  7318. ELSE IF @GiftType = 15
  7319. BEGIN
  7320. SET @GiftName = '九阳榨汁机'
  7321. END
  7322. IF @Manageruserid IS NULL
  7323. BEGIN
  7324. INSERT INTO rtxnotifylog
  7325. SELECT STUFF((SELECT ','+LTRIM(x.ID) FROM Manageruser x WHERE ID IN (180,182) FOR XML PATH('')),1,1,'')
  7326. ,'中奖通知',@CompanyName+'('+LTRIM(STR(@cpMainID))+')中奖了,奖品为[' + @GiftName + '],请及时处理http://sysback.51rc.com/yehgiiaovbjkaie871/cp/cpMainInfo.asp?id='+LTRIM(STR(@cpMainID))+'&code=' + @Code,1,0,0,null,getdate()
  7327. END
  7328. ELSE
  7329. BEGIN
  7330. INSERT INTO rtxnotifylog
  7331. SELECT @Manageruserid
  7332. ,'中奖通知',@CompanyName+'('+LTRIM(STR(@cpMainID))+')中奖了,奖品为[' + @GiftName + '],请及时处理http://sysback.51rc.com/yehgiiaovbjkaie871/cp/cpMainInfo.asp?id='+LTRIM(STR(@cpMainID))+'&code=' + @Code,1,0,0,null,getdate()
  7333. END
  7334. Update caOrder Set InvoiceConfirmDate=GetDate(),InvoiceConfirmMan=116,InvoiceAskDate=Null,NeedInvoice=0 Where ID=@NewOrderID
  7335. END
  7336. END TRY
  7337. BEGIN CATCH
  7338. END CATCH
  7339. --更新LotteryCompany,保存订单号和中奖类型
  7340. UPDATE LotteryCompany SET GiftOrderID = @NewOrderID,[type] = @GiftType WHERE ID= @LotteryID
  7341. RETURN @GiftType
  7342. END
  7343. GO
  7344. /****** Object: StoredProcedure [dbo].[ccManagerLogByIpSelect] Script Date: 2018/12/13 19:07:14 ******/
  7345. SET ANSI_NULLS ON
  7346. GO
  7347. SET QUOTED_IDENTIFIER ON
  7348. GO
  7349. /*********************
  7350. SEAN 2014-10-29
  7351. **********************/
  7352. CREATE PROCEDURE [dbo].[ccManagerLogByIpSelect]
  7353. (
  7354. @Ip VARCHAR(15)
  7355. )
  7356. AS
  7357. --INSERT INTO procLog SELECT 'ccManagerLogByIpSelect', '', GETDATE()
  7358. BEGIN
  7359. SELECT * FROM ManagerLog WITH(NOLOCK) WHERE LoginDate > GETDATE() - 0.1 AND ip = @IP
  7360. END
  7361. GO
  7362. /****** Object: StoredProcedure [dbo].[ccManagerUserByIdSelect] Script Date: 2018/12/13 19:07:14 ******/
  7363. SET ANSI_NULLS ON
  7364. GO
  7365. SET QUOTED_IDENTIFIER ON
  7366. GO
  7367. /**********************8
  7368. sean 2014-10-29
  7369. ***********************/
  7370. CREATE PROCEDURE [dbo].[ccManagerUserByIdSelect]
  7371. (
  7372. @ID INT
  7373. )
  7374. AS
  7375. --INSERT INTO procLog SELECT 'ccManagerUserByIdSelect', '', GETDATE()
  7376. BEGIN
  7377. SELECT ID,Name ShowName,ID ShowID, Name UserName
  7378. FROM Manageruser WITH(NOLOCK)
  7379. WHERE ID = @ID
  7380. END
  7381. GO
  7382. /****** Object: StoredProcedure [dbo].[ccManagerUserIDSelect] Script Date: 2018/12/13 19:07:14 ******/
  7383. SET ANSI_NULLS ON
  7384. GO
  7385. SET QUOTED_IDENTIFIER ON
  7386. GO
  7387. --#####################################################
  7388. --创建时间:2014.10.30
  7389. --创建人:Nick
  7390. --说明://得到客服id
  7391. --#####################################################
  7392. CREATE PROCEDURE [dbo].[ccManagerUserIDSelect]
  7393. AS
  7394. BEGIN
  7395. SELECT id FROM ManagerUser WITH(NOLOCK) WHERE Type=5 AND (Status=1 OR Status=2)
  7396. END
  7397. GO
  7398. /****** Object: StoredProcedure [dbo].[ccManagerUserSuperiorByID] Script Date: 2018/12/13 19:07:14 ******/
  7399. SET ANSI_NULLS ON
  7400. GO
  7401. SET QUOTED_IDENTIFIER ON
  7402. GO
  7403. --#####################################################
  7404. --创建时间:2014.10.30
  7405. --创建人:Nick
  7406. --说明:得到招聘顾问上级的ID
  7407. --#####################################################
  7408. CREATE PROCEDURE [dbo].[ccManagerUserSuperiorByID]
  7409. (
  7410. @ID INT
  7411. )
  7412. AS
  7413. BEGIN TRY
  7414. SELECT Superior FROM ManagerUser WITH(NOLOCK) WHERE ID = @ID
  7415. END TRY
  7416. BEGIN CATCH
  7417. RETURN 0
  7418. END CATCH
  7419. GO
  7420. /****** Object: StoredProcedure [dbo].[ccMessageC2pCountSelect] Script Date: 2018/12/13 19:07:14 ******/
  7421. SET ANSI_NULLS ON
  7422. GO
  7423. SET QUOTED_IDENTIFIER ON
  7424. GO
  7425. --Lambo 20101122
  7426. --查询单位在两个月内留言的数量
  7427. --用户简历显示页面,单位给求职者浏览,普通用户两个月内只能发100个留言
  7428. CREATE PROCEDURE [dbo].[ccMessageC2pCountSelect]
  7429. (
  7430. @cpMainID INT
  7431. )
  7432. AS
  7433. BEGIN
  7434. DECLARE @MessageCount INT
  7435. SELECT @MessageCount=COUNT(*) FROM exMessageC2P WITH(NOLOCK)
  7436. WHERE caMainID in (SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  7437. AND AddDate >=DateAdd(Month,-2,GETDATE())
  7438. ------PRINT @MessageCount
  7439. RETURN @MessageCount
  7440. END
  7441. GO
  7442. /****** Object: StoredProcedure [dbo].[ccNVexMessageLogSelect] Script Date: 2018/12/13 19:07:14 ******/
  7443. SET ANSI_NULLS ON
  7444. GO
  7445. SET QUOTED_IDENTIFIER ON
  7446. GO
  7447. CREATE PROCEDURE [dbo].[ccNVexMessageLogSelect]
  7448. (
  7449. @paMainID INT,
  7450. @caMainID INT
  7451. )
  7452. AS
  7453. BEGIN
  7454. SELECT * FROM (
  7455. SELECT cvMainID,ID,addDate,Message,1 IsCompany,IsViewed FROM exMessageC2p WITH(NOLOCK)
  7456. WHERE cvMainID IN(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID=@paMainID) AND caMainID=@caMainID
  7457. AND CompanyDeleted=0
  7458. UNION
  7459. SELECT cvMainID,ID,addDate,Message,0 IsCompany,IsViewed FROM exMessageP2C WITH(NOLOCK)
  7460. WHERE cvMainID IN(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID=@paMainID) AND caMainID=@caMainID
  7461. AND CompanyDeleted=0
  7462. ) a ORDER BY a.AddDate
  7463. UPDATE exMessageP2c SET isViewed = 1 WHERE cvMainID IN(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID=@paMainID) AND caMainID=@caMainID
  7464. END
  7465. GO
  7466. /****** Object: StoredProcedure [dbo].[ccNVpaMainByexMessageP2CCaMainIdSelectNew] Script Date: 2018/12/13 19:07:15 ******/
  7467. SET ANSI_NULLS ON
  7468. GO
  7469. SET QUOTED_IDENTIFIER ON
  7470. GO
  7471. CREATE PROCEDURE [dbo].[ccNVpaMainByexMessageP2CCaMainIdSelectNew]
  7472. (
  7473. @caMainID INT,
  7474. @Where VARCHAR(100)
  7475. )
  7476. AS
  7477. BEGIN
  7478. BEGIN TRY
  7479. DECLARE @SQL AS VARCHAR(MAX)
  7480. DECLARE @cpMainID AS INT
  7481. CREATE TABLE #T1(
  7482. paMainID INT,
  7483. cvMainID INT,
  7484. paName NVARCHAR(20),
  7485. AddDate DATETIME,
  7486. Message VARCHAR(500),
  7487. isC2P INT,
  7488. hasJobApply INT,
  7489. hasInterview INT,
  7490. hasRemark INT,
  7491. hasFavorate INT,
  7492. isViewed INT
  7493. )
  7494. --该用户所有聊天信息保存至临时表
  7495. INSERT INTO #T1(paMainID,cvMainID,paName,AddDate,Message,isC2P,isViewed)
  7496. SELECT c.ID paMainID,b.ID cvMainID,c.Name,a.AddDate,a.Message,1 isC2P,isViewed
  7497. FROM exMessageC2p a WITH(NOLOCK),
  7498. cvMain b WITH(NOLOCK),
  7499. paMain c WITH(NOLOCK)
  7500. WHERE a.cvMainID=b.ID
  7501. AND b.paMainID=c.ID
  7502. AND caMainID=@caMainID
  7503. AND CompanyDeleted=0
  7504. UNION
  7505. SELECT c.ID paMainID,b.ID cvMainID,c.Name,a.AddDate,a.Message,0 isC2P,isViewed
  7506. FROM exMessageP2c a WITH(NOLOCK),
  7507. cvMain b WITH(NOLOCK),
  7508. paMain c WITH(NOLOCK)
  7509. WHERE a.cvMainID=b.ID
  7510. AND b.paMainID=c.ID
  7511. AND caMainID=@caMainID
  7512. AND CompanyDeleted=0
  7513. SELECT @cpMainID=cpMainID FROM caMain WHERE ID=@caMainID
  7514. UPDATE #T1 SET paName = LEFT(dbo.GetPaName(cvMainID, @cpMainID), 20),
  7515. HasJobApply = (SELECT TOP 1 '1' FROM exJobApply a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T1.cvMainID),
  7516. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T1.cvMainID),
  7517. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T1.cvMainID),
  7518. HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T1.cvMainID)
  7519. CREATE TABLE #T2(
  7520. paMainID INT,
  7521. MsgCount INT,
  7522. MsgUnRead INT
  7523. )
  7524. --保存数量
  7525. INSERT INTO #T2 SELECT paMainID,Count(*),0 FROM #T1 GROUP BY paMainID
  7526. --保存未读数量
  7527. UPDATE #T2 SET MsgUnRead = (SELECT COUNT(*) FROM #T1 WHERE isC2p = 0 AND isViewed = 0 AND #T1.paMainID = #T2.paMainID GROUP BY paMainID)
  7528. SET @SQL = '
  7529. SELECT a.paMainID,a.cvMainID,a.paName,c.MsgCount,c.MsgUnRead,d.FullName AccountPlace,a.Message,a.AddDate,a.isC2P,a.hasJobApply,a.hasInterview,a.hasRemark,a.hasFavorate,a.isViewed FROM
  7530. (
  7531. SELECT paMainID,cvMainID,AddDate,paName,isC2P,Message,hasJobApply,hasInterview,hasRemark,hasFavorate,isViewed,ROW_NUMBER() OVER(PARTITION BY cvMainID ORDER BY AddDate DESC) RowNumber FROM #T1
  7532. ) a,paMain b WITH(NOLOCK),#T2 c WITH(NOLOCK),dcRegion d WITH(NOLOCK)
  7533. WHERE a.RowNumber=1 AND a.paMainID=b.ID AND c.paMainID=a.paMainID AND d.ID=b.AccountPlace '
  7534. IF LEN(@Where) > 0
  7535. BEGIN
  7536. SET @Where = dbo.SafeSql(@Where)
  7537. SET @SQL = @SQL + @Where
  7538. END
  7539. SET @SQL=@SQL+' ORDER BY a.AddDate DESC'
  7540. EXEC(@SQL)
  7541. DROP TABLE #T1
  7542. DROP TABLE #T2
  7543. END TRY
  7544. BEGIN CATCH
  7545. DROP TABLE #T1
  7546. DROP TABLE #T2
  7547. END CATCH
  7548. END
  7549. GO
  7550. /****** Object: StoredProcedure [dbo].[ccNVpaMainByexMessageP2CPaMainIdSelectNew] Script Date: 2018/12/13 19:07:15 ******/
  7551. SET ANSI_NULLS ON
  7552. GO
  7553. SET QUOTED_IDENTIFIER ON
  7554. GO
  7555. CREATE PROCEDURE [dbo].[ccNVpaMainByexMessageP2CPaMainIdSelectNew]
  7556. (
  7557. @cvMainID INT,
  7558. @caMainID INT
  7559. )
  7560. AS
  7561. BEGIN
  7562. BEGIN TRY
  7563. DECLARE @cpMainID AS INT
  7564. CREATE TABLE #T(
  7565. paMainID INT,
  7566. cvMainID INT,
  7567. AccountPlace NVARCHAR(20),
  7568. Gender BIT,
  7569. Birthday INT,
  7570. Degree NVARCHAR(10),
  7571. RelatedYears INT,
  7572. paName NVARCHAR(20),
  7573. hasJobApply INT,
  7574. hasInterview INT,
  7575. hasRemark INT,
  7576. hasFavorate INT
  7577. )
  7578. --该用户基本信息保存至临时表
  7579. INSERT INTO #T(paMainID,cvMainID,AccountPlace,Gender,Birthday,Degree,RelatedYears,paName)
  7580. SELECT a.ID paMainID,b.ID cvMainID,d.FullName AccountPlace,a.Gender,a.Birthday,c.Description Degree,b.RelatedWorkYears,a.Name
  7581. FROM paMain a WITH(NOLOCK)
  7582. left join cvMain b WITH(NOLOCK) on a.ID=b.paMainID
  7583. left join dcEducation c WITH(NOLOCK) on b.Degree=c.ID
  7584. left join dcRegion d WITH(NOLOCK) on a.AccountPlace=d.ID
  7585. WHERE
  7586. b.ID=@cvMainID
  7587. SELECT @cpMainID=cpMainID FROM caMain WHERE ID=@caMainID
  7588. UPDATE #T SET paName = LEFT(dbo.GetPaName(cvMainID, @cpMainID), 20),
  7589. HasJobApply = (SELECT TOP 1 '1' FROM exJobApply a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  7590. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  7591. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  7592. HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
  7593. SELECT * FROM #T
  7594. DROP TABLE #T
  7595. END TRY
  7596. BEGIN CATCH
  7597. DROP TABLE #T
  7598. END CATCH
  7599. END
  7600. GO
  7601. /****** Object: StoredProcedure [dbo].[ccPaAttentionSelect] Script Date: 2018/12/13 19:07:15 ******/
  7602. SET ANSI_NULLS ON
  7603. GO
  7604. SET QUOTED_IDENTIFIER ON
  7605. GO
  7606. --Nick 20151120
  7607. --企业关注列表
  7608. CREATE PROCEDURE [dbo].[ccPaAttentionSelect]
  7609. (
  7610. @WHERE VARCHAR(1000),
  7611. @Order VARCHAR(100),
  7612. @Page SMALLINT,
  7613. @caMainID INT,
  7614. @cpMainID INT,
  7615. @AttentionType SMALLINT --1关注企业 2关注职位
  7616. )
  7617. AS
  7618. SET NOCOUNT ON
  7619. BEGIN
  7620. SET @Where = dbo.SafeSql(@Where)
  7621. SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '''''')
  7622. DECLARE @SQL AS VARCHAR(2000)
  7623. CREATE TABLE #T(
  7624. TitleID BIGINT,
  7625. ID INT,
  7626. paMainID INT,
  7627. cvMainID INT,
  7628. AddDate SMALLDATETIME,
  7629. IsMatched BIT,
  7630. Degree TINYINT,
  7631. RelatedWorkYears TINYINT,
  7632. LivePlace NVARCHAR(50),
  7633. Gender BIT,
  7634. paName NVARCHAR(20),
  7635. BirthDay INT,
  7636. HasPhoto TINYINT,
  7637. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  7638. IsNameHidden BIT,
  7639. Valid TINYINT,
  7640. IsViewed BIT,
  7641. HasJobApply BIT,
  7642. HasInterview BIT,
  7643. HasRemark BIT,
  7644. HasFavorate BIT,
  7645. cvEducationID INT,
  7646. College NVARCHAR(50),
  7647. EduType TINYINT,
  7648. MajorName NVARCHAR(20),
  7649. Graduation INT,
  7650. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  7651. Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  7652. cvMatch INT,
  7653. RecruitmentID INT,
  7654. RecruitmentName NVARCHAR(100),
  7655. RecruitmentDate SMALLDATETIME,
  7656. MobileVerifyDate SMALLDATETIME,
  7657. IsOnline BIT,
  7658. JobID INT,
  7659. JobName VARCHAR(50),
  7660. HasWeiXin BIT,
  7661. SecondId VARCHAR(10)
  7662. )
  7663. IF @AttentionType = 1 --企业
  7664. BEGIN
  7665. SET @SQL='
  7666. INSERT INTO #T
  7667. (TitleID, ID, paMainID, AddDate, LivePlace, Gender,
  7668. BirthDay, HasPhoto, MobileVerifyDate, IsOnline)
  7669. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, c.ID, a.AddDate, c.LivePlace,
  7670. c.Gender, c.BirthDay, c.HasPhoto, c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID)
  7671. FROM paAttention a WITH(NOLOCK), paMain c WITH(NOLOCK)
  7672. WHERE a.paMainID = c.ID AND AttentionType = 1 AND AttentionID = '+CONVERT(VARCHAR(20), @cpMainID)
  7673. --PRINT @SQL
  7674. IF LEN(@WHERE) > 0
  7675. SET @SQL = @SQL + ' AND ' + @WHERE
  7676. SET @SQL = @SQL + 'ORDER BY a.AddDate '
  7677. EXEC(@SQL)
  7678. END
  7679. ELSE
  7680. BEGIN
  7681. SET @SQL='
  7682. INSERT INTO #T
  7683. (TitleID, ID, paMainID, AddDate, LivePlace, Gender,
  7684. BirthDay, HasPhoto, MobileVerifyDate, IsOnline, JobID, JobName)
  7685. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, c.ID, a.AddDate, c.LivePlace,
  7686. c.Gender, c.BirthDay, c.HasPhoto, c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID), b.ID, b.Name
  7687. FROM paAttention a WITH(NOLOCK), Job b WITH(NOLOCK), paMain c WITH(NOLOCK)
  7688. WHERE a.paMainID = c.ID
  7689. AND AttentionType = 2
  7690. AND a.AttentionID = b.ID
  7691. AND b.IsDelete = 0'
  7692. IF LEN(@WHERE) > 0
  7693. SET @SQL = @SQL + ' AND '+@WHERE
  7694. SET @SQL = @SQL + ' ORDER BY a.AddDate '
  7695. --PRINT @SQL
  7696. EXEC(@SQL)
  7697. END
  7698. --修改cvmainID
  7699. UPDATE a SET CvMainID = (
  7700. SELECT TOP 1 ID FROM CvMain WITH(NOLOCK)
  7701. WHERE PaMainID = a.PaMainID
  7702. AND (Valid > 0 OR substring(CvLevel, 0, 6)='111111' OR substring(CvLevel, 0, 6) = '111101' )
  7703. ORDER BY RefreshDate DESC
  7704. ) FROM #T a
  7705. UPDATE a
  7706. SET CvMainID = (SELECT TOP 1 ID FROM CvMain WITH(NOLOCK)
  7707. WHERE PaMainID = a.PaMainID
  7708. ORDER BY RefreshDate DESC, Id DESC),
  7709. SecondId = (SELECT TOP 1 SecondId FROM CvMain WITH(NOLOCK)
  7710. WHERE PaMainID = a.PaMainID
  7711. ORDER BY RefreshDate DESC, Id DESC)
  7712. FROM #T a
  7713. DELETE FROM #T WHERE CvMainID IS NULL
  7714. --修改简历信息
  7715. UPDATE a
  7716. SET a.Degree = b.Degree,
  7717. a.RelatedWorkYears = b.RelatedWorkYears,
  7718. a.Attachment = b.Attachment,
  7719. a.IsNameHidden = b.IsNameHidden,
  7720. a.Valid = b.Valid
  7721. FROM #T a, CvMain b
  7722. WHERE a.CvMainID = b.ID
  7723. IF LEN(@WHERE) > 0
  7724. SET @SQL = @SQL + ' AND ' + @WHERE
  7725. IF(@Page < 1)
  7726. SET @Page = 1
  7727. IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
  7728. SET @Page = 1
  7729. UPDATE #T SET paName = LEFT(dbo.GetPersonName(cvMainID, @cpMainID), 20), IsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID),
  7730. HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  7731. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  7732. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  7733. HasJobApply = (SELECT TOP 1 '1' FROM exJobApply a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#t.cvMainID)
  7734. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  7735. UPDATE #T SET Speciality = (
  7736. SELECT Speciality FROM cvMain WITH(NOLOCK)
  7737. WHERE cvMain.ID = #T.cvMainID)
  7738. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  7739. UPDATE #T SET Experience = (
  7740. SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
  7741. WHERE cvExperience.cvMainID = #T.cvMainID
  7742. ORDER BY BeginDate DESC)
  7743. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  7744. UPDATE #T SET cvEducationID = (
  7745. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  7746. WHERE cvEducation.cvMainID = #T.cvMainID
  7747. AND #T.Degree = cvEducation.Degree
  7748. ORDER BY Graduation DESC)
  7749. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  7750. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  7751. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  7752. FROM #T a, cvEducation b WITH(NOLOCK)
  7753. WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  7754. --UPDATE a SET a.RecruitmentName = b.RecruitmentName, a.RecruitmentDate = b.EndDate
  7755. --FROM #T a, Recruitment b WITH(NOLOCK)
  7756. --WHERE b.ID = a.RecruitmentID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  7757. --修改是否绑定微信
  7758. UPDATE a SET HasWeiXin = 1
  7759. FROM #T a, WxFans b WITH(NOLOCK)
  7760. WHERE a.paMainID = b.PaMainID
  7761. AND b.Status = 2
  7762. AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  7763. UPDATE #T SET cvMatch = dbo.GetCvMatch(cvMainID, JobID) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  7764. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  7765. SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  7766. --计算匹配度
  7767. DROP TABLE #T
  7768. END
  7769. GO
  7770. /****** Object: StoredProcedure [dbo].[ccPaBlackByMobileSelect] Script Date: 2018/12/13 19:07:16 ******/
  7771. SET ANSI_NULLS ON
  7772. GO
  7773. SET QUOTED_IDENTIFIER ON
  7774. GO
  7775. -- =============================================
  7776. -- 检查: Sean
  7777. -- 日期: 2010-10-5
  7778. -- 描述: 手机黑名单
  7779. -- =============================================
  7780. CREATE PROCEDURE [dbo].[ccPaBlackByMobileSelect]
  7781. AS
  7782. BEGIN
  7783. SELECT Mobile FROM Person_Black WITH(NOLOCK) WHERE ISNULL(Mobile, '') > ''
  7784. END
  7785. GO
  7786. /****** Object: StoredProcedure [dbo].[ccPaJobViewLogBycaMainIDSelect] Script Date: 2018/12/13 19:07:16 ******/
  7787. SET ANSI_NULLS ON
  7788. GO
  7789. SET QUOTED_IDENTIFIER ON
  7790. GO
  7791. --修改:Andy 2015-01-13
  7792. --1. 去掉try catch
  7793. --2. 添加职位的regionid
  7794. CREATE PROCEDURE [dbo].[ccPaJobViewLogBycaMainIDSelect]
  7795. (
  7796. @caMainID INT,
  7797. @WHERE VARCHAR(1000),
  7798. @ORDER VARCHAR(1000),
  7799. @Page SMALLINT,
  7800. @cpMainID INT
  7801. )
  7802. AS
  7803. SET NOCOUNT ON
  7804. BEGIN
  7805. IF NOT EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK) WHERE ID = @caMainID AND cpMainID = @cpMainID)
  7806. RETURN 0
  7807. SET @Where = dbo.SafeSql(@Where)
  7808. SET @ORDER = dbo.SafeSql(@Order)
  7809. CREATE TABLE #t(
  7810. TitleID BIGINT,
  7811. caMainId INT,
  7812. cvMainId INT,
  7813. jobId INT,
  7814. jobRegionID INT,
  7815. CvJobMatch INT,
  7816. JobName NVARCHAR(50),
  7817. AddDate SMALLDATETIME,
  7818. Degree TINYINT,
  7819. RelatedWorkYears TINYINT,
  7820. LivePlace VARCHAR(6) COLLATE Chinese_PRC_CI_AS,
  7821. Gender BIT,
  7822. paName NVARCHAR(20),
  7823. BirthDay INT,
  7824. HasPhoto TINYINT,
  7825. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  7826. IsNameHidden BIT,
  7827. Valid TINYINT,
  7828. IsViewed BIT,
  7829. HasJobApply BIT,
  7830. HasInterview BIT,
  7831. HasRemark BIT,
  7832. HasFavorate BIT,
  7833. cvEducationID INT,
  7834. College NVARCHAR(50),
  7835. EduType TINYINT,
  7836. MajorName NVARCHAR(20),
  7837. Graduation INT,
  7838. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  7839. Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  7840. MobileVerifyDate SMALLDATETIME,
  7841. IsOnline BIT,
  7842. PaMainID INT,
  7843. HasWeiXin BIT,
  7844. SecondId VARCHAR(100)
  7845. )
  7846. DECLARE @SQL AS VARCHAR(2000)
  7847. SET @SQL='
  7848. INSERT INTO #t(TitleID, caMainID, cvMainID, jobId, jobRegionID, AddDate, JobName,
  7849. MobileVerifyDate, IsOnline, PaMainID, SecondId)
  7850. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID,
  7851. b.caMainID, d.ID, b.ID, b.dcRegionID, a.AddDate, b.Name,
  7852. c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID), c.ID, d.SecondId
  7853. From PaJobViewLog a WITH(NOLOCK)
  7854. INNER JOIN Job b WITH(NOLOCK) ON b.ID=a.JobID
  7855. INNER JOIN paMain c WITH(NOLOCK) ON c.ID=a.paMainID
  7856. INNER JOIN cvMain d WITH(NOLOCK) ON d.paMainID=c.ID AND d.Valid>0'
  7857. SET @SQL = @SQL + '
  7858. WHERE 1=1 '
  7859. IF LEN(@WHERE)> 0
  7860. SET @SQL=@SQL + @WHERE
  7861. --PRINT(@SQL)
  7862. EXEC(@SQL)
  7863. IF(@Page < 1)
  7864. SET @Page = 1
  7865. IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
  7866. SET @Page = 1
  7867. --添加匹配度 Peter 2013-11-12 14:33
  7868. UPDATE #t SET CvJobMatch = dbo.GetCvMatch(cvMainId, jobID), Degree = a.Degree, RelatedWorkYears = a.RelatedWorkYears, Attachment = a.Attachment,
  7869. IsNameHidden = a.IsNameHidden, LivePlace = b.LivePlace, Gender = b.Gender, paName = b.Name,
  7870. BirthDay = b.BirthDay, HasPhoto = b.HasPhoto, Valid = a.Valid
  7871. FROM cvMain a WITH(NOLOCK) INNER JOIN paMain b WITH(NOLOCK) ON a.paMainID = b.ID
  7872. WHERE a.ID = #t.cvMainID AND TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  7873. UPDATE #t SET paName = LEFT(dbo.GetPersonName(cvMainID, @cpMainID), 20),
  7874. IsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID),
  7875. HasJobApply = (SELECT TOP 1 '1' FROM exJobApply a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#t.cvMainID),
  7876. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#t.cvMainID),
  7877. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#t.cvMainID),
  7878. HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#t.cvMainID)
  7879. WHERE TitleID > (@Page - 1)*20 AND TitleID <= @Page*20
  7880. UPDATE #T SET Speciality = (
  7881. SELECT Speciality FROM cvMain WITH(NOLOCK)
  7882. WHERE cvMain.ID = #T.cvMainID)
  7883. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  7884. UPDATE #T SET Experience = (
  7885. SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
  7886. WHERE cvExperience.cvMainID = #T.cvMainID
  7887. ORDER BY BeginDate DESC)
  7888. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  7889. UPDATE #T SET cvEducationID = (
  7890. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  7891. WHERE cvEducation.cvMainID = #T.cvMainID
  7892. AND #T.Degree = cvEducation.Degree
  7893. ORDER BY Graduation DESC)
  7894. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  7895. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType= b.EduType,
  7896. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  7897. FROM #T a, cvEducation b WITH(NOLOCK)
  7898. WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1) * 20 AND a.TitleID <= @Page*20
  7899. --修改是否绑定微信
  7900. UPDATE a SET HasWeiXin = 1
  7901. FROM #T a, WxFans b WITH(NOLOCK)
  7902. WHERE a.paMainID = b.PaMainID
  7903. AND b.Status = 2
  7904. AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  7905. SELECT COUNT(*) FROM #t WITH(NOLOCK)
  7906. SELECT * FROM #t WITH(NOLOCK) WHERE TitleID > (@Page - 1)*20 AND TitleID <= @Page*20
  7907. DROP TABLE #t
  7908. END
  7909. GO
  7910. /****** Object: StoredProcedure [dbo].[ccpaLoginContactByOpenIDSelect] Script Date: 2018/12/13 19:07:16 ******/
  7911. SET ANSI_NULLS ON
  7912. GO
  7913. SET QUOTED_IDENTIFIER ON
  7914. GO
  7915. --#####################################################
  7916. --创建时间:2016.4.6
  7917. --创建人:Lucifer
  7918. --说明:判断是否已绑定微信企业账号
  7919. --#####################################################
  7920. CREATE PROCEDURE [dbo].[ccpaLoginContactByOpenIDSelect]
  7921. (
  7922. @OpenID VARCHAR(100)
  7923. )
  7924. AS
  7925. BEGIN
  7926. SELECT * FROM paLoginContact WITH(NOLOCK) WHERE openid = @OpenID AND ContactType = 101
  7927. END
  7928. GO
  7929. /****** Object: StoredProcedure [dbo].[ccpaLoginContactDelete] Script Date: 2018/12/13 19:07:16 ******/
  7930. SET ANSI_NULLS ON
  7931. GO
  7932. SET QUOTED_IDENTIFIER ON
  7933. GO
  7934. CREATE PROCEDURE [dbo].[ccpaLoginContactDelete]
  7935. (
  7936. @caMainID INT,
  7937. @cpMainID INT
  7938. )
  7939. AS
  7940. SET NOCOUNT ON
  7941. BEGIN
  7942. IF NOT EXISTS(SELECT 'X' FROM caMain WITH(NOLOCK) WHERE ID = @caMainID AND cpMainID = @cpMainID)
  7943. RETURN
  7944. UPDATE wxFans SET caBindCancelDate = GETDATE() WHERE caMainID = @caMainID
  7945. DELETE FROM paLoginContact WHERE paMainID = @caMainID AND ContactType = 101
  7946. INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@cpMainID,22,-200,GETDATE())
  7947. END
  7948. GO
  7949. /****** Object: StoredProcedure [dbo].[ccPaMainBycpMainIdSelect] Script Date: 2018/12/13 19:07:16 ******/
  7950. SET ANSI_NULLS ON
  7951. GO
  7952. SET QUOTED_IDENTIFIER ON
  7953. GO
  7954. /**********************8
  7955. sean 2014-10-29
  7956. ***********************/
  7957. CREATE PROCEDURE [dbo].[ccPaMainBycpMainIdSelect]
  7958. (
  7959. @cvMainID INT,
  7960. @cpMainID INT
  7961. )
  7962. AS
  7963. --INSERT INTO procLog SELECT 'ccPaMainBycpMainIdSelect', LTRIM(STR(@cvMainID)) + ' ' + LTRIM(STR(@cpMainId)), GETDATE()
  7964. BEGIN
  7965. IF (@cpMainID = 0)
  7966. SELECT a.Name UserName, b.ID ShowID, a.Name ShowName, a.ID
  7967. FROM paMain a WITH(NOLOCK),
  7968. cvMain b WITH(NOLOCK)
  7969. WHERE a.ID = b.paMainID
  7970. AND b.ID = @cvMainID
  7971. ELSE
  7972. BEGIN
  7973. DECLARE @RegisterIp VARCHAR(50)
  7974. SELECT @RegisterIp = RegisterIp FROM cpMain WITH(NOLOCK) WHERE Id = @cpMainId
  7975. SELECT dbo.GetPaName(b.ID, @cpMainID) UserName, b.ID ShowID,
  7976. dbo.GetPaName(b.ID, @cpMainID) + '(' + (CASE Gender WHEN 0 THEN '男' WHEN 1 THEN '女' END) + '/' + CONVERT(VARCHAR(5),
  7977. dbo.BirthToAge(BirthDay)) + '岁/' + ISNULL(c.Description, '') + ')' ShowName,
  7978. LOWER(b.SecondId + SUBSTRING(SYS.Fn_VarbinToHexStr(HASHBYTES('SHA1', LTRIM(STR(a.Id)) + '-' + LTRIM(STR(@cpMainId)) + '#' + @RegisterIp + '*')), 13, 10)) HexId
  7979. FROM paMain a WITH(NOLOCK)
  7980. INNER JOIN cvMain b WITH(NOLOCK) ON a.ID = b.paMainID
  7981. LEFT JOIN dcEducation c WITH(NOLOCK) ON b.Degree = c.ID
  7982. WHERE b.ID = @cvMainID
  7983. END
  7984. END
  7985. GO
  7986. /****** Object: StoredProcedure [dbo].[ccPaMainByCvMainIdsSelect] Script Date: 2018/12/13 19:07:17 ******/
  7987. SET ANSI_NULLS ON
  7988. GO
  7989. SET QUOTED_IDENTIFIER ON
  7990. GO
  7991. --根据简历编号查询个人
  7992. --harry
  7993. --2017-6-12
  7994. CREATE PROCEDURE [dbo].[ccPaMainByCvMainIdsSelect]
  7995. (
  7996. @cvMainIds VARCHAR(200)
  7997. )
  7998. AS
  7999. SET NOCOUNT ON
  8000. BEGIN
  8001. SELECT COUNT(*) AS ReceiveNum FROM paMain WITH (NOLOCK)
  8002. WHERE id IN (SELECT paMainId FROM cvMain WHERE Id IN (SELECT * FROM dbo.FnSplit(@cvMainIds, ',')))
  8003. AND IsReceiveSms > 0
  8004. END
  8005. SET NOCOUNT OFF
  8006. GO
  8007. /****** Object: StoredProcedure [dbo].[ccPaMainByGetPaNameSelect] Script Date: 2018/12/13 19:07:17 ******/
  8008. SET ANSI_NULLS ON
  8009. GO
  8010. SET QUOTED_IDENTIFIER ON
  8011. GO
  8012. --lambo 20110221
  8013. --企业会员中心,根据cvMainID,cpMainID判断是否显示姓名
  8014. CREATE PROCEDURE [dbo].[ccPaMainByGetPaNameSelect]
  8015. (
  8016. @cvMainID INT,
  8017. @cpMainID INT
  8018. )
  8019. AS
  8020. BEGIN
  8021. SELECT dbo.GetPaName(@cvMainID, @cpMainID) Name
  8022. END
  8023. GO
  8024. /****** Object: StoredProcedure [dbo].[ccPaMainByGetPaNameSelect2] Script Date: 2018/12/13 19:07:17 ******/
  8025. SET ANSI_NULLS ON
  8026. GO
  8027. SET QUOTED_IDENTIFIER ON
  8028. GO
  8029. --lambo 20110221
  8030. --企业会员中心,根据cvMainID,cpMainID判断是否显示姓名
  8031. CREATE PROCEDURE [dbo].[ccPaMainByGetPaNameSelect2]
  8032. (
  8033. @cvMainID VARCHAR(50),
  8034. @cpMainID VARCHAR(50)
  8035. )
  8036. AS
  8037. BEGIN
  8038. SELECT dbo.GetPaName(@cvMainID, @cpMainID) Name
  8039. END
  8040. GO
  8041. /****** Object: StoredProcedure [dbo].[ccPaPlaintByCaMainIDNoViewedSelect] Script Date: 2018/12/13 19:07:17 ******/
  8042. SET ANSI_NULLS ON
  8043. GO
  8044. SET QUOTED_IDENTIFIER ON
  8045. GO
  8046. --==================================================
  8047. --检查 sean 2010-10-8
  8048. --描述 企业账号未查看的个人用户反馈
  8049. --==================================================
  8050. CREATE PROCEDURE [dbo].[ccPaPlaintByCaMainIDNoViewedSelect]
  8051. (
  8052. @caMainID INT
  8053. )
  8054. AS
  8055. BEGIN
  8056. SELECT *
  8057. FROM PaPlaint WITH(NOLOCK INDEX(IX_paPlaint_caMainID))
  8058. WHERE caMainID = @caMainID
  8059. AND IsViewed=0
  8060. AND ReplyType =1
  8061. ORDER BY ID DESC
  8062. END
  8063. GO
  8064. /****** Object: StoredProcedure [dbo].[ccPaPlaintByCaMainIDSelect] Script Date: 2018/12/13 19:07:17 ******/
  8065. SET ANSI_NULLS ON
  8066. GO
  8067. SET QUOTED_IDENTIFIER ON
  8068. GO
  8069. --==================================================
  8070. --检查 sean 2010-10-8
  8071. --描述 企业账号查看个人用户反馈
  8072. --==================================================
  8073. CREATE PROCEDURE [dbo].[ccPaPlaintByCaMainIDSelect]
  8074. (
  8075. @caMainID INT
  8076. )
  8077. AS
  8078. BEGIN
  8079. SELECT *
  8080. FROM PaPlaint WITH(NOLOCK INDEX(IX_paPlaint_caMainID))
  8081. WHERE caMainID =@caMainID
  8082. AND ReplyType =1
  8083. ORDER BY ID DESC
  8084. END
  8085. GO
  8086. /****** Object: StoredProcedure [dbo].[ccPaPlaintByCpMainIDNoViewedSelect] Script Date: 2018/12/13 19:07:17 ******/
  8087. SET ANSI_NULLS ON
  8088. GO
  8089. SET QUOTED_IDENTIFIER ON
  8090. GO
  8091. --==================================================
  8092. --检查 sean 2010-10-8
  8093. --描述 该企业所有账号的未查看的个人用户反馈
  8094. --==================================================
  8095. CREATE PROCEDURE [dbo].[ccPaPlaintByCpMainIDNoViewedSelect]
  8096. (
  8097. @cpMainID INT
  8098. )
  8099. AS
  8100. BEGIN
  8101. SELECT *
  8102. FROM PaPlaint a WITH(NOLOCK INDEX(IX_paPlaint_caMainID)), caMain b WITH(NOLOCK INDEX(IX_caMain_cpMainID))
  8103. WHERE a.caMainID = b.ID
  8104. AND b.cpMainID = @cpMainID
  8105. AND IsViewed=0
  8106. AND ReplyType =1
  8107. ORDER BY a.CaMainID,a.ID DESC
  8108. END
  8109. GO
  8110. /****** Object: StoredProcedure [dbo].[ccPaPlaintByCpMainIDSelect] Script Date: 2018/12/13 19:07:18 ******/
  8111. SET ANSI_NULLS ON
  8112. GO
  8113. SET QUOTED_IDENTIFIER ON
  8114. GO
  8115. --==================================================
  8116. --检查 sean 2010-10-8
  8117. --描述 该企业所有账号的个人用户反馈
  8118. --==================================================
  8119. CREATE PROCEDURE [dbo].[ccPaPlaintByCpMainIDSelect]
  8120. (
  8121. @cpMainID INT
  8122. )
  8123. AS
  8124. BEGIN
  8125. SELECT a.*,
  8126. b.Name caName
  8127. FROM PaPlaint a WITH(NOLOCK INDEX(IX_paPlaint_caMainID)), caMain b WITH(NOLOCK INDEX(IX_caMain_cpMainID))
  8128. WHERE a.caMainID = b.ID
  8129. AND b.cpMainID = @cpMainID
  8130. AND ReplyType = 1
  8131. AND b.isDelete = 0
  8132. ORDER BY a.CaMainID,a.ID DESC
  8133. END
  8134. GO
  8135. /****** Object: StoredProcedure [dbo].[ccPaplaintByIsViewedUpdate] Script Date: 2018/12/13 19:07:18 ******/
  8136. SET ANSI_NULLS ON
  8137. GO
  8138. SET QUOTED_IDENTIFIER ON
  8139. GO
  8140. --==================================================
  8141. --检查 sean 2010-10-8
  8142. --描述 修改个人用户反馈的查看状态 ,一次一屏,asp中取所有IsViewed = false的id
  8143. --==================================================
  8144. CREATE PROCEDURE [dbo].[ccPaplaintByIsViewedUpdate]
  8145. (
  8146. @AllID VARCHAR(200),
  8147. @caMainID INT
  8148. )
  8149. AS
  8150. BEGIN TRY
  8151. SET @AllID = dbo.FormatIDS(@AllID)
  8152. DECLARE @T AS TABLE(ID INT)
  8153. INSERT INTO @T SELECT * FROM dbo.fnSplit(@AllID, ',')
  8154. UPDATE paplaint SET IsViewed=1 WHERE ID IN(SELECT ID FROM @T) AND caMainID = @caMainID
  8155. RETURN 1
  8156. END TRY
  8157. BEGIN CATCH
  8158. RETURN 0
  8159. END CATCH
  8160. GO
  8161. /****** Object: StoredProcedure [dbo].[ccQuotaLogInsert] Script Date: 2018/12/13 19:07:18 ******/
  8162. SET ANSI_NULLS ON
  8163. GO
  8164. SET QUOTED_IDENTIFIER ON
  8165. GO
  8166. --分配配额
  8167. --harry
  8168. --2017-12-5
  8169. CREATE PROCEDURE [dbo].[ccQuotaLogInsert]
  8170. (
  8171. @quotaType INT, ---1简历
  8172. @orderId INT,
  8173. @cpMainId INT,
  8174. @caIds VARCHAR(1000),
  8175. @data VARCHAR(1000),
  8176. @isallocate BIT---0共享 1分配
  8177. )
  8178. AS
  8179. SET NOCOUNT ON
  8180. DECLARE @sumCount INT ,@sumSetCount INT
  8181. IF @quotaType = 1--简历
  8182. BEGIN
  8183. IF @isallocate =0
  8184. BEGIN
  8185. DELETE FROM QuotaLog WHERE CaOrderId = @orderId AND cpMainId = @cpMainId
  8186. UPDATE caOrder SET isCvAllocate= 0 WHERE id = @orderId
  8187. END
  8188. ELSE
  8189. BEGIN
  8190. --计算分配总数是否=简历数
  8191. SELECT @sumCount=SUM(ActiveQuota) FROM caOrder
  8192. WHERE orderType IN(8,9)
  8193. AND OpenDate IS NOT NULl
  8194. AND IsDeleted = 0
  8195. AND (MainOrderID = @orderId OR Id =@orderId)
  8196. DECLARE @T AS TABLE(id INT identity(1,1),data INT)
  8197. INSERT INTO @T(data) SELECT * FROM dbo.fnSplit(@data, ',')
  8198. SELECT @sumSetCount=SUM(data)FROM @T
  8199. IF @sumSetCount = @sumCount --数值正确,进行分配
  8200. BEGIN
  8201. DECLARE @Tid AS TABLE(id INT identity(1,1),caId INT)
  8202. DECLARE @caId INT, @id INT
  8203. INSERT INTO @Tid(caId) SELECT * FROM dbo.fnSplit(@caIds, ',')
  8204. WHILE EXISTS(SELECT 'x' FROM @Tid)
  8205. BEGIN
  8206. SELECT TOP 1 @id = id, @caId =caId FROM @Tid
  8207. IF EXISTS(SELECT 'x' FROM QuotaLog WHERE CaOrderId = @orderId AND cpMainId = @cpMainId AND CaMainId = @caId AND QuotaType =1 )
  8208. BEGIN
  8209. UPDATE QuotaLog
  8210. SET Quota =(SELECT TOP 1 data FROM @T WHERE id = @id)
  8211. WHERE CaOrderId = @orderId AND cpMainId = @cpMainId AND CaMainId = @caId AND QuotaType =1
  8212. DELETE FROM @Tid WHERE id = @id
  8213. END
  8214. ELSE
  8215. BEGIN
  8216. INSERT INTO QuotaLog(QuotaType, CaOrderId, CaMainId,CpMainId, Quota, RemainQuota, AddDate)
  8217. SELECT 1, @orderId, @caId, @cpMainId, (SELECT TOP 1 data FROM @T WHERE id = @id),(SELECT TOP 1 data FROM @T WHERE id = @id), GETDATE()
  8218. DELETE FROM @Tid WHERE id = @id
  8219. END
  8220. END
  8221. UPDATE QuotaLog
  8222. SET RemainQuota= Quota -(SELECT COUNT(1) FROM caactivelog WHERE caMainId = QuotaLog.CaMainId AND CaOrderId =QuotaLog.CaOrderId)
  8223. WHERE QuotaType =1 AND cpMainId = @cpMainId
  8224. UPDATE caOrder SET isCvAllocate= 1 WHERE id = @orderId
  8225. END
  8226. END
  8227. END
  8228. SET NOCOUNT OFF
  8229. GO
  8230. /****** Object: StoredProcedure [dbo].[ccQuotaLogSelect] Script Date: 2018/12/13 19:07:19 ******/
  8231. SET ANSI_NULLS ON
  8232. GO
  8233. SET QUOTED_IDENTIFIER ON
  8234. GO
  8235. --根据订单号获取简历下载信息
  8236. --harry
  8237. --2017-12-5
  8238. CREATE PROCEDURE [dbo].[ccQuotaLogSelect]
  8239. (
  8240. @quotaType INT, ---1简历
  8241. @orderId INT,
  8242. @cpMainId INT
  8243. )
  8244. AS
  8245. INSERT INTO ProcLog SELECT 'ccQuotaLogSelect', @cpMainId, GETDATE()
  8246. SET NOCOUNT ON
  8247. CREATE TABLE #t
  8248. (
  8249. caMainId INT,
  8250. Username VARCHAR(100),
  8251. name NVARCHAR(50),
  8252. accountType INT,
  8253. IsPause BIT,
  8254. IsDelete BIT,
  8255. Quota INT,
  8256. UsedQuota INT
  8257. )
  8258. DECLARE @isAllocate BIT --该内容是否分享是否分享
  8259. IF @quotaType =1
  8260. BEGIN
  8261. SELECT @isAllocate = ISNULL(isCvAllocate,0) FROM caOrder WITH(NOLOCK) WHERE id= @orderId
  8262. END
  8263. --先插入用户
  8264. INSERT INTO #t(caMainId, Username, name, accountType, isPause, isDelete, Quota, UsedQuota)
  8265. SELECT ID, userName, Name,accountType, isPause, isDelete, 0, 0
  8266. FROM caMain
  8267. WHERE cpMainId = @cpMainId
  8268. --再更新分配的用户数据
  8269. UPDATE #t
  8270. SET Quota = b.Quota, UsedQuota =(b.Quota-b.ReMainQuota)
  8271. FROM #t a, QuotaLog b
  8272. WHERE b.caOrderId = @orderId
  8273. AND a.caMainId = b.caMainid
  8274. AND b.QuotaType = @quotaType
  8275. IF @isAllocate = 0--共享的计算使用量
  8276. BEGIN
  8277. IF @quotaType = 1
  8278. BEGIN
  8279. UPDATE #t
  8280. SET UsedQuota = (SELECT COUNT(1) FROM caActivelog WHERE caMainID = #t.caMainId AND (caOrderId= @orderId OR caOrderId IN (SELECT Id FROM caOrder WITH(NOLOCK)
  8281. WHERE orderType = 9
  8282. AND OpenDate IS NOT NULl
  8283. AND IsDeleted = 0
  8284. AND MainOrderID = @orderId)))
  8285. END
  8286. END
  8287. --先获取订单信息
  8288. IF @quotaType = 1
  8289. BEGIN
  8290. SELECT * FROM caOrder WITH(NOLOCK)
  8291. WHERE (id = @orderId
  8292. OR MainOrderID = @orderId)
  8293. AND (orderType = 8 OR orderType = 9)
  8294. AND OpenDate IS NOT NULl
  8295. AND IsDeleted = 0
  8296. END
  8297. --再获取分配信息
  8298. SELECT * FROM #t
  8299. DROP TABLE #t
  8300. SET NOCOUNT OFF
  8301. GO
  8302. /****** Object: StoredProcedure [dbo].[ccQuotaLogSelectByCaMainid] Script Date: 2018/12/13 19:07:19 ******/
  8303. SET ANSI_NULLS ON
  8304. GO
  8305. SET QUOTED_IDENTIFIER ON
  8306. GO
  8307. --分配配额查询
  8308. --harry
  8309. --2017-12-11
  8310. CREATE PROCEDURE [dbo].[ccQuotaLogSelectByCaMainid]
  8311. (
  8312. @quotaType INT, ---1简历
  8313. @cpMainId INT,
  8314. @caMainId INT
  8315. )
  8316. AS
  8317. SET NOCOUNT ON
  8318. DECLARE @isAllocate BIT ,@validVipOrder INT, @ActiveQuota INT, @RemainQuota INT
  8319. IF @quotaType = 1--简历
  8320. BEGIN
  8321. --获取当前的vip订单号
  8322. SELECT @validVipOrder =id, @ActiveQuota = ActiveQuota, @RemainQuota = RemainQuota, @isAllocate = isCvAllocate
  8323. FROM caOrder
  8324. WHERE cpMainId = @cpMainId
  8325. AND IsDeleted =0
  8326. AND openDate<GETDATE()
  8327. AND beginDate<GETDATE()
  8328. AND endDate>GETDATE()
  8329. AND orderType = 8
  8330. --筛选判断是否进行分配
  8331. IF ISNULL(@isAllocate,0) =1
  8332. BEGIN
  8333. SELECT Quota,RemainQuota, @isAllocate IsAllocate FROM QuotaLog WITH(NOLOCK) WHERE caOrderId = @validVipOrder AND caMainId = @caMainId AND cpMainId = @cpMainId
  8334. END
  8335. ELSE
  8336. BEGIN
  8337. SELECT SUM(ISNULL(ActiveQuota,0)) AS Quota, SUM(ISNULL(RemainQuota,0)) AS RemainQuota, @isAllocate IsAllocate
  8338. FROM caOrder
  8339. WHERE cpMainId = @cpMainId
  8340. AND IsDeleted =0
  8341. AND openDate<GETDATE()
  8342. AND beginDate<GETDATE()
  8343. AND endDate>GETDATE()
  8344. END
  8345. END
  8346. SET NOCOUNT OFF
  8347. GO
  8348. /****** Object: StoredProcedure [dbo].[ccRecommendCvBySearchSelect] Script Date: 2018/12/13 19:07:19 ******/
  8349. SET ANSI_NULLS ON
  8350. GO
  8351. SET QUOTED_IDENTIFIER ON
  8352. GO
  8353. --修改Harry2018-4-19
  8354. --将ptCvInvitation 换为 ptWeixinFollow
  8355. CREATE PROCEDURE [dbo].[ccRecommendCvBySearchSelect]
  8356. (
  8357. @dcRegionID INT, --求职地区
  8358. @RecruitmentPlaceID INT, --场馆ID
  8359. @PageNumber INT, --翻页页码
  8360. @caMainID INT, --企业用户ID,用来判断是否和建立联系
  8361. @dcJobTypeIDExpect VARCHAR(50), --职位类别
  8362. @KeyWord NVARCHAR(20) --关键词
  8363. )
  8364. AS
  8365. --return
  8366. SET NOCOUNT ON
  8367. BEGIN TRY
  8368. IF @dcRegionID IS NULL
  8369. SET @dcRegionID = ''
  8370. IF @RecruitmentPlaceID > 0
  8371. SET @dcRegionID = ''
  8372. DECLARE @KeyTemp NVARCHAR(20)
  8373. SET @KeyWord = LTRIM(RTRIM(dbo.SafeSQL(REPLACE(@KeyWord, ' ', ' '))))
  8374. SET @KeyWord = REPLACE(@KeyWord, '''', '')
  8375. SET @KeyTemp = @KeyWord
  8376. IF @KeyWord IS NULL OR LEN(@KeyWord) < 2
  8377. SELECT @KeyWord = '', @KeyTemp = ''
  8378. IF @dcJobTypeIDExpect IS NULL
  8379. SET @dcJobTypeIDExpect = ''
  8380. ELSE
  8381. SET @dcJobTypeIDExpect = REPLACE(REPLACE(LTRIM(RTRIM(@dcJobTypeIDExpect)), ' ', ','), '''', '')
  8382. SET @dcJobTypeIDExpect = dbo.FormatIDS(@dcJobTypeIDExpect)
  8383. IF @RecruitmentPlaceID IS NULL OR @RecruitmentPlaceID = 0
  8384. SET @RecruitmentPlaceID = 0
  8385. DECLARE @cpSearchConditionID AS INT
  8386. SELECT @cpSearchConditionID=0
  8387. DECLARE @MinId AS INT
  8388. --SQLSERVER中计划任务自动删除60分钟前的数据
  8389. SELECT TOP 1 @cpSearchConditionID = ID
  8390. FROM SearchDB..cpSearchCondition WITH(NOLOCK)
  8391. WHERE dcRegionID=@dcRegionID AND RecruitmentPlaceID=@RecruitmentPlaceID
  8392. AND dcJobTypeID=@dcJobTypeIDExpect AND KeyWord=@KeyWord
  8393. ORDER BY ID DESC
  8394. IF ISNULL(@cpSearchConditionID, 0) = 0
  8395. GOTO SELECTRESET --无数据,重新搜索
  8396. ELSE
  8397. GOTO GETRECORDSET --从临时结果中提取数据
  8398. SELECTRESET: --从cv中搜索数据
  8399. BEGIN
  8400. DECLARE @SQL AS VARCHAR(8000),
  8401. @WHERE AS VARCHAR(8000),
  8402. @FROM AS VARCHAR(1000)
  8403. SELECT @WHERE = ''
  8404. ----记录查询条件
  8405. INSERT INTO SearchDB..cpSearchCondition(SessionID, dcRegionID, RecruitmentPlaceID, ReuseNumber, dcJobTypeIDExpect, KeyWord)
  8406. VALUES(1, @dcRegionID, @RecruitmentPlaceID, 0, @dcJobTypeIDExpect, @KeyWord)
  8407. SET @cpSearchConditionID = @@IDENTITY
  8408. ----建立关键字搜索的临时表
  8409. CREATE TABLE #FullText(
  8410. CvID INT NOT NULL
  8411. )
  8412. ----建立临时表
  8413. CREATE TABLE #Cv(
  8414. ID INT NOT NULL,
  8415. RefreshDate SMALLDATETIME NOT NULL,
  8416. ptCvInvitationId INT
  8417. )
  8418. ----生成求聘职位的表变量
  8419. DECLARE @JobTypeExpect AS VARCHAR(3000)
  8420. SET @JobTypeExpect=''
  8421. DECLARE @T_JobType AS TABLE(ID INT)
  8422. IF LEN(@dcJobTypeIDExpect) > 0
  8423. BEGIN
  8424. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  8425. INSERT INTO @T_Temp
  8426. SELECT * FROM dbo.fnSplit(@dcJobTypeIDExpect, ',')
  8427. INSERT INTO @T_JobType
  8428. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  8429. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  8430. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  8431. OR ID IN(SELECT ID FROM @T_TEMP)
  8432. ----生成in字符串
  8433. SELECT @JobTypeExpect = (@JobTypeExpect + LTRIM(STR(ID) + ',')) FROM @T_JobType
  8434. IF RIGHT(@JobTypeExpect, 1) = ','
  8435. SET @JobTypeExpect = LEFT(@JobTypeExpect, LEN(@JobTypeExpect) - 1)
  8436. END
  8437. ----期望职位类别
  8438. IF LEN(@dcJobTypeIDExpect) > 0
  8439. BEGIN
  8440. SET @WHERE = '
  8441. AND (g.dcJobTypeID IN(' + @JobTypeExpect +'))'
  8442. END
  8443. ----关键词
  8444. IF LEN(@KeyTemp) > 0 --AND @MajorName IS NULL
  8445. BEGIN
  8446. DECLARE @S DATETIME, @SqlFt VARCHAR(MAX)
  8447. SELECT @S = GETDATE()
  8448. INSERT INTO #FullText
  8449. SELECT [key] FROM CONTAINSTABLE(CvMainPublish, *, @KeyTemp, 100000) AS KeyCv
  8450. INSERT INTO #FullText
  8451. SELECT DISTINCT cvMainID FROM CvExperiencePublish WITH(NOLOCK) WHERE ID IN(
  8452. SELECT [key] FROM CONTAINSTABLE(CvExperiencePublish, *, @KeyTemp, 100000) AS KeyCv)
  8453. INSERT INTO #FullText
  8454. SELECT DISTINCT cvMainID FROM CvEducationPublish WITH(NOLOCK) WHERE ID IN(
  8455. SELECT [key] FROM CONTAINSTABLE(CvEducationPublish, *, @KeyTemp, 100000) AS KeyCv)
  8456. INSERT INTO #FullText
  8457. SELECT DISTINCT cvMainID FROM CvProjectPublish WITH(NOLOCK) WHERE ID IN(
  8458. SELECT [key] FROM CONTAINSTABLE(CvProjectPublish, *, @KeyTemp, 100000) AS KeyCv)
  8459. INSERT INTO #FullText
  8460. SELECT DISTINCT cvMainID FROM CvTrainingPublish WITH(NOLOCK) WHERE ID IN(
  8461. SELECT [key] FROM CONTAINSTABLE(CvTrainingPublish, *, @KeyTemp, 100000) AS KeyCv)
  8462. --Richard 2011.8.21增加
  8463. INSERT INTO #FullText
  8464. SELECT DISTINCT cvMainID FROM CvAppendixPublish WITH(NOLOCK) WHERE ID IN(
  8465. SELECT [key] FROM CONTAINSTABLE(CvAppendixPublish, *, @KeyTemp, 100000) AS KeyCv)
  8466. --Richard 2011.8.24增加
  8467. SELECT @SqlFt = 'SELECT [key] FROM CONTAINSTABLE(CvMainPublish, *, ''' + @KeyTemp + ''', 100000) AS KeyCv ORDER BY [key] DESC 开始:' + CONVERT(varchar(8), @S, 8) + ' 结束:' + CONVERT(varchar(8), getdate(), 8)
  8468. UPDATE SearchDB..cpSearchCondition SET SqlFT = @SqlFt WHERE ID = @cpSearchConditionID
  8469. END
  8470. ----生成插入临时表的Sql语句
  8471. SET @SQL = '
  8472. INSERT INTO #Cv
  8473. SELECT DISTINCT TOP 2000 a.ID, j.LastLoginDate, b.Id'
  8474. SET @FROM = '
  8475. FROM cvmainPublish a WITH(NOLOCK)
  8476. INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainId = j.Id
  8477. INNER JOIN MarketDb..ptWeixinFollow b WITH(NOLOCK) ON a.paMainID=b.BindPaMainID AND b.AddDate > GETDATE() - 90
  8478. INNER JOIN MarketDb..ptWorkAppoint c WITH(NOLOCK) ON b.ptWorkAppointID=c.ID
  8479. INNER JOIN Recruitment d WITH(NOLOCK) ON c.RecruitmentID=d.ID
  8480. INNER JOIN RecruitmentPlace e WITH(NOLOCK) ON d.RecruitmentPlaceID=e.ID'
  8481. IF @RecruitmentPlaceID = 0
  8482. SET @FROM = @FROM + ' AND e.dcRegionID LIKE ''' + CONVERT(VARCHAR, @dcRegionID) + '%'''
  8483. ELSE
  8484. SET @FROM = @FROM + ' AND e.ID=' + CONVERT(VARCHAR, @RecruitmentPlaceID)
  8485. IF CHARINDEX('g.', @WHERE) > 0
  8486. SET @FROM = @FROM + ' INNER JOIN cvJobTypePublish g WITH(NOLOCK) ON a.ID=g.cvMainID'
  8487. IF LEN(@KeyTemp) > 0 --AND @MajorName IS NULL
  8488. SET @FROM = @FROM + ' INNER JOIN #FullText k WITH(NOLOCK) ON a.ID=k.cvID'
  8489. SET @SQL = @SQL + @FROM + @WHERE
  8490. SET @SQL = @SQL + ' ORDER BY b.Id DESC' --j.LastLoginDate DESC, a.ID'
  8491. PRINT @SQL
  8492. ----把符合条件的职位全部列出
  8493. UPDATE SearchDB..cpSearchCondition SET Sql = REPLACE(@SQL, 'INSERT INTO #Cv', ''), StartDate = GETDATE() WHERE ID = @cpSearchConditionID
  8494. EXEC(@SQL)
  8495. ----记录查询结果总数
  8496. DECLARE @ValidCvNumber INT
  8497. SET @ValidCvNumber = @@ROWCOUNT
  8498. UPDATE SearchDB..cpSearchCondition SET ValidCvNumber = @ValidCvNumber WHERE ID = @cpSearchConditionID
  8499. --记录查询时间
  8500. UPDATE SearchDB..cpSearchCondition SET EndDate = GETDATE() WHERE ID = @cpSearchConditionID
  8501. INSERT INTO SearchDB..cpSearchCvID
  8502. SELECT TOP 2000 @cpSearchConditionID, ID FROM #Cv WITH(NOLOCK)
  8503. DROP TABLE #Cv
  8504. DROP TABLE #FullText
  8505. GOTO GETRECORDSET
  8506. END
  8507. GETRECORDSET:
  8508. BEGIN
  8509. DECLARE @PageSize AS TINYINT
  8510. SET @PageSize = 20 --每页的行数
  8511. ----返回查询数量
  8512. UPDATE SearchDB..cpSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@cpSearchConditionID
  8513. SELECT ValidCvNumber FROM SearchDB..cpSearchCondition WITH(NOLOCK) WHERE ID=@cpSearchConditionID
  8514. ----返回20行查询结果
  8515. IF @PageNumber > 0
  8516. BEGIN
  8517. DECLARE @T_CvList AS TABLE(
  8518. ID INT,
  8519. cvEducationID INT,
  8520. dcMajorID INT,
  8521. Degree TINYINT,
  8522. RelatedWorkYears INT,
  8523. dcSalaryID TINYINT,
  8524. RefreshDate SMALLDATETIME,
  8525. LastLoginDate SMALLDATETIME,
  8526. JobName VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
  8527. Gender BIT,
  8528. BirthDay INT,
  8529. LivePlace INT,
  8530. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  8531. HasPhoto TINYINT,
  8532. College NVARCHAR(50),
  8533. EduType TINYINT,
  8534. MajorName NVARCHAR(20),
  8535. Graduation INT,
  8536. HasViewed BIT,
  8537. ViewDate SMALLDATETIME,
  8538. LastJobTypeID INT,
  8539. Valid TINYINT,
  8540. PlaceName NVARCHAR(50),
  8541. RecommendDate SMALLDATETIME,
  8542. RecruitmentName NVARCHAR(50),
  8543. IsOnline BIT,
  8544. HasWeiXin BIT,
  8545. paMainId INT,
  8546. SecondId VARCHAR(10)
  8547. )
  8548. SELECT @MinId = MIN(ID) FROM SearchDB..cpSearchCvID WITH(NOLOCK) WHERE cpSearchConditionID = @cpSearchConditionID
  8549. SET @MinId = @MinId + (@PageNumber-1) * @PageSize
  8550. INSERT INTO @T_CvList(ID, dcMajorID, Degree, RelatedWorkYears, dcSalaryID, RefreshDate, LastLoginDate,
  8551. JobName, Gender, BirthDay, LivePlace, LastJobTypeID, Attachment, HasPhoto, HasViewed, Valid, IsOnline, paMainId, SecondId)
  8552. SELECT TOP 20 a.ID, a.dcMajorID, a.Degree, a.RelatedWorkYears, a.dcSalaryID, a.RefreshDate,
  8553. j.LastLoginDate, ISNULL(a.JobName, '应届毕业生') JobName, j.Gender, j.BirthDay, j.LivePlace, a.LastJobTypeID,
  8554. a.Attachment, j.HasPhoto, 0, a.Valid, dbo.GetPaOnlineStatus(j.ID), a.paMainId, a.SecondId
  8555. FROM cvmain a WITH(NOLOCK)
  8556. INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID=j.ID
  8557. INNER JOIN SearchDB..cpSearchCvID b ON a.id=b.CvID
  8558. WHERE b.cpSearchConditionID=@cpSearchConditionID AND b.ID >= @MinId
  8559. ORDER BY b.ID, a.ID DESC
  8560. --RICHARD 2011-7-23 16:51分修改
  8561. UPDATE a
  8562. SET a.cvEducationID = (
  8563. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  8564. WHERE cvEducation.cvMainID = a.ID
  8565. AND a.Degree = cvEducation.Degree
  8566. ORDER BY Graduation DESC)
  8567. FROM @T_CvList a
  8568. UPDATE a SET a.PlaceName = f.PlaceName, a.LastLoginDate = c.AddDate, --a.RecommendDate = c.AddDate,
  8569. a.RecruitmentName = e.RecruitmentName
  8570. FROM @T_CvList a, cvMain b WITH(NOLOCK), MarketDb..ptWeixinFollow c WITH(NOLOCK),
  8571. MarketDb..ptWorkAppoint d WITH(NOLOCK),
  8572. Recruitment e WITH(NOLOCK), RecruitmentPlace f WITH(NOLOCK)
  8573. WHERE a.ID=b.ID AND b.paMainID=c.BindPaMainID AND c.ptWorkAppointID=d.ID
  8574. AND d.RecruitmentID=e.ID AND e.RecruitmentPlaceID=f.ID
  8575. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  8576. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  8577. FROM @T_CvList a, cvEducation b WITH(NOLOCK)
  8578. WHERE b.ID = a.cvEducationID
  8579. --修改是否绑定微信
  8580. UPDATE a SET HasWeiXin = 1
  8581. FROM @T_CvList a, WxFans b WITH(NOLOCK), CvMain c WITH(NOLOCK)
  8582. WHERE a.ID = c.ID
  8583. AND c.PaMainID = b.PaMainID
  8584. AND b.Status = 2
  8585. UPDATE a SET a.HasViewed = 1, a.ViewDate = b.AddDate
  8586. FROM @T_CvList a, caCvViewLog b WITH(NOLOCK)
  8587. WHERE b.cvMainID = a.ID AND caMainID=@caMainID
  8588. SELECT a.*,b.Description DegreeName,c.Description LivePlaceName, dbo.BirthToAge(a.BirthDay) Age,d.Description dcSalaryName
  8589. FROM @T_CvList a
  8590. LEFT JOIN MainDB..dcEducation b WITH(NOLOCK) ON b.ID = a.Degree
  8591. LEFT JOIN MainDB..dcRegion c WITH(NOLOCK) ON c.ID = a.LivePlace
  8592. LEFT JOIN dcSalary d WITH(NOLOCK) ON d.ID = a.dcSalaryID
  8593. END
  8594. RETURN
  8595. END
  8596. END TRY
  8597. BEGIN CATCH
  8598. ---检查是否已经建立临时表,已经建立则删除
  8599. BEGIN TRY
  8600. DROP TABLE #FullText
  8601. END TRY
  8602. BEGIN CATCH
  8603. END CATCH
  8604. BEGIN TRY
  8605. DROP TABLE #cv
  8606. END TRY
  8607. BEGIN CATCH
  8608. END CATCH
  8609. PRINT '查询时出现错误,请联系技术人员检查,错误信息:'
  8610. PRINT Error_Message()
  8611. PRINT Error_Number()
  8612. PRINT Error_Line()
  8613. END CATCH
  8614. GO
  8615. /****** Object: StoredProcedure [dbo].[ccRecommendCvBySearchSelect0630] Script Date: 2018/12/13 19:07:19 ******/
  8616. SET ANSI_NULLS ON
  8617. GO
  8618. SET QUOTED_IDENTIFIER ON
  8619. GO
  8620. CREATE PROCEDURE [dbo].[ccRecommendCvBySearchSelect0630]
  8621. (
  8622. @dcRegionID INT, --求职地区
  8623. @RecruitmentPlaceID INT, --场馆ID
  8624. @PageNumber INT, --翻页页码
  8625. @caMainID INT, --企业用户ID,用来判断是否和建立联系
  8626. @dcJobTypeIDExpect VARCHAR(50), --职位类别
  8627. @KeyWord NVARCHAR(20) --关键词
  8628. )
  8629. AS
  8630. --return
  8631. SET NOCOUNT ON
  8632. BEGIN TRY
  8633. IF @dcRegionID IS NULL
  8634. SET @dcRegionID = ''
  8635. DECLARE @KeyTemp NVARCHAR(20)
  8636. WHILE @KeyWord LIKE '% %'
  8637. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  8638. SET @KeyWord = LTRIM(RTRIM(dbo.SafeSQL(@KeyWord)))
  8639. SET @KeyTemp = @KeyWord
  8640. IF @KeyWord IS NULL OR LEN(@KeyWord) < 2
  8641. SELECT @KeyWord = '', @KeyTemp = ''
  8642. IF @dcJobTypeIDExpect IS NULL
  8643. SET @dcJobTypeIDExpect = ''
  8644. ELSE
  8645. SET @dcJobTypeIDExpect = REPLACE(LTRIM(RTRIM(@dcJobTypeIDExpect)), ' ', ',')
  8646. SET @dcJobTypeIDExpect = dbo.FormatIDS(@dcJobTypeIDExpect)
  8647. IF @RecruitmentPlaceID IS NULL OR @RecruitmentPlaceID = 0
  8648. SET @RecruitmentPlaceID = 0
  8649. DECLARE @cpSearchConditionID AS INT
  8650. SELECT @cpSearchConditionID=0
  8651. DECLARE @MinId AS INT
  8652. --SQLSERVER中计划任务自动删除60分钟前的数据
  8653. SELECT TOP 1 @cpSearchConditionID = ID FROM SearchDB..cpSearchCondition WITH(NOLOCK)
  8654. WHERE dcRegionID=@dcRegionID AND RecruitmentPlaceID=@RecruitmentPlaceID AND dcJobTypeID=@dcJobTypeIDExpect AND KeyWord=@KeyWord
  8655. ORDER BY ID DESC
  8656. IF ISNULL(@cpSearchConditionID, 0) = 0
  8657. GOTO SELECTRESET --无数据,重新搜索
  8658. ELSE
  8659. GOTO GETRECORDSET --从临时结果中提取数据
  8660. SELECTRESET: --从cv中搜索数据
  8661. BEGIN
  8662. DECLARE @SQL AS VARCHAR(8000)
  8663. DECLARE @WHERE AS VARCHAR(8000)
  8664. DECLARE @FROM AS VARCHAR(1000)
  8665. SELECT @WHERE = ''
  8666. ----记录查询条件
  8667. INSERT INTO SearchDB..cpSearchCondition(SessionID,dcRegionID,RecruitmentPlaceID,ReuseNumber,dcJobTypeIDExpect,KeyWord)
  8668. VALUES(1,@dcRegionID,@RecruitmentPlaceID,0,@dcJobTypeIDExpect,@KeyWord)
  8669. SET @cpSearchConditionID = @@IDENTITY
  8670. ----建立关键字搜索的临时表
  8671. CREATE TABLE #FullText(
  8672. CvID INT NOT NULL
  8673. )
  8674. ----建立临时表
  8675. CREATE TABLE #Cv(
  8676. ID INT NOT NULL,
  8677. RefreshDate SMALLDATETIME NOT NULL
  8678. )
  8679. ----生成求聘职位的表变量
  8680. DECLARE @JobTypeExpect AS VARCHAR(3000)
  8681. SET @JobTypeExpect=''
  8682. DECLARE @T_JobType AS TABLE(ID INT)
  8683. IF LEN(@dcJobTypeIDExpect) > 0
  8684. BEGIN
  8685. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  8686. INSERT INTO @T_Temp
  8687. SELECT * FROM dbo.fnSplit(@dcJobTypeIDExpect, ',')
  8688. INSERT INTO @T_JobType
  8689. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  8690. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  8691. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  8692. OR ID IN(SELECT ID FROM @T_TEMP)
  8693. ----生成in字符串
  8694. SELECT @JobTypeExpect = (@JobTypeExpect + LTRIM(STR(ID) + ',')) FROM @T_JobType
  8695. IF RIGHT(@JobTypeExpect, 1) = ','
  8696. SET @JobTypeExpect = LEFT(@JobTypeExpect, LEN(@JobTypeExpect) - 1)
  8697. END
  8698. ----期望职位类别
  8699. IF LEN(@dcJobTypeIDExpect) > 0
  8700. BEGIN
  8701. SET @WHERE = '
  8702. AND (g.dcJobTypeID IN(' + @JobTypeExpect +'))'
  8703. END
  8704. ----关键词
  8705. IF LEN(@KeyTemp) > 0 --AND @MajorName IS NULL
  8706. BEGIN
  8707. DECLARE @S DATETIME, @SqlFt VARCHAR(MAX)
  8708. SELECT @S = GETDATE()
  8709. INSERT INTO #FullText
  8710. SELECT [key] FROM CONTAINSTABLE(CvMainPublish, *, @KeyTemp, 100000) AS KeyCv
  8711. INSERT INTO #FullText
  8712. SELECT DISTINCT cvMainID FROM CvExperiencePublish WITH(NOLOCK) WHERE ID IN(
  8713. SELECT [key] FROM CONTAINSTABLE(CvExperiencePublish, *, @KeyTemp, 100000) AS KeyCv)
  8714. INSERT INTO #FullText
  8715. SELECT DISTINCT cvMainID FROM CvEducationPublish WITH(NOLOCK) WHERE ID IN(
  8716. SELECT [key] FROM CONTAINSTABLE(CvEducationPublish, *, @KeyTemp, 100000) AS KeyCv)
  8717. INSERT INTO #FullText
  8718. SELECT DISTINCT cvMainID FROM CvProjectPublish WITH(NOLOCK) WHERE ID IN(
  8719. SELECT [key] FROM CONTAINSTABLE(CvProjectPublish, *, @KeyTemp, 100000) AS KeyCv)
  8720. INSERT INTO #FullText
  8721. SELECT DISTINCT cvMainID FROM CvTrainingPublish WITH(NOLOCK) WHERE ID IN(
  8722. SELECT [key] FROM CONTAINSTABLE(CvTrainingPublish, *, @KeyTemp, 100000) AS KeyCv)
  8723. --Richard 2011.8.21增加
  8724. INSERT INTO #FullText
  8725. SELECT DISTINCT cvMainID FROM CvAppendixPublish WITH(NOLOCK) WHERE ID IN(
  8726. SELECT [key] FROM CONTAINSTABLE(CvAppendixPublish, *, @KeyTemp, 100000) AS KeyCv)
  8727. --Richard 2011.8.24增加
  8728. SELECT @SqlFt = 'SELECT [key] FROM CONTAINSTABLE(CvMainPublish, *, ''' + @KeyTemp + ''',100000) AS KeyCv ORDER BY [key] DESC 开始:' + CONVERT(varchar(8), @S, 8) + ' 结束:' + CONVERT(varchar(8), getdate(), 8)
  8729. UPDATE SearchDB..cpSearchCondition SET SqlFT = @SqlFt WHERE ID = @cpSearchConditionID
  8730. END
  8731. ----生成插入临时表的Sql语句
  8732. SET @SQL = '
  8733. INSERT INTO #Cv
  8734. SELECT DISTINCT TOP 2000 a.ID, j.LastLoginDate'
  8735. SET @FROM = '
  8736. FROM cvmainPublish a WITH(NOLOCK)
  8737. INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainId = j.Id
  8738. INNER JOIN marketdb..RmInvitationCode b WITH(NOLOCK) ON a.paMainID=b.paMainID AND b.Valid=1
  8739. INNER JOIN marketdb..RmProject c WITH(NOLOCK) ON b.RmProjectID=c.ID
  8740. INNER JOIN Recruitment d WITH(NOLOCK) ON c.RecruitmentID=d.ID
  8741. INNER JOIN RecruitmentPlace e WITH(NOLOCK) ON d.RecruitmentPlaceID=e.ID'
  8742. IF @RecruitmentPlaceID = 0
  8743. SET @FROM = @FROM + ' AND e.dcRegionID LIKE ''' + CONVERT(VARCHAR,@dcRegionID) + '%'''
  8744. ELSE
  8745. SET @FROM = @FROM + ' AND e.ID=' + CONVERT(VARCHAR,@RecruitmentPlaceID)
  8746. SET @FROM = @FROM + ' AND b.AddDate>GETDATE()-90'
  8747. IF CHARINDEX('g.',@WHERE) > 0
  8748. SET @FROM = @FROM + ' INNER JOIN cvJobTypePublish g WITH(NOLOCK) ON a.ID=g.cvMainID'
  8749. IF LEN(@KeyTemp) > 0 --AND @MajorName IS NULL
  8750. SET @FROM = @FROM + ' INNER JOIN #FullText k WITH(NOLOCK) ON a.ID=k.cvID'
  8751. SET @SQL = @SQL + @FROM + @WHERE
  8752. SET @SQL = @SQL + ' ORDER BY j.LastLoginDate DESC, a.ID'
  8753. --PRINT @SQL
  8754. ----把符合条件的职位全部列出
  8755. UPDATE SearchDB..cpSearchCondition SET Sql = REPLACE(@SQL, 'INSERT INTO #Cv', ''), StartDate = GETDATE() WHERE ID = @cpSearchConditionID
  8756. EXEC(@SQL)
  8757. ----记录查询结果总数
  8758. DECLARE @ValidCvNumber INT
  8759. SET @ValidCvNumber = @@ROWCOUNT
  8760. UPDATE SearchDB..cpSearchCondition SET ValidCvNumber = @ValidCvNumber WHERE ID = @cpSearchConditionID
  8761. --记录查询时间
  8762. UPDATE SearchDB..cpSearchCondition SET EndDate = GETDATE() WHERE ID = @cpSearchConditionID
  8763. INSERT INTO SearchDB..cpSearchCvID
  8764. SELECT TOP 2000 @cpSearchConditionID, ID FROM #Cv WITH(NOLOCK)
  8765. DROP TABLE #Cv
  8766. DROP TABLE #FullText
  8767. GOTO GETRECORDSET
  8768. END
  8769. GETRECORDSET:
  8770. BEGIN
  8771. DECLARE @PageSize AS TINYINT
  8772. SET @PageSize = 20 --每页的行数
  8773. ----返回查询数量
  8774. UPDATE SearchDB..cpSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@cpSearchConditionID
  8775. SELECT ValidCvNumber FROM SearchDB..cpSearchCondition WITH(NOLOCK) WHERE ID=@cpSearchConditionID
  8776. ----返回20行查询结果
  8777. IF @PageNumber > 0
  8778. BEGIN
  8779. DECLARE @T_CvList AS TABLE(
  8780. ID INT,
  8781. cvEducationID INT,
  8782. dcMajorID INT,
  8783. Degree TINYINT,
  8784. RelatedWorkYears INT,
  8785. dcSalaryID TINYINT,
  8786. RefreshDate SMALLDATETIME,
  8787. LastLoginDate SMALLDATETIME,
  8788. JobName VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
  8789. Gender BIT,
  8790. BirthDay INT,
  8791. LivePlace INT,
  8792. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  8793. HasPhoto TINYINT,
  8794. College NVARCHAR(50),
  8795. EduType TINYINT,
  8796. MajorName NVARCHAR(20),
  8797. Graduation INT,
  8798. HasViewed BIT,
  8799. ViewDate SMALLDATETIME,
  8800. LastJobTypeID INT,
  8801. Valid TINYINT,
  8802. PlaceName NVARCHAR(50),
  8803. RecommendDate SMALLDATETIME,
  8804. RecruitmentName NVARCHAR(50)
  8805. )
  8806. SELECT @MinId = MIN(ID) FROM SearchDB..cpSearchCvID WITH(NOLOCK) WHERE cpSearchConditionID = @cpSearchConditionID
  8807. SET @MinId = @MinId + (@PageNumber-1) * @PageSize
  8808. INSERT INTO @T_CvList(ID,dcMajorID,Degree,RelatedWorkYears,dcSalaryID,RefreshDate,LastLoginDate,
  8809. JobName,Gender,BirthDay,LivePlace,LastJobTypeID,Attachment,HasPhoto,HasViewed,Valid)
  8810. SELECT TOP 20 a.ID,a.dcMajorID,a.Degree,a.RelatedWorkYears,a.dcSalaryID,a.RefreshDate,
  8811. j.LastLoginDate,ISNULL(a.JobName, '应届毕业生') JobName,j.Gender,j.BirthDay,j.LivePlace,a.LastJobTypeID,
  8812. a.Attachment,j.HasPhoto,0,a.Valid FROM cvmain a WITH(NOLOCK)
  8813. INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID=j.ID
  8814. INNER JOIN SearchDB..cpSearchCvID b ON a.id=b.CvID
  8815. WHERE b.cpSearchConditionID=@cpSearchConditionID AND b.ID >= @MinId
  8816. ORDER BY b.ID, a.ID DESC
  8817. --RICHARD 2011-7-23 16:51分修改
  8818. UPDATE a SET a.cvEducationID = (
  8819. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  8820. WHERE cvEducation.cvMainID = a.ID
  8821. AND a.Degree = cvEducation.Degree
  8822. ORDER BY Graduation DESC)
  8823. FROM @T_CvList a
  8824. UPDATE a SET a.PlaceName = f.PlaceName, a.RecommendDate = c.AddDate, a.RecruitmentName = e.RecruitmentName
  8825. FROM @T_CvList a, cvMain b WITH(NOLOCK), marketdb..RmInvitationCode c WITH(NOLOCK), marketdb..RmProject d WITH(NOLOCK),
  8826. Recruitment e WITH(NOLOCK), RecruitmentPlace f WITH(NOLOCK)
  8827. WHERE a.ID=b.ID AND b.paMainID=c.paMainID AND c.RmProjectID=d.ID AND d.RecruitmentID=e.ID AND e.RecruitmentPlaceID=f.ID
  8828. UPDATE a SET a.College = ISNULL(b.GraduateCollage,b.GraduateCollageEng), a.EduType = b.EduType,
  8829. a.MajorName = ISNULL(b.MajorName,b.MajorNameEng), a.Graduation = b.Graduation
  8830. FROM @T_CvList a, cvEducation b WITH(NOLOCK)
  8831. WHERE b.ID = a.cvEducationID
  8832. UPDATE a SET a.HasViewed = 1, a.ViewDate = b.AddDate
  8833. FROM @T_CvList a, caCvViewLog b WITH(NOLOCK)
  8834. WHERE b.cvMainID = a.ID AND caMainID=@caMainID
  8835. SELECT * FROM @T_CvList
  8836. END
  8837. RETURN
  8838. END
  8839. END TRY
  8840. BEGIN CATCH
  8841. ---检查是否已经建立临时表,已经建立则删除
  8842. BEGIN TRY
  8843. DROP TABLE #FullText
  8844. END TRY
  8845. BEGIN CATCH
  8846. END CATCH
  8847. BEGIN TRY
  8848. DROP TABLE #cv
  8849. END TRY
  8850. BEGIN CATCH
  8851. END CATCH
  8852. PRINT '查询时出现错误,请联系技术人员检查,错误信息:'
  8853. PRINT Error_Message()
  8854. PRINT Error_Number()
  8855. PRINT Error_Line()
  8856. END CATCH
  8857. GO
  8858. /****** Object: StoredProcedure [dbo].[ccRecruitmentByPaMainIdSelect] Script Date: 2018/12/13 19:07:20 ******/
  8859. SET ANSI_NULLS ON
  8860. GO
  8861. SET QUOTED_IDENTIFIER ON
  8862. GO
  8863. CREATE PROCEDURE [dbo].[ccRecruitmentByPaMainIdSelect]
  8864. (
  8865. @paMainID INT
  8866. )
  8867. AS
  8868. --INSERT INTO procLog SELECT 'ccRecruitmentByPaMainIdSelect', @paMainID, GETDATE() --using
  8869. BEGIN
  8870. SELECT c.BeginDate, c.RecruitmentName
  8871. FROM marketdb..ptCvInvitation a WITH(NOLOCK)
  8872. INNER JOIN marketdb..ptWorkAppoint b WITH(NOLOCK) ON a.PtWorkAppointID1 = b.ID
  8873. INNER JOIN Recruitment c WITH(NOLOCK) ON b.RecruitmentID = c.ID
  8874. WHERE a.paMainID = @paMainID
  8875. END
  8876. GO
  8877. /****** Object: StoredProcedure [dbo].[ccRecruitmentPaMainSelect] Script Date: 2018/12/13 19:07:20 ******/
  8878. SET ANSI_NULLS ON
  8879. GO
  8880. SET QUOTED_IDENTIFIER ON
  8881. GO
  8882. CREATE PROCEDURE [dbo].[ccRecruitmentPaMainSelect]
  8883. (
  8884. @RecruitmentID INT,
  8885. @Page SMALLINT,
  8886. @caMainID INT,
  8887. @cpMainID INT
  8888. )
  8889. AS
  8890. BEGIN
  8891. CREATE TABLE #T(
  8892. TitleID BIGINT,
  8893. ID INT,
  8894. cvMainID INT,
  8895. Degree TINYINT,
  8896. RelatedWorkYears TINYINT,
  8897. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  8898. IsNameHidden BIT,
  8899. LivePlace VARCHAR(6) COLLATE Chinese_PRC_CI_AS,
  8900. Gender BIT,
  8901. paName NVARCHAR(20),
  8902. BirthDay INT,
  8903. HasPhoto TINYINT,
  8904. adddate SMALLDATETIME,
  8905. Valid TINYINT,
  8906. IsViewed BIT,
  8907. cvEducationID INT,
  8908. College NVARCHAR(50),
  8909. EduType TINYINT,
  8910. MajorName NVARCHAR(20),
  8911. Graduation INT,
  8912. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  8913. Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS
  8914. )
  8915. INSERT INTO #T(
  8916. TitleID,ID, cvMainID, Degree, RelatedWorkYears,
  8917. Attachment, IsNameHidden, LivePlace, Gender, paName,
  8918. BirthDay, HasPhoto, adddate, Valid
  8919. )
  8920. SELECT ROW_NUMBER() OVER (ORDER BY a.AddDate DESC) AS TitleID,
  8921. a.ID, b.ID, b.Degree, b.RelatedWorkYears, b.Attachment,
  8922. b.IsNameHidden, c.LivePlace, c.Gender, c.Name AS paName,
  8923. c.BirthDay, c.HasPhoto, a.adddate, b.Valid
  8924. FROM RecruitmentPaMain a WITH(NOLOCK)
  8925. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = a.paMainID
  8926. INNER JOIN cvMain b WITH(NOLOCK) ON b.paMainID = c.ID
  8927. WHERE b.Valid = 1 AND a.RecruitmentID = @RecruitmentID
  8928. IF(@Page < 1)
  8929. SET @Page = 1
  8930. IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
  8931. SET @Page = 1
  8932. DELETE #t WHERE TitleID <= (@Page-1) * 20 AND TitleID > @Page*20 --sean add
  8933. UPDATE #T SET paName = LEFT(dbo.GetPaName(cvMainID, @cpMainID), 20),
  8934. IsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID)
  8935. --sean delete WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  8936. UPDATE #T SET Speciality = (
  8937. SELECT Speciality FROM cvMain WITH(NOLOCK)
  8938. WHERE cvMain.ID = #T.cvMainID)
  8939. --sean delete WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  8940. UPDATE #T
  8941. SET Experience = (
  8942. SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
  8943. WHERE cvExperience.cvMainID = #T.cvMainID
  8944. ORDER BY BeginDate DESC)
  8945. --sean delete WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  8946. UPDATE #T SET cvEducationID = (
  8947. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  8948. WHERE cvEducation.cvMainID = #T.cvMainID
  8949. AND #T.Degree = cvEducation.Degree
  8950. ORDER BY Graduation DESC)
  8951. --sean delete WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  8952. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  8953. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  8954. FROM #T a, cvEducation b WITH(NOLOCK)
  8955. WHERE b.ID = a.cvEducationID
  8956. --sean delete AND a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
  8957. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  8958. SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  8959. DROP TABLE #T
  8960. END
  8961. GO
  8962. /****** Object: StoredProcedure [dbo].[ccSearchTextLogInsert] Script Date: 2018/12/13 19:07:20 ******/
  8963. SET ANSI_NULLS ON
  8964. GO
  8965. SET QUOTED_IDENTIFIER ON
  8966. GO
  8967. -----------------
  8968. --创建日期:2013-6-9
  8969. --创建人:Lucifer
  8970. --功能说明:增加一条简历搜索关键词记录
  8971. -----------------
  8972. CREATE PROCEDURE [dbo].[ccSearchTextLogInsert]
  8973. (
  8974. @caMainID INT,
  8975. @SearchText VARCHAR(50),
  8976. @IP VARCHAR(15)
  8977. )
  8978. AS
  8979. BEGIN
  8980. IF @SearchText IS NULL
  8981. RETURN 0
  8982. IF LEN(LTRIM(RTRIM(@SearchText))) = ''
  8983. RETURN 0
  8984. BEGIN TRY
  8985. --IF CHARINDEX('公务员', @SearchText) + CHARINDEX('事业单位', @SearchText) + CHARINDEX('军队', @SearchText) = 0
  8986. -- RETURN 0
  8987. INSERT INTO ReportDB..SearchTextLog (caMainID, SearchText, IP)
  8988. VALUES(@caMainID, @SearchText, @IP)
  8989. END TRY
  8990. BEGIN CATCH
  8991. RETURN 0
  8992. END CATCH
  8993. RETURN 1
  8994. END
  8995. GO
  8996. /****** Object: StoredProcedure [dbo].[ccShareMainLogByCpIDSelect] Script Date: 2018/12/13 19:07:20 ******/
  8997. SET ANSI_NULLS ON
  8998. GO
  8999. SET QUOTED_IDENTIFIER ON
  9000. GO
  9001. --统计企业分享量
  9002. --添加人Peter
  9003. --添加时间:2016-04-08
  9004. CREATE PROCEDURE [dbo].[ccShareMainLogByCpIDSelect]
  9005. (
  9006. @CpMainId INT
  9007. )
  9008. AS
  9009. BEGIN
  9010. SELECT ShareWay,COUNT(1) cnt,SUM(ClickCount) clickcnt
  9011. FROM logdb..sharemainlog WITH(NOLOCK)
  9012. WHERE PageMark = 3 AND shareman = @CpMainId
  9013. GROUP BY ShareWay
  9014. SELECT TOP 50 *
  9015. FROM logdb..sharemainlog WITH(NOLOCK)
  9016. WHERE PageMark = 3
  9017. AND shareman = @CpMainId
  9018. ORDER BY AddDate DESc
  9019. END
  9020. GO
  9021. /****** Object: StoredProcedure [dbo].[ccShareMainLogByStatisticsSelect] Script Date: 2018/12/13 19:07:21 ******/
  9022. SET ANSI_NULLS ON
  9023. GO
  9024. SET QUOTED_IDENTIFIER ON
  9025. GO
  9026. --统计企业职位分享量------------------
  9027. --添加人Harry -----------------------
  9028. --添加时间:2015-1-14---------------
  9029. CREATE PROCEDURE [dbo].[ccShareMainLogByStatisticsSelect]
  9030. (
  9031. @CpMainId INT
  9032. )
  9033. AS
  9034. BEGIN
  9035. CREATE TABLE #T
  9036. (
  9037. PageId INT,
  9038. PageName NVARCHAR(50),
  9039. PageMark VARCHAR(10),
  9040. SecondId VARCHAR(30),
  9041. WeiBo INT DEFAULT 0,
  9042. RenRen INT DEFAULT 0,
  9043. QZone INT DEFAULT 0,
  9044. QWeiBo INT DEFAULT 0,
  9045. QQ INT DEFAULT 0,
  9046. Weixin INT DEFAULT 0
  9047. )
  9048. INSERT INTO #T(PageId,PageName,SecondId,PageMark)
  9049. SELECT DISTINCT Id, Name,SecondId,1
  9050. FROM Maindb..Job WITH (NOLOCK)
  9051. WHERE CpMainId = CAST(@CpMainId AS VARCHAR)
  9052. AND Valid=1
  9053. INSERT INTO #T(PageId,PageName,PageMark)
  9054. VALUES(CAST(@CpMainId AS VARCHAR),'公司招聘页面','2')
  9055. CREATE TABLE #1
  9056. (
  9057. PageId INT,
  9058. PageMark VARCHAR(10),
  9059. ShareWay INT,
  9060. ShareNumber INT DEFAULT 0
  9061. )
  9062. INSERT INTO #1
  9063. SELECT PageId, PageMark, ShareWay, COUNT(1)
  9064. FROM LogDb..ShareMainLog WITH (NOLOCK)
  9065. WHERE ShareBy = 2
  9066. AND ShareMode = 1
  9067. AND ShareMan = @CpMainId
  9068. GROUP BY PageId, PageMark, ShareWay
  9069. UPDATE a
  9070. SET a.RenRen = (SELECT b.ShareNumber FROM #1 b WITH (NOLOCK) WHERE b.PageId = a.PageId AND a.PageMark = b.PageMark AND b.shareWay = 3),
  9071. a.QQ = (SELECT b.ShareNumber FROM #1 b WITH (NOLOCK) WHERE b.PageId = a.PageId AND a.PageMark = b.PageMark AND b.shareWay = 6),
  9072. a.WeiBo = (SELECT b.ShareNumber FROM #1 b WITH (NOLOCK) WHERE b.PageId = a.PageId AND a.PageMark = b.PageMark AND b.shareWay = 1),
  9073. a.QZone = (SELECT b.ShareNumber FROM #1 b WITH (NOLOCK) WHERE b.PageId = a.PageId AND a.PageMark = b.PageMark AND b.shareWay = 4),
  9074. a.QWeiBo = (SELECT b.ShareNumber FROM #1 b WITH (NOLOCK) WHERE b.PageId = a.PageId AND a.PageMark = b.PageMark AND b.shareWay = 5),
  9075. a.Weixin = (SELECT b.ShareNumber FROM #1 b WITH (NOLOCK) WHERE b.PageId = a.PageId AND a.PageMark = b.PageMark AND b.shareWay = 2)
  9076. FROM #T a
  9077. SELECT * FROM #T
  9078. END
  9079. GO
  9080. /****** Object: StoredProcedure [dbo].[ccShareMainLogSelect] Script Date: 2018/12/13 19:07:21 ******/
  9081. SET ANSI_NULLS ON
  9082. GO
  9083. SET QUOTED_IDENTIFIER ON
  9084. GO
  9085. CREATE PROCEDURE [dbo].[ccShareMainLogSelect]
  9086. (
  9087. @CpMainId INT
  9088. )
  9089. AS
  9090. BEGIN
  9091. SELECT a.Shareway, a.Adddate, b.Name, b.Secondid, a.PageMark, a.PageId
  9092. FROM Logdb..ShareMainLog a WITH (NOLOCK)
  9093. LEFT JOIN Maindb..Job b WITH (NOLOCK)
  9094. ON a.PageId=b.Id
  9095. WHERE a.ShareBy = '2'
  9096. AND a.ShareMode = '1'
  9097. AND a.ShareMan = @CpMainId
  9098. ORDER BY a.Adddate DESC
  9099. END
  9100. GO
  9101. /****** Object: StoredProcedure [dbo].[ccsmsMessageLogCountByCaMainIDSelect] Script Date: 2018/12/13 19:07:21 ******/
  9102. SET ANSI_NULLS ON
  9103. GO
  9104. SET QUOTED_IDENTIFIER ON
  9105. GO
  9106. --#####################################################
  9107. --创建时间:2014.10.30
  9108. --创建人:Nick
  9109. --说明://得到面试通知数量
  9110. --#####################################################
  9111. CREATE PROCEDURE [dbo].[ccsmsMessageLogCountByCaMainIDSelect]
  9112. (
  9113. @ID INT
  9114. )
  9115. AS
  9116. BEGIN
  9117. SELECT ISNULL(SUM(SmsNumber), 0) Cnt
  9118. FROM ExInterView WITH(NOLOCK)
  9119. WHERE JobId IN(SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainId = @Id)
  9120. AND AddDate > CONVERT(VARCHAR(10), GETDATE() - 29, 120)
  9121. /*
  9122. SELECT Cnt = COUNT(*)
  9123. FROM smsMessageLog WITH(NOLOCK)
  9124. WHERE caMainId = @ID AND AddDate > CONVERT(VARCHAR(10), GETDATE() - 29, 120)
  9125. AND MsgType IN(101,105)
  9126. */
  9127. END
  9128. GO
  9129. /****** Object: StoredProcedure [dbo].[ccValidViPlanDateSelect] Script Date: 2018/12/13 19:07:21 ******/
  9130. SET ANSI_NULLS ON
  9131. GO
  9132. SET QUOTED_IDENTIFIER ON
  9133. GO
  9134. --#####################################################
  9135. --创建时间:2014.10.30
  9136. --创建人:John
  9137. --说明:获取企业发送视频面试通知时的面试时间选项
  9138. --#####################################################
  9139. CREATE PROCEDURE [dbo].[ccValidViPlanDateSelect]
  9140. (
  9141. @caMainID INT
  9142. )
  9143. AS
  9144. BEGIN
  9145. SELECT *
  9146. FROM (
  9147. SELECT TOP 1 id,begindate,1 orderby
  9148. FROM viroom
  9149. WHERE enddate IS NULL
  9150. AND camainid = @caMainID
  9151. UNION
  9152. SELECT TOP 50 id,interviewdate,2 orderby
  9153. FROM viplan
  9154. WHERE interviewdate > GETDATE()
  9155. AND iscancel = 0
  9156. AND camainid = @caMainID
  9157. ) a
  9158. ORDER BY orderby ,begindate
  9159. END
  9160. GO
  9161. /****** Object: StoredProcedure [dbo].[ccvCpMainActiveQuotaByIDSelect] Script Date: 2018/12/13 19:07:21 ******/
  9162. SET ANSI_NULLS ON
  9163. GO
  9164. SET QUOTED_IDENTIFIER ON
  9165. GO
  9166. --#####################################################
  9167. --创建时间:2014.10.31
  9168. --创建人:Nick
  9169. --说明:获取企业简历下载数 和 已经使用的简历下载数
  9170. --#####################################################
  9171. CREATE PROCEDURE [dbo].[ccvCpMainActiveQuotaByIDSelect]
  9172. (
  9173. @CpMainID VARCHAR(20)
  9174. )
  9175. AS
  9176. BEGIN TRY
  9177. SELECT ActiveQuota,RemainQuota FROM vCpMain WITH(NOLOCK) WHERE Id=@CpMainID
  9178. END TRY
  9179. BEGIN CATCH
  9180. RETURN 0
  9181. END CATCH
  9182. GO
  9183. /****** Object: StoredProcedure [dbo].[ccvCpMainByIDSelect] Script Date: 2018/12/13 19:07:21 ******/
  9184. SET ANSI_NULLS ON
  9185. GO
  9186. SET QUOTED_IDENTIFIER ON
  9187. GO
  9188. --#####################################################
  9189. --创建时间:2014.10.30
  9190. --创建人:Nick
  9191. --说明:获取状态
  9192. --修改:harry2017-6-6 增加短信RemainSmsQuota ,SmsQuota配额
  9193. --修改:harry2018-9-21 增加人才测评配额
  9194. --#####################################################
  9195. CREATE PROCEDURE [dbo].[ccvCpMainByIDSelect]
  9196. (
  9197. @ID INT
  9198. )
  9199. AS
  9200. BEGIN
  9201. SELECT VipDate, ActiveQuota, MaxJobNumber, MaxUserNumber, RemainQuota, RemainSmsQuota, SmsQuota, remainJobRefreshQuota,jobRefreshQuota,AssessReportQuota, RemainAssessReportQuota
  9202. FROM vCpMain WITH(NOLOCK)
  9203. WHERE Id=@ID
  9204. END
  9205. GO
  9206. /****** Object: StoredProcedure [dbo].[ccViPlanByCaMainIDSelect] Script Date: 2018/12/13 19:07:22 ******/
  9207. SET ANSI_NULLS ON
  9208. GO
  9209. SET QUOTED_IDENTIFIER ON
  9210. GO
  9211. --#####################################################
  9212. --创建时间:2014.10.30
  9213. --创建人:John
  9214. --说明:企业获取自己的未过期的面试计划
  9215. --#####################################################
  9216. CREATE PROCEDURE [dbo].[ccViPlanByCaMainIDSelect]
  9217. (
  9218. @caMainID INT
  9219. )
  9220. AS
  9221. BEGIN
  9222. SELECT TOP 500 a.ID,InterviewDate,IsCancel,b.name,
  9223. (
  9224. SELECT COUNT(*)
  9225. FROM viplaninvitelog
  9226. WHERE viplanid = a.id
  9227. AND addtype = 0
  9228. ) cnt1,
  9229. (
  9230. SELECT COUNT(*)
  9231. FROM viplaninvitelog
  9232. WHERE viplanid = a.id
  9233. AND addtype = 1
  9234. ) cnt2
  9235. FROM viplan a,caMain b
  9236. WHERE a.camainid = b.id
  9237. AND interviewdate > GETDATE()
  9238. AND IsCancel = 0
  9239. AND camainid = @caMainID
  9240. ORDER BY interviewdate
  9241. END
  9242. GO
  9243. /****** Object: StoredProcedure [dbo].[ccViPlanExpiredByCaMainIDSelect] Script Date: 2018/12/13 19:07:22 ******/
  9244. SET ANSI_NULLS ON
  9245. GO
  9246. SET QUOTED_IDENTIFIER ON
  9247. GO
  9248. --#####################################################
  9249. --创建时间:2014.10.30
  9250. --创建人:John
  9251. --说明:企业获取自己的已过期的面试计划
  9252. --#####################################################
  9253. CREATE PROCEDURE [dbo].[ccViPlanExpiredByCaMainIDSelect]
  9254. (
  9255. @caMainID INT
  9256. )
  9257. AS
  9258. BEGIN
  9259. SELECT TOP 500 a.ID,InterviewDate,IsCancel,b.name,
  9260. (
  9261. SELECT COUNT(*)
  9262. FROM viplaninvitelog
  9263. WHERE viplanid = a.id
  9264. AND addtype = 0
  9265. ) cnt1,
  9266. (
  9267. SELECT COUNT(*)
  9268. FROM viplaninvitelog
  9269. WHERE viplanid = a.id
  9270. AND addtype = 1
  9271. ) cnt2
  9272. FROM viplan a,caMain b
  9273. WHERE a.camainid = b.id
  9274. AND (interviewdate < GETDATE() OR IsCancel = 1)
  9275. AND camainid = @caMainID
  9276. ORDER BY interviewdate DESC
  9277. END
  9278. GO
  9279. /****** Object: StoredProcedure [dbo].[ccViPlanInsert] Script Date: 2018/12/13 19:07:22 ******/
  9280. SET ANSI_NULLS ON
  9281. GO
  9282. SET QUOTED_IDENTIFIER ON
  9283. GO
  9284. CREATE PROCEDURE [dbo].[ccViPlanInsert]
  9285. (
  9286. @CaMainID INT,
  9287. @InterviewDate SMALLDATETIME
  9288. )
  9289. AS
  9290. BEGIN
  9291. INSERT INTO viplan (CaMainID ,InterviewDate) select @CaMainID ,@InterviewDate
  9292. Return @@IDENTITY
  9293. END
  9294. GO
  9295. /****** Object: StoredProcedure [dbo].[ccViPlanInviteLog30DaysSelect] Script Date: 2018/12/13 19:07:22 ******/
  9296. SET ANSI_NULLS ON
  9297. GO
  9298. SET QUOTED_IDENTIFIER ON
  9299. GO
  9300. --#####################################################
  9301. --创建时间:2014.10.30
  9302. --创建人:John
  9303. --说明:30天内有没有邀请过
  9304. --#####################################################
  9305. CREATE PROCEDURE [dbo].[ccViPlanInviteLog30DaysSelect]
  9306. (
  9307. @cvMainID INT,
  9308. @jobID INT
  9309. )
  9310. AS
  9311. BEGIN
  9312. SELECT TOP 1 *
  9313. FROM viplaninvitelog
  9314. WHERE adddate > GETDATE()-30
  9315. AND cvMainID = @cvMainID
  9316. AND jobid = @jobID
  9317. END
  9318. GO
  9319. /****** Object: StoredProcedure [dbo].[ccVIPlanInviteLogSelect] Script Date: 2018/12/13 19:07:22 ******/
  9320. SET ANSI_NULLS ON
  9321. GO
  9322. SET QUOTED_IDENTIFIER ON
  9323. GO
  9324. CREATE PROCEDURE [dbo].[ccVIPlanInviteLogSelect]
  9325. (
  9326. @WHERE VARCHAR(1000),
  9327. @caMainID INT
  9328. )
  9329. AS
  9330. BEGIN
  9331. CREATE TABLE #t(
  9332. paMainID INT,
  9333. cvmainid INT,
  9334. Name NVARCHAR(10),
  9335. JobName NVARCHAR(50),
  9336. AddDate SMALLDATETIME,
  9337. InterviewDate SMALLDATETIME,
  9338. Degree NVARCHAR(10),
  9339. RelatedWorkYears TINYINT,
  9340. LivePlace NVARCHAR(20) COLLATE Chinese_PRC_CI_AS,
  9341. Gender BIT,
  9342. paName NVARCHAR(20),
  9343. BirthDay INT,
  9344. HasPhoto TINYINT,
  9345. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  9346. IsNameHidden BIT,
  9347. Valid TINYINT,
  9348. AddType BIT
  9349. )
  9350. DECLARE @SQL AS VARCHAR(2000)
  9351. DECLARE @SQL2 AS VARCHAR(2000)
  9352. SET @SQL='
  9353. INSERT INTO #t(paMainID,cvMainID,Name,JobName,AddDate,InterviewDate,AddType)
  9354. SELECT
  9355. c.ID,b.ID,c.Name,d.name,a.AddDate,e.InterviewDate,a.AddType
  9356. From viplaninvitelog a WITH(NOLOCK)
  9357. INNER JOIN cvMain b WITH(NOLOCK) ON a.cvMainID=b.ID
  9358. INNER JOIN paMain c WITH(NOLOCK) ON c.ID=b.paMainID
  9359. INNER JOIN job d WITH(NOLOCK) ON a.jobid=d.id
  9360. INNER JOIN VIPlan e WITH(NOLOCK) ON a.VIPlanID=e.id
  9361. '
  9362. SET @SQL=@SQL + '
  9363. WHERE e.camainid= '+ltrim(str(@caMainID))
  9364. IF LEN(@WHERE)>0
  9365. SET @SQL=@SQL + @WHERE
  9366. --PRINT @sql
  9367. EXEC(@SQL)
  9368. DECLARE @cpMainID int
  9369. SELECT @cpMainID=cpMainid from caMain where id=@caMainID
  9370. UPDATE #t SET Name=LEFT(dbo.GetPaName(cvMainID, @cpMainID), 20),RelatedWorkYears = a.RelatedWorkYears,Attachment = a.Attachment,
  9371. IsNameHidden = a.IsNameHidden,LivePlace = c.FullName,Gender = b.Gender,
  9372. BirthDay = b.BirthDay,HasPhoto = b.HasPhoto,Valid = a.Valid,Degree=d.Description
  9373. FROM cvMain a WITH(NOLOCK) INNER JOIN paMain b ON a.paMainID = b.ID INNER JOIN dcregion c WITH(NOLOCK) ON b.liveplace=c.id INNER JOIN dceducation d ON a.Degree=d.id
  9374. WHERE a.ID = #t.cvMainID
  9375. IF CHARINDEX('interviewdate<getdate',@WHERE)>0
  9376. SELECT * FROM #t WITH(NOLOCK) ORDER BY InterviewDate DESC,AddDATE
  9377. ELSE
  9378. SELECT * FROM #t WITH(NOLOCK) ORDER BY InterviewDate ,AddDATE
  9379. DROP TABLE #t
  9380. END
  9381. GO
  9382. /****** Object: StoredProcedure [dbo].[ccViPlanInviteLogViewDateUpdate] Script Date: 2018/12/13 19:07:23 ******/
  9383. SET ANSI_NULLS ON
  9384. GO
  9385. SET QUOTED_IDENTIFIER ON
  9386. GO
  9387. --#####################################################
  9388. --创建时间:2014.10.30
  9389. --创建人:John
  9390. --说明:企业修改未查看面试计划邀请记录的查看时间
  9391. --#####################################################
  9392. CREATE PROCEDURE [dbo].[ccViPlanInviteLogViewDateUpdate]
  9393. (
  9394. @caMainID INT
  9395. )
  9396. AS
  9397. BEGIN
  9398. UPDATE a SET viewdate = GETDATE()
  9399. FROM viplaninvitelog a,viplan b
  9400. WHERE a.viplanid = b.id
  9401. AND addtype = 0
  9402. AND viewdate IS NULL
  9403. AND camainid = @caMainID
  9404. END
  9405. GO
  9406. /****** Object: StoredProcedure [dbo].[ccViPlanIsCancelUpdate] Script Date: 2018/12/13 19:07:23 ******/
  9407. SET ANSI_NULLS ON
  9408. GO
  9409. SET QUOTED_IDENTIFIER ON
  9410. GO
  9411. --#####################################################
  9412. --创建时间:2014.10.30
  9413. --创建人:John
  9414. --说明:面试计划取消
  9415. --#####################################################
  9416. CREATE PROCEDURE [dbo].[ccViPlanIsCancelUpdate]
  9417. (
  9418. @caMainID INT,
  9419. @id INT
  9420. )
  9421. AS
  9422. BEGIN
  9423. UPDATE viplan SET IsCancel = 1 WHERE id = @id AND caMainID = @caMainID
  9424. END
  9425. GO
  9426. /****** Object: StoredProcedure [dbo].[ccViPlanTopFirstSelect] Script Date: 2018/12/13 19:07:23 ******/
  9427. SET ANSI_NULLS ON
  9428. GO
  9429. SET QUOTED_IDENTIFIER ON
  9430. GO
  9431. --#####################################################
  9432. --创建时间:2014.10.30
  9433. --创建人:John
  9434. --说明:企业获取一条今天要进行的面试计划
  9435. --#####################################################
  9436. CREATE PROCEDURE [dbo].[ccViPlanTopFirstSelect]
  9437. (
  9438. @caMainID INT
  9439. )
  9440. AS
  9441. BEGIN
  9442. SELECT TOP 1 interviewdate
  9443. FROM viplan
  9444. WHERE CONVERT(VARCHAR(10),interviewdate,112) = CONVERT(VARCHAR(10),GETDATE(),112)
  9445. AND interviewdate > GETDATE()
  9446. AND iscancel = 0
  9447. AND caMainid = @caMainID
  9448. END
  9449. GO
  9450. /****** Object: StoredProcedure [dbo].[ccViRoomNotOverByCaMainIDSelect] Script Date: 2018/12/13 19:07:23 ******/
  9451. SET ANSI_NULLS ON
  9452. GO
  9453. SET QUOTED_IDENTIFIER ON
  9454. GO
  9455. --#####################################################
  9456. --创建时间:2014.10.30
  9457. --创建人:John
  9458. --说明:检查该公司是否还有未结束的面试
  9459. --#####################################################
  9460. CREATE PROCEDURE [dbo].[ccViRoomNotOverByCaMainIDSelect]
  9461. (
  9462. @caMainID INT
  9463. )
  9464. AS
  9465. BEGIN
  9466. SELECT TOP 1 * FROM viRoom WITH(NOLOCK) WHERE caMainID=@caMainID AND EndDate IS NULL
  9467. END
  9468. GO
  9469. /****** Object: StoredProcedure [dbo].[ccWxMessageSendByAssessCpInviteSend] Script Date: 2018/12/13 19:07:23 ******/
  9470. SET ANSI_NULLS ON
  9471. GO
  9472. SET QUOTED_IDENTIFIER ON
  9473. GO
  9474. --#####################################################
  9475. --创建时间:20181105
  9476. --创建人:Peter
  9477. --插入企业邀请个人测评微信推送
  9478. --#####################################################
  9479. CREATE PROCEDURE [dbo].[ccWxMessageSendByAssessCpInviteSend]
  9480. (
  9481. @assessCpInviteID INT
  9482. )
  9483. AS
  9484. SET NOCOUNT ON
  9485. BEGIN
  9486. DECLARE @wxFansId INT,@cpMainID INT,@paMainID INT,@caMainID INT
  9487. SELECT @paMainID = a.PaMainID,@caMainID = a.CaMainID,@cpMainID = b.cpMainID
  9488. FROM AssessCpInvite a WITH(NOLOCK)
  9489. LEFT JOIN caMain b WITH(NOLOCK) ON b.id = a.CaMainID
  9490. WHERE a.ID = @assessCpInviteID
  9491. SELECT @wxFansId = id FROM wxFans WITH(NOLOCK) WHERE paMainId = @paMainID AND [Status] = 2
  9492. IF @wxFansId > 0
  9493. --插入到wxMessageSend表中
  9494. INSERT WxMessageSend2(Templatetype, WxFansID, PaMainId, MainTableId, CpMainID, CaMainId, AddDate)
  9495. SELECT 24, @wxFansId, @paMainID, @assessCpInviteID, @cpMainID, @caMainID, GETDATE()
  9496. END
  9497. GO
  9498. /****** Object: StoredProcedure [dbo].[FaxSendInsert] Script Date: 2018/12/13 19:07:24 ******/
  9499. SET ANSI_NULLS ON
  9500. GO
  9501. SET QUOTED_IDENTIFIER ON
  9502. GO
  9503. CREATE PROCEDURE [dbo].[FaxSendInsert]
  9504. (
  9505. @companyId INT,
  9506. @manageruserId INT,
  9507. @FaxNumber VARCHAR(20),
  9508. @FileName VARCHAR(50),
  9509. @Passage TINYINT
  9510. )
  9511. AS
  9512. DECLARE @MaxID AS INT
  9513. BEGIN TRY
  9514. INSERT INTO FaxSend
  9515. (companyId,manageruserId,FileName,FaxNumber,Passage)
  9516. VALUES
  9517. (@companyId,@manageruserId,@FileName,@FaxNumber,@Passage)
  9518. SET @MaxId = @@IDENTITY
  9519. END TRY
  9520. BEGIN CATCH
  9521. GOTO ERR
  9522. END CATCH
  9523. RETURN @MaxID
  9524. ERR:
  9525. BEGIN
  9526. RETURN 0
  9527. END
  9528. GO
  9529. /****** Object: StoredProcedure [dbo].[GetJobListByJobFinderIDApp] Script Date: 2018/12/13 19:07:24 ******/
  9530. SET ANSI_NULLS ON
  9531. GO
  9532. SET QUOTED_IDENTIFIER ON
  9533. GO
  9534. CREATE PROCEDURE [dbo].[GetJobListByJobFinderIDApp]
  9535. (
  9536. @paJobFinderID INT
  9537. )
  9538. AS
  9539. BEGIN
  9540. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  9541. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  9542. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  9543. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  9544. a.IsDelete, a.AddDate, a.RefreshDate, a.Welfare1, a.Welfare2, a.Welfare3,
  9545. a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8,
  9546. a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13,
  9547. a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18, a.Welfare19,
  9548. a.SecondId EnJobID, b.SecondId EnCpMainID,
  9549. a.LastModifyDate, b.Name cpName, b.dcCompanySizeID,
  9550. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  9551. b.MemberType, '' cpIndustry, b.IsRefreshed, ISNULL(d.IsOnline, 0) IsOnline, d.IsVi, d.ViPlanId, d.InterviewDate, e.FullName Region
  9552. FROM JobPublish a WITH(NOLOCK)
  9553. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  9554. INNER JOIN JobSubScription c WITH(NOLOCK) ON a.ID = c.JobID
  9555. INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
  9556. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  9557. WHERE c.paJobFinderID = @paJobFinderID
  9558. ORDER BY a.RefreshDate DESC
  9559. END
  9560. GO
  9561. /****** Object: StoredProcedure [dbo].[info_datereportCpUpdate] Script Date: 2018/12/13 19:07:24 ******/
  9562. SET ANSI_NULLS ON
  9563. GO
  9564. SET QUOTED_IDENTIFIER ON
  9565. GO
  9566. CREATE PROCEDURE [dbo].[info_datereportCpUpdate]
  9567. (
  9568. @cpMainID INT,
  9569. @AddMan INT,
  9570. @province_id VARCHAR(32)
  9571. )
  9572. AS
  9573. BEGIN TRAN
  9574. DECLARE @ID AS INT
  9575. BEGIN TRY
  9576. SET @ID=0
  9577. SELECT TOP 1 @ID=province_id FROM info_datereport WITH(NOLOCK)
  9578. WHERE infomanager_id=@AddMan
  9579. AND province_id=@province_id
  9580. AND CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  9581. IF @ID=0
  9582. INSERT INTO info_datereport(province_id,infomanager_id,countdate)
  9583. VALUES(@province_id,@AddMan, CONVERT(VARCHAR(8), GETDATE(), 112))
  9584. UPDATE info_datereport SET realcompany=realcompany + 1
  9585. WHERE infomanager_id=@AddMan
  9586. AND province_id=@province_id
  9587. AND CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  9588. UPDATE cpMain SET RegisterMode=11 WHERE ID=@cpMainID
  9589. END TRY
  9590. BEGIN CATCH
  9591. GOTO ERR
  9592. END CATCH
  9593. COMMIT TRAN
  9594. RETURN 1
  9595. ERR:
  9596. BEGIN
  9597. ROLLBACK TRAN
  9598. RETURN 0
  9599. END
  9600. GO
  9601. /****** Object: StoredProcedure [dbo].[mblAdverprojectBannerByProvinceIDSelect] Script Date: 2018/12/13 19:07:24 ******/
  9602. SET ANSI_NULLS ON
  9603. GO
  9604. SET QUOTED_IDENTIFIER ON
  9605. GO
  9606. CREATE PROCEDURE [dbo].[mblAdverprojectBannerByProvinceIDSelect]
  9607. (
  9608. @regionID VARCHAR(20),
  9609. @Type INT
  9610. )
  9611. AS
  9612. BEGIN
  9613. SELECT * FROM adverproject WHERE type=@Type
  9614. AND GETDATE() BETWEEN BeginTime
  9615. AND EndTime AND province_id=@regionID AND valid=1 ORDER BY AddDate DESC
  9616. END
  9617. GO
  9618. /****** Object: StoredProcedure [dbo].[mblAdverprojectByProvinceIDSelect] Script Date: 2018/12/13 19:07:25 ******/
  9619. SET ANSI_NULLS ON
  9620. GO
  9621. SET QUOTED_IDENTIFIER ON
  9622. GO
  9623. --—#####################################################
  9624. --—创建时间:2014.11.7
  9625. --—创建人:Nick
  9626. --—说明:获取最新的启动图片
  9627. --—#####################################################
  9628. CREATE PROCEDURE [dbo].[mblAdverprojectByProvinceIDSelect]
  9629. (
  9630. @regionID VARCHAR(20)
  9631. )
  9632. AS
  9633. BEGIN
  9634. SELECT * FROM adverproject
  9635. WHERE type in(23,24)
  9636. AND GETDATE() BETWEEN BeginTime
  9637. AND EndTime AND province_id=@regionID
  9638. AND Valid=1
  9639. ORDER BY Type DESC
  9640. END
  9641. GO
  9642. /****** Object: StoredProcedure [dbo].[mblAppRunLogInsert] Script Date: 2018/12/13 19:07:25 ******/
  9643. SET ANSI_NULLS ON
  9644. GO
  9645. SET QUOTED_IDENTIFIER ON
  9646. GO
  9647. /**
  9648. *Android 个人App安装运行状态信息
  9649. *Peter 2014-01-17 10:26
  9650. */
  9651. CREATE PROCEDURE [dbo].[mblAppRunLogInsert]
  9652. (
  9653. @DeviceID VARCHAR(50),
  9654. @Imei VARCHAR(50),
  9655. @AppId SMALLINT,
  9656. @AccountID INT,
  9657. @Ip VARCHAR(15)
  9658. )
  9659. AS
  9660. BEGIN
  9661. INSERT INTO AppRunLog (DeviceId, Imei, AppId, AccountId, Ip)
  9662. SELECT @DeviceId, @Imei, @AppId, @AccountId, @Ip
  9663. END
  9664. GO
  9665. /****** Object: StoredProcedure [dbo].[mblCaCvContactByCvViewSelect] Script Date: 2018/12/13 19:07:25 ******/
  9666. SET ANSI_NULLS ON
  9667. GO
  9668. SET QUOTED_IDENTIFIER ON
  9669. GO
  9670. CREATE PROCEDURE [dbo].[mblCaCvContactByCvViewSelect]
  9671. (
  9672. @cpMainID INT,
  9673. @JobID INT,
  9674. @caMainID INT,
  9675. @cvMainID INT
  9676. )
  9677. AS
  9678. SET NOCOUNT ON
  9679. BEGIN
  9680. IF @JobID > 0
  9681. BEGIN
  9682. --查询申请记录
  9683. SELECT TOP 1 a.ID, a.AddDate, a.Reply, b.ID JobID, b.Name
  9684. FROM exJobApply a WITH(NOLOCK)
  9685. INNER JOIN Job b WITH(NOLOCK) ON a.JobId = b.Id
  9686. WHERE a.cvMainId = @cvMainID
  9687. AND b.ID = @JobID
  9688. AND CompanyDeleted = 0
  9689. ORDER BY a.ID DESC
  9690. --查询最近3个月的发送面试通知记录
  9691. SELECT TOP 1 a.AddDate, b.ID, b.Name
  9692. FROM ExInterview a WITH(NOLOCK)
  9693. INNER JOIN Job b WITH(NOLOCK)
  9694. ON a.JobId = b.Id
  9695. WHERE a.cvMainId =@cvMainID
  9696. AND b.ID = @JobID
  9697. AND a.AddDate > DATEADD(MONTH, -3, GETDATE())
  9698. ORDER BY a.ID DESC
  9699. --查询收藏记录
  9700. SELECT TOP 1 a.AddDate, b.ID, b.Name
  9701. FROM caFavorate a WITH(NOLOCK)
  9702. INNER JOIN Job b WITH(NOLOCK)
  9703. ON a.JobId = b.Id
  9704. WHERE a.cvMainId = @cvMainID
  9705. AND b.ID = @JobID
  9706. ORDER BY a.ID DESC
  9707. --查询2周内浏览简历记录
  9708. SELECT TOP 1 AddDate
  9709. FROM CaCvViewLog a WITH(NOLOCK)
  9710. WHERE caMainID IN(SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  9711. AND cvMainID = @cvMainID
  9712. AND AddDate>DATEADD(DAY, -14, GETDATE())
  9713. END
  9714. ELSE
  9715. BEGIN
  9716. IF @cpMainID > 0
  9717. BEGIN
  9718. --查询最近2个月的申请记录
  9719. SELECT TOP 1 a.ID, a.AddDate, a.Reply, b.ID JobID, b.Name
  9720. FROM exJobApply a WITH(NOLOCK)
  9721. INNER JOIN Job b WITH(NOLOCK)
  9722. ON a.JobId = b.Id
  9723. WHERE a.cvMainId =@cvMainID
  9724. AND b.cpMainID = @cpMainID
  9725. AND CompanyDeleted = 0
  9726. ORDER BY a.ID DESC
  9727. --查询最近3个月的发送面试通知记录
  9728. SELECT TOP 1 a.AddDate, b.ID, b.Name
  9729. FROM ExInterview a WITH(NOLOCK)
  9730. INNER JOIN Job b WITH(NOLOCK)
  9731. ON a.JobId = b.Id
  9732. WHERE a.cvMainId =@cvMainID
  9733. AND b.cpMainID = @cpMainID
  9734. AND a.AddDate > DATEADD(MONTH, -3, GETDATE())
  9735. ORDER BY a.ID DESC
  9736. --查询收藏记录
  9737. SELECT TOP 1 a.AddDate, b.ID, b.Name
  9738. FROM caFavorate a WITH(NOLOCK)
  9739. INNER JOIN Job b WITH(NOLOCK)
  9740. ON a.JobId = b.Id
  9741. WHERE a.cvMainId =@cvMainID
  9742. AND b.cpMainID = @cpMainID
  9743. ORDER BY a.ID DESC
  9744. --查询2周内浏览简历记录
  9745. SELECT TOP 1 AddDate
  9746. FROM CaCvViewLog a WITH(NOLOCK)
  9747. WHERE caMainID IN(SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  9748. AND cvMainID = @cvMainID
  9749. AND AddDate>DATEADD(DAY, -14, GETDATE())
  9750. END
  9751. ELSE
  9752. BEGIN
  9753. --查询最近2个月的申请记录
  9754. SELECT TOP 1 a.ID, a.AddDate, a.Reply, b.ID JobID, b.Name
  9755. FROM exJobApply a WITH(NOLOCK)
  9756. INNER JOIN Job b WITH(NOLOCK)
  9757. ON a.JobId = b.Id
  9758. WHERE a.cvMainId =@cvMainID
  9759. AND b.caMainID = @caMainID
  9760. AND CompanyDeleted = 0
  9761. ORDER BY a.ID DESC
  9762. --查询最近3个月的发送面试通知记录
  9763. SELECT TOP 1 a.AddDate, b.ID, b.Name
  9764. FROM ExInterview a WITH(NOLOCK)
  9765. INNER JOIN Job b WITH(NOLOCK)
  9766. ON a.JobId = b.Id
  9767. WHERE a.cvMainId =@cvMainID
  9768. AND b.caMainID = @caMainID
  9769. AND a.AddDate > DATEADD(MONTH, -3, GETDATE())
  9770. ORDER BY a.ID DESC
  9771. --查询收藏记录
  9772. SELECT TOP 1 a.AddDate, b.ID, b.Name
  9773. FROM caFavorate a WITH(NOLOCK)
  9774. INNER JOIN Job b WITH(NOLOCK)
  9775. ON a.JobId = b.Id
  9776. WHERE a.cvMainId =@cvMainID
  9777. AND b.caMainID = @caMainID
  9778. ORDER BY a.ID DESC
  9779. --查询2周内浏览简历记录
  9780. SELECT TOP 1 AddDate
  9781. FROM CaCvViewLog a WITH(NOLOCK)
  9782. WHERE caMainID = @caMainID
  9783. AND cvMainID IN(SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  9784. AND AddDate>DATEADD(DAY, -14, GETDATE())
  9785. END
  9786. END
  9787. END
  9788. GO
  9789. /****** Object: StoredProcedure [dbo].[mblCaCvViewLogSelect] Script Date: 2018/12/13 19:07:26 ******/
  9790. SET ANSI_NULLS ON
  9791. GO
  9792. SET QUOTED_IDENTIFIER ON
  9793. GO
  9794. CREATE PROCEDURE [dbo].[mblCaCvViewLogSelect]
  9795. (
  9796. @paMainID AS INT,
  9797. @PageNum AS INT,
  9798. @PageSize AS INT
  9799. )
  9800. AS
  9801. BEGIN
  9802. DECLARE @COUNT INT
  9803. SELECT @COUNT = COUNT(*)
  9804. FROM CaCvViewLog a WITH(NOLOCK), caMain b WITH(NOLOCK), cpMain c WITH(NOLOCK)
  9805. WHERE a.caMainID = b.ID
  9806. AND b.cpMainID=c.ID
  9807. AND a.cvMainId IN(SELECT ID FROM CvMain WITH(NOLOCK) WHERE paMainId = @PaMainID)
  9808. IF @COUNT > 200
  9809. SET @COUNT = 200
  9810. SELECT *, @COUNT AS cnt
  9811. FROM (SELECT TOP 200 ROW_NUMBER() OVER (ORDER BY a.AddDate DESC) AS Rows,
  9812. c.Name CompanyName, a.AddDate, b.cpMainID ,c.secondid encpmainid
  9813. FROM CaCvViewLog a WITH(NOLOCK), caMain b WITH(NOLOCK), cpMain c WITH(NOLOCK)
  9814. WHERE a.caMainID = b.ID AND b.cpMainID=c.ID
  9815. AND a.cvMainId IN(SELECT ID FROM CvMain WITH(NOLOCK) WHERE paMainId = @PaMainID)
  9816. ) AS a
  9817. WHERE a.Rows BETWEEN (@PageNum - 1) * @PageSize + 1 AND @PageNum * @PageSize ORDER BY Rows
  9818. END
  9819. GO
  9820. /****** Object: StoredProcedure [dbo].[mblcaDownloadLogSelect] Script Date: 2018/12/13 19:07:26 ******/
  9821. SET ANSI_NULLS ON
  9822. GO
  9823. SET QUOTED_IDENTIFIER ON
  9824. GO
  9825. --20160108 nick 加入是否绑定微信
  9826. CREATE PROCEDURE [dbo].[mblcaDownloadLogSelect]
  9827. (
  9828. @cpMainID INT,
  9829. @WHERE VARCHAR(1000),
  9830. @ORDER VARCHAR(100),
  9831. @Page SMALLINT,
  9832. @caMainID INT
  9833. )
  9834. AS
  9835. SET NOCOUNT ON
  9836. BEGIN
  9837. SET @Where = dbo.SafeSql(@Where)
  9838. SET @ORDER = dbo.SafeSql(@Order)
  9839. DECLARE @SQL VARCHAR(2000)
  9840. CREATE TABLE #T(
  9841. TitleID BIGINT,
  9842. cvMainID INT,
  9843. caOrderID INT NULL,
  9844. paMainID INT,
  9845. IP VARCHAR(39) COLLATE Chinese_PRC_CI_AS NOT NULL,
  9846. RemainQuota SMALLINT NULL,
  9847. AddDate SMALLDATETIME,
  9848. Degree TINYINT,
  9849. RelatedWorkYears TINYINT,
  9850. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS ,
  9851. IsNameHidden BIT,
  9852. LivePlace VARCHAR(6) COLLATE Chinese_PRC_CI_AS ,
  9853. Gender BIT,
  9854. paName NVARCHAR(20),
  9855. BirthDay INT,
  9856. HasPhoto TINYINT,
  9857. Valid TINYINT,
  9858. HasJobApply BIT,
  9859. HasInterview BIT,
  9860. HasRemark BIT,
  9861. HasFavorate BIT,
  9862. cvEducationID INT,
  9863. College NVARCHAR(50),
  9864. EduType TINYINT,
  9865. MajorName NVARCHAR(20),
  9866. Graduation INT,
  9867. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  9868. Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  9869. MobileVerifyDate SMALLDATETIME,
  9870. IsOnline BIT,
  9871. HasWeiXin BIT,
  9872. PaPhoto VARCHAR(50),
  9873. dcSalaryID SMALLINT,
  9874. SecondId VARCHAR(10)
  9875. )
  9876. SET @SQL = '
  9877. INSERT INTO #T(TitleID, cvMainID, caOrderID, paMainID, RemainQuota, IP, AddDate, Degree,
  9878. RelatedWorkYears, Attachment, IsNameHidden, LivePlace, Gender, BirthDay, HasPhoto,
  9879. Valid, MobileVerifyDate, IsOnline, dcSalaryID, SecondId)
  9880. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.* FROM (
  9881. SELECT
  9882. a.cvMainID, NULL caOrderID, c.ID paMainID, NULL RemainQuota, a.IP, a.AddDate, b.Degree,
  9883. b.RelatedWorkYears, b.Attachment, b.IsNameHidden, c.LivePlace, c.Gender, c.BirthDay, c.HasPhoto,
  9884. b.Valid, c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID) IsOnline, b.dcSalaryID, b.SecondId
  9885. FROM caDailyGiftLog a WITH(NOLOCK)
  9886. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  9887. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  9888. WHERE cpMainID = ' + LTRIM(STR(@cpMainID)) + ' ' + REPLACE(@WHERE, 'a.caOrderID', '1') + '
  9889. AND a.AddDate > DATEADD(YEAR, -2, GETDATE())
  9890. UNION
  9891. SELECT
  9892. a.cvMainID, a.caOrderID, c.ID paMainID, a.RemainQuota, a.IP, a.AddDate, b.Degree,
  9893. b.RelatedWorkYears, b.Attachment, b.IsNameHidden, c.LivePlace, c.Gender, c.BirthDay, c.HasPhoto,
  9894. b.Valid, c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID) IsOnline, b.dcSalaryID, b.SecondId
  9895. FROM caActiveLog a WITH(NOLOCK)
  9896. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  9897. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  9898. WHERE cpMainID = ' + LTRIM(STR(@cpMainID)) + '
  9899. AND a.AddDate > DATEADD(YEAR, -2, GETDATE()) ' + @WHERE + ') a'
  9900. --PRINT @SQL
  9901. EXEC(@SQL)
  9902. IF(@Page < 1)
  9903. SET @Page = 1
  9904. IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
  9905. SET @Page = 1
  9906. UPDATE #T SET paName = LEFT(dbo.GetPaName(cvMainID, @cpMainID), 20),
  9907. HasJobApply = (SELECT TOP 1 '1' FROM exJobApply a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  9908. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  9909. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  9910. HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
  9911. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  9912. UPDATE #T SET Speciality = (
  9913. SELECT Speciality FROM cvMain WITH(NOLOCK)
  9914. WHERE cvMain.ID = #T.cvMainID)
  9915. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  9916. UPDATE #T SET PaPhoto = (
  9917. SELECT TOP 1 PhotoProcessed
  9918. FROM paPhoto a WITH(NOLOCK INDEX(IX_paPhoto_paMainId))
  9919. WHERE paMainID = (SELECT PaMainID FROM cvMain WITH(NOLOCK) WHERE ID = #T.cvMainID))
  9920. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  9921. UPDATE #T SET Experience = (
  9922. SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
  9923. WHERE cvExperience.cvMainID = #T.cvMainID
  9924. ORDER BY BeginDate DESC)
  9925. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  9926. UPDATE #T SET cvEducationID = (
  9927. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  9928. WHERE cvEducation.cvMainID = #T.cvMainID
  9929. AND #T.Degree = cvEducation.Degree
  9930. ORDER BY Graduation DESC)
  9931. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  9932. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  9933. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  9934. FROM #T a, cvEducation b WITH(NOLOCK)
  9935. WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
  9936. --修改是否绑定微信
  9937. UPDATE a SET HasWeiXin = 1
  9938. FROM #T a, WxFans b WITH(NOLOCK), CvMain c WITH(NOLOCK)
  9939. WHERE a.CvMainID = c.ID
  9940. AND c.PaMainID = b.PaMainID
  9941. AND b.Status = 2
  9942. AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  9943. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  9944. SELECT a.*,b.Description DegreeName,c.MapBarName LivePlaceName, dbo.BirthToAge(a.BirthDay) Age,d.Description dcSalaryName
  9945. FROM #T a WITH(NOLOCK)
  9946. LEFT JOIN dcEducation b WITH(NOLOCK) ON b.ID = a.Degree
  9947. LEFT JOIN dcRegion c WITH(NOLOCK) ON c.ID = a.LivePlace
  9948. LEFT JOIN dcSalary d WITH(NOLOCK) ON d.ID = a.dcSalaryID
  9949. WHERE a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
  9950. DROP TABLE #T
  9951. END
  9952. GO
  9953. /****** Object: StoredProcedure [dbo].[mblcaFavorateSelect] Script Date: 2018/12/13 19:07:26 ******/
  9954. SET ANSI_NULLS ON
  9955. GO
  9956. SET QUOTED_IDENTIFIER ON
  9957. GO
  9958. CREATE PROCEDURE [dbo].[mblcaFavorateSelect]
  9959. (
  9960. @WHERE VARCHAR(1000),
  9961. @Order VARCHAR(100),
  9962. @Page SMALLINT,
  9963. @cpMainID INT,
  9964. @caMainID INT
  9965. )
  9966. AS
  9967. SET NOCOUNT ON
  9968. IF NOT EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK) WHERE Id = @caMainId AND cpMainId = @cpMainId)
  9969. RETURN
  9970. BEGIN
  9971. SELECT @Where = dbo.SafeSql(@Where), @ORDER = dbo.SafeSql(@Order)
  9972. DECLARE @SQL AS VARCHAR(2000)
  9973. CREATE TABLE #T(
  9974. TitleID BIGINT,
  9975. ID INT,
  9976. JobID INT,
  9977. JobName VARCHAR(50),
  9978. cvMainID INT,
  9979. paMainID INT,
  9980. caFavorateMarkID INT,
  9981. Degree TINYINT,
  9982. RelatedWorkYears TINYINT,
  9983. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  9984. IsNameHidden BIT,
  9985. LivePlace VARCHAR(6) COLLATE Chinese_PRC_CI_AS,
  9986. Gender BIT,
  9987. paName NVARCHAR(20),
  9988. BirthDay INT,
  9989. HasPhoto TINYINT,
  9990. adddate SMALLDATETIME,
  9991. Valid TINYINT,
  9992. IsViewed BIT,
  9993. HasJobApply BIT,
  9994. HasInterview BIT,
  9995. HasRemark BIT,
  9996. cvEducationID INT,
  9997. College NVARCHAR(50),
  9998. EduType TINYINT,
  9999. MajorName NVARCHAR(20),
  10000. Graduation INT,
  10001. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  10002. Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  10003. MobileVerifyDate SMALLDATETIME,
  10004. IsOnline BIT,
  10005. HasWeiXin BIT,
  10006. PaPhoto VARCHAR(50),
  10007. dcSalaryID SMALLINT,
  10008. SecondId VARCHAR(10)
  10009. )
  10010. --ca的类型: 1 管理员 2 普通用户
  10011. DECLARE @AccountType AS TINYINT
  10012. SELECT @AccountType = AccountType FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
  10013. SET @SQL='
  10014. INSERT INTO #T(
  10015. TitleID, ID, JobID, JobName, cvMainID, paMainID, caFavorateMarkID, Degree, RelatedWorkYears,
  10016. Attachment, IsNameHidden, LivePlace, Gender, paName, BirthDay, HasPhoto, adddate,
  10017. Valid, MobileVerifyDate, IsOnline, dcSalaryID, SecondId
  10018. )
  10019. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID,
  10020. a.ID, a.JobID, d.Name, a.cvMainID, c.ID paMainID, a.caFavorateMarkID,
  10021. b.Degree, b.RelatedWorkYears, b.Attachment, b.IsNameHidden,
  10022. c.LivePlace, c.Gender, c.Name AS paName, c.BirthDay, c.HasPhoto,
  10023. a.adddate, b.Valid, c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID),
  10024. b.dcSalaryID, b.SecondId
  10025. FROM caFavorate a WITH(NOLOCK)
  10026. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  10027. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  10028. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  10029. WHERE d.IsDelete = 0 '
  10030. --add by mice 123 ca中的管理员可以查看子账号收藏的简历
  10031. IF @AccountType = 1
  10032. SET @SQL = @SQL + ' AND a.caMainID IN ( SELECT ID FROM caMain WHERE cpMainID = ' + LTRIM(STR(@cpMainID)) + ' AND IsDelete = 0 AND IsPause = 0 ) '
  10033. ELSE
  10034. SET @SQL = @SQL + ' AND a.caMainID = ' + LTRIM(STR(@caMainID))
  10035. IF LEN(@WHERE) > 0
  10036. SET @SQL = @SQL + @WHERE
  10037. --PRINT @sql
  10038. EXEC(@SQL)
  10039. IF(@Page < 1)
  10040. SET @Page = 1
  10041. UPDATE #T
  10042. SET paName = LEFT(dbo.GetPersonName(cvMainID, @cpMainID), 20),
  10043. IsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID),
  10044. HasJobApply = (SELECT TOP 1 '1' FROM exJobApply a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  10045. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  10046. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
  10047. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  10048. UPDATE #T SET Speciality = (
  10049. SELECT Speciality FROM cvMain WITH(NOLOCK)
  10050. WHERE cvMain.ID = #T.cvMainID)
  10051. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  10052. UPDATE #T SET PaPhoto = dbo.GetPaPhotoByCpView(#T.cvMainID, @cpMainID)
  10053. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  10054. UPDATE #T SET Experience = (
  10055. SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
  10056. WHERE cvExperience.cvMainID = #T.cvMainID
  10057. ORDER BY BeginDate DESC)
  10058. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  10059. UPDATE #T SET cvEducationID = (
  10060. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  10061. WHERE cvEducation.cvMainID = #T.cvMainID
  10062. AND #T.Degree = cvEducation.Degree
  10063. ORDER BY Graduation DESC)
  10064. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  10065. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  10066. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  10067. FROM #T a, cvEducation b WITH(NOLOCK)
  10068. WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
  10069. --修改是否绑定微信
  10070. UPDATE a SET HasWeiXin = 1
  10071. FROM #T a, WxFans b WITH(NOLOCK), CvMain c WITH(NOLOCK)
  10072. WHERE a.CvMainID = c.ID
  10073. AND c.PaMainID = b.PaMainID
  10074. AND b.Status = 2
  10075. AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  10076. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  10077. SELECT a.*,b.Description DegreeName,c.MapBarName LivePlaceName, dbo.BirthToAge(a.BirthDay) Age,d.Description dcSalaryName
  10078. FROM #T a WITH(NOLOCK)
  10079. LEFT JOIN dcEducation b WITH(NOLOCK) ON b.ID = a.Degree
  10080. LEFT JOIN dcRegion c WITH(NOLOCK) ON c.ID = a.LivePlace
  10081. LEFT JOIN dcSalary d WITH(NOLOCK) ON d.ID = a.dcSalaryID
  10082. WHERE a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
  10083. DROP TABLE #T
  10084. END
  10085. GO
  10086. /****** Object: StoredProcedure [dbo].[mblcaIOSBindDelete] Script Date: 2018/12/13 19:07:27 ******/
  10087. SET ANSI_NULLS ON
  10088. GO
  10089. SET QUOTED_IDENTIFIER ON
  10090. GO
  10091. CREATE PROCEDURE [dbo].[mblcaIOSBindDelete]
  10092. (
  10093. @caMainID INT,
  10094. @UniqueID VARCHAR(100)
  10095. )
  10096. AS
  10097. BEGIN
  10098. DELETE FROM caIOSBind WHERE UniqueID = @UniqueID
  10099. END
  10100. GO
  10101. /****** Object: StoredProcedure [dbo].[mblcaIOSBindInsert] Script Date: 2018/12/13 19:07:27 ******/
  10102. SET ANSI_NULLS ON
  10103. GO
  10104. SET QUOTED_IDENTIFIER ON
  10105. GO
  10106. CREATE PROCEDURE [dbo].[mblcaIOSBindInsert]
  10107. (
  10108. @caMainID INT,
  10109. @UniqueID VARCHAR(100),
  10110. @ClientType TINYINT
  10111. )
  10112. AS
  10113. BEGIN TRY
  10114. IF LEN(ISNULL(@UniqueID,'')) = 0
  10115. RETURN
  10116. IF NOT EXISTS(SELECT 1 FROM caIOSBind WITH(NOLOCK) WHERE caMainID = @caMainID AND UniqueID = @UniqueID AND ClientType = @ClientType)
  10117. BEGIN
  10118. INSERT INTO caIOSBind VALUES(@caMainID,@UniqueID,GETDATE(),@ClientType)
  10119. RETURN 1
  10120. END
  10121. ELSE
  10122. BEGIN
  10123. RETURN 0
  10124. END
  10125. END TRY
  10126. BEGIN CATCH
  10127. RETURN 0
  10128. END CATCH
  10129. GO
  10130. /****** Object: StoredProcedure [dbo].[mblcaJobCvMatchByCaMainIDSelect] Script Date: 2018/12/13 19:07:27 ******/
  10131. SET ANSI_NULLS ON
  10132. GO
  10133. SET QUOTED_IDENTIFIER ON
  10134. GO
  10135. ---------------
  10136. --创建人Peter
  10137. --时间 2017-4-17
  10138. --根据caMainID获取推荐简历
  10139. CREATE PROCEDURE [dbo].[mblcaJobCvMatchByCaMainIDSelect]
  10140. (
  10141. @caMainID INT,
  10142. @PageNo INT
  10143. )
  10144. AS
  10145. SET NOCOUNT ON
  10146. BEGIN
  10147. DECLARE @T_CvList AS TABLE(
  10148. iIndex INT IDENTITY(1, 1),
  10149. ID INT,
  10150. cvEducationID INT,
  10151. dcMajorID INT,
  10152. Degree TINYINT,
  10153. RelatedWorkYears INT,
  10154. dcSalaryID TINYINT,
  10155. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  10156. RefreshDate SMALLDATETIME,
  10157. LastLoginDate SMALLDATETIME,
  10158. JobName VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
  10159. MatchJobID INT,
  10160. MatchJobName VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
  10161. Gender BIT,
  10162. BirthDay INT,
  10163. LivePlace INT,
  10164. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  10165. HasPhoto TINYINT,
  10166. College NVARCHAR(50),
  10167. EduType TINYINT,
  10168. MajorName NVARCHAR(20),
  10169. Graduation INT,
  10170. HasViewed BIT,
  10171. ViewDate SMALLDATETIME,
  10172. HasRemarked BIT,
  10173. LastJobTypeID INT,
  10174. Valid TINYINT,
  10175. IsOnline BIT,
  10176. HasWeiXin BIT,
  10177. JobRecommendDate SMALLDATETIME,
  10178. paMainID INT,
  10179. SecondId VARCHAR(10)
  10180. )
  10181. CREATE TABLE #T_JobID(
  10182. JobID INT
  10183. )
  10184. DECLARE @cpMainID INT
  10185. SELECT @cpMainID = CASE AccountType WHEN 1 THEN CpMainID ELSE 0 END FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
  10186. IF @cpMainID <> 0 --管理员用户
  10187. BEGIN
  10188. INSERT INTO #T_JobID (JobID)
  10189. SELECT ID FROM Job WITH(NOLOCK)
  10190. WHERE cpMainID = @cpMainID
  10191. END
  10192. ELSE
  10193. BEGIN
  10194. INSERT INTO #T_JobID (JobID)
  10195. SELECT ID FROM Job WITH(NOLOCK)
  10196. WHERE caMainID = @caMainID
  10197. END
  10198. INSERT INTO @T_CvList(ID, dcMajorID, Degree, RelatedWorkYears, dcSalaryID, Speciality, RefreshDate,
  10199. LastLoginDate, JobName, MatchJobID, Gender, BirthDay, LivePlace, LastJobTypeID, Attachment,
  10200. HasPhoto, HasViewed, HasRemarked, Valid, IsOnline, JobRecommendDate, paMainId, SecondId)
  10201. SELECT a.ID, a.dcMajorID, a.Degree, a.RelatedWorkYears, a.dcSalaryID, ISNULL(a.Speciality, a.SpecialityEng) Speciality,
  10202. a.RefreshDate, j.LastLoginDate, ISNULL(a.JobName, '应届毕业生') JobName, b.JobID, j.Gender, j.BirthDay, j.LivePlace,
  10203. a.LastJobTypeID, a.Attachment, j.HasPhoto, 0, 0, a.Valid, dbo.GetPaOnlineStatus(j.ID), b.AddDate, a.paMainId, a.SecondId
  10204. FROM cvmainPublish a WITH(NOLOCK)
  10205. INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID=j.ID
  10206. INNER JOIN caJobCvMatch b ON a.id=b.MatchCvMainID
  10207. WHERE b.JobID IN (SELECT JobID FROM #T_JobID)
  10208. ORDER BY b.AddDate DESC
  10209. DECLARE @PageLowerBound INT --定义此页的底码
  10210. DECLARE @PageUpperBound INT --定义此页的顶码
  10211. SET @PageLowerBound = (@PageNo -1) * 20
  10212. SET @PageUpperBound = @PageLowerBound + 20
  10213. UPDATE a SET a.cvEducationID = (
  10214. SELECT TOP 1 ID FROM cvEducationPublish WITH(NOLOCK)
  10215. WHERE cvEducationPublish.cvMainID = a.ID
  10216. AND a.Degree = cvEducationPublish.Degree
  10217. ORDER BY Graduation DESC)
  10218. FROM @T_CvList a
  10219. WHERE a.iIndex > @PageLowerBound
  10220. AND a.iIndex <= @PageUpperBound
  10221. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  10222. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  10223. FROM @T_CvList a, cvEducationPublish b WITH(NOLOCK)
  10224. WHERE b.ID = a.cvEducationID
  10225. AND a.iIndex > @PageLowerBound
  10226. AND a.iIndex <= @PageUpperBound
  10227. --修改是否绑定微信
  10228. UPDATE a SET HasWeiXin = 1
  10229. FROM @T_CvList a, WxFans b WITH(NOLOCK), CvMainPublish c WITH(NOLOCK)
  10230. WHERE a.ID = c.ID
  10231. AND c.PaMainID = b.PaMainID
  10232. AND b.Status = 2
  10233. AND a.iIndex > @PageLowerBound
  10234. AND a.iIndex <= @PageUpperBound
  10235. UPDATE a SET a.MatchJobName = b.Name
  10236. FROM @T_CvList a, Job b WITH(NOLOCK)
  10237. WHERE a.MatchJobID = b.ID
  10238. AND a.iIndex > @PageLowerBound
  10239. AND a.iIndex <= @PageUpperBound
  10240. UPDATE a SET a.HasViewed = 1, a.ViewDate = b.AddDate
  10241. FROM @T_CvList a, caCvViewLog b WITH(NOLOCK)
  10242. WHERE b.cvMainID = a.ID AND caMainID=@caMainID
  10243. AND a.iIndex > @PageLowerBound
  10244. AND a.iIndex <= @PageUpperBound
  10245. SELECT a.*,b.Description DegreeName,dbo.BirthToAge(a.BirthDay) Age,c.Description LivePlaceName
  10246. FROM @T_CvList a
  10247. LEFT JOIN MainDB..dcEducation b WITH(NOLOCK) ON b.ID = a.Degree
  10248. LEFT JOIN MainDB..dcRegion c WITH(NOLOCK) ON c.ID = a.LivePlace
  10249. WHERE a.iIndex > @PageLowerBound
  10250. AND a.iIndex <= @PageUpperBound
  10251. DROP TABLE #T_JobID
  10252. END
  10253. GO
  10254. /****** Object: StoredProcedure [dbo].[mblcaLoginContactByOpenIDSelect] Script Date: 2018/12/13 19:07:28 ******/
  10255. SET ANSI_NULLS ON
  10256. GO
  10257. SET QUOTED_IDENTIFIER ON
  10258. GO
  10259. --#####################################################
  10260. --创建时间:2016.4.1
  10261. --创建人:Lucifer
  10262. --说明:根据微信号得到微信绑定企业信息
  10263. --#####################################################
  10264. CREATE PROCEDURE [dbo].[mblcaLoginContactByOpenIDSelect]
  10265. (
  10266. @OpenID VARCHAR(50)
  10267. )
  10268. AS
  10269. BEGIN
  10270. SELECT a.*, b.UserName
  10271. FROM paLoginContact a, caMain b, cpMain c
  10272. WHERE a.openid=@OpenID
  10273. AND a.ContactType = 101
  10274. AND a.PamainID = b.ID
  10275. AND b.cpMainId = c.Id
  10276. AND b.IsPause = 0
  10277. AND c.IsLimitLogin IN(0, 1)
  10278. END
  10279. GO
  10280. /****** Object: StoredProcedure [dbo].[mblCaMainByIDSelect] Script Date: 2018/12/13 19:07:28 ******/
  10281. SET ANSI_NULLS ON
  10282. GO
  10283. SET QUOTED_IDENTIFIER ON
  10284. GO
  10285. CREATE PROCEDURE [dbo].[mblCaMainByIDSelect]
  10286. (
  10287. @caMainID INT
  10288. )
  10289. AS
  10290. BEGIN TRY
  10291. SELECT a.name,b.name as companyname,b.id cpMainID,dbo.GetCaOnlineStatus(a.id) IsOnline,b.SecondId EnCpMainId
  10292. FROM camain a,cpmain b
  10293. WHERE a.id=@caMainID
  10294. AND a.cpmainid = b.id
  10295. END TRY
  10296. BEGIN CATCH
  10297. RETURN 0
  10298. END CATCH
  10299. GO
  10300. /****** Object: StoredProcedure [dbo].[mblCampusSchoolByIDSelect] Script Date: 2018/12/13 19:07:28 ******/
  10301. SET ANSI_NULLS ON
  10302. GO
  10303. SET QUOTED_IDENTIFIER ON
  10304. GO
  10305. --#####################################################
  10306. --创建时间:2014.11.06
  10307. --创建人:Nick
  10308. --说明:根据ID获取学校名称
  10309. --#####################################################
  10310. CREATE PROCEDURE [dbo].[mblCampusSchoolByIDSelect]
  10311. (
  10312. @ID INT
  10313. )
  10314. AS
  10315. BEGIN TRY
  10316. SELECT * FROM marketdb..CampusSchool WHERE ID = @ID
  10317. END TRY
  10318. BEGIN CATCH
  10319. RETURN 0
  10320. END CATCH
  10321. GO
  10322. /****** Object: StoredProcedure [dbo].[mblcaPageViewLogByNoViewSelect] Script Date: 2018/12/13 19:07:28 ******/
  10323. SET ANSI_NULLS ON
  10324. GO
  10325. SET QUOTED_IDENTIFIER ON
  10326. GO
  10327. CREATE PROCEDURE [dbo].[mblcaPageViewLogByNoViewSelect]
  10328. (
  10329. @caMainID INT
  10330. )
  10331. AS
  10332. SET NOCOUNT ON
  10333. IF @caMainID = 0
  10334. BEGIN
  10335. SELECT TOP 0 0 ID
  10336. RETURN
  10337. END
  10338. BEGIN
  10339. IF NOT EXISTS(SELECT 'x' FROM caPageViewLog WITH(NOLOCK) WHERE caMainId = @caMainID)
  10340. BEGIN
  10341. INSERT INTO caPageViewLog(caMainId,addDate,ApplyCvDate,RecommendCvDate,InterviewReplyDate)
  10342. VALUES(@caMainID, DATEADD(MINUTE, -10, GETDATE()), DATEADD(MINUTE, -10, GETDATE()), DATEADD(MINUTE, -10, GETDATE()), DATEADD(MINUTE, -10, GETDATE()))
  10343. --RETURN
  10344. END
  10345. DECLARE @AddDate SMALLDATETIME, @ApplyCvDate SMALLDATETIME, @RecommendCvDate SMALLDATETIME,
  10346. @InterviewReplyDate SMALLDATETIME, @ApplyCvCount INT, @RecommendCvCount INT,
  10347. @InterviewReplyCount INT,@ChatCount INT,@cpMainID INT,@AccountType SMALLINT
  10348. SELECT @AddDate = AddDate,
  10349. @ApplyCvDate = ISNULL(ApplyCvDate, DATEADD(MINUTE, -10, GETDATE())),
  10350. @RecommendCvDate = ISNULL(RecommendCvDate, DATEADD(MINUTE, -10, GETDATE())),
  10351. @InterviewReplyDate = ISNULL(InterviewReplyDate, DATEADD(MINUTE, -10, GETDATE())),
  10352. @ApplyCvCount = ISNULL(ApplyCvCount, 0),
  10353. @RecommendCvCount = ISNULL(RecommendCvCount, 0),
  10354. @InterviewReplyCount = ISNULL(InterviewReplyCount, 0),
  10355. @ChatCount = ISNULL(ChatCount, 0)
  10356. FROM caPageViewLog WITH(NOLOCK)
  10357. WHERE caMainId = @caMainID
  10358. SELECT @cpMainID=cpMainID,@AccountType=AccountType
  10359. FROM caMain WITH(NOLOCK)
  10360. WHERE ID = @caMainID
  10361. CREATE TABLE #TJobIDs
  10362. (
  10363. ID INT
  10364. )
  10365. IF @AccountType = 1 --管理员账户
  10366. BEGIN
  10367. INSERT INTO #TJobIDs(ID)
  10368. SELECT ID
  10369. FROM Job WITH(NOLOCK)
  10370. WHERE cpMainID = @cpMainID
  10371. END
  10372. ELSE
  10373. BEGIN
  10374. INSERT INTO #TJobIDs(ID)
  10375. SELECT ID
  10376. FROM Job WITH(NOLOCK)
  10377. WHERE caMainID = @caMainID
  10378. END
  10379. --更新时间超过30分钟的,重新计算提醒内容
  10380. IF GETDATE() > DATEADD(MINUTE, 30, @AddDate) --30分钟内的不重新生成
  10381. BEGIN
  10382. --新应聘的简历
  10383. IF @ApplyCvCount = 0
  10384. BEGIN
  10385. SELECT @ApplyCvCount = COUNT(1)
  10386. FROM exJobApply WITH(NOLOCK)
  10387. WHERE JobID IN(SELECT ID FROM #TJobIDs)
  10388. AND AddDate > @ApplyCvDate
  10389. END
  10390. --新推荐简历
  10391. IF @RecommendCvCount = 0
  10392. BEGIN
  10393. SELECT @RecommendCvCount = COUNT(1)
  10394. FROM caJobCvMatch WITH(NOLOCK)
  10395. WHERE JobID IN(SELECT ID FROM #TJobIDs)
  10396. AND AddDate > @RecommendCvDate
  10397. END
  10398. --新面试通知答复
  10399. IF @InterviewReplyCount = 0
  10400. BEGIN
  10401. SELECT @InterviewReplyCount = COUNT(1)
  10402. FROM exInterview WITH(NOLOCK)
  10403. WHERE JobID IN(SELECT ID FROM #TJobIDs)
  10404. AND Replydate > @RecommendCvDate
  10405. END
  10406. --新的聊天信息
  10407. IF @ChatCount = 0
  10408. BEGIN
  10409. SELECT @ChatCount=COUNT(1)
  10410. FROM ChatOnlineLog a WITH(NOLOCK)
  10411. LEFT JOIN ChatOnline b WITH(NOLOCK) ON a.ChatOnlineID = b.ID
  10412. WHERE b.caMainID = @caMainID
  10413. AND a.IsViewed = 0
  10414. AND a.SenderType = 2
  10415. END
  10416. --更新添加时间
  10417. IF (@ApplyCvCount + @RecommendCvCount + @InterviewReplyCount + @ChatCount)>0
  10418. UPDATE caPageViewLog
  10419. SET AddDate = GETDATE(),
  10420. ApplyCvCount = @ApplyCvCount,
  10421. RecommendCvCount = @RecommendCvCount,
  10422. InterviewReplyCount = @InterviewReplyCount,
  10423. ChatCount =@ChatCount
  10424. WHERE caMainId = @caMainID
  10425. ELSE
  10426. UPDATE caPageViewLog
  10427. SET AddDate = GETDATE()
  10428. WHERE caMainId = @caMainID
  10429. END
  10430. SELECT * FROM caPageViewLog WHERE caMainId = @caMainID --查询表内容
  10431. DROP TABLE #TJobIDs
  10432. END
  10433. GO
  10434. /****** Object: StoredProcedure [dbo].[mblChatOnlineByCaIDSelect] Script Date: 2018/12/13 19:07:28 ******/
  10435. SET ANSI_NULLS ON
  10436. GO
  10437. SET QUOTED_IDENTIFIER ON
  10438. GO
  10439. --#####################################################
  10440. --创建时间:2014.11.06
  10441. --创建人:Nick
  10442. --说明:根据camainid manageruserid 得到会话信息
  10443. --#####################################################
  10444. CREATE PROCEDURE [dbo].[mblChatOnlineByCaIDSelect]
  10445. (
  10446. @caMainID INT,
  10447. @mID INT
  10448. )
  10449. AS
  10450. BEGIN TRY
  10451. SELECT TOP 1 *
  10452. FROM chatonline
  10453. WHERE caMainID = @caMainID
  10454. AND manageruserid=@mID
  10455. AND enddate IS NULL
  10456. ORDER BY adddate DESC
  10457. END TRY
  10458. BEGIN CATCH
  10459. RETURN 0
  10460. END CATCH
  10461. GO
  10462. /****** Object: StoredProcedure [dbo].[mblChatOnlineByCaMainIDSelect] Script Date: 2018/12/13 19:07:29 ******/
  10463. SET ANSI_NULLS ON
  10464. GO
  10465. SET QUOTED_IDENTIFIER ON
  10466. GO
  10467. --#####################################################
  10468. --创建时间:2014.11.06
  10469. --创建人:Nick
  10470. --说明:获取客服
  10471. --#####################################################
  10472. CREATE PROCEDURE [dbo].[mblChatOnlineByCaMainIDSelect]
  10473. (
  10474. @caMainID INT
  10475. )
  10476. AS
  10477. BEGIN TRY
  10478. SELECT a.manageruserid,b.Name
  10479. FROM chatonline a,ManagerUser b
  10480. WHERE a.camainid = @caMainID
  10481. AND a.enddate is null
  10482. AND a.manageruserid <> 0
  10483. AND a.ManagerUserID = b.ID
  10484. END TRY
  10485. BEGIN CATCH
  10486. RETURN 0
  10487. END CATCH
  10488. GO
  10489. /****** Object: StoredProcedure [dbo].[mblChatOnlineByCvMainIDSelect] Script Date: 2018/12/13 19:07:29 ******/
  10490. SET ANSI_NULLS ON
  10491. GO
  10492. SET QUOTED_IDENTIFIER ON
  10493. GO
  10494. --#####################################################
  10495. --创建时间:2014.11.06
  10496. --创建人:Nick
  10497. --说明:根据cvmainid camainid 得到会话信息
  10498. --#####################################################
  10499. CREATE PROCEDURE [dbo].[mblChatOnlineByCvMainIDSelect]
  10500. (
  10501. @cvMainID INT,
  10502. @caMainID INT
  10503. )
  10504. AS
  10505. BEGIN TRY
  10506. SELECT TOP 1 *
  10507. FROM chatonline
  10508. WHERE cvMainID = @cvMainID
  10509. AND caMainID=@caMainID
  10510. AND enddate IS NULL
  10511. ORDER BY adddate DESC
  10512. END TRY
  10513. BEGIN CATCH
  10514. RETURN 0
  10515. END CATCH
  10516. GO
  10517. /****** Object: StoredProcedure [dbo].[mblChatOnlineByMIDSelect] Script Date: 2018/12/13 19:07:29 ******/
  10518. SET ANSI_NULLS ON
  10519. GO
  10520. SET QUOTED_IDENTIFIER ON
  10521. GO
  10522. --#####################################################
  10523. --创建时间:2014.11.06
  10524. --创建人:Nick
  10525. --说明:根据cvmainid manageruserid 得到会话信息
  10526. --#####################################################
  10527. CREATE PROCEDURE [dbo].[mblChatOnlineByMIDSelect]
  10528. (
  10529. @cvMainID INT,
  10530. @manageruserid INT
  10531. )
  10532. AS
  10533. BEGIN TRY
  10534. SELECT TOP 1 *
  10535. FROM chatonline
  10536. WHERE cvMainID = @cvMainID
  10537. AND manageruserid=@manageruserid
  10538. AND enddate IS NULL
  10539. ORDER BY adddate DESC
  10540. END TRY
  10541. BEGIN CATCH
  10542. RETURN 0
  10543. END CATCH
  10544. GO
  10545. /****** Object: StoredProcedure [dbo].[mblChatOnlineCpNoViewCntSelect] Script Date: 2018/12/13 19:07:29 ******/
  10546. SET ANSI_NULLS ON
  10547. GO
  10548. SET QUOTED_IDENTIFIER ON
  10549. GO
  10550. --#####################################################
  10551. --创建时间:2014.11.7
  10552. --创建人:John
  10553. --说明:在线沟通企业未读总条数
  10554. --#####################################################
  10555. CREATE PROCEDURE [dbo].[mblChatOnlineCpNoViewCntSelect]
  10556. (
  10557. @caMainID INT
  10558. )
  10559. AS
  10560. BEGIN
  10561. SELECT COUNT(*) cnt FROM chatonlinelog a WITH(NOLOCK) INNER JOIN chatonline b WITH(NOLOCK) ON a.chatonlineid=b.id
  10562. WHERE a.sendertype = 2 AND a.isviewed = 0 AND b.caMainID = @caMainID
  10563. END
  10564. GO
  10565. /****** Object: StoredProcedure [dbo].[mblChatOnlineInsert] Script Date: 2018/12/13 19:07:29 ******/
  10566. SET ANSI_NULLS ON
  10567. GO
  10568. SET QUOTED_IDENTIFIER ON
  10569. GO
  10570. --#####################################################
  10571. --创建时间:2014.11.06
  10572. --创建人:Nick
  10573. --说明:获取个人信息
  10574. --#####################################################
  10575. CREATE PROCEDURE [dbo].[mblChatOnlineInsert]
  10576. (
  10577. @cvMainID INT,
  10578. @caMainID INT
  10579. )
  10580. AS
  10581. BEGIN TRY
  10582. INSERT INTO chatonline (cvMainID,caMainID,initiative,startDate,valid,adddate)
  10583. VALUES(@cvMainID,@caMainID,1,getdate(),0,getdate())
  10584. RETURN 1
  10585. END TRY
  10586. BEGIN CATCH
  10587. RETURN 0
  10588. END CATCH
  10589. GO
  10590. /****** Object: StoredProcedure [dbo].[mblChatOnlineLogByCaIDSelect] Script Date: 2018/12/13 19:07:30 ******/
  10591. SET ANSI_NULLS ON
  10592. GO
  10593. SET QUOTED_IDENTIFIER ON
  10594. GO
  10595. --#####################################################
  10596. --创建时间:2014.11.06
  10597. --创建人:Nick
  10598. --说明:企业会话列表
  10599. --#####################################################
  10600. CREATE PROCEDURE [dbo].[mblChatOnlineLogByCaIDSelect]
  10601. @cvMainID INT,
  10602. @caMainID INT
  10603. AS
  10604. BEGIN TRY
  10605. SELECT a.* FROM ChatOnlineLog a
  10606. WHERE a.ChatOnlineID IN(
  10607. SELECT ID FROM
  10608. ChatOnline WHERE cvMainID=@cvMainID AND caMainID=@caMainID
  10609. )
  10610. ORDER BY a.AddDate
  10611. END TRY
  10612. BEGIN CATCH
  10613. RETURN 0
  10614. END CATCH
  10615. GO
  10616. /****** Object: StoredProcedure [dbo].[mblChatOnlineLogByConditionSelect] Script Date: 2018/12/13 19:07:30 ******/
  10617. SET ANSI_NULLS ON
  10618. GO
  10619. SET QUOTED_IDENTIFIER ON
  10620. GO
  10621. --#####################################################
  10622. --创建时间:2014.11.06
  10623. --创建人:Nick
  10624. --说明:获取企业与顾问的回话信息
  10625. --#####################################################
  10626. CREATE PROCEDURE [dbo].[mblChatOnlineLogByConditionSelect]
  10627. (
  10628. @caMainID INT,
  10629. @consultantID INT,
  10630. @Condition VARCHAR(MAX)
  10631. )
  10632. AS
  10633. BEGIN TRY
  10634. DECLARE @SQL VARCHAR(MAX)
  10635. SET @SQL = '
  10636. SELECT a.* FROM ChatOnlineLog a
  10637. WHERE a.ChatOnlineID IN(
  10638. SELECT ID FROM
  10639. ChatOnline WHERE caMainID='+CONVERT(VARCHAR(20),@caMainID)+'
  10640. AND managerUserID='+CONVERT(VARCHAR(10),@consultantID)+'
  10641. '+@Condition+'
  10642. )
  10643. ORDER BY a.AddDate'
  10644. PRINT @SQL
  10645. EXEC (@SQL)
  10646. END TRY
  10647. BEGIN CATCH
  10648. RETURN 0
  10649. END CATCH
  10650. GO
  10651. /****** Object: StoredProcedure [dbo].[mblChatOnlineLogByCvMainIDUpdate] Script Date: 2018/12/13 19:07:30 ******/
  10652. SET ANSI_NULLS ON
  10653. GO
  10654. SET QUOTED_IDENTIFIER ON
  10655. GO
  10656. --#####################################################
  10657. --创建时间:2014.11.06
  10658. --创建人:Nick
  10659. --说明:将消息修改为已读
  10660. --#####################################################
  10661. CREATE PROCEDURE [dbo].[mblChatOnlineLogByCvMainIDUpdate]
  10662. (
  10663. @cvMainID INT,
  10664. @caMainID INT
  10665. )
  10666. AS
  10667. BEGIN TRY
  10668. UPDATE chatonlinelog
  10669. SET isviewed=1
  10670. WHERE isviewed=0
  10671. AND chatonlineid IN(
  10672. SELECT ID FROM chatonline
  10673. WHERE cvmainid = @cvMainID
  10674. AND camainid = @caMainID
  10675. ) AND SenderType = 1
  10676. RETURN 1
  10677. END TRY
  10678. BEGIN CATCH
  10679. RETURN 0
  10680. END CATCH
  10681. GO
  10682. /****** Object: StoredProcedure [dbo].[mblChatOnlineLogByIDSelect] Script Date: 2018/12/13 19:07:30 ******/
  10683. SET ANSI_NULLS ON
  10684. GO
  10685. SET QUOTED_IDENTIFIER ON
  10686. GO
  10687. --#####################################################
  10688. --创建时间:2014.11.06
  10689. --创建人:Nick
  10690. --说明:根据ID获取会话信息
  10691. --#####################################################
  10692. CREATE PROCEDURE [dbo].[mblChatOnlineLogByIDSelect]
  10693. (
  10694. @ID INT
  10695. )
  10696. AS
  10697. BEGIN TRY
  10698. SELECT * FROM chatonline WHERE id=@ID
  10699. END TRY
  10700. BEGIN CATCH
  10701. RETURN 0
  10702. END CATCH
  10703. GO
  10704. /****** Object: StoredProcedure [dbo].[mblChatOnlineLogByMIDSelect] Script Date: 2018/12/13 19:07:30 ******/
  10705. SET ANSI_NULLS ON
  10706. GO
  10707. SET QUOTED_IDENTIFIER ON
  10708. GO
  10709. --#####################################################
  10710. --创建时间:2014.11.06
  10711. --创建人:Nick
  10712. --说明:顾问或客服会话
  10713. --#####################################################
  10714. CREATE PROCEDURE [dbo].[mblChatOnlineLogByMIDSelect]
  10715. (
  10716. @cvMainID INT,
  10717. @managerUserID INT
  10718. )
  10719. AS
  10720. BEGIN TRY
  10721. SELECT a.* FROM ChatOnlineLog a
  10722. WHERE a.ChatOnlineID IN(
  10723. SELECT ID
  10724. FROM ChatOnline
  10725. WHERE cvMainID=@cvMainID
  10726. AND managerUserID=@managerUserID)
  10727. ORDER BY a.AddDate
  10728. END TRY
  10729. BEGIN CATCH
  10730. RETURN 0
  10731. END CATCH
  10732. GO
  10733. /****** Object: StoredProcedure [dbo].[mblChatOnlineLogByMIDUpdate] Script Date: 2018/12/13 19:07:30 ******/
  10734. SET ANSI_NULLS ON
  10735. GO
  10736. SET QUOTED_IDENTIFIER ON
  10737. GO
  10738. --#####################################################
  10739. --创建时间:2014.11.06
  10740. --创建人:Nick
  10741. --说明:将消息修改为已读
  10742. --#####################################################
  10743. CREATE PROCEDURE [dbo].[mblChatOnlineLogByMIDUpdate]
  10744. (
  10745. @cvMainID INT,
  10746. @mID INT
  10747. )
  10748. AS
  10749. BEGIN TRY
  10750. UPDATE chatonlinelog
  10751. SET isviewed=1
  10752. WHERE isviewed=0
  10753. AND chatonlineid IN(
  10754. SELECT ID FROM chatonline
  10755. WHERE cvmainid = @cvMainID
  10756. AND managerUserID = @mID
  10757. )
  10758. END TRY
  10759. BEGIN CATCH
  10760. RETURN 0
  10761. END CATCH
  10762. GO
  10763. /****** Object: StoredProcedure [dbo].[mblChatOnlineLogBySenderTypeUpdate] Script Date: 2018/12/13 19:07:30 ******/
  10764. SET ANSI_NULLS ON
  10765. GO
  10766. SET QUOTED_IDENTIFIER ON
  10767. GO
  10768. --#####################################################
  10769. --创建时间:2014.11.06
  10770. --创建人:Nick
  10771. --说明:将消息修改为已读
  10772. --#####################################################
  10773. CREATE PROCEDURE [dbo].[mblChatOnlineLogBySenderTypeUpdate]
  10774. (
  10775. @cvMainID INT,
  10776. @caMainID INT
  10777. )
  10778. AS
  10779. BEGIN TRY
  10780. UPDATE chatonlinelog
  10781. SET isviewed=1
  10782. WHERE isviewed=0
  10783. AND chatonlineid IN(
  10784. SELECT ID FROM chatonline
  10785. WHERE cvmainid = @cvMainID
  10786. AND camainid = @caMainID
  10787. ) AND SenderType = 2
  10788. END TRY
  10789. BEGIN CATCH
  10790. RETURN 0
  10791. END CATCH
  10792. GO
  10793. /****** Object: StoredProcedure [dbo].[mblChatOnlineLogInsert] Script Date: 2018/12/13 19:07:31 ******/
  10794. SET ANSI_NULLS ON
  10795. GO
  10796. SET QUOTED_IDENTIFIER ON
  10797. GO
  10798. --#####################################################
  10799. --创建时间:2014.11.06
  10800. --创建人:Nick
  10801. --说明:发送消息 插入
  10802. --#####################################################
  10803. CREATE PROCEDURE [dbo].[mblChatOnlineLogInsert]
  10804. (
  10805. @chatOnlineID INT,
  10806. @senderType INT,
  10807. @Message VARCHAR(500)
  10808. )
  10809. AS
  10810. BEGIN TRY
  10811. INSERT INTO chatonlinelog (chatOnlineID,SenderType,isviewed,message,adddate)
  10812. VALUES(@chatOnlineID,@senderType,0,@Message,getdate())
  10813. RETURN 1
  10814. END TRY
  10815. BEGIN CATCH
  10816. RETURN 0
  10817. END CATCH
  10818. GO
  10819. /****** Object: StoredProcedure [dbo].[mblChatonlineLogNoViewCntByPaMainIDSelect] Script Date: 2018/12/13 19:07:31 ******/
  10820. SET ANSI_NULLS ON
  10821. GO
  10822. SET QUOTED_IDENTIFIER ON
  10823. GO
  10824. --#####################################################
  10825. --创建时间:2014.11.06
  10826. --创建人:Nick
  10827. --说明:个人未读总条数
  10828. --#####################################################
  10829. CREATE PROCEDURE [dbo].[mblChatonlineLogNoViewCntByPaMainIDSelect]
  10830. @PamainID INT
  10831. AS
  10832. BEGIN TRY
  10833. SELECT COUNT(*) cnt
  10834. FROM chatonlinelog
  10835. WHERE sendertype=1
  10836. AND isviewed = 0
  10837. AND chatonlineid IN (
  10838. SELECT id
  10839. FROM chatonline
  10840. WHERE cvmainid in (
  10841. SELECT ID FROM cvmain
  10842. WHERE pamainid=@PaMainID
  10843. )
  10844. )
  10845. END TRY
  10846. BEGIN CATCH
  10847. RETURN 0
  10848. END CATCH
  10849. GO
  10850. /****** Object: StoredProcedure [dbo].[mblChatOnlineLogViewByCaMainIDUpdate] Script Date: 2018/12/13 19:07:31 ******/
  10851. SET ANSI_NULLS ON
  10852. GO
  10853. SET QUOTED_IDENTIFIER ON
  10854. GO
  10855. --#####################################################
  10856. --创建时间:2014.11.06
  10857. --创建人:Nick
  10858. --说明:将消息修改为已读
  10859. --#####################################################
  10860. CREATE PROCEDURE [dbo].[mblChatOnlineLogViewByCaMainIDUpdate]
  10861. (
  10862. @caMainID INT,
  10863. @cvMainID INT
  10864. )
  10865. AS
  10866. BEGIN TRY
  10867. UPDATE chatonlinelog
  10868. SET isviewed=1
  10869. WHERE isviewed=0
  10870. AND chatonlineid IN(
  10871. SELECT ID FROM chatonline
  10872. WHERE camainid = @caMainID
  10873. AND cvmainid = @cvMainID)
  10874. END TRY
  10875. BEGIN CATCH
  10876. RETURN 0
  10877. END CATCH
  10878. GO
  10879. /****** Object: StoredProcedure [dbo].[mblChatOnlineLogViewByCIDUpdate] Script Date: 2018/12/13 19:07:31 ******/
  10880. SET ANSI_NULLS ON
  10881. GO
  10882. SET QUOTED_IDENTIFIER ON
  10883. GO
  10884. --#####################################################
  10885. --创建时间:2014.11.06
  10886. --创建人:Nick
  10887. --说明:将消息修改为已读
  10888. --#####################################################
  10889. CREATE PROCEDURE [dbo].[mblChatOnlineLogViewByCIDUpdate]
  10890. (
  10891. @caMainID INT
  10892. )
  10893. AS
  10894. BEGIN TRY
  10895. UPDATE chatonlinelog
  10896. SET isviewed=1
  10897. WHERE isviewed=0
  10898. AND chatonlineid IN(
  10899. SELECT ID FROM chatonline
  10900. WHERE camainid = @caMainID
  10901. AND managerUserID <=200)
  10902. END TRY
  10903. BEGIN CATCH
  10904. RETURN 0
  10905. END CATCH
  10906. GO
  10907. /****** Object: StoredProcedure [dbo].[mblChatOnlineLogViewByMIDUpdate] Script Date: 2018/12/13 19:07:31 ******/
  10908. SET ANSI_NULLS ON
  10909. GO
  10910. SET QUOTED_IDENTIFIER ON
  10911. GO
  10912. --#####################################################
  10913. --创建时间:2014.11.06
  10914. --创建人:Nick
  10915. --说明:将消息修改为已读
  10916. --#####################################################
  10917. CREATE PROCEDURE [dbo].[mblChatOnlineLogViewByMIDUpdate]
  10918. (
  10919. @caMainID INT,
  10920. @mID INT
  10921. )
  10922. AS
  10923. BEGIN TRY
  10924. UPDATE chatonlinelog
  10925. SET isviewed=1
  10926. WHERE isviewed=0
  10927. AND chatonlineid IN(
  10928. SELECT ID FROM chatonline
  10929. WHERE camainid = @caMainID
  10930. AND managerUserID = @mID)
  10931. END TRY
  10932. BEGIN CATCH
  10933. RETURN 0
  10934. END CATCH
  10935. GO
  10936. /****** Object: StoredProcedure [dbo].[mblChatServiceSelect] Script Date: 2018/12/13 19:07:31 ******/
  10937. SET ANSI_NULLS ON
  10938. GO
  10939. SET QUOTED_IDENTIFIER ON
  10940. GO
  10941. --#####################################################
  10942. --创建时间:2014.11.06
  10943. --创建人:Nick
  10944. --说明:获取客服
  10945. --#####################################################
  10946. CREATE PROCEDURE [dbo].[mblChatServiceSelect]
  10947. (
  10948. @IsOnline INT
  10949. )
  10950. AS
  10951. BEGIN TRY
  10952. IF @IsOnline = 1
  10953. BEGIN
  10954. SELECT TOP 1 * FROM ChatService WHERE IsOnline=1 ORDER BY ChatCount
  10955. END
  10956. ELSE
  10957. BEGIN
  10958. SELECT TOP 1 * FROM ChatService ORDER BY ChatCount
  10959. END
  10960. END TRY
  10961. BEGIN CATCH
  10962. RETURN 0
  10963. END CATCH
  10964. GO
  10965. /****** Object: StoredProcedure [dbo].[mblCpMainByIDSelect] Script Date: 2018/12/13 19:07:32 ******/
  10966. SET ANSI_NULLS ON
  10967. GO
  10968. SET QUOTED_IDENTIFIER ON
  10969. GO
  10970. --#####################################################
  10971. --创建时间:2014.11.7
  10972. --创建人:John
  10973. --说明:根据ID或SecondID获取CpMain相关信息
  10974. --修改:harry2015-6-18
  10975. --增加secondid
  10976. --修改:peter 2016-12-16 添加logo获取
  10977. --#####################################################
  10978. CREATE PROCEDURE [dbo].[mblCpMainByIDSelect]
  10979. (
  10980. @ID VARCHAR(20),
  10981. @ColumnType TINYINT
  10982. )
  10983. AS
  10984. BEGIN
  10985. IF @ColumnType = 1
  10986. SELECT a.secondId, a.Lng, a.Lat, a.ID, a.Name, a.Address, a.MemberType, a.Brief, b.FullName RegionName, c.Description CompanyKind, d.Description CompanySize, dbo.GetCpIndustry(a.ID) Industry , e.ImgFile LogoUrl, a.RealName, a.LogoFile, a.ReplyRate, a.HomePage, a.dcProvinceId
  10987. FROM CpMain a WITH(NOLOCK)
  10988. LEFT JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionID = b.ID
  10989. LEFT JOIN dcCompanyKind c WITH(NOLOCK) ON a.dcCompanyKindID = c.ID
  10990. LEFT JOIN dcCompanySize d WITH(NOLOCK) ON a.dcCompanySizeID = d.ID
  10991. LEFT JOIN cpImage e WITH(NOLOCK) ON e.cpMainID = a.ID AND e.ImgType = 1 AND e.HasPassed = 1
  10992. WHERE a.ID = @ID
  10993. AND a.IsLimitLogin <> 9
  10994. ELSE
  10995. SELECT a.secondId, a.Lng, a.Lat, a.ID, a.Name, a.Address, a.MemberType, a.Brief, b.FullName RegionName, c.Description CompanyKind, d.Description CompanySize, dbo.GetCpIndustry(a.ID) Industry, e.ImgFile LogoUrl, a.RealName, a.LogoFile, a.ReplyRate, a.HomePage, a.dcProvinceId
  10996. FROM CpMain a WITH(NOLOCK)
  10997. LEFT JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionID = b.ID
  10998. LEFT JOIN dcCompanyKind c WITH(NOLOCK) ON a.dcCompanyKindID = c.ID
  10999. LEFT JOIN dcCompanySize d WITH(NOLOCK) ON a.dcCompanySizeID = d.ID
  11000. LEFT JOIN cpImage e WITH(NOLOCK) ON e.cpMainID = a.ID AND e.ImgType = 1 AND e.HasPassed = 1
  11001. WHERE a.SecondID = @ID
  11002. AND a.IsLimitLogin <> 9
  11003. END
  11004. GO
  11005. /****** Object: StoredProcedure [dbo].[mblCvEducationByIdSelect] Script Date: 2018/12/13 19:07:32 ******/
  11006. SET ANSI_NULLS ON
  11007. GO
  11008. SET QUOTED_IDENTIFIER ON
  11009. GO
  11010. CREATE PROCEDURE [dbo].[mblCvEducationByIdSelect]
  11011. (
  11012. @ID int
  11013. )
  11014. AS
  11015. BEGIN
  11016. SELECT a.*, b.Description Major, c.Description EduTypeName, d.Description Education
  11017. FROM cvEducation a WITH(NOLOCK INDEX(IX_cvEducation_CvMainID)),
  11018. dcMajor b WITH(NOLOCK),
  11019. dcEduType c WITH(NOLOCK),
  11020. dcEducation d WITH(NOLOCK)
  11021. WHERE a.dcMajorID = b.ID
  11022. AND a.EduType = c.ID
  11023. AND a.Degree = d.ID
  11024. AND a.ID = @ID
  11025. ORDER BY a.Degree DESC,
  11026. a.Graduation Desc
  11027. END
  11028. GO
  11029. /****** Object: StoredProcedure [dbo].[mblCvEducationSave] Script Date: 2018/12/13 19:07:32 ******/
  11030. SET ANSI_NULLS ON
  11031. GO
  11032. SET QUOTED_IDENTIFIER ON
  11033. GO
  11034. CREATE PROCEDURE [dbo].[mblCvEducationSave]
  11035. @ID INT,
  11036. @cvMainID INT,
  11037. @GraduateCollage VARCHAR(250),
  11038. @Graduation INT,
  11039. @dcMajorID SMALLINT,
  11040. @MajorName VARCHAR(100),
  11041. @Degree TINYINT,
  11042. @EduType TINYINT,
  11043. @paMainID INT
  11044. AS
  11045. BEGIN TRAN
  11046. ----检查是否是该账号的简历
  11047. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID =@cvMainID AND paMainID = @paMainID)
  11048. GOTO ERR
  11049. ----检查是否是该简历的教育背景
  11050. IF @ID > 0
  11051. IF NOT EXISTS(SELECT 'x' FROM cvEducation WITH(NOLOCK) WHERE ID = @ID AND cvMainID = @cvMainID)
  11052. GOTO ERR
  11053. SET @GraduateCollage = dbo.SafeSql(dbo.TextTrim(@GraduateCollage))
  11054. SET @MajorName = dbo.SafeSql(dbo.TextTrim(@MajorName))
  11055. DECLARE @MaxId AS INT
  11056. DECLARE @CNT AS INT
  11057. DECLARE @GraduateCollageOld AS VARCHAR(250)
  11058. DECLARE @MajorNameOld AS VARCHAR(100)
  11059. DECLARE @cvdcMajorID AS SMALLINT
  11060. DECLARE @Modify AS INT
  11061. SET @Modify=-1
  11062. BEGIN TRY
  11063. BEGIN
  11064. DECLARE @GC AS NVARCHAR(50)
  11065. DECLARE @MN AS NVARCHAR(20)
  11066. SET @GC = @GraduateCollage
  11067. SET @MN = @MajorName
  11068. IF @ID>0
  11069. BEGIN
  11070. SELECT @GraduateCollageOld = dbo.TextTrim(GraduateCollage),
  11071. @MajorNameOld = dbo.TextTrim(MajorName)
  11072. FROM cvEducation WITH(NOLOCK INDEX(PK_cvEducation)) WHERE ID=@ID
  11073. UPDATE cvEducation SET
  11074. GraduateCollage = @GC,
  11075. Graduation = @Graduation,
  11076. dcMajorID = @dcMajorID,
  11077. MajorName =@MN,
  11078. Degree = @Degree,
  11079. EduType = @EduType
  11080. WHERE ID=@ID
  11081. SET @MaxID=@ID
  11082. IF ISNULL(@GraduateCollageOld, '') <> ISNULL(@GC, '')
  11083. BEGIN
  11084. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'dc1'
  11085. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'dc1',@GC)
  11086. SET @Modify=0
  11087. END
  11088. IF ISNULL(@MajorNameOld, '') <> ISNULL(@MN, '')
  11089. BEGIN
  11090. DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'dc2'
  11091. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'dc2',@MN)
  11092. SET @Modify=0
  11093. END
  11094. END
  11095. ELSE
  11096. BEGIN
  11097. SELECT @CNT=COUNT(*) FROM cvEducation WITH(NOLOCK INDEX(PK_cvEducation)) WHERE cvMainID = @cvMAinID
  11098. IF @CNT<5
  11099. BEGIN
  11100. INSERT INTO cvEducation(cvMainID,GraduateCollage,Graduation,dcMajorID,MajorName,Degree,EduType)
  11101. VALUES(@cvMainID,@GC,@Graduation,@dcMajorID,@MN,@Degree,@EduType)
  11102. SET @MaxID = @@IDENTITY
  11103. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'dc1',@GC)
  11104. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'dc2',@MN)
  11105. SET @Modify=0
  11106. END
  11107. ELSE
  11108. GOTO ERR
  11109. END
  11110. END
  11111. SELECT @Degree = MAX(DEGREE) FROM cvEducation WITH(NOLOCK) WHERE cvMainID = @cvMainID
  11112. UPDATE cvMain SET Degree=@Degree, dcMajorID=@dcMajorID WHERE ID=@cvMainID
  11113. --修改cvLevel
  11114. DECLARE @SQL AS VARCHAR(100)
  11115. SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew ' + CONVERT(CHAR(1), 0) + ',' + CONVERT(VARCHAR(10), @cvMainID) + ',3,1'
  11116. EXEC(@SQL)
  11117. END TRY
  11118. BEGIN CATCH
  11119. GOTO ERR
  11120. END CATCH
  11121. COMMIT TRAN
  11122. RETURN @MaxID
  11123. ERR:
  11124. BEGIN
  11125. ROLLBACK TRAN
  11126. RETURN 0
  11127. END
  11128. GO
  11129. /****** Object: StoredProcedure [dbo].[mblCvEducationSelect] Script Date: 2018/12/13 19:07:32 ******/
  11130. SET ANSI_NULLS ON
  11131. GO
  11132. SET QUOTED_IDENTIFIER ON
  11133. GO
  11134. CREATE PROCEDURE [dbo].[mblCvEducationSelect]
  11135. (
  11136. @cvMainID int
  11137. )
  11138. AS
  11139. BEGIN
  11140. SELECT a.*, b.Description Major, c.Description EduTypeName, d.Description Education
  11141. FROM cvEducation a WITH(NOLOCK INDEX(IX_cvEducation_CvMainID)),
  11142. dcMajor b WITH(NOLOCK),
  11143. dcEduType c WITH(NOLOCK),
  11144. dcEducation d WITH(NOLOCK)
  11145. WHERE a.dcMajorID=b.ID AND a.EduType=c.ID AND a.Degree=d.ID AND a.cvMainID=@cvMainID
  11146. ORDER BY a.Degree DESC,a.Graduation Desc
  11147. END
  11148. set ANSI_NULLS ON
  11149. set QUOTED_IDENTIFIER ON
  11150. GO
  11151. /****** Object: StoredProcedure [dbo].[mblCvExperienceByIdSelect] Script Date: 2018/12/13 19:07:33 ******/
  11152. SET ANSI_NULLS ON
  11153. GO
  11154. SET QUOTED_IDENTIFIER ON
  11155. GO
  11156. CREATE PROCEDURE [dbo].[mblCvExperienceByIdSelect]
  11157. (
  11158. @ID INT
  11159. )
  11160. AS
  11161. BEGIN
  11162. SELECT a.*, b.Description JobType, c.Description CpmpanySize, d.Description Industry,
  11163. g.Description LowerNumber, e.Description CompanyKind, f.Description LeaveReson, h.FullName Region
  11164. FROM cvExperience a WITH(NOLOCK INDEX(IX_cvExperience_cvMainID))
  11165. LEFT JOIN dcJobType b WITH(NOLOCK) ON a.dcJobTypeID=b.ID
  11166. LEFT JOIN dcCompanySize c WITH(NOLOCK) ON a.dcCompanySizeID=c.ID
  11167. LEFT JOIN dcIndustry d WITH(NOLOCK) ON a.dcIndustryID=d.ID
  11168. LEFT JOIN dcLowerNumber g WITH(NOLOCK) ON a.SubNodeNum=g.ID
  11169. LEFT JOIN dcCompanyKind e WITH(NOLOCK) ON a.dcCompanyKindID=e.ID
  11170. LEFT JOIN dcLeaveReson f WITH(NOLOCK) ON a.dcLeaveResonID=f.ID
  11171. LEFT JOIN dcRegion h WITH(NOLOCK) ON a.WorkPlace=h.ID
  11172. WHERE a.ID = @ID
  11173. ORDER BY a.BeginDate DESC
  11174. END
  11175. GO
  11176. /****** Object: StoredProcedure [dbo].[mblCvExperienceDelete] Script Date: 2018/12/13 19:07:33 ******/
  11177. SET ANSI_NULLS ON
  11178. GO
  11179. SET QUOTED_IDENTIFIER ON
  11180. GO
  11181. -----------------------------------------------
  11182. --创建Sean
  11183. --检查时间 2010-9-27
  11184. --修改了有无工作经验的判断, 取消pcCvMainVerifyResultCheck
  11185. --修改:Lambo,2010-11-25
  11186. --描述:增加了paMainID参数,判断是否是本人的
  11187. -----------------------------------------------
  11188. CREATE PROCEDURE [dbo].[mblCvExperienceDelete]
  11189. (
  11190. @ID INT,
  11191. @paMainID INT
  11192. )
  11193. AS
  11194. SET NOCOUNT ON
  11195. BEGIN TRAN
  11196. BEGIN TRY
  11197. DECLARE @cvMainId AS INT
  11198. DECLARE @RETURN AS VARCHAR(2)
  11199. SELECT @cvMainId = cvMainId FROM cvExperience WITH(NOLOCK) WHERE ID=@ID
  11200. IF @cvMainId IS NULL
  11201. GOTO ERR
  11202. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE paMainID = @paMainID AND ID = @cvMainID)
  11203. GOTO ERR
  11204. DELETE FROM bsCvModify WHERE SubID = @ID AND Location LIKE 'e%'
  11205. DELETE FROM cvExperience WHERE ID = @ID
  11206. IF (SELECT COUNT(*) FROM cvExperience WITH(NOLOCK) WHERE cvMainId = @cvMainId) = 0
  11207. UPDATE cvMain SET cvType = 1, cvLevel = LEFT(cvLevel, 3) + '1' + RIGHT(cvLevel, 6),
  11208. cvLevelEng = LEFT(cvLevelEng, 3) + '1' + RIGHT(cvLevelEng, 6)
  11209. WHERE Id = @cvMainId
  11210. END TRY
  11211. BEGIN CATCH
  11212. GOTO ERR
  11213. END CATCH
  11214. COMMIT TRAN
  11215. RETURN @RETURN
  11216. ERR:
  11217. BEGIN
  11218. ROLLBACK TRAN
  11219. RETURN 3
  11220. END
  11221. GO
  11222. /****** Object: StoredProcedure [dbo].[mblCvExperienceSave] Script Date: 2018/12/13 19:07:33 ******/
  11223. SET ANSI_NULLS ON
  11224. GO
  11225. SET QUOTED_IDENTIFIER ON
  11226. GO
  11227. CREATE PROCEDURE [dbo].[mblCvExperienceSave]
  11228. (
  11229. @ID INT,
  11230. @cvMainID INT,
  11231. @CompanyName VARCHAR(100),
  11232. @dcIndustryID INT,
  11233. @dcCompanySizeID INT,
  11234. @dcJobtypeID INT,
  11235. @JobName VARCHAR(100),
  11236. @BeginDate INT,
  11237. @EndDate INT,
  11238. @SubNodeNum INT,
  11239. @Description VARCHAR(Max),
  11240. @paMainID INT
  11241. )
  11242. AS
  11243. SET NOCOUNT ON
  11244. BEGIN TRAN
  11245. ----检查是否是该账号的简历
  11246. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID AND paMainID = @paMainID)
  11247. GOTO ERR
  11248. ----检查是否是该简历的工作经验
  11249. IF @ID > 0
  11250. IF NOT EXISTS(SELECT 'x' FROM cvExperience WITH(NOLOCK) WHERE ID = @ID AND cvMainID = @cvMainID)
  11251. GOTO ERR
  11252. SET @CompanyName = dbo.SafeSql(dbo.TextTrim(@CompanyName))
  11253. SET @JobName = dbo.SafeSql(dbo.TextTrim(@JobName))
  11254. SET @Description = dbo.SafeSql(dbo.TextTrim(@Description))
  11255. IF CHARINDEX(',', @JobName) > 0
  11256. SELECT @JobName = dbo.SafeSql(REPLACE(@JobName, ',', ','))
  11257. DECLARE @MaxId AS INT
  11258. DECLARE @CNT AS INT
  11259. DECLARE @CompanyNameOld AS VARCHAR(100)
  11260. DECLARE @JobNameOld AS VARCHAR(100)
  11261. DECLARE @DescriptionOld AS VARCHAR(Max)
  11262. DECLARE @Modify AS INT
  11263. SET @Modify = -1
  11264. BEGIN TRY
  11265. BEGIN
  11266. DECLARE @C_CompanyName AS NVARCHAR(30)
  11267. DECLARE @C_JobName AS NVARCHAR(50)
  11268. DECLARE @C_Description AS NVARCHAR(2000)
  11269. SET @C_CompanyName = dbo.TextTrim(@CompanyName)
  11270. SET @C_JobName = dbo.TextTrim(@JobName)
  11271. SET @C_Description = dbo.TextTrim(@Description)
  11272. IF @ID>0
  11273. BEGIN
  11274. SELECT @CompanyNameOld = dbo.TextTrim(ISNULL(CompanyName, '')),
  11275. @JobNameOld = dbo.TextTrim(ISNULL(JobName, '')),
  11276. @DescriptionOld = dbo.TextTrim(ISNULL(Description, ''))
  11277. FROM cvExperience WITH(NOLOCK INDEX(PK_cvExperience)) WHERE ID = @ID
  11278. UPDATE cvExperience SET
  11279. CompanyName = @C_CompanyName,
  11280. dcIndustryID = @dcIndustryID,
  11281. dcCompanySizeID = @dcCompanySizeID,
  11282. dcJobtypeID = @dcJobtypeID,
  11283. JobName = @C_JobName,
  11284. BeginDate = @BeginDate,
  11285. EndDate = @EndDate,
  11286. SubNodeNum = @SubNodeNum,
  11287. Description = @C_Description
  11288. WHERE ID = @ID
  11289. SET @MaxID = @ID
  11290. IF ISNULL(@CompanyNameOld, '') <> ISNULL(@C_CompanyName, '')
  11291. BEGIN
  11292. DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'ec1'
  11293. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec1',@CompanyName)
  11294. SET @Modify = 0
  11295. END
  11296. IF ISNULL(@JobNameOld, '') <> ISNULL(@C_JobName, '')
  11297. BEGIN
  11298. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND cvMainID = @cvMainID AND SubID = @ID AND Location = 'ec2'
  11299. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec2',@C_JobName)
  11300. SET @Modify = 0
  11301. END
  11302. IF ISNULL(@DescriptionOld, '') <> ISNULL(@C_Description, '')
  11303. BEGIN
  11304. DELETE FROM bsCvModify WHERE paMainID = @paMainID AND cvMainID = @cvMainID AND SubID = @ID AND Location = 'ec3'
  11305. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec3',@C_Description)
  11306. SET @Modify = 0
  11307. END
  11308. END
  11309. ELSE
  11310. BEGIN
  11311. SELECT @CNT = COUNT(*) FROM cvExperience WITH(NOLOCK INDEX(IX_cvExperience_cvMainID)) WHERE cvMainID = @cvMainID
  11312. IF @CNT<20
  11313. BEGIN
  11314. INSERT INTO cvExperience
  11315. (cvMainID,CompanyName,dcIndustryID,dcCompanySizeID,dcJobtypeID,JobName,
  11316. BeginDate,EndDate,SubNodeNum,Description)
  11317. VALUES
  11318. (@cvMainID,@CompanyName,@dcIndustryID,@dcCompanySizeID,@dcJobtypeID,@JobName,
  11319. @BeginDate,@EndDate,@SubNodeNum,@Description)
  11320. SET @MaxID = @@IDENTITY
  11321. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec1',@C_CompanyName)
  11322. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec2',@C_JobName)
  11323. INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec3',@C_Description)
  11324. SET @Modify = 0
  11325. END
  11326. ELSE
  11327. GOTO ERR
  11328. END
  11329. END
  11330. UPDATE cvMain SET cvType = 0 WHERE Id = @CvMainId AND cvType = 1
  11331. --修改cvLevel
  11332. DECLARE @SQL AS VARCHAR(100)
  11333. SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew ' + CONVERT(CHAR(1), 0) + ',' + CONVERT(VARCHAR(10), @cvMainID) + ',4,1'
  11334. EXEC(@SQL)
  11335. END TRY
  11336. BEGIN CATCH
  11337. GOTO ERR
  11338. END CATCH
  11339. COMMIT TRAN
  11340. RETURN @MaxID
  11341. ERR:
  11342. BEGIN
  11343. ROLLBACK TRAN
  11344. RETURN 0
  11345. END
  11346. GO
  11347. /****** Object: StoredProcedure [dbo].[mblCvExperienceSelect] Script Date: 2018/12/13 19:07:33 ******/
  11348. SET ANSI_NULLS ON
  11349. GO
  11350. SET QUOTED_IDENTIFIER ON
  11351. GO
  11352. CREATE PROCEDURE [dbo].[mblCvExperienceSelect]
  11353. (
  11354. @cvMainID INT
  11355. )
  11356. AS
  11357. BEGIN
  11358. SELECT a.*, b.Description JobType, c.Description CpmpanySize, d.Description Industry,
  11359. g.Description LowerNumber, e.Description CompanyKind, f.Description LeaveReson, h.FullName Region
  11360. FROM cvExperience a WITH(NOLOCK INDEX(IX_cvExperience_cvMainID))
  11361. LEFT JOIN dcJobType b WITH(NOLOCK) ON a.dcJobTypeID=b.ID
  11362. LEFT JOIN dcCompanySize c WITH(NOLOCK) ON a.dcCompanySizeID=c.ID
  11363. LEFT JOIN dcIndustry d WITH(NOLOCK) ON a.dcIndustryID=d.ID
  11364. LEFT JOIN dcLowerNumber g WITH(NOLOCK) ON a.SubNodeNum=g.ID
  11365. LEFT JOIN dcCompanyKind e WITH(NOLOCK) ON a.dcCompanyKindID=e.ID
  11366. LEFT JOIN dcLeaveReson f WITH(NOLOCK) ON a.dcLeaveResonID=f.ID
  11367. LEFT JOIN dcRegion h WITH(NOLOCK) ON a.WorkPlace=h.ID
  11368. WHERE cvMainID = @cvMainID
  11369. ORDER BY a.BeginDate DESC
  11370. END
  11371. set ANSI_NULLS ON
  11372. set QUOTED_IDENTIFIER ON
  11373. GO
  11374. /****** Object: StoredProcedure [dbo].[mblCvInfoSelect] Script Date: 2018/12/13 19:07:34 ******/
  11375. SET ANSI_NULLS ON
  11376. GO
  11377. SET QUOTED_IDENTIFIER ON
  11378. GO
  11379. CREATE PROCEDURE [dbo].[mblCvInfoSelect]
  11380. (
  11381. @cvMainID INT,
  11382. @paMainID INT
  11383. )
  11384. AS
  11385. BEGIN
  11386. --获取个人信息
  11387. SELECT 1 dcCareerStatus, a.*,
  11388. b.FullName LiveRegion, c.FullName GrowRegion, d.FullName AccountRegion,
  11389. ISNULL(e.Description, '目前处于离职状态,可即刻上岗') CareerStatus, f.PhotoProcessed,
  11390. (SELECT TOP 1 LoginIP FROM paLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = a.ID ORDER BY ID DESC) AS LastLoginIP,
  11391. (SELECT COUNT(1) FROM paLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = a.ID AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)) AS TodayLoginNum,
  11392. dbo.BirthToAge(a.BirthDay) Age
  11393. FROM paMain a WITH(NOLOCK INDEX(PK_paMain))
  11394. LEFT JOIN dcRegion b WITH(NOLOCK) ON a.LivePlace=b.ID
  11395. LEFT JOIN dcRegion c WITH(NOLOCK) ON a.GrowPlace=c.ID
  11396. LEFT JOIN dcRegion d WITH(NOLOCK) ON a.AccountPlace=d.ID
  11397. LEFT JOIN dcCareerStatus e WITH(NOLOCK) ON a.dcCareerStatus=e.ID
  11398. LEFT JOIN paPhoto f WITH(NOLOCK) ON a.HasPhoto<2 AND a.ID=f.paMainID
  11399. WHERE a.ID = @paMainID
  11400. --获取简历信息
  11401. SELECT *
  11402. FROM cvMain WITH(NOLOCK INDEX(PK_cvMain))
  11403. WHERE ID = @cvMainID
  11404. --获取教育背景
  11405. SELECT a.*, b.Description Major, c.Description EduTypeName, d.Description Education
  11406. FROM cvEducation a WITH(NOLOCK INDEX(IX_cvEducation_CvMainID)),
  11407. dcMajor b WITH(NOLOCK),
  11408. dcEduType c WITH(NOLOCK),
  11409. dcEducation d WITH(NOLOCK)
  11410. WHERE a.dcMajorID=b.ID AND a.EduType=c.ID AND a.Degree=d.ID AND a.cvMainID=@cvMainID
  11411. ORDER BY a.Degree DESC, a.Graduation Desc
  11412. --获取工作经验
  11413. SELECT a.*, b.Description JobType, c.Description CpmpanySize, d.Description Industry,
  11414. g.Description LowerNumber, e.Description CompanyKind, f.Description LeaveReson, h.FullName Region
  11415. FROM cvExperience a WITH(NOLOCK INDEX(IX_cvExperience_cvMainID))
  11416. LEFT JOIN dcJobType b WITH(NOLOCK) ON a.dcJobTypeID=b.ID
  11417. LEFT JOIN dcCompanySize c WITH(NOLOCK) ON a.dcCompanySizeID=c.ID
  11418. LEFT JOIN dcIndustry d WITH(NOLOCK) ON a.dcIndustryID=d.ID
  11419. LEFT JOIN dcLowerNumber g WITH(NOLOCK) ON a.SubNodeNum=g.ID
  11420. LEFT JOIN dcCompanyKind e WITH(NOLOCK) ON a.dcCompanyKindID=e.ID
  11421. LEFT JOIN dcLeaveReson f WITH(NOLOCK) ON a.dcLeaveResonID=f.ID
  11422. LEFT JOIN dcRegion h WITH(NOLOCK) ON a.WorkPlace=h.ID
  11423. WHERE cvMainID=@cvMainID
  11424. ORDER BY a.BeginDate DESC
  11425. --获取求职意向
  11426. DECLARE @JobType AS VARCHAR(100)
  11427. DECLARE @JobTypeName AS VARCHAR(1000)
  11428. DECLARE @JobPlace AS VARCHAR(100)
  11429. DECLARE @JobPlaceName AS VARCHAR(100)
  11430. DECLARE @Industry AS VARCHAR(100)
  11431. DECLARE @IndustryName AS VARCHAR(100)
  11432. DECLARE @INTTemp AS INT
  11433. DECLARE @STRTemp AS VARCHAR(20)
  11434. 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
  11435. 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
  11436. 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
  11437. --取得JobType
  11438. OPEN #JobType
  11439. FETCH NEXT FROM #JobType INTO @INTTemp, @STRTemp
  11440. WHILE @@FETCH_STATUS = 0
  11441. BEGIN
  11442. IF Len(@JobType) > 0
  11443. BEGIN
  11444. SET @JobType = @JobType + ' ' + Rtrim(CONVERT(CHAR(10), @INTTemp))
  11445. SET @JobTypeName = @JobTypeName + ' ' + @STRTemp
  11446. END
  11447. ELSE
  11448. BEGIN
  11449. SET @JobType = Rtrim(CONVERT(CHAR(10), @INTTemp))
  11450. SET @JobTypeName = @STRTemp
  11451. END
  11452. FETCH NEXT FROM #JobType INTO @INTTemp, @STRTemp
  11453. END
  11454. CLOSE #JobType
  11455. DEALLOCATE #JobType
  11456. --取得JobPlace
  11457. OPEN #JobPlace
  11458. FETCH NEXT FROM #JobPlace INTO @INTTemp, @STRTemp
  11459. WHILE @@FETCH_STATUS = 0
  11460. BEGIN
  11461. IF Len(@JobPlace) > 0
  11462. BEGIN
  11463. SET @JobPlace = @JobPlace + ' ' + Rtrim(CONVERT(CHAR(10), @INTTemp))
  11464. SET @JobPlaceName = @JobPlaceName + ' ' + @STRTemp
  11465. END
  11466. ELSE
  11467. BEGIN
  11468. SET @JobPlace = Rtrim(CONVERT(CHAR(10), @INTTemp))
  11469. SET @JobPlaceName = @STRTemp
  11470. END
  11471. FETCH NEXT FROM #JobPlace INTO @INTTemp, @STRTemp
  11472. END
  11473. CLOSE #JobPlace
  11474. DEALLOCATE #JobPlace
  11475. --取得Industry
  11476. OPEN #Industry
  11477. FETCH NEXT FROM #Industry INTO @INTTemp, @STRTemp
  11478. WHILE @@FETCH_STATUS = 0
  11479. BEGIN
  11480. IF Len(@Industry) > 0
  11481. BEGIN
  11482. SET @Industry = @Industry + ' ' + Rtrim(CONVERT(CHAR(10), @INTTemp))
  11483. SET @IndustryName = @IndustryName + ' ' + @STRTemp
  11484. END
  11485. ELSE
  11486. BEGIN
  11487. SET @Industry = Rtrim(CONVERT(CHAR(10), @INTTemp))
  11488. SET @IndustryName = @STRTemp
  11489. END
  11490. FETCH NEXT FROM #Industry INTO @INTTemp, @STRTemp
  11491. END
  11492. CLOSE #Industry
  11493. DEALLOCATE #Industry
  11494. SELECT
  11495. RelatedWorkYears,
  11496. EmployType,
  11497. dcSalaryID,
  11498. IsNegotiable,
  11499. b.Description Salary,
  11500. @JobType AS JobType,
  11501. @JobPlace AS JobPlace,
  11502. @Industry AS Industry,
  11503. @JobTypeName AS JobTypeName,
  11504. @JobPlaceName AS JobPlaceName,
  11505. @IndustryName AS IndustryName
  11506. From cvMain a WITH(NOLOCK)
  11507. LEFT JOIN dcSalary b WITH(NOLOCK) ON a.dcSalaryID=b.ID
  11508. WHERE a.id=@cvMainID
  11509. END
  11510. GO
  11511. /****** Object: StoredProcedure [dbo].[mblCvInfoSelect2] Script Date: 2018/12/13 19:07:34 ******/
  11512. SET ANSI_NULLS ON
  11513. GO
  11514. SET QUOTED_IDENTIFIER ON
  11515. GO
  11516. --peter 2018-3-28
  11517. CREATE PROCEDURE [dbo].[mblCvInfoSelect2]
  11518. (
  11519. @cvMainID INT,
  11520. @paMainID INT
  11521. )
  11522. AS
  11523. SET NOCOUNT ON
  11524. BEGIN
  11525. --获取个人信息
  11526. SELECT a.*, b.FullName LiveRegion, c.FullName GrowRegion, d.FullName AccountRegion,
  11527. e.Description CareerStatus, f.PhotoProcessed,g.Description OnlineContactName,h.Name MapPlaceName,
  11528. (SELECT TOP 1 LoginIP FROM paLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = a.ID ORDER BY ID DESC) AS LastLoginIP,
  11529. (SELECT COUNT(1) FROM paLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = a.ID AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)) AS TodayLoginNum,
  11530. dbo.BirthToAge(a.BirthDay) Age
  11531. FROM paMain a WITH(NOLOCK INDEX(PK_paMain))
  11532. LEFT JOIN dcRegion b WITH(NOLOCK) ON a.LivePlace=b.ID
  11533. LEFT JOIN dcRegion c WITH(NOLOCK) ON a.GrowPlace=c.ID
  11534. LEFT JOIN dcRegion d WITH(NOLOCK) ON a.AccountPlace=d.ID
  11535. LEFT JOIN dcCareerStatus e WITH(NOLOCK) ON a.dcCareerStatus=e.ID
  11536. LEFT JOIN paPhoto f WITH(NOLOCK) ON a.HasPhoto<2 AND a.ID=f.paMainID
  11537. LEFT JOIN dcOnlineContact g WITH(NOLOCK) ON a.OnlineContact = g.ID
  11538. LEFT JOIN dcMapPlace h WITH(NOLOCK) ON a.dcMapPlaceID = h.ID
  11539. WHERE a.ID = @paMainID
  11540. --获取简历信息
  11541. SELECT a.*, b.Description EmployTypeName, c.Description DegreeName
  11542. FROM cvMain a WITH(NOLOCK INDEX(PK_cvMain))
  11543. LEFT JOIN dcOthers b WITH(NOLOCK) ON a.EmployType = b.DetailID AND b.Category = '工作性质'
  11544. LEFT JOIN dcEducation c WITH(NOLOCK) ON a.Degree = c.ID
  11545. WHERE a.ID = @cvMainID
  11546. --获取教育背景
  11547. SELECT a.*, b.Description Major, c.Description EduTypeName, d.Description DegreeName
  11548. FROM cvEducation a WITH(NOLOCK INDEX(IX_cvEducation_CvMainID)),
  11549. dcMajor b WITH(NOLOCK),
  11550. dcEduType c WITH(NOLOCK),
  11551. dcEducation d WITH(NOLOCK)
  11552. WHERE a.dcMajorID=b.ID AND a.EduType=c.ID AND a.Degree=d.ID AND a.cvMainID=@cvMainID
  11553. ORDER BY a.Degree DESC, a.Graduation Desc
  11554. --获取工作经验
  11555. SELECT a.*, b.Description JobType, c.Description CpmpanySize, d.Description Industry,
  11556. g.Description LowerNumber, e.Description CompanyKind, f.Description LeaveReson, h.FullName Region
  11557. FROM cvExperience a WITH(NOLOCK INDEX(IX_cvExperience_cvMainID))
  11558. LEFT JOIN dcJobType b WITH(NOLOCK) ON a.dcJobTypeID=b.ID
  11559. LEFT JOIN dcCompanySize c WITH(NOLOCK) ON a.dcCompanySizeID=c.ID
  11560. LEFT JOIN dcIndustry d WITH(NOLOCK) ON a.dcIndustryID=d.ID
  11561. LEFT JOIN dcLowerNumber g WITH(NOLOCK) ON a.SubNodeNum=g.ID
  11562. LEFT JOIN dcCompanyKind e WITH(NOLOCK) ON a.dcCompanyKindID=e.ID
  11563. LEFT JOIN dcLeaveReson f WITH(NOLOCK) ON a.dcLeaveResonID=f.ID
  11564. LEFT JOIN dcRegion h WITH(NOLOCK) ON a.WorkPlace=h.ID
  11565. WHERE cvMainID=@cvMainID
  11566. ORDER BY a.BeginDate DESC
  11567. --获取求职意向
  11568. DECLARE @JobType AS VARCHAR(100)
  11569. DECLARE @JobTypeName AS VARCHAR(1000)
  11570. DECLARE @JobPlace AS VARCHAR(100)
  11571. DECLARE @JobPlaceName AS VARCHAR(100)
  11572. DECLARE @Industry AS VARCHAR(100)
  11573. DECLARE @IndustryName AS VARCHAR(100)
  11574. DECLARE @INTTemp AS INT
  11575. DECLARE @STRTemp AS VARCHAR(50)
  11576. 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
  11577. 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
  11578. 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
  11579. --取得JobType
  11580. OPEN #JobType
  11581. FETCH NEXT FROM #JobType INTO @INTTemp, @STRTemp
  11582. WHILE @@FETCH_STATUS = 0
  11583. BEGIN
  11584. IF Len(@JobType) > 0
  11585. BEGIN
  11586. SET @JobType = @JobType + ' ' + Rtrim(CONVERT(VARCHAR(20), @INTTemp))
  11587. SET @JobTypeName = @JobTypeName + ' ' + @STRTemp
  11588. END
  11589. ELSE
  11590. BEGIN
  11591. SET @JobType = Rtrim(CONVERT(VARCHAR(20), @INTTemp))
  11592. SET @JobTypeName = @STRTemp
  11593. END
  11594. FETCH NEXT FROM #JobType INTO @INTTemp, @STRTemp
  11595. END
  11596. CLOSE #JobType
  11597. DEALLOCATE #JobType
  11598. --取得JobPlace
  11599. OPEN #JobPlace
  11600. FETCH NEXT FROM #JobPlace INTO @INTTemp, @STRTemp
  11601. WHILE @@FETCH_STATUS = 0
  11602. BEGIN
  11603. IF Len(@JobPlace) > 0
  11604. BEGIN
  11605. SET @JobPlace = @JobPlace + ' ' + Rtrim(CONVERT(VARCHAR(20), @INTTemp))
  11606. SET @JobPlaceName = @JobPlaceName + ' ' + @STRTemp
  11607. END
  11608. ELSE
  11609. BEGIN
  11610. SET @JobPlace = Rtrim(CONVERT(VARCHAR(20),@INTTemp))
  11611. SET @JobPlaceName = @STRTemp
  11612. END
  11613. FETCH NEXT FROM #JobPlace INTO @INTTemp, @STRTemp
  11614. END
  11615. CLOSE #JobPlace
  11616. DEALLOCATE #JobPlace
  11617. --取得Industry
  11618. OPEN #Industry
  11619. FETCH NEXT FROM #Industry INTO @INTTemp, @STRTemp
  11620. WHILE @@FETCH_STATUS = 0
  11621. BEGIN
  11622. IF Len(@Industry) > 0
  11623. BEGIN
  11624. SET @Industry = @Industry + ' ' + Rtrim(CONVERT(VARCHAR(20), @INTTemp))
  11625. SET @IndustryName = @IndustryName + ' ' + @STRTemp
  11626. END
  11627. ELSE
  11628. BEGIN
  11629. SET @Industry = Rtrim(CONVERT(VARCHAR(20), @INTTemp))
  11630. SET @IndustryName = @STRTemp
  11631. END
  11632. FETCH NEXT FROM #Industry INTO @INTTemp, @STRTemp
  11633. END
  11634. CLOSE #Industry
  11635. DEALLOCATE #Industry
  11636. SELECT
  11637. RelatedWorkYears,
  11638. EmployType,
  11639. dcSalaryID,
  11640. IsNegotiable,
  11641. b.Description Salary,
  11642. @JobType AS JobType,
  11643. @JobPlace AS JobPlace,
  11644. @Industry AS Industry,
  11645. @JobTypeName AS JobTypeName,
  11646. @JobPlaceName AS JobPlaceName,
  11647. @IndustryName AS IndustryName
  11648. From cvMain a WITH(NOLOCK)
  11649. LEFT JOIN dcSalary b WITH(NOLOCK) ON a.dcSalaryID=b.ID
  11650. WHERE a.id=@cvMainID
  11651. END
  11652. GO
  11653. /****** Object: StoredProcedure [dbo].[mblCvmainByIDSelect] Script Date: 2018/12/13 19:07:35 ******/
  11654. SET ANSI_NULLS ON
  11655. GO
  11656. SET QUOTED_IDENTIFIER ON
  11657. GO
  11658. --#####################################################
  11659. --创建时间:2014.11.06
  11660. --创建人:Nick
  11661. --说明:获取个人信息
  11662. --#####################################################
  11663. CREATE PROCEDURE [dbo].[mblCvmainByIDSelect]
  11664. (
  11665. @cvMainID INT
  11666. )
  11667. AS
  11668. BEGIN TRY
  11669. SELECT pamainid FROM cvmain WHERE id=@cvMainID
  11670. END TRY
  11671. BEGIN CATCH
  11672. RETURN 0
  11673. END CATCH
  11674. GO
  11675. /****** Object: StoredProcedure [dbo].[mblCvMainByPaMainIDSelect] Script Date: 2018/12/13 19:07:36 ******/
  11676. SET ANSI_NULLS ON
  11677. GO
  11678. SET QUOTED_IDENTIFIER ON
  11679. GO
  11680. --#####################################################
  11681. --创建时间:2014.11.06
  11682. --创建人:Nick
  11683. --说明:获取能够申请职位的简历列表
  11684. --#####################################################
  11685. CREATE PROCEDURE [dbo].[mblCvMainByPaMainIDSelect]
  11686. (
  11687. @paMainID INT
  11688. )
  11689. AS
  11690. BEGIN TRY
  11691. SELECT * FROM cvMain WITH(NOLOCK)
  11692. WHERE paMainID=@paMainID
  11693. AND (LEFT(cvLevel,6)='111111' OR LEFT(cvLevel,6)='111101')
  11694. AND VerifyResult=1
  11695. END TRY
  11696. BEGIN CATCH
  11697. RETURN 0
  11698. END CATCH
  11699. GO
  11700. /****** Object: StoredProcedure [dbo].[mbldcJobtypeHotByPinYinSelect] Script Date: 2018/12/13 19:07:36 ******/
  11701. SET ANSI_NULLS ON
  11702. GO
  11703. SET QUOTED_IDENTIFIER ON
  11704. GO
  11705. --#####################################################
  11706. --创建时间:2014.11.06
  11707. --创建人:Nick
  11708. --说明:获取热门职位信息
  11709. --#####################################################
  11710. CREATE PROCEDURE [dbo].[mbldcJobtypeHotByPinYinSelect]
  11711. (
  11712. @PinYin VARCHAR(50)
  11713. )
  11714. AS
  11715. BEGIN TRY
  11716. SELECT jobname,dcjobtypeid FROM dcjobtypehot WHERE pinyin = @PinYin
  11717. END TRY
  11718. BEGIN CATCH
  11719. RETURN 0
  11720. END CATCH
  11721. GO
  11722. /****** Object: StoredProcedure [dbo].[mblDcJobTypeHotNumberSelect] Script Date: 2018/12/13 19:07:36 ******/
  11723. SET ANSI_NULLS ON
  11724. GO
  11725. SET QUOTED_IDENTIFIER ON
  11726. GO
  11727. --#####################################################
  11728. --创建时间:2014.11.7
  11729. --创建人:John
  11730. --说明:根据地区取得一定数量的热门职位关键字
  11731. --#####################################################
  11732. CREATE PROCEDURE [dbo].[mblDcJobTypeHotNumberSelect]
  11733. (
  11734. @topNum INT,
  11735. @siteId INT
  11736. )
  11737. AS
  11738. BEGIN
  11739. SELECT b.* FROM (
  11740. SELECT TOP (@topNum) dcJobTypeHotId
  11741. FROM dcJobTypeHotNumber WITH(NOLOCK)
  11742. WHERE dcProvinceId = @siteId
  11743. ORDER BY jobnumber DESC
  11744. ) a LEFT JOIN dcJobTypeHot b WITH(NOLOCK) ON a.dcJobTypeHotId = b.ID
  11745. END
  11746. GO
  11747. /****** Object: StoredProcedure [dbo].[mbldcSubSiteByAddressSelect] Script Date: 2018/12/13 19:07:37 ******/
  11748. SET ANSI_NULLS ON
  11749. GO
  11750. SET QUOTED_IDENTIFIER ON
  11751. GO
  11752. --#####################################################
  11753. --创建时间:2014.11.7
  11754. --创建人:Nick
  11755. --说明:根据详细地址获取站点
  11756. --#####################################################
  11757. CREATE PROCEDURE [dbo].[mbldcSubSiteByAddressSelect]
  11758. (
  11759. @Address VARCHAR(100)
  11760. )
  11761. AS
  11762. BEGIN
  11763. SELECT TOP 1 * FROM dcSubSite WITH(NOLOCK)
  11764. WHERE CHARINDEX(SubSiteCity,@Address)>0
  11765. AND IsMainSite=1 AND LEN(ID)=2
  11766. END
  11767. GO
  11768. /****** Object: StoredProcedure [dbo].[mblDcSubSiteMainSelect] Script Date: 2018/12/13 19:07:37 ******/
  11769. SET ANSI_NULLS ON
  11770. GO
  11771. SET QUOTED_IDENTIFIER ON
  11772. GO
  11773. --#####################################################
  11774. --创建时间:2014.11.7
  11775. --创建人:John
  11776. --说明:获取主站的url
  11777. --#####################################################
  11778. CREATE PROCEDURE [dbo].[mblDcSubSiteMainSelect]
  11779. AS
  11780. BEGIN
  11781. SELECT id, REPLACE(SubSiteUrl, 'www.', 'm.') Site FROM dcSubsite WITH(NOLOCK) WHERE IsMainSite = 1 ORDER BY Id
  11782. END
  11783. GO
  11784. /****** Object: StoredProcedure [dbo].[mbldcSubSiteSelect] Script Date: 2018/12/13 19:07:37 ******/
  11785. SET ANSI_NULLS ON
  11786. GO
  11787. SET QUOTED_IDENTIFIER ON
  11788. GO
  11789. --#####################################################
  11790. --创建时间:2014.11.7
  11791. --创建人:Nick
  11792. --说明:获取网站信息
  11793. --#####################################################
  11794. CREATE PROCEDURE [dbo].[mbldcSubSiteSelect]
  11795. AS
  11796. BEGIN
  11797. SELECT *, REPLACE(SubSiteUrl, 'www.', 'm.') Site
  11798. FROM dcSubSite WITH(NOLOCK) WHERE IsMainSite=1 AND LEN(ID)=2
  11799. END
  11800. GO
  11801. /****** Object: StoredProcedure [dbo].[mblExInterViewByReplyUpdate] Script Date: 2018/12/13 19:07:38 ******/
  11802. SET ANSI_NULLS ON
  11803. GO
  11804. SET QUOTED_IDENTIFIER ON
  11805. GO
  11806. CREATE PROCEDURE [dbo].[mblExInterViewByReplyUpdate]
  11807. (
  11808. @ID INT,
  11809. @Reply TINYINT,
  11810. @ReplyMessage VARCHAR(500),
  11811. @paMainID INT
  11812. )
  11813. AS
  11814. BEGIN TRY
  11815. 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)
  11816. GOTO ERR
  11817. UPDATE exInterView
  11818. SET Reply = @Reply, ReplyMessage = dbo.SafeSql(@ReplyMessage), ReplyDate=GETDATE()
  11819. WHERE ID = @ID
  11820. RETURN 1
  11821. END TRY
  11822. BEGIN CATCH
  11823. GOTO ERR
  11824. END CATCH
  11825. ERR:
  11826. BEGIN
  11827. SELECT 0
  11828. RETURN
  11829. END
  11830. GO
  11831. /****** Object: StoredProcedure [dbo].[mblexInterViewCountByPaMainIDSelect] Script Date: 2018/12/13 19:07:38 ******/
  11832. SET ANSI_NULLS ON
  11833. GO
  11834. SET QUOTED_IDENTIFIER ON
  11835. GO
  11836. --#####################################################
  11837. --创建时间:2014.11.4
  11838. --创建人:Nick
  11839. --说明:未查看面试通知消息数量
  11840. --#####################################################
  11841. CREATE PROCEDURE [dbo].[mblexInterViewCountByPaMainIDSelect]
  11842. (
  11843. @paMainID INT
  11844. )
  11845. AS
  11846. BEGIN
  11847. SELECT COUNT(*)
  11848. FROM paMain a INNER JOIN cvMain b ON a.id =b.pamainid
  11849. INNER JOIN exInterView c ON b.id=c.cvmainid
  11850. WHERE a.id=@paMainID AND c.viewdate IS NULL
  11851. END
  11852. GO
  11853. /****** Object: StoredProcedure [dbo].[mblExInterviewSelect] Script Date: 2018/12/13 19:07:38 ******/
  11854. SET ANSI_NULLS ON
  11855. GO
  11856. SET QUOTED_IDENTIFIER ON
  11857. GO
  11858. CREATE PROCEDURE [dbo].[mblExInterviewSelect]
  11859. (
  11860. @paMainID AS INT,
  11861. @PageNum AS INT,
  11862. @PageSize AS INT
  11863. )
  11864. AS
  11865. BEGIN
  11866. DECLARE @COUNT INT
  11867. SELECT @COUNT=COUNT(1)
  11868. FROM exInterview a WITH(NOLOCK)
  11869. INNER JOIN cvMain b WITH(NOLOCK) ON a.cvMainID = b.ID
  11870. WHERE PersonDeleted=0 AND b.paMainID=@paMainID
  11871. SELECT *,@COUNT AS cnt FROM(
  11872. SELECT ROW_NUMBER() OVER(ORDER BY a.AddDate DESC) AS Rows,a.*, b.Name as JobName, b.caMainID, b.dcRegionID, c.Name as cpName, c.ID as cpID,
  11873. c.HasLicence, c.IsAgent, b.IssueDate, b.IssueEND, b.IsDelete, d.Name cvName,b.secondid enjobid
  11874. FROM exInterview a WITH(NOLOCK)
  11875. inner join Job b WITH(NOLOCK) On b.ID=a.JobID
  11876. Inner Join cpMain c WITH(NOLOCK) ON b.cpMainID=c.ID
  11877. INNER JOIN cvMain d WITH(NOLOCK) ON a.cvMainID = d.ID
  11878. WHERE PersonDeleted=0 AND d.paMainID=@paMainID
  11879. ) AS a
  11880. WHERE a.Rows BETWEEN (@PageNum-1)*@PageSize+1 AND @PageNum*@PageSize ORDER BY a.ID desc
  11881. END
  11882. GO
  11883. /****** Object: StoredProcedure [dbo].[mblExJobApplyByApplyCvSelect] Script Date: 2018/12/13 19:07:39 ******/
  11884. SET ANSI_NULLS ON
  11885. GO
  11886. SET QUOTED_IDENTIFIER ON
  11887. GO
  11888. CREATE PROCEDURE [dbo].[mblExJobApplyByApplyCvSelect]
  11889. (
  11890. @WHERE VARCHAR(1000),
  11891. @Order VARCHAR(100),
  11892. @Page SMALLINT,
  11893. @caMainID INT
  11894. )
  11895. AS
  11896. SET NOCOUNT ON
  11897. BEGIN
  11898. SET @Where = dbo.SafeSql(@Where)
  11899. SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '''''')
  11900. DECLARE @SQL AS VARCHAR(2000)
  11901. CREATE TABLE #T(
  11902. TitleID BIGINT,
  11903. ID INT,
  11904. JobID INT,
  11905. JobName NVARCHAR(50) COLLATE Chinese_PRC_CI_AS NULL,
  11906. JobRegion VARCHAR(6) NULL,
  11907. paMainID INT,
  11908. cvMainID INT,
  11909. AddDate SMALLDATETIME,
  11910. Reply TINYINT,
  11911. ReplyDate SMALLDATETIME,
  11912. IsMatched BIT,
  11913. Degree TINYINT,
  11914. RelatedWorkYears TINYINT,
  11915. LivePlace NVARCHAR(50),
  11916. Gender BIT,
  11917. paName NVARCHAR(50),
  11918. BirthDay INT,
  11919. HasPhoto TINYINT,
  11920. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  11921. IsNameHidden BIT,
  11922. Valid TINYINT,
  11923. ApplyMessage NVARCHAR(1),
  11924. IsViewed BIT,
  11925. HasInterview BIT,
  11926. HasRemark BIT,
  11927. HasFavorate BIT,
  11928. cvEducationID INT,
  11929. College NVARCHAR(50),
  11930. EduType TINYINT,
  11931. MajorName NVARCHAR(20),
  11932. Graduation INT,
  11933. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  11934. Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  11935. cvMatch INT,
  11936. RecruitmentID INT,
  11937. RecruitmentName NVARCHAR(100),
  11938. RecruitmentDate SMALLDATETIME,
  11939. MobileVerifyDate SMALLDATETIME,
  11940. IsOnline BIT,
  11941. RemindDate DATETIME,
  11942. HasWeiXin BIT,
  11943. HasAccept BIT,
  11944. HsaNoAccept BIT,
  11945. PaPhoto VARCHAR(50),
  11946. SecondId VARCHAR(10)
  11947. )
  11948. SET @SQL='
  11949. INSERT INTO #T
  11950. (TitleID, ID, JobID, JobName, JobRegion, paMainID, cvMainID, AddDate, Reply, ReplyDate, IsMatched, ApplyMessage,
  11951. Degree, RelatedWorkYears, Attachment, IsNameHidden, LivePlace, Gender,
  11952. BirthDay, HasPhoto, Valid, RecruitmentID, MobileVerifyDate, IsOnline, RemindDate, SecondId)
  11953. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, a.JobID, d.Name, d.dcRegionID, c.ID, a.cvMainID,
  11954. a.AddDate, a.Reply, a.ReplyDate, a.IsMatched, LEFT(a.ApplyMessage, 1) ApplyMessage,
  11955. b.Degree, b.RelatedWorkYears, b.Attachment, b.IsNameHidden, c.LivePlace,
  11956. c.Gender, c.BirthDay, c.HasPhoto, b.Valid, a.RecruitmentID, c.MobileVerifyDate,
  11957. dbo.GetPaOnlineStatus(c.ID), a.RemindDate, b.SecondId
  11958. FROM exJobApply a WITH(NOLOCK)
  11959. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  11960. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  11961. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  11962. WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0'
  11963. IF LEN(@WHERE) > 0
  11964. SET @SQL = @SQL + ' AND '+@WHERE
  11965. --PRINT @SQL
  11966. EXEC(@SQL)
  11967. IF(@Page < 1)
  11968. SET @Page = 1
  11969. DECLARE @cpMainID AS INT
  11970. SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
  11971. UPDATE #T SET paName = LEFT(dbo.GetPersonName(cvMainID, @cpMainID), 20), IsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID),
  11972. HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  11973. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  11974. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  11975. HasAccept = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID AND a.Result = 1),
  11976. HsaNoAccept = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID AND a.Result > 1)
  11977. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  11978. UPDATE #T SET Speciality = (
  11979. SELECT Speciality FROM cvMain WITH(NOLOCK)
  11980. WHERE cvMain.ID = #T.cvMainID)
  11981. WHERE TitleID > (@Page - 1) * 20 AND TitleID <= @Page * 20
  11982. --sean 2018-3-6调整,原版本速度太慢
  11983. --UPDATE #T SET PaPhoto = dbo.GetPaPhotoByCpView(#T.cvMainID, @cpMainID)
  11984. --WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  11985. UPDATE a SET a.PaPhoto = b.PhotoProcessed
  11986. FROM #T a,
  11987. paPhoto b WITH(NOLOCK INDEX(IX_paPhoto_paMainId)),
  11988. cpCvPrivi c WITH(NOLOCK)
  11989. WHERE a.paMainID = b.paMainId
  11990. AND a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
  11991. AND a.cvMainId = c.cvMainId
  11992. AND c.cpMainId = @cpMainId
  11993. UPDATE #T SET Experience = (
  11994. SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
  11995. WHERE cvExperience.cvMainID = #T.cvMainID
  11996. ORDER BY BeginDate DESC)
  11997. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  11998. UPDATE #T SET cvEducationID = (
  11999. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  12000. WHERE cvEducation.cvMainID = #T.cvMainID
  12001. AND #T.Degree = cvEducation.Degree
  12002. ORDER BY Graduation DESC)
  12003. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  12004. --修改是否绑定微信
  12005. UPDATE a SET HasWeiXin = 1
  12006. FROM #T a, WxFans b WITH(NOLOCK)
  12007. WHERE a.paMainID = b.PaMainID
  12008. AND b.Status = 2
  12009. AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  12010. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  12011. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  12012. FROM #T a, cvEducation b WITH(NOLOCK)
  12013. WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  12014. UPDATE a SET a.RecruitmentName = b.RecruitmentName, a.RecruitmentDate = b.EndDate
  12015. FROM #T a, Recruitment b WITH(NOLOCK)
  12016. WHERE b.ID = a.RecruitmentID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  12017. UPDATE #T SET cvMatch = dbo.GetCvMatch(cvMainID, JobID) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  12018. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  12019. SELECT a.*,b.Description DegreeName,c.MapBarName LivePlaceName,d.Description JobRegionName, dbo.BirthToAge(a.BirthDay) Age
  12020. FROM #T a WITH(NOLOCK)
  12021. LEFT JOIN dcEducation b WITH(NOLOCK) ON b.ID = a.Degree
  12022. LEFT JOIN dcRegion c WITH(NOLOCK) ON c.ID = a.LivePlace
  12023. LEFT JOIN dcRegion d WITH(NOLOCK) ON d.ID = a.JobRegion
  12024. WHERE a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
  12025. --计算匹配度
  12026. DROP TABLE #T
  12027. END
  12028. GO
  12029. /****** Object: StoredProcedure [dbo].[mblexJobApplyNoViewByCaMainIDSelect] Script Date: 2018/12/13 19:07:40 ******/
  12030. SET ANSI_NULLS ON
  12031. GO
  12032. SET QUOTED_IDENTIFIER ON
  12033. GO
  12034. --#####################################################
  12035. --创建时间:2014.11.06
  12036. --创建人:Nick
  12037. --说明:简历管理未查看的应聘简历
  12038. --#####################################################
  12039. CREATE PROCEDURE [dbo].[mblexJobApplyNoViewByCaMainIDSelect]
  12040. (
  12041. @caMainID INT
  12042. )
  12043. AS
  12044. BEGIN TRY
  12045. SELECT COUNT(*) Cnt
  12046. FROM exJobApply a WITH(NOLOCK), Job b WITH(NOLOCK)
  12047. WHERE a.JobID =b.ID
  12048. AND b.caMainID = @caMainID
  12049. AND a.viewdate IS NULL
  12050. END TRY
  12051. BEGIN CATCH
  12052. RETURN 0
  12053. END CATCH
  12054. GO
  12055. /****** Object: StoredProcedure [dbo].[mblExJobApplySelect] Script Date: 2018/12/13 19:07:40 ******/
  12056. SET ANSI_NULLS ON
  12057. GO
  12058. SET QUOTED_IDENTIFIER ON
  12059. GO
  12060. CREATE PROCEDURE [dbo].[mblExJobApplySelect]
  12061. (
  12062. @paMainID AS INT,
  12063. @PageNum AS INT,
  12064. @PageSize AS INT
  12065. )
  12066. AS
  12067. SET NOCOUNT ON
  12068. INSERT ProcLog SELECT 'mblExJobApplySelect', '', GETDATE()
  12069. BEGIN
  12070. DECLARE @COUNT INT
  12071. SELECT @COUNT=COUNT(1)
  12072. FROM exJobApply a WITH(NOLOCK)
  12073. INNER JOIN cvMain b WITH(NOLOCK) ON a.cvMainID = b.ID
  12074. WHERE b.paMainID=@paMainID
  12075. SELECT *,@COUNT AS cnt FROM(
  12076. SELECT ROW_NUMBER() OVER(ORDER BY a.AddDate DESC) AS Rows,a.ID, a.JobID, a.cvMainID, a.ApplyMessage, a.AddDate, a.CompanyDeleted, a.CompanyDeleteDate,
  12077. a.PersonDeleted, a.Reply, a.ReplyDate, b.Name as JobName, b.caMainID, b.dcRegionID, c.Name as cpName, c.ID as cpID,c.secondid encpid,
  12078. c.HasLicence, c.IsAgent, b.IssueDate, b.IssueEND, b.IsDelete, d.Name cvName, b.secondid enjobid
  12079. FROM exJobApply a WITH(NOLOCK)
  12080. inner join Job b WITH(NOLOCK) On b.ID=a.JobID
  12081. Inner Join cpMain c WITH(NOLOCK) ON b.cpMainID=c.ID
  12082. INNER JOIN cvMain d WITH(NOLOCK) ON a.cvMainID = d.ID
  12083. WHERE PersonDeleted=0 AND d.paMainID=@paMainID
  12084. ) AS a
  12085. WHERE a.Rows BETWEEN (@PageNum-1)*@PageSize+1 AND @PageNum*@PageSize ORDER BY A.ID desc
  12086. END
  12087. GO
  12088. /****** Object: StoredProcedure [dbo].[mblFeedBackInsert] Script Date: 2018/12/13 19:07:40 ******/
  12089. SET ANSI_NULLS ON
  12090. GO
  12091. SET QUOTED_IDENTIFIER ON
  12092. GO
  12093. CREATE PROCEDURE [dbo].[mblFeedBackInsert]
  12094. (
  12095. @Content NVARCHAR(200),
  12096. @Version VARCHAR(50),
  12097. @paMainID INT
  12098. )
  12099. AS
  12100. BEGIN
  12101. INSERT INTO mblFeedBack(Content,Version,paMainID) VALUES(dbo.SafeSQL(@Content),dbo.SafeSQL(@Version),@paMainID)
  12102. END
  12103. GO
  12104. /****** Object: StoredProcedure [dbo].[mblGovNewsList] Script Date: 2018/12/13 19:07:40 ******/
  12105. SET ANSI_NULLS ON
  12106. GO
  12107. SET QUOTED_IDENTIFIER ON
  12108. GO
  12109. CREATE PROCEDURE [dbo].[mblGovNewsList]
  12110. (
  12111. @dcProvinceID AS SMALLINT,
  12112. @PageNum AS INT,
  12113. @PageSize AS INT
  12114. )
  12115. AS
  12116. BEGIN
  12117. DECLARE @COUNT INT
  12118. SELECT @COUNT=COUNT(1)
  12119. FROM QlrcNews WITH(NOLOCK) WHERE (
  12120. EXISTS(SELECT 'x' FROM fnSplit(DetailType,',') b,dcNewsType c WITH(NOLOCK) WHERE b.a=c.ID AND c.Category=1) OR DetailType IS NULL)
  12121. AND (VersionID=@dcProvinceID OR VersionID=0) AND NewsType = 2 AND DetailType like '%,2,%'
  12122. IF @COUNT > 200
  12123. SET @COUNT = 200
  12124. SELECT *,@COUNT AS cnt FROM(
  12125. SELECT TOP 200 ROW_NUMBER() OVER(ORDER BY RefreshDate DESC) AS Rows,ID,Title,RefreshDate,Author
  12126. FROM QlrcNews WITH(NOLOCK) WHERE (
  12127. EXISTS(SELECT 'x' FROM fnSplit(DetailType,',') b,dcNewsType c WITH(NOLOCK) WHERE b.a=c.ID AND c.Category=1) OR DetailType IS NULL)
  12128. AND (VersionID=@dcProvinceID OR VersionID=0) AND NewsType = 2 AND DetailType like '%,2,%'
  12129. ) AS a
  12130. WHERE a.Rows BETWEEN (@PageNum-1)*@PageSize+1 AND @PageNum*@PageSize ORDER BY Rows
  12131. END
  12132. set ANSI_NULLS ON
  12133. set QUOTED_IDENTIFIER ON
  12134. GO
  12135. /****** Object: StoredProcedure [dbo].[mblInfoSetByIDSelect] Script Date: 2018/12/13 19:07:40 ******/
  12136. SET ANSI_NULLS ON
  12137. GO
  12138. SET QUOTED_IDENTIFIER ON
  12139. GO
  12140. --#####################################################
  12141. --创建时间:2014.11.7
  12142. --创建人:Nick
  12143. --说明:获取手机APP下载设置
  12144. --#####################################################
  12145. CREATE PROCEDURE [dbo].[mblInfoSetByIDSelect]
  12146. (
  12147. @ID INT
  12148. )
  12149. AS
  12150. BEGIN
  12151. SELECT * FROM reportdb..InfoSet WITH(NOLOCK) WHERE id=@ID
  12152. END
  12153. GO
  12154. /****** Object: StoredProcedure [dbo].[mblInfoSetInsert] Script Date: 2018/12/13 19:07:40 ******/
  12155. SET ANSI_NULLS ON
  12156. GO
  12157. SET QUOTED_IDENTIFIER ON
  12158. GO
  12159. --#####################################################
  12160. --创建时间:2014.11.7
  12161. --创建人:Nick
  12162. --说明:添加手机APP下载记录
  12163. --#####################################################
  12164. CREATE PROCEDURE [dbo].[mblInfoSetInsert]
  12165. (
  12166. @InfoId VARCHAR(20),
  12167. @IP VARCHAR(20),
  12168. @Source VARCHAR(200),
  12169. @SubSiteID VARCHAR(6)
  12170. )
  12171. AS
  12172. BEGIN
  12173. INSERT INTO reportdb..InfoLog(InfoId,IP,Source,SubSiteID,AddDate)
  12174. VALUES(@InfoId,@IP,@Source,@SubSiteID,GETDATE())
  12175. END
  12176. GO
  12177. /****** Object: StoredProcedure [dbo].[mblJobByAppSearchSelect] Script Date: 2018/12/13 19:07:41 ******/
  12178. SET ANSI_NULLS ON
  12179. GO
  12180. SET QUOTED_IDENTIFIER ON
  12181. GO
  12182. CREATE proCEDURE [dbo].[mblJobByAppSearchSelect]
  12183. (
  12184. @dcJobTypeID VARCHAR(100), --职位类别
  12185. @dcRegionID VARCHAR(100), --求职地区
  12186. @dcIndustryID VARCHAR(100), --求职行业
  12187. @dcSalaryID TINYINT, --月薪
  12188. @IsNegotiable BIT, --1允许面议,不面议
  12189. @MinExperience TINYINT, --工作经验,100为未选择
  12190. @dcEducationID TINYINT, --最低学历
  12191. @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习,
  12192. @KeyWord NVARCHAR(50), --关键词
  12193. @KeyType TINYINT, --搜索类别,0无;1-全文;2-职位;3-公司
  12194. @ORDER VARCHAR(4), --显示顺序,没有用
  12195. @RefreshNo INT, --1, 1天内;2, 3天内;3,一周内;4,15天内;5,一个月内;6超过一个月
  12196. @Type INT, --1:主动搜索 点击搜索按钮 10分钟,翻页60分钟有效;0:翻页搜索,不刷新
  12197. @PageNumber INT, --翻页页码
  12198. @SessionID varchar(50), --10
  12199. @CompanySizeID VARCHAR(1), --企业规模
  12200. @IsOnline INT,
  12201. @Welfare VARCHAR(50) --
  12202. )
  12203. AS
  12204. --return @SessionId = 10
  12205. SET NOCOUNT ON
  12206. --insert into aa
  12207. --select getdate(), @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcSalaryID, @IsNegotiable,
  12208. -- @MinExperience, @dcEducationID, @EmployType, @KeyWord, @KeyType, @ORDER, @RefreshNo,
  12209. -- @Type, @PageNumber, @SessionID, @CompanySizeID, @IsOnline, @Welfare
  12210. INSERT INTO SearchIp(Ip, Source) SELECT @SessionId, 'm'
  12211. IF EXISTS(SELECT 'x' FROM RefuseIp WITH(NOLOCK) WHERE CHARINDEX(Ip,@SessionId) > 0)
  12212. RETURN
  12213. INSERT INTO SearchDB..paSearchLog(ProcType, SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
  12214. Salary, IsNegotiable, EmployType, CompanySizeID, KeyWord, KeyType, ReuseNumber, Welfare, IsOnline, RefreshNo)
  12215. VALUES('pcJobBySearchSelect', @SessionId, GETDATE(), @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcEducationID, @MinExperience,
  12216. @dcSalaryID, 0, @EmployType, @CompanySizeID, @KeyWord, @KeyType, 0, @Welfare, @IsOnline, @RefreshNo)
  12217. SET @SessionId = 'a' + @SessionId
  12218. SET @KeyType = 0
  12219. BEGIN TRY
  12220. DECLARE @ReuseNumber AS INT, @dcProvinceId VARCHAR(2), @Order2 VARCHAR(100)
  12221. ----给null值变量赋默认值
  12222. IF NOT LEFT(@dcRegionID,1) = 'p'
  12223. SELECT @dcRegionID = RTRIM(dbo.FormatIDS(@dcRegionID))
  12224. SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
  12225. @dcIndustryID = RTRIM(dbo.FormatIDS(@dcIndustryID)),
  12226. @dcSalaryID = ISNULL(@dcSalaryID, 0),
  12227. @IsNegotiable = ISNULL(@IsNegotiable, 0),
  12228. @MinExperience = ISNULL(@MinExperience, 100),
  12229. @dcEducationID = ISNULL(@dcEducationID, 0),
  12230. @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END,
  12231. @CompanySizeID = ISNULL(@CompanySizeID, '0'),
  12232. @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, '')),
  12233. @ORDER = ISNULL(@Order, ''),
  12234. @Type = ISNULL(@Type, 0),
  12235. @PageNumber = ISNULL(@PageNumber, 0),
  12236. @Welfare = RTRIM(dbo.FormatIDS(@Welfare)),
  12237. @IsOnline = ISNULL(@IsOnline, 0),
  12238. @Order2 = ' ORDER BY a.RefreshDate DESC, a.SecondID DESC'
  12239. IF @dcSalaryID = 0
  12240. SET @IsNegotiable = 0
  12241. IF @Order LIKE 'p=%'
  12242. SET @dcProvinceId = REPLACE(@Order, 'p=', '')
  12243. ELSE
  12244. SET @dcProvinceId = 0
  12245. --@RefreshNo = 0选择全部数据,不限制时间
  12246. SET @RefreshNo = 0
  12247. IF(@KeyWord = '' AND ISNULL(@dcJobTypeID, '') = '' AND ISNULL(@dcRegionID, '') = '' AND ISNULL(@dcIndustryID, '') = '')
  12248. RETURN
  12249. --如果关键词不为空 查询关键词对应的搜索类型 max 2012-12-25
  12250. IF RIGHT(@KeyWord, 2) = '公司'
  12251. SET @KeyWord = LEFT(@KeyWord, LEN(@KeyWord) - 2)
  12252. IF RIGHT(@dcJobTypeID, 1) = ','
  12253. SET @dcJobTypeID = LEFT(@dcJobTypeID, LEN(@dcJobTypeID) - 1)
  12254. IF RIGHT(@dcRegionID, 1) = ','
  12255. SET @dcRegionID = LEFT(@dcRegionID, LEN(@dcRegionID) - 1)
  12256. IF RIGHT(@dcIndustryID, 1) = ','
  12257. SET @dcIndustryID = LEFT(@dcIndustryID, LEN(@dcIndustryID) - 1)
  12258. DECLARE @paSearchConditionID AS INT,
  12259. @MinId AS INT,
  12260. @PageSize AS TINYINT,
  12261. @TableID AS TINYINT
  12262. SELECT @paSearchConditionID = 0, @PageSize = 30
  12263. ----搜索1分钟前的数据
  12264. SELECT TOP 1 @paSearchConditionID = ID,
  12265. @ReuseNumber = ReuseNumber
  12266. FROM SearchDB..paSearchCondition WITH(NOLOCK)
  12267. WHERE JobType=@dcJobTypeID AND IsOnline = @IsOnline
  12268. AND JobPlace=@dcRegionID AND Industry=@dcIndustryID AND Education=@dcEducationID
  12269. AND Experience=@MinExperience AND Salary=@dcSalaryID AND IsNegotiable=@IsNegotiable
  12270. AND EmployType=@EmployType AND ISNULL(KeyWord, '') = @KeyWord AND KeyType = @KeyType
  12271. AND CompanySizeID = @CompanySizeID AND Welfare = @Welfare AND IsDelete = 0
  12272. AND LogTime > DATEADD(MINUTE, -1, GETDATE()) AND ReuseNumber > 0
  12273. AND RefreshNo = 0 AND ISNULL(dcProvinceId, 0) = @dcProvinceId
  12274. ORDER BY ID DESC
  12275. IF @ReuseNumber = 0
  12276. BEGIN
  12277. SELECT TOP 1 @paSearchConditionID = ID
  12278. FROM SearchDB..paSearchCondition WITH(NOLOCK)
  12279. WHERE JobType=@dcJobTypeID AND IsOnline = @IsOnline
  12280. AND JobPlace=@dcRegionID AND Industry=@dcIndustryID AND Education=@dcEducationID
  12281. AND Experience=@MinExperience AND Salary=@dcSalaryID AND IsNegotiable=@IsNegotiable
  12282. AND EmployType=@EmployType AND ISNULL(KeyWord, '') = @KeyWord AND KeyType=@KeyType
  12283. AND CompanySizeID = @CompanySizeID AND Welfare = @Welfare AND ReuseNumber > 0
  12284. AND ReuseNumber > 0 AND LogTime > DATEADD(MINUTE, -2, GETDATE())
  12285. AND RefreshNo = 0 AND ISNULL(dcProvinceId, 0) = @dcProvinceId
  12286. ORDER BY ID DESC
  12287. END
  12288. IF ISNULL(@paSearchConditionID, 0) = 0
  12289. BEGIN
  12290. SET @Type =1
  12291. GOTO SelectReset --无数据,重新搜索
  12292. END
  12293. ELSE
  12294. BEGIN
  12295. SELECT @TableID = @paSearchConditionID % 4
  12296. GOTO GetRecordSet --从临时结果中提取数据
  12297. END
  12298. SelectReset:
  12299. --从job中搜索数据
  12300. BEGIN TRAN
  12301. DECLARE @SQL AS VARCHAR(8000)
  12302. DECLARE @WHERE AS VARCHAR(8000)
  12303. DECLARE @FROM AS VARCHAR(1000)
  12304. ----记录查询条件
  12305. INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
  12306. Salary, IsNegotiable, EmployType, CompanySizeID, KeyWord, KeyType, ReuseNumber, Welfare, IsOnline, dcProvinceId)
  12307. VALUES(@SessionId, GETDATE(), @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcEducationID, @MinExperience,
  12308. @dcSalaryID, @IsNegotiable, @EmployType, @CompanySizeID, @KeyWord, @KeyType, 0, @Welfare, @IsOnline, @dcProvinceId)
  12309. SET @paSearchConditionID = @@IDENTITY
  12310. SELECT @TableID = @paSearchConditionID % 4
  12311. ------生成职位类别的表变量,因为职位类别有包含(父子)关系
  12312. DECLARE @T_JobPlace AS TABLE(ID INT)
  12313. DECLARE @T_JobType AS TABLE(ID INT)
  12314. DECLARE @JobPlaceLen AS INT, @JobTypeLen AS INT
  12315. IF CHARINDEX(',', @dcJobTypeID) > 0
  12316. SET @JobTypeLen = -1
  12317. ELSE
  12318. SET @JobTypeLen = LEN(@dcJobTypeID)
  12319. DECLARE @JobType AS VARCHAR(3000), @JobPlace AS VARCHAR(2000), @ValidJobNumber AS INT
  12320. SELECT @JobPlace = '', @JobType=''
  12321. ----生成工作地点的表变量
  12322. IF LEN(@dcRegionID) > 0
  12323. BEGIN
  12324. IF LEFT(@dcRegionID,1) = 'p'
  12325. BEGIN
  12326. DECLARE @Degree AS DECIMAL(8,5),@LBLng AS DECIMAL(8,5),@LBLat AS DECIMAL(8,5),
  12327. @RTLng AS DECIMAL(8,5),@RTLat AS DECIMAL(8,5),@Lat AS DECIMAL(8,5),@Lng AS DECIMAL(8,5)
  12328. SELECT @Lat = Lat,@Lng = Lng FROM dcMapPlace WITH(NOLOCK) WHERE ID = RIGHT(@dcRegionID,LEN(@dcRegionID)-1)
  12329. IF @dcRegionID LIKE '3201%'
  12330. SET @Degree = 1000 / 100000.0
  12331. ELSE
  12332. SET @Degree = 2000 / 100000.0
  12333. SET @LBLng = @Lng - @Degree
  12334. SET @LBLat = @Lat - @Degree
  12335. SET @RTLng = @Lng + @Degree
  12336. SET @RTLat = @Lat + @Degree
  12337. SET @JobPlace = 'a.Lng BETWEEN ' + CONVERT(VARCHAR,@LBLng) + ' AND ' + CONVERT(VARCHAR,@RTLng) + '
  12338. AND a.Lat BETWEEN ' + CONVERT(VARCHAR,@LBLat) + ' AND ' + CONVERT(VARCHAR,@RTLat) + '
  12339. AND (a.Lng-' + CONVERT(VARCHAR,@Lng) + ')*(a.Lng-' + CONVERT(VARCHAR,@Lng) + ')+
  12340. (a.Lat-' + CONVERT(VARCHAR,@Lat) + ')*(a.Lat-' + CONVERT(VARCHAR,@Lat) + ')<' + CONVERT(VARCHAR,@Degree*@Degree)
  12341. SELECT @JobPlaceLen = 8
  12342. END
  12343. ELSE
  12344. BEGIN
  12345. INSERT INTO @T_JobPlace
  12346. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  12347. SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  12348. IF LEN(@JobPlace) > 0
  12349. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  12350. IF (SELECT COUNT(*) FROM @T_JobPlace) > 1
  12351. SET @JobPlaceLen = -1
  12352. ELSE
  12353. SET @JobPlaceLen = LEN(@dcRegionID)
  12354. END
  12355. END
  12356. ELSE
  12357. SELECT @JobPlaceLen = 0
  12358. ----生成求聘职位的表变量
  12359. IF LEN(@dcJobTypeID) > 0
  12360. BEGIN
  12361. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  12362. INSERT INTO @T_Temp
  12363. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  12364. INSERT INTO @T_JobType
  12365. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  12366. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  12367. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  12368. OR ID IN(SELECT ID FROM @T_TEMP)
  12369. ----生成in字符串
  12370. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  12371. IF RIGHT(@JobType, 1) = ','
  12372. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  12373. END
  12374. ----建立临时表
  12375. CREATE TABLE #Job(
  12376. RowID INT IDENTITY(1, 1),
  12377. ID INT NOT NULL,
  12378. cpMainId INT,
  12379. dcJobTypeID SMALLINT NOT NULL,
  12380. dcJobTypeIDMinor SMALLINT NULL,
  12381. dcSalaryID TINYINT NOT NULL,
  12382. dcRegionID VARCHAR(6) NULL,
  12383. dcEducationID TINYINT NOT NULL,
  12384. MinExperience TINYINT NOT NULL,
  12385. RefreshDate SMALLDATETIME NULL,
  12386. EmployType TINYINT NULL,
  12387. dcCompanySizeID SMALLINT NULL
  12388. )
  12389. CREATE TABLE #FullText(
  12390. Priority INT,
  12391. JobId INT NOT NULL
  12392. )
  12393. ------刷新时间,根据刷新时间编号计算
  12394. ----生成插入临时表的Sql语句
  12395. SET @SQL='
  12396. INSERT INTO #Job
  12397. SELECT a.ID, a.cpMainId, a.dcJobTypeID,
  12398. a.dcJobTypeIDMinor, a.dcSalaryID,
  12399. a.dcRegionID, a.dcEducationID, a.MinExperience,
  12400. a.IssueDate,a.EmployType,b.dcCompanySizeID'
  12401. SET @FROM = '
  12402. FROM JobPublish a WITH(NOLOCK)
  12403. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  12404. ----职位有效,单位新有效
  12405. IF LEN(@dcIndustryID) > 0
  12406. SET @WHERE = '
  12407. WHERE b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @dcIndustryID + '))
  12408. AND a.Valid = 1
  12409. AND b.Valid = 1'
  12410. ELSE
  12411. SET @WHERE = '
  12412. WHERE a.Valid = 1
  12413. AND b.Valid = 1'
  12414. IF LEN(@dcProvinceId) > 1
  12415. SET @WHere = @Where + ' AND b.dcProvinceId = ' + @dcProvinceId
  12416. ----职位类别
  12417. IF LEN(@JobType) > 0
  12418. SET @WHERE = @WHERE + '
  12419. AND (a.dcJobTypeID IN(' + @JobType +')
  12420. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  12421. IF LEN(@JobPlace) > 0
  12422. SET @WHERE = @WHERE + '
  12423. AND (' + @JobPlace + ')'
  12424. IF @dcSalaryID > 0
  12425. BEGIN
  12426. IF @dcSalaryID < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
  12427. SET @WHERE = @WHERE + '
  12428. AND a.dcSalaryID IN(' + LTRIM(STR(@dcSalaryID)) + ',' + LTRIM(STR(@dcSalaryID + 1)) + ')'
  12429. ELSE IF @dcSalaryID = 100 ----从筛选结果中点击面议,值是100
  12430. SET @WHERE = @WHERE + '
  12431. AND a.dcSalaryID = 100'
  12432. ELSE IF @dcSalaryID BETWEEN 101 AND 106 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  12433. SET @WHERE = @WHERE + '
  12434. AND a.dcSalaryID <= ' + LTRIM(STR(@dcSalaryID-99)) + ' AND a.dcSalaryIDMax > ' + LTRIM(STR(@dcSalaryID-100))
  12435. ELSE IF @dcSalaryID BETWEEN 107 AND 113 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  12436. SET @WHERE = @WHERE + '
  12437. AND a.dcSalaryID <= ' + LTRIM(STR(@dcSalaryID - 100)) + ' AND a.dcSalaryIDMax > ' + LTRIM(STR(@dcSalaryID-100))
  12438. ELSE IF @dcSalaryID BETWEEN 114 AND 120
  12439. SET @WHERE = @WHERE + '
  12440. AND a.dcSalaryID < 100 AND a.dcSalaryIDMax > ' + LTRIM(STR(@dcSalaryID - 100))
  12441. END
  12442. ----工作经验要求
  12443. IF @MinExperience < 100
  12444. SET @WHERE = @WHERE + '
  12445. AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
  12446. ----学历要求
  12447. ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
  12448. IF @dcEducationID > 0
  12449. IF @dcEducationID = 2
  12450. SET @WHERE = @WHERE + '
  12451. AND a.dcEducationID IN(2, 3, 4)'
  12452. ELSE
  12453. SET @WHERE = @WHERE + '
  12454. AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
  12455. ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
  12456. IF LEN(@EmployType) > 0
  12457. SET @WHERE = @WHERE + '
  12458. AND a.EmployType IN (' + @EmployType + ')'
  12459. IF @CompanySizeID BETWEEN 1 AND 6
  12460. SET @WHERE = @WHERE + '
  12461. AND b.dcCompanySizeID = ' + LTRIM(STR(@CompanySizeID))
  12462. IF LEN(@Welfare) > 0
  12463. SET @WHERE = @WHERE + '
  12464. AND a.Welfare' + REPLACE(@Welfare, ',', ' = 1 AND a.Welfare') + ' = 1'
  12465. IF @IsOnline = 1
  12466. SET @WHERE = @WHERE + '
  12467. AND a.caMainId IN(SELECT caMainId FROM caOnline WITH(NOLOCK) WHERE IsOnline = 1)'
  12468. IF LEN(@KeyWord) > 0 ----使用全文搜索job和cpmain2个表,经过测试发现union最快
  12469. BEGIN
  12470. IF EXISTS(SELECT TOP 1 'x' FROM cpMainPublish WITH(NOLOCK) WHERE Name = @KeyWord)
  12471. BEGIN
  12472. SET @WHERE = @WHERE + '
  12473. AND b.Name = ''' + @KeyWord + ''''
  12474. SET @SQL = @SQL + @FROM + @WHERE
  12475. END
  12476. ELSE
  12477. BEGIN
  12478. DECLARE @KeyWordTemp NVARCHAR(50)
  12479. SET @KeyWordTemp = REPLACE(@KeyWord, ' ', '%')
  12480. IF LEN(@KeyWordTemp) > 1
  12481. BEGIN
  12482. IF @dcProvinceId > 0
  12483. BEGIN
  12484. INSERT #FullText
  12485. SELECT TOP 2000 2, b.ID
  12486. FROM cpMainPublish a WITH(NOLOCK),
  12487. JobPublish b WITH(NOLOCK)
  12488. WHERE a.Id = b.cpMainId
  12489. AND a.Name LIKE '%' + @KeyWordTemp + '%'
  12490. AND a.dcProvinceId = @dcprovinceId
  12491. ORDER BY b.RefreshDate DESC
  12492. INSERT #FullText
  12493. SELECT TOP 2000 1, b.ID
  12494. FROM cpMainPublish a WITH(NOLOCK),
  12495. JobPublish b WITH(NOLOCK)
  12496. WHERE a.Id = b.cpMainId
  12497. AND b.Name LIKE '%' + @KeyWordTemp + '%'
  12498. AND a.dcProvinceId = @dcprovinceId
  12499. ORDER BY b.RefreshDate DESC
  12500. END
  12501. ELSE
  12502. BEGIN
  12503. INSERT #FullText
  12504. SELECT TOP 2000 2, b.ID
  12505. FROM cpMainPublish a WITH(NOLOCK),
  12506. JobPublish b WITH(NOLOCK)
  12507. WHERE a.Id = b.cpMainId
  12508. AND a.Name LIKE '%' + @KeyWordTemp + '%'
  12509. ORDER BY b.RefreshDate DESC
  12510. INSERT #FullText
  12511. SELECT TOP 2000 1, b.ID
  12512. FROM cpMainPublish a WITH(NOLOCK),
  12513. JobPublish b WITH(NOLOCK)
  12514. WHERE a.Id = b.cpMainId
  12515. AND b.Name LIKE '%' + @KeyWordTemp + '%'
  12516. ORDER BY b.RefreshDate DESC
  12517. END
  12518. END
  12519. IF (SELECT COUNT(*) FROM #FullText) < 800
  12520. BEGIN
  12521. INSERT #FullText
  12522. SELECT TOP 5000 3, [Key]
  12523. FROM FREETEXTTABLE(cpMainJob, *, @KeyWord, 100000) AS KeyJob ORDER BY RANK DESC
  12524. END
  12525. DELETE a FROM #FullText a, #FullText b WHERE a.JobId = b.JobId AND a.Priority > b.Priority
  12526. --------------------
  12527. SELECT @FROM = @FROM + '
  12528. INNER JOIN #FullText ON a.ID = #FullText.JobId',
  12529. @ORDER2 = ' ORDER BY #FullText.Priority, a.RefreshDate DESC, a.SecondID DESC'
  12530. SET @SQL = @SQL + @FROM + @WHERE
  12531. END
  12532. END
  12533. ELSE
  12534. SELECT @SQL = @SQL + @FROM + @WHERE
  12535. SET @SQL = @SQL + @Order2
  12536. --原来是ORDER BY a.IssueDate DESC, a.ID,Richard 2011年11月23日17:06分修改
  12537. ----把符合条件的职位全部列出
  12538. --PRINT @SQL
  12539. EXEC(@SQL)
  12540. SET @ValidJobNumber = @@ROWCOUNT
  12541. ----记录查询结果总数
  12542. UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@sql WHERE ID=@paSearchConditionID
  12543. IF LEN(@JobType) > 0 --IN(2, 4)
  12544. UPDATE #Job SET dcJobTypeId = dcJobTypeIDMinor
  12545. WHERE dcJobTypeID NOT IN(SELECT a FROM dbo.fnSplit(@JobType, ','))
  12546. ----插入JobType数据
  12547. DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
  12548. DECLARE @sc AS TABLE (
  12549. paSearchConditionID int,
  12550. Title varchar(20),
  12551. TitleID varchar(10),
  12552. TitleValue int
  12553. )
  12554. DECLARE @sc2 AS TABLE (
  12555. paSearchConditionID int,
  12556. Title varchar(20),
  12557. TitleID varchar(10),
  12558. TitleValue int
  12559. )
  12560. IF (@TableID = 0)
  12561. BEGIN
  12562. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  12563. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  12564. FROM #Job WITH(NOLOCK)
  12565. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  12566. ----计算全部某职位类别,2, 4位的数据
  12567. IF @JobTypeLen NOT IN(2, 4)
  12568. BEGIN
  12569. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  12570. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  12571. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  12572. END
  12573. IF @JobTypeLen NOT IN(0, 4)
  12574. BEGIN
  12575. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  12576. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  12577. FROM @sc2 WHERE LEN(TitleId) = 4
  12578. END
  12579. IF @JobTypeLen = -1
  12580. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  12581. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  12582. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  12583. DELETE @sc
  12584. DELETE @sc2
  12585. --------
  12586. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  12587. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  12588. GROUP BY dcRegionID ORDER BY dcRegionID
  12589. ----计算全部地区,2位的数据
  12590. IF @JobPlaceLen IN(-1, 0)
  12591. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12592. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  12593. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  12594. IF @JobPlaceLen IN(-1, 2)
  12595. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12596. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  12597. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  12598. IF @JobPlaceLen IN(-1, 4)
  12599. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12600. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  12601. FROM @sc2 WHERE LEN(TitleID) = 6
  12602. IF @JobPlaceLen = -1
  12603. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  12604. ELSE
  12605. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  12606. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  12607. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  12608. ----------------
  12609. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  12610. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  12611. GROUP BY EmployType ORDER BY EmployType
  12612. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  12613. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  12614. FROM #Job WITH(NOLOCK)
  12615. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  12616. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  12617. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  12618. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  12619. GROUP BY MinExperience ORDER BY MinExperience
  12620. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  12621. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  12622. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  12623. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  12624. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  12625. GROUP BY dcSalaryID ORDER BY dcSalaryID
  12626. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  12627. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  12628. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  12629. WHERE a.cpMainId = b.cpMainId
  12630. GROUP BY b.dcIndustryId ORDER BY b.dcIndustryId
  12631. IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
  12632. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  12633. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  12634. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  12635. WHERE b.ID = a.JobId
  12636. AND CHARINDEX(@KeyWord, a.JobName) > 0
  12637. ORDER BY a.OrderType, a.OpenDate DESC
  12638. ELSE
  12639. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  12640. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  12641. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  12642. WHERE b.ID = a.JobId
  12643. ORDER BY a.OrderType, a.OpenDate DESC
  12644. SET @TopRows = @@ROWCOUNT
  12645. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  12646. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowID
  12647. SET @AllRows = @@ROWCOUNT
  12648. IF @TopRows = 0 AND @AllRows > 100
  12649. UPDATE SearchDB..paSearchJobID_0 SET IsTop = 1
  12650. WHERE paSearchConditionID = @paSearchConditionID
  12651. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
  12652. END
  12653. ELSE IF (@TableId = 1)
  12654. BEGIN
  12655. ----------------------------jobtype
  12656. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  12657. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  12658. FROM #Job WITH(NOLOCK)
  12659. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  12660. ----计算全部某职位类别,2, 4位的数据
  12661. IF @JobTypeLen NOT IN(2, 4)
  12662. BEGIN
  12663. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  12664. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  12665. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  12666. END
  12667. IF @JobTypeLen NOT IN(0, 4)
  12668. BEGIN
  12669. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  12670. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  12671. FROM @sc2 WHERE LEN(TitleId) = 4
  12672. END
  12673. IF @JobTypeLen = -1
  12674. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  12675. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  12676. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  12677. DELETE @sc
  12678. DELETE @sc2
  12679. --------------------------region
  12680. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  12681. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  12682. GROUP BY dcRegionID ORDER BY dcRegionID
  12683. ----计算全部地区,2位的数据
  12684. IF @JobPlaceLen IN(-1, 0)
  12685. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12686. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  12687. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  12688. IF @JobPlaceLen IN(-1, 2)
  12689. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12690. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  12691. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  12692. IF @JobPlaceLen IN(-1, 4)
  12693. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12694. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  12695. FROM @sc2 WHERE LEN(TitleID) = 6
  12696. IF @JobPlaceLen = -1
  12697. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  12698. ELSE
  12699. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  12700. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  12701. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  12702. ----------------------------
  12703. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  12704. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  12705. FROM #Job WITH(NOLOCK)
  12706. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  12707. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  12708. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  12709. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  12710. GROUP BY MinExperience ORDER BY MinExperience
  12711. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  12712. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  12713. GROUP BY EmployType ORDER BY EmployType
  12714. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  12715. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  12716. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  12717. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  12718. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  12719. GROUP BY dcSalaryID ORDER BY dcSalaryID
  12720. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  12721. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  12722. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  12723. WHERE a.cpMainId = b.cpMainId
  12724. GROUP BY dcIndustryID ORDER BY dcIndustryID
  12725. IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
  12726. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  12727. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  12728. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  12729. WHERE b.ID = a.JobId
  12730. AND CHARINDEX(@KeyWord, a.JobName) > 0
  12731. ORDER BY a.OrderType, a.OpenDate DESC
  12732. ELSE
  12733. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  12734. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  12735. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  12736. WHERE b.ID = a.JobId
  12737. ORDER BY a.OrderType, a.OpenDate DESC
  12738. SET @TopRows = @@ROWCOUNT
  12739. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  12740. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowID
  12741. SET @AllRows = @@ROWCOUNT
  12742. IF @TopRows = 0 AND @AllRows > 100
  12743. UPDATE SearchDB..paSearchJobID_1 SET IsTop = 1
  12744. WHERE paSearchConditionID = @paSearchConditionID
  12745. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
  12746. END
  12747. ELSE IF (@TableId = 2)
  12748. BEGIN
  12749. ----------------------------jobtype
  12750. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  12751. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  12752. FROM #Job WITH(NOLOCK)
  12753. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  12754. ----计算全部某职位类别,2, 4位的数据
  12755. IF @JobTypeLen NOT IN(2, 4)
  12756. BEGIN
  12757. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  12758. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  12759. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  12760. END
  12761. IF @JobTypeLen NOT IN(0, 4)
  12762. BEGIN
  12763. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  12764. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  12765. FROM @sc2 WHERE LEN(TitleId) = 4
  12766. END
  12767. IF @JobTypeLen = -1
  12768. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  12769. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  12770. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  12771. DELETE @sc
  12772. DELETE @sc2
  12773. --------------------------region
  12774. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  12775. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  12776. GROUP BY dcRegionID ORDER BY dcRegionID
  12777. ----计算全部地区,2位的数据
  12778. IF @JobPlaceLen IN(-1, 0)
  12779. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12780. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  12781. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  12782. IF @JobPlaceLen IN(-1, 2)
  12783. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12784. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  12785. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  12786. IF @JobPlaceLen IN(-1, 4)
  12787. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12788. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  12789. FROM @sc2 WHERE LEN(TitleID) = 6
  12790. IF @JobPlaceLen = -1
  12791. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  12792. ELSE
  12793. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  12794. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  12795. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  12796. ----------------------------
  12797. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  12798. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  12799. FROM #Job WITH(NOLOCK)
  12800. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  12801. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  12802. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  12803. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  12804. GROUP BY MinExperience ORDER BY MinExperience
  12805. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  12806. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  12807. GROUP BY dcSalaryID ORDER BY dcSalaryID
  12808. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  12809. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  12810. GROUP BY EmployType ORDER BY EmployType
  12811. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  12812. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  12813. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  12814. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  12815. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  12816. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  12817. WHERE a.cpMainId = b.cpMainId
  12818. GROUP BY dcIndustryID ORDER BY dcIndustryID
  12819. IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
  12820. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  12821. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  12822. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  12823. WHERE b.ID = a.JobId
  12824. AND CHARINDEX(@KeyWord, a.JobName) > 0
  12825. ORDER BY a.OrderType, a.OpenDate DESC
  12826. ELSE
  12827. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  12828. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  12829. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  12830. WHERE b.ID = a.JobId
  12831. ORDER BY a.OrderType, a.OpenDate DESC
  12832. SET @TopRows = @@ROWCOUNT
  12833. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  12834. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowID
  12835. SET @AllRows = @@ROWCOUNT
  12836. IF @TopRows = 0 AND @AllRows > 100
  12837. UPDATE SearchDB..paSearchJobID_2 SET IsTop = 1
  12838. WHERE paSearchConditionID = @paSearchConditionID
  12839. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
  12840. END
  12841. ELSE IF (@TableId = 3)
  12842. BEGIN
  12843. ----------------------------jobtype
  12844. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  12845. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  12846. FROM #Job WITH(NOLOCK)
  12847. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  12848. ----计算全部某职位类别,2, 4位的数据
  12849. IF @JobTypeLen NOT IN(2, 4)
  12850. BEGIN
  12851. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  12852. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  12853. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  12854. END
  12855. IF @JobTypeLen NOT IN(0, 4)
  12856. BEGIN
  12857. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  12858. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  12859. FROM @sc2 WHERE LEN(TitleId) = 4
  12860. END
  12861. IF @JobTypeLen = -1
  12862. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  12863. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12864. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  12865. DELETE @sc
  12866. DELETE @sc2
  12867. --------------------------region
  12868. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  12869. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  12870. GROUP BY dcRegionID ORDER BY dcRegionID
  12871. ----计算全部地区,2位的数据
  12872. IF @JobPlaceLen IN(-1, 0)
  12873. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12874. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  12875. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  12876. IF @JobPlaceLen IN(-1, 2)
  12877. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12878. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  12879. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  12880. IF @JobPlaceLen IN(-1, 4)
  12881. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  12882. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  12883. FROM @sc2 WHERE LEN(TitleID) = 6
  12884. IF @JobPlaceLen = -1
  12885. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  12886. ELSE
  12887. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  12888. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12889. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  12890. ----------------------------
  12891. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12892. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  12893. FROM #Job WITH(NOLOCK)
  12894. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  12895. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  12896. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12897. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  12898. GROUP BY MinExperience ORDER BY MinExperience
  12899. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12900. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  12901. GROUP BY dcSalaryID ORDER BY dcSalaryID
  12902. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12903. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  12904. GROUP BY EmployType ORDER BY EmployType
  12905. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12906. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  12907. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  12908. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  12909. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  12910. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  12911. WHERE a.cpMainId = b.cpMainId
  12912. GROUP BY dcIndustryID ORDER BY dcIndustryID
  12913. IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
  12914. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  12915. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  12916. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  12917. WHERE b.ID = a.JobId
  12918. AND CHARINDEX(@KeyWord, a.JobName) > 0
  12919. ORDER BY a.OrderType, a.OpenDate DESC
  12920. ELSE
  12921. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  12922. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  12923. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  12924. WHERE b.ID = a.JobId
  12925. ORDER BY a.OrderType, a.OpenDate DESC
  12926. SET @TopRows = @@ROWCOUNT
  12927. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  12928. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowID
  12929. SET @AllRows = @@ROWCOUNT
  12930. IF @TopRows = 0 AND @AllRows > 100
  12931. UPDATE SearchDB..paSearchJobID_3 SET IsTop = 1
  12932. WHERE paSearchConditionID = @paSearchConditionID
  12933. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
  12934. END
  12935. DROP TABLE #Job
  12936. --PRINT 'DROP #JOB ' + CONVERT(VARCHAR(30), GETDATE(), 121)
  12937. COMMIT
  12938. --GOTO GetRecordSet
  12939. GetRecordSet:
  12940. BEGIN
  12941. DECLARE @AllJobCount AS INT
  12942. ----返回查询数量
  12943. SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
  12944. SELECT @AllJobCount = ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
  12945. UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
  12946. ----返回20行查询结果
  12947. IF (@TableID = 0)
  12948. BEGIN
  12949. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  12950. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  12951. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
  12952. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  12953. a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
  12954. b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
  12955. ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
  12956. e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber,
  12957. f.Description EducationName,g.Description ExperienceName,
  12958. h.DescriptionCp dcSalary,i.DescriptionCp dcSalaryMax
  12959. FROM JobPublish a WITH(NOLOCK)
  12960. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  12961. INNER JOIN SearchDB..paSearchJobID_0 c WITH(NOLOCK) ON a.id = c.JobID
  12962. INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
  12963. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  12964. LEFT JOIN dcEducation f WITH(NOLOCK) ON f.ID = a.dcEducationID
  12965. INNER JOIN dcOthers g WITH(NOLOCK) ON g.DetailID = a.MinExperience AND g.Category='职位要求工作经验'
  12966. INNER JOIN dcSalary h WITH(NOLOCK) ON h.ID = a.dcSalaryID
  12967. INNER JOIN dcSalary i WITH(NOLOCK) ON i.ID = a.dcSalaryIDMax
  12968. WHERE paSearchConditionID=@paSearchConditionID
  12969. AND c.ID >= @MinId
  12970. ORDER BY c.ID, a.ID DESC
  12971. END
  12972. ELSE IF (@TableID = 1)
  12973. BEGIN
  12974. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  12975. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  12976. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
  12977. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  12978. a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
  12979. b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
  12980. ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
  12981. e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber,
  12982. f.Description EducationName,g.Description ExperienceName,
  12983. h.DescriptionCp dcSalary,i.DescriptionCp dcSalaryMax
  12984. FROM JobPublish a WITH(NOLOCK)
  12985. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  12986. INNER JOIN SearchDB..paSearchJobID_1 c WITH(NOLOCK) ON a.id = c.JobID
  12987. INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
  12988. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  12989. LEFT JOIN dcEducation f WITH(NOLOCK) ON f.ID = a.dcEducationID
  12990. INNER JOIN dcOthers g WITH(NOLOCK) ON g.DetailID = a.MinExperience AND g.Category='职位要求工作经验'
  12991. INNER JOIN dcSalary h WITH(NOLOCK) ON h.ID = a.dcSalaryID
  12992. INNER JOIN dcSalary i WITH(NOLOCK) ON i.ID = a.dcSalaryIDMax
  12993. WHERE paSearchConditionID=@paSearchConditionID
  12994. AND c.ID >= @MinId
  12995. ORDER BY c.ID, a.ID DESC
  12996. END
  12997. ELSE IF (@TableID = 2)
  12998. BEGIN
  12999. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  13000. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  13001. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
  13002. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  13003. a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
  13004. b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
  13005. ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
  13006. e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber,
  13007. f.Description EducationName,g.Description ExperienceName,
  13008. h.DescriptionCp dcSalary,i.DescriptionCp dcSalaryMax
  13009. FROM JobPublish a WITH(NOLOCK)
  13010. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  13011. INNER JOIN SearchDB..paSearchJobID_2 c WITH(NOLOCK) ON a.id = c.JobID
  13012. INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
  13013. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  13014. LEFT JOIN dcEducation f WITH(NOLOCK) ON f.ID = a.dcEducationID
  13015. INNER JOIN dcOthers g WITH(NOLOCK) ON g.DetailID = a.MinExperience AND g.Category='职位要求工作经验'
  13016. INNER JOIN dcSalary h WITH(NOLOCK) ON h.ID = a.dcSalaryID
  13017. INNER JOIN dcSalary i WITH(NOLOCK) ON i.ID = a.dcSalaryIDMax
  13018. WHERE paSearchConditionID=@paSearchConditionID
  13019. AND c.ID >= @MinId
  13020. 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 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
  13027. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  13028. a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
  13029. b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
  13030. ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
  13031. e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber,
  13032. f.Description EducationName,g.Description ExperienceName,
  13033. h.DescriptionCp dcSalary,i.DescriptionCp dcSalaryMax
  13034. FROM JobPublish a WITH(NOLOCK)
  13035. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  13036. INNER JOIN SearchDB..paSearchJobID_3 c WITH(NOLOCK) ON a.id = c.JobID
  13037. INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
  13038. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  13039. LEFT JOIN dcEducation f WITH(NOLOCK) ON f.ID = a.dcEducationID
  13040. INNER JOIN dcOthers g WITH(NOLOCK) ON g.DetailID = a.MinExperience AND g.Category='职位要求工作经验'
  13041. INNER JOIN dcSalary h WITH(NOLOCK) ON h.ID = a.dcSalaryID
  13042. INNER JOIN dcSalary i WITH(NOLOCK) ON i.ID = a.dcSalaryIDMax
  13043. WHERE paSearchConditionID=@paSearchConditionID
  13044. AND c.ID >= @MinId
  13045. ORDER BY c.ID, a.ID DESC
  13046. END
  13047. --RICHARD 2011-7-23 16:51分修改
  13048. ----返回统计数量
  13049. IF @Type=1
  13050. BEGIN
  13051. DECLARE @RegionCount AS INT
  13052. SELECT @RegionCount = -1
  13053. IF CHARINDEX(',', @dcRegionID) = 0 AND LEN(@dcRegionID) > 0
  13054. BEGIN
  13055. IF NOT LEFT(@dcRegionID,1) = 'p'
  13056. SELECT @RegionCount = COUNT(*) FROM dcRegion WHERE ParentID = @dcRegionID
  13057. END
  13058. IF (@TableID = 0)
  13059. BEGIN
  13060. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcJobType b ON b.ID = a.TitleID WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  13061. IF @RegionCount = 0
  13062. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  13063. ELSE
  13064. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcRegion b ON b.ID = a.TitleID WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  13065. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcEducation b ON b.ID = a.TitleID WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13066. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='职位要求工作经验' WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13067. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13068. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='工作性质' WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13069. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcCompanySize b ON b.ID = a.TitleID WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13070. END
  13071. IF (@TableID = 1)
  13072. BEGIN
  13073. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcJobType b ON b.ID = a.TitleID WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  13074. IF @RegionCount = 0
  13075. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  13076. ELSE
  13077. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcRegion b ON b.ID = a.TitleID WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  13078. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcEducation b ON b.ID = a.TitleID WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13079. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='职位要求工作经验' WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13080. SELECT * FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13081. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='工作性质' WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13082. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcCompanySize b ON b.ID = a.TitleID WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13083. END
  13084. IF (@TableID = 2)
  13085. BEGIN
  13086. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcJobType b ON b.ID = a.TitleID WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  13087. IF @RegionCount = 0
  13088. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  13089. ELSE
  13090. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcRegion b ON b.ID = a.TitleID WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  13091. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcEducation b ON b.ID = a.TitleID WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13092. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='职位要求工作经验' WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13093. SELECT * FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13094. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='工作性质' WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13095. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcCompanySize b ON b.ID = a.TitleID WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13096. END
  13097. IF (@TableID = 3)
  13098. BEGIN
  13099. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcJobType b ON b.ID = a.TitleID WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  13100. IF @RegionCount = 0
  13101. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  13102. ELSE
  13103. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcRegion b ON b.ID = a.TitleID WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  13104. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcEducation b ON b.ID = a.TitleID WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13105. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='职位要求工作经验' WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13106. SELECT * FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13107. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='工作性质' WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13108. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcCompanySize b ON b.ID = a.TitleID WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  13109. END
  13110. END
  13111. RETURN
  13112. END
  13113. END TRY
  13114. BEGIN CATCH
  13115. ---检查是否已经建立临时表,已经建立则删除
  13116. ROLLBACK TRANSACTION
  13117. ---检查是否已经建立临时表,已经建立则删除
  13118. DECLARE @para VARCHAR(MAX)
  13119. SET @para = '@dcJobTypeID=' + ISNULL(@dcJobTypeID, '') + '|' +
  13120. '@dcRegionID=' + ISNULL(@dcRegionID, '') + '|' +
  13121. '@dcIndustryID=' + ISNULL(@dcIndustryID, '') + '|' +
  13122. '@EmployType=' + ISNULL(@EmployType, '') + '|' +
  13123. '@KeyWord=' + ISNULL(@KeyWord, '') + '|' +
  13124. '@ORDER=' + ISNULL(@ORDER, '') + '|' +
  13125. '@SessionID=' + ISNULL(@SessionID, '') + '|' +
  13126. '@Welfare=' + ISNULL(@Welfare, '')
  13127. INSERT INTO ErrorLog
  13128. SELECT 'm2 ' + ISNULL(error_Message(), ' no msg')+ ' para=' + ISNULL(@Para, 'no para ') + ISNULL(@SQL, ' no sql'), error_number(), error_line(), GETDATE()
  13129. END CATCH
  13130. GO
  13131. /****** Object: StoredProcedure [dbo].[mblJobByAppSearchSelect2] Script Date: 2018/12/13 19:07:42 ******/
  13132. SET ANSI_NULLS ON
  13133. GO
  13134. SET QUOTED_IDENTIFIER ON
  13135. GO
  13136. CREATE proCEDURE [dbo].[mblJobByAppSearchSelect2]
  13137. (
  13138. @dcJobTypeID VARCHAR(100), --职位类别
  13139. @dcRegionID VARCHAR(100), --求职地区
  13140. @dcIndustryID VARCHAR(100), --求职行业
  13141. @dcSalaryID TINYINT, --月薪
  13142. @IsNegotiable BIT, --1允许面议,不面议
  13143. @MinExperience TINYINT, --工作经验,100为未选择
  13144. @dcEducationID TINYINT, --最低学历
  13145. @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习,
  13146. @KeyWord NVARCHAR(50), --关键词
  13147. @KeyType TINYINT, --搜索类别,0无;1-全文;2-职位;3-公司
  13148. @ORDER VARCHAR(4), --显示顺序,没有用
  13149. @RefreshNo INT, --1, 1天内;2, 3天内;3,一周内;4,15天内;5,一个月内;6超过一个月
  13150. @Type INT, --1:主动搜索 点击搜索按钮 10分钟,翻页60分钟有效;0:翻页搜索,不刷新
  13151. @PageNumber INT, --翻页页码
  13152. @SessionID varchar(50), --10
  13153. @CompanySizeID VARCHAR(1), --企业规模
  13154. @IsOnline INT,
  13155. @Welfare VARCHAR(50) --
  13156. )
  13157. AS
  13158. SET NOCOUNT ON
  13159. BEGIN
  13160. DECLARE @t AS TABLE(
  13161. dcJobTypeID VARCHAR(100),
  13162. dcRegionID VARCHAR(100),
  13163. dcIndustryID VARCHAR(100),
  13164. dcSalaryID TINYINT,
  13165. IsNegotiable INT,
  13166. MinExperience TINYINT,
  13167. dcEducationID TINYINT,
  13168. EmployType VARCHAR(10),
  13169. KeyWord NVARCHAR(50),
  13170. KeyType TINYINT,
  13171. [ORDER] VARCHAR(100),
  13172. RefreshNo INT,
  13173. Type INT,
  13174. PageNumber INT,
  13175. SessionID varchar(50),
  13176. CompanySizeID VARCHAR(1),
  13177. Welfare VARCHAR(50),
  13178. IsOnline INT
  13179. )
  13180. INSERT INTO @t
  13181. SELECT @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcSalaryID, @IsNegotiable,
  13182. @MinExperience, @dcEducationID, @EmployType, @KeyWord, @KeyType, @ORDER,
  13183. @RefreshNo, @Type, @PageNumber, @SessionID, @CompanySizeID, @Welfare, @IsOnline
  13184. DECLARE @json VARCHAR(max)
  13185. SET @json = (SELECT *, 10 Source from @t for json auto)
  13186. SET @json = RIGHT(LEFT(@json, LEN(@json) - 1), LEN(@json) - 2)
  13187. EXEC procJobPublishSelect @json
  13188. END
  13189. GO
  13190. /****** Object: StoredProcedure [dbo].[mblJobByCpMainIDSelect] Script Date: 2018/12/13 19:07:43 ******/
  13191. SET ANSI_NULLS ON
  13192. GO
  13193. SET QUOTED_IDENTIFIER ON
  13194. GO
  13195. --#####################################################
  13196. --创建时间:2016.3.22
  13197. --创建人:Lucifer
  13198. --alen 2018-4-9
  13199. --#####################################################
  13200. CREATE PROCEDURE [dbo].[mblJobByCpMainIDSelect]
  13201. (
  13202. @cpMainID INT
  13203. )
  13204. AS
  13205. BEGIN
  13206. SELECT a.ForwardEmail,a.IssueEnd,a.id,a.lng,a.lat,a.caMainID,a.RefreshDate,a.dcRegionId,a.dcJobTypeId,a.Welfare1,a.dcSalaryID,a.dcSalaryIDMax,
  13207. a.Welfare2,a.Welfare3,a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8,a.Welfare9,a.Welfare10,
  13208. a.Welfare11,a.Welfare12,a.Welfare13,a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,a.Welfare19,
  13209. a.Lng,a.Lat,a.Name,a.cpMainID,i.secondid encpmainid,a.secondid enjobid,i.Name cpName,i.MemberType,a.Responsibility,
  13210. a.Demand,a.MinAge,a.MaxAge,b.Description JobType,c.FullName JobRegion,d.Description NeedNumber,
  13211. e.Description EmployType,ISNULL((SELECT IsOnline FROM caOnline WHERE caMainId =a.caMainID), 0) AS IsOnline,
  13212. f.Description Salary,(CASE WHEN g.Description IS NULL THEN '不限' ELSE g.Description END) Education,a.IssueEnd,
  13213. h.Description Experience ,a.IssueEnd,a.Promotion,STUFF((SELECT '@' + Tags FROM jobTags WITH(NOLOCK) WHERE jobID = a.ID FOR XML PATH('')),1,1,'') JobTags
  13214. FROM Job a WITH(NOLOCK)
  13215. LEFT JOIN dcJobType b WITH(NOLOCK) ON a.dcJobTypeID=b.ID
  13216. LEFT JOIN dcRegion c WITH(NOLOCK) ON a.dcRegionID=c.ID
  13217. LEFT JOIN dcOthers d WITH(NOLOCK) ON a.NeedNumber=d.DetailID AND d.Category='招聘人数'
  13218. LEFT JOIN dcOthers e WITH(NOLOCK) ON a.EmployType=e.DetailID AND e.Category='工作性质'
  13219. LEFT JOIN dcSalary f WITH(NOLOCK) ON a.dcSalaryID=f.ID
  13220. LEFT JOIN dcEducation g WITH(NOLOCK) ON a.dcEducationID=g.ID
  13221. LEFT JOIN dcOthers h WITH(NOLOCK) ON a.MinExperience=h.DetailID AND h.Category='职位要求工作经验'
  13222. LEFT JOIN cpMain i WITH(NOLOCK) ON a.cpMainID=i.ID
  13223. WHERE a.cpMainID = @cpMainID
  13224. AND a.Valid = 1
  13225. ORDER BY DisplayNo,a.IssueEnd,a.id,a.LastModifyDate DESC
  13226. END
  13227. GO
  13228. /****** Object: StoredProcedure [dbo].[mblJobByIDSelect] Script Date: 2018/12/13 19:07:43 ******/
  13229. SET ANSI_NULLS ON
  13230. GO
  13231. SET QUOTED_IDENTIFIER ON
  13232. GO
  13233. --#####################################################
  13234. --创建时间:2014.11.06
  13235. --创建人:Nick
  13236. --说明:获取职位信息
  13237. --harry 2015-6-3
  13238. --增加forwardemail
  13239. --John 2015-8-19
  13240. --增加MemberType
  13241. --#####################################################
  13242. CREATE PROCEDURE [dbo].[mblJobByIDSelect]
  13243. (
  13244. @JobID VARCHAR(20),
  13245. @ColumnName VARCHAR(10)
  13246. )
  13247. AS
  13248. SET NOCOUNT ON
  13249. BEGIN
  13250. DECLARE @SQL VARCHAR(MAX)
  13251. SELECT @ColumnName = REPLACE(@ColumnName, '''', ''),
  13252. @JobID = REPLACE(@JobID, '''', '')
  13253. SET @SQL = '
  13254. SELECT a.ForwardEmail,a.IssueEnd,a.id,a.lng,a.lat,a.caMainID,a.RefreshDate,a.dcRegionId,a.dcJobTypeId,a.Welfare1,
  13255. a.Welfare2,a.Welfare3,a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8,a.Welfare9,a.Welfare10,
  13256. a.Welfare11,a.Welfare12,a.Welfare13,a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,Welfare19,Negotiable,
  13257. a.dcSalaryId, a.dcSalaryIdMax,a.Name,a.cpMainID,i.secondid encpmainid,a.secondid enjobid,i.Name cpName,i.MemberType,a.Responsibility,
  13258. a.Demand,a.MinAge,a.MaxAge,b.Description JobType,c.FullName JobRegion,d.Description NeedNumber,
  13259. e.Description EmployType,ISNULL((SELECT IsOnline FROM caOnline WHERE caMainId =a.caMainID), 0) AS IsOnline,
  13260. f.DescriptionCp Salary,j.DescriptionCp SalaryMax,(CASE WHEN g.Description IS NULL THEN ''不限'' ELSE g.Description END) Education,
  13261. h.Description Experience,a.Valid, i.dcProvinceId,
  13262. STUFF((SELECT ''@'' + Tags FROM jobTags WITH(NOLOCK) WHERE jobID = a.ID FOR XML PATH('''')),1,1,'''') JobTags
  13263. FROM Job a WITH(NOLOCK)
  13264. LEFT JOIN dcJobType b WITH(NOLOCK) ON a.dcJobTypeID=b.ID
  13265. LEFT JOIN dcRegion c WITH(NOLOCK) ON a.dcRegionID=c.ID
  13266. LEFT JOIN dcOthers d WITH(NOLOCK) ON a.NeedNumber=d.DetailID AND d.Category=''招聘人数''
  13267. LEFT JOIN dcOthers e WITH(NOLOCK) ON a.EmployType=e.DetailID AND e.Category=''工作性质''
  13268. LEFT JOIN dcSalary f WITH(NOLOCK) ON a.dcSalaryID=f.ID
  13269. LEFT JOIN dcEducation g WITH(NOLOCK) ON a.dcEducationID=g.ID
  13270. LEFT JOIN dcOthers h WITH(NOLOCK) ON a.MinExperience=h.DetailID AND h.Category=''职位要求工作经验''
  13271. LEFT JOIN cpMain i WITH(NOLOCK) ON a.cpMainID=i.ID
  13272. LEFT JOIN dcSalary j WITH(NOLOCK) ON a.dcSalaryIDMax=j.ID
  13273. WHERE a.' + @ColumnName + ' = ''' + @JobID + ''''
  13274. --print @sql
  13275. EXEC(@SQL)
  13276. END
  13277. GO
  13278. /****** Object: StoredProcedure [dbo].[mblJobByIntentionSelect] Script Date: 2018/12/13 19:07:43 ******/
  13279. SET ANSI_NULLS ON
  13280. GO
  13281. SET QUOTED_IDENTIFIER ON
  13282. GO
  13283. --[pcJobByIntentionSelectByPhone] 8100669
  13284. CREATE PROCEDURE [dbo].[mblJobByIntentionSelect]
  13285. (
  13286. @cvMainID INT
  13287. )
  13288. AS
  13289. BEGIN
  13290. DECLARE @JobType AS VARCHAR(100)
  13291. DECLARE @JobTypeName AS VARCHAR(1000)
  13292. DECLARE @JobPlace AS VARCHAR(100)
  13293. DECLARE @JobPlaceName AS VARCHAR(100)
  13294. DECLARE @Industry AS VARCHAR(100)
  13295. DECLARE @IndustryName AS VARCHAR(100)
  13296. DECLARE @INTTemp AS INT
  13297. DECLARE @STRTemp AS VARCHAR(20)
  13298. 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
  13299. 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
  13300. 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
  13301. --取得JobType
  13302. OPEN #JobType
  13303. FETCH NEXT FROM #JobType INTO @INTTemp,@STRTemp
  13304. WHILE @@FETCH_STATUS = 0
  13305. BEGIN
  13306. IF Len(@JobType) > 0
  13307. BEGIN
  13308. SET @JobType = @JobType + ' ' + Rtrim(CONVERT(CHAR(10),@INTTemp))
  13309. SET @JobTypeName = @JobTypeName + ' ' + @STRTemp
  13310. END
  13311. ELSE
  13312. BEGIN
  13313. SET @JobType = Rtrim(CONVERT(CHAR(10),@INTTemp))
  13314. SET @JobTypeName = @STRTemp
  13315. END
  13316. FETCH NEXT FROM #JobType INTO @INTTemp,@STRTemp
  13317. END
  13318. CLOSE #JobType
  13319. DEALLOCATE #JobType
  13320. --取得JobPlace
  13321. OPEN #JobPlace
  13322. FETCH NEXT FROM #JobPlace INTO @INTTemp,@STRTemp
  13323. WHILE @@FETCH_STATUS = 0
  13324. BEGIN
  13325. IF Len(@JobPlace) > 0
  13326. BEGIN
  13327. SET @JobPlace = @JobPlace + ' ' + Rtrim(CONVERT(CHAR(10),@INTTemp))
  13328. SET @JobPlaceName = @JobPlaceName + ' ' + @STRTemp
  13329. END
  13330. ELSE
  13331. BEGIN
  13332. SET @JobPlace = Rtrim(CONVERT(CHAR(10),@INTTemp))
  13333. SET @JobPlaceName = @STRTemp
  13334. END
  13335. FETCH NEXT FROM #JobPlace INTO @INTTemp,@STRTemp
  13336. END
  13337. CLOSE #JobPlace
  13338. DEALLOCATE #JobPlace
  13339. --取得Industry
  13340. OPEN #Industry
  13341. FETCH NEXT FROM #Industry INTO @INTTemp,@STRTemp
  13342. WHILE @@FETCH_STATUS = 0
  13343. BEGIN
  13344. IF Len(@Industry) > 0
  13345. BEGIN
  13346. SET @Industry = @Industry + ' ' + Rtrim(CONVERT(CHAR(10),@INTTemp))
  13347. SET @IndustryName = @IndustryName + ' ' + @STRTemp
  13348. END
  13349. ELSE
  13350. BEGIN
  13351. SET @Industry = Rtrim(CONVERT(CHAR(10),@INTTemp))
  13352. SET @IndustryName = @STRTemp
  13353. END
  13354. FETCH NEXT FROM #Industry INTO @INTTemp,@STRTemp
  13355. END
  13356. CLOSE #Industry
  13357. DEALLOCATE #Industry
  13358. SELECT
  13359. RelatedWorkYears,
  13360. EmployType,
  13361. dcSalaryID,
  13362. IsNegotiable,
  13363. b.Description Salary,
  13364. @JobType AS JobType,
  13365. @JobPlace AS JobPlace,
  13366. @Industry AS Industry,
  13367. @JobTypeName AS JobTypeName,
  13368. @JobPlaceName AS JobPlaceName,
  13369. @IndustryName AS IndustryName
  13370. From cvMain a WITH(NOLOCK)
  13371. LEFT JOIN dcSalary b WITH(NOLOCK) ON a.dcSalaryID=b.ID
  13372. WHERE a.id=@cvMainID
  13373. END
  13374. GO
  13375. /****** Object: StoredProcedure [dbo].[mblJobByJobIDSelect] Script Date: 2018/12/13 19:07:43 ******/
  13376. SET ANSI_NULLS ON
  13377. GO
  13378. SET QUOTED_IDENTIFIER ON
  13379. GO
  13380. --#####################################################
  13381. --创建时间:2014.11.6
  13382. --创建人:Nick
  13383. --说明:
  13384. --#####################################################
  13385. CREATE PROCEDURE [dbo].[mblJobByJobIDSelect]
  13386. (
  13387. @jobID VARCHAR(MAX)
  13388. )
  13389. AS
  13390. BEGIN
  13391. SELECT DISTINCT cpmainid
  13392. FROM Job WITH(NOLOCK)
  13393. WHERE id IN (SELECT a FROM fnsplit(@jobID, ','))
  13394. GROUP BY cpmainid
  13395. HAVING COUNT(1) > 3
  13396. END
  13397. GO
  13398. /****** Object: StoredProcedure [dbo].[mblJobByMapSearchSelect] Script Date: 2018/12/13 19:07:44 ******/
  13399. SET ANSI_NULLS ON
  13400. GO
  13401. SET QUOTED_IDENTIFIER ON
  13402. GO
  13403. CREATE PROCEDURE [dbo].[mblJobByMapSearchSelect]
  13404. (
  13405. @Distance INT, --距离范围
  13406. @Lng DECIMAL(8,5), --经度
  13407. @Lat DECIMAL(8,5), --纬度
  13408. @dcJobTypeID VARCHAR(100), --职位类别
  13409. @dcIndustryID VARCHAR(40), --dcprovinceid --求职行业
  13410. @dcSalaryID TINYINT, --月薪
  13411. @MinExperience TINYINT, --工作经验,100为未选择
  13412. @dcEducationID TINYINT, --最低学历
  13413. @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习,
  13414. @CompanySizeID VARCHAR(1), --企业规模
  13415. @Welfare NVARCHAR(50), --福利待遇
  13416. @Status TINYINT, --0:无关;1:企业在线;2:企业不在线
  13417. @Type INT, --1:主动搜索 点击搜索按钮 10分钟,翻页60分钟有效;0:翻页搜索,不刷新
  13418. @PageNumber INT --翻页页码
  13419. )
  13420. AS
  13421. --INSERT procLog SELECT 'mblJobByMapSearchSelect', @Lng, GETDATE()
  13422. IF @Distance IS NULL OR @Lng IS NULL OR @Lat IS NULL
  13423. RETURN
  13424. --@SessionId = 50
  13425. SET NOCOUNT ON
  13426. BEGIN TRY
  13427. DECLARE @IsOnline INT, @dcProvinceID VARCHAR(2)
  13428. IF @dcIndustryID LIKE 'p=%'
  13429. SET @dcProvinceID = REPLACE(@dcIndustryID, 'p=', '')
  13430. ELSE
  13431. SET @dcProvinceID = 0
  13432. BEGIN
  13433. ----给null值变量赋默认值
  13434. SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
  13435. @dcIndustryID = ISNULL(@dcIndustryID, ''),
  13436. @Welfare = RTRIM(dbo.FormatIDS(ISNULL(@Welfare, ''))),
  13437. @Type = ISNULL(@Type, 0),
  13438. @dcSalaryID = ISNULL(@dcSalaryID, 0),
  13439. @MinExperience = ISNULL(@MinExperience, 100),
  13440. @dcEducationID = ISNULL(@dcEducationID, 0),
  13441. @PageNumber = ISNULL(@PageNumber, 0),
  13442. @CompanySizeID = ISNULL(@CompanySizeID, '0'),
  13443. @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END,
  13444. @IsOnline = ISNULL(@Status, 0)
  13445. IF @dcEducationID = 100
  13446. SET @dcEducationID = 0
  13447. IF RIGHT(@dcJobTypeID, 1) = ','
  13448. SET @dcJobTypeID = LEFT(@dcJobTypeID, LEN(@dcJobTypeID) - 1)
  13449. IF RIGHT(@dcIndustryID, 1) = ','
  13450. SET @dcIndustryID = LEFT(@dcIndustryID, LEN(@dcIndustryID) - 1)
  13451. DECLARE @paSearchConditionID AS INT,
  13452. @MinId AS INT,
  13453. @PageSize AS TINYINT,
  13454. @TableID AS TINYINT
  13455. SELECT @paSearchConditionID = 0, @PageSize = 30 --每页的行数
  13456. ----搜索1分钟前的数据
  13457. SELECT TOP 1 @paSearchConditionID = ID
  13458. FROM SearchDB..paSearchCondition WITH(NOLOCK)
  13459. WHERE JobType=@dcJobTypeID AND IsOnline = @IsOnline
  13460. AND Industry=@dcIndustryID AND Education=@dcEducationID
  13461. AND Experience=@MinExperience AND Salary=@dcSalaryID
  13462. AND EmployType=@EmployType AND CompanySizeID = @CompanySizeID
  13463. AND Lat = @Lat AND LNg = @Lng AND Distance = @Distance
  13464. AND Welfare = @Welfare AND IsDelete = 0 AND dcProvinceId = @dcProvinceId
  13465. ORDER BY ID DESC
  13466. IF ISNULL(@paSearchConditionID, 0) = 0
  13467. BEGIN
  13468. SET @Type =1
  13469. GOTO SelectReset --无数据,重新搜索
  13470. END
  13471. ELSE
  13472. BEGIN
  13473. SELECT @TableID = @paSearchConditionID % 4
  13474. GOTO GetRecordSet --从临时结果中提取数据
  13475. END
  13476. END
  13477. SelectReset: --从job中搜索数据
  13478. BEGIN TRAN
  13479. DECLARE @SQL AS VARCHAR(8000), @WHERE AS VARCHAR(8000), @FROM AS VARCHAR(1000),
  13480. @JobType AS VARCHAR(3000), @ValidJobNumber AS INT
  13481. DECLARE @T_JobType AS TABLE(ID INT)
  13482. ----记录查询条件
  13483. INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, Industry,
  13484. Lng, Lat, Distance, Welfare, KeyWord, KeyType, ReuseNumber, Education, Experience,
  13485. Salary, EmployType, CompanySizeID, IsOnline, dcProvinceId)
  13486. VALUES(
  13487. 50, GETDATE(), @dcJobTypeID, @dcIndustryID, @Lng, @Lat,
  13488. @Distance, @Welfare, '', 0, 0, @dcEducationID, @MinExperience,
  13489. @dcSalaryID, @EmployType, @CompanySizeID, @IsOnline, @dcProvinceId)
  13490. SET @paSearchConditionID = @@IDENTITY
  13491. SELECT @TableID = @paSearchConditionID % 4
  13492. ------生成职位类别的表变量,因为职位类别有包含(父子)关系
  13493. SELECT @JobType=''
  13494. ----生成求聘职位的表变量
  13495. IF LEN(@dcJobTypeID) > 0
  13496. BEGIN
  13497. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  13498. INSERT INTO @T_Temp
  13499. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  13500. INSERT INTO @T_JobType
  13501. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  13502. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  13503. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  13504. OR ID IN(SELECT ID FROM @T_TEMP)
  13505. ----生成in字符串
  13506. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  13507. IF RIGHT(@JobType, 1) = ','
  13508. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  13509. END
  13510. ----建立临时表
  13511. CREATE TABLE #Job(
  13512. RowID INT IDENTITY(1, 1),
  13513. ID INT NOT NULL,
  13514. dcJobTypeID SMALLINT NOT NULL,
  13515. dcJobTypeIDMinor SMALLINT NULL,
  13516. dcSalaryID TINYINT NOT NULL,
  13517. dcRegionID VARCHAR(6) NULL,
  13518. dcEducationID TINYINT NOT NULL,
  13519. MinExperience TINYINT NOT NULL,
  13520. RefreshDate SMALLDATETIME NULL,
  13521. EmployType TINYINT NULL,
  13522. dcCompanySizeID SMALLINT NULL
  13523. )
  13524. ------刷新时间,根据刷新时间编号计算
  13525. ----生成插入临时表的Sql语句
  13526. SET @SQL='
  13527. INSERT INTO #Job
  13528. SELECT a.ID, a.dcJobTypeID,
  13529. a.dcJobTypeIDMinor, a.dcSalaryID,
  13530. a.dcRegionID, a.dcEducationID, a.MinExperience,
  13531. a.IssueDate,a.EmployType,b.dcCompanySizeID'
  13532. SET @FROM = '
  13533. FROM JobPublish a WITH(NOLOCK)
  13534. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  13535. ----职位有效,单位新有效
  13536. IF LEN(@dcProvinceID) > 1
  13537. SET @WHERE = '
  13538. WHERE b.dcProvinceID = ' + @dcProvinceID + '
  13539. AND a.Valid = 1
  13540. AND b.Valid = 1'
  13541. ELSE
  13542. SET @WHERE = '
  13543. WHERE a.Valid = 1
  13544. AND b.Valid = 1'
  13545. ----需要增加全文索引的关键字查询
  13546. ----职位类别
  13547. IF LEN(@dcJobTypeID) > 0
  13548. SET @WHERE = @WHERE + '
  13549. AND (a.dcJobTypeID IN(' + @JobType +')
  13550. OR a.dcJobTypeIDMinor IN(' + @JobType + '))'
  13551. IF @dcSalaryID > 0
  13552. BEGIN
  13553. IF @dcSalaryID < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
  13554. BEGIN
  13555. SET @WHERE = @WHERE + '
  13556. AND a.dcSalaryID IN(' + LTRIM(STR(@dcSalaryID)) + ',' + LTRIM(STR(@dcSalaryID + 1))
  13557. SET @WHERE = @WHERE + ')'
  13558. END
  13559. IF @dcSalaryID = 100 ----从筛选结果中点击面议,值是100
  13560. BEGIN
  13561. SET @WHERE = @WHERE + '
  13562. AND a.dcSalaryID = 100'
  13563. END
  13564. IF @dcSalaryID > 100 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  13565. SET @WHERE = @WHERE + '
  13566. AND a.dcSalaryID=' + LTRIM(STR(@dcSalaryID-100))
  13567. END
  13568. ----工作经验要求
  13569. IF @MinExperience < 100
  13570. SET @WHERE = @WHERE + '
  13571. AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
  13572. ----学历要求
  13573. ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
  13574. IF @dcEducationID > 0
  13575. IF @dcEducationID = 2
  13576. SET @WHERE = @WHERE + '
  13577. AND a.dcEducationID IN(2, 3, 4)'
  13578. ELSE
  13579. SET @WHERE = @WHERE + '
  13580. AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
  13581. ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
  13582. IF LEN(@EmployType) > 0
  13583. SET @WHERE = @WHERE + '
  13584. AND a.EmployType IN (' + @EmployType + ')'
  13585. IF @CompanySizeID BETWEEN 1 AND 6
  13586. SET @WHERE = @WHERE + '
  13587. AND b.dcCompanySizeID = ' + LTRIM(STR(@CompanySizeID))
  13588. IF LEN(@Welfare) > 0
  13589. SET @WHERE = @WHERE + '
  13590. AND a.Welfare' + REPLACE(@Welfare, ',', ' = 1 AND a.Welfare') + ' = 1'
  13591. IF @IsOnline = 1
  13592. SET @WHERE = @WHERE + '
  13593. AND a.caMainId IN(SELECT caMainId FROM caOnline WITH(NOLOCK) WHERE IsOnline = 1) '
  13594. DECLARE @Degree AS DECIMAL(8,5),@LBLng AS DECIMAL(8,5),@LBLat AS DECIMAL(8,5),
  13595. @RTLng AS DECIMAL(8,5),@RTLat AS DECIMAL(8,5)
  13596. SET @Degree = @Distance / 100000.0;
  13597. SET @LBLng = @Lng - @Degree
  13598. SET @LBLat = @Lat - @Degree
  13599. SET @RTLng = @Lng + @Degree
  13600. SET @RTLat = @Lat + @Degree
  13601. SET @WHERE = @WHERE + '
  13602. AND a.Lng BETWEEN ' + CONVERT(VARCHAR,@LBLng) + ' AND ' + CONVERT(VARCHAR,@RTLng) + '
  13603. AND a.Lat BETWEEN ' + CONVERT(VARCHAR,@LBLat) + ' AND ' + CONVERT(VARCHAR,@RTLat) + '
  13604. AND (a.Lng-' + CONVERT(VARCHAR,@Lng) + ')*(a.Lng-' + CONVERT(VARCHAR,@Lng) + ')+
  13605. (a.Lat-' + CONVERT(VARCHAR,@Lat) + ')*(a.Lat-' + CONVERT(VARCHAR,@Lat) + ')<' + CONVERT(VARCHAR,@Degree*@Degree)
  13606. SET @SQL = @SQL + @FROM + @WHERE
  13607. --IF LEN(@ORDER)>0
  13608. SET @SQL=@SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
  13609. --原来是ORDER BY a.IssueDate DESC, a.ID,Richard 2011年11月23日17:06分修改
  13610. ----把符合条件的职位全部列出
  13611. --PRINT @SQL
  13612. EXEC(@SQL)
  13613. SET @ValidJobNumber = @@ROWCOUNT
  13614. ----记录查询结果总数
  13615. UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@SQL WHERE ID=@paSearchConditionID
  13616. ----插入JobType数据
  13617. DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
  13618. IF (@TableID = 0)
  13619. BEGIN
  13620. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  13621. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  13622. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  13623. ----计算全部某职位类别,2, 4位的数据
  13624. UPDATE a SET a.TitleValue = b.TitleValue
  13625. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
  13626. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  13627. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  13628. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  13629. GROUP BY LEFT(TitleID, 2)) b
  13630. WHERE a.TitleId = b.TitleID
  13631. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  13632. ----写入TitleDesc
  13633. UPDATE a SET a.TitleDesc = b.Description
  13634. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  13635. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  13636. AND a.Title = 'JobType'
  13637. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  13638. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  13639. GROUP BY dcSalaryID ORDER BY dcSalaryID
  13640. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  13641. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  13642. GROUP BY dcRegionID ORDER BY dcRegionID
  13643. ----计算全部地区,2位的数据
  13644. UPDATE a SET a.TitleValue = b.TitleValue
  13645. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
  13646. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  13647. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  13648. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  13649. GROUP BY LEFT(TitleID, 2)) b
  13650. WHERE a.TitleId = b.TitleID
  13651. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  13652. ----计算全部地区,4位的数据
  13653. UPDATE a SET a.TitleValue = b.TitleValue
  13654. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), (
  13655. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  13656. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  13657. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  13658. AND LEN(TitleID) >3
  13659. GROUP BY LEFT(TitleID, 4)) b
  13660. WHERE a.TitleId = b.TitleID
  13661. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  13662. ----写入TitleDesc
  13663. UPDATE a SET a.TitleDesc = b.Description
  13664. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  13665. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  13666. AND a.Title = 'Region'
  13667. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  13668. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  13669. FROM #Job WITH(NOLOCK)
  13670. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  13671. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  13672. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  13673. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  13674. GROUP BY MinExperience ORDER BY MinExperience
  13675. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  13676. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  13677. GROUP BY EmployType ORDER BY EmployType
  13678. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  13679. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  13680. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  13681. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  13682. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  13683. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  13684. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  13685. SET @TopRows = @@ROWCOUNT
  13686. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  13687. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  13688. SET @AllRows = @@ROWCOUNT
  13689. IF @TopRows = 0 AND @AllRows > 100
  13690. UPDATE SearchDB..paSearchJobID_0 SET IsTop = 1
  13691. WHERE paSearchConditionID = @paSearchConditionID
  13692. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  13693. END
  13694. ELSE IF (@TableId = 1)
  13695. BEGIN
  13696. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  13697. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  13698. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  13699. ----计算全部某职位类别,2, 4位的数据
  13700. UPDATE a SET a.TitleValue = b.TitleValue
  13701. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
  13702. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  13703. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  13704. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  13705. GROUP BY LEFT(TitleID, 2)) b
  13706. WHERE a.TitleId = b.TitleID
  13707. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  13708. ----写入TitleDesc
  13709. UPDATE a SET a.TitleDesc = b.Description
  13710. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  13711. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  13712. AND a.Title = 'JobType'
  13713. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  13714. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  13715. GROUP BY dcSalaryID ORDER BY dcSalaryID
  13716. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  13717. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  13718. GROUP BY dcRegionID ORDER BY dcRegionID
  13719. ----计算全部地区,2位的数据
  13720. UPDATE a SET a.TitleValue = b.TitleValue
  13721. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
  13722. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  13723. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  13724. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  13725. GROUP BY LEFT(TitleID, 2)) b
  13726. WHERE a.TitleId = b.TitleID
  13727. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  13728. ----计算全部地区,4位的数据
  13729. UPDATE a SET a.TitleValue = b.TitleValue
  13730. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), (
  13731. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  13732. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  13733. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  13734. AND LEN(TitleID) >3
  13735. GROUP BY LEFT(TitleID, 4)) b
  13736. WHERE a.TitleId = b.TitleID
  13737. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  13738. ----写入TitleDesc
  13739. UPDATE a SET a.TitleDesc = b.Description
  13740. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  13741. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  13742. AND a.Title = 'Region'
  13743. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  13744. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  13745. FROM #Job WITH(NOLOCK)
  13746. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  13747. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  13748. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  13749. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  13750. GROUP BY MinExperience ORDER BY MinExperience
  13751. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  13752. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  13753. GROUP BY EmployType ORDER BY EmployType
  13754. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  13755. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  13756. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  13757. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  13758. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  13759. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  13760. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  13761. SET @TopRows = @@ROWCOUNT
  13762. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  13763. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  13764. SET @AllRows = @@ROWCOUNT
  13765. IF @TopRows = 0 AND @AllRows > 100
  13766. UPDATE SearchDB..paSearchJobID_1 SET IsTop = 1
  13767. WHERE paSearchConditionID = @paSearchConditionID
  13768. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  13769. END
  13770. ELSE IF (@TableId = 2)
  13771. BEGIN
  13772. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  13773. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  13774. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  13775. ----计算全部某职位类别,2, 4位的数据
  13776. UPDATE a SET a.TitleValue = b.TitleValue
  13777. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
  13778. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  13779. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  13780. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  13781. GROUP BY LEFT(TitleID, 2)) b
  13782. WHERE a.TitleId = b.TitleID
  13783. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  13784. ----写入TitleDesc
  13785. UPDATE a SET a.TitleDesc = b.Description
  13786. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  13787. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  13788. AND a.Title = 'JobType'
  13789. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  13790. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  13791. GROUP BY dcSalaryID ORDER BY dcSalaryID
  13792. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  13793. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  13794. GROUP BY dcRegionID ORDER BY dcRegionID
  13795. ----计算全部地区,2位的数据
  13796. UPDATE a SET a.TitleValue = b.TitleValue
  13797. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
  13798. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  13799. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  13800. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  13801. GROUP BY LEFT(TitleID, 2)) b
  13802. WHERE a.TitleId = b.TitleID
  13803. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  13804. ----计算全部地区,4位的数据
  13805. UPDATE a SET a.TitleValue = b.TitleValue
  13806. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), (
  13807. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  13808. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  13809. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  13810. AND LEN(TitleID) >3
  13811. GROUP BY LEFT(TitleID, 4)) b
  13812. WHERE a.TitleId = b.TitleID
  13813. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  13814. ----写入TitleDesc
  13815. UPDATE a SET a.TitleDesc = b.Description
  13816. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  13817. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  13818. AND a.Title = 'Region'
  13819. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  13820. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  13821. FROM #Job WITH(NOLOCK)
  13822. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  13823. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  13824. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  13825. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  13826. GROUP BY MinExperience ORDER BY MinExperience
  13827. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  13828. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  13829. GROUP BY EmployType ORDER BY EmployType
  13830. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  13831. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  13832. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  13833. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  13834. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  13835. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  13836. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  13837. SET @TopRows = @@ROWCOUNT
  13838. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  13839. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  13840. SET @AllRows = @@ROWCOUNT
  13841. IF @TopRows = 0 AND @AllRows > 100
  13842. UPDATE SearchDB..paSearchJobID_2 SET IsTop = 1
  13843. WHERE paSearchConditionID = @paSearchConditionID
  13844. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  13845. END
  13846. ELSE IF (@TableId = 3)
  13847. BEGIN
  13848. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  13849. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  13850. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  13851. ----计算全部某职位类别,2, 4位的数据
  13852. UPDATE a SET a.TitleValue = b.TitleValue
  13853. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
  13854. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  13855. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  13856. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  13857. GROUP BY LEFT(TitleID, 2)) b
  13858. WHERE a.TitleId = b.TitleID
  13859. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  13860. ----写入TitleDesc
  13861. UPDATE a SET a.TitleDesc = b.Description
  13862. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  13863. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  13864. AND a.Title = 'JobType'
  13865. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  13866. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  13867. GROUP BY dcSalaryID ORDER BY dcSalaryID
  13868. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  13869. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  13870. GROUP BY dcRegionID ORDER BY dcRegionID
  13871. ----计算全部地区,2位的数据
  13872. UPDATE a SET a.TitleValue = b.TitleValue
  13873. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
  13874. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  13875. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  13876. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  13877. GROUP BY LEFT(TitleID, 2)) b
  13878. WHERE a.TitleId = b.TitleID
  13879. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  13880. ----计算全部地区,4位的数据
  13881. UPDATE a SET a.TitleValue = b.TitleValue
  13882. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), (
  13883. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  13884. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  13885. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  13886. AND LEN(TitleID) >3
  13887. GROUP BY LEFT(TitleID, 4)) b
  13888. WHERE a.TitleId = b.TitleID
  13889. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  13890. ----写入TitleDesc
  13891. UPDATE a SET a.TitleDesc = b.Description
  13892. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  13893. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  13894. AND a.Title = 'Region'
  13895. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  13896. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  13897. FROM #Job WITH(NOLOCK)
  13898. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  13899. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  13900. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  13901. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  13902. GROUP BY MinExperience ORDER BY MinExperience
  13903. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  13904. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  13905. GROUP BY EmployType ORDER BY EmployType
  13906. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  13907. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  13908. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  13909. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  13910. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  13911. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  13912. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  13913. SET @TopRows = @@ROWCOUNT
  13914. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  13915. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  13916. SET @AllRows = @@ROWCOUNT
  13917. IF @TopRows = 0 AND @AllRows > 100
  13918. UPDATE SearchDB..paSearchJobID_3 SET IsTop = 1
  13919. WHERE paSearchConditionID = @paSearchConditionID
  13920. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  13921. END
  13922. DROP TABLE #Job
  13923. --PRINT 'DROP #JOB ' + CONVERT(VARCHAR(30), GETDATE(), 121)
  13924. COMMIT
  13925. --GOTO GetRecordSet
  13926. GetRecordSet:
  13927. BEGIN
  13928. DECLARE @AllJobCount AS INT
  13929. ----返回查询数量
  13930. SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
  13931. SELECT @AllJobCount = ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
  13932. UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
  13933. ----返回20行查询结果
  13934. IF (@TableID = 0)
  13935. BEGIN
  13936. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  13937. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  13938. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName,
  13939. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  13940. a.dcRegionID, a.dcEducationID, b.HasLicence, b.IsRefreshed, dcCompanySizeID,
  13941. a.MinExperience, a.MinAge, a.MaxAge, a.RefreshDate, a.Lng, a.Lat,
  13942. b.Name as cpName, c.IsTop, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,
  13943. a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
  13944. a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,
  13945. ISNULL((SELECT IsOnline FROM caOnline WITH(NOLOCK) WHERE caMainId = a.caMainId), 0) IsOnline, b.LogoFile LogoUrl,@AllJobCount JobNumber,
  13946. d.FullName RegionName,e.Description EducationName,f.Description ExperienceName,g.DescriptionCp dcSalary,h.DescriptionCp dcSalaryMax
  13947. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_0 c WITH(NOLOCK),
  13948. dcRegion d WITH(NOLOCK),dcEducation e WITH(NOLOCK),dcOthers f WITH(NOLOCK),dcSalary g WITH(NOLOCK),dcSalary h WITH(NOLOCK)
  13949. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  13950. AND d.ID = a.dcRegionID AND e.ID = a.dcEducationID AND f.DetailID = a.MinExperience
  13951. AND f.Category='职位要求工作经验' AND g.ID = a.dcSalaryID AND h.ID = a.dcSalaryIDMax
  13952. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  13953. END
  13954. ELSE IF (@TableID = 1)
  13955. BEGIN
  13956. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  13957. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  13958. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName,
  13959. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  13960. a.dcRegionID, a.dcEducationID, b.HasLicence, b.IsRefreshed, dcCompanySizeID,
  13961. a.MinExperience, a.MinAge, a.MaxAge, a.RefreshDate, a.Lng, a.Lat,
  13962. b.Name as cpName, c.IsTop, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,
  13963. a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
  13964. a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,
  13965. ISNULL((SELECT IsOnline FROM caOnline WITH(NOLOCK) WHERE caMainId = a.caMainId), 0) IsOnline,
  13966. b.LogoFile LogoUrl,@AllJobCount JobNumber,
  13967. d.FullName RegionName,e.Description EducationName,f.Description ExperienceName,g.DescriptionCp dcSalary,h.DescriptionCp dcSalaryMax
  13968. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_1 c WITH(NOLOCK),
  13969. dcRegion d WITH(NOLOCK),dcEducation e WITH(NOLOCK),dcOthers f WITH(NOLOCK),dcSalary g WITH(NOLOCK),dcSalary h WITH(NOLOCK)
  13970. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  13971. AND d.ID = a.dcRegionID AND e.ID = a.dcEducationID AND f.DetailID = a.MinExperience
  13972. AND f.Category='职位要求工作经验' AND g.ID = a.dcSalaryID AND h.ID = a.dcSalaryIDMax
  13973. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  13974. END
  13975. ELSE IF (@TableID = 2)
  13976. BEGIN
  13977. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  13978. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  13979. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName,
  13980. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  13981. a.dcRegionID, a.dcEducationID, b.HasLicence, b.IsRefreshed, dcCompanySizeID,
  13982. a.MinExperience, a.MinAge, a.MaxAge, a.RefreshDate, a.Lng, a.Lat,
  13983. b.Name as cpName, c.IsTop, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,
  13984. a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
  13985. a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,
  13986. ISNULL((SELECT IsOnline FROM caOnline WITH(NOLOCK) WHERE caMainId = a.caMainId), 0) IsOnline,
  13987. b.LogoFile LogoUrl, @AllJobCount JobNumber,
  13988. d.FullName RegionName,e.Description EducationName,f.Description ExperienceName,g.DescriptionCp dcSalary,h.DescriptionCp dcSalaryMax
  13989. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_2 c WITH(NOLOCK),
  13990. dcRegion d WITH(NOLOCK),dcEducation e WITH(NOLOCK),dcOthers f WITH(NOLOCK),dcSalary g WITH(NOLOCK),dcSalary h WITH(NOLOCK)
  13991. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  13992. AND d.ID = a.dcRegionID AND e.ID = a.dcEducationID AND f.DetailID = a.MinExperience
  13993. AND f.Category='职位要求工作经验' AND g.ID = a.dcSalaryID AND h.ID = a.dcSalaryIDMax
  13994. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  13995. END
  13996. ELSE IF (@TableID = 3)
  13997. BEGIN
  13998. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  13999. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  14000. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  14001. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  14002. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID, b.HasLicence, b.IsRefreshed, dcCompanySizeID,
  14003. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  14004. a.IsDelete, a.AddDate, a.RefreshDate, a.Lng, a.Lat,
  14005. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  14006. b.UnLimitedDate, b.BalanceDate, b.Balance,
  14007. b.MemberType, '' cpIndustry,
  14008. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,
  14009. a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
  14010. a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,
  14011. ISNULL((SELECT IsOnline FROM caOnline WITH(NOLOCK) WHERE caMainId = a.caMainId), 0) IsOnline,
  14012. b.LogoFile LogoUrl,@AllJobCount JobNumber,
  14013. d.FullName RegionName,e.Description EducationName,f.Description ExperienceName,g.DescriptionCp dcSalary,h.DescriptionCp dcSalaryMax
  14014. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_3 c WITH(NOLOCK),
  14015. dcRegion d WITH(NOLOCK),dcEducation e WITH(NOLOCK),dcOthers f WITH(NOLOCK),dcSalary g WITH(NOLOCK),dcSalary h WITH(NOLOCK)
  14016. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  14017. AND d.ID = a.dcRegionID AND e.ID = a.dcEducationID AND f.DetailID = a.MinExperience
  14018. AND f.Category='职位要求工作经验' AND g.ID = a.dcSalaryID AND h.ID = a.dcSalaryIDMax
  14019. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  14020. END
  14021. --RICHARD 2011-7-23 16:51分修改
  14022. ----返回统计数量
  14023. IF @Type=1
  14024. BEGIN
  14025. IF (@TableID = 0)
  14026. BEGIN
  14027. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcJobType b ON b.ID = a.TitleID WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  14028. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcRegion b ON b.ID = a.TitleID WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  14029. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcEducation b ON b.ID = a.TitleID WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14030. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='职位要求工作经验' WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14031. SELECT * FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14032. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='工作性质' WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14033. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcCompanySize b ON b.ID = a.TitleID WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14034. END
  14035. IF (@TableID = 1)
  14036. BEGIN
  14037. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcJobType b ON b.ID = a.TitleID WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  14038. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcRegion b ON b.ID = a.TitleID WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  14039. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcEducation b ON b.ID = a.TitleID WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14040. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='职位要求工作经验' WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14041. SELECT * FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14042. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='工作性质' WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14043. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcCompanySize b ON b.ID = a.TitleID WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14044. END
  14045. IF (@TableID = 2)
  14046. BEGIN
  14047. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcJobType b ON b.ID = a.TitleID WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  14048. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcRegion b ON b.ID = a.TitleID WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  14049. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcEducation b ON b.ID = a.TitleID WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14050. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='职位要求工作经验' WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14051. SELECT * FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14052. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='工作性质' WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14053. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcCompanySize b ON b.ID = a.TitleID WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14054. END
  14055. IF (@TableID = 3)
  14056. BEGIN
  14057. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcJobType b ON b.ID = a.TitleID WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  14058. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcRegion b ON b.ID = a.TitleID WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  14059. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcEducation b ON b.ID = a.TitleID WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14060. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='职位要求工作经验' WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14061. SELECT * FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14062. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='工作性质' WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14063. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcCompanySize b ON b.ID = a.TitleID WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14064. END
  14065. END
  14066. RETURN
  14067. END
  14068. END TRY
  14069. BEGIN CATCH
  14070. ---检查是否已经建立临时表,已经建立则删除
  14071. ROLLBACK TRANSACTION
  14072. ---检查是否已经建立临时表,已经建立则删除
  14073. DECLARE @para VARCHAR(MAX)
  14074. SET @para = '@dcJobTypeID=' + ISNULL(@dcJobTypeID, '') + '|' +
  14075. '@dcIndustryID=' + ISNULL(@dcIndustryID, '') + '|' +
  14076. '@EmployType=' + ISNULL(@EmployType, '') + '|' +
  14077. '@Welfare=' + ISNULL(@Welfare, '')
  14078. INSERT INTO ErrorLog
  14079. SELECT 'm3 ' + ISNULL(error_Message(), ' no msg')+ ' para=' + ISNULL(@Para, 'no para ') + ISNULL(@SQL, ' no sql'), error_number(), error_line(), GETDATE()
  14080. END CATCH
  14081. GO
  14082. /****** Object: StoredProcedure [dbo].[mblJobByMapSearchSelectNew] Script Date: 2018/12/13 19:07:44 ******/
  14083. SET ANSI_NULLS ON
  14084. GO
  14085. SET QUOTED_IDENTIFIER ON
  14086. GO
  14087. CREATE PROCEDURE [dbo].[mblJobByMapSearchSelectNew]
  14088. (
  14089. @Distance INT, --距离范围
  14090. @Lng DECIMAL(8,5), --经度
  14091. @Lat DECIMAL(8,5), --纬度
  14092. @dcJobTypeID VARCHAR(100), --职位类别
  14093. @dcIndustryID VARCHAR(40), --dcprovinceid --求职行业
  14094. @dcSalaryID TINYINT, --月薪
  14095. @MinExperience TINYINT, --工作经验,100为未选择
  14096. @dcEducationID TINYINT, --最低学历
  14097. @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习,
  14098. @CompanySizeID VARCHAR(1), --企业规模
  14099. @Welfare NVARCHAR(50), --福利待遇
  14100. @Status TINYINT, --0:无关;1:企业在线;2:企业不在线
  14101. @Type INT, --1:主动搜索 点击搜索按钮 10分钟,翻页60分钟有效;0:翻页搜索,不刷新
  14102. @PageNumber INT --翻页页码
  14103. )
  14104. AS
  14105. --INSERT procLog SELECT 'mblJobByMapSearchSelect', @Lng, GETDATE()
  14106. IF @Distance IS NULL OR @Lng IS NULL OR @Lat IS NULL
  14107. RETURN
  14108. --@SessionId = 50
  14109. SET NOCOUNT ON
  14110. BEGIN TRY
  14111. DECLARE @IsOnline INT, @dcProvinceID VARCHAR(2)
  14112. IF @dcIndustryID LIKE 'p=%'
  14113. SET @dcProvinceID = REPLACE(@dcIndustryID, 'p=', '')
  14114. ELSE
  14115. SET @dcProvinceID = 0
  14116. BEGIN
  14117. ----给null值变量赋默认值
  14118. SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
  14119. @dcIndustryID = ISNULL(@dcIndustryID, ''),
  14120. @Welfare = RTRIM(dbo.FormatIDS(ISNULL(@Welfare, ''))),
  14121. @Type = ISNULL(@Type, 0),
  14122. @dcSalaryID = ISNULL(@dcSalaryID, 0),
  14123. @MinExperience = ISNULL(@MinExperience, 100),
  14124. @dcEducationID = ISNULL(@dcEducationID, 0),
  14125. @PageNumber = ISNULL(@PageNumber, 0),
  14126. @CompanySizeID = ISNULL(@CompanySizeID, '0'),
  14127. @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END,
  14128. @IsOnline = ISNULL(@Status, 0)
  14129. IF @dcEducationID = 100
  14130. SET @dcEducationID = 0
  14131. IF RIGHT(@dcJobTypeID, 1) = ','
  14132. SET @dcJobTypeID = LEFT(@dcJobTypeID, LEN(@dcJobTypeID) - 1)
  14133. IF RIGHT(@dcIndustryID, 1) = ','
  14134. SET @dcIndustryID = LEFT(@dcIndustryID, LEN(@dcIndustryID) - 1)
  14135. DECLARE @paSearchConditionID AS INT,
  14136. @MinId AS INT,
  14137. @PageSize AS TINYINT,
  14138. @TableID AS TINYINT
  14139. SELECT @paSearchConditionID = 0, @PageSize = 30 --每页的行数
  14140. ----搜索1分钟前的数据
  14141. SELECT TOP 1 @paSearchConditionID = ID
  14142. FROM SearchDB..paSearchCondition WITH(NOLOCK)
  14143. WHERE JobType=@dcJobTypeID AND IsOnline = @IsOnline
  14144. AND Industry=@dcIndustryID AND Education=@dcEducationID
  14145. AND Experience=@MinExperience AND Salary=@dcSalaryID
  14146. AND EmployType=@EmployType AND CompanySizeID = @CompanySizeID
  14147. AND Lat = @Lat AND LNg = @Lng AND Distance = @Distance
  14148. AND Welfare = @Welfare AND IsDelete = 0 AND dcProvinceId = @dcProvinceId
  14149. ORDER BY ID DESC
  14150. IF ISNULL(@paSearchConditionID, 0) = 0
  14151. BEGIN
  14152. SET @Type =1
  14153. GOTO SelectReset --无数据,重新搜索
  14154. END
  14155. ELSE
  14156. BEGIN
  14157. SELECT @TableID = @paSearchConditionID % 4
  14158. GOTO GetRecordSet --从临时结果中提取数据
  14159. END
  14160. END
  14161. SelectReset: --从job中搜索数据
  14162. BEGIN TRAN
  14163. DECLARE @SQL AS VARCHAR(8000), @WHERE AS VARCHAR(8000), @FROM AS VARCHAR(1000),
  14164. @JobType AS VARCHAR(3000), @ValidJobNumber AS INT
  14165. DECLARE @T_JobType AS TABLE(ID INT)
  14166. ----记录查询条件
  14167. INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, Industry,
  14168. Lng, Lat, Distance, Welfare, KeyWord, KeyType, ReuseNumber, Education, Experience,
  14169. Salary, EmployType, CompanySizeID, IsOnline, dcProvinceId)
  14170. VALUES(
  14171. 50, GETDATE(), @dcJobTypeID, @dcIndustryID, @Lng, @Lat,
  14172. @Distance, @Welfare, '', 0, 0, @dcEducationID, @MinExperience,
  14173. @dcSalaryID, @EmployType, @CompanySizeID, @IsOnline, @dcProvinceId)
  14174. SET @paSearchConditionID = @@IDENTITY
  14175. SELECT @TableID = @paSearchConditionID % 4
  14176. ------生成职位类别的表变量,因为职位类别有包含(父子)关系
  14177. SELECT @JobType=''
  14178. ----生成求聘职位的表变量
  14179. IF LEN(@dcJobTypeID) > 0
  14180. BEGIN
  14181. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  14182. INSERT INTO @T_Temp
  14183. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  14184. INSERT INTO @T_JobType
  14185. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  14186. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  14187. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  14188. OR ID IN(SELECT ID FROM @T_TEMP)
  14189. ----生成in字符串
  14190. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  14191. IF RIGHT(@JobType, 1) = ','
  14192. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  14193. END
  14194. ----建立临时表
  14195. CREATE TABLE #Job(
  14196. RowID INT IDENTITY(1, 1),
  14197. ID INT NOT NULL,
  14198. dcJobTypeID SMALLINT NOT NULL,
  14199. dcJobTypeIDMinor SMALLINT NULL,
  14200. dcSalaryID TINYINT NOT NULL,
  14201. dcRegionID VARCHAR(6) NULL,
  14202. dcEducationID TINYINT NOT NULL,
  14203. MinExperience TINYINT NOT NULL,
  14204. RefreshDate SMALLDATETIME NULL,
  14205. EmployType TINYINT NULL,
  14206. dcCompanySizeID SMALLINT NULL
  14207. )
  14208. ------刷新时间,根据刷新时间编号计算
  14209. ----生成插入临时表的Sql语句
  14210. SET @SQL='
  14211. INSERT INTO #Job
  14212. SELECT a.ID, a.dcJobTypeID,
  14213. a.dcJobTypeIDMinor, a.dcSalaryID,
  14214. a.dcRegionID, a.dcEducationID, a.MinExperience,
  14215. a.IssueDate,a.EmployType,b.dcCompanySizeID'
  14216. SET @FROM = '
  14217. FROM JobPublish a WITH(NOLOCK)
  14218. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  14219. ----职位有效,单位新有效
  14220. IF LEN(@dcProvinceID) > 1
  14221. SET @WHERE = '
  14222. WHERE b.dcProvinceID = ' + @dcProvinceID + '
  14223. AND a.Valid = 1
  14224. AND b.Valid = 1'
  14225. ELSE
  14226. SET @WHERE = '
  14227. WHERE a.Valid = 1
  14228. AND b.Valid = 1'
  14229. ----需要增加全文索引的关键字查询
  14230. ----职位类别
  14231. IF LEN(@dcJobTypeID) > 0
  14232. SET @WHERE = @WHERE + '
  14233. AND (a.dcJobTypeID IN(' + @JobType +')
  14234. OR a.dcJobTypeIDMinor IN(' + @JobType + '))'
  14235. IF LEN(@dcIndustryID)>0
  14236. SET @WHERE = @WHERE + ' AND b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @dcIndustryID + '))'
  14237. IF @dcSalaryID > 0
  14238. BEGIN
  14239. IF @dcSalaryID < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
  14240. BEGIN
  14241. SET @WHERE = @WHERE + '
  14242. AND a.dcSalaryID IN(' + LTRIM(STR(@dcSalaryID)) + ',' + LTRIM(STR(@dcSalaryID + 1))
  14243. SET @WHERE = @WHERE + ')'
  14244. END
  14245. IF @dcSalaryID = 100 ----从筛选结果中点击面议,值是100
  14246. BEGIN
  14247. SET @WHERE = @WHERE + '
  14248. AND a.dcSalaryID = 100'
  14249. END
  14250. IF @dcSalaryID > 100 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  14251. SET @WHERE = @WHERE + '
  14252. AND a.dcSalaryID=' + LTRIM(STR(@dcSalaryID-100))
  14253. END
  14254. ----工作经验要求
  14255. IF @MinExperience < 100
  14256. SET @WHERE = @WHERE + '
  14257. AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
  14258. ----学历要求
  14259. ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
  14260. IF @dcEducationID > 0
  14261. IF @dcEducationID = 2
  14262. SET @WHERE = @WHERE + '
  14263. AND a.dcEducationID IN(2, 3, 4)'
  14264. ELSE
  14265. SET @WHERE = @WHERE + '
  14266. AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
  14267. ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
  14268. IF LEN(@EmployType) > 0
  14269. SET @WHERE = @WHERE + '
  14270. AND a.EmployType IN (' + @EmployType + ')'
  14271. IF @CompanySizeID BETWEEN 1 AND 6
  14272. SET @WHERE = @WHERE + '
  14273. AND b.dcCompanySizeID = ' + LTRIM(STR(@CompanySizeID))
  14274. IF LEN(@Welfare) > 0
  14275. SET @WHERE = @WHERE + '
  14276. AND a.Welfare' + REPLACE(@Welfare, ',', ' = 1 AND a.Welfare') + ' = 1'
  14277. IF @IsOnline = 1
  14278. SET @WHERE = @WHERE + '
  14279. AND a.caMainId IN(SELECT caMainId FROM caOnline WITH(NOLOCK) WHERE IsOnline = 1) '
  14280. DECLARE @Degree AS DECIMAL(8,5),@LBLng AS DECIMAL(8,5),@LBLat AS DECIMAL(8,5),
  14281. @RTLng AS DECIMAL(8,5),@RTLat AS DECIMAL(8,5)
  14282. SET @Degree = @Distance / 100000.0;
  14283. SET @LBLng = @Lng - @Degree
  14284. SET @LBLat = @Lat - @Degree
  14285. SET @RTLng = @Lng + @Degree
  14286. SET @RTLat = @Lat + @Degree
  14287. SET @WHERE = @WHERE + '
  14288. AND a.Lng BETWEEN ' + CONVERT(VARCHAR,@LBLng) + ' AND ' + CONVERT(VARCHAR,@RTLng) + '
  14289. AND a.Lat BETWEEN ' + CONVERT(VARCHAR,@LBLat) + ' AND ' + CONVERT(VARCHAR,@RTLat) + '
  14290. AND (a.Lng-' + CONVERT(VARCHAR,@Lng) + ')*(a.Lng-' + CONVERT(VARCHAR,@Lng) + ')+
  14291. (a.Lat-' + CONVERT(VARCHAR,@Lat) + ')*(a.Lat-' + CONVERT(VARCHAR,@Lat) + ')<' + CONVERT(VARCHAR,@Degree*@Degree)
  14292. SET @SQL = @SQL + @FROM + @WHERE
  14293. --IF LEN(@ORDER)>0
  14294. SET @SQL=@SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
  14295. --原来是ORDER BY a.IssueDate DESC, a.ID,Richard 2011年11月23日17:06分修改
  14296. ----把符合条件的职位全部列出
  14297. --PRINT @SQL
  14298. EXEC(@SQL)
  14299. SET @ValidJobNumber = @@ROWCOUNT
  14300. ----记录查询结果总数
  14301. UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@SQL WHERE ID=@paSearchConditionID
  14302. ----插入JobType数据
  14303. DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
  14304. IF (@TableID = 0)
  14305. BEGIN
  14306. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  14307. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  14308. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  14309. ----计算全部某职位类别,2, 4位的数据
  14310. UPDATE a SET a.TitleValue = b.TitleValue
  14311. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
  14312. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  14313. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  14314. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  14315. GROUP BY LEFT(TitleID, 2)) b
  14316. WHERE a.TitleId = b.TitleID
  14317. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  14318. ----写入TitleDesc
  14319. UPDATE a SET a.TitleDesc = b.Description
  14320. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  14321. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  14322. AND a.Title = 'JobType'
  14323. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  14324. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  14325. GROUP BY dcSalaryID ORDER BY dcSalaryID
  14326. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  14327. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  14328. GROUP BY dcRegionID ORDER BY dcRegionID
  14329. ----计算全部地区,2位的数据
  14330. UPDATE a SET a.TitleValue = b.TitleValue
  14331. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
  14332. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  14333. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  14334. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  14335. GROUP BY LEFT(TitleID, 2)) b
  14336. WHERE a.TitleId = b.TitleID
  14337. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  14338. ----计算全部地区,4位的数据
  14339. UPDATE a SET a.TitleValue = b.TitleValue
  14340. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), (
  14341. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  14342. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  14343. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  14344. AND LEN(TitleID) >3
  14345. GROUP BY LEFT(TitleID, 4)) b
  14346. WHERE a.TitleId = b.TitleID
  14347. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  14348. ----写入TitleDesc
  14349. UPDATE a SET a.TitleDesc = b.Description
  14350. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  14351. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  14352. AND a.Title = 'Region'
  14353. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  14354. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  14355. FROM #Job WITH(NOLOCK)
  14356. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  14357. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  14358. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  14359. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  14360. GROUP BY MinExperience ORDER BY MinExperience
  14361. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  14362. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  14363. GROUP BY EmployType ORDER BY EmployType
  14364. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  14365. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  14366. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  14367. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  14368. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  14369. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  14370. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  14371. SET @TopRows = @@ROWCOUNT
  14372. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  14373. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  14374. SET @AllRows = @@ROWCOUNT
  14375. IF @TopRows = 0 AND @AllRows > 100
  14376. UPDATE SearchDB..paSearchJobID_0 SET IsTop = 1
  14377. WHERE paSearchConditionID = @paSearchConditionID
  14378. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  14379. END
  14380. ELSE IF (@TableId = 1)
  14381. BEGIN
  14382. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  14383. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  14384. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  14385. ----计算全部某职位类别,2, 4位的数据
  14386. UPDATE a SET a.TitleValue = b.TitleValue
  14387. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
  14388. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  14389. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  14390. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  14391. GROUP BY LEFT(TitleID, 2)) b
  14392. WHERE a.TitleId = b.TitleID
  14393. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  14394. ----写入TitleDesc
  14395. UPDATE a SET a.TitleDesc = b.Description
  14396. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  14397. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  14398. AND a.Title = 'JobType'
  14399. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  14400. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  14401. GROUP BY dcSalaryID ORDER BY dcSalaryID
  14402. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  14403. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  14404. GROUP BY dcRegionID ORDER BY dcRegionID
  14405. ----计算全部地区,2位的数据
  14406. UPDATE a SET a.TitleValue = b.TitleValue
  14407. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
  14408. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  14409. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  14410. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  14411. GROUP BY LEFT(TitleID, 2)) b
  14412. WHERE a.TitleId = b.TitleID
  14413. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  14414. ----计算全部地区,4位的数据
  14415. UPDATE a SET a.TitleValue = b.TitleValue
  14416. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), (
  14417. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  14418. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  14419. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  14420. AND LEN(TitleID) >3
  14421. GROUP BY LEFT(TitleID, 4)) b
  14422. WHERE a.TitleId = b.TitleID
  14423. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  14424. ----写入TitleDesc
  14425. UPDATE a SET a.TitleDesc = b.Description
  14426. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  14427. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  14428. AND a.Title = 'Region'
  14429. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  14430. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  14431. FROM #Job WITH(NOLOCK)
  14432. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  14433. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  14434. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  14435. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  14436. GROUP BY MinExperience ORDER BY MinExperience
  14437. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  14438. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  14439. GROUP BY EmployType ORDER BY EmployType
  14440. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  14441. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  14442. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  14443. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  14444. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  14445. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  14446. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  14447. SET @TopRows = @@ROWCOUNT
  14448. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  14449. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  14450. SET @AllRows = @@ROWCOUNT
  14451. IF @TopRows = 0 AND @AllRows > 100
  14452. UPDATE SearchDB..paSearchJobID_1 SET IsTop = 1
  14453. WHERE paSearchConditionID = @paSearchConditionID
  14454. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  14455. END
  14456. ELSE IF (@TableId = 2)
  14457. BEGIN
  14458. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  14459. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  14460. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  14461. ----计算全部某职位类别,2, 4位的数据
  14462. UPDATE a SET a.TitleValue = b.TitleValue
  14463. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
  14464. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  14465. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  14466. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  14467. GROUP BY LEFT(TitleID, 2)) b
  14468. WHERE a.TitleId = b.TitleID
  14469. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  14470. ----写入TitleDesc
  14471. UPDATE a SET a.TitleDesc = b.Description
  14472. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  14473. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  14474. AND a.Title = 'JobType'
  14475. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  14476. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  14477. GROUP BY dcSalaryID ORDER BY dcSalaryID
  14478. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  14479. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  14480. GROUP BY dcRegionID ORDER BY dcRegionID
  14481. ----计算全部地区,2位的数据
  14482. UPDATE a SET a.TitleValue = b.TitleValue
  14483. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
  14484. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  14485. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  14486. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  14487. GROUP BY LEFT(TitleID, 2)) b
  14488. WHERE a.TitleId = b.TitleID
  14489. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  14490. ----计算全部地区,4位的数据
  14491. UPDATE a SET a.TitleValue = b.TitleValue
  14492. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), (
  14493. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  14494. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  14495. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  14496. AND LEN(TitleID) >3
  14497. GROUP BY LEFT(TitleID, 4)) b
  14498. WHERE a.TitleId = b.TitleID
  14499. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  14500. ----写入TitleDesc
  14501. UPDATE a SET a.TitleDesc = b.Description
  14502. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  14503. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  14504. AND a.Title = 'Region'
  14505. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  14506. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  14507. FROM #Job WITH(NOLOCK)
  14508. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  14509. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  14510. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  14511. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  14512. GROUP BY MinExperience ORDER BY MinExperience
  14513. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  14514. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  14515. GROUP BY EmployType ORDER BY EmployType
  14516. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  14517. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  14518. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  14519. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  14520. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  14521. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  14522. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  14523. SET @TopRows = @@ROWCOUNT
  14524. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  14525. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  14526. SET @AllRows = @@ROWCOUNT
  14527. IF @TopRows = 0 AND @AllRows > 100
  14528. UPDATE SearchDB..paSearchJobID_2 SET IsTop = 1
  14529. WHERE paSearchConditionID = @paSearchConditionID
  14530. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  14531. END
  14532. ELSE IF (@TableId = 3)
  14533. BEGIN
  14534. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  14535. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  14536. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  14537. ----计算全部某职位类别,2, 4位的数据
  14538. UPDATE a SET a.TitleValue = b.TitleValue
  14539. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
  14540. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  14541. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  14542. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  14543. GROUP BY LEFT(TitleID, 2)) b
  14544. WHERE a.TitleId = b.TitleID
  14545. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  14546. ----写入TitleDesc
  14547. UPDATE a SET a.TitleDesc = b.Description
  14548. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  14549. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  14550. AND a.Title = 'JobType'
  14551. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  14552. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  14553. GROUP BY dcSalaryID ORDER BY dcSalaryID
  14554. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  14555. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  14556. GROUP BY dcRegionID ORDER BY dcRegionID
  14557. ----计算全部地区,2位的数据
  14558. UPDATE a SET a.TitleValue = b.TitleValue
  14559. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
  14560. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  14561. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  14562. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  14563. GROUP BY LEFT(TitleID, 2)) b
  14564. WHERE a.TitleId = b.TitleID
  14565. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  14566. ----计算全部地区,4位的数据
  14567. UPDATE a SET a.TitleValue = b.TitleValue
  14568. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), (
  14569. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  14570. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  14571. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  14572. AND LEN(TitleID) >3
  14573. GROUP BY LEFT(TitleID, 4)) b
  14574. WHERE a.TitleId = b.TitleID
  14575. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  14576. ----写入TitleDesc
  14577. UPDATE a SET a.TitleDesc = b.Description
  14578. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  14579. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  14580. AND a.Title = 'Region'
  14581. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  14582. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  14583. FROM #Job WITH(NOLOCK)
  14584. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  14585. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  14586. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  14587. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  14588. GROUP BY MinExperience ORDER BY MinExperience
  14589. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  14590. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  14591. GROUP BY EmployType ORDER BY EmployType
  14592. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  14593. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  14594. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  14595. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  14596. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  14597. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  14598. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  14599. SET @TopRows = @@ROWCOUNT
  14600. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  14601. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  14602. SET @AllRows = @@ROWCOUNT
  14603. IF @TopRows = 0 AND @AllRows > 100
  14604. UPDATE SearchDB..paSearchJobID_3 SET IsTop = 1
  14605. WHERE paSearchConditionID = @paSearchConditionID
  14606. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  14607. END
  14608. DROP TABLE #Job
  14609. --PRINT 'DROP #JOB ' + CONVERT(VARCHAR(30), GETDATE(), 121)
  14610. COMMIT
  14611. --GOTO GetRecordSet
  14612. GetRecordSet:
  14613. BEGIN
  14614. DECLARE @AllJobCount AS INT
  14615. ----返回查询数量
  14616. SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
  14617. SELECT @AllJobCount = ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
  14618. UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
  14619. ----返回20行查询结果
  14620. IF (@TableID = 0)
  14621. BEGIN
  14622. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  14623. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  14624. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName,
  14625. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  14626. a.dcRegionID, a.dcEducationID, b.HasLicence, b.IsRefreshed, dcCompanySizeID,
  14627. a.MinExperience, a.MinAge, a.MaxAge, a.RefreshDate, a.Lng, a.Lat,
  14628. b.Name as cpName, c.IsTop, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,
  14629. a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
  14630. a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,
  14631. ISNULL((SELECT IsOnline FROM caOnline WITH(NOLOCK) WHERE caMainId = a.caMainId), 0) IsOnline, b.LogoFile LogoUrl,@AllJobCount JobNumber,
  14632. d.FullName RegionName,e.Description EducationName,f.Description ExperienceName,g.DescriptionCp dcSalary,h.DescriptionCp dcSalaryMax
  14633. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_0 c WITH(NOLOCK),
  14634. dcRegion d WITH(NOLOCK),dcEducation e WITH(NOLOCK),dcOthers f WITH(NOLOCK),dcSalary g WITH(NOLOCK),dcSalary h WITH(NOLOCK)
  14635. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  14636. AND d.ID = a.dcRegionID AND e.ID = a.dcEducationID AND f.DetailID = a.MinExperience
  14637. AND f.Category='职位要求工作经验' AND g.ID = a.dcSalaryID AND h.ID = a.dcSalaryIDMax
  14638. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  14639. END
  14640. ELSE IF (@TableID = 1)
  14641. BEGIN
  14642. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  14643. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  14644. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName,
  14645. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  14646. a.dcRegionID, a.dcEducationID, b.HasLicence, b.IsRefreshed, dcCompanySizeID,
  14647. a.MinExperience, a.MinAge, a.MaxAge, a.RefreshDate, a.Lng, a.Lat,
  14648. b.Name as cpName, c.IsTop, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,
  14649. a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
  14650. a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,
  14651. ISNULL((SELECT IsOnline FROM caOnline WITH(NOLOCK) WHERE caMainId = a.caMainId), 0) IsOnline,
  14652. b.LogoFile LogoUrl,@AllJobCount JobNumber,
  14653. d.FullName RegionName,e.Description EducationName,f.Description ExperienceName,g.DescriptionCp dcSalary,h.DescriptionCp dcSalaryMax
  14654. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_1 c WITH(NOLOCK),
  14655. dcRegion d WITH(NOLOCK),dcEducation e WITH(NOLOCK),dcOthers f WITH(NOLOCK),dcSalary g WITH(NOLOCK),dcSalary h WITH(NOLOCK)
  14656. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  14657. AND d.ID = a.dcRegionID AND e.ID = a.dcEducationID AND f.DetailID = a.MinExperience
  14658. AND f.Category='职位要求工作经验' AND g.ID = a.dcSalaryID AND h.ID = a.dcSalaryIDMax
  14659. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  14660. END
  14661. ELSE IF (@TableID = 2)
  14662. BEGIN
  14663. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  14664. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  14665. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName,
  14666. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  14667. a.dcRegionID, a.dcEducationID, b.HasLicence, b.IsRefreshed, dcCompanySizeID,
  14668. a.MinExperience, a.MinAge, a.MaxAge, a.RefreshDate, a.Lng, a.Lat,
  14669. b.Name as cpName, c.IsTop, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,
  14670. a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
  14671. a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,
  14672. ISNULL((SELECT IsOnline FROM caOnline WITH(NOLOCK) WHERE caMainId = a.caMainId), 0) IsOnline,
  14673. b.LogoFile LogoUrl, @AllJobCount JobNumber,
  14674. d.FullName RegionName,e.Description EducationName,f.Description ExperienceName,g.DescriptionCp dcSalary,h.DescriptionCp dcSalaryMax
  14675. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_2 c WITH(NOLOCK),
  14676. dcRegion d WITH(NOLOCK),dcEducation e WITH(NOLOCK),dcOthers f WITH(NOLOCK),dcSalary g WITH(NOLOCK),dcSalary h WITH(NOLOCK)
  14677. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  14678. AND d.ID = a.dcRegionID AND e.ID = a.dcEducationID AND f.DetailID = a.MinExperience
  14679. AND f.Category='职位要求工作经验' AND g.ID = a.dcSalaryID AND h.ID = a.dcSalaryIDMax
  14680. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  14681. END
  14682. ELSE IF (@TableID = 3)
  14683. BEGIN
  14684. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  14685. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  14686. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  14687. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  14688. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID, b.HasLicence, b.IsRefreshed, dcCompanySizeID,
  14689. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  14690. a.IsDelete, a.AddDate, a.RefreshDate, a.Lng, a.Lat,
  14691. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  14692. b.UnLimitedDate, b.BalanceDate, b.Balance,
  14693. b.MemberType, '' cpIndustry,
  14694. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,
  14695. a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
  14696. a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,
  14697. ISNULL((SELECT IsOnline FROM caOnline WITH(NOLOCK) WHERE caMainId = a.caMainId), 0) IsOnline,
  14698. b.LogoFile LogoUrl,@AllJobCount JobNumber,
  14699. d.FullName RegionName,e.Description EducationName,f.Description ExperienceName,g.DescriptionCp dcSalary,h.DescriptionCp dcSalaryMax
  14700. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_3 c WITH(NOLOCK),
  14701. dcRegion d WITH(NOLOCK),dcEducation e WITH(NOLOCK),dcOthers f WITH(NOLOCK),dcSalary g WITH(NOLOCK),dcSalary h WITH(NOLOCK)
  14702. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  14703. AND d.ID = a.dcRegionID AND e.ID = a.dcEducationID AND f.DetailID = a.MinExperience
  14704. AND f.Category='职位要求工作经验' AND g.ID = a.dcSalaryID AND h.ID = a.dcSalaryIDMax
  14705. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  14706. END
  14707. --RICHARD 2011-7-23 16:51分修改
  14708. ----返回统计数量
  14709. IF @Type=1
  14710. BEGIN
  14711. IF (@TableID = 0)
  14712. BEGIN
  14713. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcJobType b ON b.ID = a.TitleID WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  14714. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcRegion b ON b.ID = a.TitleID WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  14715. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcEducation b ON b.ID = a.TitleID WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14716. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='职位要求工作经验' WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14717. SELECT * FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14718. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='工作性质' WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14719. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcCompanySize b ON b.ID = a.TitleID WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14720. END
  14721. IF (@TableID = 1)
  14722. BEGIN
  14723. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcJobType b ON b.ID = a.TitleID WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  14724. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcRegion b ON b.ID = a.TitleID WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  14725. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcEducation b ON b.ID = a.TitleID WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14726. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='职位要求工作经验' WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14727. SELECT * FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14728. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='工作性质' WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14729. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcCompanySize b ON b.ID = a.TitleID WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14730. END
  14731. IF (@TableID = 2)
  14732. BEGIN
  14733. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcJobType b ON b.ID = a.TitleID WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  14734. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcRegion b ON b.ID = a.TitleID WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  14735. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcEducation b ON b.ID = a.TitleID WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14736. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='职位要求工作经验' WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14737. SELECT * FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14738. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='工作性质' WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14739. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcCompanySize b ON b.ID = a.TitleID WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14740. END
  14741. IF (@TableID = 3)
  14742. BEGIN
  14743. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcJobType b ON b.ID = a.TitleID WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  14744. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcRegion b ON b.ID = a.TitleID WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  14745. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcEducation b ON b.ID = a.TitleID WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14746. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='职位要求工作经验' WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14747. SELECT * FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14748. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='工作性质' WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14749. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcCompanySize b ON b.ID = a.TitleID WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  14750. END
  14751. END
  14752. RETURN
  14753. END
  14754. END TRY
  14755. BEGIN CATCH
  14756. ---检查是否已经建立临时表,已经建立则删除
  14757. ROLLBACK TRANSACTION
  14758. ---检查是否已经建立临时表,已经建立则删除
  14759. DECLARE @para VARCHAR(MAX)
  14760. SET @para = '@dcJobTypeID=' + ISNULL(@dcJobTypeID, '') + '|' +
  14761. '@dcIndustryID=' + ISNULL(@dcIndustryID, '') + '|' +
  14762. '@EmployType=' + ISNULL(@EmployType, '') + '|' +
  14763. '@Welfare=' + ISNULL(@Welfare, '')
  14764. INSERT INTO ErrorLog
  14765. SELECT 'm3 ' + ISNULL(error_Message(), ' no msg')+ ' para=' + ISNULL(@Para, 'no para ') + ISNULL(@SQL, ' no sql'), error_number(), error_line(), GETDATE()
  14766. END CATCH
  14767. GO
  14768. /****** Object: StoredProcedure [dbo].[mblJobBySearchCount] Script Date: 2018/12/13 19:07:45 ******/
  14769. SET ANSI_NULLS ON
  14770. GO
  14771. SET QUOTED_IDENTIFIER ON
  14772. GO
  14773. CREATE PROCEDURE [dbo].[mblJobBySearchCount]
  14774. (
  14775. @dcJobTypeID INT, --职位类别
  14776. @dcRegionID INT, --求职地区
  14777. @dcIndustryID INT --求职行业
  14778. )
  14779. AS
  14780. BEGIN
  14781. DECLARE @COUNT INT, @ALLCOUNT INT
  14782. IF @dcIndustryID > 0
  14783. SELECT @COUNT = COUNT(*) FROM Job a WITH(NOLOCK)
  14784. INNER JOIN cpMain b ON a.cpMainID=b.ID
  14785. INNER JOIN cpIndustry d WITH(NOLOCK) ON d.cpMainID=b.ID AND d.dcIndustryID=@dcIndustryID
  14786. WHERE (dcJobTypeID=@dcJobTypeID OR dcJobTypeIDMinor=@dcJobTypeID)
  14787. AND LEFT(a.dcRegionID,4)=@dcRegionID AND a.Valid=1
  14788. ELSE
  14789. SELECT @COUNT=COUNT(*) FROM Job WITH(NOLOCK)
  14790. WHERE (dcJobTypeID=@dcJobTypeID OR dcJobTypeIDMinor=@dcJobTypeID)
  14791. AND LEFT(dcRegionID,4) = @dcRegionID
  14792. AND Valid=1
  14793. RETURN @Count
  14794. END
  14795. set ANSI_NULLS ON
  14796. set QUOTED_IDENTIFIER ON
  14797. GO
  14798. /****** Object: StoredProcedure [dbo].[mblJobBySearchSelect] Script Date: 2018/12/13 19:07:46 ******/
  14799. SET ANSI_NULLS ON
  14800. GO
  14801. SET QUOTED_IDENTIFIER ON
  14802. GO
  14803. CREATE proCEDURE [dbo].[mblJobBySearchSelect]
  14804. (
  14805. @dcJobTypeID VARCHAR(100), --职位类别
  14806. @dcRegionID VARCHAR(100), --求职地区
  14807. @dcIndustryID VARCHAR(100), --求职行业
  14808. @dcSalaryID TINYINT, --月薪
  14809. @IsNegotiable BIT, --1允许面议,不面议
  14810. @MinExperience TINYINT, --工作经验,100为未选择
  14811. @dcEducationID TINYINT, --最低学历
  14812. @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习,
  14813. @KeyWord NVARCHAR(50), --关键词
  14814. @KeyType TINYINT, --搜索类别,0无;1-全文;2-职位;3-公司
  14815. @ORDER VARCHAR(4), --显示顺序,没有用
  14816. @RefreshNo INT, --1, 1天内;2, 3天内;3,一周内;4,15天内;5,一个月内;6超过一个月
  14817. @Type INT, --1:主动搜索 点击搜索按钮 10分钟,翻页60分钟有效;0:翻页搜索,不刷新
  14818. @PageNumber INT, --翻页页码
  14819. @SessionID varchar(50), --10
  14820. @CompanySizeID VARCHAR(1), --企业规模
  14821. @IsOnline INT,
  14822. @Welfare VARCHAR(50) --
  14823. )
  14824. AS
  14825. SET NOCOUNT ON
  14826. BEGIN
  14827. DECLARE @t AS TABLE(
  14828. dcJobTypeID VARCHAR(100),
  14829. dcRegionID VARCHAR(100),
  14830. dcIndustryID VARCHAR(100),
  14831. dcSalaryID TINYINT,
  14832. IsNegotiable INT,
  14833. MinExperience TINYINT,
  14834. dcEducationID TINYINT,
  14835. EmployType VARCHAR(10),
  14836. KeyWord NVARCHAR(50),
  14837. KeyType TINYINT,
  14838. [ORDER] VARCHAR(100),
  14839. RefreshNo INT,
  14840. Type INT,
  14841. PageNumber INT,
  14842. SessionID varchar(50),
  14843. CompanySizeID VARCHAR(1),
  14844. Welfare VARCHAR(50),
  14845. IsOnline INT
  14846. )
  14847. INSERT INTO @t
  14848. SELECT @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcSalaryID, @IsNegotiable,
  14849. @MinExperience, @dcEducationID, @EmployType, @KeyWord, @KeyType, @ORDER,
  14850. @RefreshNo, @Type, @PageNumber, @SessionID, @CompanySizeID, @Welfare, @IsOnline
  14851. DECLARE @json VARCHAR(max)
  14852. SET @json = (SELECT * from @t for json auto)
  14853. SET @json = RIGHT(LEFT(@json, LEN(@json) - 1), LEN(@json) - 2)
  14854. EXEC procJobPublishSelect @json
  14855. END
  14856. GO
  14857. /****** Object: StoredProcedure [dbo].[mblJobBySearchSelect0928] Script Date: 2018/12/13 19:07:46 ******/
  14858. SET ANSI_NULLS ON
  14859. GO
  14860. SET QUOTED_IDENTIFIER ON
  14861. GO
  14862. create proCEDURE [dbo].[mblJobBySearchSelect0928]
  14863. (
  14864. @dcJobTypeID VARCHAR(100), --职位类别
  14865. @dcRegionID VARCHAR(100), --求职地区
  14866. @dcIndustryID VARCHAR(100), --求职行业
  14867. @dcSalaryID TINYINT, --月薪
  14868. @IsNegotiable BIT, --1允许面议,不面议
  14869. @MinExperience TINYINT, --工作经验,100为未选择
  14870. @dcEducationID TINYINT, --最低学历
  14871. @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习,
  14872. @KeyWord NVARCHAR(50), --关键词
  14873. @KeyType TINYINT, --搜索类别,0无;1-全文;2-职位;3-公司
  14874. @ORDER VARCHAR(4), --显示顺序,没有用
  14875. @RefreshNo INT, --1, 1天内;2, 3天内;3,一周内;4,15天内;5,一个月内;6超过一个月
  14876. @Type INT, --1:主动搜索 点击搜索按钮 10分钟,翻页60分钟有效;0:翻页搜索,不刷新
  14877. @PageNumber INT, --翻页页码
  14878. @SessionID varchar(50), --10
  14879. @CompanySizeID VARCHAR(1), --企业规模
  14880. @IsOnline INT,
  14881. @Welfare VARCHAR(50) --
  14882. )
  14883. AS
  14884. --return @SessionId = 10
  14885. SET NOCOUNT ON
  14886. INSERT INTO SearchIp(Ip, Source) SELECT @SessionId, 'm'
  14887. IF EXISTS(SELECT 'x' FROM RefuseIp WITH(NOLOCK) WHERE CHARINDEX(Ip,@SessionId) > 0)
  14888. RETURN
  14889. INSERT INTO SearchDB..paSearchLog(ProcType, SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
  14890. Salary, IsNegotiable, EmployType, CompanySizeID, KeyWord, KeyType, ReuseNumber, Welfare, IsOnline, RefreshNo)
  14891. VALUES('pcJobBySearchSelect', @SessionId, GETDATE(), @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcEducationID, @MinExperience,
  14892. @dcSalaryID, 0, @EmployType, @CompanySizeID, @KeyWord, @KeyType, 0, @Welfare, @IsOnline, @RefreshNo)
  14893. SET @SessionId = 'b' + @SessionId
  14894. SET @KeyType = 0
  14895. BEGIN TRY
  14896. DECLARE @ReuseNumber AS INT, @dcProvinceId VARCHAR(2), @Order2 VARCHAR(100)
  14897. ----给null值变量赋默认值
  14898. IF NOT LEFT(@dcRegionID,1) = 'p'
  14899. SELECT @dcRegionID = RTRIM(dbo.FormatIDS(@dcRegionID))
  14900. SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
  14901. @dcIndustryID = RTRIM(dbo.FormatIDS(@dcIndustryID)),
  14902. @dcSalaryID = ISNULL(@dcSalaryID, 0),
  14903. @IsNegotiable = ISNULL(@IsNegotiable, 0),
  14904. @MinExperience = ISNULL(@MinExperience, 100),
  14905. @dcEducationID = ISNULL(@dcEducationID, 0),
  14906. @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END,
  14907. @CompanySizeID = ISNULL(@CompanySizeID, '0'),
  14908. @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, '')),
  14909. @ORDER = ISNULL(@Order, ''),
  14910. @Type = ISNULL(@Type, 0),
  14911. @PageNumber = ISNULL(@PageNumber, 0),
  14912. @Welfare = RTRIM(dbo.FormatIDS(@Welfare)),
  14913. @IsOnline = ISNULL(@IsOnline, 0),
  14914. @Order2 = ' ORDER BY a.RefreshDate DESC, a.SecondID DESC'
  14915. IF @dcSalaryID = 0
  14916. SET @IsNegotiable = 0
  14917. IF @Order LIKE 'p=%'
  14918. SET @dcProvinceId = REPLACE(@Order, 'p=', '')
  14919. ELSE
  14920. SET @dcProvinceId = 0
  14921. --@RefreshNo = 0选择全部数据,不限制时间
  14922. SET @RefreshNo = 0
  14923. IF(@KeyWord = '' AND ISNULL(@dcJobTypeID, '') = '' AND ISNULL(@dcRegionID, '') = '' AND ISNULL(@dcIndustryID, '') = '')
  14924. RETURN
  14925. --如果关键词不为空 查询关键词对应的搜索类型 max 2012-12-25
  14926. IF RIGHT(@KeyWord, 2) = '公司'
  14927. SET @KeyWord = LEFT(@KeyWord, LEN(@KeyWord) - 2)
  14928. IF RIGHT(@dcJobTypeID, 1) = ','
  14929. SET @dcJobTypeID = LEFT(@dcJobTypeID, LEN(@dcJobTypeID) - 1)
  14930. IF RIGHT(@dcRegionID, 1) = ','
  14931. SET @dcRegionID = LEFT(@dcRegionID, LEN(@dcRegionID) - 1)
  14932. IF RIGHT(@dcIndustryID, 1) = ','
  14933. SET @dcIndustryID = LEFT(@dcIndustryID, LEN(@dcIndustryID) - 1)
  14934. DECLARE @paSearchConditionID AS INT,
  14935. @MinId AS INT,
  14936. @PageSize AS TINYINT,
  14937. @TableID AS TINYINT
  14938. SELECT @paSearchConditionID = 0, @PageSize = 30
  14939. ----搜索1分钟前的数据
  14940. SELECT TOP 1 @paSearchConditionID = ID,
  14941. @ReuseNumber = ReuseNumber
  14942. FROM SearchDB..paSearchCondition WITH(NOLOCK)
  14943. WHERE JobType=@dcJobTypeID AND IsOnline = @IsOnline
  14944. AND JobPlace=@dcRegionID AND Industry=@dcIndustryID AND Education=@dcEducationID
  14945. AND Experience=@MinExperience AND Salary=@dcSalaryID AND IsNegotiable=@IsNegotiable
  14946. AND EmployType=@EmployType AND ISNULL(KeyWord, '') = @KeyWord AND KeyType = @KeyType
  14947. AND CompanySizeID = @CompanySizeID AND Welfare = @Welfare AND IsDelete = 0
  14948. AND LogTime > DATEADD(MINUTE, -1, GETDATE()) AND ReuseNumber > 0
  14949. AND RefreshNo = 0 AND ISNULL(dcProvinceId, 0) = @dcProvinceId
  14950. ORDER BY ID DESC
  14951. IF @ReuseNumber = 0
  14952. BEGIN
  14953. SELECT TOP 1 @paSearchConditionID = ID
  14954. FROM SearchDB..paSearchCondition WITH(NOLOCK)
  14955. WHERE JobType=@dcJobTypeID AND IsOnline = @IsOnline
  14956. AND JobPlace=@dcRegionID AND Industry=@dcIndustryID AND Education=@dcEducationID
  14957. AND Experience=@MinExperience AND Salary=@dcSalaryID AND IsNegotiable=@IsNegotiable
  14958. AND EmployType=@EmployType AND ISNULL(KeyWord, '') = @KeyWord AND KeyType=@KeyType
  14959. AND CompanySizeID = @CompanySizeID AND Welfare = @Welfare AND ReuseNumber > 0
  14960. AND ReuseNumber > 0 AND LogTime > DATEADD(MINUTE, -2, GETDATE())
  14961. AND RefreshNo = 0 AND ISNULL(dcProvinceId, 0) = @dcProvinceId
  14962. ORDER BY ID DESC
  14963. END
  14964. IF ISNULL(@paSearchConditionID, 0) = 0
  14965. BEGIN
  14966. SET @Type =1
  14967. GOTO SelectReset --无数据,重新搜索
  14968. END
  14969. ELSE
  14970. BEGIN
  14971. SELECT @TableID = @paSearchConditionID % 4
  14972. GOTO GetRecordSet --从临时结果中提取数据
  14973. END
  14974. SelectReset:
  14975. --从job中搜索数据
  14976. BEGIN TRAN
  14977. DECLARE @SQL AS VARCHAR(8000)
  14978. DECLARE @WHERE AS VARCHAR(8000)
  14979. DECLARE @FROM AS VARCHAR(1000)
  14980. ----记录查询条件
  14981. INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
  14982. Salary, IsNegotiable, EmployType, CompanySizeID, KeyWord, KeyType, ReuseNumber, Welfare, IsOnline, dcProvinceId)
  14983. VALUES(@SessionId, GETDATE(), @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcEducationID, @MinExperience,
  14984. @dcSalaryID, @IsNegotiable, @EmployType, @CompanySizeID, @KeyWord, @KeyType, 0, @Welfare, @IsOnline, @dcProvinceId)
  14985. SET @paSearchConditionID = @@IDENTITY
  14986. SELECT @TableID = @paSearchConditionID % 4
  14987. ------生成职位类别的表变量,因为职位类别有包含(父子)关系
  14988. DECLARE @T_JobPlace AS TABLE(ID INT)
  14989. DECLARE @T_JobType AS TABLE(ID INT)
  14990. DECLARE @JobPlaceLen AS INT, @JobTypeLen AS INT
  14991. IF CHARINDEX(',', @dcJobTypeID) > 0
  14992. SET @JobTypeLen = -1
  14993. ELSE
  14994. SET @JobTypeLen = LEN(@dcJobTypeID)
  14995. DECLARE @JobType AS VARCHAR(3000), @JobPlace AS VARCHAR(2000), @ValidJobNumber AS INT
  14996. SELECT @JobPlace = '', @JobType=''
  14997. ----生成工作地点的表变量
  14998. IF LEN(@dcRegionID) > 0
  14999. BEGIN
  15000. IF LEFT(@dcRegionID,1) = 'p'
  15001. BEGIN
  15002. DECLARE @Degree AS DECIMAL(8,5),@LBLng AS DECIMAL(8,5),@LBLat AS DECIMAL(8,5),
  15003. @RTLng AS DECIMAL(8,5),@RTLat AS DECIMAL(8,5),@Lat AS DECIMAL(8,5),@Lng AS DECIMAL(8,5)
  15004. SELECT @Lat = Lat,@Lng = Lng FROM dcMapPlace WITH(NOLOCK) WHERE ID = RIGHT(@dcRegionID,LEN(@dcRegionID)-1)
  15005. IF @dcRegionID LIKE '3201%'
  15006. SET @Degree = 1000 / 100000.0
  15007. ELSE
  15008. SET @Degree = 2000 / 100000.0
  15009. SET @LBLng = @Lng - @Degree
  15010. SET @LBLat = @Lat - @Degree
  15011. SET @RTLng = @Lng + @Degree
  15012. SET @RTLat = @Lat + @Degree
  15013. SET @JobPlace = 'a.Lng BETWEEN ' + CONVERT(VARCHAR,@LBLng) + ' AND ' + CONVERT(VARCHAR,@RTLng) + '
  15014. AND a.Lat BETWEEN ' + CONVERT(VARCHAR,@LBLat) + ' AND ' + CONVERT(VARCHAR,@RTLat) + '
  15015. AND (a.Lng-' + CONVERT(VARCHAR,@Lng) + ')*(a.Lng-' + CONVERT(VARCHAR,@Lng) + ')+
  15016. (a.Lat-' + CONVERT(VARCHAR,@Lat) + ')*(a.Lat-' + CONVERT(VARCHAR,@Lat) + ')<' + CONVERT(VARCHAR,@Degree*@Degree)
  15017. SELECT @JobPlaceLen = 8
  15018. END
  15019. ELSE
  15020. BEGIN
  15021. INSERT INTO @T_JobPlace
  15022. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  15023. SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  15024. IF LEN(@JobPlace) > 0
  15025. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  15026. IF (SELECT COUNT(*) FROM @T_JobPlace) > 1
  15027. SET @JobPlaceLen = -1
  15028. ELSE
  15029. SET @JobPlaceLen = LEN(@dcRegionID)
  15030. END
  15031. END
  15032. ELSE
  15033. SELECT @JobPlaceLen = 0
  15034. ----生成求聘职位的表变量
  15035. IF LEN(@dcJobTypeID) > 0
  15036. BEGIN
  15037. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  15038. INSERT INTO @T_Temp
  15039. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  15040. INSERT INTO @T_JobType
  15041. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  15042. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  15043. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  15044. OR ID IN(SELECT ID FROM @T_TEMP)
  15045. ----生成in字符串
  15046. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  15047. IF RIGHT(@JobType, 1) = ','
  15048. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  15049. END
  15050. ----建立临时表
  15051. CREATE TABLE #Job(
  15052. RowID INT IDENTITY(1, 1),
  15053. ID INT NOT NULL,
  15054. cpMainId INT,
  15055. dcJobTypeID SMALLINT NOT NULL,
  15056. dcJobTypeIDMinor SMALLINT NULL,
  15057. dcSalaryID TINYINT NOT NULL,
  15058. dcRegionID VARCHAR(6) NULL,
  15059. dcEducationID TINYINT NOT NULL,
  15060. MinExperience TINYINT NOT NULL,
  15061. RefreshDate SMALLDATETIME NULL,
  15062. EmployType TINYINT NULL,
  15063. dcCompanySizeID SMALLINT NULL
  15064. )
  15065. CREATE TABLE #FullText(
  15066. Priority INT,
  15067. JobId INT NOT NULL
  15068. )
  15069. ------刷新时间,根据刷新时间编号计算
  15070. ----生成插入临时表的Sql语句
  15071. SET @SQL='
  15072. INSERT INTO #Job
  15073. SELECT a.ID, a.cpMainId, a.dcJobTypeID,
  15074. a.dcJobTypeIDMinor, a.dcSalaryID,
  15075. a.dcRegionID, a.dcEducationID, a.MinExperience,
  15076. a.IssueDate,a.EmployType,b.dcCompanySizeID'
  15077. SET @FROM = '
  15078. FROM JobPublish a WITH(NOLOCK)
  15079. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  15080. ----职位有效,单位新有效
  15081. IF LEN(@dcIndustryID) > 0
  15082. SET @WHERE = '
  15083. WHERE b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @dcIndustryID + '))
  15084. AND a.Valid = 1
  15085. AND b.Valid = 1'
  15086. ELSE
  15087. SET @WHERE = '
  15088. WHERE a.Valid = 1
  15089. AND b.Valid = 1'
  15090. IF LEN(@dcProvinceId) > 1
  15091. SET @WHere = @Where + ' AND b.dcProvinceId = ' + @dcProvinceId
  15092. ----职位类别
  15093. IF LEN(@JobType) > 0
  15094. SET @WHERE = @WHERE + '
  15095. AND (a.dcJobTypeID IN(' + @JobType +')
  15096. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  15097. IF LEN(@JobPlace) > 0
  15098. SET @WHERE = @WHERE + '
  15099. AND (' + @JobPlace + ')'
  15100. IF @dcSalaryID > 0
  15101. BEGIN
  15102. IF @dcSalaryID < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
  15103. SET @WHERE = @WHERE + '
  15104. AND a.dcSalaryID IN(' + LTRIM(STR(@dcSalaryID)) + ',' + LTRIM(STR(@dcSalaryID + 1)) + ')'
  15105. ELSE IF @dcSalaryID = 100 ----从筛选结果中点击面议,值是100
  15106. SET @WHERE = @WHERE + '
  15107. AND a.dcSalaryID = 100'
  15108. ELSE IF @dcSalaryID BETWEEN 101 AND 106 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  15109. SET @WHERE = @WHERE + '
  15110. AND a.dcSalaryID <= ' + LTRIM(STR(@dcSalaryID-99)) + ' AND a.dcSalaryIDMax > ' + LTRIM(STR(@dcSalaryID-100))
  15111. ELSE IF @dcSalaryID BETWEEN 107 AND 113 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  15112. SET @WHERE = @WHERE + '
  15113. AND a.dcSalaryID <= ' + LTRIM(STR(@dcSalaryID - 100)) + ' AND a.dcSalaryIDMax > ' + LTRIM(STR(@dcSalaryID-100))
  15114. ELSE IF @dcSalaryID BETWEEN 114 AND 120
  15115. SET @WHERE = @WHERE + '
  15116. AND a.dcSalaryID < 100 AND a.dcSalaryIDMax > ' + LTRIM(STR(@dcSalaryID - 100))
  15117. END
  15118. ----工作经验要求
  15119. IF @MinExperience < 100
  15120. SET @WHERE = @WHERE + '
  15121. AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
  15122. ----学历要求
  15123. ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
  15124. IF @dcEducationID > 0
  15125. IF @dcEducationID = 2
  15126. SET @WHERE = @WHERE + '
  15127. AND a.dcEducationID IN(2, 3, 4)'
  15128. ELSE
  15129. SET @WHERE = @WHERE + '
  15130. AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
  15131. ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
  15132. IF LEN(@EmployType) > 0
  15133. SET @WHERE = @WHERE + '
  15134. AND a.EmployType IN (' + @EmployType + ')'
  15135. IF @CompanySizeID BETWEEN 1 AND 6
  15136. SET @WHERE = @WHERE + '
  15137. AND b.dcCompanySizeID = ' + LTRIM(STR(@CompanySizeID))
  15138. IF LEN(@Welfare) > 0
  15139. SET @WHERE = @WHERE + '
  15140. AND a.Welfare' + REPLACE(@Welfare, ',', ' = 1 AND a.Welfare') + ' = 1'
  15141. IF @IsOnline = 1
  15142. SET @WHERE = @WHERE + '
  15143. AND a.caMainId IN(SELECT caMainId FROM caOnline WITH(NOLOCK) WHERE IsOnline = 1)'
  15144. IF LEN(@KeyWord) > 0 ----使用全文搜索job和cpmain2个表,经过测试发现union最快
  15145. BEGIN
  15146. IF EXISTS(SELECT TOP 1 'x' FROM cpMainPublish WITH(NOLOCK) WHERE Name = @KeyWord)
  15147. BEGIN
  15148. SET @WHERE = @WHERE + '
  15149. AND b.Name = ''' + @KeyWord + ''''
  15150. SET @SQL = @SQL + @FROM + @WHERE
  15151. END
  15152. ELSE
  15153. BEGIN
  15154. DECLARE @KeyWordTemp NVARCHAR(50)
  15155. SET @KeyWordTemp = REPLACE(@KeyWord, ' ', '%')
  15156. IF LEN(@KeyWordTemp) > 1
  15157. BEGIN
  15158. IF @dcProvinceId > 0
  15159. BEGIN
  15160. INSERT #FullText
  15161. SELECT TOP 2000 2, b.ID
  15162. FROM cpMainPublish a WITH(NOLOCK),
  15163. JobPublish b WITH(NOLOCK)
  15164. WHERE a.Id = b.cpMainId
  15165. AND a.Name LIKE '%' + @KeyWordTemp + '%'
  15166. AND a.dcProvinceId = @dcprovinceId
  15167. ORDER BY b.RefreshDate DESC
  15168. INSERT #FullText
  15169. SELECT TOP 2000 1, b.ID
  15170. FROM cpMainPublish a WITH(NOLOCK),
  15171. JobPublish b WITH(NOLOCK)
  15172. WHERE a.Id = b.cpMainId
  15173. AND b.Name LIKE '%' + @KeyWordTemp + '%'
  15174. AND a.dcProvinceId = @dcprovinceId
  15175. ORDER BY b.RefreshDate DESC
  15176. END
  15177. ELSE
  15178. BEGIN
  15179. INSERT #FullText
  15180. SELECT TOP 2000 2, b.ID
  15181. FROM cpMainPublish a WITH(NOLOCK),
  15182. JobPublish b WITH(NOLOCK)
  15183. WHERE a.Id = b.cpMainId
  15184. AND a.Name LIKE '%' + @KeyWordTemp + '%'
  15185. ORDER BY b.RefreshDate DESC
  15186. INSERT #FullText
  15187. SELECT TOP 2000 1, b.ID
  15188. FROM cpMainPublish a WITH(NOLOCK),
  15189. JobPublish b WITH(NOLOCK)
  15190. WHERE a.Id = b.cpMainId
  15191. AND b.Name LIKE '%' + @KeyWordTemp + '%'
  15192. ORDER BY b.RefreshDate DESC
  15193. END
  15194. END
  15195. IF (SELECT COUNT(*) FROM #FullText) < 800
  15196. BEGIN
  15197. INSERT #FullText
  15198. SELECT TOP 5000 3, [Key]
  15199. FROM FREETEXTTABLE(cpMainJob, *, @KeyWord, 100000) AS KeyJob ORDER BY RANK DESC
  15200. END
  15201. DELETE a FROM #FullText a, #FullText b WHERE a.JobId = b.JobId AND a.Priority > b.Priority
  15202. --------------------
  15203. SELECT @FROM = @FROM + '
  15204. INNER JOIN #FullText ON a.ID = #FullText.JobId',
  15205. @ORDER2 = ' ORDER BY #FullText.Priority, a.RefreshDate DESC, a.SecondID DESC'
  15206. SET @SQL = @SQL + @FROM + @WHERE
  15207. END
  15208. END
  15209. ELSE
  15210. SELECT @SQL = @SQL + @FROM + @WHERE
  15211. SET @SQL = @SQL + @Order2
  15212. --原来是ORDER BY a.IssueDate DESC, a.ID,Richard 2011年11月23日17:06分修改
  15213. ----把符合条件的职位全部列出
  15214. --PRINT @SQL
  15215. EXEC(@SQL)
  15216. SET @ValidJobNumber = @@ROWCOUNT
  15217. ----记录查询结果总数
  15218. UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@SQL WHERE ID=@paSearchConditionID
  15219. IF LEN(@JobType) > 0 --IN(2, 4)
  15220. UPDATE #Job SET dcJobTypeId = dcJobTypeIDMinor
  15221. WHERE dcJobTypeID NOT IN(SELECT a FROM dbo.fnSplit(@JobType, ','))
  15222. ----插入JobType数据
  15223. DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
  15224. DECLARE @sc AS TABLE (
  15225. paSearchConditionID int,
  15226. Title varchar(20),
  15227. TitleID varchar(10),
  15228. TitleValue int
  15229. )
  15230. DECLARE @sc2 AS TABLE (
  15231. paSearchConditionID int,
  15232. Title varchar(20),
  15233. TitleID varchar(10),
  15234. TitleValue int
  15235. )
  15236. IF (@TableID = 0)
  15237. BEGIN
  15238. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  15239. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  15240. FROM #Job WITH(NOLOCK)
  15241. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  15242. ----计算全部某职位类别,2, 4位的数据
  15243. IF @JobTypeLen NOT IN(2, 4)
  15244. BEGIN
  15245. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  15246. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  15247. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  15248. END
  15249. IF @JobTypeLen NOT IN(0, 4)
  15250. BEGIN
  15251. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  15252. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  15253. FROM @sc2 WHERE LEN(TitleId) = 4
  15254. END
  15255. IF @JobTypeLen = -1
  15256. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  15257. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  15258. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  15259. DELETE @sc
  15260. DELETE @sc2
  15261. --------
  15262. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  15263. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  15264. GROUP BY dcRegionID ORDER BY dcRegionID
  15265. ----计算全部地区,2位的数据
  15266. IF @JobPlaceLen IN(-1, 0)
  15267. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  15268. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  15269. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  15270. IF @JobPlaceLen IN(-1, 2)
  15271. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  15272. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  15273. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  15274. IF @JobPlaceLen IN(-1, 4)
  15275. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  15276. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  15277. FROM @sc2 WHERE LEN(TitleID) = 6
  15278. IF @JobPlaceLen = -1
  15279. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  15280. ELSE
  15281. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  15282. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  15283. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  15284. ----------------
  15285. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  15286. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  15287. GROUP BY EmployType ORDER BY EmployType
  15288. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  15289. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  15290. FROM #Job WITH(NOLOCK)
  15291. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  15292. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  15293. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  15294. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  15295. GROUP BY MinExperience ORDER BY MinExperience
  15296. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  15297. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  15298. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  15299. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  15300. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  15301. GROUP BY dcSalaryID ORDER BY dcSalaryID
  15302. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  15303. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  15304. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  15305. WHERE a.cpMainId = b.cpMainId
  15306. GROUP BY b.dcIndustryId ORDER BY b.dcIndustryId
  15307. IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
  15308. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  15309. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  15310. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  15311. WHERE b.ID = a.JobId
  15312. AND CHARINDEX(@KeyWord, a.JobName) > 0
  15313. ORDER BY a.OrderType, a.OpenDate DESC
  15314. ELSE
  15315. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  15316. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  15317. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  15318. WHERE b.ID = a.JobId
  15319. ORDER BY a.OrderType, a.OpenDate DESC
  15320. SET @TopRows = @@ROWCOUNT
  15321. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  15322. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowID
  15323. SET @AllRows = @@ROWCOUNT
  15324. IF @TopRows = 0 AND @AllRows > 100
  15325. UPDATE SearchDB..paSearchJobID_0 SET IsTop = 1
  15326. WHERE paSearchConditionID = @paSearchConditionID
  15327. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
  15328. END
  15329. ELSE IF (@TableId = 1)
  15330. BEGIN
  15331. ----------------------------jobtype
  15332. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  15333. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  15334. FROM #Job WITH(NOLOCK)
  15335. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  15336. ----计算全部某职位类别,2, 4位的数据
  15337. IF @JobTypeLen NOT IN(2, 4)
  15338. BEGIN
  15339. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  15340. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  15341. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  15342. END
  15343. IF @JobTypeLen NOT IN(0, 4)
  15344. BEGIN
  15345. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  15346. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  15347. FROM @sc2 WHERE LEN(TitleId) = 4
  15348. END
  15349. IF @JobTypeLen = -1
  15350. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  15351. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  15352. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  15353. DELETE @sc
  15354. DELETE @sc2
  15355. --------------------------region
  15356. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  15357. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  15358. GROUP BY dcRegionID ORDER BY dcRegionID
  15359. ----计算全部地区,2位的数据
  15360. IF @JobPlaceLen IN(-1, 0)
  15361. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  15362. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  15363. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  15364. IF @JobPlaceLen IN(-1, 2)
  15365. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  15366. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  15367. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  15368. IF @JobPlaceLen IN(-1, 4)
  15369. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  15370. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  15371. FROM @sc2 WHERE LEN(TitleID) = 6
  15372. IF @JobPlaceLen = -1
  15373. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  15374. ELSE
  15375. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  15376. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  15377. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  15378. ----------------------------
  15379. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  15380. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  15381. FROM #Job WITH(NOLOCK)
  15382. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  15383. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  15384. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  15385. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  15386. GROUP BY MinExperience ORDER BY MinExperience
  15387. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  15388. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  15389. GROUP BY EmployType ORDER BY EmployType
  15390. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  15391. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  15392. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  15393. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  15394. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  15395. GROUP BY dcSalaryID ORDER BY dcSalaryID
  15396. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  15397. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  15398. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  15399. WHERE a.cpMainId = b.cpMainId
  15400. GROUP BY dcIndustryID ORDER BY dcIndustryID
  15401. IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
  15402. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  15403. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  15404. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  15405. WHERE b.ID = a.JobId
  15406. AND CHARINDEX(@KeyWord, a.JobName) > 0
  15407. ORDER BY a.OrderType, a.OpenDate DESC
  15408. ELSE
  15409. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  15410. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  15411. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  15412. WHERE b.ID = a.JobId
  15413. ORDER BY a.OrderType, a.OpenDate DESC
  15414. SET @TopRows = @@ROWCOUNT
  15415. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  15416. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowID
  15417. SET @AllRows = @@ROWCOUNT
  15418. IF @TopRows = 0 AND @AllRows > 100
  15419. UPDATE SearchDB..paSearchJobID_1 SET IsTop = 1
  15420. WHERE paSearchConditionID = @paSearchConditionID
  15421. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
  15422. END
  15423. ELSE IF (@TableId = 2)
  15424. BEGIN
  15425. ----------------------------jobtype
  15426. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  15427. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  15428. FROM #Job WITH(NOLOCK)
  15429. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  15430. ----计算全部某职位类别,2, 4位的数据
  15431. IF @JobTypeLen NOT IN(2, 4)
  15432. BEGIN
  15433. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  15434. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  15435. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  15436. END
  15437. IF @JobTypeLen NOT IN(0, 4)
  15438. BEGIN
  15439. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  15440. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  15441. FROM @sc2 WHERE LEN(TitleId) = 4
  15442. END
  15443. IF @JobTypeLen = -1
  15444. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  15445. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  15446. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  15447. DELETE @sc
  15448. DELETE @sc2
  15449. --------------------------region
  15450. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  15451. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  15452. GROUP BY dcRegionID ORDER BY dcRegionID
  15453. ----计算全部地区,2位的数据
  15454. IF @JobPlaceLen IN(-1, 0)
  15455. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  15456. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  15457. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  15458. IF @JobPlaceLen IN(-1, 2)
  15459. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  15460. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  15461. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  15462. IF @JobPlaceLen IN(-1, 4)
  15463. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  15464. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  15465. FROM @sc2 WHERE LEN(TitleID) = 6
  15466. IF @JobPlaceLen = -1
  15467. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  15468. ELSE
  15469. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  15470. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  15471. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  15472. ----------------------------
  15473. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  15474. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  15475. FROM #Job WITH(NOLOCK)
  15476. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  15477. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  15478. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  15479. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  15480. GROUP BY MinExperience ORDER BY MinExperience
  15481. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  15482. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  15483. GROUP BY dcSalaryID ORDER BY dcSalaryID
  15484. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  15485. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  15486. GROUP BY EmployType ORDER BY EmployType
  15487. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  15488. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  15489. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  15490. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  15491. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  15492. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  15493. WHERE a.cpMainId = b.cpMainId
  15494. GROUP BY dcIndustryID ORDER BY dcIndustryID
  15495. IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
  15496. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  15497. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  15498. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  15499. WHERE b.ID = a.JobId
  15500. AND CHARINDEX(@KeyWord, a.JobName) > 0
  15501. ORDER BY a.OrderType, a.OpenDate DESC
  15502. ELSE
  15503. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  15504. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  15505. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  15506. WHERE b.ID = a.JobId
  15507. ORDER BY a.OrderType, a.OpenDate DESC
  15508. SET @TopRows = @@ROWCOUNT
  15509. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  15510. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowID
  15511. SET @AllRows = @@ROWCOUNT
  15512. IF @TopRows = 0 AND @AllRows > 100
  15513. UPDATE SearchDB..paSearchJobID_2 SET IsTop = 1
  15514. WHERE paSearchConditionID = @paSearchConditionID
  15515. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
  15516. END
  15517. ELSE IF (@TableId = 3)
  15518. BEGIN
  15519. ----------------------------jobtype
  15520. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  15521. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  15522. FROM #Job WITH(NOLOCK)
  15523. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  15524. ----计算全部某职位类别,2, 4位的数据
  15525. IF @JobTypeLen NOT IN(2, 4)
  15526. BEGIN
  15527. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  15528. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  15529. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  15530. END
  15531. IF @JobTypeLen NOT IN(0, 4)
  15532. BEGIN
  15533. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  15534. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  15535. FROM @sc2 WHERE LEN(TitleId) = 4
  15536. END
  15537. IF @JobTypeLen = -1
  15538. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  15539. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  15540. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  15541. DELETE @sc
  15542. DELETE @sc2
  15543. --------------------------region
  15544. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  15545. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  15546. GROUP BY dcRegionID ORDER BY dcRegionID
  15547. ----计算全部地区,2位的数据
  15548. IF @JobPlaceLen IN(-1, 0)
  15549. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  15550. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  15551. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  15552. IF @JobPlaceLen IN(-1, 2)
  15553. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  15554. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  15555. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  15556. IF @JobPlaceLen IN(-1, 4)
  15557. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  15558. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  15559. FROM @sc2 WHERE LEN(TitleID) = 6
  15560. IF @JobPlaceLen = -1
  15561. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  15562. ELSE
  15563. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  15564. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  15565. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  15566. ----------------------------
  15567. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  15568. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  15569. FROM #Job WITH(NOLOCK)
  15570. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  15571. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  15572. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  15573. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  15574. GROUP BY MinExperience ORDER BY MinExperience
  15575. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  15576. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  15577. GROUP BY dcSalaryID ORDER BY dcSalaryID
  15578. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  15579. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  15580. GROUP BY EmployType ORDER BY EmployType
  15581. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  15582. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  15583. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  15584. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  15585. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  15586. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  15587. WHERE a.cpMainId = b.cpMainId
  15588. GROUP BY dcIndustryID ORDER BY dcIndustryID
  15589. IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
  15590. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  15591. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  15592. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  15593. WHERE b.ID = a.JobId
  15594. AND CHARINDEX(@KeyWord, a.JobName) > 0
  15595. ORDER BY a.OrderType, a.OpenDate DESC
  15596. ELSE
  15597. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  15598. SELECT TOP 10 @paSearchConditionID, a.JobId, 1
  15599. FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
  15600. WHERE b.ID = a.JobId
  15601. ORDER BY a.OrderType, a.OpenDate DESC
  15602. SET @TopRows = @@ROWCOUNT
  15603. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  15604. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowID
  15605. SET @AllRows = @@ROWCOUNT
  15606. IF @TopRows = 0 AND @AllRows > 100
  15607. UPDATE SearchDB..paSearchJobID_3 SET IsTop = 1
  15608. WHERE paSearchConditionID = @paSearchConditionID
  15609. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
  15610. END
  15611. DROP TABLE #Job
  15612. --PRINT 'DROP #JOB ' + CONVERT(VARCHAR(30), GETDATE(), 121)
  15613. COMMIT
  15614. --GOTO GetRecordSet
  15615. GetRecordSet:
  15616. BEGIN
  15617. DECLARE @AllJobCount AS INT
  15618. ----返回查询数量
  15619. SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
  15620. SELECT @AllJobCount = ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
  15621. UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
  15622. ----返回20行查询结果
  15623. IF (@TableID = 0)
  15624. BEGIN
  15625. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  15626. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  15627. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
  15628. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  15629. a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
  15630. b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
  15631. ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
  15632. e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber
  15633. FROM JobPublish a WITH(NOLOCK)
  15634. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  15635. INNER JOIN SearchDB..paSearchJobID_0 c WITH(NOLOCK) ON a.id = c.JobID
  15636. INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
  15637. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  15638. WHERE paSearchConditionID=@paSearchConditionID
  15639. AND c.ID >= @MinId
  15640. ORDER BY c.ID, a.ID DESC
  15641. END
  15642. ELSE IF (@TableID = 1)
  15643. BEGIN
  15644. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  15645. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  15646. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
  15647. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  15648. a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
  15649. b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
  15650. ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
  15651. e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber
  15652. FROM JobPublish a WITH(NOLOCK)
  15653. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  15654. INNER JOIN SearchDB..paSearchJobID_1 c WITH(NOLOCK) ON a.id = c.JobID
  15655. INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
  15656. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  15657. WHERE paSearchConditionID=@paSearchConditionID
  15658. AND c.ID >= @MinId
  15659. ORDER BY c.ID, a.ID DESC
  15660. END
  15661. ELSE IF (@TableID = 2)
  15662. BEGIN
  15663. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  15664. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  15665. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
  15666. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  15667. a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
  15668. b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
  15669. ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
  15670. e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber
  15671. FROM JobPublish a WITH(NOLOCK)
  15672. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  15673. INNER JOIN SearchDB..paSearchJobID_2 c WITH(NOLOCK) ON a.id = c.JobID
  15674. INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
  15675. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  15676. WHERE paSearchConditionID=@paSearchConditionID
  15677. AND c.ID >= @MinId
  15678. ORDER BY c.ID, a.ID DESC
  15679. END
  15680. ELSE IF (@TableID = 3)
  15681. BEGIN
  15682. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  15683. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  15684. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
  15685. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  15686. a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
  15687. b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
  15688. ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
  15689. e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber
  15690. FROM JobPublish a WITH(NOLOCK)
  15691. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  15692. INNER JOIN SearchDB..paSearchJobID_3 c WITH(NOLOCK) ON a.id = c.JobID
  15693. INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
  15694. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  15695. WHERE paSearchConditionID=@paSearchConditionID
  15696. AND c.ID >= @MinId
  15697. ORDER BY c.ID, a.ID DESC
  15698. END
  15699. --RICHARD 2011-7-23 16:51分修改
  15700. ----返回统计数量
  15701. IF @Type=1
  15702. BEGIN
  15703. DECLARE @RegionCount AS INT
  15704. SELECT @RegionCount = -1
  15705. IF CHARINDEX(',', @dcRegionID) = 0 AND LEN(@dcRegionID) > 0
  15706. BEGIN
  15707. IF NOT LEFT(@dcRegionID,1) = 'p'
  15708. SELECT @RegionCount = COUNT(*) FROM dcRegion WHERE ParentID = @dcRegionID
  15709. END
  15710. IF (@TableID = 0)
  15711. BEGIN
  15712. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  15713. IF @RegionCount = 0
  15714. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  15715. ELSE
  15716. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  15717. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15718. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15719. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15720. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15721. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15722. END
  15723. IF (@TableID = 1)
  15724. BEGIN
  15725. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  15726. IF @RegionCount = 0
  15727. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  15728. ELSE
  15729. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  15730. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15731. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15732. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15733. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15734. SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15735. END
  15736. IF (@TableID = 2)
  15737. BEGIN
  15738. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  15739. IF @RegionCount = 0
  15740. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  15741. ELSE
  15742. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  15743. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15744. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15745. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15746. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15747. SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15748. END
  15749. IF (@TableID = 3)
  15750. BEGIN
  15751. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  15752. IF @RegionCount = 0
  15753. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  15754. ELSE
  15755. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  15756. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15757. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15758. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15759. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15760. SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  15761. END
  15762. END
  15763. RETURN
  15764. END
  15765. END TRY
  15766. BEGIN CATCH
  15767. ROLLBACK TRANSACTION
  15768. ---检查是否已经建立临时表,已经建立则删除
  15769. DECLARE @para VARCHAR(MAX)
  15770. SET @para = '@dcJobTypeID=' + ISNULL(@dcJobTypeID, '') + '|' +
  15771. '@dcRegionID=' + ISNULL(@dcRegionID, '') + '|' +
  15772. '@dcIndustryID=' + ISNULL(@dcIndustryID, '') + '|' +
  15773. '@EmployType=' + ISNULL(@EmployType, '') + '|' +
  15774. '@KeyWord=' + ISNULL(@KeyWord, '') + '|' +
  15775. '@ORDER=' + ISNULL(@ORDER, '') + '|' +
  15776. '@SessionID=' + ISNULL(@SessionID, '') + '|' +
  15777. '@Welfare=' + ISNULL(@Welfare, '')
  15778. INSERT INTO ErrorLog
  15779. SELECT 'm1 ' + ISNULL(error_Message(), ' no msg')+ ' para=' + ISNULL(@Para, 'no para ') + ISNULL(@SQL, ' no sql'), error_number(), error_line(), GETDATE()
  15780. END CATCH
  15781. GO
  15782. /****** Object: StoredProcedure [dbo].[mblJobBySearchSelect2] Script Date: 2018/12/13 19:07:47 ******/
  15783. SET ANSI_NULLS ON
  15784. GO
  15785. SET QUOTED_IDENTIFIER ON
  15786. GO
  15787. CREATE PROCEDURE [dbo].[mblJobBySearchSelect2]
  15788. (
  15789. @dcJobTypeID VARCHAR(100), --职位类别
  15790. @dcRegionID VARCHAR(100), --求职地区
  15791. @dcIndustryID VARCHAR(100), --求职行业
  15792. @dcSalaryID TINYINT, --月薪
  15793. @IsNegotiable BIT, --1允许面议,不面议
  15794. @MinExperience TINYINT, --工作经验,100为未选择
  15795. @dcEducationID TINYINT, --最低学历
  15796. @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习,
  15797. @KeyWord NVARCHAR(50), --关键词
  15798. @KeyType TINYINT, --搜索类别,0无;1-全文;2-职位;3-公司
  15799. @ORDER VARCHAR(4), --显示顺序,没有用
  15800. @RefreshNo INT, --1, 1天内;2, 3天内;3,一周内;4,15天内;5,一个月内;6超过一个月
  15801. @Type INT, --1:主动搜索 点击搜索按钮 10分钟,翻页60分钟有效;0:翻页搜索,不刷新
  15802. @PageNumber INT, --翻页页码
  15803. @SessionID varchar(50), --10
  15804. @CompanySizeID VARCHAR(1), --企业规模
  15805. @IsOnline INT,
  15806. @Welfare VARCHAR(50) --
  15807. )
  15808. AS
  15809. --return @SessionId = 10
  15810. SET NOCOUNT ON
  15811. INSERT INTO SearchIp(Ip, Source) SELECT @SessionId, 'm'
  15812. IF EXISTS(SELECT 'x' FROM RefuseIp WITH(NOLOCK) WHERE CHARINDEX(Ip,@SessionId) > 0)
  15813. RETURN
  15814. SET @SessionId = 10
  15815. SET @KeyType = 0
  15816. BEGIN TRY
  15817. DECLARE @ReuseNumber AS INT, @dcProvinceId VARCHAR(2), @Order2 VARCHAR(100)
  15818. ----给null值变量赋默认值
  15819. IF NOT LEFT(@dcRegionID,1) = 'p'
  15820. SELECT @dcRegionID = RTRIM(dbo.FormatIDS(@dcRegionID))
  15821. SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
  15822. @dcIndustryID = RTRIM(dbo.FormatIDS(@dcIndustryID)),
  15823. @dcSalaryID = ISNULL(@dcSalaryID, 0),
  15824. @IsNegotiable = ISNULL(@IsNegotiable, 0),
  15825. @MinExperience = ISNULL(@MinExperience, 100),
  15826. @dcEducationID = ISNULL(@dcEducationID, 0),
  15827. @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END,
  15828. @CompanySizeID = ISNULL(@CompanySizeID, '0'),
  15829. @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, '')),
  15830. @ORDER = ISNULL(@Order, ''),
  15831. @Type = ISNULL(@Type, 0),
  15832. @PageNumber = ISNULL(@PageNumber, 0),
  15833. @Welfare = RTRIM(dbo.FormatIDS(@Welfare)),
  15834. @IsOnline = ISNULL(@IsOnline, 0),
  15835. @Order2 = ' ORDER BY a.RefreshDate DESC, a.SecondID DESC'
  15836. IF @dcSalaryID = 0
  15837. SET @IsNegotiable = 0
  15838. IF @Order LIKE 'p=%'
  15839. SET @dcProvinceId = REPLACE(@Order, 'p=', '')
  15840. ELSE
  15841. SET @dcProvinceId = 0
  15842. --@RefreshNo = 0选择全部数据,不限制时间
  15843. SET @RefreshNo = 0
  15844. IF(@KeyWord = '' AND ISNULL(@dcJobTypeID, '') = '' AND ISNULL(@dcRegionID, '') = '' AND ISNULL(@dcIndustryID, '') = '')
  15845. RETURN
  15846. --如果关键词不为空 查询关键词对应的搜索类型 max 2012-12-25
  15847. IF RIGHT(@KeyWord, 2) = '公司'
  15848. SET @KeyWord = LEFT(@KeyWord, LEN(@KeyWord) - 2)
  15849. IF RIGHT(@dcJobTypeID, 1) = ','
  15850. SET @dcJobTypeID = LEFT(@dcJobTypeID, LEN(@dcJobTypeID) - 1)
  15851. IF RIGHT(@dcRegionID, 1) = ','
  15852. SET @dcRegionID = LEFT(@dcRegionID, LEN(@dcRegionID) - 1)
  15853. IF RIGHT(@dcIndustryID, 1) = ','
  15854. SET @dcIndustryID = LEFT(@dcIndustryID, LEN(@dcIndustryID) - 1)
  15855. DECLARE @paSearchConditionID AS INT,
  15856. @MinId AS INT,
  15857. @PageSize AS TINYINT,
  15858. @TableID AS TINYINT
  15859. SELECT @paSearchConditionID = 0, @PageSize = 30
  15860. ----搜索1分钟前的数据
  15861. SELECT TOP 1 @paSearchConditionID = ID,
  15862. @ReuseNumber = ReuseNumber
  15863. FROM SearchDB..paSearchCondition WITH(NOLOCK)
  15864. WHERE JobType=@dcJobTypeID AND IsOnline = @IsOnline
  15865. AND JobPlace=@dcRegionID AND Industry=@dcIndustryID AND Education=@dcEducationID
  15866. AND Experience=@MinExperience AND Salary=@dcSalaryID AND IsNegotiable=@IsNegotiable
  15867. AND EmployType=@EmployType AND ISNULL(KeyWord, '') = @KeyWord AND KeyType = @KeyType
  15868. AND CompanySizeID = @CompanySizeID AND Welfare = @Welfare AND IsDelete = 0
  15869. AND LogTime > DATEADD(MINUTE, -1, GETDATE()) AND ReuseNumber > 0
  15870. AND RefreshNo = 0 AND ISNULL(dcProvinceId, 0) = @dcProvinceId
  15871. ORDER BY ID DESC
  15872. IF @ReuseNumber = 0
  15873. BEGIN
  15874. SELECT TOP 1 @paSearchConditionID = ID
  15875. FROM SearchDB..paSearchCondition WITH(NOLOCK)
  15876. WHERE JobType=@dcJobTypeID AND IsOnline = @IsOnline
  15877. AND JobPlace=@dcRegionID AND Industry=@dcIndustryID AND Education=@dcEducationID
  15878. AND Experience=@MinExperience AND Salary=@dcSalaryID AND IsNegotiable=@IsNegotiable
  15879. AND EmployType=@EmployType AND ISNULL(KeyWord, '') = @KeyWord AND KeyType=@KeyType
  15880. AND CompanySizeID = @CompanySizeID AND Welfare = @Welfare AND ReuseNumber > 0
  15881. AND ReuseNumber > 0 AND LogTime > DATEADD(MINUTE, -2, GETDATE())
  15882. AND RefreshNo = 0 AND ISNULL(dcProvinceId, 0) = @dcProvinceId
  15883. ORDER BY ID DESC
  15884. END
  15885. IF ISNULL(@paSearchConditionID, 0) = 0
  15886. BEGIN
  15887. SET @Type =1
  15888. GOTO SelectReset --无数据,重新搜索
  15889. END
  15890. ELSE
  15891. BEGIN
  15892. SELECT @TableID = @paSearchConditionID % 4
  15893. GOTO GetRecordSet --从临时结果中提取数据
  15894. END
  15895. SelectReset:
  15896. --从job中搜索数据
  15897. BEGIN TRAN
  15898. DECLARE @SQL AS VARCHAR(8000)
  15899. DECLARE @WHERE AS VARCHAR(8000)
  15900. DECLARE @FROM AS VARCHAR(1000)
  15901. ----记录查询条件
  15902. INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
  15903. Salary, IsNegotiable, EmployType, CompanySizeID, KeyWord, KeyType, ReuseNumber, Welfare, IsOnline, dcProvinceId)
  15904. VALUES(@SessionId, GETDATE(), @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcEducationID, @MinExperience,
  15905. @dcSalaryID, @IsNegotiable, @EmployType, @CompanySizeID, @KeyWord, @KeyType, 0, @Welfare, @IsOnline, @dcProvinceId)
  15906. SET @paSearchConditionID = @@IDENTITY
  15907. SELECT @TableID = @paSearchConditionID % 4
  15908. ------生成职位类别的表变量,因为职位类别有包含(父子)关系
  15909. DECLARE @T_JobPlace AS TABLE(ID INT)
  15910. DECLARE @T_JobType AS TABLE(ID INT)
  15911. DECLARE @JobPlaceLen AS INT, @JobTypeLen AS INT
  15912. IF CHARINDEX(',', @dcJobTypeID) > 0
  15913. SET @JobTypeLen = -1
  15914. ELSE
  15915. SET @JobTypeLen = LEN(@dcJobTypeID)
  15916. DECLARE @JobType AS VARCHAR(3000), @JobPlace AS VARCHAR(2000), @ValidJobNumber AS INT
  15917. SELECT @JobPlace = '', @JobType=''
  15918. ----生成工作地点的表变量
  15919. IF LEN(@dcRegionID) > 0
  15920. BEGIN
  15921. IF LEFT(@dcRegionID,1) = 'p'
  15922. BEGIN
  15923. DECLARE @Degree AS DECIMAL(8,5),@LBLng AS DECIMAL(8,5),@LBLat AS DECIMAL(8,5),
  15924. @RTLng AS DECIMAL(8,5),@RTLat AS DECIMAL(8,5),@Lat AS DECIMAL(8,5),@Lng AS DECIMAL(8,5)
  15925. SELECT @Lat = Lat,@Lng = Lng FROM dcMapPlace WITH(NOLOCK) WHERE ID = RIGHT(@dcRegionID,LEN(@dcRegionID)-1)
  15926. IF @dcRegionID LIKE '3201%'
  15927. SET @Degree = 1000 / 100000.0
  15928. ELSE
  15929. SET @Degree = 2000 / 100000.0
  15930. SET @LBLng = @Lng - @Degree
  15931. SET @LBLat = @Lat - @Degree
  15932. SET @RTLng = @Lng + @Degree
  15933. SET @RTLat = @Lat + @Degree
  15934. SET @JobPlace = 'a.Lng BETWEEN ' + CONVERT(VARCHAR,@LBLng) + ' AND ' + CONVERT(VARCHAR,@RTLng) + '
  15935. AND a.Lat BETWEEN ' + CONVERT(VARCHAR,@LBLat) + ' AND ' + CONVERT(VARCHAR,@RTLat) + '
  15936. AND (a.Lng-' + CONVERT(VARCHAR,@Lng) + ')*(a.Lng-' + CONVERT(VARCHAR,@Lng) + ')+
  15937. (a.Lat-' + CONVERT(VARCHAR,@Lat) + ')*(a.Lat-' + CONVERT(VARCHAR,@Lat) + ')<' + CONVERT(VARCHAR,@Degree*@Degree)
  15938. SELECT @JobPlaceLen = 8
  15939. END
  15940. ELSE
  15941. BEGIN
  15942. INSERT INTO @T_JobPlace
  15943. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  15944. SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  15945. IF LEN(@JobPlace) > 0
  15946. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  15947. IF (SELECT COUNT(*) FROM @T_JobPlace) > 1
  15948. SET @JobPlaceLen = -1
  15949. ELSE
  15950. SET @JobPlaceLen = LEN(@dcRegionID)
  15951. END
  15952. END
  15953. ELSE
  15954. SELECT @JobPlaceLen = 0
  15955. ----生成求聘职位的表变量
  15956. IF LEN(@dcJobTypeID) > 0
  15957. BEGIN
  15958. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  15959. INSERT INTO @T_Temp
  15960. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  15961. INSERT INTO @T_JobType
  15962. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  15963. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  15964. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  15965. OR ID IN(SELECT ID FROM @T_TEMP)
  15966. ----生成in字符串
  15967. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  15968. IF RIGHT(@JobType, 1) = ','
  15969. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  15970. END
  15971. ----建立临时表
  15972. CREATE TABLE #Job(
  15973. RowID INT IDENTITY(1, 1),
  15974. ID INT NOT NULL,
  15975. cpMainId INT,
  15976. dcJobTypeID SMALLINT NOT NULL,
  15977. dcJobTypeIDMinor SMALLINT NULL,
  15978. dcSalaryID TINYINT NOT NULL,
  15979. dcRegionID VARCHAR(6) NULL,
  15980. dcEducationID TINYINT NOT NULL,
  15981. MinExperience TINYINT NOT NULL,
  15982. RefreshDate SMALLDATETIME NULL,
  15983. EmployType TINYINT NULL,
  15984. dcCompanySizeID SMALLINT NULL
  15985. )
  15986. CREATE TABLE #FullText(
  15987. Priority INT,
  15988. JobId INT NOT NULL
  15989. )
  15990. ------刷新时间,根据刷新时间编号计算
  15991. ----生成插入临时表的Sql语句
  15992. SET @SQL='
  15993. INSERT INTO #Job
  15994. SELECT a.ID, a.cpMainId, a.dcJobTypeID,
  15995. a.dcJobTypeIDMinor, a.dcSalaryID,
  15996. a.dcRegionID, a.dcEducationID, a.MinExperience,
  15997. a.IssueDate,a.EmployType,b.dcCompanySizeID'
  15998. SET @FROM = '
  15999. FROM JobPublish a WITH(NOLOCK)
  16000. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  16001. ----职位有效,单位新有效
  16002. IF LEN(@dcIndustryID) > 0
  16003. SET @WHERE = '
  16004. WHERE b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @dcIndustryID + '))
  16005. AND a.Valid = 1
  16006. AND b.Valid = 1'
  16007. ELSE
  16008. SET @WHERE = '
  16009. WHERE a.Valid = 1
  16010. AND b.Valid = 1'
  16011. IF LEN(@dcProvinceId) > 1
  16012. SET @WHere = @Where + ' AND b.dcProvinceId = ' + @dcProvinceId
  16013. ----职位类别
  16014. IF LEN(@JobType) > 0
  16015. SET @WHERE = @WHERE + '
  16016. AND (a.dcJobTypeID IN(' + @JobType +')
  16017. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  16018. IF LEN(@JobPlace) > 0
  16019. SET @WHERE = @WHERE + '
  16020. AND (' + @JobPlace + ')'
  16021. IF @dcSalaryID > 0
  16022. BEGIN
  16023. IF @dcSalaryID < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
  16024. BEGIN
  16025. SET @WHERE = @WHERE + '
  16026. AND a.dcSalaryID IN(' + LTRIM(STR(@dcSalaryID)) + ',' + LTRIM(STR(@dcSalaryID + 1))
  16027. IF @IsNegotiable = 1 --包括面议
  16028. SET @WHERE = @WHERE + ', 100'
  16029. SET @WHERE = @WHERE + ')'
  16030. END
  16031. IF @dcSalaryID = 100 ----从筛选结果中点击面议,值是100
  16032. BEGIN
  16033. SET @WHERE = @WHERE + '
  16034. AND a.dcSalaryID = 100'
  16035. END
  16036. IF @dcSalaryID BETWEEN 101 AND 106 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  16037. SET @WHERE = @WHERE + '
  16038. AND a.dcSalaryID <= ' + LTRIM(STR(@dcSalaryID-99)) + ' AND a.dcSalaryIDMax > ' + LTRIM(STR(@dcSalaryID-100))
  16039. IF @dcSalaryID > 106 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
  16040. SET @WHERE = @WHERE + '
  16041. AND a.dcSalaryID <= ' + LTRIM(STR(@dcSalaryID - 100)) + ' AND a.dcSalaryIDMax > ' + LTRIM(STR(@dcSalaryID-100))
  16042. END
  16043. ----工作经验要求
  16044. IF @MinExperience < 100
  16045. SET @WHERE = @WHERE + '
  16046. AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
  16047. ----学历要求
  16048. ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
  16049. IF @dcEducationID > 0
  16050. IF @dcEducationID = 2
  16051. SET @WHERE = @WHERE + '
  16052. AND a.dcEducationID IN(2, 3, 4)'
  16053. ELSE
  16054. SET @WHERE = @WHERE + '
  16055. AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
  16056. ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
  16057. IF LEN(@EmployType) > 0
  16058. SET @WHERE = @WHERE + '
  16059. AND a.EmployType IN (' + @EmployType + ')'
  16060. IF @CompanySizeID BETWEEN 1 AND 6
  16061. SET @WHERE = @WHERE + '
  16062. AND b.dcCompanySizeID = ' + LTRIM(STR(@CompanySizeID))
  16063. IF LEN(@Welfare) > 0
  16064. SET @WHERE = @WHERE + '
  16065. AND a.Welfare' + REPLACE(@Welfare, ',', ' = 1 AND a.Welfare') + ' = 1'
  16066. IF @IsOnline = 1
  16067. SET @WHERE = @WHERE + '
  16068. AND a.caMainId IN(SELECT caMainId FROM caOnline WITH(NOLOCK) WHERE IsOnline = 1)'
  16069. IF LEN(@KeyWord) > 0 ----使用全文搜索job和cpmain2个表,经过测试发现union最快
  16070. BEGIN
  16071. IF EXISTS(SELECT TOP 1 'x' FROM cpMainPublish WITH(NOLOCK) WHERE Name = @KeyWord)
  16072. BEGIN
  16073. SET @WHERE = @WHERE + '
  16074. AND b.Name = ''' + @KeyWord + ''''
  16075. SET @SQL = @SQL + @FROM + @WHERE
  16076. END
  16077. ELSE
  16078. BEGIN
  16079. DECLARE @KeyWordTemp NVARCHAR(50)
  16080. SET @KeyWordTemp = REPLACE(@KeyWord, ' ', '%')
  16081. IF LEN(@KeyWordTemp) > 1
  16082. BEGIN
  16083. IF @dcProvinceId > 0
  16084. BEGIN
  16085. INSERT #FullText
  16086. SELECT TOP 2000 2, b.ID
  16087. FROM cpMainPublish a WITH(NOLOCK),
  16088. JobPublish b WITH(NOLOCK)
  16089. WHERE a.Id = b.cpMainId
  16090. AND a.Name LIKE '%' + @KeyWordTemp + '%'
  16091. AND a.dcProvinceId = @dcprovinceId
  16092. ORDER BY b.RefreshDate DESC
  16093. INSERT #FullText
  16094. SELECT TOP 2000 1, b.ID
  16095. FROM cpMainPublish a WITH(NOLOCK),
  16096. JobPublish b WITH(NOLOCK)
  16097. WHERE a.Id = b.cpMainId
  16098. AND b.Name LIKE '%' + @KeyWordTemp + '%'
  16099. AND a.dcProvinceId = @dcprovinceId
  16100. ORDER BY b.RefreshDate DESC
  16101. END
  16102. ELSE
  16103. BEGIN
  16104. INSERT #FullText
  16105. SELECT TOP 2000 2, b.ID
  16106. FROM cpMainPublish a WITH(NOLOCK),
  16107. JobPublish b WITH(NOLOCK)
  16108. WHERE a.Id = b.cpMainId
  16109. AND a.Name LIKE '%' + @KeyWordTemp + '%'
  16110. ORDER BY b.RefreshDate DESC
  16111. INSERT #FullText
  16112. SELECT TOP 2000 1, b.ID
  16113. FROM cpMainPublish a WITH(NOLOCK),
  16114. JobPublish b WITH(NOLOCK)
  16115. WHERE a.Id = b.cpMainId
  16116. AND b.Name LIKE '%' + @KeyWordTemp + '%'
  16117. ORDER BY b.RefreshDate DESC
  16118. END
  16119. END
  16120. IF (SELECT COUNT(*) FROM #FullText) < 800
  16121. BEGIN
  16122. INSERT #FullText
  16123. SELECT TOP 5000 3, [Key]
  16124. FROM FREETEXTTABLE(cpMainJob, *, @KeyWord, 100000) AS KeyJob ORDER BY RANK DESC
  16125. END
  16126. DELETE a FROM #FullText a, #FullText b WHERE a.JobId = b.JobId AND a.Priority > b.Priority
  16127. --------------------
  16128. SELECT @FROM = @FROM + '
  16129. INNER JOIN #FullText ON a.ID = #FullText.JobId',
  16130. @ORDER2 = ' ORDER BY #FullText.Priority, a.RefreshDate DESC, a.SecondID DESC'
  16131. SET @SQL = @SQL + @FROM + @WHERE
  16132. END
  16133. END
  16134. ELSE
  16135. SELECT @SQL = @SQL + @FROM + @WHERE
  16136. SET @SQL = @SQL + @Order2
  16137. --原来是ORDER BY a.IssueDate DESC, a.ID,Richard 2011年11月23日17:06分修改
  16138. ----把符合条件的职位全部列出
  16139. --PRINT @SQL
  16140. EXEC(@SQL)
  16141. SET @ValidJobNumber = @@ROWCOUNT
  16142. ----记录查询结果总数
  16143. UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@SQL WHERE ID=@paSearchConditionID
  16144. IF LEN(@JobType) > 0 --IN(2, 4)
  16145. UPDATE #Job SET dcJobTypeId = dcJobTypeIDMinor
  16146. WHERE dcJobTypeID NOT IN(SELECT a FROM dbo.fnSplit(@JobType, ','))
  16147. ----插入JobType数据
  16148. DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
  16149. DECLARE @sc AS TABLE (
  16150. paSearchConditionID int,
  16151. Title varchar(20),
  16152. TitleID varchar(10),
  16153. TitleValue int
  16154. )
  16155. DECLARE @sc2 AS TABLE (
  16156. paSearchConditionID int,
  16157. Title varchar(20),
  16158. TitleID varchar(10),
  16159. TitleValue int
  16160. )
  16161. IF (@TableID = 0)
  16162. BEGIN
  16163. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  16164. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  16165. FROM #Job WITH(NOLOCK)
  16166. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  16167. ----计算全部某职位类别,2, 4位的数据
  16168. IF @JobTypeLen NOT IN(2, 4)
  16169. BEGIN
  16170. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  16171. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  16172. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  16173. END
  16174. IF @JobTypeLen NOT IN(0, 4)
  16175. BEGIN
  16176. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  16177. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  16178. FROM @sc2 WHERE LEN(TitleId) = 4
  16179. END
  16180. IF @JobTypeLen = -1
  16181. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  16182. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  16183. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  16184. DELETE @sc
  16185. DELETE @sc2
  16186. --------
  16187. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  16188. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  16189. GROUP BY dcRegionID ORDER BY dcRegionID
  16190. ----计算全部地区,2位的数据
  16191. IF @JobPlaceLen IN(-1, 0)
  16192. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  16193. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  16194. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  16195. IF @JobPlaceLen IN(-1, 2)
  16196. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  16197. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  16198. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  16199. IF @JobPlaceLen IN(-1, 4)
  16200. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  16201. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  16202. FROM @sc2 WHERE LEN(TitleID) = 6
  16203. IF @JobPlaceLen = -1
  16204. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  16205. ELSE
  16206. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  16207. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  16208. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  16209. ----------------
  16210. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  16211. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  16212. GROUP BY EmployType ORDER BY EmployType
  16213. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  16214. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  16215. FROM #Job WITH(NOLOCK)
  16216. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  16217. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  16218. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  16219. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  16220. GROUP BY MinExperience ORDER BY MinExperience
  16221. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  16222. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  16223. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  16224. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  16225. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  16226. GROUP BY dcSalaryID ORDER BY dcSalaryID
  16227. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  16228. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  16229. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  16230. WHERE a.cpMainId = b.cpMainId
  16231. GROUP BY b.dcIndustryId ORDER BY b.dcIndustryId
  16232. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  16233. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  16234. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  16235. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  16236. SET @TopRows = @@ROWCOUNT
  16237. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  16238. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  16239. SET @AllRows = @@ROWCOUNT
  16240. IF @TopRows = 0 AND @AllRows > 100
  16241. UPDATE SearchDB..paSearchJobID_0 SET IsTop = 1
  16242. WHERE paSearchConditionID = @paSearchConditionID
  16243. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  16244. END
  16245. ELSE IF (@TableId = 1)
  16246. BEGIN
  16247. ----------------------------jobtype
  16248. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  16249. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  16250. FROM #Job WITH(NOLOCK)
  16251. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  16252. ----计算全部某职位类别,2, 4位的数据
  16253. IF @JobTypeLen NOT IN(2, 4)
  16254. BEGIN
  16255. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  16256. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  16257. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  16258. END
  16259. IF @JobTypeLen NOT IN(0, 4)
  16260. BEGIN
  16261. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  16262. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  16263. FROM @sc2 WHERE LEN(TitleId) = 4
  16264. END
  16265. IF @JobTypeLen = -1
  16266. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  16267. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  16268. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  16269. DELETE @sc
  16270. DELETE @sc2
  16271. --------------------------region
  16272. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  16273. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  16274. GROUP BY dcRegionID ORDER BY dcRegionID
  16275. ----计算全部地区,2位的数据
  16276. IF @JobPlaceLen IN(-1, 0)
  16277. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  16278. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  16279. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  16280. IF @JobPlaceLen IN(-1, 2)
  16281. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  16282. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  16283. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  16284. IF @JobPlaceLen IN(-1, 4)
  16285. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  16286. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  16287. FROM @sc2 WHERE LEN(TitleID) = 6
  16288. IF @JobPlaceLen = -1
  16289. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  16290. ELSE
  16291. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  16292. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  16293. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  16294. ----------------------------
  16295. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  16296. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  16297. FROM #Job WITH(NOLOCK)
  16298. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  16299. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  16300. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  16301. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  16302. GROUP BY MinExperience ORDER BY MinExperience
  16303. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  16304. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  16305. GROUP BY EmployType ORDER BY EmployType
  16306. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  16307. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  16308. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  16309. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  16310. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  16311. GROUP BY dcSalaryID ORDER BY dcSalaryID
  16312. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  16313. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  16314. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  16315. WHERE a.cpMainId = b.cpMainId
  16316. GROUP BY dcIndustryID ORDER BY dcIndustryID
  16317. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  16318. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  16319. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  16320. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  16321. SET @TopRows = @@ROWCOUNT
  16322. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  16323. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  16324. SET @AllRows = @@ROWCOUNT
  16325. IF @TopRows = 0 AND @AllRows > 100
  16326. UPDATE SearchDB..paSearchJobID_1 SET IsTop = 1
  16327. WHERE paSearchConditionID = @paSearchConditionID
  16328. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  16329. END
  16330. ELSE IF (@TableId = 2)
  16331. BEGIN
  16332. ----------------------------jobtype
  16333. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  16334. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  16335. FROM #Job WITH(NOLOCK)
  16336. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  16337. ----计算全部某职位类别,2, 4位的数据
  16338. IF @JobTypeLen NOT IN(2, 4)
  16339. BEGIN
  16340. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  16341. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  16342. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  16343. END
  16344. IF @JobTypeLen NOT IN(0, 4)
  16345. BEGIN
  16346. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  16347. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  16348. FROM @sc2 WHERE LEN(TitleId) = 4
  16349. END
  16350. IF @JobTypeLen = -1
  16351. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  16352. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  16353. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  16354. DELETE @sc
  16355. DELETE @sc2
  16356. --------------------------region
  16357. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  16358. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  16359. GROUP BY dcRegionID ORDER BY dcRegionID
  16360. ----计算全部地区,2位的数据
  16361. IF @JobPlaceLen IN(-1, 0)
  16362. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  16363. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  16364. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  16365. IF @JobPlaceLen IN(-1, 2)
  16366. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  16367. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  16368. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  16369. IF @JobPlaceLen IN(-1, 4)
  16370. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  16371. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  16372. FROM @sc2 WHERE LEN(TitleID) = 6
  16373. IF @JobPlaceLen = -1
  16374. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  16375. ELSE
  16376. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  16377. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  16378. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  16379. ----------------------------
  16380. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  16381. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  16382. FROM #Job WITH(NOLOCK)
  16383. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  16384. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  16385. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  16386. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  16387. GROUP BY MinExperience ORDER BY MinExperience
  16388. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  16389. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  16390. GROUP BY dcSalaryID ORDER BY dcSalaryID
  16391. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  16392. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  16393. GROUP BY EmployType ORDER BY EmployType
  16394. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  16395. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  16396. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  16397. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  16398. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  16399. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  16400. WHERE a.cpMainId = b.cpMainId
  16401. GROUP BY dcIndustryID ORDER BY dcIndustryID
  16402. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  16403. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  16404. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  16405. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  16406. SET @TopRows = @@ROWCOUNT
  16407. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  16408. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  16409. SET @AllRows = @@ROWCOUNT
  16410. IF @TopRows = 0 AND @AllRows > 100
  16411. UPDATE SearchDB..paSearchJobID_2 SET IsTop = 1
  16412. WHERE paSearchConditionID = @paSearchConditionID
  16413. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  16414. END
  16415. ELSE IF (@TableId = 3)
  16416. BEGIN
  16417. ----------------------------jobtype
  16418. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  16419. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
  16420. FROM #Job WITH(NOLOCK)
  16421. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  16422. ----计算全部某职位类别,2, 4位的数据
  16423. IF @JobTypeLen NOT IN(2, 4)
  16424. BEGIN
  16425. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  16426. SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  16427. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  16428. END
  16429. IF @JobTypeLen NOT IN(0, 4)
  16430. BEGIN
  16431. INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
  16432. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
  16433. FROM @sc2 WHERE LEN(TitleId) = 4
  16434. END
  16435. IF @JobTypeLen = -1
  16436. DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
  16437. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  16438. SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
  16439. DELETE @sc
  16440. DELETE @sc2
  16441. --------------------------region
  16442. INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
  16443. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  16444. GROUP BY dcRegionID ORDER BY dcRegionID
  16445. ----计算全部地区,2位的数据
  16446. IF @JobPlaceLen IN(-1, 0)
  16447. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  16448. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  16449. FROM @sc2 GROUP BY LEFT(TitleID, 2)
  16450. IF @JobPlaceLen IN(-1, 2)
  16451. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  16452. SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  16453. FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
  16454. IF @JobPlaceLen IN(-1, 4)
  16455. INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
  16456. SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
  16457. FROM @sc2 WHERE LEN(TitleID) = 6
  16458. IF @JobPlaceLen = -1
  16459. DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
  16460. ELSE
  16461. DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
  16462. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  16463. SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
  16464. ----------------------------
  16465. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  16466. SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
  16467. FROM #Job WITH(NOLOCK)
  16468. GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  16469. ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
  16470. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  16471. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  16472. GROUP BY MinExperience ORDER BY MinExperience
  16473. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  16474. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  16475. GROUP BY dcSalaryID ORDER BY dcSalaryID
  16476. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  16477. SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
  16478. GROUP BY EmployType ORDER BY EmployType
  16479. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  16480. SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
  16481. GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
  16482. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  16483. SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
  16484. FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
  16485. WHERE a.cpMainId = b.cpMainId
  16486. GROUP BY dcIndustryID ORDER BY dcIndustryID
  16487. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  16488. SELECT Top 3 @paSearchConditionID, a.JobId, 1
  16489. FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  16490. WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
  16491. SET @TopRows = @@ROWCOUNT
  16492. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  16493. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  16494. SET @AllRows = @@ROWCOUNT
  16495. IF @TopRows = 0 AND @AllRows > 100
  16496. UPDATE SearchDB..paSearchJobID_3 SET IsTop = 1
  16497. WHERE paSearchConditionID = @paSearchConditionID
  16498. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  16499. END
  16500. DROP TABLE #Job
  16501. --PRINT 'DROP #JOB ' + CONVERT(VARCHAR(30), GETDATE(), 121)
  16502. COMMIT
  16503. --GOTO GetRecordSet
  16504. GetRecordSet:
  16505. BEGIN
  16506. DECLARE @AllJobCount AS INT
  16507. ----返回查询数量
  16508. SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
  16509. SELECT @AllJobCount = ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
  16510. UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
  16511. ----返回20行查询结果
  16512. IF (@TableID = 0)
  16513. BEGIN
  16514. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  16515. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  16516. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
  16517. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  16518. a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
  16519. b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
  16520. ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
  16521. e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber,
  16522. f.Description EducationName,g.Description ExperienceName,
  16523. h.DescriptionCp dcSalary,i.DescriptionCp dcSalaryMax
  16524. FROM JobPublish a WITH(NOLOCK)
  16525. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  16526. INNER JOIN SearchDB..paSearchJobID_0 c WITH(NOLOCK) ON a.id = c.JobID
  16527. INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
  16528. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  16529. INNER JOIN dcEducation f WITH(NOLOCK) ON f.ID = a.dcEducationID
  16530. INNER JOIN dcOthers g WITH(NOLOCK) ON g.DetailID = a.MinExperience AND g.Category='职位要求工作经验'
  16531. INNER JOIN dcSalary h WITH(NOLOCK) ON h.ID = a.dcSalaryID
  16532. INNER JOIN dcSalary i WITH(NOLOCK) ON i.ID = a.dcSalaryIDMax
  16533. WHERE paSearchConditionID=@paSearchConditionID
  16534. AND c.ID >= @MinId
  16535. ORDER BY c.ID, a.ID DESC
  16536. END
  16537. ELSE IF (@TableID = 1)
  16538. BEGIN
  16539. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  16540. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  16541. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
  16542. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  16543. a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
  16544. b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
  16545. ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
  16546. e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber,
  16547. f.Description EducationName,g.Description ExperienceName,
  16548. h.DescriptionCp dcSalary,i.DescriptionCp dcSalaryMax
  16549. FROM JobPublish a WITH(NOLOCK)
  16550. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  16551. INNER JOIN SearchDB..paSearchJobID_1 c WITH(NOLOCK) ON a.id = c.JobID
  16552. INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
  16553. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  16554. INNER JOIN dcEducation f WITH(NOLOCK) ON f.ID = a.dcEducationID
  16555. INNER JOIN dcOthers g WITH(NOLOCK) ON g.DetailID = a.MinExperience AND g.Category='职位要求工作经验'
  16556. INNER JOIN dcSalary h WITH(NOLOCK) ON h.ID = a.dcSalaryID
  16557. INNER JOIN dcSalary i WITH(NOLOCK) ON i.ID = a.dcSalaryIDMax
  16558. WHERE paSearchConditionID=@paSearchConditionID
  16559. AND c.ID >= @MinId
  16560. ORDER BY c.ID, a.ID DESC
  16561. END
  16562. ELSE IF (@TableID = 2)
  16563. BEGIN
  16564. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  16565. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  16566. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
  16567. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  16568. a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
  16569. b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
  16570. ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
  16571. e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber,
  16572. f.Description EducationName,g.Description ExperienceName,
  16573. h.DescriptionCp dcSalary,i.DescriptionCp dcSalaryMax
  16574. FROM JobPublish a WITH(NOLOCK)
  16575. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  16576. INNER JOIN SearchDB..paSearchJobID_2 c WITH(NOLOCK) ON a.id = c.JobID
  16577. INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
  16578. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  16579. INNER JOIN dcEducation f WITH(NOLOCK) ON f.ID = a.dcEducationID
  16580. INNER JOIN dcOthers g WITH(NOLOCK) ON g.DetailID = a.MinExperience AND g.Category='职位要求工作经验'
  16581. INNER JOIN dcSalary h WITH(NOLOCK) ON h.ID = a.dcSalaryID
  16582. INNER JOIN dcSalary i WITH(NOLOCK) ON i.ID = a.dcSalaryIDMax
  16583. WHERE paSearchConditionID=@paSearchConditionID
  16584. AND c.ID >= @MinId
  16585. ORDER BY c.ID, a.ID DESC
  16586. END
  16587. ELSE IF (@TableID = 3)
  16588. BEGIN
  16589. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  16590. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  16591. SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
  16592. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
  16593. a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
  16594. b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
  16595. ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
  16596. e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber,
  16597. f.Description EducationName,g.Description ExperienceName,
  16598. h.DescriptionCp dcSalary,i.DescriptionCp dcSalaryMax
  16599. FROM JobPublish a WITH(NOLOCK)
  16600. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
  16601. INNER JOIN SearchDB..paSearchJobID_3 c WITH(NOLOCK) ON a.id = c.JobID
  16602. INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
  16603. LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
  16604. INNER JOIN dcEducation f WITH(NOLOCK) ON f.ID = a.dcEducationID
  16605. INNER JOIN dcOthers g WITH(NOLOCK) ON g.DetailID = a.MinExperience AND g.Category='职位要求工作经验'
  16606. INNER JOIN dcSalary h WITH(NOLOCK) ON h.ID = a.dcSalaryID
  16607. INNER JOIN dcSalary i WITH(NOLOCK) ON i.ID = a.dcSalaryIDMax
  16608. WHERE paSearchConditionID=@paSearchConditionID
  16609. AND c.ID >= @MinId
  16610. ORDER BY c.ID, a.ID DESC
  16611. END
  16612. --RICHARD 2011-7-23 16:51分修改
  16613. ----返回统计数量
  16614. IF @Type=1
  16615. BEGIN
  16616. DECLARE @RegionCount AS INT
  16617. SELECT @RegionCount = -1
  16618. IF CHARINDEX(',', @dcRegionID) = 0 AND LEN(@dcRegionID) > 0
  16619. BEGIN
  16620. IF NOT LEFT(@dcRegionID,1) = 'p'
  16621. SELECT @RegionCount = COUNT(*) FROM dcRegion WHERE ParentID = @dcRegionID
  16622. END
  16623. IF (@TableID = 0)
  16624. BEGIN
  16625. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcJobType b ON b.ID = a.TitleID WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  16626. IF @RegionCount = 0
  16627. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  16628. ELSE
  16629. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcRegion b ON b.ID = a.TitleID WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  16630. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcEducation b ON b.ID = a.TitleID WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16631. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='职位要求工作经验' WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16632. SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16633. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='工作性质' WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16634. SELECT a.*,b.Description FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) LEFT JOIN dcCompanySize b ON b.ID = a.TitleID WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16635. END
  16636. IF (@TableID = 1)
  16637. BEGIN
  16638. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcJobType b ON b.ID = a.TitleID WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  16639. IF @RegionCount = 0
  16640. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  16641. ELSE
  16642. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcRegion b ON b.ID = a.TitleID WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  16643. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcEducation b ON b.ID = a.TitleID WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16644. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='职位要求工作经验' WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16645. SELECT * FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16646. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='工作性质' WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16647. SELECT a.*,b.Description FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) LEFT JOIN dcCompanySize b ON b.ID = a.TitleID WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16648. END
  16649. IF (@TableID = 2)
  16650. BEGIN
  16651. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcJobType b ON b.ID = a.TitleID WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  16652. IF @RegionCount = 0
  16653. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  16654. ELSE
  16655. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcRegion b ON b.ID = a.TitleID WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  16656. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcEducation b ON b.ID = a.TitleID WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16657. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='职位要求工作经验' WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16658. SELECT * FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16659. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='工作性质' WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16660. SELECT a.*,b.Description FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) LEFT JOIN dcCompanySize b ON b.ID = a.TitleID WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16661. END
  16662. IF (@TableID = 3)
  16663. BEGIN
  16664. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcJobType b ON b.ID = a.TitleID WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  16665. IF @RegionCount = 0
  16666. SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
  16667. ELSE
  16668. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcRegion b ON b.ID = a.TitleID WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
  16669. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcEducation b ON b.ID = a.TitleID WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16670. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='职位要求工作经验' WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16671. SELECT * FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16672. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcOthers b ON b.DetailID = a.TitleID AND Category='工作性质' WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16673. SELECT a.*,b.Description FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) LEFT JOIN dcCompanySize b ON b.ID = a.TitleID WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
  16674. END
  16675. END
  16676. RETURN
  16677. END
  16678. END TRY
  16679. BEGIN CATCH
  16680. ---检查是否已经建立临时表,已经建立则删除
  16681. PRINT 'error'
  16682. PRINT error_Message()
  16683. PRINT error_number()
  16684. PRINT error_line()
  16685. END CATCH
  16686. GO
  16687. /****** Object: StoredProcedure [dbo].[mblJobBySearchSelectSean] Script Date: 2018/12/13 19:07:48 ******/
  16688. SET ANSI_NULLS ON
  16689. GO
  16690. SET QUOTED_IDENTIFIER ON
  16691. GO
  16692. CREATE PROCEDURE [dbo].[mblJobBySearchSelectSean]
  16693. (
  16694. @dcJobTypeID VARCHAR(100), --职位类别
  16695. @dcRegionID VARCHAR(100), --求职地区
  16696. @dcIndustryID VARCHAR(100), --求职行业
  16697. @KeyWord NVARCHAR(50), --关键词
  16698. @PageNum INT,
  16699. @PageSize INT
  16700. )
  16701. AS
  16702. --return
  16703. SET NOCOUNT ON
  16704. BEGIN TRY
  16705. DECLARE @KeyWordTemp AS NVARCHAR(50),
  16706. @dcSalaryID AS TINYINT,
  16707. @IsNegotiable AS BIT,
  16708. @MinExperience AS TINYINT,
  16709. @dcEducationID AS TINYINT,
  16710. @EmployType AS VARCHAR(10),
  16711. @KeyType AS TINYINT,
  16712. @SessionID AS INT,
  16713. @ReuseNumber INT,
  16714. @ORDER VARCHAR(100)
  16715. IF @dcJobTypeID = '0'
  16716. SET @dcJobTypeID = ''
  16717. IF @dcRegionID = '0'
  16718. SET @dcRegionID = ''
  16719. IF @dcIndustryID = '0'
  16720. SET @dcIndustryID = ''
  16721. SET @KeyType = 1
  16722. ----给null值变量赋默认值
  16723. SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
  16724. @dcRegionID = RTRIM(dbo.FormatIDS(@dcRegionID)),
  16725. @dcIndustryID = RTRIM(dbo.FormatIDS(@dcIndustryID)),
  16726. @dcSalaryID = ISNULL(@dcSalaryID, 0),
  16727. @IsNegotiable = ISNULL(@IsNegotiable, 0),
  16728. @MinExperience = ISNULL(@MinExperience, 100),
  16729. @dcEducationID = ISNULL(@dcEducationID, 0),
  16730. @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END,
  16731. @KeyWord = REPLACE(dbo.SafeSQL(ISNULL(@KeyWord, '')), '''', ''),
  16732. @KeyType = CASE @KeyWord WHEN NULL THEN 0 ELSE @KeyType END,
  16733. @PageNum = ISNULL(@PageNum, 0),
  16734. @ORDER = ' ORDER BY a.RefreshDate DESC, a.ID'
  16735. IF (@KeyWord IS NOT NULL)
  16736. SET @KeyWordTemp = @KeyWord
  16737. IF LEN(@KeyWordTemp) > 2
  16738. SET @KeyWordTemp = REPLACE(@KeyWordTemp, '公司', '')
  16739. IF(@KeyType = 0 AND ISNULL(@dcJobTypeID, '') = '' AND ISNULL(@dcRegionID, '') = '' AND ISNULL(@dcIndustryID, '') = '')
  16740. RETURN
  16741. IF RIGHT(@dcJobTypeID, 1) = ','
  16742. SET @dcJobTypeID = LEFT(@dcJobTypeID, LEN(@dcJobTypeID) - 1)
  16743. IF RIGHT(@dcRegionID, 1) = ','
  16744. SET @dcRegionID = LEFT(@dcRegionID, LEN(@dcRegionID) - 1)
  16745. IF RIGHT(@dcIndustryID, 1) = ','
  16746. SET @dcIndustryID = LEFT(@dcIndustryID, LEN(@dcIndustryID) - 1)
  16747. DECLARE @paSearchConditionID AS INT,
  16748. @MinId AS INT,
  16749. @TableID AS TINYINT
  16750. SELECT @paSearchConditionID = 0, @SessionID = ISNULL(@SessionID, 9902) --每页的行数
  16751. ----搜索1分钟前的数据
  16752. SELECT TOP 1 @paSearchConditionID = ID,
  16753. @ReuseNumber = ReuseNumber
  16754. FROM SearchDB..paSearchCondition WITH(NOLOCK)
  16755. WHERE JobType=@dcJobTypeID
  16756. AND JobPlace=@dcRegionID AND Industry=@dcIndustryID AND Education=@dcEducationID
  16757. AND Experience=@MinExperience AND Salary=@dcSalaryID AND IsNegotiable=@IsNegotiable
  16758. AND EmployType=@EmployType AND KeyWord=@KeyWord AND KeyType=@KeyType
  16759. AND CompanySizeID IS NULL
  16760. AND Welfare IS NULL
  16761. AND IsDelete = 0
  16762. ORDER BY ID DESC
  16763. IF @ReuseNumber = 0
  16764. BEGIN
  16765. SELECT TOP 1 @paSearchConditionID = ID
  16766. FROM SearchDB..paSearchCondition WITH(NOLOCK)
  16767. WHERE SessionID=@SessionID AND JobType=@dcJobTypeID
  16768. AND JobPlace=@dcRegionID AND Industry=@dcIndustryID AND Education=@dcEducationID
  16769. AND Experience=@MinExperience AND Salary=@dcSalaryID AND IsNegotiable=@IsNegotiable
  16770. AND EmployType=@EmployType AND KeyWord=@KeyWord AND KeyType=@KeyType
  16771. AND CompanySizeID IS NULL
  16772. AND Welfare IS NULL
  16773. AND ReuseNumber > 0
  16774. ORDER BY ID DESC
  16775. END
  16776. IF ISNULL(@paSearchConditionID, 0) = 0
  16777. BEGIN
  16778. GOTO SelectReset --无数据,重新搜索
  16779. END
  16780. ELSE
  16781. BEGIN
  16782. SELECT @TableID = @paSearchConditionID % 4
  16783. GOTO GetRecordSet --从临时结果中提取数据
  16784. END
  16785. SelectReset: --从job中搜索数据
  16786. BEGIN TRAN
  16787. DECLARE @SQL AS VARCHAR(8000)
  16788. DECLARE @WHERE AS VARCHAR(8000)
  16789. DECLARE @FROM AS VARCHAR(1000)
  16790. ----记录查询条件
  16791. INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
  16792. Salary, IsNegotiable, EmployType, KeyWord, KeyType, ReuseNumber, Welfare)
  16793. VALUES(
  16794. ISNULL(@SessionId, 9902), GETDATE(), @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcEducationID, @MinExperience,
  16795. @dcSalaryID, @IsNegotiable, @EmployType, @KeyWord, @KeyType, 0, '')
  16796. SET @paSearchConditionID = @@IDENTITY
  16797. SELECT @TableID = @paSearchConditionID % 4
  16798. ------生成职位类别的表变量,因为职位类别有包含(父子)关系
  16799. DECLARE @T_JobPlace AS TABLE(ID INT)
  16800. DECLARE @T_JobType AS TABLE(ID INT)
  16801. DECLARE @JobType AS VARCHAR(3000)
  16802. DECLARE @JobPlace AS VARCHAR(2000)
  16803. DECLARE @ValidJobNumber AS INT
  16804. SET @JobPlace = ''
  16805. SET @JobType=''
  16806. ----生成工作地点的表变量
  16807. IF LEN(@dcRegionID) > 0
  16808. BEGIN
  16809. INSERT INTO @T_JobPlace
  16810. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  16811. SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  16812. IF LEN(@JobPlace) > 0
  16813. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  16814. END
  16815. ----生成求聘职位的表变量
  16816. IF LEN(@dcJobTypeID) > 0
  16817. BEGIN
  16818. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  16819. INSERT INTO @T_Temp
  16820. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  16821. INSERT INTO @T_JobType
  16822. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  16823. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  16824. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  16825. OR ID IN(SELECT ID FROM @T_TEMP)
  16826. ----生成in字符串
  16827. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  16828. IF RIGHT(@JobType, 1) = ','
  16829. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  16830. END
  16831. ----建立临时表
  16832. CREATE TABLE #Job(
  16833. RowID INT IDENTITY(1, 1),
  16834. ID INT NOT NULL,
  16835. dcJobTypeID SMALLINT NOT NULL,
  16836. dcJobTypeIDMinor SMALLINT NULL,
  16837. dcSalaryID TINYINT NOT NULL,
  16838. dcRegionID VARCHAR(6) NULL,
  16839. dcEducationID TINYINT NOT NULL,
  16840. MinExperience TINYINT NOT NULL,
  16841. RefreshDate SMALLDATETIME NULL
  16842. )
  16843. CREATE TABLE #FullText(
  16844. Priority INT,
  16845. JobId INT NOT NULL
  16846. )
  16847. ------刷新时间,根据刷新时间编号计算
  16848. ----生成插入临时表的Sql语句
  16849. SET @SQL='
  16850. INSERT INTO #Job
  16851. SELECT a.ID, a.dcJobTypeID,
  16852. a.dcJobTypeIDMinor, a.dcSalaryID,
  16853. a.dcRegionID, a.dcEducationID, a.MinExperience,
  16854. a.IssueDate'
  16855. SET @FROM = '
  16856. FROM JobPublish a WITH(NOLOCK)
  16857. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  16858. ----职位有效,单位新有效
  16859. IF LEN(@dcIndustryID) > 0
  16860. SET @WHERE = '
  16861. WHERE b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @dcIndustryID + '))
  16862. AND a.Valid = 1
  16863. AND b.Valid = 1'
  16864. ELSE
  16865. SET @WHERE = '
  16866. WHERE a.Valid = 1
  16867. AND b.Valid = 1'
  16868. ----需要增加全文索引的关键字查询
  16869. IF @KeyWord LIKE '% %'
  16870. BEGIN
  16871. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  16872. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  16873. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  16874. SET @KeyWord = '"' + REPLACE(@KeyWord, ' ', '" OR "') + '"'
  16875. END
  16876. IF @KeyWordTemp LIKE '% %'
  16877. BEGIN
  16878. SET @KeyWordTemp = REPLACE(@KeyWordTemp, ' ', ' ')
  16879. SET @KeyWordTemp = REPLACE(@KeyWordTemp, ' ', ' ')
  16880. SET @KeyWordTemp = REPLACE(@KeyWordTemp, ' ', ' ')
  16881. SET @KeyWordTemp = '"' + REPLACE(@KeyWordTemp, ' ', '" OR "') + '"'
  16882. END
  16883. ----职位类别
  16884. IF LEN(@dcJobTypeID) > 0
  16885. SET @WHERE = @WHERE + '
  16886. AND (a.dcJobTypeID IN(' + @JobType +')
  16887. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  16888. IF LEN(@JobPlace) > 0
  16889. SET @WHERE = @WHERE + '
  16890. AND (' + @JobPlace + ')'
  16891. IF LEN(@KeyWord) > 0 AND @KeyType = 1 ----使用全文搜索job和cpmain2个表,经过测试发现union最快
  16892. IF EXISTS(SELECT TOP 1 'x' FROM cpMainPublish WITH(NOLOCK) WHERE Name = @KeyWord)
  16893. BEGIN
  16894. SET @WHERE = @WHERE + '
  16895. AND b.Name = ''' + @KeyWord + ''''
  16896. SET @SQL = @SQL + @FROM + @WHERE
  16897. END
  16898. ELSE
  16899. BEGIN
  16900. INSERT #FullText
  16901. SELECT 1, [Key]
  16902. FROM CONTAINSTABLE(JobPublish, Name, @KeyWord, 100000) AS KeyJob
  16903. INSERT #FullText
  16904. SELECT 2, a.ID
  16905. FROM JobPublish a WITH(NOLOCK),
  16906. CONTAINSTABLE(cpMainPublish, Name, @KeyWord, 100000) AS b
  16907. WHERE a.cpMainId = b.[Key]
  16908. DELETE #FullText WHERE Priority = 2 AND JobId IN(SELECT JobId FROM #FullText WHERE Priority = 1)
  16909. IF (SELECT COUNT(*) FROM #FullText) < 5000
  16910. BEGIN
  16911. INSERT #FullText
  16912. SELECT 3, [Key]
  16913. FROM CONTAINSTABLE(JobPublish, *, @KeyWord, 100000) AS KeyJob
  16914. DELETE #FullText WHERE Priority = 3 AND JobId IN(SELECT JobId FROM #FullText WHERE Priority < 3)
  16915. IF (SELECT COUNT(*) FROM #FullText) < 5000
  16916. BEGIN
  16917. INSERT #FullText
  16918. SELECT 4, a.ID
  16919. FROM JobPublish a WITH(NOLOCK),
  16920. CONTAINSTABLE(cpMainPublish, *, @KeyWord, 100000) AS b
  16921. WHERE a.cpMainId = b.[Key]
  16922. DELETE #FullText WHERE Priority = 4 AND JobId IN(SELECT JobId FROM #FullText WHERE Priority < 4)
  16923. END
  16924. END
  16925. --------------------
  16926. SELECT @FROM = @FROM + '
  16927. INNER JOIN #FullText ON a.ID = #FullText.JobId',
  16928. @ORDER = ' ORDER BY #FullText.Priority, a.RefreshDate DESC, a.ID'
  16929. SET @SQL = @SQL + @FROM + @WHERE
  16930. END
  16931. ELSE
  16932. SET @SQL = @SQL + @FROM + @WHERE
  16933. SET @SQL = @SQL + @ORDER
  16934. EXEC(@SQL)
  16935. SET @ValidJobNumber = @@ROWCOUNT
  16936. ----记录查询结果总数
  16937. UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@SQL WHERE ID=@paSearchConditionID
  16938. ----插入JobType数据
  16939. IF (@TableID = 0)
  16940. BEGIN
  16941. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  16942. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  16943. END
  16944. ELSE IF (@TableId = 1)
  16945. BEGIN
  16946. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  16947. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  16948. END
  16949. ELSE IF (@TableId = 2)
  16950. BEGIN
  16951. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  16952. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  16953. END
  16954. ELSE IF (@TableId = 3)
  16955. BEGIN
  16956. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  16957. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  16958. END
  16959. DROP TABLE #Job
  16960. COMMIT
  16961. GetRecordSet:
  16962. BEGIN
  16963. ----返回查询数量
  16964. SELECT @ValidJobNumber=ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
  16965. UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
  16966. ----返回20行查询结果
  16967. IF (@TableID = 0)
  16968. BEGIN
  16969. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  16970. SET @MinId = @MinId+(@PageNum-1)*@PageSize
  16971. SELECT TOP 20 @ValidJobNumber AS cnt, a.ID,a.Name AS JobName,a.RefreshDate,b.Name cpName,
  16972. d.FullName Region, a.SecondId EnJobID, b.SecondId EnCpMainID
  16973. FROM JOBPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_0 c WITH(NOLOCK),
  16974. dcRegion d WITH(NOLOCK)
  16975. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND a.dcRegionID=d.ID AND c.paSearchConditionID=@paSearchConditionID
  16976. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  16977. END
  16978. ELSE IF (@TableID = 1)
  16979. BEGIN
  16980. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  16981. SET @MinId = @MinId+(@PageNum-1)*@PageSize
  16982. SELECT TOP 20 @ValidJobNumber AS cnt, a.ID,a.Name AS JobName,a.RefreshDate,b.Name cpName,
  16983. d.FullName Region, a.SecondId EnJobID, b.SecondId EnCpMainID
  16984. FROM JOBPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_1 c WITH(NOLOCK),
  16985. dcRegion d WITH(NOLOCK)
  16986. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND a.dcRegionID=d.ID AND c.paSearchConditionID=@paSearchConditionID
  16987. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  16988. END
  16989. ELSE IF (@TableID = 2)
  16990. BEGIN
  16991. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  16992. SET @MinId = @MinId+(@PageNum-1)*@PageSize
  16993. SELECT TOP 20 @ValidJobNumber AS cnt, a.ID,a.Name AS JobName,a.RefreshDate,b.Name cpName,
  16994. d.FullName Region, a.SecondId EnJobID, b.SecondId EnCpMainID
  16995. FROM JOBPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_2 c WITH(NOLOCK),
  16996. dcRegion d WITH(NOLOCK)
  16997. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND a.dcRegionID=d.ID AND c.paSearchConditionID=@paSearchConditionID
  16998. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  16999. END
  17000. ELSE IF (@TableID = 3)
  17001. BEGIN
  17002. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  17003. SET @MinId = @MinId+(@PageNum-1)*@PageSize
  17004. SELECT TOP 20 @ValidJobNumber AS cnt, a.ID,a.Name AS JobName,a.RefreshDate,b.Name cpName,
  17005. d.FullName Region, a.SecondId EnJobID, b.SecondId EnCpMainID
  17006. FROM JOBPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_3 c WITH(NOLOCK),
  17007. dcRegion d WITH(NOLOCK)
  17008. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND a.dcRegionID=d.ID AND c.paSearchConditionID=@paSearchConditionID
  17009. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  17010. END
  17011. RETURN
  17012. END
  17013. END TRY
  17014. BEGIN CATCH
  17015. ---检查是否已经建立临时表,已经建立则删除
  17016. PRINT 'error'
  17017. PRINT error_Message()
  17018. PRINT error_number()
  17019. PRINT error_line()
  17020. END CATCH
  17021. GO
  17022. /****** Object: StoredProcedure [dbo].[mblJobByWeixinSelect] Script Date: 2018/12/13 19:07:48 ******/
  17023. SET ANSI_NULLS ON
  17024. GO
  17025. SET QUOTED_IDENTIFIER ON
  17026. GO
  17027. CREATE PROCEDURE [dbo].[mblJobByWeixinSelect]
  17028. (
  17029. @FromUserName VARCHAR(50),
  17030. @Type INT --0:订阅号关键词查询;10:服务号的关键词查询;11:服务号的周边职位
  17031. )
  17032. AS
  17033. insert into proclog select 'mblJobByWeixinSelect', LTRIM(STR(@Type)) + ' ' + @FromUserName, getdate()
  17034. SET NOCOUNT ON
  17035. BEGIN TRY
  17036. DECLARE @dcRegionID VARCHAR(4),@KeyWord NVARCHAR(20),
  17037. @Lng DECIMAL(8,5),@Lat DECIMAL(8,5),@Distance INT,
  17038. @KeyType TINYINT, @ValidJobNumber INT, @PageNumber SMALLINT
  17039. IF @Type =11
  17040. BEGIN
  17041. SELECT @dcRegionID=dcRegionID,@KeyWord=KeyWord,
  17042. @Lng=Lng,@Lat=Lat,@PageNumber=PageNumber
  17043. FROM wxMessage WITH(NOLOCK)
  17044. WHERE FromUserName=@FromUserName AND CONTENT='推荐职位'
  17045. DELETE FROM wxMessage WHERE FromUserName=@FromUserName AND CONTENT <> '推荐职位'
  17046. END
  17047. ELSE
  17048. BEGIN
  17049. SELECT TOP 1 @dcRegionID=dcRegionID,@KeyWord=KeyWord,@PageNumber=PageNumber
  17050. FROM wxMessage WITH(NOLOCK) WHERE FromUserName=@FromUserName
  17051. ORDER BY ID DESC
  17052. DELETE FROM wxMessage WHERE FromUserName=@FromUserName AND CONTENT='推荐职位'
  17053. END
  17054. IF @Type =11 OR @Type = 10
  17055. BEGIN
  17056. UPDATE wxMessage SET PageNumber = 2 WHERE FromUserName=@FromUserName
  17057. END
  17058. ELSE
  17059. BEGIN
  17060. UPDATE wxMessage SET PageNumber=PageNumber+1 WHERE FromUserName=@FromUserName
  17061. END
  17062. --UPDATE wxMessage SET PageNumber=PageNumber+1 WHERE FromUserName=@FromUserName
  17063. SELECT @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, '')),
  17064. @KeyType = 2,
  17065. @Distance = 5000,
  17066. @PageNumber = ISNULL(@PageNumber, 1),
  17067. @dcRegionID = ISNULL(@dcRegionID, 0),
  17068. @Lng = ISNULL(@Lng, 0),
  17069. @Lat = ISNULL(@Lat, 0)
  17070. IF @dcRegionID = 0 AND @Lng = 0 AND @Lat = 0
  17071. RETURN
  17072. DECLARE @paSearchConditionID AS INT,
  17073. @MinId AS INT,
  17074. @PageSize AS TINYINT,
  17075. @TableID AS TINYINT
  17076. IF @Type =11 OR @Type =10
  17077. BEGIN
  17078. SELECT @paSearchConditionID = 0, @PageSize = 5 --每页的行数
  17079. END
  17080. ELSE
  17081. BEGIN
  17082. SELECT @paSearchConditionID = 0, @PageSize = 8 --每页的行数
  17083. END
  17084. --SELECT @paSearchConditionID = 0, @PageSize = 8 --每页的行数
  17085. ----搜索60分钟前的数据
  17086. SELECT TOP 1 @paSearchConditionID=ID FROM SearchDB..paSearchCondition WITH(NOLOCK)
  17087. WHERE JobType=''
  17088. AND JobPlace=@dcRegionID AND ISNULL(Industry,'')='' AND ISNULL(Education,'')=''
  17089. AND ISNULL(Experience,'')='' AND ISNULL(Salary,'')='' AND ISNULL(IsNegotiable,'')=''
  17090. AND ISNULL(EmployType,'')='' AND KeyWord=@KeyWord AND KeyType=@KeyType
  17091. AND ISNULL(CompanySizeID,'')='' AND Lng=@Lng AND Lat=@Lat
  17092. ORDER BY ID DESC
  17093. IF ISNULL(@paSearchConditionID, 0) = 0
  17094. BEGIN
  17095. GOTO SelectReset --无数据,重新搜索
  17096. END
  17097. ELSE
  17098. BEGIN
  17099. SELECT @TableID = @paSearchConditionID % 4
  17100. GOTO GetRecordSet --从临时结果中提取数据
  17101. END
  17102. SelectReset:
  17103. --从job中搜索数据
  17104. BEGIN TRAN
  17105. DECLARE @SQL AS VARCHAR(8000)
  17106. DECLARE @WHERE AS VARCHAR(8000)
  17107. DECLARE @FROM AS VARCHAR(1000)
  17108. ----记录查询条件
  17109. INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
  17110. Salary, IsNegotiable, EmployType, CompanySizeID, KeyWord, KeyType, ReuseNumber, Lng, Lat, Distance)
  17111. VALUES(1, GETDATE(), '', @dcRegionID, '', '', '', '', '', '', '', @KeyWord, @KeyType, 0, @Lng, @Lat, @Distance)
  17112. SET @paSearchConditionID = @@IDENTITY
  17113. SELECT @TableID = @paSearchConditionID % 4
  17114. ----建立临时表
  17115. CREATE TABLE #Job(
  17116. RowID INT IDENTITY(1, 1),
  17117. ID INT NOT NULL,
  17118. dcJobTypeID SMALLINT NOT NULL,
  17119. dcJobTypeIDMinor SMALLINT NULL,
  17120. dcSalaryID TINYINT NOT NULL,
  17121. dcRegionID VARCHAR(6) NULL,
  17122. dcEducationID TINYINT NOT NULL,
  17123. MinExperience TINYINT NOT NULL,
  17124. RefreshDate SMALLDATETIME NULL
  17125. )
  17126. ------刷新时间,根据刷新时间编号计算
  17127. ----生成插入临时表的Sql语句
  17128. SET @SQL='
  17129. INSERT INTO #Job
  17130. SELECT a.ID, a.dcJobTypeID,
  17131. a.dcJobTypeIDMinor, a.dcSalaryID,
  17132. a.dcRegionID, a.dcEducationID, a.MinExperience,
  17133. a.IssueDate'
  17134. SET @FROM = '
  17135. FROM JobPublish a WITH(NOLOCK)
  17136. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  17137. ----职位有效,单位新有效
  17138. SET @WHERE = '
  17139. WHERE a.Valid = 1
  17140. AND b.Valid = 1'
  17141. ----需要增加全文索引的关键字查询
  17142. IF @KeyWord LIKE '% %'
  17143. BEGIN
  17144. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  17145. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  17146. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  17147. SET @KeyWord = '"' + REPLACE(@KeyWord, ' ', '" OR "') + '"'
  17148. END
  17149. IF LEN(@KeyWord) > 0
  17150. BEGIN
  17151. IF @KeyType = 2
  17152. SET @FROM = @FROM + '
  17153. INNER JOIN CONTAINSTABLE(JobPublish, *, ''' + @KeyWord + ''', 1000000) AS KeyJob
  17154. ON a.ID = KeyJob.[Key]'
  17155. END
  17156. ---地区
  17157. IF @dcRegionID > 0
  17158. SET @WHERE = @WHERE + '
  17159. AND a.dcRegionID Like ''' + CONVERT(VARCHAR(6),@dcRegionID) + '%'''
  17160. IF @Lng > 0 AND @Lat > 0
  17161. BEGIN
  17162. DECLARE @Degree AS DECIMAL(8,5),@LBLng AS DECIMAL(8,5),@LBLat AS DECIMAL(8,5),
  17163. @RTLng AS DECIMAL(8,5),@RTLat AS DECIMAL(8,5)
  17164. SET @Degree = @Distance / 100000.0;
  17165. SET @LBLng = @Lng - @Degree
  17166. SET @LBLat = @Lat - @Degree
  17167. SET @RTLng = @Lng + @Degree
  17168. SET @RTLat = @Lat + @Degree
  17169. SET @WHERE = @WHERE + '
  17170. AND a.Lng BETWEEN ' + CONVERT(VARCHAR,@LBLng) + ' AND ' + CONVERT(VARCHAR,@RTLng) + '
  17171. AND a.Lat BETWEEN ' + CONVERT(VARCHAR,@LBLat) + ' AND ' + CONVERT(VARCHAR,@RTLat)
  17172. END
  17173. SET @SQL = @SQL + @FROM + @WHERE
  17174. SET @SQL=@SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
  17175. ----把符合条件的职位全部列出
  17176. --PRINT @SQL
  17177. EXEC(@SQL)
  17178. SET @ValidJobNumber = @@ROWCOUNT
  17179. ----记录查询结果总数
  17180. UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@SQL WHERE ID=@paSearchConditionID
  17181. ----插入JobType数据
  17182. DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
  17183. IF (@TableID = 0)
  17184. BEGIN
  17185. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  17186. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  17187. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  17188. ----计算全部某职位类别,2, 4位的数据
  17189. UPDATE a SET a.TitleValue = b.TitleValue
  17190. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
  17191. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  17192. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  17193. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  17194. GROUP BY LEFT(TitleID, 2)) b
  17195. WHERE a.TitleId = b.TitleID
  17196. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  17197. ----写入TitleDesc
  17198. UPDATE a SET a.TitleDesc = b.Description
  17199. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  17200. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  17201. AND a.Title = 'JobType'
  17202. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  17203. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  17204. GROUP BY dcSalaryID ORDER BY dcSalaryID
  17205. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  17206. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  17207. GROUP BY dcRegionID ORDER BY dcRegionID
  17208. ----计算全部地区,2位的数据
  17209. UPDATE a SET a.TitleValue = b.TitleValue
  17210. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
  17211. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  17212. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  17213. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  17214. GROUP BY LEFT(TitleID, 2)) b
  17215. WHERE a.TitleId = b.TitleID
  17216. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  17217. ----计算全部地区,4位的数据
  17218. UPDATE a SET a.TitleValue = b.TitleValue
  17219. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), (
  17220. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  17221. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  17222. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  17223. AND LEN(TitleID) >3
  17224. GROUP BY LEFT(TitleID, 4)) b
  17225. WHERE a.TitleId = b.TitleID
  17226. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  17227. ----写入TitleDesc
  17228. UPDATE a SET a.TitleDesc = b.Description
  17229. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  17230. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  17231. AND a.Title = 'Region'
  17232. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  17233. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  17234. GROUP BY dcEducationID ORDER BY dcEducationID
  17235. --学历 高中、中专、中级合并
  17236. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  17237. WHERE paSearchConditionID = @paSearchConditionID
  17238. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  17239. IF @TitleValue IS NOT NULL
  17240. BEGIN
  17241. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  17242. UPDATE SearchDB..paSearchCount_0 SET TitleValue = @TitleValue
  17243. WHERE paSearchConditionID = @paSearchConditionID
  17244. AND Title = 'Education' AND TitleID = 2
  17245. ELSE
  17246. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  17247. (@paSearchConditionID, 'Education', 2, @TitleValue)
  17248. DELETE FROM SearchDB..paSearchCount_0
  17249. WHERE paSearchConditionID = @paSearchConditionID
  17250. AND Title = 'Education' AND TitleID IN(3, 4)
  17251. END
  17252. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  17253. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  17254. GROUP BY MinExperience ORDER BY MinExperience
  17255. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  17256. SELECT Top 3 @paSearchConditionID,Balance,1
  17257. FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  17258. WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
  17259. SET @TopRows = @@ROWCOUNT
  17260. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  17261. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  17262. SET @AllRows = @@ROWCOUNT
  17263. IF @TopRows = 0 AND @AllRows > 100
  17264. UPDATE SearchDB..paSearchJobID_0 SET IsTop = 1
  17265. WHERE paSearchConditionID = @paSearchConditionID
  17266. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  17267. END
  17268. ELSE IF (@TableId = 1)
  17269. BEGIN
  17270. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  17271. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  17272. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  17273. ----计算全部某职位类别,2, 4位的数据
  17274. UPDATE a SET a.TitleValue = b.TitleValue
  17275. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
  17276. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  17277. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  17278. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  17279. GROUP BY LEFT(TitleID, 2)) b
  17280. WHERE a.TitleId = b.TitleID
  17281. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  17282. ----写入TitleDesc
  17283. UPDATE a SET a.TitleDesc = b.Description
  17284. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  17285. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  17286. AND a.Title = 'JobType'
  17287. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  17288. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  17289. GROUP BY dcSalaryID ORDER BY dcSalaryID
  17290. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  17291. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  17292. GROUP BY dcRegionID ORDER BY dcRegionID
  17293. ----计算全部地区,2位的数据
  17294. UPDATE a SET a.TitleValue = b.TitleValue
  17295. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
  17296. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  17297. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  17298. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  17299. GROUP BY LEFT(TitleID, 2)) b
  17300. WHERE a.TitleId = b.TitleID
  17301. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  17302. ----计算全部地区,4位的数据
  17303. UPDATE a SET a.TitleValue = b.TitleValue
  17304. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), (
  17305. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  17306. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  17307. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  17308. AND LEN(TitleID) >3
  17309. GROUP BY LEFT(TitleID, 4)) b
  17310. WHERE a.TitleId = b.TitleID
  17311. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  17312. ----写入TitleDesc
  17313. UPDATE a SET a.TitleDesc = b.Description
  17314. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  17315. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  17316. AND a.Title = 'Region'
  17317. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  17318. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  17319. GROUP BY dcEducationID ORDER BY dcEducationID
  17320. --学历 高中、中专、中级合并
  17321. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  17322. WHERE paSearchConditionID = @paSearchConditionID
  17323. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  17324. IF @TitleValue IS NOT NULL
  17325. BEGIN
  17326. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  17327. UPDATE SearchDB..paSearchCount_1 SET TitleValue = @TitleValue
  17328. WHERE paSearchConditionID = @paSearchConditionID
  17329. AND Title = 'Education' AND TitleID = 2
  17330. ELSE
  17331. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  17332. (@paSearchConditionID, 'Education', 2, @TitleValue)
  17333. DELETE FROM SearchDB..paSearchCount_1
  17334. WHERE paSearchConditionID = @paSearchConditionID
  17335. AND Title = 'Education' AND TitleID IN(3, 4)
  17336. END
  17337. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  17338. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  17339. GROUP BY MinExperience ORDER BY MinExperience
  17340. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  17341. SELECT Top 3 @paSearchConditionID,Balance,1
  17342. FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  17343. WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
  17344. SET @TopRows = @@ROWCOUNT
  17345. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  17346. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  17347. SET @AllRows = @@ROWCOUNT
  17348. IF @TopRows = 0 AND @AllRows > 100
  17349. UPDATE SearchDB..paSearchJobID_1 SET IsTop = 1
  17350. WHERE paSearchConditionID = @paSearchConditionID
  17351. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  17352. END
  17353. ELSE IF (@TableId = 2)
  17354. BEGIN
  17355. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  17356. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  17357. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  17358. ----计算全部某职位类别,2, 4位的数据
  17359. UPDATE a SET a.TitleValue = b.TitleValue
  17360. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
  17361. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  17362. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  17363. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  17364. GROUP BY LEFT(TitleID, 2)) b
  17365. WHERE a.TitleId = b.TitleID
  17366. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  17367. ----写入TitleDesc
  17368. UPDATE a SET a.TitleDesc = b.Description
  17369. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  17370. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  17371. AND a.Title = 'JobType'
  17372. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  17373. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  17374. GROUP BY dcSalaryID ORDER BY dcSalaryID
  17375. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  17376. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  17377. GROUP BY dcRegionID ORDER BY dcRegionID
  17378. ----计算全部地区,2位的数据
  17379. UPDATE a SET a.TitleValue = b.TitleValue
  17380. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
  17381. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  17382. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  17383. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  17384. GROUP BY LEFT(TitleID, 2)) b
  17385. WHERE a.TitleId = b.TitleID
  17386. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  17387. ----计算全部地区,4位的数据
  17388. UPDATE a SET a.TitleValue = b.TitleValue
  17389. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), (
  17390. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  17391. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  17392. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  17393. AND LEN(TitleID) >3
  17394. GROUP BY LEFT(TitleID, 4)) b
  17395. WHERE a.TitleId = b.TitleID
  17396. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  17397. ----写入TitleDesc
  17398. UPDATE a SET a.TitleDesc = b.Description
  17399. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  17400. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  17401. AND a.Title = 'Region'
  17402. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  17403. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  17404. GROUP BY dcEducationID ORDER BY dcEducationID
  17405. --学历 高中、中专、中级合并
  17406. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  17407. WHERE paSearchConditionID = @paSearchConditionID
  17408. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  17409. IF @TitleValue IS NOT NULL
  17410. BEGIN
  17411. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  17412. UPDATE SearchDB..paSearchCount_2 SET TitleValue = @TitleValue
  17413. WHERE paSearchConditionID = @paSearchConditionID
  17414. AND Title = 'Education' AND TitleID = 2
  17415. ELSE
  17416. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  17417. (@paSearchConditionID, 'Education', 2, @TitleValue)
  17418. DELETE FROM SearchDB..paSearchCount_2
  17419. WHERE paSearchConditionID = @paSearchConditionID
  17420. AND Title = 'Education' AND TitleID IN(3, 4)
  17421. END
  17422. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  17423. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  17424. GROUP BY MinExperience ORDER BY MinExperience
  17425. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  17426. SELECT Top 3 @paSearchConditionID,Balance,1
  17427. FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  17428. WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
  17429. SET @TopRows = @@ROWCOUNT
  17430. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  17431. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  17432. SET @AllRows = @@ROWCOUNT
  17433. IF @TopRows = 0 AND @AllRows > 100
  17434. UPDATE SearchDB..paSearchJobID_2 SET IsTop = 1
  17435. WHERE paSearchConditionID = @paSearchConditionID
  17436. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  17437. END
  17438. ELSE IF (@TableId = 3)
  17439. BEGIN
  17440. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  17441. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  17442. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  17443. ----计算全部某职位类别,2, 4位的数据
  17444. UPDATE a SET a.TitleValue = b.TitleValue
  17445. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
  17446. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  17447. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  17448. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  17449. GROUP BY LEFT(TitleID, 2)) b
  17450. WHERE a.TitleId = b.TitleID
  17451. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  17452. ----写入TitleDesc
  17453. UPDATE a SET a.TitleDesc = b.Description
  17454. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  17455. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  17456. AND a.Title = 'JobType'
  17457. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  17458. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  17459. GROUP BY dcSalaryID ORDER BY dcSalaryID
  17460. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  17461. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  17462. GROUP BY dcRegionID ORDER BY dcRegionID
  17463. ----计算全部地区,2位的数据
  17464. UPDATE a SET a.TitleValue = b.TitleValue
  17465. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
  17466. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  17467. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  17468. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  17469. GROUP BY LEFT(TitleID, 2)) b
  17470. WHERE a.TitleId = b.TitleID
  17471. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  17472. ----计算全部地区,4位的数据
  17473. UPDATE a SET a.TitleValue = b.TitleValue
  17474. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), (
  17475. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  17476. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  17477. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  17478. AND LEN(TitleID) >3
  17479. GROUP BY LEFT(TitleID, 4)) b
  17480. WHERE a.TitleId = b.TitleID
  17481. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  17482. ----写入TitleDesc
  17483. UPDATE a SET a.TitleDesc = b.Description
  17484. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  17485. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  17486. AND a.Title = 'Region'
  17487. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  17488. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  17489. GROUP BY dcEducationID ORDER BY dcEducationID
  17490. --学历 高中、中专、中级合并
  17491. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  17492. WHERE paSearchConditionID = @paSearchConditionID
  17493. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  17494. IF @TitleValue IS NOT NULL
  17495. BEGIN
  17496. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  17497. UPDATE SearchDB..paSearchCount_3 SET TitleValue = @TitleValue
  17498. WHERE paSearchConditionID = @paSearchConditionID
  17499. AND Title = 'Education' AND TitleID = 2
  17500. ELSE
  17501. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  17502. (@paSearchConditionID, 'Education', 2, @TitleValue)
  17503. DELETE FROM SearchDB..paSearchCount_3
  17504. WHERE paSearchConditionID = @paSearchConditionID
  17505. AND Title = 'Education' AND TitleID IN(3, 4)
  17506. END
  17507. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  17508. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  17509. GROUP BY MinExperience ORDER BY MinExperience
  17510. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  17511. SELECT Top 3 @paSearchConditionID,Balance,1
  17512. FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  17513. WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
  17514. SET @TopRows = @@ROWCOUNT
  17515. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  17516. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  17517. SET @AllRows = @@ROWCOUNT
  17518. IF @TopRows = 0 AND @AllRows > 100
  17519. UPDATE SearchDB..paSearchJobID_3 SET IsTop = 1
  17520. WHERE paSearchConditionID = @paSearchConditionID
  17521. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  17522. END
  17523. DROP TABLE #Job
  17524. COMMIT
  17525. GetRecordSet:
  17526. BEGIN
  17527. ----返回查询数量
  17528. SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
  17529. UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
  17530. ----返回20行查询结果
  17531. IF (@TableID = 0)
  17532. BEGIN
  17533. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  17534. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  17535. SELECT TOP(@PageSize)a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  17536. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  17537. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  17538. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  17539. a.IsDelete, a.AddDate, a.RefreshDate,
  17540. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  17541. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  17542. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  17543. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  17544. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  17545. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
  17546. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_0 c WITH(NOLOCK)
  17547. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  17548. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  17549. END
  17550. ELSE IF (@TableID = 1)
  17551. BEGIN
  17552. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  17553. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  17554. SELECT TOP(@PageSize)a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  17555. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  17556. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  17557. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  17558. a.IsDelete, a.AddDate, a.RefreshDate,
  17559. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  17560. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  17561. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  17562. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  17563. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  17564. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
  17565. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_1 c WITH(NOLOCK)
  17566. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  17567. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  17568. END
  17569. ELSE IF (@TableID = 2)
  17570. BEGIN
  17571. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  17572. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  17573. SELECT TOP(@PageSize)a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  17574. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  17575. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  17576. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  17577. a.IsDelete, a.AddDate, a.RefreshDate,
  17578. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  17579. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  17580. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  17581. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  17582. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  17583. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
  17584. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_2 c WITH(NOLOCK)
  17585. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  17586. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  17587. END
  17588. ELSE IF (@TableID = 3)
  17589. BEGIN
  17590. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  17591. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  17592. SELECT TOP(@PageSize)a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  17593. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  17594. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  17595. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  17596. a.IsDelete, a.AddDate, a.RefreshDate,
  17597. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  17598. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  17599. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  17600. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  17601. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  17602. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
  17603. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_3 c WITH(NOLOCK)
  17604. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  17605. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  17606. END
  17607. RETURN
  17608. END
  17609. END TRY
  17610. BEGIN CATCH
  17611. ---检查是否已经建立临时表,已经建立则删除
  17612. PRINT 'error'
  17613. PRINT error_Message()
  17614. PRINT error_number()
  17615. PRINT error_line()
  17616. END CATCH
  17617. GO
  17618. /****** Object: StoredProcedure [dbo].[mblJobByWeixinSelect1] Script Date: 2018/12/13 19:07:49 ******/
  17619. SET ANSI_NULLS ON
  17620. GO
  17621. SET QUOTED_IDENTIFIER ON
  17622. GO
  17623. CREATE PROCEDURE [dbo].[mblJobByWeixinSelect1]
  17624. (
  17625. @FromUserName VARCHAR(50),
  17626. @Type INT --0:订阅号关键词查询;10:服务号的关键词查询;11:服务号的周边职位
  17627. )
  17628. AS
  17629. --return
  17630. SET NOCOUNT ON
  17631. BEGIN TRY
  17632. DECLARE @dcRegionID INT,@KeyWord NVARCHAR(20),
  17633. @Lng DECIMAL(8,5),@Lat DECIMAL(8,5),@Distance INT,
  17634. @KeyType TINYINT, @ValidJobNumber INT, @PageNumber SMALLINT
  17635. IF @Type =11
  17636. BEGIN
  17637. SELECT @dcRegionID=dcRegionID,@KeyWord=KeyWord,@Lng=Lng,@Lat=Lat
  17638. FROM wxMessage WITH(NOLOCK) WHERE FromUserName=@FromUserName AND CONTENT='推荐职位'
  17639. END
  17640. ELSE
  17641. BEGIN
  17642. SELECT @dcRegionID=dcRegionID,@KeyWord=KeyWord,
  17643. @Lng=Lng,@Lat=Lat,@PageNumber=PageNumber
  17644. FROM wxMessage WITH(NOLOCK) WHERE FromUserName=@FromUserName
  17645. END
  17646. SELECT @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, '')),
  17647. @KeyType = 2,
  17648. @Distance = 5000,
  17649. @PageNumber = ISNULL(@PageNumber, 1),
  17650. @dcRegionID = ISNULL(@dcRegionID, 0),
  17651. @Lng = ISNULL(@Lng, 0),
  17652. @Lat = ISNULL(@Lat, 0)
  17653. IF @Type IN (10, 11)
  17654. SELECT @PageNumber = 1
  17655. UPDATE wxMessage SET PageNumber = @PageNumber + 1 WHERE FromUserName=@FromUserName
  17656. IF @dcRegionID = 0 AND @Lng = 0 AND @Lat = 0
  17657. RETURN
  17658. DECLARE @paSearchConditionID AS INT,
  17659. @MinId AS INT,
  17660. @PageSize AS TINYINT,
  17661. @TableID AS TINYINT
  17662. IF @Type =11 OR @Type =10
  17663. BEGIN
  17664. SELECT @paSearchConditionID = 0, @PageSize = 5 --每页的行数
  17665. END
  17666. ELSE
  17667. BEGIN
  17668. SELECT @paSearchConditionID = 0, @PageSize = 8 --每页的行数
  17669. END
  17670. ----搜索60分钟前的数据
  17671. SELECT TOP 1 @paSearchConditionID=ID FROM SearchDB..paSearchCondition WITH(NOLOCK)
  17672. WHERE JobType=''
  17673. AND JobPlace=@dcRegionID AND ISNULL(Industry,'')='' AND ISNULL(Education,'')=''
  17674. AND ISNULL(Experience,'')='' AND ISNULL(Salary,'')='' AND ISNULL(IsNegotiable,'')=''
  17675. AND ISNULL(EmployType,'')='' AND KeyWord=@KeyWord AND KeyType=@KeyType
  17676. AND ISNULL(CompanySizeID,'')='' AND Lng=@Lng AND Lat=@Lat
  17677. ORDER BY ID DESC
  17678. IF ISNULL(@paSearchConditionID, 0) = 0
  17679. BEGIN
  17680. GOTO SelectReset --无数据,重新搜索
  17681. END
  17682. ELSE
  17683. BEGIN
  17684. SELECT @TableID = @paSearchConditionID % 4
  17685. GOTO GetRecordSet --从临时结果中提取数据
  17686. END
  17687. SelectReset:
  17688. --从job中搜索数据
  17689. BEGIN TRAN
  17690. DECLARE @SQL AS VARCHAR(8000)
  17691. DECLARE @WHERE AS VARCHAR(8000)
  17692. DECLARE @FROM AS VARCHAR(1000)
  17693. ----记录查询条件
  17694. INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
  17695. Salary, IsNegotiable, EmployType, CompanySizeID, KeyWord, KeyType, ReuseNumber, Lng, Lat, Distance)
  17696. VALUES(1, GETDATE(), '', @dcRegionID, '', '', '', '', '', '', '', @KeyWord, @KeyType, 0, @Lng, @Lat, @Distance)
  17697. SET @paSearchConditionID = @@IDENTITY
  17698. SELECT @TableID = @paSearchConditionID % 4
  17699. ----建立临时表
  17700. CREATE TABLE #Job(
  17701. RowID INT IDENTITY(1, 1),
  17702. ID INT NOT NULL,
  17703. dcJobTypeID SMALLINT NOT NULL,
  17704. dcJobTypeIDMinor SMALLINT NULL,
  17705. dcSalaryID TINYINT NOT NULL,
  17706. dcRegionID VARCHAR(6) NULL,
  17707. dcEducationID TINYINT NOT NULL,
  17708. MinExperience TINYINT NOT NULL,
  17709. RefreshDate SMALLDATETIME NULL
  17710. )
  17711. ------刷新时间,根据刷新时间编号计算
  17712. ----生成插入临时表的Sql语句
  17713. SET @SQL='
  17714. INSERT INTO #Job
  17715. SELECT a.ID, a.dcJobTypeID,
  17716. a.dcJobTypeIDMinor, a.dcSalaryID,
  17717. a.dcRegionID, a.dcEducationID, a.MinExperience,
  17718. a.IssueDate'
  17719. SET @FROM = '
  17720. FROM JobPublish a WITH(NOLOCK)
  17721. INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
  17722. ----职位有效,单位新有效
  17723. SET @WHERE = '
  17724. WHERE a.Valid = 1
  17725. AND b.Valid = 1'
  17726. ----需要增加全文索引的关键字查询
  17727. IF @KeyWord LIKE '% %'
  17728. BEGIN
  17729. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  17730. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  17731. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  17732. SET @KeyWord = '"' + REPLACE(@KeyWord, ' ', '" OR "') + '"'
  17733. END
  17734. IF LEN(@KeyWord) > 0
  17735. BEGIN
  17736. IF @KeyType = 2
  17737. SET @FROM = @FROM + '
  17738. INNER JOIN CONTAINSTABLE(JobPublish, *, ''' + @KeyWord + ''', 1000000) AS KeyJob
  17739. ON a.ID = KeyJob.[Key]'
  17740. END
  17741. ---地区
  17742. IF @dcRegionID > 0
  17743. SET @WHERE = @WHERE + '
  17744. AND a.dcRegionID Like ''' + CONVERT(VARCHAR(6),@dcRegionID) + '%'''
  17745. IF @Lng > 0 AND @Lat > 0
  17746. BEGIN
  17747. DECLARE @Degree AS DECIMAL(8,5),@LBLng AS DECIMAL(8,5),@LBLat AS DECIMAL(8,5),
  17748. @RTLng AS DECIMAL(8,5),@RTLat AS DECIMAL(8,5)
  17749. SET @Degree = @Distance / 100000.0;
  17750. SET @LBLng = @Lng - @Degree
  17751. SET @LBLat = @Lat - @Degree
  17752. SET @RTLng = @Lng + @Degree
  17753. SET @RTLat = @Lat + @Degree
  17754. SET @WHERE = @WHERE + '
  17755. AND a.Lng BETWEEN ' + CONVERT(VARCHAR,@LBLng) + ' AND ' + CONVERT(VARCHAR,@RTLng) + '
  17756. AND a.Lat BETWEEN ' + CONVERT(VARCHAR,@LBLat) + ' AND ' + CONVERT(VARCHAR,@RTLat)
  17757. END
  17758. SET @SQL = @SQL + @FROM + @WHERE
  17759. SET @SQL=@SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
  17760. ----把符合条件的职位全部列出
  17761. --PRINT @SQL
  17762. EXEC(@SQL)
  17763. SET @ValidJobNumber = @@ROWCOUNT
  17764. ----记录查询结果总数
  17765. UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@SQL WHERE ID=@paSearchConditionID
  17766. ----插入JobType数据
  17767. DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
  17768. IF (@TableID = 0)
  17769. BEGIN
  17770. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  17771. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  17772. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  17773. ----计算全部某职位类别,2, 4位的数据
  17774. UPDATE a SET a.TitleValue = b.TitleValue
  17775. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
  17776. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  17777. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  17778. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  17779. GROUP BY LEFT(TitleID, 2)) b
  17780. WHERE a.TitleId = b.TitleID
  17781. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  17782. ----写入TitleDesc
  17783. UPDATE a SET a.TitleDesc = b.Description
  17784. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  17785. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  17786. AND a.Title = 'JobType'
  17787. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  17788. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  17789. GROUP BY dcSalaryID ORDER BY dcSalaryID
  17790. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  17791. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  17792. GROUP BY dcRegionID ORDER BY dcRegionID
  17793. ----计算全部地区,2位的数据
  17794. UPDATE a SET a.TitleValue = b.TitleValue
  17795. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
  17796. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  17797. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  17798. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  17799. GROUP BY LEFT(TitleID, 2)) b
  17800. WHERE a.TitleId = b.TitleID
  17801. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  17802. ----计算全部地区,4位的数据
  17803. UPDATE a SET a.TitleValue = b.TitleValue
  17804. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), (
  17805. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  17806. FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  17807. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  17808. AND LEN(TitleID) >3
  17809. GROUP BY LEFT(TitleID, 4)) b
  17810. WHERE a.TitleId = b.TitleID
  17811. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  17812. ----写入TitleDesc
  17813. UPDATE a SET a.TitleDesc = b.Description
  17814. FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  17815. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  17816. AND a.Title = 'Region'
  17817. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  17818. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  17819. GROUP BY dcEducationID ORDER BY dcEducationID
  17820. --学历 高中、中专、中级合并
  17821. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
  17822. WHERE paSearchConditionID = @paSearchConditionID
  17823. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  17824. IF @TitleValue IS NOT NULL
  17825. BEGIN
  17826. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  17827. UPDATE SearchDB..paSearchCount_0 SET TitleValue = @TitleValue
  17828. WHERE paSearchConditionID = @paSearchConditionID
  17829. AND Title = 'Education' AND TitleID = 2
  17830. ELSE
  17831. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  17832. (@paSearchConditionID, 'Education', 2, @TitleValue)
  17833. DELETE FROM SearchDB..paSearchCount_0
  17834. WHERE paSearchConditionID = @paSearchConditionID
  17835. AND Title = 'Education' AND TitleID IN(3, 4)
  17836. END
  17837. INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
  17838. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  17839. GROUP BY MinExperience ORDER BY MinExperience
  17840. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  17841. SELECT Top 3 @paSearchConditionID,Balance,1
  17842. FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  17843. WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
  17844. SET @TopRows = @@ROWCOUNT
  17845. INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
  17846. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  17847. SET @AllRows = @@ROWCOUNT
  17848. IF @TopRows = 0 AND @AllRows > 100
  17849. UPDATE SearchDB..paSearchJobID_0 SET IsTop = 1
  17850. WHERE paSearchConditionID = @paSearchConditionID
  17851. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  17852. END
  17853. ELSE IF (@TableId = 1)
  17854. BEGIN
  17855. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  17856. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  17857. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  17858. ----计算全部某职位类别,2, 4位的数据
  17859. UPDATE a SET a.TitleValue = b.TitleValue
  17860. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
  17861. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  17862. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  17863. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  17864. GROUP BY LEFT(TitleID, 2)) b
  17865. WHERE a.TitleId = b.TitleID
  17866. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  17867. ----写入TitleDesc
  17868. UPDATE a SET a.TitleDesc = b.Description
  17869. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  17870. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  17871. AND a.Title = 'JobType'
  17872. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  17873. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  17874. GROUP BY dcSalaryID ORDER BY dcSalaryID
  17875. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  17876. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  17877. GROUP BY dcRegionID ORDER BY dcRegionID
  17878. ----计算全部地区,2位的数据
  17879. UPDATE a SET a.TitleValue = b.TitleValue
  17880. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
  17881. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  17882. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  17883. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  17884. GROUP BY LEFT(TitleID, 2)) b
  17885. WHERE a.TitleId = b.TitleID
  17886. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  17887. ----计算全部地区,4位的数据
  17888. UPDATE a SET a.TitleValue = b.TitleValue
  17889. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), (
  17890. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  17891. FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  17892. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  17893. AND LEN(TitleID) >3
  17894. GROUP BY LEFT(TitleID, 4)) b
  17895. WHERE a.TitleId = b.TitleID
  17896. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  17897. ----写入TitleDesc
  17898. UPDATE a SET a.TitleDesc = b.Description
  17899. FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  17900. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  17901. AND a.Title = 'Region'
  17902. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  17903. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  17904. GROUP BY dcEducationID ORDER BY dcEducationID
  17905. --学历 高中、中专、中级合并
  17906. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
  17907. WHERE paSearchConditionID = @paSearchConditionID
  17908. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  17909. IF @TitleValue IS NOT NULL
  17910. BEGIN
  17911. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  17912. UPDATE SearchDB..paSearchCount_1 SET TitleValue = @TitleValue
  17913. WHERE paSearchConditionID = @paSearchConditionID
  17914. AND Title = 'Education' AND TitleID = 2
  17915. ELSE
  17916. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  17917. (@paSearchConditionID, 'Education', 2, @TitleValue)
  17918. DELETE FROM SearchDB..paSearchCount_1
  17919. WHERE paSearchConditionID = @paSearchConditionID
  17920. AND Title = 'Education' AND TitleID IN(3, 4)
  17921. END
  17922. INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
  17923. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  17924. GROUP BY MinExperience ORDER BY MinExperience
  17925. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  17926. SELECT Top 3 @paSearchConditionID,Balance,1
  17927. FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  17928. WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
  17929. SET @TopRows = @@ROWCOUNT
  17930. INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
  17931. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  17932. SET @AllRows = @@ROWCOUNT
  17933. IF @TopRows = 0 AND @AllRows > 100
  17934. UPDATE SearchDB..paSearchJobID_1 SET IsTop = 1
  17935. WHERE paSearchConditionID = @paSearchConditionID
  17936. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  17937. END
  17938. ELSE IF (@TableId = 2)
  17939. BEGIN
  17940. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  17941. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  17942. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  17943. ----计算全部某职位类别,2, 4位的数据
  17944. UPDATE a SET a.TitleValue = b.TitleValue
  17945. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
  17946. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  17947. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  17948. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  17949. GROUP BY LEFT(TitleID, 2)) b
  17950. WHERE a.TitleId = b.TitleID
  17951. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  17952. ----写入TitleDesc
  17953. UPDATE a SET a.TitleDesc = b.Description
  17954. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  17955. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  17956. AND a.Title = 'JobType'
  17957. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  17958. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  17959. GROUP BY dcSalaryID ORDER BY dcSalaryID
  17960. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  17961. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  17962. GROUP BY dcRegionID ORDER BY dcRegionID
  17963. ----计算全部地区,2位的数据
  17964. UPDATE a SET a.TitleValue = b.TitleValue
  17965. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
  17966. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  17967. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  17968. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  17969. GROUP BY LEFT(TitleID, 2)) b
  17970. WHERE a.TitleId = b.TitleID
  17971. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  17972. ----计算全部地区,4位的数据
  17973. UPDATE a SET a.TitleValue = b.TitleValue
  17974. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), (
  17975. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  17976. FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  17977. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  17978. AND LEN(TitleID) >3
  17979. GROUP BY LEFT(TitleID, 4)) b
  17980. WHERE a.TitleId = b.TitleID
  17981. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  17982. ----写入TitleDesc
  17983. UPDATE a SET a.TitleDesc = b.Description
  17984. FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  17985. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  17986. AND a.Title = 'Region'
  17987. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  17988. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  17989. GROUP BY dcEducationID ORDER BY dcEducationID
  17990. --学历 高中、中专、中级合并
  17991. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
  17992. WHERE paSearchConditionID = @paSearchConditionID
  17993. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  17994. IF @TitleValue IS NOT NULL
  17995. BEGIN
  17996. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  17997. UPDATE SearchDB..paSearchCount_2 SET TitleValue = @TitleValue
  17998. WHERE paSearchConditionID = @paSearchConditionID
  17999. AND Title = 'Education' AND TitleID = 2
  18000. ELSE
  18001. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  18002. (@paSearchConditionID, 'Education', 2, @TitleValue)
  18003. DELETE FROM SearchDB..paSearchCount_2
  18004. WHERE paSearchConditionID = @paSearchConditionID
  18005. AND Title = 'Education' AND TitleID IN(3, 4)
  18006. END
  18007. INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
  18008. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  18009. GROUP BY MinExperience ORDER BY MinExperience
  18010. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  18011. SELECT Top 3 @paSearchConditionID,Balance,1
  18012. FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  18013. WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
  18014. SET @TopRows = @@ROWCOUNT
  18015. INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
  18016. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  18017. SET @AllRows = @@ROWCOUNT
  18018. IF @TopRows = 0 AND @AllRows > 100
  18019. UPDATE SearchDB..paSearchJobID_2 SET IsTop = 1
  18020. WHERE paSearchConditionID = @paSearchConditionID
  18021. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  18022. END
  18023. ELSE IF (@TableId = 3)
  18024. BEGIN
  18025. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  18026. SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
  18027. GROUP BY dcJobTypeID ORDER BY dcJobTypeID
  18028. ----计算全部某职位类别,2, 4位的数据
  18029. UPDATE a SET a.TitleValue = b.TitleValue
  18030. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
  18031. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  18032. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  18033. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
  18034. GROUP BY LEFT(TitleID, 2)) b
  18035. WHERE a.TitleId = b.TitleID
  18036. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
  18037. ----写入TitleDesc
  18038. UPDATE a SET a.TitleDesc = b.Description
  18039. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
  18040. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  18041. AND a.Title = 'JobType'
  18042. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  18043. SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
  18044. GROUP BY dcSalaryID ORDER BY dcSalaryID
  18045. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  18046. SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
  18047. GROUP BY dcRegionID ORDER BY dcRegionID
  18048. ----计算全部地区,2位的数据
  18049. UPDATE a SET a.TitleValue = b.TitleValue
  18050. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
  18051. (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
  18052. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  18053. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  18054. GROUP BY LEFT(TitleID, 2)) b
  18055. WHERE a.TitleId = b.TitleID
  18056. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  18057. ----计算全部地区,4位的数据
  18058. UPDATE a SET a.TitleValue = b.TitleValue
  18059. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), (
  18060. SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
  18061. FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  18062. WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
  18063. AND LEN(TitleID) >3
  18064. GROUP BY LEFT(TitleID, 4)) b
  18065. WHERE a.TitleId = b.TitleID
  18066. AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
  18067. ----写入TitleDesc
  18068. UPDATE a SET a.TitleDesc = b.Description
  18069. FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
  18070. WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
  18071. AND a.Title = 'Region'
  18072. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  18073. SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
  18074. GROUP BY dcEducationID ORDER BY dcEducationID
  18075. --学历 高中、中专、中级合并
  18076. SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
  18077. WHERE paSearchConditionID = @paSearchConditionID
  18078. AND Title = 'Education' AND TitleID IN(2, 3, 4)
  18079. IF @TitleValue IS NOT NULL
  18080. BEGIN
  18081. IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
  18082. UPDATE SearchDB..paSearchCount_3 SET TitleValue = @TitleValue
  18083. WHERE paSearchConditionID = @paSearchConditionID
  18084. AND Title = 'Education' AND TitleID = 2
  18085. ELSE
  18086. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue) VALUES
  18087. (@paSearchConditionID, 'Education', 2, @TitleValue)
  18088. DELETE FROM SearchDB..paSearchCount_3
  18089. WHERE paSearchConditionID = @paSearchConditionID
  18090. AND Title = 'Education' AND TitleID IN(3, 4)
  18091. END
  18092. INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
  18093. SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
  18094. GROUP BY MinExperience ORDER BY MinExperience
  18095. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  18096. SELECT Top 3 @paSearchConditionID,Balance,1
  18097. FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
  18098. WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
  18099. SET @TopRows = @@ROWCOUNT
  18100. INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
  18101. SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
  18102. SET @AllRows = @@ROWCOUNT
  18103. IF @TopRows = 0 AND @AllRows > 100
  18104. UPDATE SearchDB..paSearchJobID_3 SET IsTop = 1
  18105. WHERE paSearchConditionID = @paSearchConditionID
  18106. AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
  18107. END
  18108. DROP TABLE #Job
  18109. COMMIT
  18110. GetRecordSet:
  18111. BEGIN
  18112. ----返回查询数量
  18113. SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
  18114. UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
  18115. ----返回20行查询结果
  18116. IF (@TableID = 0)
  18117. BEGIN
  18118. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  18119. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  18120. SELECT TOP (@PageSize) a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  18121. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  18122. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  18123. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  18124. a.IsDelete, a.AddDate, a.RefreshDate,
  18125. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  18126. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  18127. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  18128. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  18129. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  18130. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
  18131. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_0 c WITH(NOLOCK)
  18132. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  18133. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  18134. END
  18135. ELSE IF (@TableID = 1)
  18136. BEGIN
  18137. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  18138. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  18139. SELECT TOP (@PageSize) a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  18140. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  18141. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  18142. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  18143. a.IsDelete, a.AddDate, a.RefreshDate,
  18144. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  18145. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  18146. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  18147. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  18148. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  18149. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
  18150. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_1 c WITH(NOLOCK)
  18151. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  18152. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  18153. END
  18154. ELSE IF (@TableID = 2)
  18155. BEGIN
  18156. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  18157. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  18158. SELECT TOP (@PageSize) a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  18159. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  18160. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  18161. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  18162. a.IsDelete, a.AddDate, a.RefreshDate,
  18163. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  18164. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  18165. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  18166. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  18167. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  18168. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
  18169. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_2 c WITH(NOLOCK)
  18170. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  18171. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  18172. END
  18173. ELSE IF (@TableID = 3)
  18174. BEGIN
  18175. SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
  18176. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  18177. SELECT TOP (@PageSize) a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
  18178. a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
  18179. a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
  18180. a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
  18181. a.IsDelete, a.AddDate, a.RefreshDate,
  18182. a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
  18183. b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
  18184. b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
  18185. FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
  18186. AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
  18187. c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
  18188. FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_3 c WITH(NOLOCK)
  18189. WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
  18190. AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
  18191. END
  18192. RETURN
  18193. END
  18194. END TRY
  18195. BEGIN CATCH
  18196. ---检查是否已经建立临时表,已经建立则删除
  18197. PRINT 'error'
  18198. PRINT error_Message()
  18199. PRINT error_number()
  18200. PRINT error_line()
  18201. END CATCH
  18202. GO
  18203. /****** Object: StoredProcedure [dbo].[mblJobEnByIDSelect] Script Date: 2018/12/13 19:07:49 ******/
  18204. SET ANSI_NULLS ON
  18205. GO
  18206. SET QUOTED_IDENTIFIER ON
  18207. GO
  18208. --#####################################################
  18209. --创建时间:2014.11.06
  18210. --创建人:Nick
  18211. --说明:获取职位信息
  18212. --#####################################################
  18213. CREATE PROCEDURE [dbo].[mblJobEnByIDSelect]
  18214. (
  18215. @JobID INT
  18216. )
  18217. AS
  18218. BEGIN TRY
  18219. SELECT a.lng,a.lat,a.caMainID,a.RefreshDate,a.dcRegionId,a.dcJobTypeId,a.Welfare1,a.Welfare2,a.Welfare3,a.Welfare4,
  18220. a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8,a.Welfare9,a.Welfare10,a.Welfare11,a.Welfare12,a.Welfare13,a.Welfare14,
  18221. a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,a.Welfare19,a.Lng,a.Lat,a.Name,a.cpMainID,i.secondid encpmainid,a.secondid enjobid,
  18222. i.Name cpName,a.Responsibility,a.Demand,a.MinAge,
  18223. a.MaxAge,b.Description JobType,c.FullName JobRegion,d.Description NeedNumber,e.Description EmployType,
  18224. f.Description Salary,(CASE WHEN g.Description IS NULL THEN '不限' ELSE g.Description END) Education,
  18225. h.Description Experience FROM Job a WITH(NOLOCK)
  18226. LEFT JOIN dcJobType b WITH(NOLOCK) ON a.dcJobTypeID=b.ID LEFT JOIN dcRegion c WITH(NOLOCK) ON
  18227. a.dcRegionID=c.ID LEFT JOIN dcOthers d WITH(NOLOCK) ON a.NeedNumber=d.DetailID AND d.Category='招聘人数'
  18228. LEFT JOIN dcOthers e WITH(NOLOCK) ON a.EmployType=e.DetailID AND e.Category='工作性质'
  18229. LEFT JOIN dcSalary f WITH(NOLOCK) ON a.dcSalaryID=f.ID LEFT JOIN dcEducation g WITH(NOLOCK)
  18230. ON a.dcEducationID=g.ID LEFT JOIN dcOthers h WITH(NOLOCK) ON a.MinExperience=h.DetailID AND
  18231. h.Category='职位要求工作经验' LEFT JOIN cpMain i WITH(NOLOCK) ON a.cpMainID=i.ID WHERE a.SecondId=@JobID
  18232. END TRY
  18233. BEGIN CATCH
  18234. RETURN 0
  18235. END CATCH
  18236. GO
  18237. /****** Object: StoredProcedure [dbo].[mblJobIntentionSave] Script Date: 2018/12/13 19:07:49 ******/
  18238. SET ANSI_NULLS ON
  18239. GO
  18240. SET QUOTED_IDENTIFIER ON
  18241. GO
  18242. CREATE PROCEDURE [dbo].[mblJobIntentionSave]
  18243. (
  18244. @cvMainID INT,
  18245. @RelatedWorkYears TINYINT,
  18246. @EmployType TINYINT,
  18247. @dcSalaryID TINYINT,
  18248. @JobType VARCHAR(100),
  18249. @JobPlace VARCHAR(100),
  18250. @paMainID INT,
  18251. @IsNegotiable BIT
  18252. )
  18253. AS
  18254. BEGIN
  18255. IF @RelatedWorkYears IS NULL
  18256. RETURN 0
  18257. IF @EmployType IS NULL
  18258. RETURN 0
  18259. IF @dcSalaryID IS NULL
  18260. RETURN 0
  18261. IF @JobType IS NULL
  18262. RETURN 0
  18263. IF @JobPlace IS NULL
  18264. RETURN 0
  18265. IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID AND paMainID = @paMainID)
  18266. RETURN 0
  18267. DECLARE @i INT,
  18268. @Name AS VARCHAR(100),
  18269. @JobType1 AS VARCHAR(10),
  18270. @JobPlace1 AS VARCHAR(10)
  18271. BEGIN TRY
  18272. DELETE FROM cvJobType WHERE cvMainID = @cvMainID
  18273. SET @i = CHARINDEX(' ', @JobType)
  18274. WHILE @i >= 1
  18275. BEGIN
  18276. IF LEFT(@JobType, @i-1) > ''
  18277. BEGIN
  18278. INSERT cvJobType(cvMainID, dcJobTypeID) VALUES(@cvMainID, LEFT(@JobType, @i-1))
  18279. IF @JobType1 IS NULL
  18280. SET @JobType1 = LEFT(@JobType, @i-1)
  18281. END
  18282. SET @JobType = SUBSTRING(@JobType, @i+1, LEN(@JobType)-@i)
  18283. SET @i = CHARINDEX(' ', @JobType)
  18284. END
  18285. IF @JobType > ''
  18286. BEGIN
  18287. INSERT cvJobType(cvMainID, dcJobTypeID) VALUES(@cvMainID, @JobType)
  18288. IF @JobType1 IS NULL
  18289. SET @JobType1 = @JobType
  18290. END
  18291. DELETE FROM cvJobPlace WHERE cvMainID = @cvMainID
  18292. SET @i = CHARINDEX(' ', @JobPlace)
  18293. WHILE @i >= 1
  18294. BEGIN
  18295. IF LEFT(@JobPlace, @i-1) > ''
  18296. BEGIN
  18297. INSERT cvJobPlace(cvMainID, dcRegionID) VALUES(@cvMainID, LEFT(@JobPlace, @i-1))
  18298. IF @JobPlace1 IS NULL
  18299. SET @JobPlace1 = LEFT(@JobPlace, @i-1)
  18300. END
  18301. SET @JobPlace = SUBSTRING(@JobPlace, @i+1, LEN(@JobPlace)-@i)
  18302. SET @i = CHARINDEX(' ', @JobPlace)
  18303. END
  18304. IF @JobPlace > ''
  18305. BEGIN
  18306. INSERT cvJobPlace(cvMainID, dcRegionID) VALUES(@cvMainID, @JobPlace)
  18307. IF @JobPlace1 IS NULL
  18308. SET @JobPlace1 = @JobPlace
  18309. END
  18310. SELECT @Name = Name FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
  18311. IF(ISNULL(@Name, '未完成简历') = '未完成简历')
  18312. BEGIN
  18313. SELECT @Name = Description FROM dcRegion WITH(NOLOCK) WHERE ID = @JobPlace1
  18314. SELECT @Name = @Name + '+' + Description FROM dcJobType WITH(NOLOCK) WHERE ID = @JobType1
  18315. UPDATE cvMain SET Name = @Name,
  18316. RelatedWorkYears = @RelatedWorkYears,
  18317. EmployType = @EmployType,
  18318. dcSalaryID = @dcSalaryID,
  18319. IsNegotiable = @IsNegotiable
  18320. WHERE ID = @cvMainID
  18321. END
  18322. ELSE
  18323. BEGIN
  18324. UPDATE cvMain SET RelatedWorkYears = @RelatedWorkYears,
  18325. EmployType = @EmployType,
  18326. dcSalaryID = @dcSalaryID,
  18327. IsNegotiable = @IsNegotiable
  18328. WHERE ID = @cvMainID
  18329. END
  18330. DECLARE @SQL AS VARCHAR(100)
  18331. SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew 0, ' + LTRIM(STR(@cvMainID)) + ', 6, 1'
  18332. EXEC(@SQL)
  18333. SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew 1, ' + LTRIM(STR(@cvMainID)) + ', 6, 1'
  18334. EXEC(@SQL)
  18335. RETURN 1
  18336. END TRY
  18337. BEGIN CATCH
  18338. RETURN 0
  18339. END CATCH
  18340. END
  18341. set ANSI_NULLS ON
  18342. set QUOTED_IDENTIFIER ON
  18343. GO
  18344. /****** Object: StoredProcedure [dbo].[mblJobNewsList] Script Date: 2018/12/13 19:07:50 ******/
  18345. SET ANSI_NULLS ON
  18346. GO
  18347. SET QUOTED_IDENTIFIER ON
  18348. GO
  18349. --Carl 2018-03-06 修改 增加 就业大数据信息及媒体动态
  18350. CREATE PROCEDURE [dbo].[mblJobNewsList]
  18351. (
  18352. @dcProvinceID AS SMALLINT,
  18353. @PageNum AS INT,
  18354. @PageSize AS INT,
  18355. @NewsType AS INT
  18356. )
  18357. AS
  18358. BEGIN
  18359. DECLARE @COUNT INT
  18360. IF @NewsType=18 --就业大数据
  18361. BEGIN
  18362. SELECT @COUNT=COUNT(1) FROM NewsAnalysis WITH(NOLOCK) WHERE newstype=1 AND IsDelete = 0
  18363. IF @COUNT>200
  18364. SET @COUNT=200
  18365. SELECT *,@COUNT AS cnt FROM (
  18366. SELECT TOP 200 ROW_NUMBER() OVER(ORDER BY AnnounceDate DESC) AS Rows,ID,Title,Author,AnnounceDate
  18367. FROM NewsAnalysis WITH(NOLOCK) WHERE newstype=1 AND IsDelete = 0 ) AS a
  18368. WHERE a.Rows BETWEEN (@PageNum-1)*@PageSize+1 AND @PageNum*@PageSize ORDER BY Rows
  18369. END
  18370. ELSE IF @NewsType=19 --媒体动态
  18371. BEGIN
  18372. SELECT @COUNT=COUNT(1) FROM MarketDb..MarketMedia a, MarketDb..MarketProvince b
  18373. WHERE a.ID = b.MarketID
  18374. AND b.Type = 1 AND a.MediaType = 1
  18375. AND (b.ProvinceID = 0 OR b.ProvinceID = @dcProvinceID)
  18376. IF @COUNT>200
  18377. SET @COUNT=200
  18378. SELECT *,@COUNT AS cnt FROM (
  18379. SELECT TOP 200 ROW_NUMBER() OVER(ORDER BY a.AddDate DESC) AS Rows,a.Id,a.Title,a.Brief AS [Content],a.Url,a.AddDate AS AnnounceDate FROM MarketDb..MarketMedia a, MarketDb..MarketProvince b
  18380. WHERE a.ID = b.MarketID
  18381. AND b.Type = 1 AND a.MediaType = 1
  18382. AND (b.ProvinceID = 0 OR b.ProvinceID = @dcProvinceID) ) AS a
  18383. WHERE a.Rows BETWEEN (@PageNum-1)*@PageSize+1 AND @PageNum*@PageSize ORDER BY Rows
  18384. END
  18385. ELSE
  18386. BEGIN
  18387. SELECT @COUNT=COUNT(1) FROM QlrcNews WITH(NOLOCK) WHERE
  18388. (VersionID=@dcProvinceID) AND DetailType like '%,'+CONVERT(VARCHAR(10),@NewsType)+',%' AND DetailType NOT LIKE '%,2,%'
  18389. AND NewsType = 2
  18390. IF @COUNT>200
  18391. SET @COUNT=200
  18392. SELECT *,@COUNT AS cnt FROM(
  18393. SELECT TOP 200 ROW_NUMBER() OVER(ORDER BY RefreshDate DESC) AS Rows,ID,Title,RefreshDate,Author,AnnounceDate
  18394. FROM QlrcNews WITH(NOLOCK) WHERE
  18395. (VersionID=@dcProvinceID) AND DetailType like '%,'+CONVERT(VARCHAR(10),@NewsType)+',%' AND DetailType NOT LIKE '%,2,%'
  18396. AND NewsType = 2
  18397. ) AS a
  18398. WHERE a.Rows BETWEEN (@PageNum-1)*@PageSize+1 AND @PageNum*@PageSize ORDER BY Rows
  18399. END
  18400. END
  18401. GO
  18402. /****** Object: StoredProcedure [dbo].[mblJobStatusByIDSelect] Script Date: 2018/12/13 19:07:50 ******/
  18403. SET ANSI_NULLS ON
  18404. GO
  18405. SET QUOTED_IDENTIFIER ON
  18406. GO
  18407. --#####################################################
  18408. --创建时间:2014.11.06
  18409. --创建人:Nick
  18410. --说明:获取职位当前状态
  18411. --#####################################################
  18412. CREATE PROCEDURE [dbo].[mblJobStatusByIDSelect]
  18413. (
  18414. @ID INT
  18415. )
  18416. AS
  18417. BEGIN TRY
  18418. SELECT IsDelete,(CASE WHEN IssueEnd<GETDATE() THEN 1 ELSE 0 END) IsOver,caMainid FROM Job WHERE ID=@ID
  18419. END TRY
  18420. BEGIN CATCH
  18421. RETURN 0
  18422. END CATCH
  18423. GO
  18424. /****** Object: StoredProcedure [dbo].[mblManagerSOLStatusByIDSelect] Script Date: 2018/12/13 19:07:50 ******/
  18425. SET ANSI_NULLS ON
  18426. GO
  18427. SET QUOTED_IDENTIFIER ON
  18428. GO
  18429. --#####################################################
  18430. --创建时间:2014.11.06
  18431. --创建人:Nick
  18432. --说明:得到顾问的在线状态
  18433. --#####################################################
  18434. CREATE PROCEDURE [dbo].[mblManagerSOLStatusByIDSelect]
  18435. (
  18436. @manageruserid INT
  18437. )
  18438. AS
  18439. BEGIN
  18440. SELECT TOP 1 Id, Name, SOLStatus, Photo, OpenName FROM ManagerUser WHERE Id = @manageruserid
  18441. END
  18442. GO
  18443. /****** Object: StoredProcedure [dbo].[mblMblFeedBackInsert] Script Date: 2018/12/13 19:07:50 ******/
  18444. SET ANSI_NULLS ON
  18445. GO
  18446. SET QUOTED_IDENTIFIER ON
  18447. GO
  18448. --#####################################################
  18449. --创建时间:2014.11.7
  18450. --创建人:Nick
  18451. --说明:在线反馈
  18452. --#####################################################
  18453. CREATE PROCEDURE [dbo].[mblMblFeedBackInsert]
  18454. (
  18455. @Content VARCHAR(500),
  18456. @Version VARCHAR(50),
  18457. @paMainID VARCHAR(20),
  18458. @Name VARCHAR(50),
  18459. @strMobile VARCHAR(20),
  18460. @Email VARCHAR(50)
  18461. )
  18462. AS
  18463. BEGIN
  18464. INSERT INTO mblFeedBack(Content,Version,paMainID,Name,Mobile,Email)
  18465. VALUES(dbo.SafeSQL(@Content),dbo.SafeSQL(@Version),@paMainID,@Name,@strMobile,@Email)
  18466. END
  18467. GO
  18468. /****** Object: StoredProcedure [dbo].[mblMblSqlByVersionSelect] Script Date: 2018/12/13 19:07:51 ******/
  18469. SET ANSI_NULLS ON
  18470. GO
  18471. SET QUOTED_IDENTIFIER ON
  18472. GO
  18473. --#####################################################
  18474. --创建时间:2014.11.7
  18475. --创建人:Nick
  18476. --说明:
  18477. --#####################################################
  18478. CREATE PROCEDURE [dbo].[mblMblSqlByVersionSelect]
  18479. (
  18480. @version VARCHAR(100)
  18481. )
  18482. AS
  18483. BEGIN
  18484. SELECT * FROM mblSql WITH(NOLOCK) WHERE Version>@version
  18485. END
  18486. GO
  18487. /****** Object: StoredProcedure [dbo].[mblMblSqlSelect] Script Date: 2018/12/13 19:07:51 ******/
  18488. SET ANSI_NULLS ON
  18489. GO
  18490. SET QUOTED_IDENTIFIER ON
  18491. GO
  18492. --#####################################################
  18493. --创建时间:2014.11.7
  18494. --创建人:Nick
  18495. --说明:
  18496. --#####################################################
  18497. CREATE PROCEDURE [dbo].[mblMblSqlSelect]
  18498. AS
  18499. BEGIN
  18500. SELECT Top 1 Version FROM mblSql WITH(NOLOCK) ORDER BY Version DESC
  18501. END
  18502. GO
  18503. /****** Object: StoredProcedure [dbo].[mblMblVersionByAppTypeSelect] Script Date: 2018/12/13 19:07:51 ******/
  18504. SET ANSI_NULLS ON
  18505. GO
  18506. SET QUOTED_IDENTIFIER ON
  18507. GO
  18508. --#####################################################
  18509. --创建时间:2014.11.7
  18510. --创建人:Nick
  18511. --说明:获取最新版本信息
  18512. --#####################################################
  18513. CREATE PROCEDURE [dbo].[mblMblVersionByAppTypeSelect]
  18514. (
  18515. @appType VARCHAR(20)
  18516. )
  18517. AS
  18518. BEGIN
  18519. SELECT TOP 1 * FROM mblVersion WITH(NOLOCK) WHERE AppType=@appType ORDER BY AddDate DESC
  18520. END
  18521. GO
  18522. /****** Object: StoredProcedure [dbo].[mblmsEmailPrevSendInsert] Script Date: 2018/12/13 19:07:51 ******/
  18523. SET ANSI_NULLS ON
  18524. GO
  18525. SET QUOTED_IDENTIFIER ON
  18526. GO
  18527. --#####################################################
  18528. --创建时间:2014.11.7
  18529. --创建人:Nick
  18530. --说明:发送邮件
  18531. --#####################################################
  18532. CREATE PROCEDURE [dbo].[mblmsEmailPrevSendInsert]
  18533. (
  18534. @cpMainId INT,
  18535. @paMainId INT,
  18536. @EmailNo INT,
  18537. @JasonData VARCHAR(MAX),
  18538. @EmailTitle VARCHAR(50),
  18539. @Email VARCHAR(50),
  18540. @dcSubsiteId INT
  18541. )
  18542. AS
  18543. BEGIN
  18544. INSERT INTO msEmailPrevSend
  18545. (cpMainId,paMainId,EmailNo,EmailTitle,JsonData,Email,dcSubsiteId,IsSend)
  18546. VALUES(@cpMainId,@paMainId,@EmailNo,@EmailTitle,@JasonData,@Email,@dcSubsiteId,0)
  18547. END
  18548. GO
  18549. /****** Object: StoredProcedure [dbo].[mblMyBespeakListSelect] Script Date: 2018/12/13 19:07:51 ******/
  18550. SET ANSI_NULLS ON
  18551. GO
  18552. SET QUOTED_IDENTIFIER ON
  18553. GO
  18554. --#####################################################
  18555. --创建时间:2014.11.7
  18556. --创建人:Nick
  18557. --说明:我的预约
  18558. --#####################################################
  18559. CREATE PROCEDURE [dbo].[mblMyBespeakListSelect]
  18560. (
  18561. @PamainID INT
  18562. )
  18563. AS
  18564. BEGIN
  18565. SELECT TOP 500 a.paMainID, b.id , b.RecruitmentName , b.BeginDate,c.Description as cityName,
  18566. d.PlaceName,d.lng,d.lat, d.Address,
  18567. ( SELECT COUNT(id) from [MarketDb]..[RmCompany] WHERE RecruitmentID = b.id AND [Status]<=1 ) as cpNum,
  18568. ( SELECT COUNT(id) from [MarketDb]..[RmPerson] WHERE RecruitmentID = b.id) as paNum,
  18569. ( SELECT COUNT(id) from [MarketDb]..[RmPersonInvitation] WHERE RecruitmentID = b.id and paMainID=@paMainID ) as myInvitCpNum
  18570. FROM [MarketDb]..[RmPerson] a, [MarketDb]..[Recruitment] b, [MainDb]..[dcRegion] c, [MarketDb]..[RmPlace] d
  18571. WHERE a.RecruitmentID=b.id
  18572. AND b.CityID = c.id
  18573. AND b.RecruitmentPlaceId = d.id
  18574. AND a.paMainID=@PamainID
  18575. ORDER BY a.AddDate DESC
  18576. END
  18577. GO
  18578. /****** Object: StoredProcedure [dbo].[mblNewsList] Script Date: 2018/12/13 19:07:51 ******/
  18579. SET ANSI_NULLS ON
  18580. GO
  18581. SET QUOTED_IDENTIFIER ON
  18582. GO
  18583. CREATE PROCEDURE [dbo].[mblNewsList]
  18584. (
  18585. @dcProvinceID AS SMALLINT,
  18586. @PageNum AS INT,
  18587. @PageSize AS INT
  18588. )
  18589. AS
  18590. BEGIN
  18591. SELECT *
  18592. FROM SearchDb..mblQlrcNews WITH(NOLOCK)
  18593. WHERE ProvinceId = @dcProvinceID
  18594. AND Rows BETWEEN (@PageNum-1) * @PageSize+1 AND @PageNum * @PageSize
  18595. ORDER BY Rows
  18596. END
  18597. GO
  18598. /****** Object: StoredProcedure [dbo].[mblPaAttentionSelect] Script Date: 2018/12/13 19:07:52 ******/
  18599. SET ANSI_NULLS ON
  18600. GO
  18601. SET QUOTED_IDENTIFIER ON
  18602. GO
  18603. CREATE PROCEDURE [dbo].[mblPaAttentionSelect]
  18604. (
  18605. @WHERE VARCHAR(1000),
  18606. @Order VARCHAR(100),
  18607. @Page SMALLINT,
  18608. @caMainID INT,
  18609. @cpMainID INT
  18610. )
  18611. AS
  18612. SET NOCOUNT ON
  18613. BEGIN
  18614. SET @Where = dbo.SafeSql(@Where)
  18615. SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '''''')
  18616. DECLARE @SQL AS VARCHAR(2000)
  18617. CREATE TABLE #T1(
  18618. TitleID BIGINT,
  18619. ID INT,
  18620. paMainID INT,
  18621. cvMainID INT,
  18622. AddDate SMALLDATETIME,
  18623. IsMatched BIT,
  18624. Degree TINYINT,
  18625. RelatedWorkYears TINYINT,
  18626. LivePlace NVARCHAR(50),
  18627. Gender BIT,
  18628. paName NVARCHAR(20),
  18629. BirthDay INT,
  18630. HasPhoto TINYINT,
  18631. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  18632. IsNameHidden BIT,
  18633. Valid TINYINT,
  18634. IsViewed BIT,
  18635. HasJobApply BIT,
  18636. HasInterview BIT,
  18637. HasRemark BIT,
  18638. HasFavorate BIT,
  18639. cvEducationID INT,
  18640. College NVARCHAR(50),
  18641. EduType TINYINT,
  18642. MajorName NVARCHAR(20),
  18643. Graduation INT,
  18644. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  18645. Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  18646. cvMatch INT,
  18647. RecruitmentID INT,
  18648. RecruitmentName NVARCHAR(100),
  18649. RecruitmentDate SMALLDATETIME,
  18650. MobileVerifyDate SMALLDATETIME,
  18651. IsOnline BIT,
  18652. JobID INT,
  18653. JobName VARCHAR(50),
  18654. AttentionType INT
  18655. )
  18656. CREATE TABLE #T(
  18657. TitleID BIGINT,
  18658. ID INT,
  18659. paMainID INT,
  18660. cvMainID INT,
  18661. AddDate SMALLDATETIME,
  18662. IsMatched BIT,
  18663. Degree TINYINT,
  18664. RelatedWorkYears TINYINT,
  18665. LivePlace NVARCHAR(50),
  18666. Gender BIT,
  18667. paName NVARCHAR(20),
  18668. BirthDay INT,
  18669. HasPhoto TINYINT,
  18670. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  18671. IsNameHidden BIT,
  18672. Valid TINYINT,
  18673. IsViewed BIT,
  18674. HasJobApply BIT,
  18675. HasInterview BIT,
  18676. HasRemark BIT,
  18677. HasFavorate BIT,
  18678. cvEducationID INT,
  18679. College NVARCHAR(50),
  18680. EduType TINYINT,
  18681. MajorName NVARCHAR(20),
  18682. Graduation INT,
  18683. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  18684. Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  18685. cvMatch INT,
  18686. RecruitmentID INT,
  18687. RecruitmentName NVARCHAR(100),
  18688. RecruitmentDate SMALLDATETIME,
  18689. MobileVerifyDate SMALLDATETIME,
  18690. IsOnline BIT,
  18691. JobID INT,
  18692. JobName VARCHAR(50),
  18693. AttentionType INT
  18694. )
  18695. SET @SQL='
  18696. INSERT INTO #T1
  18697. (TitleID, ID, paMainID, AddDate,LivePlace,Gender,
  18698. BirthDay,HasPhoto,MobileVerifyDate,IsOnline,AttentionType)
  18699. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, c.ID,a.AddDate, c.LivePlace,
  18700. c.Gender,c.BirthDay,c.HasPhoto,c.MobileVerifyDate,dbo.GetPaOnlineStatus(c.ID),1
  18701. FROM paAttention a WITH(NOLOCK),paMain c WITH(NOLOCK)
  18702. WHERE a.paMainID = c.ID AND AttentionType = 1 AND AttentionID = '+CONVERT(VARCHAR(20),@cpMainID)
  18703. PRINT @SQL
  18704. --IF LEN(@WHERE) > 0
  18705. -- SET @SQL = @SQL + ' AND ' + @WHERE
  18706. SET @SQL = @SQL + 'ORDER BY a.AddDate '
  18707. EXEC(@SQL)
  18708. SET @SQL='
  18709. INSERT INTO #T1
  18710. (TitleID, ID, paMainID, AddDate,LivePlace,Gender,
  18711. BirthDay,HasPhoto,MobileVerifyDate,IsOnline,JobID,JobName,AttentionType)
  18712. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, c.ID,a.AddDate, c.LivePlace,
  18713. c.Gender,c.BirthDay,c.HasPhoto,c.MobileVerifyDate,dbo.GetPaOnlineStatus(c.ID),b.ID,b.Name,2
  18714. FROM paAttention a WITH(NOLOCK),Job b WITH(NOLOCK),paMain c WITH(NOLOCK)
  18715. WHERE a.paMainID = c.ID
  18716. AND AttentionType = 2
  18717. AND a.AttentionID = b.ID
  18718. AND b.IsDelete = 0'
  18719. IF LEN(@WHERE) > 0
  18720. SET @SQL = @SQL + ' AND '+@WHERE
  18721. SET @SQL = @SQL + ' ORDER BY a.AddDate '
  18722. --PRINT @SQL
  18723. EXEC(@SQL)
  18724. INSERT INTO #T
  18725. SELECT * FROM #T1 ORDER BY AddDate DESC
  18726. --修改cvmainID
  18727. UPDATE a SET CvMainID = (
  18728. SELECT TOP 1 ID FROM CvMain WITH(NOLOCK)
  18729. WHERE PaMainID = a.PaMainID
  18730. AND (Valid > 0 OR substring(CvLevel,0,7)='111111' OR substring(CvLevel,0,7) = '111101' )
  18731. ORDER BY RefreshDate DESC
  18732. ) FROM #T a
  18733. UPDATE a SET CvMainID = (
  18734. SELECT TOP 1 ID FROM CvMain WITH(NOLOCK)
  18735. WHERE PaMainID = a.PaMainID
  18736. ORDER BY RefreshDate DESC
  18737. ) FROM #T a
  18738. DELETE FROM #T WHERE CvMainID IS NULL
  18739. --修改简历信息
  18740. UPDATE a
  18741. SET a.Degree = b.Degree,
  18742. a.RelatedWorkYears = b.RelatedWorkYears,
  18743. a.Attachment = b.Attachment,
  18744. a.IsNameHidden = b.IsNameHidden,
  18745. a.Valid = b.Valid
  18746. FROM #T a,CvMain b
  18747. WHERE a.CvMainID = b.ID
  18748. IF LEN(@WHERE) > 0
  18749. SET @SQL = @SQL + ' AND ' + @WHERE
  18750. IF(@Page < 1)
  18751. SET @Page = 1
  18752. IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
  18753. SET @Page = 1
  18754. UPDATE #T SET paName = LEFT(dbo.GetPersonName(cvMainID, @cpMainID), 20), IsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID),
  18755. HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  18756. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  18757. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  18758. HasJobApply = (SELECT TOP 1 '1' FROM exJobApply a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#t.cvMainID)
  18759. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  18760. UPDATE #T SET Speciality = (
  18761. SELECT Speciality FROM cvMain WITH(NOLOCK)
  18762. WHERE cvMain.ID = #T.cvMainID)
  18763. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  18764. UPDATE #T SET Experience = (
  18765. SELECT TOP 1 ISNULL(Description,DescriptionEng) FROM cvExperience WITH(NOLOCK)
  18766. WHERE cvExperience.cvMainID = #T.cvMainID
  18767. ORDER BY BeginDate DESC)
  18768. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  18769. UPDATE #T SET cvEducationID = (
  18770. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  18771. WHERE cvEducation.cvMainID = #T.cvMainID
  18772. AND #T.Degree = cvEducation.Degree
  18773. ORDER BY Graduation DESC)
  18774. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  18775. UPDATE a SET a.College = ISNULL(b.GraduateCollage,b.GraduateCollageEng),a.EduType = b.EduType,
  18776. a.MajorName = ISNULL(b.MajorName,b.MajorNameEng), a.Graduation = b.Graduation
  18777. FROM #T a, cvEducation b WITH(NOLOCK)
  18778. WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  18779. --UPDATE a SET a.RecruitmentName = b.RecruitmentName, a.RecruitmentDate = b.EndDate
  18780. --FROM #T a, Recruitment b WITH(NOLOCK)
  18781. --WHERE b.ID = a.RecruitmentID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  18782. UPDATE #T SET cvMatch = dbo.GetCvMatch(cvMainID,JobID) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  18783. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  18784. SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  18785. --计算匹配度
  18786. DROP TABLE #T1
  18787. DROP TABLE #T
  18788. END
  18789. GO