1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791 |
- /****** Object: StoredProcedure [dbo].[ccExInterViewByJobIDSendSmsInsert] Script Date: 2018/12/13 19:06:46 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- /*#######################################
- ---面试通知(是否发送短信)
- ---创建人harry
- #######################################*/
- CREATE PROCEDURE [dbo].[ccExInterViewByJobIDSendSmsInsert]
- (
- @JobID INT,
- @cpMainID INT,
- @cvMainID INT,
- @InterviewDate VARCHAR(100),
- @InterViewPlace VARCHAR(200),
- @LinkMan VARCHAR(12),
- @Telephone VARCHAR(20),
- @Remark VARCHAR(1000),
- @SendSms INT--发送短信
- )
- AS
- SET NOCOUNT ON
- BEGIN
- SET NOCOUNT ON
- DECLARE @InterviewPoint INT --直接发送面试通知 赠送积分
- DECLARE @ReplyInterviewPoint INT --答复后 发送面试通知 赠送积分
- SET @InterviewPoint =7
- SET @ReplyInterviewPoint = 10
- DECLARE @caMainID INT, @paMainId INT, @ExInterViewID INT, @wxFansId INT,@JobName NVARCHAR(50)
- SELECT @caMainID = caMainId, @JobName = Name FROM Job WITH(NOLOCK) WHERE ID = @JobID AND cpMainID = @cpMainID
- IF ISNULL(@caMainID, 0) = 0
- RETURN -1
- SELECT @Remark = dbo.TrimNull(@Remark),
- @InterviewDate = dbo.Trim(@InterviewDate),
- @InterViewPlace = dbo.Trim(@InterViewPlace),
- @Telephone = dbo.Trim(@Telephone)
- INSERT INTO ExInterView(JobID, cvMainID, InterviewDate, InterViewPlace, LinkMan, Telephone, Remark)
- VALUES(@JobID, @cvMainID, @InterviewDate, @InterViewPlace, @LinkMan, @Telephone, @Remark)
- SET @ExInterViewID = @@IDENTITY
-
- --未答复的修改答复状态
- UPDATE exJobApply SET Reply =1,ReplyDate=GETDATE() WHERE JobID = @JobID AND CvMainID = @cvMainID
- BEGIN TRY
- SELECT @paMainId = paMainId FROM cvMain WITH(NOLOCK) WHERE Id = @cvMainId
- SELECT @wxFansId = id FROM wxFans WITH(NOLOCK) WHERE paMainId = @paMainId AND [Status] = 2
- IF @wxFansId IS NOT NULL--关注的用户发送微信消息提醒
- BEGIN
- --插入到wxMessageSend表中
- INSERT INTO WxMessageSend2(Templatetype, WxFansID, PaMainId, MainTableId, CpMainID, CvMainID, JobId, CaMainId, AddDate)
- SELECT 1, @wxFansId, @paMainId, @ExInterViewID, @cpMainId, @cvMainID, @JobId, @caMainID, GETDATE()
- END
-
- IF @SendSms > 0 --发送短信
- BEGIN
- --获取剩余可用短信量
- --优先取主订单id
- DECLARE @orderId INT --订单id
- SELECT TOP 1 @orderId = id
- FROM caOrder
- WHERE cpMainId = @cpMainId
- AND RemainSmsQuota > 0
- AND OrderType IN (8,14)
- AND OpenDate IS NOT NULL
- AND BeginDate< GETDATE()
- AND EndDate > GETDATE()
- AND IsDeleted = 0
- ORDER BY ID
-
- IF ISNULL(@orderId, 0)>0
- BEGIN
- DECLARE @smsLogId INT, @msg VARCHAR(400), @mobile CHAR(11)
-
- SELECT @mobile = Mobile, @msg = ISNULL(Name, '')
- FROM paMain WITH(NOLOCK)
- WHERE ID = @paMainId
- AND Mobile > ''
- AND IsReceiveSms = 1
-
- IF ISNULL(@mobile, '') <> ''
- BEGIN
- SELECT @msg = @msg +'你好,' + d.Name +'在' + c.SubSiteName + c.EmailSite + '给您发了面试通知,面试职位:'+ @JobName +',面试时间:' + @InterviewDate +
- ',地点:' + @InterViewPlace + ',联系电话:' + @Telephone + '。'
- FROM dcSubSite c WITH(NOLOCK), cpMain d WITH(NOLOCK)
- WHERE d.dcProvinceID = c.ID
- AND d.ID = @cpMainID
-
- INSERT SmsMessageLog(SendMan, ManagerUSerId, paMainId, caMainId, Mobile, MsgType, IsCat, Msg)
- SELECT 0, NULL, @paMainId, @caMainID, @mobile, 101, 0, @msg
-
- SET @smsLogId = @@IDENTITY
- --短信-1
- UPDATE caOrder set RemainSmsQuota = RemainSmsQuota-1 WHERE id = @orderId
-
- --插入消耗记录
- INSERT INTO casmslog(caOrderId, cvMainId, caMainId, Mobile, MsgType, RelationId, SmsMessageLogId, SendStatus, SendDate, Msg, AddDate)
- SELECT @orderId, @cvMainID, @caMainID, @mobile, 101, @ExInterViewID, @smsLogId, NULL, NULL, @msg,GETDATE()
- UPDATE ExInterView SET SmsNumber = ISNULL(SmsNumber, 0) + 1 WHERE ID = @ExInterViewID
- END
- END
- END
-
- INSERT INTO paPushLog(paMainID, PushMessage, PushType)
- SELECT @paMainId, '亲,收到一份面试通知!', 2 WHERE EXISTS(SELECT 'X' FROM paIOSBind WHERE paMainID = @paMainId)
- END TRY
- BEGIN CATCH
- END CATCH
-
- --插入积分记录
- BEGIN TRY
- --插入积分记录
- DECLARE @TodayPoint AS INT, @TodayID AS INT, @JobApplyID INT,@Reply INT
- SELECT @TodayPoint = 0, @TodayID = 0
- 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
-
- -- --判断是否是应聘的简历
- -- SELECT @JobApplyID = 0, @Reply = 0
- --
- -- SELECT @JobApplyID = ID, @Reply = Reply
- -- FROM ExJobApply WITH(NOLOCK)
- -- WHERE JobID = @JobID
- -- AND CvMainID = @cvMainID
- -- IF @JobApplyID = 0 --未应聘
- -- BEGIN
- -- SET @TodayPoint = @ReplyInterviewPoint
- -- END
- -- ELSE
- -- BEGIN
- -- IF @Reply = 0
- -- BEGIN
- -- UPDATE ExJobApply
- -- SET Reply = 1
- -- WHERE ID = @JobApplyID
- --
- -- SET @TodayPoint = @InterviewPoint
- -- END
- -- ELSE
- -- BEGIN
- -- SET @TodayPoint = @ReplyInterviewPoint
- -- END
- -- END
- SET @TodayPoint = @TodayPoint + @ReplyInterviewPoint
-
- IF @TodayPoint <= 200
- BEGIN
- IF @TodayID = 0
- BEGIN
- INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@cpMainID,4,@TodayPoint,GETDATE())
- END
- ELSE
- BEGIN
- UPDATE cpPoint SET Point = Point + @TodayPoint,LastModifyDate = GETDATE() WHERE ID = @TodayID
- END
- END
- END TRY
- BEGIN CATCH
- END CATCH
- END
- SET NOCOUNT OFF
- GO
- /****** Object: StoredProcedure [dbo].[ccExInterViewByOneWeekSelect] Script Date: 2018/12/13 19:06:47 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccExInterViewByOneWeekSelect]
- (
- @caMainID INT
- )
- AS
- BEGIN
- BEGIN TRY
- DECLARE @return INT
- SELECT @return = COUNT(1) FROM exInterView WITH(NOLOCK)
- WHERE AddDate > DATEADD(week,-1,GETDATE())
- AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE caMainID = @caMainID)
- RETURN @return
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExInterViewInsert] Script Date: 2018/12/13 19:06:47 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- /*#######################################
- ---面试通知
- 2012-10-23 sean
- update msgcount from smsmessagelog
- 2014-08-25 Peter
- 添加积分记录
- ---2015-8-27 Harry
- ---增加将绑定关注微信的,插入到wxsendmessage表中
- --修改Harry2017-4-17
- #######################################*/
- CREATE PROCEDURE [dbo].[ccExInterViewInsert]
- (
- @JobID INT,
- @cpMainID INT,
- @cvMainID INT,
- @InterviewDate VARCHAR(100),
- @InterViewPlace VARCHAR(200),
- @LinkMan VARCHAR(12),
- @Telephone VARCHAR(20),
- @Remark VARCHAR(1000)
- )
- AS
- SET NOCOUNT ON
- BEGIN
- SET NOCOUNT ON
- DECLARE @caMainID INT, @paMainId INT, @ExInterViewID INT, @wxFansId INT, @MsgCount INT
- SELECT @caMainID = caMainId FROM Job WITH(NOLOCK) WHERE ID = @JobID AND cpMainID = @cpMainID
- IF ISNULL(@caMainID, 0) = 0
- RETURN -1
- SELECT @Remark = dbo.TrimNull(@Remark),
- @InterviewDate = dbo.Trim(@InterviewDate),
- @InterViewPlace = dbo.Trim(@InterViewPlace),
- @Telephone = dbo.Trim(@Telephone)
- INSERT INTO ExInterView(JobID, cvMainID, InterviewDate, InterViewPlace, LinkMan, Telephone, Remark)
- VALUES(@JobID, @cvMainID, @InterviewDate, @InterViewPlace, @LinkMan, @Telephone, @Remark)
- SET @ExInterViewID = @@IDENTITY
-
- BEGIN TRY
- SELECT @paMainId = paMainId FROM cvMain WITH(NOLOCK) WHERE Id = @cvMainId
-
- SELECT @MsgCount = SUM(smsNumber) FROM ExInterView WITH(NOLOCK)
- WHERE JobId IN(SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainId = @cpMainID)
- AND AddDate > CONVERT(VARCHAR(10), GETDATE() - 29, 120)
- IF @MsgCount < 45
- BEGIN
- INSERT SmsMessageLog(SendMan, ManagerUSerId, paMainId, caMainId, Mobile, MsgType, IsCat, Msg)
- SELECT 0, NULL, b.ID, @caMainID, b.Mobile, 101, 0,
- ISNULL(b.Name,'') +','+ d.Name +'在'+ c.SubSiteName + c.EmailSite +'上邀请您面试,请登录网站查看'
- FROM cvMain a WITH(NOLOCK), paMain b WITH(NOLOCK), dcSubSite c WITH(NOLOCK),cpMain d WITH(NOLOCK)
- WHERE a.paMainID = b.ID
- AND b.dcSubSiteID = c.ID
- AND d.ID = @cpMainID
- AND b.Mobile > ''
- AND a.ID = @cvMainID
- AND b.IsReceiveSms = 1
- UPDATE ExInterView SET SmsNumber = ISNULL(SmsNumber, 0) + 1 WHERE ID = @ExInterViewID
- END
- ELSE --关注的用户发送微信消息提醒
- BEGIN
- SELECT @wxFansId = id FROM wxFans WITH(NOLOCK) WHERE paMainId = @paMainId AND [Status] = 2
- IF @wxFansId > 0
- --插入到wxMessageSend表中
- INSERT WxMessageSend2(Templatetype, WxFansID, PaMainId, MainTableId, CpMainID, CvMainID, JobId, CaMainId, AddDate)
- SELECT 1, @wxFansId, @paMainId, @ExInterViewID, @cpMainId, @cvMainID, @JobId, @caMainID, GETDATE()
- END
- END TRY
- BEGIN CATCH
- END CATCH
-
- --插入积分记录
- BEGIN TRY
- --插入积分记录
- DECLARE @TodayPoint AS INT
- DECLARE @TodayID AS INT
- SET @TodayPoint = 0
- SET @TodayID = 0
- 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
-
- SET @TodayPoint = @TodayPoint + 10
-
- IF @TodayPoint <= 200
- BEGIN
- IF @TodayID = 0
- BEGIN
- INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@cpMainID,4,2,GETDATE())
- END
- ELSE
- BEGIN
- UPDATE cpPoint SET Point = @TodayPoint,LastModifyDate = GETDATE() WHERE ID = @TodayID
- END
- END
-
- END TRY
- BEGIN CATCH
- END CATCH
- -- RETURN @Return
- RETURN ISNULL(@MsgCount, 0)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExInterviewSelect] Script Date: 2018/12/13 19:06:47 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- ---修改Harry 2017-6-7 增加显示短信订单内容
- CREATE PROCEDURE [dbo].[ccExInterviewSelect]
- (
- @WHERE VARCHAR(1000),
- @Order VARCHAR(100),
- @page SMALLINT,
- @caMainID INT,
- @cpMainID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- SET @WHERE = dbo.SafeSQL(@WHERE)
- SET @ORDER = dbo.SafeSQL(@ORDER)
- CREATE TABLE #T(
- TitleID BIGINT,
- ID INT,
- JobID INT,
- JobName NVARCHAR(50) COLLATE Chinese_PRC_CI_AS NULL,
- JobRegion VARCHAR(6) NULL,
- IsJobDelete BIT NULL,
- cvMainID INT,
- InterviewDate VARCHAR(100) COLLATE Chinese_PRC_CI_AS NULL,
- InterviewPlace NVARCHAR(200),
- LinkMan NVARCHAR(40),
- Telephone VARCHAR(30) COLLATE Chinese_PRC_CI_AS NULL,
- Remark VARCHAR(1000) COLLATE Chinese_PRC_CI_AS NULL,
- AddDate SMALLDATETIME,
- Reply TINYINT,
- ReplyMessage VARCHAR(500) COLLATE Chinese_PRC_CI_AS NULL,
- Degree TINYINT,
- RelatedWorkYears TINYINT,
- Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS NULL,
- IsNameHidden BIT,
- LivePlace VARCHAR(6) COLLATE Chinese_PRC_CI_AS NULL,
- Gender BIT,
- paName NVARCHAR(20),
- BirthDay INT,
- HasPhoto TINYINT,
- Valid TINYINT,
- IsViewed BIT,
- HasJobApply BIT,
- HasFavorate BIT,
- HasRemark BIT,
- Result BIT,
- ResultDate SMALLDATETIME,
- MobileVerifyDate SMALLDATETIME,
- IsOnline BIT,
- SmsMsg NVARCHAR(210) NULL, --短信内容
- paMainID INT,
- SecondId VARCHAR(10)
- )
- DECLARE @SQL AS VARCHAR(2000)
- SET @SQL='
- INSERT INTO #T(TitleID, ID, JobID, cvMainID, InterviewDate, InterviewPlace, LinkMan,
- Telephone, Remark, AddDate, Reply, ReplyMessage, Result, ResultDate, IsOnline, paMainId, SecondId)
- SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, a.JobID, a.cvMainID,
- a.InterviewDate, a.InterviewPlace, a.LinkMan, a.Telephone, a.Remark, a.AddDate, a.Reply, a.ReplyMessage,
- a.Result, a.ResultDate, dbo.GetPaOnlineStatus(c.ID), b.paMainId, b.SecondId
- FROM exInterview a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- WHERE a.JobID IN(SELECT id FROM Job WITH(NOLOCK) WHERE cpMainID = ' + CONVERT(VARCHAR,@cpMainID) + ') '
-
- SET @SQL = @SQL + ' AND CompanyDeleted=0'
- IF LEN(@WHERE) > 0
- BEGIN
- SET @Where = dbo.SafeSql(@Where)
- SET @SQL = @SQL + @WHERE
- END
- --PRINT @SQL
- EXEC(@SQL)
- IF(@Page < 1)
- SET @Page = 1
-
- UPDATE #T SET Degree = a.Degree, RelatedWorkYears = a.RelatedWorkYears, Attachment = a.Attachment,
- IsNameHidden = a.IsNameHidden, LivePlace = b.LivePlace, Gender = b.Gender, paName = b.Name,
- BirthDay = b.BirthDay, HasPhoto = b.HasPhoto, Valid = a.Valid, MobileVerifyDate = b.MobileVerifyDate
- FROM cvMain a WITH(NOLOCK) INNER JOIN paMain b WITH(NOLOCK) ON a.paMainID = b.ID
- WHERE a.ID = #T.cvMainID AND TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- 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),
- 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),
- HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
- HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
- SmsMsg = (SELECT TOP 1 Msg FROM casmslog WITH(NOLOCK) WHERE MsgType = 101 AND RelationId = #T.ID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- UPDATE #T SET JobName = a.Name, JobRegion= a.dcRegionID, IsJobDelete = IsDelete
- FROM Job a WITH(NOLOCK)
- WHERE #T.JobID = a.ID
-
- --修改查看状态
- UPDATE exInterview
- SET CpResultViewDate = GETDATE()
- WHERE JobID IN
- (
- SELECT ID FROM Job WITH(NOLOCK)
- WHERE CpMainID = @cpMainID
- AND CaMainID = @caMainID
- )
- AND CpResultViewDate IS NULL
- AND Replydate IS NOT NULL
-
- SELECT COUNT(*) FROM #T WITH(NOLOCK)
- SELECT a.*, dbo.BirthToAge(a.BirthDay) Age, b.Description DegreeName, c.MapBarName LivePlaceName, d.Description JobRegionName
- FROM #T a WITH(NOLOCK)
- LEFT JOIN dcEducation b WITH(NOLOCK) ON b.ID = a.Degree
- LEFT JOIN dcRegion c WITH(NOLOCK) ON c.ID = a.LivePlace
- LEFT JOIN dcRegion d WITH(NOLOCK) ON d.ID = a.JobRegion
- WHERE a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
-
- DROP TABLE #T
- END
- SET NOCOUNT OFF
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplyBatchDelete] Script Date: 2018/12/13 19:06:48 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --Lambo 20101130 修改
- -- 增加cpMainID 参数,只能删除本公司的
- CREATE PROCEDURE [dbo].[ccExJobApplyBatchDelete]
- (
- @AllID VARCHAR(1000),
- @cpMainID INT
- )
- AS
- BEGIN TRAN
- BEGIN TRY
- SET @AllID = dbo.FormatIDS(@AllID)
- DECLARE @T AS TABLE(ID INT)
- INSERT INTO @T SELECT * FROM dbo.fnSplit(@AllID, ',')
-
- INSERT INTO CaCvApplyDeleted(JobID,JobName,CvMainId,ApplyDate,AddDate,Reply)
- SELECT b.ID,b.Name,a.cvMainid,a.AddDate,GETDATE(),ISNULL(Reply,0)
- FROM exjobapply a,job b
- WHERE a.jobid = b.id
- AND a.id in (SELECT id FROM @t)
- DELETE FROM ExJobApply WHERE PersonDeleted=1 AND ID IN(SELECT ID FROM @T)
- AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
-
- UPDATE ExJobApply SET CompanyDeleted = 1, CompanyDeleteDate = GETDATE(),ReplyDate=GETDATE()
- WHERE Reply <> 0 AND ID IN(SELECT ID FROM @T)
- AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
-
- UPDATE ExJobApply SET CompanyDeleted = 1, CompanyDeleteDate = GETDATE(), Reply = 4,ReplyDate=GETDATE()
- WHERE Reply = 0 AND ID IN(SELECT ID FROM @T)
- AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
- END TRY
- BEGIN CATCH
- GOTO ERR
- END CATCH
- COMMIT TRAN
- RETURN 1
- ERR:
- BEGIN
- ROLLBACK TRAN
- RETURN 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplyByApplyCountSelect] Script Date: 2018/12/13 19:06:49 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- -------------------------------------------------------
- --创建时间:2015.7.14
- --创建人:Mice
- --说明:查询申请数量(包括过滤和未过滤)
- -------------------------------------------------------
- CREATE PROCEDURE [dbo].[ccExJobApplyByApplyCountSelect]
- (
- @JobID INT
- )
- AS
- BEGIN
- SET NOCOUNT ON
- SELECT COUNT(ID) AS ApplyCount
- FROM exJobApply WITH(NOLOCK)
- WHERE JobID = @JobID
- SET NOCOUNT OFF
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplyByAssessReportSelect] Script Date: 2018/12/13 19:06:49 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:20181123
- --创建人:Peter
- --查询已查看的测评报告
- --#####################################################
- CREATE PROCEDURE [dbo].[ccExJobApplyByAssessReportSelect]
- (
- @WHERE VARCHAR(1000),
- @Order VARCHAR(100),
- @Page SMALLINT,
- @caMainID INT,
- @ReplyType INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @WHERE2 VARCHAR(MAX)
- IF @ReplyType = 5
- BEGIN
- SET @WHERE2 = ' And IsFilter = 0 AND Reply = 0 AND ViewDate IS NULL'
- END
- ELSE IF @ReplyType = 1
- BEGIN
- SET @WHERE2 = ' And IsFilter = 0 AND Reply = 0 AND ViewDate IS NOT NULL'
- END
- ELSE IF @ReplyType = 2
- BEGIN
- SET @WHERE2 = ' And IsFilter = 0 AND Reply = 1 AND ViewDate IS NOT NULL'
- END
- ELSE IF @ReplyType = 3
- BEGIN
- SET @WHERE2 = ' And IsFilter = 0 AND (Reply = 2 OR Reply = 5) AND ViewDate IS NOT NULL'
- END
- ELSE IF @ReplyType = 4
- BEGIN
- SET @WHERE2 = ' And IsFilter = 1 ' --AND ViewDate is null'
- END
- ELSE
- SET @WHERE2 = ' And IsFilter = 0'
- SET @Where = dbo.SafeSql(@Where)
- SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '''''')
-
- DECLARE @SQL AS VARCHAR(2000)
- CREATE TABLE #T(
- TitleID BIGINT,
- ID INT,
- JobID INT,
- paMainID INT,
- cvMainID INT,
- AddDate SMALLDATETIME,
- Reply TINYINT,
- ReplyDate SMALLDATETIME,
- IsMatched BIT,
- Degree TINYINT,
- RelatedWorkYears TINYINT,
- LivePlace NVARCHAR(50),
- Gender BIT,
- paName NVARCHAR(20),
- BirthDay INT,
- HasPhoto TINYINT,
- Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
- IsNameHidden BIT,
- Valid TINYINT,
- ApplyMessage NVARCHAR(1),
- IsViewed BIT,
- HasInterview BIT,
- HasRemark BIT,
- HasFavorate BIT,
- cvEducationID INT,
- College NVARCHAR(50),
- EduType TINYINT,
- MajorName NVARCHAR(20),
- Graduation INT,
- Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- cvMatch INT,
- RecruitmentID INT,
- RecruitmentName NVARCHAR(100),
- RecruitmentDate SMALLDATETIME,
- MobileVerifyDate SMALLDATETIME,
- IsOnline BIT,
- RemindDate DATETIME,
- HasWeiXin BIT,
- ReplyReason VARCHAR(200),
- Accept BIT,
- NoAccept BIT,
- SecondId VARCHAR(10),
- Mobile VARCHAR(15),
- Email VARCHAR(100),
- ContactPrivi BIT,
- AssessCnt INT,
- CpViewDate SMALLDATETIME,
- AssessTestLogID INT,
- AssessTypeName VARCHAR(100)
- )
- SET @SQL='
- INSERT INTO #T(TitleID, ID, JobID, paMainID, cvMainID, AddDate, Reply, ReplyDate, IsMatched,
- ApplyMessage, Degree, RelatedWorkYears, Attachment, IsNameHidden, LivePlace, Gender, BirthDay,
- HasPhoto, Valid, RecruitmentID, MobileVerifyDate, IsOnline, RemindDate, ReplyReason, SecondId,
- CpViewDate,AssessTestLogID,AssessTypeName)
- SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, a.JobID, c.ID, a.cvMainID,
- a.AddDate, a.Reply, a.ReplyDate, a.IsMatched, LEFT(a.ApplyMessage, 1) ApplyMessage, b.Degree,
- b.RelatedWorkYears, b.Attachment, b.IsNameHidden, c.LivePlace, c.Gender, c.BirthDay, c.HasPhoto,
- b.Valid, a.RecruitmentID, c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID), a.RemindDate,
- a.ReplyReason, b.SecondId ,e.CpViewDate,e.AssessTestLogID,g.Name
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
- RIGHT JOIN AssessJobapply e WITH(NOLOCK) ON e.ExJobApplyID = a.ID
- INNER JOIN AssessTestLog f WITH(NOLOCK) ON f.id = e.AssessTestLogID
- INNER JOIN AssessType g WITH(NOLOCK) ON g.id = f.AssessTypeID
- WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0 AND e.CpViewDate IS NOT NULL '
- IF LEN(@WHERE) > 0
- SET @SQL = @SQL + ' AND ' + @WHERE + @WHERE2
- --PRINT @SQL
- EXEC(@SQL)
- DECLARE @cpMainID AS INT
- SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
- --删除在cpCvShield中的简历
- DELETE FROM #t
- WHERE cvMainId IN(select cvMainId FROM cpCvShield WHERE cpMainID=@cpMainID)
- IF(@Page < 1)
- SET @Page = 1
- IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
- SET @Page = 1
-
-
- 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),
- HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
- 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),
- HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- IF EXISTS(SELECT TOP 1 'X' FROM caMain WHERE ID = @caMainID AND AccountType = 1)
- BEGIN
- UPDATE #T SET
- 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)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- END
- UPDATE #T
- 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),
- 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)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- AND HasInterview = 1
- UPDATE #T SET Speciality = (
- SELECT Speciality FROM cvMain WITH(NOLOCK)
- WHERE cvMain.ID = #T.cvMainID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- UPDATE #T SET Experience = (
- SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
- WHERE cvExperience.cvMainID = #T.cvMainID
- ORDER BY BeginDate DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE #T SET cvEducationID = (
- SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
- WHERE cvEducation.cvMainID = #T.cvMainID
- AND #T.Degree = cvEducation.Degree
- ORDER BY Graduation DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- --修改是否绑定微信
- UPDATE a SET HasWeiXin = 1
- FROM #T a, WxFans b WITH(NOLOCK)
- WHERE a.paMainID = b.PaMainID
- AND b.Status = 2
- AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
- a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
- FROM #T a, cvEducation b WITH(NOLOCK)
- WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
-
- UPDATE a SET a.RecruitmentName = b.RecruitmentName, a.RecruitmentDate = b.EndDate
- FROM #T a, Recruitment b WITH(NOLOCK)
- WHERE b.ID = a.RecruitmentID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
- UPDATE a SET Email = b.Email,Mobile = b.Mobile,ContactPrivi = dbo.CheckCvPrivi(a.cvMainID,@cpMainID)
- FROM #T a,PaMain b WITH(NOLOCK)
- WHERE b.id = a.paMainID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
- UPDATE #T
- SET AssessCnt = (SELECT COUNT(1) FROM AssessJobApply WITH(NOLOCK) WHERE ExJobApplyID = #T.ID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- UPDATE #T SET cvMatch = dbo.GetCvMatch(cvMainID, JobID) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- SELECT COUNT(*) FROM #T WITH(NOLOCK)
- SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- DECLARE @NoViewCnt INT, @NoReply INT, @ReplyYes INT, @ReplyNo INT, @SQL2 NVARCHAR(4000), @Filter INT
- --计算匹配度
- SELECT @NoViewCnt AS NoViewCnt, @NoReply AS NoReply, @ReplyYes AS ReplyYes, @ReplyNo AS ReplyNo, @Filter AS FilterCnt
- --修改 已查看提醒时间
- UPDATE ExJobApply
- SET CpRemindViewDate = GETDATE()
- WHERE JobID IN (
- SELECT ID FROM JOB WITH(NOLOCK)
- WHERE CaMainID = @caMainID
- ) AND RemindDate IS NOT NULL
- AND CpRemindViewDate IS NULL
- DROP TABLE #T
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplyByCaMainIDSelect] Script Date: 2018/12/13 19:06:49 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --Nick 20140821 修改
- -- 加入修改应聘简历的查看日期viewdate
- --20160107
- --加入是否绑定微信
- --Carl 修改 自动答复的 应放到储备下面而不是 待答复下面
- --carl 2018-2-26
- --harry 2018-6-11 cpCvShield中的不显示
- --alen 2018-9-28 添加标签功能
- --Peter 2018-10-15 添加个人联系方式以及权限
- CREATE PROCEDURE [dbo].[ccExJobApplyByCaMainIDSelect]
- (
- @WHERE VARCHAR(1000),
- @Order VARCHAR(100),
- @Page SMALLINT,
- @caMainID INT,
- @ReplyType INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @WHERE2 VARCHAR(MAX)
- IF @ReplyType = 5
- BEGIN
- SET @WHERE2 = ' And IsFilter = 0 AND Reply = 0 AND ViewDate IS NULL'
- END
- ELSE IF @ReplyType = 1
- BEGIN
- SET @WHERE2 = ' And IsFilter = 0 AND Reply = 0 AND ViewDate IS NOT NULL'
- END
- ELSE IF @ReplyType = 2
- BEGIN
- SET @WHERE2 = ' And IsFilter = 0 AND Reply = 1 AND ViewDate IS NOT NULL'
- END
- ELSE IF @ReplyType = 3
- BEGIN
- SET @WHERE2 = ' And IsFilter = 0 AND (Reply = 2 OR Reply = 5) AND ViewDate IS NOT NULL'
- END
- ELSE IF @ReplyType = 4
- BEGIN
- SET @WHERE2 = ' And IsFilter = 1 ' --AND ViewDate is null'
- END
- ELSE
- SET @WHERE2 = ' And IsFilter = 0'
- SET @Where = dbo.SafeSql(@Where)
- SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '''''')
-
- DECLARE @SQL AS VARCHAR(2000)
- CREATE TABLE #T(
- TitleID BIGINT,
- ID INT,
- JobID INT,
- paMainID INT,
- cvMainID INT,
- AddDate SMALLDATETIME,
- Reply TINYINT,
- ReplyDate SMALLDATETIME,
- IsMatched BIT,
- Degree TINYINT,
- RelatedWorkYears TINYINT,
- LivePlace NVARCHAR(50),
- Gender BIT,
- paName NVARCHAR(20),
- BirthDay INT,
- HasPhoto TINYINT,
- Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
- IsNameHidden BIT,
- Valid TINYINT,
- ApplyMessage NVARCHAR(1),
- IsViewed BIT,
- HasInterview BIT,
- HasRemark BIT,
- HasFavorate BIT,
- cvEducationID INT,
- College NVARCHAR(50),
- EduType TINYINT,
- MajorName NVARCHAR(20),
- Graduation INT,
- Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- cvMatch INT,
- RecruitmentID INT,
- RecruitmentName NVARCHAR(100),
- RecruitmentDate SMALLDATETIME,
- MobileVerifyDate SMALLDATETIME,
- IsOnline BIT,
- RemindDate DATETIME,
- HasWeiXin BIT,
- ReplyReason VARCHAR(200),
- Accept BIT,
- NoAccept BIT,
- SecondId VARCHAR(10),
- Mobile VARCHAR(15),
- Email VARCHAR(100),
- ContactPrivi BIT,
- AssessCnt INT
- )
- SET @SQL='
- INSERT INTO #T(TitleID, ID, JobID, paMainID, cvMainID, AddDate, Reply, ReplyDate, IsMatched,
- ApplyMessage, Degree, RelatedWorkYears, Attachment, IsNameHidden, LivePlace, Gender, BirthDay,
- HasPhoto, Valid, RecruitmentID, MobileVerifyDate, IsOnline, RemindDate, ReplyReason, SecondId)
- SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, a.JobID, c.ID, a.cvMainID,
- a.AddDate, a.Reply, a.ReplyDate, a.IsMatched, LEFT(a.ApplyMessage, 1) ApplyMessage, b.Degree,
- b.RelatedWorkYears, b.Attachment, b.IsNameHidden, c.LivePlace, c.Gender, c.BirthDay, c.HasPhoto,
- b.Valid, a.RecruitmentID, c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID), a.RemindDate,
- a.ReplyReason, b.SecondId
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
- WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0 '
- IF LEN(@WHERE) > 0
- SET @SQL = @SQL + ' AND ' + @WHERE + @WHERE2
- --PRINT @SQL
- EXEC(@SQL)
- DECLARE @cpMainID AS INT
- SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
- --删除在cpCvShield中的简历
- DELETE FROM #t
- WHERE cvMainId IN(select cvMainId FROM cpCvShield WHERE cpMainID=@cpMainID)
- IF(@Page < 1)
- SET @Page = 1
- IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
- SET @Page = 1
-
-
- 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),
- HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
- 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),
- HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- IF EXISTS(SELECT TOP 1 'X' FROM caMain WHERE ID = @caMainID AND AccountType = 1)
- BEGIN
- UPDATE #T SET
- 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)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- END
- UPDATE #T
- 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),
- 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)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- AND HasInterview = 1
- UPDATE #T SET Speciality = (
- SELECT Speciality FROM cvMain WITH(NOLOCK)
- WHERE cvMain.ID = #T.cvMainID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- UPDATE #T SET Experience = (
- SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
- WHERE cvExperience.cvMainID = #T.cvMainID
- ORDER BY BeginDate DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE #T SET cvEducationID = (
- SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
- WHERE cvEducation.cvMainID = #T.cvMainID
- AND #T.Degree = cvEducation.Degree
- ORDER BY Graduation DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- --修改是否绑定微信
- UPDATE a SET HasWeiXin = 1
- FROM #T a, WxFans b WITH(NOLOCK)
- WHERE a.paMainID = b.PaMainID
- AND b.Status = 2
- AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
- a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
- FROM #T a, cvEducation b WITH(NOLOCK)
- WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
-
- UPDATE a SET a.RecruitmentName = b.RecruitmentName, a.RecruitmentDate = b.EndDate
- FROM #T a, Recruitment b WITH(NOLOCK)
- WHERE b.ID = a.RecruitmentID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
- UPDATE a SET Email = b.Email,Mobile = b.Mobile,ContactPrivi = dbo.CheckCvPrivi(a.cvMainID,@cpMainID)
- FROM #T a,PaMain b WITH(NOLOCK)
- WHERE b.id = a.paMainID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
- UPDATE #T
- SET AssessCnt = (SELECT COUNT(1) FROM AssessJobApply WITH(NOLOCK) WHERE ExJobApplyID = #T.ID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- UPDATE #T SET cvMatch = dbo.GetCvMatch(cvMainID, JobID) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- SELECT COUNT(*) FROM #T WITH(NOLOCK)
- SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- DECLARE @NoViewCnt INT, @NoReply INT, @ReplyYes INT, @ReplyNo INT, @SQL2 NVARCHAR(4000), @Filter INT
- --未查看数量
- SET @SQL2 = '
- SELECT @NoViewCnt1 = COUNT(*)
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
- WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0
- And a.IsFilter = 0
- AND a.Reply=0
- AND a.ViewDate is null AND ' + @WHERE
- EXEC SP_EXECUTESQL @SQL2, N'@NoViewCnt1 int OUTPUT', @NoViewCnt OUTPUT
- --待答复数量
- SET @SQL2 = '
- SELECT @NoReply1 = COUNT(*)
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
- WHERE a.CompanyDeleted = 0
- AND d.IsDelete = 0
- And a.IsFilter = 0
- AND Reply=0
- AND ViewDate IS NOT NULL
- AND ' + @WHERE
- EXEC SP_EXECUTESQL @SQL2, N'@NoReply1 int OUTPUT', @NoReply OUTPUT
- --符合要求数量
- SET @SQL2 = '
- SELECT @ReplyYes1 = COUNT(*)
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
- WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0
- And a.IsFilter = 0
- AND Reply=1
- AND ' + @WHERE
- EXEC SP_EXECUTESQL @SQL2, N'@ReplyYes1 int OUTPUT', @ReplyYes OUTPUT
- --不符合要求数量
- SET @SQL2 = ' SELECT @ReplyNo1 = COUNT(*)
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
- WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0
- And a.IsFilter = 0
- AND Reply IN(2, 5) AND ' + @WHERE
- EXEC SP_EXECUTESQL @SQL2, N'@ReplyNo1 int OUTPUT', @ReplyNo OUTPUT
- --未查看数量
- SET @SQL2 = '
- SELECT @Filter1 = COUNT(*)
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
- WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0
- And a.IsFilter = 1
- AND ' + @WHERE
- EXEC SP_EXECUTESQL @SQL2, N'@Filter1 int OUTPUT', @Filter OUTPUT
- --计算匹配度
- SELECT @NoViewCnt AS NoViewCnt, @NoReply AS NoReply, @ReplyYes AS ReplyYes, @ReplyNo AS ReplyNo, @Filter AS FilterCnt
- --修改 已查看提醒时间
- UPDATE ExJobApply
- SET CpRemindViewDate = GETDATE()
- WHERE JobID IN (
- SELECT ID FROM JOB WITH(NOLOCK)
- WHERE CaMainID = @caMainID
- ) AND RemindDate IS NOT NULL
- AND CpRemindViewDate IS NULL
- DROP TABLE #T
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplyByCaMainIDSelect2] Script Date: 2018/12/13 19:06:49 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --Nick 20140821 修改
- -- 加入修改应聘简历的查看日期viewdate
- --20160107
- --加入是否绑定微信
- CREATE PROCEDURE [dbo].[ccExJobApplyByCaMainIDSelect2]
- (
- @WHERE VARCHAR(1000),
- @Order VARCHAR(100),
- @Page SMALLINT,
- @caMainID INT,
- @ReplyType INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @WHERE2 VARCHAR(MAX)
- IF @ReplyType = 5
- BEGIN
- SET @WHERE2 = ' And IsFilter = 0 AND Reply = 0 AND ViewDate IS NULL'
- END
- ELSE IF @ReplyType = 1
- BEGIN
- SET @WHERE2 = ' And IsFilter = 0 AND (Reply = 0 OR Reply = 5) AND ViewDate IS NOT NULL'
- END
- ELSE IF @ReplyType = 2
- BEGIN
- SET @WHERE2 = ' And IsFilter = 0 AND Reply = 1 AND ViewDate IS NOT NULL'
- END
- ELSE IF @ReplyType = 3
- BEGIN
- SET @WHERE2 = ' And IsFilter = 0 AND Reply = 2 AND ViewDate IS NOT NULL'
- END
- ELSE IF @ReplyType = 4
- BEGIN
- SET @WHERE2 = ' And IsFilter = 1 ' --AND ViewDate is null'
- END
- ELSE
- SET @WHERE2 = ' And IsFilter = 0'
- SET @Where = dbo.SafeSql(@Where)
- SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '''''')
-
- DECLARE @SQL AS VARCHAR(2000)
- CREATE TABLE #T(
- TitleID BIGINT,
- ID INT,
- JobID INT,
- paMainID INT,
- cvMainID INT,
- AddDate SMALLDATETIME,
- Reply TINYINT,
- ReplyDate SMALLDATETIME,
- IsMatched BIT,
- Degree TINYINT,
- RelatedWorkYears TINYINT,
- LivePlace NVARCHAR(50),
- Gender BIT,
- paName NVARCHAR(20),
- BirthDay INT,
- HasPhoto TINYINT,
- Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
- IsNameHidden BIT,
- Valid TINYINT,
- ApplyMessage NVARCHAR(1),
- IsViewed BIT,
- HasInterview BIT,
- HasRemark BIT,
- HasFavorate BIT,
- cvEducationID INT,
- College NVARCHAR(50),
- EduType TINYINT,
- MajorName NVARCHAR(20),
- Graduation INT,
- Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- cvMatch INT,
- RecruitmentID INT,
- RecruitmentName NVARCHAR(100),
- RecruitmentDate SMALLDATETIME,
- MobileVerifyDate SMALLDATETIME,
- IsOnline BIT,
- RemindDate DATETIME,
- HasWeiXin BIT,
- ReplyReason VARCHAR(200),
- Accept BIT,
- NoAccept BIT,
- SecondId VARCHAR(10)
- )
- SET @SQL='
- INSERT INTO #T(TitleID, ID, JobID, paMainID, cvMainID, AddDate, Reply, ReplyDate, IsMatched,
- ApplyMessage, Degree, RelatedWorkYears, Attachment, IsNameHidden, LivePlace, Gender, BirthDay,
- HasPhoto, Valid, RecruitmentID, MobileVerifyDate, IsOnline, RemindDate, ReplyReason, SecondId)
- SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, a.JobID, c.ID, a.cvMainID,
- a.AddDate, a.Reply, a.ReplyDate, a.IsMatched, LEFT(a.ApplyMessage, 1) ApplyMessage, b.Degree,
- b.RelatedWorkYears, b.Attachment, b.IsNameHidden, c.LivePlace, c.Gender, c.BirthDay, c.HasPhoto,
- b.Valid, a.RecruitmentID, c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID), a.RemindDate,
- a.ReplyReason, b.SecondId
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
- WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0'
- IF LEN(@WHERE) > 0
- SET @SQL = @SQL + ' AND ' + @WHERE + @WHERE2
- EXEC(@SQL)
-
- IF(@Page < 1)
- SET @Page = 1
- IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
- SET @Page = 1
-
- DECLARE @cpMainID AS INT
- SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
- 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),
- HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
- 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),
- HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- IF EXISTS(SELECT TOP 1 'X' FROM caMain WHERE ID = @caMainID AND AccountType = 1)
- BEGIN
- UPDATE #T SET
- 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)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- END
- UPDATE #T
- 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),
- 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)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- AND HasInterview = 1
- UPDATE #T SET Speciality = (
- SELECT Speciality FROM cvMain WITH(NOLOCK)
- WHERE cvMain.ID = #T.cvMainID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- UPDATE #T SET Experience = (
- SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
- WHERE cvExperience.cvMainID = #T.cvMainID
- ORDER BY BeginDate DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE #T SET cvEducationID = (
- SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
- WHERE cvEducation.cvMainID = #T.cvMainID
- AND #T.Degree = cvEducation.Degree
- ORDER BY Graduation DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- --修改是否绑定微信
- UPDATE a SET HasWeiXin = 1
- FROM #T a, WxFans b WITH(NOLOCK)
- WHERE a.paMainID = b.PaMainID
- AND b.Status = 2
- AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
- a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
- FROM #T a, cvEducation b WITH(NOLOCK)
- WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
-
- UPDATE a SET a.RecruitmentName = b.RecruitmentName, a.RecruitmentDate = b.EndDate
- FROM #T a, Recruitment b WITH(NOLOCK)
- WHERE b.ID = a.RecruitmentID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
-
- UPDATE #T SET cvMatch = dbo.GetCvMatch(cvMainID, JobID) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- SELECT COUNT(*) FROM #T WITH(NOLOCK)
- SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- DECLARE @NoViewCnt INT, @NoReply INT, @ReplyYes INT, @ReplyNo INT, @SQL2 NVARCHAR(4000), @Filter INT
- --未查看数量
- SET @SQL2 = '
- SELECT @NoViewCnt1 = COUNT(*)
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
- WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0
- And a.IsFilter = 0
- AND a.Reply=0
- AND a.ViewDate is null AND ' + @WHERE
- EXEC SP_EXECUTESQL @SQL2, N'@NoViewCnt1 int OUTPUT', @NoViewCnt OUTPUT
- --待答复数量
- SET @SQL2 = '
- SELECT @NoReply1 = COUNT(*)
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
- WHERE a.CompanyDeleted = 0
- AND d.IsDelete = 0
- And a.IsFilter = 0
- AND (Reply=0 OR Reply = 5)
- AND ViewDate IS NOT NULL
- AND ' + @WHERE
- EXEC SP_EXECUTESQL @SQL2, N'@NoReply1 int OUTPUT', @NoReply OUTPUT
- --符合要求数量
- SET @SQL2 = '
- SELECT @ReplyYes1 = COUNT(*)
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
- WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0
- And a.IsFilter = 0
- AND Reply=1
- AND ' + @WHERE
- EXEC SP_EXECUTESQL @SQL2, N'@ReplyYes1 int OUTPUT', @ReplyYes OUTPUT
- --不符合要求数量
- SET @SQL2 = '
- SELECT @ReplyNo1 = COUNT(*)
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
- WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0
- And a.IsFilter = 0
- AND Reply = 2 AND ' + @WHERE
- EXEC SP_EXECUTESQL @SQL2, N'@ReplyNo1 int OUTPUT', @ReplyNo OUTPUT
- --未查看数量
- SET @SQL2 = '
- SELECT @Filter1 = COUNT(*)
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
- WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0
- And a.IsFilter = 1
- AND ' + @WHERE
- EXEC SP_EXECUTESQL @SQL2, N'@Filter1 int OUTPUT', @Filter OUTPUT
- --计算匹配度
- SELECT @NoViewCnt AS NoViewCnt, @NoReply AS NoReply, @ReplyYes AS ReplyYes, @ReplyNo AS ReplyNo, @Filter AS FilterCnt
- --修改 已查看提醒时间
- UPDATE ExJobApply
- SET CpRemindViewDate = GETDATE()
- WHERE JobID IN (
- SELECT ID FROM JOB WITH(NOLOCK)
- WHERE CaMainID = @caMainID
- ) AND RemindDate IS NOT NULL
- AND CpRemindViewDate IS NULL
- DROP TABLE #T
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplyByCpMainIDReplyUpdate] Script Date: 2018/12/13 19:06:50 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --答复后修改答复状态(无积分)
- --2017-5-25harry
- CREATE PROCEDURE [dbo].[ccExJobApplyByCpMainIDReplyUpdate]
- (
- @AllID VARCHAR(1000),
- @Reply INT,
- @cpMainID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- SET @AllID = dbo.FormatIDS(@AllID)
- DECLARE @T AS TABLE(ID INT)
- INSERT INTO @T SELECT * FROM dbo.fnSplit(@AllID, ',')
- --SELECT TOP 20 * FROM EXJOBAPPLY
- SELECT ID,Reply,RemindDate FROM EXJOBAPPLY WHERE ID IN (SELECT ID FROM @t)
-
- --未提醒答复数量
- DECLARE @CNT1 INT,@CNT2 INT,@CNT3 INT
- SELECT @CNT1 = COUNT(*)
- FROM exJobApply
- WHERE ID IN (SELECT ID FROM @T)
- AND Reply = 0
- AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
- AND RemindDate IS NULL
- --提醒答复72小时内回复的
- SELECT @CNT2 = COUNT(*)
- FROM exJobApply
- WHERE ID IN (SELECT ID FROM @T)
- AND Reply = 0
- AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
- AND DATEADD(DAY,3,RemindDate)>GETDATE()
- --提醒答复72小时内未回复的
- SELECT @CNT3 = COUNT(*)
- FROM exJobApply
- WHERE ID IN (SELECT ID FROM @T)
- AND Reply = 0
- AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
- AND DATEADD(DAY,3,RemindDate)<=GETDATE()
-
- UPDATE exJobApply SET Reply = @Reply, ReplyDate = GETDATE(),IsDeleted = 0,PersonDeleted = 0
- WHERE ID IN(SELECT ID FROM @T)
- AND JobID IN (SELECT ID FROM Job WITH(NOLOCK)
- WHERE cpMainID = @cpMainID)
- --修改查看时间
- UPDATE exJobApply SET ViewDate = GETDATE()
- WHERE ID IN(SELECT ID FROM @T)
- AND JobID IN (SELECT ID FROM Job WITH(NOLOCK)
- WHERE cpMainID = @cpMainID)
- AND ViewDate IS NULL
- --Harry Begin
- IF @Reply IN(1, 2, 3, 4)
- BEGIN
- INSERT WxMessageSend2(Templatetype, WxFansID, PaMainId, MainTableId, CpMainID, CvMainID, JobId, AddDate)
- SELECT 9, b.Id, c.paMainId, a.Id, @cpMainId, c.Id, a.JobId, GETDATE()
- FROM exJobApply a WITH(NOLOCK),
- wxFans b WITH(NOLOCK),
- cvMain c WITH(NOLOCK)
- WHERE a.ID IN(SELECT ID FROM @T)
- AND a.cvMainID = c.ID
- AND b.PaMainId = c.PaMainId
- AND b.[Status] = 2
-
- INSERT INTO paPushLog(paMainID, PushMessage, PushType)
- SELECT b.paMainID, '亲,有企业回复了您的职位申请!', 1
- FROM exJobApply a WITH(NOLOCK),
- cvMain b WITH(NOLOCK)
- WHERE a.ID IN(SELECT ID FROM @T)
- AND a.cvMainID = b.ID
- AND b.paMainID IN(SELECT paMainID FROM paIOSBind WITH(NOLOCK))
- END
- --Harry End
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplyByCpMainIDUpdate] Script Date: 2018/12/13 19:06:50 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --添加积分记录
- --答复后修改答复状态
- --20151124 nick
- --20160215 Lucifer 添加推送内容
- --修改Harry2017-5-25 增加自动答复的答复率计算
- --20180223 Carl 自动答复之后再手动答复也送积分
- CREATE PROCEDURE [dbo].[ccExJobApplyByCpMainIDUpdate]
- (
- @AllID VARCHAR(1000),
- @Reply INT,
- @cpMainID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @Reply72Point INT --72小时内答复简历 赠送积分
- DECLARE @ReplyPoint INT --答复应聘简历 赠送积分
- SET @Reply72Point = 15
- SET @ReplyPoint = 10
- SET @AllID = dbo.FormatIDS(@AllID)
- DECLARE @T AS TABLE(ID INT)
- INSERT INTO @T SELECT * FROM dbo.fnSplit(@AllID, ',')
- --SELECT TOP 20 * FROM EXJOBAPPLY
- SELECT ID,Reply,RemindDate FROM EXJOBAPPLY WHERE ID IN (SELECT ID FROM @t)
- --查询7天之内应聘的数量
- --DECLARE @ExJobApplyNum AS INT
- --SELECT @ExJobApplyNum = COUNT(1)
- --FROM exJobApply
- --WHERE ID IN(SELECT ID FROM @T)
- -- AND Reply = 0
- -- AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
- -- AND Adddate > (CONVERT(VARCHAR(10),GETDATE()-7,120))
-
- --插入积分记录 Peter 2014-08-25
- DECLARE @TodayPoint AS INT, @TodayID AS INT
- SELECT @TodayPoint = 0, @TodayID = 0
- SELECT TOP 1 @TodayPoint = ISNULL(Point, 0), @TodayID = ISNULL(ID,0)
- FROM cpPoint WITH(NOLOCK)
- WHERE changeID = 14
- AND LastModifyDate > CONVERT(VARCHAR(10), GETDATE(),120)
- AND cpMainID = @cpMainID
- --未提醒答复数量
- DECLARE @CNT1 INT,@CNT2 INT,@CNT3 INT
- SELECT @CNT1 = COUNT(*)
- FROM exJobApply
- WHERE ID IN (SELECT ID FROM @T)
- AND Reply in (0,5)
- AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
- AND RemindDate IS NULL
- --提醒答复72小时内回复的
- SELECT @CNT2 = COUNT(*)
- FROM exJobApply
- WHERE ID IN (SELECT ID FROM @T)
- AND Reply in (0,5)
- AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
- AND DATEADD(DAY,3,RemindDate)>GETDATE()
- --提醒答复72小时内未回复的
- SELECT @CNT3 = COUNT(*)
- FROM exJobApply
- WHERE ID IN (SELECT ID FROM @T)
- AND Reply in (0,5)
- AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
- AND DATEADD(DAY,3,RemindDate)<=GETDATE()
- SET @TodayPoint = @TodayPoint + @CNT1*@ReplyPoint+@CNT2*@Reply72Point+@CNT3*(@Reply72Point-@ReplyPoint)
- IF @TodayPoint > 100
- BEGIN
- SET @TodayPoint = 100
- UPDATE cpPoint SET Point = @TodayPoint,LastModifyDate = GETDATE() WHERE ID = @TodayID
- END
- ELSE
- BEGIN
- IF @TodayID = 0
- BEGIN
- INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate)
- VALUES(@cpMainID,14,@CNT1*@ReplyPoint+@CNT2*@Reply72Point+@CNT3*(@Reply72Point-@ReplyPoint),GETDATE())
- END
- ELSE
- BEGIN
- UPDATE cpPoint SET Point = @TodayPoint+@CNT1*@ReplyPoint+@CNT2*@Reply72Point+@CNT3*(@Reply72Point-@ReplyPoint),LastModifyDate = GETDATE() WHERE ID = @TodayID
- END
- END
-
- UPDATE exJobApply SET Reply = @Reply, ReplyDate = GETDATE(),IsDeleted = 0,PersonDeleted = 0
- WHERE ID IN(SELECT ID FROM @T)
- AND JobID IN (SELECT ID FROM Job WITH(NOLOCK)
- WHERE cpMainID = @cpMainID)
- --修改查看时间
- UPDATE exJobApply SET ViewDate = GETDATE()
- WHERE ID IN(SELECT ID FROM @T)
- AND JobID IN (SELECT ID FROM Job WITH(NOLOCK)
- WHERE cpMainID = @cpMainID)
- AND ViewDate IS NULL
- --Harry Begin
- IF @Reply IN(1, 2, 3, 4)
- BEGIN
- INSERT WxMessageSend2(Templatetype, WxFansID, PaMainId, MainTableId, CpMainID, CvMainID, JobId, AddDate)
- SELECT 9, b.Id, c.paMainId, a.Id, @cpMainId, c.Id, a.JobId, GETDATE()
- FROM exJobApply a WITH(NOLOCK),
- wxFans b WITH(NOLOCK),
- cvMain c WITH(NOLOCK)
- WHERE a.ID IN(SELECT ID FROM @T)
- AND a.cvMainID = c.ID
- AND b.PaMainId = c.PaMainId
- AND b.[Status] = 2
-
- INSERT INTO paPushLog(paMainID, PushMessage, PushType)
- SELECT b.paMainID, '亲,有企业回复了您的职位申请!', 1
- FROM exJobApply a WITH (NOLOCK),
- cvMain b WITH(NOLOCK)
- WHERE a.ID IN(SELECT ID FROM @T)
- AND a.cvMainID = b.ID
- AND b.paMainID IN(SELECT paMainID FROM paIOSBind WITH(NOLOCK))
- END
- --Harry End
-
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplyBycvMainIDDelete] Script Date: 2018/12/13 19:06:50 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --lambo 20101122
- --删除该简历所有对本企业的申请记录
- --用于发送面试通知页面
- CREATE PROCEDURE [dbo].[ccExJobApplyBycvMainIDDelete]
- (
- @cvMainID INT,
- @cpMainID INT
- )
- AS
- BEGIN
- BEGIN TRY
- DELETE FROM exJobApply
- WHERE cvMainID = @cvMainID
- AND JobID IN
- (
- SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID
- )
- RETURN 1
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplyByCvMainIDSelect] Script Date: 2018/12/13 19:06:51 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --修改:Andy 2015-01-13 添加职位的regionid
- --修改:harry 提升企业答复率,企业删除的也需要答复2017-5-4
- --#####################################################
- CREATE PROCEDURE [dbo].[ccExJobApplyByCvMainIDSelect]
- (
- @caMainID INT,
- @cvMainID INT,
- @cpMainID INT
- )
- AS
- BEGIN
- IF @cpMainID > 0
- SELECT a.ID,a.JobID,b.dcRegionID,a.cvMainID,a.ApplyMessage,a.AddDate,c.Name caName,
- a.CompanyDeleted,a.CompanyDeleteDate,a.PersonDeleted,
- a.Reply,a.ReplyDate,a.IsPassed,
- b.Name JobName,b.caMainID, a.RemindDate
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN Job b WITH(NOLOCK) ON b.ID=a.JobID
- INNER JOIN caMain c WITH(NOLOCK) ON b.caMainID=c.ID
- WHERE cvMainID=@cvMainID
- AND c.cpMainID=@cpMainID
- --AND CompanyDeleted=0
- ORDER BY a.adddate asc
- IF @cpMainID = 0
- SELECT a.ID,a.JobID,b.dcRegionID,a.cvMainID,a.ApplyMessage,a.AddDate,
- a.CompanyDeleted,a.CompanyDeleteDate,a.PersonDeleted,
- a.Reply,a.ReplyDate,a.IsPassed,
- b.Name as JobName,b.caMainID, a.RemindDate
- FROM exJobApply a WITH(NOLOCK)
- inner join Job b WITH(NOLOCK) On b.ID=a.JobID
- inner join cpMain c WITH(NOLOCK) On b.cpMainID=c.ID
- WHERE caMainID=@caMainID
- AND cvMainID=@cvMainID
- --AND CompanyDeleted=0
- ORDER BY a.adddate asc
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplyByExcelSelect] Script Date: 2018/12/13 19:06:51 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --alen 2018-3-28
- CREATE PROCEDURE [dbo].[ccExJobApplyByExcelSelect]
- (
- @cpMainID INT,
- @WHERE VARCHAR(2000),
- @Order VARCHAR(100)
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @SQL AS VARCHAR(2000)
- SET @SQL = 'SELECT a.ID, a.JobID, dbo.ShowContact(a.cvMainID, ' + LTRIM(STR(@cpMainID)) + ') AS ShowContact, b.paMainId, b.SecondId,
- a.cvMainID, a.AddDate, a.Reply, a.ReplyDate, c.Mobile, b.Degree, b.RelatedWorkYears, c.Email, d.Name JobName,
- c.LivePlace, c.Gender, c.Name AS paName, c.BirthDay, c.HasPhoto, b.Attachment, b.IsNameHidden, b.JobName JobNameRece
- FROM exJobApply a WITH(NOLOCK)
- inner join cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- INNER JOIN Job d WITH(NOLOCK) ON a.JobID = d.ID
- WHERE CompanyDeleted = 0'
- IF LEN(@WHERE)> 0
- BEGIN
- SET @Where = dbo.SafeSql(@Where)
- SET @SQL=@SQL + ' AND ' + @WHERE
- END
- IF LEN(@ORDER)> 0
- BEGIN
- SET @ORDER = REPLACE(dbo.SafeSQLBack(@ORDER), '''', '''')
- SET @SQL=@SQL + ' ORDER BY ' + @ORDER
- END
- EXEC(@SQL)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplyByFilterNoRepliedCountSelect] Script Date: 2018/12/13 19:06:51 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccExJobApplyByFilterNoRepliedCountSelect]
- (
- @caMainID INT
- )
- AS
- BEGIN
- SELECT COUNT(1) Cnt
- FROM exJobApply a WITH(NOLOCK), Job b WITH(NOLOCK), CvMain c WITH(NOLOCK)
- WHERE a.Reply = 0
- And a.CompanyDeleted = 0
- AND a.JobID =b.ID
- AND b.caMainID = @caMainID
- AND b.IsDelete = 0
- AND a.IsFilter = 1
- AND a.cvMainID= c.ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplyByHasAppliedSelect] Script Date: 2018/12/13 19:06:51 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --Lambo 20101022
- --查询该简历是否向本公司申请过
- --用于简历显示页面
- CREATE PROCEDURE [dbo].[ccExJobApplyByHasAppliedSelect]
- (
- @cpMainID INT,
- @cvMainID INT
- )
- AS
- BEGIN
- IF EXISTS (
- SELECT 'x' FROM ExJobApply a WITH(NOLOCK),Job b
- WHERE a.JobID = b.ID
- AND a.cvMainID = @cvMainID
- AND b.cpMainID = @cpMainID
- )
- RETURN 1
- ELSE
- RETURN 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplyByIDUpdate] Script Date: 2018/12/13 19:06:52 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:20160105
- --创建人:Nick
- --说明:根据ID修改答复原因
- --修改harry,@point>0的才进行积分计算
- --#####################################################
- CREATE PROCEDURE [dbo].[ccExJobApplyByIDUpdate]
- (
- @ID INT,
- @ReplyReason NVARCHAR(100),
- @JobID INT,
- @CpMainID INT,
- @Point INT
- )
- AS
- BEGIN
- UPDATE ExJobApply
- SET ReplyReason = @ReplyReason
- WHERE ID = @ID
- AND JobID = @JobID
-
- IF @Point >0
- BEGIN
- --修改积分
- DECLARE @TodayPoint AS INT
- DECLARE @TodayID AS INT
- SET @TodayPoint = 0
- SET @TodayID = 0
-
- SELECT TOP 1 @TodayPoint = ISNULL(Point,0),@TodayID = ISNULL(ID,0)
- FROM cpPoint WITH(NOLOCK)
- WHERE changeID = 14
- AND LastModifyDate > CONVERT(VARCHAR(10), GETDATE(),120)
- AND cpMainID = @CpMainID
- IF @TodayID = 0
- BEGIN
- INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@CpMainID,14,@Point,GETDATE())
- END
- ELSE
- BEGIN
- SET @TodayPoint = @TodayPoint + @Point
- IF @TodayPoint > 100
- BEGIN
- SET @TodayPoint = 100
- END
- UPDATE cpPoint SET Point = @TodayPoint,LastModifyDate = GETDATE() WHERE ID = @TodayID
- END
- END
- END
-
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplyByJobIDCountSelect] Script Date: 2018/12/13 19:06:52 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccExJobApplyByJobIDCountSelect]
- (
- @JobID INT
- )
- AS
- BEGIN
- SELECT COUNT(ID) AS ApplyCount FROM exJobApply WITH(NOLOCK) WHERE CompanyDeleted=0 AND JobID=@JobID AND (IsFilter IS NULL OR IsFilter=0)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplyByJobIDSelect] Script Date: 2018/12/13 19:06:52 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --nick 20160125
- --根据简历 职位查询 应聘信息
- create PROCEDURE [dbo].[ccExJobApplyByJobIDSelect]
- (
- @JobID INT,
- @CvMainID INT
- )
- AS
- BEGIN
- SELECT TOP 1 * FROM ExJobApply WITH(NOLOCK) WHERE JobID = @JobID AND CvMainID = @CvMainID ORDER BY ID DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplyByOneWeekSelect] Script Date: 2018/12/13 19:06:53 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccExJobApplyByOneWeekSelect]
- (
- @caMainID INT
- )
- AS
- BEGIN
- BEGIN TRY
- DECLARE @return INT
- SELECT @return = COUNT(1) FROM exJobApply WITH(index(IX_exJobApply_JobId) NOLOCK)
- WHERE AddDate > GETDATE() - 7
- AND CompanyDeleted = 0
- AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE caMainID = @caMainID AND IsDelete = 0)
- --AND (IsFilter IS NULL OR IsFilter=0)
- RETURN @return
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExjobApplyByRecoverUpdate] Script Date: 2018/12/13 19:06:53 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccExjobApplyByRecoverUpdate]
- (
- @cpMainId INT,
- @Ids VARCHAR(200)
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @t AS TABLE(Id INT)
- INSERT INTO @t SELECT a FROM dbo.FnSplit(@Ids, ',')
- DECLARE @Num INT
- IF EXISTS(
- SELECT 'x' FROM Job
- WHERE Id IN(SELECT jobId FROM CaCvApplyDeleted WITH(NOLOCK) WHERE ID IN(SELECT ID FROM @t))
- AND cpMainId != @cpMainId
- )
- BEGIN
- SELECT -1 NUM
- RETURN
- END
- INSERT INTO ExjobApply(JobId, cvMainId, AddDate, IsFilter, Reply, ReplyDate)
- SELECT JobId, cvMainId, GETDATE(), 0, Reply, GETDATE()
- FROM CaCvApplyDeleted WITH(NOLOCK)
- WHERE ID IN(SELECT ID FROM @t)
- AND cvDeleted = 0
- AND JobDeleted = 0
- SET @Num = @@RowCount
- IF @Num > 0
- DELETE FROM CaCvApplyDeleted
- WHERE ID IN(SELECT ID FROM @t)
- AND cvDeleted = 0
- AND JobDeleted = 0
- SELECT @Num AS Num
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplyByViewDateUpdate] Script Date: 2018/12/13 19:06:53 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --2016-1-6 nick
- --修改简历状态为已查看
- CREATE PROCEDURE [dbo].[ccExJobApplyByViewDateUpdate]
- (
- @CvMainID INT,
- @JobID INT
- )
- AS
- BEGIN
- UPDATE ExJobApply
- SET ViewDate = GETDATE() --,isFilter = 0
- WHERE CvMainID = @CvMainID
- AND JobID = @JobID
- AND ViewDate IS NULL
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplyForJobIdSelect] Script Date: 2018/12/13 19:06:54 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --Sean 20160127
- --修改harry 2017-6-14 按照申请的时间,优先显示最新申请的
- CREATE PROCEDURE [dbo].[ccExJobApplyForJobIdSelect]
- (
- @cpMainID INT,
- @cvMainID INT
- )
- AS
- BEGIN
- DECLARE @JobId VARCHAR(10)
- SELECT TOP 1 @JobId = b.Id
- FROM ExJobApply a WITH(NOLOCK),
- Job b WITH(NOLOCK)
- WHERE a.JobID = b.ID
- AND a.cvMainID = @cvMainID
- AND b.cpMainID = @cpMainID
- ORDER BY a.Id DESC
- RETURN ISNULL(@JobId, '0')
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplySelect] Script Date: 2018/12/13 19:06:54 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccExJobApplySelect]
- (
- @WHERE VARCHAR(1000),
- @Order VARCHAR(100),
- @Page SMALLINT,
- @caMainID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- BEGIN TRY
- SET @Where = dbo.SafeSql(@Where)
- SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '''''')
-
- DECLARE @SQL AS VARCHAR(2000)
- CREATE TABLE #T(
- TitleID BIGINT,
- ID INT,
- JobID INT,
- paMainID INT,
- cvMainID INT,
- AddDate SMALLDATETIME,
- Reply TINYINT,
- ReplyDate SMALLDATETIME,
- IsMatched BIT,
- Degree TINYINT,
- RelatedWorkYears TINYINT,
- LivePlace NVARCHAR(50),
- Gender BIT,
- paName NVARCHAR(20),
- BirthDay INT,
- HasPhoto TINYINT,
- Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
- IsNameHidden BIT,
- Valid TINYINT,
- ApplyMessage NVARCHAR(1),
- IsViewed BIT,
- HasInterview BIT,
- HasRemark BIT,
- HasFavorate BIT,
- cvEducationID INT,
- College NVARCHAR(50),
- EduType TINYINT,
- MajorName NVARCHAR(20),
- Graduation INT,
- Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- cvMatch INT,
- RecruitmentID INT,
- RecruitmentName NVARCHAR(100),
- RecruitmentDate SMALLDATETIME,
- MobileVerifyDate SMALLDATETIME,
- IsOnline BIT,
- RemindDate DATETIME,
- HasWeiXin BIT,
- HasAccept BIT,
- HsaNoAccept BIT
- )
- SET @SQL='
- INSERT INTO #T
- (TitleID, ID, JobID, paMainID, cvMainID, AddDate, Reply, ReplyDate, IsMatched, ApplyMessage,
- Degree,RelatedWorkYears,Attachment,IsNameHidden,LivePlace,Gender,
- BirthDay,HasPhoto,Valid,RecruitmentID,MobileVerifyDate,IsOnline,RemindDate)
- SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, a.JobID, c.ID, a.cvMainID,
- a.AddDate, a.Reply, a.ReplyDate, a.IsMatched, LEFT(a.ApplyMessage, 1) ApplyMessage,
- b.Degree,b.RelatedWorkYears,b.Attachment,b.IsNameHidden,c.LivePlace,
- c.Gender,c.BirthDay,c.HasPhoto,b.Valid,a.RecruitmentID,c.MobileVerifyDate,dbo.GetPaOnlineStatus(c.ID),a.RemindDate
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
- WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0'
- IF LEN(@WHERE) > 0
- SET @SQL = @SQL + ' AND '+@WHERE
- --PRINT @SQL
- EXEC(@SQL)
-
- IF(@Page < 1)
- SET @Page = 1
- IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
- SET @Page = 1
-
- DECLARE @cpMainID AS INT
- SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
- 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),
- HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
- 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),
- HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
- 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),
- 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)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE #T SET Speciality = (
- SELECT Speciality FROM cvMain WITH(NOLOCK)
- WHERE cvMain.ID = #T.cvMainID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- UPDATE #T SET Experience = (
- SELECT TOP 1 ISNULL(Description,DescriptionEng) FROM cvExperience WITH(NOLOCK)
- WHERE cvExperience.cvMainID = #T.cvMainID
- ORDER BY BeginDate DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE #T SET cvEducationID = (
- SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
- WHERE cvEducation.cvMainID = #T.cvMainID
- AND #T.Degree = cvEducation.Degree
- ORDER BY Graduation DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- --修改是否绑定微信
- UPDATE a SET HasWeiXin = 1
- FROM #T a,WxFans b WITH(NOLOCK)
- WHERE a.paMainID = b.PaMainID
- AND b.Status = 2
- AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE a SET a.College = ISNULL(b.GraduateCollage,b.GraduateCollageEng),a.EduType = b.EduType,
- a.MajorName = ISNULL(b.MajorName,b.MajorNameEng), a.Graduation = b.Graduation
- FROM #T a, cvEducation b WITH(NOLOCK)
- WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
-
- UPDATE a SET a.RecruitmentName = b.RecruitmentName, a.RecruitmentDate = b.EndDate
- FROM #T a, Recruitment b WITH(NOLOCK)
- WHERE b.ID = a.RecruitmentID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
-
- UPDATE #T SET cvMatch = dbo.GetCvMatch(cvMainID,JobID) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- SELECT COUNT(*) FROM #T WITH(NOLOCK)
- SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- --计算匹配度
-
- DROP TABLE #T
- END TRY
- BEGIN CATCH
- DROP TABLE #T
- END CATCH
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExJobApplyUpdate] Script Date: 2018/12/13 19:06:54 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --Lambo 20101130 修改
- -- 增加cpMainID 参数,只能删除本公司的
- --Peter 20140825修改
- --添加积分记录
- --答复后修改答复状态
- --20151124 nick
- --修改Harry2017-4-17
- CREATE PROCEDURE [dbo].[ccExJobApplyUpdate]
- (
- @AllID VARCHAR(1000),
- @Reply INT,
- @cpMainID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- SET @AllID = dbo.FormatIDS(@AllID)
- DECLARE @T AS TABLE(ID INT)
- INSERT INTO @T SELECT * FROM dbo.fnSplit(@AllID, ',')
- --查询7天之内应聘的数量
- DECLARE @ExJobApplyNum AS INT
- SELECT @ExJobApplyNum = COUNT(1)
- FROM exJobApply
- WHERE ID IN(SELECT ID FROM @T)
- AND Reply = 0
- AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
- AND Adddate > (CONVERT(VARCHAR(10),GETDATE()-7,120))
-
- --插入积分记录 Peter 2014-08-25
- DECLARE @TodayPoint AS INT, @TodayID AS INT
- SELECT @TodayPoint = 0, @TodayID = 0
- SELECT TOP 1 @TodayPoint = ISNULL(Point, 0), @TodayID = ISNULL(ID,0)
- FROM cpPoint WITH(NOLOCK)
- WHERE changeID = 14
- AND LastModifyDate > CONVERT(VARCHAR(10), GETDATE(),120)
- AND cpMainID = @cpMainID
- SET @TodayPoint = @TodayPoint + (@ExJobApplyNum * 2)
-
- IF @TodayPoint > 100
- SET @TodayPoint = 100
- IF @TodayID = 0
- INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@cpMainID,14,@TodayPoint,GETDATE())
- ELSE
- UPDATE cpPoint SET Point = @TodayPoint,LastModifyDate = GETDATE() WHERE ID = @TodayID
- UPDATE exJobApply SET Reply = @Reply, ReplyDate = GETDATE(),IsDeleted = 0,PersonDeleted = 0
- WHERE ID IN(SELECT ID FROM @T) AND Reply = 0
- AND JobID IN (SELECT ID FROM Job WITH(NOLOCK)
- WHERE cpMainID = @cpMainID)
- --Harry Begin 2017-5-23
- IF @Reply IN(1, 2, 3, 4)--4企业删除
- BEGIN
- INSERT WxMessageSend2(Templatetype, WxFansID, PaMainId, MainTableId, CpMainID, CvMainID, JobId, AddDate)
- SELECT 9, b.Id, c.paMainId, a.Id, @cpMainId, c.Id, a.JobId, GETDATE()
- FROM exJobApply a WITH(NOLOCK),
- wxFans b WITH(NOLOCK),
- cvMain c WITH(NOLOCK)
- WHERE a.ID IN(SELECT ID FROM @T)
- AND a.cvMainID = c.ID
- AND b.PaMainId = c.PaMainId
- AND b.[Status] = 2
- END
-
- DECLARE @Cnt INT, @ReplyCnt INT, @ReplyRate DECIMAL(9, 3)
- --是否同意自动答复
- IF EXISTS(SELECT 'x' FROM cpMain WHERE id=@cpMainID AND AutoReplyConfirm is NULL)
- BEGIN
- SELECT @Cnt = COUNT(*), @ReplyCnt = COUNT(ReplyDate)
- FROM ExjobApply
- WHERE JobId IN(SELECT Id FROM Job WHERE cpMainId = @cpMainId)
- AND AddDate > GETDATE() - 183
- IF @Cnt > 0
- SELECT @ReplyRate = @ReplyCnt * 1.0 / @Cnt
- --WHERE @ReplyCnt * 1.0 / @Cnt >= 0.1
- ELSE
- SELECT @ReplyRate =1
- END
- ELSE
- BEGIN
- DECLARE @AutoReplyConfirm DATETIME
- SELECT @AutoReplyConfirm=AutoReplyConfirm
- FROM CpMain WITH(NOLOCK)
- WHERE Id = @cpMainId
- SELECT @ReplyCnt = SUM(CASE WHEN reply<>5 THEN 1 ELSE 0 END), @Cnt= COUNT(ReplyDate)
- FROM ExjobApply
- WHERE JobId IN(SELECT Id FROM Job WHERE cpMainId = @cpMainId)
- AND reply!=0
- AND adddate>@AutoReplyConfirm
- IF @Cnt > 0
- SELECT @ReplyRate = @ReplyCnt * 1.0 / @Cnt
- ELSE
- SELECT @ReplyRate =1
- END
- UPDATE cpMain SET ReplyRate = @ReplyRate WHERE Id = @cpMainId
- 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)
- --Harry end
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExMessageC2PDelete] Script Date: 2018/12/13 19:06:55 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --Lambo 20101130 修改
- -- 增加cpMainID 参数,只能删除本公司的
- CREATE PROCEDURE [dbo].[ccExMessageC2PDelete]
- (
- @ID INT,
- @cpMainID INT
- )
- AS
- BEGIN TRY
- IF EXISTS(SELECT ID FROM ExMessageC2P WITH(NOLOCK)
- WHERE PersonDeleted = 1
- AND ID = @ID
- AND caMainID IN (SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID))
- DELETE FROM ExMessageC2P WHERE PersonDeleted = 1 AND ID = @ID
- ELSE
- UPDATE ExMessageC2P SET CompanyDeleted = 1
- WHERE ID = @ID AND caMainID IN (SELECT ID FROM caMain WITH(NOLOCK)
- WHERE cpMainID = @cpMainID)
- END TRY
- BEGIN CATCH
- GOTO ERR
- END CATCH
- RETURN 1
- ERR:
- BEGIN
- RETURN 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccexMessageC2PInsert] Script Date: 2018/12/13 19:06:55 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --ccexMessageC2PInsert 0,371108,14792626,'sssssssssss'
- --#########################################
- --修改:sean
- --增加了非收费会员不能超过100条的判断
- --@ID 是个人留言的id,>0:回复个人留言,=0:主动留言
- --#########################################
- CREATE PROCEDURE [dbo].[ccexMessageC2PInsert]
- (
- @ID INT,
- @caMainID INT,
- @cvMainID INT,
- @Message NVARCHAR(200)
- )
- AS
- BEGIN
- DECLARE @cpMainID AS INT, @MemberType AS TINYINT, @cnt AS INT
- SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
- SELECT @MemberType = MemberType FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
- IF @MemberType < 3 --费收费用户
- BEGIN
- SELECT @cnt = COUNT(1) FROM exMessageC2P WITH(NOLOCK)
- WHERE caMainID = @caMainID
-
- IF @cnt >= 100 --最多100条留言
- GOTO Err1
- END
- SET @Message = LTRIM(RTRIM(@Message))
- INSERT exMessageC2P(caMainID, cvMainID, Message)
- VALUES(@caMainID, @cvMainID, @Message)
- IF @ID > 0
- Update exMessageP2C Set IsReply=1 WHERE ID = @ID
- RETURN
- END
- ERR1:
- BEGIN
- RETURN -1
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExMessageC2PSelect] Script Date: 2018/12/13 19:06:55 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --[ccExMessageC2PSelect] 'And caMainID =371108 And c.Name=''杨''','a.id desc',1,371108,371108
- CREATE PROCEDURE [dbo].[ccExMessageC2PSelect]
- (
- @WHERE VARCHAR(1000),
- @Order VARCHAR(100),
- @Page SMALLINT,
- @cpMainID INT,
- @caMainID INT
- )
- AS
- BEGIN
- BEGIN TRY
- SET @Where = dbo.SafeSql(@Where)
- SET @ORDER = dbo.SafeSql(@Order)
- CREATE TABLE #T(
- TitleID BIGINT,
- ID INT,
- caMainID INT,
- cvMainID INT,
- Message VARCHAR(1000) COLLATE Chinese_PRC_CI_AS,
- AddDate SMALLDATETIME,
- IsViewed BIT,
- IsReply BIT,
- Degree TINYINT,
- RelatedWorkYears TINYINT,
- Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
- IsNameHidden BIT,
- LivePlace VARCHAR(6),
- Gender BIT,
- paName NVARCHAR(20),
- BirthDay INT,
- HasPhoto TINYINT,
- Valid TINYINT,
- HasJobApply BIT,
- HasInterview BIT,
- HasRemark BIT,
- HasFavorate BIT,
- CvIsViewed BIT
- )
- DECLARE @SQL AS VARCHAR(2000)
- SET @SQL='
- INSERT INTO #T(TitleID,
- ID,caMainID,cvMainID,Message,AddDate,IsViewed,IsReply)
- SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID,
- a.ID,a.caMainID,a.cvMainID,a.Message,a.AddDate,a.IsViewed,a.IsReply
- FROM exMessageC2P a WITH(NOLOCK)'
- IF CHARINDEX('c.',@WHERE) > 0
- SET @SQL=@SQL + '
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID'
- SET @SQL=@SQL + '
- WHERE CompanyDeleted=0'
- IF @caMainId > 0
- SET @SQL=@SQL + '
- AND a.caMainId = ' + LTRIM(STR(@caMainID))
- IF LEN(@WHERE) > 0
- SET @SQL = @SQL + @WHERE
- --PRINT @SQL
- EXEC(@SQL)
- IF(@Page < 1)
- SET @Page = 1
- IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
- SET @Page = 1
- UPDATE #T SET Degree = a.Degree,RelatedWorkYears = a.RelatedWorkYears,Attachment = a.Attachment,
- IsNameHidden = a.IsNameHidden,LivePlace = b.LivePlace,Gender = b.Gender,paName = b.Name,
- BirthDay = b.BirthDay,HasPhoto = b.HasPhoto,Valid = a.Valid
- FROM cvMain a WITH(NOLOCK) INNER JOIN paMain b WITH(NOLOCK) ON a.paMainID = b.ID
- WHERE a.ID = #T.cvMainID AND TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE #T SET paName = LEFT(dbo.GetPaName(cvMainID, @cpMainID), 20),
- CvIsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID),
- 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),
- 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),
- HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
- HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- SELECT COUNT(*) FROM #T WITH(NOLOCK)
- SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- DROP TABLE #T
- END TRY
- BEGIN CATCH
- DROP TABLE #T
- END CATCH
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExMessageLogSelect] Script Date: 2018/12/13 19:06:56 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccExMessageLogSelect]
- @caMainID INT,
- @cvMainID INT
- AS
- BEGIN
- SELECT * FROM (
- SELECT addDate,Message,1 IsCompany FROM exMessageC2p WITH(NOLOCK) WHERE cvMainID = @cvMainID AND caMainID = @caMainID AND CompanyDeleted=0
- UNION
- SELECT addDate,Message,0 IsCompany FROM exMessageP2C WITH(NOLOCK) WHERE cvMainID = @cvMainID AND caMainID = @caMainID AND CompanyDeleted=0
- ) a ORDER BY a.AddDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExMessageP2CByHasMessageSelect] Script Date: 2018/12/13 19:06:56 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --Nick 20130716
- --查询该简历是否向本公司留言过
- --用于简历显示页面
- CREATE PROCEDURE [dbo].[ccExMessageP2CByHasMessageSelect]
- (
- @cpMainID INT,
- @cvMainID INT
- )
- AS
- BEGIN
- IF EXISTS (
- SELECT 'x' FROM ExMessageP2C WITH(NOLOCK)
- WHERE cvMainID = @cvMainID
- AND caMainID IN(SELECT ID FROM CaMain WITH(NOLOCK) WHERE CpMainID = @cpMainID)
- AND CompanyDeleted = 0
- )
- RETURN 1
- ELSE
- RETURN 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExMessageP2CDelete] Script Date: 2018/12/13 19:06:56 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --Lambo 20101130 修改
- -- 增加cpMainID 参数,只能删除本公司的
- CREATE PROCEDURE [dbo].[ccExMessageP2CDelete]
- (
- @ID INT,
- @cpMainID INT
- )
- AS
- BEGIN TRY
- IF EXISTS(SELECT ID FROM ExMessageP2C WITH(NOLOCK)
- WHERE PersonDeleted = 1
- AND ID = @ID
- AND caMainID IN (SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID))
- DELETE FROM ExMessageP2C WHERE PersonDeleted = 1 AND ID = @ID
- ELSE
- UPDATE ExMessageP2C SET CompanyDeleted = 1
- WHERE ID = @ID AND caMainID IN (SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID)
- END TRY
- BEGIN CATCH
- GOTO ERR
- END CATCH
- RETURN 1
- ERR:
- BEGIN
- RETURN 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExMessageP2CIsViewedUpdate] Script Date: 2018/12/13 19:06:56 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccExMessageP2CIsViewedUpdate]
- (
- @ID INT,
- @caMainID INT
- )
- AS
- BEGIN TRY
- UPDATE exMessageP2C SET IsViewed = 1
- WHERE ID = @ID
- AND caMainID = @caMainID
- END TRY
- BEGIN CATCH
- GOTO ERR
- END CATCH
- RETURN 1
- ERR:
- BEGIN
- ROLLBACK TRAN
- RETURN 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExMessageP2CSelect] Script Date: 2018/12/13 19:06:56 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --[ccExMessageP2CSelect] 'caMainID =1002941','a.id desc'
- CREATE PROCEDURE [dbo].[ccExMessageP2CSelect]
- (
- @WHERE VARCHAR(1000),
- @Order VARCHAR(100),
- @Page SMALLINT,
- @cpMainID INT,
- @caMainID INT
- )
- AS
- BEGIN
- BEGIN TRY
- SET @Where = dbo.SafeSql(@Where)
- SET @ORDER = dbo.SafeSql(@Order)
- CREATE TABLE #T(
- TitleID BIGINT,
- ID INT,
- caMainID INT,
- cvMainID INT,
- Message VARCHAR(200) COLLATE Chinese_PRC_CI_AS,
- AddDate SMALLDATETIME,
- IsViewed BIT,
- IsReply BIT,
- Degree TINYINT,
- RelatedWorkYears TINYINT,
- Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
- IsNameHidden BIT,
- LivePlace VARCHAR(6),
- Gender BIT,
- paName NVARCHAR(20),
- BirthDay INT,
- HasPhoto TINYINT,
- IsOpen BIT,
- Valid TINYINT,
- HasJobApply BIT,
- HasInterview BIT,
- HasRemark BIT,
- HasFavorate BIT,
- CvIsViewed BIT
- )
- DECLARE @SQL AS VARCHAR(2000)
- SET @SQL='
- INSERT INTO #T(TitleID,ID,caMainID,cvMainID,Message,AddDate,IsViewed,IsReply)
- SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID,
- a.ID,a.caMainID,a.cvMainID,a.Message,a.AddDate,a.IsViewed,a.IsReply
- FROM exMessageP2C a WITH(NOLOCK)'
-
- IF CHARINDEX('c.',@WHERE) > 0
- SET @SQL=@SQL + '
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID'
-
- SET @SQL=@SQL + '
- WHERE CompanyDeleted=0'
- IF @caMainId > 0
- SET @SQL=@SQL + '
- AND a.caMainId = ' + LTRIM(STR(@caMainID))
-
- IF LEN(@WHERE)>0
- SET @SQL=@SQL + @WHERE
- --PRINT @SQL
- EXEC(@SQL)
- IF(@Page < 1)
- SET @Page = 1
- IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
- SET @Page = 1
- UPDATE #T SET Degree = a.Degree,RelatedWorkYears = a.RelatedWorkYears,Attachment = a.Attachment,
- IsNameHidden = a.IsNameHidden,LivePlace = b.LivePlace,Gender = b.Gender,paName = b.Name,
- BirthDay = b.BirthDay,HasPhoto = b.HasPhoto,Valid = a.Valid
- FROM cvMain a WITH(NOLOCK) INNER JOIN paMain b WITH(NOLOCK) ON a.paMainID = b.ID
- WHERE a.ID = #T.cvMainID AND TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE #T SET paName = LEFT(dbo.GetPaName(cvMainID, @cpMainID), 20),
- CvIsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID),
- 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),
- 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),
- HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
- HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- SELECT COUNT(*) FROM #T WITH(NOLOCK)
- SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- DROP TABLE #T
- END TRY
- BEGIN CATCH
- DROP TABLE #T
- END CATCH
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExtendLinkByCpMainIDUpdate] Script Date: 2018/12/13 19:06:57 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --创建时间:2015.7.13
- --创建人:Mice
- --说明:更新状态
- -------------------------------------------------------
- CREATE PROCEDURE [dbo].[ccExtendLinkByCpMainIDUpdate]
- (
- @cpMainID INT
- )
- AS
- BEGIN
- UPDATE ExtendLink
- SET LinkStatus = 4, RunStatus = 0
- WHERE CpMainID = @cpMainID AND RunStatus = 1
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExtendLinkByCustomLinkSelect] Script Date: 2018/12/13 19:06:57 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROC [dbo].[ccExtendLinkByCustomLinkSelect]
- (
- @cpMainId INT,
- @CustomLink VARCHAR(300)
- )
- AS
- SET NOCOUNT ON
- BEGIN
- SELECT TOP 100 * FROM ExtendLink WITH(NOLOCK)
- WHERE cpMainId <> @cpMainId
- AND CustomLink LIKE '%' + LTRIM(RTRIM(@CustomLink)) + '%'
- --AND LinkStatus <> 3
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExtendLinkByEditSelect] Script Date: 2018/12/13 19:06:57 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccExtendLinkByEditSelect]
- (
- @cpMainId INT
- )
- AS
- BEGIN
- SELECT TOP 1 *, SPACE(50) jobName, GETDATE() SelectDate
- INTO #t
- FROM ExtendLink
- WHERE cpMainID = @cpMainID
- ORDER BY id DESC
- UPDATE #t SET JobName = (SELECT Name FROM Job WITH(NOLOCK) WHERE Job.Id = #t.Ids)
- DECLARE @SelectDate DATETIME
- SELECT TOP 1 @SelectDate = DATEADD(MONTH, 1, Begindate) FROM ExtendLinkRunLog
- WHERE cpMainId = @cpMainId
- ORDER BY ID DESC
- IF ISNULL(@SelectDate, GETDATE() - 1) < GETDATE()
- SET @SelectDate = CONVERT(VARCHAR(10), GETDATE() + 1, 120)
- UPDATE #t SET SelectDate = @SelectDate
- SELECT * FROM #t
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExtendLinkRunLogSelect] Script Date: 2018/12/13 19:06:57 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccExtendLinkRunLogSelect]
- (
- @cpMainId INT
- )
- AS
- BEGIN
- SELECT a.*, CASE a.ShowType WHEN 1 THEN b.Name ELSE '' END as jobName
- FROM ExtendLinkRunLog a
- LEFT JOIN Job b on b.id = a.IDs
- WHERE a.cpMainID = @cpMainID
- ORDER BY a.id DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExtendLinkSave] Script Date: 2018/12/13 19:06:58 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccExtendLinkSave]
- (
- @cpMainID INT,
- @keyword NVARCHAR(20),
- @keywordUrl VARCHAR(300),
- @CustomLink VARCHAR(300),
- @showType INT,
- @ids INT,
- @NextRunDate DATETIME
- )
- AS
- SET NOCOUNT ON
- BEGIN
- IF EXISTS(SELECT 'x' FROM ExtendLink WITH(NOLOCK)
- WHERE cpMainID = @cpMainID
- AND keyword = @keyword
- AND keywordUrl = @keywordUrl
- AND CustomLink = @CustomLink
- AND showType = @showType
- AND ids = @ids
- AND ShowDay = DATEPART(DAY, @NextRunDate)
- AND RunStatus IN(1, 2)
- )
- RETURN
- DECLARE @BeginDate DATETIME, @IsAdd INT, @AddDate DATETIME, @LinkId INT, @LinkStatus INT,
- @keywordUrlOld VARCHAR(300), @CustomLinkOld VARCHAR(300), @ShowDay INT,
- @ManagerUserId INT
- SELECT @IsAdd = 1, @LinkStatus = 1, @ShowDay = DATEPART(DAY, @NextRunDate)
- SELECT TOP 1 @AddDate = AddDate, @LinkId = ID, @LinkStatus = LinkStatus,
- @keywordUrlOld = KeywordUrl, @CustomLinkOld = CustomLink
- FROM ExtendLink WITH(NOLOCK)
- WHERE cpMainId = @cpMainId
- ORDER BY ID DESC
- IF @showType <> 1
- SET @ids = 0
- IF @AddDate IS NOT NULL
- BEGIN
- SELECT TOP 1 @BeginDate = BeginDate FROM ExtendLinkRunLog WITH(NOLOCK) WHERE cpMainId = @cpMainId ORDER BY ID DESC
- IF ISNULL(@BeginDate, '2000-1-1') < @AddDate
- SET @IsAdd = 0
- END
-
- SELECT @ManagerUserId = ConsultantId FROM cpMain WITH(NOLOCK) WHERE id = @cpMainId
- UPDATE ExtendLink SET ManagerUserID = @ManagerUserId WHERE CpMainID=@cpMainId
-
- IF @IsAdd = 1
- BEGIN
- IF @keywordUrlOld <> @keywordUrl OR @CustomLinkOld <> @CustomLink
- SELECT @LinkStatus = 1
- SELECT @ManagerUserId = ConsultantId FROM cpMain WITH(NOLOCK) WHERE id = @cpMainId
- INSERT INTO ExtendLink(CpMainID, AddDate, KeyWord, KeywordUrl, CustomLink, RunStatus, LinkStatus, ShowType, IDs, ShowDay, NextRunDate,LinkStatusPre, ManagerUserId)
- SELECT @CpMainID, GETDATE(), @Keyword, @KeywordUrl, @CustomLink, 0, @LinkStatus, @ShowType, @IDs, @ShowDay, @NextRunDate , @LinkStatus, @ManagerUserId
- SET @linkId = @@IDENTITY
-
- END
- ELSE
- BEGIN
- IF @keywordUrlOld = @keywordUrl AND @CustomLinkOld = @CustomLink
- UPDATE ExtendLink
- SET CpMainID = @CpMainID,
- ShowType = @ShowType,
- IDs = @ids,
- ShowDay = @ShowDay,
- NextRunDate=@NextRunDate,
- AddDate = GETDATE()
- Where Id = @linkId
- ELSE
- UPDATE ExtendLink
- SET CpMainID = @CpMainID,
- KeyWord = @Keyword,
- KeywordUrl = @KeywordUrl,
- CustomLink = @CustomLink,
- ShowType = @ShowType,
- RunStatus = 0,
- LinkStatus = 1,
- IDs = @ids,
- ShowDay = @ShowDay,
- NextRunDate=@NextRunDate,
- LinkStatusPre = 1,
- AddDate = GETDATE()
- Where Id = @linkId
- END
- UPDATE ExtendLink SET RunStatus = 4 WHERE RunStatus < 3 AND cpMainId = @cpMainId AND ID < @linkId
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccExtendLinkSelect] Script Date: 2018/12/13 19:06:58 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccExtendLinkSelect]
- (
- @cpMainId INT
- )
- AS
- BEGIN
- SELECT TOP 12 a.*, CASE a.ShowType WHEN 1 THEN b.Name ELSE '' END as jobName
- FROM ExtendLink a
- LEFT JOIN Job b ON b.id = a.IDs
- WHERE a.cpMainID = @cpMainID
- ORDER BY a.id DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccFaqByCategoryIDSelect] Script Date: 2018/12/13 19:06:58 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.30
- --创建人:Nick
- --说明://根据类别获取常见问题信息
- --#####################################################
- CREATE PROCEDURE [dbo].[ccFaqByCategoryIDSelect]
- (
- @CategoryID INT
- )
- AS
- BEGIN TRY
- SELECT ID, Question,answer,CategoryID
- FROM Faq WITH(NOLOCK)
- WHERE Type=1 AND CategoryID =@CategoryID
- ORDER BY Power
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ccFaqSelect] Script Date: 2018/12/13 19:06:58 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccFaqSelect]
- AS
- BEGIN
- SELECT ID, Question,CategoryID
- FROM Faq WITH(NOLOCK)
- WHERE Type=1
- ORDER BY Power
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccFeeLogSelect] Script Date: 2018/12/13 19:06:58 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --Lambo 20110125
- --查询单位的交费记录
- CREATE PROCEDURE [dbo].[ccFeeLogSelect]
- (
- @cpMainID INT
- )
- AS
- BEGIN
- SELECT * FROM FeeLog WITH(NOLOCK) WHERE company_id = @cpMainID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccFnInvoiceByOrderIDSelect] Script Date: 2018/12/13 19:06:59 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.6
- --创建人:John
- --说明:根据订单ID获取发出发票的信息
- --#####################################################
- CREATE PROCEDURE [dbo].[ccFnInvoiceByOrderIDSelect]
- (
- @OrderID INT
- )
- AS
- BEGIN
- SELECT * FROM FnInvoice WITH(NOLOCK) WHERE Status = 1 AND OrderID = @OrderID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccFnLetterByInvoiceIDSelect] Script Date: 2018/12/13 19:06:59 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.6
- --创建人:John
- --说明:根据发票ID获取邮寄发票的信息
- --#####################################################
- CREATE PROCEDURE [dbo].[ccFnLetterByInvoiceIDSelect]
- (
- @invoiceID INT
- )
- AS
- BEGIN
- SELECT * FROM FnLetter WITH(NOLOCK) WHERE status <> 4 AND status <> 3 AND FnInvoiceID = @invoiceID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccFnLetterByOrderIDUpdate] Script Date: 2018/12/13 19:06:59 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- /*********************
- SEAN 2014-10-29
- **********************/
- CREATE PROCEDURE [dbo].[ccFnLetterByOrderIDUpdate]
- (
- @ID INT,
- @CpName NVARCHAR(100)
- )
- AS
- --INSERT INTO procLog SELECT 'ccFnLetterByOrderIDUpdate', '', GETDATE()
- BEGIN
- UPDATE FnLetter
- SET Status = 2, ReceivedDate = GETDATE(), ReceivedManName = @CpName
- FROM FnInvoice
- WHERE FnInvoice.OrderID = @ID
- AND FnLetter.FnInvoiceID = FnInvoice.ID
- AND FnLetter.Status = 1
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccFnLetterReceiveByInvoiceIDSelect] Script Date: 2018/12/13 19:06:59 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.6
- --创建人:John
- --说明:根据发票ID获取邮寄发票收到的信息
- --#####################################################
- CREATE PROCEDURE [dbo].[ccFnLetterReceiveByInvoiceIDSelect]
- (
- @invoiceID INT
- )
- AS
- BEGIN
- SELECT * FROM FnLetter WITH(NOLOCK) WHERE Status = 2 AND FnInvoiceID = @invoiceID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccIndexPageByMSiteSelect] Script Date: 2018/12/13 19:06:59 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- create PROCEDURE [dbo].[ccIndexPageByMSiteSelect]
- (
- @cpMainID INT,
- @caMainID INT,
- @ProvinceID INT,
- @IsManager BIT,
- @Object VARCHAR(10)
- )
- AS
- BEGIN
- DECLARE @t AS TABLE(
- ID INT,
- type INT,
- iCount INT NULL,
- Title NVARCHAR(100) NULL,
- Link NVARCHAR(200) NULL,
- ContentText NVARCHAR(500) NULL,
- AddDate SMALLDATETIME NULL
- )
- --取未付款订单
- 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())
- --取未查看的网站消息
- 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
- --取未查看的反馈
- 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
- --取未查看的投诉
- IF @ISManager=1
- 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
- ELSE
- 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
- --取未查看的网站分类通知
- INSERT INTO @T(ID, type, Title, ContentText, link, iCount)
- SELECT TOP 1 ID, 4, Title, Content, link, Type
- FROM CompanyInform WITH(NOLOCK)
- WHERE Status = 1
- AND Object LIKE '%' + @Object + '%'
- AND Province LIKE '%' + LTRIM(STR(@ProvinceID)) + '%'
- AND EndDate > GETDATE() ORDER BY AddDate DESC
- --取当前调查
- -- INSERT INTO @T(ID,type,ContentText)
- -- SELECT TOP 1 ID, 5, Title FROM Ivgt_Investigation WITH(NOLOCK)
- -- WHERE ENDdate > GETDATE()
- -- AND province Like '%' + LTRIM(STR(@provinceid)) + '%'
- -- AND type = 1
- -- ORDER BY adddate
- --如果有1个月内到期的职位,修改截止日期
- BEGIN TRY
- UPDATE Job SET IssueEnd = DATEADD(MINUTE,-1, CONVERT(VARCHAR(10), DATEADD(MONTH, 2, GETDATE()) + 1, 120))
- WHERE caMainId = @caMainID
- AND IssueEnd < DATEADD(MONTH, 1, GETDATE())
- AND Valid = 1
- AND @cpMainId <> 10371941
- END TRY
- BEGIN CATCH
- END CATCH
- IF @@ROWCOUNT > 0
- BEGIN
- INSERT INTO @T(ID, [Type], ContentText) VALUES(@caMainID, 6, '')
- END
- ----面试通知
- --DECLARE @InterViewCnt INT
- --SELECT @InterViewCnt = COUNT(*)
- --FROM exInterview WITH(NOLOCK)
- --WHERE JOBID IN (
- -- SELECT ID FROM JOB WITH(NOLOCK)
- -- WHERE CpMainID = @cpMainID
- -- AND CaMainID = @caMainID
- --) AND ResultDate IS NOT NULL
- --AND CpResultViewDate IS NULL
- --IF @InterViewCnt > 0
- --BEGIN
- -- INSERT INTO @T(ID, [Type], ContentText,AddDate) VALUES(@caMainID, 7, '有'+@InterViewCnt+'位求职者答复了面试通知',GETDATE())
- --END
- ----求答复提醒
- --DECLARE @ReplyViewCnt INT
- --SELECT @ReplyViewCnt = COUNT(*)
- --FROM ExJobApply WITH(NOLOCK)
- --WHERE JOBID IN (
- -- SELECT ID FROM JOB WITH(NOLOCK)
- -- WHERE CpMainID = @cpMainID
- -- AND CaMainID = @caMainID
- --) AND RemindDate IS NOT NULL
- --AND CpRemindViewDate IS NULL
- --IF @ReplyViewCnt > 0
- --BEGIN
- -- INSERT INTO @T(ID, [Type], ContentText,AddDate) VALUES(@caMainID, 8, @ReplyViewCnt,GETDATE())
- --END
- SELECT * FROM @T ORDER BY Type,ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccIndexPageSelect] Script Date: 2018/12/13 19:07:00 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccIndexPageSelect]
- (
- @cpMainID INT,
- @caMainID INT,
- @ProvinceID INT,
- @IsManager BIT,
- @Object VARCHAR(10)
- )
- AS
- BEGIN
- DECLARE @t AS TABLE(
- ID INT,
- type INT,
- iCount INT NULL,
- Title NVARCHAR(100) NULL,
- Link NVARCHAR(200) NULL,
- ContentText NVARCHAR(500) NULL,
- AddDate SMALLDATETIME NULL
- )
- --取未付款订单
- 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())
- --取未查看的网站消息
- 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
- --取未查看的反馈
- 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
- --取未查看的投诉
- IF @ISManager=1
- 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
- ELSE
- 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
- --取未查看的网站分类通知
- INSERT INTO @T(ID, type, Title, ContentText, link, iCount)
- SELECT TOP 1 ID, 4, Title, Content, link, Type
- FROM CompanyInform WITH(NOLOCK)
- WHERE Status = 1
- AND Object LIKE '%' + @Object + '%'
- AND Province LIKE '%' + LTRIM(STR(@ProvinceID)) + '%'
- AND EndDate > GETDATE() ORDER BY AddDate DESC
- --取当前调查
- INSERT INTO @T(ID,type,ContentText)
- SELECT TOP 1 ID,5,Title FROM Ivgt_Investigation WITH(NOLOCK)
- WHERE ENDdate > GETDATE()
- AND province Like '%' + LTRIM(STR(@provinceid)) + '%'
- AND type=1
- ORDER BY adddate
- --如果有1个月内到期的职位,修改截止日期
- BEGIN TRY
- UPDATE Job SET IssueEnd = DATEADD(MINUTE,-1, CONVERT(VARCHAR(10), DATEADD(MONTH, 2, GETDATE()) + 1, 120))
- WHERE caMainId = @caMainID
- AND IssueEnd < DATEADD(MONTH, 1, GETDATE())
- AND Valid = 1
- AND @cpMainId <> 10371941
- END TRY
- BEGIN CATCH
- END CATCH
- IF @@ROWCOUNT > 0
- BEGIN
- INSERT INTO @T(ID, [Type], ContentText) VALUES(@caMainID, 6, '')
- END
- ----面试通知
- --DECLARE @InterViewCnt INT
- --SELECT @InterViewCnt = COUNT(*)
- --FROM exInterview WITH(NOLOCK)
- --WHERE JOBID IN (
- -- SELECT ID FROM JOB WITH(NOLOCK)
- -- WHERE CpMainID = @cpMainID
- -- AND CaMainID = @caMainID
- --) AND ResultDate IS NOT NULL
- --AND CpResultViewDate IS NULL
- --IF @InterViewCnt > 0
- --BEGIN
- -- INSERT INTO @T(ID, [Type], ContentText,AddDate) VALUES(@caMainID, 7, '有'+@InterViewCnt+'位求职者答复了面试通知',GETDATE())
- --END
- ----求答复提醒
- --DECLARE @ReplyViewCnt INT
- --SELECT @ReplyViewCnt = COUNT(*)
- --FROM ExJobApply WITH(NOLOCK)
- --WHERE JOBID IN (
- -- SELECT ID FROM JOB WITH(NOLOCK)
- -- WHERE CpMainID = @cpMainID
- -- AND CaMainID = @caMainID
- --) AND RemindDate IS NOT NULL
- --AND CpRemindViewDate IS NULL
- --IF @ReplyViewCnt > 0
- --BEGIN
- -- INSERT INTO @T(ID, [Type], ContentText,AddDate) VALUES(@caMainID, 8, @ReplyViewCnt,GETDATE())
- --END
- SELECT * FROM @T ORDER BY Type,ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobByCaMainIDIssuedSelect] Script Date: 2018/12/13 19:07:00 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --时间 2014-01-05
- --查询某个企业用户发布的所有职位
- CREATE PROCEDURE [dbo].[ccJobByCaMainIDIssuedSelect]
- (
- @caMainID INT
- )
- AS
- BEGIN
- SELECT a.ID,a.Name,a.IssueEnd,a.dcRegionID
- FROM Job a WITH(NOLOCK)
- WHERE a.caMainID = @caMainID AND a.IsDelete=0 AND a.IssueDate IS NOT NULL
- GROUP BY a.ID,a.Valid,a.IssueEnd,a.Name,a.dcRegionID
- ORDER BY a.Valid DESC,a.IssueEnd DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobByCaMainIDSelect] Script Date: 2018/12/13 19:07:00 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --修改harry 2017-10-19 修改status=1的显示定制刷新状态jobrefreshIng
- --a;en 2018-4-9
- CREATE PROCEDURE [dbo].[ccJobByCaMainIDSelect]
- (
- @caMainID INT,
- @Status INT
- )
- AS
- BEGIN
- IF @Status=0
- SELECT *,(SELECT COUNT(ID) FROM exJobApply WITH(NOLOCK) WHERE CompanyDeleted=0 AND JobID=Job.ID AND (IsFilter IS NULL OR IsFilter=0)) ApplyCount
- FROM Job WITH(NOLOCK)
- WHERE caMainID = @caMainID AND IsDelete=0 AND IssueDate IS NULL
- ORDER BY LastModifyDate DESC
- IF @Status=1
- SELECT *, CASE WHEN EXISTS(SELECT 'X' FROM jobRefreshLog WHERE jobId = job.id AND runDateTime is NULL) THEN 1 ELSE 0 END AS jobrefreshIng,
- (SELECT COUNT(ID) FROM exJobApply WITH(NOLOCK) WHERE CompanyDeleted=0 AND JobID=Job.ID AND (IsFilter IS NULL OR IsFilter=0)) ApplyCount
- FROM Job WITH(NOLOCK)
- WHERE caMainID = @caMainID AND IsDelete=0 AND IssueEND > GETDATE()
- ORDER BY DisplayNo, IssueEnd, ID DESC
- IF @Status=2
- SELECT *,(SELECT COUNT(ID) FROM exJobApply WITH(NOLOCK) WHERE CompanyDeleted=0 AND JobID=Job.ID AND (IsFilter IS NULL OR IsFilter=0)) ApplyCount
- FROM Job WITH(NOLOCK)
- WHERE caMainID = @caMainID AND IsDelete=0 AND IssueEND < GETDATE()
- ORDER BY IssueEnd DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobBycaMainIDSelectAll] Script Date: 2018/12/13 19:07:01 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccJobBycaMainIDSelectAll]
- (
- @caMainID INT
- )
- AS
- BEGIN
- SELECT *
- FROM Job WITH(NOLOCK)
- WHERE caMainID = @caMainID AND IsDelete=0
- ORDER BY DisplayNo,LastModifyDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobBycaMainIDSelectCount] Script Date: 2018/12/13 19:07:01 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccJobBycaMainIDSelectCount]
- (
- @caMainID INT
- )
- AS
- BEGIN
- SELECT COUNT(*) cnt
- FROM Job WITH(NOLOCK)
- WHERE caMainID = @caMainID AND IsDelete=0 AND IssueDate IS NOT NULL
- AND IssueEnd > GETDATE()
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobBycaMainIDSelectFilter] Script Date: 2018/12/13 19:07:02 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccJobBycaMainIDSelectFilter]
- (
- @caMainID INT
- )
- AS
- --INSERT INTO procLog select 'ccJobByCaMainIDSelectFilter', '', getdate()
- BEGIN
- SELECT a.ID,a.Name,a.IssueEnd
- FROM Job a WITH(NOLOCK), exJobApply b WITH(NOLOCK)
- WHERE a.ID=b.JobID AND a.caMainID = @caMainID AND a.IsDelete=0 AND a.IssueDate IS NOT NULL
- GROUP BY a.ID,a.Valid,a.IssueEnd,a.Name
- ORDER BY a.Valid DESC,a.IssueEnd DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobBycaMainIDSelectHasIssued] Script Date: 2018/12/13 19:07:02 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --修改人:harry2015-8-28
- --管理员用户可以查看所有的职位
- CREATE PROCEDURE [dbo].[ccJobBycaMainIDSelectHasIssued]
- (
- @caMainID INT
- )
- AS
- BEGIN
- DECLARE @cpMainId INT,@accountType INT
- SELECT @cpMainId=cpMainID, @accountType=AccountType
- FROM caMain
- WHERE ID=@caMainID
- IF @accountType=1
- BEGIN
- SELECT *
- FROM Job WITH(NOLOCK)
- WHERE cpMainID = @cpMainId AND IsDelete=0 AND IssueDate IS NOT NULL
- ORDER BY Valid DESC,DisplayNo,IssueEnd DESC,LastModifyDate DESC
- END
- ELSE
- BEGIN
- SELECT *
- FROM Job WITH(NOLOCK)
- WHERE caMainID = @caMainID AND IsDelete=0 AND IssueDate IS NOT NULL
- ORDER BY Valid DESC,DisplayNo,IssueEnd DESC,LastModifyDate DESC
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobByCaMainIDUpdate] Script Date: 2018/12/13 19:07:02 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --lambo 20110616
- --修改职位的所属用户
- --[dbo].[ccJobByCaMainIDUpdate] 2458146,9041691,9041691
- CREATE PROCEDURE [dbo].[ccJobByCaMainIDUpdate]
- @ID INT,
- @caMainID INT,
- @cpMainID INT
- AS
- BEGIN TRAN
- BEGIN TRY
- IF EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK) WHERE ID = @caMainID AND cpMainID = @cpMainID)
- BEGIN
- UPDATE Job SET caMainID = @caMainID WHERE ID = @ID AND cpMainID = @cpMainID
- UPDATE caFavorate SET caMainID = @caMainID WHERE JobID = @ID
- UPDATE paPlaint SET caMainID = @caMainID WHERE JobID = @ID
- END
- ELSE
- GOTO ERR
- END TRY
- BEGIN CATCH
- GOTO ERR
- END CATCH
- COMMIT TRAN
- RETURN 1
- ERR:
- BEGIN
- ROLLBACK TRAN
- RETURN 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobByCpMainIDIssuedSelect] Script Date: 2018/12/13 19:07:02 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --Edit By Andy 2014-12-05
- --添加a.dcRegionID列
- CREATE PROCEDURE [dbo].[ccJobByCpMainIDIssuedSelect]
- (
- @cpMainID INT
- )
- AS
- BEGIN
- SELECT a.ID, a.Name, a.IssueEnd, a.dcRegionID
- FROM Job a WITH(NOLOCK)
- WHERE a.cpMainID = @cpMainID
- AND a.IsDelete=0
- AND a.IssueDate IS NOT NULL
- ORDER BY a.Valid DESC, a.IssueEnd DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobBycpMainIDNewSelect] Script Date: 2018/12/13 19:07:02 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --根据企业ID查询职位 20151121
- CREATE PROCEDURE [dbo].[ccJobBycpMainIDNewSelect]
- (
- @cpMainID INT,
- @Status INT,
- @PaMainID INT
- )
- AS
- BEGIN
- IF @Status=0
- BEGIN
- SELECT *, 0 IsOnline,0 IsAttention INTO #T1
- FROM Job WITH(NOLOCK)
- WHERE cpMainID = @cpMainID AND IsDelete = 0 AND IssueDate IS NULL
- ORDER BY LastModifyDate DESC
- IF @PaMainID<>0
- BEGIN
- UPDATE #T1 SET IsAttention = 1
- WHERE ID IN(
- SELECT AttentionID FROM PaAttention
- WHERE AttentionType = 2 AND PaMainID = @paMainID
- )
- END
- SELECT * FROM #T1
- END
- IF @Status=1
- BEGIN
- SELECT a.*, ISNULL(b.IsOnline, 0) IsOnline ,0 IsAttention INTO #T2
- FROM Job a WITH(NOLOCK)
- LEFT JOIN caOnline b WITH(NOLOCK) ON a.caMainId = b.caMainId
- WHERE a.cpMainID = @cpMainID AND a.Valid = 1
- ORDER BY a.DisplayNo, CONVERT(VARCHAR(4), a.dcJobtypeId)
- IF @PaMainID<>0
- BEGIN
- UPDATE #T2 SET IsAttention = 1
- WHERE ID IN(
- SELECT AttentionID FROM PaAttention
- WHERE AttentionType = 2 AND PaMainID = @paMainID
- )
- END
- SELECT * FROM #2
- END
- IF @Status=2
- BEGIN
- SELECT *, 0 IsOnline,0 IsAttention INTO #T3
- FROM Job WITH(NOLOCK)
- WHERE cpMainID = @cpMainID AND IsDelete = 0 AND IssueEND < GETDATE()
- ORDER BY IssueEnd DESC
- IF @PaMainID<>0
- BEGIN
- UPDATE #T3 SET IsAttention = 1
- WHERE ID IN(
- SELECT AttentionID FROM PaAttention
- WHERE AttentionType = 2 AND PaMainID = @paMainID
- )
- END
- SELECT * FROM #T3
- END
- IF @Status=3
- BEGIN
- SELECT *, 0 IsOnline,0 IsAttention INTO #T4
- FROM Job WITH(NOLOCK)
- WHERE cpMainID = @cpMainID AND IsDelete = 1
- ORDER BY DisplayNo, LastModifyDate DESC
- IF @PaMainID<>0
- BEGIN
- UPDATE #T4 SET IsAttention = 1
- WHERE ID IN(
- SELECT AttentionID FROM PaAttention
- WHERE AttentionType = 2 AND PaMainID = @paMainID
- )
- END
- SELECT * FROM #T4
- END
- IF @Status=4
- BEGIN
- SELECT a.*, b.FullName Region, 0 IsOnline,0 IsAttention INTO #T5
- FROM Job a WITH(NOLOCK)
- LEFT JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionId = b.ID
- WHERE cpMainID = @cpMainID AND IsDelete = 0
- ORDER BY Valid DESC, DisplayNo, CONVERT(VARCHAR(4), dcJobtypeId)
- IF @PaMainID<>0
- BEGIN
- UPDATE #T5 SET IsAttention = 1
- WHERE ID IN(
- SELECT AttentionID FROM PaAttention
- WHERE AttentionType = 2 AND PaMainID = @paMainID
- )
- END
- SELECT * FROM #T5
- END
- IF @Status=5
- BEGIN
- SELECT a.*, b.FullName Region,
- (SELECT IsOnline FROM caOnline WHERE caOnline.caMainId = a.caMainId) IsOnline,0 IsAttention INTO #T6
- FROM Job a WITH(NOLOCK)
- LEFT JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionId = b.ID
- WHERE cpMainID = @cpMainID AND IsDelete = 0
- AND IssueEnd > GETDATE() AND IssueDate < GETDATE()
- ORDER BY DisplayNo, CONVERT(VARCHAR(4), dcJobtypeId)
- IF @PaMainID<>0
- BEGIN
- UPDATE #T6 SET IsAttention = 1
- WHERE ID IN(
- SELECT AttentionID FROM PaAttention
- WHERE AttentionType = 2 AND PaMainID = @paMainID
- )
- END
- SELECT * FROM #T6
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobByCpMainIDSelect] Script Date: 2018/12/13 19:07:03 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --修改harry 2017-10-19 修改status=1的显示定制刷新状态jobrefreshIng
- --lucifer 2018-4-2
- CREATE PROCEDURE [dbo].[ccJobByCpMainIDSelect]
- (
- @cpMainID INT,
- @Status INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- IF @Status=0
- SELECT *, 0 IsOnline, '' LogoUrl --dbo.GetCpLogo(cpMainID) LogoUrl
- FROM Job WITH(NOLOCK)
- WHERE cpMainID = @cpMainID AND IsDelete = 0 AND IssueDate IS NULL
- ORDER BY LastModifyDate DESC
- IF @Status=1
- 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,
- (SELECT COUNT(ID) FROM exJobApply WITH(NOLOCK) WHERE CompanyDeleted=0 AND JobID=a.ID AND (IsFilter IS NULL OR IsFilter=0)) ApplyCount
- FROM Job a WITH(NOLOCK)
- LEFT JOIN caOnline b WITH(NOLOCK) ON a.caMainId = b.caMainId
- WHERE a.cpMainID = @cpMainID AND a.Valid = 1
- ORDER BY a.DisplayNo, CONVERT(VARCHAR(4), a.dcJobtypeId)
- IF @Status=2
- SELECT *, 0 IsOnline, '' LogoUrl, --dbo.GetCpLogo(cpMainID) LogoUrl,
- (SELECT COUNT(ID) FROM exJobApply WITH(NOLOCK) WHERE CompanyDeleted=0 AND JobID=Job.ID AND (IsFilter IS NULL OR IsFilter=0)) ApplyCount
- FROM Job WITH(NOLOCK)
- WHERE cpMainID = @cpMainID AND IsDelete = 0 AND IssueEND < GETDATE()
- ORDER BY IssueEnd DESC
- IF @Status=3
- SELECT *, 0 IsOnline, '' LogoUrl --dbo.GetCpLogo(cpMainID) LogoUrl
- FROM Job WITH(NOLOCK)
- WHERE cpMainID = @cpMainID AND IsDelete = 1
- ORDER BY DisplayNo, LastModifyDate DESC
- IF @Status=4
- SELECT a.*, b.FullName Region, 0 IsOnline, '' LogoUrl --dbo.GetCpLogo(a.cpMainID) LogoUrl
- FROM Job a WITH(NOLOCK)
- LEFT JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionId = b.ID
- WHERE cpMainID = @cpMainID AND IsDelete = 0
- ORDER BY Valid DESC, DisplayNo, CONVERT(VARCHAR(4), dcJobtypeId)
- IF @Status=5
- 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,
- (SELECT IsOnline FROM caOnline WHERE caOnline.caMainId = a.caMainId) IsOnline, '' LogoUrl --dbo.GetCpLogo(a.cpMainID) LogoUrl
- FROM Job a WITH(NOLOCK)
- LEFT JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionId = b.ID
- LEFT JOIN dcSalary c WITH(NOLOCK) ON a.dcSalaryID = c.ID
- LEFT JOIN dcSalary d WITH(NOLOCK) ON a.dcSalaryIDMax = d.ID
- LEFT JOIN dcEducation e WITH(NOLOCK) ON a.dcEducationID = e.ID
- LEFT JOIN dcOthers f WITH(NOLOCK) ON a.MinExperience = f.DetailID AND f.Category = '职位要求工作经验'
- WHERE cpMainID = @cpMainID AND IsDelete = 0
- AND IssueEnd > GETDATE() AND IssueDate < GETDATE()
- ORDER BY DisplayNo, CONVERT(VARCHAR(4), dcJobtypeId)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobBycpMainIDSelectFilter] Script Date: 2018/12/13 19:07:03 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --Edit By Andy 2014-12-05
- --添加a.dcRegionID列
- CREATE PROCEDURE [dbo].[ccJobBycpMainIDSelectFilter]
- (
- @cpMainID INT
- )
- AS
- --INSERT INTO procLog select 'ccJobBycpMainIDSelectFilter', '', getdate()
- BEGIN
- SELECT a.ID, a.Name, a.IssueEnd, a.dcRegionID
- FROM Job a WITH(NOLOCK)
- WHERE a.cpMainID = @cpMainID
- AND a.IsDelete=0
- AND a.IssueDate IS NOT NULL
- ORDER BY a.Valid DESC, a.IssueEnd DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobByEncryptViewSelect] Script Date: 2018/12/13 19:07:03 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --职位修改页面获取职位信息
- CREATE PROCEDURE [dbo].[ccJobByEncryptViewSelect]
- (
- @ID VARCHAR(12)
- )
- AS
- BEGIN
- SELECT a.*, b.FullName Region, ISNULL(c.IsOnline, 0) IsOnline,
- STUFF((SELECT '@' + Tags FROM jobTags WITH(NOLOCK) WHERE jobID = a.ID FOR XML PATH('')),1,1,'') JobTags
- FROM Job a WITH(NOLOCK)
- INNER JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionID = b.ID
- LEFT JOIN caOnline c WITH(NOLOCK) ON a.caMainId = c.caMainId
- WHERE a.SecondID = @ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobByIssueStopUpdate] Script Date: 2018/12/13 19:07:03 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --终止职位
- --修改harry 增加职位刷新操作2017-11-8
- CREATE PROCEDURE [dbo].[ccJobByIssueStopUpdate]
- (
- @ID INT,
- @caMainID INT,
- @cpMainID INT
- )
- AS
- BEGIN TRAN
- IF NOT EXISTS(SELECT 'x' FROM Job WHERE ID = @ID AND cpMainID = @cpMainID)
- GOTO ERR
- UPDATE JOB
- SET IssueDate = (CASE WHEN IssueDate >= GETDATE() THEN CONVERT(VARCHAR(10), GETDATE(), 23) ELSE IssueDate END),
- IssueEnd = DATEADD(MINUTE, -1, GETDATE())
- WHERE ID = @ID
-
- UPDATE jobrefreshSet
- SET runState =0
- WHERE runState =1
- AND jobId = @ID
- ----暂停职位
- --DECLARE @JobNum AS INT, @JobName AS NVARCHAR(100), @Desc AS NVARCHAR(200)
- --SELECT @JobName = LTRIM(RTRIM([Name])) FROM Job WITH(NOLOCK) WHERE ID = @ID
- --SET @Desc = '停止职位:编号<' + LTRIM(STR(@ID)) + '>职位名称<' + @JobName +'>。'
- --EXEC ccCaOperationLogInsert @caMainID, 41, @Desc
- COMMIT TRAN
- RETURN 1
- ERR:
- BEGIN
- ROLLBACK TRAN
- RETURN 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobByIssueUpdate] Script Date: 2018/12/13 19:07:03 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --##############################################################################
- --Sean 2012-4-20
- --Cancel 计划发布职位:编号
- --Peter 2016-10-17修改
- --harry 管理员操作暂停用户的职位时有效2018-4-23
- --##############################################################################
- CREATE PROCEDURE [dbo].[ccJobByIssueUpdate]
- (
- @ID INT,
- @IssueDate SMALLDATETIME,
- @IssueEnd SMALLDATETIME,
- @maxJobNum INT,
- @cpMainId INT
- )
- AS
- SET NOCOUNT ON
- DECLARE @JobNum AS INT, @JobName AS NVARCHAR(100), @Desc AS NVARCHAR(200), @caMainID AS INT
- IF ISNULL(@cpMainId, 0) != 10880312
- BEGIN
- SET @IssueDate = DATEADD(MINUTE, -1, GETDATE())
- IF @IssueEnd < GETDATE()
- SET @IssueEnd = DATEADD(MONTH, 2, GETDATE())
- SET @IssueEnd = CONVERT(VARCHAR(10), @IssueEnd, 120) + ' 23:59'
- IF @IssueEnd < @IssueDate
- SET @IssueEnd = CONVERT(VARCHAR(10), @IssueDate, 120) + ' 23:59'
- BEGIN TRAN
- BEGIN TRY
- IF NOT EXISTS(SELECT 'x' FROM Job WITH(NOLOCK) WHERE ID = @ID AND cpMainID = @cpMainID)
- GOTO ERR
-
- SELECT @JobName = LTRIM(RTRIM([Name])), @caMainID = caMainID FROM Job WITH(NOLOCK) WHERE ID = @ID
- IF @IssueEnd > GETDATE()
- BEGIN
- SELECT @JobNum = COUNT(*) FROM Job WITH(NOLOCK)
- WHERE IsDelete = 0 AND IssueDate<GETDATE() AND IssueEnd>GETDATE()
- AND cpMainID=@cpMainID AND ID <> @ID
- SELECT @maxJobNum = MaxJobNumber FROM cpMain WITH(NOLOCK) WHERE Id = @cpMainId
- IF @maxJobNum <= @JobNum
- GOTO ERR1
- END
- IF EXISTS(SELECT 'X' FROM caMain WITH(NOLOCK) WHERE ID=@caMainID AND IsPause=1)
- BEGIN
- --GOTO ERR2
- UPDATE job SET caMainId=(select TOP 1 id from caMain where cpmainid=@cpMainId AND accountType=1)
- FROM Job WITH(NOLOCK) WHERE ID = @ID
- END
- UPDATE Job SET IssueDate = @IssueDate, IssueEnd = @IssueEnd WHERE ID=@ID
- ----立即发布职位
- --SET @Desc = '发布职位:编号<' + LTRIM(STR(@ID)) + '>职位名称<' + @JobName +'>,有效期至' + CONVERT(VARCHAR(19), @IssueEnd, 120) + '。'
- --EXEC ccCaOperationLogInsert @caMainID, 40, @Desc
-
- INSERT INTO paPushLog(paMainID, PushMessage, PushType, DetailID)
- SELECT PaMainID, '亲,您关注的企业发布新职位啦!', 6, @ID FROM paAttention
- WHERE AttentionType = 1 AND AttentionID = @cpMainId AND EXISTS(
- SELECT 'X' FROM paIOSBind WHERE paMainID = paAttention.paMainID
- )
- --修改推送的相关信息
- IF EXISTS(SELECT 'x' FROM caPushSet WITH(NOLOCK) WHERE caMainID = @caMainID)
- BEGIN
- UPDATE caPushSet
- SET PushNo = 0
- WHERE caMainID = @caMainID
- END
- ELSE
- BEGIN
- INSERT INTO caPushSet(caMainID,PushFrequency,PushNo)
- VALUES (@CaMainID,99,0)
- END
- END TRY
- BEGIN CATCH
- RETURN -3
- END CATCH
- COMMIT TRAN
- RETURN 1
- END
- ELSE
- ------------------------------------------------------
- BEGIN
- SET @IssueDate = DATEADD(MINUTE, -1, GETDATE())
- IF @IssueEnd < GETDATE()
- SET @IssueEnd = DATEADD(MONTH, 2, GETDATE())
- SET @IssueEnd = CONVERT(VARCHAR(10), @IssueEnd, 120) + ' 23:59'
- IF @IssueEnd < @IssueDate
- SET @IssueEnd = CONVERT(VARCHAR(10), @IssueDate, 120) + ' 23:59'
- -- BEGIN TRAN
- -- BEGIN TRY
- IF NOT EXISTS(SELECT 'x' FROM Job WITH(NOLOCK) WHERE ID = @ID AND cpMainID = @cpMainID)
- GOTO ERR
-
- -- DECLARE @JobNum AS INT, @JobName AS NVARCHAR(100), @Desc AS NVARCHAR(200), @caMainID AS INT
- SELECT @JobName = LTRIM(RTRIM([Name])), @caMainID = caMainID FROM Job WITH(NOLOCK) WHERE ID = @ID
-
- IF @IssueEnd > GETDATE()
- BEGIN
- SELECT @JobNum = COUNT(*) FROM Job WITH(NOLOCK)
- WHERE IsDelete = 0 AND IssueDate<GETDATE() AND IssueEnd>GETDATE()
- AND cpMainID=@cpMainID AND ID <> @ID
- SELECT @maxJobNum = MaxJobNumber FROM cpMain WITH(NOLOCK) WHERE Id = @cpMainId
- IF @maxJobNum <= @JobNum
- GOTO ERR1
- END
- IF EXISTS(SELECT 'X' FROM caMain WITH(NOLOCK) WHERE ID=@caMainID AND IsPause=1)
- BEGIN
- --GOTO ERR2
- UPDATE job SET caMainId=(select TOP 1 id from caMain where cpmainid=@cpMainId AND accountType=1)
- FROM Job WITH(NOLOCK) WHERE ID = @ID
- END
- UPDATE Job SET IssueDate = @IssueDate, IssueEnd = @IssueEnd WHERE ID=@ID
- ----立即发布职位
- --SET @Desc = '发布职位:编号<' + LTRIM(STR(@ID)) + '>职位名称<' + @JobName +'>,有效期至' + CONVERT(VARCHAR(19), @IssueEnd, 120) + '。'
- --EXEC ccCaOperationLogInsert @caMainID, 40, @Desc
-
- INSERT INTO paPushLog(paMainID, PushMessage, PushType, DetailID)
- SELECT PaMainID, '亲,您关注的企业发布新职位啦!', 6, @ID FROM paAttention
- WHERE AttentionType = 1 AND AttentionID = @cpMainId AND EXISTS(
- SELECT 'X' FROM paIOSBind WHERE paMainID = paAttention.paMainID
- )
- --修改推送的相关信息
- IF EXISTS(SELECT 'x' FROM caPushSet WITH(NOLOCK) WHERE caMainID = @caMainID)
- BEGIN
- UPDATE caPushSet
- SET PushNo = 0
- WHERE caMainID = @caMainID
- END
- ELSE
- BEGIN
- INSERT INTO caPushSet(caMainID,PushFrequency,PushNo)
- VALUES (@CaMainID,99,0)
- END
- -- END TRY
- -- BEGIN CATCH
- -- GOTO ERR
- -- END CATCH
- -- COMMIT TRAN
- RETURN 1
- END
- ---------------------------------------------------------------
- ERR:
- BEGIN
- IF ISNULL(@cpMainId, 0) != 10880312
- ROLLBACK TRAN
- RETURN 0
- END
- ERR1:
- BEGIN
- IF ISNULL(@cpMainId, 0) != 10880312
- ROLLBACK TRAN
- RETURN -1
- END
- ERR2:
- BEGIN
- IF ISNULL(@cpMainId, 0) != 10880312
- ROLLBACK TRAN
- RETURN -2
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobByIssueUpdate2] Script Date: 2018/12/13 19:07:04 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --##############################################################################
- --Sean 2012-4-20
- --Cancel 计划发布职位:编号
- --##############################################################################
- CREATE PROCEDURE [dbo].[ccJobByIssueUpdate2]
- (
- @ID INT,
- @IssueDate SMALLDATETIME,
- @IssueEnd SMALLDATETIME,
- @maxJobNum INT,
- @cpMainId INT
- )
- AS
- SET NOCOUNT ON
- INSERT INTO aa SELECT @Id, @IssueDate, @IssueEnd, @MaxJobNum, @CpMainId
- BEGIN
- SET @IssueDate = DATEADD(MINUTE, -1, GETDATE())
- SET @IssueEnd = CONVERT(VARCHAR(10), @IssueEnd, 120) + ' 23:59'
- IF @IssueEnd < @IssueDate
- SET @IssueEnd = CONVERT(VARCHAR(10), @IssueDate, 120) + ' 23:59'
- BEGIN TRAN
- BEGIN TRY
- IF NOT EXISTS(SELECT 'x' FROM Job WITH(NOLOCK) WHERE ID = @ID AND cpMainID = @cpMainID)
- GOTO ERR
-
- DECLARE @JobNum AS INT, @JobName AS NVARCHAR(100), @Desc AS NVARCHAR(200), @caMainID AS INT
- SELECT @JobName = LTRIM(RTRIM([Name])), @caMainID = caMainID FROM Job WITH(NOLOCK) WHERE ID = @ID
- IF EXISTS(SELECT 'X' FROM caMain WITH(NOLOCK) WHERE ID=@caMainID AND IsPause=1)
- GOTO ERR2
- IF @IssueEnd > GETDATE()
- BEGIN
- SELECT @JobNum = COUNT(*) FROM Job WITH(NOLOCK)
- WHERE IsDelete = 0 AND IssueDate<GETDATE() AND IssueEnd>GETDATE() AND cpMainID=@cpMainID
- AND ID <> @ID
- IF @maxJobNum <= @JobNum
- GOTO ERR1
- END
- UPDATE Job SET IssueDate = @IssueDate, IssueEnd = @IssueEnd WHERE ID=@ID
- ----立即发布职位
- --SET @Desc = '发布职位:编号<' + LTRIM(STR(@ID)) + '>职位名称<' + @JobName +'>,有效期至' + CONVERT(VARCHAR(19), @IssueEnd, 120) + '。'
- --EXEC ccCaOperationLogInsert @caMainID, 40, @Desc
- END TRY
- BEGIN CATCH
- GOTO ERR
- END CATCH
- COMMIT TRAN
- RETURN 1
- END
- ERR:
- BEGIN
- ROLLBACK TRAN
- RETURN 0
- END
- ERR1:
- BEGIN
- ROLLBACK TRAN
- RETURN -1
- END
- ERR2:
- BEGIN
- ROLLBACK TRAN
- RETURN -2
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobByIssueUpdate3] Script Date: 2018/12/13 19:07:04 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --##############################################################################
- --Sean 2012-4-20
- --Cancel 计划发布职位:编号
- --Peter 2016-10-17修改
- --harry 管理员操作暂停用户的职位时有效2018-4-23
- --##############################################################################
- CREATE PROCEDURE [dbo].[ccJobByIssueUpdate3]
- (
- @ID INT,
- @IssueDate SMALLDATETIME,
- @IssueEnd SMALLDATETIME,
- @maxJobNum INT,
- @cpMainId INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- SET @IssueDate = DATEADD(MINUTE, -1, GETDATE())
- IF @IssueEnd < GETDATE()
- SET @IssueEnd = DATEADD(MONTH, 2, GETDATE())
- SET @IssueEnd = CONVERT(VARCHAR(10), @IssueEnd, 120) + ' 23:59'
- IF @IssueEnd < @IssueDate
- SET @IssueEnd = CONVERT(VARCHAR(10), @IssueDate, 120) + ' 23:59'
- DECLARE @JobNum AS INT, @JobName AS NVARCHAR(100), @Desc AS NVARCHAR(200), @caMainID AS INT
- SELECT @JobName = LTRIM(RTRIM([Name])), @caMainID = caMainID FROM Job WITH(NOLOCK) WHERE ID = @ID
- IF @IssueEnd > GETDATE()
- BEGIN
- SELECT @JobNum = COUNT(*) FROM Job WITH(NOLOCK)
- WHERE IsDelete = 0 AND IssueDate<GETDATE() AND IssueEnd>GETDATE()
- AND cpMainID=@cpMainID AND ID <> @ID
- SELECT @maxJobNum = MaxJobNumber FROM cpMain WITH(NOLOCK) WHERE Id = @cpMainId
- IF @maxJobNum <= @JobNum
- GOTO ERR1
- END
- IF EXISTS(SELECT 'X' FROM caMain WITH(NOLOCK) WHERE ID=@caMainID AND IsPause=1)
- BEGIN
- --GOTO ERR2
- UPDATE job SET caMainId=(select TOP 1 id from caMain where cpmainid=@cpMainId AND accountType=1)
- FROM Job WITH(NOLOCK) WHERE ID = @ID
- END
- UPDATE Job SET IssueDate = @IssueDate, IssueEnd = @IssueEnd WHERE ID=@ID
- ----立即发布职位
- --SET @Desc = '发布职位:编号<' + LTRIM(STR(@ID)) + '>职位名称<' + @JobName +'>,有效期至' + CONVERT(VARCHAR(19), @IssueEnd, 120) + '。'
- --EXEC ccCaOperationLogInsert @caMainID, 40, @Desc
- INSERT INTO paPushLog(paMainID, PushMessage, PushType, DetailID)
- SELECT PaMainID, '亲,您关注的企业发布新职位啦!', 6, @ID FROM paAttention
- WHERE AttentionType = 1 AND AttentionID = @cpMainId AND EXISTS(
- SELECT 'X' FROM paIOSBind WHERE paMainID = paAttention.paMainID
- )
- --修改推送的相关信息
- IF EXISTS(SELECT 'x' FROM caPushSet WITH(NOLOCK) WHERE caMainID = @caMainID)
- BEGIN
- UPDATE caPushSet
- SET PushNo = 0
- WHERE caMainID = @caMainID
- END
- ELSE
- BEGIN
- INSERT INTO caPushSet(caMainID,PushFrequency,PushNo)
- VALUES (@CaMainID,99,0)
- END
- RETURN 1
- END
- ---------------------------------------------------------------
- ERR:
- BEGIN
- print 'aaa'
- RETURN 0
- END
- ERR1:
- BEGIN
- select @maxJobNum , @JobNum
- print 'bbb'
- RETURN -1
- END
- ERR2:
- BEGIN
- print 'ccc'
- RETURN -2
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobByMapBarIDUpdate] Script Date: 2018/12/13 19:07:04 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- -- =============================================
- -- Author: <Author,,Name>
- -- Create date: <Create Date,,>
- -- Description: <Description,,>
- -- =============================================
- CREATE PROCEDURE [dbo].[ccJobByMapBarIDUpdate]
- @ID INT,
- @MapBarID VARCHAR(50),
- @cpMainID INT
- AS
- BEGIN
- UPDATE Job SET MapBarID=@MapBarID WHERE ID=@ID AND cpMainID = @cpMainID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobByMapBarUpdate] Script Date: 2018/12/13 19:07:05 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccJobByMapBarUpdate]
- @ID INT,
- @Lng VARCHAR(20),
- @Lat VARCHAR(20),
- @Address NVARCHAR(50),
- @cpMainID INT
- AS
- BEGIN
- UPDATE Job SET Lng=@Lng,Lat=@Lat WHERE ID=@ID AND cpMainID = @cpMainID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobByNameExist] Script Date: 2018/12/13 19:07:05 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --sean 2013-1-30
- --update ccJobNameExist
- --nick 2013-07-22
- --update 判断 发布中还是过期 重名
- CREATE PROCEDURE [dbo].[ccJobByNameExist]
- (
- @ID INT ,
- @cpMainID INT,
- @Name VARCHAR(100)
- )
- AS
- SET NOCOUNT ON
- INSERT INTO procLog select 'ccJobByNameExist', @ID, getdate()
- BEGIN TRY
- DECLARE @IssueEnd DATETIME --截止时间
- SET @Name = LTRIM(RTRIM(@Name))
- SELECT @IssueEnd = IssueEnd
- FROM Job WITH(NOLOCK)
- WHERE NAME=@Name
- AND ID<>@ID
- AND cpMainID = @cpMainID
- AND IsDelete = 0
- IF @IssueEND > GETDATE()
- RETURN 1 --发布中
- IF @IssueEND < GETDATE()
- RETURN 2 --已过期
-
- RETURN 0
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ccJobByNameExist2] Script Date: 2018/12/13 19:07:05 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --sean 2013-1-30
- --update ccJobNameExist
- --nick 2013-07-22
- --update 判断 发布中还是过期 重名
- CREATE PROCEDURE [dbo].[ccJobByNameExist2]
- (
- @ID INT ,
- @cpMainID INT,
- @Name VARCHAR(100),
- @dcRegionId VARCHAR(6)
- )
- AS
- SET NOCOUNT ON
- --INSERT INTO procLog select 'ccJobByNameExist2', @ID, getdate()
- --this proc is valid
- IF @cpMainID = 10576676
- RETURN 0
- BEGIN
- DECLARE @IssueEnd DATETIME --截止时间
- SET @Name = LTRIM(RTRIM(@Name))
- SELECT @IssueEnd = IssueEnd
- FROM Job WITH(NOLOCK)
- WHERE cpMainID = @cpMainID
- AND Name = @Name
- AND dcREgionId = @dcRegionId
- AND ID <> @ID
- AND IsDelete = 0
- IF @IssueEND > GETDATE()
- RETURN 1 --发布中
- IF @IssueEND < GETDATE()
- RETURN 2 --已过期
-
- RETURN 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobByRecentApplySelect] Script Date: 2018/12/13 19:07:05 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccJobByRecentApplySelect]
- (
- @dcRegionID VARCHAR(50), --求职地区
- @dcJobTypeID VARCHAR(50), --期望职位类别
- @RowCount INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- SET @dcJobTypeID = dbo.FormatIDS(@dcJobTypeID)
- DECLARE @T_JobType AS TABLE(ID INT)
- DECLARE @JobTypeExpect AS VARCHAR(3000)
- DECLARE @T_Temp1 AS TABLE(ID INT) --临时表,用于构建组合查询语句
- INSERT INTO @T_Temp1
- SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
- INSERT INTO @T_JobType
- SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
- WHERE ParentId IN(SELECT ID FROM @T_TEMP1)
- OR ParentId2 in(SELECT ID FROM @T_TEMP1)
- OR ID IN(SELECT ID FROM @T_TEMP1)
- ----生成in字符串
- SELECT @JobTypeExpect = ''
- SELECT @JobTypeExpect = (@JobTypeExpect + LTRIM(STR(ID) + ',')) FROM @T_JobType
- IF RIGHT(@JobTypeExpect, 1) = ','
- SET @JobTypeExpect = LEFT(@JobTypeExpect, LEN(@JobTypeExpect) - 1)
-
- DECLARE @T_JobPlace AS TABLE(ID INT)
- DECLARE @JobPlace AS VARCHAR(3000)
- INSERT INTO @T_JobPlace
- SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
- SELECT @JobPlace = ''
- SELECT @JobPlace = (@JobPlace + ' OR c.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
- SELECT @JobPlace = (@JobPlace + ' OR c.dcRegionID = ''' + LTRIM(STR(LEFT(ID,2)))+'''' )
- FROM @T_JobPlace WHERE LEN(ID) > 2
- SELECT @JobPlace = (@JobPlace + ' OR c.dcRegionID = ''' + LTRIM(STR(LEFT(ID,4)))+'''' )
- FROM @T_JobPlace WHERE LEN(ID) > 4
- SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
- DECLARE @SQL AS VARCHAR(3000)
- SET @SQL = 'SELECT TOP ' + CONVERT(VARCHAR, @RowCount) + ' b.SecondID EnJobID, b.Name JobName, c.Name CpName,
- c.HasLicence, c.SecondID EnCpMainID, b.ID,dbo.GetCaOnlineStatus(b.caMainID) AS IsOnline,b.caMainID,
- b.dcRegionID, b.dcSalaryID, b.Refreshdate, b.Responsibility, b.Demand, b.dcEducationID,
- b.MinExperience, c.dcCompanySizeID, b.EmployType,b.Welfare1,b.Welfare2,b.Welfare3,b.Welfare4,b.Welfare5,b.Welfare6,b.Welfare7,b.Welfare8,
- b.Welfare9,b.Welfare10,b.Welfare11,b.Welfare12,b.Welfare13,b.Welfare14,b.Welfare15,b.Welfare16,
- b.Welfare17,b.Welfare18,b.Welfare19
- FROM exJobApply a WITH(NOLOCK), JobPublish b WITH(NOLOCK), cpMainPublish c WITH(NOLOCK)
- WHERE a.JobID = b.ID AND b.cpMainID = c.ID AND a.cvMainID IN(
- SELECT a.ID FROM cvMainPublish a WITH(NOLOCK)
- INNER JOIN paMainPublish b WITH(NOLOCK) ON a.paMainID = b.ID
- INNER JOIN cvJobPlacePublish c ON a.ID = c.cvMainID
- INNER JOIN cvJobTypePublish d ON a.ID = d.cvMainID
- WHERE d.dcJobTypeID IN(' + @JobTypeExpect +') AND (' + @JobPlace + ')
- ) ORDER BY a.AddDate DESC'
- --PRINT(@SQL)
- EXEC(@SQL)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobByViewSelect] Script Date: 2018/12/13 19:07:05 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --Peter 2016-10-31修改读取职位订阅内容时区别
- CREATE PROCEDURE [dbo].[ccJobByViewSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT *, b.FullName Region, ISNULL(c.IsOnline, 0) IsOnline,dbo.Int2Bin(a.EMailSendFreq) PushFreq,
- STUFF((SELECT '@' + Tags FROM jobTags WITH(NOLOCK) WHERE jobID = a.ID FOR XML PATH('')),1,1,'') JobTags,
- ISNULL((SELECT Description FROM dcEducation WHERE Id = dcEducationId), '不限') Education, d.Name cpName,
- e.Description JobTypeName,f.Description JobTypeMinorName,g.Description NeedNumName,h.Description EmployTypeName,
- i.Description ExperienceName,j.DescriptionCp SalaryName,k.DescriptionCp SalaryMaxName
- FROM Job a WITH(NOLOCK)
- INNER JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionID = b.ID
- LEFT JOIN caOnline c WITH(NOLOCK) ON a.caMainId = c.caMainId
- INNER JOIN cpMain d WITH(NOLOCK) ON a.cpMainId = d.ID
- LEFT JOIN dcJobType e WITH(NOLOCK) ON a.dcJobTypeId = e.ID
- LEFT JOIN dcJobType f WITH(NOLOCK) ON a.dcJobTypeIdMinor = f.ID
- LEFT JOIN dcOthers g WITH(NOLOCK) ON a.NeedNumber = g.DetailID AND g.Category = '招聘人数'
- LEFT JOIN dcOthers h WITH(NOLOCK) ON a.EmployType = h.DetailID AND h.Category = '工作性质'
- LEFT JOIN dcOthers i WITH(NOLOCK) ON a.MinExperience = i.DetailID AND i.Category = '职位要求工作经验'
- LEFT JOIN dcSalary j WITH(NOLOCK) ON a.dcSalaryId = j.ID
- LEFT JOIN dcSalary k WITH(NOLOCK) ON a.dcSalaryIdMax = k.ID
- WHERE a.ID = @ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobDelete] Script Date: 2018/12/13 19:07:06 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccJobDelete]
- (
- @OperatorID INT,
- @ID INT,
- @caMainID INT
- )
- AS
- BEGIN TRAN
- DECLARE @JobName AS NVARCHAR(100)
- DECLARE @caID AS INT
- DECLARE @jobnumber AS INT
- DECLARE @cpMainID AS INT
- DECLARE @cpID AS INT
- DECLARE @AccountType AS INT
- SELECT @JobName = Name, @caID = caMainId, @cpID = cpMainID FROM Job WITH(NOLOCK) WHERE ID = @ID
- SELECT @AccountType=AccountType,@cpMainID=cpMainID FROM caMain WITH(NOLOCK) WHERE id = @OperatorID
- IF @JobName Is NUll
- GOTO ERR1
- IF @caID != @caMainID
- BEGIN
- IF @AccountType != 1
- GOTO ERR2
- IF @cpMainID != @cpID
- GOTO ERR2
- END
-
- IF EXISTS(SELECT 'x' FROM caMain WHERE Id = @caMainId)
- INSERT INTO caOperationLog(caMainId, Operation, Details, Ip)
- VALUES(@caMainId, 42, '删除职位:编号<' + LTRIM(STR(@ID)) + '>职位名称<' + @JobName + '>。', ' ')
- UPDATE Job SET isDelete = 1 WHERE id = @ID
- INSERT INTO CaCvApplyDeleted(JobID, JobName, CvMainId, ApplyDate, AddDate, Reply)
- SELECT b.ID, b.Name, a.cvMainid, a.AddDate, GETDATE(), ISNULL(Reply, 0)
- FROM exjobapply a,job b
- WHERE a.jobid = b.id
- AND b.id=@ID
- AND a.CompanyDeleted=0
- IF @@ERROR <> 0
- GOTO ERR
- SELECT @JobNumber = COUNT(1) FROM Job WITH(NOLOCK)
- WHERE IsDelete = 0
- AND IssueDate < GETDATE()
- AND IssueEnd > GETDATE()
- AND cpMainID = @cpMainID
- UPDATE cpMain SET jobNumber = @jobnumber WHERE ID = @cpMainID
- DELETE FROM bsCpModify WHERE SubID = @ID AND Location Like 'c%'
- COMMIT TRAN
- RETURN 1
- ERR:
- BEGIN
- ROLLBACK TRAN
- RETURN 0
- END
- ERR1:
- BEGIN
- ROLLBACK TRAN
- RETURN -1
- END
- ERR2:
- BEGIN
- ROLLBACK TRAN
- RETURN -2
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobDeleteNew] Script Date: 2018/12/13 19:07:06 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- Create PROCEDURE [dbo].[ccJobDeleteNew]
- (
- @OperatorID INT,
- @ID INT,
- @caMainID INT,
- @Ip VARCHAR(15)
- )
- AS
- BEGIN TRAN
- DECLARE @JobName AS NVARCHAR(100)
- DECLARE @caID AS INT
- DECLARE @jobnumber AS INT
- DECLARE @cpMainID AS INT
- DECLARE @cpID AS INT
- DECLARE @AccountType AS INT
- SELECT @JobName = Name, @caID = caMainId, @cpID = cpMainID FROM Job WITH(NOLOCK) WHERE ID = @ID
- SELECT @AccountType=AccountType,@cpMainID=cpMainID FROM caMain WITH(NOLOCK) WHERE id = @OperatorID
- IF @JobName Is NUll
- GOTO ERR1
- IF @caID != @caMainID
- BEGIN
- IF @AccountType != 1
- GOTO ERR2
- IF @cpMainID != @cpID
- GOTO ERR2
- END
-
- IF EXISTS(SELECT 'x' FROM caMain WHERE Id = @caMainId)
- INSERT INTO caOperationLog(caMainId, Operation, Details, Ip)
- VALUES(@caMainId, 42, '删除职位:编号<' + LTRIM(STR(@ID)) + '>职位名称<' + @JobName + '>。', @Ip)
- UPDATE Job SET isDelete = 1 WHERE id = @ID
- INSERT INTO CaCvApplyDeleted(JobID, JobName, CvMainId, ApplyDate, AddDate, Reply)
- SELECT b.ID, b.Name, a.cvMainid, a.AddDate, GETDATE(), ISNULL(Reply, 0)
- FROM exjobapply a,job b
- WHERE a.jobid = b.id
- AND b.id=@ID
- AND a.CompanyDeleted=0
- IF @@ERROR <> 0
- GOTO ERR
- SELECT @JobNumber = COUNT(1) FROM Job WITH(NOLOCK)
- WHERE IsDelete = 0
- AND IssueDate < GETDATE()
- AND IssueEnd > GETDATE()
- AND cpMainID = @cpMainID
- UPDATE cpMain SET jobNumber = @jobnumber WHERE ID = @cpMainID
- DELETE FROM bsCpModify WHERE SubID = @ID AND Location Like 'c%'
- COMMIT TRAN
- RETURN 1
- ERR:
- BEGIN
- ROLLBACK TRAN
- RETURN 0
- END
- ERR1:
- BEGIN
- ROLLBACK TRAN
- RETURN -1
- END
- ERR2:
- BEGIN
- ROLLBACK TRAN
- RETURN -2
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobDisplayNoByAutoSortUpdate] Script Date: 2018/12/13 19:07:06 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccJobDisplayNoByAutoSortUpdate]
- (
- @cpMainID INT,
- @Type INT
- )
- AS
- BEGIN
- BEGIN TRY
- DECLARE @SQL VARCHAR(400)
- DECLARE @ColName VARCHAR(200)
- IF @Type = 0
- SET @ColName = 'c.LastModifyDate DESC'
- IF @Type = 1
- SET @ColName = 'c.IssueEnd'
- IF @Type = 2
- SET @ColName = '(SELECT count(1) FROM exJobApply WITH(NOLOCK) WHERE jobID = c.id),CONVERT(VARCHAR(4), c.dcJobtypeId)'
- SET @SQL = 'UPDATE a SET displayno =b.num
- FROM Job a ,
- (SELECT ROW_NUMBER() OVER(ORDER BY ' + @ColName + ' ) num ,id
- FROM Job c WITH(NOLOCK) WHERE c.cpMainID = ' + LTRIM(STR(@cpMainID)) + '
- AND c.IsDelete=0 AND c.IssueEND>GETDATE() ) b
- WHERE a.id = b.id AND a.IsDelete=0 AND a.IssueEND > GETDATE()
- AND a.cpMainID = ' + LTRIM(STR(@cpMainID))
- EXEC(@SQL)
- RETURN 1
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobDisplayNoByPlusTenUpdate] Script Date: 2018/12/13 19:07:06 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccJobDisplayNoByPlusTenUpdate]
- (
- @cpMainID INT
- )
- AS
- BEGIN
- BEGIN TRY
- UPDATE Job SET DisplayNO = DisplayNO + 10
- WHERE cpMainID = @cpMainID
- -- AND IssueDate < GETDATE()
- AND IssueEND > GETDATE()
- AND IsDelete = 0
- UPDATE Job SET DisplayNO = 999
- WHERE cpMainID = @cpMainID
- AND DisplayNo > 999
- RETURN 1
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobDisplayNoByResetUpdate] Script Date: 2018/12/13 19:07:06 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccJobDisplayNoByResetUpdate]
- (
- @cpMainID INT
- )
- AS
- BEGIN
- BEGIN TRY
- UPDATE Job SET DisplayNO = 1
- WHERE cpMainID = @cpMainID
- -- AND IssueDate < GETDATE()
- AND IssueEND > GETDATE()
- AND IsDelete = 0
- RETURN 1
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobDisplayNoUpdate] Script Date: 2018/12/13 19:07:06 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccJobDisplayNoUpdate]
- (
- @ID INT,
- @DisplayNO SMALLINT ,
- @cpMainID INT
- )
- AS
- BEGIN
- BEGIN TRY
- UPDATE Job SET DisplayNo=@DisplayNO WHERE ID=@ID AND cpMainID = @cpMainID
- RETURN 1
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobRefreshLogBypreRefreshDateTimeUpdate] Script Date: 2018/12/13 19:07:07 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --职位刷新数计划任务
- --每分钟执行一次,执行后分配订单号,更新职位刷新时间,同时刷新数remainJobRefreshQuota-1
- --harry 2017-11-9
- --修改harry 2018-5-14 修改过期的刷新只刷过期时间不超过1h的
- CREATE PROCEDURE [dbo].[ccJobRefreshLogBypreRefreshDateTimeUpdate]
- AS
- --return
- BEGIN
- SET NOCOUNT ON
- --获取待执行的数据 preRefreshDateTime<DATEADD(minute,1,getdate()) AND refreshType=0 AND runDateTime IS NULL
- SELECT * INTO #t
- FROM JobRefreshLog
- WHERE preRefreshDateTime<=DATEADD(minute,1,getdate()) AND preRefreshDateTime>=DATEADD(hour,-1,getdate()) AND refreshType=0 AND runDateTime IS NULL
-
- --遍历#t
- DECLARE @Id INT, @jobId INT, @cpMainId INT, @orderId INT, @preRefreshDateTime DATETIME --职位,jobrefrshid
-
- --获取所有可用的订单
- SELECT * INTO #tOrder FROM caOrder WITH(NOLOCK)
- WHERE cpMainID IN(SELECT DISTINCT cpMainId FROM #t)
- AND openDate is NOT NULL
- AND endDate >GETDATE()
- AND OrderType IN(8,15)
- AND ISNULL(remainJobRefreshQuota,0) != 0
- ORDER BY endDate
- WHILE EXISTS (SELECT TOP 1 ID FROM #t)
- BEGIN
- SELECT TOP 1 @Id = ID, @jobId = jobid, @cpMainId =cpMainId, @preRefreshDateTime =preRefreshDateTime FROM #t
- 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 )
- BEGIN
- SELECT TOP 1 @orderId = Id
- FROM #tOrder
- WHERE cpMainId = @cpMainId
- AND openDate is NOT NULL
- AND endDate >GETDATE()
- AND OrderType IN(8,15)
- AND ISNULL(remainJobRefreshQuota,0) != 0
- ORDER BY endDate
- --更新订单
- UPDATE caorder SET remainJobRefreshQuota =remainJobRefreshQuota -1
- WHERE id = @orderId
- --更新jobrefreshlog,
- UPDATE jobrefreshlog
- SET runDateTime =GETDATE(), orderId = @orderId
- WHERE ID =@Id
- --更新job refrshdate
- UPDATE job
- SET RefreshDate= @preRefreshDateTime
- WHERE id =@jobId
- END
- ELSE
- BEGIN
- DELETE FROM jobrefreshlog WHERE ID= @Id
- END
- DELETE FROM #t WHERE ID= @Id
- END
- DROP TABLE #tOrder
- DROP TABLE #t
- SET NOCOUNT OFF
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobRefreshLogBypreRefreshDateTimeUpdatetest] Script Date: 2018/12/13 19:07:07 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --职位刷新数计划任务
- --每分钟执行一次,执行后分配订单号,更新职位刷新时间,同时刷新数remainJobRefreshQuota-1
- --harry 2017-11-9
- CREATE PROCEDURE [dbo].[ccJobRefreshLogBypreRefreshDateTimeUpdatetest]
- AS
- BEGIN
- SET NOCOUNT ON
- --获取待执行的数据 preRefreshDateTime<DATEADD(minute,1,getdate()) AND refreshType=0 AND runDateTime IS NULL
- SELECT * INTO #t
- FROM JobRefreshLog
- WHERE preRefreshDateTime<=DATEADD(minute,1,getdate()) AND refreshType=0 AND runDateTime IS NULL
-
- --遍历#t
- DECLARE @Id INT, @jobId INT, @cpMainId INT, @orderId INT, @preRefreshDateTime DATETIME --职位,jobrefrshid
-
- --获取所有可用的订单
- SELECT * INTO #tOrder FROM caOrder WITH(NOLOCK)
- WHERE cpMainID IN(SELECT DISTINCT cpMainId FROM #t)
- AND openDate is NOT NULL
- AND endDate >GETDATE()
- AND OrderType IN(8,15)
- AND ISNULL(remainJobRefreshQuota,0) != 0
- ORDER BY endDate
- WHILE EXISTS (SELECT TOP 1 ID FROM #t)
- BEGIN
- SELECT TOP 1 @Id = ID, @jobId = jobid, @cpMainId =cpMainId, @preRefreshDateTime =preRefreshDateTime FROM #t
- 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 )
- BEGIN
- SELECT TOP 1 @orderId = Id
- FROM #tOrder
- WHERE cpMainId = @cpMainId
- AND openDate is NOT NULL
- AND endDate >GETDATE()
- AND OrderType IN(8,15)
- AND ISNULL(remainJobRefreshQuota,0) != 0
- ORDER BY endDate
- --更新订单
- UPDATE caorder SET remainJobRefreshQuota =remainJobRefreshQuota -1
- WHERE id = @orderId
- --更新jobrefreshlog,
- UPDATE jobrefreshlog
- SET runDateTime =GETDATE(), orderId = @orderId
- WHERE ID =@Id
- --更新job refrshdate
- UPDATE job
- SET RefreshDate= @preRefreshDateTime
- WHERE id =@jobId
-
- END
- ELSE
- BEGIN
- DELETE FROM jobrefreshlog WHERE ID= @Id
- END
- DELETE FROM #t WHERE ID= @Id
- END
- DROP TABLE #tOrder
- DROP TABLE #t
- SET NOCOUNT OFF
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobRefreshLogInsertByJobId] Script Date: 2018/12/13 19:07:07 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- ---职位刷新数手动刷新
- ---harry
- ---返回值 -1 可用刷新数不够,其它为刷新成功数量
- ---2017-11-2
- CREATE PROCEDURE [dbo].[ccJobRefreshLogInsertByJobId]
- (
- @jobIds VARCHAR(200),
- @caMainId INT,
- @cpMainId INT
- )
- AS
- BEGIN
- --职位id
- DECLARE @jobId INT
- DECLARE @jobInfo NVARCHAR(200)
- DECLARE @TjobId AS TABLE(jobId INT, jobInfo NVARCHAR(200))
- INSERT INTO @TjobId (jobId)
- SELECT * FROM dbo.fnSplit(@jobIds, ',')
- --更新职位信息
- UPDATE @TjobId
- SET jobInfo= (SELECT name+','+ b.FullName FROM job a WITH(NOLOCK), dcregion b WITH(NOLOCK) WHERE a.id = jobId AND a.dcregionid = b.id)
-
- --判断是否可用
- CREATE TABLE #temp(availableNumber INT)
- INSERT INTO #temp EXEC ccCaorderByremainJobRefreshQuotaSelect @cpMainId, @caMainId, @jobIds
-
- DECLARE @availableNumber INT
- SELECT TOP 1 @availableNumber = availableNumber FROM #temp
- IF @availableNumber=0 OR @availableNumber< (SELECT COUNT(1) FROM @TjobId)
- BEGIN
- DROP TABLE #temp
- SELECT -1 AS result
- END
- ELSE
- BEGIN
- --获取所有可用的订单
- SELECT * INTO #tOrder FROM caOrder WITH(NOLOCK)
- WHERE cpMainID = @cpMainID
- AND openDate is NOT NULL
- AND endDate >GETDATE()
- AND OrderType IN(8,15)
- AND ISNULL(remainJobRefreshQuota,0) != 0
- AND IsDeleted !=1
- ORDER BY endDate
-
- DECLARE @successNum INT
- SELECT @successNum = 0
- DECLARE @caoderId INT, @remainJobRefreshQuota INT
- WHILE EXISTS(SELECT TOP 1 id FROM #tOrder) AND EXISTS(SELECT 'x' FROM @TjobId)
- BEGIN
- SELECT TOP 1 @caoderId = id, @remainJobRefreshQuota = remainJobRefreshQuota FROM #tOrder ORDER BY endDate
- WHILE @remainJobRefreshQuota > 0 AND EXISTS(SELECT 'x' FROM @TjobId)
- BEGIN
- SELECT TOP 1 @jobId =jobId, @jobInfo = jobInfo FROM @TjobId
- ---插入刷新log
- INSERT INTO jobRefreshLog(orderId, jobId, jobInfo, refreshType,preRefreshDateTime, runDateTime, operateMan, cpMainId)
- SELECT @caoderId, @jobId, @jobInfo, 1, GETDATE(), GETDATE(), @caMainId,@cpMainId
- ---更新刷新时间
- UPDATE job SET refreshDate = GETDATE() WHERE id = @jobId
- --刷新数减去1
- UPDATE caorder SET remainJobRefreshQuota= remainJobRefreshQuota-1 WHERE id =@caoderId
- SELECT @remainJobRefreshQuota=@remainJobRefreshQuota-1
- DELETE FROM @TjobId WHERE jobId = @jobId
- --成功数+1
- SELECT @successNum = @successNum+1
- END
- DELETE FROM #tOrder WHERE id = @caoderId
- END
- DROP TABLE #temp
- DROP TABLE #tOrder
- SELECT @successNum AS result
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobRefreshSetByRunStateSelect] Script Date: 2018/12/13 19:07:08 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --过滤掉正在刷新数定制中的职位,返回未定制的职位信息
- --harry
- --2017-11-6
- CREATE PROCEDURE [dbo].[ccJobRefreshSetByRunStateSelect]
- (
- @jobIds VARCHAR(200)
- )
- AS
- BEGIN
- --职位id
- DECLARE @TjobId AS TABLE(jobId INT)
-
- INSERT INTO @TjobId (jobId)
- SELECT * FROM dbo.fnSplit(@jobIds, ',')
-
- --校正定制刷新的状态
- UPDATE a SET a.runState =0
- FROM jobRefreshSet a
- 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 )
- DELETE FROM @TjobId WHERE jobId IN( SELECT jobId FROM JobRefreshSet WHERE jobId IN(SELECT jobId FROM @TjobId ) AND runState = 1)--删除定制中的jobid
-
- SELECT jobId FROM @TjobId --返回非定制中的职位id,最大开始时间 最小结束时间
- SELECT MAX(IssueDate) AS MaxIssueDate ,MIN(IssueEnd) AS MinIssueEnd
- FROM job WHERE id in(select jobId FROM @TjobId) AND valid=1
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobRefreshSetInsert] Script Date: 2018/12/13 19:07:08 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --刷新数定制刷新设置
- --harry
- --2017-11-3
- CREATE PROCEDURE [dbo].[ccJobRefreshSetInsert]
- (
- @beginDate SMALLDATETIME,
- @endDate SMALLDATETIME,
- @refreshType TINYINT, --1d 2week
- @weekDays CHAR(13),
- @hours VARCHAR(100),
- @minute INT,
- @jobIds VARCHAR(200),
- @caMainId INT,
- @cpMainId INT
- )
- AS
- BEGIN
- --职位id
- DECLARE @jobId INT, @jobRefreshSetId INT
- DECLARE @TjobId AS TABLE(jobId INT)
- INSERT INTO @TjobId (jobId)
- SELECT * FROM dbo.fnSplit(@jobIds, ',')
-
- WHILE EXISTS (SELECT TOP 1 jobid FROM @TjobId)
- BEGIN
- SELECT TOP 1 @jobId = jobid FROM @TjobId
- IF NOT EXISTS(SELECT 'x' FROM jobRefreshset WITH(NOLOCK) WHERE jobid = @jobId AND runState =1 )--排除定制中的职位
- BEGIN
- DELETE FROM jobRefreshset WHERE jobid = @jobId AND runState = 0
- INSERT INTO jobRefreshset(beginDate, endDate, refreshType, weekDays,[hours],[minute], jobId, caMainId, runState, addDate)
- SELECT @beginDate, @endDate, @refreshType, @weekDays, @hours, @minute, @jobId, @caMainId, 1, GETDATE()
- SELECT @jobRefreshSetId =SCOPE_IDENTITY()
- --选取jobrefreshlog_temp表中预插入的数据
- INSERT INTO jobRefreshLog(jobRefreshSetId, jobId, jobInfo, refreshType, preRefreshDateTime, operateMan, cpMainId)
- SELECT @jobRefreshSetId, @jobId, jobInfo,refreshType, preRefreshDateTime, @caMainId, @cpMainId
- FROM jobRefreshLog_temp
- 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
-
- --删除以插入的数据
- DELETE FROM jobRefreshLog_temp
- 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
- END
- DELETE FROM @TjobId WHERE jobid = @jobId
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobRefreshSetSelect] Script Date: 2018/12/13 19:07:08 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --根据职位id获取职位的定制信息
- --harry
- --2017-11-6
- CREATE PROCEDURE [dbo].[ccJobRefreshSetSelect]
- (
- @jobId INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- CREATE TABLE #t
- (
- [refreshType] [tinyint] NULL,
- [weekDays] [char](13) NULL,
- [hours] [varchar](100) NULL,
- [minute] [tinyint] NULL,
- [jobId] [int] NOT NULL,
- [runState] [tinyint] NULL,
- [IssueDate] DATETIME NOT NULL,
- [IssueEnd] DATETIME NOT NULL,
- [beginDate] SMALLDATETIME NULL,
- [endDate] SMALLDATETIME NULL
- )
- --校正定制刷新的状态
- UPDATE a SET a.runState =0
- FROM jobRefreshSet a
- 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 )
- INSERT INTO #t(jobId, IssueDate,IssueEnd)
- SELECT id, IssueDate, IssueEnd FROM job WHERE id = @jobId
-
- IF EXISTS( SELECT 'X' FROM jobRefreshset WHERE jobid = @jobId)
- BEGIN
- UPDATE a
- 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
- FROM #t a, jobRefreshset b
- WHERE a.jobId =b.jobId AND b.Id =(SELECT TOP 1 id FROM jobRefreshset WHERE jobid = @jobId ORDER BY addDate DESC,ID DESC)
-
- END
- SELECT * FROM #t
- DROP TABLE #t
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobRefrshSetUpdate] Script Date: 2018/12/13 19:07:08 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --停止职位刷新的定制
- --harry
- --2017-11-3
- CREATE PROCEDURE [dbo].[ccJobRefrshSetUpdate]
- (
- @jobIds VARCHAR(200),
- @cpMainId INT
- )
- AS
- BEGIN
- --职位id
- DECLARE @jobId INT, @usedRefreshNum INT , @setId INT
- DECLARE @TjobId AS TABLE(jobId INT)
- DECLARE @TsetId AS TABLE(setId INT)
- INSERT INTO @TjobId (jobId)
- SELECT * FROM dbo.fnSplit(@jobIds, ',')
- INSERT INTO @TsetId(setId)
- SELECT id FROM jobRefreshSet WHERE jobId IN(SELECT jobId FROM @TjobId) AND runState =1
- --设置set runState =0
- UPDATE jobRefreshSet SET runState = 0 WHERE id IN(select setId FROM @TsetId) AND runState =1
- --删除未执行的定制刷新
- DELETE FROM jobRefreshLog WHERE runDateTime IS NULL AND jobRefreshSetId IN(select setId FROM @TsetId) AND refreshType =0
- --计算使用的刷新数
- 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)
-
- --返回使用的刷新数
- SELECT @usedRefreshNum AS usedRefreshNum
-
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccjobReportDataSelectByCpMainId] Script Date: 2018/12/13 19:07:08 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --职位发布效果统计
- --harry
- --2017-11-27
- CREATE PROCEDURE [dbo].[ccjobReportDataSelectByCpMainId]
- (
- @cpMainId INT,
- @beginDate INT,
- @endDate INT,
- @caMainId INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- IF @caMainId = 0
- BEGIN
- SELECT b.name, a.jobid, a.countdate,SUM(applycount) applycount,SUM(viewcount) viewcount,SUM(interview) interview,
- SUM(interviewreply) interviewreply,SUM(interviewresult) interviewresult
- FROM ReportDB..jobReportData a WITH(NOLOCK),job b WITH(NOLOCK)
- WHERE a.countdate>=@beginDate
- AND a.countdate<= @endDate
- AND a.jobid =b.id
- AND a.jobid in (
- (
- SELECT id FROM Job with(nolock)
- WHERE isdelete=0
- AND cpmainid= @cpMainId
- ) union (
- SELECT jobid id
- FROM JobDeleted WITH(NOLOCK)
- WHERE cpmainid= @cpMainId
- )
- )
- GROUP BY a.jobid,a.countdate,b.name
- ORDER BY a.countdate
- END
- ELSE
- BEGIN
- SELECT b.name, a.jobid, a.countdate,SUM(applycount) applycount,SUM(viewcount) viewcount,SUM(interview) interview,
- SUM(interviewreply) interviewreply,SUM(interviewresult) interviewresult
- FROM ReportDB..jobReportData a WITH(NOLOCK),job b WITH(NOLOCK)
- WHERE a.countdate>=@beginDate
- AND a.countdate<= @endDate
- AND a.jobid =b.id
- AND a.jobid in (
- (
- SELECT id FROM Job with(nolock)
- WHERE isdelete=0
- AND camainid= @caMainId
- ) union (
- SELECT jobid id
- FROM JobDeleted WITH(NOLOCK)
- WHERE camainid= @caMainId
- )
- )
- GROUP BY a.jobid,a.countdate,b.name
- ORDER BY a.countdate
- END
- END
- SET NOCOUNT OFF
- GO
- /****** Object: StoredProcedure [dbo].[ccJobSave] Script Date: 2018/12/13 19:07:08 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --nick 20130815 update
- --去掉filtercvmainid相关内容
- --Peter 2016-10-31修改 订阅方式的修改
- -- 应该已经被ccjobsavenew取代了
- CREATE PROCEDURE [dbo].[ccJobSave]
- (
- @OperatorID INT,
- @ID INT,
- @cpMainID INT,
- @caMainID INT,
- @Name VARCHAR(50),
- @dcJobTypeID INT,
- @dcJobTypeIDMinor INT,
- @NeedNumber SMALLINT,
- @dcSalaryID TINYINT,
- @EmployType TINYINT,
- @dcRegionID VARCHAR(6),
- @Lng DECIMAL(8, 5),
- @Lat DECIMAL(8, 5),
- @Responsibility VARCHAR(MAX),
- @Demand VARCHAR(MAX),
- @dcEducationID TINYINT,
- @MinExperience TINYINT,
- @MinAge TINYINT,
- @MaxAge TINYINT,
- @EMailSendFreq VARCHAR(7),
- @EMailSendNumber TINYINT,
- --屏蔽简历相关
- @FilterMaxDegree TINYINT,
- @FilterMinDegree TINYINT,
- @FilterMaxWorkYear TINYINT,
- @FilterMinWorkYear TINYINT,
- @FilterMaxAge TINYINT,
- @FilterMinAge TINYINT,
- @FilterGender VARCHAR(1),
- @FilterJobRegion VARCHAR(6),
- @ForwardEmail VARCHAR(100)
- )
- AS
- return
- SET NOCOUNT ON
- IF @dcRegionID NOT LIKE '[0-9]%'
- RETURN -1
- IF ISNULL(@dcSalaryID, 0) = 0
- SET @dcSalaryID = 100
- IF ISNULL(@dcEducationID, 0) = 0
- SET @dcEducationID = 100
- BEGIN TRAN
- BEGIN TRY
- SET @Name = dbo.TrimNull(@Name)
- IF @Name IS NULL
- GOTO Err
- -- Can Not Name Repeat
- IF @cpMainID <> 10576676
- BEGIN
- IF EXISTS(SELECT 'x' FROM Job WITH(NOLOCK)
- WHERE Name = @Name
- AND dcRegionId = @dcRegionID
- AND cpMainId = @CpMainId
- AND ID <> ISNULL(@ID, 0)
- AND IsDelete = 0)
- GOTO Err1
- END
- SET @Responsibility = REPLACE(dbo.TextTrim(@Responsibility), '', '')
- SET @Demand = REPLACE(dbo.TextTrim(@Demand), '', '')
- IF CHARINDEX(', ', @Name) > 0
- SELECT @Name = REPLACE(@Name, ',', ',')
- DECLARE @MaxID AS INT
- IF @ID>0
- BEGIN
- IF @OperatorID <> (SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID AND AccountType = 1) AND @OperatorID<>@caMainID
- RETURN 0
- DECLARE @NameOld AS NVARCHAR(60), @ResponsibilityOld AS VARCHAR(MAX),
- @DemandOld AS VARCHAR(MAX), @IsVerify AS BIT
- SELECT @NameOld = dbo.TextTrim(ISNULL(Name, '')), @ResponsibilityOld = ISNULL(Responsibility, ''),
- @DemandOld = ISNULL(Demand, '')
- FROM Job WITH(NOLOCK)
- WHERE ID = @ID
- UPDATE Job SET
- Name = @Name,
- dcJobTypeID = @dcJobTypeID,
- dcJobTypeIDMinor = @dcJobTypeIDMinor,
- NeedNumber = @NeedNumber,
- dcSalaryID = @dcSalaryID,
- EmployType = @EmployType,
- dcRegionID = @dcRegionID,
- Lng = @Lng,
- Lat = @Lat,
- Responsibility = @Responsibility,
- Demand = @Demand,
- dcEducationID = @dcEducationID,
- MinExperience = @MinExperience,
- MinAge = @MinAge,
- MaxAge = @MaxAge,
- EMailSendFreq = dbo.BinToINT(@EMailSendFreq),
- RefreshDate = GETDATE(),
- LastModifyDate = GETDATE(),
- FilterMaxDegree = @FilterMaxDegree,
- FilterMinDegree = @FilterMinDegree,
- FilterMaxWorkYear = @FilterMaxWorkYear,
- FilterMinWorkYear = @FilterMinWorkYear,
- FilterMaxAge = @FilterMaxAge,
- FilterMinAge = @FilterMinAge,
- FilterGender = @FilterGender,
- FilterJobRegion = @FilterJobRegion,
- ForwardEmail = @ForwardEmail
- WHERE ID = @ID
- SET @MaxID = @ID
- SET @IsVerify = 0
- IF @NameOld <> dbo.TextTrim(@Name)
- BEGIN
- DELETE FROM bsCpModify WHERE SubId = @ID AND Location = 'c1'
- INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @ID, 'c1', @Name)
- SET @IsVerify = 1
- END
- IF @ResponsibilityOld <> @Responsibility
- BEGIN
- DELETE FROM bsCpModify WHERE SubId = @ID AND Location = 'c2'
- INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @ID, 'c2', @Responsibility)
- SET @IsVerify = 1
- END
- IF @DemandOld <> @Demand
- BEGIN
- DELETE FROM bsCpModify WHERE SubId = @ID AND Location = 'c3'
- INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @ID, 'c3', @Demand)
- SET @IsVerify = 1
- END
- END
- ELSE
- BEGIN
- INSERT INTO Job
- (
- cpMainID, caMainID, Name, dcJobTypeID, dcJobTypeIDMinor,
- NeedNumber, dcSalaryID, EmployType, dcRegionID, Lng, Lat,
- Responsibility, Demand, dcEducationID, MinExperience,
- MinAge, MaxAge, EMailSendFreq,
- AddDate, LastModifyDate, RefreshDate, IssueDate, IssueEnd,
- FilterMaxDegree, FilterMinDegree, FilterMaxWorkYear, FilterMinWorkYear,
- FilterMaxAge, FilterMinAge, FilterGender, FilterJobRegion,
- ForwardEmail
- )
- VALUES
- (
- @cpMainID, @caMainID, @Name, @dcJobTypeID, @dcJobTypeIDMinor,
- @NeedNumber, @dcSalaryID, @EmployType, @dcRegionID, @Lng, @Lat,
- @Responsibility, @Demand, @dcEducationID, @MinExperience,
- @MinAge, @MaxAge, dbo.BinToINT(@EMailSendFreq),
- GETDATE(), GETDATE(), GETDATE(), GETDATE(), DATEADD(MONTH, 2, GETDATE()),
- @FilterMaxDegree, @FilterMinDegree, @FilterMaxWorkYear, @FilterMinWorkYear,
- @FilterMaxAge, @FilterMinAge, @FilterGender, @FilterJobRegion,
- @ForwardEmail
- )
- SET @MaxID = @@IDENTITY
- INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @MaxID, 'c1', @Name)
- INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @MaxID, 'c2', @Responsibility)
- INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @MaxID, 'c3', @Demand)
- SET @IsVerify = 1
- END
-
- END TRY
- BEGIN CATCH
- GOTO ERR
- END CATCH
- COMMIT TRAN
- RETURN @MaxID
- ERR:
- BEGIN
- --insert into a_tmp select ERROR_MESSAGE(), getdate()
- ROLLBACK TRAN
- RETURN 0
- END
- RETURN @MaxID
- ERR1:
- BEGIN
- --insert into a_tmp select ERROR_MESSAGE(), getdate()
- ROLLBACK TRAN
- RETURN -1
- END
- SET NOCOUNT OFF
- GO
- /****** Object: StoredProcedure [dbo].[ccJobSaveNew] Script Date: 2018/12/13 19:07:09 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --nick 20130815 update
- --去掉filtercvmainid相关内容
- --Peter 2016-10-31修改 订阅方式的修改
- --Lucifer 2017-3-21修改 月薪改为范围,添加可面议
- CREATE PROCEDURE [dbo].[ccJobSaveNew]
- (
- @OperatorID INT,
- @ID INT,
- @cpMainID INT,
- @caMainID INT,
- @Name VARCHAR(50),
- @dcJobTypeID INT,
- @dcJobTypeIDMinor INT,
- @NeedNumber SMALLINT,
- @dcSalaryID TINYINT,
- @EmployType TINYINT,
- @dcRegionID VARCHAR(6),
- @Lng DECIMAL(8, 5),
- @Lat DECIMAL(8, 5),
- @Responsibility VARCHAR(MAX),
- @Demand VARCHAR(MAX),
- @dcEducationID TINYINT,
- @MinExperience TINYINT,
- @MinAge TINYINT,
- @MaxAge TINYINT,
- @EMailSendFreq VARCHAR(7),
- @EMailSendNumber TINYINT,
- --屏蔽简历相关
- @FilterMaxDegree TINYINT,
- @FilterMinDegree TINYINT,
- @FilterMaxWorkYear TINYINT,
- @FilterMinWorkYear TINYINT,
- @FilterMaxAge TINYINT,
- @FilterMinAge TINYINT,
- @FilterGender VARCHAR(1),
- @FilterJobRegion VARCHAR(6),
- @ForwardEmail VARCHAR(100),
- @dcSalaryMaxID TINYINT,
- @Negotiable BIT
- )
- AS
- SET NOCOUNT ON
- IF @dcRegionID NOT LIKE '[0-9]%'
- RETURN -1
- IF ISNULL(@dcSalaryID, 0) = 0
- SET @dcSalaryID = 100
- IF ISNULL(@dcEducationID, 0) = 0
- SET @dcEducationID = 100
- BEGIN TRAN
- SET @Name = dbo.TrimNull(@Name)
- IF @Name IS NULL
- GOTO Err
- -- Can Not Name Repeat
- IF @cpMainID <> 10576676
- BEGIN
- IF EXISTS(SELECT 'x' FROM Job WITH(NOLOCK)
- WHERE Name = @Name
- AND dcRegionId = @dcRegionID
- AND cpMainId = @CpMainId
- AND ID <> ISNULL(@ID, 0)
- AND IsDelete = 0)
- GOTO Err1
- END
- SET @Responsibility = REPLACE(dbo.TextTrim(@Responsibility), '', '')
- SET @Demand = REPLACE(dbo.TextTrim(@Demand), '', '')
- IF CHARINDEX(', ', @Name) > 0
- SELECT @Name = REPLACE(@Name, ',', ',')
- DECLARE @MaxID AS INT
- IF @ID>0
- BEGIN
- IF @OperatorID <> (SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID AND AccountType = 1) AND @OperatorID<>@caMainID
- RETURN 0
- DECLARE @NameOld AS NVARCHAR(60), @ResponsibilityOld AS VARCHAR(MAX),
- @DemandOld AS VARCHAR(MAX), @IsVerify AS BIT
- SELECT @NameOld = dbo.TextTrim(ISNULL(Name, '')), @ResponsibilityOld = ISNULL(Responsibility, ''),
- @DemandOld = ISNULL(Demand, '')
- FROM Job WITH(NOLOCK)
- WHERE ID = @ID
- UPDATE Job SET
- Name = @Name,
- dcJobTypeID = @dcJobTypeID,
- dcJobTypeIDMinor = @dcJobTypeIDMinor,
- NeedNumber = @NeedNumber,
- dcSalaryID = @dcSalaryID,
- EmployType = @EmployType,
- dcRegionID = @dcRegionID,
- Lng = @Lng,
- Lat = @Lat,
- Responsibility = @Responsibility,
- Demand = @Demand,
- dcEducationID = @dcEducationID,
- MinExperience = @MinExperience,
- MinAge = @MinAge,
- MaxAge = @MaxAge,
- EMailSendFreq = dbo.BinToINT(@EMailSendFreq),
- RefreshDate = GETDATE(),
- LastModifyDate = GETDATE(),
- FilterMaxDegree = @FilterMaxDegree,
- FilterMinDegree = @FilterMinDegree,
- FilterMaxWorkYear = @FilterMaxWorkYear,
- FilterMinWorkYear = @FilterMinWorkYear,
- FilterMaxAge = @FilterMaxAge,
- FilterMinAge = @FilterMinAge,
- FilterGender = @FilterGender,
- FilterJobRegion = @FilterJobRegion,
- ForwardEmail = @ForwardEmail,
- dcSalaryIdMax = @dcSalaryMaxID,
- Negotiable = @Negotiable
- WHERE ID = @ID
- SET @MaxID = @ID
- SET @IsVerify = 0
- IF @NameOld <> dbo.TextTrim(@Name)
- BEGIN
- DELETE FROM bsCpModify WHERE SubId = @ID AND Location = 'c1'
- INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @ID, 'c1', @Name)
- SET @IsVerify = 1
- END
- IF @ResponsibilityOld <> @Responsibility
- BEGIN
- DELETE FROM bsCpModify WHERE SubId = @ID AND Location = 'c2'
- INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @ID, 'c2', @Responsibility)
- SET @IsVerify = 1
- END
- IF @DemandOld <> @Demand
- BEGIN
- DELETE FROM bsCpModify WHERE SubId = @ID AND Location = 'c3'
- INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @ID, 'c3', @Demand)
- SET @IsVerify = 1
- END
- END
- ELSE
- BEGIN
- INSERT INTO Job
- (
- cpMainID, caMainID, Name, dcJobTypeID, dcJobTypeIDMinor,
- NeedNumber, dcSalaryID, EmployType, dcRegionID, Lng, Lat,
- Responsibility, Demand, dcEducationID, MinExperience,
- MinAge, MaxAge, EMailSendFreq,
- AddDate, LastModifyDate, RefreshDate, IssueDate, IssueEnd,
- FilterMaxDegree, FilterMinDegree, FilterMaxWorkYear, FilterMinWorkYear,
- FilterMaxAge, FilterMinAge, FilterGender, FilterJobRegion,
- ForwardEmail, dcSalaryIdMax, Negotiable
- )
- VALUES
- (
- @cpMainID, @caMainID, @Name, @dcJobTypeID, @dcJobTypeIDMinor,
- @NeedNumber, @dcSalaryID, @EmployType, @dcRegionID, @Lng, @Lat,
- @Responsibility, @Demand, @dcEducationID, @MinExperience,
- @MinAge, @MaxAge, dbo.BinToINT(@EMailSendFreq),
- GETDATE(), GETDATE(), GETDATE(), GETDATE(), DATEADD(MONTH, 2, GETDATE()),
- @FilterMaxDegree, @FilterMinDegree, @FilterMaxWorkYear, @FilterMinWorkYear,
- @FilterMaxAge, @FilterMinAge, @FilterGender, @FilterJobRegion,
- @ForwardEmail, @dcSalaryMaxID, @Negotiable
- )
- SET @MaxID = @@IDENTITY
- INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @MaxID, 'c1', @Name)
- INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @MaxID, 'c2', @Responsibility)
- INSERT INTO bsCpModify (cpMainID, caMainID, SubID, Location, ColValue) VALUES (@cpMainID, @caMainID, @MaxID, 'c3', @Demand)
- SET @IsVerify = 1
- END
- COMMIT TRAN
- RETURN @MaxID
- ERR:
- BEGIN
- --insert into a_tmp select ERROR_MESSAGE(), getdate()
- ROLLBACK TRAN
- RETURN 0
- END
- RETURN @MaxID
- ERR1:
- BEGIN
- --insert into a_tmp select ERROR_MESSAGE(), getdate()
- ROLLBACK TRAN
- RETURN -1
- END
- SET NOCOUNT OFF
- GO
- /****** Object: StoredProcedure [dbo].[ccJobSelect] Script Date: 2018/12/13 19:07:09 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccJobSelect]
- (
- @ID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- SELECT *
- FROM Job WITH(NOLOCK)
- WHERE ID = @ID
- AND IsDelete = 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobTemplateBycaMainIDSelect] Script Date: 2018/12/13 19:07:10 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccJobTemplateBycaMainIDSelect]
- @caMainID INT
- AS
- BEGIN
- SELECT a.*, b.FullName Region,dbo.Int2Bin(EMailSendFreq) PushFreq,
- ISNULL((SELECT Description FROM dcEducation WHERE Id = dcEducationId), '不限') Education,
- e.Description JobTypeName,f.Description JobTypeMinorName,g.Description NeedNumName,h.Description EmployTypeName,
- i.Description ExperienceName,j.DescriptionCp SalaryName,k.DescriptionCp SalaryMaxName
- FROM JobTemplate a WITH(NOLOCK)
- LEFT JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionID = b.ID
- LEFT JOIN caOnline c WITH(NOLOCK) ON a.caMainId = c.caMainId
- LEFT JOIN dcJobType e WITH(NOLOCK) ON a.dcJobTypeId = e.ID
- LEFT JOIN dcJobType f WITH(NOLOCK) ON a.dcJobTypeIdMinor = f.ID
- LEFT JOIN dcOthers g WITH(NOLOCK) ON a.NeedNumber = g.DetailID AND g.Category = '招聘人数'
- LEFT JOIN dcOthers h WITH(NOLOCK) ON a.EmployType = h.DetailID AND h.Category = '工作性质'
- LEFT JOIN dcOthers i WITH(NOLOCK) ON a.MinExperience = i.DetailID AND i.Category = '职位要求工作经验'
- LEFT JOIN dcSalary j WITH(NOLOCK) ON a.dcSalaryId = j.ID
- LEFT JOIN dcSalary k WITH(NOLOCK) ON a.dcSalaryIdMax = k.ID
- WHERE a.caMainID = @caMainID
- ORDER BY a.ID DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobTemplateByMapBarUpdate] Script Date: 2018/12/13 19:07:10 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccJobTemplateByMapBarUpdate]
- @ID INT,
- @Lng VARCHAR(20),
- @Lat VARCHAR(20),
- @cpMainID INT
- AS
- BEGIN
- UPDATE JobTemplate SET Lng=@Lng,Lat=@Lat WHERE ID=@ID AND cpMainID=@cpMainID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobTemplateDelete] Script Date: 2018/12/13 19:07:10 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccJobTemplateDelete]
- (
- @ID INT,
- @caMainID INT
- )
- AS
- BEGIN TRAN
- DECLARE @caID AS INT
- DECLARE @AccountType AS INT
- DECLARE @cpMainID AS INT
- DECLARE @cpID AS INT
- SELECT @caID=caMainId ,@cpID = cpMainID FROM JobTemplate WITH(NOLOCK) WHERE ID = @ID AND caMainID = @caMainID
- SELECT @AccountType=AccountType,@cpMainID=cpMainID FROM caMain WITH(NOLOCK) WHERE id = @caMainID
- IF @caID Is NUll
- GOTO ERR1
- IF @caID != @caMainID
- BEGIN
- IF @AccountType != 1
- GOTO ERR2
- IF @cpMainID != @cpID
- GOTO ERR2
- END
- IF @caID Is NUll
- GOTO ERR1
- IF @caID != @caMainID
- GOTO ERR2
- DELETE FROM JobTemplate WHERE ID = @ID
- IF @@ERROR <>0
- GOTO ERR
- COMMIT TRAN
- RETURN 1
- ERR:
- BEGIN
- ROLLBACK TRAN
- RETURN 0
- END
- ERR1:
- BEGIN
- ROLLBACK TRAN
- RETURN -1
- END
- ERR2:
- BEGIN
- ROLLBACK TRAN
- RETURN -2
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobTemplateMapBarIDUpdate] Script Date: 2018/12/13 19:07:10 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- -- =============================================
- -- Author: <Author,,Name>
- -- Create date: <Create Date,,>
- -- Description: <Description,,>
- -- =============================================
- CREATE PROCEDURE [dbo].[ccJobTemplateMapBarIDUpdate]
- @ID INT,
- @MapBarID VARCHAR(50),
- @cpMainID INT
- AS
- BEGIN
- UPDATE JobTemplate SET MapBarID=@MapBarID WHERE ID=@ID AND cpMainID = @cpMainID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobTemplateSave] Script Date: 2018/12/13 19:07:10 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --修改职位模板
- --Peter 2016-10-31修改 修改职位订阅的订阅方式
- CREATE PROCEDURE [dbo].[ccJobTemplateSave]
- (
- @ID INT,
- @cpMainID INT,
- @caMainID INT,
- @Name VARCHAR(50),
- @dcJobTypeID INT,
- @dcJobTypeIDMinor INT,
- @NeedNumber SMALLINT,
- @dcSalaryID TINYINT,
- @EmployType TINYINT,
- @dcRegionID VARCHAR(6),
- @Lng DECIMAL(8, 5),
- @Lat DECIMAL(8, 5),
- @Responsibility VARCHAR(MAX),
- @DemAND VARCHAR(MAX),
- @dcEducationID TINYINT,
- @MinExperience TINYINT,
- @MinAge TINYINT,
- @MaxAge TINYINT,
- @EMailSendFreq VARCHAR(7),
- @EMailSendNumber TINYINT
- )
- AS
- SELECT @Responsibility = dbo.SafeSql(@Responsibility), @Demand = dbo.SafeSql(@Demand)
- BEGIN TRY
- IF @ID>0
- BEGIN
- UPDATE JobTemplate SET
- Name = @Name,
- dcJobTypeID = @dcJobTypeID,
- dcJobTypeIDMinor = @dcJobTypeIDMinor,
- NeedNumber = @NeedNumber,
- dcSalaryID = @dcSalaryID,
- EmployType = @EmployType,
- dcRegionID = @dcRegionID,
- Lng = @Lng,
- Lat = @Lat,
- Responsibility = @Responsibility,
- DemAND = @Demand,
- dcEducationID = @dcEducationID,
- MinExperience = @MinExperience,
- MinAge = @MinAge,
- MaxAge = @MaxAge,
- EMailSendFreq = dbo.BinToINT(@EMailSendFreq),
- LastModifyDate = GETDATE()
- WHERE ID=@ID
- AND caMainID = @caMainID
- End
- ELSE
- BEGIN
- INSERT INTO JobTemplate
- (
- cpMainID,caMainID,Name,dcJobTypeID,dcJobTypeIDMinor,
- NeedNumber,dcSalaryID,EmployType,dcRegionID,Lng,Lat,
- Responsibility,Demand,dcEducationID,MinExperience,
- MinAge,MaxAge,EMailSendFreq,
- AddDate,LastModifyDate
- )
- VALUES
- (
- @cpMainID,@caMainID,@Name,@dcJobTypeID,@dcJobTypeIDMinor,
- @NeedNumber,@dcSalaryID,@EmployType,@dcRegionID,@Lng,@Lat,
- @Responsibility,@Demand,@dcEducationID,@MinExperience,
- @MinAge,@MaxAge,dbo.BinToINT(@EMailSendFreq),
- GETDATE(),GETDATE()
- )
- END
- END TRY
- BEGIN CATCH
- GOTO ERR
- END CATCH
- RETURN 1
- ERR:
- BEGIN
- RETURN 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobTemplateSave2] Script Date: 2018/12/13 19:07:10 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --修改职位模板
- --Peter 2016-10-31修改 修改职位订阅的订阅方式
- --Peter 2017-2-7修改 添加职位标签保存
- CREATE PROCEDURE [dbo].[ccJobTemplateSave2]
- (
- @ID INT,
- @cpMainID INT,
- @caMainID INT,
- @Name VARCHAR(50),
- @dcJobTypeID INT,
- @dcJobTypeIDMinor INT,
- @NeedNumber SMALLINT,
- @dcSalaryID TINYINT,
- @EmployType TINYINT,
- @dcRegionID VARCHAR(6),
- @Lng DECIMAL(8, 5),
- @Lat DECIMAL(8, 5),
- @Responsibility VARCHAR(MAX),
- @DemAND VARCHAR(MAX),
- @dcEducationID TINYINT,
- @MinExperience TINYINT,
- @MinAge TINYINT,
- @MaxAge TINYINT,
- @EMailSendFreq VARCHAR(7),
- @EMailSendNumber TINYINT,
- @JobTags NVARCHAR(100)
- )
- AS
- SELECT @Responsibility = dbo.SafeSql(@Responsibility), @Demand = dbo.SafeSql(@Demand)
- BEGIN TRY
- IF @ID>0
- BEGIN
- UPDATE JobTemplate SET
- Name = @Name,
- dcJobTypeID = @dcJobTypeID,
- dcJobTypeIDMinor = @dcJobTypeIDMinor,
- NeedNumber = @NeedNumber,
- dcSalaryID = @dcSalaryID,
- EmployType = @EmployType,
- dcRegionID = @dcRegionID,
- Lng = @Lng,
- Lat = @Lat,
- Responsibility = @Responsibility,
- DemAND = @Demand,
- dcEducationID = @dcEducationID,
- MinExperience = @MinExperience,
- MinAge = @MinAge,
- MaxAge = @MaxAge,
- EMailSendFreq = dbo.BinToINT(@EMailSendFreq),
- LastModifyDate = GETDATE(),
- JobTags = @JobTags
- WHERE ID=@ID
- AND caMainID = @caMainID
- End
- ELSE
- BEGIN
- INSERT INTO JobTemplate
- (
- cpMainID,caMainID,Name,dcJobTypeID,dcJobTypeIDMinor,
- NeedNumber,dcSalaryID,EmployType,dcRegionID,Lng,Lat,
- Responsibility,Demand,dcEducationID,MinExperience,
- MinAge,MaxAge,EMailSendFreq,
- AddDate,LastModifyDate,JobTags
- )
- VALUES
- (
- @cpMainID,@caMainID,@Name,@dcJobTypeID,@dcJobTypeIDMinor,
- @NeedNumber,@dcSalaryID,@EmployType,@dcRegionID,@Lng,@Lat,
- @Responsibility,@Demand,@dcEducationID,@MinExperience,
- @MinAge,@MaxAge,dbo.BinToINT(@EMailSendFreq),
- GETDATE(),GETDATE(),@JobTags
- )
- END
- END TRY
- BEGIN CATCH
- GOTO ERR
- END CATCH
- RETURN 1
- ERR:
- BEGIN
- RETURN 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobTemplateSaveNew] Script Date: 2018/12/13 19:07:11 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --修改职位模板
- --Peter 2016-10-31修改 修改职位订阅的订阅方式
- --Peter 2017-2-7修改 添加职位标签保存
- --Lucifer 2017-3-21修改 月薪改为范围,添加可面议
- CREATE PROCEDURE [dbo].[ccJobTemplateSaveNew]
- (
- @ID INT,
- @cpMainID INT,
- @caMainID INT,
- @Name VARCHAR(50),
- @dcJobTypeID INT,
- @dcJobTypeIDMinor INT,
- @NeedNumber SMALLINT,
- @dcSalaryID TINYINT,
- @EmployType TINYINT,
- @dcRegionID VARCHAR(6),
- @Lng DECIMAL(8, 5),
- @Lat DECIMAL(8, 5),
- @Responsibility VARCHAR(MAX),
- @DemAND VARCHAR(MAX),
- @dcEducationID TINYINT,
- @MinExperience TINYINT,
- @MinAge TINYINT,
- @MaxAge TINYINT,
- @EMailSendFreq VARCHAR(7),
- @EMailSendNumber TINYINT,
- @JobTags NVARCHAR(100),
- @dcSalaryMaxID TINYINT,
- @Negotiable BIT
- )
- AS
- SELECT @Responsibility = dbo.SafeSql(@Responsibility), @Demand = dbo.SafeSql(@Demand)
- BEGIN TRY
- IF @ID>0
- BEGIN
- UPDATE JobTemplate SET
- Name = @Name,
- dcJobTypeID = @dcJobTypeID,
- dcJobTypeIDMinor = @dcJobTypeIDMinor,
- NeedNumber = @NeedNumber,
- dcSalaryID = @dcSalaryID,
- EmployType = @EmployType,
- dcRegionID = @dcRegionID,
- Lng = @Lng,
- Lat = @Lat,
- Responsibility = @Responsibility,
- DemAND = @Demand,
- dcEducationID = @dcEducationID,
- MinExperience = @MinExperience,
- MinAge = @MinAge,
- MaxAge = @MaxAge,
- EMailSendFreq = dbo.BinToINT(@EMailSendFreq),
- LastModifyDate = GETDATE(),
- JobTags = @JobTags,
- dcSalaryIDMax = @dcSalaryMaxID,
- Negotiable = @Negotiable
- WHERE ID=@ID
- AND caMainID = @caMainID
- End
- ELSE
- BEGIN
- INSERT INTO JobTemplate
- (
- cpMainID,caMainID,Name,dcJobTypeID,dcJobTypeIDMinor,
- NeedNumber,dcSalaryID,EmployType,dcRegionID,Lng,Lat,
- Responsibility,Demand,dcEducationID,MinExperience,
- MinAge,MaxAge,EMailSendFreq,
- AddDate,LastModifyDate,JobTags,dcSalaryIDMax,Negotiable
- )
- VALUES
- (
- @cpMainID,@caMainID,@Name,@dcJobTypeID,@dcJobTypeIDMinor,
- @NeedNumber,@dcSalaryID,@EmployType,@dcRegionID,@Lng,@Lat,
- @Responsibility,@Demand,@dcEducationID,@MinExperience,
- @MinAge,@MaxAge,dbo.BinToINT(@EMailSendFreq),
- GETDATE(),GETDATE(),@JobTags,@dcSalaryMaxID,@Negotiable
- )
- END
- END TRY
- BEGIN CATCH
- GOTO ERR
- END CATCH
- RETURN 1
- ERR:
- BEGIN
- RETURN 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccJobTemplateSelect] Script Date: 2018/12/13 19:07:11 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --Peter 2016-10-31修改职位订阅内容展现
- CREATE PROCEDURE [dbo].[ccJobTemplateSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT a.*, b.FullName Region,dbo.Int2Bin(EMailSendFreq) PushFreq,
- ISNULL((SELECT Description FROM dcEducation WHERE Id = dcEducationId), '不限') Education,
- e.Description JobTypeName,f.Description JobTypeMinorName,g.Description NeedNumName,h.Description EmployTypeName,
- i.Description ExperienceName,j.DescriptionCp SalaryName,k.DescriptionCp SalaryMaxName
- FROM JobTemplate a WITH(NOLOCK)
- LEFT JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionID = b.ID
- LEFT JOIN caOnline c WITH(NOLOCK) ON a.caMainId = c.caMainId
- LEFT JOIN dcJobType e WITH(NOLOCK) ON a.dcJobTypeId = e.ID
- LEFT JOIN dcJobType f WITH(NOLOCK) ON a.dcJobTypeIdMinor = f.ID
- LEFT JOIN dcOthers g WITH(NOLOCK) ON a.NeedNumber = g.DetailID AND g.Category = '招聘人数'
- LEFT JOIN dcOthers h WITH(NOLOCK) ON a.EmployType = h.DetailID AND h.Category = '工作性质'
- LEFT JOIN dcOthers i WITH(NOLOCK) ON a.MinExperience = i.DetailID AND i.Category = '职位要求工作经验'
- LEFT JOIN dcSalary j WITH(NOLOCK) ON a.dcSalaryId = j.ID
- LEFT JOIN dcSalary k WITH(NOLOCK) ON a.dcSalaryIdMax = k.ID
- WHERE a.ID = @ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccLotteryCompany201310Update] Script Date: 2018/12/13 19:07:11 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --创建人:lambo
- --创建时间:2013-9-29
- --企业13周年抽奖
- --奖项内容: 平时 10月8日、18日、28日
- -- 10职位并发 20% 20%
- -- 20份简历 30% 30%
- -- 50份简历 10% 10%
- -- 2周文字广告 5% 5%
- -- 2周职位置顶 5% 5%
- -- 2周职位自动刷新 10% 10%
- -- Vip会员—季度 0% 5%(至少有一个)
- -- 1:1的赠送 0% 5%(至少有一个)
- -- 空奖 20% 10%
- -- 保险公司,抽奖中奖概率调整为10%
- CREATE PROCEDURE [dbo].[ccLotteryCompany201310Update]
- (
- @caMainID INT
- )
- AS
- BEGIN
- RETURN 9 --活动已结束
- DECLARE @LotteryID INT
- DECLARE @cpMainID INT
- 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)
- IF @LotteryID IS NULL
- RETURN -1 --没有抽奖次数
- UPDATE LotteryCompany201310 SET Used = 1,LotteryDate=GETDATE() WHERE ID = @LotteryID --更新状态 防止重复抽奖
- ------------------****************生成抽奖结果****************-----------------
- DECLARE @IsAgent INT --是否是保险公司
- SELECT top 1 @IsAgent = IsAgent FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
-
- DECLARE @Today VARCHAR(4) --用于判断 是否是10月8日、18日、28日
- SELECT @Today = RIGHT(CONVERT(VARCHAR(8) , GETDATE() , 112) , 4)
-
- DECLARE @GiftNo INT
- SELECT @GiftNo = CAST((RAND()*999+1) AS INT) --生成抽奖的数字
-
- --奖品类型:1、10职位并发 2、20份简历 3、50份简历 4、2周文字广告 5、2周职位置顶 6、2周职位自动刷新 7、Vip会员—季度 8、1:1的赠送 9、空奖
- DECLARE @GiftType INT
- IF @IsAgent = 0
- BEGIN
- IF @GiftNo BETWEEN 51 AND 250 --51-250之间 职位并发 20%概率
- SET @GiftType = 1
- ELSE IF @GiftNo BETWEEN 251 AND 550 --251-550之间 20简历下载 30%概率
- SET @GiftType = 2
- ELSE IF @GiftNo BETWEEN 551 AND 650 --551-650之间 50简历下载 10%概率
- SET @GiftType = 3
- ELSE IF @GiftNo BETWEEN 651 AND 700 --651-700之间 两周文字广告 5%概率
- SET @GiftType = 4
- ELSE IF @GiftNo BETWEEN 701 AND 750 --701-750之间 两周职位置顶 5%概率
- SET @GiftType = 5
- ELSE IF @GiftNo BETWEEN 751 AND 850 --751-850之间 两周职位刷新 10%概率
- SET @GiftType = 6
- ELSE IF @GiftNo BETWEEN 0 AND 50 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' ) --0-50之间 Vip会员—季度 5%概率
- SET @GiftType = 7
- ELSE IF @GiftNo BETWEEN 951 AND 1000 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' ) --951-1000之间 1:1赠送 5%概率
- SET @GiftType = 8
- ELSE --空奖 20%概率
- SET @GiftType = 9
- END
- ELSE -- 保险公司中奖概率10%
- BEGIN
- IF @GiftNo BETWEEN 61 AND 80 --61-80之间 职位并发 20%概率
- SET @GiftType = 1
- ELSE IF @GiftNo BETWEEN 281 AND 310 --281-310之间 20简历下载 30%概率
- SET @GiftType = 2
- ELSE IF @GiftNo BETWEEN 581 AND 590 --551-650之间 50简历下载 10%概率
- SET @GiftType = 3
- ELSE IF @GiftNo BETWEEN 661 AND 665 --651-700之间 两周文字广告 5%概率
- SET @GiftType = 4
- ELSE IF @GiftNo BETWEEN 731 AND 735 --701-750之间 两周职位置顶 5%概率
- SET @GiftType = 5
- ELSE IF @GiftNo BETWEEN 761 AND 770 --751-850之间 两周职位刷新 10%概率
- SET @GiftType = 6
- ELSE IF @GiftNo BETWEEN 31 AND 35 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' ) --0-50之间 Vip会员—季度 5%概率
- SET @GiftType = 7
- ELSE IF @GiftNo BETWEEN 981 AND 985 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' ) --951-1000之间 1:1赠送 5%概率
- SET @GiftType = 8
- ELSE --空奖 20%概率
- SET @GiftType = 9
- END
- -- IF @GiftType =7 OR @GiftType = 8
- -- SET @GiftType = 1
- /*---------****************自动提交订单**************-------------*/
- DECLARE @ProvinceID INT
- DECLARE @PayMethod INT --取上次订单的付款方式
- DECLARE @LinkMan NVARCHAR(50)
- DECLARE @Telephone NVARCHAR(50)
- DECLARE @CompanyName NVARCHAR(50)
- DECLARE @Accounts NUMERIC(18,2)
- DECLARE @dcFeeDetailsID INT
- DECLARE @Manageruserid INT
- DECLARE @MemberType INT
- DECLARE @MainOrderID INT
- DECLARE @InvoiceCompany NVARCHAR(50)
- SELECT TOP 1
- @ProvinceID = b.dcProvinceID,
- @PayMethod = c.PayMethod,
- @MemberType = MemberType,
- @LinkMan = LinkMan,
- @Telephone = Telephone,
- @CompanyName = CompanyName,
- @InvoiceCompany = InvoiceCompany,
- @Manageruserid = ConsultantID
- FROM LotteryCompany201310 a,cpMain b ,caOrder c
- WHERE a.cpMainID = b.ID
- AND a.caOrderID = c.ID
- AND a.cpMainID = @cpMainID
- ORDER BY a.ID
-
- SET @PayMethod = 7
- DECLARE @NewOrderID INT
- IF @GiftType = 1 AND @MemberType=3 --自动提交职位并发订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 10,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 10
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=10 AND MaxValue>=10) OR (MinValue<=10 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- 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
- --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,0, 32, NULL,NULL,@PayMethod,10,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,10,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
- VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
- 10,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,10,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
- SET @NewOrderID = @@IDENTITY
- END
- ELSE IF @GiftType = 2 AND @MemberType=3 --自动提交20简历下载订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 20,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 9
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=20 AND MaxValue>=20) OR (MinValue<=20 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- IF @dcFeeDetailsID IS NULL
- SELECT TOP 1 @Accounts = Price * 20
- FROM dcFee WITH(NOLOCK)
- WHERE type = 9
- AND dcProvinceID = LEFT(@ProvinceID,2)
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- 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
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
- VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
- 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,20,20,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
- SET @NewOrderID = @@IDENTITY
- END
- ELSE IF @GiftType = 3 AND @MemberType=3 --自动提交50简历下载订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 50,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 9
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=50 AND MaxValue>=50) OR (MinValue<=50 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- IF @dcFeeDetailsID IS NULL
- SELECT TOP 1 @Accounts = Price * 50
- FROM dcFee WITH(NOLOCK)
- WHERE type = 9
- AND dcProvinceID = LEFT(@ProvinceID,2)
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- 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
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
- VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
- 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,50,50,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
- SET @NewOrderID = @@IDENTITY
- END
- ELSE IF @GiftType = 4 --自动提交2周固定位置订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 2,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 7
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
- VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
- 7,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
- SET @NewOrderID = @@IDENTITY
- --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,7,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
- END
- ELSE IF @GiftType = 5 --自动提交2周职位置顶订单,职位默认取最新发布的,前台企业选择后再修改
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 2,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 22
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- DECLARE @JobID INT
- 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() )
- IF @JobID >0
- BEGIN
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
- VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
- 12,@Accounts,0,@JobID,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
- SET @NewOrderID = @@IDENTITY
- --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,12,@Accounts,0,@JobID,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
- END
- END
- ELSE IF @GiftType = 6 --自动提交2周职位刷新订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 2,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 24
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
- VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
- 13,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
- SET @NewOrderID = @@IDENTITY
- --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,13,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
- END
- ELSE IF @GiftType = 7 --自动提交VIP订单
- BEGIN
- DECLARE @ActiveQuota INT
- DECLARE @JobNumber INT
- DECLARE @UserNumber INT
- --取本省份价格最便宜的季度套餐
- SELECT @dcFeeDetailsID = b.ID,
- @Accounts = (a.PriceMonth * b.[Month]+b.ResumeNumber*a.PriceResume+JobNumber*a.PriceJob+UserNumber*a.PriceUser),
- @ActiveQuota = b.ResumeNumber,
- @JobNumber = b.JobNumber,
- @UserNumber = b.UserNumber
- FROM dcVip a WITH(NOLOCK),dcVipDetail b WITH(NOLOCK)
- WHERE a.id = b.dcVipId
- AND dcProvinceid=32
- AND b.[Month]=3
- AND startDate<GETDATE()
- AND enddate > GETDATE()
- ORDER BY Price
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
- VALUES(@cpMainID,@ProvinceID,null,NULL,@PayMethod,@UserNumber,
- 8,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,@ActiveQuota,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
- SET @NewOrderID = @@IDENTITY
- --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,0,@PayMethod,8,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,@UserNumber,@dcFeeDetailsID
- END
- ELSE IF @GiftType = 8 --自动提交 1:1赠送
- BEGIN
- ---取最新有赠送抽奖次数的订单
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
- SELECT cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,0,0,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,ActiveQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID
- FROM caOrder WITH(NOLOCK)
- WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany201310 WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID ORDER BY ID DESC)
- SET @NewOrderID = @@IDENTITY
- END
-
- BEGIN TRY
- IF @GiftType<>9
- BEGIN
- IF @Manageruserid IS NULL
- BEGIN
- INSERT INTO rtxnotifylog
- SELECT STUFF((SELECT ','+LTRIM(x.ID) FROM Manageruser x WHERE ID >= 180 and ID <190 FOR XML PATH('')),1,1,'')
- ,'中奖通知',@CompanyName+'('+LTRIM(STR(@cpMainID))+')中奖了,请及时处理',1,0,0,null,getdate()
- END
- ELSE
- BEGIN
- INSERT INTO rtxnotifylog
- SELECT @Manageruserid
- ,'中奖通知',@CompanyName+'('+LTRIM(STR(@cpMainID))+')中奖了,请及时处理',1,0,0,null,getdate()
- END
- Update caOrder Set InvoiceConfirmDate=GetDate(),InvoiceConfirmMan=119,InvoiceAskDate=Null,NeedInvoice=0 Where ID=@NewOrderID
- END
- END TRY
- BEGIN CATCH
-
- END CATCH
- --更新LotteryCompany201310,保存订单号和中奖类型
- UPDATE LotteryCompany201310 SET GiftOrderID=@NewOrderID,[type]=@GiftType WHERE ID = @LotteryID
- RETURN @GiftType
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccLotteryCompanyUpdate] Script Date: 2018/12/13 19:07:12 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --创建人:lambo
- --创建时间:2014-9-29
- --企业14周年抽奖
- --奖项内容: 平时 10月8日、18日、28日
- -- 50职位并发 15% 5%
- -- 50份简历 15% 20%
- -- 100份简历 15% 20%
- -- 200份简历 10% 15%
- -- 4周六分之一图片 10% 15%
- -- 2周知名企业 10% 10%
- -- 2周职位置顶 5% 5%
- -- 2周职位自动刷新 15% 9%
- -- 4周六分之二图片 0% 8%
- -- Vip会员—季度 0% 2%(至少有一个,不能重复 )
- -- 1:1的赠送 0% 1%(至少有一个,不能重复,如果是年度的不能抽到)
- -- 保险公司,培训公司,代理招聘类公司仅能够中奖的范围:职位数、简历数、自动刷新。其他内容不允许抽中。需要在抽选中排除。
- --修改人:nick
- --修改时间:2014-10-10
- --修改内容:发送rtx消息,加入奖品名称
- CREATE PROCEDURE [dbo].[ccLotteryCompanyUpdate]
- (
- @caMainID INT
- )
- AS
- BEGIN
- DECLARE @LotteryID INT
- DECLARE @cpMainID INT
- 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)
- IF @LotteryID IS NULL
- RETURN -1 --没有抽奖次数
- UPDATE LotteryCompany SET Used = 1,LotteryDate=GETDATE() WHERE ID = @LotteryID --更新状态 防止重复抽奖
- ------------------****************生成抽奖结果****************-----------------
- DECLARE @IsAgent INT --是否是保险公司
- DECLARE @Name NVARCHAR(200)
- SELECT top 1 @IsAgent = IsAgent,@Name = Name FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
- IF @IsAgent=0
- BEGIN
- IF @Name LIKE '%人寿%' OR @Name LIKE '%保险%'
- SET @IsAgent=1
- END
- DECLARE @Today VARCHAR(4) --用于判断 是否是10月8日、18日、28日
- SELECT @Today = RIGHT(CONVERT(VARCHAR(8) , GETDATE() , 112) , 4)
-
- DECLARE @GiftNo INT
- SELECT @GiftNo = CAST((RAND()*999+1) AS INT) --生成抽奖的数字
-
- --奖品类型:1、50职位并发 2、50份简历 3、100份简历 4、200份简历 5、4周六分之一图片 6、2周文字广告 7、2周职位置顶
- --8、2周职位自动刷新 9、4周六分之二 10、Vip会员—季度 11、1:1的赠送
- DECLARE @GiftType INT
- IF @IsAgent = 0
- BEGIN
- IF (@Today = '1008' OR @Today = '1016' OR @Today = '1028' OR @Today = '1025' )
- BEGIN
- IF @GiftNo BETWEEN 51 AND 100 --51-100之间 职位并发 5%概率
- SET @GiftType = 1
- ELSE IF @GiftNo BETWEEN 101 AND 200 --101-200之间 50份简历 10%概率
- SET @GiftType = 2
- ELSE IF @GiftNo BETWEEN 201 AND 400 --201-400之间 100份简历 20%概率
- SET @GiftType = 3
- ELSE IF @GiftNo BETWEEN 401 AND 550 --401-500之间 200份简历 15%概率
- SET @GiftType = 4
- ELSE IF @GiftNo BETWEEN 551 AND 700 --401-500之间 六分之一广告 15%概率
- SET @GiftType = 5
- ELSE IF @GiftNo BETWEEN 701 AND 800 --701-750之间 2周文字广告 10%概率
- SET @GiftType = 6
- ELSE IF @GiftNo BETWEEN 801 AND 850 --801-850之间 两周职位置顶 5%概率
- SET @GiftType = 7
- ELSE IF @GiftNo BETWEEN 851 AND 940 --851-940之间 两周职位刷新 9%概率
- SET @GiftType = 8
- ELSE IF @GiftNo BETWEEN 941 AND 1000 OR @GiftNo BETWEEN 1 AND 20 --941-1000之间 1到20 六分之二广告 8%概率
- SET @GiftType = 9
- ELSE IF @GiftNo BETWEEN 21 AND 40 --21-40之间 Vip会员—季度 2%概率
- SET @GiftType = 10
- ELSE IF @GiftNo BETWEEN 41 AND 50 --41-50之间 1:1赠送 1%概率
- SET @GiftType = 11
- ELSE --空奖 0%概率
- SET @GiftType = 12
- END
- ELSE
- BEGIN
- IF @GiftNo BETWEEN 51 AND 200 --51-200之间 职位并发 15%概率
- SET @GiftType = 1
- ELSE IF @GiftNo BETWEEN 201 AND 400 --201-400之间 50份简历 20%概率
- SET @GiftType = 2
- ELSE IF @GiftNo BETWEEN 401 AND 550 --201-400之间 100份简历 15%概率
- SET @GiftType = 3
- ELSE IF @GiftNo BETWEEN 551 AND 650 --401-500之间 200份简历 10%概率
- SET @GiftType = 4
- ELSE IF @GiftNo BETWEEN 651 AND 800 --401-500之间 六分之一广告 15%概率
- SET @GiftType = 5
- ELSE IF @GiftNo BETWEEN 801 AND 900 --701-750之间 2周文字广告 10%概率
- SET @GiftType = 6
- ELSE IF @GiftNo BETWEEN 901 AND 950 --801-850之间 两周职位置顶 5%概率
- SET @GiftType = 7
- ELSE IF @GiftNo BETWEEN 951 AND 1000 OR @GiftNo BETWEEN 1 AND 50 --851-940之间 两周职位刷新 15%概率
- SET @GiftType = 8
- ELSE --空奖 0%概率
- SET @GiftType = 12
- END
- END
- ELSE -- 保险公司中奖概率10%
- BEGIN
- IF @GiftNo BETWEEN 1 AND 200 --1-200之间 职位并发 15%概率
- SET @GiftType = 1
- ELSE IF @GiftNo BETWEEN 201 AND 450 --201-450之间 50份简历 25%概率
- SET @GiftType = 2
- ELSE IF @GiftNo BETWEEN 451 AND 650 --201-400之间 100份简历 20%概率
- SET @GiftType = 3
- ELSE IF @GiftNo BETWEEN 651 AND 800 --401-500之间 200份简历 15%概率
- SET @GiftType = 4
- ELSE IF @GiftNo BETWEEN 801 AND 1000 --851-940之间 两周职位刷新 20%概率
- SET @GiftType = 8
- ELSE --空奖 0%概率
- SET @GiftType = 12
- END
- IF GETDATE()>'2015-11-1'
- SET @GiftType = 9
- /*---------****************抽奖结果处理,判断是否合理,重复 **************-------------*/
- IF (@GiftType =9 OR @GiftType = 10 OR @GiftType = 11) AND NOT (@Today = '1008' OR @Today = '1016' OR @Today = '1028' OR @Today = '1025' ) --不是带8的日子不能抽到
- SET @GiftType = 1
- IF @Today = '1008' OR @Today = '1016' OR @Today = '1028' OR @Today = '1025'
- BEGIN
- IF EXISTS(SELECT TOP 1 'x' FROM LotteryCompany WHERE [Type]=@GiftType AND cpMainID=@cpMainID) --重复抽到了
- SELECT TOP 1 @GiftType = s.a
- 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)
- END
- ELSE
- BEGIN
- IF (SELECT COUNT(1) FROM LotteryCompany WHERE [Type]=@GiftType AND cpMainID=@cpMainID)>1 --重复抽到了一次
- 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)
-
- END
- IF @GiftType IN (10,11) AND EXISTS(SELECT TOP 1 'x' FROM LotteryCompany WHERE [Type]=@GiftType AND cpMainID=@cpMainID) --重复抽到了
- SET @GiftType = 1
- IF @GiftType IN (10,11) --本月开通的非年度的才赠送
- IF NOT EXISTS(SELECT TOP 1 'x' FROM caOrder WITH(NOLOCK)
- WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany WITH(NOLOCK)
- WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID
- ORDER BY ID DESC)
- AND dcFeeDetailId in (SELECT id FROM dcVipDetail WITH(NOLOCK) WHERE [Month]<12)
- AND orderType=8
- AND OpenDate>'2015-10-1'
- AND Paid>0
- ) OR EXISTS(SELECT TOP 1 'x' FROM caOrder WITH(NOLOCK)
- WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany WITH(NOLOCK)
- WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID
- ORDER BY ID DESC)
- AND dcFeeDetailId in (SELECT id FROM dcVipDetail WITH(NOLOCK) WHERE [Month]>=12)
- AND orderType=8
- AND OpenDate>'2015-10-1'
- )
- SET @GiftType = 1
- /*---------****************自动提交订单**************-------------*/
- DECLARE @ProvinceID INT
- DECLARE @PayMethod INT --取上次订单的付款方式
- DECLARE @LinkMan NVARCHAR(50)
- DECLARE @Telephone NVARCHAR(50)
- DECLARE @CompanyName NVARCHAR(50)
- DECLARE @Accounts NUMERIC(18,2)
- DECLARE @dcFeeDetailsID INT
- DECLARE @Manageruserid INT
- DECLARE @MemberType INT
- DECLARE @MainOrderID INT
- DECLARE @MainEndDate SMALLDATETIME
- DECLARE @InvoiceCompany NVARCHAR(50)
- DECLARE @Hour INT
- DECLARE @Minute INT
- DECLARE @Code VARCHAR(10)
- DECLARE @RegDate DATETIME
- SELECT TOP 1
- @ProvinceID = b.dcProvinceID,
- @PayMethod = c.PayMethod,
- @MemberType = MemberType,
- @LinkMan = LinkMan,
- @Telephone = Telephone,
- @CompanyName = CompanyName,
- @InvoiceCompany = InvoiceCompany,
- @Manageruserid = ConsultantID,
- @RegDate = RegDate
- FROM cpMain b ,caOrder c
- WHERE b.id =c.cpmainid
- AND c.cpMainID = @cpMainID
- AND Paid>0
- ORDER BY c.ID DESC
-
- SELECT @Hour = DATEPART(HOUR,@RegDate)
- SELECT @Minute = DATEPART(Minute,@RegDate)
-
- SET @Code = CONVERT(VARCHAR(10),@Hour*100+@Minute)
-
- SET @PayMethod = 7
- DECLARE @NewOrderID INT
- IF @GiftType= 1 AND @MemberType=3 --自动提交50个职位并发数的订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 50,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 10
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=50 AND MaxValue>=50) OR (MinValue<=50 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- 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
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
- VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
- 10,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,50,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,GETDATE(),@MainEndDate,GETDATE(),119,4)
- SET @NewOrderID = @@IDENTITY
- UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
- END
- ELSE IF @GiftType = 5 --自动提交4周1/6图片 广告
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 4,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 4
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=4 AND MaxValue>=4) OR (MinValue<=4 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
- VALUES(@cpMainID,@ProvinceID,6,4,@PayMethod,0,
- 4,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
- SET @NewOrderID = @@IDENTITY
- END
- ELSE IF @GiftType = 9 --自动提交4周2/6图片 广告
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 4,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 4
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=4 AND MaxValue>=4) OR (MinValue<=4 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
- VALUES(@cpMainID,@ProvinceID,7,4,@PayMethod,0,
- 4,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
- SET @NewOrderID = @@IDENTITY
- END
- ELSE IF @GiftType = 2 AND @MemberType=3 --自动提交50简历下载订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 50,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 9
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=50 AND MaxValue>=50) OR (MinValue<=50 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- IF @dcFeeDetailsID IS NULL
- SELECT TOP 1 @Accounts = Price * 50
- FROM dcFee WITH(NOLOCK)
- WHERE type = 9
- AND dcProvinceID = LEFT(@ProvinceID,2)
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- 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
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate)
- VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
- 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,50,50,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,GETDATE(),@MainEndDate)
- SET @NewOrderID = @@IDENTITY
- --UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
- END
- ELSE IF @GiftType = 3 AND @MemberType=3 --自动提交100简历下载订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 100,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 9
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=100 AND MaxValue>=100) OR (MinValue<=100 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- IF @dcFeeDetailsID IS NULL
- SELECT TOP 1 @Accounts = Price * 100
- FROM dcFee WITH(NOLOCK)
- WHERE type = 9
- AND dcProvinceID = LEFT(@ProvinceID,2)
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- 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
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate)
- VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
- 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,100,100,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,GETDATE(),@MainEndDate)
- SET @NewOrderID = @@IDENTITY
- --UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
- END
- ELSE IF @GiftType = 4 AND @MemberType=3 --自动提交200简历下载订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 200,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 9
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=50 AND MaxValue>=200) OR (MinValue<=200 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- IF @dcFeeDetailsID IS NULL
- SELECT TOP 1 @Accounts = Price * 200
- FROM dcFee WITH(NOLOCK)
- WHERE type = 9
- AND dcProvinceID = LEFT(@ProvinceID,2)
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- 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
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate)
- VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
- 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,200,200,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,GETDATE(),@MainEndDate)
- SET @NewOrderID = @@IDENTITY
- --UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
- END
- ELSE IF @GiftType =6 --自动提交2周固定位置订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 2,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 7
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- DECLARE @FixBeginDate SMALLDATETIME
- --取最后一个固定位置的订单
- 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
- SET @FixBeginDate=ISNULL(@FixBeginDate,GETDATE())
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
- VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
- 7,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,@FixBeginDate,DATEADD(day,14,@FixBeginDate),GETDATE(),119,4)
- SET @NewOrderID = @@IDENTITY
- UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
- --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,7,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
- END
- ELSE IF @GiftType = 7 --自动提交2周职位置顶订单,职位默认取最新发布的,前台企业选择后再修改
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 2,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 22
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- DECLARE @JobID INT
- 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() )
- IF @JobID >0
- BEGIN
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
- VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
- 12,@Accounts,0,@JobID,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
- SET @NewOrderID = @@IDENTITY
- --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,12,@Accounts,0,@JobID,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
- END
- END
- ELSE IF @GiftType = 8 --自动提交2周职位刷新订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 2,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 24
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- DECLARE @RefreshBeginDate SMALLDATETIME
- --取最后一个固定位置的订单
- 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
- SET @RefreshBeginDate=ISNULL(@RefreshBeginDate,GETDATE())
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
- VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
- 13,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,@RefreshBeginDate,DATEADD(day,14,@RefreshBeginDate),GETDATE(),119,4)
- SET @NewOrderID = @@IDENTITY
- UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
- --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,13,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
- END
- ELSE IF @GiftType = 10 --自动提交VIP订单
- BEGIN
- DECLARE @ActiveQuota INT
- DECLARE @JobNumber INT
- DECLARE @UserNumber INT
- --取本省份价格最便宜的季度套餐
- SELECT TOP 1 @dcFeeDetailsID = b.ID,
- @Accounts = (a.PriceMonth * b.[Month]+b.ResumeNumber*a.PriceResume+JobNumber*a.PriceJob+UserNumber*a.PriceUser),
- @ActiveQuota = b.ResumeNumber,
- @JobNumber = b.JobNumber,
- @UserNumber = b.UserNumber
- FROM dcVip a WITH(NOLOCK),dcVipDetail b WITH(NOLOCK)
- WHERE a.id = b.dcVipId
- AND dcProvinceid=@ProvinceID
- AND b.[Month]=3
- AND startDate<GETDATE()
- AND enddate > GETDATE()
- ORDER BY Price
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
- VALUES(@cpMainID,@ProvinceID,null,NULL,@PayMethod,@UserNumber,
- 8,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,@ActiveQuota,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
- SET @NewOrderID = @@IDENTITY
- --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,0,@PayMethod,8,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,@UserNumber,@dcFeeDetailsID
- END
- ELSE IF @GiftType = 11 --自动提交 1:1赠送
- BEGIN
- ---取最新有赠送抽奖次数的订单
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
- SELECT cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,0,0,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,ActiveQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,0
- FROM caOrder WITH(NOLOCK)
- WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID ORDER BY ID DESC)
- SET @NewOrderID = @@IDENTITY
- END
-
- BEGIN TRY
- IF @GiftType<>12
- BEGIN
- --奖品类型:1、50职位并发 2、50份简历 3、100份简历 4、200份简历 5、4周六分之一图片 6、2周文字广告 7、2周职位置顶
- --8、2周职位自动刷新 9、4周六分之二 10、Vip会员—季度 11、1:1的赠送
- DECLARE @GiftName VARCHAR(50)
- IF @GiftType =1
- BEGIN
- SET @GiftName = '50职位并发'
- END
- ELSE IF @GiftType =2
- BEGIN
- SET @GiftName = '50份简历'
- END
- ELSE IF @GiftType =3
- BEGIN
- SET @GiftName = '100份简历'
- END
- ELSE IF @GiftType =4
- BEGIN
- SET @GiftName = '200份简历 '
- END
- ELSE IF @GiftType =5
- BEGIN
- SET @GiftName = '4周六分之一图片广告'
- END
- ELSE IF @GiftType =6
- BEGIN
- SET @GiftName = '2周文字广告'
- END
- ELSE IF @GiftType =7
- BEGIN
- SET @GiftName = '2周职位置顶'
- END
- ELSE IF @GiftType =8
- BEGIN
- SET @GiftName = '2周职位自动刷新'
- END
- ELSE IF @GiftType =9
- BEGIN
- SET @GiftName = '4周六分之二'
- END
- ELSE IF @GiftType =10
- BEGIN
- SET @GiftName = 'Vip会员—季度'
- END
- ELSE
- BEGIN
- SET @GiftName = '1:1的赠送'
- END
-
- IF @Manageruserid IS NULL
- BEGIN
- INSERT INTO rtxnotifylog
- SELECT STUFF((SELECT ','+LTRIM(x.ID) FROM Manageruser x WHERE ID IN (180,181,182) FOR XML PATH('')),1,1,'')
- ,'中奖通知',@CompanyName+'('+LTRIM(STR(@cpMainID))+')中奖了,奖品为['+@GiftName+'],请及时处理http://sysback.51rc.com/yehgiiaovbjkaie871/cp/cpMainInfo.asp?id='+LTRIM(STR(@cpMainID))+'&code='+@Code,1,0,0,null,getdate()
- END
- ELSE
- BEGIN
- INSERT INTO rtxnotifylog
- SELECT @Manageruserid
- ,'中奖通知',@CompanyName+'('+LTRIM(STR(@cpMainID))+')中奖了,奖品为['+@GiftName+'],请及时处理http://sysback.51rc.com/yehgiiaovbjkaie871/cp/cpMainInfo.asp?id='+LTRIM(STR(@cpMainID))+'&code='+@Code,1,0,0,null,getdate()
- END
- Update caOrder Set InvoiceConfirmDate=GetDate(),InvoiceConfirmMan=119,InvoiceAskDate=Null,NeedInvoice=0 Where ID=@NewOrderID
- END
- END TRY
- BEGIN CATCH
-
- END CATCH
- --更新LotteryCompany,保存订单号和中奖类型
- UPDATE LotteryCompany SET GiftOrderID=@NewOrderID,[type]=@GiftType WHERE ID= @LotteryID
- RETURN @GiftType
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccLotteryCompanyUpdate2014] Script Date: 2018/12/13 19:07:12 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --创建人:lambo
- --创建时间:2014-9-29
- --企业14周年抽奖
- --奖项内容: 平时 10月8日、18日、28日
- -- 20职位并发 15% 20%
- -- 2周图片 10% 10%
- -- 50份简历 30% 30%
- -- 2周文字广告 5% 5%
- -- 2周职位置顶 5% 5%
- -- 2周职位自动刷新 10% 10%
- -- Vip会员—季度 0% 5%(至少有一个,不能重复 )
- -- 1:1的赠送 0% 1%(至少有一个,不能重复,如果是年度的不能抽到)
- -- 学习卡 5% 4%(至少有一个,不能重复)
- -- 空奖 20% 10%
- -- 保险公司,抽奖中奖概率调整为10%
- --修改人:nick
- --修改时间:2014-10-10
- --修改内容:发送rtx消息,加入奖品名称
- CREATE PROCEDURE [dbo].[ccLotteryCompanyUpdate2014]
- (
- @caMainID INT
- )
- AS
- BEGIN
- DECLARE @LotteryID INT
- DECLARE @cpMainID INT
- 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)
- IF @LotteryID IS NULL
- RETURN -1 --没有抽奖次数
- UPDATE LotteryCompany SET Used = 1,LotteryDate=GETDATE() WHERE ID = @LotteryID --更新状态 防止重复抽奖
- ------------------****************生成抽奖结果****************-----------------
- DECLARE @IsAgent INT --是否是保险公司
- SELECT top 1 @IsAgent = IsAgent FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
-
- DECLARE @Today VARCHAR(4) --用于判断 是否是10月8日、18日、28日
- SELECT @Today = RIGHT(CONVERT(VARCHAR(8) , GETDATE() , 112) , 4)
-
- DECLARE @GiftNo INT
- SELECT @GiftNo = CAST((RAND()*999+1) AS INT) --生成抽奖的数字
-
- --奖品类型:1、20职位并发 2、2周图片 3、50份简历 4、2周文字广告 5、2周职位置顶 6、2周职位自动刷新 7、Vip会员—季度 8、1:1的赠送 9、空奖 10、学习卡
- DECLARE @GiftType INT
- IF @IsAgent = 0
- BEGIN
- IF @GiftNo BETWEEN 51 AND 200 OR (@GiftNo BETWEEN 201 AND 250 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' )) --51-200之间 职位并发 15%概率
- SET @GiftType = 1
- ELSE IF @GiftNo BETWEEN 251 AND 350 --251-350之间 2周图片 10%概率
- SET @GiftType = 2
- ELSE IF @GiftNo BETWEEN 351 AND 650 --351-650之间 50简历下载 30%概率
- SET @GiftType = 3
- ELSE IF @GiftNo BETWEEN 651 AND 700 --651-700之间 两周文字广告 5%概率
- SET @GiftType = 4
- ELSE IF @GiftNo BETWEEN 701 AND 750 --701-750之间 两周职位置顶 5%概率
- SET @GiftType = 5
- ELSE IF @GiftNo BETWEEN 751 AND 850 --751-850之间 两周职位刷新 10%概率
- SET @GiftType = 6
- ELSE IF @GiftNo BETWEEN 851 AND 900 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' ) --0-50之间 Vip会员—季度 5%概率
- SET @GiftType = 7
- ELSE IF @GiftNo BETWEEN 951 AND 960 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' ) --951-1000之间 1:1赠送 1%概率
- SET @GiftType = 8
- ELSE IF @GiftNo BETWEEN 961 AND 1000 OR (@GiftNo BETWEEN 910 AND 920 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' )) --学习卡 4%概率
- SET @GiftType = 10
- ELSE --空奖 20%概率
- SET @GiftType = 9
- END
- ELSE -- 保险公司中奖概率10%
- BEGIN
- IF @GiftNo BETWEEN 61 AND 81 --61-80之间 职位并发 15%概率
- SET @GiftType = 1
- ELSE IF @GiftNo BETWEEN 281 AND 310 --281-310之间 2周图片 不能被抽到
- SET @GiftType = 9
- ELSE IF @GiftNo BETWEEN 581 AND 590 --581-590之间 50简历下载 30%概率
- SET @GiftType = 3
- ELSE IF @GiftNo BETWEEN 661 AND 665 --661-665 两周文字广告 不能被抽到
- SET @GiftType = 9
- ELSE IF @GiftNo BETWEEN 731 AND 735 --731-735 两周职位置顶 5%概率
- SET @GiftType = 5
- ELSE IF @GiftNo BETWEEN 761 AND 770 --761-770 两周职位刷新 10%概率
- SET @GiftType = 6
- ELSE IF @GiftNo = 851 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' )
- SET @GiftType = 7
- ELSE IF @GiftNo = 951 AND (@Today = '1008' OR @Today = '1018' OR @Today = '1028' )
- SET @GiftType = 8
- ELSE IF @GiftNo BETWEEN 961 AND 966
- SET @GiftType = 10
- ELSE --空奖 20%概率
- SET @GiftType = 9
- END
- IF GETDATE()>'2014-11-1'
- SET @GiftType = 9
- /*---------****************抽奖结果处理,判断是否合理,重复 **************-------------*/
- IF (@GiftType =7 OR @GiftType = 8) AND NOT (@Today = '1008' OR @Today = '1018' OR @Today = '1028' ) --不是带8的日子不能抽到
- SET @GiftType = 1
- IF @GiftType IN (7,8,10) AND EXISTS(SELECT TOP 1 'x' FROM LotteryCompany WHERE [Type]=@GiftType AND cpMainID=@cpMainID) --重复抽到了
- SET @GiftType = 1
- IF @GiftType =8 --本月开通的非年度的才赠送
- IF NOT EXISTS(SELECT TOP 1 'x' FROM caOrder WITH(NOLOCK)
- WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany WITH(NOLOCK)
- WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID
- ORDER BY ID DESC)
- AND dcFeeDetailId in (SELECT id FROM dcVipDetail WITH(NOLOCK) WHERE [Month]<12)
- AND orderType=8
- AND OpenDate>'2014-10-1'
- AND Paid>0
- ) OR EXISTS(SELECT TOP 1 'x' FROM caOrder WITH(NOLOCK)
- WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany WITH(NOLOCK)
- WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID
- ORDER BY ID DESC)
- AND dcFeeDetailId in (SELECT id FROM dcVipDetail WITH(NOLOCK) WHERE [Month]>=12)
- AND orderType=8
- AND OpenDate>'2014-10-1'
- )
- SET @GiftType = 1
- IF @GiftType =7 --本月开通的会员的才赠送
- IF NOT EXISTS(SELECT TOP 1 'x' FROM caOrder WITH(NOLOCK)
- WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany WITH(NOLOCK)
- WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID
- ORDER BY ID DESC)
- AND orderType=8
- AND OpenDate>'2014-10-1'
- AND Paid>0
- )
- SET @GiftType = 1
-
- DECLARE @GiftCount INT
- SELECT @GiftCount = COUNT(*) FROM LotteryCompany WHERE cpMainID=@cpMainID and [type]<>9 and used=1
- --年度、双年度以上最多中奖为8次,最多中8次奖。
- IF @GiftCount>=8
- BEGIN
- SET @GiftType = 9
- END
- ELSE IF @GiftCount>=5 --季度、半年度最多中奖为5次。
- BEGIN
- IF NOT EXISTS(SELECT TOP 1 'x' FROM caOrder WITH(NOLOCK)
- WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany WITH(NOLOCK)
- WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID
- ORDER BY ID DESC)
- AND dcFeeDetailId in (SELECT id FROM dcVipDetail WITH(NOLOCK) WHERE [Month]>=12)
- AND orderType=8)
- BEGIN
- SET @GiftType = 9
- END
- END
- ELSE IF @GiftCount>=3 --如果当月没有购买会员,仅进行连续登陆,那么最多中奖为3次。
- BEGIN
- IF NOT EXISTS(SELECT TOP 1 'x' FROM caOrder WITH(NOLOCK)
- WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany WITH(NOLOCK)
- WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID
- ORDER BY ID DESC)
- AND dcFeeDetailId in (SELECT id FROM dcVipDetail WITH(NOLOCK) WHERE [Month]>=3)
- AND orderType=8)
- BEGIN
- SET @GiftType = 9
- END
- END
- IF @GiftType = 10
- BEGIN
- DECLARE @GiftCardCount INT
- SELECT @GiftCardCount = COUNT(*) FROM LotteryCompany WHERE [type] =10 and used=1
- IF @GiftCardCount>=80
- SET @GiftType = 9
- END
- IF @cpMainID =371108
- BEGIN
- SET @GiftType = 6
- END
- /*---------****************自动提交订单**************-------------*/
- DECLARE @ProvinceID INT
- DECLARE @PayMethod INT --取上次订单的付款方式
- DECLARE @LinkMan NVARCHAR(50)
- DECLARE @Telephone NVARCHAR(50)
- DECLARE @CompanyName NVARCHAR(50)
- DECLARE @Accounts NUMERIC(18,2)
- DECLARE @dcFeeDetailsID INT
- DECLARE @Manageruserid INT
- DECLARE @MemberType INT
- DECLARE @MainOrderID INT
- DECLARE @MainEndDate SMALLDATETIME
- DECLARE @InvoiceCompany NVARCHAR(50)
- DECLARE @Hour INT
- DECLARE @Minute INT
- DECLARE @Code VARCHAR(10)
- DECLARE @RegDate DATETIME
- SELECT TOP 1
- @ProvinceID = b.dcProvinceID,
- @PayMethod = c.PayMethod,
- @MemberType = MemberType,
- @LinkMan = LinkMan,
- @Telephone = Telephone,
- @CompanyName = CompanyName,
- @InvoiceCompany = InvoiceCompany,
- @Manageruserid = ConsultantID,
- @RegDate = RegDate
- FROM cpMain b ,caOrder c
- WHERE b.id =c.cpmainid
- AND c.cpMainID = @cpMainID
- AND Paid>0
- ORDER BY c.ID DESC
-
- SELECT @Hour = DATEPART(HOUR,@RegDate)
- SELECT @Minute = DATEPART(Minute,@RegDate)
-
- SET @Code = CONVERT(VARCHAR(10),@Hour*100+@Minute)
-
- SET @PayMethod = 7
- DECLARE @NewOrderID INT
- IF @GiftType= 1 AND @MemberType=3 --自动提交20个职位并发数的订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 10,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 10
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=20 AND MaxValue>=20) OR (MinValue<=20 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- 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
- --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,0, 32, NULL,NULL,@PayMethod,10,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,10,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
- VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
- 10,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,20,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,GETDATE(),@MainEndDate,GETDATE(),119,4)
- SET @NewOrderID = @@IDENTITY
- UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
- END
- ELSE IF @GiftType = 2 --自动提交2周1/6图片 广告
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 2,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 4
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
- VALUES(@cpMainID,@ProvinceID,6,2,@PayMethod,0,
- 4,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
- SET @NewOrderID = @@IDENTITY
- --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,7,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
- END
- ELSE IF @GiftType = 3 AND @MemberType=3 --自动提交50简历下载订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 50,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 9
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=50 AND MaxValue>=50) OR (MinValue<=50 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- IF @dcFeeDetailsID IS NULL
- SELECT TOP 1 @Accounts = Price * 50
- FROM dcFee WITH(NOLOCK)
- WHERE type = 9
- AND dcProvinceID = LEFT(@ProvinceID,2)
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- 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
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate)
- VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
- 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,50,50,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,GETDATE(),@MainEndDate)
- SET @NewOrderID = @@IDENTITY
- --UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
- END
- ELSE IF @GiftType = 4 --自动提交2周固定位置订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 2,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 7
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- DECLARE @FixBeginDate SMALLDATETIME
- --取最后一个固定位置的订单
- 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
- SET @FixBeginDate=ISNULL(@FixBeginDate,GETDATE())
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
- VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
- 7,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,@FixBeginDate,DATEADD(day,14,@FixBeginDate),GETDATE(),119,4)
- SET @NewOrderID = @@IDENTITY
- UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
- --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,7,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
- END
- ELSE IF @GiftType = 5 --自动提交2周职位置顶订单,职位默认取最新发布的,前台企业选择后再修改
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 2,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 22
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- DECLARE @JobID INT
- 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() )
- IF @JobID >0
- BEGIN
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
- VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
- 12,@Accounts,0,@JobID,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
- SET @NewOrderID = @@IDENTITY
- --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,12,@Accounts,0,@JobID,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
- END
- END
- ELSE IF @GiftType = 6 --自动提交2周职位刷新订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 2,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 24
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- DECLARE @RefreshBeginDate SMALLDATETIME
- --取最后一个固定位置的订单
- 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
- SET @RefreshBeginDate=ISNULL(@RefreshBeginDate,GETDATE())
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
- VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
- 13,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,@RefreshBeginDate,DATEADD(day,14,@RefreshBeginDate),GETDATE(),119,4)
- SET @NewOrderID = @@IDENTITY
- UPDATE caOrder SET ReceiveDate=GETDATE() ,ReceiveMan=146 WHERE ID=@NewOrderID
- --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,2,@PayMethod,13,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,0,@dcFeeDetailsID
- END
- ELSE IF @GiftType = 7 --自动提交VIP订单
- BEGIN
- DECLARE @ActiveQuota INT
- DECLARE @JobNumber INT
- DECLARE @UserNumber INT
- --取本省份价格最便宜的季度套餐
- SELECT TOP 1 @dcFeeDetailsID = b.ID,
- @Accounts = (a.PriceMonth * b.[Month]+b.ResumeNumber*a.PriceResume+JobNumber*a.PriceJob+UserNumber*a.PriceUser),
- @ActiveQuota = b.ResumeNumber,
- @JobNumber = b.JobNumber,
- @UserNumber = b.UserNumber
- FROM dcVip a WITH(NOLOCK),dcVipDetail b WITH(NOLOCK)
- WHERE a.id = b.dcVipId
- AND dcProvinceid=@ProvinceID
- AND b.[Month]=3
- AND startDate<GETDATE()
- AND enddate > GETDATE()
- ORDER BY Price
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
- VALUES(@cpMainID,@ProvinceID,null,NULL,@PayMethod,@UserNumber,
- 8,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,@ActiveQuota,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
- SET @NewOrderID = @@IDENTITY
- --EXEC @NewOrderID = [dbo].[ccCaOrderInsert] @cpMainID,@IsAgent, 32, NULL,0,@PayMethod,8,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,@UserNumber,@dcFeeDetailsID
- END
- ELSE IF @GiftType = 8 --自动提交 1:1赠送
- BEGIN
- ---取最新有赠送抽奖次数的订单
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
- SELECT cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,0,0,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,ActiveQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,0
- FROM caOrder WITH(NOLOCK)
- WHERE ID IN (SELECT TOP 1 caOrderID FROM LotteryCompany WHERE caOrderID IS NOT NULL AND cpMainID= @cpMainID ORDER BY ID DESC)
- SET @NewOrderID = @@IDENTITY
- END
-
- BEGIN TRY
- IF @GiftType<>9
- BEGIN
- --奖品类型:1、20职位并发 2、2周图片 3、50份简历 4、2周文字广告 5、2周职位置顶 6、2周职位自动刷新 7、Vip会员—季度 8、1:1的赠送 9、空奖 10、学习卡
- DECLARE @GiftName VARCHAR(50)
- IF @GiftType =1
- BEGIN
- SET @GiftName = '20职位并发'
- END
- ELSE IF @GiftType =2
- BEGIN
- SET @GiftName = '2周图片'
- END
- ELSE IF @GiftType =3
- BEGIN
- SET @GiftName = '50份简历'
- END
- ELSE IF @GiftType =4
- BEGIN
- SET @GiftName = '2周文字广告'
- END
- ELSE IF @GiftType =5
- BEGIN
- SET @GiftName = '2周职位置顶'
- END
- ELSE IF @GiftType =6
- BEGIN
- SET @GiftName = '2周职位自动刷新'
- END
- ELSE IF @GiftType =7
- BEGIN
- SET @GiftName = 'Vip会员—季度'
- END
- ELSE IF @GiftType =8
- BEGIN
- SET @GiftName = '1:1的赠送'
- END
- ELSE IF @GiftType =10
- BEGIN
- SET @GiftName = '学习卡'
- END
- ELSE
- BEGIN
- SET @GiftName = '空奖'
- END
-
- IF @Manageruserid IS NULL
- BEGIN
- INSERT INTO rtxnotifylog
- SELECT STUFF((SELECT ','+LTRIM(x.ID) FROM Manageruser x WHERE ID IN (180,181,182) FOR XML PATH('')),1,1,'')
- ,'中奖通知',@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()
- END
- ELSE
- BEGIN
- INSERT INTO rtxnotifylog
- SELECT @Manageruserid
- ,'中奖通知',@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()
- END
- Update caOrder Set InvoiceConfirmDate=GetDate(),InvoiceConfirmMan=119,InvoiceAskDate=Null,NeedInvoice=0 Where ID=@NewOrderID
- END
- END TRY
- BEGIN CATCH
-
- END CATCH
- --更新LotteryCompany,保存订单号和中奖类型
- UPDATE LotteryCompany SET GiftOrderID=@NewOrderID,[type]=@GiftType WHERE ID= @LotteryID
- RETURN @GiftType
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccLotteryCompanyUpdate2016] Script Date: 2018/12/13 19:07:12 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --创建人:Lucifer
- --创建时间:2016-9-20
- --企业16周年抽奖
- --奖项内容: 平时 10月8日、18日、25日、28日
- --50职位并发 15% 5%
- --50份简历 20% 10%
- --100份简历 15% 20%
- --200份简历 10% 15%
- --4周六分之一图片 10% 15%
- --2周知名企业 10% 10%
- --2周职位置顶 5% 5%
- --2周职位自动刷新 15% 10%
- --4周六分之二图片 0% 8%
- --Vip会员—季度 0% 2%(至少有一个,不能重复)
- --保险公司,培训公司,代理招聘类公司仅能够中奖的范围:职位数、简历数、自动刷新。其他内容不允许抽中。需要在抽选中排除。
- CREATE PROCEDURE [dbo].[ccLotteryCompanyUpdate2016]
- (
- @caMainID INT
- )
- AS
- BEGIN
- DECLARE @LotteryID INT
- DECLARE @cpMainID INT
- 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)
- IF @LotteryID IS NULL
- RETURN -1 --没有抽奖次数
- UPDATE LotteryCompany SET Used = 1,LotteryDate = GETDATE() WHERE ID = @LotteryID --更新状态 防止重复抽奖
- ------------------****************生成抽奖结果****************-----------------
- DECLARE @IsAgent INT --是否是保险公司
- DECLARE @Name NVARCHAR(200)
- SELECT TOP 1 @IsAgent = IsAgent,@Name = Name FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
- IF @IsAgent = 0
- BEGIN
- IF @Name LIKE '%人寿%' OR @Name LIKE '%保险%'
- SET @IsAgent = 1
- END
-
- DECLARE @GiftNo INT, @GiftType INT, @LoopCount INT
- SELECT @GiftNo = CAST((RAND()*999+1) AS INT) --生成抽奖的数字
- SELECT @GiftType = dbo.GetLotteryGiftType(@IsAgent, @GiftNo)
- SET @LoopCount = 0
- WHILE EXISTS(SELECT 'X' FROM LotteryCompany WHERE [Type] = @GiftType AND cpMainID = @cpMainID) OR @LoopCount < 1000
- BEGIN
- SELECT @GiftNo = CAST((RAND()*999 + 1) AS INT) --生成抽奖的数字
- SELECT @GiftType = dbo.GetLotteryGiftType(@IsAgent, @GiftNo)
- SET @LoopCount = @LoopCount + 1
- END
- PRINT @GiftType
- /*---------****************自动提交订单**************-------------*/
- DECLARE @ProvinceID INT
- DECLARE @PayMethod INT --取上次订单的付款方式
- DECLARE @LinkMan NVARCHAR(50)
- DECLARE @Telephone NVARCHAR(50)
- DECLARE @CompanyName NVARCHAR(50)
- DECLARE @Accounts NUMERIC(18,2)
- DECLARE @dcFeeDetailsID INT
- DECLARE @Manageruserid INT
- DECLARE @MemberType INT
- DECLARE @MainOrderID INT
- DECLARE @InvoiceCompany NVARCHAR(50)
- DECLARE @Hour INT
- DECLARE @MainEndDate SMALLDATETIME
- DECLARE @Minute INT
- DECLARE @Code VARCHAR(10)
- DECLARE @RegDate DATETIME
- SELECT TOP 1
- @ProvinceID = b.dcProvinceID,
- @PayMethod = c.PayMethod,
- @MemberType = MemberType,
- @LinkMan = LinkMan,
- @Telephone = Telephone,
- @CompanyName = CompanyName,
- @InvoiceCompany = InvoiceCompany,
- @Manageruserid = ConsultantID,
- @RegDate = RegDate
- FROM cpMain b ,caOrder c
- WHERE b.id =c.cpmainid
- AND c.cpMainID = @cpMainID
- AND Paid>0
- ORDER BY c.ID DESC
-
- SELECT @Hour = DATEPART(HOUR,@RegDate)
- SELECT @Minute = DATEPART(Minute,@RegDate)
-
- SET @Code = CONVERT(VARCHAR(10),@Hour*100+@Minute)
-
- SET @PayMethod = 7
- DECLARE @NewOrderID INT
- IF @GiftType= 1 AND @MemberType=3 --自动提交50个职位并发数的订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 50,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 10
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue <= 50 AND MaxValue >= 50) OR (MinValue <= 50 AND MaxValue = 0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- 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
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
- VALUES(@cpMainID,@ProvinceID,NULL,NULL,@PayMethod,0,
- 10,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,50,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,GETDATE(),@MainEndDate,GETDATE(),116,4)
- SET @NewOrderID = @@IDENTITY
- END
- ELSE IF @GiftType = 5 --自动提交4周1/6图片 广告
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 4,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 4
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=4 AND MaxValue>=4) OR (MinValue<=4 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
- VALUES(@cpMainID,@ProvinceID,6,4,@PayMethod,0,
- 4,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
- SET @NewOrderID = @@IDENTITY
- END
- ELSE IF @GiftType = 9 --自动提交4周2/6图片 广告
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 4,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 4
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=4 AND MaxValue>=4) OR (MinValue<=4 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
- VALUES(@cpMainID,@ProvinceID,7,4,@PayMethod,0,
- 4,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
- SET @NewOrderID = @@IDENTITY
- END
- ELSE IF @GiftType = 2 AND @MemberType=3 --自动提交50简历下载订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 50,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 9
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=50 AND MaxValue>=50) OR (MinValue<=50 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- IF @dcFeeDetailsID IS NULL
- SELECT TOP 1 @Accounts = Price * 50
- FROM dcFee WITH(NOLOCK)
- WHERE type = 9
- AND dcProvinceID = LEFT(@ProvinceID,2)
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- 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
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
- VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
- 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,50,50,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
- SET @NewOrderID = @@IDENTITY
- END
- ELSE IF @GiftType = 3 AND @MemberType=3 --自动提交100简历下载订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 100,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 9
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=100 AND MaxValue>=100) OR (MinValue<=100 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- IF @dcFeeDetailsID IS NULL
- SELECT TOP 1 @Accounts = Price * 100
- FROM dcFee WITH(NOLOCK)
- WHERE type = 9
- AND dcProvinceID = LEFT(@ProvinceID,2)
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- 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
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
- VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
- 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,100,100,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
- SET @NewOrderID = @@IDENTITY
- END
- ELSE IF @GiftType = 4 AND @MemberType=3 --自动提交200简历下载订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 200,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 9
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=50 AND MaxValue>=200) OR (MinValue<=200 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- IF @dcFeeDetailsID IS NULL
- SELECT TOP 1 @Accounts = Price * 200
- FROM dcFee WITH(NOLOCK)
- WHERE type = 9
- AND dcProvinceID = LEFT(@ProvinceID,2)
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- 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
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
- VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
- 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,200,200,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
- SET @NewOrderID = @@IDENTITY
- END
- ELSE IF @GiftType = 6 --自动提交2周固定位置订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 2,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 7
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- DECLARE @FixBeginDate SMALLDATETIME
- --取最后一个固定位置的订单
- 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
- SET @FixBeginDate=ISNULL(@FixBeginDate,GETDATE())
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
- VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
- 7,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,@FixBeginDate,DATEADD(DAY,14,@FixBeginDate),GETDATE(),116,4)
- SET @NewOrderID = @@IDENTITY
- END
- ELSE IF @GiftType = 7 --自动提交2周职位置顶订单,职位默认取最新发布的,前台企业选择后再修改
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 2,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 22
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- DECLARE @JobID INT
- 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())
- IF @JobID >0
- BEGIN
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
- VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
- 12,@Accounts,0,@JobID,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
- SET @NewOrderID = @@IDENTITY
- END
- END
- ELSE IF @GiftType = 8 --自动提交2周职位刷新订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 2,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 24
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- DECLARE @RefreshBeginDate SMALLDATETIME
- --取最后一个固定位置的订单
- 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
- SET @RefreshBeginDate=ISNULL(@RefreshBeginDate,GETDATE())
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
- VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
- 13,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,@RefreshBeginDate,DATEADD(DAY,14,@RefreshBeginDate),GETDATE(),116,4)
- SET @NewOrderID = @@IDENTITY
- END
- ELSE IF @GiftType = 10 --自动提交VIP订单
- BEGIN
- DECLARE @ActiveQuota INT
- DECLARE @JobNumber INT
- DECLARE @UserNumber INT
- --取本省份价格最便宜的季度套餐
- SELECT TOP 1 @dcFeeDetailsID = b.ID,
- @Accounts = (a.PriceMonth * b.[Month]+b.ResumeNumber*a.PriceResume+JobNumber*a.PriceJob+UserNumber*a.PriceUser),
- @ActiveQuota = b.ResumeNumber,
- @JobNumber = b.JobNumber,
- @UserNumber = b.UserNumber
- FROM dcVip a WITH(NOLOCK),dcVipDetail b WITH(NOLOCK)
- WHERE a.id = b.dcVipId
- AND dcProvinceid=@ProvinceID
- AND b.[Month]=3
- AND startDate<GETDATE()
- AND enddate > GETDATE()
- ORDER BY Price
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
- VALUES(@cpMainID,@ProvinceID,NULL,NULL,@PayMethod,@UserNumber,
- 8,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,@ActiveQuota,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
- SET @NewOrderID = @@IDENTITY
- END
-
- BEGIN TRY
- IF @GiftType<>12
- BEGIN
- --奖品类型:1、50职位并发 2、50份简历 3、100份简历 4、200份简历 5、4周六分之一图片 6、2周文字广告 7、2周职位置顶
- --8、2周职位自动刷新 9、4周六分之二 10、Vip会员—季度
- DECLARE @GiftName VARCHAR(50)
- IF @GiftType =1
- BEGIN
- SET @GiftName = '50职位并发'
- END
- ELSE IF @GiftType =2
- BEGIN
- SET @GiftName = '50份简历'
- END
- ELSE IF @GiftType =3
- BEGIN
- SET @GiftName = '100份简历'
- END
- ELSE IF @GiftType =4
- BEGIN
- SET @GiftName = '200份简历 '
- END
- ELSE IF @GiftType =5
- BEGIN
- SET @GiftName = '4周六分之一图片广告'
- END
- ELSE IF @GiftType =6
- BEGIN
- SET @GiftName = '2周文字广告'
- END
- ELSE IF @GiftType =7
- BEGIN
- SET @GiftName = '2周职位置顶'
- END
- ELSE IF @GiftType =8
- BEGIN
- SET @GiftName = '2周职位自动刷新'
- END
- ELSE IF @GiftType =9
- BEGIN
- SET @GiftName = '4周六分之二'
- END
- ELSE IF @GiftType =10
- BEGIN
- SET @GiftName = 'Vip会员—季度'
- END
-
- IF @Manageruserid IS NULL
- BEGIN
- INSERT INTO rtxnotifylog
- SELECT STUFF((SELECT ','+LTRIM(x.ID) FROM Manageruser x WHERE ID IN (180,181,182) FOR XML PATH('')),1,1,'')
- ,'中奖通知',@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()
- END
- ELSE
- BEGIN
- INSERT INTO rtxnotifylog
- SELECT @Manageruserid
- ,'中奖通知',@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()
- END
- Update caOrder Set InvoiceConfirmDate=GetDate(),InvoiceConfirmMan=116,InvoiceAskDate=Null,NeedInvoice=0 Where ID=@NewOrderID
- END
- END TRY
- BEGIN CATCH
-
- END CATCH
- --更新LotteryCompany,保存订单号和中奖类型
- UPDATE LotteryCompany SET GiftOrderID=@NewOrderID,[type]=@GiftType WHERE ID= @LotteryID
- RETURN @GiftType
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccLotteryCompanyUpdate2017] Script Date: 2018/12/13 19:07:13 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --创建人:Lucifer
- --创建时间:2017-10-9
- --企业17周年抽奖
- --奖项内容: VIP会员 普通会员
- --50职位并发 15% 0%
- --50份简历 15% 0%
- --100条短信数 13% 0%
- --2周六分之一图片 10% 10%
- --2周知名企业 10% 15%
- --2周职位置顶 5% 5%
- --200次职位刷新 20% 15%
- --2周六分之二图片 10% 10%
- --满1000-50优惠券 2% 45%
- --Vip会员—三个月 特殊
- --九阳煮蛋器 特殊
- --小米充电宝 特殊
- --小涴熊电热饭盒 特殊
- --美的豆浆机 特殊
- --九阳榨汁机 特殊
- --特殊奖项时间定为: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个。
- --保险公司,培训公司,代理招聘类公司仅能够中奖的范围:职位数、简历数、短信数、自动刷新。其他内容不允许抽中。需要在抽选中排除。
- --50职位并发 30%
- --50份简历 20%
- --100份短信数 10%
- --100次自动刷新 40%
- --奖品类型: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、没中奖
- --lucifer 2018-2-23
- CREATE PROCEDURE [dbo].[ccLotteryCompanyUpdate2017]
- (
- @caMainID INT
- )
- AS
- BEGIN
- DECLARE @LotteryID INT
- DECLARE @cpMainID INT
- 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)
- IF @LotteryID IS NULL
- RETURN -1 --没有抽奖次数
- UPDATE LotteryCompany SET Used = 1,LotteryDate = GETDATE() WHERE ID = @LotteryID --更新状态 防止重复抽奖
- ------------------****************生成抽奖结果****************-----------------
- DECLARE @IsAgent TINYINT --是否是保险公司
- DECLARE @IsVip TINYINT --是否是VIP
- DECLARE @ProvinceId SMALLINT
- DECLARE @Name NVARCHAR(200)
- 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
- IF @IsAgent = 0
- BEGIN
- IF @Name LIKE '%人寿%' OR @Name LIKE '%保险%'
- SET @IsAgent = 1
- END
-
- DECLARE @GiftNo INT, @GiftType INT, @LoopCount INT
- SELECT @GiftNo = CAST((RAND()*999+1) AS INT) --生成抽奖的数字
- SELECT @GiftType = dbo.GetLotteryGiftType(@IsAgent, @GiftNo, @IsVip)
- SET @LoopCount = 0
- WHILE EXISTS(SELECT 'X' FROM LotteryCompany WHERE [Type] = @GiftType AND cpMainID = @cpMainID) OR @LoopCount < 1000
- BEGIN
- SELECT @GiftNo = CAST((RAND()*999 + 1) AS INT) --生成抽奖的数字
- SELECT @GiftType = dbo.GetLotteryGiftType(@IsAgent, @GiftNo, @IsVip)
- SET @LoopCount = @LoopCount + 1
- END
- --特殊奖项时间定为: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个。
- DECLARE @Today VARCHAR(4)
- SELECT @Today = RIGHT(CONVERT(VARCHAR(8), GETDATE(), 112), 4)
- IF @IsVip = 1 AND @IsAgent = 0
- BEGIN
- IF @ProvinceId = 32
- BEGIN
- 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))
- SET @Today='1234'
- END
- ELSE
- BEGIN
- 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))
- SET @Today='1234'
- END
- IF @Today = '1008'
- BEGIN
- IF @ProvinceId = 32
- BEGIN
- 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))
- BEGIN
- 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
- SELECT @GiftType = 3
- END
- 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)
- SELECT @GiftType = 14
- END
- ELSE
- BEGIN
- 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))
- BEGIN
- 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
- SELECT @GiftType = 3
- END
- 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)
- SELECT @GiftType = 14
- END
- END
- ELSE IF @Today = '1015'
- BEGIN
- IF @ProvinceId = 32
- BEGIN
- 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))
- BEGIN
- 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
- SELECT @GiftType = 10
- END
- 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)
- SELECT @GiftType = 15
- END
- ELSE
- BEGIN
- 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))
- BEGIN
- 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
- SELECT @GiftType = 10
- END
- 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)
- SELECT @GiftType = 15
- END
- END
- ELSE IF @Today = '1025'
- BEGIN
- IF @ProvinceId = 32
- BEGIN
- 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))
- BEGIN
- 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
- SELECT @GiftType = 12
- END
- 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))
- BEGIN
- 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
- SELECT @GiftType = 13
- END
- END
- ELSE
- BEGIN
- 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))
- BEGIN
- 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
- SELECT @GiftType = 12
- END
- 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))
- BEGIN
- 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
- SELECT @GiftType = 13
- END
- END
- END
-
- END
- -- IF @IsVip = 1
- -- BEGIN
- -- IF (SELECT COUNT(1) FROM LotteryCompany WHERE cpMainID=@cpMainID AND caOrderID IS NULL) >= 2
- -- SELECT @GiftType = 99
- -- END
- -- ELSE
- -- BEGIN
- -- IF (SELECT COUNT(1) FROM LotteryCompany WHERE cpMainID=@cpMainID AND caOrderID IS NULL) >= 1
- -- SELECT @GiftType = 99
- -- END
- --每个企业最多中奖3次
- IF (SELECT COUNT(1) FROM maindb..LotteryCompany WHERE cpMainID = @cpMainID AND AddDate>'2018-09-26 00:00:00' AND LotteryDate IS NOT NULL) >= 4
- SELECT @GiftType = 99
- PRINT @GiftType
- /*---------****************自动提交订单**************-------------*/
- DECLARE @PayMethod INT --取上次订单的付款方式
- DECLARE @LinkMan NVARCHAR(50)
- DECLARE @Telephone NVARCHAR(50)
- DECLARE @CompanyName NVARCHAR(50)
- DECLARE @Accounts NUMERIC(18,2)
- DECLARE @dcFeeDetailsID INT
- DECLARE @Manageruserid INT
- DECLARE @MemberType INT
- DECLARE @MainOrderID INT
- DECLARE @InvoiceCompany NVARCHAR(50)
- DECLARE @Hour INT
- DECLARE @MainEndDate SMALLDATETIME
- DECLARE @Minute INT
- DECLARE @Code VARCHAR(10)
- DECLARE @RegDate DATETIME
- SELECT TOP 1
- @ProvinceID = b.dcProvinceID,
- @PayMethod = c.PayMethod,
- @MemberType = MemberType,
- @LinkMan = LinkMan,
- @Telephone = Telephone,
- @CompanyName = b.[Name],
- @InvoiceCompany = InvoiceCompany,
- @Manageruserid = ConsultantID,
- @RegDate = RegDate
- FROM cpMain b ,caOrder c
- WHERE b.id = c.cpmainid
- AND c.cpMainID = @cpMainID
- AND Paid > 0
- ORDER BY c.ID DESC
- IF @CompanyName IS NULL
- BEGIN
- SELECT TOP 1
- @ProvinceID = dcProvinceID,
- @PayMethod = 1,
- @MemberType = MemberType,
- @CompanyName = [Name],
- @InvoiceCompany = 4,
- @Manageruserid = ConsultantID,
- @RegDate = RegDate
- FROM cpMain
- WHERE ID = @cpMainID
- END
- SELECT TOP 1
- @LinkMan = LinkMan,
- @Telephone = Mobile
- FROM LotteryCompany WHERE cpMainID = @cpMainID AND AddDate>'2018-09-26 00:00:00' AND LinkMan IS NOT NULL
-
- SELECT @Hour = DATEPART(HOUR,@RegDate)
- SELECT @Minute = DATEPART(Minute,@RegDate)
-
- SET @Code = CONVERT(VARCHAR(10),@Hour*100+@Minute)
-
- SET @PayMethod = 7
- DECLARE @NewOrderID INT
- IF @GiftType = 1 AND @MemberType = 3 --自动提交50个职位并发数的订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 50,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 10
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue <= 50 AND MaxValue >= 50) OR (MinValue <= 50 AND MaxValue = 0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- SELECT TOP 1 @MainOrderID = ID, @MainEndDate = EndDate FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
- VALUES(@cpMainID,@ProvinceID,NULL,NULL,@PayMethod,0,
- 10,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,50,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,GETDATE(),@MainEndDate,GETDATE(),116,4)
- SET @NewOrderID = @@IDENTITY
- END
- ELSE IF @GiftType = 5 --自动提交2周1/6图片 广告
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 4,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 4
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=4 AND MaxValue>=4) OR (MinValue<=4 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
- VALUES(@cpMainID,@ProvinceID,6,2,@PayMethod,0,
- 4,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
- SET @NewOrderID = @@IDENTITY
- END
- ELSE IF @GiftType = 9 --自动提交2周2/6图片 广告
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 4,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 4
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=4 AND MaxValue>=4) OR (MinValue<=4 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
- VALUES(@cpMainID,@ProvinceID,7,2,@PayMethod,0,
- 4,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
- SET @NewOrderID = @@IDENTITY
- END
- ELSE IF @GiftType = 2 AND @MemberType = 3 --自动提交50简历下载订单
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 50,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 9
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=50 AND MaxValue>=50) OR (MinValue<=50 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- IF @dcFeeDetailsID IS NULL
- SELECT TOP 1 @Accounts = Price * 50
- FROM dcFee WITH(NOLOCK)
- WHERE type = 9
- AND dcProvinceID = LEFT(@ProvinceID,2)
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- 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
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
- VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
- 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,50,50,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
- SET @NewOrderID = @@IDENTITY
- END
- --ELSE IF @GiftType = 3 AND @MemberType = 3 --自动提交100简历下载订单
- --BEGIN
- -- --取原价和对应的资费ID
- -- SELECT TOP 1 @Accounts = b.Price * 100,
- -- @dcFeeDetailsID = a.ID
- -- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- -- WHERE b.type = 9
- -- AND a.dcFeeID = b.ID
- -- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- -- AND ((MinValue<=100 AND MaxValue>=100) OR (MinValue<=100 AND MaxValue=0))
- -- AND StartDate < GETDATE() AND EndDate > GETDATE()
- -- IF @dcFeeDetailsID IS NULL
- -- SELECT TOP 1 @Accounts = Price * 100
- -- FROM dcFee WITH(NOLOCK)
- -- WHERE type = 9
- -- AND dcProvinceID = LEFT(@ProvinceID,2)
- -- AND StartDate < GETDATE() AND EndDate > GETDATE()
- -- 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
- -- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- -- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
- -- VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
- -- 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,100,100,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
- -- SET @NewOrderID = @@IDENTITY
- --END
- --ELSE IF @GiftType = 4 AND @MemberType = 3 --自动提交200简历下载订单
- --BEGIN
- -- --取原价和对应的资费ID
- -- SELECT TOP 1 @Accounts = b.Price * 200,
- -- @dcFeeDetailsID = a.ID
- -- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- -- WHERE b.type = 9
- -- AND a.dcFeeID = b.ID
- -- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- -- AND ((MinValue<=50 AND MaxValue>=200) OR (MinValue<=200 AND MaxValue=0))
- -- AND StartDate < GETDATE() AND EndDate > GETDATE()
- -- IF @dcFeeDetailsID IS NULL
- -- SELECT TOP 1 @Accounts = Price * 200
- -- FROM dcFee WITH(NOLOCK)
- -- WHERE type = 9
- -- AND dcProvinceID = LEFT(@ProvinceID,2)
- -- AND StartDate < GETDATE() AND EndDate > GETDATE()
- -- 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
- -- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- -- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID)
- -- VALUES(@cpMainID,@ProvinceID,null,null,@PayMethod,0,
- -- 9,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,200,200,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID)
- -- SET @NewOrderID = @@IDENTITY
- --END
- ELSE IF @GiftType = 4 --100条短信数
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 200,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 14
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- --取最后一个固定位置的订单
- SELECT TOP 1 @MainOrderID = ID, @MainEndDate = EndDate FROM CaOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND EndDate>GETDATE() AND OrderType = 8 ORDER BY EndDate DESC
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PayMethod,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,EndDate,SmsQuota,RemainSmsQuota,OrderStatus)
- VALUES(@cpMainID,@ProvinceID,null,@PayMethod,
- 14,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,@MainEndDate,100,100,0)
- SET @NewOrderID = @@IDENTITY
- END
- ELSE IF @GiftType = 6 --自动提交2周知名企业
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 2,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 7
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- DECLARE @FixBeginDate SMALLDATETIME
- --取最后一个固定位置的订单
- 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
- SET @FixBeginDate=ISNULL(@FixBeginDate,GETDATE())
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,BeginDate,EndDate,OpenDate,OpenMan,OrderStatus)
- VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
- 7,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,@FixBeginDate,DATEADD(DAY,14,@FixBeginDate),GETDATE(),116,4)
- SET @NewOrderID = @@IDENTITY
- END
- ELSE IF @GiftType = 7 --自动提交2周职位置顶订单,职位默认取最新发布的,前台企业选择后再修改
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 2,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 22
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND ((MinValue<=2 AND MaxValue>=2) OR (MinValue<=2 AND MaxValue=0))
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- DECLARE @JobID INT
- 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())
- IF @JobID >0
- BEGIN
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
- VALUES(@cpMainID,@ProvinceID,null,2,@PayMethod,0,
- 12,@Accounts,0,@JobID,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
- SET @NewOrderID = @@IDENTITY
- END
- END
- ELSE IF @GiftType = 8 --200次职位刷新
- BEGIN
- --取原价和对应的资费ID
- SELECT TOP 1 @Accounts = b.Price * 200,
- @dcFeeDetailsID = a.ID
- FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
- WHERE b.type = 15
- AND a.dcFeeID = b.ID
- AND b.dcProvinceID = LEFT(@ProvinceID,2)
- AND StartDate < GETDATE() AND EndDate > GETDATE()
- DECLARE @RefreshBeginDate SMALLDATETIME
- --取最后一个固定位置的订单
- 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
- SET @RefreshBeginDate=ISNULL(@RefreshBeginDate,GETDATE())
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PayMethod,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,jobRefreshQuota,remainJobRefreshQuota,OrderStatus)
- VALUES(@cpMainID,@ProvinceID,null,@PayMethod,
- 15,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,0,0,0,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,200,200,0)
- SET @NewOrderID = @@IDENTITY
- END
- ELSE IF @GiftType = 3 --自动提交VIP订单(3个月)
- BEGIN
- DECLARE @ActiveQuota INT
- DECLARE @JobNumber INT
- DECLARE @UserNumber INT
- --取本省份价格最便宜的季度套餐
- SELECT TOP 1 @dcFeeDetailsID = b.ID,
- @Accounts = (a.PriceMonth * b.[Month]+b.ResumeNumber*a.PriceResume+JobNumber*a.PriceJob+UserNumber*a.PriceUser),
- @ActiveQuota = b.ResumeNumber,
- @JobNumber = b.JobNumber,
- @UserNumber = b.UserNumber
- FROM dcVip a WITH(NOLOCK),dcVipDetail b WITH(NOLOCK)
- WHERE a.id = b.dcVipId
- AND dcProvinceid=@ProvinceID
- AND b.[Month]=3
- AND startDate<GETDATE()
- AND enddate > GETDATE()
- ORDER BY Price
- INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,UserNumber,
- OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,dcFeeDetailID,NeedInvoice)
- VALUES(@cpMainID,@ProvinceID,NULL,NULL,@PayMethod,@UserNumber,
- 8,@Accounts,0,0,@LinkMan,@Telephone,'',@Manageruserid,@ActiveQuota,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,@dcFeeDetailsID,0)
- SET @NewOrderID = @@IDENTITY
- END
- --奖品类型: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、没中奖
- BEGIN TRY
- IF @GiftType <> 99
- BEGIN
- DECLARE @GiftName VARCHAR(50)
- IF @GiftType = 1
- BEGIN
- SET @GiftName = '50职位并发'
- END
- ELSE IF @GiftType = 2
- BEGIN
- SET @GiftName = '50份简历'
- END
- ELSE IF @GiftType = 3
- BEGIN
- SET @GiftName = 'Vip会员—三个月'
- END
- ELSE IF @GiftType = 4
- BEGIN
- SET @GiftName = '100条短信数'
- END
- ELSE IF @GiftType = 5
- BEGIN
- SET @GiftName = '2周六分之一图片广告'
- END
- ELSE IF @GiftType = 6
- BEGIN
- SET @GiftName = '2周知名企业'
- END
- ELSE IF @GiftType = 7
- BEGIN
- SET @GiftName = '2周职位置顶'
- END
- ELSE IF @GiftType = 8
- BEGIN
- SET @GiftName = '200次职位刷新'
- END
- ELSE IF @GiftType = 9
- BEGIN
- SET @GiftName = '2周六分之二'
- END
- ELSE IF @GiftType = 10
- BEGIN
- SET @GiftName = '九阳煮蛋器'
- END
- ELSE IF @GiftType = 11
- BEGIN
- SET @GiftName = '满1000-50优惠券'
- END
- ELSE IF @GiftType = 12
- BEGIN
- SET @GiftName = '小米充电宝'
- END
- ELSE IF @GiftType = 13
- BEGIN
- SET @GiftName = '小涴熊电热饭盒'
- END
- ELSE IF @GiftType = 14
- BEGIN
- SET @GiftName = '美的豆浆机'
- END
- ELSE IF @GiftType = 15
- BEGIN
- SET @GiftName = '九阳榨汁机'
- END
-
- IF @Manageruserid IS NULL
- BEGIN
- INSERT INTO rtxnotifylog
- SELECT STUFF((SELECT ','+LTRIM(x.ID) FROM Manageruser x WHERE ID IN (180,182) FOR XML PATH('')),1,1,'')
- ,'中奖通知',@CompanyName+'('+LTRIM(STR(@cpMainID))+')中奖了,奖品为[' + @GiftName + '],请及时处理http://sysback.51rc.com/yehgiiaovbjkaie871/cp/cpMainInfo.asp?id='+LTRIM(STR(@cpMainID))+'&code=' + @Code,1,0,0,null,getdate()
- END
- ELSE
- BEGIN
- INSERT INTO rtxnotifylog
- SELECT @Manageruserid
- ,'中奖通知',@CompanyName+'('+LTRIM(STR(@cpMainID))+')中奖了,奖品为[' + @GiftName + '],请及时处理http://sysback.51rc.com/yehgiiaovbjkaie871/cp/cpMainInfo.asp?id='+LTRIM(STR(@cpMainID))+'&code=' + @Code,1,0,0,null,getdate()
- END
- Update caOrder Set InvoiceConfirmDate=GetDate(),InvoiceConfirmMan=116,InvoiceAskDate=Null,NeedInvoice=0 Where ID=@NewOrderID
- END
- END TRY
- BEGIN CATCH
-
- END CATCH
- --更新LotteryCompany,保存订单号和中奖类型
- UPDATE LotteryCompany SET GiftOrderID = @NewOrderID,[type] = @GiftType WHERE ID= @LotteryID
- RETURN @GiftType
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccManagerLogByIpSelect] Script Date: 2018/12/13 19:07:14 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- /*********************
- SEAN 2014-10-29
- **********************/
- CREATE PROCEDURE [dbo].[ccManagerLogByIpSelect]
- (
- @Ip VARCHAR(15)
- )
- AS
- --INSERT INTO procLog SELECT 'ccManagerLogByIpSelect', '', GETDATE()
- BEGIN
- SELECT * FROM ManagerLog WITH(NOLOCK) WHERE LoginDate > GETDATE() - 0.1 AND ip = @IP
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccManagerUserByIdSelect] Script Date: 2018/12/13 19:07:14 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- /**********************8
- sean 2014-10-29
- ***********************/
- CREATE PROCEDURE [dbo].[ccManagerUserByIdSelect]
- (
- @ID INT
- )
- AS
- --INSERT INTO procLog SELECT 'ccManagerUserByIdSelect', '', GETDATE()
- BEGIN
- SELECT ID,Name ShowName,ID ShowID, Name UserName
- FROM Manageruser WITH(NOLOCK)
- WHERE ID = @ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccManagerUserIDSelect] Script Date: 2018/12/13 19:07:14 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.30
- --创建人:Nick
- --说明://得到客服id
- --#####################################################
- CREATE PROCEDURE [dbo].[ccManagerUserIDSelect]
- AS
- BEGIN
- SELECT id FROM ManagerUser WITH(NOLOCK) WHERE Type=5 AND (Status=1 OR Status=2)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccManagerUserSuperiorByID] Script Date: 2018/12/13 19:07:14 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.30
- --创建人:Nick
- --说明:得到招聘顾问上级的ID
- --#####################################################
- CREATE PROCEDURE [dbo].[ccManagerUserSuperiorByID]
- (
- @ID INT
- )
- AS
- BEGIN TRY
- SELECT Superior FROM ManagerUser WITH(NOLOCK) WHERE ID = @ID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ccMessageC2pCountSelect] Script Date: 2018/12/13 19:07:14 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --Lambo 20101122
- --查询单位在两个月内留言的数量
- --用户简历显示页面,单位给求职者浏览,普通用户两个月内只能发100个留言
- CREATE PROCEDURE [dbo].[ccMessageC2pCountSelect]
- (
- @cpMainID INT
- )
- AS
- BEGIN
- DECLARE @MessageCount INT
- SELECT @MessageCount=COUNT(*) FROM exMessageC2P WITH(NOLOCK)
- WHERE caMainID in (SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID)
- AND AddDate >=DateAdd(Month,-2,GETDATE())
- ------PRINT @MessageCount
- RETURN @MessageCount
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccNVexMessageLogSelect] Script Date: 2018/12/13 19:07:14 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccNVexMessageLogSelect]
- (
- @paMainID INT,
- @caMainID INT
- )
- AS
- BEGIN
- SELECT * FROM (
- SELECT cvMainID,ID,addDate,Message,1 IsCompany,IsViewed FROM exMessageC2p WITH(NOLOCK)
- WHERE cvMainID IN(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID=@paMainID) AND caMainID=@caMainID
- AND CompanyDeleted=0
- UNION
- SELECT cvMainID,ID,addDate,Message,0 IsCompany,IsViewed FROM exMessageP2C WITH(NOLOCK)
- WHERE cvMainID IN(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID=@paMainID) AND caMainID=@caMainID
- AND CompanyDeleted=0
- ) a ORDER BY a.AddDate
- UPDATE exMessageP2c SET isViewed = 1 WHERE cvMainID IN(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID=@paMainID) AND caMainID=@caMainID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccNVpaMainByexMessageP2CCaMainIdSelectNew] Script Date: 2018/12/13 19:07:15 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccNVpaMainByexMessageP2CCaMainIdSelectNew]
- (
- @caMainID INT,
- @Where VARCHAR(100)
- )
- AS
- BEGIN
- BEGIN TRY
- DECLARE @SQL AS VARCHAR(MAX)
- DECLARE @cpMainID AS INT
- CREATE TABLE #T1(
- paMainID INT,
- cvMainID INT,
- paName NVARCHAR(20),
- AddDate DATETIME,
- Message VARCHAR(500),
- isC2P INT,
- hasJobApply INT,
- hasInterview INT,
- hasRemark INT,
- hasFavorate INT,
- isViewed INT
- )
- --该用户所有聊天信息保存至临时表
- INSERT INTO #T1(paMainID,cvMainID,paName,AddDate,Message,isC2P,isViewed)
- SELECT c.ID paMainID,b.ID cvMainID,c.Name,a.AddDate,a.Message,1 isC2P,isViewed
- FROM exMessageC2p a WITH(NOLOCK),
- cvMain b WITH(NOLOCK),
- paMain c WITH(NOLOCK)
- WHERE a.cvMainID=b.ID
- AND b.paMainID=c.ID
- AND caMainID=@caMainID
- AND CompanyDeleted=0
- UNION
- SELECT c.ID paMainID,b.ID cvMainID,c.Name,a.AddDate,a.Message,0 isC2P,isViewed
- FROM exMessageP2c a WITH(NOLOCK),
- cvMain b WITH(NOLOCK),
- paMain c WITH(NOLOCK)
- WHERE a.cvMainID=b.ID
- AND b.paMainID=c.ID
- AND caMainID=@caMainID
- AND CompanyDeleted=0
- SELECT @cpMainID=cpMainID FROM caMain WHERE ID=@caMainID
- UPDATE #T1 SET paName = LEFT(dbo.GetPaName(cvMainID, @cpMainID), 20),
- 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),
- 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),
- HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T1.cvMainID),
- HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T1.cvMainID)
- CREATE TABLE #T2(
- paMainID INT,
- MsgCount INT,
- MsgUnRead INT
- )
- --保存数量
- INSERT INTO #T2 SELECT paMainID,Count(*),0 FROM #T1 GROUP BY paMainID
- --保存未读数量
- UPDATE #T2 SET MsgUnRead = (SELECT COUNT(*) FROM #T1 WHERE isC2p = 0 AND isViewed = 0 AND #T1.paMainID = #T2.paMainID GROUP BY paMainID)
-
- SET @SQL = '
- 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
- (
- 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
- ) a,paMain b WITH(NOLOCK),#T2 c WITH(NOLOCK),dcRegion d WITH(NOLOCK)
- WHERE a.RowNumber=1 AND a.paMainID=b.ID AND c.paMainID=a.paMainID AND d.ID=b.AccountPlace '
- IF LEN(@Where) > 0
- BEGIN
- SET @Where = dbo.SafeSql(@Where)
- SET @SQL = @SQL + @Where
- END
- SET @SQL=@SQL+' ORDER BY a.AddDate DESC'
- EXEC(@SQL)
- DROP TABLE #T1
- DROP TABLE #T2
- END TRY
- BEGIN CATCH
- DROP TABLE #T1
- DROP TABLE #T2
- END CATCH
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccNVpaMainByexMessageP2CPaMainIdSelectNew] Script Date: 2018/12/13 19:07:15 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccNVpaMainByexMessageP2CPaMainIdSelectNew]
- (
- @cvMainID INT,
- @caMainID INT
- )
- AS
- BEGIN
- BEGIN TRY
- DECLARE @cpMainID AS INT
- CREATE TABLE #T(
- paMainID INT,
- cvMainID INT,
- AccountPlace NVARCHAR(20),
- Gender BIT,
- Birthday INT,
- Degree NVARCHAR(10),
- RelatedYears INT,
- paName NVARCHAR(20),
- hasJobApply INT,
- hasInterview INT,
- hasRemark INT,
- hasFavorate INT
- )
- --该用户基本信息保存至临时表
- INSERT INTO #T(paMainID,cvMainID,AccountPlace,Gender,Birthday,Degree,RelatedYears,paName)
- SELECT a.ID paMainID,b.ID cvMainID,d.FullName AccountPlace,a.Gender,a.Birthday,c.Description Degree,b.RelatedWorkYears,a.Name
- FROM paMain a WITH(NOLOCK)
- left join cvMain b WITH(NOLOCK) on a.ID=b.paMainID
- left join dcEducation c WITH(NOLOCK) on b.Degree=c.ID
- left join dcRegion d WITH(NOLOCK) on a.AccountPlace=d.ID
- WHERE
- b.ID=@cvMainID
- SELECT @cpMainID=cpMainID FROM caMain WHERE ID=@caMainID
- UPDATE #T SET paName = LEFT(dbo.GetPaName(cvMainID, @cpMainID), 20),
- 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),
- 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),
- HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
- HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
- SELECT * FROM #T
-
- DROP TABLE #T
- END TRY
- BEGIN CATCH
- DROP TABLE #T
- END CATCH
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccPaAttentionSelect] Script Date: 2018/12/13 19:07:15 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --Nick 20151120
- --企业关注列表
- CREATE PROCEDURE [dbo].[ccPaAttentionSelect]
- (
- @WHERE VARCHAR(1000),
- @Order VARCHAR(100),
- @Page SMALLINT,
- @caMainID INT,
- @cpMainID INT,
- @AttentionType SMALLINT --1关注企业 2关注职位
- )
- AS
- SET NOCOUNT ON
- BEGIN
- SET @Where = dbo.SafeSql(@Where)
- SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '''''')
-
- DECLARE @SQL AS VARCHAR(2000)
- CREATE TABLE #T(
- TitleID BIGINT,
- ID INT,
- paMainID INT,
- cvMainID INT,
- AddDate SMALLDATETIME,
- IsMatched BIT,
- Degree TINYINT,
- RelatedWorkYears TINYINT,
- LivePlace NVARCHAR(50),
- Gender BIT,
- paName NVARCHAR(20),
- BirthDay INT,
- HasPhoto TINYINT,
- Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
- IsNameHidden BIT,
- Valid TINYINT,
- IsViewed BIT,
- HasJobApply BIT,
- HasInterview BIT,
- HasRemark BIT,
- HasFavorate BIT,
- cvEducationID INT,
- College NVARCHAR(50),
- EduType TINYINT,
- MajorName NVARCHAR(20),
- Graduation INT,
- Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- cvMatch INT,
- RecruitmentID INT,
- RecruitmentName NVARCHAR(100),
- RecruitmentDate SMALLDATETIME,
- MobileVerifyDate SMALLDATETIME,
- IsOnline BIT,
- JobID INT,
- JobName VARCHAR(50),
- HasWeiXin BIT,
- SecondId VARCHAR(10)
- )
- IF @AttentionType = 1 --企业
- BEGIN
- SET @SQL='
- INSERT INTO #T
- (TitleID, ID, paMainID, AddDate, LivePlace, Gender,
- BirthDay, HasPhoto, MobileVerifyDate, IsOnline)
- SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, c.ID, a.AddDate, c.LivePlace,
- c.Gender, c.BirthDay, c.HasPhoto, c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID)
- FROM paAttention a WITH(NOLOCK), paMain c WITH(NOLOCK)
- WHERE a.paMainID = c.ID AND AttentionType = 1 AND AttentionID = '+CONVERT(VARCHAR(20), @cpMainID)
- --PRINT @SQL
- IF LEN(@WHERE) > 0
- SET @SQL = @SQL + ' AND ' + @WHERE
- SET @SQL = @SQL + 'ORDER BY a.AddDate '
- EXEC(@SQL)
- END
- ELSE
- BEGIN
- SET @SQL='
- INSERT INTO #T
- (TitleID, ID, paMainID, AddDate, LivePlace, Gender,
- BirthDay, HasPhoto, MobileVerifyDate, IsOnline, JobID, JobName)
- SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, c.ID, a.AddDate, c.LivePlace,
- c.Gender, c.BirthDay, c.HasPhoto, c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID), b.ID, b.Name
- FROM paAttention a WITH(NOLOCK), Job b WITH(NOLOCK), paMain c WITH(NOLOCK)
- WHERE a.paMainID = c.ID
- AND AttentionType = 2
- AND a.AttentionID = b.ID
- AND b.IsDelete = 0'
- IF LEN(@WHERE) > 0
- SET @SQL = @SQL + ' AND '+@WHERE
- SET @SQL = @SQL + ' ORDER BY a.AddDate '
- --PRINT @SQL
- EXEC(@SQL)
- END
- --修改cvmainID
- UPDATE a SET CvMainID = (
- SELECT TOP 1 ID FROM CvMain WITH(NOLOCK)
- WHERE PaMainID = a.PaMainID
- AND (Valid > 0 OR substring(CvLevel, 0, 6)='111111' OR substring(CvLevel, 0, 6) = '111101' )
- ORDER BY RefreshDate DESC
- ) FROM #T a
- UPDATE a
- SET CvMainID = (SELECT TOP 1 ID FROM CvMain WITH(NOLOCK)
- WHERE PaMainID = a.PaMainID
- ORDER BY RefreshDate DESC, Id DESC),
- SecondId = (SELECT TOP 1 SecondId FROM CvMain WITH(NOLOCK)
- WHERE PaMainID = a.PaMainID
- ORDER BY RefreshDate DESC, Id DESC)
- FROM #T a
- DELETE FROM #T WHERE CvMainID IS NULL
- --修改简历信息
- UPDATE a
- SET a.Degree = b.Degree,
- a.RelatedWorkYears = b.RelatedWorkYears,
- a.Attachment = b.Attachment,
- a.IsNameHidden = b.IsNameHidden,
- a.Valid = b.Valid
- FROM #T a, CvMain b
- WHERE a.CvMainID = b.ID
- IF LEN(@WHERE) > 0
- SET @SQL = @SQL + ' AND ' + @WHERE
- IF(@Page < 1)
- SET @Page = 1
- IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
- SET @Page = 1
-
- 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),
- HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
- 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),
- HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
- 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)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE #T SET Speciality = (
- SELECT Speciality FROM cvMain WITH(NOLOCK)
- WHERE cvMain.ID = #T.cvMainID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- UPDATE #T SET Experience = (
- SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
- WHERE cvExperience.cvMainID = #T.cvMainID
- ORDER BY BeginDate DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE #T SET cvEducationID = (
- SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
- WHERE cvEducation.cvMainID = #T.cvMainID
- AND #T.Degree = cvEducation.Degree
- ORDER BY Graduation DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
- a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
- FROM #T a, cvEducation b WITH(NOLOCK)
- WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
-
- --UPDATE a SET a.RecruitmentName = b.RecruitmentName, a.RecruitmentDate = b.EndDate
- --FROM #T a, Recruitment b WITH(NOLOCK)
- --WHERE b.ID = a.RecruitmentID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
-
- --修改是否绑定微信
- UPDATE a SET HasWeiXin = 1
- FROM #T a, WxFans b WITH(NOLOCK)
- WHERE a.paMainID = b.PaMainID
- AND b.Status = 2
- AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- UPDATE #T SET cvMatch = dbo.GetCvMatch(cvMainID, JobID) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- SELECT COUNT(*) FROM #T WITH(NOLOCK)
- SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- --计算匹配度
- DROP TABLE #T
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccPaBlackByMobileSelect] Script Date: 2018/12/13 19:07:16 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- -- =============================================
- -- 检查: Sean
- -- 日期: 2010-10-5
- -- 描述: 手机黑名单
- -- =============================================
- CREATE PROCEDURE [dbo].[ccPaBlackByMobileSelect]
- AS
- BEGIN
- SELECT Mobile FROM Person_Black WITH(NOLOCK) WHERE ISNULL(Mobile, '') > ''
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccPaJobViewLogBycaMainIDSelect] Script Date: 2018/12/13 19:07:16 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --修改:Andy 2015-01-13
- --1. 去掉try catch
- --2. 添加职位的regionid
- CREATE PROCEDURE [dbo].[ccPaJobViewLogBycaMainIDSelect]
- (
- @caMainID INT,
- @WHERE VARCHAR(1000),
- @ORDER VARCHAR(1000),
- @Page SMALLINT,
- @cpMainID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- IF NOT EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK) WHERE ID = @caMainID AND cpMainID = @cpMainID)
- RETURN 0
-
- SET @Where = dbo.SafeSql(@Where)
- SET @ORDER = dbo.SafeSql(@Order)
- CREATE TABLE #t(
- TitleID BIGINT,
- caMainId INT,
- cvMainId INT,
- jobId INT,
- jobRegionID INT,
- CvJobMatch INT,
- JobName NVARCHAR(50),
- AddDate SMALLDATETIME,
- Degree TINYINT,
- RelatedWorkYears TINYINT,
- LivePlace VARCHAR(6) COLLATE Chinese_PRC_CI_AS,
- Gender BIT,
- paName NVARCHAR(20),
- BirthDay INT,
- HasPhoto TINYINT,
- Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
- IsNameHidden BIT,
- Valid TINYINT,
- IsViewed BIT,
- HasJobApply BIT,
- HasInterview BIT,
- HasRemark BIT,
- HasFavorate BIT,
- cvEducationID INT,
- College NVARCHAR(50),
- EduType TINYINT,
- MajorName NVARCHAR(20),
- Graduation INT,
- Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- MobileVerifyDate SMALLDATETIME,
- IsOnline BIT,
- PaMainID INT,
- HasWeiXin BIT,
- SecondId VARCHAR(100)
- )
- DECLARE @SQL AS VARCHAR(2000)
- SET @SQL='
- INSERT INTO #t(TitleID, caMainID, cvMainID, jobId, jobRegionID, AddDate, JobName,
- MobileVerifyDate, IsOnline, PaMainID, SecondId)
- SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID,
- b.caMainID, d.ID, b.ID, b.dcRegionID, a.AddDate, b.Name,
- c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID), c.ID, d.SecondId
- From PaJobViewLog a WITH(NOLOCK)
- INNER JOIN Job b WITH(NOLOCK) ON b.ID=a.JobID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID=a.paMainID
- INNER JOIN cvMain d WITH(NOLOCK) ON d.paMainID=c.ID AND d.Valid>0'
- SET @SQL = @SQL + '
- WHERE 1=1 '
- IF LEN(@WHERE)> 0
- SET @SQL=@SQL + @WHERE
- --PRINT(@SQL)
- EXEC(@SQL)
- IF(@Page < 1)
- SET @Page = 1
- IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
- SET @Page = 1
- --添加匹配度 Peter 2013-11-12 14:33
- UPDATE #t SET CvJobMatch = dbo.GetCvMatch(cvMainId, jobID), Degree = a.Degree, RelatedWorkYears = a.RelatedWorkYears, Attachment = a.Attachment,
- IsNameHidden = a.IsNameHidden, LivePlace = b.LivePlace, Gender = b.Gender, paName = b.Name,
- BirthDay = b.BirthDay, HasPhoto = b.HasPhoto, Valid = a.Valid
- FROM cvMain a WITH(NOLOCK) INNER JOIN paMain b WITH(NOLOCK) ON a.paMainID = b.ID
- WHERE a.ID = #t.cvMainID AND TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- 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),
- 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),
- 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),
- HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#t.cvMainID),
- HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#t.cvMainID)
- WHERE TitleID > (@Page - 1)*20 AND TitleID <= @Page*20
- UPDATE #T SET Speciality = (
- SELECT Speciality FROM cvMain WITH(NOLOCK)
- WHERE cvMain.ID = #T.cvMainID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- UPDATE #T SET Experience = (
- SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
- WHERE cvExperience.cvMainID = #T.cvMainID
- ORDER BY BeginDate DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE #T SET cvEducationID = (
- SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
- WHERE cvEducation.cvMainID = #T.cvMainID
- AND #T.Degree = cvEducation.Degree
- ORDER BY Graduation DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType= b.EduType,
- a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
- FROM #T a, cvEducation b WITH(NOLOCK)
- WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1) * 20 AND a.TitleID <= @Page*20
- --修改是否绑定微信
- UPDATE a SET HasWeiXin = 1
- FROM #T a, WxFans b WITH(NOLOCK)
- WHERE a.paMainID = b.PaMainID
- AND b.Status = 2
- AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- SELECT COUNT(*) FROM #t WITH(NOLOCK)
- SELECT * FROM #t WITH(NOLOCK) WHERE TitleID > (@Page - 1)*20 AND TitleID <= @Page*20
-
- DROP TABLE #t
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccpaLoginContactByOpenIDSelect] Script Date: 2018/12/13 19:07:16 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2016.4.6
- --创建人:Lucifer
- --说明:判断是否已绑定微信企业账号
- --#####################################################
- CREATE PROCEDURE [dbo].[ccpaLoginContactByOpenIDSelect]
- (
- @OpenID VARCHAR(100)
- )
- AS
- BEGIN
- SELECT * FROM paLoginContact WITH(NOLOCK) WHERE openid = @OpenID AND ContactType = 101
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccpaLoginContactDelete] Script Date: 2018/12/13 19:07:16 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccpaLoginContactDelete]
- (
- @caMainID INT,
- @cpMainID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- IF NOT EXISTS(SELECT 'X' FROM caMain WITH(NOLOCK) WHERE ID = @caMainID AND cpMainID = @cpMainID)
- RETURN
- UPDATE wxFans SET caBindCancelDate = GETDATE() WHERE caMainID = @caMainID
- DELETE FROM paLoginContact WHERE paMainID = @caMainID AND ContactType = 101
- INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@cpMainID,22,-200,GETDATE())
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccPaMainBycpMainIdSelect] Script Date: 2018/12/13 19:07:16 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- /**********************8
- sean 2014-10-29
- ***********************/
- CREATE PROCEDURE [dbo].[ccPaMainBycpMainIdSelect]
- (
- @cvMainID INT,
- @cpMainID INT
- )
- AS
- --INSERT INTO procLog SELECT 'ccPaMainBycpMainIdSelect', LTRIM(STR(@cvMainID)) + ' ' + LTRIM(STR(@cpMainId)), GETDATE()
- BEGIN
- IF (@cpMainID = 0)
- SELECT a.Name UserName, b.ID ShowID, a.Name ShowName, a.ID
- FROM paMain a WITH(NOLOCK),
- cvMain b WITH(NOLOCK)
- WHERE a.ID = b.paMainID
- AND b.ID = @cvMainID
- ELSE
- BEGIN
- DECLARE @RegisterIp VARCHAR(50)
- SELECT @RegisterIp = RegisterIp FROM cpMain WITH(NOLOCK) WHERE Id = @cpMainId
- SELECT dbo.GetPaName(b.ID, @cpMainID) UserName, b.ID ShowID,
- dbo.GetPaName(b.ID, @cpMainID) + '(' + (CASE Gender WHEN 0 THEN '男' WHEN 1 THEN '女' END) + '/' + CONVERT(VARCHAR(5),
- dbo.BirthToAge(BirthDay)) + '岁/' + ISNULL(c.Description, '') + ')' ShowName,
- LOWER(b.SecondId + SUBSTRING(SYS.Fn_VarbinToHexStr(HASHBYTES('SHA1', LTRIM(STR(a.Id)) + '-' + LTRIM(STR(@cpMainId)) + '#' + @RegisterIp + '*')), 13, 10)) HexId
- FROM paMain a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON a.ID = b.paMainID
- LEFT JOIN dcEducation c WITH(NOLOCK) ON b.Degree = c.ID
- WHERE b.ID = @cvMainID
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccPaMainByCvMainIdsSelect] Script Date: 2018/12/13 19:07:17 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --根据简历编号查询个人
- --harry
- --2017-6-12
- CREATE PROCEDURE [dbo].[ccPaMainByCvMainIdsSelect]
- (
- @cvMainIds VARCHAR(200)
- )
- AS
- SET NOCOUNT ON
- BEGIN
- SELECT COUNT(*) AS ReceiveNum FROM paMain WITH (NOLOCK)
- WHERE id IN (SELECT paMainId FROM cvMain WHERE Id IN (SELECT * FROM dbo.FnSplit(@cvMainIds, ',')))
- AND IsReceiveSms > 0
- END
- SET NOCOUNT OFF
-
- GO
- /****** Object: StoredProcedure [dbo].[ccPaMainByGetPaNameSelect] Script Date: 2018/12/13 19:07:17 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --lambo 20110221
- --企业会员中心,根据cvMainID,cpMainID判断是否显示姓名
- CREATE PROCEDURE [dbo].[ccPaMainByGetPaNameSelect]
- (
- @cvMainID INT,
- @cpMainID INT
- )
- AS
- BEGIN
- SELECT dbo.GetPaName(@cvMainID, @cpMainID) Name
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccPaMainByGetPaNameSelect2] Script Date: 2018/12/13 19:07:17 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --lambo 20110221
- --企业会员中心,根据cvMainID,cpMainID判断是否显示姓名
- CREATE PROCEDURE [dbo].[ccPaMainByGetPaNameSelect2]
- (
- @cvMainID VARCHAR(50),
- @cpMainID VARCHAR(50)
- )
- AS
- BEGIN
- SELECT dbo.GetPaName(@cvMainID, @cpMainID) Name
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccPaPlaintByCaMainIDNoViewedSelect] Script Date: 2018/12/13 19:07:17 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --==================================================
- --检查 sean 2010-10-8
- --描述 企业账号未查看的个人用户反馈
- --==================================================
- CREATE PROCEDURE [dbo].[ccPaPlaintByCaMainIDNoViewedSelect]
- (
- @caMainID INT
- )
- AS
- BEGIN
- SELECT *
- FROM PaPlaint WITH(NOLOCK INDEX(IX_paPlaint_caMainID))
- WHERE caMainID = @caMainID
- AND IsViewed=0
- AND ReplyType =1
- ORDER BY ID DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccPaPlaintByCaMainIDSelect] Script Date: 2018/12/13 19:07:17 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --==================================================
- --检查 sean 2010-10-8
- --描述 企业账号查看个人用户反馈
- --==================================================
- CREATE PROCEDURE [dbo].[ccPaPlaintByCaMainIDSelect]
- (
- @caMainID INT
- )
- AS
- BEGIN
- SELECT *
- FROM PaPlaint WITH(NOLOCK INDEX(IX_paPlaint_caMainID))
- WHERE caMainID =@caMainID
- AND ReplyType =1
- ORDER BY ID DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccPaPlaintByCpMainIDNoViewedSelect] Script Date: 2018/12/13 19:07:17 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --==================================================
- --检查 sean 2010-10-8
- --描述 该企业所有账号的未查看的个人用户反馈
- --==================================================
- CREATE PROCEDURE [dbo].[ccPaPlaintByCpMainIDNoViewedSelect]
- (
- @cpMainID INT
- )
- AS
- BEGIN
- SELECT *
- 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
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccPaPlaintByCpMainIDSelect] Script Date: 2018/12/13 19:07:18 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --==================================================
- --检查 sean 2010-10-8
- --描述 该企业所有账号的个人用户反馈
- --==================================================
- CREATE PROCEDURE [dbo].[ccPaPlaintByCpMainIDSelect]
- (
- @cpMainID INT
- )
- AS
- BEGIN
- SELECT a.*,
- b.Name caName
- 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 ReplyType = 1
- AND b.isDelete = 0
- ORDER BY a.CaMainID,a.ID DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccPaplaintByIsViewedUpdate] Script Date: 2018/12/13 19:07:18 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --==================================================
- --检查 sean 2010-10-8
- --描述 修改个人用户反馈的查看状态 ,一次一屏,asp中取所有IsViewed = false的id
- --==================================================
- CREATE PROCEDURE [dbo].[ccPaplaintByIsViewedUpdate]
- (
- @AllID VARCHAR(200),
- @caMainID INT
- )
- AS
- BEGIN TRY
- SET @AllID = dbo.FormatIDS(@AllID)
- DECLARE @T AS TABLE(ID INT)
- INSERT INTO @T SELECT * FROM dbo.fnSplit(@AllID, ',')
- UPDATE paplaint SET IsViewed=1 WHERE ID IN(SELECT ID FROM @T) AND caMainID = @caMainID
- RETURN 1
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ccQuotaLogInsert] Script Date: 2018/12/13 19:07:18 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --分配配额
- --harry
- --2017-12-5
- CREATE PROCEDURE [dbo].[ccQuotaLogInsert]
- (
- @quotaType INT, ---1简历
- @orderId INT,
- @cpMainId INT,
- @caIds VARCHAR(1000),
- @data VARCHAR(1000),
- @isallocate BIT---0共享 1分配
- )
- AS
- SET NOCOUNT ON
- DECLARE @sumCount INT ,@sumSetCount INT
- IF @quotaType = 1--简历
- BEGIN
- IF @isallocate =0
- BEGIN
- DELETE FROM QuotaLog WHERE CaOrderId = @orderId AND cpMainId = @cpMainId
- UPDATE caOrder SET isCvAllocate= 0 WHERE id = @orderId
- END
- ELSE
- BEGIN
- --计算分配总数是否=简历数
- SELECT @sumCount=SUM(ActiveQuota) FROM caOrder
- WHERE orderType IN(8,9)
- AND OpenDate IS NOT NULl
- AND IsDeleted = 0
- AND (MainOrderID = @orderId OR Id =@orderId)
-
- DECLARE @T AS TABLE(id INT identity(1,1),data INT)
- INSERT INTO @T(data) SELECT * FROM dbo.fnSplit(@data, ',')
-
- SELECT @sumSetCount=SUM(data)FROM @T
- IF @sumSetCount = @sumCount --数值正确,进行分配
- BEGIN
- DECLARE @Tid AS TABLE(id INT identity(1,1),caId INT)
- DECLARE @caId INT, @id INT
- INSERT INTO @Tid(caId) SELECT * FROM dbo.fnSplit(@caIds, ',')
- WHILE EXISTS(SELECT 'x' FROM @Tid)
- BEGIN
- SELECT TOP 1 @id = id, @caId =caId FROM @Tid
- IF EXISTS(SELECT 'x' FROM QuotaLog WHERE CaOrderId = @orderId AND cpMainId = @cpMainId AND CaMainId = @caId AND QuotaType =1 )
- BEGIN
- UPDATE QuotaLog
- SET Quota =(SELECT TOP 1 data FROM @T WHERE id = @id)
- WHERE CaOrderId = @orderId AND cpMainId = @cpMainId AND CaMainId = @caId AND QuotaType =1
-
- DELETE FROM @Tid WHERE id = @id
- END
- ELSE
- BEGIN
- INSERT INTO QuotaLog(QuotaType, CaOrderId, CaMainId,CpMainId, Quota, RemainQuota, AddDate)
- SELECT 1, @orderId, @caId, @cpMainId, (SELECT TOP 1 data FROM @T WHERE id = @id),(SELECT TOP 1 data FROM @T WHERE id = @id), GETDATE()
- DELETE FROM @Tid WHERE id = @id
- END
- END
- UPDATE QuotaLog
- SET RemainQuota= Quota -(SELECT COUNT(1) FROM caactivelog WHERE caMainId = QuotaLog.CaMainId AND CaOrderId =QuotaLog.CaOrderId)
- WHERE QuotaType =1 AND cpMainId = @cpMainId
- UPDATE caOrder SET isCvAllocate= 1 WHERE id = @orderId
-
- END
- END
- END
-
- SET NOCOUNT OFF
- GO
- /****** Object: StoredProcedure [dbo].[ccQuotaLogSelect] Script Date: 2018/12/13 19:07:19 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --根据订单号获取简历下载信息
- --harry
- --2017-12-5
- CREATE PROCEDURE [dbo].[ccQuotaLogSelect]
- (
- @quotaType INT, ---1简历
- @orderId INT,
- @cpMainId INT
- )
- AS
- INSERT INTO ProcLog SELECT 'ccQuotaLogSelect', @cpMainId, GETDATE()
- SET NOCOUNT ON
- CREATE TABLE #t
- (
- caMainId INT,
- Username VARCHAR(100),
- name NVARCHAR(50),
- accountType INT,
- IsPause BIT,
- IsDelete BIT,
- Quota INT,
- UsedQuota INT
- )
- DECLARE @isAllocate BIT --该内容是否分享是否分享
-
- IF @quotaType =1
- BEGIN
- SELECT @isAllocate = ISNULL(isCvAllocate,0) FROM caOrder WITH(NOLOCK) WHERE id= @orderId
- END
- --先插入用户
- INSERT INTO #t(caMainId, Username, name, accountType, isPause, isDelete, Quota, UsedQuota)
- SELECT ID, userName, Name,accountType, isPause, isDelete, 0, 0
- FROM caMain
- WHERE cpMainId = @cpMainId
- --再更新分配的用户数据
- UPDATE #t
- SET Quota = b.Quota, UsedQuota =(b.Quota-b.ReMainQuota)
- FROM #t a, QuotaLog b
- WHERE b.caOrderId = @orderId
- AND a.caMainId = b.caMainid
- AND b.QuotaType = @quotaType
- IF @isAllocate = 0--共享的计算使用量
- BEGIN
- IF @quotaType = 1
- BEGIN
- UPDATE #t
- SET UsedQuota = (SELECT COUNT(1) FROM caActivelog WHERE caMainID = #t.caMainId AND (caOrderId= @orderId OR caOrderId IN (SELECT Id FROM caOrder WITH(NOLOCK)
- WHERE orderType = 9
- AND OpenDate IS NOT NULl
- AND IsDeleted = 0
- AND MainOrderID = @orderId)))
- END
- END
-
- --先获取订单信息
- IF @quotaType = 1
- BEGIN
- SELECT * FROM caOrder WITH(NOLOCK)
- WHERE (id = @orderId
- OR MainOrderID = @orderId)
- AND (orderType = 8 OR orderType = 9)
- AND OpenDate IS NOT NULl
- AND IsDeleted = 0
- END
- --再获取分配信息
- SELECT * FROM #t
- DROP TABLE #t
- SET NOCOUNT OFF
- GO
- /****** Object: StoredProcedure [dbo].[ccQuotaLogSelectByCaMainid] Script Date: 2018/12/13 19:07:19 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --分配配额查询
- --harry
- --2017-12-11
- CREATE PROCEDURE [dbo].[ccQuotaLogSelectByCaMainid]
- (
- @quotaType INT, ---1简历
- @cpMainId INT,
- @caMainId INT
- )
- AS
- SET NOCOUNT ON
- DECLARE @isAllocate BIT ,@validVipOrder INT, @ActiveQuota INT, @RemainQuota INT
- IF @quotaType = 1--简历
- BEGIN
- --获取当前的vip订单号
- SELECT @validVipOrder =id, @ActiveQuota = ActiveQuota, @RemainQuota = RemainQuota, @isAllocate = isCvAllocate
- FROM caOrder
- WHERE cpMainId = @cpMainId
- AND IsDeleted =0
- AND openDate<GETDATE()
- AND beginDate<GETDATE()
- AND endDate>GETDATE()
- AND orderType = 8
- --筛选判断是否进行分配
- IF ISNULL(@isAllocate,0) =1
- BEGIN
- SELECT Quota,RemainQuota, @isAllocate IsAllocate FROM QuotaLog WITH(NOLOCK) WHERE caOrderId = @validVipOrder AND caMainId = @caMainId AND cpMainId = @cpMainId
- END
- ELSE
- BEGIN
- SELECT SUM(ISNULL(ActiveQuota,0)) AS Quota, SUM(ISNULL(RemainQuota,0)) AS RemainQuota, @isAllocate IsAllocate
- FROM caOrder
- WHERE cpMainId = @cpMainId
- AND IsDeleted =0
- AND openDate<GETDATE()
- AND beginDate<GETDATE()
- AND endDate>GETDATE()
- END
- END
-
- SET NOCOUNT OFF
- GO
- /****** Object: StoredProcedure [dbo].[ccRecommendCvBySearchSelect] Script Date: 2018/12/13 19:07:19 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --修改Harry2018-4-19
- --将ptCvInvitation 换为 ptWeixinFollow
- CREATE PROCEDURE [dbo].[ccRecommendCvBySearchSelect]
- (
- @dcRegionID INT, --求职地区
- @RecruitmentPlaceID INT, --场馆ID
- @PageNumber INT, --翻页页码
- @caMainID INT, --企业用户ID,用来判断是否和建立联系
- @dcJobTypeIDExpect VARCHAR(50), --职位类别
- @KeyWord NVARCHAR(20) --关键词
- )
- AS
- --return
- SET NOCOUNT ON
- BEGIN TRY
- IF @dcRegionID IS NULL
- SET @dcRegionID = ''
- IF @RecruitmentPlaceID > 0
- SET @dcRegionID = ''
- DECLARE @KeyTemp NVARCHAR(20)
- SET @KeyWord = LTRIM(RTRIM(dbo.SafeSQL(REPLACE(@KeyWord, ' ', ' '))))
- SET @KeyWord = REPLACE(@KeyWord, '''', '')
- SET @KeyTemp = @KeyWord
- IF @KeyWord IS NULL OR LEN(@KeyWord) < 2
- SELECT @KeyWord = '', @KeyTemp = ''
- IF @dcJobTypeIDExpect IS NULL
- SET @dcJobTypeIDExpect = ''
- ELSE
- SET @dcJobTypeIDExpect = REPLACE(REPLACE(LTRIM(RTRIM(@dcJobTypeIDExpect)), ' ', ','), '''', '')
- SET @dcJobTypeIDExpect = dbo.FormatIDS(@dcJobTypeIDExpect)
-
- IF @RecruitmentPlaceID IS NULL OR @RecruitmentPlaceID = 0
- SET @RecruitmentPlaceID = 0
-
- DECLARE @cpSearchConditionID AS INT
- SELECT @cpSearchConditionID=0
- DECLARE @MinId AS INT
-
- --SQLSERVER中计划任务自动删除60分钟前的数据
- SELECT TOP 1 @cpSearchConditionID = ID
- FROM SearchDB..cpSearchCondition WITH(NOLOCK)
- WHERE dcRegionID=@dcRegionID AND RecruitmentPlaceID=@RecruitmentPlaceID
- AND dcJobTypeID=@dcJobTypeIDExpect AND KeyWord=@KeyWord
- ORDER BY ID DESC
- IF ISNULL(@cpSearchConditionID, 0) = 0
- GOTO SELECTRESET --无数据,重新搜索
- ELSE
- GOTO GETRECORDSET --从临时结果中提取数据
- SELECTRESET: --从cv中搜索数据
- BEGIN
- DECLARE @SQL AS VARCHAR(8000),
- @WHERE AS VARCHAR(8000),
- @FROM AS VARCHAR(1000)
- SELECT @WHERE = ''
- ----记录查询条件
- INSERT INTO SearchDB..cpSearchCondition(SessionID, dcRegionID, RecruitmentPlaceID, ReuseNumber, dcJobTypeIDExpect, KeyWord)
- VALUES(1, @dcRegionID, @RecruitmentPlaceID, 0, @dcJobTypeIDExpect, @KeyWord)
- SET @cpSearchConditionID = @@IDENTITY
- ----建立关键字搜索的临时表
- CREATE TABLE #FullText(
- CvID INT NOT NULL
- )
- ----建立临时表
- CREATE TABLE #Cv(
- ID INT NOT NULL,
- RefreshDate SMALLDATETIME NOT NULL,
- ptCvInvitationId INT
- )
- ----生成求聘职位的表变量
- DECLARE @JobTypeExpect AS VARCHAR(3000)
- SET @JobTypeExpect=''
- DECLARE @T_JobType AS TABLE(ID INT)
- IF LEN(@dcJobTypeIDExpect) > 0
- BEGIN
- DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
- INSERT INTO @T_Temp
- SELECT * FROM dbo.fnSplit(@dcJobTypeIDExpect, ',')
- INSERT INTO @T_JobType
- SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
- WHERE ParentId IN(SELECT ID FROM @T_TEMP)
- OR ParentId2 in(SELECT ID FROM @T_TEMP)
- OR ID IN(SELECT ID FROM @T_TEMP)
- ----生成in字符串
- SELECT @JobTypeExpect = (@JobTypeExpect + LTRIM(STR(ID) + ',')) FROM @T_JobType
- IF RIGHT(@JobTypeExpect, 1) = ','
- SET @JobTypeExpect = LEFT(@JobTypeExpect, LEN(@JobTypeExpect) - 1)
- END
- ----期望职位类别
- IF LEN(@dcJobTypeIDExpect) > 0
- BEGIN
- SET @WHERE = '
- AND (g.dcJobTypeID IN(' + @JobTypeExpect +'))'
- END
- ----关键词
- IF LEN(@KeyTemp) > 0 --AND @MajorName IS NULL
- BEGIN
- DECLARE @S DATETIME, @SqlFt VARCHAR(MAX)
- SELECT @S = GETDATE()
- INSERT INTO #FullText
- SELECT [key] FROM CONTAINSTABLE(CvMainPublish, *, @KeyTemp, 100000) AS KeyCv
-
- INSERT INTO #FullText
- SELECT DISTINCT cvMainID FROM CvExperiencePublish WITH(NOLOCK) WHERE ID IN(
- SELECT [key] FROM CONTAINSTABLE(CvExperiencePublish, *, @KeyTemp, 100000) AS KeyCv)
-
- INSERT INTO #FullText
- SELECT DISTINCT cvMainID FROM CvEducationPublish WITH(NOLOCK) WHERE ID IN(
- SELECT [key] FROM CONTAINSTABLE(CvEducationPublish, *, @KeyTemp, 100000) AS KeyCv)
-
- INSERT INTO #FullText
- SELECT DISTINCT cvMainID FROM CvProjectPublish WITH(NOLOCK) WHERE ID IN(
- SELECT [key] FROM CONTAINSTABLE(CvProjectPublish, *, @KeyTemp, 100000) AS KeyCv)
- INSERT INTO #FullText
- SELECT DISTINCT cvMainID FROM CvTrainingPublish WITH(NOLOCK) WHERE ID IN(
- SELECT [key] FROM CONTAINSTABLE(CvTrainingPublish, *, @KeyTemp, 100000) AS KeyCv)
- --Richard 2011.8.21增加
- INSERT INTO #FullText
- SELECT DISTINCT cvMainID FROM CvAppendixPublish WITH(NOLOCK) WHERE ID IN(
- SELECT [key] FROM CONTAINSTABLE(CvAppendixPublish, *, @KeyTemp, 100000) AS KeyCv)
- --Richard 2011.8.24增加
- 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)
- UPDATE SearchDB..cpSearchCondition SET SqlFT = @SqlFt WHERE ID = @cpSearchConditionID
- END
- ----生成插入临时表的Sql语句
- SET @SQL = '
- INSERT INTO #Cv
- SELECT DISTINCT TOP 2000 a.ID, j.LastLoginDate, b.Id'
-
- SET @FROM = '
- FROM cvmainPublish a WITH(NOLOCK)
- INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainId = j.Id
- INNER JOIN MarketDb..ptWeixinFollow b WITH(NOLOCK) ON a.paMainID=b.BindPaMainID AND b.AddDate > GETDATE() - 90
- INNER JOIN MarketDb..ptWorkAppoint c WITH(NOLOCK) ON b.ptWorkAppointID=c.ID
- INNER JOIN Recruitment d WITH(NOLOCK) ON c.RecruitmentID=d.ID
- INNER JOIN RecruitmentPlace e WITH(NOLOCK) ON d.RecruitmentPlaceID=e.ID'
-
- IF @RecruitmentPlaceID = 0
- SET @FROM = @FROM + ' AND e.dcRegionID LIKE ''' + CONVERT(VARCHAR, @dcRegionID) + '%'''
- ELSE
- SET @FROM = @FROM + ' AND e.ID=' + CONVERT(VARCHAR, @RecruitmentPlaceID)
- IF CHARINDEX('g.', @WHERE) > 0
- SET @FROM = @FROM + ' INNER JOIN cvJobTypePublish g WITH(NOLOCK) ON a.ID=g.cvMainID'
- IF LEN(@KeyTemp) > 0 --AND @MajorName IS NULL
- SET @FROM = @FROM + ' INNER JOIN #FullText k WITH(NOLOCK) ON a.ID=k.cvID'
- SET @SQL = @SQL + @FROM + @WHERE
- SET @SQL = @SQL + ' ORDER BY b.Id DESC' --j.LastLoginDate DESC, a.ID'
- PRINT @SQL
- ----把符合条件的职位全部列出
- UPDATE SearchDB..cpSearchCondition SET Sql = REPLACE(@SQL, 'INSERT INTO #Cv', ''), StartDate = GETDATE() WHERE ID = @cpSearchConditionID
- EXEC(@SQL)
- ----记录查询结果总数
- DECLARE @ValidCvNumber INT
- SET @ValidCvNumber = @@ROWCOUNT
- UPDATE SearchDB..cpSearchCondition SET ValidCvNumber = @ValidCvNumber WHERE ID = @cpSearchConditionID
- --记录查询时间
- UPDATE SearchDB..cpSearchCondition SET EndDate = GETDATE() WHERE ID = @cpSearchConditionID
- INSERT INTO SearchDB..cpSearchCvID
- SELECT TOP 2000 @cpSearchConditionID, ID FROM #Cv WITH(NOLOCK)
- DROP TABLE #Cv
- DROP TABLE #FullText
- GOTO GETRECORDSET
- END
- GETRECORDSET:
- BEGIN
- DECLARE @PageSize AS TINYINT
- SET @PageSize = 20 --每页的行数
- ----返回查询数量
- UPDATE SearchDB..cpSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@cpSearchConditionID
- SELECT ValidCvNumber FROM SearchDB..cpSearchCondition WITH(NOLOCK) WHERE ID=@cpSearchConditionID
- ----返回20行查询结果
- IF @PageNumber > 0
- BEGIN
- DECLARE @T_CvList AS TABLE(
- ID INT,
- cvEducationID INT,
- dcMajorID INT,
- Degree TINYINT,
- RelatedWorkYears INT,
- dcSalaryID TINYINT,
- RefreshDate SMALLDATETIME,
- LastLoginDate SMALLDATETIME,
- JobName VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
- Gender BIT,
- BirthDay INT,
- LivePlace INT,
- Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
- HasPhoto TINYINT,
- College NVARCHAR(50),
- EduType TINYINT,
- MajorName NVARCHAR(20),
- Graduation INT,
- HasViewed BIT,
- ViewDate SMALLDATETIME,
- LastJobTypeID INT,
- Valid TINYINT,
- PlaceName NVARCHAR(50),
- RecommendDate SMALLDATETIME,
- RecruitmentName NVARCHAR(50),
- IsOnline BIT,
- HasWeiXin BIT,
- paMainId INT,
- SecondId VARCHAR(10)
- )
- SELECT @MinId = MIN(ID) FROM SearchDB..cpSearchCvID WITH(NOLOCK) WHERE cpSearchConditionID = @cpSearchConditionID
- SET @MinId = @MinId + (@PageNumber-1) * @PageSize
- INSERT INTO @T_CvList(ID, dcMajorID, Degree, RelatedWorkYears, dcSalaryID, RefreshDate, LastLoginDate,
- JobName, Gender, BirthDay, LivePlace, LastJobTypeID, Attachment, HasPhoto, HasViewed, Valid, IsOnline, paMainId, SecondId)
- SELECT TOP 20 a.ID, a.dcMajorID, a.Degree, a.RelatedWorkYears, a.dcSalaryID, a.RefreshDate,
- j.LastLoginDate, ISNULL(a.JobName, '应届毕业生') JobName, j.Gender, j.BirthDay, j.LivePlace, a.LastJobTypeID,
- a.Attachment, j.HasPhoto, 0, a.Valid, dbo.GetPaOnlineStatus(j.ID), a.paMainId, a.SecondId
- FROM cvmain a WITH(NOLOCK)
- INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID=j.ID
- INNER JOIN SearchDB..cpSearchCvID b ON a.id=b.CvID
- WHERE b.cpSearchConditionID=@cpSearchConditionID AND b.ID >= @MinId
- ORDER BY b.ID, a.ID DESC
- --RICHARD 2011-7-23 16:51分修改
- UPDATE a
- SET a.cvEducationID = (
- SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
- WHERE cvEducation.cvMainID = a.ID
- AND a.Degree = cvEducation.Degree
- ORDER BY Graduation DESC)
- FROM @T_CvList a
-
- UPDATE a SET a.PlaceName = f.PlaceName, a.LastLoginDate = c.AddDate, --a.RecommendDate = c.AddDate,
- a.RecruitmentName = e.RecruitmentName
- FROM @T_CvList a, cvMain b WITH(NOLOCK), MarketDb..ptWeixinFollow c WITH(NOLOCK),
- MarketDb..ptWorkAppoint d WITH(NOLOCK),
- Recruitment e WITH(NOLOCK), RecruitmentPlace f WITH(NOLOCK)
- WHERE a.ID=b.ID AND b.paMainID=c.BindPaMainID AND c.ptWorkAppointID=d.ID
- AND d.RecruitmentID=e.ID AND e.RecruitmentPlaceID=f.ID
-
- UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
- a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
- FROM @T_CvList a, cvEducation b WITH(NOLOCK)
- WHERE b.ID = a.cvEducationID
- --修改是否绑定微信
- UPDATE a SET HasWeiXin = 1
- FROM @T_CvList a, WxFans b WITH(NOLOCK), CvMain c WITH(NOLOCK)
- WHERE a.ID = c.ID
- AND c.PaMainID = b.PaMainID
- AND b.Status = 2
- UPDATE a SET a.HasViewed = 1, a.ViewDate = b.AddDate
- FROM @T_CvList a, caCvViewLog b WITH(NOLOCK)
- WHERE b.cvMainID = a.ID AND caMainID=@caMainID
- SELECT a.*,b.Description DegreeName,c.Description LivePlaceName, dbo.BirthToAge(a.BirthDay) Age,d.Description dcSalaryName
- FROM @T_CvList a
- LEFT JOIN MainDB..dcEducation b WITH(NOLOCK) ON b.ID = a.Degree
- LEFT JOIN MainDB..dcRegion c WITH(NOLOCK) ON c.ID = a.LivePlace
- LEFT JOIN dcSalary d WITH(NOLOCK) ON d.ID = a.dcSalaryID
- END
- RETURN
- END
- END TRY
- BEGIN CATCH
- ---检查是否已经建立临时表,已经建立则删除
- BEGIN TRY
- DROP TABLE #FullText
- END TRY
- BEGIN CATCH
- END CATCH
- BEGIN TRY
- DROP TABLE #cv
- END TRY
- BEGIN CATCH
- END CATCH
- PRINT '查询时出现错误,请联系技术人员检查,错误信息:'
- PRINT Error_Message()
- PRINT Error_Number()
- PRINT Error_Line()
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ccRecommendCvBySearchSelect0630] Script Date: 2018/12/13 19:07:19 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccRecommendCvBySearchSelect0630]
- (
- @dcRegionID INT, --求职地区
- @RecruitmentPlaceID INT, --场馆ID
- @PageNumber INT, --翻页页码
- @caMainID INT, --企业用户ID,用来判断是否和建立联系
- @dcJobTypeIDExpect VARCHAR(50), --职位类别
- @KeyWord NVARCHAR(20) --关键词
- )
- AS
- --return
- SET NOCOUNT ON
- BEGIN TRY
- IF @dcRegionID IS NULL
- SET @dcRegionID = ''
-
- DECLARE @KeyTemp NVARCHAR(20)
- WHILE @KeyWord LIKE '% %'
- SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
- SET @KeyWord = LTRIM(RTRIM(dbo.SafeSQL(@KeyWord)))
- SET @KeyTemp = @KeyWord
- IF @KeyWord IS NULL OR LEN(@KeyWord) < 2
- SELECT @KeyWord = '', @KeyTemp = ''
- IF @dcJobTypeIDExpect IS NULL
- SET @dcJobTypeIDExpect = ''
- ELSE
- SET @dcJobTypeIDExpect = REPLACE(LTRIM(RTRIM(@dcJobTypeIDExpect)), ' ', ',')
- SET @dcJobTypeIDExpect = dbo.FormatIDS(@dcJobTypeIDExpect)
-
- IF @RecruitmentPlaceID IS NULL OR @RecruitmentPlaceID = 0
- SET @RecruitmentPlaceID = 0
-
- DECLARE @cpSearchConditionID AS INT
- SELECT @cpSearchConditionID=0
- DECLARE @MinId AS INT
-
- --SQLSERVER中计划任务自动删除60分钟前的数据
- SELECT TOP 1 @cpSearchConditionID = ID FROM SearchDB..cpSearchCondition WITH(NOLOCK)
- WHERE dcRegionID=@dcRegionID AND RecruitmentPlaceID=@RecruitmentPlaceID AND dcJobTypeID=@dcJobTypeIDExpect AND KeyWord=@KeyWord
- ORDER BY ID DESC
- IF ISNULL(@cpSearchConditionID, 0) = 0
- GOTO SELECTRESET --无数据,重新搜索
- ELSE
- GOTO GETRECORDSET --从临时结果中提取数据
- SELECTRESET: --从cv中搜索数据
- BEGIN
- DECLARE @SQL AS VARCHAR(8000)
- DECLARE @WHERE AS VARCHAR(8000)
- DECLARE @FROM AS VARCHAR(1000)
- SELECT @WHERE = ''
- ----记录查询条件
- INSERT INTO SearchDB..cpSearchCondition(SessionID,dcRegionID,RecruitmentPlaceID,ReuseNumber,dcJobTypeIDExpect,KeyWord)
- VALUES(1,@dcRegionID,@RecruitmentPlaceID,0,@dcJobTypeIDExpect,@KeyWord)
- SET @cpSearchConditionID = @@IDENTITY
- ----建立关键字搜索的临时表
- CREATE TABLE #FullText(
- CvID INT NOT NULL
- )
- ----建立临时表
- CREATE TABLE #Cv(
- ID INT NOT NULL,
- RefreshDate SMALLDATETIME NOT NULL
- )
- ----生成求聘职位的表变量
- DECLARE @JobTypeExpect AS VARCHAR(3000)
- SET @JobTypeExpect=''
- DECLARE @T_JobType AS TABLE(ID INT)
- IF LEN(@dcJobTypeIDExpect) > 0
- BEGIN
- DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
- INSERT INTO @T_Temp
- SELECT * FROM dbo.fnSplit(@dcJobTypeIDExpect, ',')
- INSERT INTO @T_JobType
- SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
- WHERE ParentId IN(SELECT ID FROM @T_TEMP)
- OR ParentId2 in(SELECT ID FROM @T_TEMP)
- OR ID IN(SELECT ID FROM @T_TEMP)
- ----生成in字符串
- SELECT @JobTypeExpect = (@JobTypeExpect + LTRIM(STR(ID) + ',')) FROM @T_JobType
- IF RIGHT(@JobTypeExpect, 1) = ','
- SET @JobTypeExpect = LEFT(@JobTypeExpect, LEN(@JobTypeExpect) - 1)
- END
- ----期望职位类别
- IF LEN(@dcJobTypeIDExpect) > 0
- BEGIN
- SET @WHERE = '
- AND (g.dcJobTypeID IN(' + @JobTypeExpect +'))'
- END
- ----关键词
- IF LEN(@KeyTemp) > 0 --AND @MajorName IS NULL
- BEGIN
- DECLARE @S DATETIME, @SqlFt VARCHAR(MAX)
- SELECT @S = GETDATE()
- INSERT INTO #FullText
- SELECT [key] FROM CONTAINSTABLE(CvMainPublish, *, @KeyTemp, 100000) AS KeyCv
-
- INSERT INTO #FullText
- SELECT DISTINCT cvMainID FROM CvExperiencePublish WITH(NOLOCK) WHERE ID IN(
- SELECT [key] FROM CONTAINSTABLE(CvExperiencePublish, *, @KeyTemp, 100000) AS KeyCv)
-
- INSERT INTO #FullText
- SELECT DISTINCT cvMainID FROM CvEducationPublish WITH(NOLOCK) WHERE ID IN(
- SELECT [key] FROM CONTAINSTABLE(CvEducationPublish, *, @KeyTemp, 100000) AS KeyCv)
-
- INSERT INTO #FullText
- SELECT DISTINCT cvMainID FROM CvProjectPublish WITH(NOLOCK) WHERE ID IN(
- SELECT [key] FROM CONTAINSTABLE(CvProjectPublish, *, @KeyTemp, 100000) AS KeyCv)
- INSERT INTO #FullText
- SELECT DISTINCT cvMainID FROM CvTrainingPublish WITH(NOLOCK) WHERE ID IN(
- SELECT [key] FROM CONTAINSTABLE(CvTrainingPublish, *, @KeyTemp, 100000) AS KeyCv)
- --Richard 2011.8.21增加
- INSERT INTO #FullText
- SELECT DISTINCT cvMainID FROM CvAppendixPublish WITH(NOLOCK) WHERE ID IN(
- SELECT [key] FROM CONTAINSTABLE(CvAppendixPublish, *, @KeyTemp, 100000) AS KeyCv)
- --Richard 2011.8.24增加
- 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)
- UPDATE SearchDB..cpSearchCondition SET SqlFT = @SqlFt WHERE ID = @cpSearchConditionID
- END
- ----生成插入临时表的Sql语句
- SET @SQL = '
- INSERT INTO #Cv
- SELECT DISTINCT TOP 2000 a.ID, j.LastLoginDate'
-
- SET @FROM = '
- FROM cvmainPublish a WITH(NOLOCK)
- INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainId = j.Id
- INNER JOIN marketdb..RmInvitationCode b WITH(NOLOCK) ON a.paMainID=b.paMainID AND b.Valid=1
- INNER JOIN marketdb..RmProject c WITH(NOLOCK) ON b.RmProjectID=c.ID
- INNER JOIN Recruitment d WITH(NOLOCK) ON c.RecruitmentID=d.ID
- INNER JOIN RecruitmentPlace e WITH(NOLOCK) ON d.RecruitmentPlaceID=e.ID'
-
- IF @RecruitmentPlaceID = 0
- SET @FROM = @FROM + ' AND e.dcRegionID LIKE ''' + CONVERT(VARCHAR,@dcRegionID) + '%'''
- ELSE
- SET @FROM = @FROM + ' AND e.ID=' + CONVERT(VARCHAR,@RecruitmentPlaceID)
- SET @FROM = @FROM + ' AND b.AddDate>GETDATE()-90'
- IF CHARINDEX('g.',@WHERE) > 0
- SET @FROM = @FROM + ' INNER JOIN cvJobTypePublish g WITH(NOLOCK) ON a.ID=g.cvMainID'
- IF LEN(@KeyTemp) > 0 --AND @MajorName IS NULL
- SET @FROM = @FROM + ' INNER JOIN #FullText k WITH(NOLOCK) ON a.ID=k.cvID'
- SET @SQL = @SQL + @FROM + @WHERE
- SET @SQL = @SQL + ' ORDER BY j.LastLoginDate DESC, a.ID'
- --PRINT @SQL
- ----把符合条件的职位全部列出
- UPDATE SearchDB..cpSearchCondition SET Sql = REPLACE(@SQL, 'INSERT INTO #Cv', ''), StartDate = GETDATE() WHERE ID = @cpSearchConditionID
- EXEC(@SQL)
- ----记录查询结果总数
- DECLARE @ValidCvNumber INT
- SET @ValidCvNumber = @@ROWCOUNT
- UPDATE SearchDB..cpSearchCondition SET ValidCvNumber = @ValidCvNumber WHERE ID = @cpSearchConditionID
- --记录查询时间
- UPDATE SearchDB..cpSearchCondition SET EndDate = GETDATE() WHERE ID = @cpSearchConditionID
- INSERT INTO SearchDB..cpSearchCvID
- SELECT TOP 2000 @cpSearchConditionID, ID FROM #Cv WITH(NOLOCK)
- DROP TABLE #Cv
- DROP TABLE #FullText
- GOTO GETRECORDSET
- END
- GETRECORDSET:
- BEGIN
- DECLARE @PageSize AS TINYINT
- SET @PageSize = 20 --每页的行数
- ----返回查询数量
- UPDATE SearchDB..cpSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@cpSearchConditionID
- SELECT ValidCvNumber FROM SearchDB..cpSearchCondition WITH(NOLOCK) WHERE ID=@cpSearchConditionID
- ----返回20行查询结果
- IF @PageNumber > 0
- BEGIN
- DECLARE @T_CvList AS TABLE(
- ID INT,
- cvEducationID INT,
- dcMajorID INT,
- Degree TINYINT,
- RelatedWorkYears INT,
- dcSalaryID TINYINT,
- RefreshDate SMALLDATETIME,
- LastLoginDate SMALLDATETIME,
- JobName VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
- Gender BIT,
- BirthDay INT,
- LivePlace INT,
- Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
- HasPhoto TINYINT,
- College NVARCHAR(50),
- EduType TINYINT,
- MajorName NVARCHAR(20),
- Graduation INT,
- HasViewed BIT,
- ViewDate SMALLDATETIME,
- LastJobTypeID INT,
- Valid TINYINT,
- PlaceName NVARCHAR(50),
- RecommendDate SMALLDATETIME,
- RecruitmentName NVARCHAR(50)
- )
- SELECT @MinId = MIN(ID) FROM SearchDB..cpSearchCvID WITH(NOLOCK) WHERE cpSearchConditionID = @cpSearchConditionID
- SET @MinId = @MinId + (@PageNumber-1) * @PageSize
- INSERT INTO @T_CvList(ID,dcMajorID,Degree,RelatedWorkYears,dcSalaryID,RefreshDate,LastLoginDate,
- JobName,Gender,BirthDay,LivePlace,LastJobTypeID,Attachment,HasPhoto,HasViewed,Valid)
- SELECT TOP 20 a.ID,a.dcMajorID,a.Degree,a.RelatedWorkYears,a.dcSalaryID,a.RefreshDate,
- j.LastLoginDate,ISNULL(a.JobName, '应届毕业生') JobName,j.Gender,j.BirthDay,j.LivePlace,a.LastJobTypeID,
- a.Attachment,j.HasPhoto,0,a.Valid FROM cvmain a WITH(NOLOCK)
- INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID=j.ID
- INNER JOIN SearchDB..cpSearchCvID b ON a.id=b.CvID
- WHERE b.cpSearchConditionID=@cpSearchConditionID AND b.ID >= @MinId
- ORDER BY b.ID, a.ID DESC
- --RICHARD 2011-7-23 16:51分修改
- UPDATE a SET a.cvEducationID = (
- SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
- WHERE cvEducation.cvMainID = a.ID
- AND a.Degree = cvEducation.Degree
- ORDER BY Graduation DESC)
- FROM @T_CvList a
-
- UPDATE a SET a.PlaceName = f.PlaceName, a.RecommendDate = c.AddDate, a.RecruitmentName = e.RecruitmentName
- FROM @T_CvList a, cvMain b WITH(NOLOCK), marketdb..RmInvitationCode c WITH(NOLOCK), marketdb..RmProject d WITH(NOLOCK),
- Recruitment e WITH(NOLOCK), RecruitmentPlace f WITH(NOLOCK)
- 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
- UPDATE a SET a.College = ISNULL(b.GraduateCollage,b.GraduateCollageEng), a.EduType = b.EduType,
- a.MajorName = ISNULL(b.MajorName,b.MajorNameEng), a.Graduation = b.Graduation
- FROM @T_CvList a, cvEducation b WITH(NOLOCK)
- WHERE b.ID = a.cvEducationID
- UPDATE a SET a.HasViewed = 1, a.ViewDate = b.AddDate
- FROM @T_CvList a, caCvViewLog b WITH(NOLOCK)
- WHERE b.cvMainID = a.ID AND caMainID=@caMainID
- SELECT * FROM @T_CvList
- END
- RETURN
- END
- END TRY
- BEGIN CATCH
- ---检查是否已经建立临时表,已经建立则删除
- BEGIN TRY
- DROP TABLE #FullText
- END TRY
- BEGIN CATCH
- END CATCH
- BEGIN TRY
- DROP TABLE #cv
- END TRY
- BEGIN CATCH
- END CATCH
- PRINT '查询时出现错误,请联系技术人员检查,错误信息:'
- PRINT Error_Message()
- PRINT Error_Number()
- PRINT Error_Line()
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ccRecruitmentByPaMainIdSelect] Script Date: 2018/12/13 19:07:20 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccRecruitmentByPaMainIdSelect]
- (
- @paMainID INT
- )
- AS
- --INSERT INTO procLog SELECT 'ccRecruitmentByPaMainIdSelect', @paMainID, GETDATE() --using
- BEGIN
- SELECT c.BeginDate, c.RecruitmentName
- FROM marketdb..ptCvInvitation a WITH(NOLOCK)
- INNER JOIN marketdb..ptWorkAppoint b WITH(NOLOCK) ON a.PtWorkAppointID1 = b.ID
- INNER JOIN Recruitment c WITH(NOLOCK) ON b.RecruitmentID = c.ID
- WHERE a.paMainID = @paMainID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccRecruitmentPaMainSelect] Script Date: 2018/12/13 19:07:20 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccRecruitmentPaMainSelect]
- (
- @RecruitmentID INT,
- @Page SMALLINT,
- @caMainID INT,
- @cpMainID INT
- )
- AS
- BEGIN
- CREATE TABLE #T(
- TitleID BIGINT,
- ID INT,
- cvMainID INT,
- Degree TINYINT,
- RelatedWorkYears TINYINT,
- Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
- IsNameHidden BIT,
- LivePlace VARCHAR(6) COLLATE Chinese_PRC_CI_AS,
- Gender BIT,
- paName NVARCHAR(20),
- BirthDay INT,
- HasPhoto TINYINT,
- adddate SMALLDATETIME,
- Valid TINYINT,
- IsViewed BIT,
- cvEducationID INT,
- College NVARCHAR(50),
- EduType TINYINT,
- MajorName NVARCHAR(20),
- Graduation INT,
- Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS
- )
- INSERT INTO #T(
- TitleID,ID, cvMainID, Degree, RelatedWorkYears,
- Attachment, IsNameHidden, LivePlace, Gender, paName,
- BirthDay, HasPhoto, adddate, Valid
- )
- SELECT ROW_NUMBER() OVER (ORDER BY a.AddDate DESC) AS TitleID,
- a.ID, b.ID, b.Degree, b.RelatedWorkYears, b.Attachment,
- b.IsNameHidden, c.LivePlace, c.Gender, c.Name AS paName,
- c.BirthDay, c.HasPhoto, a.adddate, b.Valid
- FROM RecruitmentPaMain a WITH(NOLOCK)
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = a.paMainID
- INNER JOIN cvMain b WITH(NOLOCK) ON b.paMainID = c.ID
- WHERE b.Valid = 1 AND a.RecruitmentID = @RecruitmentID
- IF(@Page < 1)
- SET @Page = 1
- IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
- SET @Page = 1
- DELETE #t WHERE TitleID <= (@Page-1) * 20 AND TitleID > @Page*20 --sean add
- UPDATE #T SET paName = LEFT(dbo.GetPaName(cvMainID, @cpMainID), 20),
- IsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID)
- --sean delete WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE #T SET Speciality = (
- SELECT Speciality FROM cvMain WITH(NOLOCK)
- WHERE cvMain.ID = #T.cvMainID)
- --sean delete WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- UPDATE #T
- SET Experience = (
- SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
- WHERE cvExperience.cvMainID = #T.cvMainID
- ORDER BY BeginDate DESC)
- --sean delete WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE #T SET cvEducationID = (
- SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
- WHERE cvEducation.cvMainID = #T.cvMainID
- AND #T.Degree = cvEducation.Degree
- ORDER BY Graduation DESC)
- --sean delete WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
- a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
- FROM #T a, cvEducation b WITH(NOLOCK)
- WHERE b.ID = a.cvEducationID
- --sean delete AND a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
- SELECT COUNT(*) FROM #T WITH(NOLOCK)
- SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- DROP TABLE #T
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccSearchTextLogInsert] Script Date: 2018/12/13 19:07:20 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- -----------------
- --创建日期:2013-6-9
- --创建人:Lucifer
- --功能说明:增加一条简历搜索关键词记录
- -----------------
- CREATE PROCEDURE [dbo].[ccSearchTextLogInsert]
- (
- @caMainID INT,
- @SearchText VARCHAR(50),
- @IP VARCHAR(15)
- )
- AS
- BEGIN
- IF @SearchText IS NULL
- RETURN 0
- IF LEN(LTRIM(RTRIM(@SearchText))) = ''
- RETURN 0
- BEGIN TRY
- --IF CHARINDEX('公务员', @SearchText) + CHARINDEX('事业单位', @SearchText) + CHARINDEX('军队', @SearchText) = 0
- -- RETURN 0
- INSERT INTO ReportDB..SearchTextLog (caMainID, SearchText, IP)
- VALUES(@caMainID, @SearchText, @IP)
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- RETURN 1
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccShareMainLogByCpIDSelect] Script Date: 2018/12/13 19:07:20 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --统计企业分享量
- --添加人Peter
- --添加时间:2016-04-08
- CREATE PROCEDURE [dbo].[ccShareMainLogByCpIDSelect]
- (
- @CpMainId INT
- )
- AS
- BEGIN
- SELECT ShareWay,COUNT(1) cnt,SUM(ClickCount) clickcnt
- FROM logdb..sharemainlog WITH(NOLOCK)
- WHERE PageMark = 3 AND shareman = @CpMainId
- GROUP BY ShareWay
-
- SELECT TOP 50 *
- FROM logdb..sharemainlog WITH(NOLOCK)
- WHERE PageMark = 3
- AND shareman = @CpMainId
- ORDER BY AddDate DESc
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccShareMainLogByStatisticsSelect] Script Date: 2018/12/13 19:07:21 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --统计企业职位分享量------------------
- --添加人Harry -----------------------
- --添加时间:2015-1-14---------------
- CREATE PROCEDURE [dbo].[ccShareMainLogByStatisticsSelect]
- (
- @CpMainId INT
- )
- AS
- BEGIN
- CREATE TABLE #T
- (
- PageId INT,
- PageName NVARCHAR(50),
- PageMark VARCHAR(10),
- SecondId VARCHAR(30),
- WeiBo INT DEFAULT 0,
- RenRen INT DEFAULT 0,
- QZone INT DEFAULT 0,
- QWeiBo INT DEFAULT 0,
- QQ INT DEFAULT 0,
- Weixin INT DEFAULT 0
- )
- INSERT INTO #T(PageId,PageName,SecondId,PageMark)
- SELECT DISTINCT Id, Name,SecondId,1
- FROM Maindb..Job WITH (NOLOCK)
- WHERE CpMainId = CAST(@CpMainId AS VARCHAR)
- AND Valid=1
- INSERT INTO #T(PageId,PageName,PageMark)
- VALUES(CAST(@CpMainId AS VARCHAR),'公司招聘页面','2')
- CREATE TABLE #1
- (
- PageId INT,
- PageMark VARCHAR(10),
- ShareWay INT,
- ShareNumber INT DEFAULT 0
- )
- INSERT INTO #1
- SELECT PageId, PageMark, ShareWay, COUNT(1)
- FROM LogDb..ShareMainLog WITH (NOLOCK)
- WHERE ShareBy = 2
- AND ShareMode = 1
- AND ShareMan = @CpMainId
- GROUP BY PageId, PageMark, ShareWay
- UPDATE a
- 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),
- a.QQ = (SELECT b.ShareNumber FROM #1 b WITH (NOLOCK) WHERE b.PageId = a.PageId AND a.PageMark = b.PageMark AND b.shareWay = 6),
- a.WeiBo = (SELECT b.ShareNumber FROM #1 b WITH (NOLOCK) WHERE b.PageId = a.PageId AND a.PageMark = b.PageMark AND b.shareWay = 1),
- a.QZone = (SELECT b.ShareNumber FROM #1 b WITH (NOLOCK) WHERE b.PageId = a.PageId AND a.PageMark = b.PageMark AND b.shareWay = 4),
- a.QWeiBo = (SELECT b.ShareNumber FROM #1 b WITH (NOLOCK) WHERE b.PageId = a.PageId AND a.PageMark = b.PageMark AND b.shareWay = 5),
- a.Weixin = (SELECT b.ShareNumber FROM #1 b WITH (NOLOCK) WHERE b.PageId = a.PageId AND a.PageMark = b.PageMark AND b.shareWay = 2)
- FROM #T a
- SELECT * FROM #T
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccShareMainLogSelect] Script Date: 2018/12/13 19:07:21 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccShareMainLogSelect]
- (
- @CpMainId INT
- )
- AS
- BEGIN
- SELECT a.Shareway, a.Adddate, b.Name, b.Secondid, a.PageMark, a.PageId
- FROM Logdb..ShareMainLog a WITH (NOLOCK)
- LEFT JOIN Maindb..Job b WITH (NOLOCK)
- ON a.PageId=b.Id
- WHERE a.ShareBy = '2'
- AND a.ShareMode = '1'
- AND a.ShareMan = @CpMainId
- ORDER BY a.Adddate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccsmsMessageLogCountByCaMainIDSelect] Script Date: 2018/12/13 19:07:21 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.30
- --创建人:Nick
- --说明://得到面试通知数量
- --#####################################################
- CREATE PROCEDURE [dbo].[ccsmsMessageLogCountByCaMainIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT ISNULL(SUM(SmsNumber), 0) Cnt
- FROM ExInterView WITH(NOLOCK)
- WHERE JobId IN(SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainId = @Id)
- AND AddDate > CONVERT(VARCHAR(10), GETDATE() - 29, 120)
- /*
- SELECT Cnt = COUNT(*)
- FROM smsMessageLog WITH(NOLOCK)
- WHERE caMainId = @ID AND AddDate > CONVERT(VARCHAR(10), GETDATE() - 29, 120)
- AND MsgType IN(101,105)
- */
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccValidViPlanDateSelect] Script Date: 2018/12/13 19:07:21 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.30
- --创建人:John
- --说明:获取企业发送视频面试通知时的面试时间选项
- --#####################################################
- CREATE PROCEDURE [dbo].[ccValidViPlanDateSelect]
- (
- @caMainID INT
- )
- AS
- BEGIN
- SELECT *
- FROM (
- SELECT TOP 1 id,begindate,1 orderby
- FROM viroom
- WHERE enddate IS NULL
- AND camainid = @caMainID
- UNION
- SELECT TOP 50 id,interviewdate,2 orderby
- FROM viplan
- WHERE interviewdate > GETDATE()
- AND iscancel = 0
- AND camainid = @caMainID
- ) a
- ORDER BY orderby ,begindate
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccvCpMainActiveQuotaByIDSelect] Script Date: 2018/12/13 19:07:21 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.31
- --创建人:Nick
- --说明:获取企业简历下载数 和 已经使用的简历下载数
- --#####################################################
- CREATE PROCEDURE [dbo].[ccvCpMainActiveQuotaByIDSelect]
- (
- @CpMainID VARCHAR(20)
- )
- AS
- BEGIN TRY
- SELECT ActiveQuota,RemainQuota FROM vCpMain WITH(NOLOCK) WHERE Id=@CpMainID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ccvCpMainByIDSelect] Script Date: 2018/12/13 19:07:21 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.30
- --创建人:Nick
- --说明:获取状态
- --修改:harry2017-6-6 增加短信RemainSmsQuota ,SmsQuota配额
- --修改:harry2018-9-21 增加人才测评配额
- --#####################################################
- CREATE PROCEDURE [dbo].[ccvCpMainByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT VipDate, ActiveQuota, MaxJobNumber, MaxUserNumber, RemainQuota, RemainSmsQuota, SmsQuota, remainJobRefreshQuota,jobRefreshQuota,AssessReportQuota, RemainAssessReportQuota
- FROM vCpMain WITH(NOLOCK)
- WHERE Id=@ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccViPlanByCaMainIDSelect] Script Date: 2018/12/13 19:07:22 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.30
- --创建人:John
- --说明:企业获取自己的未过期的面试计划
- --#####################################################
- CREATE PROCEDURE [dbo].[ccViPlanByCaMainIDSelect]
- (
- @caMainID INT
- )
- AS
- BEGIN
- SELECT TOP 500 a.ID,InterviewDate,IsCancel,b.name,
- (
- SELECT COUNT(*)
- FROM viplaninvitelog
- WHERE viplanid = a.id
- AND addtype = 0
- ) cnt1,
- (
- SELECT COUNT(*)
- FROM viplaninvitelog
- WHERE viplanid = a.id
- AND addtype = 1
- ) cnt2
- FROM viplan a,caMain b
- WHERE a.camainid = b.id
- AND interviewdate > GETDATE()
- AND IsCancel = 0
- AND camainid = @caMainID
- ORDER BY interviewdate
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccViPlanExpiredByCaMainIDSelect] Script Date: 2018/12/13 19:07:22 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.30
- --创建人:John
- --说明:企业获取自己的已过期的面试计划
- --#####################################################
- CREATE PROCEDURE [dbo].[ccViPlanExpiredByCaMainIDSelect]
- (
- @caMainID INT
- )
- AS
- BEGIN
- SELECT TOP 500 a.ID,InterviewDate,IsCancel,b.name,
- (
- SELECT COUNT(*)
- FROM viplaninvitelog
- WHERE viplanid = a.id
- AND addtype = 0
- ) cnt1,
- (
- SELECT COUNT(*)
- FROM viplaninvitelog
- WHERE viplanid = a.id
- AND addtype = 1
- ) cnt2
- FROM viplan a,caMain b
- WHERE a.camainid = b.id
- AND (interviewdate < GETDATE() OR IsCancel = 1)
- AND camainid = @caMainID
- ORDER BY interviewdate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccViPlanInsert] Script Date: 2018/12/13 19:07:22 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccViPlanInsert]
- (
- @CaMainID INT,
- @InterviewDate SMALLDATETIME
- )
- AS
- BEGIN
- INSERT INTO viplan (CaMainID ,InterviewDate) select @CaMainID ,@InterviewDate
- Return @@IDENTITY
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccViPlanInviteLog30DaysSelect] Script Date: 2018/12/13 19:07:22 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.30
- --创建人:John
- --说明:30天内有没有邀请过
- --#####################################################
- CREATE PROCEDURE [dbo].[ccViPlanInviteLog30DaysSelect]
- (
- @cvMainID INT,
- @jobID INT
- )
- AS
- BEGIN
- SELECT TOP 1 *
- FROM viplaninvitelog
- WHERE adddate > GETDATE()-30
- AND cvMainID = @cvMainID
- AND jobid = @jobID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccVIPlanInviteLogSelect] Script Date: 2018/12/13 19:07:22 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ccVIPlanInviteLogSelect]
- (
- @WHERE VARCHAR(1000),
- @caMainID INT
- )
- AS
- BEGIN
- CREATE TABLE #t(
- paMainID INT,
- cvmainid INT,
- Name NVARCHAR(10),
- JobName NVARCHAR(50),
- AddDate SMALLDATETIME,
- InterviewDate SMALLDATETIME,
- Degree NVARCHAR(10),
- RelatedWorkYears TINYINT,
- LivePlace NVARCHAR(20) COLLATE Chinese_PRC_CI_AS,
- Gender BIT,
- paName NVARCHAR(20),
- BirthDay INT,
- HasPhoto TINYINT,
- Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
- IsNameHidden BIT,
- Valid TINYINT,
- AddType BIT
- )
- DECLARE @SQL AS VARCHAR(2000)
- DECLARE @SQL2 AS VARCHAR(2000)
- SET @SQL='
- INSERT INTO #t(paMainID,cvMainID,Name,JobName,AddDate,InterviewDate,AddType)
- SELECT
- c.ID,b.ID,c.Name,d.name,a.AddDate,e.InterviewDate,a.AddType
- From viplaninvitelog a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON a.cvMainID=b.ID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID=b.paMainID
- INNER JOIN job d WITH(NOLOCK) ON a.jobid=d.id
- INNER JOIN VIPlan e WITH(NOLOCK) ON a.VIPlanID=e.id
- '
- SET @SQL=@SQL + '
- WHERE e.camainid= '+ltrim(str(@caMainID))
- IF LEN(@WHERE)>0
- SET @SQL=@SQL + @WHERE
- --PRINT @sql
- EXEC(@SQL)
-
- DECLARE @cpMainID int
- SELECT @cpMainID=cpMainid from caMain where id=@caMainID
-
- UPDATE #t SET Name=LEFT(dbo.GetPaName(cvMainID, @cpMainID), 20),RelatedWorkYears = a.RelatedWorkYears,Attachment = a.Attachment,
- IsNameHidden = a.IsNameHidden,LivePlace = c.FullName,Gender = b.Gender,
- BirthDay = b.BirthDay,HasPhoto = b.HasPhoto,Valid = a.Valid,Degree=d.Description
- 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
- WHERE a.ID = #t.cvMainID
-
- IF CHARINDEX('interviewdate<getdate',@WHERE)>0
- SELECT * FROM #t WITH(NOLOCK) ORDER BY InterviewDate DESC,AddDATE
- ELSE
- SELECT * FROM #t WITH(NOLOCK) ORDER BY InterviewDate ,AddDATE
- DROP TABLE #t
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccViPlanInviteLogViewDateUpdate] Script Date: 2018/12/13 19:07:23 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.30
- --创建人:John
- --说明:企业修改未查看面试计划邀请记录的查看时间
- --#####################################################
- CREATE PROCEDURE [dbo].[ccViPlanInviteLogViewDateUpdate]
- (
- @caMainID INT
- )
- AS
- BEGIN
- UPDATE a SET viewdate = GETDATE()
- FROM viplaninvitelog a,viplan b
- WHERE a.viplanid = b.id
- AND addtype = 0
- AND viewdate IS NULL
- AND camainid = @caMainID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccViPlanIsCancelUpdate] Script Date: 2018/12/13 19:07:23 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.30
- --创建人:John
- --说明:面试计划取消
- --#####################################################
- CREATE PROCEDURE [dbo].[ccViPlanIsCancelUpdate]
- (
- @caMainID INT,
- @id INT
- )
- AS
- BEGIN
- UPDATE viplan SET IsCancel = 1 WHERE id = @id AND caMainID = @caMainID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccViPlanTopFirstSelect] Script Date: 2018/12/13 19:07:23 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.30
- --创建人:John
- --说明:企业获取一条今天要进行的面试计划
- --#####################################################
- CREATE PROCEDURE [dbo].[ccViPlanTopFirstSelect]
- (
- @caMainID INT
- )
- AS
- BEGIN
- SELECT TOP 1 interviewdate
- FROM viplan
- WHERE CONVERT(VARCHAR(10),interviewdate,112) = CONVERT(VARCHAR(10),GETDATE(),112)
- AND interviewdate > GETDATE()
- AND iscancel = 0
- AND caMainid = @caMainID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccViRoomNotOverByCaMainIDSelect] Script Date: 2018/12/13 19:07:23 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.30
- --创建人:John
- --说明:检查该公司是否还有未结束的面试
- --#####################################################
- CREATE PROCEDURE [dbo].[ccViRoomNotOverByCaMainIDSelect]
- (
- @caMainID INT
- )
- AS
- BEGIN
- SELECT TOP 1 * FROM viRoom WITH(NOLOCK) WHERE caMainID=@caMainID AND EndDate IS NULL
- END
- GO
- /****** Object: StoredProcedure [dbo].[ccWxMessageSendByAssessCpInviteSend] Script Date: 2018/12/13 19:07:23 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:20181105
- --创建人:Peter
- --插入企业邀请个人测评微信推送
- --#####################################################
- CREATE PROCEDURE [dbo].[ccWxMessageSendByAssessCpInviteSend]
- (
- @assessCpInviteID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @wxFansId INT,@cpMainID INT,@paMainID INT,@caMainID INT
- SELECT @paMainID = a.PaMainID,@caMainID = a.CaMainID,@cpMainID = b.cpMainID
- FROM AssessCpInvite a WITH(NOLOCK)
- LEFT JOIN caMain b WITH(NOLOCK) ON b.id = a.CaMainID
- WHERE a.ID = @assessCpInviteID
- SELECT @wxFansId = id FROM wxFans WITH(NOLOCK) WHERE paMainId = @paMainID AND [Status] = 2
-
- IF @wxFansId > 0
- --插入到wxMessageSend表中
- INSERT WxMessageSend2(Templatetype, WxFansID, PaMainId, MainTableId, CpMainID, CaMainId, AddDate)
- SELECT 24, @wxFansId, @paMainID, @assessCpInviteID, @cpMainID, @caMainID, GETDATE()
- END
- GO
- /****** Object: StoredProcedure [dbo].[FaxSendInsert] Script Date: 2018/12/13 19:07:24 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[FaxSendInsert]
- (
- @companyId INT,
- @manageruserId INT,
- @FaxNumber VARCHAR(20),
- @FileName VARCHAR(50),
- @Passage TINYINT
- )
- AS
- DECLARE @MaxID AS INT
- BEGIN TRY
- INSERT INTO FaxSend
- (companyId,manageruserId,FileName,FaxNumber,Passage)
- VALUES
- (@companyId,@manageruserId,@FileName,@FaxNumber,@Passage)
- SET @MaxId = @@IDENTITY
- END TRY
- BEGIN CATCH
- GOTO ERR
- END CATCH
- RETURN @MaxID
- ERR:
- BEGIN
- RETURN 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[GetJobListByJobFinderIDApp] Script Date: 2018/12/13 19:07:24 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[GetJobListByJobFinderIDApp]
- (
- @paJobFinderID INT
- )
- AS
- BEGIN
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
- a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
- a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
- a.IsDelete, a.AddDate, a.RefreshDate, a.Welfare1, a.Welfare2, a.Welfare3,
- a.Welfare4, a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8,
- a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13,
- a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18, a.Welfare19,
- a.SecondId EnJobID, b.SecondId EnCpMainID,
- a.LastModifyDate, b.Name cpName, b.dcCompanySizeID,
- b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
- b.MemberType, '' cpIndustry, b.IsRefreshed, ISNULL(d.IsOnline, 0) IsOnline, d.IsVi, d.ViPlanId, d.InterviewDate, e.FullName Region
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
- INNER JOIN JobSubScription c WITH(NOLOCK) ON a.ID = c.JobID
- INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
- LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
- WHERE c.paJobFinderID = @paJobFinderID
- ORDER BY a.RefreshDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[info_datereportCpUpdate] Script Date: 2018/12/13 19:07:24 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[info_datereportCpUpdate]
- (
- @cpMainID INT,
- @AddMan INT,
- @province_id VARCHAR(32)
- )
- AS
- BEGIN TRAN
- DECLARE @ID AS INT
- BEGIN TRY
- SET @ID=0
- SELECT TOP 1 @ID=province_id FROM info_datereport WITH(NOLOCK)
- WHERE infomanager_id=@AddMan
- AND province_id=@province_id
- AND CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
- IF @ID=0
- INSERT INTO info_datereport(province_id,infomanager_id,countdate)
- VALUES(@province_id,@AddMan, CONVERT(VARCHAR(8), GETDATE(), 112))
- UPDATE info_datereport SET realcompany=realcompany + 1
- WHERE infomanager_id=@AddMan
- AND province_id=@province_id
- AND CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
- UPDATE cpMain SET RegisterMode=11 WHERE ID=@cpMainID
- END TRY
- BEGIN CATCH
- GOTO ERR
- END CATCH
- COMMIT TRAN
- RETURN 1
- ERR:
- BEGIN
- ROLLBACK TRAN
- RETURN 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblAdverprojectBannerByProvinceIDSelect] Script Date: 2018/12/13 19:07:24 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblAdverprojectBannerByProvinceIDSelect]
- (
- @regionID VARCHAR(20),
- @Type INT
- )
- AS
- BEGIN
- SELECT * FROM adverproject WHERE type=@Type
- AND GETDATE() BETWEEN BeginTime
- AND EndTime AND province_id=@regionID AND valid=1 ORDER BY AddDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblAdverprojectByProvinceIDSelect] Script Date: 2018/12/13 19:07:25 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --—#####################################################
- --—创建时间:2014.11.7
- --—创建人:Nick
- --—说明:获取最新的启动图片
- --—#####################################################
- CREATE PROCEDURE [dbo].[mblAdverprojectByProvinceIDSelect]
- (
- @regionID VARCHAR(20)
- )
- AS
- BEGIN
- SELECT * FROM adverproject
- WHERE type in(23,24)
- AND GETDATE() BETWEEN BeginTime
- AND EndTime AND province_id=@regionID
- AND Valid=1
- ORDER BY Type DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblAppRunLogInsert] Script Date: 2018/12/13 19:07:25 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- /**
- *Android 个人App安装运行状态信息
- *Peter 2014-01-17 10:26
- */
- CREATE PROCEDURE [dbo].[mblAppRunLogInsert]
- (
- @DeviceID VARCHAR(50),
- @Imei VARCHAR(50),
- @AppId SMALLINT,
- @AccountID INT,
- @Ip VARCHAR(15)
- )
- AS
- BEGIN
- INSERT INTO AppRunLog (DeviceId, Imei, AppId, AccountId, Ip)
- SELECT @DeviceId, @Imei, @AppId, @AccountId, @Ip
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblCaCvContactByCvViewSelect] Script Date: 2018/12/13 19:07:25 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblCaCvContactByCvViewSelect]
- (
- @cpMainID INT,
- @JobID INT,
- @caMainID INT,
- @cvMainID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- IF @JobID > 0
- BEGIN
- --查询申请记录
- SELECT TOP 1 a.ID, a.AddDate, a.Reply, b.ID JobID, b.Name
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN Job b WITH(NOLOCK) ON a.JobId = b.Id
- WHERE a.cvMainId = @cvMainID
- AND b.ID = @JobID
- AND CompanyDeleted = 0
- ORDER BY a.ID DESC
- --查询最近3个月的发送面试通知记录
- SELECT TOP 1 a.AddDate, b.ID, b.Name
- FROM ExInterview a WITH(NOLOCK)
- INNER JOIN Job b WITH(NOLOCK)
- ON a.JobId = b.Id
- WHERE a.cvMainId =@cvMainID
- AND b.ID = @JobID
- AND a.AddDate > DATEADD(MONTH, -3, GETDATE())
- ORDER BY a.ID DESC
- --查询收藏记录
- SELECT TOP 1 a.AddDate, b.ID, b.Name
- FROM caFavorate a WITH(NOLOCK)
- INNER JOIN Job b WITH(NOLOCK)
- ON a.JobId = b.Id
- WHERE a.cvMainId = @cvMainID
- AND b.ID = @JobID
- ORDER BY a.ID DESC
- --查询2周内浏览简历记录
- SELECT TOP 1 AddDate
- FROM CaCvViewLog a WITH(NOLOCK)
- WHERE caMainID IN(SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID)
- AND cvMainID = @cvMainID
- AND AddDate>DATEADD(DAY, -14, GETDATE())
- END
- ELSE
- BEGIN
- IF @cpMainID > 0
- BEGIN
- --查询最近2个月的申请记录
- SELECT TOP 1 a.ID, a.AddDate, a.Reply, b.ID JobID, b.Name
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN Job b WITH(NOLOCK)
- ON a.JobId = b.Id
- WHERE a.cvMainId =@cvMainID
- AND b.cpMainID = @cpMainID
- AND CompanyDeleted = 0
- ORDER BY a.ID DESC
- --查询最近3个月的发送面试通知记录
- SELECT TOP 1 a.AddDate, b.ID, b.Name
- FROM ExInterview a WITH(NOLOCK)
- INNER JOIN Job b WITH(NOLOCK)
- ON a.JobId = b.Id
- WHERE a.cvMainId =@cvMainID
- AND b.cpMainID = @cpMainID
- AND a.AddDate > DATEADD(MONTH, -3, GETDATE())
- ORDER BY a.ID DESC
- --查询收藏记录
- SELECT TOP 1 a.AddDate, b.ID, b.Name
- FROM caFavorate a WITH(NOLOCK)
- INNER JOIN Job b WITH(NOLOCK)
- ON a.JobId = b.Id
- WHERE a.cvMainId =@cvMainID
- AND b.cpMainID = @cpMainID
- ORDER BY a.ID DESC
- --查询2周内浏览简历记录
- SELECT TOP 1 AddDate
- FROM CaCvViewLog a WITH(NOLOCK)
- WHERE caMainID IN(SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID)
- AND cvMainID = @cvMainID
- AND AddDate>DATEADD(DAY, -14, GETDATE())
- END
- ELSE
- BEGIN
- --查询最近2个月的申请记录
- SELECT TOP 1 a.ID, a.AddDate, a.Reply, b.ID JobID, b.Name
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN Job b WITH(NOLOCK)
- ON a.JobId = b.Id
- WHERE a.cvMainId =@cvMainID
- AND b.caMainID = @caMainID
- AND CompanyDeleted = 0
- ORDER BY a.ID DESC
- --查询最近3个月的发送面试通知记录
- SELECT TOP 1 a.AddDate, b.ID, b.Name
- FROM ExInterview a WITH(NOLOCK)
- INNER JOIN Job b WITH(NOLOCK)
- ON a.JobId = b.Id
- WHERE a.cvMainId =@cvMainID
- AND b.caMainID = @caMainID
- AND a.AddDate > DATEADD(MONTH, -3, GETDATE())
- ORDER BY a.ID DESC
- --查询收藏记录
- SELECT TOP 1 a.AddDate, b.ID, b.Name
- FROM caFavorate a WITH(NOLOCK)
- INNER JOIN Job b WITH(NOLOCK)
- ON a.JobId = b.Id
- WHERE a.cvMainId =@cvMainID
- AND b.caMainID = @caMainID
- ORDER BY a.ID DESC
- --查询2周内浏览简历记录
- SELECT TOP 1 AddDate
- FROM CaCvViewLog a WITH(NOLOCK)
- WHERE caMainID = @caMainID
- AND cvMainID IN(SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID)
- AND AddDate>DATEADD(DAY, -14, GETDATE())
- END
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblCaCvViewLogSelect] Script Date: 2018/12/13 19:07:26 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblCaCvViewLogSelect]
- (
- @paMainID AS INT,
- @PageNum AS INT,
- @PageSize AS INT
- )
- AS
- BEGIN
- DECLARE @COUNT INT
- SELECT @COUNT = COUNT(*)
- FROM CaCvViewLog a WITH(NOLOCK), caMain b WITH(NOLOCK), cpMain c WITH(NOLOCK)
- WHERE a.caMainID = b.ID
- AND b.cpMainID=c.ID
- AND a.cvMainId IN(SELECT ID FROM CvMain WITH(NOLOCK) WHERE paMainId = @PaMainID)
- IF @COUNT > 200
- SET @COUNT = 200
- SELECT *, @COUNT AS cnt
- FROM (SELECT TOP 200 ROW_NUMBER() OVER (ORDER BY a.AddDate DESC) AS Rows,
- c.Name CompanyName, a.AddDate, b.cpMainID ,c.secondid encpmainid
- FROM CaCvViewLog a WITH(NOLOCK), caMain b WITH(NOLOCK), cpMain c WITH(NOLOCK)
- WHERE a.caMainID = b.ID AND b.cpMainID=c.ID
- AND a.cvMainId IN(SELECT ID FROM CvMain WITH(NOLOCK) WHERE paMainId = @PaMainID)
- ) AS a
- WHERE a.Rows BETWEEN (@PageNum - 1) * @PageSize + 1 AND @PageNum * @PageSize ORDER BY Rows
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblcaDownloadLogSelect] Script Date: 2018/12/13 19:07:26 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --20160108 nick 加入是否绑定微信
- CREATE PROCEDURE [dbo].[mblcaDownloadLogSelect]
- (
- @cpMainID INT,
- @WHERE VARCHAR(1000),
- @ORDER VARCHAR(100),
- @Page SMALLINT,
- @caMainID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- SET @Where = dbo.SafeSql(@Where)
- SET @ORDER = dbo.SafeSql(@Order)
- DECLARE @SQL VARCHAR(2000)
- CREATE TABLE #T(
- TitleID BIGINT,
- cvMainID INT,
- caOrderID INT NULL,
- paMainID INT,
- IP VARCHAR(39) COLLATE Chinese_PRC_CI_AS NOT NULL,
- RemainQuota SMALLINT NULL,
- AddDate SMALLDATETIME,
- Degree TINYINT,
- RelatedWorkYears TINYINT,
- Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS ,
- IsNameHidden BIT,
- LivePlace VARCHAR(6) COLLATE Chinese_PRC_CI_AS ,
- Gender BIT,
- paName NVARCHAR(20),
- BirthDay INT,
- HasPhoto TINYINT,
- Valid TINYINT,
- HasJobApply BIT,
- HasInterview BIT,
- HasRemark BIT,
- HasFavorate BIT,
- cvEducationID INT,
- College NVARCHAR(50),
- EduType TINYINT,
- MajorName NVARCHAR(20),
- Graduation INT,
- Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- MobileVerifyDate SMALLDATETIME,
- IsOnline BIT,
- HasWeiXin BIT,
- PaPhoto VARCHAR(50),
- dcSalaryID SMALLINT,
- SecondId VARCHAR(10)
- )
- SET @SQL = '
- INSERT INTO #T(TitleID, cvMainID, caOrderID, paMainID, RemainQuota, IP, AddDate, Degree,
- RelatedWorkYears, Attachment, IsNameHidden, LivePlace, Gender, BirthDay, HasPhoto,
- Valid, MobileVerifyDate, IsOnline, dcSalaryID, SecondId)
- SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.* FROM (
- SELECT
- a.cvMainID, NULL caOrderID, c.ID paMainID, NULL RemainQuota, a.IP, a.AddDate, b.Degree,
- b.RelatedWorkYears, b.Attachment, b.IsNameHidden, c.LivePlace, c.Gender, c.BirthDay, c.HasPhoto,
- b.Valid, c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID) IsOnline, b.dcSalaryID, b.SecondId
- FROM caDailyGiftLog a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- WHERE cpMainID = ' + LTRIM(STR(@cpMainID)) + ' ' + REPLACE(@WHERE, 'a.caOrderID', '1') + '
- AND a.AddDate > DATEADD(YEAR, -2, GETDATE())
- UNION
- SELECT
- a.cvMainID, a.caOrderID, c.ID paMainID, a.RemainQuota, a.IP, a.AddDate, b.Degree,
- b.RelatedWorkYears, b.Attachment, b.IsNameHidden, c.LivePlace, c.Gender, c.BirthDay, c.HasPhoto,
- b.Valid, c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID) IsOnline, b.dcSalaryID, b.SecondId
- FROM caActiveLog a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- WHERE cpMainID = ' + LTRIM(STR(@cpMainID)) + '
- AND a.AddDate > DATEADD(YEAR, -2, GETDATE()) ' + @WHERE + ') a'
- --PRINT @SQL
- EXEC(@SQL)
- IF(@Page < 1)
- SET @Page = 1
- IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
- SET @Page = 1
- UPDATE #T SET paName = LEFT(dbo.GetPaName(cvMainID, @cpMainID), 20),
- 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),
- 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),
- HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
- HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- UPDATE #T SET Speciality = (
- SELECT Speciality FROM cvMain WITH(NOLOCK)
- WHERE cvMain.ID = #T.cvMainID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- UPDATE #T SET PaPhoto = (
- SELECT TOP 1 PhotoProcessed
- FROM paPhoto a WITH(NOLOCK INDEX(IX_paPhoto_paMainId))
- WHERE paMainID = (SELECT PaMainID FROM cvMain WITH(NOLOCK) WHERE ID = #T.cvMainID))
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- UPDATE #T SET Experience = (
- SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
- WHERE cvExperience.cvMainID = #T.cvMainID
- ORDER BY BeginDate DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE #T SET cvEducationID = (
- SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
- WHERE cvEducation.cvMainID = #T.cvMainID
- AND #T.Degree = cvEducation.Degree
- ORDER BY Graduation DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
- a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
- FROM #T a, cvEducation b WITH(NOLOCK)
- WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
- --修改是否绑定微信
- UPDATE a SET HasWeiXin = 1
- FROM #T a, WxFans b WITH(NOLOCK), CvMain c WITH(NOLOCK)
- WHERE a.CvMainID = c.ID
- AND c.PaMainID = b.PaMainID
- AND b.Status = 2
- AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- SELECT COUNT(*) FROM #T WITH(NOLOCK)
-
- SELECT a.*,b.Description DegreeName,c.MapBarName LivePlaceName, dbo.BirthToAge(a.BirthDay) Age,d.Description dcSalaryName
- FROM #T a WITH(NOLOCK)
- LEFT JOIN dcEducation b WITH(NOLOCK) ON b.ID = a.Degree
- LEFT JOIN dcRegion c WITH(NOLOCK) ON c.ID = a.LivePlace
- LEFT JOIN dcSalary d WITH(NOLOCK) ON d.ID = a.dcSalaryID
- WHERE a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
-
- DROP TABLE #T
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblcaFavorateSelect] Script Date: 2018/12/13 19:07:26 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblcaFavorateSelect]
- (
- @WHERE VARCHAR(1000),
- @Order VARCHAR(100),
- @Page SMALLINT,
- @cpMainID INT,
- @caMainID INT
- )
- AS
- SET NOCOUNT ON
- IF NOT EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK) WHERE Id = @caMainId AND cpMainId = @cpMainId)
- RETURN
- BEGIN
- SELECT @Where = dbo.SafeSql(@Where), @ORDER = dbo.SafeSql(@Order)
- DECLARE @SQL AS VARCHAR(2000)
- CREATE TABLE #T(
- TitleID BIGINT,
- ID INT,
- JobID INT,
- JobName VARCHAR(50),
- cvMainID INT,
- paMainID INT,
- caFavorateMarkID INT,
- Degree TINYINT,
- RelatedWorkYears TINYINT,
- Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
- IsNameHidden BIT,
- LivePlace VARCHAR(6) COLLATE Chinese_PRC_CI_AS,
- Gender BIT,
- paName NVARCHAR(20),
- BirthDay INT,
- HasPhoto TINYINT,
- adddate SMALLDATETIME,
- Valid TINYINT,
- IsViewed BIT,
- HasJobApply BIT,
- HasInterview BIT,
- HasRemark BIT,
- cvEducationID INT,
- College NVARCHAR(50),
- EduType TINYINT,
- MajorName NVARCHAR(20),
- Graduation INT,
- Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- MobileVerifyDate SMALLDATETIME,
- IsOnline BIT,
- HasWeiXin BIT,
- PaPhoto VARCHAR(50),
- dcSalaryID SMALLINT,
- SecondId VARCHAR(10)
- )
- --ca的类型: 1 管理员 2 普通用户
- DECLARE @AccountType AS TINYINT
- SELECT @AccountType = AccountType FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
- SET @SQL='
- INSERT INTO #T(
- TitleID, ID, JobID, JobName, cvMainID, paMainID, caFavorateMarkID, Degree, RelatedWorkYears,
- Attachment, IsNameHidden, LivePlace, Gender, paName, BirthDay, HasPhoto, adddate,
- Valid, MobileVerifyDate, IsOnline, dcSalaryID, SecondId
- )
- SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID,
- a.ID, a.JobID, d.Name, a.cvMainID, c.ID paMainID, a.caFavorateMarkID,
- b.Degree, b.RelatedWorkYears, b.Attachment, b.IsNameHidden,
- c.LivePlace, c.Gender, c.Name AS paName, c.BirthDay, c.HasPhoto,
- a.adddate, b.Valid, c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID),
- b.dcSalaryID, b.SecondId
- FROM caFavorate a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
- WHERE d.IsDelete = 0 '
- --add by mice 123 ca中的管理员可以查看子账号收藏的简历
- IF @AccountType = 1
- SET @SQL = @SQL + ' AND a.caMainID IN ( SELECT ID FROM caMain WHERE cpMainID = ' + LTRIM(STR(@cpMainID)) + ' AND IsDelete = 0 AND IsPause = 0 ) '
- ELSE
- SET @SQL = @SQL + ' AND a.caMainID = ' + LTRIM(STR(@caMainID))
-
- IF LEN(@WHERE) > 0
- SET @SQL = @SQL + @WHERE
- --PRINT @sql
- EXEC(@SQL)
- IF(@Page < 1)
- SET @Page = 1
-
- 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),
- 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),
- 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),
- HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE #T SET Speciality = (
- SELECT Speciality FROM cvMain WITH(NOLOCK)
- WHERE cvMain.ID = #T.cvMainID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- UPDATE #T SET PaPhoto = dbo.GetPaPhotoByCpView(#T.cvMainID, @cpMainID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- UPDATE #T SET Experience = (
- SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
- WHERE cvExperience.cvMainID = #T.cvMainID
- ORDER BY BeginDate DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE #T SET cvEducationID = (
- SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
- WHERE cvEducation.cvMainID = #T.cvMainID
- AND #T.Degree = cvEducation.Degree
- ORDER BY Graduation DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
- a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
- FROM #T a, cvEducation b WITH(NOLOCK)
- WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
- --修改是否绑定微信
- UPDATE a SET HasWeiXin = 1
- FROM #T a, WxFans b WITH(NOLOCK), CvMain c WITH(NOLOCK)
- WHERE a.CvMainID = c.ID
- AND c.PaMainID = b.PaMainID
- AND b.Status = 2
- AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- SELECT COUNT(*) FROM #T WITH(NOLOCK)
- SELECT a.*,b.Description DegreeName,c.MapBarName LivePlaceName, dbo.BirthToAge(a.BirthDay) Age,d.Description dcSalaryName
- FROM #T a WITH(NOLOCK)
- LEFT JOIN dcEducation b WITH(NOLOCK) ON b.ID = a.Degree
- LEFT JOIN dcRegion c WITH(NOLOCK) ON c.ID = a.LivePlace
- LEFT JOIN dcSalary d WITH(NOLOCK) ON d.ID = a.dcSalaryID
- WHERE a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
-
- DROP TABLE #T
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblcaIOSBindDelete] Script Date: 2018/12/13 19:07:27 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblcaIOSBindDelete]
- (
- @caMainID INT,
- @UniqueID VARCHAR(100)
- )
- AS
- BEGIN
- DELETE FROM caIOSBind WHERE UniqueID = @UniqueID
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblcaIOSBindInsert] Script Date: 2018/12/13 19:07:27 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblcaIOSBindInsert]
- (
- @caMainID INT,
- @UniqueID VARCHAR(100),
- @ClientType TINYINT
- )
- AS
- BEGIN TRY
- IF LEN(ISNULL(@UniqueID,'')) = 0
- RETURN
- IF NOT EXISTS(SELECT 1 FROM caIOSBind WITH(NOLOCK) WHERE caMainID = @caMainID AND UniqueID = @UniqueID AND ClientType = @ClientType)
- BEGIN
- INSERT INTO caIOSBind VALUES(@caMainID,@UniqueID,GETDATE(),@ClientType)
- RETURN 1
- END
- ELSE
- BEGIN
- RETURN 0
- END
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblcaJobCvMatchByCaMainIDSelect] Script Date: 2018/12/13 19:07:27 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- ---------------
- --创建人Peter
- --时间 2017-4-17
- --根据caMainID获取推荐简历
- CREATE PROCEDURE [dbo].[mblcaJobCvMatchByCaMainIDSelect]
- (
- @caMainID INT,
- @PageNo INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @T_CvList AS TABLE(
- iIndex INT IDENTITY(1, 1),
- ID INT,
- cvEducationID INT,
- dcMajorID INT,
- Degree TINYINT,
- RelatedWorkYears INT,
- dcSalaryID TINYINT,
- Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- RefreshDate SMALLDATETIME,
- LastLoginDate SMALLDATETIME,
- JobName VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
- MatchJobID INT,
- MatchJobName VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
- Gender BIT,
- BirthDay INT,
- LivePlace INT,
- Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
- HasPhoto TINYINT,
- College NVARCHAR(50),
- EduType TINYINT,
- MajorName NVARCHAR(20),
- Graduation INT,
- HasViewed BIT,
- ViewDate SMALLDATETIME,
- HasRemarked BIT,
- LastJobTypeID INT,
- Valid TINYINT,
- IsOnline BIT,
- HasWeiXin BIT,
- JobRecommendDate SMALLDATETIME,
- paMainID INT,
- SecondId VARCHAR(10)
- )
-
- CREATE TABLE #T_JobID(
- JobID INT
- )
-
- DECLARE @cpMainID INT
-
- SELECT @cpMainID = CASE AccountType WHEN 1 THEN CpMainID ELSE 0 END FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
-
- IF @cpMainID <> 0 --管理员用户
- BEGIN
- INSERT INTO #T_JobID (JobID)
- SELECT ID FROM Job WITH(NOLOCK)
- WHERE cpMainID = @cpMainID
- END
- ELSE
- BEGIN
- INSERT INTO #T_JobID (JobID)
- SELECT ID FROM Job WITH(NOLOCK)
- WHERE caMainID = @caMainID
- END
-
- INSERT INTO @T_CvList(ID, dcMajorID, Degree, RelatedWorkYears, dcSalaryID, Speciality, RefreshDate,
- LastLoginDate, JobName, MatchJobID, Gender, BirthDay, LivePlace, LastJobTypeID, Attachment,
- HasPhoto, HasViewed, HasRemarked, Valid, IsOnline, JobRecommendDate, paMainId, SecondId)
- SELECT a.ID, a.dcMajorID, a.Degree, a.RelatedWorkYears, a.dcSalaryID, ISNULL(a.Speciality, a.SpecialityEng) Speciality,
- a.RefreshDate, j.LastLoginDate, ISNULL(a.JobName, '应届毕业生') JobName, b.JobID, j.Gender, j.BirthDay, j.LivePlace,
- a.LastJobTypeID, a.Attachment, j.HasPhoto, 0, 0, a.Valid, dbo.GetPaOnlineStatus(j.ID), b.AddDate, a.paMainId, a.SecondId
- FROM cvmainPublish a WITH(NOLOCK)
- INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID=j.ID
- INNER JOIN caJobCvMatch b ON a.id=b.MatchCvMainID
- WHERE b.JobID IN (SELECT JobID FROM #T_JobID)
- ORDER BY b.AddDate DESC
-
- DECLARE @PageLowerBound INT --定义此页的底码
- DECLARE @PageUpperBound INT --定义此页的顶码
- SET @PageLowerBound = (@PageNo -1) * 20
- SET @PageUpperBound = @PageLowerBound + 20
- UPDATE a SET a.cvEducationID = (
- SELECT TOP 1 ID FROM cvEducationPublish WITH(NOLOCK)
- WHERE cvEducationPublish.cvMainID = a.ID
- AND a.Degree = cvEducationPublish.Degree
- ORDER BY Graduation DESC)
- FROM @T_CvList a
- WHERE a.iIndex > @PageLowerBound
- AND a.iIndex <= @PageUpperBound
-
- UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
- a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
- FROM @T_CvList a, cvEducationPublish b WITH(NOLOCK)
- WHERE b.ID = a.cvEducationID
- AND a.iIndex > @PageLowerBound
- AND a.iIndex <= @PageUpperBound
- --修改是否绑定微信
- UPDATE a SET HasWeiXin = 1
- FROM @T_CvList a, WxFans b WITH(NOLOCK), CvMainPublish c WITH(NOLOCK)
- WHERE a.ID = c.ID
- AND c.PaMainID = b.PaMainID
- AND b.Status = 2
- AND a.iIndex > @PageLowerBound
- AND a.iIndex <= @PageUpperBound
-
- UPDATE a SET a.MatchJobName = b.Name
- FROM @T_CvList a, Job b WITH(NOLOCK)
- WHERE a.MatchJobID = b.ID
- AND a.iIndex > @PageLowerBound
- AND a.iIndex <= @PageUpperBound
- UPDATE a SET a.HasViewed = 1, a.ViewDate = b.AddDate
- FROM @T_CvList a, caCvViewLog b WITH(NOLOCK)
- WHERE b.cvMainID = a.ID AND caMainID=@caMainID
- AND a.iIndex > @PageLowerBound
- AND a.iIndex <= @PageUpperBound
- SELECT a.*,b.Description DegreeName,dbo.BirthToAge(a.BirthDay) Age,c.Description LivePlaceName
- FROM @T_CvList a
- LEFT JOIN MainDB..dcEducation b WITH(NOLOCK) ON b.ID = a.Degree
- LEFT JOIN MainDB..dcRegion c WITH(NOLOCK) ON c.ID = a.LivePlace
- WHERE a.iIndex > @PageLowerBound
- AND a.iIndex <= @PageUpperBound
-
- DROP TABLE #T_JobID
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblcaLoginContactByOpenIDSelect] Script Date: 2018/12/13 19:07:28 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2016.4.1
- --创建人:Lucifer
- --说明:根据微信号得到微信绑定企业信息
- --#####################################################
- CREATE PROCEDURE [dbo].[mblcaLoginContactByOpenIDSelect]
- (
- @OpenID VARCHAR(50)
- )
- AS
- BEGIN
- SELECT a.*, b.UserName
- FROM paLoginContact a, caMain b, cpMain c
- WHERE a.openid=@OpenID
- AND a.ContactType = 101
- AND a.PamainID = b.ID
- AND b.cpMainId = c.Id
- AND b.IsPause = 0
- AND c.IsLimitLogin IN(0, 1)
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblCaMainByIDSelect] Script Date: 2018/12/13 19:07:28 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblCaMainByIDSelect]
- (
- @caMainID INT
- )
- AS
- BEGIN TRY
- SELECT a.name,b.name as companyname,b.id cpMainID,dbo.GetCaOnlineStatus(a.id) IsOnline,b.SecondId EnCpMainId
- FROM camain a,cpmain b
- WHERE a.id=@caMainID
- AND a.cpmainid = b.id
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblCampusSchoolByIDSelect] Script Date: 2018/12/13 19:07:28 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:根据ID获取学校名称
- --#####################################################
- CREATE PROCEDURE [dbo].[mblCampusSchoolByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN TRY
- SELECT * FROM marketdb..CampusSchool WHERE ID = @ID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblcaPageViewLogByNoViewSelect] Script Date: 2018/12/13 19:07:28 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblcaPageViewLogByNoViewSelect]
- (
- @caMainID INT
- )
- AS
- SET NOCOUNT ON
- IF @caMainID = 0
- BEGIN
- SELECT TOP 0 0 ID
- RETURN
- END
- BEGIN
- IF NOT EXISTS(SELECT 'x' FROM caPageViewLog WITH(NOLOCK) WHERE caMainId = @caMainID)
- BEGIN
- INSERT INTO caPageViewLog(caMainId,addDate,ApplyCvDate,RecommendCvDate,InterviewReplyDate)
- VALUES(@caMainID, DATEADD(MINUTE, -10, GETDATE()), DATEADD(MINUTE, -10, GETDATE()), DATEADD(MINUTE, -10, GETDATE()), DATEADD(MINUTE, -10, GETDATE()))
- --RETURN
- END
-
- DECLARE @AddDate SMALLDATETIME, @ApplyCvDate SMALLDATETIME, @RecommendCvDate SMALLDATETIME,
- @InterviewReplyDate SMALLDATETIME, @ApplyCvCount INT, @RecommendCvCount INT,
- @InterviewReplyCount INT,@ChatCount INT,@cpMainID INT,@AccountType SMALLINT
-
- SELECT @AddDate = AddDate,
- @ApplyCvDate = ISNULL(ApplyCvDate, DATEADD(MINUTE, -10, GETDATE())),
- @RecommendCvDate = ISNULL(RecommendCvDate, DATEADD(MINUTE, -10, GETDATE())),
- @InterviewReplyDate = ISNULL(InterviewReplyDate, DATEADD(MINUTE, -10, GETDATE())),
- @ApplyCvCount = ISNULL(ApplyCvCount, 0),
- @RecommendCvCount = ISNULL(RecommendCvCount, 0),
- @InterviewReplyCount = ISNULL(InterviewReplyCount, 0),
- @ChatCount = ISNULL(ChatCount, 0)
- FROM caPageViewLog WITH(NOLOCK)
- WHERE caMainId = @caMainID
-
- SELECT @cpMainID=cpMainID,@AccountType=AccountType
- FROM caMain WITH(NOLOCK)
- WHERE ID = @caMainID
-
- CREATE TABLE #TJobIDs
- (
- ID INT
- )
-
- IF @AccountType = 1 --管理员账户
- BEGIN
- INSERT INTO #TJobIDs(ID)
- SELECT ID
- FROM Job WITH(NOLOCK)
- WHERE cpMainID = @cpMainID
- END
- ELSE
- BEGIN
- INSERT INTO #TJobIDs(ID)
- SELECT ID
- FROM Job WITH(NOLOCK)
- WHERE caMainID = @caMainID
- END
-
- --更新时间超过30分钟的,重新计算提醒内容
- IF GETDATE() > DATEADD(MINUTE, 30, @AddDate) --30分钟内的不重新生成
- BEGIN
- --新应聘的简历
- IF @ApplyCvCount = 0
- BEGIN
- SELECT @ApplyCvCount = COUNT(1)
- FROM exJobApply WITH(NOLOCK)
- WHERE JobID IN(SELECT ID FROM #TJobIDs)
- AND AddDate > @ApplyCvDate
- END
-
- --新推荐简历
- IF @RecommendCvCount = 0
- BEGIN
- SELECT @RecommendCvCount = COUNT(1)
- FROM caJobCvMatch WITH(NOLOCK)
- WHERE JobID IN(SELECT ID FROM #TJobIDs)
- AND AddDate > @RecommendCvDate
- END
-
- --新面试通知答复
- IF @InterviewReplyCount = 0
- BEGIN
- SELECT @InterviewReplyCount = COUNT(1)
- FROM exInterview WITH(NOLOCK)
- WHERE JobID IN(SELECT ID FROM #TJobIDs)
- AND Replydate > @RecommendCvDate
- END
-
- --新的聊天信息
- IF @ChatCount = 0
- BEGIN
- SELECT @ChatCount=COUNT(1)
- FROM ChatOnlineLog a WITH(NOLOCK)
- LEFT JOIN ChatOnline b WITH(NOLOCK) ON a.ChatOnlineID = b.ID
- WHERE b.caMainID = @caMainID
- AND a.IsViewed = 0
- AND a.SenderType = 2
- END
-
- --更新添加时间
- IF (@ApplyCvCount + @RecommendCvCount + @InterviewReplyCount + @ChatCount)>0
- UPDATE caPageViewLog
- SET AddDate = GETDATE(),
- ApplyCvCount = @ApplyCvCount,
- RecommendCvCount = @RecommendCvCount,
- InterviewReplyCount = @InterviewReplyCount,
- ChatCount =@ChatCount
- WHERE caMainId = @caMainID
- ELSE
- UPDATE caPageViewLog
- SET AddDate = GETDATE()
- WHERE caMainId = @caMainID
- END
- SELECT * FROM caPageViewLog WHERE caMainId = @caMainID --查询表内容
- DROP TABLE #TJobIDs
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblChatOnlineByCaIDSelect] Script Date: 2018/12/13 19:07:28 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:根据camainid manageruserid 得到会话信息
- --#####################################################
- CREATE PROCEDURE [dbo].[mblChatOnlineByCaIDSelect]
- (
- @caMainID INT,
- @mID INT
- )
- AS
- BEGIN TRY
- SELECT TOP 1 *
- FROM chatonline
- WHERE caMainID = @caMainID
- AND manageruserid=@mID
- AND enddate IS NULL
- ORDER BY adddate DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblChatOnlineByCaMainIDSelect] Script Date: 2018/12/13 19:07:29 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:获取客服
- --#####################################################
- CREATE PROCEDURE [dbo].[mblChatOnlineByCaMainIDSelect]
- (
- @caMainID INT
- )
- AS
- BEGIN TRY
- SELECT a.manageruserid,b.Name
- FROM chatonline a,ManagerUser b
- WHERE a.camainid = @caMainID
- AND a.enddate is null
- AND a.manageruserid <> 0
- AND a.ManagerUserID = b.ID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblChatOnlineByCvMainIDSelect] Script Date: 2018/12/13 19:07:29 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:根据cvmainid camainid 得到会话信息
- --#####################################################
- CREATE PROCEDURE [dbo].[mblChatOnlineByCvMainIDSelect]
- (
- @cvMainID INT,
- @caMainID INT
- )
- AS
- BEGIN TRY
- SELECT TOP 1 *
- FROM chatonline
- WHERE cvMainID = @cvMainID
- AND caMainID=@caMainID
- AND enddate IS NULL
- ORDER BY adddate DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblChatOnlineByMIDSelect] Script Date: 2018/12/13 19:07:29 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:根据cvmainid manageruserid 得到会话信息
- --#####################################################
- CREATE PROCEDURE [dbo].[mblChatOnlineByMIDSelect]
- (
- @cvMainID INT,
- @manageruserid INT
- )
- AS
- BEGIN TRY
- SELECT TOP 1 *
- FROM chatonline
- WHERE cvMainID = @cvMainID
- AND manageruserid=@manageruserid
- AND enddate IS NULL
- ORDER BY adddate DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblChatOnlineCpNoViewCntSelect] Script Date: 2018/12/13 19:07:29 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.7
- --创建人:John
- --说明:在线沟通企业未读总条数
- --#####################################################
- CREATE PROCEDURE [dbo].[mblChatOnlineCpNoViewCntSelect]
- (
- @caMainID INT
- )
- AS
- BEGIN
- SELECT COUNT(*) cnt FROM chatonlinelog a WITH(NOLOCK) INNER JOIN chatonline b WITH(NOLOCK) ON a.chatonlineid=b.id
- WHERE a.sendertype = 2 AND a.isviewed = 0 AND b.caMainID = @caMainID
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblChatOnlineInsert] Script Date: 2018/12/13 19:07:29 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:获取个人信息
- --#####################################################
- CREATE PROCEDURE [dbo].[mblChatOnlineInsert]
- (
- @cvMainID INT,
- @caMainID INT
- )
- AS
- BEGIN TRY
- INSERT INTO chatonline (cvMainID,caMainID,initiative,startDate,valid,adddate)
- VALUES(@cvMainID,@caMainID,1,getdate(),0,getdate())
- RETURN 1
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblChatOnlineLogByCaIDSelect] Script Date: 2018/12/13 19:07:30 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:企业会话列表
- --#####################################################
- CREATE PROCEDURE [dbo].[mblChatOnlineLogByCaIDSelect]
- @cvMainID INT,
- @caMainID INT
- AS
- BEGIN TRY
- SELECT a.* FROM ChatOnlineLog a
- WHERE a.ChatOnlineID IN(
- SELECT ID FROM
- ChatOnline WHERE cvMainID=@cvMainID AND caMainID=@caMainID
- )
- ORDER BY a.AddDate
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblChatOnlineLogByConditionSelect] Script Date: 2018/12/13 19:07:30 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:获取企业与顾问的回话信息
- --#####################################################
- CREATE PROCEDURE [dbo].[mblChatOnlineLogByConditionSelect]
- (
- @caMainID INT,
- @consultantID INT,
- @Condition VARCHAR(MAX)
- )
- AS
- BEGIN TRY
- DECLARE @SQL VARCHAR(MAX)
- SET @SQL = '
- SELECT a.* FROM ChatOnlineLog a
- WHERE a.ChatOnlineID IN(
- SELECT ID FROM
- ChatOnline WHERE caMainID='+CONVERT(VARCHAR(20),@caMainID)+'
- AND managerUserID='+CONVERT(VARCHAR(10),@consultantID)+'
- '+@Condition+'
- )
- ORDER BY a.AddDate'
- PRINT @SQL
- EXEC (@SQL)
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblChatOnlineLogByCvMainIDUpdate] Script Date: 2018/12/13 19:07:30 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:将消息修改为已读
- --#####################################################
- CREATE PROCEDURE [dbo].[mblChatOnlineLogByCvMainIDUpdate]
- (
- @cvMainID INT,
- @caMainID INT
- )
- AS
- BEGIN TRY
- UPDATE chatonlinelog
- SET isviewed=1
- WHERE isviewed=0
- AND chatonlineid IN(
- SELECT ID FROM chatonline
- WHERE cvmainid = @cvMainID
- AND camainid = @caMainID
- ) AND SenderType = 1
- RETURN 1
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblChatOnlineLogByIDSelect] Script Date: 2018/12/13 19:07:30 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:根据ID获取会话信息
- --#####################################################
- CREATE PROCEDURE [dbo].[mblChatOnlineLogByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN TRY
- SELECT * FROM chatonline WHERE id=@ID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblChatOnlineLogByMIDSelect] Script Date: 2018/12/13 19:07:30 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:顾问或客服会话
- --#####################################################
- CREATE PROCEDURE [dbo].[mblChatOnlineLogByMIDSelect]
- (
- @cvMainID INT,
- @managerUserID INT
- )
- AS
- BEGIN TRY
- SELECT a.* FROM ChatOnlineLog a
- WHERE a.ChatOnlineID IN(
- SELECT ID
- FROM ChatOnline
- WHERE cvMainID=@cvMainID
- AND managerUserID=@managerUserID)
- ORDER BY a.AddDate
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblChatOnlineLogByMIDUpdate] Script Date: 2018/12/13 19:07:30 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:将消息修改为已读
- --#####################################################
- CREATE PROCEDURE [dbo].[mblChatOnlineLogByMIDUpdate]
- (
- @cvMainID INT,
- @mID INT
- )
- AS
- BEGIN TRY
- UPDATE chatonlinelog
- SET isviewed=1
- WHERE isviewed=0
- AND chatonlineid IN(
- SELECT ID FROM chatonline
- WHERE cvmainid = @cvMainID
- AND managerUserID = @mID
- )
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblChatOnlineLogBySenderTypeUpdate] Script Date: 2018/12/13 19:07:30 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:将消息修改为已读
- --#####################################################
- CREATE PROCEDURE [dbo].[mblChatOnlineLogBySenderTypeUpdate]
- (
- @cvMainID INT,
- @caMainID INT
- )
- AS
- BEGIN TRY
- UPDATE chatonlinelog
- SET isviewed=1
- WHERE isviewed=0
- AND chatonlineid IN(
- SELECT ID FROM chatonline
- WHERE cvmainid = @cvMainID
- AND camainid = @caMainID
- ) AND SenderType = 2
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblChatOnlineLogInsert] Script Date: 2018/12/13 19:07:31 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:发送消息 插入
- --#####################################################
- CREATE PROCEDURE [dbo].[mblChatOnlineLogInsert]
- (
- @chatOnlineID INT,
- @senderType INT,
- @Message VARCHAR(500)
- )
- AS
- BEGIN TRY
- INSERT INTO chatonlinelog (chatOnlineID,SenderType,isviewed,message,adddate)
- VALUES(@chatOnlineID,@senderType,0,@Message,getdate())
- RETURN 1
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblChatonlineLogNoViewCntByPaMainIDSelect] Script Date: 2018/12/13 19:07:31 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:个人未读总条数
- --#####################################################
- CREATE PROCEDURE [dbo].[mblChatonlineLogNoViewCntByPaMainIDSelect]
- @PamainID INT
- AS
- BEGIN TRY
- SELECT COUNT(*) cnt
- FROM chatonlinelog
- WHERE sendertype=1
- AND isviewed = 0
- AND chatonlineid IN (
- SELECT id
- FROM chatonline
- WHERE cvmainid in (
- SELECT ID FROM cvmain
- WHERE pamainid=@PaMainID
- )
- )
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblChatOnlineLogViewByCaMainIDUpdate] Script Date: 2018/12/13 19:07:31 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:将消息修改为已读
- --#####################################################
- CREATE PROCEDURE [dbo].[mblChatOnlineLogViewByCaMainIDUpdate]
- (
- @caMainID INT,
- @cvMainID INT
- )
- AS
- BEGIN TRY
- UPDATE chatonlinelog
- SET isviewed=1
- WHERE isviewed=0
- AND chatonlineid IN(
- SELECT ID FROM chatonline
- WHERE camainid = @caMainID
- AND cvmainid = @cvMainID)
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblChatOnlineLogViewByCIDUpdate] Script Date: 2018/12/13 19:07:31 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:将消息修改为已读
- --#####################################################
- CREATE PROCEDURE [dbo].[mblChatOnlineLogViewByCIDUpdate]
- (
- @caMainID INT
- )
- AS
- BEGIN TRY
- UPDATE chatonlinelog
- SET isviewed=1
- WHERE isviewed=0
- AND chatonlineid IN(
- SELECT ID FROM chatonline
- WHERE camainid = @caMainID
- AND managerUserID <=200)
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblChatOnlineLogViewByMIDUpdate] Script Date: 2018/12/13 19:07:31 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:将消息修改为已读
- --#####################################################
- CREATE PROCEDURE [dbo].[mblChatOnlineLogViewByMIDUpdate]
- (
- @caMainID INT,
- @mID INT
- )
- AS
- BEGIN TRY
- UPDATE chatonlinelog
- SET isviewed=1
- WHERE isviewed=0
- AND chatonlineid IN(
- SELECT ID FROM chatonline
- WHERE camainid = @caMainID
- AND managerUserID = @mID)
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblChatServiceSelect] Script Date: 2018/12/13 19:07:31 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:获取客服
- --#####################################################
- CREATE PROCEDURE [dbo].[mblChatServiceSelect]
- (
- @IsOnline INT
- )
- AS
- BEGIN TRY
- IF @IsOnline = 1
- BEGIN
- SELECT TOP 1 * FROM ChatService WHERE IsOnline=1 ORDER BY ChatCount
- END
- ELSE
- BEGIN
- SELECT TOP 1 * FROM ChatService ORDER BY ChatCount
- END
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblCpMainByIDSelect] Script Date: 2018/12/13 19:07:32 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.7
- --创建人:John
- --说明:根据ID或SecondID获取CpMain相关信息
- --修改:harry2015-6-18
- --增加secondid
- --修改:peter 2016-12-16 添加logo获取
- --#####################################################
- CREATE PROCEDURE [dbo].[mblCpMainByIDSelect]
- (
- @ID VARCHAR(20),
- @ColumnType TINYINT
- )
- AS
- BEGIN
- IF @ColumnType = 1
- 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
- FROM CpMain a WITH(NOLOCK)
- LEFT JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionID = b.ID
- LEFT JOIN dcCompanyKind c WITH(NOLOCK) ON a.dcCompanyKindID = c.ID
- LEFT JOIN dcCompanySize d WITH(NOLOCK) ON a.dcCompanySizeID = d.ID
- LEFT JOIN cpImage e WITH(NOLOCK) ON e.cpMainID = a.ID AND e.ImgType = 1 AND e.HasPassed = 1
- WHERE a.ID = @ID
- AND a.IsLimitLogin <> 9
- ELSE
- 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
- FROM CpMain a WITH(NOLOCK)
- LEFT JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionID = b.ID
- LEFT JOIN dcCompanyKind c WITH(NOLOCK) ON a.dcCompanyKindID = c.ID
- LEFT JOIN dcCompanySize d WITH(NOLOCK) ON a.dcCompanySizeID = d.ID
- LEFT JOIN cpImage e WITH(NOLOCK) ON e.cpMainID = a.ID AND e.ImgType = 1 AND e.HasPassed = 1
- WHERE a.SecondID = @ID
- AND a.IsLimitLogin <> 9
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblCvEducationByIdSelect] Script Date: 2018/12/13 19:07:32 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblCvEducationByIdSelect]
- (
- @ID int
- )
- AS
- BEGIN
- SELECT a.*, b.Description Major, c.Description EduTypeName, d.Description Education
- FROM cvEducation a WITH(NOLOCK INDEX(IX_cvEducation_CvMainID)),
- dcMajor b WITH(NOLOCK),
- dcEduType c WITH(NOLOCK),
- dcEducation d WITH(NOLOCK)
- WHERE a.dcMajorID = b.ID
- AND a.EduType = c.ID
- AND a.Degree = d.ID
- AND a.ID = @ID
- ORDER BY a.Degree DESC,
- a.Graduation Desc
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblCvEducationSave] Script Date: 2018/12/13 19:07:32 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblCvEducationSave]
- @ID INT,
- @cvMainID INT,
- @GraduateCollage VARCHAR(250),
- @Graduation INT,
- @dcMajorID SMALLINT,
- @MajorName VARCHAR(100),
- @Degree TINYINT,
- @EduType TINYINT,
- @paMainID INT
- AS
- BEGIN TRAN
- ----检查是否是该账号的简历
- IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID =@cvMainID AND paMainID = @paMainID)
- GOTO ERR
- ----检查是否是该简历的教育背景
- IF @ID > 0
- IF NOT EXISTS(SELECT 'x' FROM cvEducation WITH(NOLOCK) WHERE ID = @ID AND cvMainID = @cvMainID)
- GOTO ERR
-
- SET @GraduateCollage = dbo.SafeSql(dbo.TextTrim(@GraduateCollage))
- SET @MajorName = dbo.SafeSql(dbo.TextTrim(@MajorName))
- DECLARE @MaxId AS INT
- DECLARE @CNT AS INT
- DECLARE @GraduateCollageOld AS VARCHAR(250)
- DECLARE @MajorNameOld AS VARCHAR(100)
- DECLARE @cvdcMajorID AS SMALLINT
- DECLARE @Modify AS INT
- SET @Modify=-1
- BEGIN TRY
- BEGIN
- DECLARE @GC AS NVARCHAR(50)
- DECLARE @MN AS NVARCHAR(20)
- SET @GC = @GraduateCollage
- SET @MN = @MajorName
- IF @ID>0
- BEGIN
- SELECT @GraduateCollageOld = dbo.TextTrim(GraduateCollage),
- @MajorNameOld = dbo.TextTrim(MajorName)
- FROM cvEducation WITH(NOLOCK INDEX(PK_cvEducation)) WHERE ID=@ID
- UPDATE cvEducation SET
- GraduateCollage = @GC,
- Graduation = @Graduation,
- dcMajorID = @dcMajorID,
- MajorName =@MN,
- Degree = @Degree,
- EduType = @EduType
- WHERE ID=@ID
- SET @MaxID=@ID
- IF ISNULL(@GraduateCollageOld, '') <> ISNULL(@GC, '')
- BEGIN
- DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'dc1'
- INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'dc1',@GC)
- SET @Modify=0
- END
- IF ISNULL(@MajorNameOld, '') <> ISNULL(@MN, '')
- BEGIN
- DELETE FROM bsCvModify WHERE paMainID=@paMainID AND cvMainID=@cvMainID AND SubID = @ID AND Location = 'dc2'
- INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'dc2',@MN)
- SET @Modify=0
- END
- END
- ELSE
- BEGIN
- SELECT @CNT=COUNT(*) FROM cvEducation WITH(NOLOCK INDEX(PK_cvEducation)) WHERE cvMainID = @cvMAinID
- IF @CNT<5
- BEGIN
- INSERT INTO cvEducation(cvMainID,GraduateCollage,Graduation,dcMajorID,MajorName,Degree,EduType)
- VALUES(@cvMainID,@GC,@Graduation,@dcMajorID,@MN,@Degree,@EduType)
- SET @MaxID = @@IDENTITY
- INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'dc1',@GC)
- INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'dc2',@MN)
- SET @Modify=0
- END
- ELSE
- GOTO ERR
- END
- END
-
- SELECT @Degree = MAX(DEGREE) FROM cvEducation WITH(NOLOCK) WHERE cvMainID = @cvMainID
- UPDATE cvMain SET Degree=@Degree, dcMajorID=@dcMajorID WHERE ID=@cvMainID
- --修改cvLevel
- DECLARE @SQL AS VARCHAR(100)
- SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew ' + CONVERT(CHAR(1), 0) + ',' + CONVERT(VARCHAR(10), @cvMainID) + ',3,1'
- EXEC(@SQL)
- END TRY
- BEGIN CATCH
- GOTO ERR
- END CATCH
- COMMIT TRAN
- RETURN @MaxID
- ERR:
- BEGIN
- ROLLBACK TRAN
- RETURN 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblCvEducationSelect] Script Date: 2018/12/13 19:07:32 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblCvEducationSelect]
- (
- @cvMainID int
- )
- AS
- BEGIN
- SELECT a.*, b.Description Major, c.Description EduTypeName, d.Description Education
- FROM cvEducation a WITH(NOLOCK INDEX(IX_cvEducation_CvMainID)),
- dcMajor b WITH(NOLOCK),
- dcEduType c WITH(NOLOCK),
- dcEducation d WITH(NOLOCK)
- WHERE a.dcMajorID=b.ID AND a.EduType=c.ID AND a.Degree=d.ID AND a.cvMainID=@cvMainID
- ORDER BY a.Degree DESC,a.Graduation Desc
- END
- set ANSI_NULLS ON
- set QUOTED_IDENTIFIER ON
- GO
- /****** Object: StoredProcedure [dbo].[mblCvExperienceByIdSelect] Script Date: 2018/12/13 19:07:33 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblCvExperienceByIdSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT a.*, b.Description JobType, c.Description CpmpanySize, d.Description Industry,
- g.Description LowerNumber, e.Description CompanyKind, f.Description LeaveReson, h.FullName Region
- FROM cvExperience a WITH(NOLOCK INDEX(IX_cvExperience_cvMainID))
- LEFT JOIN dcJobType b WITH(NOLOCK) ON a.dcJobTypeID=b.ID
- LEFT JOIN dcCompanySize c WITH(NOLOCK) ON a.dcCompanySizeID=c.ID
- LEFT JOIN dcIndustry d WITH(NOLOCK) ON a.dcIndustryID=d.ID
- LEFT JOIN dcLowerNumber g WITH(NOLOCK) ON a.SubNodeNum=g.ID
- LEFT JOIN dcCompanyKind e WITH(NOLOCK) ON a.dcCompanyKindID=e.ID
- LEFT JOIN dcLeaveReson f WITH(NOLOCK) ON a.dcLeaveResonID=f.ID
- LEFT JOIN dcRegion h WITH(NOLOCK) ON a.WorkPlace=h.ID
- WHERE a.ID = @ID
- ORDER BY a.BeginDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblCvExperienceDelete] Script Date: 2018/12/13 19:07:33 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- -----------------------------------------------
- --创建Sean
- --检查时间 2010-9-27
- --修改了有无工作经验的判断, 取消pcCvMainVerifyResultCheck
- --修改:Lambo,2010-11-25
- --描述:增加了paMainID参数,判断是否是本人的
- -----------------------------------------------
- CREATE PROCEDURE [dbo].[mblCvExperienceDelete]
- (
- @ID INT,
- @paMainID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN TRAN
- BEGIN TRY
- DECLARE @cvMainId AS INT
- DECLARE @RETURN AS VARCHAR(2)
- SELECT @cvMainId = cvMainId FROM cvExperience WITH(NOLOCK) WHERE ID=@ID
- IF @cvMainId IS NULL
- GOTO ERR
- IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE paMainID = @paMainID AND ID = @cvMainID)
- GOTO ERR
- DELETE FROM bsCvModify WHERE SubID = @ID AND Location LIKE 'e%'
- DELETE FROM cvExperience WHERE ID = @ID
- IF (SELECT COUNT(*) FROM cvExperience WITH(NOLOCK) WHERE cvMainId = @cvMainId) = 0
- UPDATE cvMain SET cvType = 1, cvLevel = LEFT(cvLevel, 3) + '1' + RIGHT(cvLevel, 6),
- cvLevelEng = LEFT(cvLevelEng, 3) + '1' + RIGHT(cvLevelEng, 6)
- WHERE Id = @cvMainId
- END TRY
- BEGIN CATCH
- GOTO ERR
- END CATCH
- COMMIT TRAN
- RETURN @RETURN
- ERR:
- BEGIN
- ROLLBACK TRAN
- RETURN 3
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblCvExperienceSave] Script Date: 2018/12/13 19:07:33 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblCvExperienceSave]
- (
- @ID INT,
- @cvMainID INT,
- @CompanyName VARCHAR(100),
- @dcIndustryID INT,
- @dcCompanySizeID INT,
- @dcJobtypeID INT,
- @JobName VARCHAR(100),
- @BeginDate INT,
- @EndDate INT,
- @SubNodeNum INT,
- @Description VARCHAR(Max),
- @paMainID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN TRAN
- ----检查是否是该账号的简历
- IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID AND paMainID = @paMainID)
- GOTO ERR
- ----检查是否是该简历的工作经验
- IF @ID > 0
- IF NOT EXISTS(SELECT 'x' FROM cvExperience WITH(NOLOCK) WHERE ID = @ID AND cvMainID = @cvMainID)
- GOTO ERR
- SET @CompanyName = dbo.SafeSql(dbo.TextTrim(@CompanyName))
- SET @JobName = dbo.SafeSql(dbo.TextTrim(@JobName))
- SET @Description = dbo.SafeSql(dbo.TextTrim(@Description))
- IF CHARINDEX(',', @JobName) > 0
- SELECT @JobName = dbo.SafeSql(REPLACE(@JobName, ',', ','))
- DECLARE @MaxId AS INT
- DECLARE @CNT AS INT
- DECLARE @CompanyNameOld AS VARCHAR(100)
- DECLARE @JobNameOld AS VARCHAR(100)
- DECLARE @DescriptionOld AS VARCHAR(Max)
- DECLARE @Modify AS INT
- SET @Modify = -1
- BEGIN TRY
- BEGIN
- DECLARE @C_CompanyName AS NVARCHAR(30)
- DECLARE @C_JobName AS NVARCHAR(50)
- DECLARE @C_Description AS NVARCHAR(2000)
- SET @C_CompanyName = dbo.TextTrim(@CompanyName)
- SET @C_JobName = dbo.TextTrim(@JobName)
- SET @C_Description = dbo.TextTrim(@Description)
-
- IF @ID>0
- BEGIN
- SELECT @CompanyNameOld = dbo.TextTrim(ISNULL(CompanyName, '')),
- @JobNameOld = dbo.TextTrim(ISNULL(JobName, '')),
- @DescriptionOld = dbo.TextTrim(ISNULL(Description, ''))
- FROM cvExperience WITH(NOLOCK INDEX(PK_cvExperience)) WHERE ID = @ID
- UPDATE cvExperience SET
- CompanyName = @C_CompanyName,
- dcIndustryID = @dcIndustryID,
- dcCompanySizeID = @dcCompanySizeID,
- dcJobtypeID = @dcJobtypeID,
- JobName = @C_JobName,
- BeginDate = @BeginDate,
- EndDate = @EndDate,
- SubNodeNum = @SubNodeNum,
- Description = @C_Description
- WHERE ID = @ID
- SET @MaxID = @ID
- IF ISNULL(@CompanyNameOld, '') <> ISNULL(@C_CompanyName, '')
- BEGIN
- DELETE FROM bsCvModify WHERE SubID = @ID AND Location = 'ec1'
- INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec1',@CompanyName)
- SET @Modify = 0
- END
- IF ISNULL(@JobNameOld, '') <> ISNULL(@C_JobName, '')
- BEGIN
- DELETE FROM bsCvModify WHERE paMainID = @paMainID AND cvMainID = @cvMainID AND SubID = @ID AND Location = 'ec2'
- INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec2',@C_JobName)
- SET @Modify = 0
- END
- IF ISNULL(@DescriptionOld, '') <> ISNULL(@C_Description, '')
- BEGIN
- DELETE FROM bsCvModify WHERE paMainID = @paMainID AND cvMainID = @cvMainID AND SubID = @ID AND Location = 'ec3'
- INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec3',@C_Description)
- SET @Modify = 0
- END
-
- END
- ELSE
- BEGIN
- SELECT @CNT = COUNT(*) FROM cvExperience WITH(NOLOCK INDEX(IX_cvExperience_cvMainID)) WHERE cvMainID = @cvMainID
- IF @CNT<20
- BEGIN
- INSERT INTO cvExperience
- (cvMainID,CompanyName,dcIndustryID,dcCompanySizeID,dcJobtypeID,JobName,
- BeginDate,EndDate,SubNodeNum,Description)
- VALUES
- (@cvMainID,@CompanyName,@dcIndustryID,@dcCompanySizeID,@dcJobtypeID,@JobName,
- @BeginDate,@EndDate,@SubNodeNum,@Description)
- SET @MaxID = @@IDENTITY
- INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec1',@C_CompanyName)
- INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec2',@C_JobName)
- INSERT INTO bsCvModify(paMainID,cvMainID,SubID,Location,ColValue) VALUES(@paMainID,@cvMainID,@MaxID,'ec3',@C_Description)
- SET @Modify = 0
- END
- ELSE
- GOTO ERR
- END
- END
- UPDATE cvMain SET cvType = 0 WHERE Id = @CvMainId AND cvType = 1
- --修改cvLevel
- DECLARE @SQL AS VARCHAR(100)
- SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew ' + CONVERT(CHAR(1), 0) + ',' + CONVERT(VARCHAR(10), @cvMainID) + ',4,1'
- EXEC(@SQL)
- END TRY
- BEGIN CATCH
- GOTO ERR
- END CATCH
- COMMIT TRAN
- RETURN @MaxID
- ERR:
- BEGIN
- ROLLBACK TRAN
- RETURN 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblCvExperienceSelect] Script Date: 2018/12/13 19:07:33 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblCvExperienceSelect]
- (
- @cvMainID INT
- )
- AS
- BEGIN
- SELECT a.*, b.Description JobType, c.Description CpmpanySize, d.Description Industry,
- g.Description LowerNumber, e.Description CompanyKind, f.Description LeaveReson, h.FullName Region
- FROM cvExperience a WITH(NOLOCK INDEX(IX_cvExperience_cvMainID))
- LEFT JOIN dcJobType b WITH(NOLOCK) ON a.dcJobTypeID=b.ID
- LEFT JOIN dcCompanySize c WITH(NOLOCK) ON a.dcCompanySizeID=c.ID
- LEFT JOIN dcIndustry d WITH(NOLOCK) ON a.dcIndustryID=d.ID
- LEFT JOIN dcLowerNumber g WITH(NOLOCK) ON a.SubNodeNum=g.ID
- LEFT JOIN dcCompanyKind e WITH(NOLOCK) ON a.dcCompanyKindID=e.ID
- LEFT JOIN dcLeaveReson f WITH(NOLOCK) ON a.dcLeaveResonID=f.ID
- LEFT JOIN dcRegion h WITH(NOLOCK) ON a.WorkPlace=h.ID
- WHERE cvMainID = @cvMainID
- ORDER BY a.BeginDate DESC
- END
- set ANSI_NULLS ON
- set QUOTED_IDENTIFIER ON
- GO
- /****** Object: StoredProcedure [dbo].[mblCvInfoSelect] Script Date: 2018/12/13 19:07:34 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblCvInfoSelect]
- (
- @cvMainID INT,
- @paMainID INT
- )
- AS
- BEGIN
- --获取个人信息
- SELECT 1 dcCareerStatus, a.*,
- b.FullName LiveRegion, c.FullName GrowRegion, d.FullName AccountRegion,
- ISNULL(e.Description, '目前处于离职状态,可即刻上岗') CareerStatus, f.PhotoProcessed,
- (SELECT TOP 1 LoginIP FROM paLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = a.ID ORDER BY ID DESC) AS LastLoginIP,
- (SELECT COUNT(1) FROM paLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = a.ID AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)) AS TodayLoginNum,
- dbo.BirthToAge(a.BirthDay) Age
- FROM paMain a WITH(NOLOCK INDEX(PK_paMain))
- LEFT JOIN dcRegion b WITH(NOLOCK) ON a.LivePlace=b.ID
- LEFT JOIN dcRegion c WITH(NOLOCK) ON a.GrowPlace=c.ID
- LEFT JOIN dcRegion d WITH(NOLOCK) ON a.AccountPlace=d.ID
- LEFT JOIN dcCareerStatus e WITH(NOLOCK) ON a.dcCareerStatus=e.ID
- LEFT JOIN paPhoto f WITH(NOLOCK) ON a.HasPhoto<2 AND a.ID=f.paMainID
- WHERE a.ID = @paMainID
- --获取简历信息
- SELECT *
- FROM cvMain WITH(NOLOCK INDEX(PK_cvMain))
- WHERE ID = @cvMainID
-
- --获取教育背景
- SELECT a.*, b.Description Major, c.Description EduTypeName, d.Description Education
- FROM cvEducation a WITH(NOLOCK INDEX(IX_cvEducation_CvMainID)),
- dcMajor b WITH(NOLOCK),
- dcEduType c WITH(NOLOCK),
- dcEducation d WITH(NOLOCK)
- WHERE a.dcMajorID=b.ID AND a.EduType=c.ID AND a.Degree=d.ID AND a.cvMainID=@cvMainID
- ORDER BY a.Degree DESC, a.Graduation Desc
-
- --获取工作经验
- SELECT a.*, b.Description JobType, c.Description CpmpanySize, d.Description Industry,
- g.Description LowerNumber, e.Description CompanyKind, f.Description LeaveReson, h.FullName Region
- FROM cvExperience a WITH(NOLOCK INDEX(IX_cvExperience_cvMainID))
- LEFT JOIN dcJobType b WITH(NOLOCK) ON a.dcJobTypeID=b.ID
- LEFT JOIN dcCompanySize c WITH(NOLOCK) ON a.dcCompanySizeID=c.ID
- LEFT JOIN dcIndustry d WITH(NOLOCK) ON a.dcIndustryID=d.ID
- LEFT JOIN dcLowerNumber g WITH(NOLOCK) ON a.SubNodeNum=g.ID
- LEFT JOIN dcCompanyKind e WITH(NOLOCK) ON a.dcCompanyKindID=e.ID
- LEFT JOIN dcLeaveReson f WITH(NOLOCK) ON a.dcLeaveResonID=f.ID
- LEFT JOIN dcRegion h WITH(NOLOCK) ON a.WorkPlace=h.ID
- WHERE cvMainID=@cvMainID
- ORDER BY a.BeginDate DESC
- --获取求职意向
- DECLARE @JobType AS VARCHAR(100)
- DECLARE @JobTypeName AS VARCHAR(1000)
- DECLARE @JobPlace AS VARCHAR(100)
- DECLARE @JobPlaceName AS VARCHAR(100)
- DECLARE @Industry AS VARCHAR(100)
- DECLARE @IndustryName AS VARCHAR(100)
- DECLARE @INTTemp AS INT
- DECLARE @STRTemp AS VARCHAR(20)
- 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
- 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
- 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
-
- --取得JobType
- OPEN #JobType
- FETCH NEXT FROM #JobType INTO @INTTemp, @STRTemp
- WHILE @@FETCH_STATUS = 0
- BEGIN
- IF Len(@JobType) > 0
- BEGIN
- SET @JobType = @JobType + ' ' + Rtrim(CONVERT(CHAR(10), @INTTemp))
- SET @JobTypeName = @JobTypeName + ' ' + @STRTemp
- END
- ELSE
- BEGIN
- SET @JobType = Rtrim(CONVERT(CHAR(10), @INTTemp))
- SET @JobTypeName = @STRTemp
- END
- FETCH NEXT FROM #JobType INTO @INTTemp, @STRTemp
- END
- CLOSE #JobType
- DEALLOCATE #JobType
-
- --取得JobPlace
- OPEN #JobPlace
- FETCH NEXT FROM #JobPlace INTO @INTTemp, @STRTemp
- WHILE @@FETCH_STATUS = 0
- BEGIN
- IF Len(@JobPlace) > 0
- BEGIN
- SET @JobPlace = @JobPlace + ' ' + Rtrim(CONVERT(CHAR(10), @INTTemp))
- SET @JobPlaceName = @JobPlaceName + ' ' + @STRTemp
- END
- ELSE
- BEGIN
- SET @JobPlace = Rtrim(CONVERT(CHAR(10), @INTTemp))
- SET @JobPlaceName = @STRTemp
- END
- FETCH NEXT FROM #JobPlace INTO @INTTemp, @STRTemp
- END
- CLOSE #JobPlace
- DEALLOCATE #JobPlace
- --取得Industry
- OPEN #Industry
- FETCH NEXT FROM #Industry INTO @INTTemp, @STRTemp
- WHILE @@FETCH_STATUS = 0
- BEGIN
- IF Len(@Industry) > 0
- BEGIN
- SET @Industry = @Industry + ' ' + Rtrim(CONVERT(CHAR(10), @INTTemp))
- SET @IndustryName = @IndustryName + ' ' + @STRTemp
- END
- ELSE
- BEGIN
- SET @Industry = Rtrim(CONVERT(CHAR(10), @INTTemp))
- SET @IndustryName = @STRTemp
- END
- FETCH NEXT FROM #Industry INTO @INTTemp, @STRTemp
- END
- CLOSE #Industry
- DEALLOCATE #Industry
- SELECT
- RelatedWorkYears,
- EmployType,
- dcSalaryID,
- IsNegotiable,
- b.Description Salary,
- @JobType AS JobType,
- @JobPlace AS JobPlace,
- @Industry AS Industry,
- @JobTypeName AS JobTypeName,
- @JobPlaceName AS JobPlaceName,
- @IndustryName AS IndustryName
- From cvMain a WITH(NOLOCK)
- LEFT JOIN dcSalary b WITH(NOLOCK) ON a.dcSalaryID=b.ID
- WHERE a.id=@cvMainID
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblCvInfoSelect2] Script Date: 2018/12/13 19:07:34 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --peter 2018-3-28
- CREATE PROCEDURE [dbo].[mblCvInfoSelect2]
- (
- @cvMainID INT,
- @paMainID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- --获取个人信息
- SELECT a.*, b.FullName LiveRegion, c.FullName GrowRegion, d.FullName AccountRegion,
- e.Description CareerStatus, f.PhotoProcessed,g.Description OnlineContactName,h.Name MapPlaceName,
- (SELECT TOP 1 LoginIP FROM paLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = a.ID ORDER BY ID DESC) AS LastLoginIP,
- (SELECT COUNT(1) FROM paLoginLog WITH(NOLOCK) WHERE paLoginLog.paMainID = a.ID AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)) AS TodayLoginNum,
- dbo.BirthToAge(a.BirthDay) Age
- FROM paMain a WITH(NOLOCK INDEX(PK_paMain))
- LEFT JOIN dcRegion b WITH(NOLOCK) ON a.LivePlace=b.ID
- LEFT JOIN dcRegion c WITH(NOLOCK) ON a.GrowPlace=c.ID
- LEFT JOIN dcRegion d WITH(NOLOCK) ON a.AccountPlace=d.ID
- LEFT JOIN dcCareerStatus e WITH(NOLOCK) ON a.dcCareerStatus=e.ID
- LEFT JOIN paPhoto f WITH(NOLOCK) ON a.HasPhoto<2 AND a.ID=f.paMainID
- LEFT JOIN dcOnlineContact g WITH(NOLOCK) ON a.OnlineContact = g.ID
- LEFT JOIN dcMapPlace h WITH(NOLOCK) ON a.dcMapPlaceID = h.ID
- WHERE a.ID = @paMainID
- --获取简历信息
- SELECT a.*, b.Description EmployTypeName, c.Description DegreeName
- FROM cvMain a WITH(NOLOCK INDEX(PK_cvMain))
- LEFT JOIN dcOthers b WITH(NOLOCK) ON a.EmployType = b.DetailID AND b.Category = '工作性质'
- LEFT JOIN dcEducation c WITH(NOLOCK) ON a.Degree = c.ID
- WHERE a.ID = @cvMainID
-
- --获取教育背景
- SELECT a.*, b.Description Major, c.Description EduTypeName, d.Description DegreeName
- FROM cvEducation a WITH(NOLOCK INDEX(IX_cvEducation_CvMainID)),
- dcMajor b WITH(NOLOCK),
- dcEduType c WITH(NOLOCK),
- dcEducation d WITH(NOLOCK)
- WHERE a.dcMajorID=b.ID AND a.EduType=c.ID AND a.Degree=d.ID AND a.cvMainID=@cvMainID
- ORDER BY a.Degree DESC, a.Graduation Desc
-
- --获取工作经验
- SELECT a.*, b.Description JobType, c.Description CpmpanySize, d.Description Industry,
- g.Description LowerNumber, e.Description CompanyKind, f.Description LeaveReson, h.FullName Region
- FROM cvExperience a WITH(NOLOCK INDEX(IX_cvExperience_cvMainID))
- LEFT JOIN dcJobType b WITH(NOLOCK) ON a.dcJobTypeID=b.ID
- LEFT JOIN dcCompanySize c WITH(NOLOCK) ON a.dcCompanySizeID=c.ID
- LEFT JOIN dcIndustry d WITH(NOLOCK) ON a.dcIndustryID=d.ID
- LEFT JOIN dcLowerNumber g WITH(NOLOCK) ON a.SubNodeNum=g.ID
- LEFT JOIN dcCompanyKind e WITH(NOLOCK) ON a.dcCompanyKindID=e.ID
- LEFT JOIN dcLeaveReson f WITH(NOLOCK) ON a.dcLeaveResonID=f.ID
- LEFT JOIN dcRegion h WITH(NOLOCK) ON a.WorkPlace=h.ID
- WHERE cvMainID=@cvMainID
- ORDER BY a.BeginDate DESC
- --获取求职意向
- DECLARE @JobType AS VARCHAR(100)
- DECLARE @JobTypeName AS VARCHAR(1000)
- DECLARE @JobPlace AS VARCHAR(100)
- DECLARE @JobPlaceName AS VARCHAR(100)
- DECLARE @Industry AS VARCHAR(100)
- DECLARE @IndustryName AS VARCHAR(100)
- DECLARE @INTTemp AS INT
- DECLARE @STRTemp AS VARCHAR(50)
- 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
- 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
- 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
-
- --取得JobType
- OPEN #JobType
- FETCH NEXT FROM #JobType INTO @INTTemp, @STRTemp
- WHILE @@FETCH_STATUS = 0
- BEGIN
- IF Len(@JobType) > 0
- BEGIN
- SET @JobType = @JobType + ' ' + Rtrim(CONVERT(VARCHAR(20), @INTTemp))
- SET @JobTypeName = @JobTypeName + ' ' + @STRTemp
- END
- ELSE
- BEGIN
- SET @JobType = Rtrim(CONVERT(VARCHAR(20), @INTTemp))
- SET @JobTypeName = @STRTemp
- END
- FETCH NEXT FROM #JobType INTO @INTTemp, @STRTemp
- END
- CLOSE #JobType
- DEALLOCATE #JobType
-
- --取得JobPlace
- OPEN #JobPlace
- FETCH NEXT FROM #JobPlace INTO @INTTemp, @STRTemp
- WHILE @@FETCH_STATUS = 0
- BEGIN
- IF Len(@JobPlace) > 0
- BEGIN
- SET @JobPlace = @JobPlace + ' ' + Rtrim(CONVERT(VARCHAR(20), @INTTemp))
- SET @JobPlaceName = @JobPlaceName + ' ' + @STRTemp
- END
- ELSE
- BEGIN
- SET @JobPlace = Rtrim(CONVERT(VARCHAR(20),@INTTemp))
- SET @JobPlaceName = @STRTemp
- END
- FETCH NEXT FROM #JobPlace INTO @INTTemp, @STRTemp
- END
- CLOSE #JobPlace
- DEALLOCATE #JobPlace
- --取得Industry
- OPEN #Industry
- FETCH NEXT FROM #Industry INTO @INTTemp, @STRTemp
- WHILE @@FETCH_STATUS = 0
- BEGIN
- IF Len(@Industry) > 0
- BEGIN
- SET @Industry = @Industry + ' ' + Rtrim(CONVERT(VARCHAR(20), @INTTemp))
- SET @IndustryName = @IndustryName + ' ' + @STRTemp
- END
- ELSE
- BEGIN
- SET @Industry = Rtrim(CONVERT(VARCHAR(20), @INTTemp))
- SET @IndustryName = @STRTemp
- END
- FETCH NEXT FROM #Industry INTO @INTTemp, @STRTemp
- END
- CLOSE #Industry
- DEALLOCATE #Industry
- SELECT
- RelatedWorkYears,
- EmployType,
- dcSalaryID,
- IsNegotiable,
- b.Description Salary,
- @JobType AS JobType,
- @JobPlace AS JobPlace,
- @Industry AS Industry,
- @JobTypeName AS JobTypeName,
- @JobPlaceName AS JobPlaceName,
- @IndustryName AS IndustryName
- From cvMain a WITH(NOLOCK)
- LEFT JOIN dcSalary b WITH(NOLOCK) ON a.dcSalaryID=b.ID
- WHERE a.id=@cvMainID
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblCvmainByIDSelect] Script Date: 2018/12/13 19:07:35 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:获取个人信息
- --#####################################################
- CREATE PROCEDURE [dbo].[mblCvmainByIDSelect]
- (
- @cvMainID INT
- )
- AS
- BEGIN TRY
- SELECT pamainid FROM cvmain WHERE id=@cvMainID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblCvMainByPaMainIDSelect] Script Date: 2018/12/13 19:07:36 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:获取能够申请职位的简历列表
- --#####################################################
- CREATE PROCEDURE [dbo].[mblCvMainByPaMainIDSelect]
- (
- @paMainID INT
- )
- AS
- BEGIN TRY
- SELECT * FROM cvMain WITH(NOLOCK)
- WHERE paMainID=@paMainID
- AND (LEFT(cvLevel,6)='111111' OR LEFT(cvLevel,6)='111101')
- AND VerifyResult=1
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mbldcJobtypeHotByPinYinSelect] Script Date: 2018/12/13 19:07:36 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:获取热门职位信息
- --#####################################################
- CREATE PROCEDURE [dbo].[mbldcJobtypeHotByPinYinSelect]
- (
- @PinYin VARCHAR(50)
- )
- AS
- BEGIN TRY
- SELECT jobname,dcjobtypeid FROM dcjobtypehot WHERE pinyin = @PinYin
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblDcJobTypeHotNumberSelect] Script Date: 2018/12/13 19:07:36 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.7
- --创建人:John
- --说明:根据地区取得一定数量的热门职位关键字
- --#####################################################
- CREATE PROCEDURE [dbo].[mblDcJobTypeHotNumberSelect]
- (
- @topNum INT,
- @siteId INT
- )
- AS
- BEGIN
- SELECT b.* FROM (
- SELECT TOP (@topNum) dcJobTypeHotId
- FROM dcJobTypeHotNumber WITH(NOLOCK)
- WHERE dcProvinceId = @siteId
- ORDER BY jobnumber DESC
- ) a LEFT JOIN dcJobTypeHot b WITH(NOLOCK) ON a.dcJobTypeHotId = b.ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[mbldcSubSiteByAddressSelect] Script Date: 2018/12/13 19:07:37 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.7
- --创建人:Nick
- --说明:根据详细地址获取站点
- --#####################################################
- CREATE PROCEDURE [dbo].[mbldcSubSiteByAddressSelect]
- (
- @Address VARCHAR(100)
- )
- AS
- BEGIN
- SELECT TOP 1 * FROM dcSubSite WITH(NOLOCK)
- WHERE CHARINDEX(SubSiteCity,@Address)>0
- AND IsMainSite=1 AND LEN(ID)=2
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblDcSubSiteMainSelect] Script Date: 2018/12/13 19:07:37 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.7
- --创建人:John
- --说明:获取主站的url
- --#####################################################
- CREATE PROCEDURE [dbo].[mblDcSubSiteMainSelect]
- AS
- BEGIN
- SELECT id, REPLACE(SubSiteUrl, 'www.', 'm.') Site FROM dcSubsite WITH(NOLOCK) WHERE IsMainSite = 1 ORDER BY Id
- END
- GO
- /****** Object: StoredProcedure [dbo].[mbldcSubSiteSelect] Script Date: 2018/12/13 19:07:37 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.7
- --创建人:Nick
- --说明:获取网站信息
- --#####################################################
- CREATE PROCEDURE [dbo].[mbldcSubSiteSelect]
- AS
- BEGIN
- SELECT *, REPLACE(SubSiteUrl, 'www.', 'm.') Site
- FROM dcSubSite WITH(NOLOCK) WHERE IsMainSite=1 AND LEN(ID)=2
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblExInterViewByReplyUpdate] Script Date: 2018/12/13 19:07:38 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblExInterViewByReplyUpdate]
- (
- @ID INT,
- @Reply TINYINT,
- @ReplyMessage VARCHAR(500),
- @paMainID INT
- )
- AS
- BEGIN TRY
- 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)
- GOTO ERR
- UPDATE exInterView
- SET Reply = @Reply, ReplyMessage = dbo.SafeSql(@ReplyMessage), ReplyDate=GETDATE()
- WHERE ID = @ID
-
- RETURN 1
- END TRY
- BEGIN CATCH
- GOTO ERR
- END CATCH
- ERR:
- BEGIN
- SELECT 0
- RETURN
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblexInterViewCountByPaMainIDSelect] Script Date: 2018/12/13 19:07:38 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.4
- --创建人:Nick
- --说明:未查看面试通知消息数量
- --#####################################################
- CREATE PROCEDURE [dbo].[mblexInterViewCountByPaMainIDSelect]
- (
- @paMainID INT
- )
- AS
- BEGIN
- SELECT COUNT(*)
- FROM paMain a INNER JOIN cvMain b ON a.id =b.pamainid
- INNER JOIN exInterView c ON b.id=c.cvmainid
- WHERE a.id=@paMainID AND c.viewdate IS NULL
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblExInterviewSelect] Script Date: 2018/12/13 19:07:38 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblExInterviewSelect]
- (
- @paMainID AS INT,
- @PageNum AS INT,
- @PageSize AS INT
- )
- AS
- BEGIN
- DECLARE @COUNT INT
- SELECT @COUNT=COUNT(1)
- FROM exInterview a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON a.cvMainID = b.ID
- WHERE PersonDeleted=0 AND b.paMainID=@paMainID
-
-
- SELECT *,@COUNT AS cnt FROM(
- 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,
- c.HasLicence, c.IsAgent, b.IssueDate, b.IssueEND, b.IsDelete, d.Name cvName,b.secondid enjobid
- FROM exInterview a WITH(NOLOCK)
- inner join Job b WITH(NOLOCK) On b.ID=a.JobID
- Inner Join cpMain c WITH(NOLOCK) ON b.cpMainID=c.ID
- INNER JOIN cvMain d WITH(NOLOCK) ON a.cvMainID = d.ID
- WHERE PersonDeleted=0 AND d.paMainID=@paMainID
- ) AS a
- WHERE a.Rows BETWEEN (@PageNum-1)*@PageSize+1 AND @PageNum*@PageSize ORDER BY a.ID desc
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblExJobApplyByApplyCvSelect] Script Date: 2018/12/13 19:07:39 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblExJobApplyByApplyCvSelect]
- (
- @WHERE VARCHAR(1000),
- @Order VARCHAR(100),
- @Page SMALLINT,
- @caMainID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- SET @Where = dbo.SafeSql(@Where)
- SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '''''')
-
- DECLARE @SQL AS VARCHAR(2000)
- CREATE TABLE #T(
- TitleID BIGINT,
- ID INT,
- JobID INT,
- JobName NVARCHAR(50) COLLATE Chinese_PRC_CI_AS NULL,
- JobRegion VARCHAR(6) NULL,
- paMainID INT,
- cvMainID INT,
- AddDate SMALLDATETIME,
- Reply TINYINT,
- ReplyDate SMALLDATETIME,
- IsMatched BIT,
- Degree TINYINT,
- RelatedWorkYears TINYINT,
- LivePlace NVARCHAR(50),
- Gender BIT,
- paName NVARCHAR(50),
- BirthDay INT,
- HasPhoto TINYINT,
- Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
- IsNameHidden BIT,
- Valid TINYINT,
- ApplyMessage NVARCHAR(1),
- IsViewed BIT,
- HasInterview BIT,
- HasRemark BIT,
- HasFavorate BIT,
- cvEducationID INT,
- College NVARCHAR(50),
- EduType TINYINT,
- MajorName NVARCHAR(20),
- Graduation INT,
- Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- cvMatch INT,
- RecruitmentID INT,
- RecruitmentName NVARCHAR(100),
- RecruitmentDate SMALLDATETIME,
- MobileVerifyDate SMALLDATETIME,
- IsOnline BIT,
- RemindDate DATETIME,
- HasWeiXin BIT,
- HasAccept BIT,
- HsaNoAccept BIT,
- PaPhoto VARCHAR(50),
- SecondId VARCHAR(10)
- )
- SET @SQL='
- INSERT INTO #T
- (TitleID, ID, JobID, JobName, JobRegion, paMainID, cvMainID, AddDate, Reply, ReplyDate, IsMatched, ApplyMessage,
- Degree, RelatedWorkYears, Attachment, IsNameHidden, LivePlace, Gender,
- BirthDay, HasPhoto, Valid, RecruitmentID, MobileVerifyDate, IsOnline, RemindDate, SecondId)
- SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, a.JobID, d.Name, d.dcRegionID, c.ID, a.cvMainID,
- a.AddDate, a.Reply, a.ReplyDate, a.IsMatched, LEFT(a.ApplyMessage, 1) ApplyMessage,
- b.Degree, b.RelatedWorkYears, b.Attachment, b.IsNameHidden, c.LivePlace,
- c.Gender, c.BirthDay, c.HasPhoto, b.Valid, a.RecruitmentID, c.MobileVerifyDate,
- dbo.GetPaOnlineStatus(c.ID), a.RemindDate, b.SecondId
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
- INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
- INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
- WHERE a.CompanyDeleted = 0 AND d.IsDelete = 0'
- IF LEN(@WHERE) > 0
- SET @SQL = @SQL + ' AND '+@WHERE
- --PRINT @SQL
- EXEC(@SQL)
-
- IF(@Page < 1)
- SET @Page = 1
-
- DECLARE @cpMainID AS INT
- SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
- 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),
- HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
- 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),
- HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
- 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),
- 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)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE #T SET Speciality = (
- SELECT Speciality FROM cvMain WITH(NOLOCK)
- WHERE cvMain.ID = #T.cvMainID)
- WHERE TitleID > (@Page - 1) * 20 AND TitleID <= @Page * 20
-
- --sean 2018-3-6调整,原版本速度太慢
- --UPDATE #T SET PaPhoto = dbo.GetPaPhotoByCpView(#T.cvMainID, @cpMainID)
- --WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE a SET a.PaPhoto = b.PhotoProcessed
- FROM #T a,
- paPhoto b WITH(NOLOCK INDEX(IX_paPhoto_paMainId)),
- cpCvPrivi c WITH(NOLOCK)
- WHERE a.paMainID = b.paMainId
- AND a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
- AND a.cvMainId = c.cvMainId
- AND c.cpMainId = @cpMainId
-
- UPDATE #T SET Experience = (
- SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
- WHERE cvExperience.cvMainID = #T.cvMainID
- ORDER BY BeginDate DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE #T SET cvEducationID = (
- SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
- WHERE cvEducation.cvMainID = #T.cvMainID
- AND #T.Degree = cvEducation.Degree
- ORDER BY Graduation DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- --修改是否绑定微信
- UPDATE a SET HasWeiXin = 1
- FROM #T a, WxFans b WITH(NOLOCK)
- WHERE a.paMainID = b.PaMainID
- AND b.Status = 2
- AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
- a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
- FROM #T a, cvEducation b WITH(NOLOCK)
- WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
-
- UPDATE a SET a.RecruitmentName = b.RecruitmentName, a.RecruitmentDate = b.EndDate
- FROM #T a, Recruitment b WITH(NOLOCK)
- WHERE b.ID = a.RecruitmentID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
-
- UPDATE #T SET cvMatch = dbo.GetCvMatch(cvMainID, JobID) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- SELECT COUNT(*) FROM #T WITH(NOLOCK)
-
- SELECT a.*,b.Description DegreeName,c.MapBarName LivePlaceName,d.Description JobRegionName, dbo.BirthToAge(a.BirthDay) Age
- FROM #T a WITH(NOLOCK)
- LEFT JOIN dcEducation b WITH(NOLOCK) ON b.ID = a.Degree
- LEFT JOIN dcRegion c WITH(NOLOCK) ON c.ID = a.LivePlace
- LEFT JOIN dcRegion d WITH(NOLOCK) ON d.ID = a.JobRegion
- WHERE a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
- --计算匹配度
- DROP TABLE #T
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblexJobApplyNoViewByCaMainIDSelect] Script Date: 2018/12/13 19:07:40 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:简历管理未查看的应聘简历
- --#####################################################
- CREATE PROCEDURE [dbo].[mblexJobApplyNoViewByCaMainIDSelect]
- (
- @caMainID INT
- )
- AS
- BEGIN TRY
- SELECT COUNT(*) Cnt
- FROM exJobApply a WITH(NOLOCK), Job b WITH(NOLOCK)
- WHERE a.JobID =b.ID
- AND b.caMainID = @caMainID
- AND a.viewdate IS NULL
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblExJobApplySelect] Script Date: 2018/12/13 19:07:40 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblExJobApplySelect]
- (
- @paMainID AS INT,
- @PageNum AS INT,
- @PageSize AS INT
- )
- AS
- SET NOCOUNT ON
- INSERT ProcLog SELECT 'mblExJobApplySelect', '', GETDATE()
- BEGIN
- DECLARE @COUNT INT
- SELECT @COUNT=COUNT(1)
- FROM exJobApply a WITH(NOLOCK)
- INNER JOIN cvMain b WITH(NOLOCK) ON a.cvMainID = b.ID
- WHERE b.paMainID=@paMainID
-
-
- SELECT *,@COUNT AS cnt FROM(
- 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,
- 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,
- c.HasLicence, c.IsAgent, b.IssueDate, b.IssueEND, b.IsDelete, d.Name cvName, b.secondid enjobid
- FROM exJobApply a WITH(NOLOCK)
- inner join Job b WITH(NOLOCK) On b.ID=a.JobID
- Inner Join cpMain c WITH(NOLOCK) ON b.cpMainID=c.ID
- INNER JOIN cvMain d WITH(NOLOCK) ON a.cvMainID = d.ID
- WHERE PersonDeleted=0 AND d.paMainID=@paMainID
- ) AS a
- WHERE a.Rows BETWEEN (@PageNum-1)*@PageSize+1 AND @PageNum*@PageSize ORDER BY A.ID desc
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblFeedBackInsert] Script Date: 2018/12/13 19:07:40 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblFeedBackInsert]
- (
- @Content NVARCHAR(200),
- @Version VARCHAR(50),
- @paMainID INT
- )
- AS
- BEGIN
- INSERT INTO mblFeedBack(Content,Version,paMainID) VALUES(dbo.SafeSQL(@Content),dbo.SafeSQL(@Version),@paMainID)
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblGovNewsList] Script Date: 2018/12/13 19:07:40 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblGovNewsList]
- (
- @dcProvinceID AS SMALLINT,
- @PageNum AS INT,
- @PageSize AS INT
- )
- AS
- BEGIN
- DECLARE @COUNT INT
- SELECT @COUNT=COUNT(1)
- FROM QlrcNews WITH(NOLOCK) WHERE (
- EXISTS(SELECT 'x' FROM fnSplit(DetailType,',') b,dcNewsType c WITH(NOLOCK) WHERE b.a=c.ID AND c.Category=1) OR DetailType IS NULL)
- AND (VersionID=@dcProvinceID OR VersionID=0) AND NewsType = 2 AND DetailType like '%,2,%'
- IF @COUNT > 200
- SET @COUNT = 200
- SELECT *,@COUNT AS cnt FROM(
- SELECT TOP 200 ROW_NUMBER() OVER(ORDER BY RefreshDate DESC) AS Rows,ID,Title,RefreshDate,Author
- FROM QlrcNews WITH(NOLOCK) WHERE (
- EXISTS(SELECT 'x' FROM fnSplit(DetailType,',') b,dcNewsType c WITH(NOLOCK) WHERE b.a=c.ID AND c.Category=1) OR DetailType IS NULL)
- AND (VersionID=@dcProvinceID OR VersionID=0) AND NewsType = 2 AND DetailType like '%,2,%'
- ) AS a
- WHERE a.Rows BETWEEN (@PageNum-1)*@PageSize+1 AND @PageNum*@PageSize ORDER BY Rows
- END
- set ANSI_NULLS ON
- set QUOTED_IDENTIFIER ON
- GO
- /****** Object: StoredProcedure [dbo].[mblInfoSetByIDSelect] Script Date: 2018/12/13 19:07:40 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.7
- --创建人:Nick
- --说明:获取手机APP下载设置
- --#####################################################
- CREATE PROCEDURE [dbo].[mblInfoSetByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT * FROM reportdb..InfoSet WITH(NOLOCK) WHERE id=@ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblInfoSetInsert] Script Date: 2018/12/13 19:07:40 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.7
- --创建人:Nick
- --说明:添加手机APP下载记录
- --#####################################################
- CREATE PROCEDURE [dbo].[mblInfoSetInsert]
- (
- @InfoId VARCHAR(20),
- @IP VARCHAR(20),
- @Source VARCHAR(200),
- @SubSiteID VARCHAR(6)
- )
- AS
- BEGIN
- INSERT INTO reportdb..InfoLog(InfoId,IP,Source,SubSiteID,AddDate)
- VALUES(@InfoId,@IP,@Source,@SubSiteID,GETDATE())
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblJobByAppSearchSelect] Script Date: 2018/12/13 19:07:41 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE proCEDURE [dbo].[mblJobByAppSearchSelect]
- (
- @dcJobTypeID VARCHAR(100), --职位类别
- @dcRegionID VARCHAR(100), --求职地区
- @dcIndustryID VARCHAR(100), --求职行业
- @dcSalaryID TINYINT, --月薪
- @IsNegotiable BIT, --1允许面议,不面议
- @MinExperience TINYINT, --工作经验,100为未选择
- @dcEducationID TINYINT, --最低学历
- @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习,
- @KeyWord NVARCHAR(50), --关键词
- @KeyType TINYINT, --搜索类别,0无;1-全文;2-职位;3-公司
- @ORDER VARCHAR(4), --显示顺序,没有用
- @RefreshNo INT, --1, 1天内;2, 3天内;3,一周内;4,15天内;5,一个月内;6超过一个月
- @Type INT, --1:主动搜索 点击搜索按钮 10分钟,翻页60分钟有效;0:翻页搜索,不刷新
- @PageNumber INT, --翻页页码
- @SessionID varchar(50), --10
- @CompanySizeID VARCHAR(1), --企业规模
- @IsOnline INT,
- @Welfare VARCHAR(50) --
- )
- AS
- --return @SessionId = 10
- SET NOCOUNT ON
- --insert into aa
- --select getdate(), @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcSalaryID, @IsNegotiable,
- -- @MinExperience, @dcEducationID, @EmployType, @KeyWord, @KeyType, @ORDER, @RefreshNo,
- -- @Type, @PageNumber, @SessionID, @CompanySizeID, @IsOnline, @Welfare
- INSERT INTO SearchIp(Ip, Source) SELECT @SessionId, 'm'
- IF EXISTS(SELECT 'x' FROM RefuseIp WITH(NOLOCK) WHERE CHARINDEX(Ip,@SessionId) > 0)
- RETURN
- INSERT INTO SearchDB..paSearchLog(ProcType, SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
- Salary, IsNegotiable, EmployType, CompanySizeID, KeyWord, KeyType, ReuseNumber, Welfare, IsOnline, RefreshNo)
- VALUES('pcJobBySearchSelect', @SessionId, GETDATE(), @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcEducationID, @MinExperience,
- @dcSalaryID, 0, @EmployType, @CompanySizeID, @KeyWord, @KeyType, 0, @Welfare, @IsOnline, @RefreshNo)
- SET @SessionId = 'a' + @SessionId
- SET @KeyType = 0
- BEGIN TRY
- DECLARE @ReuseNumber AS INT, @dcProvinceId VARCHAR(2), @Order2 VARCHAR(100)
- ----给null值变量赋默认值
- IF NOT LEFT(@dcRegionID,1) = 'p'
- SELECT @dcRegionID = RTRIM(dbo.FormatIDS(@dcRegionID))
- SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
- @dcIndustryID = RTRIM(dbo.FormatIDS(@dcIndustryID)),
- @dcSalaryID = ISNULL(@dcSalaryID, 0),
- @IsNegotiable = ISNULL(@IsNegotiable, 0),
- @MinExperience = ISNULL(@MinExperience, 100),
- @dcEducationID = ISNULL(@dcEducationID, 0),
- @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END,
- @CompanySizeID = ISNULL(@CompanySizeID, '0'),
- @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, '')),
- @ORDER = ISNULL(@Order, ''),
- @Type = ISNULL(@Type, 0),
- @PageNumber = ISNULL(@PageNumber, 0),
- @Welfare = RTRIM(dbo.FormatIDS(@Welfare)),
- @IsOnline = ISNULL(@IsOnline, 0),
- @Order2 = ' ORDER BY a.RefreshDate DESC, a.SecondID DESC'
- IF @dcSalaryID = 0
- SET @IsNegotiable = 0
- IF @Order LIKE 'p=%'
- SET @dcProvinceId = REPLACE(@Order, 'p=', '')
- ELSE
- SET @dcProvinceId = 0
- --@RefreshNo = 0选择全部数据,不限制时间
- SET @RefreshNo = 0
- IF(@KeyWord = '' AND ISNULL(@dcJobTypeID, '') = '' AND ISNULL(@dcRegionID, '') = '' AND ISNULL(@dcIndustryID, '') = '')
- RETURN
- --如果关键词不为空 查询关键词对应的搜索类型 max 2012-12-25
-
- IF RIGHT(@KeyWord, 2) = '公司'
- SET @KeyWord = LEFT(@KeyWord, LEN(@KeyWord) - 2)
-
- IF RIGHT(@dcJobTypeID, 1) = ','
- SET @dcJobTypeID = LEFT(@dcJobTypeID, LEN(@dcJobTypeID) - 1)
- IF RIGHT(@dcRegionID, 1) = ','
- SET @dcRegionID = LEFT(@dcRegionID, LEN(@dcRegionID) - 1)
- IF RIGHT(@dcIndustryID, 1) = ','
- SET @dcIndustryID = LEFT(@dcIndustryID, LEN(@dcIndustryID) - 1)
- DECLARE @paSearchConditionID AS INT,
- @MinId AS INT,
- @PageSize AS TINYINT,
- @TableID AS TINYINT
- SELECT @paSearchConditionID = 0, @PageSize = 30
- ----搜索1分钟前的数据
- SELECT TOP 1 @paSearchConditionID = ID,
- @ReuseNumber = ReuseNumber
- FROM SearchDB..paSearchCondition WITH(NOLOCK)
- WHERE JobType=@dcJobTypeID AND IsOnline = @IsOnline
- AND JobPlace=@dcRegionID AND Industry=@dcIndustryID AND Education=@dcEducationID
- AND Experience=@MinExperience AND Salary=@dcSalaryID AND IsNegotiable=@IsNegotiable
- AND EmployType=@EmployType AND ISNULL(KeyWord, '') = @KeyWord AND KeyType = @KeyType
- AND CompanySizeID = @CompanySizeID AND Welfare = @Welfare AND IsDelete = 0
- AND LogTime > DATEADD(MINUTE, -1, GETDATE()) AND ReuseNumber > 0
- AND RefreshNo = 0 AND ISNULL(dcProvinceId, 0) = @dcProvinceId
- ORDER BY ID DESC
- IF @ReuseNumber = 0
- BEGIN
- SELECT TOP 1 @paSearchConditionID = ID
- FROM SearchDB..paSearchCondition WITH(NOLOCK)
- WHERE JobType=@dcJobTypeID AND IsOnline = @IsOnline
- AND JobPlace=@dcRegionID AND Industry=@dcIndustryID AND Education=@dcEducationID
- AND Experience=@MinExperience AND Salary=@dcSalaryID AND IsNegotiable=@IsNegotiable
- AND EmployType=@EmployType AND ISNULL(KeyWord, '') = @KeyWord AND KeyType=@KeyType
- AND CompanySizeID = @CompanySizeID AND Welfare = @Welfare AND ReuseNumber > 0
- AND ReuseNumber > 0 AND LogTime > DATEADD(MINUTE, -2, GETDATE())
- AND RefreshNo = 0 AND ISNULL(dcProvinceId, 0) = @dcProvinceId
- ORDER BY ID DESC
- END
- IF ISNULL(@paSearchConditionID, 0) = 0
- BEGIN
- SET @Type =1
- GOTO SelectReset --无数据,重新搜索
- END
- ELSE
- BEGIN
- SELECT @TableID = @paSearchConditionID % 4
- GOTO GetRecordSet --从临时结果中提取数据
- END
- SelectReset:
- --从job中搜索数据
- BEGIN TRAN
- DECLARE @SQL AS VARCHAR(8000)
- DECLARE @WHERE AS VARCHAR(8000)
- DECLARE @FROM AS VARCHAR(1000)
- ----记录查询条件
- INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
- Salary, IsNegotiable, EmployType, CompanySizeID, KeyWord, KeyType, ReuseNumber, Welfare, IsOnline, dcProvinceId)
- VALUES(@SessionId, GETDATE(), @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcEducationID, @MinExperience,
- @dcSalaryID, @IsNegotiable, @EmployType, @CompanySizeID, @KeyWord, @KeyType, 0, @Welfare, @IsOnline, @dcProvinceId)
- SET @paSearchConditionID = @@IDENTITY
- SELECT @TableID = @paSearchConditionID % 4
- ------生成职位类别的表变量,因为职位类别有包含(父子)关系
- DECLARE @T_JobPlace AS TABLE(ID INT)
- DECLARE @T_JobType AS TABLE(ID INT)
- DECLARE @JobPlaceLen AS INT, @JobTypeLen AS INT
- IF CHARINDEX(',', @dcJobTypeID) > 0
- SET @JobTypeLen = -1
- ELSE
- SET @JobTypeLen = LEN(@dcJobTypeID)
- DECLARE @JobType AS VARCHAR(3000), @JobPlace AS VARCHAR(2000), @ValidJobNumber AS INT
- SELECT @JobPlace = '', @JobType=''
- ----生成工作地点的表变量
- IF LEN(@dcRegionID) > 0
- BEGIN
- IF LEFT(@dcRegionID,1) = 'p'
- BEGIN
- DECLARE @Degree AS DECIMAL(8,5),@LBLng AS DECIMAL(8,5),@LBLat AS DECIMAL(8,5),
- @RTLng AS DECIMAL(8,5),@RTLat AS DECIMAL(8,5),@Lat AS DECIMAL(8,5),@Lng AS DECIMAL(8,5)
-
- SELECT @Lat = Lat,@Lng = Lng FROM dcMapPlace WITH(NOLOCK) WHERE ID = RIGHT(@dcRegionID,LEN(@dcRegionID)-1)
- IF @dcRegionID LIKE '3201%'
- SET @Degree = 1000 / 100000.0
- ELSE
- SET @Degree = 2000 / 100000.0
- SET @LBLng = @Lng - @Degree
- SET @LBLat = @Lat - @Degree
- SET @RTLng = @Lng + @Degree
- SET @RTLat = @Lat + @Degree
- SET @JobPlace = 'a.Lng BETWEEN ' + CONVERT(VARCHAR,@LBLng) + ' AND ' + CONVERT(VARCHAR,@RTLng) + '
- AND a.Lat BETWEEN ' + CONVERT(VARCHAR,@LBLat) + ' AND ' + CONVERT(VARCHAR,@RTLat) + '
- AND (a.Lng-' + CONVERT(VARCHAR,@Lng) + ')*(a.Lng-' + CONVERT(VARCHAR,@Lng) + ')+
- (a.Lat-' + CONVERT(VARCHAR,@Lat) + ')*(a.Lat-' + CONVERT(VARCHAR,@Lat) + ')<' + CONVERT(VARCHAR,@Degree*@Degree)
- SELECT @JobPlaceLen = 8
- END
- ELSE
- BEGIN
- INSERT INTO @T_JobPlace
- SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
- SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
- IF LEN(@JobPlace) > 0
- SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
- IF (SELECT COUNT(*) FROM @T_JobPlace) > 1
- SET @JobPlaceLen = -1
- ELSE
- SET @JobPlaceLen = LEN(@dcRegionID)
- END
- END
- ELSE
- SELECT @JobPlaceLen = 0
- ----生成求聘职位的表变量
- IF LEN(@dcJobTypeID) > 0
- BEGIN
- DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
- INSERT INTO @T_Temp
- SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
- INSERT INTO @T_JobType
- SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
- WHERE ParentId IN(SELECT ID FROM @T_TEMP)
- OR ParentId2 in(SELECT ID FROM @T_TEMP)
- OR ID IN(SELECT ID FROM @T_TEMP)
- ----生成in字符串
- SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
- IF RIGHT(@JobType, 1) = ','
- SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
- END
- ----建立临时表
- CREATE TABLE #Job(
- RowID INT IDENTITY(1, 1),
- ID INT NOT NULL,
- cpMainId INT,
- dcJobTypeID SMALLINT NOT NULL,
- dcJobTypeIDMinor SMALLINT NULL,
- dcSalaryID TINYINT NOT NULL,
- dcRegionID VARCHAR(6) NULL,
- dcEducationID TINYINT NOT NULL,
- MinExperience TINYINT NOT NULL,
- RefreshDate SMALLDATETIME NULL,
- EmployType TINYINT NULL,
- dcCompanySizeID SMALLINT NULL
- )
- CREATE TABLE #FullText(
- Priority INT,
- JobId INT NOT NULL
- )
- ------刷新时间,根据刷新时间编号计算
- ----生成插入临时表的Sql语句
- SET @SQL='
- INSERT INTO #Job
- SELECT a.ID, a.cpMainId, a.dcJobTypeID,
- a.dcJobTypeIDMinor, a.dcSalaryID,
- a.dcRegionID, a.dcEducationID, a.MinExperience,
- a.IssueDate,a.EmployType,b.dcCompanySizeID'
- SET @FROM = '
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
- ----职位有效,单位新有效
- IF LEN(@dcIndustryID) > 0
- SET @WHERE = '
- WHERE b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @dcIndustryID + '))
- AND a.Valid = 1
- AND b.Valid = 1'
- ELSE
- SET @WHERE = '
- WHERE a.Valid = 1
- AND b.Valid = 1'
-
- IF LEN(@dcProvinceId) > 1
- SET @WHere = @Where + ' AND b.dcProvinceId = ' + @dcProvinceId
- ----职位类别
- IF LEN(@JobType) > 0
- SET @WHERE = @WHERE + '
- AND (a.dcJobTypeID IN(' + @JobType +')
- OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
- IF LEN(@JobPlace) > 0
- SET @WHERE = @WHERE + '
- AND (' + @JobPlace + ')'
- IF @dcSalaryID > 0
- BEGIN
- IF @dcSalaryID < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID IN(' + LTRIM(STR(@dcSalaryID)) + ',' + LTRIM(STR(@dcSalaryID + 1)) + ')'
- ELSE IF @dcSalaryID = 100 ----从筛选结果中点击面议,值是100
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID = 100'
- ELSE IF @dcSalaryID BETWEEN 101 AND 106 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID <= ' + LTRIM(STR(@dcSalaryID-99)) + ' AND a.dcSalaryIDMax > ' + LTRIM(STR(@dcSalaryID-100))
- ELSE IF @dcSalaryID BETWEEN 107 AND 113 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID <= ' + LTRIM(STR(@dcSalaryID - 100)) + ' AND a.dcSalaryIDMax > ' + LTRIM(STR(@dcSalaryID-100))
- ELSE IF @dcSalaryID BETWEEN 114 AND 120
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID < 100 AND a.dcSalaryIDMax > ' + LTRIM(STR(@dcSalaryID - 100))
- END
- ----工作经验要求
- IF @MinExperience < 100
- SET @WHERE = @WHERE + '
- AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
- ----学历要求
- ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
- IF @dcEducationID > 0
- IF @dcEducationID = 2
- SET @WHERE = @WHERE + '
- AND a.dcEducationID IN(2, 3, 4)'
- ELSE
- SET @WHERE = @WHERE + '
- AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
- ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
- IF LEN(@EmployType) > 0
- SET @WHERE = @WHERE + '
- AND a.EmployType IN (' + @EmployType + ')'
- IF @CompanySizeID BETWEEN 1 AND 6
- SET @WHERE = @WHERE + '
- AND b.dcCompanySizeID = ' + LTRIM(STR(@CompanySizeID))
- IF LEN(@Welfare) > 0
- SET @WHERE = @WHERE + '
- AND a.Welfare' + REPLACE(@Welfare, ',', ' = 1 AND a.Welfare') + ' = 1'
- IF @IsOnline = 1
- SET @WHERE = @WHERE + '
- AND a.caMainId IN(SELECT caMainId FROM caOnline WITH(NOLOCK) WHERE IsOnline = 1)'
- IF LEN(@KeyWord) > 0 ----使用全文搜索job和cpmain2个表,经过测试发现union最快
- BEGIN
- IF EXISTS(SELECT TOP 1 'x' FROM cpMainPublish WITH(NOLOCK) WHERE Name = @KeyWord)
- BEGIN
- SET @WHERE = @WHERE + '
- AND b.Name = ''' + @KeyWord + ''''
- SET @SQL = @SQL + @FROM + @WHERE
- END
- ELSE
- BEGIN
- DECLARE @KeyWordTemp NVARCHAR(50)
- SET @KeyWordTemp = REPLACE(@KeyWord, ' ', '%')
- IF LEN(@KeyWordTemp) > 1
- BEGIN
- IF @dcProvinceId > 0
- BEGIN
- INSERT #FullText
- SELECT TOP 2000 2, b.ID
- FROM cpMainPublish a WITH(NOLOCK),
- JobPublish b WITH(NOLOCK)
- WHERE a.Id = b.cpMainId
- AND a.Name LIKE '%' + @KeyWordTemp + '%'
- AND a.dcProvinceId = @dcprovinceId
- ORDER BY b.RefreshDate DESC
- INSERT #FullText
- SELECT TOP 2000 1, b.ID
- FROM cpMainPublish a WITH(NOLOCK),
- JobPublish b WITH(NOLOCK)
- WHERE a.Id = b.cpMainId
- AND b.Name LIKE '%' + @KeyWordTemp + '%'
- AND a.dcProvinceId = @dcprovinceId
- ORDER BY b.RefreshDate DESC
- END
- ELSE
- BEGIN
- INSERT #FullText
- SELECT TOP 2000 2, b.ID
- FROM cpMainPublish a WITH(NOLOCK),
- JobPublish b WITH(NOLOCK)
- WHERE a.Id = b.cpMainId
- AND a.Name LIKE '%' + @KeyWordTemp + '%'
- ORDER BY b.RefreshDate DESC
- INSERT #FullText
- SELECT TOP 2000 1, b.ID
- FROM cpMainPublish a WITH(NOLOCK),
- JobPublish b WITH(NOLOCK)
- WHERE a.Id = b.cpMainId
- AND b.Name LIKE '%' + @KeyWordTemp + '%'
- ORDER BY b.RefreshDate DESC
- END
- END
- IF (SELECT COUNT(*) FROM #FullText) < 800
- BEGIN
- INSERT #FullText
- SELECT TOP 5000 3, [Key]
- FROM FREETEXTTABLE(cpMainJob, *, @KeyWord, 100000) AS KeyJob ORDER BY RANK DESC
- END
- DELETE a FROM #FullText a, #FullText b WHERE a.JobId = b.JobId AND a.Priority > b.Priority
- --------------------
- SELECT @FROM = @FROM + '
- INNER JOIN #FullText ON a.ID = #FullText.JobId',
- @ORDER2 = ' ORDER BY #FullText.Priority, a.RefreshDate DESC, a.SecondID DESC'
- SET @SQL = @SQL + @FROM + @WHERE
- END
- END
- ELSE
- SELECT @SQL = @SQL + @FROM + @WHERE
-
- SET @SQL = @SQL + @Order2
- --原来是ORDER BY a.IssueDate DESC, a.ID,Richard 2011年11月23日17:06分修改
- ----把符合条件的职位全部列出
- --PRINT @SQL
- EXEC(@SQL)
- SET @ValidJobNumber = @@ROWCOUNT
- ----记录查询结果总数
- UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@sql WHERE ID=@paSearchConditionID
- IF LEN(@JobType) > 0 --IN(2, 4)
- UPDATE #Job SET dcJobTypeId = dcJobTypeIDMinor
- WHERE dcJobTypeID NOT IN(SELECT a FROM dbo.fnSplit(@JobType, ','))
- ----插入JobType数据
- DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
- DECLARE @sc AS TABLE (
- paSearchConditionID int,
- Title varchar(20),
- TitleID varchar(10),
- TitleValue int
- )
- DECLARE @sc2 AS TABLE (
- paSearchConditionID int,
- Title varchar(20),
- TitleID varchar(10),
- TitleValue int
- )
- IF (@TableID = 0)
- BEGIN
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- IF @JobTypeLen NOT IN(2, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- END
- IF @JobTypeLen NOT IN(0, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
- FROM @sc2 WHERE LEN(TitleId) = 4
- END
- IF @JobTypeLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
- DELETE @sc
- DELETE @sc2
- --------
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- IF @JobPlaceLen IN(-1, 0)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- IF @JobPlaceLen IN(-1, 2)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
- IF @JobPlaceLen IN(-1, 4)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
- FROM @sc2 WHERE LEN(TitleID) = 6
- IF @JobPlaceLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
- ELSE
- DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
- ----------------
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
- FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
- WHERE a.cpMainId = b.cpMainId
- GROUP BY b.dcIndustryId ORDER BY b.dcIndustryId
- IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
- INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
- SELECT TOP 10 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
- WHERE b.ID = a.JobId
- AND CHARINDEX(@KeyWord, a.JobName) > 0
- ORDER BY a.OrderType, a.OpenDate DESC
- ELSE
- INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
- SELECT TOP 10 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
- WHERE b.ID = a.JobId
- ORDER BY a.OrderType, a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowID
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_0 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
- END
- ELSE IF (@TableId = 1)
- BEGIN
- ----------------------------jobtype
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- IF @JobTypeLen NOT IN(2, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- END
- IF @JobTypeLen NOT IN(0, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
- FROM @sc2 WHERE LEN(TitleId) = 4
- END
- IF @JobTypeLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
- DELETE @sc
- DELETE @sc2
- --------------------------region
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- IF @JobPlaceLen IN(-1, 0)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- IF @JobPlaceLen IN(-1, 2)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
- IF @JobPlaceLen IN(-1, 4)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
- FROM @sc2 WHERE LEN(TitleID) = 6
- IF @JobPlaceLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
- ELSE
- DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
- ----------------------------
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
-
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
-
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
- FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
- WHERE a.cpMainId = b.cpMainId
- GROUP BY dcIndustryID ORDER BY dcIndustryID
-
- IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
- INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
- SELECT TOP 10 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
- WHERE b.ID = a.JobId
- AND CHARINDEX(@KeyWord, a.JobName) > 0
- ORDER BY a.OrderType, a.OpenDate DESC
- ELSE
- INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
- SELECT TOP 10 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
- WHERE b.ID = a.JobId
- ORDER BY a.OrderType, a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowID
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_1 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
- END
- ELSE IF (@TableId = 2)
- BEGIN
- ----------------------------jobtype
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- IF @JobTypeLen NOT IN(2, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- END
- IF @JobTypeLen NOT IN(0, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
- FROM @sc2 WHERE LEN(TitleId) = 4
- END
- IF @JobTypeLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
- DELETE @sc
- DELETE @sc2
- --------------------------region
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- IF @JobPlaceLen IN(-1, 0)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- IF @JobPlaceLen IN(-1, 2)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
- IF @JobPlaceLen IN(-1, 4)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
- FROM @sc2 WHERE LEN(TitleID) = 6
- IF @JobPlaceLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
- ELSE
- DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
- ----------------------------
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
-
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
- FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
- WHERE a.cpMainId = b.cpMainId
- GROUP BY dcIndustryID ORDER BY dcIndustryID
-
- IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
- INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
- SELECT TOP 10 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
- WHERE b.ID = a.JobId
- AND CHARINDEX(@KeyWord, a.JobName) > 0
- ORDER BY a.OrderType, a.OpenDate DESC
- ELSE
- INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
- SELECT TOP 10 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
- WHERE b.ID = a.JobId
- ORDER BY a.OrderType, a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowID
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_2 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
- END
- ELSE IF (@TableId = 3)
- BEGIN
- ----------------------------jobtype
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- IF @JobTypeLen NOT IN(2, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- END
- IF @JobTypeLen NOT IN(0, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
- FROM @sc2 WHERE LEN(TitleId) = 4
- END
- IF @JobTypeLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
- DELETE @sc
- DELETE @sc2
- --------------------------region
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- IF @JobPlaceLen IN(-1, 0)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- IF @JobPlaceLen IN(-1, 2)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
- IF @JobPlaceLen IN(-1, 4)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
- FROM @sc2 WHERE LEN(TitleID) = 6
- IF @JobPlaceLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
- ELSE
- DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
- ----------------------------
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
-
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
- FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
- WHERE a.cpMainId = b.cpMainId
- GROUP BY dcIndustryID ORDER BY dcIndustryID
-
- IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
- INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
- SELECT TOP 10 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
- WHERE b.ID = a.JobId
- AND CHARINDEX(@KeyWord, a.JobName) > 0
- ORDER BY a.OrderType, a.OpenDate DESC
- ELSE
- INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
- SELECT TOP 10 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
- WHERE b.ID = a.JobId
- ORDER BY a.OrderType, a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowID
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_3 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
- END
- DROP TABLE #Job
- --PRINT 'DROP #JOB ' + CONVERT(VARCHAR(30), GETDATE(), 121)
- COMMIT
- --GOTO GetRecordSet
- GetRecordSet:
- BEGIN
- DECLARE @AllJobCount AS INT
- ----返回查询数量
- SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
- SELECT @AllJobCount = ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
- UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
- ----返回20行查询结果
- IF (@TableID = 0)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
- b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
- ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
- e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber,
- f.Description EducationName,g.Description ExperienceName,
- h.DescriptionCp dcSalary,i.DescriptionCp dcSalaryMax
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
- INNER JOIN SearchDB..paSearchJobID_0 c WITH(NOLOCK) ON a.id = c.JobID
- INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
- LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
- LEFT JOIN dcEducation f WITH(NOLOCK) ON f.ID = a.dcEducationID
- INNER JOIN dcOthers g WITH(NOLOCK) ON g.DetailID = a.MinExperience AND g.Category='职位要求工作经验'
- INNER JOIN dcSalary h WITH(NOLOCK) ON h.ID = a.dcSalaryID
- INNER JOIN dcSalary i WITH(NOLOCK) ON i.ID = a.dcSalaryIDMax
- WHERE paSearchConditionID=@paSearchConditionID
- AND c.ID >= @MinId
- ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 1)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
- b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
- ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
- e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber,
- f.Description EducationName,g.Description ExperienceName,
- h.DescriptionCp dcSalary,i.DescriptionCp dcSalaryMax
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
- INNER JOIN SearchDB..paSearchJobID_1 c WITH(NOLOCK) ON a.id = c.JobID
- INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
- LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
- LEFT JOIN dcEducation f WITH(NOLOCK) ON f.ID = a.dcEducationID
- INNER JOIN dcOthers g WITH(NOLOCK) ON g.DetailID = a.MinExperience AND g.Category='职位要求工作经验'
- INNER JOIN dcSalary h WITH(NOLOCK) ON h.ID = a.dcSalaryID
- INNER JOIN dcSalary i WITH(NOLOCK) ON i.ID = a.dcSalaryIDMax
- WHERE paSearchConditionID=@paSearchConditionID
- AND c.ID >= @MinId
- ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 2)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
- b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
- ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
- e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber,
- f.Description EducationName,g.Description ExperienceName,
- h.DescriptionCp dcSalary,i.DescriptionCp dcSalaryMax
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
- INNER JOIN SearchDB..paSearchJobID_2 c WITH(NOLOCK) ON a.id = c.JobID
- INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
- LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
- LEFT JOIN dcEducation f WITH(NOLOCK) ON f.ID = a.dcEducationID
- INNER JOIN dcOthers g WITH(NOLOCK) ON g.DetailID = a.MinExperience AND g.Category='职位要求工作经验'
- INNER JOIN dcSalary h WITH(NOLOCK) ON h.ID = a.dcSalaryID
- INNER JOIN dcSalary i WITH(NOLOCK) ON i.ID = a.dcSalaryIDMax
- WHERE paSearchConditionID=@paSearchConditionID
- AND c.ID >= @MinId
- ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 3)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
- b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
- ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
- e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber,
- f.Description EducationName,g.Description ExperienceName,
- h.DescriptionCp dcSalary,i.DescriptionCp dcSalaryMax
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
- INNER JOIN SearchDB..paSearchJobID_3 c WITH(NOLOCK) ON a.id = c.JobID
- INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
- LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
- LEFT JOIN dcEducation f WITH(NOLOCK) ON f.ID = a.dcEducationID
- INNER JOIN dcOthers g WITH(NOLOCK) ON g.DetailID = a.MinExperience AND g.Category='职位要求工作经验'
- INNER JOIN dcSalary h WITH(NOLOCK) ON h.ID = a.dcSalaryID
- INNER JOIN dcSalary i WITH(NOLOCK) ON i.ID = a.dcSalaryIDMax
- WHERE paSearchConditionID=@paSearchConditionID
- AND c.ID >= @MinId
- ORDER BY c.ID, a.ID DESC
- END
- --RICHARD 2011-7-23 16:51分修改
- ----返回统计数量
- IF @Type=1
- BEGIN
- DECLARE @RegionCount AS INT
- SELECT @RegionCount = -1
- IF CHARINDEX(',', @dcRegionID) = 0 AND LEN(@dcRegionID) > 0
- BEGIN
- IF NOT LEFT(@dcRegionID,1) = 'p'
- SELECT @RegionCount = COUNT(*) FROM dcRegion WHERE ParentID = @dcRegionID
- END
- IF (@TableID = 0)
- BEGIN
- 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)
- IF @RegionCount = 0
- SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
- ELSE
- 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)
-
- 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)
- 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)
- SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- 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)
- 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)
- END
- IF (@TableID = 1)
- BEGIN
- 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)
- IF @RegionCount = 0
- SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
- ELSE
- 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)
-
- 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)
- 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)
- SELECT * FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- 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)
- 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)
- END
- IF (@TableID = 2)
- BEGIN
- 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)
- IF @RegionCount = 0
- SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
- ELSE
- 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)
-
- 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)
- 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)
- SELECT * FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- 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)
- 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)
- END
- IF (@TableID = 3)
- BEGIN
- 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)
- IF @RegionCount = 0
- SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
- ELSE
- 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)
-
- 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)
- 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)
- SELECT * FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- 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)
- 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)
- END
- END
- RETURN
- END
- END TRY
- BEGIN CATCH
- ---检查是否已经建立临时表,已经建立则删除
- ROLLBACK TRANSACTION
- ---检查是否已经建立临时表,已经建立则删除
- DECLARE @para VARCHAR(MAX)
- SET @para = '@dcJobTypeID=' + ISNULL(@dcJobTypeID, '') + '|' +
- '@dcRegionID=' + ISNULL(@dcRegionID, '') + '|' +
- '@dcIndustryID=' + ISNULL(@dcIndustryID, '') + '|' +
- '@EmployType=' + ISNULL(@EmployType, '') + '|' +
- '@KeyWord=' + ISNULL(@KeyWord, '') + '|' +
- '@ORDER=' + ISNULL(@ORDER, '') + '|' +
- '@SessionID=' + ISNULL(@SessionID, '') + '|' +
- '@Welfare=' + ISNULL(@Welfare, '')
- INSERT INTO ErrorLog
- SELECT 'm2 ' + ISNULL(error_Message(), ' no msg')+ ' para=' + ISNULL(@Para, 'no para ') + ISNULL(@SQL, ' no sql'), error_number(), error_line(), GETDATE()
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblJobByAppSearchSelect2] Script Date: 2018/12/13 19:07:42 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE proCEDURE [dbo].[mblJobByAppSearchSelect2]
- (
- @dcJobTypeID VARCHAR(100), --职位类别
- @dcRegionID VARCHAR(100), --求职地区
- @dcIndustryID VARCHAR(100), --求职行业
- @dcSalaryID TINYINT, --月薪
- @IsNegotiable BIT, --1允许面议,不面议
- @MinExperience TINYINT, --工作经验,100为未选择
- @dcEducationID TINYINT, --最低学历
- @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习,
- @KeyWord NVARCHAR(50), --关键词
- @KeyType TINYINT, --搜索类别,0无;1-全文;2-职位;3-公司
- @ORDER VARCHAR(4), --显示顺序,没有用
- @RefreshNo INT, --1, 1天内;2, 3天内;3,一周内;4,15天内;5,一个月内;6超过一个月
- @Type INT, --1:主动搜索 点击搜索按钮 10分钟,翻页60分钟有效;0:翻页搜索,不刷新
- @PageNumber INT, --翻页页码
- @SessionID varchar(50), --10
- @CompanySizeID VARCHAR(1), --企业规模
- @IsOnline INT,
- @Welfare VARCHAR(50) --
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @t AS TABLE(
- dcJobTypeID VARCHAR(100),
- dcRegionID VARCHAR(100),
- dcIndustryID VARCHAR(100),
- dcSalaryID TINYINT,
- IsNegotiable INT,
- MinExperience TINYINT,
- dcEducationID TINYINT,
- EmployType VARCHAR(10),
- KeyWord NVARCHAR(50),
- KeyType TINYINT,
- [ORDER] VARCHAR(100),
- RefreshNo INT,
- Type INT,
- PageNumber INT,
- SessionID varchar(50),
- CompanySizeID VARCHAR(1),
- Welfare VARCHAR(50),
- IsOnline INT
- )
- INSERT INTO @t
- SELECT @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcSalaryID, @IsNegotiable,
- @MinExperience, @dcEducationID, @EmployType, @KeyWord, @KeyType, @ORDER,
- @RefreshNo, @Type, @PageNumber, @SessionID, @CompanySizeID, @Welfare, @IsOnline
-
- DECLARE @json VARCHAR(max)
- SET @json = (SELECT *, 10 Source from @t for json auto)
- SET @json = RIGHT(LEFT(@json, LEN(@json) - 1), LEN(@json) - 2)
-
- EXEC procJobPublishSelect @json
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblJobByCpMainIDSelect] Script Date: 2018/12/13 19:07:43 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2016.3.22
- --创建人:Lucifer
- --alen 2018-4-9
- --#####################################################
- CREATE PROCEDURE [dbo].[mblJobByCpMainIDSelect]
- (
- @cpMainID INT
- )
- AS
- BEGIN
- 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,
- a.Welfare2,a.Welfare3,a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8,a.Welfare9,a.Welfare10,
- a.Welfare11,a.Welfare12,a.Welfare13,a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,a.Welfare19,
- a.Lng,a.Lat,a.Name,a.cpMainID,i.secondid encpmainid,a.secondid enjobid,i.Name cpName,i.MemberType,a.Responsibility,
- a.Demand,a.MinAge,a.MaxAge,b.Description JobType,c.FullName JobRegion,d.Description NeedNumber,
- e.Description EmployType,ISNULL((SELECT IsOnline FROM caOnline WHERE caMainId =a.caMainID), 0) AS IsOnline,
- f.Description Salary,(CASE WHEN g.Description IS NULL THEN '不限' ELSE g.Description END) Education,a.IssueEnd,
- h.Description Experience ,a.IssueEnd,a.Promotion,STUFF((SELECT '@' + Tags FROM jobTags WITH(NOLOCK) WHERE jobID = a.ID FOR XML PATH('')),1,1,'') JobTags
- FROM Job a WITH(NOLOCK)
- LEFT JOIN dcJobType b WITH(NOLOCK) ON a.dcJobTypeID=b.ID
- LEFT JOIN dcRegion c WITH(NOLOCK) ON a.dcRegionID=c.ID
- LEFT JOIN dcOthers d WITH(NOLOCK) ON a.NeedNumber=d.DetailID AND d.Category='招聘人数'
- LEFT JOIN dcOthers e WITH(NOLOCK) ON a.EmployType=e.DetailID AND e.Category='工作性质'
- LEFT JOIN dcSalary f WITH(NOLOCK) ON a.dcSalaryID=f.ID
- LEFT JOIN dcEducation g WITH(NOLOCK) ON a.dcEducationID=g.ID
- LEFT JOIN dcOthers h WITH(NOLOCK) ON a.MinExperience=h.DetailID AND h.Category='职位要求工作经验'
- LEFT JOIN cpMain i WITH(NOLOCK) ON a.cpMainID=i.ID
- WHERE a.cpMainID = @cpMainID
- AND a.Valid = 1
- ORDER BY DisplayNo,a.IssueEnd,a.id,a.LastModifyDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblJobByIDSelect] Script Date: 2018/12/13 19:07:43 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:获取职位信息
- --harry 2015-6-3
- --增加forwardemail
- --John 2015-8-19
- --增加MemberType
- --#####################################################
- CREATE PROCEDURE [dbo].[mblJobByIDSelect]
- (
- @JobID VARCHAR(20),
- @ColumnName VARCHAR(10)
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @SQL VARCHAR(MAX)
- SELECT @ColumnName = REPLACE(@ColumnName, '''', ''),
- @JobID = REPLACE(@JobID, '''', '')
- SET @SQL = '
- SELECT a.ForwardEmail,a.IssueEnd,a.id,a.lng,a.lat,a.caMainID,a.RefreshDate,a.dcRegionId,a.dcJobTypeId,a.Welfare1,
- a.Welfare2,a.Welfare3,a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8,a.Welfare9,a.Welfare10,
- a.Welfare11,a.Welfare12,a.Welfare13,a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,Welfare19,Negotiable,
- a.dcSalaryId, a.dcSalaryIdMax,a.Name,a.cpMainID,i.secondid encpmainid,a.secondid enjobid,i.Name cpName,i.MemberType,a.Responsibility,
- a.Demand,a.MinAge,a.MaxAge,b.Description JobType,c.FullName JobRegion,d.Description NeedNumber,
- e.Description EmployType,ISNULL((SELECT IsOnline FROM caOnline WHERE caMainId =a.caMainID), 0) AS IsOnline,
- f.DescriptionCp Salary,j.DescriptionCp SalaryMax,(CASE WHEN g.Description IS NULL THEN ''不限'' ELSE g.Description END) Education,
- h.Description Experience,a.Valid, i.dcProvinceId,
- STUFF((SELECT ''@'' + Tags FROM jobTags WITH(NOLOCK) WHERE jobID = a.ID FOR XML PATH('''')),1,1,'''') JobTags
- FROM Job a WITH(NOLOCK)
- LEFT JOIN dcJobType b WITH(NOLOCK) ON a.dcJobTypeID=b.ID
- LEFT JOIN dcRegion c WITH(NOLOCK) ON a.dcRegionID=c.ID
- LEFT JOIN dcOthers d WITH(NOLOCK) ON a.NeedNumber=d.DetailID AND d.Category=''招聘人数''
- LEFT JOIN dcOthers e WITH(NOLOCK) ON a.EmployType=e.DetailID AND e.Category=''工作性质''
- LEFT JOIN dcSalary f WITH(NOLOCK) ON a.dcSalaryID=f.ID
- LEFT JOIN dcEducation g WITH(NOLOCK) ON a.dcEducationID=g.ID
- LEFT JOIN dcOthers h WITH(NOLOCK) ON a.MinExperience=h.DetailID AND h.Category=''职位要求工作经验''
- LEFT JOIN cpMain i WITH(NOLOCK) ON a.cpMainID=i.ID
- LEFT JOIN dcSalary j WITH(NOLOCK) ON a.dcSalaryIDMax=j.ID
- WHERE a.' + @ColumnName + ' = ''' + @JobID + ''''
- --print @sql
- EXEC(@SQL)
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblJobByIntentionSelect] Script Date: 2018/12/13 19:07:43 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --[pcJobByIntentionSelectByPhone] 8100669
- CREATE PROCEDURE [dbo].[mblJobByIntentionSelect]
- (
- @cvMainID INT
- )
- AS
- BEGIN
- DECLARE @JobType AS VARCHAR(100)
- DECLARE @JobTypeName AS VARCHAR(1000)
- DECLARE @JobPlace AS VARCHAR(100)
- DECLARE @JobPlaceName AS VARCHAR(100)
- DECLARE @Industry AS VARCHAR(100)
- DECLARE @IndustryName AS VARCHAR(100)
- DECLARE @INTTemp AS INT
- DECLARE @STRTemp AS VARCHAR(20)
- 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
- 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
- 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
-
- --取得JobType
- OPEN #JobType
- FETCH NEXT FROM #JobType INTO @INTTemp,@STRTemp
- WHILE @@FETCH_STATUS = 0
- BEGIN
- IF Len(@JobType) > 0
- BEGIN
- SET @JobType = @JobType + ' ' + Rtrim(CONVERT(CHAR(10),@INTTemp))
- SET @JobTypeName = @JobTypeName + ' ' + @STRTemp
- END
- ELSE
- BEGIN
- SET @JobType = Rtrim(CONVERT(CHAR(10),@INTTemp))
- SET @JobTypeName = @STRTemp
- END
- FETCH NEXT FROM #JobType INTO @INTTemp,@STRTemp
- END
- CLOSE #JobType
- DEALLOCATE #JobType
- --取得JobPlace
- OPEN #JobPlace
- FETCH NEXT FROM #JobPlace INTO @INTTemp,@STRTemp
- WHILE @@FETCH_STATUS = 0
- BEGIN
- IF Len(@JobPlace) > 0
- BEGIN
- SET @JobPlace = @JobPlace + ' ' + Rtrim(CONVERT(CHAR(10),@INTTemp))
- SET @JobPlaceName = @JobPlaceName + ' ' + @STRTemp
- END
- ELSE
- BEGIN
- SET @JobPlace = Rtrim(CONVERT(CHAR(10),@INTTemp))
- SET @JobPlaceName = @STRTemp
- END
- FETCH NEXT FROM #JobPlace INTO @INTTemp,@STRTemp
- END
- CLOSE #JobPlace
- DEALLOCATE #JobPlace
- --取得Industry
- OPEN #Industry
- FETCH NEXT FROM #Industry INTO @INTTemp,@STRTemp
- WHILE @@FETCH_STATUS = 0
- BEGIN
- IF Len(@Industry) > 0
- BEGIN
- SET @Industry = @Industry + ' ' + Rtrim(CONVERT(CHAR(10),@INTTemp))
- SET @IndustryName = @IndustryName + ' ' + @STRTemp
- END
- ELSE
- BEGIN
- SET @Industry = Rtrim(CONVERT(CHAR(10),@INTTemp))
- SET @IndustryName = @STRTemp
- END
- FETCH NEXT FROM #Industry INTO @INTTemp,@STRTemp
- END
- CLOSE #Industry
- DEALLOCATE #Industry
- SELECT
- RelatedWorkYears,
- EmployType,
- dcSalaryID,
- IsNegotiable,
- b.Description Salary,
- @JobType AS JobType,
- @JobPlace AS JobPlace,
- @Industry AS Industry,
- @JobTypeName AS JobTypeName,
- @JobPlaceName AS JobPlaceName,
- @IndustryName AS IndustryName
- From cvMain a WITH(NOLOCK)
- LEFT JOIN dcSalary b WITH(NOLOCK) ON a.dcSalaryID=b.ID
- WHERE a.id=@cvMainID
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblJobByJobIDSelect] Script Date: 2018/12/13 19:07:43 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.6
- --创建人:Nick
- --说明:
- --#####################################################
- CREATE PROCEDURE [dbo].[mblJobByJobIDSelect]
- (
- @jobID VARCHAR(MAX)
- )
- AS
- BEGIN
- SELECT DISTINCT cpmainid
- FROM Job WITH(NOLOCK)
- WHERE id IN (SELECT a FROM fnsplit(@jobID, ','))
- GROUP BY cpmainid
- HAVING COUNT(1) > 3
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblJobByMapSearchSelect] Script Date: 2018/12/13 19:07:44 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblJobByMapSearchSelect]
- (
- @Distance INT, --距离范围
- @Lng DECIMAL(8,5), --经度
- @Lat DECIMAL(8,5), --纬度
- @dcJobTypeID VARCHAR(100), --职位类别
- @dcIndustryID VARCHAR(40), --dcprovinceid --求职行业
- @dcSalaryID TINYINT, --月薪
- @MinExperience TINYINT, --工作经验,100为未选择
- @dcEducationID TINYINT, --最低学历
- @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习,
- @CompanySizeID VARCHAR(1), --企业规模
- @Welfare NVARCHAR(50), --福利待遇
- @Status TINYINT, --0:无关;1:企业在线;2:企业不在线
- @Type INT, --1:主动搜索 点击搜索按钮 10分钟,翻页60分钟有效;0:翻页搜索,不刷新
- @PageNumber INT --翻页页码
- )
- AS
- --INSERT procLog SELECT 'mblJobByMapSearchSelect', @Lng, GETDATE()
- IF @Distance IS NULL OR @Lng IS NULL OR @Lat IS NULL
- RETURN
- --@SessionId = 50
- SET NOCOUNT ON
- BEGIN TRY
- DECLARE @IsOnline INT, @dcProvinceID VARCHAR(2)
- IF @dcIndustryID LIKE 'p=%'
- SET @dcProvinceID = REPLACE(@dcIndustryID, 'p=', '')
- ELSE
- SET @dcProvinceID = 0
-
- BEGIN
- ----给null值变量赋默认值
- SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
- @dcIndustryID = ISNULL(@dcIndustryID, ''),
- @Welfare = RTRIM(dbo.FormatIDS(ISNULL(@Welfare, ''))),
- @Type = ISNULL(@Type, 0),
- @dcSalaryID = ISNULL(@dcSalaryID, 0),
- @MinExperience = ISNULL(@MinExperience, 100),
- @dcEducationID = ISNULL(@dcEducationID, 0),
- @PageNumber = ISNULL(@PageNumber, 0),
- @CompanySizeID = ISNULL(@CompanySizeID, '0'),
- @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END,
- @IsOnline = ISNULL(@Status, 0)
- IF @dcEducationID = 100
- SET @dcEducationID = 0
- IF RIGHT(@dcJobTypeID, 1) = ','
- SET @dcJobTypeID = LEFT(@dcJobTypeID, LEN(@dcJobTypeID) - 1)
- IF RIGHT(@dcIndustryID, 1) = ','
- SET @dcIndustryID = LEFT(@dcIndustryID, LEN(@dcIndustryID) - 1)
- DECLARE @paSearchConditionID AS INT,
- @MinId AS INT,
- @PageSize AS TINYINT,
- @TableID AS TINYINT
- SELECT @paSearchConditionID = 0, @PageSize = 30 --每页的行数
-
- ----搜索1分钟前的数据
- SELECT TOP 1 @paSearchConditionID = ID
- FROM SearchDB..paSearchCondition WITH(NOLOCK)
- WHERE JobType=@dcJobTypeID AND IsOnline = @IsOnline
- AND Industry=@dcIndustryID AND Education=@dcEducationID
- AND Experience=@MinExperience AND Salary=@dcSalaryID
- AND EmployType=@EmployType AND CompanySizeID = @CompanySizeID
- AND Lat = @Lat AND LNg = @Lng AND Distance = @Distance
- AND Welfare = @Welfare AND IsDelete = 0 AND dcProvinceId = @dcProvinceId
- ORDER BY ID DESC
- IF ISNULL(@paSearchConditionID, 0) = 0
- BEGIN
- SET @Type =1
- GOTO SelectReset --无数据,重新搜索
- END
- ELSE
- BEGIN
- SELECT @TableID = @paSearchConditionID % 4
- GOTO GetRecordSet --从临时结果中提取数据
- END
- END
- SelectReset: --从job中搜索数据
- BEGIN TRAN
- DECLARE @SQL AS VARCHAR(8000), @WHERE AS VARCHAR(8000), @FROM AS VARCHAR(1000),
- @JobType AS VARCHAR(3000), @ValidJobNumber AS INT
- DECLARE @T_JobType AS TABLE(ID INT)
-
- ----记录查询条件
- INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, Industry,
- Lng, Lat, Distance, Welfare, KeyWord, KeyType, ReuseNumber, Education, Experience,
- Salary, EmployType, CompanySizeID, IsOnline, dcProvinceId)
- VALUES(
- 50, GETDATE(), @dcJobTypeID, @dcIndustryID, @Lng, @Lat,
- @Distance, @Welfare, '', 0, 0, @dcEducationID, @MinExperience,
- @dcSalaryID, @EmployType, @CompanySizeID, @IsOnline, @dcProvinceId)
- SET @paSearchConditionID = @@IDENTITY
- SELECT @TableID = @paSearchConditionID % 4
- ------生成职位类别的表变量,因为职位类别有包含(父子)关系
- SELECT @JobType=''
-
- ----生成求聘职位的表变量
- IF LEN(@dcJobTypeID) > 0
- BEGIN
- DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
- INSERT INTO @T_Temp
- SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
- INSERT INTO @T_JobType
- SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
- WHERE ParentId IN(SELECT ID FROM @T_TEMP)
- OR ParentId2 in(SELECT ID FROM @T_TEMP)
- OR ID IN(SELECT ID FROM @T_TEMP)
- ----生成in字符串
- SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
- IF RIGHT(@JobType, 1) = ','
- SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
- END
-
- ----建立临时表
- CREATE TABLE #Job(
- RowID INT IDENTITY(1, 1),
- ID INT NOT NULL,
- dcJobTypeID SMALLINT NOT NULL,
- dcJobTypeIDMinor SMALLINT NULL,
- dcSalaryID TINYINT NOT NULL,
- dcRegionID VARCHAR(6) NULL,
- dcEducationID TINYINT NOT NULL,
- MinExperience TINYINT NOT NULL,
- RefreshDate SMALLDATETIME NULL,
- EmployType TINYINT NULL,
- dcCompanySizeID SMALLINT NULL
- )
- ------刷新时间,根据刷新时间编号计算
- ----生成插入临时表的Sql语句
- SET @SQL='
- INSERT INTO #Job
- SELECT a.ID, a.dcJobTypeID,
- a.dcJobTypeIDMinor, a.dcSalaryID,
- a.dcRegionID, a.dcEducationID, a.MinExperience,
- a.IssueDate,a.EmployType,b.dcCompanySizeID'
- SET @FROM = '
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
- ----职位有效,单位新有效
- IF LEN(@dcProvinceID) > 1
- SET @WHERE = '
- WHERE b.dcProvinceID = ' + @dcProvinceID + '
- AND a.Valid = 1
- AND b.Valid = 1'
- ELSE
- SET @WHERE = '
- WHERE a.Valid = 1
- AND b.Valid = 1'
- ----需要增加全文索引的关键字查询
- ----职位类别
- IF LEN(@dcJobTypeID) > 0
- SET @WHERE = @WHERE + '
- AND (a.dcJobTypeID IN(' + @JobType +')
- OR a.dcJobTypeIDMinor IN(' + @JobType + '))'
- IF @dcSalaryID > 0
- BEGIN
- IF @dcSalaryID < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
- BEGIN
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID IN(' + LTRIM(STR(@dcSalaryID)) + ',' + LTRIM(STR(@dcSalaryID + 1))
- SET @WHERE = @WHERE + ')'
- END
- IF @dcSalaryID = 100 ----从筛选结果中点击面议,值是100
- BEGIN
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID = 100'
- END
- IF @dcSalaryID > 100 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID=' + LTRIM(STR(@dcSalaryID-100))
- END
- ----工作经验要求
- IF @MinExperience < 100
- SET @WHERE = @WHERE + '
- AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
- ----学历要求
- ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
- IF @dcEducationID > 0
- IF @dcEducationID = 2
- SET @WHERE = @WHERE + '
- AND a.dcEducationID IN(2, 3, 4)'
- ELSE
- SET @WHERE = @WHERE + '
- AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
- ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
- IF LEN(@EmployType) > 0
- SET @WHERE = @WHERE + '
- AND a.EmployType IN (' + @EmployType + ')'
- IF @CompanySizeID BETWEEN 1 AND 6
- SET @WHERE = @WHERE + '
- AND b.dcCompanySizeID = ' + LTRIM(STR(@CompanySizeID))
- IF LEN(@Welfare) > 0
- SET @WHERE = @WHERE + '
- AND a.Welfare' + REPLACE(@Welfare, ',', ' = 1 AND a.Welfare') + ' = 1'
- IF @IsOnline = 1
- SET @WHERE = @WHERE + '
- AND a.caMainId IN(SELECT caMainId FROM caOnline WITH(NOLOCK) WHERE IsOnline = 1) '
-
- DECLARE @Degree AS DECIMAL(8,5),@LBLng AS DECIMAL(8,5),@LBLat AS DECIMAL(8,5),
- @RTLng AS DECIMAL(8,5),@RTLat AS DECIMAL(8,5)
- SET @Degree = @Distance / 100000.0;
- SET @LBLng = @Lng - @Degree
- SET @LBLat = @Lat - @Degree
- SET @RTLng = @Lng + @Degree
- SET @RTLat = @Lat + @Degree
- SET @WHERE = @WHERE + '
- AND a.Lng BETWEEN ' + CONVERT(VARCHAR,@LBLng) + ' AND ' + CONVERT(VARCHAR,@RTLng) + '
- AND a.Lat BETWEEN ' + CONVERT(VARCHAR,@LBLat) + ' AND ' + CONVERT(VARCHAR,@RTLat) + '
- AND (a.Lng-' + CONVERT(VARCHAR,@Lng) + ')*(a.Lng-' + CONVERT(VARCHAR,@Lng) + ')+
- (a.Lat-' + CONVERT(VARCHAR,@Lat) + ')*(a.Lat-' + CONVERT(VARCHAR,@Lat) + ')<' + CONVERT(VARCHAR,@Degree*@Degree)
- SET @SQL = @SQL + @FROM + @WHERE
-
- --IF LEN(@ORDER)>0
- SET @SQL=@SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
- --原来是ORDER BY a.IssueDate DESC, a.ID,Richard 2011年11月23日17:06分修改
- ----把符合条件的职位全部列出
- --PRINT @SQL
- EXEC(@SQL)
-
- SET @ValidJobNumber = @@ROWCOUNT
- ----记录查询结果总数
- UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@SQL WHERE ID=@paSearchConditionID
- ----插入JobType数据
- DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
- IF (@TableID = 0)
- BEGIN
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'JobType'
-
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----计算全部地区,4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), (
- SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- AND LEN(TitleID) >3
- GROUP BY LEFT(TitleID, 4)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'Region'
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
-
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
-
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_0 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- ELSE IF (@TableId = 1)
- BEGIN
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'JobType'
-
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----计算全部地区,4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), (
- SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- AND LEN(TitleID) >3
- GROUP BY LEFT(TitleID, 4)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'Region'
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
-
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
-
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_1 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- ELSE IF (@TableId = 2)
- BEGIN
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'JobType'
-
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----计算全部地区,4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), (
- SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- AND LEN(TitleID) >3
- GROUP BY LEFT(TitleID, 4)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'Region'
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
-
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
-
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_2 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- ELSE IF (@TableId = 3)
- BEGIN
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'JobType'
-
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----计算全部地区,4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), (
- SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- AND LEN(TitleID) >3
- GROUP BY LEFT(TitleID, 4)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'Region'
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
-
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
-
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_3 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- DROP TABLE #Job
- --PRINT 'DROP #JOB ' + CONVERT(VARCHAR(30), GETDATE(), 121)
- COMMIT
- --GOTO GetRecordSet
- GetRecordSet:
- BEGIN
- DECLARE @AllJobCount AS INT
- ----返回查询数量
- SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
- SELECT @AllJobCount = ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
- UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
- ----返回20行查询结果
- IF (@TableID = 0)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.dcEducationID, b.HasLicence, b.IsRefreshed, dcCompanySizeID,
- a.MinExperience, a.MinAge, a.MaxAge, a.RefreshDate, a.Lng, a.Lat,
- b.Name as cpName, c.IsTop, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,
- a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
- a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,
- ISNULL((SELECT IsOnline FROM caOnline WITH(NOLOCK) WHERE caMainId = a.caMainId), 0) IsOnline, b.LogoFile LogoUrl,@AllJobCount JobNumber,
- d.FullName RegionName,e.Description EducationName,f.Description ExperienceName,g.DescriptionCp dcSalary,h.DescriptionCp dcSalaryMax
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_0 c WITH(NOLOCK),
- dcRegion d WITH(NOLOCK),dcEducation e WITH(NOLOCK),dcOthers f WITH(NOLOCK),dcSalary g WITH(NOLOCK),dcSalary h WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
- AND d.ID = a.dcRegionID AND e.ID = a.dcEducationID AND f.DetailID = a.MinExperience
- AND f.Category='职位要求工作经验' AND g.ID = a.dcSalaryID AND h.ID = a.dcSalaryIDMax
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 1)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.dcEducationID, b.HasLicence, b.IsRefreshed, dcCompanySizeID,
- a.MinExperience, a.MinAge, a.MaxAge, a.RefreshDate, a.Lng, a.Lat,
- b.Name as cpName, c.IsTop, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,
- a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
- a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,
- ISNULL((SELECT IsOnline FROM caOnline WITH(NOLOCK) WHERE caMainId = a.caMainId), 0) IsOnline,
- b.LogoFile LogoUrl,@AllJobCount JobNumber,
- d.FullName RegionName,e.Description EducationName,f.Description ExperienceName,g.DescriptionCp dcSalary,h.DescriptionCp dcSalaryMax
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_1 c WITH(NOLOCK),
- dcRegion d WITH(NOLOCK),dcEducation e WITH(NOLOCK),dcOthers f WITH(NOLOCK),dcSalary g WITH(NOLOCK),dcSalary h WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
- AND d.ID = a.dcRegionID AND e.ID = a.dcEducationID AND f.DetailID = a.MinExperience
- AND f.Category='职位要求工作经验' AND g.ID = a.dcSalaryID AND h.ID = a.dcSalaryIDMax
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 2)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.dcEducationID, b.HasLicence, b.IsRefreshed, dcCompanySizeID,
- a.MinExperience, a.MinAge, a.MaxAge, a.RefreshDate, a.Lng, a.Lat,
- b.Name as cpName, c.IsTop, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,
- a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
- a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,
- ISNULL((SELECT IsOnline FROM caOnline WITH(NOLOCK) WHERE caMainId = a.caMainId), 0) IsOnline,
- b.LogoFile LogoUrl, @AllJobCount JobNumber,
- d.FullName RegionName,e.Description EducationName,f.Description ExperienceName,g.DescriptionCp dcSalary,h.DescriptionCp dcSalaryMax
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_2 c WITH(NOLOCK),
- dcRegion d WITH(NOLOCK),dcEducation e WITH(NOLOCK),dcOthers f WITH(NOLOCK),dcSalary g WITH(NOLOCK),dcSalary h WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
- AND d.ID = a.dcRegionID AND e.ID = a.dcEducationID AND f.DetailID = a.MinExperience
- AND f.Category='职位要求工作经验' AND g.ID = a.dcSalaryID AND h.ID = a.dcSalaryIDMax
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 3)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID, b.HasLicence, b.IsRefreshed, dcCompanySizeID,
- a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
- a.IsDelete, a.AddDate, a.RefreshDate, a.Lng, a.Lat,
- a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
- b.UnLimitedDate, b.BalanceDate, b.Balance,
- b.MemberType, '' cpIndustry,
- c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,
- a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
- a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,
- ISNULL((SELECT IsOnline FROM caOnline WITH(NOLOCK) WHERE caMainId = a.caMainId), 0) IsOnline,
- b.LogoFile LogoUrl,@AllJobCount JobNumber,
- d.FullName RegionName,e.Description EducationName,f.Description ExperienceName,g.DescriptionCp dcSalary,h.DescriptionCp dcSalaryMax
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_3 c WITH(NOLOCK),
- dcRegion d WITH(NOLOCK),dcEducation e WITH(NOLOCK),dcOthers f WITH(NOLOCK),dcSalary g WITH(NOLOCK),dcSalary h WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
- AND d.ID = a.dcRegionID AND e.ID = a.dcEducationID AND f.DetailID = a.MinExperience
- AND f.Category='职位要求工作经验' AND g.ID = a.dcSalaryID AND h.ID = a.dcSalaryIDMax
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- --RICHARD 2011-7-23 16:51分修改
- ----返回统计数量
- IF @Type=1
- BEGIN
- IF (@TableID = 0)
- BEGIN
- 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)
- 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)
- 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)
- 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)
- SELECT * FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- 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)
- 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)
- END
- IF (@TableID = 1)
- BEGIN
- 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)
- 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)
- 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)
- 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)
- SELECT * FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- 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)
- 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)
- END
- IF (@TableID = 2)
- BEGIN
- 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)
- 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)
- 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)
- 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)
- SELECT * FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- 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)
- 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)
- END
- IF (@TableID = 3)
- BEGIN
- 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)
- 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)
- 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)
- 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)
- SELECT * FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- 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)
- 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)
- END
- END
- RETURN
- END
- END TRY
- BEGIN CATCH
- ---检查是否已经建立临时表,已经建立则删除
- ROLLBACK TRANSACTION
- ---检查是否已经建立临时表,已经建立则删除
- DECLARE @para VARCHAR(MAX)
- SET @para = '@dcJobTypeID=' + ISNULL(@dcJobTypeID, '') + '|' +
- '@dcIndustryID=' + ISNULL(@dcIndustryID, '') + '|' +
- '@EmployType=' + ISNULL(@EmployType, '') + '|' +
- '@Welfare=' + ISNULL(@Welfare, '')
- INSERT INTO ErrorLog
- SELECT 'm3 ' + ISNULL(error_Message(), ' no msg')+ ' para=' + ISNULL(@Para, 'no para ') + ISNULL(@SQL, ' no sql'), error_number(), error_line(), GETDATE()
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblJobByMapSearchSelectNew] Script Date: 2018/12/13 19:07:44 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblJobByMapSearchSelectNew]
- (
- @Distance INT, --距离范围
- @Lng DECIMAL(8,5), --经度
- @Lat DECIMAL(8,5), --纬度
- @dcJobTypeID VARCHAR(100), --职位类别
- @dcIndustryID VARCHAR(40), --dcprovinceid --求职行业
- @dcSalaryID TINYINT, --月薪
- @MinExperience TINYINT, --工作经验,100为未选择
- @dcEducationID TINYINT, --最低学历
- @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习,
- @CompanySizeID VARCHAR(1), --企业规模
- @Welfare NVARCHAR(50), --福利待遇
- @Status TINYINT, --0:无关;1:企业在线;2:企业不在线
- @Type INT, --1:主动搜索 点击搜索按钮 10分钟,翻页60分钟有效;0:翻页搜索,不刷新
- @PageNumber INT --翻页页码
- )
- AS
- --INSERT procLog SELECT 'mblJobByMapSearchSelect', @Lng, GETDATE()
- IF @Distance IS NULL OR @Lng IS NULL OR @Lat IS NULL
- RETURN
- --@SessionId = 50
- SET NOCOUNT ON
- BEGIN TRY
- DECLARE @IsOnline INT, @dcProvinceID VARCHAR(2)
- IF @dcIndustryID LIKE 'p=%'
- SET @dcProvinceID = REPLACE(@dcIndustryID, 'p=', '')
- ELSE
- SET @dcProvinceID = 0
-
- BEGIN
- ----给null值变量赋默认值
- SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
- @dcIndustryID = ISNULL(@dcIndustryID, ''),
- @Welfare = RTRIM(dbo.FormatIDS(ISNULL(@Welfare, ''))),
- @Type = ISNULL(@Type, 0),
- @dcSalaryID = ISNULL(@dcSalaryID, 0),
- @MinExperience = ISNULL(@MinExperience, 100),
- @dcEducationID = ISNULL(@dcEducationID, 0),
- @PageNumber = ISNULL(@PageNumber, 0),
- @CompanySizeID = ISNULL(@CompanySizeID, '0'),
- @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END,
- @IsOnline = ISNULL(@Status, 0)
- IF @dcEducationID = 100
- SET @dcEducationID = 0
- IF RIGHT(@dcJobTypeID, 1) = ','
- SET @dcJobTypeID = LEFT(@dcJobTypeID, LEN(@dcJobTypeID) - 1)
- IF RIGHT(@dcIndustryID, 1) = ','
- SET @dcIndustryID = LEFT(@dcIndustryID, LEN(@dcIndustryID) - 1)
- DECLARE @paSearchConditionID AS INT,
- @MinId AS INT,
- @PageSize AS TINYINT,
- @TableID AS TINYINT
- SELECT @paSearchConditionID = 0, @PageSize = 30 --每页的行数
-
- ----搜索1分钟前的数据
- SELECT TOP 1 @paSearchConditionID = ID
- FROM SearchDB..paSearchCondition WITH(NOLOCK)
- WHERE JobType=@dcJobTypeID AND IsOnline = @IsOnline
- AND Industry=@dcIndustryID AND Education=@dcEducationID
- AND Experience=@MinExperience AND Salary=@dcSalaryID
- AND EmployType=@EmployType AND CompanySizeID = @CompanySizeID
- AND Lat = @Lat AND LNg = @Lng AND Distance = @Distance
- AND Welfare = @Welfare AND IsDelete = 0 AND dcProvinceId = @dcProvinceId
- ORDER BY ID DESC
- IF ISNULL(@paSearchConditionID, 0) = 0
- BEGIN
- SET @Type =1
- GOTO SelectReset --无数据,重新搜索
- END
- ELSE
- BEGIN
- SELECT @TableID = @paSearchConditionID % 4
- GOTO GetRecordSet --从临时结果中提取数据
- END
- END
- SelectReset: --从job中搜索数据
- BEGIN TRAN
- DECLARE @SQL AS VARCHAR(8000), @WHERE AS VARCHAR(8000), @FROM AS VARCHAR(1000),
- @JobType AS VARCHAR(3000), @ValidJobNumber AS INT
- DECLARE @T_JobType AS TABLE(ID INT)
-
- ----记录查询条件
- INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, Industry,
- Lng, Lat, Distance, Welfare, KeyWord, KeyType, ReuseNumber, Education, Experience,
- Salary, EmployType, CompanySizeID, IsOnline, dcProvinceId)
- VALUES(
- 50, GETDATE(), @dcJobTypeID, @dcIndustryID, @Lng, @Lat,
- @Distance, @Welfare, '', 0, 0, @dcEducationID, @MinExperience,
- @dcSalaryID, @EmployType, @CompanySizeID, @IsOnline, @dcProvinceId)
- SET @paSearchConditionID = @@IDENTITY
- SELECT @TableID = @paSearchConditionID % 4
- ------生成职位类别的表变量,因为职位类别有包含(父子)关系
- SELECT @JobType=''
-
- ----生成求聘职位的表变量
- IF LEN(@dcJobTypeID) > 0
- BEGIN
- DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
- INSERT INTO @T_Temp
- SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
- INSERT INTO @T_JobType
- SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
- WHERE ParentId IN(SELECT ID FROM @T_TEMP)
- OR ParentId2 in(SELECT ID FROM @T_TEMP)
- OR ID IN(SELECT ID FROM @T_TEMP)
- ----生成in字符串
- SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
- IF RIGHT(@JobType, 1) = ','
- SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
- END
-
- ----建立临时表
- CREATE TABLE #Job(
- RowID INT IDENTITY(1, 1),
- ID INT NOT NULL,
- dcJobTypeID SMALLINT NOT NULL,
- dcJobTypeIDMinor SMALLINT NULL,
- dcSalaryID TINYINT NOT NULL,
- dcRegionID VARCHAR(6) NULL,
- dcEducationID TINYINT NOT NULL,
- MinExperience TINYINT NOT NULL,
- RefreshDate SMALLDATETIME NULL,
- EmployType TINYINT NULL,
- dcCompanySizeID SMALLINT NULL
- )
- ------刷新时间,根据刷新时间编号计算
- ----生成插入临时表的Sql语句
- SET @SQL='
- INSERT INTO #Job
- SELECT a.ID, a.dcJobTypeID,
- a.dcJobTypeIDMinor, a.dcSalaryID,
- a.dcRegionID, a.dcEducationID, a.MinExperience,
- a.IssueDate,a.EmployType,b.dcCompanySizeID'
- SET @FROM = '
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
- ----职位有效,单位新有效
- IF LEN(@dcProvinceID) > 1
- SET @WHERE = '
- WHERE b.dcProvinceID = ' + @dcProvinceID + '
- AND a.Valid = 1
- AND b.Valid = 1'
- ELSE
- SET @WHERE = '
- WHERE a.Valid = 1
- AND b.Valid = 1'
- ----需要增加全文索引的关键字查询
- ----职位类别
- IF LEN(@dcJobTypeID) > 0
- SET @WHERE = @WHERE + '
- AND (a.dcJobTypeID IN(' + @JobType +')
- OR a.dcJobTypeIDMinor IN(' + @JobType + '))'
- IF LEN(@dcIndustryID)>0
- SET @WHERE = @WHERE + ' AND b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @dcIndustryID + '))'
- IF @dcSalaryID > 0
- BEGIN
- IF @dcSalaryID < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
- BEGIN
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID IN(' + LTRIM(STR(@dcSalaryID)) + ',' + LTRIM(STR(@dcSalaryID + 1))
- SET @WHERE = @WHERE + ')'
- END
- IF @dcSalaryID = 100 ----从筛选结果中点击面议,值是100
- BEGIN
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID = 100'
- END
- IF @dcSalaryID > 100 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID=' + LTRIM(STR(@dcSalaryID-100))
- END
- ----工作经验要求
- IF @MinExperience < 100
- SET @WHERE = @WHERE + '
- AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
- ----学历要求
- ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
- IF @dcEducationID > 0
- IF @dcEducationID = 2
- SET @WHERE = @WHERE + '
- AND a.dcEducationID IN(2, 3, 4)'
- ELSE
- SET @WHERE = @WHERE + '
- AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
- ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
- IF LEN(@EmployType) > 0
- SET @WHERE = @WHERE + '
- AND a.EmployType IN (' + @EmployType + ')'
- IF @CompanySizeID BETWEEN 1 AND 6
- SET @WHERE = @WHERE + '
- AND b.dcCompanySizeID = ' + LTRIM(STR(@CompanySizeID))
- IF LEN(@Welfare) > 0
- SET @WHERE = @WHERE + '
- AND a.Welfare' + REPLACE(@Welfare, ',', ' = 1 AND a.Welfare') + ' = 1'
- IF @IsOnline = 1
- SET @WHERE = @WHERE + '
- AND a.caMainId IN(SELECT caMainId FROM caOnline WITH(NOLOCK) WHERE IsOnline = 1) '
-
- DECLARE @Degree AS DECIMAL(8,5),@LBLng AS DECIMAL(8,5),@LBLat AS DECIMAL(8,5),
- @RTLng AS DECIMAL(8,5),@RTLat AS DECIMAL(8,5)
- SET @Degree = @Distance / 100000.0;
- SET @LBLng = @Lng - @Degree
- SET @LBLat = @Lat - @Degree
- SET @RTLng = @Lng + @Degree
- SET @RTLat = @Lat + @Degree
- SET @WHERE = @WHERE + '
- AND a.Lng BETWEEN ' + CONVERT(VARCHAR,@LBLng) + ' AND ' + CONVERT(VARCHAR,@RTLng) + '
- AND a.Lat BETWEEN ' + CONVERT(VARCHAR,@LBLat) + ' AND ' + CONVERT(VARCHAR,@RTLat) + '
- AND (a.Lng-' + CONVERT(VARCHAR,@Lng) + ')*(a.Lng-' + CONVERT(VARCHAR,@Lng) + ')+
- (a.Lat-' + CONVERT(VARCHAR,@Lat) + ')*(a.Lat-' + CONVERT(VARCHAR,@Lat) + ')<' + CONVERT(VARCHAR,@Degree*@Degree)
- SET @SQL = @SQL + @FROM + @WHERE
-
- --IF LEN(@ORDER)>0
- SET @SQL=@SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
- --原来是ORDER BY a.IssueDate DESC, a.ID,Richard 2011年11月23日17:06分修改
- ----把符合条件的职位全部列出
- --PRINT @SQL
- EXEC(@SQL)
-
- SET @ValidJobNumber = @@ROWCOUNT
- ----记录查询结果总数
- UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@SQL WHERE ID=@paSearchConditionID
- ----插入JobType数据
- DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
- IF (@TableID = 0)
- BEGIN
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'JobType'
-
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----计算全部地区,4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), (
- SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- AND LEN(TitleID) >3
- GROUP BY LEFT(TitleID, 4)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'Region'
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
-
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
-
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_0 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- ELSE IF (@TableId = 1)
- BEGIN
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'JobType'
-
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----计算全部地区,4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), (
- SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- AND LEN(TitleID) >3
- GROUP BY LEFT(TitleID, 4)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'Region'
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
-
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
-
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_1 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- ELSE IF (@TableId = 2)
- BEGIN
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'JobType'
-
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----计算全部地区,4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), (
- SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- AND LEN(TitleID) >3
- GROUP BY LEFT(TitleID, 4)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'Region'
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
-
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
-
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_2 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- ELSE IF (@TableId = 3)
- BEGIN
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'JobType'
-
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----计算全部地区,4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), (
- SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- AND LEN(TitleID) >3
- GROUP BY LEFT(TitleID, 4)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'Region'
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
-
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
-
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_3 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- DROP TABLE #Job
- --PRINT 'DROP #JOB ' + CONVERT(VARCHAR(30), GETDATE(), 121)
- COMMIT
- --GOTO GetRecordSet
- GetRecordSet:
- BEGIN
- DECLARE @AllJobCount AS INT
- ----返回查询数量
- SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
- SELECT @AllJobCount = ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
- UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
- ----返回20行查询结果
- IF (@TableID = 0)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.dcEducationID, b.HasLicence, b.IsRefreshed, dcCompanySizeID,
- a.MinExperience, a.MinAge, a.MaxAge, a.RefreshDate, a.Lng, a.Lat,
- b.Name as cpName, c.IsTop, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,
- a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
- a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,
- ISNULL((SELECT IsOnline FROM caOnline WITH(NOLOCK) WHERE caMainId = a.caMainId), 0) IsOnline, b.LogoFile LogoUrl,@AllJobCount JobNumber,
- d.FullName RegionName,e.Description EducationName,f.Description ExperienceName,g.DescriptionCp dcSalary,h.DescriptionCp dcSalaryMax
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_0 c WITH(NOLOCK),
- dcRegion d WITH(NOLOCK),dcEducation e WITH(NOLOCK),dcOthers f WITH(NOLOCK),dcSalary g WITH(NOLOCK),dcSalary h WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
- AND d.ID = a.dcRegionID AND e.ID = a.dcEducationID AND f.DetailID = a.MinExperience
- AND f.Category='职位要求工作经验' AND g.ID = a.dcSalaryID AND h.ID = a.dcSalaryIDMax
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 1)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.dcEducationID, b.HasLicence, b.IsRefreshed, dcCompanySizeID,
- a.MinExperience, a.MinAge, a.MaxAge, a.RefreshDate, a.Lng, a.Lat,
- b.Name as cpName, c.IsTop, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,
- a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
- a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,
- ISNULL((SELECT IsOnline FROM caOnline WITH(NOLOCK) WHERE caMainId = a.caMainId), 0) IsOnline,
- b.LogoFile LogoUrl,@AllJobCount JobNumber,
- d.FullName RegionName,e.Description EducationName,f.Description ExperienceName,g.DescriptionCp dcSalary,h.DescriptionCp dcSalaryMax
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_1 c WITH(NOLOCK),
- dcRegion d WITH(NOLOCK),dcEducation e WITH(NOLOCK),dcOthers f WITH(NOLOCK),dcSalary g WITH(NOLOCK),dcSalary h WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
- AND d.ID = a.dcRegionID AND e.ID = a.dcEducationID AND f.DetailID = a.MinExperience
- AND f.Category='职位要求工作经验' AND g.ID = a.dcSalaryID AND h.ID = a.dcSalaryIDMax
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 2)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.dcEducationID, b.HasLicence, b.IsRefreshed, dcCompanySizeID,
- a.MinExperience, a.MinAge, a.MaxAge, a.RefreshDate, a.Lng, a.Lat,
- b.Name as cpName, c.IsTop, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,
- a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
- a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,
- ISNULL((SELECT IsOnline FROM caOnline WITH(NOLOCK) WHERE caMainId = a.caMainId), 0) IsOnline,
- b.LogoFile LogoUrl, @AllJobCount JobNumber,
- d.FullName RegionName,e.Description EducationName,f.Description ExperienceName,g.DescriptionCp dcSalary,h.DescriptionCp dcSalaryMax
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_2 c WITH(NOLOCK),
- dcRegion d WITH(NOLOCK),dcEducation e WITH(NOLOCK),dcOthers f WITH(NOLOCK),dcSalary g WITH(NOLOCK),dcSalary h WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
- AND d.ID = a.dcRegionID AND e.ID = a.dcEducationID AND f.DetailID = a.MinExperience
- AND f.Category='职位要求工作经验' AND g.ID = a.dcSalaryID AND h.ID = a.dcSalaryIDMax
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 3)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID, b.HasLicence, b.IsRefreshed, dcCompanySizeID,
- a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
- a.IsDelete, a.AddDate, a.RefreshDate, a.Lng, a.Lat,
- a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
- b.UnLimitedDate, b.BalanceDate, b.Balance,
- b.MemberType, '' cpIndustry,
- c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID,a.Welfare1,a.Welfare2,
- a.Welfare3, a.Welfare4,a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8, a.Welfare9,a.Welfare10,
- a.Welfare11,a.Welfare12,a.Welfare13, a.Welfare14,a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,
- ISNULL((SELECT IsOnline FROM caOnline WITH(NOLOCK) WHERE caMainId = a.caMainId), 0) IsOnline,
- b.LogoFile LogoUrl,@AllJobCount JobNumber,
- d.FullName RegionName,e.Description EducationName,f.Description ExperienceName,g.DescriptionCp dcSalary,h.DescriptionCp dcSalaryMax
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_3 c WITH(NOLOCK),
- dcRegion d WITH(NOLOCK),dcEducation e WITH(NOLOCK),dcOthers f WITH(NOLOCK),dcSalary g WITH(NOLOCK),dcSalary h WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
- AND d.ID = a.dcRegionID AND e.ID = a.dcEducationID AND f.DetailID = a.MinExperience
- AND f.Category='职位要求工作经验' AND g.ID = a.dcSalaryID AND h.ID = a.dcSalaryIDMax
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- --RICHARD 2011-7-23 16:51分修改
- ----返回统计数量
- IF @Type=1
- BEGIN
- IF (@TableID = 0)
- BEGIN
- 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)
- 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)
- 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)
- 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)
- SELECT * FROM SearchDB..paSearchCount_0 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- 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)
- 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)
- END
- IF (@TableID = 1)
- BEGIN
- 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)
- 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)
- 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)
- 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)
- SELECT * FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- 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)
- 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)
- END
- IF (@TableID = 2)
- BEGIN
- 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)
- 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)
- 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)
- 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)
- SELECT * FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- 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)
- 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)
- END
- IF (@TableID = 3)
- BEGIN
- 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)
- 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)
- 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)
- 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)
- SELECT * FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- 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)
- 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)
- END
- END
- RETURN
- END
- END TRY
- BEGIN CATCH
- ---检查是否已经建立临时表,已经建立则删除
- ROLLBACK TRANSACTION
- ---检查是否已经建立临时表,已经建立则删除
- DECLARE @para VARCHAR(MAX)
- SET @para = '@dcJobTypeID=' + ISNULL(@dcJobTypeID, '') + '|' +
- '@dcIndustryID=' + ISNULL(@dcIndustryID, '') + '|' +
- '@EmployType=' + ISNULL(@EmployType, '') + '|' +
- '@Welfare=' + ISNULL(@Welfare, '')
- INSERT INTO ErrorLog
- SELECT 'm3 ' + ISNULL(error_Message(), ' no msg')+ ' para=' + ISNULL(@Para, 'no para ') + ISNULL(@SQL, ' no sql'), error_number(), error_line(), GETDATE()
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblJobBySearchCount] Script Date: 2018/12/13 19:07:45 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblJobBySearchCount]
- (
- @dcJobTypeID INT, --职位类别
- @dcRegionID INT, --求职地区
- @dcIndustryID INT --求职行业
- )
- AS
- BEGIN
- DECLARE @COUNT INT, @ALLCOUNT INT
- IF @dcIndustryID > 0
- SELECT @COUNT = COUNT(*) FROM Job a WITH(NOLOCK)
- INNER JOIN cpMain b ON a.cpMainID=b.ID
- INNER JOIN cpIndustry d WITH(NOLOCK) ON d.cpMainID=b.ID AND d.dcIndustryID=@dcIndustryID
- WHERE (dcJobTypeID=@dcJobTypeID OR dcJobTypeIDMinor=@dcJobTypeID)
- AND LEFT(a.dcRegionID,4)=@dcRegionID AND a.Valid=1
- ELSE
- SELECT @COUNT=COUNT(*) FROM Job WITH(NOLOCK)
- WHERE (dcJobTypeID=@dcJobTypeID OR dcJobTypeIDMinor=@dcJobTypeID)
- AND LEFT(dcRegionID,4) = @dcRegionID
- AND Valid=1
-
- RETURN @Count
- END
- set ANSI_NULLS ON
- set QUOTED_IDENTIFIER ON
- GO
- /****** Object: StoredProcedure [dbo].[mblJobBySearchSelect] Script Date: 2018/12/13 19:07:46 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE proCEDURE [dbo].[mblJobBySearchSelect]
- (
- @dcJobTypeID VARCHAR(100), --职位类别
- @dcRegionID VARCHAR(100), --求职地区
- @dcIndustryID VARCHAR(100), --求职行业
- @dcSalaryID TINYINT, --月薪
- @IsNegotiable BIT, --1允许面议,不面议
- @MinExperience TINYINT, --工作经验,100为未选择
- @dcEducationID TINYINT, --最低学历
- @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习,
- @KeyWord NVARCHAR(50), --关键词
- @KeyType TINYINT, --搜索类别,0无;1-全文;2-职位;3-公司
- @ORDER VARCHAR(4), --显示顺序,没有用
- @RefreshNo INT, --1, 1天内;2, 3天内;3,一周内;4,15天内;5,一个月内;6超过一个月
- @Type INT, --1:主动搜索 点击搜索按钮 10分钟,翻页60分钟有效;0:翻页搜索,不刷新
- @PageNumber INT, --翻页页码
- @SessionID varchar(50), --10
- @CompanySizeID VARCHAR(1), --企业规模
- @IsOnline INT,
- @Welfare VARCHAR(50) --
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @t AS TABLE(
- dcJobTypeID VARCHAR(100),
- dcRegionID VARCHAR(100),
- dcIndustryID VARCHAR(100),
- dcSalaryID TINYINT,
- IsNegotiable INT,
- MinExperience TINYINT,
- dcEducationID TINYINT,
- EmployType VARCHAR(10),
- KeyWord NVARCHAR(50),
- KeyType TINYINT,
- [ORDER] VARCHAR(100),
- RefreshNo INT,
- Type INT,
- PageNumber INT,
- SessionID varchar(50),
- CompanySizeID VARCHAR(1),
- Welfare VARCHAR(50),
- IsOnline INT
- )
- INSERT INTO @t
- SELECT @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcSalaryID, @IsNegotiable,
- @MinExperience, @dcEducationID, @EmployType, @KeyWord, @KeyType, @ORDER,
- @RefreshNo, @Type, @PageNumber, @SessionID, @CompanySizeID, @Welfare, @IsOnline
-
- DECLARE @json VARCHAR(max)
- SET @json = (SELECT * from @t for json auto)
- SET @json = RIGHT(LEFT(@json, LEN(@json) - 1), LEN(@json) - 2)
-
- EXEC procJobPublishSelect @json
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblJobBySearchSelect0928] Script Date: 2018/12/13 19:07:46 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- create proCEDURE [dbo].[mblJobBySearchSelect0928]
- (
- @dcJobTypeID VARCHAR(100), --职位类别
- @dcRegionID VARCHAR(100), --求职地区
- @dcIndustryID VARCHAR(100), --求职行业
- @dcSalaryID TINYINT, --月薪
- @IsNegotiable BIT, --1允许面议,不面议
- @MinExperience TINYINT, --工作经验,100为未选择
- @dcEducationID TINYINT, --最低学历
- @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习,
- @KeyWord NVARCHAR(50), --关键词
- @KeyType TINYINT, --搜索类别,0无;1-全文;2-职位;3-公司
- @ORDER VARCHAR(4), --显示顺序,没有用
- @RefreshNo INT, --1, 1天内;2, 3天内;3,一周内;4,15天内;5,一个月内;6超过一个月
- @Type INT, --1:主动搜索 点击搜索按钮 10分钟,翻页60分钟有效;0:翻页搜索,不刷新
- @PageNumber INT, --翻页页码
- @SessionID varchar(50), --10
- @CompanySizeID VARCHAR(1), --企业规模
- @IsOnline INT,
- @Welfare VARCHAR(50) --
- )
- AS
- --return @SessionId = 10
- SET NOCOUNT ON
- INSERT INTO SearchIp(Ip, Source) SELECT @SessionId, 'm'
- IF EXISTS(SELECT 'x' FROM RefuseIp WITH(NOLOCK) WHERE CHARINDEX(Ip,@SessionId) > 0)
- RETURN
- INSERT INTO SearchDB..paSearchLog(ProcType, SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
- Salary, IsNegotiable, EmployType, CompanySizeID, KeyWord, KeyType, ReuseNumber, Welfare, IsOnline, RefreshNo)
- VALUES('pcJobBySearchSelect', @SessionId, GETDATE(), @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcEducationID, @MinExperience,
- @dcSalaryID, 0, @EmployType, @CompanySizeID, @KeyWord, @KeyType, 0, @Welfare, @IsOnline, @RefreshNo)
- SET @SessionId = 'b' + @SessionId
- SET @KeyType = 0
- BEGIN TRY
- DECLARE @ReuseNumber AS INT, @dcProvinceId VARCHAR(2), @Order2 VARCHAR(100)
- ----给null值变量赋默认值
- IF NOT LEFT(@dcRegionID,1) = 'p'
- SELECT @dcRegionID = RTRIM(dbo.FormatIDS(@dcRegionID))
- SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
- @dcIndustryID = RTRIM(dbo.FormatIDS(@dcIndustryID)),
- @dcSalaryID = ISNULL(@dcSalaryID, 0),
- @IsNegotiable = ISNULL(@IsNegotiable, 0),
- @MinExperience = ISNULL(@MinExperience, 100),
- @dcEducationID = ISNULL(@dcEducationID, 0),
- @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END,
- @CompanySizeID = ISNULL(@CompanySizeID, '0'),
- @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, '')),
- @ORDER = ISNULL(@Order, ''),
- @Type = ISNULL(@Type, 0),
- @PageNumber = ISNULL(@PageNumber, 0),
- @Welfare = RTRIM(dbo.FormatIDS(@Welfare)),
- @IsOnline = ISNULL(@IsOnline, 0),
- @Order2 = ' ORDER BY a.RefreshDate DESC, a.SecondID DESC'
- IF @dcSalaryID = 0
- SET @IsNegotiable = 0
- IF @Order LIKE 'p=%'
- SET @dcProvinceId = REPLACE(@Order, 'p=', '')
- ELSE
- SET @dcProvinceId = 0
- --@RefreshNo = 0选择全部数据,不限制时间
- SET @RefreshNo = 0
- IF(@KeyWord = '' AND ISNULL(@dcJobTypeID, '') = '' AND ISNULL(@dcRegionID, '') = '' AND ISNULL(@dcIndustryID, '') = '')
- RETURN
- --如果关键词不为空 查询关键词对应的搜索类型 max 2012-12-25
-
- IF RIGHT(@KeyWord, 2) = '公司'
- SET @KeyWord = LEFT(@KeyWord, LEN(@KeyWord) - 2)
-
- IF RIGHT(@dcJobTypeID, 1) = ','
- SET @dcJobTypeID = LEFT(@dcJobTypeID, LEN(@dcJobTypeID) - 1)
- IF RIGHT(@dcRegionID, 1) = ','
- SET @dcRegionID = LEFT(@dcRegionID, LEN(@dcRegionID) - 1)
- IF RIGHT(@dcIndustryID, 1) = ','
- SET @dcIndustryID = LEFT(@dcIndustryID, LEN(@dcIndustryID) - 1)
- DECLARE @paSearchConditionID AS INT,
- @MinId AS INT,
- @PageSize AS TINYINT,
- @TableID AS TINYINT
- SELECT @paSearchConditionID = 0, @PageSize = 30
- ----搜索1分钟前的数据
- SELECT TOP 1 @paSearchConditionID = ID,
- @ReuseNumber = ReuseNumber
- FROM SearchDB..paSearchCondition WITH(NOLOCK)
- WHERE JobType=@dcJobTypeID AND IsOnline = @IsOnline
- AND JobPlace=@dcRegionID AND Industry=@dcIndustryID AND Education=@dcEducationID
- AND Experience=@MinExperience AND Salary=@dcSalaryID AND IsNegotiable=@IsNegotiable
- AND EmployType=@EmployType AND ISNULL(KeyWord, '') = @KeyWord AND KeyType = @KeyType
- AND CompanySizeID = @CompanySizeID AND Welfare = @Welfare AND IsDelete = 0
- AND LogTime > DATEADD(MINUTE, -1, GETDATE()) AND ReuseNumber > 0
- AND RefreshNo = 0 AND ISNULL(dcProvinceId, 0) = @dcProvinceId
- ORDER BY ID DESC
- IF @ReuseNumber = 0
- BEGIN
- SELECT TOP 1 @paSearchConditionID = ID
- FROM SearchDB..paSearchCondition WITH(NOLOCK)
- WHERE JobType=@dcJobTypeID AND IsOnline = @IsOnline
- AND JobPlace=@dcRegionID AND Industry=@dcIndustryID AND Education=@dcEducationID
- AND Experience=@MinExperience AND Salary=@dcSalaryID AND IsNegotiable=@IsNegotiable
- AND EmployType=@EmployType AND ISNULL(KeyWord, '') = @KeyWord AND KeyType=@KeyType
- AND CompanySizeID = @CompanySizeID AND Welfare = @Welfare AND ReuseNumber > 0
- AND ReuseNumber > 0 AND LogTime > DATEADD(MINUTE, -2, GETDATE())
- AND RefreshNo = 0 AND ISNULL(dcProvinceId, 0) = @dcProvinceId
- ORDER BY ID DESC
- END
- IF ISNULL(@paSearchConditionID, 0) = 0
- BEGIN
- SET @Type =1
- GOTO SelectReset --无数据,重新搜索
- END
- ELSE
- BEGIN
- SELECT @TableID = @paSearchConditionID % 4
- GOTO GetRecordSet --从临时结果中提取数据
- END
- SelectReset:
- --从job中搜索数据
- BEGIN TRAN
- DECLARE @SQL AS VARCHAR(8000)
- DECLARE @WHERE AS VARCHAR(8000)
- DECLARE @FROM AS VARCHAR(1000)
- ----记录查询条件
- INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
- Salary, IsNegotiable, EmployType, CompanySizeID, KeyWord, KeyType, ReuseNumber, Welfare, IsOnline, dcProvinceId)
- VALUES(@SessionId, GETDATE(), @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcEducationID, @MinExperience,
- @dcSalaryID, @IsNegotiable, @EmployType, @CompanySizeID, @KeyWord, @KeyType, 0, @Welfare, @IsOnline, @dcProvinceId)
- SET @paSearchConditionID = @@IDENTITY
- SELECT @TableID = @paSearchConditionID % 4
- ------生成职位类别的表变量,因为职位类别有包含(父子)关系
- DECLARE @T_JobPlace AS TABLE(ID INT)
- DECLARE @T_JobType AS TABLE(ID INT)
- DECLARE @JobPlaceLen AS INT, @JobTypeLen AS INT
- IF CHARINDEX(',', @dcJobTypeID) > 0
- SET @JobTypeLen = -1
- ELSE
- SET @JobTypeLen = LEN(@dcJobTypeID)
- DECLARE @JobType AS VARCHAR(3000), @JobPlace AS VARCHAR(2000), @ValidJobNumber AS INT
- SELECT @JobPlace = '', @JobType=''
- ----生成工作地点的表变量
- IF LEN(@dcRegionID) > 0
- BEGIN
- IF LEFT(@dcRegionID,1) = 'p'
- BEGIN
- DECLARE @Degree AS DECIMAL(8,5),@LBLng AS DECIMAL(8,5),@LBLat AS DECIMAL(8,5),
- @RTLng AS DECIMAL(8,5),@RTLat AS DECIMAL(8,5),@Lat AS DECIMAL(8,5),@Lng AS DECIMAL(8,5)
-
- SELECT @Lat = Lat,@Lng = Lng FROM dcMapPlace WITH(NOLOCK) WHERE ID = RIGHT(@dcRegionID,LEN(@dcRegionID)-1)
- IF @dcRegionID LIKE '3201%'
- SET @Degree = 1000 / 100000.0
- ELSE
- SET @Degree = 2000 / 100000.0
- SET @LBLng = @Lng - @Degree
- SET @LBLat = @Lat - @Degree
- SET @RTLng = @Lng + @Degree
- SET @RTLat = @Lat + @Degree
- SET @JobPlace = 'a.Lng BETWEEN ' + CONVERT(VARCHAR,@LBLng) + ' AND ' + CONVERT(VARCHAR,@RTLng) + '
- AND a.Lat BETWEEN ' + CONVERT(VARCHAR,@LBLat) + ' AND ' + CONVERT(VARCHAR,@RTLat) + '
- AND (a.Lng-' + CONVERT(VARCHAR,@Lng) + ')*(a.Lng-' + CONVERT(VARCHAR,@Lng) + ')+
- (a.Lat-' + CONVERT(VARCHAR,@Lat) + ')*(a.Lat-' + CONVERT(VARCHAR,@Lat) + ')<' + CONVERT(VARCHAR,@Degree*@Degree)
- SELECT @JobPlaceLen = 8
- END
- ELSE
- BEGIN
- INSERT INTO @T_JobPlace
- SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
- SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
- IF LEN(@JobPlace) > 0
- SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
- IF (SELECT COUNT(*) FROM @T_JobPlace) > 1
- SET @JobPlaceLen = -1
- ELSE
- SET @JobPlaceLen = LEN(@dcRegionID)
- END
- END
- ELSE
- SELECT @JobPlaceLen = 0
- ----生成求聘职位的表变量
- IF LEN(@dcJobTypeID) > 0
- BEGIN
- DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
- INSERT INTO @T_Temp
- SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
- INSERT INTO @T_JobType
- SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
- WHERE ParentId IN(SELECT ID FROM @T_TEMP)
- OR ParentId2 in(SELECT ID FROM @T_TEMP)
- OR ID IN(SELECT ID FROM @T_TEMP)
- ----生成in字符串
- SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
- IF RIGHT(@JobType, 1) = ','
- SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
- END
- ----建立临时表
- CREATE TABLE #Job(
- RowID INT IDENTITY(1, 1),
- ID INT NOT NULL,
- cpMainId INT,
- dcJobTypeID SMALLINT NOT NULL,
- dcJobTypeIDMinor SMALLINT NULL,
- dcSalaryID TINYINT NOT NULL,
- dcRegionID VARCHAR(6) NULL,
- dcEducationID TINYINT NOT NULL,
- MinExperience TINYINT NOT NULL,
- RefreshDate SMALLDATETIME NULL,
- EmployType TINYINT NULL,
- dcCompanySizeID SMALLINT NULL
- )
- CREATE TABLE #FullText(
- Priority INT,
- JobId INT NOT NULL
- )
- ------刷新时间,根据刷新时间编号计算
- ----生成插入临时表的Sql语句
- SET @SQL='
- INSERT INTO #Job
- SELECT a.ID, a.cpMainId, a.dcJobTypeID,
- a.dcJobTypeIDMinor, a.dcSalaryID,
- a.dcRegionID, a.dcEducationID, a.MinExperience,
- a.IssueDate,a.EmployType,b.dcCompanySizeID'
- SET @FROM = '
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
- ----职位有效,单位新有效
- IF LEN(@dcIndustryID) > 0
- SET @WHERE = '
- WHERE b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @dcIndustryID + '))
- AND a.Valid = 1
- AND b.Valid = 1'
- ELSE
- SET @WHERE = '
- WHERE a.Valid = 1
- AND b.Valid = 1'
-
- IF LEN(@dcProvinceId) > 1
- SET @WHere = @Where + ' AND b.dcProvinceId = ' + @dcProvinceId
- ----职位类别
- IF LEN(@JobType) > 0
- SET @WHERE = @WHERE + '
- AND (a.dcJobTypeID IN(' + @JobType +')
- OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
- IF LEN(@JobPlace) > 0
- SET @WHERE = @WHERE + '
- AND (' + @JobPlace + ')'
- IF @dcSalaryID > 0
- BEGIN
- IF @dcSalaryID < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID IN(' + LTRIM(STR(@dcSalaryID)) + ',' + LTRIM(STR(@dcSalaryID + 1)) + ')'
- ELSE IF @dcSalaryID = 100 ----从筛选结果中点击面议,值是100
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID = 100'
- ELSE IF @dcSalaryID BETWEEN 101 AND 106 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID <= ' + LTRIM(STR(@dcSalaryID-99)) + ' AND a.dcSalaryIDMax > ' + LTRIM(STR(@dcSalaryID-100))
- ELSE IF @dcSalaryID BETWEEN 107 AND 113 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID <= ' + LTRIM(STR(@dcSalaryID - 100)) + ' AND a.dcSalaryIDMax > ' + LTRIM(STR(@dcSalaryID-100))
- ELSE IF @dcSalaryID BETWEEN 114 AND 120
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID < 100 AND a.dcSalaryIDMax > ' + LTRIM(STR(@dcSalaryID - 100))
- END
- ----工作经验要求
- IF @MinExperience < 100
- SET @WHERE = @WHERE + '
- AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
- ----学历要求
- ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
- IF @dcEducationID > 0
- IF @dcEducationID = 2
- SET @WHERE = @WHERE + '
- AND a.dcEducationID IN(2, 3, 4)'
- ELSE
- SET @WHERE = @WHERE + '
- AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
- ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
- IF LEN(@EmployType) > 0
- SET @WHERE = @WHERE + '
- AND a.EmployType IN (' + @EmployType + ')'
- IF @CompanySizeID BETWEEN 1 AND 6
- SET @WHERE = @WHERE + '
- AND b.dcCompanySizeID = ' + LTRIM(STR(@CompanySizeID))
- IF LEN(@Welfare) > 0
- SET @WHERE = @WHERE + '
- AND a.Welfare' + REPLACE(@Welfare, ',', ' = 1 AND a.Welfare') + ' = 1'
- IF @IsOnline = 1
- SET @WHERE = @WHERE + '
- AND a.caMainId IN(SELECT caMainId FROM caOnline WITH(NOLOCK) WHERE IsOnline = 1)'
- IF LEN(@KeyWord) > 0 ----使用全文搜索job和cpmain2个表,经过测试发现union最快
- BEGIN
- IF EXISTS(SELECT TOP 1 'x' FROM cpMainPublish WITH(NOLOCK) WHERE Name = @KeyWord)
- BEGIN
- SET @WHERE = @WHERE + '
- AND b.Name = ''' + @KeyWord + ''''
- SET @SQL = @SQL + @FROM + @WHERE
- END
- ELSE
- BEGIN
- DECLARE @KeyWordTemp NVARCHAR(50)
- SET @KeyWordTemp = REPLACE(@KeyWord, ' ', '%')
- IF LEN(@KeyWordTemp) > 1
- BEGIN
- IF @dcProvinceId > 0
- BEGIN
- INSERT #FullText
- SELECT TOP 2000 2, b.ID
- FROM cpMainPublish a WITH(NOLOCK),
- JobPublish b WITH(NOLOCK)
- WHERE a.Id = b.cpMainId
- AND a.Name LIKE '%' + @KeyWordTemp + '%'
- AND a.dcProvinceId = @dcprovinceId
- ORDER BY b.RefreshDate DESC
- INSERT #FullText
- SELECT TOP 2000 1, b.ID
- FROM cpMainPublish a WITH(NOLOCK),
- JobPublish b WITH(NOLOCK)
- WHERE a.Id = b.cpMainId
- AND b.Name LIKE '%' + @KeyWordTemp + '%'
- AND a.dcProvinceId = @dcprovinceId
- ORDER BY b.RefreshDate DESC
- END
- ELSE
- BEGIN
- INSERT #FullText
- SELECT TOP 2000 2, b.ID
- FROM cpMainPublish a WITH(NOLOCK),
- JobPublish b WITH(NOLOCK)
- WHERE a.Id = b.cpMainId
- AND a.Name LIKE '%' + @KeyWordTemp + '%'
- ORDER BY b.RefreshDate DESC
- INSERT #FullText
- SELECT TOP 2000 1, b.ID
- FROM cpMainPublish a WITH(NOLOCK),
- JobPublish b WITH(NOLOCK)
- WHERE a.Id = b.cpMainId
- AND b.Name LIKE '%' + @KeyWordTemp + '%'
- ORDER BY b.RefreshDate DESC
- END
- END
- IF (SELECT COUNT(*) FROM #FullText) < 800
- BEGIN
- INSERT #FullText
- SELECT TOP 5000 3, [Key]
- FROM FREETEXTTABLE(cpMainJob, *, @KeyWord, 100000) AS KeyJob ORDER BY RANK DESC
- END
- DELETE a FROM #FullText a, #FullText b WHERE a.JobId = b.JobId AND a.Priority > b.Priority
- --------------------
- SELECT @FROM = @FROM + '
- INNER JOIN #FullText ON a.ID = #FullText.JobId',
- @ORDER2 = ' ORDER BY #FullText.Priority, a.RefreshDate DESC, a.SecondID DESC'
- SET @SQL = @SQL + @FROM + @WHERE
- END
- END
- ELSE
- SELECT @SQL = @SQL + @FROM + @WHERE
-
- SET @SQL = @SQL + @Order2
- --原来是ORDER BY a.IssueDate DESC, a.ID,Richard 2011年11月23日17:06分修改
- ----把符合条件的职位全部列出
- --PRINT @SQL
- EXEC(@SQL)
- SET @ValidJobNumber = @@ROWCOUNT
- ----记录查询结果总数
- UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@SQL WHERE ID=@paSearchConditionID
- IF LEN(@JobType) > 0 --IN(2, 4)
- UPDATE #Job SET dcJobTypeId = dcJobTypeIDMinor
- WHERE dcJobTypeID NOT IN(SELECT a FROM dbo.fnSplit(@JobType, ','))
- ----插入JobType数据
- DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
- DECLARE @sc AS TABLE (
- paSearchConditionID int,
- Title varchar(20),
- TitleID varchar(10),
- TitleValue int
- )
- DECLARE @sc2 AS TABLE (
- paSearchConditionID int,
- Title varchar(20),
- TitleID varchar(10),
- TitleValue int
- )
- IF (@TableID = 0)
- BEGIN
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- IF @JobTypeLen NOT IN(2, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- END
- IF @JobTypeLen NOT IN(0, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
- FROM @sc2 WHERE LEN(TitleId) = 4
- END
- IF @JobTypeLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
- DELETE @sc
- DELETE @sc2
- --------
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- IF @JobPlaceLen IN(-1, 0)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- IF @JobPlaceLen IN(-1, 2)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
- IF @JobPlaceLen IN(-1, 4)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
- FROM @sc2 WHERE LEN(TitleID) = 6
- IF @JobPlaceLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
- ELSE
- DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
- ----------------
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
- FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
- WHERE a.cpMainId = b.cpMainId
- GROUP BY b.dcIndustryId ORDER BY b.dcIndustryId
- IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
- INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
- SELECT TOP 10 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
- WHERE b.ID = a.JobId
- AND CHARINDEX(@KeyWord, a.JobName) > 0
- ORDER BY a.OrderType, a.OpenDate DESC
- ELSE
- INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
- SELECT TOP 10 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
- WHERE b.ID = a.JobId
- ORDER BY a.OrderType, a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowID
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_0 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
- END
- ELSE IF (@TableId = 1)
- BEGIN
- ----------------------------jobtype
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- IF @JobTypeLen NOT IN(2, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- END
- IF @JobTypeLen NOT IN(0, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
- FROM @sc2 WHERE LEN(TitleId) = 4
- END
- IF @JobTypeLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
- DELETE @sc
- DELETE @sc2
- --------------------------region
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- IF @JobPlaceLen IN(-1, 0)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- IF @JobPlaceLen IN(-1, 2)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
- IF @JobPlaceLen IN(-1, 4)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
- FROM @sc2 WHERE LEN(TitleID) = 6
- IF @JobPlaceLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
- ELSE
- DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
- ----------------------------
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
-
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
-
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
- FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
- WHERE a.cpMainId = b.cpMainId
- GROUP BY dcIndustryID ORDER BY dcIndustryID
- IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
- INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
- SELECT TOP 10 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
- WHERE b.ID = a.JobId
- AND CHARINDEX(@KeyWord, a.JobName) > 0
- ORDER BY a.OrderType, a.OpenDate DESC
- ELSE
- INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
- SELECT TOP 10 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
- WHERE b.ID = a.JobId
- ORDER BY a.OrderType, a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowID
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_1 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
- END
- ELSE IF (@TableId = 2)
- BEGIN
- ----------------------------jobtype
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- IF @JobTypeLen NOT IN(2, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- END
- IF @JobTypeLen NOT IN(0, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
- FROM @sc2 WHERE LEN(TitleId) = 4
- END
- IF @JobTypeLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
- DELETE @sc
- DELETE @sc2
- --------------------------region
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- IF @JobPlaceLen IN(-1, 0)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- IF @JobPlaceLen IN(-1, 2)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
- IF @JobPlaceLen IN(-1, 4)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
- FROM @sc2 WHERE LEN(TitleID) = 6
- IF @JobPlaceLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
- ELSE
- DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
- ----------------------------
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
-
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
- FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
- WHERE a.cpMainId = b.cpMainId
- GROUP BY dcIndustryID ORDER BY dcIndustryID
- IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
- INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
- SELECT TOP 10 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
- WHERE b.ID = a.JobId
- AND CHARINDEX(@KeyWord, a.JobName) > 0
- ORDER BY a.OrderType, a.OpenDate DESC
- ELSE
- INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
- SELECT TOP 10 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
- WHERE b.ID = a.JobId
- ORDER BY a.OrderType, a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowID
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_2 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
- END
- ELSE IF (@TableId = 3)
- BEGIN
- ----------------------------jobtype
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- IF @JobTypeLen NOT IN(2, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- END
- IF @JobTypeLen NOT IN(0, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
- FROM @sc2 WHERE LEN(TitleId) = 4
- END
- IF @JobTypeLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
- DELETE @sc
- DELETE @sc2
- --------------------------region
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- IF @JobPlaceLen IN(-1, 0)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- IF @JobPlaceLen IN(-1, 2)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
- IF @JobPlaceLen IN(-1, 4)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
- FROM @sc2 WHERE LEN(TitleID) = 6
- IF @JobPlaceLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
- ELSE
- DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
- ----------------------------
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
-
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
- FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
- WHERE a.cpMainId = b.cpMainId
- GROUP BY dcIndustryID ORDER BY dcIndustryID
- IF EXISTS(SELECT TOP 1 'x' FROM #FullText)
- INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
- SELECT TOP 10 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
- WHERE b.ID = a.JobId
- AND CHARINDEX(@KeyWord, a.JobName) > 0
- ORDER BY a.OrderType, a.OpenDate DESC
- ELSE
- INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
- SELECT TOP 10 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT ID FROM #Job WITH(NOLOCK) WHERE RowId < 2001) b
- WHERE b.ID = a.JobId
- ORDER BY a.OrderType, a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK) ORDER BY RowID
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_3 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID ORDER BY ID)
- END
- DROP TABLE #Job
- --PRINT 'DROP #JOB ' + CONVERT(VARCHAR(30), GETDATE(), 121)
- COMMIT
- --GOTO GetRecordSet
- GetRecordSet:
- BEGIN
- DECLARE @AllJobCount AS INT
- ----返回查询数量
- SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
- SELECT @AllJobCount = ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
- UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
- ----返回20行查询结果
- IF (@TableID = 0)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
- b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
- ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
- e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
- INNER JOIN SearchDB..paSearchJobID_0 c WITH(NOLOCK) ON a.id = c.JobID
- INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
- LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
- WHERE paSearchConditionID=@paSearchConditionID
- AND c.ID >= @MinId
- ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 1)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
- b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
- ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
- e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
- INNER JOIN SearchDB..paSearchJobID_1 c WITH(NOLOCK) ON a.id = c.JobID
- INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
- LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
- WHERE paSearchConditionID=@paSearchConditionID
- AND c.ID >= @MinId
- ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 2)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
- b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
- ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
- e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
- INNER JOIN SearchDB..paSearchJobID_2 c WITH(NOLOCK) ON a.id = c.JobID
- INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
- LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
- WHERE paSearchConditionID=@paSearchConditionID
- AND c.ID >= @MinId
- ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 3)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
- b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
- ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
- e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
- INNER JOIN SearchDB..paSearchJobID_3 c WITH(NOLOCK) ON a.id = c.JobID
- INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
- LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
- WHERE paSearchConditionID=@paSearchConditionID
- AND c.ID >= @MinId
- ORDER BY c.ID, a.ID DESC
- END
- --RICHARD 2011-7-23 16:51分修改
- ----返回统计数量
- IF @Type=1
- BEGIN
- DECLARE @RegionCount AS INT
- SELECT @RegionCount = -1
- IF CHARINDEX(',', @dcRegionID) = 0 AND LEN(@dcRegionID) > 0
- BEGIN
- IF NOT LEFT(@dcRegionID,1) = 'p'
- SELECT @RegionCount = COUNT(*) FROM dcRegion WHERE ParentID = @dcRegionID
- END
- IF (@TableID = 0)
- BEGIN
- SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
- IF @RegionCount = 0
- SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
- ELSE
- SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
- SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- END
- IF (@TableID = 1)
- BEGIN
- SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
- IF @RegionCount = 0
- SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
- ELSE
- SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
- SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- SELECT * FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- END
- IF (@TableID = 2)
- BEGIN
- SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
- IF @RegionCount = 0
- SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
- ELSE
- SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
- SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- SELECT * FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- END
- IF (@TableID = 3)
- BEGIN
- SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'JobType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
- IF @RegionCount = 0
- SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
- ELSE
- SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Region' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(VARCHAR(10), TitleID)
- SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Education' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Experience' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'EmployType' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- SELECT * FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE Title = 'CompanySize' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- END
- END
- RETURN
- END
- END TRY
- BEGIN CATCH
- ROLLBACK TRANSACTION
- ---检查是否已经建立临时表,已经建立则删除
- DECLARE @para VARCHAR(MAX)
- SET @para = '@dcJobTypeID=' + ISNULL(@dcJobTypeID, '') + '|' +
- '@dcRegionID=' + ISNULL(@dcRegionID, '') + '|' +
- '@dcIndustryID=' + ISNULL(@dcIndustryID, '') + '|' +
- '@EmployType=' + ISNULL(@EmployType, '') + '|' +
- '@KeyWord=' + ISNULL(@KeyWord, '') + '|' +
- '@ORDER=' + ISNULL(@ORDER, '') + '|' +
- '@SessionID=' + ISNULL(@SessionID, '') + '|' +
- '@Welfare=' + ISNULL(@Welfare, '')
- INSERT INTO ErrorLog
- SELECT 'm1 ' + ISNULL(error_Message(), ' no msg')+ ' para=' + ISNULL(@Para, 'no para ') + ISNULL(@SQL, ' no sql'), error_number(), error_line(), GETDATE()
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblJobBySearchSelect2] Script Date: 2018/12/13 19:07:47 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblJobBySearchSelect2]
- (
- @dcJobTypeID VARCHAR(100), --职位类别
- @dcRegionID VARCHAR(100), --求职地区
- @dcIndustryID VARCHAR(100), --求职行业
- @dcSalaryID TINYINT, --月薪
- @IsNegotiable BIT, --1允许面议,不面议
- @MinExperience TINYINT, --工作经验,100为未选择
- @dcEducationID TINYINT, --最低学历
- @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习,
- @KeyWord NVARCHAR(50), --关键词
- @KeyType TINYINT, --搜索类别,0无;1-全文;2-职位;3-公司
- @ORDER VARCHAR(4), --显示顺序,没有用
- @RefreshNo INT, --1, 1天内;2, 3天内;3,一周内;4,15天内;5,一个月内;6超过一个月
- @Type INT, --1:主动搜索 点击搜索按钮 10分钟,翻页60分钟有效;0:翻页搜索,不刷新
- @PageNumber INT, --翻页页码
- @SessionID varchar(50), --10
- @CompanySizeID VARCHAR(1), --企业规模
- @IsOnline INT,
- @Welfare VARCHAR(50) --
- )
- AS
- --return @SessionId = 10
- SET NOCOUNT ON
- INSERT INTO SearchIp(Ip, Source) SELECT @SessionId, 'm'
- IF EXISTS(SELECT 'x' FROM RefuseIp WITH(NOLOCK) WHERE CHARINDEX(Ip,@SessionId) > 0)
- RETURN
- SET @SessionId = 10
- SET @KeyType = 0
- BEGIN TRY
- DECLARE @ReuseNumber AS INT, @dcProvinceId VARCHAR(2), @Order2 VARCHAR(100)
- ----给null值变量赋默认值
- IF NOT LEFT(@dcRegionID,1) = 'p'
- SELECT @dcRegionID = RTRIM(dbo.FormatIDS(@dcRegionID))
- SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
- @dcIndustryID = RTRIM(dbo.FormatIDS(@dcIndustryID)),
- @dcSalaryID = ISNULL(@dcSalaryID, 0),
- @IsNegotiable = ISNULL(@IsNegotiable, 0),
- @MinExperience = ISNULL(@MinExperience, 100),
- @dcEducationID = ISNULL(@dcEducationID, 0),
- @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END,
- @CompanySizeID = ISNULL(@CompanySizeID, '0'),
- @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, '')),
- @ORDER = ISNULL(@Order, ''),
- @Type = ISNULL(@Type, 0),
- @PageNumber = ISNULL(@PageNumber, 0),
- @Welfare = RTRIM(dbo.FormatIDS(@Welfare)),
- @IsOnline = ISNULL(@IsOnline, 0),
- @Order2 = ' ORDER BY a.RefreshDate DESC, a.SecondID DESC'
- IF @dcSalaryID = 0
- SET @IsNegotiable = 0
- IF @Order LIKE 'p=%'
- SET @dcProvinceId = REPLACE(@Order, 'p=', '')
- ELSE
- SET @dcProvinceId = 0
- --@RefreshNo = 0选择全部数据,不限制时间
- SET @RefreshNo = 0
- IF(@KeyWord = '' AND ISNULL(@dcJobTypeID, '') = '' AND ISNULL(@dcRegionID, '') = '' AND ISNULL(@dcIndustryID, '') = '')
- RETURN
- --如果关键词不为空 查询关键词对应的搜索类型 max 2012-12-25
-
- IF RIGHT(@KeyWord, 2) = '公司'
- SET @KeyWord = LEFT(@KeyWord, LEN(@KeyWord) - 2)
-
- IF RIGHT(@dcJobTypeID, 1) = ','
- SET @dcJobTypeID = LEFT(@dcJobTypeID, LEN(@dcJobTypeID) - 1)
- IF RIGHT(@dcRegionID, 1) = ','
- SET @dcRegionID = LEFT(@dcRegionID, LEN(@dcRegionID) - 1)
- IF RIGHT(@dcIndustryID, 1) = ','
- SET @dcIndustryID = LEFT(@dcIndustryID, LEN(@dcIndustryID) - 1)
- DECLARE @paSearchConditionID AS INT,
- @MinId AS INT,
- @PageSize AS TINYINT,
- @TableID AS TINYINT
- SELECT @paSearchConditionID = 0, @PageSize = 30
- ----搜索1分钟前的数据
- SELECT TOP 1 @paSearchConditionID = ID,
- @ReuseNumber = ReuseNumber
- FROM SearchDB..paSearchCondition WITH(NOLOCK)
- WHERE JobType=@dcJobTypeID AND IsOnline = @IsOnline
- AND JobPlace=@dcRegionID AND Industry=@dcIndustryID AND Education=@dcEducationID
- AND Experience=@MinExperience AND Salary=@dcSalaryID AND IsNegotiable=@IsNegotiable
- AND EmployType=@EmployType AND ISNULL(KeyWord, '') = @KeyWord AND KeyType = @KeyType
- AND CompanySizeID = @CompanySizeID AND Welfare = @Welfare AND IsDelete = 0
- AND LogTime > DATEADD(MINUTE, -1, GETDATE()) AND ReuseNumber > 0
- AND RefreshNo = 0 AND ISNULL(dcProvinceId, 0) = @dcProvinceId
- ORDER BY ID DESC
- IF @ReuseNumber = 0
- BEGIN
- SELECT TOP 1 @paSearchConditionID = ID
- FROM SearchDB..paSearchCondition WITH(NOLOCK)
- WHERE JobType=@dcJobTypeID AND IsOnline = @IsOnline
- AND JobPlace=@dcRegionID AND Industry=@dcIndustryID AND Education=@dcEducationID
- AND Experience=@MinExperience AND Salary=@dcSalaryID AND IsNegotiable=@IsNegotiable
- AND EmployType=@EmployType AND ISNULL(KeyWord, '') = @KeyWord AND KeyType=@KeyType
- AND CompanySizeID = @CompanySizeID AND Welfare = @Welfare AND ReuseNumber > 0
- AND ReuseNumber > 0 AND LogTime > DATEADD(MINUTE, -2, GETDATE())
- AND RefreshNo = 0 AND ISNULL(dcProvinceId, 0) = @dcProvinceId
- ORDER BY ID DESC
- END
- IF ISNULL(@paSearchConditionID, 0) = 0
- BEGIN
- SET @Type =1
- GOTO SelectReset --无数据,重新搜索
- END
- ELSE
- BEGIN
- SELECT @TableID = @paSearchConditionID % 4
- GOTO GetRecordSet --从临时结果中提取数据
- END
- SelectReset:
- --从job中搜索数据
- BEGIN TRAN
- DECLARE @SQL AS VARCHAR(8000)
- DECLARE @WHERE AS VARCHAR(8000)
- DECLARE @FROM AS VARCHAR(1000)
- ----记录查询条件
- INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
- Salary, IsNegotiable, EmployType, CompanySizeID, KeyWord, KeyType, ReuseNumber, Welfare, IsOnline, dcProvinceId)
- VALUES(@SessionId, GETDATE(), @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcEducationID, @MinExperience,
- @dcSalaryID, @IsNegotiable, @EmployType, @CompanySizeID, @KeyWord, @KeyType, 0, @Welfare, @IsOnline, @dcProvinceId)
- SET @paSearchConditionID = @@IDENTITY
- SELECT @TableID = @paSearchConditionID % 4
- ------生成职位类别的表变量,因为职位类别有包含(父子)关系
- DECLARE @T_JobPlace AS TABLE(ID INT)
- DECLARE @T_JobType AS TABLE(ID INT)
- DECLARE @JobPlaceLen AS INT, @JobTypeLen AS INT
- IF CHARINDEX(',', @dcJobTypeID) > 0
- SET @JobTypeLen = -1
- ELSE
- SET @JobTypeLen = LEN(@dcJobTypeID)
- DECLARE @JobType AS VARCHAR(3000), @JobPlace AS VARCHAR(2000), @ValidJobNumber AS INT
- SELECT @JobPlace = '', @JobType=''
- ----生成工作地点的表变量
- IF LEN(@dcRegionID) > 0
- BEGIN
- IF LEFT(@dcRegionID,1) = 'p'
- BEGIN
- DECLARE @Degree AS DECIMAL(8,5),@LBLng AS DECIMAL(8,5),@LBLat AS DECIMAL(8,5),
- @RTLng AS DECIMAL(8,5),@RTLat AS DECIMAL(8,5),@Lat AS DECIMAL(8,5),@Lng AS DECIMAL(8,5)
-
- SELECT @Lat = Lat,@Lng = Lng FROM dcMapPlace WITH(NOLOCK) WHERE ID = RIGHT(@dcRegionID,LEN(@dcRegionID)-1)
- IF @dcRegionID LIKE '3201%'
- SET @Degree = 1000 / 100000.0
- ELSE
- SET @Degree = 2000 / 100000.0
- SET @LBLng = @Lng - @Degree
- SET @LBLat = @Lat - @Degree
- SET @RTLng = @Lng + @Degree
- SET @RTLat = @Lat + @Degree
- SET @JobPlace = 'a.Lng BETWEEN ' + CONVERT(VARCHAR,@LBLng) + ' AND ' + CONVERT(VARCHAR,@RTLng) + '
- AND a.Lat BETWEEN ' + CONVERT(VARCHAR,@LBLat) + ' AND ' + CONVERT(VARCHAR,@RTLat) + '
- AND (a.Lng-' + CONVERT(VARCHAR,@Lng) + ')*(a.Lng-' + CONVERT(VARCHAR,@Lng) + ')+
- (a.Lat-' + CONVERT(VARCHAR,@Lat) + ')*(a.Lat-' + CONVERT(VARCHAR,@Lat) + ')<' + CONVERT(VARCHAR,@Degree*@Degree)
- SELECT @JobPlaceLen = 8
- END
- ELSE
- BEGIN
- INSERT INTO @T_JobPlace
- SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
- SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
- IF LEN(@JobPlace) > 0
- SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
- IF (SELECT COUNT(*) FROM @T_JobPlace) > 1
- SET @JobPlaceLen = -1
- ELSE
- SET @JobPlaceLen = LEN(@dcRegionID)
- END
- END
- ELSE
- SELECT @JobPlaceLen = 0
- ----生成求聘职位的表变量
- IF LEN(@dcJobTypeID) > 0
- BEGIN
- DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
- INSERT INTO @T_Temp
- SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
- INSERT INTO @T_JobType
- SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
- WHERE ParentId IN(SELECT ID FROM @T_TEMP)
- OR ParentId2 in(SELECT ID FROM @T_TEMP)
- OR ID IN(SELECT ID FROM @T_TEMP)
- ----生成in字符串
- SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
- IF RIGHT(@JobType, 1) = ','
- SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
- END
- ----建立临时表
- CREATE TABLE #Job(
- RowID INT IDENTITY(1, 1),
- ID INT NOT NULL,
- cpMainId INT,
- dcJobTypeID SMALLINT NOT NULL,
- dcJobTypeIDMinor SMALLINT NULL,
- dcSalaryID TINYINT NOT NULL,
- dcRegionID VARCHAR(6) NULL,
- dcEducationID TINYINT NOT NULL,
- MinExperience TINYINT NOT NULL,
- RefreshDate SMALLDATETIME NULL,
- EmployType TINYINT NULL,
- dcCompanySizeID SMALLINT NULL
- )
- CREATE TABLE #FullText(
- Priority INT,
- JobId INT NOT NULL
- )
- ------刷新时间,根据刷新时间编号计算
- ----生成插入临时表的Sql语句
- SET @SQL='
- INSERT INTO #Job
- SELECT a.ID, a.cpMainId, a.dcJobTypeID,
- a.dcJobTypeIDMinor, a.dcSalaryID,
- a.dcRegionID, a.dcEducationID, a.MinExperience,
- a.IssueDate,a.EmployType,b.dcCompanySizeID'
- SET @FROM = '
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
- ----职位有效,单位新有效
- IF LEN(@dcIndustryID) > 0
- SET @WHERE = '
- WHERE b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @dcIndustryID + '))
- AND a.Valid = 1
- AND b.Valid = 1'
- ELSE
- SET @WHERE = '
- WHERE a.Valid = 1
- AND b.Valid = 1'
-
- IF LEN(@dcProvinceId) > 1
- SET @WHere = @Where + ' AND b.dcProvinceId = ' + @dcProvinceId
- ----职位类别
- IF LEN(@JobType) > 0
- SET @WHERE = @WHERE + '
- AND (a.dcJobTypeID IN(' + @JobType +')
- OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
- IF LEN(@JobPlace) > 0
- SET @WHERE = @WHERE + '
- AND (' + @JobPlace + ')'
- IF @dcSalaryID > 0
- BEGIN
- IF @dcSalaryID < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
- BEGIN
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID IN(' + LTRIM(STR(@dcSalaryID)) + ',' + LTRIM(STR(@dcSalaryID + 1))
- IF @IsNegotiable = 1 --包括面议
- SET @WHERE = @WHERE + ', 100'
- SET @WHERE = @WHERE + ')'
- END
- IF @dcSalaryID = 100 ----从筛选结果中点击面议,值是100
- BEGIN
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID = 100'
- END
- IF @dcSalaryID BETWEEN 101 AND 106 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID <= ' + LTRIM(STR(@dcSalaryID-99)) + ' AND a.dcSalaryIDMax > ' + LTRIM(STR(@dcSalaryID-100))
- IF @dcSalaryID > 106 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
- SET @WHERE = @WHERE + '
- AND a.dcSalaryID <= ' + LTRIM(STR(@dcSalaryID - 100)) + ' AND a.dcSalaryIDMax > ' + LTRIM(STR(@dcSalaryID-100))
- END
- ----工作经验要求
- IF @MinExperience < 100
- SET @WHERE = @WHERE + '
- AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
- ----学历要求
- ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
- IF @dcEducationID > 0
- IF @dcEducationID = 2
- SET @WHERE = @WHERE + '
- AND a.dcEducationID IN(2, 3, 4)'
- ELSE
- SET @WHERE = @WHERE + '
- AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
- ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
- IF LEN(@EmployType) > 0
- SET @WHERE = @WHERE + '
- AND a.EmployType IN (' + @EmployType + ')'
- IF @CompanySizeID BETWEEN 1 AND 6
- SET @WHERE = @WHERE + '
- AND b.dcCompanySizeID = ' + LTRIM(STR(@CompanySizeID))
- IF LEN(@Welfare) > 0
- SET @WHERE = @WHERE + '
- AND a.Welfare' + REPLACE(@Welfare, ',', ' = 1 AND a.Welfare') + ' = 1'
- IF @IsOnline = 1
- SET @WHERE = @WHERE + '
- AND a.caMainId IN(SELECT caMainId FROM caOnline WITH(NOLOCK) WHERE IsOnline = 1)'
- IF LEN(@KeyWord) > 0 ----使用全文搜索job和cpmain2个表,经过测试发现union最快
- BEGIN
- IF EXISTS(SELECT TOP 1 'x' FROM cpMainPublish WITH(NOLOCK) WHERE Name = @KeyWord)
- BEGIN
- SET @WHERE = @WHERE + '
- AND b.Name = ''' + @KeyWord + ''''
- SET @SQL = @SQL + @FROM + @WHERE
- END
- ELSE
- BEGIN
- DECLARE @KeyWordTemp NVARCHAR(50)
- SET @KeyWordTemp = REPLACE(@KeyWord, ' ', '%')
- IF LEN(@KeyWordTemp) > 1
- BEGIN
- IF @dcProvinceId > 0
- BEGIN
- INSERT #FullText
- SELECT TOP 2000 2, b.ID
- FROM cpMainPublish a WITH(NOLOCK),
- JobPublish b WITH(NOLOCK)
- WHERE a.Id = b.cpMainId
- AND a.Name LIKE '%' + @KeyWordTemp + '%'
- AND a.dcProvinceId = @dcprovinceId
- ORDER BY b.RefreshDate DESC
- INSERT #FullText
- SELECT TOP 2000 1, b.ID
- FROM cpMainPublish a WITH(NOLOCK),
- JobPublish b WITH(NOLOCK)
- WHERE a.Id = b.cpMainId
- AND b.Name LIKE '%' + @KeyWordTemp + '%'
- AND a.dcProvinceId = @dcprovinceId
- ORDER BY b.RefreshDate DESC
- END
- ELSE
- BEGIN
- INSERT #FullText
- SELECT TOP 2000 2, b.ID
- FROM cpMainPublish a WITH(NOLOCK),
- JobPublish b WITH(NOLOCK)
- WHERE a.Id = b.cpMainId
- AND a.Name LIKE '%' + @KeyWordTemp + '%'
- ORDER BY b.RefreshDate DESC
- INSERT #FullText
- SELECT TOP 2000 1, b.ID
- FROM cpMainPublish a WITH(NOLOCK),
- JobPublish b WITH(NOLOCK)
- WHERE a.Id = b.cpMainId
- AND b.Name LIKE '%' + @KeyWordTemp + '%'
- ORDER BY b.RefreshDate DESC
- END
- END
- IF (SELECT COUNT(*) FROM #FullText) < 800
- BEGIN
- INSERT #FullText
- SELECT TOP 5000 3, [Key]
- FROM FREETEXTTABLE(cpMainJob, *, @KeyWord, 100000) AS KeyJob ORDER BY RANK DESC
- END
- DELETE a FROM #FullText a, #FullText b WHERE a.JobId = b.JobId AND a.Priority > b.Priority
- --------------------
- SELECT @FROM = @FROM + '
- INNER JOIN #FullText ON a.ID = #FullText.JobId',
- @ORDER2 = ' ORDER BY #FullText.Priority, a.RefreshDate DESC, a.SecondID DESC'
- SET @SQL = @SQL + @FROM + @WHERE
- END
- END
- ELSE
- SELECT @SQL = @SQL + @FROM + @WHERE
-
- SET @SQL = @SQL + @Order2
- --原来是ORDER BY a.IssueDate DESC, a.ID,Richard 2011年11月23日17:06分修改
- ----把符合条件的职位全部列出
- --PRINT @SQL
- EXEC(@SQL)
- SET @ValidJobNumber = @@ROWCOUNT
- ----记录查询结果总数
- UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@SQL WHERE ID=@paSearchConditionID
- IF LEN(@JobType) > 0 --IN(2, 4)
- UPDATE #Job SET dcJobTypeId = dcJobTypeIDMinor
- WHERE dcJobTypeID NOT IN(SELECT a FROM dbo.fnSplit(@JobType, ','))
- ----插入JobType数据
- DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
- DECLARE @sc AS TABLE (
- paSearchConditionID int,
- Title varchar(20),
- TitleID varchar(10),
- TitleValue int
- )
- DECLARE @sc2 AS TABLE (
- paSearchConditionID int,
- Title varchar(20),
- TitleID varchar(10),
- TitleValue int
- )
- IF (@TableID = 0)
- BEGIN
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- IF @JobTypeLen NOT IN(2, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- END
- IF @JobTypeLen NOT IN(0, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
- FROM @sc2 WHERE LEN(TitleId) = 4
- END
- IF @JobTypeLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
- DELETE @sc
- DELETE @sc2
- --------
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- IF @JobPlaceLen IN(-1, 0)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- IF @JobPlaceLen IN(-1, 2)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
- IF @JobPlaceLen IN(-1, 4)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
- FROM @sc2 WHERE LEN(TitleID) = 6
- IF @JobPlaceLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
- ELSE
- DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
- ----------------
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
- FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
- WHERE a.cpMainId = b.cpMainId
- GROUP BY b.dcIndustryId ORDER BY b.dcIndustryId
- INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_0 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- ELSE IF (@TableId = 1)
- BEGIN
- ----------------------------jobtype
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- IF @JobTypeLen NOT IN(2, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- END
- IF @JobTypeLen NOT IN(0, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
- FROM @sc2 WHERE LEN(TitleId) = 4
- END
- IF @JobTypeLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
- DELETE @sc
- DELETE @sc2
- --------------------------region
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- IF @JobPlaceLen IN(-1, 0)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- IF @JobPlaceLen IN(-1, 2)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
- IF @JobPlaceLen IN(-1, 4)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
- FROM @sc2 WHERE LEN(TitleID) = 6
- IF @JobPlaceLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
- ELSE
- DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
- ----------------------------
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
-
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
-
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
- FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
- WHERE a.cpMainId = b.cpMainId
- GROUP BY dcIndustryID ORDER BY dcIndustryID
- INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_1 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- ELSE IF (@TableId = 2)
- BEGIN
- ----------------------------jobtype
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- IF @JobTypeLen NOT IN(2, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- END
- IF @JobTypeLen NOT IN(0, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
- FROM @sc2 WHERE LEN(TitleId) = 4
- END
- IF @JobTypeLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
- DELETE @sc
- DELETE @sc2
- --------------------------region
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- IF @JobPlaceLen IN(-1, 0)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- IF @JobPlaceLen IN(-1, 2)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
- IF @JobPlaceLen IN(-1, 4)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
- FROM @sc2 WHERE LEN(TitleID) = 6
- IF @JobPlaceLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
- ELSE
- DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
- ----------------------------
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
-
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
- FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
- WHERE a.cpMainId = b.cpMainId
- GROUP BY dcIndustryID ORDER BY dcIndustryID
- INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_2 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- ELSE IF (@TableId = 3)
- BEGIN
- ----------------------------jobtype
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- IF @JobTypeLen NOT IN(2, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- END
- IF @JobTypeLen NOT IN(0, 4)
- BEGIN
- INSERT INTO @Sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue
- FROM @sc2 WHERE LEN(TitleId) = 4
- END
- IF @JobTypeLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT a FROM dbo.fnSplit(@dcJobTypeID, ','))
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', TitleId, TitleValue FROM @sc
- DELETE @sc
- DELETE @sc2
- --------------------------region
- INSERT INTO @sc2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- IF @JobPlaceLen IN(-1, 0)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 GROUP BY LEFT(TitleID, 2)
- IF @JobPlaceLen IN(-1, 2)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM @sc2 WHERE LEN(TitleID) >= 4 GROUP BY LEFT(TitleID, 4)
- IF @JobPlaceLen IN(-1, 4)
- INSERT INTO @sc(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', TitleID, TitleValue
- FROM @sc2 WHERE LEN(TitleID) = 6
- IF @JobPlaceLen = -1
- DELETE @sc WHERE TitleID NOT IN(SELECT ID FROM @T_JobPlace)
- ELSE
- DELETE @sc WHERE LEN(TitleID) <> @JobPlaceLen + 2
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT paSearchConditionID, Title, TitleId, TitleValue FROM @sc
- ----------------------------
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Job WITH(NOLOCK)
- GROUP BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
- ORDER BY CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END
-
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'EmployType', EmployType, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'CompanySize', dcCompanySizeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Industry', dcIndustryID, COUNT(*)
- FROM #Job a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)
- WHERE a.cpMainId = b.cpMainId
- GROUP BY dcIndustryID ORDER BY dcIndustryID
- INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID, a.JobId, 1
- FROM SearchJobTop a WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE b.ID = a.JobId ORDER BY a.OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_3 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- DROP TABLE #Job
- --PRINT 'DROP #JOB ' + CONVERT(VARCHAR(30), GETDATE(), 121)
- COMMIT
- --GOTO GetRecordSet
- GetRecordSet:
- BEGIN
- DECLARE @AllJobCount AS INT
- ----返回查询数量
- SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
- SELECT @AllJobCount = ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
- UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
- ----返回20行查询结果
- IF (@TableID = 0)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
- b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
- ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
- e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber,
- f.Description EducationName,g.Description ExperienceName,
- h.DescriptionCp dcSalary,i.DescriptionCp dcSalaryMax
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
- INNER JOIN SearchDB..paSearchJobID_0 c WITH(NOLOCK) ON a.id = c.JobID
- INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
- LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
- INNER JOIN dcEducation f WITH(NOLOCK) ON f.ID = a.dcEducationID
- INNER JOIN dcOthers g WITH(NOLOCK) ON g.DetailID = a.MinExperience AND g.Category='职位要求工作经验'
- INNER JOIN dcSalary h WITH(NOLOCK) ON h.ID = a.dcSalaryID
- INNER JOIN dcSalary i WITH(NOLOCK) ON i.ID = a.dcSalaryIDMax
- WHERE paSearchConditionID=@paSearchConditionID
- AND c.ID >= @MinId
- ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 1)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
- b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
- ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
- e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber,
- f.Description EducationName,g.Description ExperienceName,
- h.DescriptionCp dcSalary,i.DescriptionCp dcSalaryMax
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
- INNER JOIN SearchDB..paSearchJobID_1 c WITH(NOLOCK) ON a.id = c.JobID
- INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
- LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
- INNER JOIN dcEducation f WITH(NOLOCK) ON f.ID = a.dcEducationID
- INNER JOIN dcOthers g WITH(NOLOCK) ON g.DetailID = a.MinExperience AND g.Category='职位要求工作经验'
- INNER JOIN dcSalary h WITH(NOLOCK) ON h.ID = a.dcSalaryID
- INNER JOIN dcSalary i WITH(NOLOCK) ON i.ID = a.dcSalaryIDMax
- WHERE paSearchConditionID=@paSearchConditionID
- AND c.ID >= @MinId
- ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 2)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
- b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
- ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
- e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber,
- f.Description EducationName,g.Description ExperienceName,
- h.DescriptionCp dcSalary,i.DescriptionCp dcSalaryMax
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
- INNER JOIN SearchDB..paSearchJobID_2 c WITH(NOLOCK) ON a.id = c.JobID
- INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
- LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
- INNER JOIN dcEducation f WITH(NOLOCK) ON f.ID = a.dcEducationID
- INNER JOIN dcOthers g WITH(NOLOCK) ON g.DetailID = a.MinExperience AND g.Category='职位要求工作经验'
- INNER JOIN dcSalary h WITH(NOLOCK) ON h.ID = a.dcSalaryID
- INNER JOIN dcSalary i WITH(NOLOCK) ON i.ID = a.dcSalaryIDMax
- WHERE paSearchConditionID=@paSearchConditionID
- AND c.ID >= @MinId
- ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 3)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP 30 a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.MinExperience ,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.dcSalaryIDMax, a.EmployType,
- a.dcRegionID, a.dcEducationID, a.RefreshDate,a.SecondId EnJobID,
- b.SecondId EnCpMainID, b.Name as cpName, b.HasLicence, c.IsTop,
- ISNULL(d.IsOnline, 0) IsOnline, d.ViPlanId, d.InterviewDate,
- e.FullName Region, b.LogoFile LogoUrl,@AllJobCount JobNumber,
- f.Description EducationName,g.Description ExperienceName,
- h.DescriptionCp dcSalary,i.DescriptionCp dcSalaryMax
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
- INNER JOIN SearchDB..paSearchJobID_3 c WITH(NOLOCK) ON a.id = c.JobID
- INNER JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.Id
- LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
- INNER JOIN dcEducation f WITH(NOLOCK) ON f.ID = a.dcEducationID
- INNER JOIN dcOthers g WITH(NOLOCK) ON g.DetailID = a.MinExperience AND g.Category='职位要求工作经验'
- INNER JOIN dcSalary h WITH(NOLOCK) ON h.ID = a.dcSalaryID
- INNER JOIN dcSalary i WITH(NOLOCK) ON i.ID = a.dcSalaryIDMax
- WHERE paSearchConditionID=@paSearchConditionID
- AND c.ID >= @MinId
- ORDER BY c.ID, a.ID DESC
- END
- --RICHARD 2011-7-23 16:51分修改
- ----返回统计数量
- IF @Type=1
- BEGIN
- DECLARE @RegionCount AS INT
- SELECT @RegionCount = -1
- IF CHARINDEX(',', @dcRegionID) = 0 AND LEN(@dcRegionID) > 0
- BEGIN
- IF NOT LEFT(@dcRegionID,1) = 'p'
- SELECT @RegionCount = COUNT(*) FROM dcRegion WHERE ParentID = @dcRegionID
- END
- IF (@TableID = 0)
- BEGIN
- 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)
- IF @RegionCount = 0
- SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
- ELSE
- 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)
-
- 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)
- 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)
- SELECT * FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- 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)
- 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)
- END
- IF (@TableID = 1)
- BEGIN
- 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)
- IF @RegionCount = 0
- SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
- ELSE
- 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)
-
- 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)
- 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)
- SELECT * FROM SearchDB..paSearchCount_1 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- 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)
- 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)
- END
- IF (@TableID = 2)
- BEGIN
- 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)
- IF @RegionCount = 0
- SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
- ELSE
- 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)
-
- 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)
- 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)
- SELECT * FROM SearchDB..paSearchCount_2 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- 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)
- 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)
- END
- IF (@TableID = 3)
- BEGIN
- 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)
- IF @RegionCount = 0
- SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionID = @dcRegionID
- ELSE
- 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)
-
- 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)
- 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)
- SELECT * FROM SearchDB..paSearchCount_3 a WITH(NOLOCK) WHERE Title = 'Salary' AND paSearchConditionID=@paSearchConditionID ORDER BY Title, CONVERT(INT, TitleID)
- 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)
- 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)
- END
- END
- RETURN
- END
- END TRY
- BEGIN CATCH
- ---检查是否已经建立临时表,已经建立则删除
- PRINT 'error'
- PRINT error_Message()
- PRINT error_number()
- PRINT error_line()
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblJobBySearchSelectSean] Script Date: 2018/12/13 19:07:48 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblJobBySearchSelectSean]
- (
- @dcJobTypeID VARCHAR(100), --职位类别
- @dcRegionID VARCHAR(100), --求职地区
- @dcIndustryID VARCHAR(100), --求职行业
- @KeyWord NVARCHAR(50), --关键词
- @PageNum INT,
- @PageSize INT
- )
- AS
- --return
- SET NOCOUNT ON
- BEGIN TRY
- DECLARE @KeyWordTemp AS NVARCHAR(50),
- @dcSalaryID AS TINYINT,
- @IsNegotiable AS BIT,
- @MinExperience AS TINYINT,
- @dcEducationID AS TINYINT,
- @EmployType AS VARCHAR(10),
- @KeyType AS TINYINT,
- @SessionID AS INT,
- @ReuseNumber INT,
- @ORDER VARCHAR(100)
-
- IF @dcJobTypeID = '0'
- SET @dcJobTypeID = ''
- IF @dcRegionID = '0'
- SET @dcRegionID = ''
- IF @dcIndustryID = '0'
- SET @dcIndustryID = ''
- SET @KeyType = 1
- ----给null值变量赋默认值
- SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
- @dcRegionID = RTRIM(dbo.FormatIDS(@dcRegionID)),
- @dcIndustryID = RTRIM(dbo.FormatIDS(@dcIndustryID)),
- @dcSalaryID = ISNULL(@dcSalaryID, 0),
- @IsNegotiable = ISNULL(@IsNegotiable, 0),
- @MinExperience = ISNULL(@MinExperience, 100),
- @dcEducationID = ISNULL(@dcEducationID, 0),
- @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END,
- @KeyWord = REPLACE(dbo.SafeSQL(ISNULL(@KeyWord, '')), '''', ''),
- @KeyType = CASE @KeyWord WHEN NULL THEN 0 ELSE @KeyType END,
- @PageNum = ISNULL(@PageNum, 0),
- @ORDER = ' ORDER BY a.RefreshDate DESC, a.ID'
- IF (@KeyWord IS NOT NULL)
- SET @KeyWordTemp = @KeyWord
- IF LEN(@KeyWordTemp) > 2
- SET @KeyWordTemp = REPLACE(@KeyWordTemp, '公司', '')
- IF(@KeyType = 0 AND ISNULL(@dcJobTypeID, '') = '' AND ISNULL(@dcRegionID, '') = '' AND ISNULL(@dcIndustryID, '') = '')
- RETURN
- IF RIGHT(@dcJobTypeID, 1) = ','
- SET @dcJobTypeID = LEFT(@dcJobTypeID, LEN(@dcJobTypeID) - 1)
- IF RIGHT(@dcRegionID, 1) = ','
- SET @dcRegionID = LEFT(@dcRegionID, LEN(@dcRegionID) - 1)
- IF RIGHT(@dcIndustryID, 1) = ','
- SET @dcIndustryID = LEFT(@dcIndustryID, LEN(@dcIndustryID) - 1)
- DECLARE @paSearchConditionID AS INT,
- @MinId AS INT,
- @TableID AS TINYINT
- SELECT @paSearchConditionID = 0, @SessionID = ISNULL(@SessionID, 9902) --每页的行数
-
- ----搜索1分钟前的数据
- SELECT TOP 1 @paSearchConditionID = ID,
- @ReuseNumber = ReuseNumber
- FROM SearchDB..paSearchCondition WITH(NOLOCK)
- WHERE JobType=@dcJobTypeID
- AND JobPlace=@dcRegionID AND Industry=@dcIndustryID AND Education=@dcEducationID
- AND Experience=@MinExperience AND Salary=@dcSalaryID AND IsNegotiable=@IsNegotiable
- AND EmployType=@EmployType AND KeyWord=@KeyWord AND KeyType=@KeyType
- AND CompanySizeID IS NULL
- AND Welfare IS NULL
- AND IsDelete = 0
- ORDER BY ID DESC
- IF @ReuseNumber = 0
- BEGIN
- SELECT TOP 1 @paSearchConditionID = ID
- FROM SearchDB..paSearchCondition WITH(NOLOCK)
- WHERE SessionID=@SessionID AND JobType=@dcJobTypeID
- AND JobPlace=@dcRegionID AND Industry=@dcIndustryID AND Education=@dcEducationID
- AND Experience=@MinExperience AND Salary=@dcSalaryID AND IsNegotiable=@IsNegotiable
- AND EmployType=@EmployType AND KeyWord=@KeyWord AND KeyType=@KeyType
- AND CompanySizeID IS NULL
- AND Welfare IS NULL
- AND ReuseNumber > 0
- ORDER BY ID DESC
- END
- IF ISNULL(@paSearchConditionID, 0) = 0
- BEGIN
- GOTO SelectReset --无数据,重新搜索
- END
- ELSE
- BEGIN
- SELECT @TableID = @paSearchConditionID % 4
- GOTO GetRecordSet --从临时结果中提取数据
- END
- SelectReset: --从job中搜索数据
- BEGIN TRAN
- DECLARE @SQL AS VARCHAR(8000)
- DECLARE @WHERE AS VARCHAR(8000)
- DECLARE @FROM AS VARCHAR(1000)
- ----记录查询条件
- INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
- Salary, IsNegotiable, EmployType, KeyWord, KeyType, ReuseNumber, Welfare)
- VALUES(
- ISNULL(@SessionId, 9902), GETDATE(), @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcEducationID, @MinExperience,
- @dcSalaryID, @IsNegotiable, @EmployType, @KeyWord, @KeyType, 0, '')
- SET @paSearchConditionID = @@IDENTITY
- SELECT @TableID = @paSearchConditionID % 4
- ------生成职位类别的表变量,因为职位类别有包含(父子)关系
- DECLARE @T_JobPlace AS TABLE(ID INT)
- DECLARE @T_JobType AS TABLE(ID INT)
- DECLARE @JobType AS VARCHAR(3000)
- DECLARE @JobPlace AS VARCHAR(2000)
- DECLARE @ValidJobNumber AS INT
- SET @JobPlace = ''
- SET @JobType=''
- ----生成工作地点的表变量
- IF LEN(@dcRegionID) > 0
- BEGIN
- INSERT INTO @T_JobPlace
- SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
- SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
- IF LEN(@JobPlace) > 0
- SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
- END
- ----生成求聘职位的表变量
- IF LEN(@dcJobTypeID) > 0
- BEGIN
- DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
- INSERT INTO @T_Temp
- SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
- INSERT INTO @T_JobType
- SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
- WHERE ParentId IN(SELECT ID FROM @T_TEMP)
- OR ParentId2 in(SELECT ID FROM @T_TEMP)
- OR ID IN(SELECT ID FROM @T_TEMP)
- ----生成in字符串
- SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
- IF RIGHT(@JobType, 1) = ','
- SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
- END
- ----建立临时表
- CREATE TABLE #Job(
- RowID INT IDENTITY(1, 1),
- ID INT NOT NULL,
- dcJobTypeID SMALLINT NOT NULL,
- dcJobTypeIDMinor SMALLINT NULL,
- dcSalaryID TINYINT NOT NULL,
- dcRegionID VARCHAR(6) NULL,
- dcEducationID TINYINT NOT NULL,
- MinExperience TINYINT NOT NULL,
- RefreshDate SMALLDATETIME NULL
- )
- CREATE TABLE #FullText(
- Priority INT,
- JobId INT NOT NULL
- )
- ------刷新时间,根据刷新时间编号计算
- ----生成插入临时表的Sql语句
- SET @SQL='
- INSERT INTO #Job
- SELECT a.ID, a.dcJobTypeID,
- a.dcJobTypeIDMinor, a.dcSalaryID,
- a.dcRegionID, a.dcEducationID, a.MinExperience,
- a.IssueDate'
- SET @FROM = '
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
- ----职位有效,单位新有效
- IF LEN(@dcIndustryID) > 0
- SET @WHERE = '
- WHERE b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @dcIndustryID + '))
- AND a.Valid = 1
- AND b.Valid = 1'
- ELSE
- SET @WHERE = '
- WHERE a.Valid = 1
- AND b.Valid = 1'
- ----需要增加全文索引的关键字查询
- IF @KeyWord LIKE '% %'
- BEGIN
- SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
- SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
- SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
- SET @KeyWord = '"' + REPLACE(@KeyWord, ' ', '" OR "') + '"'
- END
- IF @KeyWordTemp LIKE '% %'
- BEGIN
- SET @KeyWordTemp = REPLACE(@KeyWordTemp, ' ', ' ')
- SET @KeyWordTemp = REPLACE(@KeyWordTemp, ' ', ' ')
- SET @KeyWordTemp = REPLACE(@KeyWordTemp, ' ', ' ')
- SET @KeyWordTemp = '"' + REPLACE(@KeyWordTemp, ' ', '" OR "') + '"'
- END
- ----职位类别
- IF LEN(@dcJobTypeID) > 0
- SET @WHERE = @WHERE + '
- AND (a.dcJobTypeID IN(' + @JobType +')
- OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
- IF LEN(@JobPlace) > 0
- SET @WHERE = @WHERE + '
- AND (' + @JobPlace + ')'
- IF LEN(@KeyWord) > 0 AND @KeyType = 1 ----使用全文搜索job和cpmain2个表,经过测试发现union最快
- IF EXISTS(SELECT TOP 1 'x' FROM cpMainPublish WITH(NOLOCK) WHERE Name = @KeyWord)
- BEGIN
- SET @WHERE = @WHERE + '
- AND b.Name = ''' + @KeyWord + ''''
- SET @SQL = @SQL + @FROM + @WHERE
- END
- ELSE
- BEGIN
- INSERT #FullText
- SELECT 1, [Key]
- FROM CONTAINSTABLE(JobPublish, Name, @KeyWord, 100000) AS KeyJob
- INSERT #FullText
- SELECT 2, a.ID
- FROM JobPublish a WITH(NOLOCK),
- CONTAINSTABLE(cpMainPublish, Name, @KeyWord, 100000) AS b
- WHERE a.cpMainId = b.[Key]
- DELETE #FullText WHERE Priority = 2 AND JobId IN(SELECT JobId FROM #FullText WHERE Priority = 1)
- IF (SELECT COUNT(*) FROM #FullText) < 5000
- BEGIN
- INSERT #FullText
- SELECT 3, [Key]
- FROM CONTAINSTABLE(JobPublish, *, @KeyWord, 100000) AS KeyJob
- DELETE #FullText WHERE Priority = 3 AND JobId IN(SELECT JobId FROM #FullText WHERE Priority < 3)
- IF (SELECT COUNT(*) FROM #FullText) < 5000
- BEGIN
- INSERT #FullText
- SELECT 4, a.ID
- FROM JobPublish a WITH(NOLOCK),
- CONTAINSTABLE(cpMainPublish, *, @KeyWord, 100000) AS b
- WHERE a.cpMainId = b.[Key]
-
- DELETE #FullText WHERE Priority = 4 AND JobId IN(SELECT JobId FROM #FullText WHERE Priority < 4)
- END
- END
- --------------------
- SELECT @FROM = @FROM + '
- INNER JOIN #FullText ON a.ID = #FullText.JobId',
- @ORDER = ' ORDER BY #FullText.Priority, a.RefreshDate DESC, a.ID'
- SET @SQL = @SQL + @FROM + @WHERE
- END
- ELSE
- SET @SQL = @SQL + @FROM + @WHERE
-
- SET @SQL = @SQL + @ORDER
- EXEC(@SQL)
-
- SET @ValidJobNumber = @@ROWCOUNT
- ----记录查询结果总数
- UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@SQL WHERE ID=@paSearchConditionID
-
- ----插入JobType数据
- IF (@TableID = 0)
- BEGIN
- INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- END
- ELSE IF (@TableId = 1)
- BEGIN
- INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- END
- ELSE IF (@TableId = 2)
- BEGIN
- INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- END
- ELSE IF (@TableId = 3)
- BEGIN
- INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- END
- DROP TABLE #Job
- COMMIT
- GetRecordSet:
- BEGIN
- ----返回查询数量
- SELECT @ValidJobNumber=ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
- UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
- ----返回20行查询结果
- IF (@TableID = 0)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNum-1)*@PageSize
- SELECT TOP 20 @ValidJobNumber AS cnt, a.ID,a.Name AS JobName,a.RefreshDate,b.Name cpName,
- d.FullName Region, a.SecondId EnJobID, b.SecondId EnCpMainID
- FROM JOBPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_0 c WITH(NOLOCK),
- dcRegion d WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND a.dcRegionID=d.ID AND c.paSearchConditionID=@paSearchConditionID
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 1)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNum-1)*@PageSize
- SELECT TOP 20 @ValidJobNumber AS cnt, a.ID,a.Name AS JobName,a.RefreshDate,b.Name cpName,
- d.FullName Region, a.SecondId EnJobID, b.SecondId EnCpMainID
- FROM JOBPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_1 c WITH(NOLOCK),
- dcRegion d WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND a.dcRegionID=d.ID AND c.paSearchConditionID=@paSearchConditionID
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 2)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNum-1)*@PageSize
- SELECT TOP 20 @ValidJobNumber AS cnt, a.ID,a.Name AS JobName,a.RefreshDate,b.Name cpName,
- d.FullName Region, a.SecondId EnJobID, b.SecondId EnCpMainID
- FROM JOBPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_2 c WITH(NOLOCK),
- dcRegion d WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND a.dcRegionID=d.ID AND c.paSearchConditionID=@paSearchConditionID
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 3)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNum-1)*@PageSize
- SELECT TOP 20 @ValidJobNumber AS cnt, a.ID,a.Name AS JobName,a.RefreshDate,b.Name cpName,
- d.FullName Region, a.SecondId EnJobID, b.SecondId EnCpMainID
- FROM JOBPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_3 c WITH(NOLOCK),
- dcRegion d WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND a.dcRegionID=d.ID AND c.paSearchConditionID=@paSearchConditionID
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- RETURN
- END
- END TRY
- BEGIN CATCH
- ---检查是否已经建立临时表,已经建立则删除
- PRINT 'error'
- PRINT error_Message()
- PRINT error_number()
- PRINT error_line()
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblJobByWeixinSelect] Script Date: 2018/12/13 19:07:48 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblJobByWeixinSelect]
- (
- @FromUserName VARCHAR(50),
- @Type INT --0:订阅号关键词查询;10:服务号的关键词查询;11:服务号的周边职位
- )
- AS
- insert into proclog select 'mblJobByWeixinSelect', LTRIM(STR(@Type)) + ' ' + @FromUserName, getdate()
- SET NOCOUNT ON
- BEGIN TRY
- DECLARE @dcRegionID VARCHAR(4),@KeyWord NVARCHAR(20),
- @Lng DECIMAL(8,5),@Lat DECIMAL(8,5),@Distance INT,
- @KeyType TINYINT, @ValidJobNumber INT, @PageNumber SMALLINT
- IF @Type =11
- BEGIN
- SELECT @dcRegionID=dcRegionID,@KeyWord=KeyWord,
- @Lng=Lng,@Lat=Lat,@PageNumber=PageNumber
- FROM wxMessage WITH(NOLOCK)
- WHERE FromUserName=@FromUserName AND CONTENT='推荐职位'
- DELETE FROM wxMessage WHERE FromUserName=@FromUserName AND CONTENT <> '推荐职位'
- END
- ELSE
- BEGIN
- SELECT TOP 1 @dcRegionID=dcRegionID,@KeyWord=KeyWord,@PageNumber=PageNumber
- FROM wxMessage WITH(NOLOCK) WHERE FromUserName=@FromUserName
- ORDER BY ID DESC
- DELETE FROM wxMessage WHERE FromUserName=@FromUserName AND CONTENT='推荐职位'
- END
- IF @Type =11 OR @Type = 10
- BEGIN
- UPDATE wxMessage SET PageNumber = 2 WHERE FromUserName=@FromUserName
- END
- ELSE
- BEGIN
- UPDATE wxMessage SET PageNumber=PageNumber+1 WHERE FromUserName=@FromUserName
- END
- --UPDATE wxMessage SET PageNumber=PageNumber+1 WHERE FromUserName=@FromUserName
- SELECT @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, '')),
- @KeyType = 2,
- @Distance = 5000,
- @PageNumber = ISNULL(@PageNumber, 1),
- @dcRegionID = ISNULL(@dcRegionID, 0),
- @Lng = ISNULL(@Lng, 0),
- @Lat = ISNULL(@Lat, 0)
- IF @dcRegionID = 0 AND @Lng = 0 AND @Lat = 0
- RETURN
- DECLARE @paSearchConditionID AS INT,
- @MinId AS INT,
- @PageSize AS TINYINT,
- @TableID AS TINYINT
- IF @Type =11 OR @Type =10
- BEGIN
- SELECT @paSearchConditionID = 0, @PageSize = 5 --每页的行数
- END
- ELSE
- BEGIN
- SELECT @paSearchConditionID = 0, @PageSize = 8 --每页的行数
- END
- --SELECT @paSearchConditionID = 0, @PageSize = 8 --每页的行数
-
- ----搜索60分钟前的数据
- SELECT TOP 1 @paSearchConditionID=ID FROM SearchDB..paSearchCondition WITH(NOLOCK)
- WHERE JobType=''
- AND JobPlace=@dcRegionID AND ISNULL(Industry,'')='' AND ISNULL(Education,'')=''
- AND ISNULL(Experience,'')='' AND ISNULL(Salary,'')='' AND ISNULL(IsNegotiable,'')=''
- AND ISNULL(EmployType,'')='' AND KeyWord=@KeyWord AND KeyType=@KeyType
- AND ISNULL(CompanySizeID,'')='' AND Lng=@Lng AND Lat=@Lat
- ORDER BY ID DESC
- IF ISNULL(@paSearchConditionID, 0) = 0
- BEGIN
- GOTO SelectReset --无数据,重新搜索
- END
- ELSE
- BEGIN
- SELECT @TableID = @paSearchConditionID % 4
- GOTO GetRecordSet --从临时结果中提取数据
- END
- SelectReset:
- --从job中搜索数据
- BEGIN TRAN
- DECLARE @SQL AS VARCHAR(8000)
- DECLARE @WHERE AS VARCHAR(8000)
- DECLARE @FROM AS VARCHAR(1000)
- ----记录查询条件
- INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
- Salary, IsNegotiable, EmployType, CompanySizeID, KeyWord, KeyType, ReuseNumber, Lng, Lat, Distance)
- VALUES(1, GETDATE(), '', @dcRegionID, '', '', '', '', '', '', '', @KeyWord, @KeyType, 0, @Lng, @Lat, @Distance)
- SET @paSearchConditionID = @@IDENTITY
- SELECT @TableID = @paSearchConditionID % 4
- ----建立临时表
- CREATE TABLE #Job(
- RowID INT IDENTITY(1, 1),
- ID INT NOT NULL,
- dcJobTypeID SMALLINT NOT NULL,
- dcJobTypeIDMinor SMALLINT NULL,
- dcSalaryID TINYINT NOT NULL,
- dcRegionID VARCHAR(6) NULL,
- dcEducationID TINYINT NOT NULL,
- MinExperience TINYINT NOT NULL,
- RefreshDate SMALLDATETIME NULL
- )
- ------刷新时间,根据刷新时间编号计算
- ----生成插入临时表的Sql语句
- SET @SQL='
- INSERT INTO #Job
- SELECT a.ID, a.dcJobTypeID,
- a.dcJobTypeIDMinor, a.dcSalaryID,
- a.dcRegionID, a.dcEducationID, a.MinExperience,
- a.IssueDate'
- SET @FROM = '
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
- ----职位有效,单位新有效
- SET @WHERE = '
- WHERE a.Valid = 1
- AND b.Valid = 1'
- ----需要增加全文索引的关键字查询
- IF @KeyWord LIKE '% %'
- BEGIN
- SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
- SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
- SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
- SET @KeyWord = '"' + REPLACE(@KeyWord, ' ', '" OR "') + '"'
- END
- IF LEN(@KeyWord) > 0
- BEGIN
- IF @KeyType = 2
- SET @FROM = @FROM + '
- INNER JOIN CONTAINSTABLE(JobPublish, *, ''' + @KeyWord + ''', 1000000) AS KeyJob
- ON a.ID = KeyJob.[Key]'
- END
- ---地区
- IF @dcRegionID > 0
- SET @WHERE = @WHERE + '
- AND a.dcRegionID Like ''' + CONVERT(VARCHAR(6),@dcRegionID) + '%'''
- IF @Lng > 0 AND @Lat > 0
- BEGIN
- DECLARE @Degree AS DECIMAL(8,5),@LBLng AS DECIMAL(8,5),@LBLat AS DECIMAL(8,5),
- @RTLng AS DECIMAL(8,5),@RTLat AS DECIMAL(8,5)
- SET @Degree = @Distance / 100000.0;
- SET @LBLng = @Lng - @Degree
- SET @LBLat = @Lat - @Degree
- SET @RTLng = @Lng + @Degree
- SET @RTLat = @Lat + @Degree
- SET @WHERE = @WHERE + '
- AND a.Lng BETWEEN ' + CONVERT(VARCHAR,@LBLng) + ' AND ' + CONVERT(VARCHAR,@RTLng) + '
- AND a.Lat BETWEEN ' + CONVERT(VARCHAR,@LBLat) + ' AND ' + CONVERT(VARCHAR,@RTLat)
- END
- SET @SQL = @SQL + @FROM + @WHERE
-
- SET @SQL=@SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
- ----把符合条件的职位全部列出
- --PRINT @SQL
- EXEC(@SQL)
-
- SET @ValidJobNumber = @@ROWCOUNT
- ----记录查询结果总数
- UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@SQL WHERE ID=@paSearchConditionID
-
- ----插入JobType数据
- DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
- IF (@TableID = 0)
- BEGIN
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'JobType'
-
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----计算全部地区,4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), (
- SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- AND LEN(TitleID) >3
- GROUP BY LEFT(TitleID, 4)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'Region'
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcEducationID ORDER BY dcEducationID
- --学历 高中、中专、中级合并
- SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID IN(2, 3, 4)
- IF @TitleValue IS NOT NULL
- BEGIN
- IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
- UPDATE SearchDB..paSearchCount_0 SET TitleValue = @TitleValue
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID = 2
- ELSE
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue) VALUES
- (@paSearchConditionID, 'Education', 2, @TitleValue)
- DELETE FROM SearchDB..paSearchCount_0
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID IN(3, 4)
- END
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
-
- INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID,Balance,1
- FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_0 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- ELSE IF (@TableId = 1)
- BEGIN
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'JobType'
-
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----计算全部地区,4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), (
- SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- AND LEN(TitleID) >3
- GROUP BY LEFT(TitleID, 4)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'Region'
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcEducationID ORDER BY dcEducationID
- --学历 高中、中专、中级合并
- SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID IN(2, 3, 4)
- IF @TitleValue IS NOT NULL
- BEGIN
- IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
- UPDATE SearchDB..paSearchCount_1 SET TitleValue = @TitleValue
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID = 2
- ELSE
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue) VALUES
- (@paSearchConditionID, 'Education', 2, @TitleValue)
- DELETE FROM SearchDB..paSearchCount_1
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID IN(3, 4)
- END
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
-
- INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID,Balance,1
- FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_1 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- ELSE IF (@TableId = 2)
- BEGIN
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'JobType'
-
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----计算全部地区,4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), (
- SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- AND LEN(TitleID) >3
- GROUP BY LEFT(TitleID, 4)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'Region'
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcEducationID ORDER BY dcEducationID
- --学历 高中、中专、中级合并
- SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID IN(2, 3, 4)
- IF @TitleValue IS NOT NULL
- BEGIN
- IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
- UPDATE SearchDB..paSearchCount_2 SET TitleValue = @TitleValue
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID = 2
- ELSE
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue) VALUES
- (@paSearchConditionID, 'Education', 2, @TitleValue)
- DELETE FROM SearchDB..paSearchCount_2
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID IN(3, 4)
- END
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
- INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID,Balance,1
- FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_2 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- ELSE IF (@TableId = 3)
- BEGIN
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'JobType'
-
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----计算全部地区,4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), (
- SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- AND LEN(TitleID) >3
- GROUP BY LEFT(TitleID, 4)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'Region'
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcEducationID ORDER BY dcEducationID
- --学历 高中、中专、中级合并
- SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID IN(2, 3, 4)
- IF @TitleValue IS NOT NULL
- BEGIN
- IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
- UPDATE SearchDB..paSearchCount_3 SET TitleValue = @TitleValue
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID = 2
- ELSE
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue) VALUES
- (@paSearchConditionID, 'Education', 2, @TitleValue)
- DELETE FROM SearchDB..paSearchCount_3
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID IN(3, 4)
- END
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
-
- INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID,Balance,1
- FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_3 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- DROP TABLE #Job
- COMMIT
- GetRecordSet:
- BEGIN
- ----返回查询数量
- SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
- UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
- ----返回20行查询结果
- IF (@TableID = 0)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP(@PageSize)a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
- a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
- a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
- a.IsDelete, a.AddDate, a.RefreshDate,
- a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
- b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
- b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
- FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
- AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
- c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_0 c WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 1)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP(@PageSize)a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
- a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
- a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
- a.IsDelete, a.AddDate, a.RefreshDate,
- a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
- b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
- b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
- FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
- AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
- c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_1 c WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 2)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP(@PageSize)a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
- a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
- a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
- a.IsDelete, a.AddDate, a.RefreshDate,
- a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
- b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
- b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
- FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
- AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
- c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_2 c WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 3)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP(@PageSize)a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
- a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
- a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
- a.IsDelete, a.AddDate, a.RefreshDate,
- a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
- b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
- b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
- FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
- AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
- c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_3 c WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- RETURN
- END
- END TRY
- BEGIN CATCH
- ---检查是否已经建立临时表,已经建立则删除
- PRINT 'error'
- PRINT error_Message()
- PRINT error_number()
- PRINT error_line()
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblJobByWeixinSelect1] Script Date: 2018/12/13 19:07:49 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblJobByWeixinSelect1]
- (
- @FromUserName VARCHAR(50),
- @Type INT --0:订阅号关键词查询;10:服务号的关键词查询;11:服务号的周边职位
- )
- AS
- --return
- SET NOCOUNT ON
- BEGIN TRY
- DECLARE @dcRegionID INT,@KeyWord NVARCHAR(20),
- @Lng DECIMAL(8,5),@Lat DECIMAL(8,5),@Distance INT,
- @KeyType TINYINT, @ValidJobNumber INT, @PageNumber SMALLINT
- IF @Type =11
- BEGIN
- SELECT @dcRegionID=dcRegionID,@KeyWord=KeyWord,@Lng=Lng,@Lat=Lat
- FROM wxMessage WITH(NOLOCK) WHERE FromUserName=@FromUserName AND CONTENT='推荐职位'
- END
- ELSE
- BEGIN
- SELECT @dcRegionID=dcRegionID,@KeyWord=KeyWord,
- @Lng=Lng,@Lat=Lat,@PageNumber=PageNumber
- FROM wxMessage WITH(NOLOCK) WHERE FromUserName=@FromUserName
- END
-
- SELECT @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, '')),
- @KeyType = 2,
- @Distance = 5000,
- @PageNumber = ISNULL(@PageNumber, 1),
- @dcRegionID = ISNULL(@dcRegionID, 0),
- @Lng = ISNULL(@Lng, 0),
- @Lat = ISNULL(@Lat, 0)
- IF @Type IN (10, 11)
- SELECT @PageNumber = 1
-
- UPDATE wxMessage SET PageNumber = @PageNumber + 1 WHERE FromUserName=@FromUserName
- IF @dcRegionID = 0 AND @Lng = 0 AND @Lat = 0
- RETURN
- DECLARE @paSearchConditionID AS INT,
- @MinId AS INT,
- @PageSize AS TINYINT,
- @TableID AS TINYINT
- IF @Type =11 OR @Type =10
- BEGIN
- SELECT @paSearchConditionID = 0, @PageSize = 5 --每页的行数
- END
- ELSE
- BEGIN
- SELECT @paSearchConditionID = 0, @PageSize = 8 --每页的行数
- END
- ----搜索60分钟前的数据
- SELECT TOP 1 @paSearchConditionID=ID FROM SearchDB..paSearchCondition WITH(NOLOCK)
- WHERE JobType=''
- AND JobPlace=@dcRegionID AND ISNULL(Industry,'')='' AND ISNULL(Education,'')=''
- AND ISNULL(Experience,'')='' AND ISNULL(Salary,'')='' AND ISNULL(IsNegotiable,'')=''
- AND ISNULL(EmployType,'')='' AND KeyWord=@KeyWord AND KeyType=@KeyType
- AND ISNULL(CompanySizeID,'')='' AND Lng=@Lng AND Lat=@Lat
- ORDER BY ID DESC
- IF ISNULL(@paSearchConditionID, 0) = 0
- BEGIN
- GOTO SelectReset --无数据,重新搜索
- END
- ELSE
- BEGIN
- SELECT @TableID = @paSearchConditionID % 4
- GOTO GetRecordSet --从临时结果中提取数据
- END
- SelectReset:
- --从job中搜索数据
- BEGIN TRAN
- DECLARE @SQL AS VARCHAR(8000)
- DECLARE @WHERE AS VARCHAR(8000)
- DECLARE @FROM AS VARCHAR(1000)
- ----记录查询条件
- INSERT INTO SearchDB..paSearchCondition(SessionID, LogTime, JobType, JobPlace, Industry, Education, Experience,
- Salary, IsNegotiable, EmployType, CompanySizeID, KeyWord, KeyType, ReuseNumber, Lng, Lat, Distance)
- VALUES(1, GETDATE(), '', @dcRegionID, '', '', '', '', '', '', '', @KeyWord, @KeyType, 0, @Lng, @Lat, @Distance)
- SET @paSearchConditionID = @@IDENTITY
- SELECT @TableID = @paSearchConditionID % 4
- ----建立临时表
- CREATE TABLE #Job(
- RowID INT IDENTITY(1, 1),
- ID INT NOT NULL,
- dcJobTypeID SMALLINT NOT NULL,
- dcJobTypeIDMinor SMALLINT NULL,
- dcSalaryID TINYINT NOT NULL,
- dcRegionID VARCHAR(6) NULL,
- dcEducationID TINYINT NOT NULL,
- MinExperience TINYINT NOT NULL,
- RefreshDate SMALLDATETIME NULL
- )
- ------刷新时间,根据刷新时间编号计算
- ----生成插入临时表的Sql语句
- SET @SQL='
- INSERT INTO #Job
- SELECT a.ID, a.dcJobTypeID,
- a.dcJobTypeIDMinor, a.dcSalaryID,
- a.dcRegionID, a.dcEducationID, a.MinExperience,
- a.IssueDate'
- SET @FROM = '
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID'
- ----职位有效,单位新有效
- SET @WHERE = '
- WHERE a.Valid = 1
- AND b.Valid = 1'
- ----需要增加全文索引的关键字查询
- IF @KeyWord LIKE '% %'
- BEGIN
- SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
- SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
- SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
- SET @KeyWord = '"' + REPLACE(@KeyWord, ' ', '" OR "') + '"'
- END
- IF LEN(@KeyWord) > 0
- BEGIN
- IF @KeyType = 2
- SET @FROM = @FROM + '
- INNER JOIN CONTAINSTABLE(JobPublish, *, ''' + @KeyWord + ''', 1000000) AS KeyJob
- ON a.ID = KeyJob.[Key]'
- END
- ---地区
- IF @dcRegionID > 0
- SET @WHERE = @WHERE + '
- AND a.dcRegionID Like ''' + CONVERT(VARCHAR(6),@dcRegionID) + '%'''
- IF @Lng > 0 AND @Lat > 0
- BEGIN
- DECLARE @Degree AS DECIMAL(8,5),@LBLng AS DECIMAL(8,5),@LBLat AS DECIMAL(8,5),
- @RTLng AS DECIMAL(8,5),@RTLat AS DECIMAL(8,5)
- SET @Degree = @Distance / 100000.0;
- SET @LBLng = @Lng - @Degree
- SET @LBLat = @Lat - @Degree
- SET @RTLng = @Lng + @Degree
- SET @RTLat = @Lat + @Degree
- SET @WHERE = @WHERE + '
- AND a.Lng BETWEEN ' + CONVERT(VARCHAR,@LBLng) + ' AND ' + CONVERT(VARCHAR,@RTLng) + '
- AND a.Lat BETWEEN ' + CONVERT(VARCHAR,@LBLat) + ' AND ' + CONVERT(VARCHAR,@RTLat)
- END
- SET @SQL = @SQL + @FROM + @WHERE
-
- SET @SQL=@SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
- ----把符合条件的职位全部列出
- --PRINT @SQL
- EXEC(@SQL)
-
- SET @ValidJobNumber = @@ROWCOUNT
- ----记录查询结果总数
- UPDATE SearchDB..paSearchCondition SET ValidJobNumber=@ValidJobNumber, SQl=@SQL WHERE ID=@paSearchConditionID
-
- ----插入JobType数据
- DECLARE @TitleValue AS INT, @TopRows AS INT, @AllRows AS INT
- IF (@TableID = 0)
- BEGIN
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'JobType'
-
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----计算全部地区,4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), (
- SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- AND LEN(TitleID) >3
- GROUP BY LEFT(TitleID, 4)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_0 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'Region'
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcEducationID ORDER BY dcEducationID
- --学历 高中、中专、中级合并
- SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_0 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID IN(2, 3, 4)
- IF @TitleValue IS NOT NULL
- BEGIN
- IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
- UPDATE SearchDB..paSearchCount_0 SET TitleValue = @TitleValue
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID = 2
- ELSE
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue) VALUES
- (@paSearchConditionID, 'Education', 2, @TitleValue)
- DELETE FROM SearchDB..paSearchCount_0
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID IN(3, 4)
- END
- INSERT INTO SearchDB..paSearchCount_0(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
-
- INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID,Balance,1
- FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_0(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_0 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- ELSE IF (@TableId = 1)
- BEGIN
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'JobType'
-
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----计算全部地区,4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), (
- SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- AND LEN(TitleID) >3
- GROUP BY LEFT(TitleID, 4)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_1 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'Region'
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcEducationID ORDER BY dcEducationID
- --学历 高中、中专、中级合并
- SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_1 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID IN(2, 3, 4)
- IF @TitleValue IS NOT NULL
- BEGIN
- IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
- UPDATE SearchDB..paSearchCount_1 SET TitleValue = @TitleValue
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID = 2
- ELSE
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue) VALUES
- (@paSearchConditionID, 'Education', 2, @TitleValue)
- DELETE FROM SearchDB..paSearchCount_1
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID IN(3, 4)
- END
- INSERT INTO SearchDB..paSearchCount_1(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
-
- INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID,Balance,1
- FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_1(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_1 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- ELSE IF (@TableId = 2)
- BEGIN
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'JobType'
-
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----计算全部地区,4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), (
- SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- AND LEN(TitleID) >3
- GROUP BY LEFT(TitleID, 4)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_2 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'Region'
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcEducationID ORDER BY dcEducationID
- --学历 高中、中专、中级合并
- SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_2 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID IN(2, 3, 4)
- IF @TitleValue IS NOT NULL
- BEGIN
- IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
- UPDATE SearchDB..paSearchCount_2 SET TitleValue = @TitleValue
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID = 2
- ELSE
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue) VALUES
- (@paSearchConditionID, 'Education', 2, @TitleValue)
- DELETE FROM SearchDB..paSearchCount_2
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID IN(3, 4)
- END
- INSERT INTO SearchDB..paSearchCount_2(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
- INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID,Balance,1
- FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_2(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_2 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- ELSE IF (@TableId = 3)
- BEGIN
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'JobType', dcJobTypeID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'JobType'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'JobType'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcJobType b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'JobType'
-
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Salary', dcSalaryID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Region', dcRegionID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcRegionID ORDER BY dcRegionID
- ----计算全部地区,2位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK),
- (SELECT LEFT(TitleID, 2) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- GROUP BY LEFT(TitleID, 2)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----计算全部地区,4位的数据
- UPDATE a SET a.TitleValue = b.TitleValue
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), (
- SELECT LEFT(TitleID, 4) TitleID, SUM(TitleValue) TitleValue
- FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Region'
- AND LEN(TitleID) >3
- GROUP BY LEFT(TitleID, 4)) b
- WHERE a.TitleId = b.TitleID
- AND a.paSearchConditionID = @paSearchConditionID AND a.Title = 'Region'
- ----写入TitleDesc
- UPDATE a SET a.TitleDesc = b.Description
- FROM SearchDB..paSearchCount_3 a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
- WHERE a.TitleID = b.ID AND a.paSearchConditionID = @paSearchConditionID
- AND a.Title = 'Region'
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Education', dcEducationID, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY dcEducationID ORDER BY dcEducationID
- --学历 高中、中专、中级合并
- SELECT @TitleValue = SUM(TitleValue) FROM SearchDB..paSearchCount_3 WITH(NOLOCK)
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID IN(2, 3, 4)
- IF @TitleValue IS NOT NULL
- BEGIN
- IF EXISTS(SELECT 'X' FROM SearchDB..paSearchCount_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID AND Title = 'Education' AND TitleID = 2)
- UPDATE SearchDB..paSearchCount_3 SET TitleValue = @TitleValue
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID = 2
- ELSE
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue) VALUES
- (@paSearchConditionID, 'Education', 2, @TitleValue)
- DELETE FROM SearchDB..paSearchCount_3
- WHERE paSearchConditionID = @paSearchConditionID
- AND Title = 'Education' AND TitleID IN(3, 4)
- END
- INSERT INTO SearchDB..paSearchCount_3(paSearchConditionID, Title, TitleId, TitleValue)
- SELECT @paSearchConditionID, 'Experience', MinExperience, COUNT(*) FROM #Job WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
-
- INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
- SELECT Top 3 @paSearchConditionID,Balance,1
- FROM caOrder WITH(NOLOCK), (SELECT TOP 2000 ID FROM #Job WITH(NOLOCK)) b
- WHERE caOrder.OrderType = 12 AND BeginDate<GETDATE() AND EndDate>GETDATE() AND b.ID = caOrder.Balance ORDER BY OpenDate DESC
- SET @TopRows = @@ROWCOUNT
- INSERT INTO SearchDB..paSearchJobID_3(paSearchConditionID, JobId, IsTop)
- SELECT TOP 2000 @paSearchConditionID, ID, 0 FROM #Job WITH(NOLOCK)
- SET @AllRows = @@ROWCOUNT
- IF @TopRows = 0 AND @AllRows > 100
- UPDATE SearchDB..paSearchJobID_3 SET IsTop = 1
- WHERE paSearchConditionID = @paSearchConditionID
- AND ID IN (SELECT TOP 3 ID FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID = @paSearchConditionID)
- END
- DROP TABLE #Job
- COMMIT
- GetRecordSet:
- BEGIN
- ----返回查询数量
- SELECT ValidJobNumber FROM SearchDB..paSearchCondition WITH(NOLOCK) WHERE ID=@paSearchConditionID
- UPDATE SearchDB..paSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@paSearchConditionID
- ----返回20行查询结果
- IF (@TableID = 0)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_0 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP (@PageSize) a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
- a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
- a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
- a.IsDelete, a.AddDate, a.RefreshDate,
- a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
- b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
- b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
- FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
- AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
- c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_0 c WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 1)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_1 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP (@PageSize) a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
- a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
- a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
- a.IsDelete, a.AddDate, a.RefreshDate,
- a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
- b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
- b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
- FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
- AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
- c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_1 c WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 2)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_2 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP (@PageSize) a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
- a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
- a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
- a.IsDelete, a.AddDate, a.RefreshDate,
- a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
- b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
- b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
- FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
- AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
- c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_2 c WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- ELSE IF (@TableID = 3)
- BEGIN
- SELECT @MinId = MIN(ID) FROM SearchDB..paSearchJobID_3 WITH(NOLOCK) WHERE paSearchConditionID=@paSearchConditionID
- SET @MinId = @MinId+(@PageNumber-1)*@PageSize
- SELECT TOP (@PageSize) a.ID, a.cpMainID, a.caMainID, a.Name as JobName, a.dcJobTypeID,
- a.dcJobTypeIDMinor, a.NeedNumber, a.dcSalaryID, a.EmployType,
- a.dcRegionID, a.Responsibility, a.Demand, a.dcEducationID,
- a.MinExperience, a.MinAge, a.MaxAge, a.IssueDate, a.IssueEND,
- a.IsDelete, a.AddDate, a.RefreshDate,
- a.LastModifyDate, b.Name as cpName, b.dcCompanySizeID,
- b.HasLicence, b.UnLimitedDate, b.BalanceDate, b.Balance,
- b.MemberType, STUFF((SELECT ','+LTRIM(x.dcIndustryid)+',c'+LTRIM(isnull(y.Category,0))
- FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id
- AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
- c.IsTop, b.IsRefreshed, a.SecondId EnJobID, b.SecondId EnCpMainID
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), SearchDB..paSearchJobID_3 c WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.id=c.JobID AND c.paSearchConditionID=@paSearchConditionID
- AND c.ID>=@MinId ORDER BY c.ID, a.ID DESC
- END
- RETURN
- END
- END TRY
- BEGIN CATCH
- ---检查是否已经建立临时表,已经建立则删除
- PRINT 'error'
- PRINT error_Message()
- PRINT error_number()
- PRINT error_line()
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblJobEnByIDSelect] Script Date: 2018/12/13 19:07:49 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:获取职位信息
- --#####################################################
- CREATE PROCEDURE [dbo].[mblJobEnByIDSelect]
- (
- @JobID INT
- )
- AS
- BEGIN TRY
- SELECT a.lng,a.lat,a.caMainID,a.RefreshDate,a.dcRegionId,a.dcJobTypeId,a.Welfare1,a.Welfare2,a.Welfare3,a.Welfare4,
- a.Welfare5,a.Welfare6,a.Welfare7,a.Welfare8,a.Welfare9,a.Welfare10,a.Welfare11,a.Welfare12,a.Welfare13,a.Welfare14,
- a.Welfare15,a.Welfare16,a.Welfare17,a.Welfare18,a.Welfare19,a.Lng,a.Lat,a.Name,a.cpMainID,i.secondid encpmainid,a.secondid enjobid,
- i.Name cpName,a.Responsibility,a.Demand,a.MinAge,
- a.MaxAge,b.Description JobType,c.FullName JobRegion,d.Description NeedNumber,e.Description EmployType,
- f.Description Salary,(CASE WHEN g.Description IS NULL THEN '不限' ELSE g.Description END) Education,
- h.Description Experience FROM Job a WITH(NOLOCK)
- LEFT JOIN dcJobType b WITH(NOLOCK) ON a.dcJobTypeID=b.ID LEFT JOIN dcRegion c WITH(NOLOCK) ON
- a.dcRegionID=c.ID LEFT JOIN dcOthers d WITH(NOLOCK) ON a.NeedNumber=d.DetailID AND d.Category='招聘人数'
- LEFT JOIN dcOthers e WITH(NOLOCK) ON a.EmployType=e.DetailID AND e.Category='工作性质'
- LEFT JOIN dcSalary f WITH(NOLOCK) ON a.dcSalaryID=f.ID LEFT JOIN dcEducation g WITH(NOLOCK)
- ON a.dcEducationID=g.ID LEFT JOIN dcOthers h WITH(NOLOCK) ON a.MinExperience=h.DetailID AND
- h.Category='职位要求工作经验' LEFT JOIN cpMain i WITH(NOLOCK) ON a.cpMainID=i.ID WHERE a.SecondId=@JobID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblJobIntentionSave] Script Date: 2018/12/13 19:07:49 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblJobIntentionSave]
- (
- @cvMainID INT,
- @RelatedWorkYears TINYINT,
- @EmployType TINYINT,
- @dcSalaryID TINYINT,
- @JobType VARCHAR(100),
- @JobPlace VARCHAR(100),
- @paMainID INT,
- @IsNegotiable BIT
- )
- AS
- BEGIN
- IF @RelatedWorkYears IS NULL
- RETURN 0
- IF @EmployType IS NULL
- RETURN 0
- IF @dcSalaryID IS NULL
- RETURN 0
- IF @JobType IS NULL
- RETURN 0
- IF @JobPlace IS NULL
- RETURN 0
- IF NOT EXISTS(SELECT 'x' FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID AND paMainID = @paMainID)
- RETURN 0
- DECLARE @i INT,
- @Name AS VARCHAR(100),
- @JobType1 AS VARCHAR(10),
- @JobPlace1 AS VARCHAR(10)
- BEGIN TRY
- DELETE FROM cvJobType WHERE cvMainID = @cvMainID
- SET @i = CHARINDEX(' ', @JobType)
- WHILE @i >= 1
- BEGIN
- IF LEFT(@JobType, @i-1) > ''
- BEGIN
- INSERT cvJobType(cvMainID, dcJobTypeID) VALUES(@cvMainID, LEFT(@JobType, @i-1))
- IF @JobType1 IS NULL
- SET @JobType1 = LEFT(@JobType, @i-1)
- END
- SET @JobType = SUBSTRING(@JobType, @i+1, LEN(@JobType)-@i)
- SET @i = CHARINDEX(' ', @JobType)
- END
- IF @JobType > ''
- BEGIN
- INSERT cvJobType(cvMainID, dcJobTypeID) VALUES(@cvMainID, @JobType)
- IF @JobType1 IS NULL
- SET @JobType1 = @JobType
- END
- DELETE FROM cvJobPlace WHERE cvMainID = @cvMainID
- SET @i = CHARINDEX(' ', @JobPlace)
- WHILE @i >= 1
- BEGIN
- IF LEFT(@JobPlace, @i-1) > ''
- BEGIN
- INSERT cvJobPlace(cvMainID, dcRegionID) VALUES(@cvMainID, LEFT(@JobPlace, @i-1))
- IF @JobPlace1 IS NULL
- SET @JobPlace1 = LEFT(@JobPlace, @i-1)
- END
- SET @JobPlace = SUBSTRING(@JobPlace, @i+1, LEN(@JobPlace)-@i)
- SET @i = CHARINDEX(' ', @JobPlace)
- END
- IF @JobPlace > ''
- BEGIN
- INSERT cvJobPlace(cvMainID, dcRegionID) VALUES(@cvMainID, @JobPlace)
- IF @JobPlace1 IS NULL
- SET @JobPlace1 = @JobPlace
- END
- SELECT @Name = Name FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
- IF(ISNULL(@Name, '未完成简历') = '未完成简历')
- BEGIN
- SELECT @Name = Description FROM dcRegion WITH(NOLOCK) WHERE ID = @JobPlace1
- SELECT @Name = @Name + '+' + Description FROM dcJobType WITH(NOLOCK) WHERE ID = @JobType1
-
- UPDATE cvMain SET Name = @Name,
- RelatedWorkYears = @RelatedWorkYears,
- EmployType = @EmployType,
- dcSalaryID = @dcSalaryID,
- IsNegotiable = @IsNegotiable
- WHERE ID = @cvMainID
- END
- ELSE
- BEGIN
- UPDATE cvMain SET RelatedWorkYears = @RelatedWorkYears,
- EmployType = @EmployType,
- dcSalaryID = @dcSalaryID,
- IsNegotiable = @IsNegotiable
- WHERE ID = @cvMainID
- END
- DECLARE @SQL AS VARCHAR(100)
- SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew 0, ' + LTRIM(STR(@cvMainID)) + ', 6, 1'
- EXEC(@SQL)
- SET @SQL = 'EXEC pcCvMainByCvLevelUpdateNew 1, ' + LTRIM(STR(@cvMainID)) + ', 6, 1'
- EXEC(@SQL)
- RETURN 1
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- END
- set ANSI_NULLS ON
- set QUOTED_IDENTIFIER ON
- GO
- /****** Object: StoredProcedure [dbo].[mblJobNewsList] Script Date: 2018/12/13 19:07:50 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --Carl 2018-03-06 修改 增加 就业大数据信息及媒体动态
- CREATE PROCEDURE [dbo].[mblJobNewsList]
- (
- @dcProvinceID AS SMALLINT,
- @PageNum AS INT,
- @PageSize AS INT,
- @NewsType AS INT
- )
- AS
- BEGIN
- DECLARE @COUNT INT
- IF @NewsType=18 --就业大数据
- BEGIN
- SELECT @COUNT=COUNT(1) FROM NewsAnalysis WITH(NOLOCK) WHERE newstype=1 AND IsDelete = 0
- IF @COUNT>200
- SET @COUNT=200
- SELECT *,@COUNT AS cnt FROM (
- SELECT TOP 200 ROW_NUMBER() OVER(ORDER BY AnnounceDate DESC) AS Rows,ID,Title,Author,AnnounceDate
- FROM NewsAnalysis WITH(NOLOCK) WHERE newstype=1 AND IsDelete = 0 ) AS a
- WHERE a.Rows BETWEEN (@PageNum-1)*@PageSize+1 AND @PageNum*@PageSize ORDER BY Rows
- END
- ELSE IF @NewsType=19 --媒体动态
- BEGIN
- SELECT @COUNT=COUNT(1) FROM MarketDb..MarketMedia a, MarketDb..MarketProvince b
- WHERE a.ID = b.MarketID
- AND b.Type = 1 AND a.MediaType = 1
- AND (b.ProvinceID = 0 OR b.ProvinceID = @dcProvinceID)
-
- IF @COUNT>200
- SET @COUNT=200
- SELECT *,@COUNT AS cnt FROM (
- 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
- WHERE a.ID = b.MarketID
- AND b.Type = 1 AND a.MediaType = 1
- AND (b.ProvinceID = 0 OR b.ProvinceID = @dcProvinceID) ) AS a
- WHERE a.Rows BETWEEN (@PageNum-1)*@PageSize+1 AND @PageNum*@PageSize ORDER BY Rows
- END
- ELSE
- BEGIN
- SELECT @COUNT=COUNT(1) FROM QlrcNews WITH(NOLOCK) WHERE
- (VersionID=@dcProvinceID) AND DetailType like '%,'+CONVERT(VARCHAR(10),@NewsType)+',%' AND DetailType NOT LIKE '%,2,%'
- AND NewsType = 2
- IF @COUNT>200
- SET @COUNT=200
- SELECT *,@COUNT AS cnt FROM(
- SELECT TOP 200 ROW_NUMBER() OVER(ORDER BY RefreshDate DESC) AS Rows,ID,Title,RefreshDate,Author,AnnounceDate
- FROM QlrcNews WITH(NOLOCK) WHERE
- (VersionID=@dcProvinceID) AND DetailType like '%,'+CONVERT(VARCHAR(10),@NewsType)+',%' AND DetailType NOT LIKE '%,2,%'
- AND NewsType = 2
- ) AS a
- WHERE a.Rows BETWEEN (@PageNum-1)*@PageSize+1 AND @PageNum*@PageSize ORDER BY Rows
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblJobStatusByIDSelect] Script Date: 2018/12/13 19:07:50 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:获取职位当前状态
- --#####################################################
- CREATE PROCEDURE [dbo].[mblJobStatusByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN TRY
- SELECT IsDelete,(CASE WHEN IssueEnd<GETDATE() THEN 1 ELSE 0 END) IsOver,caMainid FROM Job WHERE ID=@ID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[mblManagerSOLStatusByIDSelect] Script Date: 2018/12/13 19:07:50 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.06
- --创建人:Nick
- --说明:得到顾问的在线状态
- --#####################################################
- CREATE PROCEDURE [dbo].[mblManagerSOLStatusByIDSelect]
- (
- @manageruserid INT
- )
- AS
- BEGIN
- SELECT TOP 1 Id, Name, SOLStatus, Photo, OpenName FROM ManagerUser WHERE Id = @manageruserid
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblMblFeedBackInsert] Script Date: 2018/12/13 19:07:50 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.7
- --创建人:Nick
- --说明:在线反馈
- --#####################################################
- CREATE PROCEDURE [dbo].[mblMblFeedBackInsert]
- (
- @Content VARCHAR(500),
- @Version VARCHAR(50),
- @paMainID VARCHAR(20),
- @Name VARCHAR(50),
- @strMobile VARCHAR(20),
- @Email VARCHAR(50)
- )
- AS
- BEGIN
- INSERT INTO mblFeedBack(Content,Version,paMainID,Name,Mobile,Email)
- VALUES(dbo.SafeSQL(@Content),dbo.SafeSQL(@Version),@paMainID,@Name,@strMobile,@Email)
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblMblSqlByVersionSelect] Script Date: 2018/12/13 19:07:51 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.7
- --创建人:Nick
- --说明:
- --#####################################################
- CREATE PROCEDURE [dbo].[mblMblSqlByVersionSelect]
- (
- @version VARCHAR(100)
- )
- AS
- BEGIN
- SELECT * FROM mblSql WITH(NOLOCK) WHERE Version>@version
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblMblSqlSelect] Script Date: 2018/12/13 19:07:51 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.7
- --创建人:Nick
- --说明:
- --#####################################################
- CREATE PROCEDURE [dbo].[mblMblSqlSelect]
- AS
- BEGIN
- SELECT Top 1 Version FROM mblSql WITH(NOLOCK) ORDER BY Version DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblMblVersionByAppTypeSelect] Script Date: 2018/12/13 19:07:51 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.7
- --创建人:Nick
- --说明:获取最新版本信息
- --#####################################################
- CREATE PROCEDURE [dbo].[mblMblVersionByAppTypeSelect]
- (
- @appType VARCHAR(20)
- )
- AS
- BEGIN
- SELECT TOP 1 * FROM mblVersion WITH(NOLOCK) WHERE AppType=@appType ORDER BY AddDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblmsEmailPrevSendInsert] Script Date: 2018/12/13 19:07:51 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.7
- --创建人:Nick
- --说明:发送邮件
- --#####################################################
- CREATE PROCEDURE [dbo].[mblmsEmailPrevSendInsert]
- (
- @cpMainId INT,
- @paMainId INT,
- @EmailNo INT,
- @JasonData VARCHAR(MAX),
- @EmailTitle VARCHAR(50),
- @Email VARCHAR(50),
- @dcSubsiteId INT
- )
- AS
- BEGIN
- INSERT INTO msEmailPrevSend
- (cpMainId,paMainId,EmailNo,EmailTitle,JsonData,Email,dcSubsiteId,IsSend)
- VALUES(@cpMainId,@paMainId,@EmailNo,@EmailTitle,@JasonData,@Email,@dcSubsiteId,0)
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblMyBespeakListSelect] Script Date: 2018/12/13 19:07:51 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.7
- --创建人:Nick
- --说明:我的预约
- --#####################################################
- CREATE PROCEDURE [dbo].[mblMyBespeakListSelect]
- (
- @PamainID INT
- )
- AS
- BEGIN
- SELECT TOP 500 a.paMainID, b.id , b.RecruitmentName , b.BeginDate,c.Description as cityName,
- d.PlaceName,d.lng,d.lat, d.Address,
- ( SELECT COUNT(id) from [MarketDb]..[RmCompany] WHERE RecruitmentID = b.id AND [Status]<=1 ) as cpNum,
- ( SELECT COUNT(id) from [MarketDb]..[RmPerson] WHERE RecruitmentID = b.id) as paNum,
- ( SELECT COUNT(id) from [MarketDb]..[RmPersonInvitation] WHERE RecruitmentID = b.id and paMainID=@paMainID ) as myInvitCpNum
- FROM [MarketDb]..[RmPerson] a, [MarketDb]..[Recruitment] b, [MainDb]..[dcRegion] c, [MarketDb]..[RmPlace] d
- WHERE a.RecruitmentID=b.id
- AND b.CityID = c.id
- AND b.RecruitmentPlaceId = d.id
- AND a.paMainID=@PamainID
- ORDER BY a.AddDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblNewsList] Script Date: 2018/12/13 19:07:51 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblNewsList]
- (
- @dcProvinceID AS SMALLINT,
- @PageNum AS INT,
- @PageSize AS INT
- )
- AS
- BEGIN
- SELECT *
- FROM SearchDb..mblQlrcNews WITH(NOLOCK)
- WHERE ProvinceId = @dcProvinceID
- AND Rows BETWEEN (@PageNum-1) * @PageSize+1 AND @PageNum * @PageSize
- ORDER BY Rows
- END
- GO
- /****** Object: StoredProcedure [dbo].[mblPaAttentionSelect] Script Date: 2018/12/13 19:07:52 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[mblPaAttentionSelect]
- (
- @WHERE VARCHAR(1000),
- @Order VARCHAR(100),
- @Page SMALLINT,
- @caMainID INT,
- @cpMainID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- SET @Where = dbo.SafeSql(@Where)
- SET @ORDER = REPLACE(dbo.SafeSQL(@ORDER), '''', '''''')
-
- DECLARE @SQL AS VARCHAR(2000)
- CREATE TABLE #T1(
- TitleID BIGINT,
- ID INT,
- paMainID INT,
- cvMainID INT,
- AddDate SMALLDATETIME,
- IsMatched BIT,
- Degree TINYINT,
- RelatedWorkYears TINYINT,
- LivePlace NVARCHAR(50),
- Gender BIT,
- paName NVARCHAR(20),
- BirthDay INT,
- HasPhoto TINYINT,
- Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
- IsNameHidden BIT,
- Valid TINYINT,
- IsViewed BIT,
- HasJobApply BIT,
- HasInterview BIT,
- HasRemark BIT,
- HasFavorate BIT,
- cvEducationID INT,
- College NVARCHAR(50),
- EduType TINYINT,
- MajorName NVARCHAR(20),
- Graduation INT,
- Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- cvMatch INT,
- RecruitmentID INT,
- RecruitmentName NVARCHAR(100),
- RecruitmentDate SMALLDATETIME,
- MobileVerifyDate SMALLDATETIME,
- IsOnline BIT,
- JobID INT,
- JobName VARCHAR(50),
- AttentionType INT
- )
- CREATE TABLE #T(
- TitleID BIGINT,
- ID INT,
- paMainID INT,
- cvMainID INT,
- AddDate SMALLDATETIME,
- IsMatched BIT,
- Degree TINYINT,
- RelatedWorkYears TINYINT,
- LivePlace NVARCHAR(50),
- Gender BIT,
- paName NVARCHAR(20),
- BirthDay INT,
- HasPhoto TINYINT,
- Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
- IsNameHidden BIT,
- Valid TINYINT,
- IsViewed BIT,
- HasJobApply BIT,
- HasInterview BIT,
- HasRemark BIT,
- HasFavorate BIT,
- cvEducationID INT,
- College NVARCHAR(50),
- EduType TINYINT,
- MajorName NVARCHAR(20),
- Graduation INT,
- Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
- cvMatch INT,
- RecruitmentID INT,
- RecruitmentName NVARCHAR(100),
- RecruitmentDate SMALLDATETIME,
- MobileVerifyDate SMALLDATETIME,
- IsOnline BIT,
- JobID INT,
- JobName VARCHAR(50),
- AttentionType INT
- )
- SET @SQL='
- INSERT INTO #T1
- (TitleID, ID, paMainID, AddDate,LivePlace,Gender,
- BirthDay,HasPhoto,MobileVerifyDate,IsOnline,AttentionType)
- SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, c.ID,a.AddDate, c.LivePlace,
- c.Gender,c.BirthDay,c.HasPhoto,c.MobileVerifyDate,dbo.GetPaOnlineStatus(c.ID),1
- FROM paAttention a WITH(NOLOCK),paMain c WITH(NOLOCK)
- WHERE a.paMainID = c.ID AND AttentionType = 1 AND AttentionID = '+CONVERT(VARCHAR(20),@cpMainID)
- PRINT @SQL
- --IF LEN(@WHERE) > 0
- -- SET @SQL = @SQL + ' AND ' + @WHERE
- SET @SQL = @SQL + 'ORDER BY a.AddDate '
- EXEC(@SQL)
- SET @SQL='
- INSERT INTO #T1
- (TitleID, ID, paMainID, AddDate,LivePlace,Gender,
- BirthDay,HasPhoto,MobileVerifyDate,IsOnline,JobID,JobName,AttentionType)
- SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, c.ID,a.AddDate, c.LivePlace,
- c.Gender,c.BirthDay,c.HasPhoto,c.MobileVerifyDate,dbo.GetPaOnlineStatus(c.ID),b.ID,b.Name,2
- FROM paAttention a WITH(NOLOCK),Job b WITH(NOLOCK),paMain c WITH(NOLOCK)
- WHERE a.paMainID = c.ID
- AND AttentionType = 2
- AND a.AttentionID = b.ID
- AND b.IsDelete = 0'
- IF LEN(@WHERE) > 0
- SET @SQL = @SQL + ' AND '+@WHERE
- SET @SQL = @SQL + ' ORDER BY a.AddDate '
- --PRINT @SQL
- EXEC(@SQL)
- INSERT INTO #T
- SELECT * FROM #T1 ORDER BY AddDate DESC
- --修改cvmainID
- UPDATE a SET CvMainID = (
- SELECT TOP 1 ID FROM CvMain WITH(NOLOCK)
- WHERE PaMainID = a.PaMainID
- AND (Valid > 0 OR substring(CvLevel,0,7)='111111' OR substring(CvLevel,0,7) = '111101' )
- ORDER BY RefreshDate DESC
- ) FROM #T a
- UPDATE a SET CvMainID = (
- SELECT TOP 1 ID FROM CvMain WITH(NOLOCK)
- WHERE PaMainID = a.PaMainID
- ORDER BY RefreshDate DESC
- ) FROM #T a
- DELETE FROM #T WHERE CvMainID IS NULL
- --修改简历信息
- UPDATE a
- SET a.Degree = b.Degree,
- a.RelatedWorkYears = b.RelatedWorkYears,
- a.Attachment = b.Attachment,
- a.IsNameHidden = b.IsNameHidden,
- a.Valid = b.Valid
- FROM #T a,CvMain b
- WHERE a.CvMainID = b.ID
- IF LEN(@WHERE) > 0
- SET @SQL = @SQL + ' AND ' + @WHERE
- IF(@Page < 1)
- SET @Page = 1
- IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
- SET @Page = 1
-
- 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),
- HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
- 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),
- HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
- 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)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE #T SET Speciality = (
- SELECT Speciality FROM cvMain WITH(NOLOCK)
- WHERE cvMain.ID = #T.cvMainID)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
-
- UPDATE #T SET Experience = (
- SELECT TOP 1 ISNULL(Description,DescriptionEng) FROM cvExperience WITH(NOLOCK)
- WHERE cvExperience.cvMainID = #T.cvMainID
- ORDER BY BeginDate DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE #T SET cvEducationID = (
- SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
- WHERE cvEducation.cvMainID = #T.cvMainID
- AND #T.Degree = cvEducation.Degree
- ORDER BY Graduation DESC)
- WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- UPDATE a SET a.College = ISNULL(b.GraduateCollage,b.GraduateCollageEng),a.EduType = b.EduType,
- a.MajorName = ISNULL(b.MajorName,b.MajorNameEng), a.Graduation = b.Graduation
- FROM #T a, cvEducation b WITH(NOLOCK)
- WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
-
- --UPDATE a SET a.RecruitmentName = b.RecruitmentName, a.RecruitmentDate = b.EndDate
- --FROM #T a, Recruitment b WITH(NOLOCK)
- --WHERE b.ID = a.RecruitmentID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
-
- UPDATE #T SET cvMatch = dbo.GetCvMatch(cvMainID,JobID) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- SELECT COUNT(*) FROM #T WITH(NOLOCK)
- SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
- --计算匹配度
- DROP TABLE #T1
- DROP TABLE #T
- END
- GO
|