123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327 |
- /****** Object: StoredProcedure [dbo].[ProcBaiduXmlSelect] Script Date: 2018/12/13 19:09:31 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcBaiduXmlSelect]
- (
- @SiteId INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- IF @SiteId = 32
- BEGIN
- SELECT id, jobname, JobDESC, JobDemand, jobregion, companyname, edulevel, IsDelete,
- experiencelevel, AnnounceDate, dcSalaryID, dcjobtypeID, ShortName, Address, dcCompanySizeID, Brief,
- EmployType, adddate, dcCompanyKindID, enddate, email, EnJobID, EnCpMainID,
- IndustryId, SubSiteUrl, SubSiteName, NeedNumber, Welfare1, Welfare2, Welfare3, Welfare4, Welfare5,
- Welfare6, Welfare7, Welfare8, Welfare9, Welfare10, Welfare11, Welfare12, Welfare13, Welfare14,
- Welfare15, Welfare16, Welfare17, Welfare18
- FROM ShortDb..BaiduXMLJobQlrcOut WITH(NOLOCK)
- WHERE SiteId = 32
- ORDER BY RowNo
- RETURN
- END
- IF EXISTS(SELECT 'x' FROM ShortDb..BaiduXMLJobOut WHERE SiteId = @SiteID AND crDate > GETDATE() - 1)
- BEGIN
- SELECT id, jobname, JobDESC, JobDemand, jobregion, companyname, edulevel, IsDelete,
- experiencelevel, AnnounceDate, dcSalaryID, dcjobtypeID, ShortName, Address, dcCompanySizeID, Brief,
- EmployType, adddate, dcCompanyKindID, CASE WHEN EndDate < GETDATE() THEN GETDATE() + 10 ELSE EndDate END enddate, email, EnJobID, EnCpMainID,
- IndustryId, SubSiteUrl, SubSiteName, NeedNumber, Welfare1, Welfare2, Welfare3, Welfare4, Welfare5,
- Welfare6, Welfare7, Welfare8, Welfare9, Welfare10, Welfare11, Welfare12, Welfare13, Welfare14,
- Welfare15, Welfare16, Welfare17, Welfare18
- FROM ShortDb..BaiduXMLJobOut WITH(NOLOCK)
- WHERE SiteId = @SiteId
- ORDER BY RowNo
- RETURN
- END
-
- CREATE TABLE #t
- (
- RowNo INT IDENTITY(1, 1),
- [Id] [int] NOT NULL,
- [JobName] [nvarchar](80) NOT NULL,
- [JobDESC] [varchar](max) NOT NULL,
- [JobDemand] [varchar](max) NOT NULL,
- [JobRegion] [varchar](6) NULL,
- [CompanyName] [varchar](100) NOT NULL,
- [EduLevel] [tinyint] NOT NULL,
- [IsDelete] [bit] NOT NULL,
- [ExperienceLevel] [tinyint] NOT NULL,
- [Announcedate] [datetime] NOT NULL,
- [dcSalaryID] [tinyint] NOT NULL,
- [dcJobtypeID] [smallint] NOT NULL,
- [ShortName] [varchar](40) NULL,
- [Address] [nvarchar](100) NULL,
- [dcCompanySizeID] [tinyint] NULL,
- [Brief] [varchar](6000) NULL,
- [EmployType] [tinyint] NOT NULL,
- [AddDate] [smalldatetime] NOT NULL,
- [dcCompanyKindID] [smallint] NULL,
- [EndDate] [smalldatetime] NULL,
- [Email] [varchar](50) NOT NULL,
- [EnJobID] [varchar](12) NULL,
- [EnCpMainID] [varchar](10) NULL,
- [IndustryId] [smallint] NULL,
- [SubSiteUrl] [varchar](50) NOT NULL,
- [SubSiteName] [varchar](50) NOT NULL,
- NeedNumber VARCHAR(10),
- [Welfare1] [bit] NULL,
- [Welfare2] [bit] NULL,
- [Welfare3] [bit] NULL,
- [Welfare4] [bit] NULL,
- [Welfare5] [bit] NULL,
- [Welfare6] [bit] NULL,
- [Welfare7] [bit] NULL,
- [Welfare8] [bit] NULL,
- [Welfare9] [bit] NULL,
- [Welfare10] [bit] NULL,
- [Welfare11] [bit] NULL,
- [Welfare12] [bit] NULL,
- [Welfare13] [bit] NULL,
- [Welfare14] [bit] NULL,
- [Welfare15] [bit] NULL,
- [Welfare16] [bit] NULL,
- [Welfare17] [bit] NULL,
- [Welfare18] [bit] NULL,
- RegionDesc NVARCHAR(50)
- )
- DECLARE @SubSiteUrl VARCHAR(100), @SubSiteName VARCHAR(100)
- SELECT @SubSiteUrl = SubSiteUrl, @SubSiteName = SubSiteName
- FROM dcsubsite WITH(NOLOCK)
- WHERE Id = LEFT(@SiteId, 2)
- IF @SiteId > 99
- INSERT INTO #t
- SELECT a.Id, a.Name JobName, a.Responsibility JobDESC, a.Demand JobDemand,
- a.dcRegionId JobRegion, b.Name CompanyName, a.dcEducationID EduLevel, a.IsDelete,
- a.MinExperience ExperienceLevel, a.RefreshDate Announcedate,
- a.dcSalaryID, a.dcJobtypeID, ISNULL(b.ShortName, b.Name) ShortName, b.Address, dcCompanySizeID, Brief,
- a.EmployType, a.AddDate, b.dcCompanyKindID, a.IssueEnd EndDate, c.Email, a.SecondId EnJobID, b.SecondId EnCpMainID,
- (SELECT TOP 1 dcIndustryId FROM cpIndustry WITH(NOLOCK) WHERE cpIndustry.cpMainID = b.ID) IndustryId,
- @SubSiteUrl SubSiteUrl, @SubSiteName SubSiteName, a.NeedNumber, a.Welfare1, a.Welfare2, a.Welfare3, a.Welfare4,
- a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8, a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13,
- a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18, ''
- FROM job a WITH(NOLOCK),cpmain b WITH(NOLOCK),camain c WITH(NOLOCK)
- WHERE c.Id = a.caMainId AND a.cpMainId = b.Id
- AND a.Valid = 1 AND b.Valid = 1
- AND a.cpMainId NOT IN(select distinct cpMainId from noshowoldjob WITH(NOLOCK) )--harry2016-11-29
- AND IssueEnd > CONVERT(VARCHAR(10), GETDATE() + 1, 120) AND b.VerifyCount > 0
- --AND (b.dcSubsiteId = @SiteId OR b.dcRegionId = @SiteId)
- AND a.dcRegionId LIKE LTRIM(STR(@SiteId)) + '%'
- AND LEN(RTRIM(a.Name)) > 1
- AND a.Refreshdate > CONVERT(VARCHAR(10), GETDATE() - 1, 120)
- ORDER BY a.RefreshDate DESC
- ELSE
- BEGIN
- IF @SiteId <> 32
- BEGIN
- INSERT INTO #t
- SELECT a.id, a.name jobname, a.responsibility JobDESC, a.Demand JobDemand,
- a.dcregionid jobregion, b.name companyname, a.dcEducationID edulevel, a.IsDelete,
- a.MinExperience experiencelevel, a.RefreshDate announcedate,
- a.dcSalaryID, a.dcjobtypeID, ISNULL(b.ShortName, b.Name) ShortName, b.Address, dcCompanySizeID, Brief,
- a.EmployType, a.adddate, b.dcCompanyKindID, a.IssueEnd enddate, c.email, a.SecondId EnJobID, b.SecondId EnCpMainID,
- (SELECT TOP 1 dcIndustryId FROM cpindustry WITH(NOLOCK) WHERE cpindustry.cpMainID = b.ID) IndustryId,
- @SubSiteUrl SubSiteUrl, @SubSiteName SubSiteName, a.NeedNumber, a.Welfare1, a.Welfare2, a.Welfare3, a.Welfare4,
- a.Welfare5, a.Welfare6, a.Welfare7, a.Welfare8, a.Welfare9, a.Welfare10, a.Welfare11, a.Welfare12, a.Welfare13,
- a.Welfare14, a.Welfare15, a.Welfare16, a.Welfare17, a.Welfare18, ''
- FROM job a WITH(NOLOCK),cpmain b WITH(NOLOCK),camain c
- WHERE a.camainid=c.id AND a.cpmainid=b.id
- AND a.valid=1--harry2016-11-29
- AND issueend>CONVERT(VARCHAR(10),GETDATE()+1,120)--harry2016-11-29
- AND b.valid=1 AND b.VerifyCount > 0 --harry2016-11-29
- AND a.cpMainId NOT IN(select distinct cpMainId from noshowoldjob WITH(NOLOCK) )--harry2016-11-29
- AND b.dcprovinceid = @SiteId AND LEN(RTRIM(a.name)) > 1
- AND a.dcRegionId LIKE LTRIM(STR(@SiteId)) + '%'
- --AND a.Refreshdate>CONVERT(VARCHAR(10), GETDATE()-1,120)
- ORDER BY a.RefreshDate DESC
- END
- END
- ALTER TABLE #t ADD RegionName VARCHAR(50)
- ALTER TABLE #t ADD RegionName2 VARCHAR(50)
- UPDATE a SET a.RegionName = b.Description FROM #t a, dcRegion b WHERE LEFT(a.JobRegion, 4) = b.Id
- UPDATE #t SET RegionName2 = LEFT(RegionName, LEN(RegionName) - 1) WHERE LEN(RegionName) > 2
- UPDATE #t SET JobName = RegionName + JobName WHERE CHARINDEX(RegionName2, JobName) = 0
- UPDATE #t SET JobName = JobName + '招聘' WHERE CHARINDEX('聘', JobName) = 0
- DECLARE @t AS TABLE(Id INT, Description NVARCHAR(110))
- INSERT INTO @t SELECT DetailId, REPLACE(Description, '以上', '') FROM dcOthers WHERE Category = '招聘人数' AND Description NOT LIKE '%~%'
- INSERT INTO @t SELECT DetailId, LEFT(Description, CHARINDEX('~', Description) - 1) + '人' FROM dcOthers WHERE Category = '招聘人数' AND Description LIKE '%~%'
- UPDATE a SET NeedNumber = b.Description FROM #t a, @t b WHERE a.NeedNumber = b.Id
- UPDATE #t
- SET JobDesc = REPLACE(JobDesc, '',''),
- JobDemand = REPLACE(JobDemand, '',''),
- Brief = REPLACE(Brief, '','')
- WHERE CHARINDEX('', JobDesc) > 0
- OR CHARINDEX('', JobDemand) > 0
- OR CHARINDEX('', Brief) > 0
- UPDATE a
- SET a.RegionDesc = b.FullName
- FROM #t a, MainDb..dcRegion b
- WHERE a.JobREgion = b.Id
- UPDATE #t SET RegionDesc = '' WHERE CHARINDEX(RegionDesc, Address) > 0
- UPDATE #t
- SET Address = RIGHT(Address, LEN(Address) - 3)
- WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
- AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
- UPDATE #t
- SET Address = RIGHT(Address, LEN(Address) - 3)
- WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
- AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
- UPDATE #t
- SET Address = RIGHT(Address, LEN(Address) - 3)
- WHERE CHARINDEX(LEFT(Address, 3), RegionDesc) > 0
- AND LEN(Address) > 3 AND LEN(RegionDesc) > 0
- UPDATE #t SET Address = '' WHERE CHARINDEX(Address, RegionDesc) > 0 AND LEN(RegionDesc) > 0
- UPDATE #t SET Address = RegionDesc + Address WHERE LEN(RegionDesc) > 0
- SELECT id, jobname, JobDESC, JobDemand, jobregion, companyname, edulevel, IsDelete,
- experiencelevel, AnnounceDate, dcSalaryID, dcjobtypeID, ShortName, Address, dcCompanySizeID, Brief,
- EmployType, adddate, dcCompanyKindID, CASE WHEN EndDate < GETDATE() THEN GETDATE() + 10 ELSE EndDate END enddate, email, EnJobID, EnCpMainID,
- IndustryId, SubSiteUrl, SubSiteName, NeedNumber, Welfare1, Welfare2, Welfare3, Welfare4, Welfare5,
- Welfare6, Welfare7, Welfare8, Welfare9, Welfare10, Welfare11, Welfare12, Welfare13, Welfare14,
- Welfare15, Welfare16, Welfare17, Welfare18
- FROM #t ORDER BY RowNo
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcBaiduZhidaoProcess] Script Date: 2018/12/13 19:09:32 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcBaiduZhidaoProcess]
- AS
- BEGIN
- UPDATE Marketdb..BaiduZhidaoAnswer SET AnswerKeyWord='伍亿人才网' WHERE CHARINDEX('伍亿人才网',Answer)>0 AND CheckDate>CONVERT(VARCHAR(10),GETDATE(),120)
- UPDATE Marketdb..BaiduZhidaoAnswer SET IsLink=1 WHERE CHARINDEX('www.51rc.com',Lower(Answer))>0 AND CheckDate>CONVERT(VARCHAR(10),GETDATE(),120)
- UPDATE a SET AnswerKeyWord=b.SubSiteName FROM Marketdb..BaiduZhidaoAnswer a,(
- SELECT (SELECT TOP 1 SubSiteName FROM dcSubSite WHERE CHARINDEX(SubSiteName,f.Answer)>0 AND IsMainSite=1) SubSiteName,ID
- FROM Marketdb..BaiduZhidaoAnswer f WHERE EXISTS(SELECT 'x' FROM dcSubSite b WHERE CHARINDEX(SubSiteName ,f.Answer)>0 AND IsMainSite=1)
- ) b
- WHERE a.ID=b.ID AND CheckDate>CONVERT(VARCHAR(10),GETDATE(),120)
-
- UPDATE Marketdb..BaiduZhidaoAnswer SET IsValid=0 WHERE LEN(ANSWER)<10 AND CheckDate>CONVERT(VARCHAR(10),GETDATE(),120)
- UPDATE a SET IsLink=1 FROM Marketdb..BaiduZhidaoAnswer a,(
- SELECT (SELECT TOP 1 Replace(SubSiteUrl,'www.','') FROM dcSubSite WHERE CHARINDEX(Replace(SubSiteUrl,'www.',''),f.Answer)>0 AND IsMainSite=1) ProvinceDomain,ID
- FROM Marketdb..BaiduZhidaoAnswer f WHERE EXISTS(SELECT 'x' FROM dcSubSite b WHERE CHARINDEX(Replace(SubSiteUrl,'www.','') ,f.Answer)>0)
- ) b
- WHERE a.ID=b.ID AND CheckDate>CONVERT(VARCHAR(10),GETDATE(),120)
- UPDATE Marketdb..BaiduZhidaoAnswer SET IsValid=0 WHERE AnswerKeyWord IS NULL AND CheckDate>CONVERT(VARCHAR(10),GETDATE(),120)
- UPDATE a SET IsValid=0 FROM Marketdb..BaiduZhidaoAnswer a,dcProvince b WHERE a.dcProvinceID=b.ID AND a.AnswerKeyWord<>b.WebSiteName
- AND CheckDate>CONVERT(VARCHAR(10),GETDATE(),120) AND a.AnswerKeyWord<>'伍亿人才网' AND NOT EXISTS(
- SELECT 'x' FROM dcSubSite WHERE IsMainSite=1 AND a.dcProvinceID=dcSubSite.ProvinceID AND a.AnswerKeyWord=dcSubSite.SubSiteName
- )
- UPDATE Marketdb..BaiduZhidaoAnswer SET IsValid=0 WHERE
- (SELECT Type FROM WorkDate WITH(NOLOCK) WHERE WorkDate = CONVERT(VARCHAR(8), AnswerDate, 112))=1
- AND AnswerDate>CONVERT(VARCHAR(10), AnswerDate, 120)+' 7:00' AND AnswerDate<CONVERT(VARCHAR(10), AnswerDate, 120)+' 18:00'
- AND CheckDate>CONVERT(VARCHAR(10),GETDATE(),120)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcBatchSms] Script Date: 2018/12/13 19:09:32 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcBatchSms]
- AS
- BEGIN
- BEGIN TRY
- DROP Table a_00
- END TRY
- BEGIN CATCH
- END CATCH
- BEGIN TRY
- DROP Table A_01
- END TRY
- BEGIN CATCH
- END CATCH
- BEGIN TRY
- DROP Table A_02
- END TRY
- BEGIN CATCH
- END CATCH
- BEGIN TRY
- DROP Table A_03
- END TRY
- BEGIN CATCH
- END CATCH
- --个人:年前一个月注册且年后没登陆。(北京、上海、山东)
- --尊敬的会员,3月5日xxx人才x元宵节找工作送福利,多名就业导师为您求职答疑解惑,期待您的登录www.xxxxrc.com
- select DISTINCT dcProvinceId, space(50) SiteName, space(50) SiteUrl, Mobile, space(300) Msg, 0 Status
- INTO a_00
- from pamain
- where id between 25572640 and 25629133
- and mobile like '1%'
- and lastlogindate < '2015-2-18'
- and dcprovinceid in(10,30,32)
- delete a_00 where mobile in(select mobile from paMain where lastlogindate > '2015-2-18')
- INSERT INTO a_00 select 10, '', '', '13455496132', '', 0
- --单位:1个月内即将到期的付费会员
- --尊敬的会员,3月5日xxx人才x元宵节嗨聊全场,多种活动期待您的参与,www.xxxxrc.com
- select id cpMainId, id camainid, dcProvinceId, space(50) SiteName, space(50) SiteUrl, space(11) Mobile, space(300) Msg, 0 Status
- into A_01
- from cpmain
- where membertype=3
- and id not in(select cpmainid from caorder where enddate > getdate()+30 and ordertype=8 and isdeleted=0 and opendate > '')
- and dcprovinceid in(10,30,32)
- INSERT into A_01 SELECT 371108, 371108, 32,'','','','',0
- --单位:年后查看过资费标准的免费会员 5100
- --drop table A_02
- select DISTINCT caMainId cpMainId, caMainId, 999 dcProvinceId, space(50) SiteName, space(50) SiteUrl, space(11) Mobile, space(300) Msg
- into A_02
- from cafeepageviewlog
- where adddate >'2015-2-18'
- UPDATE A_01 SET caMainId = 0
- UPDATE A_02 SET cpMainId = 0
- UPDATE A_02 SET cpMainId = (SELECT cpMainId FROM caMain WHERE caMain.ID = A_02.caMainId)
- INSERT A_01(cpMainID, caMainId, dcProvinceId, status) SELECT DISTINCT cpMainID, 0, 0, 0 FROM A_02 WHERE cpMainId NOT IN(SELECT CpMainID FROM A_01) AND cpMainId > 0
- UPDATE a SET a.dcProvinceID = b.dcProvinceId FROM A_01 a, cpMain b WHERE a.cpMainId = b.Id
- UPDATE a SET a.caMainId = b.Id,
- a.Mobile = b.Mobile
- FROM A_01 a, caMain b
- WHERE b.AccountType = 1 AND a.cpMainId = b.cpMainId
- DELETE A_01 WHERE CaMainId = 0
- DELETE A_01 WHERE Mobile NOT LIKE '1%'
- DELETE A_01 WHERE LEN(Mobile) <> 11
- DELETE A_01 WHERE Mobile IS NULL
- DELETE A_01 WHERE Mobile = '13000000000'
- DELETE A_01 WHERE dcProvinceId NOT IN(10, 30, 32)
- UPDATE a SET a.SiteName = b.WebSiteName, a.SiteUrl = 'www.' + b.ProvinceDomain
- FROM A_01 a, dcProvince b
- WHERE a.dcProvinceID = b.Id
- UPDATE a SET a.SiteName = b.WebSiteName, a.SiteUrl = 'www.' + b.ProvinceDomain
- FROM a_00 a, dcProvince b
- WHERE a.dcProvinceID = b.Id
- UPDATE a_00 SET Msg = '尊敬的会员,3月5日' + SiteName + '元宵节找工作送福利,多名就业导师为您求职答疑解惑,期待您的登录' + SiteUrl
- UPDATE A_01 set Msg = '尊敬的会员,3月5日' + SiteName + '元宵节嗨聊全场,多种活动期待您的参与' + SiteUrl
- --drop table A_03
- SELECT DISTINCT dcProvinceID, Mobile, Msg, Status INTO A_03 FROM A_01
-
- -- select * from a_00 where mobile='13455496132'
- -- select * from A_03 where mobile='13455496132'
- -- select mobile, count(*) from a_00 group by mobile having count(*) >1 order by count(*) DESC
- -- select mobile, count(*) from A_03 group by mobile having count(*) >1 order by count(*) DESC
- ---must updated
- CREATE TABLE #t(Id INT IDENTITY(1, 1), ProvinceId INT, Cnt INT, Msg NVARCHAR(500))
- CREATE TABLE #m(Mobile VARCHAR(20))
- INSERT INTO #t(provinceid, cnt, msg)
- SELECT dcProvinceId, COUNT(*) Cnt, msg
- FROM a_00
- WHERE Status = 0
- GROUP BY dcProvinceId,msg
-
- DECLARE @Id INT, @MobileString VARCHAR(MAX), @Msg NVARCHAR(500), @ProvinceId INT
- SET @Id = 0
- WHILE EXISTS(SELECT Id FROM #t WHERE Id > @Id)
- BEGIN
- SELECT TOP 1 @MobileString = '', @Id = Id, @ProvinceId = ProvinceId, @Msg = Msg FROM #t WHERE Id > @Id ORDER BY Id
- TRUNCATE TABLE #m
- INSERT INTO #m
- SELECT TOP 500 Mobile
- FROM a_00
- WHERE dcProvinceId = @ProvinceId
- AND Status = 0
- ORDER BY Mobile
- SELECT TOP 500 @MobileString = @MobileString + ',' + Mobile
- FROM #m
- IF LEN(@MobileString) > 1
- BEGIN
- SET @MobileString = RIGHT(@MobileString, LEN(@MobileString) - 1)
- INSERT INTO a04(Mobile, Msg) SELECT @MobileString, @Msg
- UPDATE a_00 SET Status = 1 WHERE Mobile IN(SELECT Mobile FROM #m)
- END
- END
- /*
- insert smsBatchSend(mobile,msg) select mobile,msg from a04
- SELECT top 100 * FROM smsBatchSend
- --where sendstatus is null
- order by id desc
- */
- /*
- truncate table a04
- drop table #t
- drop table #m
- CREATE TABLE #t(Id INT IDENTITY(1, 1), ProvinceId INT, Cnt INT, Msg NVARCHAR(500))
- CREATE TABLE #m(Mobile VARCHAR(20))
- select * from #t
- select * from #m
- select * from A_03
- INSERT INTO #t(provinceid, cnt, msg)
- SELECT dcProvinceId, COUNT(*) Cnt, msg
- FROM A_03
- WHERE Status = 0
- GROUP BY dcProvinceId,msg
- DECLARE @Id INT, @MobileString VARCHAR(MAX), @Msg NVARCHAR(500), @ProvinceId INT
- SET @Id = 0
- WHILE EXISTS(SELECT Id FROM #t WHERE Id > @Id)
- BEGIN
- SELECT TOP 1 @MobileString = '', @Id = Id, @ProvinceId = ProvinceId, @Msg = Msg FROM #t WHERE Id > @Id ORDER BY Id
- TRUNCATE TABLE #m
- INSERT INTO #m
- SELECT TOP 500 Mobile
- FROM A_03
- WHERE dcProvinceId = @ProvinceId
- AND Status = 0
- ORDER BY Mobile
- SELECT TOP 500 @MobileString = @MobileString + ',' + Mobile
- FROM #m
- IF LEN(@MobileString) > 1
- BEGIN
- SET @MobileString = RIGHT(@MobileString, LEN(@MobileString) - 1)
- INSERT INTO a04(Mobile, Msg) SELECT @MobileString, @Msg
- UPDATE A_03 SET Status = 1 WHERE Mobile IN(SELECT Mobile FROM #m)
- END
- END
- select len(mobile)/12,* from a04
- -----
- select * from a04
- insert smsBatchSend(mobile,msg) select mobile,msg from a04
- SELECT top 100 * FROM smsBatchSend
- where sendstatus is null
- order by id desc
- */
- END
- GO
- /****** Object: StoredProcedure [dbo].[procbatchsms2] Script Date: 2018/12/13 19:09:33 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE procedure [dbo].[procbatchsms2]
- as
- begin
- BEGIN TRY
- DROP Table a_00
- END TRY
- BEGIN CATCH
- END CATCH
- BEGIN TRY
- DROP Table A_01
- END TRY
- BEGIN CATCH
- END CATCH
- BEGIN TRY
- DROP Table A_02
- END TRY
- BEGIN CATCH
- END CATCH
- BEGIN TRY
- DROP Table A_03
- END TRY
- BEGIN CATCH
- END CATCH
- BEGIN TRY
- DROP Table A_04
- END TRY
- BEGIN CATCH
- END CATCH
- /*
- --1、一个月即将到期的(后续没有开通订单的)会员。
- select distinct id cpMainId, id camainid, dcProvinceId, space(50) SiteName, space(50) SiteUrl, space(11) Mobile, space(300) Msg, 0 Status
- into A_00
- from cpmain
- where MemberType = 3
- AND Id IN(SELECT cpMainId FROM caorder
- WHERE OrderType = 8 AND IsDeleted = 0 AND OpenDate > 0
- AND EndDate BETWEEN getdate() and GETDATE() + 31)
- AND Id NOT IN(SELECT cpMainId FROM caorder WHERE OrderType = 8 AND IsDeleted = 0 AND EndDate > GETDATE()+ 31)
- --2、两个月内查看资费标准在三次以上的处于免费会员状态的。
- select id cpMainId, id camainid, dcProvinceId, space(50) SiteName, space(50) SiteUrl, space(11) Mobile, space(300) Msg, 0 Status
- into A_01
- from cpmain
- where membertype=3
- and id IN(
- SELECT a.cpMainId
- FROM caMain a, caFeePageViewLog b
- WHERE a.Id = b.caMainId
- AND b.AddDate > GETDATE() - 61
- GROUP BY a.cpMainId
- HAVING COUNT(*) > 2
- )
- AND ID NOT IN(SELECT cpMainId FROM A_00)
- INSERT into A_01 select * from a_00
- --3、到期后三个月内没有付费并处于免费会员状态的。
- insert into a_01
- select distinct id cpMainId, id camainid, dcProvinceId, space(50) SiteName, space(50) SiteUrl, space(11) Mobile, space(300) Msg, 0 Status
- from cpmain
- where MemberType < 3
- AND Id IN(SELECT cpMainId FROM caorder
- WHERE OrderType = 8 AND IsDeleted = 0 AND OpenDate > 0
- AND EndDate > getdate() - 92)
- AND Id NOT IN(SELECT cpMainId FROM caorder WHERE OrderType = 8 AND IsDeleted = 0 AND EndDate > GETDATE() AND OpenDate > '')
- AND Id NOT IN(SELECT cpMainId FROM A_01)
- --4、本月提交订单未开通并处于免费会员状态的。
- insert into a_01
- select distinct id cpMainId, id camainid, dcProvinceId, space(50) SiteName, space(50) SiteUrl, space(11) Mobile, space(300) Msg, 0 Status
- from cpmain
- where MemberType < 3
- AND Id IN(SELECT cpMainId FROM caorder
- WHERE OrderType = 8 AND IsDeleted = 0 AND OpenDate IS NULL
- AND AddDate > '2016-5-26')
- AND Id NOT IN(SELECT cpMainId FROM caorder WHERE OrderType = 8 AND IsDeleted = 0 AND EndDate > GETDATE() AND OpenDate > '')
- AND Id NOT IN(SELECT cpMainId FROM A_01)
- -- INSERT into A_01 SELECT 371108, 371108, 32,'','','','',0
- --UPDATE A_01 SET caMainId = 0
- --UPDATE A_02 SET cpMainId = 0
- --UPDATE A_02 SET cpMainId = ISNULL((SELECT cpMainId FROM caMain WHERE caMain.ID = A_02.caMainId), 0)
- --DELETE from a_02 where cpmainid=0
- --INSERT A_01(cpMainID, caMainId, dcProvinceId, status)
- --SELECT DISTINCT cpMainID, 0, 0, 0 FROM A_02 WHERE cpMainId NOT IN(SELECT CpMainID FROM A_01) AND cpMainId > 0
- ---------------------------
- UPDATE a SET a.dcProvinceID = b.dcProvinceId FROM A_01 a, cpMain b WHERE a.cpMainId = b.Id
- UPDATE a SET a.caMainId = b.Id,
- a.Mobile = b.Mobile
- FROM A_01 a, caMain b
- WHERE b.AccountType = 1 AND a.cpMainId = b.cpMainId
- DELETE A_01 WHERE CaMainId = 0
- DELETE A_01 WHERE Mobile NOT LIKE '1%'
- DELETE A_01 WHERE LEN(Mobile) <> 11
- DELETE A_01 WHERE Mobile IS NULL
- DELETE A_01 WHERE Mobile = '13000000000'
- DELETE A_01 WHERE Mobile = '15000000000'
- DELETE A_01 WHERE Mobile = '15555555555'
- DELETE A_01 WHERE Mobile = '13222222222'
- delete a_01 WHERE cpMainId NOT IN(select max(cpMainId) cpMainId FROM a_01 group by Mobile)
- DELETE a_01 where mobile in(select mobile from marketdb..NoSendSms)
- --select mobile, count(*) from a_01 group by mobile order by count(*) desc
- UPDATE a SET a.SiteName = b.WebSiteName, a.SiteUrl = 'www.' + b.ProvinceDomain
- FROM A_01 a, dcProvince b
- WHERE a.dcProvinceID = b.Id
-
- -- UPDATE a SET a.SiteName = b.WebSiteName, a.SiteUrl = 'www.' + b.ProvinceDomain
- -- FROM a_00 a, dcProvince b
- -- WHERE a.dcProvinceID = b.Id
- -- select * from a_01 where subno > 7000
- select * from a_01 where subno > 7900 or subno < 5600
- alter table a_01 add subno int
- update a set a.subno = b.consultantid from a_01 a, cpmain b where a.cpmainid= b.id
- update a_01 set subno = subno + 6000 where subno > 699
- update a_01 set subno = subno + 6000 where subno < 600
- update a_01 set subno = subno + 5000 where subno between 600 and 699
- --UPDATE a_00 SET Msg = '尊敬的会员,3月5日' + SiteName + '元宵节找工作送福利,多名就业导师为您求职答疑解惑,期待您的登录' + SiteUrl
- UPDATE A_01 set Msg = '亲爱的会员,' + SiteName + '粽情端午套餐优惠活动邀您参与,时间有限快来咨询吧!4006265151'
- + CASE WHEN SubNo IS NULL THEN '' ELSE '-' + LTRIM(STR(SubNo)) END + '。'
-
- --select sitename, count(*) from a_01 group by sitename order by count(*)
- --select * from a_01
- alter table a_01 add id int identity(1,1)
- SELECT min(id) id, Mobile, Status INTO A_03 FROM A_01 group by Mobile, Status
- alter table a_03 add dcProvinceId int
- alter table a_03 add msg nvarchar(200)
- update a set a.dcProvinceId = b.dcProvinceId,a.msg=b.msg from a_03 a, a_01 b where a.id=b.id
- --select left(msg, 5), count(*) from a_03 group by left(msg, 5) order by count(*) Desc
- -- select * from a_00 where mobile='13455496132'
- -- select * from A_03 where mobile='13455496132'
- -- select mobile, count(*) from a_00 group by mobile having count(*) >1 order by count(*) DESC
- -- select mobile, count(*) from A_03 group by mobile having count(*) >1 order by count(*) DESC
- ---must updated
- --delete a_03 where msg in(select msg from a_03 group by msg having count(*) < 120)
- --select count(distinct mobile), count(*) from a_03
- --select * from a_03
- --drop table #t
- --drop table #m
- --drop table a_04
- CREATE TABLE #t(Id INT IDENTITY(1, 1), ProvinceId INT, Cnt INT, Msg NVARCHAR(500))
- CREATE TABLE #m(Mobile VARCHAR(20))
- INSERT INTO #t(provinceid, cnt, msg)
- SELECT dcProvinceId, COUNT(*) Cnt, msg
- FROM a_03
- WHERE Status = 0
- GROUP BY dcProvinceId, msg
- CREATE TABLE a_04(Id INT IDENTITY(1, 1), Mobile varchar(MAX), Msg NVARCHAR(300))
- --select * from a_03
- DECLARE @Id INT, @MobileString VARCHAR(MAX), @Msg NVARCHAR(500), @ProvinceId INT
- SET @Id = 0
- WHILE EXISTS(SELECT Id FROM #t WHERE Id > @Id)
- BEGIN
- SELECT TOP 1 @MobileString = '', @Id = Id, @ProvinceId = ProvinceId, @Msg = Msg FROM #t WHERE Id > @Id ORDER BY Id
- TRUNCATE TABLE #m
- INSERT INTO #m
- SELECT TOP 500 Mobile
- FROM a_03
- WHERE dcProvinceId = @ProvinceId
- AND Status = 0
- ORDER BY Mobile
- SELECT TOP 500 @MobileString = @MobileString + ',' + Mobile
- FROM #m
- IF LEN(@MobileString) > 1
- BEGIN
- SET @MobileString = RIGHT(@MobileString, LEN(@MobileString) - 1)
- INSERT INTO a_04(Mobile, Msg) SELECT @MobileString, @Msg
- UPDATE a_03 SET Status = 1 WHERE Mobile IN(SELECT Mobile FROM #m)
- END
- END
- --update a_04 set mobile='18363443519,' + mobile where id=2
- select sum((len(mobile)+1)/12.0) from a_04
- select (len(mobile)+1)/12.0,* from a_04 order by id
- insert smsBatchSend(mobile,msg) select mobile,msg from a_04 WHERE ID <> 2
- SELECT top 35 * FROM smsBatchSend
- where sendstatus is null
- order by id desc
- */
- end
- GO
- /****** Object: StoredProcedure [dbo].[ProcBeisenAdsSave] Script Date: 2018/12/13 19:09:33 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcBeisenAdsSave]
- (
- @Id INT,
- @TenantId VARCHAR(50),
- @JobAdId VARCHAR(50),
- @JobAdName NVARCHAR(500),
- @JobType NVARCHAR(500),
- @LocID NVARCHAR(500),
- @Salary NVARCHAR(500),
- @Degree NVARCHAR(500),
- @YearsofWorking NVARCHAR(50),
- @EndTime DATETIME,
- @Email VARCHAR,
- @Status NVARCHAR(100),
- @CreateDate DATETIME,
- @ModifiedDate DATETIME
- )
- AS
- SET NOCOUNT ON
- BEGIN
- IF NOT EXISTS (SELECT 'x' FROM BeisenAds WHERE Id = @Id)
- BEGIN
- INSERT INTO BeisenAds(Id, TenantId, JobAdId, JobAdName, JobType, LocID, Salary, Degree, YearsofWorking, EndTime, Email, Status, CreateDate, ModifiedDate, Adddate, LastGetDate)
- SELECT @Id, @TenantId, @JobAdId, @JobAdName, @JobType, @LocID, @Salary, @Degree, @YearsofWorking, @EndTime, @Email, @Status, @CreateDate, @ModifiedDate, GETDATE(), GETDATE()
- END
- ELSE
- BEGIN
- DECLARE @ModifiedDate2 AS DATETIME
- SELECT @ModifiedDate2 FROM BeisenAds WHERE Id = @Id
- IF @ModifiedDate2 < @ModifiedDate
- BEGIN
- UPDATE BeisenAds
- SET TenantId = @TenantId,
- JobAdId = @JobAdId,
- JobAdName = @JobAdName,
- JobType = @JobType,
- LocID = @LocID,
- Salary = @Salary,
- Degree = @Degree,
- YearsofWorking = @YearsofWorking,
- EndTime = @EndTime,
- Email = @Email,
- Status = @Status,
- CreateDate = @CreateDate,
- ModifiedDate = @ModifiedDate,
- LastGetDate = GETDATE()
- WHERE ID = @Id
-
- UPDATE BeisenAdsId SET IsModified = 1 WHERE BeisenAdsId = @Id
- END
- END
- RETURN 1
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcBeiSenCompanySave] Script Date: 2018/12/13 19:09:34 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcBeiSenCompanySave]
- (
- @TenantId VARCHAR(50),
- @Name NVARCHAR(500),
- @Domain NVARCHAR(500),
- @Abbreviation NVARCHAR(500),
- @Address NVARCHAR(500),
- @PostalCode NVARCHAR(500),
- @EmailHost NVARCHAR(500),
- @Logo VARCHAR(500)
- )
- AS
- SET NOCOUNT ON
- BEGIN
- IF NOT EXISTS (SELECT 'x' FROM BeiSenCompany WHERE TenantId = @TenantId)
- BEGIN
- INSERT INTO BeiSenCompany(TenantId, Name, Domain, Abbreviation, Address, PostalCode, EmailHost, Logo, AddDate)
- SELECT @TenantId, @Name, @Domain, @Abbreviation, @Address, @PostalCode, @EmailHost, @Logo, GETDATE()
- END
- ELSE
- BEGIN
- DECLARE @IsModified BIT
-
- IF EXISTS(SELECT 'x' FROM BeisenCompany
- WHERE TenantId = @TenantId
- AND ISNULL(Name, '') != ISNULL(@Name, '')
- AND ISNULL(Domain, '') != ISNULL(@Domain, '')
- AND ISNULL(Abbreviation, '') != ISNULL(@Abbreviation, '')
- AND ISNULL(Address, '') != ISNULL(@Address, '')
- AND ISNULL(PostalCode, '') != ISNULL(@PostalCode, '')
- AND ISNULL(EmailHost, '') != ISNULL(@EmailHost, '')
- AND ISNULL(Logo, '') != ISNULL(@Logo, ''))
- BEGIN
- UPDATE BeisenCompany
- SET Name= @Name,
- Domain= @Domain,
- Abbreviation= @Abbreviation,
- Address= @Address,
- PostalCode= @PostalCode,
- EmailHost= @EmailHost,
- Logo= @Logo
- WHERE TenantId = @TenantId
- END
- END
-
- RETURN 1
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcBeisenJobApplyBySendSelect] Script Date: 2018/12/13 19:09:34 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcBeisenJobApplyBySendSelect]
- AS
- SET NOCOUNT ON
- BEGIN
- IF NOT EXISTS(SELECT '' FROM BeisenJobApply WHERE BeisenHasApply IS NULL)
- BEGIN
- SELECT TOP 0 'a' a
- RETURN
- END
-
- SELECT TOP 99 *
- INTO #t
- FROM BeisenJobApply
- WHERE BeisenHasApply IS NULL
-
- UPDATE #t SET cvText = dbo.GetBeiSenCvText(cvMainID) WHERE cvText IS NULL
- UPDATE a SET a.cvText = b.cvText FROM BeisenJobApply a, #t b WHERE a.Id = b.Id AND a.cvText = ''
- DELETE a FROM BeisenJobApply a, #t b WHERE a.Id = b.Id AND b.cvText = ''
- DELETE #t WHERE cvText = ''
-
- IF EXISTS(SELECT 'x' FROM #t)
- BEGIN
- SELECT a.Id, b.Name, d.TenantID, d.JobAdId, c.Id BeisenJobApplyId, c.cvText, b.Mobile, b.Email
- FROM cvMain a, paMain b, #t c, BeisenAds d
- WHERE a.paMainId = b.Id
- AND a.Id = c.cvMainId
- AND c.BeisenHasApply IS NULL
- AND c.JobId = d.JobId
- END
- ELSE
- SELECT * FROM #t
- END
- GO
- /****** Object: StoredProcedure [dbo].[procBestEmployerByCpMainIDSelect] Script Date: 2018/12/13 19:09:34 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procBestEmployerByCpMainIDSelect]
- (
- @cpMainID INT
- )
- AS
- BEGIN
- SET NOCOUNT OFF
- SELECT * FROM BestEmployer WITH(NOLOCK) WHERE cpMainID = @cpMainID
- SET NOCOUNT ON
- END
- GO
- /****** Object: StoredProcedure [dbo].[procBestEmployerInsert] Script Date: 2018/12/13 19:09:35 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procBestEmployerInsert]
- (
- @cpMainID INT
- )
- AS
- BEGIN
- SET NOCOUNT OFF
- IF EXISTS(SELECT 'X' FROM BestEmployer WITH(NOLOCK) WHERE cpMainID = @cpMainID)
- RETURN
- INSERT INTO BestEmployer(cpMainID, CompanyName)
- SELECT ID, [Name] FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
- SET NOCOUNT ON
- END
- GO
- /****** Object: StoredProcedure [dbo].[procBestEmployerSelect] Script Date: 2018/12/13 19:09:35 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procBestEmployerSelect]
- (
- @Where VARCHAR(500)
- )
- AS
- BEGIN
- SET NOCOUNT OFF
- DECLARE @SQL VARCHAR(2000)
- SET @SQL = 'SELECT * FROM BestEmployer WITH(NOLOCK) WHERE 1 = 1' + @Where + ' ORDER BY ID DESC'
- EXEC(@SQL)
- SET NOCOUNT ON
- END
- GO
- /****** Object: StoredProcedure [dbo].[procBestEmployVoteInsert] Script Date: 2018/12/13 19:09:35 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procBestEmployVoteInsert]
- (
- @ID INT,
- @OpenID VARCHAR(50)
- )
- AS
- BEGIN
- SET NOCOUNT OFF
- IF EXISTS(SELECT 'X' FROM BestEmployerVote WHERE OpenID = @OpenID AND BestEmployerID = @ID AND CONVERT(VARCHAR(8), GETDATE(), 112) = CONVERT(VARCHAR(8), AddDate, 112))
- RETURN -1
- IF (SELECT COUNT(1) FROM BestEmployerVote WHERE OpenID = @OpenID AND CONVERT(VARCHAR(8), GETDATE(), 112) = CONVERT(VARCHAR(8), AddDate, 112)) >= 3
- RETURN -2
- INSERT INTO BestEmployerVote(BestEmployerID, OpenID) VALUES(@ID, @OpenID)
- RETURN 1
- SET NOCOUNT ON
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcbsAskDetailSelect] Script Date: 2018/12/13 19:09:35 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcbsAskDetailSelect]
- (
- @ID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- --修改点击量
- UPDATE bsASKInfo SET ClickNumber = ClickNumber + 1 WHERE ID = @ID
- --记录每日点击
- -- DECLARE @bsAskInfoDayReportId INT
- -- SELECT @bsAskInfoDayReportId = ID FROM bsAskInfoDayReport WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112) AND bsAskInfoId = @Id
- -- IF @bsAskInfoDayReportId > 0
- -- UPDATE bsAskInfoDayReport
- -- SET VisitNumber = VisitNumber + 1
- -- WHERE Id = @bsAskInfoDayReportId
- -- ELSE
- -- INSERT INTO bsAskInfoDayReport
- -- SELECT CONVERT(VARCHAR(8), GETDATE(), 112), @id, 1
- SELECT ID, Title, Question, Answer, SolveDate, UpdateDate, UserName, Mark, ProvinceIDs, TypeID,
- (SELECT TypeName FROM bsAskTypeSet WITH(NOLOCK) WHERE ID = bsaskinfo.TypeID) TypeName,ClickNumber
- FROM bsASKInfo WITH(NOLOCK)
- WHERE ID = @ID
- END
- SET NOCOUNT OFF
- GO
- /****** Object: StoredProcedure [dbo].[ProcbsASKInfoALLSelect] Script Date: 2018/12/13 19:09:35 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:Nick
- --说明:获取全部求职互助
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcbsASKInfoALLSelect]
- @dcProvinceId INT,
- @PageNo INT
- AS
- BEGIN TRY
- SELECT *
- FROM bsAskInfoTmp WITH(NOLOCK)
- WHERE dcProvinceId=@dcProvinceId
- AND PageNo=@PageNo ORDER BY OrderNo
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcBsAskInfoByAdvicesSelect] Script Date: 2018/12/13 19:09:35 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --sean 2014-11-19
- CREATE PROCEDURE [dbo].[ProcBsAskInfoByAdvicesSelect]
- (
- @ProvinceId INT
- )
- AS
- SET NOCOUNT ON
- --INSERT INTO procLog SELECT 'ProcBsAskInfoByAdvicesSelect', @ProvinceId, GETDATE()
- BEGIN
- SET @ProvinceId = LEFT(@ProvinceId, 2)
- DECLARE @p VARCHAR(10), @u VARCHAR(100), @s VARCHAR(50)
- SELECT @p = ',' + LTRIM(STR(@ProvinceId)), @s = SubSiteUrl, @u = 'http://' + SubSiteUrl + '/ask/' FROM dcSubSite WHERE Id = @ProvinceId
- CREATE TABLE #t(
- Title VARCHAR(300),
- Question NVARCHAR(MAX),
- Answer NVARCHAR(MAX),
- ID INT,
- Url VARCHAR(100),
- UserName VARCHAR(20),
- AddDate SMALLDATETIME,
- SubSiteUrl VARCHAR(50))
- INSERT INTO #t
- SELECT Title, Question, Answer, Id, SPACE(100) Url, UserName, AddDate, @s
- FROM bsAskInfo WITH(NOLOCK)
- WHERE CHARINDEX(@p, ProvinceIds) > 0
-
- UPDATE #t SET Url = @u + LTRIM(STR(ID)) + '.html'
- SELECT *, AddDate + 1 Replydate FROM #t ORDER BY ID DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procBsAskInfoByProvinceIDSelect] Script Date: 2018/12/13 19:09:36 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:求职互助
- --#####################################################
- CREATE PROCEDURE [dbo].[procBsAskInfoByProvinceIDSelect]
- (
- @provinceID VARCHAR(20)
- )
- AS
- BEGIN
- SELECT TOP 11 a.id, a.title, a.typeid, a.solvedate, a.updatedate, t.typename
- FROM bsaskinfo a WITH(NOLOCK), bsAskTypeSet t WITH(NOLOCK)
- WHERE a.typeid=t.id
- AND a.isonline=1
- AND provinceids LIKE '%,'+@provinceID+',%'
- ORDER BY a.updatedate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcBsAskInfoByXmlSelect] Script Date: 2018/12/13 19:09:36 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcBsAskInfoByXmlSelect]
- (
- @ProvinceId INT
- )
- AS
- --INSERT INTO procLog SELECT 'ProcBsAskInfoByXmlSelect', @ProvinceId, GETDATE()
- BEGIN
- SELECT TOP 5000 '/ask/' + CONVERT(VARCHAR,ID) + '.html' link
- FROM bsAskInfo WITH(NOLOCK)
- WHERE IsOnline = 1
- AND ProvinceIds LIKE '%,' + LTRIM(STR(@ProvinceId)) + '%'
- AND SolveDate > GETDATE() - 14
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcbsASKInfoHotQuestionSelect] Script Date: 2018/12/13 19:09:36 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:Nick
- --说明:获取求职互助热门话题
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcbsASKInfoHotQuestionSelect]
- (
- @ProvinceID INT
- )
- AS
- BEGIN TRY
- /*
- SELECT TOP 10 a.Id, a.Title
- FROM bsAskInfo a WITH(NOLOCK)
- WHERE a.IsOnline = 1
- AND ProvinceIds LIKE '%'+CONVERT(VARCHAR(10),@ProvinceID)+'%'
- AND AddDate > DATEADD(MONTH, -1, GETDATE())
- ORDER BY a.ClickNumber DESC
- */
- SELECT TOP 10 ID, Title
- FROM SearchDb..bsAskInfoHot WITH(NOLOCK)
- WHERE ProvinceId = @ProvinceId
- ORDER BY ClickNumber DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcBsAskInfoIdByBatchUpdate] Script Date: 2018/12/13 19:09:36 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --sean 2014-8-13
- CREATE PROCEDURE [dbo].[ProcBsAskInfoIdByBatchUpdate]
- AS
- BEGIN
- SELECT TOP 1000 bsAskInfoId INTO #t FROM Marketdb..bsaskInfoInclude where checkdate > '' AND IncludeDate IS NULL ORDER BY bsAskInfoId
- INSERT INTO bsAskInfo(Title, Url, ClassID, Question, Answer, TypeID, Mark, UserName, AddUserID, AddDate, Comment, SolveDate, IsOnline, UpdateDate, ProvinceIds, GetWay, ReferUrl, ClickNumber)
- SELECT Title, Url, ClassID, Question, Answer, TypeID, Mark, UserName, AddUserID, AddDate + DATEDIFF(DAY, AddDate, GETDATE() -1 ),
- Comment, SolveDate + DATEDIFF(DAY, SolveDate, GETDATE() -1 ), IsOnline, UpdateDate + DATEDIFF(DAY, UpdateDate, GETDATE() -1 ), ProvinceIds, GetWay, ReferUrl, ClickNumber
- FROM bsAskInfo
- WHERE ID IN(SELECT bsAskInfoId FROM #t)
- DELETE bsAskInfo WHERE ID IN(SELECT bsAskInfoId FROM #t)
- DELETE Marketdb..bsaskInfoInclude WHERE bsAskInfoId NOT IN (SELECT ID FROM bsAskInfo)
- --------------------------
- INSERT INTO Marketdb..bsaskInfoInclude
- SELECT Id, REPLACE(ProvinceIds, ',', ''), NULL, NULL
- FROM bsAskInfo WITH(NOLOCK)
- WHERE LEN(provinceids) < 10
- AND ID NOT IN(SELECT bsAskInfoId FROM Marketdb..bsaskInfoInclude)
- /*
- INSERT INTO Marketdb..bsaskInfoInclude
- SELECT a.Id, b.Id, NULL, NULL
- FROM bsAskInfo a WITH(NOLOCK), dcProvince b
- WHERE LEN(a.provinceids) > 10
- AND a.ID NOT IN(SELECT bsAskInfoId FROM Marketdb..bsaskInfoInclude)
- */
- END
-
- GO
- /****** Object: StoredProcedure [dbo].[ProcBsAskInfoIncludeSelect] Script Date: 2018/12/13 19:09:36 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --sean 2014-8-13
- CREATE PROCEDURE [dbo].[ProcBsAskInfoIncludeSelect]
- AS
- BEGIN
- SELECT TOP 100 id, ProvinceId, bsAskInfoId
- FROM MarketDb..bsAskInfoInclude
- ORDER BY ISNULL(CheckDate, '2000-1-1'), IncludeDate, BsAskInfoId
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcbsAskInfoNewSelect] Script Date: 2018/12/13 19:09:36 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.27
- --创建人:Nick
- --说明:得到最新5条求职互助
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcbsAskInfoNewSelect]
- (
- @ProvinceID INT,
- @SubSiteID INT
- )
- AS
- BEGIN TRY
- SELECT TOP 5 ID,Title
- FROM bsAskInfo WITH(NOLOCK)
- WHERE IsOnline = 1
- AND (Provinceids LIKE '%'+CONVERT(VARCHAR(10),@ProvinceID)+'%'
- OR Provinceids LIKE '%'+CONVERT(VARCHAR(10),@SubSiteID)+'%')
- ORDER BY UpdateDate DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcbsAskInfoSelect] Script Date: 2018/12/13 19:09:37 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:Nick
- --说明:求职互助列表
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcbsAskInfoSelect]
- (
- @TypeId INT,
- @ProvinceId INT,
- @KeyWord VARCHAR(50)
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @SQL VARCHAR(1000)
- SET @SQL = 'SELECT TOP 1000 a.Id, a.title, a.TypeId, a.solvedate, a.updatedate, t.Typename
- FROM bsAskInfo a WITH(NOLOCK), bsAskTypeSet t WITH(NOLOCK)
- WHERE a.TypeId = t.Id
- AND a.isonline = 1
- AND ProvinceIds = '',' + CONVERT(VARCHAR(10), @ProvinceId) + ',''
- '
- IF @TypeId <> 0
- BEGIN
- SET @SQL = @SQL + ' AND a.TypeId = ' + CONVERT(VARCHAR(10), @TypeId)
- END
- IF @KeyWord <> ''
- BEGIN
- SET @SQL = @SQL + ' AND a.Title LIKE ''%' + dbo.SafeSql(@KeyWord) + '%'''
- END
- SET @SQL = @SQL + ' ORDER BY a.UpdateDate DESC '
- --print @sql
- EXEC(@SQL)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcbsASKTagInfoByIDSelect] Script Date: 2018/12/13 19:09:37 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:Nick
- --说明:获取求职互助标签
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcbsASKTagInfoByIDSelect]
- @ID INT
- AS
- BEGIN TRY
- SELECT * FROM bsASKTagInfo WHERE ID = @ID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procbsASKTypeSetAllSelect] Script Date: 2018/12/13 19:09:37 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.04
- --创建人:Nick
- --说明:select bsASKTypeSet
- --#####################################################
- CREATE PROCEDURE [dbo].[procbsASKTypeSetAllSelect]
- AS
- BEGIN TRY
- SELECT * FROM bsASKTypeSet WHERE id>0 AND typename<>'美通社' ORDER BY orderno
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcbsAskTypeSetSelect] Script Date: 2018/12/13 19:09:37 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.27
- --创建人:Nick
- --说明:得到热门求职互助类别
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcbsAskTypeSetSelect]
- AS
- BEGIN TRY
- SELECT TOP 14 *
- FROM bsAskTypeSet WITH(NOLOCK)
- WHERE ID>0
- ORDER BY Newid()
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcBsPageClickLogInsert] Script Date: 2018/12/13 19:09:37 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcBsPageClickLogInsert]
- AS
- BEGIN
- DECLARE @M AS VARCHAR(6)
- SET @m = CONVERT(VARCHAR(6), GETDATE(), 112)
- DELETE bsPageClickLog WHERE CountMonth = @M
- -- 职场资讯
- INSERT bsPageClickLog(PageType, PageId, ClickNumber, ClickNumberAll)
- SELECT 1, ID, ViewNumber, ViewNUmber_All FROM QlrcNews WITH(NOLOCK)
- --招聘会
- INSERT bsPageClickLog(PageType, PageId, ClickNumber)
- SELECT 2, ID, ViewNumber FROM recruitment WITH(NOLOCK)
- --文档下载
- INSERT bsPageClickLog(PageType, PageId, ClickNumber)
- SELECT 3, ID, dwnnum FROM dwndoc WITH(NOLOCK)
- DECLARE @ThisMonth AS VARCHAR(6), @PrevMonth AS VARCHAR(6)
- SELECT @ThisMonth = CONVERT(VARCHAR(6), GETDATE(), 112),
- @PrevMonth = CONVERT(VARCHAR(6), DATEADD(mm, -1, GETDATE()), 112)
- UPDATE a
- SET a.Increase = a.ClickNumber - b.ClickNumber,
- a.IncreaseAll = a.ClickNumberAll - b.ClickNumberAll
- FROM bsPageClickLog a, bsPageClickLog b
- WHERE a.CountMonth = @ThisMonth
- AND b.CountMonth = @PrevMonth
- AND a.PageID = b.PageID
- AND a.PageType = b.PageType
- UPDATE bsPageClickLog
- SET Increase = ClickNumber,
- IncreaseAll = ClickNumberAll
- FROM bsPageClickLog
- WHERE CountMonth = @ThisMonth
- AND PageID NOT IN(
- SELECT PageID FROM bsPageClickLog WITH(NOLOCK)
- WHERE CountMonth = @PrevMonth)
- END
- GO
- /****** Object: StoredProcedure [dbo].[procBsSourceDetailInsert] Script Date: 2018/12/13 19:09:38 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
-
- --创建人 Nick 20141015
- --用于记录每个页面的来源访问情况
- CREATE PROCEDURE [dbo].[procBsSourceDetailInsert]
- (
- @SubSiteID INT,
- @SiteType SMALLINT,
- @SessionID VARCHAR(100),
- @Referer VARCHAR(200),
- @IP VARCHAR(15),
- @Url VARCHAR(200)
- )
- AS
- return 0
- BEGIN
- DECLARE @MaxID INT
- SELECT @MaxID = Id FROM BsSourceDetail WITH(NOLOCK) WHERE SessionId = @SessionID
- IF @MaxID IS NULL
- BEGIN
- INSERT INTO BsSourceDetail
- VALUES (@SubSiteID, @SiteType, @SessionID, @IP, @Referer, 1, GETDATE(), GETDATE())
- SET @MaxID = @@IDENTITY
- END
- ELSE
- BEGIN
- UPDATE BsSourceDetail
- SET ViewNumber = ViewNumber+1, LastViewDate = GETDATE()
- WHERE ID = @MaxId
- END
- RETURN @MaxID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procBsSourceDetailInsert2] Script Date: 2018/12/13 19:09:38 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
-
- --创建人 Nick 20141015
- --用于记录每个页面的来源访问情况
- CREATE PROCEDURE [dbo].[procBsSourceDetailInsert2]
- (
- @SubSiteID INT,
- @SiteType SMALLINT,
- @SessionID VARCHAR(100),
- @Referer VARCHAR(200),
- @IP VARCHAR(15),
- @Url VARCHAR(200)
- )
- AS
- return 0
- BEGIN
- DECLARE @MaxID INT
- SELECT @MaxID = Id FROM BsSourceDetail WITH(NOLOCK) WHERE SessionId = @SessionID
- IF @MaxID IS NULL
- BEGIN
- INSERT INTO BsSourceDetail
- VALUES (@SubSiteID, @SiteType, @SessionID, @IP, @Referer, 1, GETDATE(), GETDATE())
- SET @MaxID = @@IDENTITY
- END
- ELSE
- BEGIN
- UPDATE BsSourceDetail
- SET ViewNumber = ViewNumber+1, LastViewDate = GETDATE()
- WHERE ID = @MaxId
- END
- RETURN @MaxID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procBsSourceDetailUpdate] Script Date: 2018/12/13 19:09:38 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- /****** Object: StoredProcedure [dbo].[procBsSourceDetailInsert] Script Date: 10/20/2014 08:46:46 ******/
- --创建人 Nick 20141015
- --用于记录每个页面的来源访问情况
- CREATE PROCEDURE [dbo].[procBsSourceDetailUpdate]
- (
- @bsSourceDetailID INT,
- @url VARCHAR(200)
- )
- AS
- return
- BEGIN TRY
- UPDATE BsSourceDetail
- SET ViewNumber = ViewNumber+1, LastViewDate = GETDATE()
- WHERE ID = @bsSourceDetailID
- IF @@ROWCOUNT = 0
- BEGIN
- IF NOT EXISTS(SELECT 'x' FROM BsSourceDetail WITH(NOLOCK) WHERE ID = @bsSourceDetailID)
- BEGIN
- SET IDENTITY_INSERT LogDb..bsSourceDetail ON
- INSERT INTO BsSourceDetail(ID, SubSiteID, SiteType, SessionID, IP, Referer, ViewNumber, LastViewDate, AddDate)
- SELECT ID, SubSiteID, SiteType, SessionID, IP, Referer, ViewNumber, LastViewDate, AddDate
- FROM BsSourceDetailAll WITH(NOLOCK) WHERE Id = @bsSourceDetailID
- SET IDENTITY_INSERT LogDb..bsSourceDetail OFF
- DELETE FROM BsSourceDetailAll WHERE Id = @bsSourceDetailID
- UPDATE BsSourceDetail
- SET ViewNumber = ViewNumber+1, LastViewDate = GETDATE()
- WHERE ID = @bsSourceDetailID
- END
- END
- END TRY
- BEGIN CATCH
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procBsSourceDetailUpdate2] Script Date: 2018/12/13 19:09:38 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- /****** Object: StoredProcedure [dbo].[procBsSourceDetailInsert] Script Date: 10/20/2014 08:46:46 ******/
- --创建人 Nick 20141015
- --用于记录每个页面的来源访问情况
- CREATE PROCEDURE [dbo].[procBsSourceDetailUpdate2]
- (
- @bsSourceDetailID INT,
- @url VARCHAR(200)
- )
- AS
- return
- BEGIN TRY
- UPDATE BsSourceDetail
- SET ViewNumber = ViewNumber+1, LastViewDate = GETDATE()
- WHERE ID = @bsSourceDetailID
- IF @@ROWCOUNT = 0
- BEGIN
- IF NOT EXISTS(SELECT 'x' FROM BsSourceDetail WITH(NOLOCK) WHERE ID = @bsSourceDetailID)
- BEGIN
- SET IDENTITY_INSERT LogDb..bsSourceDetail ON
- INSERT INTO BsSourceDetail(ID, SubSiteID, SiteType, SessionID, IP, Referer, ViewNumber, LastViewDate, AddDate)
- SELECT ID, SubSiteID, SiteType, SessionID, IP, Referer, ViewNumber, LastViewDate, AddDate
- FROM BsSourceDetailAll WITH(NOLOCK) WHERE Id = @bsSourceDetailID
- SET IDENTITY_INSERT LogDb..bsSourceDetail OFF
- DELETE FROM BsSourceDetailAll WHERE Id = @bsSourceDetailID
- UPDATE BsSourceDetail
- SET ViewNumber = ViewNumber+1, LastViewDate = GETDATE()
- WHERE ID = @bsSourceDetailID
- END
- END
- END TRY
- BEGIN CATCH
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcBsSourceRefererCountUpdate] Script Date: 2018/12/13 19:09:38 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --创建人 Nick 20141020
- --生成推广每天的统计数据
- CREATE PROCEDURE [dbo].[ProcBsSourceRefererCountUpdate]
- AS
- BEGIN
- DECLARE @Countdate VARCHAR(8), @Referer_AllNum INT,
- @Referer_Ref VARCHAR(200), @dcSubSiteID INT,
- @dcSubsiteDomain VARCHAR(50), @CountNumber AS INT,
- @p INT, @StartTime DATETIME , @EndTime DATETIME
-
- SELECT @CountDate = CONVERT(VARCHAR(8), GETDATE() - 1, 112),
- @StartTime = CONVERT(VARCHAR(10), GETDATE() - 1, 120),
- @EndTime = CONVERT(VARCHAR(10), GETDATE(), 120)
- --select @CountDate, @StartTime, @EndTime
- --SET @CountDate = '20141020'
- --SET @StartTime = '2014-10-20'
- --SET @EndTime = '2014-10-20 23:59:00'
- --删除当前统计天数据
- DELETE FROM bsSourceRefererCount WHERE CountDate = @CountDate
- DELETE FROM bsSourceCount WHERE CountDate = @CountDate
-
- DECLARE @t AS TABLE(
- ID INT,
- Domain VARCHAR(100),
- CountNumber INT
- )
-
- INSERT INTO @t SELECT Id, SubSiteUrl, 200 FROM dcSubsite WITH(NOLOCK) ORDER BY Id
- DECLARE curSite CURSOR FOR
- SELECT Id, Domain, CountNumber FROM @t ORDER BY Id
- FOR READ ONLY
- OPEN curSite
- FETCH NEXT FROM curSite INTO @dcSubSiteID, @dcSubsiteDomain, @CountNumber
- WHILE @@FETCH_STATUS = 0
- BEGIN
- INSERT INTO bsSourceRefererCount(subSiteID, CountDate, Referer, HowMany, SiteType)
- SELECT TOP (@CountNumber) @dcSubSiteID, @CountDate, LEFT(Referer, CHARINDEX('/', Referer, 8)) Ref, COUNT(*), 1
- FROM bsSourceDetailAll WITH(NOLOCK)
- WHERE CHARINDEX('/', Referer, 8) > 0
- AND SubSiteID = @dcSubSiteID
- AND SiteType = 1
- AND LastViewDate > @StartTime AND LastViewDate < @EndTime
- AND CHARINDEX(SUBSTRING(@dcSubsiteDomain, CHARINDEX('.', @dcSubsiteDomain) + 1, LEN(@dcSubsiteDomain)), Referer, 0) = 0
- GROUP BY LEFT(Referer, CHARINDEX('/', Referer, 8))
- ORDER BY COUNT(*) DESC
-
- IF @dcSubSiteID > 0 AND LEN(@dcSubSiteID) = 2
- BEGIN
- --手机m站
- INSERT INTO bsSourceRefererCount(subSiteID, CountDate, Referer, HowMany, SiteType)
- SELECT TOP (@CountNumber) @dcSubSiteID, @CountDate, LEFT(Referer, CHARINDEX('/', Referer, 8)) Ref, COUNT(*), 2
- FROM bsSourceDetailAll WITH(NOLOCK)
- WHERE CHARINDEX('/', Referer, 8) > 0
- AND SubSiteID = @dcSubSiteID
- AND SiteType = 2
- AND LastViewDate > @StartTime AND LastViewDate < @EndTime
- AND CHARINDEX(SUBSTRING(@dcSubsiteDomain, CHARINDEX('.', @dcSubsiteDomain) + 1, LEN(@dcSubsiteDomain)), Referer, 0) = 0
- GROUP BY LEFT(Referer, CHARINDEX('/', Referer, 8))
- ORDER BY COUNT(*) DESC
-
- --县级站
- INSERT INTO bsSourceRefererCount(subSiteID, CountDate, Referer, HowMany, SiteType)
- SELECT TOP (@CountNumber) CONVERT(VARCHAR(10), @dcSubSiteID) + '0000', @CountDate, LEFT(Referer, CHARINDEX('/', Referer, 8)) Ref, COUNT(*), 1
- FROM bsSourceDetailAll WITH(NOLOCK)
- WHERE CHARINDEX('/', Referer, 8) > 0
- AND SUBSTRING(CONVERT(VARCHAR(10), SubSiteID), 0, 2) = @dcSubSiteID
- AND LEN(SubSiteID) = 6
- AND LastViewDate > @StartTime AND LastViewDate < @EndTime
- AND CHARINDEX(SUBSTRING(@dcSubsiteDomain, CHARINDEX('.', @dcSubsiteDomain) + 1, LEN(@dcSubsiteDomain)), Referer, 0) = 0
- GROUP BY LEFT(Referer, CHARINDEX('/', Referer, 8))
- ORDER BY COUNT(*) DESC
- END
- FETCH NEXT FROM curSite INTO @dcSubSiteID, @dcSubsiteDomain, @CountNumber
- END
- CLOSE curSite
- DEALLOCATE curSite
- --修改bsSourceRefererCount typeID 字段
- --搜索引擎
- UPDATE a SET a.TypeID = 1,
- a.Referer = c.Item_Name
- FROM bsSourceRefererCount a, Referer_Item_Keywords b, Referer_Item c
- WHERE b.Item_Id = c.ID
- AND CHARINDEX(b.Keywords, a.referer) > 0
- AND C.ID IN (3, 8, 14, 11, 31, 45, 62, 74)
- AND CountDate = @CountDate
-
- --修改外部链接 typeid
- UPDATE bsSourceRefererCount
- SET TypeID = 2, SiteType = 1
- WHERE (CHARINDEX('mail.qq.com', referer) > 0
- OR CHARINDEX('mail.126.com', referer) > 0
- OR CHARINDEX('mail.163.com', referer) > 0
- OR CHARINDEX('mail.sina.com.cn', referer) > 0
- OR CHARINDEX('mail.10086.cn', referer) > 0
- OR CHARINDEX('mail.sohu.com', referer) > 0
- OR CHARINDEX('mail.189.cn', referer) > 0
- OR CHARINDEX('www.126.com', referer) > 0
- OR CHARINDEX('www.2345.com', referer) > 0
- OR CHARINDEX('www.hao123.com', referer) > 0
- OR CHARINDEX('www.dn1234.com', referer) > 0
- OR CHARINDEX('hao.360.com', referer) > 0
- OR CHARINDEX('www.3600.com', referer) > 0
- )
- AND TypeID IS NULL
- AND CountDate = @CountDate
-
- --修改外部链接其他
- UPDATE bsSourceRefererCount
- SET TypeID = 2, SiteType = 1, Referer='外部链接其他'
- WHERE TypeID IS NULL
- AND CountDate = @CountDate
-
- --修改bssourcecount表数据--
- --省份、城市 访问的访客数、ip数
- INSERT INTO bsSourceCount (SubSiteID, CountDate, VisitorCount, IPCount, SiteType)
- SELECT SubSiteID, @CountDate, COUNT(DISTINCT SessionID), COUNT(DISTINCT IP), SiteType
- FROM bsSourceDetailAll WITH(NOLOCK)
- WHERE LastViewDate > @StartTime AND LastViewDate < @EndTime
- AND LEN(SubSiteID) < = 4
- GROUP BY SubSiteID, SiteType
-
- --县级市 访问的访客数、IP数
- INSERT INTO bsSourceCount (SubSiteID, CountDate, VisitorCount, IPCount, SiteType)
- SELECT SUBSTRING(CONVERT(VARCHAR(10), SubSiteID), 0, 2) + '0000', @CountDate, COUNT(DISTINCT SessionID), COUNT(DISTINCT IP), 1
- FROM bsSourceDetailAll
- WHERE LastViewDate > @StartTime AND LastViewDate < @EndTime
- AND LEN(SubSiteID)=6
- GROUP BY SUBSTRING(CONVERT(VARCHAR(10), SubSiteID), 0, 2)
-
- --省份、城市、县级市 访问的来源总数
- UPDATE bsSourceCount
- SET RefererCount = VisitorCount
- WHERE CountDate = @CountDate
-
- --省份 城市 只访问一个页面的访客数量
- UPDATE a
- SET a.VisitOnePageCount = b.cnt
- FROM bsSourceCount a,
- ( SELECT SubSiteID, SiteType , COUNT(*) cnt
- FROM bsSourceDetailAll WITH(NOLOCK)
- WHERE LastViewDate > @StartTime AND LastViewDate < @EndTime
- AND LEN(SubSiteID) < = 4
- AND ViewNumber = 1
- GROUP BY SubSiteID, SiteType
- ) b
- WHERE a.SubSiteID = b.SubSiteID
- AND a.SiteType = b.SiteType
- AND a.CountDate = @CountDate
-
-
- --县级站 只访问一个页面的访客数量
- UPDATE a
- SET a.VisitOnePageCount = b.cnt
- FROM bsSourceCount a,
- (SELECT SUBSTRING(CONVERT(VARCHAR(10), SubSiteID), 0, 2) + '0000' SubSiteID, SiteType , COUNT(*) cnt
- FROM bsSourceDetailAll WITH(NOLOCK)
- WHERE LastViewDate > @StartTime AND LastViewDate < @EndTime
- AND LEN(SubSiteID)=6
- AND ViewNumber = 1
- GROUP BY SubSiteID, SiteType
- ) b
- WHERE a.SubSiteID = b.SubSiteID
- AND a.SiteType = b.SiteType
- AND a.CountDate = @CountDate
- --省份、城市 访问小时数合计
- UPDATE a
- SET a.VisitTimeCount = b.tSum
- FROM bsSourceCount a,
- (SELECT SubSiteID, SiteType, SUM(DATEDIFF(Second, AddDate, LastViewDate)) tSum
- FROM bsSourceDetailAll WITH(NOLOCK)
- WHERE LastViewDate > @StartTime AND LastViewDate < @EndTime
- AND LEN(SubSiteID) < = 4
- GROUP BY SubSiteID, SiteType
- ) b
- WHERE a.SubSiteID = b.SubSiteID
- AND a.SiteType = b.SiteType
- AND a.CountDate = @CountDate
- --县级市 访问小时数合计
- UPDATE a
- SET a.VisitTimeCount = b.tSum
- FROM bsSourceCount a,
- (SELECT SUBSTRING(CONVERT(VARCHAR(10), SubSiteID), 0, 2) + '0000' AS SubSiteID, SiteType,
- SUM(DATEDIFF(Second, AddDate, LastViewDate)) AS tSum
- FROM bsSourceDetailAll WITH(NOLOCK)
- WHERE LastViewDate > @StartTime AND LastViewDate < @EndTime
- AND LEN(SubSiteID)=6 GROUP BY SUBSTRING(CONVERT(VARCHAR(10), SubSiteID), 0, 2) + '0000', SiteType
- ) b
- WHERE a.SubSiteID = b.SubSiteID
- AND a.SiteType = b.SiteType
- AND a.CountDate = @CountDate
-
- --省份、城市 个人手机注册数
- UPDATE A
- SET A.PersonRegisterCount = B.CNT
- FROM bsSourceCount A,
- (SELECT dcSubSiteID, COUNT(*) CNT
- FROM PaMain
- WHERE (RegisterMode in (4, 5, 6) OR RegisterFrom > 1)
- AND AddDate > @StartTime
- AND AddDate < @EndTime
- GROUP BY dcSubSiteID
- ) b
- WHERE a.CountDate = @CountDate
- AND SiteType = 2
- AND A.SubSiteID = B.dcSubSiteID
-
- --省份、城市 个人电脑注册数
- UPDATE A
- SET A.PersonRegisterCount = B.CNT
- FROM bsSourceCount A,
- (SELECT dcSubSiteID, COUNT(*) CNT
- FROM PaMain
- WHERE (RegisterMode = 1 OR RegisterType = 101)
- AND AddDate > @StartTime
- AND AddDate < @EndTime
- GROUP BY dcSubSiteID
- ) b
- WHERE a.CountDate = @CountDate
- AND SiteType = 1
- AND A.SubSiteID = B.dcSubSiteID
-
- --省份、城市 企业电脑注册数
- UPDATE A
- SET A.CompanyRegisterCount = B.CNT
- FROM bsSourceCount A,
- (SELECT dcSubSiteID, COUNT(*) CNT
- FROM CpMain
- WHERE RegisterMode = 1
- AND RegDate > @StartTime
- AND RegDate < @EndTime
- GROUP BY dcSubSiteID
- ) b
- WHERE a.CountDate = @CountDate
- AND SiteType = 1
- AND A.SubSiteID = B.dcSubSiteID
-
- --搜索引擎数量
- UPDATE a
- SET a.SearchEngineCount = b.cnt
- FROM bsSourceCount a,
- (SELECT SubSiteID, SiteType, SUM(HowMany) cnt
- FROM bsSourceRefererCount
- WHERE CountDate = @CountDate
- AND TypeID = 1
- Group By SubSiteID, SiteType
- ) b
- WHERE a.SubSiteID = b.SubSiteID
- AND a.SiteType = b.SiteType
- AND a.CountDate = @CountDate
-
- --外部链接数量
- UPDATE a
- SET a.ExternalLinkCount = b.cnt
- FROM bsSourceCount a,
- (SELECT SubSiteID, SiteType, SUM(HowMany) cnt
- FROM bsSourceRefererCount
- WHERE CountDate = @CountDate
- AND TypeID = 2
- Group By SubSiteID, SiteType
- ) b
- WHERE a.SubSiteID = b.SubSiteID
- AND a.SiteType = b.SiteType
- AND a.CountDate = @CountDate
-
- --直接输入数量
- --省份、城市 访问的直接输入数量
- UPDATE a
- SET a.DirectInputCount = b.cnt
- FROM bsSourceCount a,
- (SELECT SubSiteID, SiteType, COUNT(*) cnt
- FROM bsSourceDetailAll WITH(NOLOCK)
- WHERE LastViewDate > @StartTime
- AND LastViewDate < @EndTime
- AND LEN(SubSiteID) < =4
- AND Referer = ''
- Group By SubSiteID, SiteType
- ) b
- WHERE a.SubSiteID = b.SubSiteID
- AND a.SiteType = b.SiteType
- AND a.CountDate = @CountDate
-
- --县级市 访问的访直接输入数量
- UPDATE a
- SET a.DirectInputCount = b.cnt
- FROM bsSourceCount a,
- (SELECT SUBSTRING(CONVERT(VARCHAR(10), SubSiteID), 0, 2) + '0000' AS SubSiteID, 1 AS SiteType, COUNT(*) cnt
- FROM bsSourceDetailAll WITH(NOLOCK)
- WHERE LastViewDate > @StartTime
- AND LastViewDate < @EndTime
- AND LEN(SubSiteID)=6
- AND Referer = ''
- Group By SUBSTRING(CONVERT(VARCHAR(10), SubSiteID), 0, 2) + '0000', SiteType
- ) b
- WHERE a.SubSiteID = b.SubSiteID
- AND a.SiteType = b.SiteType
- AND a.CountDate = @CountDate
-
- --百度竞价数量 BaiduBiddingCount
- --每天注册简历数
- UPDATE a
- SET BaiduBiddingResumeCount = B.resumeCnt
- FROM bsSourceCount a,
- (SELECT province_Id, SUM(toDayResume) AS resumeCnt
- FROM Url
- WHERE BeginDate > @StartTime AND BeginDate < @EndTime
- GROUP BY province_Id
- ) b
- WHERE a.SubSiteID = b.province_Id
- AND a.CountDate = @CountDate
-
- --每天注册单位数
- UPDATE a
- SET BaiduBiddingCompanyCount = B.companyCnt
- FROM bsSourceCount a,
- (SELECT province_Id, SUM(toDayCompany) AS companyCnt
- FROM Url
- WHERE BeginDate > @StartTime AND BeginDate < @EndTime
- GROUP BY province_Id
- ) b
- WHERE a.SubSiteID = b.province_Id
- AND a.CountDate = @CountDate
-
- --清空表数据 加入备份表
- --INSERT INTO bsSourceDetailBak SELECT * FROM bsSourceDetail
- --TRUNCATE TABLE bsSourceDetail
- SELECT * INTO #t FROM bsSourceDetailAll WHERE LastViewDate > CONVERT(VARCHAR(10), GETDATE(), 120)
- TRUNCATE TABLE LogDb..bsSourceDetailAll
- INSERT INTO bsSourceDetailAll SELECT * FROM #t
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCaActiveStatusByCaMainIDSelect] Script Date: 2018/12/13 19:09:39 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.30
- --创建人:John
- --说明:获取企业用户的当前状态
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCaActiveStatusByCaMainIDSelect]
- (
- @caMainID INT
- )
- AS
- BEGIN
- SELECT TOP 1 * FROM caActiveStatus WHERE camainid = @caMainID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCaActiveStatusUpdate] Script Date: 2018/12/13 19:09:39 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcCaActiveStatusUpdate]
- AS
- BEGIN
- BEGIN TRY
- INSERT caActiveStatus(caMainId)
- SELECT DISTINCT caMainId FROM cpSession WHERE RefreshDate > DATEADD(MINUTE, -2, GETDATE())
- AND caMainId NOT IN(SELECT caMainId FROM caActiveStatus)
- END TRY
- BEGIN CATCH
- END CATCH
- DELETE caActiveStatus
- WHERE caMainId NOT IN(SELECT caMainId FROM cpSession WHERE RefreshDate > DATEADD(MINUTE, -2, GETDATE()))
-
- SELECT caMainId, MIN(Id) ID, MIN(InterviewDate) InterviewDate
- INTO #t
- FROM viPlan WHERE InterviewDate > GETDATE() AND IsCancel = 0
- GROUP BY caMainId
- UPDATE #t SET InterviewDate = (SELECT InterviewDate FROM viPlan WHERE ID= #t.Id)
- UPDATE caActiveStatus SET viPlanId = NULL, InterviewDate = NULL WHERE viPlanId > 0
- INSERT caActiveStatus(caMainId, IsOnline)
- SELECT caMainId, 0 FROM #t WHERE caMainId NOT IN(SELECT caMainId FROM caActiveStatus)
-
- UPDATE a
- SET a.viPlanId = b.Id,
- a.InterviewDate = b.InterviewDate
- FROM caActiveStatus a, #t b
- WHERE a.caMainId = b.caMainId
- UPDATE caActiveStatus SET IsVi = 0 WHERE caMainId NOT IN(SELECT caMainId FROM viRoom WHERE EndDate IS NULL) AND IsVi = 1
- UPDATE caActiveStatus SET IsVi = 1 WHERE caMainId IN(SELECT caMainId FROM viRoom WHERE EndDate IS NULL)
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCaFavoratecaDailyGiftLogcaActiveLogSelect] Script Date: 2018/12/13 19:09:39 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --创建时间:2017-11-26
- --创建人:harry
- --说明:数据统计 --获取企业 收藏和下载的简历数量
- --#####################################################
- CREATE PROCEDURE [dbo].[procCaFavoratecaDailyGiftLogcaActiveLogSelect]
- (
- @beginDate DATETIME,
- @endDate DATETIME,
- @caMainId INT,
- @cpMainId INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- CREATE TABLE #t(
- viewInt INT NULL,
- downloadInt INT NULL,
- favourateInt INT NULL,
- intentionInt INT NULL,
- interviewInt INT NULL,
- addDate VARCHAR(10)
- )
- --生成数据表
- IF @caMainId =0
- BEGIN
- --计算收藏的简历量
-
- --更新#t
- INSERT INTO #t (favourateInt,addDate)
- SELECT COUNT (1) AS favourateInt, CONVERT(varchar(10),AddDate,23) AS addDate
- FROM caFavorate
- WHERE caMainId IN(select id FROM caMain WITH(NOLOCK) WHERE cpMainId = @cpMainId)
- AND AddDate BETWEEN @beginDate AND @endDate
- GROUP BY CONVERT(varchar(10),AddDate,23)
-
- --计算下载的简历量
- SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS downloadInt
- INTO #td11
- FROM caDailyGiftLog
- WHERE cpMainId = @cpMainId
- AND AddDate BETWEEN @beginDate AND @endDate
- GROUP BY CONVERT(varchar(10),AddDate,23)
-
- SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS downloadInt
- INTO #td12
- FROM caActiveLog
- WHERE cpMainId = @cpMainId
- AND AddDate BETWEEN @beginDate AND @endDate
- GROUP BY CONVERT(varchar(10),AddDate,23)
-
- --更新#t,插入
-
- UPDATE #t
- SET downloadInt= ISNULL(#t.downloadInt,0)+#td11.downloadInt
- FROM #td11
- WHERE #td11.addDate = #t.addDate
-
- INSERT INTO #t(downloadInt,addDate)
- SELECT downloadInt, addDate
- FROM #td11
- WHERE #td11.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
-
- DROP TABLE #td11
- --更新#t,插入
- UPDATE #t
- SET downloadInt= ISNULL(#t.downloadInt,0)+#td12.downloadInt
- FROM #td12
- WHERE #td12.addDate = #t.addDate
-
- INSERT INTO #t(downloadInt,addDate)
- SELECT downloadInt, addDate
- FROM #td12
- WHERE #td12.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
-
- DROP TABLE #td12
-
- --计算浏览量
- SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS viewInt
- INTO #td13
- FROM CaCvViewLog
- WHERE caMainId IN(select id FROM caMain WITH(NOLOCK) WHERE cpMainId = @cpMainId)
- AND AddDate BETWEEN @beginDate AND @endDate
- GROUP BY CONVERT(varchar(10),AddDate,23)
- --计算应聘邀请
- SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS viewInt
- INTO #td14
- FROM caCvIntention
- WHERE caMainId IN(select id FROM caMain WITH(NOLOCK) WHERE cpMainId = @cpMainId)
- AND AddDate BETWEEN @beginDate AND @endDate
- GROUP BY CONVERT(varchar(10),AddDate,23)
- --计算面试通知
- SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS viewInt
- INTO #td15
- FROM exInterview
- WHERE JobID IN(
- SELECT ID FROM Job WITH(NOLOCK)
- WHERE CpMainID = @cpMainID
- )
- AND AddDate BETWEEN @beginDate AND @endDate
- GROUP BY CONVERT(varchar(10),AddDate,23)
- --浏览,邀请,面试 数据更新插入
- UPDATE #t
- SET viewInt= ISNULL(#t.viewInt,0)+#td13.viewInt
- FROM #td13
- WHERE #td13.addDate = #t.addDate
-
- INSERT INTO #t(viewInt,addDate)
- SELECT viewInt, addDate
- FROM #td13
- WHERE #td13.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
- DROP TABLE #td13
-
- UPDATE #t
- SET intentionInt= ISNULL(#t.intentionInt,0)+#td14.viewInt
- FROM #td14
- WHERE #td14.addDate = #t.addDate
-
- INSERT INTO #t(intentionInt,addDate)
- SELECT viewInt, addDate
- FROM #td14
- WHERE #td14.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
- DROP TABLE #td14
-
- UPDATE #t
- SET interviewInt= ISNULL(#t.interviewInt,0)+#td15.viewInt
- FROM #td15
- WHERE #td15.addDate = #t.addDate
-
- INSERT INTO #t(interviewInt,addDate)
- SELECT viewInt, addDate
- FROM #td15
- WHERE #td15.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
- DROP TABLE #td15
-
- END
- ELSE
- BEGIN
- --计算收藏的简历量
- INSERT INTO #t (favourateInt,addDate)
- SELECT COUNT (1) AS favourateInt, CONVERT(varchar(10),AddDate,23) AS addDate
- FROM caFavorate
- WHERE caMainId = @caMainId
- AND AddDate BETWEEN @beginDate AND @endDate
- GROUP BY CONVERT(varchar(10),AddDate,23)
-
-
- --计算下载的简历量
- SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS downloadInt
- INTO #td21
- FROM caDailyGiftLog
- WHERE caMainId = @caMainId
- AND AddDate BETWEEN @beginDate AND @endDate
- GROUP BY CONVERT(varchar(10),AddDate,23)
-
- SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS downloadInt
- INTO #td22
- FROM caActiveLog
- WHERE caMainId = @caMainId
- AND AddDate BETWEEN @beginDate AND @endDate
- GROUP BY CONVERT(varchar(10),AddDate,23)
-
- --更新#t
-
- UPDATE #t
- SET downloadInt= ISNULL(#t.downloadInt,0)+#td21.downloadInt
- FROM #td21
- WHERE #td21.addDate = #t.addDate
-
- INSERT INTO #t(downloadInt,addDate)
- SELECT downloadInt, addDate
- FROM #td21
- WHERE #td21.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
-
- DROP TABLE #td21
- --更新#t
- UPDATE #t
- SET downloadInt= ISNULL(#t.downloadInt,0)+#td22.downloadInt
- FROM #td22
- WHERE #td22.addDate = #t.addDate
-
- INSERT INTO #t(downloadInt,addDate)
- SELECT downloadInt, addDate
- FROM #td22
- WHERE #td22.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
-
- DROP TABLE #td22
-
- --计算浏览量
- SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS viewInt
- INTO #td23
- FROM CaCvViewLog
- WHERE caMainId = @caMainId
- AND AddDate BETWEEN @beginDate AND @endDate
- GROUP BY CONVERT(varchar(10),AddDate,23)
- --计算应聘邀请
- SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS viewInt
- INTO #td24
- FROM caCvIntention
- WHERE caMainId = @caMainId
- AND AddDate BETWEEN @beginDate AND @endDate
- GROUP BY CONVERT(varchar(10),AddDate,23)
- --计算面试通知
- SELECT CONVERT(varchar(10),AddDate,23) AS addDate, COUNT (1) AS viewInt
- INTO #td25
- FROM exInterview
- WHERE JobID IN(
- SELECT ID FROM Job WITH(NOLOCK)
- WHERE CaMainID = @caMainId
- )
- AND AddDate BETWEEN @beginDate AND @endDate
- GROUP BY CONVERT(varchar(10),AddDate,23)
- --浏览,邀请,面试 数据更新插入
- UPDATE #t
- SET viewInt= ISNULL(#t.viewInt,0)+#td23.viewInt
- FROM #td23
- WHERE #td23.addDate = #t.addDate
-
- INSERT INTO #t(viewInt,addDate)
- SELECT viewInt, addDate
- FROM #td23
- WHERE #td23.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
- DROP TABLE #td23
-
- UPDATE #t
- SET intentionInt= ISNULL(#t.intentionInt,0)+#td24.viewInt
- FROM #td24
- WHERE #td24.addDate = #t.addDate
-
- INSERT INTO #t(intentionInt,addDate)
- SELECT viewInt, addDate
- FROM #td24
- WHERE #td24.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
- DROP TABLE #td24
-
- UPDATE #t
- SET interviewInt= ISNULL(#t.interviewInt,0)+#td25.viewInt
- FROM #td25
- WHERE #td25.addDate = #t.addDate
-
- INSERT INTO #t(interviewInt,addDate)
- SELECT viewInt, addDate
- FROM #td25
- WHERE #td25.addDate NOT IN(SELECT addDate FROM #t WITH(NOLOCK))
- DROP TABLE #td25
- END
-
- SELECT * FROM #t ORDER BY addDate
- DROP TABLE #t
- END
- SET NOCOUNT OFF
- GO
- /****** Object: StoredProcedure [dbo].[procCaFeedbackHomepageSelect] Script Date: 2018/12/13 19:09:40 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --创建人 Lambo 20101010
- --用于网站首页查询来信答复
- CREATE PROCEDURE [dbo].[procCaFeedbackHomepageSelect]
- (
- @dcProvinceID SMALLINT
- )
- AS
- BEGIN
- -- SELECT TOP 15 a.*, c.Name
- -- FROM caFeedback a WITH(NOLOCK),
- -- caMain b WITH(NOLOCK),
- -- cpMain c WITH(NOLOCK)
- -- WHERE a.caMainID = b.id
- -- AND b.cpMainID = c.id
- -- AND a.homepage = 1
- -- AND c.dcProvinceID = 32
- -- AND c.Valid = 1
- -- AND b.IsDelete = 0
- -- AND b.IsPAuse = 0
- -- ORDER BY a.AddDate DESC
- SELECT TOP 15 ID newids,Preid ID,ProvinceID, Name, Message, AddDate, ReplyMan, ReplyMessage, ReplyDate
- FROM SearchDb..hpcaFeedbackDay WITH(NOLOCK)
- WHERE ProvinceID = @dcProvinceID
- ORDER BY newids
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCaJobCvMatchInsert] Script Date: 2018/12/13 19:09:41 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- ---------------------
- --创建人 Peter
- --时间 2016-10-13
- --企业精确匹配数据插入
- --peter 2018-4-2
- CREATE PROCEDURE [dbo].[procCaJobCvMatchInsert]
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @Today DATETIME
- SET @Today = GETDATE()
- --将最近一个月内企业个人交互存放到临时表
- SELECT JobID, cvMainID
- INTO #TCaJobCvOperateLog
- FROM caCvIntention WITH(NOLOCK)
- WHERE Adddate > GETDATE() - 30
- INSERT INTO #TCaJobCvOperateLog
- SELECT JobID, cvMainID
- FROM exInterview WITH(NOLOCK)
- WHERE Adddate > GETDATE() - 30
- AND NOT EXISTS(
- SELECT 'x'
- FROM #TCaJobCvOperateLog
- WHERE JobID = exInterview.JobID
- AND cvMainID = exInterview.cvMainID
- )
- INSERT INTO #TCaJobCvOperateLog
- SELECT JobID, cvMainID
- FROM exJobApply WITH(NOLOCK)
- WHERE Adddate > GETDATE() - 30
- AND reply = 1
- AND NOT EXISTS(
- SELECT 'x'
- FROM #TCaJobCvOperateLog
- WHERE JobID = exJobApply.JobID
- AND cvMainID = exJobApply.cvMainID
- )
- --排除海量操作
- DELETE FROM #TCaJobCvOperateLog
- WHERE JobID IN (
- SELECT JobID
- FROM #TCaJobCvOperateLog
- GROUP BY JobID
- HAVING COUNT(1) > 50
- )
- --排除受限制的企业操作
- DELETE FROM #TCaJobCvOperateLog
- WHERE JobID IN (
- SELECT ID
- FROM Job WHERE cpMainId IN(SELECT ID FROM cpMain WHERE IsLimitLogin = 9)
- )
-
- --需要推荐简历的职位
- CREATE TABLE #TJobNeedPush(JobID INT)
-
- --插入需要推送的职位
-
- DECLARE @t AS TABLE(EMailSendFreq INT)
- DECLARE @num INT
- SET @Num = 0
- WHILE @Num < 128
- BEGIN
- SET @Num = @Num + 1
- IF SUBSTRING(RIGHT('0000000' + dbo.Int2Bin(@Num), 7), DATEPART(WEEKDAY, GETDATE() - 1), 1) = '1'
- INSERT INTO @t SELECT @Num
- END
-
- INSERT INTO #TJobNeedPush
- SELECT ID
- FROM Job a WITH(NOLOCK)
- WHERE EMailSendFreq IN(SELECT EMailSendFreq FROM @t)
- AND valid = 1
-
- SELECT CvMainID, COUNT(1) Cnt INTO #TCvOperateCount
- FROM #TCaJobCvOperateLog
- GROUP BY CvMainID
- --生成所有记录简历的近似简历
- CREATE TABLE #TCvSimilar1
- (
- MainCvID INT,
- SimilarCvID INT,
- MainCvCount INT,
- SimilarCvCount INT,
- Rate FLOAT
- )
- --按照操作简历记录分组
- INSERT INTO #TCvSimilar1(MainCvID, SimilarCvID, SimilarCvCount)
- SELECT b.CvMainID MainCvID, a.CvMainID SimilarCvID, COUNT(1) SimilarCvCount
- FROM #TCaJobCvOperateLog a, #TCaJobCvOperateLog b
- WHERE a.JobID = b.JobID
- GROUP BY a.CvMainID, b.CvMainID
- HAVING COUNT(1) > 1
- ORDER BY b.CvMainID, COUNT(1) DESC
- --删除无效的,以及自己的推荐
- DELETE FROM #TCvSimilar1 WHERE MainCvID = 0
- DELETE FROM #TCvSimilar1 WHERE MainCvID = SimilarCvID
- --修改总的简历操作次数
- UPDATE a SET a.MainCvCount = b.Cnt
- FROM #TCvSimilar1 a, #TCvOperateCount b
- WHERE a.MainCvID = b.CvMainID
- --排除无效简历
- DELETE FROM #TCvSimilar1 WHERE Rate = 100
- DELETE FROM #TCvSimilar1
- WHERE (
- SELECT Valid
- FROM CvMain WITH(NOLOCK)
- WHERE id = #TCvSimilar1.SimilarCvID
- ) = 0
- --通过职位操作简历记录 匹配职位与简历
- SELECT a.JobID, b.SimilarCvID, b.MainCvCount, b.SimilarCvCount, b.Rate
- INTO #TCvSimilar2
- FROM #TCaJobCvOperateLog a, #TCvSimilar1 b
- WHERE a.CvMainID = b.MainCvID
- ORDER BY a.JobID, b.Rate DESC
- --删除已经操作的简历
- DELETE FROM a
- FROM #TCvSimilar2 a, #TCaJobCvOperateLog b
- WHERE a.JobID = b.JobID
- AND a.SimilarCvID = b.CvMainID
- --整理 一份简历被推荐给同一个职位的次数
- SELECT JobID, SimilarCvID, COUNT(1) Cnt
- INTO #TCvSimilar3
- FROM #TCvSimilar2
- GROUP BY JobID, SimilarCvID
- --排序整理 根据简历近似简历分析结束
- SELECT *, ROW_NUMBER() OVER(PARTITION BY JobID ORDER BY Cnt DESC) CvRank
- INTO #TJobSimilarCv
- FROM #TCvSimilar3
- --根据职位的近似职位推荐简历
- CREATE TABLE #TJobSimilar1
- (
- MainJobID INT,
- SimilarJobID INT,
- SimilarJobCount INT
- )
- --按照职位操作简历进行分组排序查询 分析职位近似职位
- INSERT INTO #TJobSimilar1(MainJobID, SimilarJobID, SimilarJobCount)
- SELECT a.JobID, b.JobID, COUNT(1)
- FROM #TCaJobCvOperateLog a, #TCaJobCvOperateLog b
- WHERE a.CvMainID = b.CvMainID
- AND a.JobID <> b.JobID
- GROUP BY a.JobID, b.JobID
- ORDER BY COUNT(1) DESC
- --按照近似的相同个数进行排序整理
- SELECT *, ROW_NUMBER() OVER(PARTITION BY MainJobID ORDER BY SimilarJobCount DESC) JobRank
- INTO #TJobSimilar2
- FROM #TJobSimilar1
- --DELETE FROM #TJobSimilar2 WHERE JobRank > 10
- --根据相似职位推荐 操作简历的相似推荐
- SELECT a.MainJobID, b.CvMainID, COUNT(1) Cnt
- INTO #TJobSimilar3
- FROM #TJobSimilar2 a, #TCaJobCvOperateLog b
- WHERE a.SimilarJobID = b.JobID
- GROUP BY a.MainJobID, b.CvMainID
- HAVING COUNT(1) > 1
- --插入到总的推荐列表
- INSERT INTO #TJobSimilarCv (JobID, SimilarCvID, Cnt)
- SELECT MainJobID, CvMainID, 1
- FROM #TJobSimilar3
- --删除曾经推荐过的
- DELETE FROM #TJobSimilarCv
- WHERE EXISTS(
- SELECT 'x'
- FROM caJobCvMatch WITH(NOLOCK)
- WHERE MatchCvMainID = #TJobSimilarCv.SimilarCvID
- )
- --删除已经操作的简历
- DELETE FROM a
- FROM #TJobSimilarCv a, #TCaJobCvOperateLog b
- WHERE a.JobID = b.JobID
- AND a.SimilarCvID = b.CvMainID
- --整理两种推荐方式推荐的所有简历
- SELECT JobID, SimilarCvID, SUM(Cnt) Cnt
- INTO #TJobSimilarCv1
- FROM #TJobSimilarCv
- GROUP BY JobID, SimilarCvID
- SELECT *, ROW_NUMBER() OVER(PARTITION BY JobID ORDER BY Cnt DESC) JobRank
- INTO #TJobSimilarCv2
- FROM #TJobSimilarCv1
- WHERE EXISTS( --最后一次登录在一个月内,并且有效的简历
- SELECT 'x'
- FROM cvMain a WITH(NOLOCK), paMain b WITH(NOLOCK)
- WHERE a.ID = #TJobSimilarCv1.SimilarCvID
- AND a.paMainID = b.ID
- AND b.LastLoginDate > GETDATE() - 30
- AND a.Valid = 1
- )
- --取10个推荐放到推荐表中
- INSERT INTO caJobCvMatch(JobID, MatchCvMainID, DataSource, AddDate)
- SELECT JobID, SimilarCvID, 1, GETDATE()
- FROM #TJobSimilarCv2
- WHERE JobID IN(SELECT JobID FROM #TJobNeedPush) --需要发送的职位
- AND JobRank <= 10
- GROUP BY JobID, SimilarCvID
- ORDER BY SUM(Cnt) DESC
- --为推荐不足10个的根据职位要求第一次匹配数据
- SELECT a.JobID, c.ResumeID CvMainID, ROW_NUMBER() OVER(PARTITION BY a.JobID ORDER BY COUNT(1) DESC) RowIndex
- INTO #TJobSimilarCvSearch
- FROM #TJobNeedPush a, JobPublish b WITH(NOLOCK), caJobResumePre c WITH(NOLOCK)
- WHERE a.JobID = b.ID
- AND (SELECT COUNT(1) FROM caJobCvMatch WHERE JobID = a.JobID AND AddDate > @Today) < 10
- AND b.dcRegionID = c.AtPlace
- AND c.Age BETWEEN b.MinAge AND b.MaxAge
- AND EXISTS(SELECT 'x' FROM cvJobType WHERE cvMainID = c.ResumeID AND dcJobTypeID = b.dcJobTypeID)
- GROUP BY a.JobID, c.ResumeID
- ORDER BY a.JobID
- DELETE FROM #TJobSimilarCvSearch
- WHERE EXISTS(
- SELECT 'x'
- FROM caJobCvMatch WITH(NOLOCK)
- WHERE JobID = #TJobSimilarCvSearch.JobID
- AND MatchCvMainID = #TJobSimilarCvSearch.CvMainID
- )
- INSERT INTO caJobCvMatch (JobID, MatchCvMainID, DataSource, AddDate)
- SELECT JobID, CvMainID, 2, GETDATE()
- FROM #TJobSimilarCvSearch a
- WHERE RowIndex <= (SELECT (10 - COUNT(1)) FROM caJobCvMatch WHERE JobID = a.JobID AND AddDate > @Today)
- GROUP BY JobID, CvMainID
- --为推荐不足10个的根据职位要求第二次匹配数据 放宽地点要求 放宽职位类别
- SELECT a.JobID, c.ResumeID CvMainID, ROW_NUMBER() OVER(PARTITION BY a.JobID ORDER BY COUNT(1) DESC) RowIndex
- INTO #TJobSimilarCvSearch1
- FROM #TJobNeedPush a, JobPublish b WITH(NOLOCK), caJobResumePre c WITH(NOLOCK)
- WHERE a.JobID = b.ID
- AND (SELECT COUNT(1) FROM caJobCvMatch WHERE JobID = a.JobID AND AddDate > @Today) < 10
- AND LEFT(b.dcRegionID, 4) = LEFT(c.AtPlace, 4)
- AND c.Age BETWEEN b.MinAge AND b.MaxAge
- AND EXISTS(SELECT 'x' FROM cvJobType WHERE cvMainID = c.ResumeID AND LEFT(dcJobTypeID, 2) = LEFT(b.dcJobTypeID, 2))
- GROUP BY a.JobID, c.ResumeID
- ORDER BY a.JobID
- DELETE FROM #TJobSimilarCvSearch1
- WHERE EXISTS(
- SELECT 'x'
- FROM caJobCvMatch WITH(NOLOCK)
- WHERE JobID = #TJobSimilarCvSearch1.JobID
- AND MatchCvMainID = #TJobSimilarCvSearch1.CvMainID
- )
- INSERT INTO caJobCvMatch(JobID, MatchCvMainID, DataSource, AddDate)
- SELECT JobID, CvMainID, 2, GETDATE()
- FROM #TJobSimilarCvSearch1 a
- WHERE RowIndex <= (SELECT (10 - COUNT(1)) FROM caJobCvMatch WHERE JobID = a.JobID)
- GROUP BY JobID, CvMainID
-
- --修改相关的推送信息
- UPDATE Job
- SET LastEmailDate = GETDATE()
- WHERE ID IN(SELECT JobID FROM #TJobNeedPush)
-
- --papush
- SELECT b.caMainId,count(1) cvcnt
- INTO #t
- FROM caJobCvMatch a LEFT JOIN job b ON a.jobId= b.Id
- WHERE a.AddDate> @Today
- GROUP BY b.caMainId
-
- DELETE FROM #t WHERE cvcnt=0
- INSERT INTO paPushLog(paMainID, PushMessage, PushType)
- SELECT a.caMainID, '今天给您推荐了'+CONVERT(char(5),a.cvcnt)+'个简历了解一下→', 12
- FROM #t a,caIOSBind b
- WHERE a.caMainId=b.caMainId
-
- --删除所有临时表
- DROP TABLE #t
- DROP TABLE #TCaJobCvOperateLog
- DROP TABLE #TJobNeedPush
- DROP TABLE #TCvOperateCount
- DROP TABLE #TCvSimilar1
- DROP TABLE #TCvSimilar2
- DROP TABLE #TCvSimilar3
- DROP TABLE #TJobSimilarCv
- DROP TABLE #TJobSimilarCv1
- DROP TABLE #TJobSimilarCv2
- DROP TABLE #TJobSimilar1
- DROP TABLE #TJobSimilar2
- DROP TABLE #TJobSimilar3
- DROP TABLE #TJobSimilarCvSearch
- DROP TABLE #TJobSimilarCvSearch1
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCaJobResumePreRebuild] Script Date: 2018/12/13 19:09:42 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcCaJobResumePreRebuild]
- AS
- SET NOCOUNT ON
- BEGIN
- TRUNCATE TABLE caJobResumePre
- INSERT INTO caJobResumePre(ResumeID, Name, Sex, Age, BirthDay, EduLevel, Experience, JobType, AtPlace, LastLoginDate, paMainId, SecondId)
- SELECT a.id resumeid, b.name name, b.gender sex, dbo.BirthToAge(b.birthday) age,
- b.birthday, a.degree edulevel, a.relatedworkyears experience,
- dbo.GetCvJobType(a.id) jobtype, b.LivePlace AtPlace, b.LastLoginDate, a.paMainId, LOWER(a.SecondId)
- FROM cvMain a with(nolock), paMain b with(nolock)
- WHERE a.paMainID=b.ID
- And b.lastlogindate>getdate()-30
- And a.valid > 0
- UPDATE a SET a.AtPlaceDesc = b.Description
- FROM caJobResumePre a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
- WHERE LEFT(a.AtPlace, 2) = b.ID
- UPDATE a SET a.AtPlaceDesc = a.AtPlaceDesc + b.Description
- FROM caJobResumePre a WITH(NOLOCK), dcRegion b WITH(NOLOCK)
- WHERE a.AtPlace = b.ID
- AND Len(A.AtPlace) > 2
- AND LEFT(a.AtPlace, 4) = b.ID
- TRUNCATE TABLE caJobResumePreJobType
- INSERT INTO caJobResumePreJobType
- SELECT * FROM cvJobType WHERE cvMainID IN(SELECT ResumeID FROM caJobResumePre)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCaLoginLogByWeiXinInsert] Script Date: 2018/12/13 19:09:42 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcCaLoginLogByWeiXinInsert]
- (
- @FromUserName VARCHAR(100)
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @caMainId INT
- SELECT @caMainId = caMainId FROM wxFans WITH(NOLOCK) WHERE OpenId = @FromUserName
- IF @caMainId IS NULL
- BEGIN
- SELECT @caMainId = paMainId FROM palogincontact WITH(NOLOCK) WHERE OpenId = @FromUserName AND ContactType = 101
- IF @caMainId IS NULL
- RETURN
- END
- DECLARE @Ip VARCHAR(31), @AddDate SMALLDATETIME, @Name NVARCHAR(100)
- SELECT TOP 1 @AddDate = AddDate, @ip = LoginIp FROM caLoginLog WITH(NOLOCK)
- WHERE caMainId = @caMainId ORDER BY Id DESC
- SELECT @Name = Name FROM cpMain WITH(NOLOCK) WHERE Id = (SELECT cpMainId FROM caMain WITH(NOLOCK) WHERE Id = @caMainId)
- IF @Ip IS NULL
- BEGIN
- INSERT INTO caLoginLog
- SELECT @caMainId, @Name, '', '', '', GETDATE(), 'weixin', 10
- RETURN
- END
- DECLARE @cpMainId INT, @LastLoginDate DATETIME
- SELECT @cpMainId = Id, @LastLoginDate = LastLoginDate FROM cpMain WITH(NOLOCK) WHERE Id = (SELECT cpMainId FROM caMain WITH(NOLOCK) WHERE id = @caMainId)
- IF @LastLoginDate < CONVERT(VARCHAR(10), GETDATE(), 120)
- BEGIN
- INSERT INTO caLoginLog
- SELECT @caMainId, @Name, '', '', '未记录', GETDATE(), 'weixin', 11
- UPDATE cpMaIn SET LastLoginDate = GETDATE(), RefreshDate = GETDATE() WHERE Id = @cpMainId
- UPDATE Job SET RefreshDate = GETDATE() WHERE caMainId = @caMainId AND Valid = 1
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCaMainByUserNameLowerSelect] Script Date: 2018/12/13 19:09:42 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:NICK
- --说明:
- --#####################################################
- CREATE PROCEDURE [dbo].[procCaMainByUserNameLowerSelect]
- (
- @UserName VARCHAR(50)
- )
- AS
- BEGIN
- SELECT TOP 1 cpMainID FROM camain WHERE UserNameLower = @UserName
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusBrochure30Select] Script Date: 2018/12/13 19:09:43 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.29
- --创建人:Nick
- --说明:获取最新校园招聘结束时间在30天内的,取120条,点击量前15的加hot
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusBrochure30Select]
- (
- @ProvinceID INT
- )
- AS
- BEGIN TRY
- SELECT TOP 120 a.id, a.CompanyID, a.Title,0 IsHot
- FROM marketdb..CampusBrochure a WITH(NOLOCK),
- marketdb..CampusBrochureSite b WITH(NOLOCK)
- WHERE a.EndDate>Getdate()
- AND a.id = b.CampusBrochure
- AND b.dcSubSiteID = @provinceID
- ORDER BY CASE a.id WHEN 7866 THEN 1 WHEN 7865 THEN 1 WHEN 7870 THEN 1 ELSE 2 END ,a.OrderBy ,AddDate DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procCampusBrochureByConditionSelect] Script Date: 2018/12/13 19:09:43 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:Nick
- --说明:根据条件获取 校园招聘信息
- --#####################################################
- CREATE PROCEDURE [dbo].[procCampusBrochureByConditionSelect]
- (
- @Condition VARCHAR(MAX)
- )
- AS
- BEGIN
- DECLARE @SQL VARCHAR(MAX)
- SET @SQL = '
- SELECT top 5 A.id, a.Title
- FROM marketdb..CampusBrochure a WITH(nolock),marketdb..CampusBrochureSite b WITH(nolock)
- WHERE a.EndDate>Getdate()
- AND a.id = b.CampusBrochure '+@Condition+'
- ORDER BY CASE a.id WHEN 7866 THEN 1 WHEN 7865 THEN 1 WHEN 7870 THEN 1 ELSE 2 END , AddDate DESC '
- EXEC(@SQL)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusBrochureByIDSelect] Script Date: 2018/12/13 19:09:43 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:Nick
- --说明:通过ID获取公司信息数据
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusBrochureByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN TRY
-
- --修改点击量
- UPDATE marketdb..CampusBrochure
- SET ClickNumber=ClickNumber+1
- WHERE id = @ID
- SELECT TOP 1 a.*,b.ID CompanyID,b.CompanyName,b.Description CompanyDescription,
- d.Description RegionName,e.Description Industry,b.Homepage
- FROM marketdb..CampusBrochure a WITH(NOLOCK) ,marketdb..CampusCompany b WITH(NOLOCK) ,
- dcRegion d WITH(NOLOCK) ,dcIndustry e WITH(NOLOCK)
- WHERE a.CompanyID = b.ID
- AND b.dcRegionID = d.id
- AND b.dcIndustryID = e.ID
- AND a.ID = @ID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusBrochureByIndustryIDSelect] Script Date: 2018/12/13 19:09:43 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- -- =============================================
- -- Author: <Mice 123>
- -- Create date: <2014-11-25>
- -- Description: <按照industryids查询招聘简章>
- -- Modify:harry
- -- 修改取前210条,不再按照行业取,优先显示未过期,然后显现过期的
- -- =============================================
- CREATE PROCEDURE [dbo].[ProcCampusBrochureByIndustryIDSelect]
- (
- @ProvinceID INT,
- @IndustryID VARCHAR(200)
- )
- AS
- --INSERT INTO procLog SELECT 'ProcCampusBrochureByIndustryIDSelect', @ProvinceID, GETDATE()
- BEGIN
- SELECT TOP 210 c.dcIndustryID, a.id, a.CompanyID, a.Title, 0 IsHot , a.ClickNumber
- FROM MarketDb..CampusBrochure a WITH(NOLOCK),
- MarketDb..CampusBrochureSite b WITH(NOLOCK) ,
- MarketDb..campuscompany c WITH(NOLOCK)
- WHERE a.id = b.CampusBrochure AND a.CompanyID = c.id
- AND b.dcSubSiteID = @ProvinceID
- --AND c.dcIndustryID IN ( SELECT a FROM dbo.fnsplit(@IndustryID,',') )
- ORDER BY a.EndDate DESC, a.id, a.OrderBy , a.AddDate DESC
- END
-
- GO
- /****** Object: StoredProcedure [dbo].[procCampusBrochureByKeyWordSelect] Script Date: 2018/12/13 19:09:43 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:
- --#####################################################
- CREATE PROCEDURE [dbo].[procCampusBrochureByKeyWordSelect]
- (
- @keyword VARCHAR(50)
- )
- AS
- BEGIN
- SELECT a.id,a.Title,a.addDate
- FROM marketdb..CampusBrochure a WITH(NOLOCK) ,
- marketdb..CampusBrochureSite b WITH(NOLOCK)
- WHERE a.EndDate>Getdate() and a.id = b.CampusBrochure
- AND a.Title LIKE '%'+@keyword+'%'
- ORDER BY a.AddDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCampusBrochureByProvinceIDSelect] Script Date: 2018/12/13 19:09:44 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:Nick
- --说明:根据省份获取校园招聘信息
- --#####################################################
- CREATE PROCEDURE [dbo].[procCampusBrochureByProvinceIDSelect]
- (
- @ProvinceID INT
- )
- AS
- BEGIN
- SELECT top 5 A.id, a.Title FROM marketdb..CampusBrochure a WITH(nolock),marketdb..CampusBrochureSite b WITH(nolock)
- WHERE a.EndDate>Getdate()
- AND a.id = b.CampusBrochure
- AND b.dcSubSiteID = @ProvinceID
- ORDER BY CASE a.id WHEN 7866 THEN 1 WHEN 7865 THEN 1 WHEN 7870 THEN 1 ELSE 2 END , AddDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusBrochureFamousSelect] Script Date: 2018/12/13 19:09:44 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.29
- --创建人:Nick
- --说明:获取64条名企招聘简章
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusBrochureFamousSelect]
- (
- @ProvinceID INT
- )
- AS
- BEGIN TRY
- SELECT TOP 64 a.id , a.CompanyID ,a.Title,0 IsHot
- FROM marketdb..CampusBrochure a WITH(NOLOCK),
- marketdb..CampusBrochureSite b WITH(NOLOCK)
- WHERE a.EndDate>Getdate()
- AND a.id = b.CampusBrochure
- AND b.dcSubSiteID = @provinceID
- ORDER BY CASE a.id WHEN 7866 THEN 1 WHEN 7865 THEN 1 WHEN 7870 THEN 1 ELSE 2 END ,a.OrderBy ,AddDate DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusBrochureHotSelect] Script Date: 2018/12/13 19:09:44 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.29
- --创建人:Nick
- --说明:获取热门企业招聘
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusBrochureHotSelect]
- (
- @ProvinceID INT
- )
- AS
- BEGIN TRY
- SELECT TOP 10 a.id,a.Title
- FROM marketdb..CampusBrochure a WITH(NOLOCK),marketdb..CampusBrochureSite b WITH(NOLOCK)
- WHERE a.id = b.CampusBrochure
- AND a.EndDate < GETDATE()+30
- AND b.dcSubSiteID = @ProvinceID
- ORDER BY AddDate
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusBrochureListSelect] Script Date: 2018/12/13 19:09:45 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- -- =============================================
- -- Author: <Mice 123>
- -- Create date: <2014-11-26>
- -- Description: <查询该省份下符合行业的未举行的招聘简章>
- -- =============================================
- CREATE PROCEDURE [dbo].[ProcCampusBrochureListSelect]
- (
- @ProvinceID INT,
- @IndustryID VARCHAR(200)
- )
- AS
- BEGIN
- SELECT c.dcIndustryID, a.id, a.CompanyID, a.Title, 0 IsHot, a.ClickNumber
- FROM marketdb..CampusBrochure a WITH(NOLOCK),
- marketdb..CampusBrochureSite b WITH(NOLOCK) ,
- marketdb..campuscompany c WITH(NOLOCK)
- WHERE a.EndDate > Getdate()
- AND a.id = b.CampusBrochure
- AND a.CompanyID = c.id
- AND b.dcSubSiteID = @ProvinceID
- AND c.dcIndustryID IN(SELECT a FROM dbo.fnsplit(@IndustryID, ','))
- ORDER BY a.id , a.OrderBy , a.AddDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusBrochureOtherByIDSelect] Script Date: 2018/12/13 19:09:45 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:Nick
- --说明:通过公司ID获取公司其他招聘简章
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusBrochureOtherByIDSelect]
- (
- @CompanyID INT
- )
- AS
- BEGIN TRY
- SELECT TOP 8 a.*,b.Id CompanyID,a.Adddate,b.CompanyName,b.Description CompanyDescription,
- d.Description RegionName,e.Description Industry,b.Homepage
- FROM marketdb..CampusBrochure a WITH(NOLOCK) ,marketdb..CampusCompany b WITH(NOLOCK) ,
- dcRegion d WITH(NOLOCK) ,dcIndustry e WITH(NOLOCK)
- WHERE a.CompanyID = b.ID
- AND b.dcRegionID = d.id
- AND b.dcIndustryID = e.ID
- AND a.CompanyID = @CompanyID
- ORDER BY a.Adddate DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusBrochurePeriodSelect] Script Date: 2018/12/13 19:09:45 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.29
- --创建人:Nick
- --说明:获取公司往期招聘简章
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusBrochurePeriodSelect]
- (
- @ProvinceID INT,
- @CompanyID INT
- )
- AS
- BEGIN TRY
- SELECT a.*
- FROM marketdb..CampusBrochure a WITH(NOLOCK),marketdb..CampusBrochureSite b WITH(NOLOCK)
- WHERE a.ID = b.CampusBrochure
- AND a.EndDate<Getdate()
- AND b.dcSubSiteID = @ProvinceID
- AND a.CompanyId = @CompanyID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procCampusByHomePageList] Script Date: 2018/12/13 19:09:46 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################
- --创建人: Lambo
- --创建时间:20120628
- --用于首页校园招聘宣讲会
- --######################################
- CREATE PROCEDURE [dbo].[procCampusByHomePageList]
- (
- @ProvinceID SMALLINT
- )
- AS
- BEGIN
- SET NOCOUNT ON
- SELECT TOP 1 ImageFile,alt FROM fpHomePageImage WITH(NOLOCK)
- WHERE ImageType = 5
- AND dcProvinceID = LEFT(@ProvinceID, 2)
- ORDER BY AddDate DESC
- SELECT TOP 5 * FROM SearchDb..HPCampus WITH(NOLOCK)
- WHERE provinceID = LEFT(@ProvinceID, 2)
- ORDER BY ID
-
- SET NOCOUNT OFF
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCampusByHomePageListNew] Script Date: 2018/12/13 19:09:46 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procCampusByHomePageListNew]
- (
- @ProvinceID SMALLINT
- )
- AS
- BEGIN
- SET NOCOUNT ON
- SELECT TOP 1 ImageFile,alt FROM fpHomePageImage WITH(NOLOCK)
- WHERE ImageType = 5
- AND dcProvinceID = LEFT(@ProvinceID, 2)
- ORDER BY AddDate DESC
- SELECT TOP 15 * FROM SearchDb..HPCampus WITH(NOLOCK)
- WHERE provinceID =LEFT(@ProvinceID, 2)
- ORDER BY ID
-
- SET NOCOUNT OFF
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusCollectInsert] Script Date: 2018/12/13 19:09:46 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcCampusCollectInsert]
- (
- @InfoText NVARCHAR(Max)
- )
- AS
- BEGIN
- DECLARE @SourceType VARCHAR(1),
- @HostDate VARCHAR(50),
- @HostTime VARCHAR(50),
- @CompanyName VARCHAR(50),
- @SchoolName VARCHAR(50),
- @HostAddress VARCHAR(50),
- @CityName VARCHAR(10),
- @i AS INT,
- @Sql VARCHAR(MAX)
- SET @SourceType = LEFT(@InfoText, 1)
- IF @SourceType NOT IN('1', '2', '3')
- BEGIN
- SELECT 0 [RowCount]
- RETURN
- END
- SET @InfoText = RIGHT(@InfoText, LEN(@InfoText) - 1)
- DECLARE @campus AS TABLE(
- Id INT,
- [SourceType] [tinyint],
- [HostDate] [nvarchar](50),
- [HostTime] [nvarchar](50),
- [CompanyName] [nvarchar](50),
- [SchoolName] [nvarchar](50),
- [HostAddress] [nvarchar](50),
- [CityName] [nvarchar](10),
- RowNo int identity(1,1)
- )
- DECLARE @campus1 AS TABLE(
- [SourceType] [tinyint],
- [HostDate] [nvarchar](50),
- [HostTime] [nvarchar](50),
- [CompanyName] [nvarchar](50),
- [SchoolName] [nvarchar](50),
- [HostAddress] [nvarchar](50),
- [CityName] [nvarchar](10),
- RowNo INT
- )
- DECLARE @t1 AS TABLE (ID INT Identity(1, 1), infoText NVARCHAR(MAX))
- CREATE TABLE #t2 (ID INT Identity(1, 1), infoText NVARCHAR(100))
-
- INSERT @t1(infoText)
- SELECT * FROM dbo.FnSplit(@InfoText, '^')
-
- SET @i = 0
- WHILE EXISTS(SELECT 'x' FROM @t1 WHERE @i < Id)
- BEGIN
- SET @I = @I + 1
- SELECT TOP 1 @Sql = infoText FROM @t1 WHERE Id = @i
- TRUNCATE TABLE #t2
- INSERT INTO #t2(infoText)
- SELECT * FROM Dbo.FnSplit(@Sql, '|')
-
- IF @@RowCount = 6
- BEGIN
- SELECT @HostDate = infoText FROM #t2 WHERE Id = 1
- SELECT @HostTime = CASE WHEN infoText = '-' THEN '' ELSE infoText END FROM #t2 WHERE Id = 2
- SELECT @CompanyName = infoText FROM #t2 WHERE Id = 3
- SELECT @SchoolName = infoText FROM #t2 WHERE Id = 4
- SELECT @HostAddress = infoText FROM #t2 WHERE Id = 5
- SELECT @CityName = infoText FROM #t2 WHERE Id = 6
- INSERT INTO @campus(Id, SourceType, HostDate, HostTime, CompanyName, SchoolName, HostAddress, CityName)
- SELECT 0, @SourceType, @HostDate, @HostTime, @CompanyName, @SchoolName, @HostAddress, @CityName
- END
- END
- UPDATE a
- SET a.Id = b.Id
- FROM @campus a, CampusCollect b
- WHERE a.SourceType = b.SourceType
- AND a.HostDate = b.HostDate
- AND a.HostTime = b.HostTime
- AND a.CompanyName = b.CompanyName
- AND a.SchoolName = b.SchoolName
- AND a.HostAddress = b.HostAddress
- AND a.CityName = b.CityName
-
- INSERT INTO @campus1
- SELECT SourceType, HostDate, HostTime, CompanyName, SchoolName, HostAddress, CityName, MIN(RowNo) RowNo
- FROM @Campus
- WHERE Id = 0
- GROUP BY SourceType, HostDate, HostTime, CompanyName, SchoolName, HostAddress, CityName
- INSERT INTO CampusCollect(SourceType, HostDate, HostTime, CompanyName, SchoolName, HostAddress, CityName)
- SELECT SourceType, HostDate, HostTime, CompanyName, SchoolName, HostAddress, CityName
- FROM @Campus1
- ORDER BY RowNo
- UPDATE CampusCollect SET CheckDate = GETDATE() WHERE Id IN(SELECT ID FROM @Campus WHERE Id > 0)
- SELECT 1 [RowCount]
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusCompanyByCompanyIDSelect] Script Date: 2018/12/13 19:09:46 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:Nick
- --说明:通过公司ID获取公司信息的数据
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusCompanyByCompanyIDSelect]
- (
- @CompanyID INT
- )
- AS
- BEGIN TRY
- SELECT a.*,b.Id CompanyID,b.CompanyName,b.Description CompanyDescription,d.Description RegionName,
- e.Description Industry,b.Homepage
- FROM marketdb..CampusCompany b WITH(NOLOCK)
- INNER JOIN dcRegion d WITH(NOLOCK) ON b.dcRegionID = d.id
- INNER JOIN dcIndustry e WITH(NOLOCK) ON b.dcIndustryID = e.ID
- LEFT JOIN marketdb..CampusBrochure a WITH(NOLOCK) ON a.CompanyID = b.ID And EndDate>Getdate()
- WHERE b.ID = @CompanyID
- ORDER BY EndDate DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusCompanyByProvinceIDSelect] Script Date: 2018/12/13 19:09:46 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:Nick
- --说明:通过公司ID获取公司信息的数据
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusCompanyByProvinceIDSelect]
- (
- @ProvinceID INT
- )
- AS
- BEGIN TRY
- SELECT TOP 1 a.*,b.Id CompanyID,b.CompanyName,b.Description
- CompanyDescription,d.Description RegionName,e.Description Industry,b.Homepage
- FROM marketdb..CampusBrochure a WITH(NOLOCK) ,marketdb..CampusCompany b WITH(NOLOCK),
- marketdb..CampusBrochureSite c WITH(NOLOCK),dcRegion d WITH(NOLOCK),dcIndustry e WITH(NOLOCK)
- WHERE a.CompanyID = b.ID
- AND a.ID = c.CampusBrochure
- AND b.dcRegionID = d.id
- AND b.dcIndustryID = e.ID
- AND c.dcSubsiteID = @ProvinceID
- ORDER BY addDate DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusListTmpInsert] Script Date: 2018/12/13 19:09:47 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.29
- --创建人:Nick
- --说明:生成宣讲会信息 每小时生成一次
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusListTmpInsert]
- AS
- BEGIN
- DECLARE @Ok INT, @MaxID INT
- SELECT TOP 1 @MaxId = ID, @Ok = 0 FROM MarketDb..CampusPresentation WITH(NOLOCK) ORDER BY Id DESC
- IF EXISTS(SELECT 'x' FROM SearchDb..CampusListTmp WITH(NOLOCK) WHERE CampusPresentationID > @MaxID)
- SET @Ok = 1
- IF @Ok = 0
- SELECT @Ok = 1
- FROM MarketDb..CampusPresentation WITH(NOLOCK)
- WHERE BeginTime BETWEEN DATEADD(MINUTE, -5, GETDATE()) AND GETDATE()
- OR EndTime BETWEEN DATEADD(MINUTE, -5, GETDATE()) AND GETDATE()
-
- IF @Ok = 0
- RETURN
- SELECT TOP 0 * INTO #t FROM SearchDb..CampusListTmp
- --插入数据
- INSERT INTO #t
- SELECT b.Homepage,b.dcRegionID, a.CompanyID, d.Description RegionName, b.id SchoolID, b.SchoolName,
- a.Address, c.CompanyName, a.BeginTime, a.EndTime, a.Id
- FROM MarketDb..CampusPresentation a WITH(NOLOCK),
- MarketDb..CampusSchool b WITH(NOLOCK),
- MarketDb..CampusCompany c WITH(NOLOCK),
- MainDb..dcRegion d WITH(NOLOCK)
- WHERE a.CompanyID = c.id
- AND a.SchoolID = b.ID
- AND b.dcRegionID = d.id
- ORDER BY a.BeginTime
- --删除数据
- TRUNCATE TABLE SearchDb..CampusListTmp
- INSERT SearchDb..CampusListTmp(Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName,
- Address, CompanyName, BeginTime, EndTime, CampusPresentationId)
- SELECT Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName,
- Address, CompanyName, BeginTime, EndTime, CampusPresentationId
- FROM #t
- ORDER BY ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusPresentation10Select] Script Date: 2018/12/13 19:09:47 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.29
- --创建人:Nick
- --说明:获取前10条重点高校宣讲会
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusPresentation10Select]
- AS
- BEGIN TRY
- SELECT a.* , b.Homepage, b.SchoolName
- FROM marketdb..CampusPresentation a WITH(NOLOCK),marketdb..CampusSchool b WITH(NOLOCK)
- WHERE a.SchoolID = b.ID
- AND a.id IN (
- SELECT TOP 10 MAX(id)
- FROM marketdb..CampusPresentation a WITH(NOLOCK)
- WHERE a.beginTime > GETDATE()
- GROUP BY a.SchoolID )
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusPresentationPeriodSelect] Script Date: 2018/12/13 19:09:47 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.29
- --创建人:Nick
- --说明:获取公司往期宣讲会
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusPresentationPeriodSelect]
- (
- @CompanyID INT
- )
- AS
- BEGIN TRY
- SELECT a.*,b.Homepage,b.SchoolName
- FROM marketdb..CampusPresentation a WITH(NOLOCK),marketdb..CampusSchool b WITH(NOLOCK)
- WHERE a.SchoolID = b.ID
- AND EndTime<Getdate()
- AND a.CompanyId = @CompanyID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusPresentationSelect] Script Date: 2018/12/13 19:09:47 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:Nick
- --说明:获取校园宣讲会数据
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusPresentationSelect]
- @ProvinceID INT
- AS
- BEGIN TRY
- SELECT TOP 8 a.ID,b.id SchoolID,b.dcRegionID, c.ID CompanyID, Replace(d.Description,'市','')
- RegionName, b.SchoolName, a.Address, c.CompanyName, BeginTime, EndTime, b.Homepage
- FROM marketdb..CampusPresentation a WITH(NOLOCK),
- marketdb..CampusSchool b WITH(NOLOCK),
- marketdb..CampusCompany c WITH(NOLOCK),
- dcRegion d WITH(NOLOCK)
- WHERE a.CompanyID = c.id
- AND a.SchoolID = b.ID
- AND b.dcRegionID = d.id
- AND EndTime>GETDATE()
- ORDER BY CASE CHARINDEX(CONVERT(VARCHAR(10),@ProvinceID),b.dcRegionID)
- WHEN 1 THEN 1 ELSE 2 END ,
- a.BeginTime, a.AddDate DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusRecruitmentListSelect] Script Date: 2018/12/13 19:09:47 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.29
- --创建人:Nick
- --说明:获取学校的校园招聘会
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusRecruitmentListSelect]
- (
- @CampusID INT,
- @PaMainID INT
- )
- AS
- --INSERT INTO procLog SELECT 'ProcCampusRecruitmentListSelect', @PaMAinId, GETDATE()
- BEGIN TRY
- SELECT TOP 500 a.ID, a.RecruitmentName,a.BeginDate,a.EndDate,a.CityID,a.RecruitmentPlaceId , a.CanBook, b.PlaceName ,
- (
- SELECT COUNT(*) FROM marketdb..rmplacephoto m WITH(NOLOCK) ,marketdb..rmmyplace n WITH(NOLOCK)
- WHERE m.rmmyplaceid=n.id
- AND n.rmdeptid=a.RecruitmentDeptID
- AND n.rmplaceid=a.RecruitmentPlaceId
- ) AS photoCount ,
- (
- SELECT c.AddDate
- FROM Marketdb..RmPerson c WITH(NOLOCK)
- WHERE c.RecruitmentID=a.id and c.paMainID = @PaMainID
- ) AS AddDate
- FROM recruitment a WITH(NOLOCK) , recruitmentPlace b WITH(NOLOCK)
- WHERE b.id= a.RecruitmentPlaceId
- AND a.BeginDate > DATEADD(YEAR,-1,GETDATE())
- AND b.CampusSchoolID = @CampusID
- order by a.BeginDate DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusSchoolBydcRegionIDSelect] Script Date: 2018/12/13 19:09:48 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:Nick
- --说明:根据regionID 获取学校信息
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusSchoolBydcRegionIDSelect]
- (
- @RegionID INT
- )
- AS
- BEGIN
- SELECT *
- FROM MarketDb..CampusSchool
- WHERE dcRegionID LIKE CONVERT(VARCHAR(10), @RegionID) + '%'
- AND EXISTS(SELECT 'X' FROM CampusListTmp WHERE SchoolID = MarketDb..CampusSchool.ID)
- ORDER BY OrderBy
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusSchoolByIDSelect] Script Date: 2018/12/13 19:09:48 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.29
- --创建人:Nick
- --说明:返回学校信息
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusSchoolByIDSelect]
- (
- @campusID INT
- )
- AS
- BEGIN TRY
- SELECT TOP 1 *
- FROM MarketDB..CampusSchool WITH(NOLOCK)
- WHERE ID=@campusID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusSchoolPartner12Select] Script Date: 2018/12/13 19:09:48 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.29 --创建人:Nick
- --说明:获取前12条合作院校
- --sean update 2015-3-19
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusSchoolPartner12Select]
- (
- @ProvinceID INT
- )
- AS
- BEGIN
- IF @ProvinceID > 9999
- SET @ProvinceID = LEFT(@ProvinceID, 4)
- SELECT *
- FROM SearchDb..CampusSchoolPartner12 WITH(NOLOCK)
- WHERE dcProvinceID = @ProvinceID
- ORDER BY RowNo
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusSchoolPartnerSelect] Script Date: 2018/12/13 19:09:48 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.29
- --创建人:Nick
- --说明:获取合作院校
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusSchoolPartnerSelect]
- (
- @ProvinceID INT
- )
- AS
- BEGIN TRY
- SELECT a.*
- FROM MarketDB..CampusSchool a WITH(NOLOCK)
- WHERE EXISTS(
- SELECT 'x'
- FROM marketdb..CampusPresentation b WITH(NOLOCK)
- WHERE SchoolID = a.id
- ) AND dcRegionID LIKE ''+CONVERT(VARCHAR(4),@ProvinceID)+'%'
- ORDER BY OrderBy, AddDate DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusTalkByCompanyIDSelect] Script Date: 2018/12/13 19:09:48 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:Nick
- --说明:获取企业校园宣讲会数据
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusTalkByCompanyIDSelect]
- @CompanyID INT
- AS
- BEGIN TRY
- select top 4 a.ID,b.dcRegionID, c.ID CompanyID, Replace(d.Description,'市','')
- RegionName, b.SchoolName,a.schoolid, a.Address, c.CompanyName, BeginTime, EndTime, b.Homepage
- FROM marketdb..CampusPresentation a WITH(NOLOCK),
- marketdb..CampusSchool b WITH(NOLOCK),
- marketdb..CampusCompany c WITH(NOLOCK),
- dcRegion d WITH(NOLOCK)
- WHERE a.CompanyID = c.id
- AND a.SchoolID = b.ID
- AND b.dcRegionID = d.id
- AND a.CompanyID = @CompanyID
- ORDER BY a.BeginTime DESC, a.AddDate
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusTalkByProvinceIDCompanyIDSelect] Script Date: 2018/12/13 19:09:49 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:Nick
- --说明:通过省ID和公司ID获取该公司在页面所在省的校园宣讲会内容
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusTalkByProvinceIDCompanyIDSelect]
- (
- @ProvinceID INT,
- @CompanyID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- SELECT TOP 8 ID, dcRegionID, CompanyID, RegionName, SchoolName, SchoolID, Address, CompanyName,
- BeginTime, EndTime, Homepage
- FROM SearchDb..cpPreachTmp WITH(NOLOCK)
- WHERE dcProvinceId = @ProvinceID
- ORDER BY RowNo
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusTalkByProvinceIDSelect] Script Date: 2018/12/13 19:09:49 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.29
- --创建人:Nick
- --说明:取校园宣讲会数据
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusTalkByProvinceIDSelect]
- (
- @ProvinceID INT
- )
- AS
- BEGIN
- SELECT TOP 10 a.ID,b.id SchoolID,b.dcRegionID, c.ID CompanyID, Replace(d.Description,'市','')
- RegionName, b.SchoolName, a.Address, c.CompanyName, BeginTime, EndTime, b.Homepage
- FROM marketdb..CampusPresentation a WITH(NOLOCK),
- marketdb..CampusSchool b WITH(NOLOCK),
- marketdb..CampusCompany c WITH(NOLOCK),
- dcRegion d WITH(NOLOCK)
- WHERE a.CompanyID = c.id
- AND a.SchoolID = b.ID
- AND b.dcRegionID = d.id
- AND EndTime > GETDATE()
- ORDER BY CASE CHARINDEX(CONVERT(VARCHAR(4),@ProvinceID),b.dcRegionID) WHEN 1 THEN 1 ELSE 2 END ,
- a.BeginTime, a.AddDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusTalkInfoOneYearSelect] Script Date: 2018/12/13 19:09:49 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.29
- --创建人:Nick
- --说明:获取校园宣讲会信息 一年之内
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusTalkInfoOneYearSelect]
- (
- @RegionID INT,
- @SchoolID INT,
- @ProvinceID INT
- )
- AS
- --INSERT INTO procLog SELECT 'ProcCampusTalkInfoOneYearSelect', @Regionid, GETDATE()
- BEGIN
- DECLARE @SQL VARCHAR(2000)
- SET @SQL = 'SELECT * FROM (SELECT '
- IF(@RegionID>0)
- BEGIN
- SET @SQL = @SQL + ' ROW_NUMBER() OVER(ORDER BY CASE CHARINDEX('''+CONVERT(VARCHAR(10),@RegionID)+''',b.dcRegionID) when 1 then 1 else 2 end ,case
- b.dcRegionID when '''+CONVERT(VARCHAR(10),@RegionID)+''' then 1 else 2 end, BeginTime) as tline,'
- END
- ELSE
- BEGIN
- SET @SQL = @SQL +' ROW_NUMBER() OVER(ORDER BY CASE CHARINDEX('''+CONVERT(VARCHAR(10),@ProvinceID)+''',b.dcRegionID) when 1 then 1 else 2 end ,
- BeginTime) as tline,'
- END
- SET @SQL = @SQL +' b.Homepage,b.dcRegionID, a.CompanyID, d.Description RegionName,b.id SchoolID, b.SchoolName, a.Address, c.CompanyName, BeginTime, EndTime '
- SET @SQL = @SQL +' FROM marketdb..CampusPresentation a WITH(NOLOCK),'
- SET @SQL = @SQL +' marketdb..CampusSchool b WITH(NOLOCK),'
- SET @SQL = @SQL +' marketdb..CampusCompany c WITH(NOLOCK),'
- SET @SQL = @SQL +' dcRegion d WITH(NOLOCK) '
- SET @SQL = @SQL +' WHERE EndTime>getdate() AND a.CompanyID = c.id AND a.SchoolID = b.ID AND b.dcRegionID = d.id'
- IF @SchoolID>0
- BEGIN
- SET @SQL = @SQL+' AND (b.ID = ' + CONVERT(VARCHAR(10),@SchoolID)+')'
- END
- IF (@RegionID>0)
- BEGIN
- SET @SQL = @SQL+ ' AND b.dcRegionID like '''+CONVERT(VARCHAR(10),@RegionID)+'%'''
- END
- SET @SQL = @SQL+ ') as t1 union '
- SET @SQL = @SQL+ 'SELECT 999 as tline,b.Homepage,b.dcRegionID, a.CompanyID, d.Description RegionName,b.id SchoolID, b.SchoolName, a.Address, c.CompanyName,
- BeginTime, EndTime '
- SET @SQL = @SQL +' FROM marketdb..CampusPresentation a WITH(NOLOCK),'
- SET @SQL = @SQL +' marketdb..CampusSchool b WITH(NOLOCK),'
- SET @SQL = @SQL +' marketdb..CampusCompany c with(NOLOCK),'
- SET @SQL = @SQL +' dcRegion d WITH(NOLOCK) '
-
- SET @SQL = @SQL +' WHERE EndTime<getdate() AND BeginTime>'''+CONVERT(VARCHAR(20),DATEADD(YEAR,-1,GETDATE())) +''' AND a.CompanyID = c.id AND a.SchoolID = b.ID AND b.dcRegionID = d.id'
- IF @SchoolID>0
- BEGIN
- SET @SQL = @SQL+' AND (b.ID = '+CONVERT(VARCHAR(10),@SchoolID)+')'
- END
- SET @SQL = @SQL + ' ORDER BY tline,BeginTime desc'
- PRINT(@SQL)
- EXEC(@SQL)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusTalkInfoSelect] Script Date: 2018/12/13 19:09:49 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.29
- --创建人:Nick
- --说明:获取校园宣讲会信息
- --修改:默认优先显示本省的(按照举办时间正序显示),后面是邻近四个省份的(按照举办时间正序显示),再后面是其他省(按照举办时间正序显示),最后就是本省过期的(按举办时间倒叙显示)
- --修改人:Lucifer 2014.12.1
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusTalkInfoSelect]
- (
- @RegionID INT,
- @SchoolID INT,
- @PageNo INT
- )
- AS
- --INSERT INTO procLog select 'ProcCampusTalkInfoSelect', LTRIM(STR(@RegionId)) + '|' + LTRIM(STR(@SchoolId)) + '|' + LTRIM(STR(@PageNo)), GETDATE()
- BEGIN
- IF ISNULL(@PageNo, 1) < 1
- SET @PageNo = 1
- DECLARE @t AS TABLE(
- ID [int] IDENTITY(1, 1),
- [Homepage] [varchar](200),
- [dcRegionID] [int],
- [CompanyID] [varchar](20),
- [RegionName] [nvarchar](50),
- [SchoolID] [int],
- [SchoolName] [nvarchar](50),
- [Address] [nvarchar](100),
- [CompanyName] [nvarchar](50),
- [BeginTime] [smalldatetime],
- [EndTime] [smalldatetime],
- PageNo INT,
- AllNumber INT
- )
- IF @SchoolID > 0
- BEGIN
- INSERT @t(Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime)
- SELECT Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime
- FROM CampusListTmp WITH(NOLOCK)
- WHERE SchoolId = @schoolId
- AND EndTime > GETDATE()
- ORDER BY BeginTime
- INSERT @t(Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime)
- SELECT Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime
- FROM CampusListTmp WITH(NOLOCK)
- WHERE SchoolId = @schoolId
- AND EndTime < GETDATE()
- ORDER BY BeginTime DESC
- UPDATE @t SET PageNo = (ID - 1) / 20 + 1
- UPDATE @t SET AllNumber = (SELECT COUNT(*) FROM @t)
- SELECT * FROM @t WHERE PageNo = @PageNo ORDER BY ID
- END
- ELSE
- BEGIN
- IF NOT EXISTS(SELECT 'x' FROM ShortDb..campusRegionTmp WITH(NOLOCK) WHERE ProvinceId = @RegionId AND AddDate > DATEADD(MINUTE, -10, GETDATE()))
- BEGIN
- DELETE FROM ShortDb..campusRegionTmp WHERE ProvinceId = @RegionId
- INSERT @t(Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime)
- SELECT Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime
- FROM CampusListTmp WITH(NOLOCK)
- WHERE dcRegionID LIKE LTRIM(STR(@RegionID)) + '%'
- AND EndTime > GETDATE()
- ORDER BY CASE WHEN Companyid = 29247 THEN 0 ELSE 1 END, BeginTime
- IF LEN(@RegionID) = 2
- BEGIN
- INSERT @t(Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime)
- SELECT Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime
- FROM CampusListTmp WITH(NOLOCK)
- WHERE LEFT(dcRegionID,2) IN(SELECT NearProvinceID FROM dcProvinceNear WITH(NOLOCK) WHERE dcProvinceID = @RegionID)
- AND EndTime > GETDATE()
- ORDER BY CASE WHEN Companyid = 29247 THEN 0 ELSE 1 END, BeginTime
- INSERT @t(Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime)
- SELECT Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime
- FROM CampusListTmp WITH(NOLOCK)
- WHERE LEFT(dcRegionID,2) NOT IN(SELECT NearProvinceID FROM dcProvinceNear WITH(NOLOCK) WHERE dcProvinceID = @RegionID)
- AND LEFT(dcRegionID, 2) <> @RegionID
- AND EndTime > GETDATE()
- ORDER BY CASE WHEN Companyid = 29247 THEN 0 ELSE 1 END, BeginTime
- END
-
- INSERT @t(Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime)
- SELECT Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime
- FROM CampusListTmp WITH(NOLOCK)
- WHERE dcRegionID LIKE LTRIM(STR(@RegionID)) + '%'
- AND EndTime < GETDATE()
- ORDER BY BeginTime DESC
-
- UPDATE @t SET PageNo = (ID - 1) / 20 + 1
- UPDATE @t SET AllNumber = (SELECT COUNT(*) FROM @t)
- INSERT INTO ShortDb..campusRegionTmp(Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime, ProvinceId, RowId, PageNo, AllNumber, AddDate)
- SELECT Homepage, dcRegionID, CompanyID, RegionName, SchoolID, SchoolName, Address, CompanyName, BeginTime, EndTime, @RegionID, Id, PageNo, AllNumber, GETDATE() FROM @t
- END
- SELECT * FROM ShortDb..campusRegionTmp WITH(NOLOCK)
- WHERE ProvinceId = @RegionId
- AND PageNo = @PageNo
- ORDER BY RowID
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusTalkNewByProvinceIDCompanyIDSelect] Script Date: 2018/12/13 19:09:50 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:Nick
- --说明:通过省ID和公司ID获取该公司在页面所在省的校园宣讲会内容
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusTalkNewByProvinceIDCompanyIDSelect]
- (
- @ProvinceID INT,
- @CompanyID INT
- )
- AS
- BEGIN TRY
- SELECT TOP 8 b.dcRegionID, c.ID CompanyID, REPLACE(d.Description,'市','')
- RegionName, b.SchoolName, a.Address, c.CompanyName,b.ID SchoolID, BeginTime, EndTime, b.Homepage
- FROM marketdb..CampusPresentation a WITH(NOLOCK),
- marketdb..CampusSchool b WITH(NOLOCK),
- marketdb..CampusCompany c WITH(NOLOCK),
- dcRegion d WITH(NOLOCK)
- WHERE a.CompanyID = c.id
- AND a.SchoolID = b.ID
- AND b.dcRegionID = d.id
- AND c.ID = @CompanyID
- ORDER BY a.BeginTime, a.AddDate DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcCampusTopBannerSelect] Script Date: 2018/12/13 19:09:50 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.29
- --创建人:Nick
- --说明:新版校园招聘 图片列表
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCampusTopBannerSelect]
- (
- @ProvinceID INT,
- @TypeID INT
- )
- AS
- BEGIN TRY
- DECLARE @SQL VARCHAR(1000)
- SET @SQL = 'SELECT '
- IF @TypeID = 26
- BEGIN
- SET @SQL = @SQL + ' TOP 3 '
- END
- ELSE IF @TypeID = 27
- BEGIN
- SET @SQL = @SQL + ' TOP 6 '
- END
- SET @SQL = @SQL + ' * FROM AdverProject WITH(NOLOCK) '
- SET @SQL = @SQL + ' WHERE Valid=''1'' AND BeginTime < GETDATE() '
- SET @SQL = @SQL + ' AND EndTime > GETDATE() AND Province_Id = ' + CONVERT(VARCHAR(4),@ProvinceID)
- SET @SQL = @SQL + ' AND Type = ' + CONVERT(VARCHAR(4),@TypeID)
- SET @SQL = @SQL + ' ORDER BY OrderBy ASC'
- print (@SQL)
- EXEC(@SQL)
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcCaOnlineBycaMainIdUpdate] Script Date: 2018/12/13 19:09:51 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcCaOnlineBycaMainIdUpdate]
- (
- @caMainID INT,
- @Status VARCHAR(5)
- )
- AS
- BEGIN
- DELETE FROM caOnline WHERE caMainID = @caMainID
- IF @Status = '1'
- INSERT INTO caOnline VALUES(@caMainID, 1, 0, NULL, NULL, GETDATE())
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCaOnlineStatusUpdate] Script Date: 2018/12/13 19:09:51 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcCaOnlineStatusUpdate]
- (
- @caMainIDs VARCHAR(MAX)
- )
- AS
- BEGIN
- SELECT a ID INTO #t FROM dbo.fnSplit(@caMainIDs,',')
- UPDATE CaOnline SET IsOnline=1, RefreshDate=GETDATE() WHERE caMainID IN(SELECT ID FROM #t)
- INSERT caOnline(caMainId, IsOnline, IsVi, RefreshDate)
- SELECT Id, 1, 0, GETDATE() FROM #t WHERE ID NOT IN(SELECT caMainId FROM caOnline)
- UPDATE caOnline SET IsOnline = 0 WHERE caMainID NOT IN(SELECT ID FROM #t)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCaOnlineUpdate] Script Date: 2018/12/13 19:09:51 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcCaOnlineUpdate]
- AS
- BEGIN
- SELECT caMainId, MIN(Id) ID, MIN(InterviewDate) InterviewDate
- INTO #t
- FROM viPlan WHERE InterviewDate > GETDATE() AND IsCancel = 0
- GROUP BY caMainId
- UPDATE #t SET InterviewDate = (SELECT InterviewDate FROM viPlan WHERE ID= #t.Id)
- UPDATE caOnline SET viPlanId = NULL, InterviewDate = NULL WHERE viPlanId > 0
- INSERT caOnline(caMainId, IsOnline)
- SELECT caMainId, 0 FROM #t WHERE caMainId NOT IN(SELECT caMainId FROM caOnline)
-
- UPDATE a
- SET a.viPlanId = b.Id,
- a.InterviewDate = b.InterviewDate
- FROM caOnline a, #t b
- WHERE a.caMainId = b.caMainId
- UPDATE caOnline SET IsVi = 0 WHERE caMainId NOT IN(SELECT caMainId FROM viRoom WHERE EndDate IS NULL) AND IsVi = 1
- UPDATE caOnline SET IsVi = 1 WHERE caMainId IN(SELECT caMainId FROM viRoom WHERE EndDate IS NULL)
- UPDATE caOnline SET isOnline = 0 WHERE RefreshDate < DATEADD(MINUTE,-2, GETDATE())
- DELETE caOnline WHERE RefreshDate < DATEADD(MINUTE, -7, GETDATE()) AND IsVi = 0 AND ViPlanId IS NULL
- UPDATE paOnline SET isOnline = 0 WHERE RefreshDate < DATEADD(MINUTE,-2, GETDATE())
- DELETE paOnline WHERE RefreshDate < DATEADD(MINUTE, -7, GETDATE())
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCaorderByBalanceUpdate] Script Date: 2018/12/13 19:09:51 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --###################################################3
- --2011-9-1 sean 用于知名企业招聘 点击数 balance=clickcount
- --###################################################3
- CREATE PROCEDURE [dbo].[procCaorderByBalanceUpdate]
- (
- @Id INT,
- @CompanyID INT,
- @JobId INT
- )
- AS
- BEGIN
- SELECT @CompanyID = ISNULL(@CompanyID, 0), @JobId = ISNULL(@JobId, 0)
- IF @CompanyID = 0 AND @JobID = 0
- RETURN
- IF @CompanyID = 0 AND @JobID > 0
- SELECT @CompanyID = cpMainID FROM Job WITH(NOLOCK) WHERE ID = @JobID
- IF @CompanyID > 0
- UPDATE caOrder SET Balance = ISNULL(Balance, 0) + 1
- WHERE ID = @ID
- AND cpMainId = @CompanyID
- AND OrderType = 7
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCaPageViewLogUpdate] Script Date: 2018/12/13 19:09:52 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procCaPageViewLogUpdate]
- (
- @caMainID INT,
- @ViewPageType TINYINT --1.应聘的简历 2.推荐的简历,3.面试通知答复 4.聊天
- )
- AS
- SET NOCOUNT ON
- 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
-
- IF @ViewPageType = 1
- UPDATE caPageViewLog SET ApplyCvDate = GETDATE(), ApplyCvCount = 0 WHERE caMainId = @caMainID
-
- IF @ViewPageType = 2
- UPDATE caPageViewLog SET RecommendCvDate = GETDATE(), RecommendCvCount = 0 WHERE caMainId = @caMainID
-
- IF @ViewPageType = 3
- UPDATE caPageViewLog SET InterviewReplyDate = GETDATE(), InterviewReplyCount = 0 WHERE caMainId = @caMainID
-
- IF @ViewPageType = 4
- UPDATE caPageViewLog SET ChatCount = 0 WHERE caMainId = @caMainID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCaSMSWaitSelect] Script Date: 2018/12/13 19:09:52 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- -----------------
- --创建日期:2012-4-17
- --创建人:lambo
- --功能说明:企业汇总类短信发送。将marketdb..caSMSWait里的数据转入SmsMessageLog
- -----------------
- CREATE PROCEDURE [dbo].[ProcCaSMSWaitSelect]
- AS
- BEGIN TRY
- IF oadb.dbo.IsWorkDate(getdate())<>1
- RETURN
-
- --删除今天已经登录过的企业的记录
- If DATEPART(HOUR,GETDATE())*100 + DATEPART(MINUTE,GETDATE()) <= 905
- DELETE FROM marketdb..cpSmsWait WHERE cpMainID IN(SELECT ID FROM cpMain WITH(NOLOCK) WHERE LastLoginDate > GETDATE() - 1)
- ELSE
- DELETE FROM marketdb..cpSmsWait WHERE cpMainID IN(SELECT ID FROM cpMain WITH(NOLOCK) WHERE LastLoginDate > DATEADD(MINUTE, -10, GETDATE()))
- SELECT TOP 20 * INTO #T FROM marketdb..cpSmsWait WHERE LastLoginTime < DATEPART(HOUR, GETDATE()) * 100 + DATEPART(MINUTE, GETDATE()) AND Msg > '' ORDER BY CASE WHEN SmsType > 16 THEN 0 ELSE 1 END, LastLoginTime
- INSERT SmsMessageLog(SendMan, ManagerUSerId, paMainId, caMainId, Mobile, MsgType, IsCat, Msg)
- SELECT 0, NULL, NULL, caMainID, Mobile, SmsType-1, 0,Msg FROM #T
- DELETE FROM marketdb..cpSMSWait WHERE ID IN (select ID FROM #T)
- END TRY
- BEGIN CATCH
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcCategoryIdByJobTypeIdSelect] Script Date: 2018/12/13 19:09:52 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.4
- --创建人:John
- --说明:根据子类别获取上级职位类别
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCategoryIdByJobTypeIdSelect]
- (
- @JobTypeId INT
- )
- AS
- BEGIN
- SELECT CategoryId FROM dcJobTypeMap WITH(NOLOCK) WHERE JobTypeId = @JobTypeId
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcChatOnlineByEndDateUpdate] Script Date: 2018/12/13 19:09:52 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcChatOnlineByEndDateUpdate]
- (
- @EndType TINYINT,
- @Evaluate TINYINT,
- @cvMainID INT,
- @caMainID INT,
- @ManageruserID SMALLINT
- )
- AS
- --INSERT INTO procLog SELECT 'ProcChatOnlineByEndDateUpdate', @caMainID, GETDATE()
- BEGIN
- IF @ManageruserID > 0 AND @caMainID > 0 AND @Evaluate > 0
- BEGIN
- DECLARE @Evaluation NVARCHAR(10)
- IF @Evaluate = 1
- SET @Evaluation = '满意'
- ELSE IF @Evaluate = 2
- SET @Evaluation = '一般'
- ELSE IF @Evaluate = 3
- SET @Evaluation = '不满意'
- INSERT INTO RtxNotifyLog (Receiver, RtxTitle, RtxMessage, SendType, ShowType, DelayTime)
- VALUES(@ManageruserID, '在线客服评价', '有企业对您的在线客服服务做出了评价,“' + @Evaluation + '”', 1, 0, 0)
- END
-
- IF EXISTS(SELECT 'X' FROM ChatOnline WHERE cvMainID = @cvMainID
- AND caMainID = @caMainID
- AND ManageruserID = @ManageruserID
- AND EndDate IS NULL)
- BEGIN
- UPDATE ChatOnline SET EndDate = GETDATE(),EndType = @EndType,Evaluate = @Evaluate
- WHERE cvMainID = @cvMainID
- AND caMainID = @caMainID
- AND ManageruserID = @ManageruserID
- AND EndDate IS NULL
- IF @cvMainID > 0
- BEGIN
- DECLARE @paMainID INT
- SELECT @paMainID = paMainID FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
- IF NOT EXISTS(SELECT 'X' FROM ChatOnlineExchange WHERE UserID = @paMainID AND UserType = 0)
- INSERT INTO ChatOnlineExchange VALUES(@paMainID,0)
- END
-
- IF @caMainID > 0
- BEGIN
- IF NOT EXISTS(SELECT 'X' FROM ChatOnlineExchange WHERE UserID = @caMainID AND UserType = 1)
- INSERT INTO ChatOnlineExchange VALUES(@caMainID,1)
- END
- IF @ManageruserID > 0
- BEGIN
- IF NOT EXISTS(SELECT 'X' FROM ChatOnlineExchange WHERE UserID = @ManageruserID AND UserType = 3)
- INSERT INTO ChatOnlineExchange VALUES(@ManageruserID,3)
- END
- END
- ELSE
- BEGIN
- UPDATE ChatOnline SET EndType = 0,Evaluate = @Evaluate
- WHERE ID IN
- (
- SELECT TOP 1 ID FROM ChatOnline WHERE cvMainID = @cvMainID
- AND caMainID = @caMainID
- AND ManageruserID = @ManageruserID
- ORDER BY EndDate DESC
- )
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcChatOnLineByManagerUserIDNoEndSelect] Script Date: 2018/12/13 19:09:53 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --Andy.Yin 2014-06-26
- --获取客服的15日内联系人列表,或者曾经有留言的的联系人
- -------------------------------
- CREATE PROCEDURE [dbo].[ProcChatOnLineByManagerUserIDNoEndSelect]
- (
- @UserID INT --客服的ID
- )
- AS
- --INSERT INTO procLog SELECT 'ProcChatOnLineByManagerUserIDNoEndSelect', @UserID, GETDATE()
- BEGIN
- --首先获取联系人列表中的企业-------------------
- CREATE TABLE #CpUserList
- (
- ChatOnlineID INT,
- CaMainID INT,
- CvMainID INT,
- ManagerUserID INT,
- LastChatDate SMALLDATETIME,
- SumUnRead INT,
- IsHidden BIT
- )
- --客服的联系人企业列表,有留言的
- INSERT INTO #CpUserList
- SELECT
- MAX(a.ID),
- a.CaMainID,
- a.CvMainID,
- a.ManagerUserID,
- MAX(b.Adddate),
- COUNT(1),
- 0
- FROM ChatOnline a, ChatOnlineLog b
- WHERE a.id = b.ChatOnlineID
- AND b.IsViewed = 0
- AND b.SenderType <> 3 --不是自己发送的
- AND a.ManagerUserID = @UserID
- GROUP BY a.CaMainID,a.CvMainID, a.ManagerUserID
-
- --客服联系人企业列表,未结束的回话
- INSERT INTO #CpUserList
- SELECT
- MAX(ID),
- CaMainID,
- CvMainID,
- ManagerUserID,
- (SELECT MAX(Adddate) FROM ChatOnlineLog WHERE ChatOnlineLog.ChatOnlineID IN(SELECT ID FROM ChatOnline a WHERE a.cvMainID = ChatOnline.cvMainID AND a.caMainID = ChatOnline.caMainID)),
- 0,
- 0
- FROM ChatOnline
- WHERE ManagerUserID = @UserID
- AND EndDate IS NULL
- AND NOT EXISTS(SELECT 'X' FROM #CpUserList b WHERE b.cvMainID = ChatOnline.cvMainID AND b.caMainID = ChatOnline.caMainID)
- GROUP BY CaMainID,CvMainID, ManagerUserID
- --最终联系人中企业列表
- SELECT
- a.*,
- b.Name CpName,
- b.SecondID,
- c.Name UserName,
- c.cpMainID,
- dbo.GetCaOnlineStatus(a.caMainID) IsOnline
- FROM #CpUserList a, cpMain b, caMain c
- WHERE a.caMainID = c.ID
- AND b.ID = c.cpMainID
- ORDER BY a.LastChatDate DESC
- DROP TABLE #CpUserList
-
- ---------------首先获取联系人列表中的个人-------------------
- CREATE TABLE #PaUserList
- (
- ChatOnlineID INT,
- CaMainID INT,
- CvMainID INT,
- ManagerUserID INT,
- LastChatDate SMALLDATETIME,
- SumUnRead INT,
- IsHidden BIT
- )
- --客服的联系人求职者列表,有留言的
- INSERT INTO #PaUserList
- SELECT
- MAX(a.ID),
- a.CaMainID,
- a.CvMainID,
- a.ManagerUserID,
- MAX(b.Adddate),
- COUNT(1),
- 0
- FROM ChatOnline a, ChatOnlineLog b
- WHERE a.id = b.ChatOnlineID
- AND b.IsViewed = 0
- AND b.SenderType <> 3 --不是客服发送的
- AND a.ManagerUserID = @UserID
- GROUP BY a.CaMainID, a.CvMainID, A.ManagerUserID
-
- --客服联系人求职者列表,未结束的回话
- INSERT INTO #PaUserList
- SELECT
- MAX(ID),
- CaMainID,
- CvMainID,
- ManagerUserID,
- (SELECT MAX(Adddate) FROM ChatOnlineLog WHERE ChatOnlineLog.ChatOnlineID IN(SELECT ID FROM ChatOnline a WHERE a.cvMainID = ChatOnline.cvMainID AND a.caMainID = ChatOnline.caMainID)),
- 0,
- 0
- FROM ChatOnline
- WHERE ManagerUserID = @UserID
- AND EndDate IS NULL
- AND NOT EXISTS(SELECT 'X' FROM #PaUserList b WHERE b.cvMainID = ChatOnline.cvMainID AND b.caMainID = ChatOnline.caMainID)
- GROUP BY CaMainID,CvMainID, ManagerUserID
- --最终结果
- SELECT
- a.*,
- b.Name PaName,
- b.ID PaMainID,
- c.Name UserName,
- dbo.GetPaOnlineStatus(a.cvMainID) IsOnline
- FROM #PaUserList a, PaMain b, cvMain c
- WHERE a.cvMainID = c.ID
- AND b.ID = c.paMainID
- ORDER BY a.LastChatDate DESC
- --检查数据库,把曾经已经结束但是还有unread的记录都设置为已读
- UPDATE ChatOnlineLog
- SET IsViewed=1
- WHERE IsViewed=0 AND chatOnlineID IN (SELECT ID FROM ChatOnline where ManagerUserID=@UserID and EndDate is not null)
-
- DROP TABLE #PaUserList
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcChatOnlineByMoveDelete] Script Date: 2018/12/13 19:09:54 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcChatOnlineByMoveDelete]
- AS
- BEGIN
- select id into #t from chatonline where startdate < convert(varchar(10), getdate() - 366)
- INSERT INTO LogDb..ChatOnline
- select * FROM chatonline WHERE ID IN(SELECT ID FROM #t)
- INSERT INTO LogDb..ChatOnlineLog
- select * FROM ChatOnlineLog WHERE ChatOnlineId IN(SELECT ID FROM #t)
- DELETE FROM chatonline WHERE ID IN(SELECT ID FROM #t)
- END
- GO
- /****** Object: StoredProcedure [dbo].[procChatOnlineByRefreshDateUpdate] Script Date: 2018/12/13 19:09:54 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procChatOnlineByRefreshDateUpdate]
- (
- @UserID INT,
- @UserType TINYINT
- )
- AS
- --INSERT INTO procLog SELECT 'procChatOnlineByRefreshDateUpdate', @UserID, GETDATE()
- BEGIN
- DELETE FROM ChatOnlineExchange WHERE UserID=@UserID AND UserType=@UserType
- IF @UserType = 0
- BEGIN
- IF EXISTS(SELECT 'X' FROM paOnline WITH(NOLOCK) WHERE paMainID=@UserID)
- UPDATE paOnline SET IsOnline=1,RefreshDate=GETDATE() WHERE paMainID=@UserID
- ELSE
- INSERT INTO paOnline (paMainID, IsOnline, RefreshDate) VALUES(@UserID, 1, GETDATE())
- END
- ELSE IF @UserType = 1
- BEGIN
- IF EXISTS(SELECT 'X' FROM caOnline WITH(NOLOCK) WHERE caMainID=@UserID)
- UPDATE caOnline SET IsOnline=1,RefreshDate = GETDATE() WHERE caMainID=@UserID
- ELSE
- INSERT INTO caOnline (caMainID, IsOnline, IsVi, RefreshDate) VALUES(@UserID, 1, '0', GETDATE())
- END
- ELSE IF @UserType = 3
- BEGIN
- UPDATE Manageruser SET SOLStatus = 1,SOLTime = GETDATE() WHERE ID = @UserID
- UPDATE a SET IsOnline = b.SOLStatus FROM ChatService a WITH(NOLOCK),Manageruser b WITH(NOLOCK) WHERE a.ManageruserID = b.ID
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcChatOnlineExchangeSelect] Script Date: 2018/12/13 19:09:54 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcChatOnlineExchangeSelect]
- AS
- --INSERT INTO procLog SELECT 'ProcChatOnlineExchangeSelect', '', GETDATE()
- BEGIN
- SELECT * FROM ChatOnlineExchange WITH(NOLOCK)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcChatOnlineLogByCaMainIDAndManageruserIDSelect] Script Date: 2018/12/13 19:09:54 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcChatOnlineLogByCaMainIDAndManageruserIDSelect]
- (
- @caMainID INT,
- @ManageruserID INT,
- @userType TINYINT
- )
- AS
- --INSERT INTO procLog SELECT 'ProcChatOnlineLogByCaMainIDAndManageruserIDSelect', @caMainID, GETDATE()
- BEGIN
- IF @userType = 1
- UPDATE ChatOnlineLog SET IsViewed=1
- WHERE SenderType = 3 AND ChatOnlineID IN(
- SELECT ID FROM ChatOnline WHERE caMainID=@caMainID AND ManageruserID=@ManageruserID
- )
- ELSE
- UPDATE ChatOnlineLog SET IsViewed=1
- WHERE SenderType = 1 AND ChatOnlineID IN(
- SELECT ID FROM ChatOnline WHERE caMainID=@caMainID AND ManageruserID=@ManageruserID
- )
-
- SELECT * FROM ChatOnlineLog
- WHERE ChatOnlineID IN(
- SELECT ID FROM ChatOnline WHERE caMainID=@caMainID AND ManageruserID=@ManageruserID
- ) AND (
- CheckResult=0 OR CheckResult IS NULL
- ) ORDER BY AddDate
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcChatOnlineLogByCvMainIDAndCaMainIDSelect] Script Date: 2018/12/13 19:09:54 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcChatOnlineLogByCvMainIDAndCaMainIDSelect]
- (
- @cvMainID INT,
- @caMainID INT,
- @UserType TINYINT
- )
- AS
- SET NOCOUNT ON
- --INSERT INTO procLog SELECT 'ProcChatOnlineLogByCvMainIDAndCaMainIDSelect', LTRIM(STR(@cvMainID)) + ' ' + LTRIM(STR(@caMainID)) + ' ' + LTRIM(STR(@UserType)), GETDATE()
- BEGIN
- DECLARE @t AS TABLE(ID INT)
- DECLARE @n1 INT, @N2 INT
- INSERT INTO @t
- SELECT ID
- FROM ChatOnline WITH(NOLOCK INDEX(IX_ChatOnline_Complex))
- WHERE cvMainID = @cvMainID
- AND caMainID = @caMainID
- --AND AddDate > DATEADD(MONTH, -2, GETDATE())
- IF @@RowCount = 0
- BEGIN
- SELECT TOP 0 * FROM ChatOnlineLog WITH(NOLOCK)
- RETURN
- END
-
- IF @UserType = 0
- BEGIN
- UPDATE ChatOnlineLog
- SET IsViewed = 1
- WHERE SenderType = 1
- AND ChatOnlineID IN(SELECT ID FROM @t)
- --AND AddDate > DATEADD(MONTH, -2, GETDATE())
- AND IsViewed = 0
- SET @n1 = @@ROWCOUNT
-
- UPDATE ChatOnline
- SET paUnViewed = 0
- WHERE Id IN(SELECT ID FROM @t)
- AND caUnViewed > 0
- SET @n2 = @@ROWCOUNT
- IF @n1 + @n2 > 0
- DELETE SearchDb..ChatOnlineListLog WHERE caMainId = @caMainId
- END
- ELSE
- BEGIN
- UPDATE ChatOnlineLog
- SET IsViewed = 1
- WHERE SenderType = 2
- AND ChatOnlineID IN(SELECT ID FROM ChatOnline WHERE cvMainID=@cvMainID AND caMainID=@caMainID)
- --AND AddDate > DATEADD(MONTH, -2, GETDATE())
- AND IsViewed = 0
- SET @n1 = @@ROWCOUNT
-
- UPDATE ChatOnline
- SET caUnViewed = 0
- WHERE Id IN(SELECT ID FROM ChatOnline WITH(NOLOCK) WHERE cvMainID=@cvMainID AND caMainID=@caMainID)
- AND caUnViewed > 0
- SET @n2 = @@ROWCOUNT
- IF @n1 + @n2 > 0
- DELETE SearchDb..ChatOnlineListLog WHERE caMainId = @caMainId
- END
- SELECT *
- FROM ChatOnlineLog WITH(NOLOCK)
- WHERE ChatOnlineID IN(SELECT ID FROM ChatOnline WITH(NOLOCK) WHERE cvMainID=@cvMainID AND caMainID=@caMainID)
- AND (CheckResult=1 OR CheckResult IS NULL)
- ORDER BY AddDate
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcChatOnlineLogByCvMainIDAndManageruserIDSelect] Script Date: 2018/12/13 19:09:54 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcChatOnlineLogByCvMainIDAndManageruserIDSelect]
- (
- @cvMainID INT,
- @ManageruserID INT,
- @userType TINYINT
- )
- AS
- --INSERT INTO procLog SELECT 'ProcChatOnlineLogByCvMainIDAndManageruserIDSelect', @cvMainID, GETDATE()
- BEGIN
- IF @userType = 0
- UPDATE ChatOnlineLog SET IsViewed=1
- WHERE SenderType = 3 AND ChatOnlineID IN(
- SELECT ID FROM ChatOnline WHERE cvMainID=@cvMainID AND ManageruserID=@ManageruserID
- )
- ELSE
- UPDATE ChatOnlineLog SET IsViewed=1
- WHERE SenderType = 2 AND ChatOnlineID IN(
- SELECT ID FROM ChatOnline WHERE cvMainID=@cvMainID AND ManageruserID=@ManageruserID
- )
- SELECT * FROM ChatOnlineLog
- WHERE ChatOnlineID IN(
- SELECT ID FROM ChatOnline WHERE cvMainID=@cvMainID AND ManageruserID=@ManageruserID
- ) AND (
- CheckResult=0 OR CheckResult IS NULL
- ) ORDER BY AddDate
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcChatOnlineLogSave] Script Date: 2018/12/13 19:09:55 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --在线客服
- --修改人:Andy
- --修改内容:修改客服自己首次给某其发送消息时,自己也收到rtx提醒的bug
- --修改时间:2015-3-20
- --修改人:harry 2015-7-7
- --修改:增加与陌生人发起聊天,增加积分
- ---20160216 Lucifer 添加推送
- ---20160411 Lucifer 添加企业微信提醒
- --修改Harry2017-4-17 修改积分
- --修改Harry2018-06-12 修改企业推送
- CREATE PROCEDURE [dbo].[ProcChatOnlineLogSave]
- (
- @cvMainID INT,
- @caMainID INT,
- @ManageruserID INT,
- @Message VARCHAR(MAX),
- @UserType TINYINT,
- @ClientType TINYINT
- )
- AS
- SET NOCOUNT ON
- DECLARE @cpMainID INT
- IF ISNULL(@cvMainID,0) <> 0 AND ISNULL(@caMainID,0) <> 0 AND @UserType = 1
- BEGIN
- SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
- IF dbo.GetChatPrivi(@cvMainID, @cpMainID) = 0
- RETURN -1
- END
- ELSE
- BEGIN
- SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
- END
- BEGIN
- DECLARE @ChatOnlineID INT, @IsNew INT, @Initiative TINYINT, @SenderType TINYINT,
- @ChatToUserID INT, @ChatToUserType INT, @paMainID INT, @IsPaNew INT
- SELECT @ChatOnlineID = 0, @IsNew = 0
- IF @UserType = 0
- SET @SenderType = 2
- ELSE IF @UserType = 1
- SET @SenderType = 1
- ELSE
- SET @SenderType = 3
- IF ISNULL(@ManageruserID,0) = 0
- BEGIN
- SELECT @paMainID = paMainID FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
- SELECT @ChatOnlineID = ID FROM ChatOnline WITH(NOLOCK)
- WHERE cvMainID = @cvMainID AND caMainID = @caMainID AND EndDate IS NULL
- IF @UserType = 0
- BEGIN
- SET @Initiative = 1
- SET @ChatToUserID = @caMainID
- SET @ChatToUserType = 1
- END
- ELSE
- BEGIN
- SET @Initiative = 2
- SET @ChatToUserID = @paMainID
- SET @ChatToUserType = 0
- END
- END
- ELSE IF ISNULL(@caMainID,0) = 0
- BEGIN
- SELECT @ChatOnlineID = ID FROM ChatOnline WITH(NOLOCK)
- WHERE cvMainID = @cvMainID AND ManageruserID = @ManageruserID AND EndDate IS NULL
- SET @Initiative = 3
- IF @UserType = 0
- BEGIN
- SET @ChatToUserID = @ManageruserID
- SET @ChatToUserType = 3
- END
- ELSE
- BEGIN
- SELECT @paMainID = paMainID FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
- SET @ChatToUserID = @paMainID
- SET @ChatToUserType = 0
- END
- END
- ELSE IF ISNULL(@cvMainID,0) = 0
- BEGIN
- SELECT @ChatOnlineID = ID FROM ChatOnline WITH(NOLOCK)
- WHERE caMainID = @caMainID AND ManageruserID = @ManageruserID AND EndDate IS NULL
- IF @UserType = 1
- BEGIN
- SET @Initiative = 4
- SET @ChatToUserID = @ManageruserID
- SET @ChatToUserType = 3
- END
- ELSE
- BEGIN
- SET @Initiative = 5
- SET @ChatToUserID = @caMainID
- SET @ChatToUserType = 1
- END
- END
-
- IF @ChatOnlineID = 0
- BEGIN
- IF ISNULL(@cvMainID,0) = 0
- UPDATE ChatService SET ChatCount = ChatCount + 1 WHERE ManageruserID = @ManageruserID
- INSERT INTO ChatOnline(cvMainID,caMainID,ManagerUserID,Initiative,StartDate,AddDate,ClientType)
- VALUES(@cvMainID,@caMainID,@ManagerUserID,@Initiative,GETDATE(),GETDATE(),@ClientType)
- SET @ChatOnlineID = @@IDENTITY
- IF ISNULL(@ManageruserID,0) <> 0
- BEGIN
- DECLARE @Status INT
- DECLARE @Superior INT
- SET @Status=(SELECT Status FROM Maindb..Manageruser WHERE Id=@ManageruserID)
- IF(@Status=3)--如果为空岗,则将消息发给经理
- BEGIN
- SET @Superior = (SELECT Superior FROM Maindb..Manageruser WHERE Id=@ManageruserID)
- INSERT INTO RtxNotifyLog(Receiver,RtxTitle,RtxMessage,SendType,DelayTime,ShowType)
- VALUES(@Superior,'新在线客服消息',CONVERT(VARCHAR(10),@ManageruserID)+'号顾问有新的在线客服消息,请及时查看',1,0,0)
- END
- ELSE IF (@UserType <> 3)--不是客服自己发送的
- INSERT INTO RtxNotifyLog(Receiver,RtxTitle,RtxMessage,SendType,DelayTime,ShowType)
- VALUES(@ManageruserID,'新在线客服消息','您有新的在线客服消息,请及时查看',1,0,0)
- END
- ELSE
- BEGIN
- IF @UserType = 1
- SET @IsNew = 1
- IF @UserType = 0
- SET @IsPaNew = 1
- END
- END
- IF NOT EXISTS(SELECT 'X' FROM ChatOnlineExchange WHERE UserID = @ChatToUserID AND UserType = @ChatToUserType)
- INSERT INTO ChatOnlineExchange VALUES(@ChatToUserID,@ChatToUserType)
- DECLARE @ChatOnlineLogId INT
- IF @UserType = 0
- BEGIN
- IF CHARINDEX('通讯录', @Message) > 0 OR CHARINDEX('名单', @Message) > 0
- OR CHARINDEX('QQ群', UPPER(@Message)) > 0 OR CHARINDEX('招聘工作', @Message) > 0 OR CHARINDEX('近期招聘', @Message) > 0
- SET @Message = @Message + '<br /><p class="ChatWarning">涉及公司重要信息请一定电话确认!发现可疑,请马上反馈。</p>'
- END
- INSERT INTO ChatOnlineLog(ChatOnlineID,SenderType,IsViewed,[Message],AddDate)
- VALUES(@ChatOnlineID,@SenderType,0,@Message,GETDATE())
- SET @ChatOnlineLogId = @@IDENTITY
- --插入积分 Harry
- --判断是否为初次聊天
- IF @IsNew = 1
- BEGIN
- DECLARE @Count AS INT
- SET @Count=0
- SELECT @Count=Count(1) FROM ChatOnline
- WHERE cvMainID=@cvMainID
- AND caMainID=@caMainID
- AND ID < @ChatOnlineId
- IF @Count = 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 = 6
- AND LastModifyDate > CONVERT(VARCHAR(10), GETDATE(),120)
- AND cpMainID = @cpMainID
-
- SET @TodayPoint = @TodayPoint + 10
-
- IF @TodayPoint <= 200
- BEGIN
- IF @TodayID = 0
- INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@cpMainID,6,10,GETDATE())
- ELSE
- UPDATE cpPoint SET Point = @TodayPoint,LastModifyDate = GETDATE() WHERE ID = @TodayID
- END
- END
- IF @paMainID > 0
- INSERT INTO paPushLog(paMainID, PushMessage, PushType)
- SELECT @paMainID, '亲,收到一条HR发送的消息!', 5 WHERE EXISTS(SELECT 'X' FROM paIOSBind WHERE paMainID = @paMainID)
-
-
- END
- IF @IsPaNew = 1
- BEGIN
- IF @paMainID > 0 AND @cpMainID > 0
- BEGIN
- INSERT wxMessageSend2(Templatetype, WxFansID, PaMainId, CvMainId, CpMainID, CaMainId, AddDate)
- SELECT 17, b.ID, @paMainID, @cvMainID, @cpMainID, a.paMainID, GETDATE()
- FROM paLoginContact a WITH(NOLOCK), wxFans b WITH(NOLOCK)
- WHERE a.OpenID = b.OpenID AND a.ContactType = 101 AND a.paMainID = @caMainID
-
-
- END
- INSERT INTO paPushLog(paMainID, PushMessage, PushType)
- SELECT @caMainID, '亲,收到一条求职者发送的消息!', 11 WHERE EXISTS(SELECT 'X' FROM caIOSBind WHERE caMainID = @caMainID)
- END
- --Harry
- SET NOCOUNT OFF
- RETURN @ChatOnlineLogId
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcChatOnlineLogSave20170428] Script Date: 2018/12/13 19:09:55 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --@MessageType 1 文本 2 表情 3 图片 4 职位 5 面试通知 6 相关职位 7 相关简历
- --@Initiative 1 个人主动 2 企业主动
- --@SenderType 1 企业 2 个人
- --Carl 2018-05-08 企业黑名单中的用户无法给该企业发消息
- --修改harry 增加企业app提醒2018-6-11
- --修改harry 发送图片时增加提醒2018-8-17
- --修改harry 增加一些关键词增加提醒2018-9-21
- -- 修改Sunshine2018-10-17Sunhsine注释rtx弹窗
- CREATE PROCEDURE [dbo].[ProcChatOnlineLogSave20170428]
- (
- @cvMainID INT,
- @caMainID INT,
- @ManagerUserID INT,
- @Message VARCHAR(MAX),
- @MessageType TINYINT,
- @SenderType TINYINT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @cpMainID INT, @paMainID INT, @ChatOnlineID INT
- SET @ChatOnlineID = 0
- SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
- SELECT @paMainID = paMainID FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
- IF @SenderType = 1 AND dbo.GetChatPrivi(@cvMainID, @cpMainID) = 0 --企业发起会话,检查是否有权限
- RETURN -1
- --新增的
- IF EXISTS(SELECT 'X' FROM cpCvShield a WITH(NOLOCK) WHERE a.cpMainId=@cpMainID
- AND EXISTS(SELECT 'X' FROM cvMain c WHERE c.paMainId = @paMainID AND a.cvMainId = c.Id))
- RETURN -1
- SELECT @ChatOnlineID = ID FROM ChatOnline WITH(NOLOCK)
- WHERE cvMainID = @cvMainID AND caMainID = @caMainID AND ManagerUserID = @ManagerUserID
- IF @ChatOnlineID = 0 --第一次聊
- BEGIN
- DECLARE @Initiative TINYINT
- IF @SenderType = 1
- SET @Initiative = 2
- ELSE
- SET @Initiative = 1
- INSERT INTO ChatOnline(cvMainID, caMainID, ManagerUserID, Initiative, StartDate, AddDate)
- VALUES(@cvMainID, @caMainID, @ManagerUserID, @Initiative, GETDATE(), GETDATE())
- SET @ChatOnlineID = @@IDENTITY
- IF @SenderType = 1
- BEGIN
- --如果是企业发起,添加积分
- EXEC ccCpPointByChatOnlineInsert @caMainID
- --IF @ManagerUserID > 0
- INSERT INTO paPushLog(paMainID, PushMessage, PushType)
- SELECT @paMainID, '亲,收到一条HR发送的消息!', 5 WHERE EXISTS(SELECT 'X' FROM paIOSBind WHERE paMainID = @paMainID)
- END
- IF @SenderType = 2
- BEGIN
- --如果是个人发起,企业添加微信消息提醒
- INSERT wxMessageSend2(Templatetype, WxFansID, PaMainId, CvMainId, CpMainID, CaMainId, AddDate)
- SELECT 17, b.ID, @paMainID, @cvMainID, @cpMainID, a.paMainID, GETDATE()
- FROM paLoginContact a WITH(NOLOCK), wxFans b WITH(NOLOCK)
- WHERE a.OpenID = b.OpenID AND a.ContactType = 101 AND a.paMainID = @caMainID
- INSERT INTO paPushLog(paMainID, PushMessage, PushType)
- SELECT @caMainID, '亲,收到一条求职者发送的消息!', 11 WHERE EXISTS(SELECT 'X' FROM caIOSBind WHERE caMainID = @caMainID)
- END
- END
- IF @MessageType=1 AND @SenderType=2
- BEGIN
- IF CHARINDEX('最近招聘', @Message) > 0 OR CHARINDEX('招聘效果', @Message) > 0
- OR CHARINDEX('招聘进展', UPPER(@Message)) > 0 OR CHARINDEX('人员名单', @Message) > 0
- OR CHARINDEX('招聘', @Message) > 0 OR CHARINDEX('效果', @Message) > 0 OR CHARINDEX('进展', @Message) > 0
- OR CHARINDEX('开展', @Message) > 0 OR CHARINDEX('进度', @Message) > 0 OR CHARINDEX('情况', @Message) > 0
- OR CHARINDEX('事情', @Message) > 0 OR CHARINDEX('名单', @Message) > 0 OR CHARINDEX('工作', @Message) > 0
- OR CHARINDEX('事情', @Message) > 0 OR CHARINDEX('重要', @Message) > 0 OR CHARINDEX('要事', @Message) > 0
- OR CHARINDEX('有事', @Message) > 0 OR CHARINDEX('事情', @Message) > 0 OR CHARINDEX('急', @Message) > 0
- OR CHARINDEX('安排', @Message) > 0 OR CHARINDEX('QQ', @Message) > 0 OR CHARINDEX('扣扣', @Message) > 0
- OR CHARINDEX('抠抠', @Message) > 0 OR CHARINDEX('叩叩', @Message) > 0 OR CHARINDEX('蔻蔻', @Message) > 0
- OR CHARINDEX('口口', @Message) > 0 OR CHARINDEX('微信', @Message) > 0 OR CHARINDEX('weixin', @Message) > 0
- OR CHARINDEX('qiuqiu', @Message) > 0 OR CHARINDEX('面试', @Message) > 0 OR CHARINDEX('手机', @Message) > 0
- OR CHARINDEX('qq', @Message) > 0 OR CHARINDEX('球球', @Message) > 0 OR CHARINDEX('求求', @Message) > 0
- BEGIN
- SET @Message = @Message + '<br /><p class="ChatWarning">涉及公司重要信息请一定电话确认!发现可疑,请马上反馈。</p>'
- END
- END
-
-
- IF @MessageType = 5
- BEGIN
- SELECT TOP 1 @Message = ID FROM exInterview WITH(NOLOCK) WHERE cvMainID = @cvMainID ORDER BY ID DESC
- END
- IF LEN(@Message) = 0
- RETURN -1
- INSERT INTO ChatOnlineLog(ChatOnlineID, SenderType, IsViewed, [Message], MessageType, AddDate)
- VALUES(@ChatOnlineID, @SenderType, 0, @Message, @MessageType, GETDATE())
-
- DECLARE @LogId INT
- SET @LogId = @@IDENTITY
- --rtx提醒审核 最近招聘 招聘效果 招聘进展 人员名单 2018-10-17Sunhsine注释
- --IF @MessageType=1 AND @SenderType=2
- --BEGIN
- --IF CHARINDEX('最近招聘', @Message) > 0 OR CHARINDEX('招聘效果', @Message) > 0
- --OR CHARINDEX('招聘进展', UPPER(@Message)) > 0 OR CHARINDEX('人员名单', @Message) > 0
- --OR CHARINDEX('招聘', @Message) > 0 OR CHARINDEX('效果', @Message) > 0 OR CHARINDEX('进展', @Message) > 0
- --OR CHARINDEX('开展', @Message) > 0 OR CHARINDEX('进度', @Message) > 0 OR CHARINDEX('情况', @Message) > 0
- --OR CHARINDEX('事情', @Message) > 0 OR CHARINDEX('名单', @Message) > 0 OR CHARINDEX('工作', @Message) > 0
- --OR CHARINDEX('事情', @Message) > 0 OR CHARINDEX('重要', @Message) > 0 OR CHARINDEX('要事', @Message) > 0
- --OR CHARINDEX('有事', @Message) > 0 OR CHARINDEX('事情', @Message) > 0 OR CHARINDEX('急', @Message) > 0
- --OR CHARINDEX('安排', @Message) > 0 OR CHARINDEX('QQ', @Message) > 0 OR CHARINDEX('扣扣', @Message) > 0
- --OR CHARINDEX('抠抠', @Message) > 0 OR CHARINDEX('叩叩', @Message) > 0 OR CHARINDEX('蔻蔻', @Message) > 0
- --OR CHARINDEX('口口', @Message) > 0 OR CHARINDEX('微信', @Message) > 0 OR CHARINDEX('weixin', @Message) > 0
- --OR CHARINDEX('qiuqiu', @Message) > 0 OR CHARINDEX('面试', @Message) > 0 OR CHARINDEX('手机', @Message) > 0
- --OR CHARINDEX('qq', @Message) > 0 OR CHARINDEX('球球', @Message) > 0 OR CHARINDEX('求求', @Message) > 0
- --BEGIN
- --INSERT INTO RtxNotifyLog(Receiver, RtxTitle, RtxMessage, SendType, DelayTime, ShowType)
- -- SELECT '155,180,216,222,223', '聊聊内容监控提醒','【公司id】'+CONVERT(CHAR(10),@cpMainID)+'【个人id】'+CONVERT(CHAR--(10),@paMainID)+ 'http://sysback.51rc.com/newoa/operate/chatOnline/LogDetails?ID='+CONVERT(CHAR(10),@ChatOnlineID), 1, 0, 0
- --END
- --END
- IF CHARINDEX('相关职位:',@Message) > 0 OR CHARINDEX('相关简历:',@Message) > 0
- BEGIN
- UPDATE ChatOnlineLog SET CheckUserID = 182,CheckResult = 1 WHERE ID = @LogId
- END
- UPDATE ChatOnline SET AddDate = GETDATE() WHERE ID = @ChatOnlineID
- IF @SenderType = 1
- BEGIN
- IF NOT EXISTS(SELECT 'X' FROM ChatOnlineExchange WHERE UserID = @paMainID AND UserType = 2)
- BEGIN
- INSERT INTO ChatOnlineExchange VALUES(@paMainID, 2)
- END
- END
- ELSE
- BEGIN
- IF NOT EXISTS(SELECT 'X' FROM ChatOnlineExchange WHERE UserID = @caMainID AND UserType = 1)
- BEGIN
- INSERT INTO ChatOnlineExchange VALUES(@caMainID, 1)
- END
- END
- RETURN @LogId
- END
- GO
- /****** Object: StoredProcedure [dbo].[procChatOnlineLogSelect] Script Date: 2018/12/13 19:09:56 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procChatOnlineLogSelect]
- (
- @caMainId INT,
- @cvMainId INT,
- @SenderType TINYINT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- UPDATE a SET IsViewed = 1
- FROM ChatOnlineLog a WITH(NOLOCK), ChatOnline b WITH(NOLOCK)
- WHERE a.ChatOnlineID = b.ID AND b.caMainID = @caMainId AND b.cvMainID = @cvMainId AND SenderType <> @SenderType
- SELECT a.*
- FROM ChatOnlineLog a WITH(NOLOCK), ChatOnline b WITH(NOLOCK)
- WHERE a.ChatOnlineID = b.ID AND b.caMainID = @caMainId AND b.cvMainID = @cvMainId
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcChatOnlineSchedule] Script Date: 2018/12/13 19:09:56 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcChatOnlineSchedule]
- AS
- --INSERT INTO procLog SELECT 'ProcChatOnlineSchedule', '', GETDATE()
- BEGIN
- --删除离线的数据(1分钟不刷新)
- DELETE FROM caOnline WHERE RefreshDate < DATEADD(SECOND, -80, GETDATE())
- DELETE FROM paOnline WHERE RefreshDate < DATEADD(SECOND, -80, GETDATE())
- --DELETE FROM paOnline WHERE RefreshDate < DATEADD(Minute, -70, GETDATE())
- UPDATE Manageruser SET SOLStatus = 0 WHERE SOLTime < DATEADD(SECOND, -80, GETDATE())
- UPDATE a SET IsOnline = b.SOLStatus FROM ChatService a,Manageruser b WHERE a.ManageruserID = b.ID
- --删除交互表中的记录
- DELETE FROM ChatOnlineExchange WHERE UserID NOT IN(SELECT paMainID FROM paOnline) AND UserType = 2
- DELETE FROM ChatOnlineExchange WHERE UserID NOT IN(SELECT caMainID FROM caOnline) AND UserType = 1
- --结束两方都不在线的聊天记录
- UPDATE ChatOnline SET EndDate = GETDATE()
- WHERE ManageruserID = 0
- AND EndDate IS NULL
- AND caMainID NOT IN(SELECT caMainID FROM caOnline)
- AND cvMainID NOT IN(SELECT a.ID FROM cvMain a,paOnline b WHERE a.paMainID = b.paMainID)
- UPDATE ChatOnline SET EndDate = GETDATE()
- WHERE cvMainID = 0
- AND EndDate IS NULL
- AND caMainID NOT IN(SELECT caMainID FROM caOnline)
- AND ManageruserID NOT IN(SELECT ID FROM Manageruser WHERE SOLStatus = 1)
- UPDATE ChatOnline SET EndDate = GETDATE()
- WHERE caMainID = 0
- AND EndDate IS NULL
- AND ManageruserID NOT IN(SELECT ID FROM Manageruser WHERE SOLStatus = 1)
- AND cvMainID NOT IN(SELECT a.ID FROM cvMain a,paOnline b WHERE a.paMainID = b.paMainID)
- END
- GO
- /****** Object: StoredProcedure [dbo].[procChatOnlineSelect] Script Date: 2018/12/13 19:09:56 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --lucifer2018-4-27
- CREATE PROCEDURE [dbo].[procChatOnlineSelect]
- (
- @caMainId INT,
- @paMainId INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- CREATE TABLE #ChatList(
- cvMainID INT,
- caMainID INT,
- [Name] VARCHAR(100),
- [Message] VARCHAR(MAX),
- LastSendDate DATETIME,
- NoViewedNum INT,
- OnlineStatus INT,
- PhotoUrl VARCHAR(300),
- paMainId INT,
- SecondId VARCHAR(10),
- Gender BIT
- )
- IF @paMainId > 0
- BEGIN
- INSERT INTO #ChatList(cvMainID, caMainID, LastSendDate, OnlineStatus, [Message])
- SELECT cvMainID, caMainID, AddDate, dbo.GetCaOnlineStatus(caMainID),
- CASE MessageType
- WHEN 1 THEN [Message]
- WHEN 2 THEN '[表情]'
- WHEN 3 THEN '[图片]'
- WHEN 4 THEN '[职位]'
- WHEN 5 THEN '[面试通知]'
- ELSE '' END
- FROM (SELECT TOP 100000 a.cvMainID, a.caMainID, b.AddDate, b.Message, b.MessageType, ROW_NUMBER() OVER(PARTITION BY a.cvMainID, a.caMainID ORDER BY b.ID DESC) row
- FROM ChatOnline a WITH(NOLOCK), ChatOnlineLog b WITH(NOLOCK)
- WHERE a.ID = b.ChatOnlineID AND a.caMainID > 0 AND b.MessageType <> 6 AND a.cvMainID IN(
- SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID = @paMainId
- )
- ORDER BY b.ID DESC
- ) t WHERE row = 1
- UPDATE #ChatList SET NoViewedNum = (SELECT COUNT(1)
- FROM ChatOnlineLog WITH(NOLOCK)
- WHERE ChatOnlineID IN (SELECT ID FROM ChatOnline WITH(NOLOCK) WHERE cvMainID = #ChatList.cvMainID AND caMainID = #ChatList.caMainID)
- AND IsViewed = 0 AND SenderType = 1 AND MessageType NOT IN(6, 7))
- UPDATE a SET a.PhotoUrl = b.LogoFile, a.[Name] = c.[Name] + ' ' + b.[Name]
- FROM #ChatList a, cpMain b WITH(NOLOCK), caMain c WITH(NOLOCK)
- WHERE b.ID = c.cpMainID AND c.ID = a.caMainID
- END
- ELSE IF @caMainID > 0
- BEGIN
- INSERT INTO #ChatList(cvMainID, caMainID, LastSendDate, [Message])
- SELECT cvMainID, caMainID, AddDate,
- CASE MessageType
- WHEN 1 THEN [Message]
- WHEN 2 THEN '[表情]'
- WHEN 3 THEN '[图片]'
- WHEN 4 THEN '[职位]'
- WHEN 5 THEN '[面试通知]'
- ELSE '' END
- FROM (SELECT TOP 100000 a.cvMainID, a.caMainID, b.AddDate, b.Message, b.MessageType, ROW_NUMBER() OVER(PARTITION BY a.cvMainID, a.caMainID ORDER BY b.ID DESC) row
- FROM ChatOnline a WITH(NOLOCK), ChatOnlineLog b WITH(NOLOCK)
- WHERE a.ID = b.ChatOnlineID AND a.caMainID = @caMainId AND b.MessageType <> 7 AND a.cvMainID > 0
- ORDER BY b.ID DESC) t
- WHERE row = 1
- UPDATE #ChatList
- SET NoViewedNum = (SELECT COUNT(1)
- FROM ChatOnlineLog WITH(NOLOCK)
- WHERE ChatOnlineID IN (SELECT ID FROM ChatOnline WITH(NOLOCK)
- WHERE cvMainID = #ChatList.cvMainID AND caMainID = #ChatList.caMainID)
- AND IsViewed = 0 AND SenderType = 2 AND MessageType NOT IN(6, 7))
- UPDATE #ChatList
- SET PhotoUrl = (
- SELECT TOP 1 a.PhotoProcessed
- FROM paPhoto a WITH(NOLOCK), cvMain b WITH(NOLOCK)
- WHERE a.paMainID = b.paMainID AND b.ID = #ChatList.cvMainID)
- WHERE EXISTS(SELECT 'X' FROM cpMain a, caMain b WHERE a.ID = b.cpMainID AND b.ID = #ChatList.caMainID AND a.MemberType > 1)
- UPDATE #ChatList
- SET OnlineStatus = (SELECT TOP 1 dbo.GetPaOnlineStatus(paMainID)
- FROM cvMain WITH(NOLOCK)
- WHERE ID = #ChatList.cvMainID)
- UPDATE a SET a.paMainId = b.paMainId, a.SecondId = b.SecondId FROM #ChatList a, cvMAin b WHERE a.cvMainId = b.Id
- UPDATE a SET a.Gender = c.Gender FROM #ChatList a, cvMain b, paMain c WHERE a.cvMainId = b.Id AND b.paMainID = c.ID
- UPDATE #ChatList
- SET [Name] = (SELECT TOP 1 dbo.GetPaName(#ChatList.cvMainId, cpMainId)
- FROM caMain WITH(NOLOCK)
- WHERE ID = #ChatList.caMainId)
- END
- SELECT * FROM #ChatList
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcChatOnlineUpdate] Script Date: 2018/12/13 19:09:56 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcChatOnlineUpdate]
- AS
- --INSERT INTO procLog SELECT 'ProcChatOnlineUpdate', '', GETDATE()
- BEGIN
- UPDATE ChatOnline
- SET caUnViewed = 0
- WHERE caUnViewed > 0
- AND StartDate < DATEADD(MINUTE, -30, GETDATE())
- AND EndDate > DATEADD(MINUTE, -30, GETDATE())
- UPDATE a
- SET a.caUnViewed = b.Cnt
- FROM ChatOnline a, (
- SELECT MAX(a.ID) Id, COUNT(*) Cnt
- FROM ChatOnline a, ChatOnlineLog b
- WHERE a.id = b.ChatOnlineID
- AND b.IsViewed = 0
- AND b.SenderType <> 1 --不是企业发送的
- AND StartDate < DATEADD(MINUTE, -30, GETDATE())
- AND EndDate > DATEADD(MINUTE, -30, GETDATE())
- GROUP BY a.CaMainID, a.CvMainID
- ) b
- WHERE a.Id = b.Id
- ------------------
- UPDATE ChatOnline
- SET paUnViewed = 0
- WHERE paUnViewed > 0
- AND StartDate < DATEADD(MINUTE, -30, GETDATE())
- AND EndDate > DATEADD(MINUTE, -30, GETDATE())
- UPDATE a
- SET a.paUnViewed = b.Cnt
- FROM ChatOnline a, (
- SELECT MAX(a.ID) ID, COUNT(1) Cnt
- FROM ChatOnline a, ChatOnlineLog b
- WHERE a.id = b.ChatOnlineID
- AND b.IsViewed = 0
- AND b.SenderType <> 2 --不是自己发送的
- AND StartDate < DATEADD(MINUTE, -30, GETDATE())
- AND EndDate > DATEADD(MINUTE, -30, GETDATE())
- GROUP BY a.CaMainID, a.CvMainID
- ) b
- WHERE a.Id = b.Id
- END
- GO
- /****** Object: StoredProcedure [dbo].[procChatRoomUserByUserIdDelete] Script Date: 2018/12/13 19:09:57 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procChatRoomUserByUserIdDelete]
- (
- @UserID INT,
- @UserType INT,
- @RoomID INT,
- @IpAddress VARCHAR(50)
- )
- AS
- BEGIN
- SET NOCOUNT ON
- --从用户列表中删除
- DELETE FROM Shortdb..ChatRoomUser WHERE ChatRoomID = @RoomID AND UserID = @UserID AND UserType = @UserType
- --加入黑名单
- INSERT INTO Shortdb..ChatRoomBlack( ChatRoomID, UserID, UserType, IP, AddDate )
- VALUES ( @RoomID ,@UserID, @UserType, @IpAddress , getDate() )
- SET NOCOUNT OFF
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCitySalaryRankByReginIDSelect] Script Date: 2018/12/13 19:09:57 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.3
- --创建人:John
- --说明:根据RegionID获取当前地区所在省级下属城市薪水排行
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCitySalaryRankByReginIDSelect]
- (
- @dcRegionID VARCHAR(6)
- )
- AS
- BEGIN
- IF LEN(@dcRegionID) > 4
- SET @dcRegionID = LEFT(@dcRegionID, LEN(@dcRegionId) - 2) + '__'
- ELSE
- SET @dcRegionID = @dcRegionId + '__'
- IF LEFT(@dcRegionID, 2) = '32'
- SELECT dcRegionID,AvgSalary
- FROM reportdb..SalaryReportRegion
- WHERE dcRegionid LIKE @dcRegionID AND LEN(dcRegionid) > 2
- ORDER BY AvgSalary DESC
- ELSE
- SELECT TOP 10 dcRegionID,AvgSalary
- FROM reportdb..SalaryReportRegion
- WHERE dcRegionid LIKE @dcRegionID AND LEN(dcRegionid) > 2
- ORDER BY AvgSalary DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procColdCustomerInsert] Script Date: 2018/12/13 19:09:57 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --采集的冷客户分配
- --harry
- --2016-10-13
- --修改harry 2018-1-25 增加推广
- --harry 2018-1-26
- CREATE PROCEDURE [dbo].[procColdCustomerInsert]
- (
- @ManagerUserId INT,
- @Allocater INT,
- @SourceType INT,
- @AllocateNumber INT,
- @isSpread INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @Id INT
- DECLARE @AllocateId INT
- DECLARE @cpName VARCHAR(200)
- DECLARE @ProvinceId INT
- SET @ProvinceId=32
- DECLARE @dtLastLoginDate DATETIME
- DECLARE @dtLastContactDate DATETIME
- SET @dtLastLoginDate=dateAdd(month,-6,getdate())
- SET @dtLastContactDate=dateAdd(month,-6,getdate())
- IF(@ProvinceId=32)
- SET @dtLastContactDate=dateAdd(month,-3,getdate())
- --分配前,更新已被注册的信息
- CREATE TABLE #t(
- Id INT ,
- [state] INT,
- SourceType INT,
- RegType INT,
- CompanyName VARCHAR(200),
- LinkMan varchar(50),
- Phone varchar(50),
- Tel varchar(50),
- Email varchar(50),
- SourceLink varchar(500),
- [Address] varchar(200),
- QQ char(15),
- IsNameRepeat BIT,
- IsEmailRepeat BIT,
- IsMobileRepeat BIT,
- IsAgree BIT,
- IsValid BIT,
- CheckDate DATETIME,
- AddDate DATETIME
- )
- INSERT #t(id,[state],sourceType,companyName,LinkMan,Phone,Tel,Email,SourceLink,[address],qq)
- SELECT id,[state],sourceType,companyName,linkMan,Phone,Tel,Email,SourceLink,[address],qq
- FROM precoldCustomer
- WHERE [state]=0--未分配
- AND ISNULL(isSpread,0) = @isSpread
-
- IF EXISTS(SELECT 'x' FROM #t )
- BEGIN
- --删除在coldcustomer表中的数据
- UPDATE #t SET [state]=2
- WHERE EXISTS(SELECT 'x' FROM Maindb..coldcustomer
- WHERE companyName=#t.CompanyName AND ProvinceID=@ProvinceId)
- AND [state]=0
-
- IF @isSpread = 0 --冷客户部门的规则
- BEGIN
- --有顾问的(上次联系时间,和登录时间不为空的)
- --3(6)个月内未联系,删除3(6)个月内联系过的
- UPDATE #t SET [state]=2
- WHERE EXISTS
- (
- SELECT 'x' FROM cpMain
- WHERE NAME=#t.CompanyName
- AND dcProvinceID = @ProvinceId
- AND ISNULL(ConsultantID, -1) != -1
- AND id =(
- SELECT TOP 1 companyID
- FROM MainDB..contact
- WHERE companyID = CpMain.ID
- AND addDate>@dtLastContactDate
- ORDER BY addDate DESC
- )
- )
- AND [state]=0
-
- --6个月未登录,删除6个月内登录过的
- UPDATE #t SET [state]=2
- WHERE EXISTS(
- SELECT 'x' FROM cpMain
- WHERE NAME=#t.CompanyName
- AND dcProvinceID=@ProvinceId
- AND ISNULL(ConsultantID,-1)!=-1
- AND LastLoginDate>@dtLastLoginDate
- )
- AND [state]=0
- --无顾问
- --无执照且一个月未登录,删除一个月内登录的
- UPDATE #t SET [state]=2
- WHERE EXISTS(
- SELECT 'x' FROM cpMain
- WHERE NAME=#t.CompanyName
- AND dcProvinceID=@ProvinceId
- AND ISNULL(ConsultantID,-1)=-1
- AND HasLicence=0
- AND LastLoginDate>DateAdd(month,-1,getdate())
- )
- AND [state]=0
-
- --有执照且三个月未登录,删除3个月内登录的
- UPDATE #t SET [state]=2
- WHERE EXISTS
- (
- SELECT 'x' FROM cpMain
- WHERE NAME=#t.CompanyName
- AND dcProvinceID=@ProvinceId
- AND ISNULL(ConsultantID,-1)=-1
- AND HasLicence=1
- AND LastLoginDate>DateAdd(month,-3,getdate())
- )
- AND [state]=0
- END
- ELSE
- BEGIN
- --推广的规则
- --有顾问的,已认证的
- UPDATE #t SET [state]=2
- WHERE EXISTS
- (
- SELECT 'x' FROM cpMain
- WHERE NAME=#t.CompanyName
- AND dcProvinceID=@ProvinceId
- AND (ISNULL(ConsultantID,0)!=0 OR memberType>1)
- )
- AND [state]=0
- END
- END
- --更新新结束,开始分配
- UPDATE precoldCustomer
- SET [state]=2
- WHERE id in(select id FROM #t where [state]=2)
-
- TRUNCATE TABLE #t
-
- INSERT INTO #t(id,sourceType,companyName,LinkMan,Phone,Tel,Email,SourceLink,[address],qq,IsAgree,IsValid,CheckDate,AddDate)
- SELECT TOP (@AllocateNumber) id,sourceType,companyName,
- REPLACE(linkMan,'_',''),
- REPLACE(Phone,'_',''),
- REPLACE(Tel,'_',''),
- REPLACE(Email,'_',''),
- REPLACE(SourceLink,'_',''),
- REPLACE([address],'_',''),
- REPLACE(qq,'_',''),1,1,GETDATE(),GETDATE()
- FROM precoldCustomer
- WHERE [state]=0
- AND SourceType=@SourceType
- AND ISNULL(isSpread,0) = @isSpread
- --判断用户名,手机,邮箱等是否重复IsNameRepeat BIT,IsEmailRepeat BIT, IsMobileRepeat BIT,
- UPDATE #t
- SET IsNameRepeat=(CASE WHEN EXISTS(select 'x' from MainDB..CpMain where name =#t.CompanyName)
- THEN 1
- ELSE 0 END),
- IsEmailRepeat=(
- CASE WHEN Email!=''
- THEN
- (CASE WHEN EXISTS(select 'x' from MainDB..CaMain a,MainDB..CpMain b where a.email =#t.Email and a.CpMainID=b.ID)
- THEN 1
- ELSE 0 END)
- ELSE 0 END),
- IsMobileRepeat=(CASE WHEN #t.Phone!='' OR #t.Tel !=''
- THEN (CASE
- WHEN #t.Phone!='' AND #t.Tel!='' AND EXISTS(select 'x' from MainDB..CaMain a,MainDB..cpmain b
- where (a.telephone like #t.Tel+ '%' or a.mobile=#t.Phone)
- and a.CpMainID=b.ID)
- THEN 1
- WHEN #t.Phone!='' AND #t.Tel ='' AND EXISTS(select 'x' from MainDB..CaMain a,MainDB..cpmain b
- where a.mobile=#t.Phone and a.CpMainID=b.ID)
- THEN 1
- WHEN #t.Phone ='' AND #t.Tel!='' AND EXISTS(select a.cpmainid,b.ConsultantID,b.LastLoginDate,b.HasLicence
- from MainDB..CaMain a,MainDB..cpmain b
- where a.telephone like #t.Tel+'%' and a.CpMainID=b.ID)
- THEN 1
- ELSE 0
- END)
- ELSE 0
- END)
- --更新regtype
- UPDATE #t SET regType=1 --无顾问的
-
- --有顾问的 regType=4,HasLicence=1 regtype=3 haslicence=0 regtype=2
-
- UPDATE #t
- SET regType=4
- WHERE EXISTS(SELECT 'x' FROM cpMain
- WHERE NAME=#t.CompanyName
- AND dcProvinceID=@ProvinceId
- AND ISNULL(ConsultantID,-1)!=-1)
- UPDATE #t
- SET regType=3
- WHERE EXISTS(
- SELECT 'x' FROM cpMain
- WHERE NAME=#t.CompanyName
- AND dcProvinceID=@ProvinceId
- AND HasLicence=1
- AND ISNULL(ConsultantID,-1)!=-1)
-
- UPDATE #t
- SET regType=3
- WHERE EXISTS(
- SELECT 'x' FROM cpMain
- WHERE NAME=#t.CompanyName
- AND dcProvinceID=@ProvinceId
- AND HasLicence=0
- AND ISNULL(ConsultantID,-1)!=-1)
-
- --#t
- IF EXISTS(SELECT 'x' FROM #t)
- BEGIN
- INSERT INTO ColdCustomerAllocateLog(ManagerUserId,SourceType,Allocater,AllocateNumber,Adddate)
- SELECT @ManagerUserId,@SourceType,@Allocater,(SELECT COUNT(*) FROM #t),GETDATE()
-
- SELECT @AllocateId=(SELECT @@IDENTITY) --赋值
- --插入冷客户表
- INSERT INTO coldCustomer(CompanyName, ProvinceId, Email, Phone, SourceLink, LinkMan, [Address], qq, AllocateLogID, AddWorkUserID,AddMan,IsNameRepeat,IsEmailRepeat,IsMobilerepeat,IsAgree,IsValid,CheckDate,addDate,regType)
- SELECT CompanyName,32,Email,Phone,SourceLink,LinkMan,[Address],qq,@AllocateId,(select TOP 1 id from oadb..workuser where manageruserid=@ManagerUserId and loginstatus=1 AND JobStatus<3 ),@ManagerUserId,IsNameRepeat, IsEmailRepeat,IsMobileRepeat,IsAgree,IsValid,CheckDate ,AddDate,regType
- FROM #t
-
- UPDATE precoldCustomer SET [state]=1,ColdCustomerAllocateLogID=@AllocateId WHERE ID IN(SELECT id FROM #t)
- --释放顾问
- UPDATE Maindb..cpMain SET ConsultantID = NULL, ConsultantDate = NULL WHERE [Name] IN(SELECT CompanyName FROM #t) AND dcProvinceID=32
- --rtx 通知 操作人和分配人
- INSERT RtxNotifyLog SELECT @ManagerUserId, Convert(VARCHAR,@Allocater)+'分配给您'+Convert(VARCHAR,(SELECT COUNT(*) FROM #t))+'个新的冷客户', Convert(VARCHAR,@Allocater)+'分配给您'+Convert(VARCHAR,(SELECT COUNT(*) FROM #t))+'个新的冷客户,请及时处理', 0, 0, 0, Null, GETDATE()
- INSERT RtxNotifyLog SELECT @Allocater, '分配冷客户成功通知', '成功分配'+Convert(VARCHAR,(SELECT COUNT(*) FROM #t))+'个新的冷客户给'+Convert(VARCHAR,@ManagerUserId), 0, 0, 0, Null, GETDATE()
- END
-
- END
- SET NOCOUNT OFF
- GO
- /****** Object: StoredProcedure [dbo].[ProcColdCustomerSave] Script Date: 2018/12/13 19:09:58 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --冷客户采集插入
- --Harry
- --2016-10-11
- --修改harry2017-7-31 0库中的数据重新采集,同时删除存在的0库数据
- --修改harry2017-10-12 删除vip用户
- --修改harry 2018-1-24 增加推广采集 @ProvinceId len=4时为推广采集,推广采集原则:无顾问,未认证
- CREATE PROCEDURE [dbo].[ProcColdCustomerSave]
- (
- @CompanyInfo VARCHAR(MAX),
- @ProvinceId INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @dtLastLoginDate DATETIME
- DECLARE @dtLastContactDate DATETIME
- DECLARE @cpName VARCHAR(200)
- SET @dtLastLoginDate=dateAdd(month,-6,getdate())
- SET @dtLastContactDate=dateAdd(month,-6,getdate())
- IF(LEFT(@ProvinceId,2)=32)
- SET @dtLastContactDate=dateAdd(month,-3,getdate())
- CREATE TABLE #t(
- Id INT IDENTITY,
- SeekInfo VARCHAR(MAX),
- SourceType INT,
- CompanyName VARCHAR(200),
- LinkMan varchar(50),
- Phone varchar(50),
- Tel varchar(50),
- Email varchar(50),
- SourceLink varchar(500),
- [Address] varchar(200),
- QQ char(15),
- )
- INSERT INTO #t(SeekInfo)
- SELECT * FROM dbo.FnSplit(@CompanyInfo, '#')
- DECLARE @Id INT, @Info VARCHAR(MAX)
- CREATE TABLE #One(
- Id INT IDENTITY(1, 1),
- Info VARCHAR(1000)
- )
-
- SET @Id = 0
- WHILE EXISTS(SELECT 'x' FROM #t WHERE Id > @Id)
- BEGIN
- SELECT TOP 1 @Id = Id, @Info = SeekInfo FROM #t WHERE Id > @Id ORDER BY ID
- TRUNCATE TABLE #One
- INSERT INTO #One
- SELECT * FROM dbo.FnSplit(@Info, '|')
- IF(SELECT COUNT(*) FROM #One) = 9
- BEGIN
- UPDATE #t SET SourceType = convert(INT,b.Info) FROM #t a, #One b WHERE a.Id = @Id AND b.Id = 1
- UPDATE #t SET CompanyName = LEFT(b.Info, 200) FROM #t a, #One b WHERE a.Id = @Id AND b.Id = 2
- UPDATE #t SET LinkMan = LEFT(b.Info, 50) FROM #t a, #One b WHERE a.Id = @Id AND b.Id = 3
- UPDATE #t SET Phone = LEFT(b.Info, 50) FROM #t a, #One b WHERE a.Id = @Id AND b.Id = 4
- UPDATE #t SET Tel= LEFT(b.Info, 50) FROM #t a, #One b WHERE a.Id = @Id AND b.Id = 5
- UPDATE #t SET Email = LEFT(b.Info, 50) FROM #t a, #One b WHERE a.Id = @Id AND b.Id = 6
- UPDATE #t SET SourceLink = LEFT(b.Info, 500) FROM #t a, #One b WHERE a.Id = @Id AND b.Id = 7
- UPDATE #t SET [Address] = LEFT(b.Info,200) FROM #t a, #One b WHERE a.Id = @Id AND b.Id = 8
- UPDATE #t SET QQ = LEFT(b.Info,15) FROM #t a, #One b WHERE a.Id = @Id AND b.Id = 9
- END
- END
- --插入maindb..precoldcustomer表中
- SET @Id = 0
- WHILE EXISTS(SELECT 'x' FROM #t WHERE Id > @Id)
- BEGIN
- SELECT TOP 1 @Id = Id, @cpName = CompanyName FROM #t WHERE Id > @Id ORDER BY ID
- --删除在maindb..precoldcustomer的数据
- DELETE FROM #t WHERE EXISTS(SELECT 'x' FROM Maindb..precoldcustomer WHERE companyName=@cpName) AND companyName=@cpName
- --删除在coldcustomer表中的数据,0库的保留,同时删除0库数据
- DELETE FROM #t WHERE EXISTS(SELECT 'x' FROM Maindb..coldcustomer WHERE companyName=@cpName AND ProvinceID=LEFT(@ProvinceId,2) AND ISNULL(addMan,0)!=0) AND companyName=@cpName
- --删除0库数据
- DELETE FROM Maindb..coldcustomer WHERE companyName=@cpName AND ProvinceID=LEFT(@ProvinceId,2) AND ISNULL(addMan,0) =0
-
- DELETE FROM #t WHERE companyName LIKE '%保险%'
-
- IF LEN(@ProvinceId )=4
- BEGIN
- --删除有顾问的--删除已认证的
- DELETE FROM #t WHERE companyName=@cpName AND EXISTS(SELECT 'X' FROM cpMain WHERE name =@cpName AND dcProvinceID=LEFT(@ProvinceId,2) AND (ISNULL(ConsultantID,0)>0 OR ISNULL(MemberType,0)>1))
-
- END
- ELSE
- BEGIN
- --有顾问的(上次联系时间,和登录时间不为空的)
- --3(6)个月内未联系,删除3(6)个月内联系过的
- DELETE FROM #t
- WHERE EXISTS
- (
- SELECT 'x' FROM cpMain
- WHERE NAME=@cpName
- AND dcProvinceID=LEFT(@ProvinceId,2)
- AND ISNULL(ConsultantID,-1)!=-1
- AND id =(
- SELECT TOP 1 companyID
- FROM MainDB..contact
- WHERE companyID = CpMain.ID
- AND addDate>@dtLastContactDate
- ORDER BY addDate DESC
- )
- ) AND companyName=@cpName
- --6个月未登录,删除6个月内登录过的
- DELETE FROM #t
- WHERE EXISTS
- (
- SELECT 'x' FROM cpMain
- WHERE NAME=@cpName
- AND dcProvinceID=LEFT(@ProvinceId,2)
- AND ISNULL(ConsultantID,-1)!=-1
- AND LastLoginDate>@dtLastLoginDate
- ) AND companyName=@cpName
- --无顾问
- --无执照且一个月未登录,删除一个月内登录的
- DELETE FROM #t
- WHERE EXISTS
- (
- SELECT 'x' FROM cpMain
- WHERE NAME=@cpName
- AND dcProvinceID=LEFT(@ProvinceId,2)
- AND ISNULL(ConsultantID,-1)=-1
- AND HasLicence=0
- AND LastLoginDate>DateAdd(month,-1,getdate())
- ) AND companyName=@cpName
- --有执照且三个月未登录,删除3个月内登录的
- DELETE FROM #t
- WHERE EXISTS
- (
- SELECT 'x' FROM cpMain
- WHERE NAME=@cpName
- AND dcProvinceID=LEFT(@ProvinceId,2)
- AND ISNULL(ConsultantID,-1)=-1
- AND HasLicence=1
- AND LastLoginDate>DateAdd(month,-3,getdate())
- ) AND companyName=@cpName
- --删除vip
- DELETE FROM #t
- WHERE EXISTS
- (
- SELECT 'x' FROM cpMain
- WHERE NAME=@cpName
- AND dcProvinceID=LEFT(@ProvinceId,2)
- AND MemberType=3
- ) AND companyName=@cpName
-
- END
- END
- --插入数据
- IF EXISTS(SELECT 'x' FROM #t)
- BEGIN
- IF LEN(@ProvinceId)=4
- BEGIN
- INSERT INTO precoldcustomer(State,SourceType,CompanyName,LinkMan,Phone,Tel,Email,SourceLink,[Address],QQ, AddDate, IsSpread )
- SELECT 0,SourceType,CompanyName,LinkMan,Phone,Tel,Email,SourceLink,[Address],QQ, GETDATE(), 1 FROM #t
- END
- ELSE
- BEGIN
- INSERT INTO precoldcustomer(State,SourceType,CompanyName,LinkMan,Phone,Tel,Email,SourceLink,[Address],QQ, AddDate)
- SELECT 0,SourceType,CompanyName,LinkMan,Phone,Tel,Email,SourceLink,[Address],QQ, GETDATE() FROM #t
- END
- END
- END
- SET NOCOUNT OFF
- GO
- /****** Object: StoredProcedure [dbo].[proccoldcustomerUpdate] Script Date: 2018/12/13 19:09:58 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --proccoldcustomerUpdate
- --后台冷客户的手机号,邮箱重复校正,每天运行一次
- --harry
- --2017-12-28
- CREATE PROCEDURE [dbo].[proccoldcustomerUpdate]
- AS
- BEGIN
- SET NOCOUNT ON
- CREATE TABLE #t(
- Id INT ,
- coldId INT,
- CompanyName VARCHAR(200),
- Phone varchar(50),
- Tel varchar(50),
- Email varchar(50),
- IsNameRepeat BIT,
- IsEmailRepeat BIT,
- IsMobileRepeat BIT
- )
- INSERT INTO #t(id,coldId,companyName,Phone,Tel,Email,IsNameRepeat,IsEmailRepeat,IsMobileRepeat)
- select b.id,a.id, a.companyName, a.Phone, a.Phone, a.Email,a.IsNameRepeat,a.IsEmailRepeat,a.IsMobileRepeat
- from coldcustomer a, cpmain b
- WHERE (a.IsNameRepeat=1 OR a.isEmailRepeat =1 OR a.IsMobilerepeat=1 )
- and b.name =a.CompanyName
- and a.cpmainid is NOT null
- UPDATE u
- SET u.IsNameRepeat=(
- CASE WHEN EXISTS(select 'x' from MainDB..CpMain a where a.name =#t.CompanyName AND a.id!=#t.id )
- THEN 1
- ELSE 0 END),
- u.IsEmailRepeat=(
- CASE WHEN #t.Email!=''
- THEN
- (CASE WHEN EXISTS(select 'x' from MainDB..CaMain a where a.email =#t.Email and a.id=#t.id)
- THEN 1
- ELSE 0 END)
- ELSE 0 END),
- u.IsMobileRepeat=(
- CASE WHEN ISNULL(#t.Phone,'')!=''
- THEN
- (CASE WHEN ISNULL(#t.Phone,'')!='' AND EXISTS(select 'x' from MainDB..CaMain a
- where (a.Telephone like #t.Phone+ '%' or a.mobile=#t.Phone)
- AND a.CpMainId !=#t.id)
- THEN 1
- WHEN ISNULL(#t.Phone,'')!='' AND EXISTS(select 'x' from MainDB..CaMain a
- where a.mobile=#t.Phone and a.cpMainID !=#t.id)
- THEN 1
- WHEN ISNULL(#t.Phone,'')!='' AND EXISTS(select 'x' from MainDB..CaMain a
- where a.Telephone like #t.Phone+'%' and a.CpMainID!=#t.id)
- THEN 1
- ELSE 0
- END)
- ELSE 0
- END)
- FROM coldcustomer u, #t
- WHERE u.id =#t.coldid
-
- DROP TABLE #t
- SET NOCOUNT OFF
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCommentCompanyListSelect] Script Date: 2018/12/13 19:09:58 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.27
- --创建人:Nick
- --说明:获取点评公司列表
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCommentCompanyListSelect]
- (
- @dcRegionID VARCHAR(100),
- @PageNo INT,
- @KeyWord VARCHAR(50)
- )
- AS
- BEGIN TRY
- DECLARE @WHERE VARCHAR(MAX),@JobPlace AS VARCHAR(2000)
- SET @JobPlace = ''
- SET @WHERE = ''
-
- IF CHARINDEX(',',@dcRegionID)>0
- BEGIN
- DECLARE @T_JobPlace AS TABLE(ID INT)
- INSERT INTO @T_JobPlace
- SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
-
- SELECT @JobPlace = (@JobPlace + ' OR b.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
-
- IF LEN(@JobPlace) > 0
- SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
- SET @WHERE = @WHERE + '
- AND (' + @JobPlace + ')'
- END
- ELSE
- BEGIN
- SET @WHERE = ' AND (b.dcRegionID Like '''+@dcRegionID+'%'')'
- END
-
- SET @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, ''))
-
- IF @KeyWord <> ''
- BEGIN
- SET @WHERE = @WHERE + ' AND b.Name LIKE ''%'+@KeyWord+'%'' '
- END
-
- DECLARE @PageSize INT
- SET @PageSize = 5
- DECLARE @PageLowerBound INT --定义此页的底码
- DECLARE @PageUpperBound INT --定义此页的顶码
- SET @PageLowerBound = (@PageNo -1) * @pagesize
- SET @PageUpperBound = @PageLowerBound + @pagesize
-
- DECLARE @AllCnt INT
- SET @AllCnt = 0
- DECLARE @SQL NVARCHAR(MAX)
- SET @SQL = N'
- SELECT @All = COUNT(DISTINCT CpMainID)
- FROM Comments a,Cpmain b
- WHERE (a.CommentType IN (1,2))
- AND a.id IN(SELECT MAX(id) FROM comments GROUP BY cpmainid)
- AND a.CpMainID = b.ID
- '+@WHERE
- exec sp_executesql @SQL,N'@All INT output',@AllCnt output
-
- IF @AllCnt>500
- BEGIN
- SET @AllCnt = 500
- END
-
- --SET @SQL = 'SELECT TOP 5000 rid=ROW_NUMBER() OVER(PARTITION BY CpmainID ORDER BY a.AddDate DESC),a.CpMainID,a.AddDate INTO ##Tmp
- -- FROM Comments a, CpMain b WHERE a.cpMainID=b.ID '+@WHERE
- ----exec sp_executesql @SQL,N'#Tmp INT output',#Tmp2 output
-
- SET @SQL = '
- SELECT TOP 500 cpmainid,b.name,b.secondid,a.AddDate INTO ##T1
- FROM comments a,cpmain b
- WHERE a.id IN(SELECT MAX(id) FROM comments GROUP BY cpmainid)
- AND a.cpmainid = b.id AND a.CommentType IN(1,2) '+@WHERE+'
- ORDER BY a.adddate DESC '
- EXEC(@SQL)
-
- SELECT * ,ROW_NUMBER() OVER( ORDER BY AddDate DESC) AS num INTO #T2 FROM ##T1
-
- SELECT *,0 AS cnt,0 AS Score INTO #T3 FROM #T2 WHERE NUM > @PageLowerBound AND NUM <= @PageUpperBound
-
- --修改评价数量
- UPDATE a
- SET a.cnt = b.Num
- FROM #T3 a,(
- SELECT COUNT(*) AS num,CpMainID
- FROM Comments
- WHERE (CommentType IN (1,2))
- AND CpMainID IN (SELECT CpMainID FROM #T3)
- GROUP BY CpMainID
- )b
- WHERE a.CpMainID = b.CpMainID
-
- --修改平均分数
- UPDATE a
- SET a.Score = b.Score
- FROM #T3 a,(
- SELECT CONVERT(DECIMAL(18,1),(SUM(GradeStar)*1.0)/(COUNT(*)*1.0)) AS Score,CpMainID
- FROM Comments
- WHERE CommentType IN (1,2)
- AND CpMainID IN (SELECT CpMainID FROM #T3)
- GROUP BY CpMainID
- )b
- WHERE a.CpMainID = b.CpMainID
-
- SELECT * FROM #T3
-
- SELECT @AllCnt
-
- SELECT * FROM
- (
- SELECT rid=ROW_NUMBER() OVER(PARTITION BY a.CpmainID ORDER BY a.AddDate DESC),*
- FROM Comments a
- WHERE (a.CommentType IN (1,2))
- AND CpMainID IN (SELECT CpMainID FROM #T3)
- ) AS c
- WHERE c.rid<=2
-
- DROP TABLE ##T1
- END TRY
- BEGIN CATCH
- DROP TABLE ##T1
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcCommentPraiseByIDUpdate] Script Date: 2018/12/13 19:09:59 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.20
- --创建人:Nick
- --说明:根据点评ID 点赞
- --修改:harry,修改登录用户未点击提示点击的bug20151224
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCommentPraiseByIDUpdate]
- (
- @ID INT,
- @PaMainID INT,
- @CommentType INT --1 点评 2面试经历
- )
- AS
- BEGIN
- IF @PaMainID = 0
- BEGIN
- --只更新总数
- IF @CommentType = 1
- BEGIN
- UPDATE Comments
- SET PraiseCount = PraiseCount+1
- WHERE ID = @ID
- END
- ELSE
- BEGIN
- UPDATE InterView
- SET PraiseCount = PraiseCount+1
- WHERE ID = @ID
- END
- RETURN 1
- END
- ELSE
- BEGIN
- --判断用户是否点过赞
- DECLARE @Tmp INT
- SELECT @Tmp = COUNT(*) FROM CommentPraise WHERE CommentID = @ID AND CommentType = @CommentType AND pamainId=@PaMainID
- IF @Tmp = 0 --没点过
- BEGIN
- INSERT INTO CommentPraise (CommentID,CommentType,AddDate,PamainID)
- VAlUES (@ID,@CommentType,GETDATE(),@PaMainID)
-
- IF @CommentType = 1 --更新点评 点赞总数
- BEGIN
- UPDATE Comments
- SET PraiseCount = PraiseCount+1,
- LoginPraiseCount = LoginPraiseCount+1
- WHERE ID = @ID
- END
- ELSE
- BEGIN
- UPDATE InterView
- SET PraiseCount = PraiseCount+1,
- LoginPraiseCount = LoginPraiseCount+1
- WHERE ID = @ID
- END
- RETURN 1
- END
- ELSE
- RETURN 0
- END
- RETURN 0
- End
-
- GO
- /****** Object: StoredProcedure [dbo].[ProcCommentsByCompanyIDSelect] Script Date: 2018/12/13 19:09:59 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.20
- --创建人:Nick
- --说明:根据公司ID获取 点评信息,以及平均分
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCommentsByCompanyIDSelect]
- (
- @CpMainID INT,
- @SessionID VARCHAR(50),
- @paMainID INT
- )
- AS
- SET NOCOUNT ON
- --insert a2 select @cpmainid, @sessionId, @paMainID, GETDATE()
- BEGIN
- DECLARE @CommentCount INT --评论人数
- DECLARE @StarCount INT --星星数量
- DECLARE @StarScore DECIMAL(18,1) --综合评分
- SELECT @CommentCount = COUNT(1),@StarCount = SUM(GradeStar) FROM Comments
- WHERE CpMainID = @CpMainID
- AND CommentType<>3
- AND VerifyDate IS NOT NULL
-
- IF @CommentCount>0
- SET @StarScore = @StarCount * 1.0 / @CommentCount
- ELSE
- SET @StarScore = 0
-
- IF @paMainID <> 0
- BEGIN
- SELECT * FROM Comments
- WHERE CpMainID = @CpMainID
- AND CommentType<>3
- AND (VerifyDate IS NOT NULL OR PaMainID = @paMainID)
- ORDER BY ADDDATE DESC
- END
- ELSE
- BEGIN
- -- IF @SessionID<>''
- -- BEGIN
- -- SELECT * FROM Comments
- -- WHERE CpMainID = @CpMainID
- -- AND CommentType<>3
- -- AND (VerifyDate IS NOT NULL OR (PaMainID = 0 AND SessionID = @SessionID))
- -- ORDER BY ADDDATE DESC
- -- END
- -- ELSE
- -- BEGIN
- SELECT * FROM Comments WITH(NOLOCK INDEX(IX_Comments_Complex))
- WHERE CpMainID = @CpMainID
- AND CommentType <> 3
- AND VerifyDate IS NOT NULL
- ORDER BY ADDDATE DESC
- -- END
- END
- SELECT @StarScore AS Score
- End
- GO
- /****** Object: StoredProcedure [dbo].[ProcCommentsByID] Script Date: 2018/12/13 19:09:59 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.24
- --创建人:Nick
- --说明:根据ID获取点评信息
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCommentsByID]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT * FROM Comments WHERE ID = @ID AND CommentType <> 3
- End
- GO
- /****** Object: StoredProcedure [dbo].[ProcCommentsByIDUpdate] Script Date: 2018/12/13 19:09:59 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.18
- --创建人:Nick
- --说明:根据ID修改点评信息
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCommentsByIDUpdate]
- (
- @ID INT,
- @Relation INT,
- @GradeStar INT,
- @Remark1 NVARCHAR(MAX),
- @Remark2 NVARCHAR(MAX),
- @Remark3 NVARCHAR(MAX),
- @Title NVARCHAR(50),
- @Position NVARCHAR(50),
- @WorkRegionID INT,
- @EntryDate VARCHAR(6),
- @QuitDate VARCHAR(6),
- @CommentType INT,
- @VerifyMan INT
- )
- AS
- BEGIN TRY
- DECLARE @AddDate DATETIME,@CpName NVARCHAR(100),@Title2 NVARCHAR(50)
- SELECT @AddDate = a.AddDate,@CpName = b.Name,@Title2 = a.Title
- FROM Comments a,Cpmain b
- WHERE a.ID = @ID
- AND a.CpMainID = b.ID
- UPDATE Comments
- SET Relation = @Relation,
- GradeStar = @GradeStar,
- Remark1 = @Remark1,
- Remark2 = @Remark2,
- Remark3 = @Remark3,
- Title = @Title,
- Position = @Position,
- WorkRegionID = @WorkRegionID,
- EntryDate = @EntryDate,
- QuitDate = @QuitDate,
- CommentType = @CommentType,
- VerifyMan = @VerifyMan,
- VerifyDate = GETDATE()
- WHERE CpMainID IN (SELECT ID FROM CPMAIN WHERE Name = @CpName)
- AND AddDate = @AddDate
- AND Title = @Title2
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcCommentsByKeyWordSelect] Script Date: 2018/12/13 19:09:59 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --###########################
- --创建时间:2014.11.27
- --创建人:Nick
- --说明:获取点评公司列表
- --###########################
- CREATE PROCEDURE [dbo].[ProcCommentsByKeyWordSelect]
- (
- @dcRegionID VARCHAR(100),
- @PageNo INT,
- @KeyWord VARCHAR(50)
- )
- AS
- BEGIN
- DECLARE @WHERE VARCHAR(MAX),@JobPlace AS VARCHAR(2000),@WHERE2 VARCHAR(MAX)
- SET @JobPlace = ''
- SET @WHERE = ''
- SET @WHERE2 = ''
-
- IF CHARINDEX(',',@dcRegionID)>0
- BEGIN
- DECLARE @T_JobPlace AS TABLE(ID INT)
- INSERT INTO @T_JobPlace
- SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
-
- SELECT @JobPlace = (@JobPlace + ' OR b.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
-
- IF LEN(@JobPlace) > 0
- SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
- SET @WHERE = @WHERE + '
- AND (' + @JobPlace + ')'
- SET @WHERE2 = @WHERE2 + '
- AND (' + @JobPlace + ')'
- END
- ELSE
- BEGIN
- SET @WHERE = ' AND (b.dcRegionID Like '''+@dcRegionID+'%'')'
- SET @WHERE2 = ' AND (b.dcRegionID Like '''+@dcRegionID+'%'')'
- END
-
- SET @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, ''))
-
- IF @KeyWord <> ''
- BEGIN
- SET @WHERE = @WHERE + ' AND b.Name LIKE ''%'+@KeyWord+'%'' '
- END
-
- DECLARE @PageSize INT
- SET @PageSize = 5
- DECLARE @PageLowerBound INT --定义此页的底码
- DECLARE @PageUpperBound INT --定义此页的顶码
- SET @PageLowerBound = (@PageNo -1) * @pagesize
- SET @PageUpperBound = @PageLowerBound + @pagesize
-
- DECLARE @AllCnt INT
- SET @AllCnt = 0
- DECLARE @SQL NVARCHAR(MAX)
-
- --创建临时表
- CREATE TABLE #T1(
- [cpmainid] [int] NOT NULL,
- [name] [varchar](100) NULL,
- [secondid] varchar(12) NULL,
- [AddDate] [datetime] NULL,
- [OrderBY] [int] NULL
- )
- IF @KeyWord = ''
- BEGIN
- SET @SQL = '
- INSERT INTO #T1
- SELECT TOP 500 cpmainid,b.name,b.secondid,a.AddDate,1 AS OrderBY
- FROM comments a,cpmain b
- WHERE a.id IN(SELECT TOP 999 MAX(id) FROM comments GROUP BY cpmainid ORDER BY MAX(ID) DESC)
- AND a.cpmainid = b.id AND a.CommentType IN(1,2) '+@WHERE+'
- AND a.IsDirect = 1
- ORDER BY a.adddate DESC '
- EXEC(@SQL)
- END
- ELSE
- BEGIN
- SET @SQL = '
- INSERT INTO #T1
- SELECT TOP 500 b.ID AS cpmainid,b.Name, b.SecondId, LastLoginDate AS AddDate,1 AS OrderBY
- FROM cpMainPublish b WITH(NOLOCK),
- CONTAINSTABLE(cpMainPublish, Name, '''+@KeyWord+''', 100) AS a
- WHERE b.Id = a.[Key] '+@WHERE2+'
- ORDER BY b. LastLoginDate DESC '
- --PRINT(@SQL)
- EXEC(@SQL)
- IF NOT EXISTS(SELECT 'x' FROM #T1)
- BEGIN
- SET @SQL = '
- INSERT INTO #T1
- SELECT TOP 500 b.ID AS cpmainid,b.Name, b.SecondId, LastLoginDate AS AddDate,1 AS OrderBY
- FROM cpMainPublish b WITH(NOLOCK INDEX(IX_cpMainPublish_Name))
- WHERE 1=1 '+@WHERE+'
- ORDER BY b. LastLoginDate DESC '
- --PRINT(@SQL)
- EXEC(@SQL)
- END
- END
-
- SELECT @AllCnt = COUNT(*) FROM #T1
-
- IF @KeyWord <> '' --对临时表 #T1 进行排序 修改最后点评时间
- BEGIN
- UPDATE a
- SET a.AddDate = b.AddDate,a.OrderBY = b.OrderBY
- FROM #T1 a,(
- SELECT AddDate,CpMainID,2 AS OrderBy
- FROM Comments
- WHERE ID IN(SELECT MAX(id) FROM comments GROUP BY cpmainid)
- ) b
- WHERE a.CpmainID = b.CpMainID
- END
-
- SELECT * ,ROW_NUMBER() OVER( ORDER BY OrderBY DESC,AddDate DESC) AS num INTO #T2 FROM #T1
-
- --创建临时表
- CREATE TABLE #T3(
- [cpmainid] [int] NOT NULL,
- [name] [varchar](100) NULL,
- [secondid] varchar(12) NULL,
- [AddDate] [datetime] NULL,
- [OrderBY] [int] NULL,
- [num] [int] null,
- cnt INT NULL,
- Score DECIMAL(18, 1) NULL
- )
- INSERT INTO #T3
- SELECT *,0 AS cnt,1.0 AS Score FROM #T2 WHERE NUM > @PageLowerBound AND NUM <= @PageUpperBound
-
- --修改评价数量
- UPDATE a
- SET a.cnt = b.Num
- FROM #T3 a,(
- SELECT COUNT(*) AS num,CpMainID
- FROM Comments
- WHERE (CommentType IN (1,2))
- AND CpMainID IN (SELECT CpMainID FROM #T3)
- GROUP BY CpMainID
- )b
- WHERE a.CpMainID = b.CpMainID
-
- --修改平均分数
- UPDATE a
- SET a.Score = b.Score
- FROM #T3 a,(
- SELECT SUM(GradeStar)*1.0 AS Score,CpMainID
- FROM Comments
- WHERE CommentType IN (1,2)
- AND CpMainID IN (SELECT CpMainID FROM #T3)
- GROUP BY CpMainID
- )b
- WHERE a.CpMainID = b.CpMainID
-
- UPDATE #T3
- SET Score = CONVERT(DECIMAL(18,1),(Score*1.0)/(cnt*1.0))
- WHERE cnt>0
-
- UPDATE #T3
- SET Score = 0
- WHERE cnt = 0
-
- --拷贝列
- CREATE TABLE #T5(
- [ID] [int] NOT NULL,
- [CpMainID] [int] NOT NULL,
- [PaMainID] [int] NOT NULL,
- [IP] [varchar](15) NULL,
- [SessionID] [varchar](50) NULL,
- [Relation] [tinyint] NOT NULL,
- [GradeStar] [tinyint] NOT NULL,
- [Remark1] [nvarchar](max) NOT NULL,
- [Remark2] [nvarchar](max) NOT NULL,
- [Remark3] [nvarchar](max) NOT NULL,
- [Title] [nvarchar](50) NOT NULL,
- [Position] [nvarchar](50) NULL,
- [WorkRegionID] [varchar](6) NULL,
- [EntryDate] [varchar](6) NULL,
- [QuitDate] [varchar](6) NULL,
- [AddDate] [smalldatetime] NOT NULL,
- [CommentType] [tinyint] NULL,
- [VerifyMan] [int] NULL,
- [VerifyDate] [smalldatetime] NULL,
- [ReplyDate] [smalldatetime] NULL,
- [ReplyContent] [nvarchar](max) NULL,
- [ReplyVerifyMan] [int] NULL,
- [ReplyVerifyDate] [smalldatetime] NULL,
- [PraiseCount] [int] NULL,
- [LoginPraiseCount] [int] NULL,
- [ReplyVerifyResult] [int] NULL,
- [IsDirect] [BIT] NULL,
- [rid] [int] NULL
- )
-
- DECLARE @CpCnt INT --公司数量
- SELECT @CpCnt = COUNT(*) FROM #T3
- IF @CpCnt = 1
- BEGIN
- --取10条点评
- INSERT INTO #T5
- SELECT * FROM
- (
- SELECT *,rid=ROW_NUMBER() OVER(PARTITION BY a.CpmainID ORDER BY a.AddDate DESC)
- FROM Comments a
- WHERE (a.CommentType IN (1,2))
- AND CpMainID IN (SELECT CpMainID FROM #T3)
- ) AS c
- WHERE c.rid<=10
- END
- ELSE
- BEGIN
- --取2条点评
- INSERT INTO #T5
- SELECT * FROM
- (
- SELECT *,rid=ROW_NUMBER() OVER(PARTITION BY a.CpmainID ORDER BY a.AddDate DESC)
- FROM Comments a
- WHERE (a.CommentType IN (1,2))
- AND CpMainID IN (SELECT CpMainID FROM #T3)
- ) AS c
- WHERE c.rid<=2
- END
-
- SELECT * FROM #T3 --公司列表
-
- SELECT @AllCnt --所有公司数
-
- SELECT * FROM #T5 --点评数
-
- --DROP TABLE #T1
- DROP TABLE #T5
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCommentsByPaMainIDSelect] Script Date: 2018/12/13 19:10:00 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.12
- --创建人:Nick
- --说明:判断用户是否发布过点评或面试经历
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCommentsByPaMainIDSelect]
- (
- @PamainID INT,
- @Type INT --1点评 2面试经历
- )
- AS
- BEGIN
- IF @Type = 1
- BEGIN
- SELECT ID FROM Comments WHERE CommentType<>3 AND PamainID = @PamainID
- END
- ELSE
- BEGIN
- SELECT ID FROM InterView WHERE InterviewType<>3 AND PamainID = @PamainID
- END
- End
- GO
- /****** Object: StoredProcedure [dbo].[ProcCommentsByReplyUpdate] Script Date: 2018/12/13 19:10:00 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.20
- --创建人:Nick
- --说明:点评回复
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCommentsByReplyUpdate]
- (
- @ID INT,
- @ReplyContent NVARCHAR(MAX)
- )
- AS
- BEGIN
- UPDATE Comments
- SET ReplyContent = @ReplyContent,
- ReplyDate = GETDATE() ,
- ReplyVerifyResult = NULL ,
- ReplyVerifyDate = NULL
- WHERE ID = @ID
- AND (ReplyVerifyResult <> 1 OR ReplyVerifyResult IS NULL)
- End
- GO
- /****** Object: StoredProcedure [dbo].[ProcCommentsHotSelect] Script Date: 2018/12/13 19:10:00 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.27
- --创建人:Nick
- --说明:获取最多点评排行 最佳点评排行
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCommentsHotSelect]
- (
- @ProvinceID INT
- )
- AS
- BEGIN
- --最多面经排行
- SELECT * FROM SearchDB..CommentsHot
- WHERE CommentType = 1
- AND TypeID = 1
- AND dcProvinceID = @ProvinceID
- ORDER BY Cnt DESC
-
- --最佳点评排行
- SELECT * FROM SearchDB..CommentsHot
- WHERE CommentType = 1
- AND TypeID = 2
- AND dcProvinceID = @ProvinceID
- ORDER BY Cnt DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCommentsInsert] Script Date: 2018/12/13 19:10:00 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.20
- --创建人:Nick
- --说明:插入点评
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCommentsInsert]
- (
- @CpmainID INT,
- @PaMainID INT,
- @IP VARCHAR(15),
- @SessionID VARCHAR(50),
- @Relation INT,
- @GradeStar INT,
- @Remark1 NVARCHAR(MAX),
- @Remark2 NVARCHAR(MAX),
- @Remark3 NVARCHAR(MAX),
- @Title NVARCHAR(50),
- @Position NVARCHAR(50),
- @WorkRegionID INT,
- @EntryDate VARCHAR(6),
- @QuitDate VARCHAR(6)
- )
- AS
- BEGIN
- DECLARE @MemberType INT
- SELECT @MemberType = MemberType FROM CpMain WHERE ID = @CpmainID
- IF @MemberType > 1
- BEGIN
- INSERT INTO Comments (CpmainID,PaMainID,IP,SessionID,Relation,GradeStar,Remark1,Remark2,Remark3,Title,
- Position,WorkRegionID,EntryDate,QuitDate,AddDate,PraiseCount,LoginPraiseCount,CommentType,IsDirect)
- SELECT ID,@PaMainID,@IP,@SessionID,@Relation,@GradeStar,@Remark1,@Remark2,@Remark3,@Title,
- @Position,@WorkRegionID,@EntryDate,@QuitDate,GETDATE(),0,0 ,0,0
- FROM CPMAIN
- WHERE NAME = (
- SELECT Name FROM CpMain WHERE ID = @CpmainID)
- AND MemberType > 1
- AND ID <> @CpmainID
- END
-
- INSERT INTO Comments (CpmainID,PaMainID,IP,SessionID,Relation,GradeStar,Remark1,Remark2,Remark3,Title,
- Position,WorkRegionID,EntryDate,QuitDate,AddDate,PraiseCount,LoginPraiseCount,CommentType,IsDirect)
- VALUES(@CpmainID,@PaMainID,@IP,@SessionID,@Relation,@GradeStar,@Remark1,@Remark2,@Remark3,@Title,
- @Position,@WorkRegionID,@EntryDate,@QuitDate,GETDATE(),0,0 ,0,1 )
- End
- GO
- /****** Object: StoredProcedure [dbo].[ProcCommentsInterviewByHomePageSelect] Script Date: 2018/12/13 19:10:01 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.12.3
- --创建人:John
- --说明:前台首页根据省份ID获取点评与面经的最新5条记录
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCommentsInterviewByHomePageSelect]
- (
- @dcProvinceID INT
- )
- AS
- BEGIN
- SELECT TOP 0 * FROM SearchDb..Hp_Comments WITH(NOLOCK) --WHERE ProvinceId = @dcProvinceID ORDER BY AddDate DESC
- /*
- SELECT TOP 5 * FROM
- (
- SELECT * FROM
- (
- SELECT TOP 5 a.ID,a.CpMainID,a.Title,a.AddDate,1 AS CIType, a.CommentType AS IsGood,b.Name,b.SecondID
- FROM Comments a WITH(NOLOCK),CpMain b WITH(NOLOCK)
- WHERE a.CommentType IN (1,2)
- AND a.CpMainID = b.ID
- AND b.dcRegionID like ''+CONVERT(VARCHAR(6),@dcProvinceID)+'%'
- AND a.IsDirect = 1
- ORDER BY a.AddDate DESC
- ) AS tempComment
- UNION
- SELECT * FROM
- (
- SELECT TOP 5 a.ID,a.CpMainID,a.Title,a.AddDate,2 AS CIType, a.InterviewType AS IsGood,b.Name,b.SecondID
- FROM InterView a WITH(NOLOCK), cpmain b WITH(NOLOCK)
- WHERE a.InterviewType IN (1,2)
- AND a.CpMainID = b.ID
- AND b.dcRegionID like ''+CONVERT(VARCHAR(6),@dcProvinceID)+'%'
- AND a.IsDirect = 1
- ORDER BY a.AddDate DESC
- ) AS tempInterview
- ) AS CIResult ORDER BY AddDate DESC
- */
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCommentsReplyByIDUpdate] Script Date: 2018/12/13 19:10:01 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.18
- --创建人:Nick
- --说明:根据ID修改点评回复信息
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCommentsReplyByIDUpdate]
- (
- @ID INT,
- @ReplyContent NVARCHAR(MAX),
- @ReplyVerifyMan INT,
- @ReplyVerifyResult INT
- )
- AS
- BEGIN
- UPDATE Comments
- SET ReplyContent = @ReplyContent,
- ReplyVerifyMan = @ReplyVerifyMan,
- ReplyVerifyDate = GETDATE(),
- ReplyVerifyResult = @ReplyVerifyResult
- WHERE ID = @ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCommentsSelect] Script Date: 2018/12/13 19:10:01 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.18
- --创建人:Nick
- --说明:查询 点评信息 用于后台审核
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCommentsSelect]
- (
- @Type INT, --1 待审核 点评 2 最近审核 点评 3待审核点评回复 4最近审核 点评回复
- @Where VARCHAR(MAX)
- )
- AS
- BEGIN
- DECLARE @SQL VARCHAR(MAX)
- IF @Type = 1
- BEGIN
- SET @SQL = '
- SELECT a.*,b.name AS CpName,b.RegDate,
- CASE a.PamainID
- WHEN 0 THEN IP
- ELSE (SELECT Name FROM PaMain WHERE ID = a.PaMainID)
- END AS PaName
- FROM Comments a,CpMain b
- WHERE VerifyDate IS NULL
- AND a.IsDirect = 1
- AND a.CpMainID = b.ID '+@Where+'
- ORDER BY AddDate DESC '
- END
- ELSE IF @Type = 2
- BEGIN
- SET @SQL = '
- SELECT a.*,b.name AS CpName ,b.RegDate,
- CASE a.PamainID
- WHEN 0 THEN IP
- ELSE (SELECT Name FROM PaMain WHERE ID = a.PaMainID)
- END AS PaName
- FROM Comments a,CpMain b
- WHERE VerifyDate IS NOT NULL
- AND a.CpMainID = b.ID '+@Where+'
- ORDER BY VerifyDate DESC'
- END
- ELSE IF @Type = 3
- BEGIN
- SET @SQL = '
- SELECT a.*,b.name AS CpName ,b.RegDate,
- CASE a.PamainID
- WHEN 0 THEN IP
- ELSE (SELECT Name FROM PaMain WHERE ID = a.PaMainID)
- END AS PaName
- FROM Comments a,CpMain b
- WHERE ReplyVerifyDate IS NULL
- AND a.CpMainID = b.ID '+@Where+'
- ORDER BY ReplyDate DESC'
- END
- ELSE IF @Type = 4
- BEGIN
- SET @SQL = '
- SELECT a.*,b.name AS CpName ,b.RegDate,
- CASE a.PamainID
- WHEN 0 THEN IP
- ELSE (SELECT Name FROM PaMain WHERE ID = a.PaMainID)
- END AS PaName
- FROM Comments a,CpMain b
- WHERE ReplyVerifyDate IS NOT NULL
- AND a.CpMainID = b.ID '+@Where+'
- ORDER BY ReplyVerifyDate DESC'
- END
- EXEC(@SQL)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCommentsVerifyUpdate] Script Date: 2018/12/13 19:10:01 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.19
- --创建人:Nick
- --说明:批量审核点评或面试信息
- ---增加审核记录,用于计算审核延误7
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCommentsVerifyUpdate]
- (
- @ID INT,
- @Type INT , -- 1点评 2点评 回复 3 面试经历 4面试经历回复
- @VerifyMan INT,
- @VerifyResult INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @submitDate DATETIME
- IF @Type = 1
- BEGIN
- UPDATE Comments
- SET VerifyMan = @VerifyMan,
- VerifyDate = GETDATE(),
- CommentType = @VerifyResult
- WHERE ID =@ID
-
- SELECT @submitDate=AddDate
- FROM Comments
- WHERE ID =@ID
- END
- ELSE IF @Type = 2
- BEGIN
- UPDATE Comments
- SET ReplyVerifyMan = @VerifyMan,
- ReplyVerifyDate = GETDATE(),
- ReplyVerifyResult = @VerifyResult
- WHERE ID =@ID
-
- SELECT @submitDate=ReplyDate
- FROM Comments
- WHERE ID =@ID
-
- END
- ELSE IF @Type = 3
- BEGIN
- UPDATE Interview
- SET VerifyMan = @VerifyMan,
- VerifyDate = GETDATE(),
- InterviewType = @VerifyResult
- WHERE ID =@ID
-
- SELECT @submitDate=AddDate
- FROM Interview
- WHERE ID =@ID
- END
- ELSE IF @Type = 4
- BEGIN
- UPDATE Interview
- SET ReplyVerifyMan = @VerifyMan,
- ReplyVerifyDate = GETDATE(),
- ReplyVerifyResult = @VerifyResult
- WHERE ID =@ID
-
- SELECT @submitDate=ReplyDate
- FROM Interview
- WHERE ID =@ID
- END
- --插入审核延误记录表
- INSERT INTO logdb..VerifyDelayLog(verifyType, relationId, submitDate, verifyDate, verifyMan)
- SELECT 7,@ID,@submitDate, GETDATE(), @VerifyMan
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCompanyByFixPositionIndustrySelect] Script Date: 2018/12/13 19:10:01 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --创建人 sean
- --20111121
- --用于首页查询固定位置单位名称,按行业划分的
- --###########################3
- ---知名企业招聘的hot 是按照 职位的最新增加日期, 加hot的大约是总数的1/5
- ---推荐职位 是在最新发布的职位上加new,数量平均6、7个
- ---热门职位是根据营业执照审核时间最新的加hot,数量是10个
- --###########################3
- CREATE PROCEDURE [dbo].[procCompanyByFixPositionIndustrySelect]
- (
- @subSiteID INT
- )
- AS
- BEGIN
- DECLARE @t AS TABLE(
- ID int IDENTITY(1,1),
- cpMainID VARCHAR(10),
- Name varchar(100),
- JobID varchar(max),
- JobName nvarchar(max),
- Paid numeric(18, 2),
- OpenDate smalldatetime,
- NewXId VARCHAR(12),
- AddDate datetime,
- caORderID INT,
- IndustryCategory INT,
- NoFollow VARCHAR(1)
- )
- IF @subSiteID < 100 --省站
- INSERT @t(cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, IndustryCategory, NoFollow)
- SELECT cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, IndustryCategory, NoFollow
- FROM FpFixPosition
- WHERE dcProvinceId = @subSiteID
- ORDER BY AddDate DESC
- ELSE
- INSERT @t(cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, IndustryCategory, NoFollow)
- SELECT cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, IndustryCategory, NoFollow
- FROM FpFixPosition
- WHERE dcRegionID LIKE LTRIM(STR(@subSiteID)) + '%'
- OR dcSubSiteID LIKE LTRIM(STR(@subSiteID)) + '%'
- ORDER BY AddDate DESC
-
- DECLARE @Num INT, @FlagNum INT, @Sql VARCHAR(MAX)
- SELECT @Num = COUNT(1) FROM @t
- IF @Num > 3
- BEGIN
- SELECT @FlagNum = @Num / 3 + 1
- UPDATE @t SET NewXId = NULL WHERE ID > @FlagNum
- END
- ----加New图标
- SELECT ID, NoFollow + cpMainID cpMainID, Name, JobID, JobName, Paid, OpenDate, NewXId, AddDate, caORderID, IndustryCategory
- FROM @t
- ORDER BY IndustryCategory, CASE Paid WHEN 0 THEN 100 ELSE 0 END, OpenDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCompanyByFixPositionSecIndustrySelect] Script Date: 2018/12/13 19:10:02 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --创建人 sean
- --20111121
- --用于首页查询固定位置单位名称,按行业划分的
- --###########################3
- ---知名企业招聘的hot 是按照 职位的最新增加日期, 加hot的大约是总数的1/5
- ---推荐职位 是在最新发布的职位上加new,数量平均6、7个
- ---热门职位是根据营业执照审核时间最新的加hot,数量是10个
- --###########################3
- CREATE PROCEDURE [dbo].[procCompanyByFixPositionSecIndustrySelect]
- (
- @subSiteID INT
- )
- AS
- BEGIN
- DECLARE @t AS TABLE(
- ID int IDENTITY(1,1),
- cpMainID VARCHAR(10),
- Name varchar(100),
- JobID varchar(max),
- JobName nvarchar(max),
- Paid numeric(18, 2),
- OpenDate smalldatetime,
- NewXId VARCHAR(12),
- AddDate datetime,
- caORderID INT,
- IndustryCategory INT,
- NoFollow VARCHAR(1)
- )
- IF @subSiteID < 100 --省站
- INSERT @t(cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, IndustryCategory, NoFollow)
- SELECT cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, IndustryCategory, NoFollow
- FROM FpFixPosition
- WHERE dcProvinceId = @subSiteID
- ORDER BY AddDate DESC
- ELSE
- INSERT @t(cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, IndustryCategory, NoFollow)
- SELECT cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, IndustryCategory, NoFollow
- FROM FpFixPosition
- WHERE dcRegionID LIKE LTRIM(STR(@subSiteID)) + '%'
- OR dcSubSiteID LIKE LTRIM(STR(@subSiteID)) + '%'
- ORDER BY AddDate DESC
-
- DECLARE @Num INT, @FlagNum INT, @Sql VARCHAR(MAX)
- SELECT @Num = COUNT(1) FROM @t
- IF @Num > 3
- BEGIN
- SELECT @FlagNum = @Num / 3 + 1
- UPDATE @t SET NewXId = NULL WHERE ID > @FlagNum
- END
- ----加New图标
- SELECT ID, NoFollow + cpMainID cpMainID, Name, JobID, JobName, Paid, OpenDate, NewXId, AddDate, caORderID, IndustryCategory
- FROM @t
- ORDER BY IndustryCategory, CASE Paid WHEN 0 THEN 100 ELSE 0 END, OpenDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCompanyByFixPositionSecSelect] Script Date: 2018/12/13 19:10:02 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --创建人 Lambo
- --20101009
- --用于首页查询固定位置单位名称
- --###########################3
- ---知名企业招聘的hot 是按照 职位的最新增加日期, 加hot的大约是总数的1/5
- ---推荐职位 是在最新发布的职位上加new,数量平均6、7个
- ---热门职位是根据营业执照审核时间最新的加hot,数量是10个
- --###########################3
- CREATE PROCEDURE [dbo].[procCompanyByFixPositionSecSelect]
- (
- @subSiteID INT
- )
- AS
- BEGIN
- DECLARE @t AS TABLE(
- ID int IDENTITY(1,1),
- cpMainID varchar(10),
- Name varchar(100),
- JobID varchar(max),
- JobName nvarchar(max),
- Paid numeric(18, 2),
- OpenDate smalldatetime,
- NewXId VARCHAR(12),
- AddDate datetime,
- caORderID INT,
- NoFollow VARCHAR(1)
- )
- IF @subSiteID < 100 --省站
- INSERT @t(cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow)
- SELECT cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow
- FROM FpFixPosition WITH(NOLOCK)
- WHERE dcProvinceId = @subSiteID
- ORDER BY AddDate DESC
- ELSE
- INSERT @t(cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow)
- SELECT cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow
- FROM FpFixPosition WITH(NOLOCK)
- WHERE dcRegionID LIKE LTRIM(STR(@subSiteID)) + '%'
- OR dcSubSiteID LIKE LTRIM(STR(@subSiteID)) + '%'
- ORDER BY AddDate DESC
-
- DECLARE @Num INT, @FlagNum INT, @Sql VARCHAR(MAX)
- SELECT @Num = COUNT(1) FROM @t
- IF @Num > 3
- BEGIN
- SELECT @FlagNum = @Num / 3 + 1
- UPDATE @t SET NewXId = NULL WHERE ID > @FlagNum
- END
- ----加New图标
- SELECT ID, NoFollow + cpMainID cpMainID, Name, JobID, JobName, Paid, OpenDate, NewXId, AddDate, caORderID
- FROM @t
- ORDER BY CASE Paid WHEN 0 THEN 100 ELSE 0 END, OpenDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCompanyByFixPositionSelect] Script Date: 2018/12/13 19:10:02 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --创建人 Lambo
- --20101009
- --用于首页查询固定位置单位名称
- --###########################3
- ---知名企业招聘的hot 是按照 职位的最新增加日期, 加hot的大约是总数的1/5
- ---推荐职位 是在最新发布的职位上加new,数量平均6、7个
- ---热门职位是根据营业执照审核时间最新的加hot,数量是10个
- --###########################3
- CREATE PROCEDURE [dbo].[procCompanyByFixPositionSelect]
- (
- @subSiteID INT
- )
- AS
- BEGIN
- DECLARE @t AS TABLE(
- ID int IDENTITY(1,1),
- cpMainID varchar(10),
- Name varchar(100),
- JobID varchar(max),
- JobName nvarchar(max),
- Paid numeric(18, 2),
- OpenDate smalldatetime,
- NewXId VARCHAR(12),
- AddDate datetime,
- caORderID INT,
- NoFollow VARCHAR(1)
- )
- IF @subSiteID < 100 --省站
- INSERT @t(cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow)
- SELECT cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow
- FROM FpFixPosition WITH(NOLOCK)
- WHERE dcProvinceId = @subSiteID
- ORDER BY Paid DESC, AddDate DESC
- ELSE
- BEGIN
- IF @subSiteID = 3206 AND GETDATE() < '2017-4-29'
- INSERT @t(cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow)
- SELECT cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow
- FROM FpFixPosition WITH(NOLOCK)
- WHERE dcRegionID LIKE LTRIM(STR(@subSiteID)) + '%'
- OR dcSubSiteID LIKE LTRIM(STR(@subSiteID)) + '%'
- OR cpMainId = 'BFE74A5251'
- ORDER BY Paid DESC, AddDate DESC
- ELSE
- INSERT @t(cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow)
- SELECT cpMainID, Name, Paid, OpenDate, JobID, JobName, NewXId, AddDate, caORderID, NoFollow
- FROM FpFixPosition WITH(NOLOCK)
- WHERE dcRegionID LIKE LTRIM(STR(@subSiteID)) + '%'
- OR dcSubSiteID LIKE LTRIM(STR(@subSiteID)) + '%'
- ORDER BY Paid DESC, AddDate DESC
- END
-
- DECLARE @Num INT, @FlagNum INT, @Sql VARCHAR(MAX)
- SELECT @Num = COUNT(1) FROM @t
- IF @Num > 3
- BEGIN
- SELECT @FlagNum = @Num / 3 + 1
- UPDATE @t SET NewXId = NULL WHERE ID > @FlagNum
- END
- ----加New图标
- SELECT ID, NoFollow + cpMainID cpMainID, Name, JobID, JobName, Paid, OpenDate, NewXId, AddDate, caORderID
- FROM @t
- ORDER BY CASE Paid WHEN 0 THEN 100 ELSE 0 END, OpenDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCompanyHomepageLogoSecSelect] Script Date: 2018/12/13 19:10:02 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procCompanyHomepageLogoSecSelect]
- (
- @ProvinceID SMALLINT
- )
- AS
- BEGIN
- SELECT ID, Name, ImgFile, JobIDs, JobNames
- FROM SearchDb..cpMainLogoShot
- WHERE dcProvinceID = @ProvinceID
- ORDER BY RowNo
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCompanyHomepageLogoSelect] Script Date: 2018/12/13 19:10:03 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procCompanyHomepageLogoSelect]
- (
- @ProvinceID SMALLINT
- )
- AS
- BEGIN
- SELECT ID, Name, ImgFile, JobIDs, JobNames, RealCpMainId cpMainId
- FROM SearchDb..cpMainLogoShot
- WHERE dcProvinceID = @ProvinceID
- ORDER BY RowNo
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCompanyHomepageLogoSelectNew] Script Date: 2018/12/13 19:10:03 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procCompanyHomepageLogoSelectNew]
- (
- @ProvinceID SMALLINT
- )
- AS
- BEGIN
- SELECT ID, Name, ImgFile, JobIDs, JobNames
- FROM SEARCHDB..cpMainLogoShot
- WHERE dcProvinceID = @ProvinceID
- ORDER BY RowNo
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCompanyHomepageSecSelect] Script Date: 2018/12/13 19:10:03 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procCompanyHomepageSecSelect]
- (
- @SubSiteId INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @ProvinceID AS INT,
- @RegionType AS INT, ----1:省站;2:二级站
- @RecommendNumber AS INT, ----推荐职位行数
- @HotNumber AS INT, ----热门职位行数
- @RowNumber AS INT,
- @Sql AS VARCHAR(MAX),
- @strRegion AS VARCHAR(100),
- @strMember AS VARCHAR(100)
- SELECT @RecommendNumber = 75, @RegionType = 1, @ProvinceID = @subSiteId
- IF @subSiteId > 100
- BEGIN
- SET @RegionType = 2
- SET @ProvinceID = LEFT(@subSiteId, 2)
- END
-
- ---将推荐职位的和热门的企业都放在临时表中
- CREATE TABLE #t(
- ID int IDENTITY(1,1) NOT NULL,
- dcSubsiteID smallint NULL,
- dcRegionID varchar(6) COLLATE Chinese_PRC_CI_AS NULL,
- cpMainID VARCHAR(11) NULL,
- Name varchar(100) COLLATE Chinese_PRC_CI_AS NULL,
- IsAgent bit NULL,
- JobNumber int NULL,
- JobID varchar(max) COLLATE Chinese_PRC_CI_AS NULL,
- JobName nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL,
- LastJobIssueDate smalldatetime NULL,
- LastJobId VARCHAR(12) NULL,
- cpLicenceDate smalldatetime NULL,
- RefreshDate smalldatetime NULL,
- MemberType tinyint NULL,
- NewXID VARCHAR(12),
- NoFollow VARCHAR(1),
- RealCpMainId INT
- )
- ---向临时表中填入75行推荐职位的
- AddRecommend:
- SELECT @RowNumber = COUNT(1) FROM #t
- IF @RowNumber = 0
- SET @RowNumber = @RecommendNumber
- ELSE
- SET @RowNumber = @RecommendNumber - @RowNumber
- IF @RegionType = 1 --省
- SET @strRegion = '
- AND dcSubsiteID LIKE ''' + LTRIM(STR(@ProvinceID)) + '%'''
- ELSE
- SET @strRegion = '
- AND (dcRegionID like ''' + LTRIM(STR(@subSiteId)) + '%''
- OR dcSubsiteID = ' + LTRIM(STR(@SubsiteID)) + ')'
- ----再该市注测的企业
- SET @Sql = '
- INSERT #t(dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId)
- SELECT TOP ' + LTRIM(STR(@RowNumber)) + ' dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId
- FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK)
- WHERE JobNumber > 0
- AND MemberType > 2
- AND cpMainID Not IN(SELECT cpMainID FROM #t)'
- SET @Sql = @Sql + @strRegion + '
- ORDER BY RefreshDate DESC'
- EXEC(@SQL)
- SELECT @RowNumber = COUNT(1) FROM #t
- IF((@RowNumber < @RecommendNumber) AND (@RegionType = 2))
- BEGIN
- SELECT @RegionType = 1
- GOTO AddRecommend
- END
- ---向临时表中填入热门职位,按照普通会员的刷新时间计算
- SELECT @HotNumber = 80, @RegionType = 1
- IF @subSiteId > 100
- SET @RegionType = 2
- AddHot:
- SELECT @RowNumber = COUNT(1) FROM #t
- SET @RowNumber = @HotNumber + @RecommendNumber - @RowNumber
- IF @RowNumber < 1
- GOTO AddFlag
- IF @ProvinceID IN (32, 30, 31, 35, 10, 11, 12, 40)
- SET @strMember = '
- AND MemberType = 2'
- ELSE
- BEGIN
- SET @strMember = '
- AND MemberType IN(1, 2)'
- END
- SET @Sql = '
- INSERT #t(dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId)
- SELECT TOP ' + LTRIM(STR(@RowNumber)) + ' dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId
- FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK)
- WHERE JobNumber > 0
- AND cpMainID Not IN(SELECT cpMainID FROM #t)'
- SET @Sql = @Sql + @strRegion + @strMember + '
- ORDER BY RefreshDate DESC'
- EXEC(@SQL)
- SELECT @RowNumber = COUNT(1) FROM #t
- IF((@RowNumber < @RecommendNumber + @HotNumber) AND (@RegionType = 2))
- BEGIN
- SELECT @RegionType = 1
- GOTO AddHot
- END
- AddFlag:
- DELETE FROM #t WHERE ID > @RecommendNumber + @HotNumber
- SELECT @RowNumber = 1 + COUNT(1) / 6 FROM #t WHERE MemberType > 2
- SELECT @SQL = 'UPDATE #t SET NewXId = LastJobID WHERE ID IN(SELECT TOP ' + LTRIM(STR(@RowNumber)) +' ID FROM #t WHERE MemberType > 2 ORDER BY LastJobIssueDate DESC)'
- EXEC(@SQL)
- SELECT @RowNumber = 1 + COUNT(1) / 8 FROM #t WHERE MemberType < 3
- SELECT @SQL = 'UPDATE #t SET NewXId = 1 WHERE ID IN(SELECT TOP ' + LTRIM(STR(@RowNumber)) +' ID FROM #t WHERE MemberType < 3 ORDER BY cpLicenceDate DESC)'
- EXEC(@SQL)
- UPDATE #t SET Name = LEFT(Name, 16) WHERE ID > @RecommendNumber AND NewXId = 1 AND LEN(Name) > 16
- UPDATE #t SET cpMainID = NoFollow + cpMainID
- SELECT ID, dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName,
- LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NewXID
- FROM #t WITH(NOLOCK)
- ORDER BY ID
- DROP TABLE #t
- SET NOCOUNT OFF
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCompanyHomepageSelect] Script Date: 2018/12/13 19:10:04 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- /***
- *Peter 2014-02-20修改 添加修正热门职位的地区判断
- *
- */
- CREATE PROCEDURE [dbo].[procCompanyHomepageSelect]
- (
- @SubSiteId INT
- )
- AS
- SET NOCOUNT ON
- --INSERT ProcLog SELECT 'procCompanyHomepageSelect', @SubSiteId, GETDATE()
- IF @SubSiteId > 9999
- BEGIN
- EXEC ProcCountyJobSelect @SubSiteId
- RETURN
- END
- BEGIN
- DECLARE @ProvinceID AS INT,
- @RegionType AS INT, ----1:省站;2:二级站
- @RecommendNumber AS INT, ----推荐职位行数
- @HotNumber AS INT, ----热门职位行数
- @RowNumber AS INT,
- @Sql AS VARCHAR(MAX),
- @strRegion AS VARCHAR(100),
- @strMember AS VARCHAR(100)
- SELECT @RecommendNumber = 75, @RegionType = 1, @ProvinceID = @subSiteId
- IF @subSiteId > 100
- BEGIN
- SET @RegionType = 2
- SET @ProvinceID = LEFT(@subSiteId, 2)
- END
-
- ---将推荐职位的和热门的企业都放在临时表中
- CREATE TABLE #t(
- ID int IDENTITY(1,1) NOT NULL,
- dcSubsiteID smallint NULL,
- dcRegionID varchar(6) COLLATE Chinese_PRC_CI_AS NULL,
- cpMainID VARCHAR(11) NULL,
- Name varchar(100) COLLATE Chinese_PRC_CI_AS NULL,
- IsAgent bit NULL,
- JobNumber int NULL,
- JobID varchar(max) COLLATE Chinese_PRC_CI_AS NULL,
- JobName nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL,
- LastJobIssueDate smalldatetime NULL,
- LastJobId VARCHAR(12) NULL,
- cpLicenceDate smalldatetime NULL,
- RefreshDate smalldatetime NULL,
- MemberType tinyint NULL,
- NewXID VARCHAR(12),
- NoFollow VARCHAR(1),
- RealCpMainId INT
- )
- ---向临时表中填入75行推荐职位的
- AddRecommend:
- SELECT @RowNumber = COUNT(1) FROM #t
- IF @RowNumber = 0
- SET @RowNumber = @RecommendNumber
- ELSE
- SET @RowNumber = @RecommendNumber - @RowNumber
- IF @RegionType = 1 --省
- SET @strRegion = '
- AND dcSubsiteID LIKE ''' + LTRIM(STR(@ProvinceID)) + '%'''
- ELSE
- SET @strRegion = '
- AND (dcRegionID like ''' + LTRIM(STR(@subSiteId)) + '%''
- OR dcSubsiteID = ' + LTRIM(STR(@SubsiteID)) + ')'
- ----再该市注测的企业
- SET @Sql = '
- INSERT #t(dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId)
- SELECT TOP ' + LTRIM(STR(@RowNumber)) + ' dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId
- FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK)
- WHERE JobNumber > 0
- AND MemberType > 2
- AND cpMainID Not IN(SELECT cpMainID FROM #t)'
- SET @Sql = @Sql + @strRegion + '
- ORDER BY RefreshDate DESC'
- --print @sql
- EXEC(@SQL)
- SELECT @RowNumber = COUNT(1) FROM #t
- IF((@RowNumber < @RecommendNumber) AND (@RegionType = 2))
- BEGIN
- SELECT @RegionType = 1
- GOTO AddRecommend
- END
- ---向临时表中填入热门职位,按照普通会员的刷新时间计算
- SELECT @HotNumber = 80, @RegionType = 1
- IF @subSiteId > 100
- SET @RegionType = 2
- AddHot:
- SELECT @RowNumber = COUNT(1) FROM #t
- SET @RowNumber = @HotNumber + @RecommendNumber - @RowNumber
- IF @RowNumber < 1
- GOTO AddFlag
- IF @ProvinceID IN (32, 30, 31, 35, 10, 11, 12, 40)
- SET @strMember = '
- AND MemberType = 2'
- ELSE
- BEGIN
- SET @strMember = '
- AND MemberType IN(1, 2)'
- END
- IF @RegionType = 1 --省
- SET @strRegion = '
- AND dcSubsiteID LIKE ''' + LTRIM(STR(@ProvinceID)) + '%'''
- ELSE
- SET @strRegion = '
- AND (dcRegionID like ''' + LTRIM(STR(@subSiteId)) + '%''
- OR dcSubsiteID = ' + LTRIM(STR(@SubsiteID)) + ')'
- SET @Sql = '
- INSERT #t(dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId)
- SELECT TOP ' + LTRIM(STR(@RowNumber)) + ' dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId
- FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK)
- WHERE JobNumber > 0
- AND cpMainID Not IN(SELECT cpMainID FROM #t)'
- SET @Sql = @Sql + @strRegion + @strMember + '
- ORDER BY RefreshDate DESC'
- EXEC(@SQL)
- SELECT @RowNumber = COUNT(1) FROM #t
- IF((@RowNumber < @RecommendNumber + @HotNumber) AND (@RegionType = 2))
- BEGIN
- SELECT @RegionType = 1
- GOTO AddHot
- END
- AddFlag:
- DELETE FROM #t WHERE ID > @RecommendNumber + @HotNumber
- SELECT @RowNumber = 1 + COUNT(1) / 6 FROM #t WHERE MemberType > 2
- SELECT @SQL = 'UPDATE #t SET NewXId = LastJobID WHERE ID IN(SELECT TOP ' + LTRIM(STR(@RowNumber)) +' ID FROM #t WHERE MemberType > 2 ORDER BY LastJobIssueDate DESC)'
- EXEC(@SQL)
- SELECT @RowNumber = 1 + COUNT(1) / 8 FROM #t WHERE MemberType < 3
- SELECT @SQL = 'UPDATE #t SET NewXId = 1 WHERE ID IN(SELECT TOP ' + LTRIM(STR(@RowNumber)) +' ID FROM #t WHERE MemberType < 3 ORDER BY cpLicenceDate DESC)'
- EXEC(@SQL)
- UPDATE #t SET Name = LEFT(Name, 16) WHERE ID > @RecommendNumber AND NewXId = 1 AND LEN(Name) > 16
- UPDATE #t SET cpMainID = NoFollow + cpMainID
- SELECT ID, dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName,
- LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NewXID
- FROM #t WITH(NOLOCK)
- ORDER BY ID
- DROP TABLE #t
- SET NOCOUNT OFF
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCompanyListByCpIDsSelect] Script Date: 2018/12/13 19:10:05 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.3
- --创建人:John
- --说明:返回cpid在参数内的企业信息
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCompanyListByCpIDsSelect]
- (
- @CpIDs VARCHAR(1000)
- )
- AS
- BEGIN
- DECLARE @SQL VARCHAR(2000)
- SET @SQL = 'SELECT TOP 500 a.id AS cpid, a.Name AS companyName, b.id AS caid
- FROM [MainDb]..[cpMain] a, [MainDb]..[caMain] b
- WHERE a.id = b.cpMainID
- AND b.IsPause = 0
- AND b.IsDelete = 0
- AND b.AccountType = 1
- AND a.id IN ( ' + @CpIDs + ' )'
- EXEC(@SQL)
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCoorperation8Select] Script Date: 2018/12/13 19:10:05 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:NICK
- --说明:获取合作伙伴
- --#####################################################
- CREATE PROCEDURE [dbo].[procCoorperation8Select]
- AS
- BEGIN
- SELECT top 8 * FROM Maindb..Coorperation WITH(NOLOCK)
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCounterByVersionIDUpdate] Script Date: 2018/12/13 19:10:06 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procCounterByVersionIDUpdate]
- (
- @VersionId SMALLINT,
- @VNumber INT,
- @SVNumber INT
- )
- AS
- BEGIN
- SET NOCOUNT ON
- UPDATE Counter SET ViewNumber = ViewNumber + @VNumber,
- SpiderViewNumber = SpiderViewNumber + @SVNumber
- WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
- AND VersionId = @VersionId
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCounterSpiderUpdate] Script Date: 2018/12/13 19:10:06 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER OFF
- GO
- CREATE PROCEDURE [dbo].[procCounterSpiderUpdate]
- (
- @VersionId SMALLINT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- -- UPDATE Counter SET SpiderViewNumber = SpiderViewNumber + 1
- -- WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
- -- AND VersionId = @VersionId
- INSERT INTO CounterSpider SELECT @VersionId, GETDATE()
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCounterUpdate] Script Date: 2018/12/13 19:10:06 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER OFF
- GO
- CREATE PROCEDURE [dbo].[procCounterUpdate]
- (
- @VersionId SMALLINT
- )
- AS
- BEGIN
- SET NOCOUNT ON
- UPDATE Counter SET ViewNumber = ViewNumber + 1
- WHERE CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
- AND VersionId = @VersionId
- SET NOCOUNT OFF
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCountyHotJobSelect] Script Date: 2018/12/13 19:10:06 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- /***
- *Peter 2014-02-20修改 添加修正热门职位的地区判断
- *
- */
- CREATE PROCEDURE [dbo].[procCountyHotJobSelect]
- (
- @RegionId INT
- )
- AS
- BEGIN
- SET NOCOUNT ON
- DECLARE @HotNumber AS INT, ----热门职位行数
- @ProvinceID AS INT,
- @RegionType AS INT,
- @RowNumber AS INT,
- @Sql AS VARCHAR(MAX),
- @strMember AS VARCHAR(100),
- @strRegion AS VARCHAR(100)
-
- ---将推荐职位的和热门的企业都放在临时表中
- CREATE TABLE #t(
- ID int IDENTITY(1,1) NOT NULL,
- dcSubsiteID smallint NULL,
- dcRegionID varchar(6) COLLATE Chinese_PRC_CI_AS NULL,
- cpMainID VARCHAR(11) NULL,
- Name varchar(100) COLLATE Chinese_PRC_CI_AS NULL,
- IsAgent bit NULL,
- JobNumber int NULL,
- JobID varchar(max) COLLATE Chinese_PRC_CI_AS NULL,
- JobName nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL,
- LastJobIssueDate smalldatetime NULL,
- LastJobId VARCHAR(12) NULL,
- cpLicenceDate smalldatetime NULL,
- RefreshDate smalldatetime NULL,
- MemberType tinyint NULL,
- NewXID VARCHAR(12),
- NoFollow VARCHAR(1),
- RealCpMainId INT
- )
- ---向临时表中填入热门职位,按照普通会员的刷新时间计算
- SELECT @HotNumber = 60
- SET @ProvinceID = LEFT(@RegionId, 2)
- SET @RegionType=3--县级市
- AddHot:
- SELECT @RowNumber = COUNT(1) FROM #t
- IF @RowNumber < 1
- GOTO AddFlag
- IF @ProvinceID IN (32, 30, 31, 35, 10, 11, 12, 40)
- SET @strMember = '
- AND MemberType = 2'
- ELSE
- BEGIN
- SET @strMember = '
- AND MemberType IN(1, 2)'
- END
- IF @RegionType = 1 --省
- SET @strRegion = '
- AND dcSubsiteID LIKE ''' + LTRIM(STR(@ProvinceID)) + '%'''
- IF @RegionType = 2 --市
- SET @strRegion = '
- AND (dcRegionID like ''' + LTRIM(STR(@ProvinceID)) + '%''
- OR dcSubsiteID = ' + LTRIM(STR(@ProvinceID)) + ')'
- IF @RegionType = 3 --县级
- SET @strRegion = '
- AND (dcRegionID = ''' + LTRIM(STR(@RegionId)) + '%''
- OR dcSubsiteID = ' + LTRIM(STR(@RegionId)) + ')'
- SET @Sql = '
- INSERT #t(dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId)
- SELECT TOP ' + LTRIM(STR(@RowNumber)) + ' dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NoFollow, RealCpMainId
- FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK)
- WHERE JobNumber > 0
- AND cpMainID Not IN(SELECT cpMainID FROM #t)'
- SET @Sql = @Sql + @strRegion + @strMember + '
- ORDER BY RefreshDate DESC'
- print @sql
- EXEC(@SQL)
- SELECT @RowNumber = COUNT(1) FROM #t
- IF((@RowNumber <@HotNumber))
- BEGIN
- IF @RegionType = 3
- SELECT @RegionType = 2
- ELSE IF @RegionType = 2
- SELECT @RegionType = 1
- GOTO AddHot
- END
- AddFlag:
- DELETE FROM #t WHERE ID > @HotNumber
- SELECT @RowNumber = 1 + COUNT(1) / 6 FROM #t WHERE MemberType > 2
- SELECT @SQL = 'UPDATE #t SET NewXId = LastJobID WHERE ID IN(SELECT TOP ' + LTRIM(STR(@RowNumber)) +' ID FROM #t WHERE MemberType > 2 ORDER BY LastJobIssueDate DESC)'
- EXEC(@SQL)
- SELECT @RowNumber = 1 + COUNT(1) / 8 FROM #t WHERE MemberType < 3
- SELECT @SQL = 'UPDATE #t SET NewXId = 1 WHERE ID IN(SELECT TOP ' + LTRIM(STR(@RowNumber)) +' ID FROM #t WHERE MemberType < 3 ORDER BY cpLicenceDate DESC)'
- EXEC(@SQL)
-
- UPDATE #t SET cpMainID = NoFollow + cpMainID
- SELECT ID, dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName,
- LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NewXID
- FROM #t WITH(NOLOCK)
- ORDER BY ID
- DROP TABLE #t
- SET NOCOUNT OFF
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCountyJobInsert] Script Date: 2018/12/13 19:10:06 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procCountyJobInsert]
- (
- @RegionId VARCHAR(6)
- )
- AS
- SET NOCOUNT ON
- INSERT INTO ProcLog SELECT 'procCountyJobInsert', @RegionId, GETDATE()
- IF EXISTS(SELECT 'x' FROM SearchDb..CountyJob WHERE JobPlaceId = @RegionId AND crDate > DATEADD(MINUTE, -120, GETDATE()))
- RETURN
- BEGIN TRY
- CREATE TABLE #t(
- RowID int IDENTITY(1, 1) NOT NULL,
- PageId int NOT NULL DEFAULT ((0)),
- ID int NOT NULL,
- cpMainID int NOT NULL,
- caMainID int NOT NULL,
- JobName nvarchar(50) NOT NULL,
- dcJobTypeID smallint NOT NULL,
- dcJobTypeIDMinor smallint NULL,
- NeedNumber tinyint NULL,
- dcSalaryID tinyint NOT NULL,
- EmployType tinyint NOT NULL,
- dcRegionID varchar(6) NOT NULL,
- Responsibility nvarchar(max) NULL,
- Demand nvarchar(max) NULL,
- dcEducationID tinyint NOT NULL,
- MinExperience tinyint NOT NULL,
- MinAge tinyint NULL,
- MaxAge tinyint NULL,
- IssueDate smalldatetime NULL,
- IssueEND smalldatetime NULL,
- IsDelete bit NOT NULL,
- AddDate smalldatetime NOT NULL,
- RefreshDate smalldatetime NULL,
- Welfare1 bit NULL,
- Welfare2 bit NULL,
- Welfare3 bit NULL,
- Welfare4 bit NULL,
- Welfare5 bit NULL,
- Welfare6 bit NULL,
- Welfare7 bit NULL,
- Welfare8 bit NULL,
- Welfare9 bit NULL,
- Welfare10 bit NULL,
- Welfare11 bit NULL,
- Welfare12 bit NULL,
- Welfare13 bit NULL,
- Welfare14 bit NULL,
- Welfare15 bit NULL,
- Welfare16 bit NULL,
- Welfare17 bit NULL,
- Welfare18 bit NULL,
- EnJobID varchar(12) NULL,
- EnCpMainID varchar(10) NULL,
- LastModifyDate smalldatetime NOT NULL,
- cpName nvarchar(100) NULL,
- dcCompanySizeID tinyint NULL,
- HasLicence bit NOT NULL,
- UnLimitedDate smalldatetime NOT NULL,
- BalanceDate smalldatetime NOT NULL,
- Balance smallint NOT NULL,
- MemberType tinyint NOT NULL,
- cpIndustry nvarchar(max) NULL,
- IsRefreshed bit NOT NULL
- )
-
- ----建立临时表
- CREATE TABLE #Job(
- ID int NOT NULL,
- cpMainID int NOT NULL,
- caMainID int NOT NULL,
- JobName nvarchar(50) NOT NULL,
- dcJobTypeID smallint NOT NULL,
- dcJobTypeIDMinor smallint NULL,
- NeedNumber tinyint NULL,
- dcSalaryID tinyint NOT NULL,
- EmployType tinyint NOT NULL,
- dcRegionID varchar(6) NOT NULL,
- Responsibility nvarchar(max) NULL,
- Demand nvarchar(max) NULL,
- dcEducationID tinyint NOT NULL,
- MinExperience tinyint NOT NULL,
- MinAge tinyint NULL,
- MaxAge tinyint NULL,
- IssueDate smalldatetime NULL,
- IssueEND smalldatetime NULL,
- IsDelete bit NOT NULL,
- AddDate smalldatetime NOT NULL,
- RefreshDate smalldatetime NULL,
- Welfare1 bit NULL,
- Welfare2 bit NULL,
- Welfare3 bit NULL,
- Welfare4 bit NULL,
- Welfare5 bit NULL,
- Welfare6 bit NULL,
- Welfare7 bit NULL,
- Welfare8 bit NULL,
- Welfare9 bit NULL,
- Welfare10 bit NULL,
- Welfare11 bit NULL,
- Welfare12 bit NULL,
- Welfare13 bit NULL,
- Welfare14 bit NULL,
- Welfare15 bit NULL,
- Welfare16 bit NULL,
- Welfare17 bit NULL,
- Welfare18 bit NULL,
- EnJobID varchar(12) NULL,
- EnCpMainID varchar(10) NULL,
- LastModifyDate smalldatetime NOT NULL,
- cpName nvarchar(100) NULL,
- dcCompanySizeID tinyint NULL,
- HasLicence bit NOT NULL,
- UnLimitedDate smalldatetime NOT NULL,
- BalanceDate smalldatetime NOT NULL,
- Balance smallint NOT NULL,
- MemberType tinyint NOT NULL,
- cpIndustry nvarchar(max) NULL,
- IsRefreshed bit NOT NULL
- )
- INSERT INTO #Job
- SELECT TOP 2000 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.SecondId EnJobID, b.SecondId EnCpMainID,
- 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,
- b.IsRefreshed
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK)
- WHERE a.cpMainID = b.ID
- AND a.dcRegionId LIKE LEFT(@RegionId, 2) + '%'
- AND a.Valid = 1
- AND b.Valid = 1
- ORDER BY a.RefreshDate DESC
- DELETE #Job WHERE dcRegionId = @RegionId
- INSERT INTO #Job
- SELECT TOP 2000 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.SecondId EnJobID, b.SecondId EnCpMainID,
- 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,
- b.IsRefreshed
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK)
- WHERE a.cpMainID = b.ID
- AND a.dcRegionId = @RegionId
- AND a.Valid = 1
- AND b.Valid = 1
- ORDER BY a.RefreshDate DESC
- CREATE NONCLUSTERED INDEX [IX_#Job_dcRegionID] ON [dbo].[#Job](dcRegionId ASC)
- CREATE NONCLUSTERED INDEX [IX_#Job_RefreshDate] ON [dbo].[#Job](RefreshDate DESC)
- --DELETE SearchDb..CountyJobNumber WHERE ProvinceId = @ProvinceId
- --INSERT SearchDb..CountyJobNumber SELECT @ProvinceId, COUNT(*) FROM #Job
- INSERT #t
- SELECT TOP 2000 0, ID, cpMainID, caMainID, JobName, dcJobTypeID,
- dcJobTypeIDMinor, NeedNumber, dcSalaryID, EmployType,
- dcRegionID, Responsibility, Demand, dcEducationID,
- MinExperience, MinAge, MaxAge, IssueDate, IssueEND,
- IsDelete, AddDate, RefreshDate, Welfare1, Welfare2, Welfare3,
- Welfare4, Welfare5, Welfare6, Welfare7, Welfare8,
- Welfare9, Welfare10, Welfare11, Welfare12, Welfare13,
- Welfare14, Welfare15, Welfare16, Welfare17, Welfare18, EnJobID, EnCpMainID,
- LastModifyDate, cpName, dcCompanySizeID,
- HasLicence, UnLimitedDate, BalanceDate, Balance,
- MemberType, cpIndustry, IsRefreshed
- FROM #Job WITH(NOLOCK)
- ORDER BY CASE dcRegionID WHEN @RegionId THEN 1 ELSE 2 END,
- RefreshDate DESC
- BEGIN TRY
- UPDATE #t SET PageId = (RowId + 19) / 20
- DELETE SearchDb..CountyJob WHERE JobPlaceId = @RegionID
- INSERT INTO SearchDb..CountyJob SELECT @RegionID, *, GETDATE() FROM #t
- TRUNCATE TABLE #t
- END TRY
- BEGIN CATCH
- END CATCH
- END TRY
- BEGIN CATCH
- ---检查是否已经建立临时表,已经建立则删除
- PRINT 'error'
- PRINT error_Message()
- PRINT error_number()
- PRINT error_line()
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcCountyJobSelect] Script Date: 2018/12/13 19:10:07 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcCountyJobSelect]
- (
- @SubSiteId INT
- )
- AS
- SET NOCOUNT ON
- --this proc is valid
- BEGIN
- DECLARE @Refresh INT
- SET @Refresh = 0
- IF @SubSiteId LIKE '32%'
- BEGIN
- IF ISNULL((SELECT TOP 1 DATEDIFF(MINUTE, AddDate, GETDATE()) FROM ShortDb..CountyJob WHERE CountyId = @SubSiteId), 999) > 120
- SET @Refresh = 1
- END
- ELSE
- BEGIN
- IF ISNULL((SELECT TOP 1 DATEDIFF(MINUTE, AddDate, GETDATE()) FROM ShortDb..CountyJob WHERE CountyId = @SubSiteId), 999) > 480
- SET @Refresh = 1
- END
- IF @Refresh = 1
- BEGIN
- DECLARE @RowNumber AS INT, @SiteId INT
- SELECT @SiteId = @SubSiteId, @RowNumber = 0
- ---将推荐职位的和热门的企业都放在临时表中
- DECLARE @t AS TABLE(
- ID int IDENTITY(1, 1) NOT NULL,
- dcSubsiteID smallint NOT NULL,
- dcRegionID varchar(6) NULL,
- cpMainID varchar(11) NULL,
- Name varchar(100) NULL,
- IsAgent bit NULL,
- JobNumber int NULL,
- JobID varchar(max) NULL,
- JobName nvarchar(max) NULL,
- LastJobIssueDate smalldatetime NULL,
- LastJobId varchar(12) NULL,
- cpLicenceDate smalldatetime NULL,
- RefreshDate smalldatetime NULL,
- MemberType tinyint NULL,
- NewXID varchar(12) NULL,
- NoFollow varchar(1) NULL,
- RealCpMainId int NULL,
- AddDate smalldatetime NOT NULL DEFAULT (getdate())
- )
- ---向临时表中填入75行推荐职位的
- AddRecommend:
- INSERT @t(cpMainId, dcSubsiteID, dcRegionID, Name, IsAgent, JobNumber, RefreshDate, MemberType, RealCpMainId)
- SELECT TOP (75 - @RowNumber) SecondId, dcSubsiteID, dcRegionID, Name, IsAgent, JobNumber, RefreshDate, MemberType, Id
- FROM MainDb..cpMain WITH(NOLOCK)
- WHERE JobNumber > 0
- AND MemberType > 1
- AND (dcRegionID = @SiteId
- OR dcSubsiteID = @SiteId)
- ORDER BY MemberType DESC, RefreshDate DESC
-
- SELECT @RowNumber = COUNT(1) FROM @t
- IF(@RowNumber < 75)
- BEGIN
- INSERT @t(cpMainId, dcSubsiteID, dcRegionID, Name, IsAgent, JobNumber, RefreshDate, MemberType, RealCpMainId)
- SELECT TOP (75 - @RowNumber) SecondId, dcSubsiteID, dcRegionID, Name, IsAgent, JobNumber, RefreshDate, MemberType, Id
- FROM MainDb..cpMain WITH(NOLOCK)
- WHERE JobNumber > 0
- AND MemberType = 1
- AND (dcRegionID = @SiteId
- OR dcSubsiteID = @SiteId)
- ORDER BY RefreshDate DESC
- END
- SELECT @RowNumber = COUNT(1) FROM @t
- IF(@RowNumber < 75 AND @SiteId > 99)
- BEGIN
- SET @SiteId = LEFT(@SiteId, LEN(@SiteId) - 2)
- GOTO AddRecommend
- END
- DELETE @t WHERE Id > 75
- UPDATE @t SET JobId = dbo.getJobSecondIds(RealCpMainid), JobName = dbo.getJobNames(RealCpMainid)
- UPDATE a SET a.cplicenceDate = b.checkDate
- FROM @t a, cpLicence b
- WHERE a.RealCpMainid = b.cpMainid
- AND a.MemberType < 3
- SELECT @RowNumber = COUNT(*) FROM @t WHERE MemberType = 3
- UPDATE a SET LastJobId = (SELECT TOP 1 ID FROM Job WITH(NOLOCK) WHERE Job.cpMainid = a.RealCpMainid AND Valid = 1 ORDER BY IssueDate DESC) FROM @t a
- UPDATE a SET LastJobIssueDate = (SELECT IssueDate FROM Job WHERE Job.id = a.LastJobid) FROM @t a WHERE MemberType > 2
- UPDATE @t SET NewXId = LastJobID WHERE Id IN(SELECT TOP (@RowNumber / 4) Id FROM @t WHERE MemberType = 3 ORDER BY LastJobIssueDate DESC)
- UPDATE @t SET NewXId = LastJobID WHERE Id IN(SELECT TOP (@RowNumber / 6) Id FROM @t WHERE MemberType < 3 ORDER BY cplicenceDate DESC)
- DELETE FROM ShortDb..CountyJob WHERE CountyId = @SubSiteId
- INSERT INTO ShortDb..CountyJob(ID, CountyId, dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName,
- LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NewXID)
- SELECT ID, @SubsiteID, dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName,
- LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, MemberType, NewXID
- FROM @t
- ORDER BY ID
- END
- SELECT * FROM ShortDb..CountyJob WHERE CountyId = @SubSiteId ORDER BY ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCpImageSelect] Script Date: 2018/12/13 19:10:07 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --------------------------------------------------
- --创建:Nick
- --创建日期:2016-2-15
- --获取环境照片企业列表
- --------------------------------------------------
- CREATE PROCEDURE [dbo].[procCpImageSelect]
- (
- @ProvinceID INT,
- @PageNo INT
- )
- AS
- BEGIN
- CREATE TABLE #indextable(
- [NUM] int identity(1,1),
- ID INT NULL,
- chDate DATETIME
- )
- INSERT INTO #indextable(ID,chDate)
- SELECT TOP 500 CpmainID,MAX(a.CheckDate) AS ChDate
- FROM CpImage a WITH(NOLOCK),CpMain b WITH(NOLOCK)
- WHERE a.Imgtype = 3
- AND a.HasPassed=1
- AND a.CheckDate IS NOT NULL
- AND A.CpMainID = b.ID
- AND dcProvinceID = @ProvinceID
- AND a.AddDate > '2016-2-17'
- GROUP BY a.CpmainID
- ORDER BY ChDate DESC
-
- --分页
- DECLARE @PageSize INT
- SET @PageSize = 10
- DECLARE @PageLowerBound INT --定义此页的底码
- DECLARE @PageUpperBound INT --定义此页的顶码
- SET @PageLowerBound = (@PageNo -1) * @pagesize
- SET @PageUpperBound = @PageLowerBound + @pagesize
- DECLARE @Campus AS TABLE(
- [CpMainID] INT,
- SecondID VARCHAR(100),
- ImgFile VARCHAR(200),
- Name NVARCHAR(100),
- Content VARCHAR(200)
- )
-
- INSERT INTO @Campus (CpMainID,SecondID,Name)
- SELECT b.ID,b.SecondID,b.Name
- FROM (SELECT * FROM #indextable WHERE Num > @PageLowerBound AND Num <= @PageUpperBound)a,
- CpMain b WITH(NOLOCK)
- WHERE a.ID = b.ID
-
- UPDATE a
- SET ImgFile = (
- SELECT TOP 1 ImgFile
- FROM CpImage WITH(NOLOCK)
- WHERE CpMainID = a.CpMainID
- AND Imgtype = 3
- AND HasPassed=1
- AND CheckDate IS NOT NULL
- ORDER BY CheckDate DESC
- ) FROM @Campus a
- UPDATE a
- SET Content = (
- SELECT TOP 1 Description
- FROM CpImage WITH(NOLOCK)
- WHERE CpMainID = a.CpMainID
- AND Imgtype = 3
- AND HasPassed=1
- AND CheckDate IS NOT NULL
- ORDER BY CheckDate DESC
- ) FROM @Campus a
- SELECT COUNT(*) FROM #indextable
- SELECT * FROM @Campus
- END
- GO
- /****** Object: StoredProcedure [dbo].[proccpIndustryByJobIDSelect] Script Date: 2018/12/13 19:10:07 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.31
- --创建人:Nick
- --说明:获取职位信息 用于计算与简历的匹配度
- --#####################################################
- CREATE PROCEDURE [dbo].[proccpIndustryByJobIDSelect]
- (
- @JobID INT
- )
- AS
- BEGIN TRY
- SELECT x.*,','+STUFF((
- SELECT ','+LTRIM(a.dcIndustryid)+',c'+LTRIM(b.CateGory)
- FROM cpIndustry a,dcIndustry b
- WHERE a.dcIndustryid = b.ID AND cpMainid = x.cpMainID FOR XML PATH('')),1,1,'')+',' cpIndustry
- FROM Job x WITH(NOLOCK)
- WHERE ID = @JobID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procCpMainByCpImageSelect] Script Date: 2018/12/13 19:10:07 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --福利分享专题根据公司上传环境图获取公司列表
- --创建时间 2016-02-15
- --创建人 Peter
- CREATE PROCEDURE [dbo].[procCpMainByCpImageSelect]
- (
- @SqlWhere AS VARCHAR(500),
- @PageNo AS INT
- )
- AS
- BEGIN
- CREATE TABLE #T(
- cpMainID INT,
- CheckDate DATETIME
- )
- SET @SqlWhere = dbo.SafeSql(@SqlWhere)
- DECLARE @SQL AS VARCHAR(1000)
-
- SET @SQL='INSERT INTO #T SELECT cpmainid,MAX(CheckDate) CheckDate
- FROM cpImage WITH(NOLOCK)
- WHERE HasPassed = 1
- AND ImgType = 3
- AND (SELECT TOP 1 Valid FROM CpMain WITH(NOLOCK) WHERE id = cpImage.cpMainID) = 1
- AND EXISTS(SELECT id FROM Job WITH(NOLOCK) WHERE cpMainID = cpimage.cpMainid AND IsDelete = 0 AND IssueEnd > GETDATE() AND IssueDate < GETDATE()) ' + @SqlWhere + '
- GROUP BY cpmainid '
- EXEC(@SQL)
- SELECT b.PageIndex,a.id,a.Name,a.SecondID
- FROM cpMain a WITH(NOLOCK),(
- SELECT TOP (@PageNo*12) ROW_NUMBER() OVER (ORDER BY CheckDate DESC) PageIndex,cpMainID
- FROM #T) b
- WHERE b.cpMainID=a.id
- AND b.PageIndex > (@PageNo-1)*12
- ORDER BY b.PageIndex ASC
- SELECT COUNT(1) FROM #T
- DROP TABLE #T
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCpMainByEndDateSelect] Script Date: 2018/12/13 19:10:08 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcCpMainByEndDateSelect]
- AS
- BEGIN
- CREATE TABLE #t(ID INT, CompanyName NVARCHAR(60), ConsultantID INT, Superior INT, Code INT)
- INSERT INTO #t
- SELECT ID, Name, ConsultantID, 0, DATEPART(HOUR, RegDate) * 100 + DATEPART(MINUTE, RegDate) FROM cpMain WITH(NOLOCK)
- WHERE UnlimitedDate BETWEEN GETDATE() AND GETDATE() + 7
- INSERT INTO #t
- SELECT ID, Name, ConsultantID, 0, DATEPART(HOUR, RegDate) * 100 + DATEPART(MINUTE, RegDate) FROM cpMain WITH(NOLOCK)
- WHERE BalanceDate BETWEEN GETDATE() AND GETDATE() + 7
- INSERT INTO #t
- SELECT ID, Name, ConsultantID, 0, DATEPART(HOUR, RegDate) * 100 + DATEPART(MINUTE, RegDate) FROM cpMain WITH(NOLOCK)
- WHERE MemberType = 3 AND id IN
- (
- SELECT cpmainid FROM caOrder WITH(NOLOCK)
- WHERE ORderType = 8
- GROUP BY cpMainid
- HAVING MAX(EndDate) BETWEEN GETDATE() AND GETDATE() + 7
- )
- --DELETE FROM #t WHERE ConsultantID IN(SELECT ID FROM ManagerUser WHERE Status<> 3)
- UPDATE #t SET Superior = ConsultantId WHERE ConsultantId IN(SELECT ID FROM ManagerUser WHERE Status<3 AND RtxStatus IN(1, 2))
- UPDATE #t SET Superior = (SELECT Superior FROM ManagerUser WHERE ManagerUser.Id = ConsultantID) WHERE ISNULL(Superior, 0) = 0
- UPDATE #t SET Superior = 180 + (ID % 4) WHERE ISNULL(Superior, 0) = 0
- --SELECT * FROM #t
- INSERT INTO OaDb..RtxSend(Receiver, RtxTitle, RtxMessage, SendType, DelayTime, ShowType, SendTime, AddTime)
- SELECT Superior, '订单到期通知', CompanyName + '(' + LTRIM(STR(ID)) + ') http://sysback.51rc.com/newoa/company/cp/cpMainInfo?id=' + LTRIM(STR(ID)) + '&code=' + LTRIM(STR(Code)) + ' 将在7天内到期,请关注。', 1, 0, 0, NULL, GETDATE()
- FROM #t
- DROP TABLE #t
- END
-
- GO
- /****** Object: StoredProcedure [dbo].[procCpMainByFewSelect] Script Date: 2018/12/13 19:10:08 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procCpMainByFewSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT RegisterIp
- FROM cpMain a WITH(NOLOCK)
- WHERE a.ID =@ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCpMainByIDSelect] Script Date: 2018/12/13 19:10:08 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:NICK
- --说明:根据ID获取cpmain
- --#####################################################
- CREATE PROCEDURE [dbo].[procCpMainByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT TOP 1 * FROM cpmain WHERE ID = @ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCpMainByKeyWordSelect] Script Date: 2018/12/13 19:10:08 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.25
- --创建人:Nick
- --说明:点评 搜索公司
- --#####################################################
- CREATE PROCEDURE [dbo].[procCpMainByKeyWordSelect]
- (
- @Name VARCHAR(25),
- @ProvinceID INT
- )
- AS
- BEGIN
- DECLARE @t AS TABLE(ID INT,
- SecondId VARCHAR(12),
- Name NVARCHAR(50)
- )
- INSERT INTO @t
- SELECT TOP 48 a.ID, a.SecondId, a.Name
- FROM cpMainPublish a WITH(NOLOCK),
- CONTAINSTABLE(cpMainPublish, Name, @Name, 100) AS b
- WHERE a.Id = b.[Key]
- AND a.dcRegionID LIKE LTRIM(STR(@ProvinceID)) + '%'
- IF NOT EXISTS(SELECT 'x' FROM @t)
- BEGIN
- INSERT @t
- SELECT TOP 48 ID,SecondId, Name
- FROM cpMainPublish WITH(NOLOCK INDEX(IX_cpMainPublish_Name))
- WHERE Name LIKE @Name + '%'
- AND LEFT(cpMainPublish.dcRegionID, 2) = @ProvinceID
- ORDER BY RefreshDate DESC
- END
- SELECT * FROM @t
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCpMainByReplyRateUpdate] Script Date: 2018/12/13 19:10:09 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --计算企业回复率
- --20151126 nick
- --修改harry,修改此方法只计算未确认自动答复的答复率2017-5-25,答复率小于0.6的也显示
- CREATE PROCEDURE [dbo].[procCpMainByReplyRateUpdate]
- AS
- SET NOCOUNT ON
- BEGIN
- UPDATE ExjobApply SET ReplyDate = CompanyDeleteDate WHERE ReplyDate IS NULL AND Reply = 4
- UPDATE ExjobApply SET ReplyDate = CompanyDeleteDate WHERE ReplyDate IS NULL AND Reply = 4
- UPDATE ExjobApply SET ReplyDate = ViewDate WHERE ReplyDate IS NULL AND Reply = 1 AND ViewDate IS NOT NULL
- UPDATE ExjobApply SET ReplyDate = CompanyDeleteDate WHERE ReplyDate IS NULL AND Reply = 1 AND CompanyDeleteDate IS NOT NULL
- UPDATE ExjobApply SET ReplyDate = AddDate + 1 WHERE ReplyDate IS NULL AND Reply > 0
- SELECT DISTINCT a.cpMainId
- INTO #t
- FROM Job a, ExJobApply b, cpMain c
- WHERE a.id = b.JobId
- AND b.ReplyDate > CONVERT(VARCHAR(10), GETDate() - 2, 120)
- AND c.id = a.cpMainId
- AND c.AutoReplyConfirm is NULL --harry
- SELECT a.cpMainId, COUNT(*) Cnt, COUNT(ReplyDate) ReplyCnt
- INTO #1
- FROM #t a, ExjobApply b, Job c
- WHERE a.cpMainId = c.cpMainId
- AND c.Id = b.JobId
- AND b.AddDate > GETDate() - 183
- GROUP BY a.cpMainId
- --HAVING COUNT(*) > 9
- UPDATE a
- SET a.ReplyRate = b.ReplyCnt * 1.0 / b.Cnt
- FROM cpMain a, #1 b
- WHERE a.Id = b.cpMainId
- AND b.ReplyCnt * 1.0 / b.Cnt > = 0.1
- --UPDATE cpMain SET ReplyRate = NULL WHERE ReplyRate < 0.6
- SELECT a.id, a.ReplyRate rate1, b.ReplyRate rate2
- INTO #t2
- FROM cpMainpublish a, cpMain b
- WHERE a.id = b.id
- AND isNULL(a.ReplyRate,0) <> ISNULL(b.ReplyRate, 0)
- UPDATE a SET a.ReplyRate = b.rate2 FROM cpMainpublish a, #t2 b WHERE a.id = b.id --AND b.rate2> = 0.6
- 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)
- --UPDATE cpMainpublish SET ReplyRate = NULL WHERE ReplyRate <0.6
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCpMainHomepageLogoSelect] Script Date: 2018/12/13 19:10:09 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --创建人 Lambo 20101014
- --用于首页免费logo区查询单位logo
- CREATE PROCEDURE [dbo].[procCpMainHomepageLogoSelect]
- (
- @province_id SMALLINT
- )
- AS
- BEGIN
- SELECT TOP 24 a.id companyid, a.Name companyname, b.ImgFile filename
- FROM cpMain a, cpImage b WITH(nolock)
- WHERE a.Jobnumber > 0
- AND a.MemberType > 1
- AND a.Valid = 1
- AND a.HasLogo = 1
- AND a.dcProvinceid = @province_id
- ORDER BY RefreshDate DESC
- OPTION (KEEPFIXED PLAN)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCpMainHomepageSnapshotDelete] Script Date: 2018/12/13 19:10:09 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcCpMainHomepageSnapshotDelete]
- AS
- BEGIN
- CREATE TABLE #t(Id INT)
- CREATE TABLE #t1(Id INT)
- DELETE FROM SearchDB..CpMainHomepageSnapshot WHERE MemberType IS NULL
- UPDATE CpMainHomepageSnapshot SET dcRegionId = LEFT(dcRegionId, 4) WHERE Len(dcRegionId) > 4
- INSERT INTO #t
- SELECT ID FROM (SELECT dcRegionID, ID, ROW_NUMBER() over(PARTITION by dcRegionID order by RefreshDate desc) as num
- FROM SearchDB..CpMainHomepageSnapshot WITH(NOLOCK)
- WHERE MemberType > 2) a
- WHERE Num <= 74
- INSERT INTO #t
- SELECT ID FROM (SELECT dcRegionID, ID, ROW_NUMBER() over(PARTITION by dcRegionID order by RefreshDate desc) as num
- FROM SearchDB..CpMainHomepageSnapshot WITH(NOLOCK)
- WHERE MemberType < 3) a
- WHERE Num <= 80
- INSERT INTO #t
- SELECT ID FROM (SELECT dcSubSiteID, ID, ROW_NUMBER() over(PARTITION by dcSubSiteID order by RefreshDate desc) as num
- FROM SearchDB..CpMainHomepageSnapshot WITH(NOLOCK)
- WHERE MemberType > 2) a
- WHERE Num <= 74
- INSERT INTO #t
- SELECT ID FROM (SELECT dcSubSiteID, ID, ROW_NUMBER() over(PARTITION by dcSubSiteID order by RefreshDate desc) as num
- FROM SearchDB..CpMainHomepageSnapshot WITH(NOLOCK)
- WHERE MemberType < 3) a
- WHERE Num <= 80
-
- INSERT #t1 SELECT ID FROM SearchDB..CpMainHomepageSnapshot
- DELETE #t1 WHERE ID IN(SELECT ID FROM #t)
- DELETE FROM SearchDB..CpMainHomepageSnapshot WHERE ID IN(SELECT ID FROM #t1)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCpMainHomepageSnapShotFix] Script Date: 2018/12/13 19:10:09 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- /*
- sean 2013-8-21
- 写一下注释,以便以后容易检查和阅读
- */
- CREATE PROCEDURE [dbo].[ProcCpMainHomepageSnapShotFix]
- AS
- BEGIN
- --清空暂存表
- TRUNCATE TABLE SearchDB..cpMainHomepageSnapshotTmp
- DELETE CpMainHomepageSnapshot WHERE Name IS NULL OR RealCpMainId IS NULL Or RefreshDate IS NULL
- DECLARE @t AS TABLE(CpMainID INT)
- SELECT Id cpMainID
- INTO #t
- FROM cpMain WITH(NOLOCK)
- WHERE MemberType > 0
- AND (RefreshDate > DATEADD(MINUTE, -10, GETDATE())
- OR LastLoginDate > DATEADD(MINUTE, -10, GETDATE())
- )
- AND Valid = 1
- DELETE #t WHERE cpMainId IN(SELECT RealCpMainId FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK))
- INSERT @t SELECT * FROM #t
- --加入cpmaintmp临时表
- INSERT INTO @t
- SELECT DISTINCT cpMainID
- FROM SearchDB..cpMainTmp WITH(NOLOCK)
- INSERT INTO @t
- SELECT a.Id
- FROM cpMain a WITH(NOLOCK), SearchDB..cpMainHomepageSnapshot b WITH(NOLOCK)
- WHERE a.Id = b.RealCpMainId
- AND a.RefreshDate <> b.RefreshDate
-
- --加入12分钟内修改过职位的企业
- INSERT INTO @t(CpMainID)
- SELECT DISTINCT cpMainID FROM Job WITH(NOLOCK)
- WHERE LastModifyDate > DATEADD(MINUTE, -12, GETDATE())
- AND cpMainID NOT IN(SELECT cpMainID FROM @t)
- --把临时表的数据加入暂存表
- INSERT INTO SearchDB..cpMainHomepageSnapshotTmp(cpMainId, RefreshDate, MemberType, dcSubsiteId, dcRegionId, Name, IsAgent, RealCpMainId)
- SELECT SecondId, RefreshDate, MemberType, dcSubsiteId, dcRegionId, Name, IsAgent, Id
- FROM cpMain WITH(NOLOCK)
- WHERE ID IN(SELECT CpMainId FROM @t)
- AND MemberType > 0 AND Valid = 1
- --没有在百度上抓到的,设置nofollow="",就是要 follow
- UPDATE SearchDB..cpMainHomepageSnapshotTmp SET NoFollow = ''
- --WHERE cpMainId IN(SELECT PageID FROM PageBaiduInclude WHERE PageType = 1 AND IncludeDate IS NULL)
- --填充暂存表数据
- UPDATE a
- SET a.JobNumber = b.JobNumber, a.IsAgent = b.IsAgent, a.dcSubSiteID = b.dcSubSiteID, a.MemberType = b.MemberType,
- a.Name = b.Name, a.dcRegionID = b.dcRegionID
- FROM SearchDB..cpMainHomepageSnapshotTmp a, cpMain b
- WHERE a.RealCpMainid = b.id
- --填充暂存表数据 jobids
- UPDATE SearchDB..cpMainHomepageSnapshotTmp
- SET JobId = dbo.getJobSecondIds(RealCpMainid), JobName = dbo.getJobNames(RealCpMainid)
-
- --填充暂存表数据 最新职位
- -- UPDATE SearchDB..CpMainHomepageSnapshotTmp
- -- SET LastJobId = (SELECT TOP 1 SecondID FROM Job WITH(NOLOCK) WHERE Job.cpMainid = SearchDB..CpMainHomepageSnapshotTmp.RealCpMainId
- -- AND Valid = 1 ORDER BY IssueDate DESC)
- UPDATE a
- SET a.LastJobId = (SELECT TOP 1 SecondID FROM Job WITH(NOLOCK) WHERE Job.cpMainid = a.RealCpMainId
- AND Valid = 1 AND CHARINDEX(Job.SecondId, LEFT(a.JobId, 21)) > 0 ORDER BY IssueDate DESC)
- FROM SearchDB..CpMainHomepageSnapshotTmp a
- WHERE MemberType > 2
- --填充暂存表数据最后发布时间
- UPDATE SearchDB..cpMainHomepageSnapshotTmp
- SET LastJobIssueDate = (SELECT IssueDate FROM Job WHERE Job.Secondid = SearchDB..cpMainHomepageSnapshotTmp.LastJobid)
- WHERE MemberType > 2
- --填充暂存表数据 营业执照审核时间
- UPDATE a SET a.cplicenceDate=b.checkDate
- FROM SearchDB..cpMainHomepageSnapshotTmp a, cpLicence b
- WHERE a.RealCpMainid = b.cpMainid
- AND a.MemberType < 3
- --先添加未增加的
- INSERT INTO SearchDB..cpMainHomepageSnapshot(cpMainId, NoFollow, RealCpMainid)
- SELECT cpMainId, NoFollow, RealCpMainid
- FROM SearchDB..cpMainHomepageSnapshotTmp WITH(NOLOCK)
- WHERE RealCpMainid NOT IN(SELECT RealCpMainid FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK))
- --再更改数据
- UPDATE a
- SET a.dcSubsiteID = b.dcSubsiteID,
- a.dcRegionID = b.dcRegionID,
- a.MemberType = b.MemberType,
- a.Name = b.Name,
- a.IsAgent = b.IsAgent,
- a.JobNumber = b.JobNumber,
- a.JobID = b.JobID,
- a.JobName = b.JobName,
- a.LastJobIssueDate = b.LastJobIssueDate,
- a.LastJobId = b.LastJobId,
- a.cpLicenceDate = b.cpLicenceDate,
- a.RefreshDate = b.RefreshDate
- FROM SearchDb..cpMainHomepageSnapshot a WITH(NOLOCK),
- SearchDb..cpMainHomepageSnapshotTmp b WITH(NOLOCK)
- WHERE a.RealCpMainid = b.RealCpMainid
- UPDATE a
- SET a.LastJobId = (SELECT TOP 1 SecondID FROM Job WITH(NOLOCK) WHERE Job.cpMainid = a.RealCpMainId
- AND Valid = 1 AND CHARINDEX(Job.SecondId, LEFT(a.JobId, 21)) > 0 ORDER BY IssueDate DESC)
- FROM SearchDB..CpMainHomepageSnapshot a
- WHERE MemberType > 2
- TRUNCATE TABLE SearchDB..cpMainTmp
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCpMainHomepageSnapshotRebuild] Script Date: 2018/12/13 19:10:10 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcCpMainHomepageSnapshotRebuild]
- AS
- BEGIN
- TRUNCATE TABLE SearchDB..CpMainHomepageSnapshotTmp
- --找出所有1天内刷新的,未认证的或普通或缴费的,并且有效的企业
- INSERT SearchDB..CpMainHomepageSnapshotTmp(cpMainId, RefreshDate, RealCpMainId, MemberType, dcRegionID, dcSubSiteId)
- SELECT SecondId, RefreshDate, Id, MemberType, dcRegionID, dcSubSiteId
- FROM cpMain WITH(NOLOCK)
- WHERE Refreshdate > GETDATE() - 1 AND MemberType > 0 AND Valid = 1
- EXEC ProcCpMainHomepageSnapshotTmpDelete
- --没有在百度上抓到的,设置nofollow="",就是要 follow
- UPDATE SearchDB..CpMainHomepageSnapshotTmp SET NoFollow = ''
- --WHERE CpMainId IN(SELECT PageID FROM PageBaiduInclude WHERE PageType = 1 AND IncludeDate IS NULL)
-
- --填写内容
- UPDATE a
- SET a.JobNumber = b.JobNumber, a.IsAgent = b.IsAgent, a.Name = b.Name
- FROM SearchDB..CpMainHomepageSnapshotTmp a, cpMain b
- WHERE a.RealCpMainId=b.id
-
- --填写jobids
- UPDATE SearchDB..CpMainHomepageSnapshotTmp
- SET JobId = dbo.GetJobSecondIds(RealCpMainId), JobName = dbo.GetJobNames(RealCpMainId)
- --找出收费用户的最新职位id
- -- UPDATE SearchDB..CpMainHomepageSnapshotTmp
- -- SET LastJobId = (SELECT TOP 1 SecondID FROM Job WITH(NOLOCK) WHERE Job.cpMainid = SearchDB..CpMainHomepageSnapshotTmp.RealCpMainId
- -- AND Valid = 1 ORDER BY IssueDate DESC)
- UPDATE a
- SET a.LastJobId = (SELECT TOP 1 SecondID FROM Job WITH(NOLOCK) WHERE Job.cpMainid = a.RealCpMainId
- AND Valid = 1 AND CHARINDEX(Job.SecondId, LEFT(a.JobId, 21)) > 0 ORDER BY IssueDate DESC)
- FROM SearchDB..CpMainHomepageSnapshotTmp a
- WHERE MemberType > 2
- --找出收费用户的最后发布日期
- UPDATE SearchDB..CpMainHomepageSnapshotTmp
- SET LastJobIssueDate = (SELECT IssueDate FROM Job WHERE Job.SecondId = SearchDB..CpMainHomepageSnapshotTmp.LastJobid)
- WHERE MemberType > 2
- --普通用户填写营业执照审核时间
- UPDATE a SET a.cplicenceDate=b.checkDate
- FROM SearchDB..CpMainHomepageSnapshotTmp a, cpLicence b
- WHERE a.RealCpMainId = b.cpMainid
- AND a.MemberType < 3
- --如果CpMainHomepageSnapshotTmp数量少于3000行就不更新了,因为很可能是出错了
- IF (SELECT COUNT(*) FROM SearchDB..CpMainHomepageSnapshotTmp WITH(NOLOCK)) > 3000
- BEGIN
- TRUNCATE TABLE SearchDB..CpMainHomepageSnapshot
- SET IDENTITY_INSERT SearchDB..CpMainHomepageSnapshot ON
- INSERT INTO SearchDB..CpMainHomepageSnapshot(ID, dcSubsiteID, dcRegionID, cpMainID, MemberType, Name, IsAgent, JobNumber, JobID,
- JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, NoFollow, RealCpMainId)
- SELECT ID, dcSubsiteID, dcRegionID, cpMainID, MemberType, Name, IsAgent, JobNumber, JobID,
- JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, NoFollow, RealCpMainId
- FROM SearchDB..CpMainHomepageSnapshotTmp
- SET IDENTITY_INSERT SearchDB..CpMainHomepageSnapshot OFF
- END
- ELSE
- RETURN
- --如果CpMainHomepageSnapshot数量少于3000行,尝试更新一次
- IF (SELECT COUNT(*) FROM SearchDB..CpMainHomepageSnapshot WITH(NOLOCK)) < 3000
- BEGIN
- TRUNCATE TABLE SearchDB..CpMainHomepageSnapshot
- SET IDENTITY_INSERT SearchDB..CpMainHomepageSnapshot ON
- INSERT INTO SearchDB..CpMainHomepageSnapshot(ID, dcSubsiteID, dcRegionID, cpMainID, MemberType, Name, IsAgent, JobNumber, JobID,
- JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, NoFollow, RealCpMainId)
- SELECT ID, dcSubsiteID, dcRegionID, cpMainID, MemberType, Name, IsAgent, JobNumber, JobID,
- JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, NoFollow, RealCpMainId
- FROM SearchDB..CpMainHomepageSnapshotTmp
- SET IDENTITY_INSERT SearchDB..CpMainHomepageSnapshot OFF
- END
- --如果CpMainHomepageSnapshot数量少于3000行,再尝试更新一次
- IF (SELECT COUNT(*) FROM SearchDB..CpMainHomepageSnapshot WITH(NOLOCK)) < 3000
- BEGIN
- TRUNCATE TABLE SearchDB..CpMainHomepageSnapshot
- SET IDENTITY_INSERT SearchDB..CpMainHomepageSnapshot ON
- INSERT INTO SearchDB..CpMainHomepageSnapshot(ID, dcSubsiteID, dcRegionID, cpMainID, MemberType, Name, IsAgent, JobNumber, JobID,
- JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, NoFollow, RealCpMainId)
- SELECT ID, dcSubsiteID, dcRegionID, cpMainID, MemberType, Name, IsAgent, JobNumber, JobID,
- JobName, LastJobIssueDate, LastJobId, cpLicenceDate, RefreshDate, NoFollow, RealCpMainId
- FROM SearchDB..CpMainHomepageSnapshotTmp
- SET IDENTITY_INSERT SearchDB..CpMainHomepageSnapshot OFF
- END
- END
-
- GO
- /****** Object: StoredProcedure [dbo].[ProcCpMainHomepageSnapshotTmpDelete] Script Date: 2018/12/13 19:10:11 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcCpMainHomepageSnapshotTmpDelete]
- AS
- BEGIN
- CREATE TABLE #t(Id INT)
- CREATE TABLE #t1(Id INT)
- DELETE FROM SearchDB..CpMainHomepageSnapshotTmp WHERE MemberType IS NULL
- UPDATE SearchDb..CpMainHomepageSnapshotTmp SET dcRegionId = LEFT(dcRegionId, 4) WHERE Len(dcRegionId) > 4
- INSERT INTO #t
- SELECT RealcpMainID FROM (SELECT dcRegionID, RealcpMainID, ROW_NUMBER() over(PARTITION by dcRegionID order by RefreshDate desc) as num
- FROM SearchDB..CpMainHomepageSnapshotTmp WITH(NOLOCK)
- WHERE MemberType > 2) a
- WHERE Num <= 74
- INSERT INTO #t
- SELECT RealcpMainID FROM (SELECT dcRegionID, RealcpMainID, ROW_NUMBER() over(PARTITION by dcRegionID order by RefreshDate desc) as num
- FROM SearchDB..CpMainHomepageSnapshotTmp WITH(NOLOCK)
- WHERE MemberType < 3) a
- WHERE Num <= 80
- INSERT INTO #t
- SELECT RealcpMainID FROM (SELECT dcSubSiteID, RealcpMainID, ROW_NUMBER() over(PARTITION by dcSubSiteID order by RefreshDate desc) as num
- FROM SearchDB..CpMainHomepageSnapshotTmp WITH(NOLOCK)
- WHERE MemberType > 2) a
- WHERE Num <= 74
- INSERT INTO #t
- SELECT RealcpMainID FROM (SELECT dcSubSiteID, RealcpMainID, ROW_NUMBER() over(PARTITION by dcSubSiteID order by RefreshDate desc) as num
- FROM SearchDB..CpMainHomepageSnapshotTmp WITH(NOLOCK)
- WHERE MemberType < 3) a
- WHERE Num <= 80
-
- INSERT #t1 SELECT RealcpMainID FROM SearchDB..CpMainHomepageSnapshotTmp
- DELETE #t1 WHERE ID IN(SELECT ID FROM #t)
- DELETE FROM SearchDB..CpMainHomepageSnapshotTmp WHERE RealcpMainID IN(SELECT ID FROM #t1)
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCpMainProvinceIDByCaMainIDSelect] Script Date: 2018/12/13 19:10:11 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:John
- --说明:获取公司所在地ID信息
- --#####################################################
- CREATE PROCEDURE [dbo].[procCpMainProvinceIDByCaMainIDSelect]
- (
- @caMainID INT
- )
- AS
- BEGIN
- SELECT b.dcProvinceID FROM caMain a WITH(NOLOCK),cpMain b WITH(NOLOCK) WHERE a.id = @caMainID AND a.cpMainID = b.id
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCpMainSameIndustry32Insert] Script Date: 2018/12/13 19:10:12 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcCpMainSameIndustry32Insert]
- AS
- SET NOCOUNT ON
- BEGIN
- SELECT 32 dcRegionId, dcIndustryID, ID RealId, SecondID, Name, Row
- INTO #t
- FROM (SELECT Left(a.dcRegionId, 4) dcRegionId, b.dcIndustryID, a.Id, a.SecondID, a.Name, a.LastLoginDate,
- ROW_NUMBER() OVER(PARTITION BY b.dcIndustryId ORDER BY a.Id DESC) Row
- FROM cpMainPublish a WITH(NOLOCK)
- LEFT JOIN cpIndustry b ON a.id = b.CpmainID
- WHERE a.dcProvinceId = '30' --temp modify
- AND MemberType > 1
- ) a
- WHERE a.Row < 11
- AND a.Id IN (SELECT cpMainId FROM JobPublish WITH(NOLOCK) WHERE Valid > 0)
- ORDER BY dcRegionId, dcIndustryID, Row
- ALTER TABLE #t ADD LogoFile VARCHAR(90)
- UPDATE a SET A.LogoFile = b.LogoFile FROM #t a, cpMain b WHERE a.RealId = b.ID
- TRUNCATE TABLE SearchDb..CpMainSameIndustry32
- INSERT INTO SearchDb..CpMainSameIndustry32 SELECT * FROM #t
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCpMainSameIndustryInsert] Script Date: 2018/12/13 19:10:12 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcCpMainSameIndustryInsert]
- AS
- BEGIN
- SELECT dcRegionId, dcIndustryID, ID RealId, SecondID, Name, Row
- INTO #t
- FROM (SELECT Left(a.dcRegionId, 4) dcRegionId, b.dcIndustryID, a.Id, a.SecondID, a.Name, a.LastLoginDate,
- ROW_NUMBER() OVER(PARTITION BY Left(a.dcRegionId, 4), b.dcIndustryId ORDER BY a.LastLoginDate DESC) Row
- FROM cpMainPublish a WITH(NOLOCK)
- LEFT JOIN cpIndustry b ON a.id = b.CpmainID
- WHERE a.dcRegionId NOT LIKE '32%' --temp modify
- ) a
- WHERE a.Row < 11
- AND a.Id IN (SELECT cpMainId FROM JobPublish WITH(NOLOCK) WHERE Valid > 0)
- ORDER BY dcRegionId, dcIndustryID, Row
- ALTER TABLE #t ADD LogoFile VARCHAR(90)
- UPDATE a SET A.LogoFile = b.LogoFile FROM #t a, cpMain b WHERE a.RealId = b.ID
- TRUNCATE TABLE SearchDb..CpMainSameIndustry
- INSERT INTO SearchDb..CpMainSameIndustry SELECT * FROM #t WHERE dcRegionId NOT LIKE '32%'
- --TRUNCATE TABLE SearchDb..CpMainSameIndustry32
- --INSERT INTO SearchDb..CpMainSameIndustry32 SELECT * FROM #t WHERE dcRegionId LIKE '32%'
- EXEC ProcCpMainSameIndustry32Insert
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCpViPlanSmsMessageLogInsert] Script Date: 2018/12/13 19:10:12 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.29
- --创建人:John
- --说明:企业邀请个人视频面试添加短信通知
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcCpViPlanSmsMessageLogInsert]
- (
- @JobID INT,
- @CvMainID INT
- )
- AS
- BEGIN
- DECLARE @cnt INT
- SELECT @cnt = COUNT(1)
- FROM SmsMessageLog
- WHERE msgtype = 121
- AND camainid =
- (
- SELECT camainid
- FROM job
- WHERE id = @JobID
- )
- AND adddate > CONVERT(VARCHAR(10), GETDATE(), 23)
- IF @cnt < 10
- BEGIN
- INSERT SmsMessageLog(SendMan, ManagerUserId, paMainId, caMainId, Mobile, MsgType, IsCat, Msg)
- SELECT TOP 1 0, NULL, a.ID, e.caMainID, b.Mobile, 121, 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),
- job e WITH(NOLOCK)
- WHERE a.paMainID = b.ID
- AND b.dcSubSiteID = c.ID
- AND d.id = e.cpMainID
- AND e.ID = @JobID
- AND b.Mobile > ''
- AND a.ID = @CvMainID
- AND b.IsReceiveSms = 1
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCpwishByIDSelect] Script Date: 2018/12/13 19:10:12 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:祝福墙数据
- --#####################################################
- CREATE PROCEDURE [dbo].[procCpwishByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- UPDATE ShortDB..cpwish SET ClickNumber=ClickNumber+1 WHERE ID=@ID
- SELECT * FROM ShortDB..cpwish WITH(NOLOCK) WHERE ID=@ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCpwishInsert] Script Date: 2018/12/13 19:10:13 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:祝福墙数据插入
- --#####################################################
- CREATE PROCEDURE [dbo].[procCpwishInsert]
- (
- @Content VARCHAR(500),
- @cpMainID INT
- )
- AS
- BEGIN
- INSERT INTO ShortDB..cpwish VALUES(@cpMainID,@Content,1,0,GETDATE())
- RETURN 1
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCpwishSelect] Script Date: 2018/12/13 19:10:13 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:祝福墙数据获取
- --#####################################################
- CREATE PROCEDURE [dbo].[procCpwishSelect]
- AS
- BEGIN
- SELECT TOP 200 a.*,b.Name cpName
- FROM ShortDB..cpwish a WITH(NOLOCK),cpMain b WITH(NOLOCK)
- WHERE b.ID=a.cpMainID
- AND IsDesplay='1'
- ORDER BY addDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCvDownDocByDowncountSelect] Script Date: 2018/12/13 19:10:13 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --type=1 首页/下载排行获取
- --harry
- --2017-12-18
- --Carl 2018-02-01
- --Carl 2018-02-28
- CREATE PROCEDURE [dbo].[procCvDownDocByDowncountSelect]
- (
- @type INT
- )
- AS
- BEGIN
- SET NOCOUNT ON
- IF @type =1 --首页
- BEGIN
- SELECT TOP 10 *
- FROM cvdowndoc WITH(NOLOCK)
- WHERE IsBeta=0 ORDER BY newid()
- END
- ELSE IF @type=2
- BEGIN
- SELECT *
- FROM cvdowndoc WITH(NOLOCK)
- WHERE IsBeta=0
- ORDER BY downcount DESC
- END
- ELSE--测试用的
- BEGIN
- SELECT *
- FROM cvdowndoc WITH(NOLOCK)
- ORDER BY downcount DESC
- END
- SET NOCOUNT OFF
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCvDownDocByIdSelect] Script Date: 2018/12/13 19:10:13 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --获取简历模板详情
- --harry
- --2017-12-21
- CREATE PROCEDURE [dbo].[procCvDownDocByIdSelect]
- (
- @Id INT
- )
- AS
- BEGIN
- SET NOCOUNT ON
- SELECT *
- FROM cvdowndoc WITH(NOLOCK)
- WHERE id = @Id
- SET NOCOUNT OFF
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCvDownDocUpdate] Script Date: 2018/12/13 19:10:14 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --更新简历模板的浏览量、下载量
- --type 1浏览量 2下载量
- --harry
- --2017-12-21
- CREATE PROCEDURE [dbo].[procCvDownDocUpdate]
- (
- @type INT,
- @id INT
- )
- AS
- BEGIN
- IF @type = 1
- BEGIN
- UPDATE cvdowndoc
- SET ViewCount = ISNULL(ViewCount,0) +1
- WHERE id = @id
- END
- ELSE
- BEGIN
- UPDATE cvdowndoc
- SET DownCount = ISNULL(DownCount,0) +1
- WHERE id = @id
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcCvMainByHasVerifySelect] Script Date: 2018/12/13 19:10:14 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- create procedure [dbo].[ProcCvMainByHasVerifySelect]
- (
- @cvMainId INT
- )
- AS
- BEGIN
- IF EXISTS(SELECT 'x' FROM paMain a, cvMain b
- WHERE a.Id = b.paMainId
- AND a.VerifyCount > 0
- AND b.Id = @cvMAinId
- AND b.VerifyResult = 1
- )
- RETURN 1
- ELSE
- RETURN 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[procCvMainByPaMainIDSelect] Script Date: 2018/12/13 19:10:14 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:Nick
- --说明:根据PaMianID来获取其简历的ID和AddDate
- --#####################################################
- CREATE PROCEDURE [dbo].[procCvMainByPaMainIDSelect]
- (
- @paMainID INT
- )
- AS
- BEGIN TRY
- SELECT * FROM cvmain a WITH(NOLOCK),pamain b WITH(NOLOCK)
- WHERE a.paMainID=b.ID
- AND pamainid= @paMainID
- ORDER BY a.valid DESC,a.refreshdate DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[proccvrExchangeByRecommendIDSelect] Script Date: 2018/12/13 19:10:15 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.31
- --创建人:Nick
- --说明:获取礼品列表
- --#####################################################
- CREATE PROCEDURE [dbo].[proccvrExchangeByRecommendIDSelect]
- (
- @RecommendID INT
- )
- AS
- BEGIN TRY
- SELECT (
- SELECT COUNT(*) cnt
- FROM marketdb..cvrRecommend
- WHERE RecommendID=@RecommendID
- AND HasValid=3
- AND HasReply=1
- )
- allIntegral,(
- SELECT SUM(Amount)
- FROM marketdb..cvrExchange
- WHERE RecommendID=@RecommendID AND HasVerify<>2
- ) lastIntegral
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcDcAutoEmailInsert] Script Date: 2018/12/13 19:10:15 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcDcAutoEmailInsert]
- AS
- BEGIN
- IF(SELECT COUNT(*) FROM dcAutoEmail) > 50000
- RETURN
- SELECT TOP 0 * INTO #t FROM dcAutoEmail
- INSERT #t
- SELECT TOP 10000 LEFT(NEWID(), 3) + '_' + LEFT(NEWID(), 2) + '@your_email.com' FROM cpMain
- UPDATE #t SET Email = CHAR(65 + id % 26) + Email
- DELETE a
- FROM #t a, dcAutoEmail b
- WHERE a.Email = b.Email
- DELETE a
- FROM #t a, paMain b
- WHERE a.Email = b.Email
- DELETE a
- FROM #t a, Resume_XinXi b
- WHERE a.Email = b.Email
- INSERT INTO dcAutoEmail SELECT DISTINCT Email FROM #t
- END
- GO
- /****** Object: StoredProcedure [dbo].[procdcAutoEmailSelect] Script Date: 2018/12/13 19:10:15 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.12
- --创建人:Nick
- --说明:
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcAutoEmailSelect]
- AS
- BEGIN
- SELECT top 1 * FROM dcAutoEmail ORDER BY id
- END
- GO
- /****** Object: StoredProcedure [dbo].[procdcCollegeSelect] Script Date: 2018/12/13 19:10:15 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.31
- --创建人:Nick
- --说明:读取学校信息
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcCollegeSelect]
- (
- @CollegeName VARCHAR(50)
- )
- AS
- BEGIN TRY
- SELECT TOP 10 COLNAME
- FROM dccollege
- WHERE COLNAME LIKE ''+@CollegeName+'%'
- OR Pinyin LIKE ''+@CollegeName+'%'
- OR Jianpin LIKE ''+@CollegeName+'%'
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procdcCvConvertMapSelect] Script Date: 2018/12/13 19:10:16 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.31
- --创建人:Nick
- --说明:获取对应的自己数据库中的ID
- --修改:Mice 123 修改@type 的长度为50
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcCvConvertMapSelect]
- (
- @webName VARCHAR(100),
- @type VARCHAR(50),
- @description VARCHAR(500)
- )
- AS
- BEGIN
- SELECT *
- FROM dcCvConvertMap WITH(NOLOCK)
- WHERE webName = @webName
- AND type = @type
- AND description = @description
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcDcFeeStandardByPriceCvSelect] Script Date: 2018/12/13 19:10:16 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcDcFeeStandardByPriceCvSelect]
- (
- @dcProvinceID AS INT
- )
- AS
- BEGIN
- SELECT PriceCv FROM DcFeeStandard WITH(NOLOCK)
- WHERE dcProvinceID = @dcProvinceID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDcFeeStandardByProvinceIDSelect] Script Date: 2018/12/13 19:10:16 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:dcfeestandard
- --#####################################################
- CREATE PROCEDURE [dbo].[procDcFeeStandardByProvinceIDSelect]
- (
- @ProvinceID INT
- )
- AS
- BEGIN TRY
- SELECT NeedPoint FROM dcfeestandard With(Nolock) WHERE dcprovinceid=@ProvinceID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procDcIndustrySelect] Script Date: 2018/12/13 19:10:16 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:获取行业信息
- --#####################################################
- CREATE PROCEDURE [dbo].[procDcIndustrySelect]
- AS
- BEGIN
- SELECT * FROM dcindustry ORDER BY category,orderno
- END
- GO
- /****** Object: StoredProcedure [dbo].[procdcIpPlaceByIPMobileSelect] Script Date: 2018/12/13 19:10:17 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2018.6.11
- --创建人:harry
- --说明:根据ip或mobile得到dcIpPlace
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcIpPlaceByIPMobileSelect]
- (
- @IP INT,
- @Mobile CHAR(11)
- )
- AS
- BEGIN
- DECLARE @regionId INT
- IF LEN(@Mobile)>0
- BEGIN
- SELECT TOP 1 @regionId=dcRegionId
- FROM dcMobilearea WITH (NOLOCK)
- WHERE LEFT(@Mobile,7)=Num
- END
- ELSE
- BEGIN
- SELECT TOP 1 @regionId=dcSubSiteId
- FROM dcIpPlace a WITH(NOLOCK INDEX(IX_dcIpPlace_IpStart))
- WHERE IPStart <= @IP
- ORDER BY IPStart DESC
-
- IF LEN(@regionId)<3
- BEGIN
- SELECT TOP 1 @regionId=dcRegionId
- FROM dcMobilearea WITH (NOLOCK)
- WHERE LEFT(@Mobile,7)=Num
- END
-
- END
-
- IF LEN(@regionId)<4
- BEGIN
- SELECT TOP 0 ID, Abbr
- FROM dcRegion
- END
- ELSE
- BEGIN
- SELECT ID, Abbr
- FROM dcRegion
- WHERE ID=LEFT(@regionId,4)
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[procdcIpPlaceByIPSelect] Script Date: 2018/12/13 19:10:17 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.3
- --创建人:NICK
- --说明:根据ip得到dcIpPlace
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcIpPlaceByIPSelect]
- (
- @IP VARCHAR(20)
- )
- AS
- BEGIN
- SELECT TOP 1 *
- FROM dcIpPlace WITH(NOLOCK INDEX(IX_dcIpPlace_IpStart))
- WHERE IPStart <= @IP
- ORDER BY IPStart DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcDcIpPlaceInsert] Script Date: 2018/12/13 19:10:17 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcDcIpPlaceInsert]
- AS
- BEGIN
- IF (SELECT COUNT(*) FROM tmp_IpPlace) < 400000
- RETURN
- TRUNCATE TABLE dcIPPlace
- INSERT INTO dcIPPlace(ipstart, ipend, city, Provider, dcSubsiteId)
- SELECT ipStart, ipEnd, City, Provider, 0 FROM tmp_ipplace --插入地址表
-
- update dcIpplace set international = 1 where city in(select distinct city from dcipplace
- where provider not in('CZ88.NET')
- and provider not like ('%电信%')
- and provider not like ('%联通%')
- and left(city,2)not in(select left(description,2) from dcregion)
- and city not like '%大学%'
- and city not like '中%'
- and city not like '东北%'
- and city not like '华%'
- and city not like '%网络'
- and city not like '局域网'
- and city not like '联通'
- and city not like '全国通用'
- and city not like '本机地址'
- )
-
- update dcipplace set provider='地址不详' where city='局域网'
- update dcipplace set provider='地址不详' where city='本机地址'
- UPDATE a SET a.dcSubSiteId = b.dcSubSiteID
- FROM dcIpPlace a, dcIpPlaceCity b
- WHERE a.City = b.City
- UPDATE a SET a.dcSubSiteId = b.dcSubSiteID
- FROM dcIpPlace a, dcIpPlaceCity b
- WHERE a.City LIKE b.City + '%'
- AND a.international IS NULL
- AND a.dcSubSiteId = 0
- AND LEN(b.dcSubSiteID) = 6
- UPDATE a SET a.dcSubSiteId = b.dcSubSiteID
- FROM dcIpPlace a, dcIpPlaceCity b
- WHERE a.City LIKE b.City + '%'
- AND a.international IS NULL
- AND a.dcSubSiteId = 0
- AND LEN(b.dcSubSiteID) = 4
- UPDATE a SET a.dcSubSiteId = b.dcSubSiteID
- FROM dcIpPlace a, dcIpPlaceCity b
- WHERE a.City LIKE b.City + '%'
- AND a.international IS NULL
- AND a.dcSubSiteId = 0
- AND LEN(b.dcSubSiteID) = 2
- UPDATE a SET a.dcSubSiteId = b.ID
- FROM dcIpPlace a, dcSubSite b
- WHERE a.City LIKE b.SubSiteCity + '%'
- AND a.international IS NULL
- AND a.dcSubSiteId = 0
- UPDATE dcIpPlace SET international = 1 WHERE international IS NULL AND dcSubSiteId = 0
- UPDATE dcIpPlace SET dcSubSiteId = 0 WHERE international IS NULL AND dcSubSiteId = 1
- DROP TABLE tmp_IpPlace
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcdcJobtypeByIdSelect] Script Date: 2018/12/13 19:10:18 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --根据jobtypeID查询jobtype
- --Harry
- --2015-7-24
- CREATE PROCEDURE [dbo].[ProcdcJobtypeByIdSelect]
- (
- @id INT
- )
- AS
- BEGIN
- SELECT [Description]
- FROM dcjobtype
- WHERE id=@id
- END
- GO
- /****** Object: StoredProcedure [dbo].[procdcJobTypeByJobTypeID6Select] Script Date: 2018/12/13 19:10:18 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.04
- --创建人:Nick
- --说明:根据职位id查询前6个感兴趣的职位
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcJobTypeByJobTypeID6Select]
- (
- @JobTypeID VARCHAR(20)
- )
- AS
- BEGIN TRY
- Select TOP 6 id,description
- FROM dcJobType
- WHERE ID LIKE LEFT(@JobTypeID, 2) + '%' AND ID <> @JobTypeID
- AND description NOT LIKE '其他%' ORDER BY NEWID()
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procdcJobTypeByKeyWordSelect] Script Date: 2018/12/13 19:10:18 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:根据关键字获取职位类别
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcJobTypeByKeyWordSelect]
- (
- @KeyWord VARCHAR(100),
- @IsEnglish INT
- )
- AS
- BEGIN TRY
- IF @IsEnglish = 1
- BEGIN
- SELECT * FROM dcJobType WITH(NOLOCK) WHERE dbo.GetPyFirst(Description) LIKE '%'+@KeyWord+'%'
- END
- ELSE
- BEGIN
- SELECT * FROM dcJobType WITH(NOLOCK) WHERE Description LIKE '%'+@KeyWord+'%'
- END
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcdcJobTypeHotNumberInsert] Script Date: 2018/12/13 19:10:18 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --生成M站热门职位关键词对应的职位数量,计划任务每天凌晨1点执行
- CREATE PROCEDURE [dbo].[ProcdcJobTypeHotNumberInsert]
- AS
- BEGIN
- --清空dcJobTypeHotNumber
- TRUNCATE TABLE dcJobTypeHotNumber
- DECLARE DcProvince_Cursor CURSOR
- FOR SELECT ID FROM dcProvince
- OPEN DcProvince_Cursor
- DECLARE @ProvinceID sysname
- FETCH NEXT FROM DcProvince_Cursor INTO @ProvinceID
- WHILE (@@FETCH_STATUS <> -1)
- BEGIN
- IF (@@FETCH_STATUS <> -2)
- BEGIN
- INSERT dcJobTypeHotNumber
- SELECT @ProvinceID, a.Id,
- CASE CHARINDEX(',', dcJobTypeId)
- WHEN 0
- THEN (
- SELECT SUM(JobNum)
- FROM hpJobTypeInfo
- WHERE CONVERT(VARCHAR(8),dcJobTypeID) like ''+a.dcJobTypeId+'%'
- AND dcRegionId like ''+CONVERT(VARCHAR,@ProvinceID)+'%'
- )
- ELSE(
- SELECT SUM(JobNum)
- FROM hpJobTypeInfo
- WHERE CONVERT(VARCHAR(8),dcJobTypeID) IN (SELECT * FROM [fnSplit](a.dcJobTypeId,','))
- AND dcRegionId like ''+CONVERT(VARCHAR(8),@ProvinceID)+'%'
- )
- END
- FROM DcJobTypeHot a
- END
- FETCH NEXT FROM DcProvince_Cursor INTO @ProvinceID
- END
- CLOSE DcProvince_Cursor
- DEALLOCATE DcProvince_Cursor
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcDcJobTypeHotSelect] Script Date: 2018/12/13 19:10:19 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --M站获取热门职位关键词
- --nick 20140539
- CREATE PROCEDURE [dbo].[ProcDcJobTypeHotSelect]
- (
- @ProvinceID INT
- )
- AS
- BEGIN
- return
- DECLARE @t AS TABLE(ID INT, JobTypeName VARCHAR(100), dcJobTypeId VARCHAR(200), PinYin VARCHAR(20), OrderBy INT,JobNum INT)
- INSERT @t
- SELECT *,
- CASE CHARINDEX(',', dcJobTypeId)
- WHEN 0
- THEN (
- SELECT SUM(JobNum)
- FROM hpJobTypeInfo
- WHERE CONVERT(VARCHAR(8),dcJobTypeID) like ''+a.dcJobTypeId+'%'
- AND dcRegionID like ''+CONVERT(VARCHAR,@ProvinceID)+'%'
- )
- ELSE(
- SELECT SUM(JobNum)
- FROM hpJobTypeInfo
- WHERE CONVERT(VARCHAR(8),dcJobTypeID) IN (SELECT * FROM [fnSplit](a.dcJobTypeId,','))
- AND dcRegionID like ''+CONVERT(VARCHAR(8),@ProvinceID)+'%'
- )
- END
- FROM DcJobTypeHot A
- SELECT * FROM @t ORDER BY JobNum DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procdcJobTypeMapByRegionIDSelect] Script Date: 2018/12/13 19:10:19 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.13
- --创建人:Nick
- --说明:获取各个站点下的热门职位类别
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcJobTypeMapByRegionIDSelect]
- (
- @RegionID INT
- )
- AS
- BEGIN
- SELECT TOP 49 a.dcJobTypeId JobTypeID,a.JobNum JobNumber,b.CategoryId,c.parentID,c.grade,c.description,
- c.parentID2,c.parentID3
- FROM hpjobtypeinfo a
- LEFT JOIN dcJobTypeMap b ON b.JobTypeId=a.dcJobtypeid
- LEFT JOIN dcJobType c ON c.id=a.dcJobTypeid
- WHERE a.dcRegionID = @RegionID
- AND c.Grade = 3
- AND c.description IS NOT NULL
- ORDER BY JobNumber DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procdcJobTypeMapSelect] Script Date: 2018/12/13 19:10:19 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:获取职位地图的数据
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcJobTypeMapSelect]
- AS
- BEGIN TRY
- SELECT a.id,a.description jobtypel0,c.description jobtypel1,b.*
- FROM dcJobtypeCategory a,dcJobTypeMap b,dcjobtype c
- WHERE a.id=b.categoryid and b.jobtypeid=c.id and len(b.jobtypeid)>2
- ORDER BY a.id,b.orderby
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procDcJobTypeSelect] Script Date: 2018/12/13 19:10:19 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:获取职位类别
- --#####################################################
- CREATE PROCEDURE [dbo].[procDcJobTypeSelect]
- AS
- BEGIN TRY
- SELECT ID, ParentID, ParentID2, ParentId3 FROM dcjobtype WITH(NOLOCK) WHERE ID > 100 ORDER BY ID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procdcjobtypesimilarSelect] Script Date: 2018/12/13 19:10:20 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.31
- --创建人:Nick
- --说明:获取职位类别的匹配度
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcjobtypesimilarSelect]
- (
- @JobTypeID VARCHAR(20)
- )
- AS
- BEGIN
- --SELECT * FROM dcjobtypesimilar WITH(NOLOCK) WHERE dcJobTypeId in (@JobTypeID) OR SimilarId IN (@JobTypeID)
- SELECT TOP 0 0 ID, 0 dcJobTypeId, 0 SimilarId, 0 Coefficient
- END
- GO
- /****** Object: StoredProcedure [dbo].[procdcJobTypeTemplateByJobTypeIDSelect] Script Date: 2018/12/13 19:10:20 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.04
- --创建人:Nick
- --说明:取职位模版和晋升机制
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcJobTypeTemplateByJobTypeIDSelect]
- (
- @dcJobTypeID INT
- )
- AS
- BEGIN TRY
- SELECT TOP 1 *
- FROM dcJobTypeTemplate WITH(NOLOCK)
- WHERE dcJobTypeID = @dcJobTypeID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcDcJobTypeTop6Insert] Script Date: 2018/12/13 19:10:20 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcDcJobTypeTop6Insert]
- AS
- BEGIN
- SELECT Id, LEFT(ID, 2) Id2, Description, NewID() Seq, 999 RowNo
- INTO #t
- FROM dcJobType
- WHERE ID > 99
- AND Description NOT LIKE '其他%'
- UPDATE a
- SET a.RowNo = b.RowNo
- FROM #t a, (SELECT ID, Row_Number() OVER(PARTITION BY ID2 ORDER BY Seq) RowNo FROM #t) b
- WHERE a.Id = b.Id
- DELETE FROM #t WHERE RowNo > 7
- TRUNCATE TABLE dcJobTypeTop6
- INSERT INTO dcJobTypeTop6 SELECT Id, Id2, Description, RowNo FROM #t ORDER BY id2, rowno
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDcJobTypeTop6Select] Script Date: 2018/12/13 19:10:20 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:优化感兴趣的职位的搜索速度
- --#####################################################
- CREATE PROCEDURE [dbo].[procDcJobTypeTop6Select]
- AS
- BEGIN TRY
- SELECT * FROM dcJobTypeTop6 With(Nolock) ORDER BY ID2, RowNo
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procdcLinkManagerBySubSiteIDSelect] Script Date: 2018/12/13 19:10:21 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.04
- --创建人:Nick
- --说明:根据subsiteid查询 dcLinkManager
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcLinkManagerBySubSiteIDSelect]
- (
- @SubSiteID INT
- )
- AS
- BEGIN TRY
- SELECT a.ManagerUserId, b.Introduce
- FROM dcLinkManager a WItH(NOLOCK), ManagerUser b WITH(NOLOCK)
- WHERE a.ManagerUserId = b.Id AND a.SubSiteId = @SubSiteID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procdcMajorByKeyWordSelect] Script Date: 2018/12/13 19:10:21 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2018.09.25
- --创建人:Alen
- --说明:根据关键字获取专业类别
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcMajorByKeyWordSelect]
- (
- @KeyWord VARCHAR(100),
- @IsEnglish TINYINT
- )
- AS
- BEGIN
- IF @IsEnglish = 1
- BEGIN
- SELECT *
- FROM dcmajor WITH(NOLOCK)
- WHERE dbo.GetPyFirst(Description) LIKE '%'+@KeyWord+'%'
- END
- ELSE
- BEGIN
- SELECT *
- FROM dcmajor WITH(NOLOCK)
- WHERE Description LIKE '%'+@KeyWord+'%'
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcDcMajorKeywordSelect] Script Date: 2018/12/13 19:10:21 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcDcMajorKeywordSelect]
- (
- @Major NVARCHAR(20)
- )
- AS
- SET NOCOUNT ON
- BEGIN
- IF LEN(@Major) < 2
- SELECT TOP 10 MajorName, dcMajorId, b.Description Major
- FROM dcMajorKeyword a WITH(NOLOCK), dcMajor b WITH(NOLOCK)
- WHERE a.dcMajorId = b.ID AND (MajorName LIKE @Major + '%'
- OR PinYin LIKE @Major + '%'
- OR JianPin LIKE @Major + '%')
- ORDER BY MajorName
- ELSE
- BEGIN
- IF ASCII(LEFT(@Major, 1)) > 127
- SELECT TOP 10 MajorName, dcMajorId, b.Description Major
- FROM dcMajorKeyword a WITH(NOLOCK), dcMajor b WITH(NOLOCK)
- WHERE a.dcMajorId = b.ID AND CHARINDEX(@major, MajorName) > 0
- ORDER BY CHARINDEX(@major, MajorName), MajorName
- ELSE
- SELECT TOP 10 MajorName, dcMajorId, b.Description Major
- FROM dcMajorKeyword a WITH(NOLOCK), dcMajor b WITH(NOLOCK)
- WHERE a.dcMajorId = b.ID AND (CHARINDEX(@major, PinYin) > 0
- OR CHARINDEX(@major, JianPin) > 0)
- ORDER BY MajorName
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDcMapLineSelect] Script Date: 2018/12/13 19:10:22 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:获取热门地标
- --#####################################################
- CREATE PROCEDURE [dbo].[procDcMapLineSelect]
- AS
- BEGIN TRY
- SELECT * FROM dcMapLine WITH(NOLOCK) ORDER BY dcRegionId,OrderNo
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procdcMapPlaceSelect] Script Date: 2018/12/13 19:10:22 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:dcMapPlace
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcMapPlaceSelect]
- AS
- BEGIN TRY
- SELECT * FROM dcMapPlace WITH(NOLOCK) ORDER BY dcRegionID,OrderNo
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procDcMapStationSelect] Script Date: 2018/12/13 19:10:22 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:dcMapStation
- --#####################################################
- CREATE PROCEDURE [dbo].[procDcMapStationSelect]
- AS
- BEGIN TRY
- SELECT * FROM dcMapStation WITH(NOLOCK) ORDER BY dcMapLineId,OrderNo
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procdcNewsTypeByCategorySelect] Script Date: 2018/12/13 19:10:22 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:获取资讯类别
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcNewsTypeByCategorySelect]
- (
- @Category INT
- )
- AS
- BEGIN
- DECLARE @SQL VARCHAR(MAX)
- SET @SQL = 'SELECT * FROM dcNewsType WITH(NOLOCK) '
- IF @Category > 0
- BEGIN
- SET @SQL = @SQL + ' WHERE Category = '+CONVERT(VARCHAR(20),@Category)
- END
- SET @SQL = @SQL + ' ORDER BY OrderNo'
- EXEC(@SQL)
- END
- GO
- /****** Object: StoredProcedure [dbo].[procdcNewsTypeByIDSelect] Script Date: 2018/12/13 19:10:22 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:获取一行资讯类别
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcNewsTypeByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT * FROM dcNewsType WITH(NOLOCK) WHERE id = @ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDcProvinceByIDSelect] Script Date: 2018/12/13 19:10:22 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:Nick
- --说明:获取省份信息
- --#####################################################
- CREATE PROCEDURE [dbo].[procDcProvinceByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT * FROM dcProvince WITH(NOLOCK) WHERE ID=@ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDcProvinceByPinyinSelect] Script Date: 2018/12/13 19:10:23 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:Nick
- --说明:获取省份信息
- --#####################################################
- CREATE PROCEDURE [dbo].[procDcProvinceByPinyinSelect]
- AS
- BEGIN TRY
- SELECT Id, ProvinceName, WebSiteName, dbo.ToPinYin(ProvinceName) PinYin,
- ProvinceDomain
- FROM dcProvince WITH(NOLOCK)
- ORDER BY ID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcDcProvinceSelect] Script Date: 2018/12/13 19:10:23 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.3
- --创建人:John
- --说明:获取省份信息
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcDcProvinceSelect]
- AS
- BEGIN
- SELECT * FROM dcProvince
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDcRegionAllSelect] Script Date: 2018/12/13 19:10:23 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:全部地区
- --#####################################################
- CREATE PROCEDURE [dbo].[procDcRegionAllSelect]
- AS
- BEGIN TRY
- SELECT *
- FROM dcRegion WITH(NOLOCK)
- ORDER BY Id
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procdcRegionByGradeParentIDSelect] Script Date: 2018/12/13 19:10:24 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.11
- --创建人:NICK
- --说明:根据provincieid得到dcregion
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcRegionByGradeParentIDSelect]
- (
- @ParentID INT,
- @Grade INT
- )
- AS
- BEGIN
- IF @Grade = 1
- BEGIN
- SELECT TOP 100 *
- FROM maindb..dcregion
- WHERE grade = @Grade
- ORDER BY id
- END
- ELSE
- BEGIN
- SELECT TOP 100 *
- FROM maindb..dcregion
- WHERE grade = @Grade
- AND ParentID = @ParentID
- ORDER BY id
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[procdcRegionByIDSelect] Script Date: 2018/12/13 19:10:24 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:根据ID获取dcRegion
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcRegionByIDSelect]
- (
- @ID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- --SELECT * FROM dcRegion WITH(NOLOCK) WHERE ID = @ID
- SELECT ID, Abbr Description, Abbr, TqPinyin, PinYin FROM dcRegion WITH(NOLOCK) WHERE ID = @ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procdcRegionByParentIDSelect] Script Date: 2018/12/13 19:10:24 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.3
- --创建人:NICK
- --说明:根据provincieid得到dcregion
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcRegionByParentIDSelect]
- (
- @ProvinceID INT
- )
- AS
- BEGIN
- SELECT id,Description
- FROM dcregion WHERE parentid=@ProvinceID
- OR id=@ProvinceID
- ORDER BY id
- END
- GO
- /****** Object: StoredProcedure [dbo].[procdcRegionByPinYinSelect] Script Date: 2018/12/13 19:10:25 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:根据ProvinceID和pinyin获取dcRegion
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcRegionByPinYinSelect]
- (
- @ProvinceID INT,
- @PinYin1 VARCHAR(50),
- @PinYin2 VARCHAR(50)
- )
- AS
- BEGIN TRY
- IF @PinYin2 = ''
- BEGIN
- SELECT * FROM dcRegion WITH(NOLOCK) WHERE Pinyin=@Pinyin1 AND LEN(ID)=4 AND LEFT(ID,2)=@ProvinceID
- END
- ELSE
- BEGIN
- SELECT a.*,b.Abbr UpperName
- FROM dcRegion a,dcRegion b WITH(NOLOCK)
- WHERE a.ParentID=b.ID
- AND b.Pinyin=@Pinyin1
- AND a.Pinyin=@Pinyin2
- AND LEN(a.ID)=6
- AND LEFT(a.ID,2)=@ProvinceID
- END
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procdcRegionByProvinceIDSelect] Script Date: 2018/12/13 19:10:25 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:根据ProvinceID获取dcRegion
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcRegionByProvinceIDSelect]
- (
- @ProvinceID INT
- )
- AS
- BEGIN TRY
- SELECT * FROM dcRegion WITH(NOLOCK) WHERE LEFT(ID,2)=@ProvinceID AND Pinyin IS NOT NULL
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procdcRegionByRegionNameSelect] Script Date: 2018/12/13 19:10:25 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.31
- --创建人:Nick
- --说明:由地区名称获取地区ID
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcRegionByRegionNameSelect]
- (
- @RegionName VARCHAR(20)
- )
- AS
- BEGIN TRY
- SELECT * FROM dcRegion WITH(NOLOCK) WHERE Description LIKE '%'+@RegionName+'%'
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procDcRegionSelect] Script Date: 2018/12/13 19:10:25 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:获取地区
- --#####################################################
- CREATE PROCEDURE [dbo].[procDcRegionSelect]
- AS
- BEGIN TRY
- SELECT ID, Description, DescriptionEng, OrderNo,Lng,Lat FROM dcRegion WITH(NOLOCK)
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcDcRegionTDKSelect] Script Date: 2018/12/13 19:10:26 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcDcRegionTDKSelect]
- AS
- BEGIN
- SELECT * FROM dcRegionTDK
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDcRunParameterByNameSelect] Script Date: 2018/12/13 19:10:26 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:获取不显示职位广告的企业id。
- --#####################################################
- CREATE PROCEDURE [dbo].[procDcRunParameterByNameSelect]
- AS
- BEGIN TRY
- SELECT Value FROM dcRunParameter WITH(NOLOCK) WHERE System = 1 AND Name = 'do not show Job Ads'
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procDcRunParameterSelect] Script Date: 2018/12/13 19:10:26 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:获取iis运行参数,搜索职位和搜索简历使用数据库的信息。放在这里,便于数据库故障时及时调整
- --#####################################################
- CREATE PROCEDURE [dbo].[procDcRunParameterSelect]
- AS
- insert proclog select 'procDcRunParameterSelect','', getdate()
- BEGIN
- SELECT Name, Value
- FROM dcRunParameter WITH(NOLOCK)
- --WHERE System = 1
- --AND (Name LIKE 'JobSearchDb%' OR Name LIKE 'CvSearchDb%' OR Name LIKE 'ueolog%')
- END
- GO
- /****** Object: StoredProcedure [dbo].[procdcSubSiteByIDSelect] Script Date: 2018/12/13 19:10:26 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:NICK
- --说明:根据省份编号获取 subsite信息
- --#####################################################
- CREATE PROCEDURE [dbo].[procdcSubSiteByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT * FROM dcSubSite WHERE id=@ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcDcSubSiteByPinYinSelect] Script Date: 2018/12/13 19:10:26 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcDcSubSiteByPinYinSelect]
- (
- @Pinyin NVARCHAR(20),
- @dcProvinceID INT
- )
- AS
- BEGIN
- SELECT TOP 1 SubSiteUrl
- FROM dcSubSite WITH(NOLOCK)
- WHERE Pinyin = @Pinyin
- AND ProvinceId = @dcProvinceID
- ORDER BY IsMainSite
- /*
- SELECT TOP 1 a.SubSiteUrl
- FROM dcSubSite a, dcRegion b
- WHERE A.ID = B.ID
- AND b.Pinyin = @Pinyin
- AND a.ProvinceId = @dcProvinceID
- AND b.Id < 9999
- ORDER BY a.IsMainSite
- */
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDcSubSiteByProvinceSelect] Script Date: 2018/12/13 19:10:27 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:John
- --说明:获取所有省份相应的站点
- --#####################################################
- CREATE PROCEDURE [dbo].[procDcSubSiteByProvinceSelect]
- AS
- BEGIN
- SELECT id, REPLACE(SubSiteUrl, 'www.', '') Domain,SubSiteName FROM dcSubSite WITH(NOLOCK) WHERE ismainsite = 1 AND LEN(ID)=2
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDcSubSiteBySecondSelect] Script Date: 2018/12/13 19:10:27 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2015.5.06
- --创建人: sean
- --说明:获取网站PinYin信息
- --#####################################################
- CREATE PROCEDURE [dbo].[procDcSubSiteBySecondSelect]
- AS
- BEGIN
- SELECT Id, SecondSite SubSiteUrl, PinYin
- FROM dcSubSite a WITH(NOLOCK)
- WHERE ID > 99
- AND ProvinceId IN(10, 32, 13, 20, 21, 22, 30, 31, 33, 34, 35, 36, 40, 42, 62, 63, 70, 71, 83, 84, 12, 14, 41, 61, 72, 80)
- ORDER BY ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDcSubSiteBySiteCitySelect] Script Date: 2018/12/13 19:10:27 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:Nick
- --说明:根据城市名称获取省份编号
- --#####################################################
- CREATE PROCEDURE [dbo].[procDcSubSiteBySiteCitySelect]
- (
- @City VARCHAR(50)
- )
- AS
- BEGIN
- SELECT provinceID FROM dcsubsite WITH(NOLOCK) WHere subsitecity like '%'+@City+'%'
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDcSubSiteSelect] Script Date: 2018/12/13 19:10:27 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:获取所有网站信息
- --#####################################################
- CREATE PROCEDURE [dbo].[procDcSubSiteSelect]
- AS
- BEGIN
- SELECT * FROM dcSubSite a WITH(NOLOCK) ORDER BY ProvinceId, ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDcSubSiteUrlByRegionNameSelect] Script Date: 2018/12/13 19:10:28 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:John
- --说明:根据地区名获取网站地址
- --#####################################################
- CREATE PROCEDURE [dbo].[procDcSubSiteUrlByRegionNameSelect]
- (
- @RegionName NVARCHAR(12)
- )
- AS
- BEGIN
- SELECT SubSiteUrl FROM dcSubSite WHERE SubSiteCity LIKE @RegionName ORDER BY ismainsite DESC ,id
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDcSystemdataByIDSelect] Script Date: 2018/12/13 19:10:28 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:Nick
- --说明:
- --#####################################################
- CREATE PROCEDURE [dbo].[procDcSystemdataByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN TRY
- SELECT CONVERT(INT, Value) AS cnt FROM dcsystemdata WITH(NOLOCK) WHERE Id = @ID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcdcVipStandardByPriceCvSelect] Script Date: 2018/12/13 19:10:28 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcdcVipStandardByPriceCvSelect]
- (
- @dcProvinceID AS INT
- )
- AS
- BEGIN
- SELECT PriceCv FROM dcVipStandard WITH(NOLOCK)
- WHERE dcProvinceID = @dcProvinceID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcDcWxTokenByJsApi_TicketUpdate] Script Date: 2018/12/13 19:10:28 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.4
- --创建人:John
- --说明:根据id更新微信记录
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcDcWxTokenByJsApi_TicketUpdate]
- (
- @JsApi_Ticket VARCHAR(200),
- @ProvinceId TINYINT
- )
- AS
- BEGIN
- UPDATE dcWxToken SET JsApi_Ticket = @JsApi_Ticket,
- JsApi_Ticket_adddate = GETDATE()
- WHERE dcProvinceId = @ProvinceId
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcDcWxTokenByProvinceIDSelect] Script Date: 2018/12/13 19:10:29 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.4
- --创建人:John
- --说明:根据id获取微信生成记录
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcDcWxTokenByProvinceIDSelect]
- (
- @ProvinceId TINYINT
- )
- AS
- BEGIN
- SELECT TOP 1 * FROM dcWxToken WHERE adddate > DATEADD(MINUTE,-60,GETDATE()) AND dcProvinceId = @ProvinceId
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcDcWxTokenUpdate] Script Date: 2018/12/13 19:10:29 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.4
- --创建人:John
- --说明:根据id更新微信记录
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcDcWxTokenUpdate]
- (
- @token VARCHAR(200),
- @ProvinceId TINYINT
- )
- AS
- BEGIN
- UPDATE dcWxToken SET Token = @token,adddate = GETDATE() WHERE dcProvinceId = @ProvinceId
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcDeletedJobByRegionIdSelect] Script Date: 2018/12/13 19:10:29 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:John
- --说明:获取一天之内删除的职位
- --@regionId 地区编号
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcDeletedJobByRegionIdSelect]
- (
- @regionId VARCHAR(6)
- )
- AS
- BEGIN TRY
- SELECT a.JobId
- FROM JobDeleted a, Job b
- WHERE DATEADD(DAY,1,a.DeleteDate) > GETDATE()
- AND a.JobId = b.Id
- AND b.dcRegionID = @regionId
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procDicSelect] Script Date: 2018/12/13 19:10:29 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:获取字典信息
- --#####################################################
- CREATE PROCEDURE [dbo].[procDicSelect]
- (
- @TableName VARCHAR(20),
- @queryCondition VARCHAR(200)
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @SQL VARCHAR(500)
- SET @SQL = 'Select ID, Description, Replace(DescriptionEng, '''', ''''''\'''''''''') FROM '+ @TableName + ' WITH(NOLOCK) ORDER BY ID'
- IF @TableName = 'dcIndustry'
- BEGIN
- SET @SQL = 'SELECT ID, Description, Replace(DescriptionEng, '''', ''''''\'''''''''') FROM ' + @TableName + ' WITH(NOLOCK) ORDER BY OrderNo'
- END
- IF @TableName = 'dcMajor'
- BEGIN
- SET @SQL = 'SELECT ID, Description, Replace(DescriptionEng, '''', ''''''\'''''''''') FROM ' + @TableName + ' WITH(NOLOCK) ORDER BY OrderNo, Id'
- END
- IF @TableName = 'dcSalary'
- BEGIN
- SET @SQL = 'SELECT ID,Description,Replace(DescriptionEng, '''', ''''''\''''''''''), DescriptionCp FROM dcSalary' + ' WITH(NOLOCK) WHERE ID>1 ORDER BY OrderNo' END
- IF @queryCondition <> ''
- BEGIN
- SET @SQL = 'SELECT DetailID, Description, Replace(DescriptionEng, '''', ''''''\'''''''''') FROM ' + @TableName + ' WITH(NOLOCK) WHERE '+ @queryCondition +' ORDER BY OrderNo'
- END
- -- IF @queryCondition = 'major'
- -- BEGIN
- -- SET @SQL = 'SELECT ID, Description, Replace(DescriptionEng, '''', ''''''\'''''''''') FROM dcMajor WITH(NOLOCK) WHERE Id NOT IN(1106, 1713) ORDER BY MajorCategoryId, OrderNo'
- -- END
- EXEC (@SQL)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcDouBanEmailUpdate] Script Date: 2018/12/13 19:10:30 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.4
- --创建人:John
- --说明:更新豆瓣 邮件信息
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcDouBanEmailUpdate]
- (
- @PaMainID INT,
- @DouBanID INT
- )
- AS
- BEGIN
- UPDATE doubanmail SET isregister = 1, pamainid = @PaMainID WHERE id = @DouBanID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDwnClass1ByDocIDSelect] Script Date: 2018/12/13 19:10:30 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:根据docid获取doc所在的大类名称
- --#####################################################
- CREATE PROCEDURE [dbo].[procDwnClass1ByDocIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT a.id,b.title,b.id as typeid
- FROM maindb..dwndoc a WITH(NOLOCK),maindb..dwnclass1 b WITH(NOLOCK),maindb..dwnclass2 c WITH(NOLOCK)
- WHERE a.classid=c.id
- AND c.class1id=b.id
- AND a.id=@ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDwnClass1ByIDSelect] Script Date: 2018/12/13 19:10:30 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:获取个人文档下载大类名稱
- --#####################################################
- CREATE PROCEDURE [dbo].[procDwnClass1ByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT * FROM dwnclass1 WITH(NOLOCK) WHERE id=@ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDwnClass2ByIDSelect] Script Date: 2018/12/13 19:10:30 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:获取文档下载二级类别
- --#####################################################
- CREATE PROCEDURE [dbo].[procDwnClass2ByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT TOP 18 * FROM dwnclass2 WITH(NOLOCK) WHERE class1id=@ID ORDER BY power
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDwnDoc44ByCompanySelect] Script Date: 2018/12/13 19:10:31 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:文档下载 企业
- --#####################################################
- CREATE PROCEDURE [dbo].[procDwnDoc44ByCompanySelect]
- AS
- BEGIN
- SELECT TOP 44 a.id,a.Name ,classid
- FROM dwndoc a WITH(NOLOCK)
- WHERE danwei=1
- ORDER BY updatedate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDwnDoc44ByPersonSelect] Script Date: 2018/12/13 19:10:31 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:文档下载 个人
- --#####################################################
- CREATE PROCEDURE [dbo].[procDwnDoc44ByPersonSelect]
- AS
- BEGIN
- SELECT TOP 44 a.id,a.Name ,classid
- FROM dwndoc a WITH(NOLOCK)
- WHERE geren=1
- ORDER BY updatedate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDwnDoc51rcByIDSelect] Script Date: 2018/12/13 19:10:31 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:NICK
- --说明:随机得到一定数目的个人文档
- --alen 2018-3-26
- --#####################################################
- CREATE PROCEDURE [dbo].[procDwnDoc51rcByIDSelect]
- (
- @Second INT,
- @Number INT
- )
- AS
- BEGIN
- DECLARE @SQL VARCHAR(MAX)
- SET @SQL = '
- SELECT TOP ' + CONVERT(VARCHAR(10), @Number)+' ID, Name, ClassId, Type
- FROM Searchdb..DwnDoc51rc WITH(NOLOCK)
- ORDER BY NEWID()'
- EXEC(@SQL)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcDwnDocByClassIdSelect] Script Date: 2018/12/13 19:10:32 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcDwnDocByClassIdSelect]
- (
- @ClassId INT,
- @DocId INT
- )
- AS
- BEGIN
- IF ISNULL(@DocId, 0) = 0
- SELECT Id, FileType, LEN(HtmlContent) HtmlContent, [Name], [Description]
- FROM DwnDoc WITH(NOLOCK)
- WHERE Classid = @ClassId
- ORDER BY Id DESC
- ELSE
- SELECT Id, FileType, LEN(HtmlContent) HtmlContent, [Name], [Description]
- FROM DwnDoc WITH(NOLOCK)
- WHERE Classid = @ClassId
- ORDER BY CASE Id WHEN @DocID THEN 1 ELSE 10 END, Id DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDwnDocByCompanySelect] Script Date: 2018/12/13 19:10:32 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:获取企业doc文档下载排行(top10)
- --#####################################################
- CREATE PROCEDURE [dbo].[procDwnDocByCompanySelect]
- AS
- BEGIN TRY
- SELECT TOP 10 id,name,dwnnum
- FROM maindb..dwndoc
- WHERE danwei=1
- ORDER BY dwnnum DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procDwnDocByIDSelect] Script Date: 2018/12/13 19:10:32 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:获取doc文档内容
- --#####################################################
- CREATE PROCEDURE [dbo].[procDwnDocByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT a.*, b.dir dir1, c.dir dir2
- FROM Maindb..DwnDoc a, DwnClass1 b, DwnClass2 c
- WHERE a.ID = @ID
- AND a.ClassID = c.ID
- AND c.Class1ID = b.ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDwnDocByIDUpdate] Script Date: 2018/12/13 19:10:32 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:文档增加点击数
- --#####################################################
- CREATE PROCEDURE [dbo].[procDwnDocByIDUpdate]
- (
- @ID INT
- )
- AS
- BEGIN
- UPDATE dwndoc SET dwnnum=dwnnum+1 WHERE id=@ID
- RETURN 1
- END
- GO
- /****** Object: StoredProcedure [dbo].[procDwnDocByPersonSelect] Script Date: 2018/12/13 19:10:33 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:获取个人doc文档下载排行(top10)
- --#####################################################
- CREATE PROCEDURE [dbo].[procDwnDocByPersonSelect]
- AS
- BEGIN TRY
- SELECT TOP 10 id,name,dwnnum
- FROM maindb..dwndoc
- WHERE geren=1
- ORDER BY dwnnum DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcDwnDocByTop5Select] Script Date: 2018/12/13 19:10:33 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --修改harry 2017-10-10
- --may要求按照添加时间排序
- CREATE PROCEDURE [dbo].[ProcDwnDocByTop5Select]
- AS
- SET NOCOUNT ON
- BEGIN
- SELECT TOP 8 a.ID, a.Name, a.ClassID Class2ID, b.Title, c.ID Class1ID
- FROM DwnDoc a WITH(NOLOCK),
- DwnClass2 b WITH(NOLOCK),
- DwnClass1 c WITH(NOLOCK)
- WHERE a.Geren = 1
- AND a.ClassID = b.ID
- AND b.Class1ID = c.ID
- ORDER BY a.adddate desc
- END
- SET NOCOUNT OFF
- GO
- /****** Object: StoredProcedure [dbo].[procDwnDocDetailByIDSelect] Script Date: 2018/12/13 19:10:33 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:获取文档内容
- --#####################################################
- CREATE PROCEDURE [dbo].[procDwnDocDetailByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT a.id,a.name,a.lgg,a.adddate,a.filetype,a.description,a.authtype,a.dwnnum,b.dir dir1,c.dir dir2,a.filename
- FROM dwndoc a WITH(NOLOCK),dwnclass1 b WITH(NOLOCK),dwnclass2 c WITH(NOLOCK)
- WHERE a.classid=c.id
- AND c.class1id=b.id
- AND a.id=@ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcDwnDocSelect] Script Date: 2018/12/13 19:10:33 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:Nick
- --说明:获取文档下载数据
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcDwnDocSelect]
- AS
- BEGIN TRY
- SELECT TOP 14 a.ID,a.Name,ClassID
- FROM DwnDoc a WITH(NOLOCK)
- WHERE Geren = 1
- ORDER BY UpdateDate DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procDwnDocUpdate] Script Date: 2018/12/13 19:10:33 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.31
- --创建人:Nick
- --说明:修改下载文档
- --#####################################################
- CREATE PROCEDURE [dbo].[procDwnDocUpdate]
- (
- @ID INT
- )
- AS
- BEGIN TRY
- UPDATE dwndoc SET dwnnum=dwnnum+1 WHERE id = @ID
- RETURN 1
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcEmailPrevSendInsert] Script Date: 2018/12/13 19:10:34 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:John
- --说明:即时邮件发送
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcEmailPrevSendInsert]
- (
- @cpMainID INT,
- @paMainID INT,
- @emailNo TINYINT,
- @emailTitle NVARCHAR(50),
- @jsonData NVARCHAR(MAX),
- @email VARCHAR(100),
- @subSiteID SMALLINT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- INSERT INTO msEmailPrevSend(cpMainId, paMainId, EmailNo, EmailTitle, JsonData, Email, dcSubsiteId, IsSend)
- VALUES(@cpMainID, @paMainID, @emailNo, @emailTitle, @jsonData, @email, @subSiteID, 0)
- END
- GO
- /****** Object: StoredProcedure [dbo].[procexInterviewByPamainIDSelect] Script Date: 2018/12/13 19:10:34 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:Nick
- --说明:面试通知
- --#####################################################
- CREATE PROCEDURE [dbo].[procexInterviewByPamainIDSelect]
- (
- @PamainID INT
- )
- AS
- BEGIN
- SELECT TOP 5 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
- 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
- ORDER BY a.adddate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procExJobApplyByCvMainIDCpMainIDSelect] Script Date: 2018/12/13 19:10:34 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:
- --#####################################################
- CREATE PROCEDURE [dbo].[procExJobApplyByCvMainIDCpMainIDSelect]
- (
- @IsManager INT,
- @CvMainID INT,
- @ID INT
- )
- AS
- BEGIN TRY
- IF @IsManager = 1
- BEGIN
- SELECT TOP 1 JobID
- FROM exJobApply a,Job b
- WHERE a.JobID=b.ID
- AND a.cvMainID=@CvMainID
- AND b.cpMainID=@ID
- ORDER BY a.AddDate DESC
- END
- ELSE
- BEGIN
- SELECT TOP 1 JobID
- FROM exJobApply a,Job b
- WHERE a.JobID=b.ID
- AND a.cvMainID=@CvMainID
- AND b.caMainID=@ID
- ORDER BY a.AddDate DESC
- END
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procExJobApplyByCvMainIDSelect] Script Date: 2018/12/13 19:10:35 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:
- --#####################################################
- CREATE PROCEDURE [dbo].[procExJobApplyByCvMainIDSelect]
- (
- @IsManager INT,
- @CvMainID INT,
- @ID INT
- )
- AS
- BEGIN TRY
- IF @IsManager = 1
- BEGIN
- SELECT TOP 1 JobID
- FROM exJobApply a,Job b
- WHERE a.JobID=b.ID
- AND a.cvMainID=@CvMainID
- AND b.cpMainID=@ID
- ORDER BY a.AddDate DESC
- END
- ELSE
- BEGIN
- SELECT TOP 1 JobID
- FROM exJobApply a,Job b
- WHERE a.JobID=b.ID
- AND a.cvMainID=@CvMainID
- AND b.caMainID=@ID
- ORDER BY a.AddDate DESC
- END
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procexJobApplyByPamainIDSelect] Script Date: 2018/12/13 19:10:35 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:Nick
- --说明:获取职位申请信息
- --#####################################################
- CREATE PROCEDURE [dbo].[procexJobApplyByPamainIDSelect]
- (
- @PamainID INT
- )
- AS
- BEGIN
- SELECT TOP 5 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.HasLicence, c.IsAgent, b.IssueDate, b.IssueEND, b.IsDelete, d.Name cvName
- 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
- ORDER BY a.AddDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcFamousCompanyGroupSelect] Script Date: 2018/12/13 19:10:35 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.29
- --创建人:Nick
- --说明:获取名企导航Group
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcFamousCompanyGroupSelect]
- (
- @ProvinceID INT
- )
- AS
- BEGIN TRY
- SELECT a.*,STUFF((SELECT ','+CONVERT(VARCHAR(10),dcRegionID)
- FROM marketdb..CampusGroupRegion WITH(NOLOCK)
- WHERE GroupID=a.id for xml path('')),1,1,'') RegionIDs FROM MarketDB..CampusGroup a WITH(NOLOCK)
- WHERE EXISTS(
- SELECT TOP 1 'x'
- FROM MarketDB..CampusGroupRegion WITH(NOLOCK)
- WHERE GroupID=a.ID
- AND dcRegionID LIKE ''+CONVERT(VARCHAR(4),@ProvinceID)+'%'
- )
- ORDER BY a.id
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcFamousCompanySelect] Script Date: 2018/12/13 19:10:35 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.29
- --创建人:Nick
- --说明:获取名企导航
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcFamousCompanySelect]
- (
- @ProvinceID INT,
- @RegionIDs VARCHAR(100)
- )
- AS
- BEGIN TRY
- SELECT a.*
- FROM MarketDB..CampusCompany a WITH(NOLOCK)
- WHERE
- (
- dcRegionID = @ProvinceID OR dcRegionID IN (SELECT * FROM dbo.fnSplit(@RegionIDs,','))
- )
- AND (
- EXISTS(
- SELECT TOP 1 'x' FROM MarketDB..CampusBrochure x
- WITH(NOLOCK),MarketDB..CampusBrochureSite y WITH(NOLOCK)
- WHERE x.ID = y.CampusBrochure
- AND x.CompanyID=a.ID
- AND x.EndDate>getdate()
- AND y.dcSubSiteId = @ProvinceID
- )
- OR EXISTS(
- SELECT TOP 1 'x'
- FROM MarketDB..CampusPresentation m WITH(NOLOCK),MarketDB..CampusSchool n WITH(NOLOCK)
- WHERE m.SchoolID = n.ID
- AND m.endtime>getdate()
- AND m.CompanyID=a.ID
- AND n.dcRegionID LIKE ''+CONVERT(VARCHAR(4),@ProvinceID)+'%'
- )
- ) ORDER BY AddDate DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procFeedback_NoregInsert] Script Date: 2018/12/13 19:10:35 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.04
- --创建人:Nick
- --说明:插入 feedback_noreg
- --#####################################################
- CREATE PROCEDURE [dbo].[procFeedback_NoregInsert]
- (
- @Content VARCHAR(400),
- @Name VARCHAR(50),
- @IP VARCHAR(20),
- @Tel VARCHAR(20),
- @Email VARCHAR(50),
- @SiteID INT
- )
- AS
- BEGIN TRY
- INSERT INTO feedback_noreg (content,name,ip,telephone,email,province_id)
- SELECT dbo.SafeSQL(@Content), dbo.SafeSQL(@Name), @IP, dbo.SafeSQL(@Tel), dbo.SafeSQL(@Email), @SiteID
- RETURN 1
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procFixCompanyByRecruitmentSelect] Script Date: 2018/12/13 19:10:36 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procFixCompanyByRecruitmentSelect]
- (
- @SubSiteID VARCHAR(4)
- )
- AS
- BEGIN
- CREATE TABLE #Tmp --创建临时表#Tmp
- (
- CpMainId INT,
- SecondId VARCHAR(50),
- Name NVARCHAR(50),
- DcCompanySizeId SMALLINT,
- Industry VARCHAR(100),
- Logo VARCHAR(200)
- )
- INSERT INTO #Tmp (CpMainId,SecondId,Name,DcCompanySizeId)
- SELECT DISTINCT TOP 8 cp.Id, fp.CpMainId,fp.Name,cp.DcCompanySizeId
- FROM FpFixPosition fp LEFT JOIN cpMain cp ON fp.cpmainid = cp.SecondId
- WHERE LEFT(fp.dcSubSiteID,LEN(@SubSiteID)) = @SubSiteID
- ORDER BY DcCompanySizeID DESC
- DECLARE @Cnt INT
- SELECT @Cnt = COUNT(1) FROM #Tmp
-
- IF @Cnt < 3 AND LEN(@SubSiteID) > 2
- INSERT INTO #Tmp (CpMainId,SecondId,Name,DcCompanySizeId)
- SELECT DISTINCT TOP 8 cp.Id, fp.CpMainId,fp.Name,cp.DcCompanySizeId
- FROM FpFixPosition fp LEFT JOIN cpMain cp ON fp.cpmainid = cp.SecondId
- WHERE fp.DcProvinceId = LEFT(@SubSiteID,2)
- ORDER BY DcCompanySizeID DESC
- UPDATE #Tmp SET Industry = dbo.GetCpIndustry(#Tmp.CpMainId)
- UPDATE #Tmp SET Logo = dbo.GetCpLogo(#Tmp.CpMainId)
- SELECT TOP 8 * FROM #Tmp
- END
- GO
- /****** Object: StoredProcedure [dbo].[procFpcommonSearchByProvinceIDSelect] Script Date: 2018/12/13 19:10:36 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:获取地区
- --#####################################################
- CREATE PROCEDURE [dbo].[procFpcommonSearchByProvinceIDSelect]
- (
- @ProvinceID INT
- )
- AS
- BEGIN TRY
- SELECT SearchText, SearchValue, SearchType
- FROM fpcommonsearch WITH(NOLOCK)
- WHERE dcProvinceID = @ProvinceID
- ORDER BY SearchType, Sequence
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcFpFixPositionReBuild] Script Date: 2018/12/13 19:10:36 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcFpFixPositionReBuild]
- AS
- SET NOCOUNT ON;
- IF NOT EXISTS(SELECT 'x' FROM caOrder WITH(NOLOCK)
- WHERE OrderType=7 AND BeginDate < GETDATE()
- AND EndDate > GETDATE()
- and (BeginDate > DaTEADD(MINUTE, -3, GETDATE())
- OR OpenDate > DaTEADD(MINUTE, -3, GETDATE())
- )
- )
- BEGIN
- IF DATEPART(MINUTE, GETDATE()) % 10 > 20
- RETURN
- END
- BEGIN TRAN
- TRUNCATE TABLE SearchDb..FpFixPosition
- INSERT FpFixPosition(RealCpMainID, cpMainID, Name, Paid, OpenDate, dcProvinceId, dcRegionID, dcSubsiteID, caOrderId, dcIndustryId)
- SELECT a.ID CompanyId, a.SecondId SecondCompanyId, a.Name, b.Paid, b.OpenDate, a.dcProvinceID, a.dcRegionID, a.dcSubsiteID, b.Id, c.dcIndustryId
- FROM cpMain a WITH(NOLOCK INDEX(IX_cpMain_HomepageFix))
- INNER JOIN caOrder b WITH(NOLOCK) ON b.cpMainID = a.id
- INNER JOIN cpIndustry c WITH(NOLOCK) ON a.id = c.cpMainId
- WHERE b.BeginDate < GETDATE()
- AND b.EndDate > GETDATE()
- AND b.OpenDate IS NOT NULL
- AND b.OrderType = 7
- AND a.JobNumber>0
- AND a.Valid = 1
- AND b.IsDeleted = 0 --是否可被搜索
- --UPDATE a SET a.Name = b.ShortName
- --FROM FpFixPosition a, cpMain b
- --WHERE a.RealCpMainID = b.Id
- --AND b.ShortName > ''
- UPDATE FpFixPosition SET Name = '日照天宁集团' WHERE RealCpMAinId = 10174411
- UPDATE FpFixPosition SET JobID = dbo.GetJobSecondIds(RealCpMainID),
- JobName = dbo.GetJobNames(RealCpMainID)
- UPDATE FpFixPosition SET ThreeIds = dbo.TruncJobIDs(JobID)
- UPDATE FpFixPosition
- SET AddDate =
- (SELECT MAX(AddDate) FROM Job WITH(NOLOCK)
- WHERE Job.SecondID IN (SELECT REPLACE(ID, '_', '') FROM dbo.Get3JobSecondIds(FpFixPosition.ThreeIds))
- )
- UPDATE FpFixPosition SET NoFollow = ''
- --WHERE CpMainId IN(SELECT PageId FROM MarketDb..PageBaiduInclude WITH(NOLOCK) WHERE PageType = 1 AND InCludeDate IS NULL)
- UPDATE FpFixPosition
- SET NewXId =
- (SELECT TOP 1 SecondID FROM Job WITH(NOLOCK)
- WHERE Job.SecondID IN (SELECT ID FROM dbo.Get3JobSecondIds(FpFixPosition.ThreeIds))
- AND Job.AddDate = FpFixPosition.AddDate
- )
- --UPDATE FpFixPosition SET dcIndustryId =(SELECT TOP 1 dcIndustryID FROM cpIndustry WITH(NOLOCK) WHERE cpIndustry.cpMainID = FpFixPosition.RealCpMainID)
- UPDATE FpFixPosition SET IndustryCategory=(SELECT CategoryId FROM dcIndustryCategory WITH(NOLOCK) WHERE dcIndustryCategory.dcIndustryId = FpFixPosition.dcIndustryId)
- DELETE FpFixPosition WHERE Id IN(SELECT MAX(ID) ID FROM FpFixPosition GROUP BY cpMainId, INDustryCategory HAVING COUNT(*) > 1)
- DELETE FpFixPosition WHERE Id IN(SELECT MAX(ID) ID FROM FpFixPosition GROUP BY cpMainId, INDustryCategory HAVING COUNT(*) > 1)
- DELETE FpFixPosition WHERE Id IN(SELECT MAX(ID) ID FROM FpFixPosition GROUP BY cpMainId, INDustryCategory HAVING COUNT(*) > 1)
- UPDATE a SET a.IndustryCategory = 8
- FROM FpFixPosition a, (
- SELECT dcProvinceId, IndustryCategory
- FROM FpFixPosition WITH(NOLOCK)
- GROUP BY dcProvinceId, IndustryCategory
- HAVING COUNT(*) < 4) b
- WHERE a.dcProvinceId = b.dcProvinceId
- AND a.IndustryCategory = b.IndustryCategory
- COMMIT
- GO
- /****** Object: StoredProcedure [dbo].[procFpHomepageimage51RCSelect] Script Date: 2018/12/13 19:10:36 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:NICK
- --说明:
- --#####################################################
- CREATE PROCEDURE [dbo].[procFpHomepageimage51RCSelect]
- AS
- BEGIN
- SELECT TOP 1 *
- FROM fphomepageimage
- WHERE url is not null
- AND ltrim(url)<>'' ORDER BY adddate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procfpHomepageImageByProvinceIDSelect] Script Date: 2018/12/13 19:10:37 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:获取网站头条
- --#####################################################
- CREATE PROCEDURE [dbo].[procfpHomepageImageByProvinceIDSelect]
- (
- @ProvinceID INT,
- @Num INT
- )
- AS
- BEGIN
- DECLARE @SQL VARCHAR(MAX)
- SET @SQL = 'SELECT TOP '+CONVERT(VARCHAR(10),@Num)+' *
- FROM fpHomepageImage
- WHERE dcProvinceID='+CONVERT(VARCHAR(10),@ProvinceID)+'
- AND imagetype=1
- AND url >''''
- ORDER BY AddDate DESC '
- EXEC(@SQL)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcGdFixedSelect] Script Date: 2018/12/13 19:10:37 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --创建人:lambo
- --创建时间:2013-5-25
- --用途:查询固定资产列表
- CREATE PROCEDURE [dbo].[ProcGdFixedSelect]
- (
- @WorkUserID INT,
- @Where NVARCHAR(MAX)
- )
- AS
- BEGIN
- --待确认的
- SELECT a.*,0 OrderBY INTO #T FROM GdFixed a WITH(NOLOCK)
- WHERE
- EXISTS(SELECT 'x' FROM GdRepair x WITH(NOLOCK) WHERE x.GdFixedID = a.ID AND OwnerConfirmDate IS NULL AND Owner = @WorkUserID )
- OR
- EXISTS(SELECT 'x' FROM GdShift x WITH(NOLOCK) WHERE x.GdFixedID = a.ID AND ReceiverDate IS NULL AND Owner = @WorkUserID )
- OR
- EXISTS(SELECT 'x' FROM GdShift x WITH(NOLOCK) WHERE x.GdFixedID = a.ID AND ReceiverDate IS NULL AND GdHouseID IN (SELECT ID FROM GdHouse WITH(NOLOCK) WHERE HouseOwner = @WorkUserID ))
- OR
- (ScrapMan in
- (
- SELECT ID FROM WorkUser WITH(NOLOCK)
- WHERE ManagerUserID IN
- (
- SELECT ID FROM ManagerUser WITH(NOLOCK)
- WHERE Superior=(
- SELECT ManagerUserID FROM WorkUser WITH(NOLOCK)
- WHERE ID = @WorkUserID
- )
- )
- )
- AND ScrapConfirmdate IS NULL
- )
- SET IDENTITY_INSERT #t ON
- --自己发出 别人代办的
- INSERT INTO #t (ID,FixedName,Format,BarcodeText,BarcodeLabel,GdClassId,SourceType,Buyer,BuyDate,Price,UsedMonth,Warranty,AddMan,AddDate,PhotoFile,status,ScrapDate,ScrapMan,ScrapReason,ScrapConfirmor,ScrapConfirmDate,ScrapMemo,OrderBY)
- SELECT ID,FixedName,Format,BarcodeText,BarcodeLabel,GdClassId,SourceType,Buyer,BuyDate,Price,UsedMonth,Warranty,AddMan,AddDate,PhotoFile,status,ScrapDate,ScrapMan,ScrapReason,ScrapConfirmor,ScrapConfirmDate,ScrapMemo,1 OrderBY FROM GdFixed a WITH(NOLOCK)
- WHERE
- (
- EXISTS(SELECT 'x' FROM GdRepair x WITH(NOLOCK) WHERE x.GdFixedID = a.ID AND OwnerConfirmDate IS NULL AND AddMan = @WorkUserID )
- OR
- EXISTS(SELECT 'x' FROM GdShift x WITH(NOLOCK) WHERE x.GdFixedID = a.ID AND ReceiverDate IS NULL AND AddMan = @WorkUserID )
- OR
- (ScrapMan = @WorkUserID AND ScrapConfirmdate IS NULL)
- )
- AND ID NOT IN (SELECT ID FROM #t)
-
- --自己使用的
- INSERT INTO #t (ID,FixedName,Format,BarcodeText,BarcodeLabel,GdClassId,SourceType,Buyer,BuyDate,Price,UsedMonth,Warranty,AddMan,AddDate,PhotoFile,status,ScrapDate,ScrapMan,ScrapReason,ScrapConfirmor,ScrapConfirmDate,ScrapMemo,OrderBY)
- SELECT ID,FixedName,Format,BarcodeText,BarcodeLabel,GdClassId,SourceType,Buyer,BuyDate,Price,UsedMonth,Warranty,AddMan,AddDate,PhotoFile,status,ScrapDate,ScrapMan,ScrapReason,ScrapConfirmor,ScrapConfirmDate,ScrapMemo,2 OrderBY FROM GdFixed a WITH(NOLOCK)
- WHERE
- EXISTS (SELECT 'x' FROM GdShift WITH(NOLOCK) WHERE GdFixedID = a.id AND Owner IS NOT NULL AND id = (SELECT MAX(id) FROM GdShift WITH(NOLOCK) WHERE ReceiverDate IS NOT NULL AND GdFixedID = a.id) AND Owner = @WorkUserID )
- AND ID NOT IN (SELECT ID FROM #t)
- --自己负责的
- INSERT INTO #t (ID,FixedName,Format,BarcodeText,BarcodeLabel,GdClassId,SourceType,Buyer,BuyDate,Price,UsedMonth,Warranty,AddMan,AddDate,PhotoFile,status,ScrapDate,ScrapMan,ScrapReason,ScrapConfirmor,ScrapConfirmDate,ScrapMemo,OrderBY)
- SELECT ID,FixedName,Format,BarcodeText,BarcodeLabel,GdClassId,SourceType,Buyer,BuyDate,Price,UsedMonth,Warranty,AddMan,AddDate,PhotoFile,status,ScrapDate,ScrapMan,ScrapReason,ScrapConfirmor,ScrapConfirmDate,ScrapMemo,2 OrderBY FROM GdFixed a WITH(NOLOCK)
- WHERE
- EXISTS (SELECT 'x' FROM GdShift WITH(NOLOCK) WHERE GdFixedID = a.id AND Owner IS NULL AND id = (SELECT MAX(id) FROM GdShift WITH(NOLOCK) WHERE ReceiverDate IS NOT NULL AND GdFixedID = a.id) AND GdHouseID IN (SELECT ID FROM GdHouse WITH(NOLOCK) WHERE HouseOwner = @WorkUserID) )
- AND ID NOT IN (SELECT ID FROM #t)
- --其它
- INSERT INTO #t (ID,FixedName,Format,BarcodeText,BarcodeLabel,GdClassId,SourceType,Buyer,BuyDate,Price,UsedMonth,Warranty,AddMan,AddDate,PhotoFile,status,ScrapDate,ScrapMan,ScrapReason,ScrapConfirmor,ScrapConfirmDate,ScrapMemo,OrderBY)
- SELECT ID,FixedName,Format,BarcodeText,BarcodeLabel,GdClassId,SourceType,Buyer,BuyDate,Price,UsedMonth,Warranty,AddMan,AddDate,PhotoFile,status,ScrapDate,ScrapMan,ScrapReason,ScrapConfirmor,ScrapConfirmDate,ScrapMemo,2 OrderBY FROM GdFixed a WITH (NOLOCK)
- WHERE ID NOT IN (SELECT ID FROM #t)
-
- SET @Where = dbo.SafeSql(@Where)
- EXEC('SELECT a.*, b.ClassName,
- ISNULL((SELECT LTRIM(STR(ManagerUserID)) + '' '' + Name From WorkUser WHERE ID IN( SELECT TOP 1 ISNULL(owner,0) FROM gdshift WITH(NOLOCK) WHERE gdfixedid=a.id and ReceiverDate IS NOT NULL ORDER BY ID DESC)),'''') WorkUserName,
- ISNULL((SELECT HouseName+''(''+Ltrim(str(n.manageruserid))+n.Name+'')'' From GdHouse m with(nolock),workuser n with(nolock) WHERE m.HouseOwner=n.id and m.ID IN( SELECT TOP 1 ISNULL(GdHouseId,0) FROM gdshift WITH(NOLOCK) WHERE gdfixedid=a.id and ReceiverDate IS NOT NULL ORDER BY ID DESC)),'''') GdHouseName,
- (SELECT count(1) FROM GdShift WITH(NOLOCK) WHERE gdFixedID=a.ID ) ShiftCount
- FROM #t a WITH(NOLOCK) ,GdClass b WITH(NOLOCK) WHERE a.GdClassid = b.id ' + @Where)
- END
- GO
- /****** Object: StoredProcedure [dbo].[procGetCvMatchSelect] Script Date: 2018/12/13 19:10:37 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:获取简历和职位的匹配度
- --#####################################################
- CREATE PROCEDURE [dbo].[procGetCvMatchSelect]
- (
- @CvMainID INT,
- @JobID INT
- )
- AS
- BEGIN TRY
- SELECT dbo.GetCvMatch(@CvMainID,@JobID) MatchNo
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcHotJobByRegionIDSelect] Script Date: 2018/12/13 19:10:38 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.31
- --创建人:John
- --说明:根据RegionID 获取当前地区热门招聘职位
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcHotJobByRegionIDSelect]
- (
- @dcRegionID VARCHAR(4)
- )
- AS
- BEGIN
- SELECT TOP 10 dcJobTypeID,AvgSalary FROM reportdb..SalaryReportJobtype WHERE dcRegionid = @dcRegionID ORDER BY JobNumber DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcHotRankingInsert] Script Date: 2018/12/13 19:10:38 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --sean 2014-8-14
- CREATE PROCEDURE [dbo].[ProcHotRankingInsert]
- AS
- BEGIN
- TRUNCATE TABLE SearchDb..HotRanking
- DECLARE @ProvinceId INT
- SET @ProvinceId = 0
- WHILE EXISTS(SELECT 'x' FROM dcProvince WHERE ID > @ProvinceId)
- BEGIN
- SELECT TOP 1 @ProvinceId = ID FROM dcProvince WHERE ID > @ProvinceId ORDER BY ID
-
- INSERT INTO SearchDb..HotRanking(Category, ProvinceId, ID, Title, ViewNumber_All, ResionOrder)
- --SELECT TOP 10 2, @ProvinceId, a.ID, a.Title, CASE CHARINDEX(@RegionName, Title) WHEN 0 THEN 0 ELSE 1 END AS ResionOrder
- SELECT TOP 10 2, @ProvinceId, a.ID, a.Title, ViewNumber_All, 0 ResionOrder
- FROM QlrcNews a WITH(NOLOCK)
- WHERE EXISTS(SELECT 'x' FROM fnSplit(DetailType, ',') b, dcNewsType c WITH(NOLOCK) WHERE b.a = c.id AND c.id = 2)
- AND VersionID = @ProvinceId --OR VersionID = 0)
- AND Type = 1
- AND RefreshDate > DATEADD(MONTH, -3, GETDATE())
- ORDER BY ResionOrder DESC, ViewNumber_All desc
- INSERT INTO SearchDb..HotRanking(Category, ProvinceId, ID, Title, ViewNumber_All, ResionOrder)
- SELECT TOP 10 1, @ProvinceId, ID, Title, ViewNumber_All, 0 ResionOrder
- FROM QlrcNews a WITH(NOLOCK)
- WHERE EXISTS(SELECT 'x' FROM fnSplit(DetailType, ',') b, dcNewsType c WITH(NOLOCK) WHERE b.a = c.id AND c.id <> 2)
- AND VersionID = @ProvinceID --OR VersionID = 0)
- AND Type = 1
- AND RefreshDate > DATEADD(MONTH, -3, GETDATE())
- ORDER BY ViewNumber_All desc
- END
- ---- '32__'
- DECLARE @RegionName NVARCHAR(5)
- SET @ProvinceId = 0
- WHILE EXISTS(SELECT 'x' FROM dcRegion WHERE ID LIKE '32__' AND ID > @ProvinceId)
- BEGIN
- SELECT TOP 1 @ProvinceId = ID, @RegionName = LEFT(Description, 2)
- FROM dcRegion WHERE ID LIKE '32__' AND ID > @ProvinceId ORDER BY ID
- INSERT INTO SearchDb..HotRanking(Category, ProvinceId, ID, Title, ViewNumber_All, ResionOrder)
- SELECT TOP 10 2, @ProvinceId, a.ID, a.Title, ViewNumber_All, CASE CHARINDEX(@RegionName, Title) WHEN 0 THEN 0 ELSE 1 END AS ResionOrder
- FROM QlrcNews a WITH(NOLOCK)
- WHERE EXISTS(SELECT 'x' FROM fnSplit(DetailType, ',') b, dcNewsType c WITH(NOLOCK) WHERE b.a = c.id AND c.id = 2)
- AND (VersionID = 32 OR VersionID = 0)
- AND Type = 1
- AND RefreshDate > DATEADD(MONTH, -3, GETDATE())
- ORDER BY ResionOrder DESC, ViewNumber_All desc
- INSERT INTO SearchDb..HotRanking(Category, ProvinceId, ID, Title, ViewNumber_All, ResionOrder)
- SELECT TOP 10 1, @ProvinceId, ID, Title, ViewNumber_All, 0 ResionOrder
- FROM QlrcNews a WITH(NOLOCK)
- WHERE EXISTS(SELECT 'x' FROM fnSplit(DetailType, ',') b, dcNewsType c WITH(NOLOCK) WHERE b.a = c.id AND c.id <> 2)
- AND (VersionID LIKE '32%' OR VersionID = 0)
- AND Type = 1
- AND RefreshDate > DATEADD(MONTH, -3, GETDATE())
- ORDER BY ViewNumber_All desc
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcHotRankingSelect] Script Date: 2018/12/13 19:10:38 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- -- sean 2014-8-14
- CREATE PROCEDURE [dbo].[ProcHotRankingSelect]
- (
- @ProvinceID INT,
- @Category INT
- )
- AS
- BEGIN
- IF @ProvinceID > 99 AND LEFT(@ProvinceID, 2) < '32'
- SET @ProvinceID = LEFT(@ProvinceID, 2)
- IF @Category > 0
- BEGIN
- IF @Category <> 2
- SET @Category = 1
- SELECT ID, Title, ResionOrder
- FROM SearchDb..HotRanking WITH(NOLOCK)
- WHERE ProvinceId = @ProvinceID
- AND Category = @Category
- ORDER BY ViewNumber_All DESC
- END
- ELSE
- SELECT TOP 10 ID, Title, ResionOrder
- FROM SearchDb..HotRanking WITH(NOLOCK)
- WHERE ProvinceId = @ProvinceID
- ORDER BY ViewNumber_All DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procHpHighSalaryJobNewSelect] Script Date: 2018/12/13 19:10:38 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- /***
- *Peter 2016-9-1
- *首页高薪职位查询
- *
- */
- CREATE PROCEDURE [dbo].[procHpHighSalaryJobNewSelect]
- (
- @dcSubSiteID SMALLINT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- SELECT TOP 10 a.*, b.dcRegionID JobRegionID, b.dcSalaryIdMax,b.Negotiable
- FROM HpHighSalaryJobNew a WITH(NOLOCK), Job b WITH(NOLOCK)
- WHERE a.JobID = b.ID AND a.dcRegionID = @dcSubSiteID
- ORDER BY JobRefreshDate DESC, ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procHpHighSalaryJobNewUpdate] Script Date: 2018/12/13 19:10:39 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procHpHighSalaryJobNewUpdate]
- AS
- SET NOCOUNT ON
- BEGIN
- UPDATE a SET a.RefreshDate = b.RefreshDate
- FROM hpHighSalaryCompanyNew a, cpMain b
- WHERE a.cpMainId = b.Id AND a.RefreshDate != b.RefreshDate
- UPDATE hpHighSalaryCompanyNew SET RowNo = 999 WHERE RowNo < 20
- UPDATE a
- SET a.RowNo = b.RowNo2
- FROM hpHighSalaryCompanyNew a,
- (SELECT Id, ROW_NUMBER() OVER(PARTITION BY dcRegionId ORDER BY RefreshDate DESC, cpMainId DESC) RowNo2 FROM hpHighSalaryCompanyNew WITH(NOLOCK) WHERE LogoUrl > '') b
- WHERE a.id = b.Id
- AND b.RowNo2 < 20
- TRUNCATE TABLE HpHighSalaryJobNew;
- INSERT INTO HpHighSalaryJobNew(dcRegionID, JobID, JobSecondID, JobName, CpMainID, CpSecondID, CpName, dcSalaryID, JobRefreshDate, LogoUrl)
- SELECT dcRegionID, JobId, JobSecondID, JobName, CpMainID, CpSecondID, CpName, dcSalaryID, RefreshDate, LogoUrl
- FROM hpHighSalaryCompanyNew
- WHERE RowNo < 19
- ORDER BY dcRegionId, RowNo;
- IF GETDATE() < CONVERT(DATETIME, '2018-04-25')
- BEGIN
- IF EXISTS(SELECT 'x' FROM HpHighSalaryJobNew WITH(NOLOCK) WHERE cpMainId = 5654050)
- UPDATE HpHighSalaryJobNew SET JobRefreshDate = GETDATE() + 1 WHERE cpMainId = 5654050
- ELSE
- INSERT INTO HpHighSalaryJobNew(dcRegionID, JobID, JobSecondID, JobName, CpMainID, CpSecondID, CpName, dcSalaryID, JobRefreshDate, LogoUrl)
- SELECT dcRegionID, JobId, JobSecondID, JobName, CpMainID, CpSecondID, CpName, dcSalaryID, GETDATE() + 1, LogoUrl
- FROM hpHighSalaryCompanyNew
- WHERE cpMainId = 5654050
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[procHpHighSalaryJobSelect] Script Date: 2018/12/13 19:10:40 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- /***
- *Peter 2016-9-1
- *首页高薪职位查询
- *
- */
- CREATE PROCEDURE [dbo].[procHpHighSalaryJobSelect]
- (
- @dcSubSiteID SMALLINT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- SELECT a.*, b.dcRegionID JobRegionID
- FROM HpHighSalaryJob a WITH(NOLOCK), Job b WITH(NOLOCK)
- WHERE a.JobID = b.ID AND a.dcRegionID = @dcSubSiteID
- ORDER BY ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procHpHighSalaryJobUpdate] Script Date: 2018/12/13 19:10:40 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- /***
- *Peter 2016-9-1
- *首页高薪职位更新
- *
- */
- CREATE PROCEDURE [dbo].[procHpHighSalaryJobUpdate]
- AS
- SET NOCOUNT ON
- BEGIN
- UPDATE a SET a.RefreshDate = b.RefreshDate FROM hpHighSalaryCompany a, cpMain b WHERE a.cpMainId = b.Id AND a.RefreshDate != b.RefreshDate
- UPDATE hpHighSalaryCompany SET RowNo = 0 WHERE RowNo < 20
- UPDATE a
- SET a.RowNo = b.RowNo2
- FROM hpHighSalaryCompany a,
- (SELECT Id, ROW_NUMBER() OVER(PARTITION BY dcRegionId ORDER BY RefreshDate DESC, cpMainId DESC) RowNo2 FROM hpHighSalaryCompany WITH(NOLOCK) WHERE LogoUrl > '') b
- WHERE a.id = b.Id
- AND b.RowNo2 < 7
- UPDATE a
- SET a.RowNo = 10 + b.RowNo2
- FROM hpHighSalaryCompany a,
- (SELECT Id, ROW_NUMBER() OVER(PARTITION BY dcRegionId ORDER BY RefreshDate DESC, cpMainId DESC) RowNo2 FROM hpHighSalaryCompany WITH(NOLOCK) WHERE RowNo = 0) b
- WHERE a.id = b.Id
- TRUNCATE TABLE HpHighSalaryJob
- INSERT INTO hpHighSalaryJob(dcRegionID, JobID, JobSecondID, JobName, CpMainID, CpSecondID, CpName, dcSalaryID, JobRefreshDate, LogoUrl)
- SELECT dcRegionID, JobId, JobSecondID, JobName, CpMainID, CpSecondID, CpName, dcSalaryID, RefreshDate, CASE WHEN RowNo < 10 THEN LogoUrl ELSE NULL END
- FROM hpHighSalaryCompany
- WHERE RowNo < 19
- ORDER BY dcRegionId, RowNo
- -- --=========================
- -- CREATE TABLE #t2(
- -- dcRegionId INT,
- -- dcJobtypeId [varchar](4) NULL,
- -- cpMainId INT,
- -- cpSecondID [varchar](10) NULL,
- -- ImgFile [varchar](50) NOT NULL
- -- )
- -- INSERT INTO #T2
- -- SELECT dcRegionId, dcJobtypeId, cpMainId, cpSecondID, ImgFile
- -- FROM (
- -- SELECT a.dcProvinceid dcRegionId,
- -- LEFT(b.dcJobTypeId, 2) dcJobtypeId,
- -- a.Id cpMainId,
- -- a.SecondID cpSecondID,
- -- c.ImgFile,
- -- ROW_NUMBER() OVER(PARTITION BY a.dcProvinceid, LEFT(b.dcJobTypeId, 2) ORDER BY a.RefreshDate DESC, a.Id DESC) Row
- -- FROM cpMainPubLish a, JobPublish b, cpImage c
- -- WHERE a.Id = b.cpMainId
- -- AND a.Id = c.cpMainId
- -- AND c.Imgtype = 1
- -- AND b.RefreshDate > DATEADD(MINUTE, - 3, GETDATE())) a
- -- WHERE a.Row = 1
- -- ORDER BY dcRegionId, dcJobtypeId
- --
- -- DELETE a
- -- FROM HpJobTypeCpLogo a, #T2 b
- -- WHERE a.dcRegionId = b.dcRegionId AND a.dcJobtypeId = b.dcJobTypeId
- --
- -- INSERT INTO HpJobTypeCpLogo(dcRegionID,dcJobTypeID,CpMainID,CpSecondID,LogoUrl)
- -- SELECT dcRegionID, dcJobtypeId, cpMainId,cpSecondID, ImgFile
- -- FROM #T2
- END
- GO
- /****** Object: StoredProcedure [dbo].[procHpJobNewsByDetailTypeSelect] Script Date: 2018/12/13 19:10:40 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:获取某类N条资讯
- --#####################################################
- CREATE PROCEDURE [dbo].[procHpJobNewsByDetailTypeSelect]
- (
- @newsNumber INT,
- @detailType INT,
- @provinceID INT
- )
- AS
- BEGIN
- DECLARE @SQL VARCHAR(MAX)
- SET @SQL = 'SELECT TOP ' + CONVERT(VARCHAR(20),@newsNumber) + ' * '
- SET @SQL = @SQL+' FROM HpJobNews WITH(NOLOCK)'
- SET @SQL = @SQL+' WHERE DetailType = '+CONVERT(VARCHAR(20),@detailType)
- SET @SQL = @SQL+' AND VersionId = '+CONVERT(VARCHAR(20),@provinceID)
- SET @SQL = @SQL+' ORDER BY RefreshDate DESC '
- EXEC(@SQL)
- END
- GO
- /****** Object: StoredProcedure [dbo].[procHpJobTypeCpLogoSelect] Script Date: 2018/12/13 19:10:40 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- /***
- *Peter 2016-9-1
- *首页职位类别Logo查询
- *
- */
- CREATE PROCEDURE [dbo].[procHpJobTypeCpLogoSelect]
- (
- @dcSubSiteID SMALLINT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- SELECT *
- FROM HpJobTypeCpLogo WITH(NOLOCK)
- WHERE dcRegionID = @dcSubSiteID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procHpJobTypeinfoByRegionID24Select] Script Date: 2018/12/13 19:10:40 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:根据职位数量获取最多的职位类别
- --#####################################################
- CREATE PROCEDURE [dbo].[procHpJobTypeinfoByRegionID24Select]
- (
- @dcRegionID INT
- )
- AS
- BEGIN TRY
- SELECT TOP 24 dcJobTypeID,Description
- FROM hpJobTypeInfo a, dcJobType b
- WHERE a.dcJobTypeID=b.ID
- AND a.dcRegionID=@dcRegionID
- AND LEN(dcJobTypeID) = 4
- ORDER BY JobNum DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procHpJobTypeinfoByRegionIDSelect] Script Date: 2018/12/13 19:10:42 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:添加获取职位类型左侧导航数据
- --修改:harry2015-8-18
- --增加c.orderNo
- --#####################################################
- CREATE PROCEDURE [dbo].[procHpJobTypeinfoByRegionIDSelect]
- (
- @dcRegionID INT
- )
- AS
- BEGIN
- SELECT TOP 1000 a.dcJobTypeId JobTypeID,a.JobNum JobNumber,b.CategoryId,c.parentID,c.grade,
- c.description,c.parentID2,c.parentID3,c.OrderNo
- FROM hpjobtypeinfo a
- LEFT JOIN dcJobTypeMap b ON b.JobTypeId=a.dcJobtypeid
- LEFT JOIN dcJobType c ON c.id=a.dcJobTypeid
- WHERE a.dcRegionID = @dcRegionID
- ORDER BY c.OrderNo,b.OrderBy
- END
- GO
- /****** Object: StoredProcedure [dbo].[procHpJobTypeInfoUpdate] Script Date: 2018/12/13 19:10:42 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- /**
- *创建 Peter
- *时间 2013-01-09 15:51
- *作用 首页左侧职位索引区域职位数量更新
- **/
- CREATE PROCEDURE [dbo].[procHpJobTypeInfoUpdate]
- AS
- SET NOCOUNT ON
- BEGIN
- TRUNCATE TABLE LogDb..hpJobTypeInfo
- CREATE TABLE #T(
- dcJobTypeID INT,
- dcRegionID INT,
- JobNum INT
- )
- DELETE hpJobTypeInfo WHERE dcRegionId NOT IN(SELECT ID FROM dcSubSite)
- DELETE hpJobTypeInfo WHERE dcJobTypeId NOT IN(SELECT ID FROM dcJobType)
- INSERT INTO #T SELECT a.ID, b.Id, 0 FROM dcJobType a, dcSubSite b
- DELETE #t FROM hpJobTypeInfo a WHERE #t.dcJobTypeId = a.dcJobTypeId AND a.dcRegionId = #t.dcRegionId
- INSERT hpJobTypeInfo SELECT dcJobTypeID, dcRegionID, 0, GETDATE() FROM #t
- TRUNCATE TABLE #t
- INSERT INTO #T
- SELECT dcJobTypeId, LEFT(dcRegionId, 4), COUNT(*)
- FROM JobPublish WITH(NOLOCK)
- WHERE Valid = 1
- GROUP BY dcJobTypeId, LEFT(dcRegionId, 4)
- SELECT LEFT(dcJobTypeId, 2) dcJobTypeID, dcRegionID, SUM(JobNum) JobNum
- INTO #tt
- FROM #t
- GROUP BY LEFT(dcJobTypeId, 2), dcRegionID
- DELETE #t WHERE dcJobTypeId < 99
- INSERT #t SELECT * FROM #tt
-
- TRUNCATE TABLE #tt
- INSERT INTO #tt
- SELECT dcJobTypeId, LEFT(dcRegionID, 2), SUM(JobNum) JobNum
- FROM #t
- GROUP BY dcJobTypeId, LEFT(dcRegionID, 2)
- DELETE #t WHERE dcRegionId < 99
- INSERT #t SELECT * FROM #tt
- UPDATE hpJobTypeInfo SET JobNum = 0
- UPDATE a
- SET a.ModifyDate = GETDATE(), a.JobNum = b.JobNum
- FROM hpJobTypeInfo a, #t b
- WHERE a.dcRegionId = b.dcRegionId AND a.dcJobTypeId = b.dcJobTypeId
- DROP TABLE #T
- DROP TABLE #TT
- END
- GO
- /****** Object: StoredProcedure [dbo].[prochpNewsSetByProvinceIDSelect] Script Date: 2018/12/13 19:10:42 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:取新首页职场新闻模块的显示
- --#####################################################
- CREATE PROCEDURE [dbo].[prochpNewsSetByProvinceIDSelect]
- (
- @ProvinceID INT
- )
- AS
- BEGIN TRY
- SELECT Section FROM hpNewsSet WHERE dcProvinceID=@ProvinceID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[prociIvgt_AnswerSumByQuestionIDSelect] Script Date: 2018/12/13 19:10:42 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:NICK
- --说明:获得调查的点击总数
- --#####################################################
- CREATE PROCEDURE [dbo].[prociIvgt_AnswerSumByQuestionIDSelect]
- (
- @QuesionID INT
- )
- AS
- BEGIN
- SELECT SUM(clicknum) cnt FROM ivgt_answer WITH(NOLOCK) WHERE questionid=@QuesionID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcIncludeRateSelect] Script Date: 2018/12/13 19:10:43 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcIncludeRateSelect]
- (
- @ProvinceID INT, ----网站省份编号
- @CatalogID INT, ----目录编号(1、职位页面;2、公司页面;3、招聘会页面4、求职互助页面;5、职场新闻页面;6、职位地图页面;7、校园招聘页面)
- @GenerateStartDate DATETIME, ----生成开始时间
- @GenerateEndDate DATETIME, ----生成结束时间
- @FlashStartDate DATETIME, ----刷新开始时间
- @FlashEndDate DATETIME, ----刷新结束时间
- @Percentage DECIMAL(18, 4), ----百分比 (例0.1 百分之十)
- @SortID INT, -----排序 (1、正序;2、倒序;3、随机)
- @Type INT ------0,存储过程返回页面的数量;1、返回页面信息
- )
- AS
- BEGIN
- DECLARE @t AS TABLE(ID INT, Date DATETIME, Rnd VARCHAR(100))
- DECLARE @Cnt AS INT, @p AS VARCHAR(4)
- SELECT @GenerateStartDate = ISNULL(@GenerateStartDate, '2000-1-1'),
- @GenerateEndDate = ISNULL(@GenerateEndDate, GETDATE()),
- @FlashStartDate = ISNULL(@GenerateStartDate, '2000-1-1'),
- @FlashEndDate = ISNULL(@GenerateEndDate, GETDATE()),
- @p = CONVERT(VARCHAR, @ProvinceID)
-
- IF (@CatalogID = 1)
- BEGIN
- INSERT INTO @t(ID, Date)
- SELECT ID, RefreshDate FROM Job WITH(NOLOCK)
- WHERE AddDate BETWEEN @GenerateStartDate AND @GenerateEndDate
- AND RefreshDate BETWEEN @FlashStartDate AND @FlashEndDate
- AND cpMainID IN(SELECT ID FROM cpMain WITH(NOLOCK) WHERE dcSUbSiteId LIKE @p + '%')
- END
- ELSE IF (@CatalogID = 2)
- BEGIN
- INSERT INTO @t(ID, Date)
- SELECT ID, RefreshDate FROM cpMain WITH(NOLOCK)
- WHERE RegDate BETWEEN @GenerateStartDate - 2 AND @GenerateEndDate - 2
- AND RefreshDate BETWEEN @FlashStartDate AND @FlashEndDate
- AND MemberType > 0
- AND dcSubSiteId LIKE @p + '%'
- END
- ELSE IF (@CatalogID = 3)
- BEGIN
- INSERT INTO @t(ID, Date)
- SELECT ID, AddDate FROM RecruitMent WITH(NOLOCK)
- WHERE AddDate BETWEEN @GenerateStartDate AND @GenerateEndDate
- AND CityId LIKE @p + '%'
- END
- ELSE IF (@CatalogID = 4)
- BEGIN
- INSERT INTO @t(ID, Date)
- SELECT ID, AddDate FROM bsAskInfo WITH(NOLOCK)
- WHERE AddDate BETWEEN @GenerateStartDate AND @GenerateEndDate
- AND ProvinceIds LIKE '%,%' + @p + ',%'
- END
- ELSE IF (@CatalogID = 5)
- BEGIN
- INSERT INTO @t(ID, Date)
- SELECT ID, AnnounceDate FROM QlrcNews WITH(NOLOCK)
- WHERE AnnounceDate BETWEEN @GenerateStartDate AND @GenerateEndDate
- AND VersionId LIKE @p + '%'
- END
- SELECT @Cnt = COUNT(*) FROM @t
- IF @Cnt = 0
- BEGIN
- SELECT 0
- RETURN
- END
- ELSE IF @Type = 0 OR @Percentage = 0
- SELECT @Cnt
- ELSE
- BEGIN
- DECLARE @FetchNumber AS INT
- SELECT @FetchNumber = @Cnt * @Percentage
- IF @FetchNumber = 0
- BEGIN
- SELECT 0
- RETURN
- END
- IF @SortID = 3 ----随机
- BEGIN
- UPDATE @t SET Rnd = NewId()
- SELECT TOP (@FetchNumber) ID FROM @t ORDER BY Rnd
- END
- ELSE
- BEGIN
- IF @CatalogID IN(1, 2) AND @FlashStartDate > '2001-1-1'
- BEGIN
- IF @SortID = 1
- SELECT TOP (@FetchNumber) ID FROM @t ORDER BY Date
- IF @SortID = 2
- SELECT TOP (@FetchNumber) ID FROM @t ORDER BY Date DESC
- END
- ELSE
- BEGIN
- IF @SortID = 1 ----正序
- SELECT TOP (@FetchNumber) ID FROM @t ORDER BY ID
- IF @SortID = 2 ----倒序
- SELECT TOP (@FetchNumber) ID FROM @t ORDER BY ID DESC
- END
- END
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[procInfo_datereportUpdate] Script Date: 2018/12/13 19:10:43 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procInfo_datereportUpdate]
- (
- @province_id SMALLINT,
- @infomanager_id SMALLINT,
- @ip VARCHAR(15),
- @referer VARCHAR(100),
- @result SMALLINT OUTPUT
- )
- AS
- BEGIN
- SET NOCOUNT ON
- SELECT TOP 1 countdate
- FROM info_datereport WITH(NOLOCK)
- WHERE countdate=YEAR(GETDATE())*10000+MONTH(GETDATE())*100+DAY(GETDATE())
- AND province_id = @province_id
- AND infomanager_id=@infomanager_id
- IF (@@ROWCOUNT=0)
- BEGIN
- INSERT INTO info_datereport (province_id,infomanager_id,countdate)
- VALUES(@province_id,@infomanager_id,YEAR(GETDATE())*10000+MONTH(GETDATE())*100+day(GETDATE()))
- END
- SELECT TOP 1 adddate
- FROM infolog WITH(NOLOCK)
- WHERE adddate > GETDATE()-1
- AND infomanager_id = @infomanager_id
- AND ip = @ip
- AND Ip NOT LIKE '60.215.144%'
- IF (@@ROWCOUNT=0)
- BEGIN
- UPDATE info_datereport SET homepage = homepage + 1
- WHERE countdate=YEAR(GETDATE())*10000+MONTH(GETDATE())*100+DAY(GETDATE())
- AND province_id = @province_id
- AND infomanager_id=@infomanager_id
- INSERT INTO infolog (infomanager_id,ip,referer) VALUES(@infomanager_id,@ip,@referer)
- SET @result=1
- END
- ELSE
- BEGIN
- SET @result=0
- END
- --PRINT @result
- SET NOCOUNT OFF
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcInfoLogInsert] Script Date: 2018/12/13 19:10:44 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.31
- --创建人:John
- --说明:新增InfoLog
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcInfoLogInsert]
- (
- @InfoId SMALLINT,
- @IP VARCHAR(15),
- @Source VARCHAR(200),
- @SubSiteID SMALLINT
- )
- AS
- BEGIN
- INSERT INTO reportdb..InfoLog(InfoId,IP,Source,SubSiteID,AddDate) VALUES(@InfoId,@IP,@Source,@SubSiteID,GETDATE())
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcInfoSetByKeySelect] Script Date: 2018/12/13 19:10:44 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.31
- --创建人:John
- --说明:根据Key查InfoSet
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcInfoSetByKeySelect]
- (
- @InfoKey VARCHAR(200)
- )
- AS
- BEGIN
- SELECT * FROM reportdb..InfoSet WITH(NOLOCK) WHERE InfoKey = @InfoKey
- END
- GO
- /****** Object: StoredProcedure [dbo].[procInnererInsert] Script Date: 2018/12/13 19:10:44 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procInnererInsert]
- (
- @province_id SMALLINT,
- @VersionID SMALLINT,
- @referer VARCHAR(190),
- @ip VARCHAR(15),
- @keyve NVARCHAR(50),
- @innerpage SMALLINT
- )
- AS
- BEGIN
- SET NOCOUNT ON
- SELECT TOP 1 ip
- FROM Innerer WITH(INDEX=IX_Innerer_VersionID, NOLOCK)
- WHERE VersionID = @VersionID
- AND referer=@referer
- AND ip=@ip
- AND LoginDate > DATEADD(MINUTE, -10, GETDATE())
- IF (@@ROWCOUNT = 0)
- BEGIN
- INSERT INTO Innerer(province_id,VersionID,referer,ip,keywords,innerpage)
- VALUES(ISNULL(@province_id, 0), ISNULL(@VersionID, 0),@referer,@ip,@keyve,@innerpage)
- END
- SET NOCOUNT OFF
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcInterViewByCpMainIDSelect] Script Date: 2018/12/13 19:10:44 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.20
- --创建人:Nick
- --说明:根据公司ID获取 面试经历信息,以及平均分
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcInterViewByCpMainIDSelect]
- (
- @CpMainID INT,
- @SessionID VARCHAR(50),
- @PamainID INT
- )
- AS
- BEGIN
- IF @PamainID <> 0
- BEGIN
- SELECT * FROM InterView
- WHERE CpMainID = @CpMainID
- AND InterViewType<>3
- AND (VerifyDate IS NOT NULL OR PaMainID = @PamainID)
- ORDER BY ADDDATE DESC
- END
- ELSE
- BEGIN
- -- IF @SessionID<>''
- -- BEGIN
- -- SELECT * FROM InterView
- -- WHERE CpMainID = @CpMainID
- -- AND InterViewType<>3
- -- AND (VerifyDate IS NOT NULL OR (PaMainID = 0 AND SessionID = @SessionID))
- -- ORDER BY ADDDATE DESC
- -- END
- -- ELSE
- -- BEGIN
- SELECT * FROM InterView
- WHERE CpMainID = @CpMainID
- AND InterViewType<>3
- AND VerifyDate IS NOT NULL
- ORDER BY ADDDATE DESC
- -- END
- END
- End
- GO
- /****** Object: StoredProcedure [dbo].[ProcInterViewByID] Script Date: 2018/12/13 19:10:44 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.24
- --创建人:Nick
- --说明:根据ID获取面试经历信息
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcInterViewByID]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT * FROM InterView WHERE ID = @ID
- End
- GO
- /****** Object: StoredProcedure [dbo].[ProcInterviewByIDUpdate] Script Date: 2018/12/13 19:10:45 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.19
- --创建人:Nick
- --说明:根据ID修改面试信息
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcInterviewByIDUpdate]
- (
- @ID INT,
- @JobName VARCHAR(50),
- @InterviewDate VARCHAR(6),
- @InterViewResult INT,
- @SalaryMonth INT,
- @InterViewExperience NVARCHAR(MAX),
- @InterviewFeeling NVARCHAR(MAX),
- @Title NVARCHAR(50),
- @VerifyMan INT,
- @InterviewType INT
- )
- AS
- SET NOCOUNT ON
- BEGIN TRY
- DECLARE @AddDate DATETIME,@CpName NVARCHAR(100),@Title2 NVARCHAR(50)
- SELECT @AddDate = a.AddDate,@CpName = b.Name,@Title2 = a.Title
- FROM Interview a,Cpmain b
- WHERE a.ID = @ID
- AND a.CpMainID = b.ID
- UPDATE Interview
- SET JobName = @JobName,
- InterviewDate = @InterviewDate,
- InterViewResult = @InterViewResult,
- SalaryMonth = @SalaryMonth,
- InterViewExperience = @InterViewExperience,
- InterviewFeeling = @InterviewFeeling,
- Title = @Title,
- VerifyMan = @VerifyMan,
- VerifyDate = GETDATE(),
- InterviewType = @InterviewType
- WHERE CpMainID IN (SELECT ID FROM cpMain WITH(NOLOCK) WHERE Name = @CpName)
- AND AddDate = @AddDate
- AND Title = @Title2
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcInterViewByKeyWordSelect] Script Date: 2018/12/13 19:10:45 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --###########################
- --创建时间:2014.11.27
- --创建人:Nick
- --说明:获取面试经历公司列表
- --###########################
- CREATE PROCEDURE [dbo].[ProcInterViewByKeyWordSelect]
- (
- @dcRegionID VARCHAR(100),
- @PageNo INT,
- @KeyWord VARCHAR(50)
- )
- AS
- BEGIN
- DECLARE @WHERE VARCHAR(MAX),@JobPlace AS VARCHAR(2000),@WHERE2 VARCHAR(MAX)
- SET @JobPlace = ''
- SET @WHERE = ''
- SET @WHERE2 = ''
-
- IF CHARINDEX(',',@dcRegionID)>0
- BEGIN
- DECLARE @T_JobPlace AS TABLE(ID INT)
- INSERT INTO @T_JobPlace
- SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
-
- SELECT @JobPlace = (@JobPlace + ' OR b.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
-
- IF LEN(@JobPlace) > 0
- SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
- SET @WHERE = @WHERE + '
- AND (' + @JobPlace + ')'
- SET @WHERE2 = @WHERE2 + '
- AND (' + @JobPlace + ')'
- END
- ELSE
- BEGIN
- SET @WHERE = ' AND (b.dcRegionID Like '''+@dcRegionID+'%'')'
- SET @WHERE2 = ' AND (b.dcRegionID Like '''+@dcRegionID+'%'')'
- END
-
- SET @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, ''))
-
- IF @KeyWord <> ''
- BEGIN
- SET @WHERE = @WHERE + ' AND b.Name LIKE ''%'+@KeyWord+'%'' '
- END
-
- DECLARE @PageSize INT
- SET @PageSize = 5
- DECLARE @PageLowerBound INT --定义此页的底码
- DECLARE @PageUpperBound INT --定义此页的顶码
- SET @PageLowerBound = (@PageNo -1) * @pagesize
- SET @PageUpperBound = @PageLowerBound + @pagesize
-
- DECLARE @AllCnt INT
- SET @AllCnt = 0
- DECLARE @SQL NVARCHAR(MAX)
-
- --创建临时表
- CREATE TABLE #T1(
- [cpmainid] [int] NOT NULL,
- [name] [varchar](100) NULL,
- [secondid] varchar(12) NULL,
- [AddDate] [datetime] NULL,
- [OrderBY] [int] NULL
- )
- IF @KeyWord = ''
- BEGIN
- SET @SQL = '
- INSERT INTO #T1
- SELECT TOP 500 cpmainid,b.name,b.secondid,a.AddDate,1 AS OrderBY
- FROM InterView a,cpmain b
- WHERE a.id IN(SELECT MAX(id) FROM InterView GROUP BY cpmainid)
- AND b.valid=1
- AND IsDirect=1
- AND a.cpmainid = b.id AND a.InterViewType IN(1,2) '+@WHERE+'
- ORDER BY a.adddate DESC '
- EXEC(@SQL)
- END
- ELSE
- BEGIN
- SET @SQL = '
- INSERT INTO #T1
- SELECT TOP 500 b.ID AS cpmainid,b.Name, b.SecondId, LastLoginDate AS AddDate,1 AS OrderBY
- FROM cpMainPublish b WITH(NOLOCK),
- CONTAINSTABLE(cpMainPublish, Name, '''+@KeyWord+''', 100) AS a
- WHERE b.Id = a.[Key] '+@WHERE2+'
- AND b.valid=1
- ORDER BY b. LastLoginDate DESC '
- PRINT(@SQL)
- EXEC(@SQL)
- IF NOT EXISTS(SELECT 'x' FROM #T1)
- BEGIN
- SET @SQL = '
- INSERT INTO #T1
- SELECT TOP 500 b.ID AS cpmainid,b.Name, b.SecondId, LastLoginDate AS AddDate,1 AS OrderBY
- FROM cpMainPublish b WITH(NOLOCK INDEX(IX_cpMainPublish_Name))
- WHERE 1=1 '+@WHERE+'
- AND b.valid=1
- ORDER BY b. LastLoginDate DESC '
- PRINT(@SQL)
- EXEC(@SQL)
- END
- END
-
- DELETE FROM #T1 WHERE cpmainid NOT IN (SELECT Max(cpMainID) FROM #T1 GROUP BY name)
- SELECT @AllCnt = COUNT(*) FROM #T1
-
- IF @KeyWord <> '' --对临时表 #T1 进行排序 修改最后点评时间
- BEGIN
- UPDATE a
- SET a.AddDate = b.AddDate,a.OrderBY = b.OrderBY
- FROM #T1 a,(
- SELECT AddDate,CpMainID,2 AS OrderBy
- FROM InterView
- WHERE ID IN(SELECT MAX(id) FROM InterView GROUP BY cpmainid)
- ) b
- WHERE a.CpmainID = b.CpMainID
- END
-
- SELECT * ,ROW_NUMBER() OVER( ORDER BY OrderBY DESC,AddDate DESC) AS num INTO #T2 FROM #T1
-
- SELECT *,0 AS cnt,0 AS Score INTO #T3 FROM #T2 WHERE NUM > @PageLowerBound AND NUM <= @PageUpperBound
-
- --修改评价数量
- UPDATE a
- SET a.cnt = b.Num
- FROM #T3 a,(
- SELECT COUNT(*) AS num,CpMainID
- FROM InterView
- WHERE (InterViewType IN (1,2))
- AND CpMainID IN (SELECT CpMainID FROM #T3)
- GROUP BY CpMainID
- )b
- WHERE a.CpMainID = b.CpMainID
-
- --拷贝列
- CREATE TABLE #T5(
- [ID] [int] NOT NULL,
- [CpmainID] [int] NOT NULL,
- [PaMainID] [int] NOT NULL,
- [IP] [varchar](15) NOT NULL,
- [SessionID] [varchar](50) NULL,
- [JobName] [varchar](50) NOT NULL,
- [InterviewDate] [varchar](6) NOT NULL,
- [InterViewResult] [tinyint] NOT NULL,
- [SalaryMonth] [int] NULL,
- [InterViewExperience] [nvarchar](max) NOT NULL,
- [InterviewFeeling] [nvarchar](max) NOT NULL,
- [Title] [nvarchar](50) NOT NULL,
- [AddDate] [smalldatetime] NULL,
- [VerifyMan] [int] NULL,
- [VerifyDate] [smalldatetime] NULL,
- [InterviewType] [int] NULL,
- [ReplyDate] [smalldatetime] NULL,
- [ReplyContent] [nvarchar](max) NULL,
- [ReplyVerifyMan] [int] NULL,
- [ReplyVerifyDate] [smalldatetime] NULL,
- [ReplyVerifyResult] [tinyint] NULL,
- [PraiseCount] [int] NULL,
- [LoginPraiseCount] [int] NULL,
- [IsDirect] [BIT] NULL,
- [rid] [int] NULL
- )
-
- DECLARE @CpCnt INT --公司数量
- SELECT @CpCnt = COUNT(*) FROM #T3
- IF @CpCnt = 1
- BEGIN
- --取10条点评
- INSERT INTO #T5
- SELECT * FROM
- (
- SELECT *,rid=ROW_NUMBER() OVER(PARTITION BY a.CpmainID ORDER BY a.AddDate DESC)
- FROM InterView a
- WHERE (a.InterViewType IN (1,2))
- AND CpMainID IN (SELECT CpMainID FROM #T3)
- ) AS c
- WHERE c.rid<=10
- END
- ELSE
- BEGIN
- --取2条点评
- INSERT INTO #T5
- SELECT * FROM
- (
- SELECT *,rid=ROW_NUMBER() OVER(PARTITION BY a.CpmainID ORDER BY a.AddDate DESC)
- FROM InterView a
- WHERE (a.InterViewType IN (1,2))
- AND CpMainID IN (SELECT CpMainID FROM #T3)
- ) AS c
- WHERE c.rid<=2
- END
-
- SELECT * FROM #T3 --公司列表
-
- SELECT @AllCnt --所有公司数
-
- SELECT * FROM #T5 --点评数
-
- DROP TABLE #T5
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcInterViewByReplyUpdate] Script Date: 2018/12/13 19:10:45 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.20
- --创建人:Nick
- --说明:面试经历回复
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcInterViewByReplyUpdate]
- (
- @ID INT,
- @ReplyContent NVARCHAR(MAX)
- )
- AS
- BEGIN
- UPDATE InterView
- SET ReplyContent = @ReplyContent,
- ReplyDate = GETDATE() ,
- ReplyVerifyResult = NULL ,
- ReplyVerifyDate = NULL
- WHERE ID = @ID
- AND (ReplyVerifyResult <> 1 OR ReplyVerifyResult IS NULL)
- End
- GO
- /****** Object: StoredProcedure [dbo].[ProcInterViewCompanyListSelect] Script Date: 2018/12/13 19:10:45 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.27
- --创建人:Nick
- --说明:获取面试经历公司列表
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcInterViewCompanyListSelect]
- (
- @dcRegionID VARCHAR(100),
- @PageNo INT,
- @KeyWord VARCHAR(50)
- )
- AS
- BEGIN TRY
- DECLARE @WHERE VARCHAR(MAX),@JobPlace AS VARCHAR(2000)
- SET @JobPlace = ''
- SET @WHERE = ''
-
- IF CHARINDEX(',',@dcRegionID)>0
- BEGIN
- DECLARE @T_JobPlace AS TABLE(ID INT)
- INSERT INTO @T_JobPlace
- SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
-
- SELECT @JobPlace = (@JobPlace + ' OR b.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
-
- IF LEN(@JobPlace) > 0
- SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
- SET @WHERE = @WHERE + '
- AND (' + @JobPlace + ')'
- END
- ELSE
- BEGIN
- SET @WHERE = ' AND (b.dcRegionID Like '''+@dcRegionID+'%'')'
- END
-
- SET @KeyWord = dbo.SafeSQL(ISNULL(@KeyWord, ''))
-
- IF @KeyWord <> ''
- BEGIN
- SET @WHERE = @WHERE+' AND b.Name LIKE ''%'+@KeyWord+'%'' '
- END
-
- DECLARE @PageSize INT
- SET @PageSize = 5
- DECLARE @PageLowerBound INT --定义此页的底码
- DECLARE @PageUpperBound INT --定义此页的顶码
- SET @PageLowerBound = (@PageNo -1) * @pagesize
- SET @PageUpperBound = @PageLowerBound + @pagesize
-
- DECLARE @AllCnt INT
- SET @AllCnt = 0
- DECLARE @SQL NVARCHAR(MAX)
- SET @SQL = N'
- SELECT @All = COUNT(DISTINCT CpMainID)
- FROM InterView a,Cpmain b
- WHERE (a.InterViewType IN (1,2))
- AND a.id IN(SELECT MAX(id) FROM InterView GROUP BY cpmainid)
- AND a.CpMainID = b.ID
- '+@WHERE
- print('123')
- exec sp_executesql @SQL,N'@All INT output',@AllCnt output
- IF @AllCnt>500
- BEGIN
- SET @AllCnt = 500
- END
-
- SET @SQL = '
- SELECT TOP 500 cpmainid,b.name,b.secondid,a.AddDate INTO ##T1
- FROM InterView a,cpmain b
- WHERE a.id IN(SELECT MAX(id) FROM InterView GROUP BY cpmainid)
- AND a.cpmainid = b.id AND a.InterViewType IN (1,2)'+@WHERE+'
- ORDER BY a.adddate DESC '
- print(@SQL)
- EXEC(@SQL)
-
- SELECT * ,ROW_NUMBER() OVER( ORDER BY AddDate DESC) AS num INTO #T2 FROM ##T1
- SELECT *,0 AS cnt INTO #T3 FROM #T2 WHERE NUM > @PageLowerBound AND NUM <= @PageUpperBound
- --修改评价数量
- UPDATE a
- SET a.cnt = b.Num
- FROM #T3 a,(
- SELECT COUNT(*) AS num,CpMainID
- FROM InterView
- WHERE (InterViewType IN (1,2))
- AND CpMainID IN (SELECT CpMainID FROM #T3)
- GROUP BY CpMainID
- )b
- WHERE a.CpMainID = b.CpMainID
-
- SELECT * FROM #T3
-
- SELECT @AllCnt
- SELECT * FROM
- (
- SELECT rid=ROW_NUMBER() OVER(PARTITION BY a.CpmainID ORDER BY a.AddDate DESC),*
- FROM InterView a
- WHERE (a.InterViewType IN (1,2))
- AND CpMainID IN (SELECT CpMainID FROM #T3)
- ) AS c
- WHERE c.rid<=2
-
- DROP TABLE ##T1
- END TRY
- BEGIN CATCH
- DROP TABLE ##T1
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcInterViewHotSelect] Script Date: 2018/12/13 19:10:46 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.27
- --创建人:Nick
- --说明:获取最多面经排行 最佳面经排行
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcInterViewHotSelect]
- (
- @ProvinceID INT
- )
- AS
- BEGIN
- --最多面经排行
- SELECT * FROM SearchDB..CommentsHot
- WHERE CommentType = 2
- AND TypeID = 1
- AND dcProvinceID = @ProvinceID
- ORDER BY Cnt DESC
-
- --最佳点评排行
- SELECT * FROM SearchDB..CommentsHot
- WHERE CommentType = 2
- AND TypeID = 2
- AND dcProvinceID = @ProvinceID
- ORDER BY Cnt DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcInterViewInsert] Script Date: 2018/12/13 19:10:46 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.20
- --创建人:Nick
- --说明:插入面试经历
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcInterViewInsert]
- (
- @CpmainID INT,
- @PaMainID INT,
- @IP VARCHAR(15),
- @SessionID VARCHAR(50),
- @JobName NVARCHAR(50),
- @InterviewDate VARCHAR(6),
- @InterViewResult INT,
- @SalaryMonth INT,
- @InterViewExperience NVARCHAR(MAX),
- @InterviewFeeling NVARCHAR(MAX),
- @Title NVARCHAR(50)
- )
- AS
- BEGIN
- DECLARE @MemberType INT
- SELECT @MemberType = MemberType FROM CpMain WHERE ID = @CpmainID
- IF @MemberType > 1
- BEGIN
- INSERT INTO InterView (CpmainID,PaMainID,IP,SessionID,JobName,InterviewDate,InterViewResult,SalaryMonth,
- InterViewExperience,InterviewFeeling,Title,AddDate,PraiseCount,LoginPraiseCount,InterviewType,IsDirect)
- SELECT ID,@PaMainID,@IP,@SessionID,@JobName,@InterviewDate,@InterViewResult,@SalaryMonth,
- @InterViewExperience,@InterviewFeeling,@Title,GETDATE(),0,0,0,0
- FROM CPMAIN
- WHERE NAME = (
- SELECT Name FROM CpMain WHERE ID = @CpmainID)
- AND MemberType > 1
- AND ID <> @CpmainID
- END
-
- INSERT INTO InterView (CpmainID,PaMainID,IP,SessionID,JobName,InterviewDate,InterViewResult,SalaryMonth,
- InterViewExperience,InterviewFeeling,Title,AddDate,PraiseCount,LoginPraiseCount,InterviewType,IsDirect)
- VALUES(@CpmainID,@PaMainID,@IP,@SessionID,@JobName,@InterviewDate,@InterViewResult,@SalaryMonth,
- @InterViewExperience,@InterviewFeeling,@Title,GETDATE(),0,0,0,1)
- End
- GO
- /****** Object: StoredProcedure [dbo].[ProcInterviewRecordByCaMainIDSelect] Script Date: 2018/12/13 19:10:46 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.29
- --创建人:John
- --说明:获取企业面试大厅的记录
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcInterviewRecordByCaMainIDSelect]
- (
- @caMainID INT
- )
- AS
- BEGIN
- SELECT a.*,c.Name paName,d.Name caName
- FROM ViInterviewRecord a
- LEFT JOIN viRoom b ON b.ID = a.viRoomID
- LEFT JOIN paMain c ON c.ID = a.paMainID
- LEFT JOIN caMain d ON d.ID = b.caMainID
- WHERE a.Begindate IS NOT NULL
- AND b.caMainID = @caMainID
- ORDER BY a.Id DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcInterviewReplyByIDUpdate] Script Date: 2018/12/13 19:10:46 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.18
- --创建人:Nick
- --说明:根据ID修改面试回复信息
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcInterviewReplyByIDUpdate]
- (
- @ID INT,
- @ReplyContent NVARCHAR(MAX),
- @ReplyVerifyMan INT,
- @ReplyVerifyResult INT
- )
- AS
- BEGIN
- UPDATE Interview
- SET ReplyContent = @ReplyContent,
- ReplyVerifyMan = @ReplyVerifyMan,
- ReplyVerifyDate = GETDATE(),
- ReplyVerifyResult = @ReplyVerifyResult
- WHERE ID = @ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcInterviewSelect] Script Date: 2018/12/13 19:10:47 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.18
- --创建人:Nick
- --说明:查询 面试经历信息 用于后台审核
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcInterviewSelect]
- (
- @Type INT, --1 待审核 面试经历 2 最近审核 面试经历 3待审核面试经历回复 4最近审核 面试经历回复
- @Where VARCHAR(MAX)
- )
- AS
- BEGIN
- DECLARE @SQL VARCHAR(MAX)
- IF @Type = 1
- BEGIN
- SET @SQL = '
- SELECT a.*,b.name AS CpName ,b.RegDate,
- CASE a.PamainID
- WHEN 0 THEN IP
- ELSE (SELECT Name FROM PaMain WHERE ID = a.PaMainID)
- END AS PaName
- FROM Interview a,CpMain b
- WHERE VerifyDate IS NULL
- AND a.IsDirect = 1
- AND a.CpMainID = b.ID '+@Where+'
- ORDER BY AddDate DESC '
- END
- ELSE IF @Type = 2
- BEGIN
- SET @SQL = '
- SELECT TOP 200 a.*,b.name AS CpName ,b.RegDate,
- CASE a.PamainID
- WHEN 0 THEN IP
- ELSE (SELECT Name FROM PaMain WHERE ID = a.PaMainID)
- END AS PaName
- FROM Interview a,CpMain b
- WHERE VerifyDate IS NOT NULL
- AND a.CpMainID = b.ID '+@Where+'
- ORDER BY VerifyDate DESC '
- END
- ELSE IF @Type = 3
- BEGIN
- SET @SQL = '
- SELECT a.*,b.name AS CpName ,b.RegDate,
- CASE a.PamainID
- WHEN 0 THEN IP
- ELSE (SELECT Name FROM PaMain WHERE ID = a.PaMainID)
- END AS PaName
- FROM Interview a,CpMain b
- WHERE ReplyVerifyDate IS NULL
- AND a.CpMainID = b.ID '+@Where+'
- ORDER BY ReplyDate DESC '
- END
- ELSE IF @Type = 4
- BEGIN
- SET @SQL = '
- SELECT TOP 200 a.*,b.name AS CpName ,b.RegDate,
- CASE a.PamainID
- WHEN 0 THEN IP
- ELSE (SELECT Name FROM PaMain WHERE ID = a.PaMainID)
- END AS PaName
- FROM Interview a,CpMain b
- WHERE ReplyVerifyDate IS NOT NULL
- AND a.CpMainID = b.ID '+@Where+'
- ORDER BY ReplyVerifyDate DESC '
- END
- EXEC(@SQL)
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcIp_BlackInsert] Script Date: 2018/12/13 19:10:47 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE procedure [dbo].[ProcIp_BlackInsert]
- AS
- BEGIN
- return
- SELECT top 0 * into #t from ip_black
- insert into #t
- select top 199 ip, 'sean add 0706', getdate(), 2, '大量访问' from synueolog with(nolock) where adddate > dateadd(minute, -60, getdate()) group by ip order by count(*) desc
- delete #t where ip in(select loginip from paloginlog where adddate > getdate() -1)
- delete #t where ip in(select loginip from caloginlog where adddate > getdate() -1)
- delete #t where ip in(select ip from ip_black)
- insert into ip_black
- select distinct ip,description,getdate(),type,remarks FROM #t order by ip
- delete a from ip_black a, ip_white b where charindex(b.ip, a.ip) > 0
- delete ip_black where ip in('218.201.144.184','111.16.244.80','27.204.87.36','223.96.158.225')
- END
- GO
- /****** Object: StoredProcedure [dbo].[procIp_BlackSelect] Script Date: 2018/12/13 19:10:47 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:ip黑名单
- --#####################################################
- CREATE PROCEDURE [dbo].[procIp_BlackSelect]
- AS
- BEGIN TRY
- SELECT * FROM ip_Black With(Nolock) ORDER BY ID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcIp_WhiteByBatchUpdate] Script Date: 2018/12/13 19:10:47 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- create PROCEDURE [dbo].[ProcIp_WhiteByBatchUpdate]
- AS
- BEGIN
- SELECT ip, COUNT(*) cnt INTO #t FROM IpVisitAll GROUP BY ip
- TRUNCATE TABLE IpVisitAll
- SELECT b.ip, sum(a.cnt) Cnt
- INTO #1
- FROM #t a, ip_white b
- WHERE a.ip LIKE b.ip + '%'
- GROUP BY b.ip
- ORDER BY b.ip
- UPDATE a
- SET a.VisitNum = a.VisitNum + b.Cnt,
- a.VisitNum_ThisMonth = a.VisitNum_ThisMonth + b.Cnt
- FROM Ip_White a, #1 b
- WHERE a.ip = b.ip
- END
- GO
- /****** Object: StoredProcedure [dbo].[procIp_WhiteSelect] Script Date: 2018/12/13 19:10:48 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:ip白名单
- --#####################################################
- CREATE PROCEDURE [dbo].[procIp_WhiteSelect]
- AS
- BEGIN TRY
- SELECT * FROM ip_White With(Nolock)
- ORDER BY ID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcIp_WhiteUpdate] Script Date: 2018/12/13 19:10:48 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcIp_WhiteUpdate]
- (
- @Ip VARCHAR(15)
- )
- AS
- SET NOCOUNT ON
- BEGIN
- INSERT INTO IpVisitAll(Ip) SELECT @Ip
- --UPDATE Ip_White SET VisitNum = VisitNum + 1, VisitNum_ThisMonth = VisitNum_ThisMonth + 1
- --WHERE CHARINDEX(ip, @Ip) = 1
- END
- GO
- /****** Object: StoredProcedure [dbo].[procIpJobViewInsert] Script Date: 2018/12/13 19:10:48 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --*********************************************************
- --sean 2015-10-12 职位页面频繁访问的不显示联系方式
- --*********************************************************
- CREATE PROCEDURE [dbo].[procIpJobViewInsert]
- (
- @Ip VARCHAR(50),
- @JobId INT,
- @paMainId INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- INSERT INTO IpJobView(Ip, JobId, paMainId) SELECT @Ip, @JobId, @paMainId
-
- IF EXISTS(SELECT 'x' FROM IpJobViewRefuse WITH(NOLOCK) WHERE Ip = @Ip)
- SELECT 'x'
- ELSE
- SELECT 'x' FROM IpJobViewRefuse WITH(NOLOCK) WHERE paMainId = @paMainId
- END
- GO
- /****** Object: StoredProcedure [dbo].[procIpLogInsert] Script Date: 2018/12/13 19:10:48 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:插入iplog
- --#####################################################
- CREATE PROCEDURE [dbo].[procIpLogInsert]
- @RemoteAddr VARCHAR(50),
- @UserAgent VARCHAR(200),
- @ServerName VARCHAR(100)
- AS
- BEGIN TRY
- INSERT INTO iplog (ip,http_user_agent,type,path_info)
- VALUES (@remoteAddr, @userAgent, 0, @ServerName)
- RETURN 1
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcIpPlaceSelect] Script Date: 2018/12/13 19:10:49 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.31
- --创建人:John
- --说明:获取IP对应的地区
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcIpPlaceSelect]
- (
- @ip BIGINT
- )
- AS
- BEGIN
- SELECT TOP 1 * FROM dcIpPlace WITH(NOLOCK INDEX(IX_dcIpPlace_IpStart)) WHERE IPStart <= @ip ORDER BY IPStart DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procIpReportByIDUpdate] Script Date: 2018/12/13 19:10:49 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.31
- --创建人:Nick
- --说明:更新ipreport
- --#####################################################
- CREATE PROCEDURE [dbo].[procIpReportByIDUpdate]
- (
- @ID INT,
- @IP VARCHAR(20)
- )
- AS
- BEGIN TRY
- UPDATE ipreport SET ip=@IP,refresh=getdate() WHERE id= @ID
- RETURN 1
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procIsWorkDateSelect] Script Date: 2018/12/13 19:10:49 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.30
- --创建人:Nick
- --说明:判断是不是工作日
- --#####################################################
- CREATE PROCEDURE [dbo].[procIsWorkDateSelect]
- AS
- BEGIN TRY
- SELECT oadb.dbo.isworkdate(GETDATE()) IsWorkDate
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procIvgt_AnswerByIDIpUpdate] Script Date: 2018/12/13 19:10:49 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:NICK
- --说明:修改调查文档点击次数
- --#####################################################
- CREATE PROCEDURE [dbo].[procIvgt_AnswerByIDIpUpdate]
- (
- @ID INT,
- @Ip VARCHAR(15)
- )
- AS
- SET NOCOUNT ON
- BEGIN
- INSERT INTO Ivgt_AnswerLog SELECT @ip, GETDATE()
- IF (SELECT COUNT(*) FROM Ivgt_AnswerLog WITH(NOLOCK)
- WHERE Ip = @ip AND AddDate > DATEADD(MINUTE, -240, GETDATE())) > 50
- RETURN 1
- UPDATE ivgt_answer SET clicknum = clicknum + 1 WHERE id = @ID
- RETURN 1
- END
- GO
- /****** Object: StoredProcedure [dbo].[procIvgt_AnswerByIDUpdate] Script Date: 2018/12/13 19:10:49 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:NICK
- --说明:修改调查文档点击次数
- --#####################################################
- CREATE PROCEDURE [dbo].[procIvgt_AnswerByIDUpdate]
- (
- @ID INT
- )
- AS
- BEGIN
- UPDATE ivgt_answer SET clicknum=clicknum+1 WHERE id=@ID
- RETURN 1
- END
- GO
- /****** Object: StoredProcedure [dbo].[procIvgt_AnswerByQuesionIDSelect] Script Date: 2018/12/13 19:10:50 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:NICK
- --说明:
- --#####################################################
- CREATE PROCEDURE [dbo].[procIvgt_AnswerByQuesionIDSelect]
- (
- @IvgID INT
- )
- AS
- BEGIN
- SELECT id,title,clicknum,showType
- FROM ivgt_answer WITH(NOLOCK)
- WHERE questionid=@IvgID
- ORDER BY power
- END
- GO
- /****** Object: StoredProcedure [dbo].[procIvgt_AnswerTextInsert] Script Date: 2018/12/13 19:10:50 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
-
- --#####################################################
- --创建时间:2014.11.10
- --创建人:NICK
- --说明:ivgt_answerText插入
- --Harry:增加返回id 2015-12-11
- --#####################################################
- CREATE PROCEDURE [dbo].[procIvgt_AnswerTextInsert]
- (
- @ID INT,
- @Text VARCHAR(500)
- )
- AS
- SET NOCOUNT ON
- BEGIN
- IF dbo.HaveChinese(@Text) = 0
- SET @Text = '无'
- INSERT INTO ivgt_answerText(answerid, answerText) VALUES(@ID, @Text)
- SELECT @@IDENTITY AS ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procIvgt_InvestigationBy51rcSelect] Script Date: 2018/12/13 19:10:50 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:Nick
- --说明:51rc 调查
- --#####################################################
- CREATE PROCEDURE [dbo].[procIvgt_InvestigationBy51rcSelect]
- AS
- BEGIN TRY
- SELECT TOP 3 id,title,adddate,enddate,clicknum,reporturl,reporttitle,description
- FROM ivgt_investigation WITH(NOLOCK)
- WHERE homepagesee=1
- ORDER BY adddate desc
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procIvgt_investigationByHomePageList] Script Date: 2018/12/13 19:10:50 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --创建人 Lambo
- --20101009
- --用于首页用户调查
- --修改:增加exlink harry 2017-8-5
- CREATE PROCEDURE [dbo].[procIvgt_investigationByHomePageList]
- (
- @ProvinceID SMALLINT
- )
- AS
- BEGIN
- SET NOCOUNT ON
- SELECT TOP 1 ImageFile,alt FROM fpHomePageImage WITH(NOLOCK)
- WHERE ImageType = 3
- AND dcProvinceID = LEFT(@ProvinceID, 2)
- ORDER BY AddDate DESC
- SELECT TOP 15 id newIDs,PreID id, title, description, reporturl, type, reporturl, reporttitle, addDate, exlink
- FROM SearchDb..HPInvestigationDay WITH(NOLOCK)
- WHERE
- provinceID =LEFT(@ProvinceID, 2)
- ORDER BY newIDs
-
- SET NOCOUNT OFF
- END
- GO
- /****** Object: StoredProcedure [dbo].[procIvgt_investigationByHomepageSelect] Script Date: 2018/12/13 19:10:50 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --修改harry
- --增加exlink harry 2017-8-5
- CREATE PROCEDURE [dbo].[procIvgt_investigationByHomepageSelect]
- (
- @province_id SMALLINT
- )
- AS
- BEGIN
- SELECT TOP 1 id, 99 ProvinceId, title, description, AddDate, exLink
- FROM SearchDb..ivgt_investigationDay WITH(NOLOCK)
- WHERE ProvinceID = @Province_ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procIvgt_InvestigationBYIDSelect] Script Date: 2018/12/13 19:10:51 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procIvgt_InvestigationBYIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT * FROM Ivgt_Investigation WITH(NOLOCK)
- WHERE ID = @ID
- SELECT * FROM Ivgt_Question WITH(NOLOCK)
- WHERE InvestID = @ID
- ORDER BY ID
- SELECT a.* FROM Ivgt_Answer a WITH(NOLOCK), Ivgt_Question b WITH(NOLOCK)
- WHERE b.InvestID = @ID
- AND a.QuestionID = b.id
- ORDER BY a.QuestionID,a.ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procIvgt_investigationByIDUpdate] Script Date: 2018/12/13 19:10:51 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:NICK
- --说明:ivgt_investigation修改点击次数
- --#####################################################
- CREATE PROCEDURE [dbo].[procIvgt_investigationByIDUpdate]
- (
- @ID INT
- )
- AS
- BEGIN
- UPDATE ivgt_investigation SET clicknum=clicknum+1 WHERE id = @ID
- RETURN 1
- END
- GO
- /****** Object: StoredProcedure [dbo].[procIvgt_InvestigationByProvinceIDSelect] Script Date: 2018/12/13 19:10:51 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:根据省份ID得到用户调查列表
- --修改:harry 2017-8-5 增加exlink
- --#####################################################
- CREATE PROCEDURE [dbo].[procIvgt_InvestigationByProvinceIDSelect]
- (
- @ProvinceID VARCHAR(20)
- )
- AS
- BEGIN
- IF @ProvinceID = '' OR @ProvinceID = '0'
- BEGIN
- SELECT id, title, reporturl, reporttitle, ReportType, exLink
- FROM ivgt_investigation WITH(NOLOCK)
- WHERE ENDdate < GETDATE()
- AND homepagesee = 1
- ORDER BY ENDdate DESC
- END
- ELSE
- BEGIN
- SELECT id, title, reporturl, reporttitle, ReportType, exLink
- FROM ivgt_investigation WITH(NOLOCK)
- WHERE ENDdate < GETDATE()
- AND province LIKE '%'+@ProvinceID+'%'
- AND homepagesee = 1
- ORDER BY ENDdate DESC
- END
- END
-
- GO
- /****** Object: StoredProcedure [dbo].[procIvgt_InvestigationNotEndSelect] Script Date: 2018/12/13 19:10:51 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procIvgt_InvestigationNotEndSelect]
- (
- @ProvinceID VARCHAR(2),
- @Type SMALLINT
- )
- AS
- BEGIN
- SELECT ID,Title FROM Ivgt_Investigation WITH(NOLOCK)
- WHERE ENDDate > GETDATE()
- AND Province LIKE '%' + @ProvinceID+'%'
- AND Type=@Type
- ORDER BY ID DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procIvgt_InvestigationSelect] Script Date: 2018/12/13 19:10:53 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procIvgt_InvestigationSelect]
- (
- @province_id VARCHAR(2),
- @manid INTeger,
- @type SMALLINT
- )
- as
- BEGIN
- SELECT id,title FROM Ivgt_investigation WITH(NOLOCK)
- WHERE ENDdate>GETDATE()
- AND province like '%'+@province_id+'%'
- AND type=@type
- ORDER BY adddate
- END
- GO
- /****** Object: StoredProcedure [dbo].[procIvgt_QuestionByInvestIDSelect] Script Date: 2018/12/13 19:10:53 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:NICK
- --说明:
- --#####################################################
- CREATE PROCEDURE [dbo].[procIvgt_QuestionByInvestIDSelect]
- (
- @IvgID INT
- )
- AS
- BEGIN
- SELECT id,title,type
- FROM ivgt_question WITH(NOLOCK)
- WHERE investid=@IvgID
- ORDER BY power
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcIvrDayReportInsert] Script Date: 2018/12/13 19:10:53 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --修改人:harry 2016-3-31
- --修改冷客户顾问部deptid=42,时间按照all计算
- CREATE PROCEDURE [dbo].[ProcIvrDayReportInsert]
- AS
- BEGIN
- DECLARE @YearMonth VARCHAR(8)
- IF DATEPART(DAY, GETDATE()) > 25
- SET @YearMonth = CONVERT(VARCHAR(6), GETDATE() + 10, 112)
- ELSE
- SET @YearMonth = CONVERT(VARCHAR(6), GETDATE(), 112)
- --IF NOT EXISTS(SELECT 'x' FROM Oadb..WorkDate WHERE WorkType = 1 AND Workdate = CONVERT(VARCHAR(8), GETDATE(), 112))
- -- RETURN
- INSERT IvrDayReport(CountDate, ManagerUserId, Status, Name, DeptID, RealWorkTime)
- SELECT CONVERT(VARCHAR(8), GETDATE(), 112), a.ConsultantId, 0, b.Name, b.DeptId,8
- FROM Consultant_Manageruser_Month a, ManagerUser b
- WHERE b.id = a.ConsultantId
- AND a.YearMonth = @YearMonth
- AND b.Id NOT IN(SELECT ManagerUserId FROM IvrDayReport WHERE CountDate =CONVERT(VARCHAR(8), GETDATE(), 112))
- AND b.ID <> 762
- INSERT IvrDayReport(CountDate, ManagerUserId, Status, Name, DeptID, RealWorkTime)
- SELECT CONVERT(VARCHAR(8), GETDATE(), 112), Id, 0, Name, DeptId, 8
- FROM ManagerUser
- WHERE DeptID =42 AND STatus < 3
- AND LEN(Name) < 5
- AND Id NOT IN(SELECT ManagerUserId FROM IvrDayReport WHERE CountDate =CONVERT(VARCHAR(8), GETDATE(), 112))
- AND ID <> 762
- INSERT IvrDayReport(CountDate, ManagerUserId, Status, Name, DeptID, RealWorkTime)
- SELECT CONVERT(VARCHAR(8), GETDATE(), 112), Id, 0, Name, DeptId, 8
- FROM ManagerUser
- WHERE DeptID in (50,52) AND STatus < 3 AND id<>881
- AND Id NOT IN(SELECT ManagerUserId FROM IvrDayReport WHERE CountDate =CONVERT(VARCHAR(8), GETDATE(), 112))
- INSERT IvrDayReport(CountDate, ManagerUserId, Status, Name, DeptID, RealWorkTime)
- SELECT CONVERT(VARCHAR(8), GETDATE(), 112), Id, 0, Name, DeptId, 8
- FROM ManagerUser WHERE DeptID BETWEEN 180 AND 184 AND STatus < 3
-
- UPDATE a
- SET a.RealNumber = CallinNum_up40 + CalloutNum_up40,
- a.RealMinute = (CallinInterval_Up40 + CalloutInterval_Up40) / 60
- FROM IvrDayReport a, ivrList_Day b
- WHERE a.CountDate = b.CountDate
- AND a.ManagerUserId = b.ManagerUserId
- AND a.RealNumber = 0
- AND a.CountDate > CONVERT(VARCHAR(8), GETDATE() - 2, 112)
- AND a.DeptID!=42--Harry2016-3-30
- AND a.DeptID != 50
-
- --Harry begin
- UPDATE a
- SET a.RealNumber = CallinNum_all + CalloutNum_all,
- a.RealMinute = (CallinInterval_all + CalloutInterval_all) / 60
- FROM IvrDayReport a, ivrList_Day b
- WHERE a.CountDate = b.CountDate
- AND a.ManagerUserId = b.ManagerUserId
- AND a.RealNumber = 0
- AND a.CountDate > CONVERT(VARCHAR(8), GETDATE() - 2, 112)
- AND (a.DeptID=42 OR a.DeptID = 50 )
- --Harry end
- UPDATE IvrDayReport
- SET RealNumber = 0, RealMinute = 0
- FROM IvrDayReport
- WHERE CountDate > CONVERT(VARCHAR(8), GETDATE() - 2, 112)
- AND RealNumber IS NULL
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcIvrList_DayInsert] Script Date: 2018/12/13 19:10:54 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcIvrList_DayInsert]
- AS
- BEGIN
- DECLARE @begindate varchar(50), @enddate varchar(50),
- @id int, @name nvarchar(50), @status tinyint,
- @CallinNum_all smallint, @CallinInterval_all int,
- @CallinNum_up30 smallint, @CallinInterval_up30 int,
- @CallinNum_up40 smallint, @CallinInterval_up40 int,
- @CallinNum_up60 smallint, @CallinInterval_up60 int,
- @CallinNum_up180 smallint, @CallinInterval_up180 int,
- @CallinNum_up600 smallint, @CallinInterval_up600 int
- DECLARE @CalloutNum_all smallint, @CalloutInterval_all int,
- @CalloutNum_up30 smallint, @CalloutInterval_up30 int,
- @CalloutNum_up40 smallint, @CalloutInterval_up40 int,
- @CalloutNum_up60 smallint, @CalloutInterval_up60 int,
- @CalloutNum_up180 smallint, @CalloutInterval_up180 int,
- @CalloutNum_up600 smallint, @CalloutInterval_up600 int
- DECLARE @Callin_notdeal smallint, @Callin_leak smallint,
- @Callin_queueleak smallint, @Callin_blacklist smallint,
- @Callin_voicemail smallint, @Callout_notdeal smallint,
- @Callout_leak smallint, @Callout_queueleak smallint,
- @Callout_blacklist smallint, @Callout_voicemail smallint
- SET @begindate=ltrim(rtrim(str(year(getdate()))))+'-'+ltrim(rtrim(str(month(getdate()))))+'-'+ltrim(rtrim(str(day(getdate()))))+' 00:00:00'
- SET @enddate=ltrim(rtrim(str(year(getdate()))))+'-'+ltrim(rtrim(str(month(getdate()))))+'-'+ltrim(rtrim(str(day(getdate()))))+' 23:59:59'
- DECLARE manageruser CURSOR FOR
- SELECT id, name, status from manageruser with(nolock) where (status=1 or status=2) and (type=1 or type=5) order by id
- OPEN manageruser
- FETCH NEXT FROM manageruser INTO @id, @name, @status
- WHILE @@FETCH_STATUS = 0
- BEGIN
- BEGIN TRANSACTION
- SELECT @CallinNum_all=count(1) from IvrList with(nolock)
- where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate and exten=@id
- SELECT @CallinInterval_all=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
- where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate and exten=@id
- if @CallinInterval_all is null
- set @CallinInterval_all=0
- SELECT @CallinNum_up30=count(1) from IvrList with(nolock)
- where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=30 and exten=@id
- SELECT @CallinInterval_up30=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
- where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=30 and exten=@id
- if @CallinInterval_up30 is null
- set @CallinInterval_up30=0
-
- SELECT @CallinNum_up40=count(1) from IvrList with(nolock)
- where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=40 and exten=@id
- SELECT @CallinInterval_up40=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
- where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=40 and exten=@id
- if @CallinInterval_up40 is null
- set @CallinInterval_up40=0
- SELECT @CallinNum_up60=count(1) from IvrList with(nolock)
- where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=60 and exten=@id
- SELECT @CallinInterval_up60=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
- where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=60 and exten=@id
- if @CallinInterval_up60 is null
- set @CallinInterval_up60=0
- SELECT @CallinNum_up180=count(1) from IvrList with(nolock)
- where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=180 and exten=@id
- SELECT @CallinInterval_up180=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
- where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=180 and exten=@id
- if @CallinInterval_up180 is null
- set @CallinInterval_up180=0
- SELECT @CallinNum_up600=count(1) from IvrList with(nolock)
- where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=600 and exten=@id
- SELECT @CallinInterval_up600=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
- where (CallType='normal'or CallType='transfer') and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=600 and exten=@id
- if @CallinInterval_up600 is null
- set @CallinInterval_up600=0
- SELECT @CalloutNum_all=count(1) from IvrList with(nolock)
- where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate and exten=@id
- SELECT @CalloutInterval_all=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
- where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate and exten=@id
- if @CalloutInterval_all is null
- set @CalloutInterval_all=0
- SELECT @CalloutNum_up30=count(1) from IvrList with(nolock)
- where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=30 and exten=@id
- SELECT @CalloutInterval_up30=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
- where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=30 and exten=@id
- if @CalloutInterval_up30 is null
- set @CalloutInterval_up30=0
- SELECT @CalloutNum_up40=count(1) from IvrList with(nolock)
- where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=40 and exten=@id
- SELECT @CalloutInterval_up40=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
- where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=40 and exten=@id
- if @CalloutInterval_up40 is null
- set @CalloutInterval_up40=0
- SELECT @CalloutNum_up60=count(1) from IvrList with(nolock)
- where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=60 and exten=@id
- SELECT @CalloutInterval_up60=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
- where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=60 and exten=@id
- if @CalloutInterval_up60 is null
- set @CalloutInterval_up60=0
- SELECT @CalloutNum_up180=count(1) from IvrList with(nolock)
- where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=180 and exten=@id
- SELECT @CalloutInterval_up180=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
- where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=180 and exten=@id
- if @CalloutInterval_up180 is null
- set @CalloutInterval_up180=0
- SELECT @CalloutNum_up600=count(1) from IvrList with(nolock)
- where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=600 and exten=@id
- SELECT @CalloutInterval_up600=SUM(datediff(s, begintime, endtime)) from IvrList with(nolock)
- where CallType='dialout' and State='dealing' and endtime>@begindate and endtime<@enddate
- and datediff(s, begintime, endtime)>=600 and exten=@id
- if @CalloutInterval_up600 is null
- set @CalloutInterval_up600=0
- SELECT @Callin_notdeal=count(1) from IvrList with(nolock)
- where CallType='normal' and State='notdeal' and endtime>@begindate and endtime<@enddate and exten=@id
- SELECT @Callin_leak=count(1) from IvrList with(nolock)
- where CallType='normal' and State='leak' and endtime>@begindate and endtime<@enddate and exten=@id
- SELECT @Callin_queueleak=count(1) from IvrList with(nolock)
- where CallType='normal' and State='queueleak' and endtime>@begindate and endtime<@enddate and exten=@id
- SELECT @Callin_blacklist=count(1) from IvrList with(nolock)
- where CallType='normal' and State='blacklist' and endtime>@begindate and endtime<@enddate and exten=@id
- SELECT @Callin_voicemail=count(1) from IvrList with(nolock)
- where CallType='normal' and State='voicemail' and endtime>@begindate and endtime<@enddate and exten=@id
- SELECT @Callout_notdeal=count(1) from IvrList with(nolock)
- where CallType='dialout' and State='notdeal' and endtime>@begindate and endtime<@enddate and exten=@id
- SELECT @Callout_leak=count(1) from IvrList with(nolock)
- where CallType='dialout' and State='leak' and endtime>@begindate and endtime<@enddate and exten=@id
- SELECT @Callout_queueleak=count(1) from IvrList with(nolock)
- where CallType='dialout' and State='queueleak' and endtime>@begindate and endtime<@enddate and exten=@id
- SELECT @Callout_blacklist=count(1) from IvrList with(nolock)
- where CallType='dialout' and State='blacklist' and endtime>@begindate and endtime<@enddate and exten=@id
- SELECT @Callout_voicemail=count(1) from IvrList with(nolock)
- where CallType='dialout' and State='voicemail' and endtime>@begindate and endtime<@enddate and exten=@id
- insert into Ivrlist_day (countdate, manageruserid, name, status, CallinNum_all, CallinInterval_all,
- CallinNum_up30, CallinInterval_up30, CallinNum_up40, CallinInterval_up40, CallinNum_up60, CallinInterval_up60, CallinNum_up180, CallinInterval_up180,
- CallinNum_up600, CallinInterval_up600,
- CalloutNum_all, CalloutInterval_all,
- CalloutNum_up30, CalloutInterval_up30, CalloutNum_up40, CalloutInterval_up40, CalloutNum_up60, CalloutInterval_up60, CalloutNum_up180, CalloutInterval_up180,
- CalloutNum_up600, CalloutInterval_up600, Callin_notdeal, Callin_leak, Callin_queueleak, Callin_blacklist, Callin_voicemail,
- Callout_notdeal, Callout_leak, Callout_queueleak, Callout_blacklist, Callout_voicemail)
- values ((year(getdate())*10000+month(getdate())*100+day(getdate())), @id, @name, @status,
- @CallinNum_all, @CallinInterval_all,
- @CallinNum_up30, @CallinInterval_up30, @CallinNum_up40, @CallinInterval_up40, @CallinNum_up60, @CallinInterval_up60, @CallinNum_up180, @CallinInterval_up180,
- @CallinNum_up600, @CallinInterval_up600,
- @CalloutNum_all, @CalloutInterval_all,
- @CalloutNum_up30, @CalloutInterval_up30, @CalloutNum_up40, @CalloutInterval_up40, @CalloutNum_up60, @CalloutInterval_up60, @CalloutNum_up180,
- @CalloutInterval_up180,
- @CalloutNum_up600, @CalloutInterval_up600, @Callin_notdeal, @Callin_leak, @Callin_queueleak, @Callin_blacklist, @Callin_voicemail,
- @Callout_notdeal, @Callout_leak, @Callout_queueleak, @Callout_blacklist, @Callout_voicemail)
- COMMIT TRANSACTION
- FETCH NEXT FROM manageruser INTO @id, @name, @status
- END
- CLOSE manageruser
- DEALLOCATE manageruser
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcIvrList_DaySelect] Script Date: 2018/12/13 19:10:54 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --Edit by 2014-12-17,修改Coefficient为:折算后个数/100+折算后时长/260
- --修改:冷客户顾问部 电话量系数指标是80个,100分钟-harry2017-4-27
- CREATE PROCEDURE [dbo].[ProcIvrList_DaySelect]
- (
- @QueryType TINYINT, --1:南北方个人;2:山东个人;3:客服个人;4:所有部门对比;5:部门查询
- @BeginDate DATETIME, --20140505
- @EndDate DATETIME, --20140510
- @TimeType TINYINT, --0:不选择; 1:30秒以上;2:1分钟以上;3:3分钟以上;4:10分钟以上;
- @CallType TINYINT, --0:不选择; 1:呼入; 2:呼出
- --@Region TINYINT, --0:不选择; 1:北方; 2:南方; 3:山东
- @DeptId INT --0:不选择; 其他见dept
- )
- AS
- SET NOCOUNT ON
- --insert a2 select @QueryType, @BeginDate, @EndDate, @TimeType, @CallType, @DeptId
- BEGIN
- --转换时间
- DECLARE @BDate VARCHAR(8), @EDate VARCHAR(8),
- @Sql VARCHAR(MAX), @CallNumber VARCHAR(100), @CallInterval VARCHAR(100)
- SELECT @BDate = CONVERT(VARCHAR(8), @BeginDate, 112),
- @EDate = CONVERT(VARCHAR(8), @EndDate, 112)
- CREATE TABLE #t(
- DeptId BIGINT,
- DeptName NVARCHAR(20),
- ManagerUserId BIGINT,
- ManagerName NVARCHAR(20),
- AvgNumber BIGINT,
- AvgMinute BIGINT,
- AvgConvertNumber BIGINT,
- AvgConvertMinute BIGINT,
- SumNumber BIGINT,
- SumMinute BIGINT,
- SumConvertNumber BIGINT,
- SumConvertMinute BIGINT,
- RealWorkTime DECIMAL(9, 2),
- WorkDays BIGINT,
- Coefficient DECIMAL(9, 3))
- --@TimeType BIGINT, --0:不选择; 1:30秒以上;2:1分钟以上;3:3分钟以上;4:5分钟以上;5:10分钟以上;6:30分钟以上
-
- IF @CallType = 1
- SELECT @CallNumber = 'CallInNum_All', @CallInterval = 'CallInInterval_All'
- ELSE IF @CallType = 2
- SELECT @CallNumber = 'CallOutNum_All', @CallInterval = 'CallOutInterval_All'
- ELSE
- SELECT @CallNumber = 'CallInNum_All + CallOutNum_All',
- @CallInterval = 'CallInInterval_All + CallOutInterval_All'
- IF @TimeType = 1
- SELECT @CallNumber = REPLACE(@CallNumber, '_All', '_Up30'),
- @CallInterval = REPLACE(@CallInterval, '_All', '_Up30')
- ELSE IF @TimeType = 2
- SELECT @CallNumber = REPLACE(@CallNumber, '_All', '_Up60'),
- @CallInterval = REPLACE(@CallInterval, '_All', '_Up60')
- ELSE IF @TimeType = 3
- SELECT @CallNumber = REPLACE(@CallNumber, '_All', '_Up180'),
- @CallInterval = REPLACE(@CallInterval, '_All', '_Up180')
- ELSE IF @TimeType = 4
- SELECT @CallNumber = REPLACE(@CallNumber, '_All', '_Up600'),
- @CallInterval = REPLACE(@CallInterval, '_All', '_Up600')
- ELSE IF @TimeType = 5
- SELECT @CallNumber = REPLACE(@CallNumber, '_All', '_Up40'),
- @CallInterval = REPLACE(@CallInterval, '_All', '_Up40')
- SET @Sql ='
- INSERT #t(ManagerUserId, AvgNumber, AvgMinute, SumNumber, SumMinute, Coefficient, RealWorkTime, WorkDays)
- SELECT a.ManagerUserId, AVG(' + @CallNumber + '), AVG(' + @CallInterval + '),
- SUM(' + @CallNumber + '), SUM(' + @CallInterval + '), AVG(b.Coefficient),
- SUM(b.RealWorkTime), COUNT(1)
- FROM IvrList_Day a, IvrDayReport b
- WHERE a.CountDate BETWEEN ' + @BDate + ' AND ' + @EDate + '
- AND a.CountDate = b.Countdate
- AND a.ManagerUserId = b.ManagerUserId
- AND b.IsCheck = 1
- GROUP BY a.ManagerUserId'
- PRINT @SQL
- EXEC(@SQL)
- UPDATE a
- Set a.ManagerName = b.Name,
- a.DeptId = b.DeptId
- FROM #t a, ManagerUser b
- WHERE a.ManagerUSerId = b.Id
- UPDATE a
- Set a.DeptName = b.DeptName
- FROM #t a, Dept b
- WHERE a.DeptId = b.Id
- --1:南北方个人;2:山东个人;3:客服个人;4:所有部门对比;5:部门查询
- IF @QueryType = 1
- DELETE #t WHERE DeptId NOT IN(4,19,25,28)
- IF @QueryType = 2
- DELETE #t WHERE DeptId NOT IN(31,34,36,37,39,42,54)
- IF @QueryType = 3
- DELETE #t WHERE DeptId <> 14
- IF @QueryType = 5
- BEGIN
- DELETE #t WHERE DeptId <> @DeptId
- INSERT #t(DeptId, DeptName, ManagerUserId, ManagerName, AvgNumber, AvgMinute,
- SumNumber, SumMinute, RealWorkTime, WorkDays)
- SELECT DeptId, DeptName, NULL, '部门', AVG(AvgNumber), AVG(AvgMinute),
- SUM(SumNumber), SUM(SumMinute), SUM(RealWorkTime), SUM(WorkDays)
- FROM #t
- GROUP BY DeptID, DeptName
- END
- IF @QueryType = 4
- BEGIN
- DELETE #t WHERE DeptId = 14
- INSERT #t(DeptId, DeptName, ManagerUserId, ManagerName, AvgNumber, AvgMinute,
- SumNumber, SumMinute, RealWorkTime, WorkDays, Coefficient)
- SELECT DeptId, DeptName, NULL, '', AVG(AvgNumber), AVG(AvgMinute),
- SUM(SumNumber), SUM(SumMinute), SUM(RealWorkTime), SUM(WorkDays), AVG(Coefficient)
- FROM #t
- GROUP BY DeptID, DeptName
- DELETE #t WHERE ManagerUserID < 1000
- INSERT #t(DeptId, DeptName, ManagerUserId, ManagerName, AvgNumber, AvgMinute,
- SumNumber, SumMinute, RealWorkTime, WorkDays)
- SELECT 0, '体系', NULL, '', AVG(AvgNumber), AVG(AvgMinute),
- SUM(SumNumber), SUM(SumMinute), SUM(RealWorkTime), SUM(WorkDays)
- FROM #t
- END
- UPDATE #t SET AvgConvertNumber = AvgNumber * (WorkDays * 8) / RealWorkTime,
- AvgConvertMinute = AvgMinute * (WorkDays * 8) / RealWorkTime,
- SumConvertNumber = SumNumber * (WorkDays * 8) / RealWorkTime,
- SumConvertMinute = SumMinute * (WorkDays * 8) / RealWorkTime
- UPDATE #t SET Coefficient = (AvgConvertNumber / 100.0 + AvgConvertMinute / (260.0 * 60))
- WHERE DeptId != 42
- UPDATE #t SET Coefficient = (AvgConvertNumber / 160.0 + AvgConvertMinute / (200.0 * 60))
- WHERE DeptId = 42
- --WHERE ManagerUserId IS NULL
- DECLARE @t AS TABLE(
- DeptId BIGINT,
- DeptName NVARCHAR(20),
- ManagerUserId BIGINT,
- ManagerName NVARCHAR(20),
- CountType NVARCHAR(2),
- RealNumber BIGINT,
- RealMinute BIGINT,
- ConvertNumber BIGINT,
- ConvertMinute BIGINT,
- Coefficient DECIMAL(9, 2))
- INSERT @t(DeptId, DeptName, ManagerUserId, ManagerName, CountType,
- RealNumber, RealMinute, ConvertNumber, ConvertMinute, Coefficient)
- SELECT DeptId, DeptName, ManagerUserId, ManagerName, '平均',
- AvgNumber, AvgMinute / 60, AvgConvertNumber, AvgConvertMinute / 60, Coefficient
- FROM #t
- INSERT @t(DeptId, DeptName, ManagerUserId, ManagerName, CountType,
- RealNumber, RealMinute, ConvertNumber, ConvertMinute, Coefficient)
- SELECT DeptId, DeptName, ManagerUserId, ManagerName, '合计',
- SumNumber, SumMinute / 60, SumConvertNumber, SumConvertMinute / 60, Coefficient
- FROM #t
- DECLARE @d AS TABLE(DeptId BIGINT, OrderNo INT)
- INSERT @d SELECT 4, 1
- INSERT @d SELECT 28, 2
- INSERT @d SELECT 19, 3
- INSERT @d SELECT 25, 4
- INSERT @d SELECT 39, 5
- INSERT @d SELECT 31, 6
- INSERT @d SELECT 34, 7
- INSERT @d SELECT 36, 8
- INSERT @d SELECT 37, 9
- INSERT @d SELECT 42, 10
- INSERT @d SELECT 14, 11
- INSERT @d SELECT 54, 12
- INSERT @d SELECT 0, 13
- SELECT a.* FROM @t a, @d b WHERE a.DeptId = b.DeptId
- ORDER BY b.OrderNo, CASE WHEN a.ManagerUserId IS NULL THEN 9999 ELSE a.ManagerUserId END, CASE CountType WHEN '平均' THEN 1 ELSE 2 END
- SELECT * FROM #t ORDER BY DeptName, ManagerUserId
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcIvrListByCaMainIdUpdate] Script Date: 2018/12/13 19:10:55 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcIvrListByCaMainIdUpdate]
- AS
- BEGIN
- --DECLARE @ID INT
- --SELECT TOP 1 @ID = ID FROM IvrList WHERE caMainId IS NOT NULL ORDER BY ID DESC
- DECLARE @t AS TABLE(ID INT,
- CallNo VARCHAR(50),
- CalledNo VARCHAR(50),
- CallType VARCHAR(10),
- Telephone VARCHAR(50),
- Telephone2 VARCHAR(50),
- Exten VARCHAR(10),
- caMainId INT,
- cpAccountID INT,
- cpLinkManID INT,
- IsWtg INT
- )
- INSERT INTO @t(ID, CallNo, CalledNo, CallType, Exten,cpAccountID,cpLinkManID, IsWtg)
- SELECT ID, CallNo, CalledNo, CallType, Exten, 0,0,0 FROM IvrList WHERE caMainId IS NULL
- IF (SELECT COUNT(*) FROM @t) = 0
- RETURN
- UPDATE a SET IsWtg = 1 FROM @t a WHERE Exten IN (SELECT LTRIM(STR(ID)) FROM Manageruser WITH(NOLOCK) WHERE DeptID IN (SELECT ID FROM Dept WITH(NOLOCK) WHERE Superior = 43))
- UPDATE a
- SET a.TelePhone = a.CallNo
- FROM @t a
- UPDATE a
- SET a.TelePhone = a.CalledNo
- FROM @t a
- WHERE a.CallType = 'dialout'
-
- UPDATE a
- SET a.TelePhone2 = LEFT(TelePhone, 3) + '-' + RIGHT(TelePhone, LEN(TelePhone) - 3)
- FROM @t a
- WHERE LEFT(TelePhone, 2) IN('01', '02')
- AND TelePhone NOT LIKE '1%'
- UPDATE a
- SET a.TelePhone2 = LEFT(TelePhone, 4) + '-' + RIGHT(TelePhone, LEN(TelePhone) - 4)
- FROM @t a
- WHERE TelePhone2 IS NULL
- AND TelePhone NOT LIKE '1%'
- --#############################判断是否是社招平台的联系方式
- UPDATE a
- SET a.caMainId = (SELECT TOP 1 Id FROM caMain WHERE caMain.Mobile = a.TelePhone AND cpMainId IN(SELECT id FROM cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY Id DESc)
- FROM @t a
- WHERE a.TelePhone LIKE '1%'
- AND IsWtg = 0
- UPDATE a
- SET a.caMainId = (SELECT TOP 1 Id FROM caMain WHERE caMain.Mobile = a.TelePhone ORDER BY ID DESC)
- FROM @t a
- WHERE a.TelePhone LIKE '1%'
- AND a.CaMainId IS NULL
- AND IsWtg = 0
- UPDATE a
- SET a.caMainId = (SELECT TOP 1 Id FROM caMain WITH(NOLOCK INDEX(IX_CaMainID_TelePhone)) WHERE caMain.TelePhone LIKE a.TelePhone + '%' AND cpMainId IN(SELECT id FROM cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
- FROM @t a
- WHERE a.CaMainId IS NULL
- AND IsWtg = 0
- UPDATE a
- SET a.caMainId = (SELECT TOP 1 Id FROM caMain WITH(NOLOCK INDEX(IX_CaMainID_TelePhone)) WHERE caMain.TelePhone LIKE a.TelePhone + '%' ORDER BY ID DESC)
- FROM @t a
- WHERE a.CaMainId IS NULL
- AND IsWtg = 0
- UPDATE a
- SET a.caMainId = (SELECT TOP 1 Id FROM caMain WITH(NOLOCK INDEX(IX_CaMainID_TelePhone)) WHERE caMain.TelePhone LIKE a.TelePhone2 + '%' AND cpMainId IN(SELECT id FROM cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
- FROM @t a
- WHERE a.CaMainId IS NULL
- AND IsWtg = 0
- UPDATE a
- SET a.caMainId = (SELECT TOP 1 Id FROM caMain WITH(NOLOCK INDEX(IX_CaMainID_TelePhone)) WHERE TelePhone LIKE a.TelePhone2 + '%' ORDER BY ID DESC)
- FROM @t a
- WHERE a.CaMainId IS NULL
- AND IsWtg = 0
- UPDATE a
- SET a.caMainId = 0
- FROM @t a
- WHERE a.CaMainId IS NULL
- --AND IsWtg = 0
- UPDATE a
- SET a.caMainId = b.caMainId
- FROM IvrList a, @t b
- WHERE a.Id = b.Id
- --AND IsWtg = 0
- --#############################判断是否是梧桐果校招平台的联系方式
- UPDATE a
- SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK) WHERE cpAccount.Mobile = a.TelePhone AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY Id DESc)
- FROM @t a
- WHERE a.TelePhone LIKE '1%'
- AND cpAccountID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK) WHERE cpAccount.Mobile = a.TelePhone ORDER BY Id DESc)
- FROM @t a
- WHERE a.TelePhone LIKE '1%'
- AND cpAccountID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK) WHERE CpLinkMan.Mobile = a.TelePhone AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
- FROM @t a
- WHERE a.TelePhone LIKE '1%'
- AND IsWtg = 1
- UPDATE a
- SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK) WHERE CpLinkMan.Mobile = a.TelePhone ORDER BY ID DESC)
- FROM @t a
- WHERE a.TelePhone LIKE '1%'
- AND CpLinkManID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK INDEX(IX_CpAccount_TelePhone)) WHERE cpAccount.TelePhone LIKE a.TelePhone + '%' AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
- FROM @t a
- WHERE cpAccountID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK INDEX(IX_CpAccount_TelePhone)) WHERE cpAccount.TelePhone LIKE a.TelePhone + '%' ORDER BY ID DESC)
- FROM @t a
- WHERE cpAccountID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK INDEX(IX_CpLinkMan_Tel)) WHERE CpLinkMan.Tel LIKE a.TelePhone + '%' AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
- FROM @t a
- WHERE CpLinkManID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK INDEX(IX_CpLinkMan_Tel)) WHERE CpLinkMan.Tel LIKE a.TelePhone + '%' ORDER BY ID DESC)
- FROM @t a
- WHERE CpLinkManID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK INDEX(IX_CpAccount_TelePhone)) WHERE cpAccount.TelePhone LIKE a.TelePhone2 + '%' AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
- FROM @t a
- WHERE cpAccountID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK INDEX(IX_CpAccount_TelePhone)) WHERE cpAccount.TelePhone LIKE a.TelePhone2 + '%' ORDER BY ID DESC)
- FROM @t a
- WHERE cpAccountID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK INDEX(IX_CpLinkMan_Tel)) WHERE CpLinkMan.Tel LIKE a.TelePhone2 + '%' AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
- FROM @t a
- WHERE CpLinkManID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK INDEX(IX_CpLinkMan_Tel)) WHERE CpLinkMan.Tel LIKE a.TelePhone2 + '%' ORDER BY ID DESC)
- FROM @t a
- WHERE CpLinkManID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.cpAccountID = b.cpAccountID
- FROM IvrList a, @t b
- WHERE a.Id = b.Id
- AND IsWtg = 1
- UPDATE a
- SET a.CpLinkManID = b.CpLinkManID
- FROM IvrList a, @t b
- WHERE a.Id = b.Id
- AND IsWtg = 1
-
- -- INSERT INTO Wutongguodb..CpContactLog(CpMainID,IvrListID,CpLinkManID,CpAccountID,ContentText,ManageruserID,Name,Tel)
- -- SELECT
- -- ISNULL(b.CpMainID,c.CpMainID)
- -- ,a.id
- -- ,CpLinkManID
- -- ,CpAccountID
- -- ,''
- -- ,Exten,ISNULL(b.Name,c.Name),a.TelePhone
- -- FROM @t a LEFT JOIN Wutongguodb..CpLinkMan b WITH(NOLOCK) ON a.CpLinkManID = b.ID
- -- LEFT JOIN Wutongguodb..CpAccount c WITH(NOLOCK) ON a.CpAccountID = c.ID
- -- WHERE a.IsWtg=1 AND (CpLinkManID >0 OR CpLinkManID>0) and a.CallType = 'dialout'
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcIvrListByCaMainIdUpdate2] Script Date: 2018/12/13 19:10:56 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcIvrListByCaMainIdUpdate2]
- AS
- BEGIN
- --DECLARE @ID INT
- --SELECT TOP 1 @ID = ID FROM IvrList WHERE caMainId IS NOT NULL ORDER BY ID DESC
- DECLARE @t AS TABLE(ID INT,
- CallNo VARCHAR(50),
- CalledNo VARCHAR(50),
- CallType VARCHAR(10),
- Telephone VARCHAR(50),
- Telephone2 VARCHAR(50),
- Exten VARCHAR(10),
- caMainId INT,
- cpAccountID INT,
- cpLinkManID INT,
- IsWtg INT
- )
- INSERT INTO @t(ID, CallNo, CalledNo, CallType, Exten,cpAccountID,cpLinkManID, IsWtg)
- SELECT ID, CallNo, CalledNo, CallType, Exten, 0,0,0 FROM IvrList WHERE caMainId IS NULL
- IF (SELECT COUNT(*) FROM @t) = 0
- RETURN
- UPDATE a SET IsWtg = 1 FROM @t a WHERE Exten IN (SELECT LTRIM(STR(ID)) FROM Manageruser WITH(NOLOCK) WHERE DeptID IN (SELECT ID FROM Dept WITH(NOLOCK) WHERE Superior = 43))
- UPDATE a
- SET a.TelePhone = a.CallNo
- FROM @t a
- UPDATE a
- SET a.TelePhone = a.CalledNo
- FROM @t a
- WHERE a.CallType = 'dialout'
-
- UPDATE a
- SET a.TelePhone2 = LEFT(TelePhone, 3) + '-' + RIGHT(TelePhone, LEN(TelePhone) - 3)
- FROM @t a
- WHERE LEFT(TelePhone, 2) IN('01', '02')
- AND TelePhone NOT LIKE '1%'
- UPDATE a
- SET a.TelePhone2 = LEFT(TelePhone, 4) + '-' + RIGHT(TelePhone, LEN(TelePhone) - 4)
- FROM @t a
- WHERE TelePhone2 IS NULL
- AND TelePhone NOT LIKE '1%'
- --#############################判断是否是社招平台的联系方式
- UPDATE a
- SET a.caMainId = (SELECT TOP 1 Id FROM caMain WHERE caMain.Mobile = a.TelePhone AND cpMainId IN(SELECT id FROM cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY Id DESc)
- FROM @t a
- WHERE a.TelePhone LIKE '1%'
- AND IsWtg = 0
- UPDATE a
- SET a.caMainId = (SELECT TOP 1 Id FROM caMain WHERE caMain.Mobile = a.TelePhone ORDER BY ID DESC)
- FROM @t a
- WHERE a.TelePhone LIKE '1%'
- AND a.CaMainId IS NULL
- AND IsWtg = 0
- UPDATE a
- SET a.caMainId = (SELECT TOP 1 Id FROM caMain WITH(NOLOCK INDEX(IX_CaMainID_TelePhone)) WHERE caMain.TelePhone LIKE a.TelePhone + '%' AND cpMainId IN(SELECT id FROM cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
- FROM @t a
- WHERE a.CaMainId IS NULL
- AND IsWtg = 0
- UPDATE a
- SET a.caMainId = (SELECT TOP 1 Id FROM caMain WITH(NOLOCK INDEX(IX_CaMainID_TelePhone)) WHERE caMain.TelePhone LIKE a.TelePhone + '%' ORDER BY ID DESC)
- FROM @t a
- WHERE a.CaMainId IS NULL
- AND IsWtg = 0
- UPDATE a
- SET a.caMainId = (SELECT TOP 1 Id FROM caMain WITH(NOLOCK INDEX(IX_CaMainID_TelePhone)) WHERE caMain.TelePhone LIKE a.TelePhone2 + '%' AND cpMainId IN(SELECT id FROM cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
- FROM @t a
- WHERE a.CaMainId IS NULL
- AND IsWtg = 0
- UPDATE a
- SET a.caMainId = (SELECT TOP 1 Id FROM caMain WITH(NOLOCK INDEX(IX_CaMainID_TelePhone)) WHERE TelePhone LIKE a.TelePhone2 + '%' ORDER BY ID DESC)
- FROM @t a
- WHERE a.CaMainId IS NULL
- AND IsWtg = 0
- UPDATE a
- SET a.caMainId = 0
- FROM @t a
- WHERE a.CaMainId IS NULL
- AND IsWtg = 0
- UPDATE a
- SET a.caMainId = b.caMainId
- FROM IvrList a, @t b
- WHERE a.Id = b.Id
- AND IsWtg = 0
- --#############################判断是否是梧桐果校招平台的联系方式
- UPDATE a
- SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK) WHERE cpAccount.Mobile = a.TelePhone AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY Id DESc)
- FROM @t a
- WHERE a.TelePhone LIKE '1%'
- AND IsWtg = 1
- UPDATE a
- SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK) WHERE cpAccount.Mobile = a.TelePhone ORDER BY Id DESc)
- FROM @t a
- WHERE a.TelePhone LIKE '1%'
- AND cpAccountID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK) WHERE CpLinkMan.Mobile = a.TelePhone AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
- FROM @t a
- WHERE a.TelePhone LIKE '1%'
- AND IsWtg = 1
- UPDATE a
- SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK) WHERE CpLinkMan.Mobile = a.TelePhone ORDER BY ID DESC)
- FROM @t a
- WHERE a.TelePhone LIKE '1%'
- AND CpLinkManID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK INDEX(IX_CpAccount_TelePhone)) WHERE cpAccount.TelePhone LIKE a.TelePhone + '%' AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
- FROM @t a
- WHERE cpAccountID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK INDEX(IX_CpAccount_TelePhone)) WHERE cpAccount.TelePhone LIKE a.TelePhone + '%' ORDER BY ID DESC)
- FROM @t a
- WHERE cpAccountID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK INDEX(IX_CpLinkMan_Tel)) WHERE CpLinkMan.Tel LIKE a.TelePhone + '%' AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
- FROM @t a
- WHERE CpLinkManID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK INDEX(IX_CpLinkMan_Tel)) WHERE CpLinkMan.Tel LIKE a.TelePhone + '%' ORDER BY ID DESC)
- FROM @t a
- WHERE CpLinkManID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK INDEX(IX_CpAccount_TelePhone)) WHERE cpAccount.TelePhone LIKE a.TelePhone2 + '%' AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
- FROM @t a
- WHERE cpAccountID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.cpAccountID = (SELECT TOP 1 Id FROM Wutongguodb..cpAccount WITH(NOLOCK INDEX(IX_CpAccount_TelePhone)) WHERE cpAccount.TelePhone LIKE a.TelePhone2 + '%' ORDER BY ID DESC)
- FROM @t a
- WHERE cpAccountID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK INDEX(IX_CpLinkMan_Tel)) WHERE CpLinkMan.Tel LIKE a.TelePhone2 + '%' AND cpMainId IN(SELECT id FROM Wutongguodb..cpMain WITH(NOLOCK) WHERE ConsultantId = a.Exten) ORDER BY ID DESC)
- FROM @t a
- WHERE CpLinkManID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.CpLinkManID = (SELECT TOP 1 Id FROM Wutongguodb..CpLinkMan WITH(NOLOCK INDEX(IX_CpLinkMan_Tel)) WHERE CpLinkMan.Tel LIKE a.TelePhone2 + '%' ORDER BY ID DESC)
- FROM @t a
- WHERE CpLinkManID = 0
- AND IsWtg = 1
- UPDATE a
- SET a.cpAccountID = b.cpAccountID
- FROM IvrList a, @t b
- WHERE a.Id = b.Id
- AND IsWtg = 1
- UPDATE a
- SET a.CpLinkManID = b.CpLinkManID
- FROM IvrList a, @t b
- WHERE a.Id = b.Id
- AND IsWtg = 1
-
- INSERT INTO Wutongguodb..CpContactLog(CpMainID,IvrListID,CpLinkManID,CpAccountID,ContentText,ManageruserID)
- SELECT
- ISNULL(b.CpMainID,c.CpMainID)
- ,a.id
- ,CpLinkManID
- ,CpAccountID
- ,''
- ,Exten
- FROM @t a LEFT JOIN Wutongguodb..CpLinkMan b WITH(NOLOCK) ON a.CpLinkManID = b.ID
- LEFT JOIN Wutongguodb..CpAccount c WITH(NOLOCK) ON a.CpAccountID = c.ID
- WHERE a.IsWtg=1 AND (CpLinkManID >0 OR CpLinkManID>0)
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobByAlipayEndSelect] Script Date: 2018/12/13 19:10:56 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --职位下线存储过程
- CREATE PROCEDURE [dbo].[procJobByAlipayEndSelect]
- (
- @BeginDate VARCHAR(50)
- )
- AS
- BEGIN
- SELECT ID
- FROM Job WITH(NOLOCK)
- WHERE IssueEnd BETWEEN @BeginDate AND GETDATE()
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobByAlipayPushSelect] Script Date: 2018/12/13 19:10:56 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procJobByAlipayPushSelect]
- AS
- BEGIN
- CREATE TABLE #T(
- JobID INT,
- JobName NVARCHAR(128),
- JobDesc NVARCHAR(MAX),
- dcJobType INT,
- JobTypeLevel1ID VARCHAR(32),
- JobTypeLevel2ID VARCHAR(32),
- JobTypeLevel3ID VARCHAR(32),
- JobTypeLevel1Name NVARCHAR(50),
- JobTypeLevel2Name NVARCHAR(50),
- JobTypeLevel3Name NVARCHAR(50),
- JobTag NVARCHAR(1000),
- NeedNum INT,
- EmployType TINYINT,
- dcEducationID TINYINT,
- dcSalaryMin VARCHAR(20),
- dcSalaryMax VARCHAR(20),
- CpMainID INT,
- CpName NVARCHAR(256),
- CpLogo VARCHAR(256),
- dcRegionID VARCHAR(6),
- ProvinceID VARCHAR(6),
- ProvinceName NVARCHAR(20),
- CityID VARCHAR(6),
- CityName NVARCHAR(20),
- DistrictID VARCHAR(6),
- DistrictName NVARCHAR(20),
- IssueEnd SMALLDATETIME,
- IssueDate SMALLDATETIME,
- RefreshDate SMALLDATETIME ,
- industry_tier1_code VARCHAR(30),
- industry_tier1 NVARCHAR(50),
- industry_tier2_code VARCHAR(30),
- industry_tier2 NVARCHAR(50),
- homepage VARCHAR(256),
- CpAddress NVARCHAR(256),
- lng VARCHAR(20),
- lat VARCHAR(20),
- ApplyEmail VARCHAR(200)
- )
- INSERT INTO #T(JobID,JobName,JobDesc,dcJobType,NeedNum,EmployType,dcEducationID,CpMainID,dcRegionID,IssueEnd,IssueDate,RefreshDate,dcSalaryMin,dcSalaryMax)
- SELECT TOP 100 a.ID,a.Name,'岗位职责:'+a.Responsibility+'岗位要求:'+a.Demand,a.dcJobTypeID,a.NeedNumber,a.EmployType,a.dcEducationID,a.cpMainID,a.dcRegionID,a.IssueEnd,a.IssueDate,a.RefreshDate,REPLACE(b.DescriptionCp,'K',''),REPLACE(c.DescriptionCp,'K','')
- FROM Job a WITH(NOLOCK)
- LEFT JOIN dcSalary b WITH(NOLOCK) ON b.id = a.dcSalaryID
- LEFT JOIN dcSalary c WITH(NOLOCK) ON c.id = a.dcSalaryIdMax
- WHERE a.Valid = 1
- AND a.id > (SELECT ISNULL(MAX(JobID),0) FROM LogDb..AlipayJobPushLog WITH(NOLOCK))
- AND a.dcSalaryID <> 100
- ORDER BY a.ID ASC
- INSERT INTO LogDb..AlipayJobPushLog(JobId,PushStatus)
- SELECT JobID,0
- FROM #T
- --改为支付宝对应的职位类别信息
- UPDATE a
- SET a.JobTypeLevel3ID = c.alipayID,a.JobTypeLevel3Name = c.alipayDescription
- FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
- WHERE CONVERT(VARCHAR,a.dcJobType) = b.qlrcID
- AND c.id = b.dcAlipayDicID
- AND b.DataType = 3
- AND c.AlipayLevel = 3
- UPDATE #T
- SET JobTypeLevel2ID = (SELECT TOP 1 alipayParentId FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.JobTypeLevel3ID AND DataType = 3)
- WHERE JobTypeLevel3ID IS NOT NULL
- UPDATE #T
- SET JobTypeLevel2Name = (SELECT TOP 1 alipayDescription FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.JobTypeLevel2ID AND DataType = 3)
- WHERE JobTypeLevel2ID IS NOT NULL
- UPDATE a
- SET a.JobTypeLevel2ID = c.alipayID,a.JobTypeLevel2Name = c.alipayDescription
- FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
- WHERE CONVERT(VARCHAR,a.dcJobType) = b.qlrcID
- AND c.id = b.dcAlipayDicID
- AND b.DataType = 3
- AND c.AlipayLevel = 2
- UPDATE #T
- SET JobTypeLevel1ID = (SELECT TOP 1 alipayParentId FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.JobTypeLevel2ID AND DataType = 3)
- WHERE JobTypeLevel2ID IS NOT NULL
- UPDATE #T
- SET JobTypeLevel1Name = (SELECT TOP 1 alipayDescription FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.JobTypeLevel1ID AND DataType = 3)
- WHERE JobTypeLevel1ID IS NOT NULL
- UPDATE a
- SET a.JobTypeLevel1ID = c.alipayID,a.JobTypeLevel1Name = c.alipayDescription
- FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
- WHERE CONVERT(VARCHAR,a.dcJobType) = b.qlrcID
- AND c.id = b.dcAlipayDicID
- AND b.DataType = 3
- AND c.AlipayLevel = 1
- --改为支付宝对应的省份信息
- UPDATE a
- SET a.ProvinceID = c.alipayID,a.ProvinceName = c.alipayDescription
- FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
- WHERE LEFT(a.dcRegionID,2) = b.qlrcID
- AND c.id = b.dcAlipayDicID
- AND b.DataType = 1
- --改为支付宝对应的城市信息
- --修改直辖市的市与省对应
- UPDATE #T
- SET CityID = ProvinceID,CityName = ProvinceName
- WHERE CONVERT(INT,LEFT(dcRegionID,2)) IN(10,11,30,60,90,91,92)
- --非直辖市的并且可以查到城市信息的
- UPDATE a
- SET a.CityID = c.alipayID,a.CityName = c.alipayDescription
- FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
- WHERE LEFT(a.dcRegionID,4) = b.qlrcID
- AND c.id = b.dcAlipayDicID
- AND b.DataType = 1
- AND c.alipaylevel = 2
- AND a.CityID IS NULL
- AND LEN(a.dcRegionID) >=4
- --非直辖市,并且只有省份的修改为直辖市
- UPDATE a
- SET a.CityID = c.alipayID,a.CityName = c.alipayDescription
- FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
- WHERE a.dcRegionID+'01' = b.qlrcID
- AND c.id = b.dcAlipayDicID
- AND b.DataType = 1
- AND c.alipaylevel = 2
- AND a.CityID IS NULL
- AND LEN(a.dcRegionID) = 2
- --改为支付宝对应的区的信息
- UPDATE a
- SET a.DistrictID = c.alipayID,a.DistrictName = c.alipayDescription
- FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
- WHERE a.dcRegionID = b.qlrcID
- AND c.id = b.dcAlipayDicID
- AND b.DataType = 1
- AND c.alipaylevel = 3
- --修改企业名称字段
- UPDATE a
- SET cpName = b.Name
- FROM #T a WITH(NOLOCK),cpMain b WITH(NOLOCK)
- WHERE a.cpMainID = b.ID
- UPDATE #T
- SET CpLogo = (SELECT TOP 1 ImgFile FROM cpImage WITH(NOLOCK) WHERE cpMainID = #T.cpMainID AND ImgType = 1 ORDER BY AddDate DESC)
- UPDATE #T
- SET JobTag = (
- SELECT STUFF((
- SELECT ',' + Tags
- FROM JobTags WITH(NOLOCK)
- WHERE JobID = #T.JobID
- FOR XML PATH('')),1,1,'' )
- )
- --设置企业信息结构
- UPDATE a
- SET a.homepage = b.HomePage,a.CpAddress = b.Address,a.lng = b.Lng,a.lat = b.Lat,a.ApplyEmail = c.EMail
- FROM #T a WITH(NOLOCK),cpmain b WITH(NOLOCK),camain c WITH(NOLOCK)
- WHERE a.CpMainID = b.ID
- AND c.cpMainID = b.ID
- AND c.AccountType = 1
- --设置企业信息所属二级行业code
- UPDATE #T
- SET industry_tier2_code = (
- SELECT TOP 1 d.alipayid
- FROM #T a WITH(NOLOCK),cpIndustry b WITH(NOLOCK),dcAlipayDicConvert c WITH(NOLOCK),dcAlipayDic d WITH(NOLOCK)
- WHERE a.CpMainID = b.cpMainID
- AND c.qlrcId = b.dcIndustryID
- AND d.id = c.dcAlipayDicId
- AND c.DataType = 2
- )
- --设置企业信息所属二级行业
- UPDATE #T
- SET industry_tier2 = (SELECT TOP 1 alipayDescription FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.industry_tier2_code AND DataType = 2)
- WHERE industry_tier2_code IS NOT NULL
- --设置企业信息所属一级行业code
- UPDATE #T
- SET industry_tier1_code = (SELECT TOP 1 alipayParentId FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.industry_tier2_code AND DataType = 2)
- WHERE industry_tier2_code IS NOT NULL
- --设置企业信息所属一级行业
- UPDATE #T
- SET industry_tier1 = (SELECT TOP 1 alipayDescription FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.industry_tier1_code AND DataType = 2)
- WHERE industry_tier1_code IS NOT NULL
- SELECT a.*,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 #T a
- LEFT JOIN Job b WITH(NOLOCK) ON b.id = a.JobID
- DROP TABLE #T
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobByAlipayRefreshSelect] Script Date: 2018/12/13 19:10:57 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --职位刷新存储过程
- CREATE PROCEDURE [dbo].[procJobByAlipayRefreshSelect]
- (
- @BeginDate VARCHAR(50)
- )
- AS
- BEGIN
- SELECT ID,IssueEnd,RefreshDate
- FROM Job WITH(NOLOCK)
- WHERE Valid = 1
- AND RefreshDate > @BeginDate
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobByAlipaySelect] Script Date: 2018/12/13 19:10:58 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procJobByAlipaySelect]
- (
- @BeginDate VARCHAR(50)
- )
- AS
- BEGIN
- CREATE TABLE #T(
- JobID INT,
- JobName NVARCHAR(128),
- JobDesc NVARCHAR(MAX),
- dcJobType INT,
- JobTypeLevel1ID VARCHAR(32),
- JobTypeLevel2ID VARCHAR(32),
- JobTypeLevel3ID VARCHAR(32),
- JobTypeLevel1Name NVARCHAR(50),
- JobTypeLevel2Name NVARCHAR(50),
- JobTypeLevel3Name NVARCHAR(50),
- JobTag NVARCHAR(1000),
- NeedNum INT,
- EmployType TINYINT,
- dcEducationID TINYINT,
- dcSalaryMin VARCHAR(20),
- dcSalaryMax VARCHAR(20),
- CpMainID INT,
- CpName NVARCHAR(256),
- CpLogo VARCHAR(256),
- dcRegionID VARCHAR(6),
- ProvinceID VARCHAR(6),
- ProvinceName NVARCHAR(20),
- CityID VARCHAR(6),
- CityName NVARCHAR(20),
- DistrictID VARCHAR(6),
- DistrictName NVARCHAR(20),
- IssueEnd SMALLDATETIME,
- IssueDate SMALLDATETIME,
- RefreshDate SMALLDATETIME ,
- industry_tier1_code VARCHAR(30),
- industry_tier1 NVARCHAR(50),
- industry_tier2_code VARCHAR(30),
- industry_tier2 NVARCHAR(50),
- homepage VARCHAR(256),
- CpAddress NVARCHAR(256),
- lng VARCHAR(20),
- lat VARCHAR(20),
- ApplyEmail VARCHAR(200)
- )
- INSERT INTO #T(JobID,JobName,JobDesc,dcJobType,NeedNum,EmployType,dcEducationID,CpMainID,dcRegionID,IssueEnd,IssueDate,RefreshDate,dcSalaryMin,dcSalaryMax)
- SELECT a.ID,a.Name,'岗位职责:'+a.Responsibility+'岗位要求:'+a.Demand,a.dcJobTypeID,a.NeedNumber,a.EmployType,a.dcEducationID,a.cpMainID,a.dcRegionID,a.IssueEnd,a.IssueDate,a.RefreshDate,REPLACE(b.DescriptionCp,'K',''),REPLACE(c.DescriptionCp,'K','')
- FROM logdb..AlipayJobPushLog d WITH(NOLOCK)
- LEFT JOIN Job a WITH(NOLOCK) ON d.JobId = a.ID
- LEFT JOIN dcSalary b WITH(NOLOCK) ON b.id = a.dcSalaryID
- LEFT JOIN dcSalary c WITH(NOLOCK) ON c.id = a.dcSalaryIdMax
- WHERE a.dcSalaryID <> 100
- AND d.PushDate IS NULL
-
- UPDATE logdb..AlipayJobPushLog SET PushDate = GETDATE()
- WHERE JobID IN(SELECT JobID FROM #T)
- --改为支付宝对应的职位类别信息
- UPDATE a
- SET a.JobTypeLevel3ID = c.alipayID,a.JobTypeLevel3Name = c.alipayDescription
- FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
- WHERE CONVERT(VARCHAR,a.dcJobType) = b.qlrcID
- AND c.id = b.dcAlipayDicID
- AND b.DataType = 3
- AND c.AlipayLevel = 3
- UPDATE #T
- SET JobTypeLevel2ID = (SELECT TOP 1 alipayParentId FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.JobTypeLevel3ID AND DataType = 3)
- WHERE JobTypeLevel3ID IS NOT NULL
- UPDATE #T
- SET JobTypeLevel2Name = (SELECT TOP 1 alipayDescription FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.JobTypeLevel2ID AND DataType = 3)
- WHERE JobTypeLevel2ID IS NOT NULL
- UPDATE a
- SET a.JobTypeLevel2ID = c.alipayID,a.JobTypeLevel2Name = c.alipayDescription
- FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
- WHERE CONVERT(VARCHAR,a.dcJobType) = b.qlrcID
- AND c.id = b.dcAlipayDicID
- AND b.DataType = 3
- AND c.AlipayLevel = 2
- UPDATE #T
- SET JobTypeLevel1ID = (SELECT TOP 1 alipayParentId FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.JobTypeLevel2ID AND DataType = 3)
- WHERE JobTypeLevel2ID IS NOT NULL
- UPDATE #T
- SET JobTypeLevel1Name = (SELECT TOP 1 alipayDescription FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.JobTypeLevel1ID AND DataType = 3)
- WHERE JobTypeLevel1ID IS NOT NULL
- UPDATE a
- SET a.JobTypeLevel1ID = c.alipayID,a.JobTypeLevel1Name = c.alipayDescription
- FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
- WHERE CONVERT(VARCHAR,a.dcJobType) = b.qlrcID
- AND c.id = b.dcAlipayDicID
- AND b.DataType = 3
- AND c.AlipayLevel = 1
- --改为支付宝对应的省份信息
- UPDATE a
- SET a.ProvinceID = c.alipayID,a.ProvinceName = c.alipayDescription
- FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
- WHERE LEFT(a.dcRegionID,2) = b.qlrcID
- AND c.id = b.dcAlipayDicID
- AND b.DataType = 1
- --改为支付宝对应的城市信息
- --修改直辖市的市与省对应
- UPDATE #T
- SET CityID = ProvinceID,CityName = ProvinceName
- WHERE CONVERT(INT,LEFT(dcRegionID,2)) IN(10,11,30,60,90,91,92)
- --非直辖市的并且可以查到城市信息的
- UPDATE a
- SET a.CityID = c.alipayID,a.CityName = c.alipayDescription
- FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
- WHERE LEFT(a.dcRegionID,4) = b.qlrcID
- AND c.id = b.dcAlipayDicID
- AND b.DataType = 1
- AND c.alipaylevel = 2
- AND a.CityID IS NULL
- AND LEN(a.dcRegionID) >=4
- --非直辖市,并且只有省份的修改为直辖市
- UPDATE a
- SET a.CityID = c.alipayID,a.CityName = c.alipayDescription
- FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
- WHERE a.dcRegionID+'01' = b.qlrcID
- AND c.id = b.dcAlipayDicID
- AND b.DataType = 1
- AND c.alipaylevel = 2
- AND a.CityID IS NULL
- AND LEN(a.dcRegionID) = 2
- --改为支付宝对应的区的信息
- UPDATE a
- SET a.DistrictID = c.alipayID,a.DistrictName = c.alipayDescription
- FROM #T a WITH(NOLOCK),dcAlipayDicConvert b WITH(NOLOCK),dcAlipayDic c WITH(NOLOCK)
- WHERE a.dcRegionID = b.qlrcID
- AND c.id = b.dcAlipayDicID
- AND b.DataType = 1
- AND c.alipaylevel = 3
- --修改企业名称字段
- UPDATE a
- SET cpName = b.Name
- FROM #T a WITH(NOLOCK),cpMain b WITH(NOLOCK)
- WHERE a.cpMainID = b.ID
- UPDATE #T
- SET JobTag = (
- SELECT STUFF((
- SELECT ',' + Tags
- FROM JobTags WITH(NOLOCK)
- WHERE JobID = #T.JobID
- FOR XML PATH('')),1,1,'' )
- )
- --设置企业信息结构
- UPDATE a
- SET a.homepage = b.HomePage,a.CpAddress = b.Address,a.lng = b.Lng,a.lat = b.Lat,a.ApplyEmail = c.EMail,CpLogo = b.LogoFile
- FROM #T a WITH(NOLOCK),cpmain b WITH(NOLOCK),camain c WITH(NOLOCK)
- WHERE a.CpMainID = b.ID
- AND c.cpMainID = b.ID
- AND c.AccountType = 1
- --设置企业信息所属二级行业code
- UPDATE #T
- SET industry_tier2_code = (
- SELECT TOP 1 d.alipayid
- FROM #T a WITH(NOLOCK),cpIndustry b WITH(NOLOCK),dcAlipayDicConvert c WITH(NOLOCK),dcAlipayDic d WITH(NOLOCK)
- WHERE a.CpMainID = b.cpMainID
- AND c.qlrcId = b.dcIndustryID
- AND d.id = c.dcAlipayDicId
- AND c.DataType = 2
- )
- --设置企业信息所属二级行业
- UPDATE #T
- SET industry_tier2 = (SELECT TOP 1 alipayDescription FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.industry_tier2_code AND DataType = 2)
- WHERE industry_tier2_code IS NOT NULL
- --设置企业信息所属一级行业code
- UPDATE #T
- SET industry_tier1_code = (SELECT TOP 1 alipayParentId FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.industry_tier2_code AND DataType = 2)
- WHERE industry_tier2_code IS NOT NULL
- --设置企业信息所属一级行业
- UPDATE #T
- SET industry_tier1 = (SELECT TOP 1 alipayDescription FROM dcAlipayDic WITH(NOLOCK) WHERE alipayId = #T.industry_tier1_code AND DataType = 2)
- WHERE industry_tier1_code IS NOT NULL
- SELECT a.*,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 #T a
- LEFT JOIN Job b WITH(NOLOCK) ON b.id = a.JobID
- DROP TABLE #T
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobByCaMainIDSelect] Script Date: 2018/12/13 19:10:58 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:本用户正在发布的职位列表
- --修改:2015-01-15 Andy
- -- 1. 添加dcRegionID列
- -- 2. 去掉try catch
- --#####################################################
- CREATE PROCEDURE [dbo].[procJobByCaMainIDSelect]
- (
- @caMainID INT
- )
- AS
- BEGIN
- SELECT ID, Name, dcRegionID FROM job WITH(NOLOCK) WHERE camainid = @caMainID AND Valid = 1
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobByConditionCaMainIDSelect] Script Date: 2018/12/13 19:10:59 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.04
- --创建人:Nick
- --说明:
- --修改harry 2017-10-19 修改status=1的显示定制刷新状态jobrefreshIng
- --#####################################################
- CREATE PROCEDURE [dbo].[procJobByConditionCaMainIDSelect]
- (
- @CaMainID INT,
- @Condition VARCHAR(500),
- @Status INT
- )
- AS
- BEGIN TRY
- IF CHARINDEX('@',@Condition)>0
- BEGIN
- IF @Status = 1
- BEGIN
- SELECT *,CASE WHEN EXISTS(SELECT 'X' FROM jobRefreshLog WHERE jobId = job.id AND runDateTime is NULL) THEN 1 ELSE 0 END AS jobrefreshIng
- FROM Job WITH(NOLOCK)
- WHERE caMainID=@CaMainID
- AND [ForwardEmail] LIKE '%'+@Condition+'%'
- AND IsDelete=0
- AND IssueEND > GETDATE()
- ORDER BY DisplayNo, IssueEnd, ID DESC
- END
- ELSE
- BEGIN
- SELECT * FROM Job WITH(NOLOCK)
- WHERE caMainID=@CaMainID
- AND [ForwardEmail] LIKE '%'+@Condition+'%'
- AND IsDelete=0
- AND IssueEND < GETDATE()
- ORDER BY IssueEnd DESC
- END
- END
- ELSE
- BEGIN
- IF @Status = 1
- BEGIN
- SELECT *,CASE WHEN EXISTS(SELECT 'X' FROM jobRefreshLog WHERE jobId = job.id AND runDateTime is NULL) THEN 1 ELSE 0 END AS jobrefreshIng
- FROM Job WITH(NOLOCK)
- WHERE caMainID=@CaMainID
- AND [Name] LIKE '%'+@Condition+'%'
- AND IsDelete=0
- AND IssueEND > GETDATE()
- ORDER BY DisplayNo, IssueEnd, ID DESC
- END
- ELSE
- BEGIN
- SELECT * FROM Job WITH(NOLOCK)
- WHERE caMainID=@CaMainID
- AND [Name] LIKE '%'+@Condition+'%'
- AND IsDelete=0
- AND IssueEND < GETDATE()
- ORDER BY IssueEnd DESC
- END
- END
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procJobByConditionSelect] Script Date: 2018/12/13 19:10:59 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.04
- --创建人:Nick
- --说明:企业搜索发布的指定职位
- --修改harry 2017-10-19 修改status=1的显示定制刷新状态jobrefreshIng
- --#####################################################
- CREATE PROCEDURE [dbo].[procJobByConditionSelect]
- (
- @CpMainID INT,
- @Condition VARCHAR(500),
- @Status INT
- )
- AS
- BEGIN TRY
- IF @Status = 1
- BEGIN
- SELECT * ,CASE WHEN EXISTS(SELECT 'X' FROM jobRefreshLog WHERE jobId = job.id AND runDateTime is NULL) THEN 1 ELSE 0 END AS jobrefreshIng
- FROM Job WITH(NOLOCK)
- WHERE cpMainID=@CpMainID
- AND [Name] LIKE '%'+@Condition+'%'
- AND IsDelete=0
- AND IssueEND > GETDATE()
- ORDER BY DisplayNo, IssueEnd, ID DESC
- END
- ELSE
- BEGIN
- SELECT * FROM Job WITH(NOLOCK)
- WHERE cpMainID=@CpMainID
- AND [Name] LIKE '%'+@Condition+'%'
- AND IsDelete=0
- AND IssueEND < GETDATE()
- ORDER BY IssueEnd DESC
- END
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcJobByCpMainID] Script Date: 2018/12/13 19:10:59 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --创建人 Lambo
- --20101009
- --用于首页根据单位编号查询职位名称
- CREATE PROCEDURE [dbo].[ProcJobByCpMainID]
- (
- @cpMainID INT
- )
- AS
- BEGIN
- SELECT TOP 20 Id, Name
- FROM Job WITH(NOLOCK)
- WHERE cpMainID = @cpMainID AND valid=1
- ORDER BY DisplayNo, dcJobTypeID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobByCpMainIDSelect] Script Date: 2018/12/13 19:10:59 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:得到公司正在发布的职位列表
- --#####################################################
- CREATE PROCEDURE [dbo].[procJobByCpMainIDSelect]
- (
- @cpMainID INT
- )
- AS
- BEGIN TRY
- SELECT a.ID,a.Name,a.IssueEnd
- FROM Job a WITH(NOLOCK)
- WHERE a.cpMainID = @cpMainID AND Valid=1
- ORDER BY a.Valid DESC,a.IssueEnd DESC
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procJobByIDSelect] Script Date: 2018/12/13 19:10:59 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:获取职位的过滤条件
- --#####################################################
- CREATE PROCEDURE [dbo].[procJobByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- SELECT * FROM Job WITH(NOLOCK) WHERE Id = @ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcJobByIndustryIdSelect] Script Date: 2018/12/13 19:11:00 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2015.3.31
- --创建人:Andy
- --说明:获取可能感兴趣的公司
- --#####################################################
- --ProcJobByIndustryIdSelect 1,1
- CREATE PROCEDURE [dbo].[ProcJobByIndustryIdSelect]
- (
- @RegionID INT,
- @IndustryID INT
- )
- AS
- BEGIN
- SELECT TOP 10
- a.cpMainID,
- a.RefreshDate,
- a.dcRegionID,
- a.Name,
- a.dcSalaryID,
- a.SecondID,
- b.Name cpName,
- b.SecondID cpSecondID,
- b.LastLoginDate,
- (SELECT subSiteUrl FROM dcSubSite WHERE id = b.dcProvinceID) subSiteUrl
- FROM jobPublish a
- LEFT JOIN cpMain b ON a.CpMainID = b.ID
- WHERE a.cpMainId IN
- (
- SELECT TOP 10 realid
- FROM Searchdb..CpMainSameIndustry WITH(NOLOCK)
- WHERE dcIndustryID = @IndustryID AND dcRegionId = @RegionID
- )
- ORDER BY RefreshDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcJobByJobuiIndexSelect] Script Date: 2018/12/13 19:11:00 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- create PROCEDURE [dbo].[ProcJobByJobuiIndexSelect]
- AS
- SET NOCOUNT ON
- BEGIN
- SELECT DISTINCT dcProvinceId, PageNo
- FROM ShortDb..JobuiJobXmlOut
- ORDER BY dcProvinceId, PageNo
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcJobByJobuiSelect] Script Date: 2018/12/13 19:11:00 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcJobByJobuiSelect]
- (
- @ProvinceId INT,
- @PageNo INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- IF ISNULL(@ProvinceId, 0) < 10
- SELECT @ProvinceId = 10
- IF ISNULL(@PageNo, 0) < 1
- SELECT @PageNo = 1
- SELECT * FROM ShortDb..JobuiJobXmlOut WHERE dcProvinceId = @ProvinceId AND PageNo = @PageNo ORDER BY Id
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcJobByNewst30Select] Script Date: 2018/12/13 19:11:00 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcJobByNewst30Select]
- (
- @dcProvinceID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- 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,
- 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.RealName, b.UnLimitedDate, b.BalanceDate, b.Balance,
- b.MemberType, '' cpIndustry, --STUFF((SELECT ',' + LTRIM(x.dcIndustryid) + ',c' + LTRIM(isnull(y.Category,0)) FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
- 0, b.IsRefreshed, ISNULL(d.IsOnline, 0) IsOnline, d.IsVi, d.ViPlanId, d.InterviewDate, CASE WHEN b.ReplyRate >= 0.6 THEN b.ReplyRate ELSE NULL END Replyrate,
- NULL AttentionId
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
- LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
- WHERE b.dcProvinceId = @dcProvinceID
- ORDER BY a.RefreshDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobBySalarySelect] Script Date: 2018/12/13 19:11:01 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procJobBySalarySelect]
- (
- @dcJobTypeId INT,
- @dcRegionId VARCHAR(6)
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @AddDate DATETIME
- SELECT TOP 1 @AddDate = AddDate FROM ShortDb..JobSalaryAnalysis QITH(NOLOCK) WHERE JobTypeId = @dcjobTypeId AND RegionId = @dcRegionId
- IF @AddDate > DATEADD(MINUTE, -10, GETDATE())
- BEGIN
- SELECT * FROM ShortDb..JobSalaryAnalysis WITH(NOLOCK) WHERE JobTypeId = @dcjobTypeId AND RegionId = @dcRegionId ORDER BY RowNo
- RETURN
- END
- ELSE
- DELETE FROM ShortDb..JobSalaryAnalysis WHERE JobTypeId = @dcjobTypeId AND RegionId = @dcRegionId
- DECLARE @SQL AS VARCHAR(MAX)
- SET @SQL = 'INSERT INTO ShortDb..JobSalaryAnalysis
- SELECT TOP 60 ' + @dcRegionId + ' RegionId, ' + LTRIM(STR(@dcJobTypeId)) + ' JobTypeId, GETDATE() AddDate, a.Id, a.SecondId, a.Name JobName, a.NeedNumber, a.DcSalaryID,
- dbo.GetCaOnlineStatus(a.caMainID) AS IsOnline, a.MinExperience,a.caMainId, b.LogoFile LogoUrl, a.SecondId enjobid,
- a.DcSalaryIdMax, a.DcRegionID, b.Name CpName, a.dcEducationID, b.SecondId cpSecondId,
- STUFF((SELECT ''、'' + Tags FROM JobTags WITH(NOLOCK) WHERE jobID = a.ID FOR XML PATH('''')),1,1,'''') JobTags
- FROM JobPublish a WITH(NOLOCK) INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainId=b.Id
- WHERE a.cpMainID = b.ID AND dcSalaryIDMax < 100 AND dcSalaryID < 100'
- IF ISNULL(@dcRegionId, '') <> ''
- SET @SQL = @SQL + ' AND a.dcRegionID LIKE ''' + CONVERT(VARCHAR(4), @dcRegionId) + '%'''
- IF @dcJobTypeId > 0
- SET @SQL = @SQL + ' AND a.dcJobTypeID LIKE ''' + CONVERT(VARCHAR(4), @dcJobTypeId) + '%'''
- SET @SQL = @SQL + ' ORDER BY (dcSalaryIDMax + dcSalaryID) DESC, a.RefreshDate DESC'
- --PRINT @SQL
- EXEC(@SQL)
- SELECT * FROM ShortDb..JobSalaryAnalysis WITH(NOLOCK) WHERE JobTypeId = @dcjobTypeId AND RegionId = @dcRegionId ORDER BY RowNo
- END
- SET NOCOUNT OFF
- GO
- /****** Object: StoredProcedure [dbo].[procJobBySosoSelect] Script Date: 2018/12/13 19:11:01 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:John
- --说明:获取SosoXML数据
- --#####################################################
- CREATE PROCEDURE [dbo].[procJobBySosoSelect]
- (
- @pid INT
- )
- AS
- BEGIN
- SELECT a.id jobid,b.id cpid,a.name jobname,dbo.GetCpIndustry(b.id) industry,b.name cpname,a.dcSalaryID,g.DescriptionEng NeedNumber,
- f.description jobtypebig,b.dccompanykindid,e.description jobtypesmall,h.Description employtype,a.minexperience,c.fullname region,
- i.description education,a.issuedate,a.issueend,a.responsibility
- FROM job a WITH(NOLOCK) INNER JOIN cpmain b WITH(NOLOCK) ON a.cpmainid = b.id
- LEFT JOIN dcRegion c WITH(NOLOCK) ON c.id = a.dcRegionID
- LEFT JOIN dcJobType e WITH(NOLOCK) ON e.id = a.dcJobTypeID
- LEFT JOIN dcJobType f WITH(NOLOCK) ON f.id = left(a.dcJobTypeID,2)
- LEFT JOIN dcothers g WITH(NOLOCK) ON g.Category = '招聘人数' AND g.detailid = a.NeedNumber
- LEFT JOIN dcothers h WITH(NOLOCK) ON h.Category = '工作性质' AND h.detailid = a.employtype
- LEFT JOIN dceducation i WITH(NOLOCK) ON i.id = a.dceducationID
- WHERE a.valid = 1 AND b.valid = 1 AND dcprovinceid = @pid ORDER BY a.refreshdate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobCountByRegionIDSelect] Script Date: 2018/12/13 19:11:01 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:根据职位列表和工作地点获取数量
- --#####################################################
- CREATE PROCEDURE [dbo].[procJobCountByRegionIDSelect]
- (
- @RegionID VARCHAR(6),
- @JobTypeID VARCHAR(20)
- )
- AS
- BEGIN TRY
- SELECT COUNT(1) cnt
- FROM job a WITH(NOLOCK)
- WHERE a.dcjobtypeid LIKE ''+@JobTypeID+'%'
- AND a.dcregionid like ''+@RegionID+'%'
- AND a.Valid>0
- AND a.dcSalaryID IS NOT NULL
- AND a.dcSalaryID<>100
- AND a.RefreshDate>GetDate()-365
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procJobEMailSendFreqByIDUpdate] Script Date: 2018/12/13 19:11:01 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.04
- --创建人:Nick
- --说明:修改职位的订阅
- --#####################################################
- CREATE PROCEDURE [dbo].[procJobEMailSendFreqByIDUpdate]
- (
- @eMailSendFreq INT,
- @eMailSendNumber INT,
- @ID INT
- )
- AS
- BEGIN TRY
- UPDATE JOB SET EMailSendFreq=@eMailSendFreq, EMailSendNumber=@eMailSendNumber WHERE ID = @ID
- RETURN 1
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procJobJobTypeIDSelect] Script Date: 2018/12/13 19:11:01 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:获取职位列表、工作地点
- --#####################################################
- CREATE PROCEDURE [dbo].[procJobJobTypeIDSelect]
- (
- @CpMainID VARCHAR(20),
- @JobID VARCHAR(20),
- @CaMainID VARCHAR(20),
- @IsManager INT
- )
- AS
- BEGIN TRY
- IF @JobID = ''
- BEGIN
- IF @IsManager = 1
- BEGIN
- SELECT TOP 1 dcJobtypeID,dcRegionID
- FROM job WITH(NOLOCK)
- WHERE issueEnd>getdate()
- AND isdelete=0
- AND valid=1
- AND cpMainID= CONVERT(INT,@CpMainID)
- ORDER BY AddDate DESC
- END
- ELSE
- BEGIN
- SELECT TOP 1 dcJobtypeID,dcRegionID
- FROM job WITH(NOLOCK)
- WHERE issueEnd>getdate() AND isdelete=0 AND valid=1
- AND caMainID = CONVERT(INT,@CaMainID) ORDER BY AddDate DESC
- END
- END
- ELSE
- BEGIN
- SELECT TOP 1 dcJobtypeID,dcRegionID
- FROM job WITH(NOLOCK)
- WHERE issueEnd>getdate() AND isdelete=0 AND valid=1
- AND ID=CONVERT(INT,@JobID) AND cpMainID=CONVERT(INT,@CpMainID)
- END
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcJobMapIdByProvinceIdSelect] Script Date: 2018/12/13 19:11:02 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:John
- --说明:根据省份得到JobMap信息
- --@provinceId 省份编号
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcJobMapIdByProvinceIdSelect]
- (
- @provinceId VARCHAR(2)
- )
- AS
- BEGIN TRY
- SELECT ID FROM marketdb..MapClass WHERE dcSubSiteId = @provinceId
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcJobMatchDataByPaMainIDSelect] Script Date: 2018/12/13 19:11:02 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.4
- --创建人:John
- --说明:获取用于职位匹配的数据
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcJobMatchDataByPaMainIDSelect]
- (
- @paMainID INT
- )
- AS
- BEGIN
- SELECT TOP 1 a.ID cvMainID,Degree,ISNULL(RelatedWorkYears,0) RelatedWorkYears,dcSalaryID,IsNegotiable,dbo.BirthToAge(b.Birthday) age,
- STUFF((SELECT ',' + LTRIM(dcJobTypeID) FROM cvJobType WHERE cvMainid = a.ID FOR XML PATH('')),1,1,'') JobTypeID,
- STUFF((SELECT ',' + LTRIM(dcRegionID) FROM cvJobPlace WHERE cvMainid = a.ID FOR XML PATH('')),1,1,'') RegionID,
- STUFF((
- SELECT ','+LTRIM(x.dcIndustryID)+',c'+LTRIM(y.CateGoryId)
- FROM cvIndustry x WITH(NOLOCK),dcIndustryCategory y WITH(NOLOCK)
- WHERE x.dcIndustryid = y.dcIndustryid AND x.cvMainid = a.ID FOR XML PATH('')),1,1,'') Industry
- From cvMain a WITH(NOLOCK), paMain b WITH(NOLOCK)
- WHERE a.paMainID = b.ID AND paMainID = @paMainID
- ORDER BY a.CvLevel DESC,a.RefreshDate DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobNameCopySelect] Script Date: 2018/12/13 19:11:02 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procJobNameCopySelect]
- (
- @provinceId INT,
- @KeyWord VARCHAR(50),
- @Type INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @t AS TABLE(id INT IDENTITY(1, 1), JobName NVARCHAR(50), JobNumber INT)
- DECLARE @Top INT
- IF @Type = 1
- BEGIN
- INSERT INTO @t
- SELECT TOP 10 JobName, JobNumber
- FROM JobNameCopy WITH(NOLOCK)
- WHERE dcProvinceId = @provinceId
- AND JobName LIKE @KeyWord + '_%'
- ORDER BY JobNumber DESC
- SET @Top = 10 - @@ROWCOUNT
- END
- ELSE
- BEGIN
- INSERT INTO @t
- SELECT TOP 10 JobName, JobNumber
- FROM JobNameCopy WITH(NOLOCK)
- WHERE dcProvinceId = @provinceId
- AND PinYin LIKE @KeyWord + '_%'
- ORDER BY JobNumber DESC
- SET @Top = 10 - @@ROWCOUNT
- END
- IF @Top > 0
- INSERT INTO @t
- SELECT TOP (@Top) Name, ISNULL(AvgSalary, 0)
- FROM cpMainPublish WITH(NOLOCK)
- WHERE dcProvinceId = @provinceId
- AND CHARINDEX(@Keyword, Name) > 0
- ORDER BY AvgSalary DESC
-
- DECLARE @json VARCHAR(max)
- SET @json = (SELECT * FROM @t ORDER BY Id FOR JSON AUTO)
- SELECT @json jsonstr
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobPublishByRegionIdSelect] Script Date: 2018/12/13 19:11:02 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2015.7.3
- --创建人:MICE
- --说明:县级站获取5条最新职位
- --#####################################################
- CREATE PROCEDURE [dbo].[procJobPublishByRegionIdSelect]
- (
- @regionId INT
- )
- AS
- BEGIN
- SET NOCOUNT ON
- SELECT TOP 5 a.cpmainId, a.[Name] AS jobName, a.SecondId AS jobId, b.[Name] AS cpName
- FROM Maindb..JobPublish a WITH(NOLOCK) ,Maindb..cpMainPublish b WITH(NOLOCK)
- WHERE a.dcregionId = @regionId AND a.valid = 1 AND a.cpmainId = b.id
- ORDER BY a.LastModifyDate DESC
- SET NOCOUNT OFF
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcJobPublishMatch] Script Date: 2018/12/13 19:11:02 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcJobPublishMatch]
- AS
- BEGIN
- SET NOCOUNT on
- delete jobpublish where id in(select top 100 id from JobPublish WITH(NOLOCK) where valid=0)
- SELECT a.ID cpMainId, b.Id JobId
- INTO #3
- FROM cpMain a WITH(NOLOCK), Job b WITH(NOLOCK)
- WHERE a.id = b.cpMainId AND a.Valid= 1 AND b.Valid = 1
- AND b.id NOT IN(SELECT b.Id JobId
- FROM cpMainPublish a WITH(NOLOCK), JobPublish b WITH(NOLOCK)
- WHERE a.id = b.cpMainId AND a.Valid= 1 AND b.Valid = 1)
- AND a.LastLoginDate > CONVERT(VARCHAR(10), GETDATE() - 183, 120)
- DECLARE @S VARCHAR(MAX)
- SET @s = ''
- select DISTINCT @s = @s + 'UPDATE cpMain SET RefreshDate=RefreshDate WHERE ID = ' + LTRIM(STR(cpMainId)) + '
- '
- from #3
- --print @s
- EXEC(@S)
- SET @s = ''
- select @s = @s + 'UPDATE Job SET RefreshDate=RefreshDate WHERE ID = ' + LTRIM(STR(JobId)) + '
- '
- from #3
- print @s
- EXEC(@S)
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobPublishSelect] Script Date: 2018/12/13 19:11:03 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- /*
- go
- DECLARE @json NVARCHAR(MAX) = N'
- {
- "ip":"192.168.1.1",
- "province":"32",
- "JobType":"",
- "region":"32",
- "Negotiable":"0",
- "keyword":"齐鲁 人才",
- "cvJobType":"24",
- "cvregion":"3212"
- }';
- set @json = '{"dcJobTypeID" : "",
- "dcRegionId" : "32",
- "dcIndustryID" : "",
- "dcSalaryID" : "",
- "IsNegotiable" : "",
- "MinExperience" : "",
- "dcEducationID" : "",
- "EmployType" : "",
- "KeyWord" : "请填写关键词或选择职位",
- "KeyType" : "1",
- "Order" : "",
- "RefreshNo" : "32",
- "Type" : "1",
- "PageNumber" : "1",
- "SessionID" : "60.215.144.163",
- "CompanySizeID" : "",
- "JobID" : "0",
- "Welfare" : "",
- "IsOnline" : ""
- }
- '
- exec procJobPublishSelect '[{"dcRegionId":"32","dcIndustryID":"5"}]'
- go
- select * from jsonlist
- */
- CREATE PROCEDURE [dbo].[procJobPublishSelect]
- (
- @json nVARCHAR(max)
- )
- as
- SET NOCOUNT ON
- DECLARE @Start DATETIME
- SET @Start = GETDATE()
- DECLARE @Sql VARCHAR(MAX), @Order VARCHAR(1000), @Exe VARCHAR(MAX), @Result INT = 0, @CanReturn BIT = 0, @ValidJobNumber INT = 0
- BEGIN TRY
- --分析参数结束开始,约3ms
- DECLARE @t_value AS TABLE (name VARCHAR(20), para VARCHAR(500), seq int);
- INSERT INTO @t_value
- SELECT * FROM OPENJSON(@json);
- DECLARE @Province INT = 32,
- @JobType VARCHAR(50) = '', --职位类别
- @Region VARCHAR(50) = '', --求职地区
- @MapPlace INT = 0,
- @Industry VARCHAR(20) = '', --求职行业
- @MinSalary TINYINT = 0, --月薪
- @MaxSalary TINYINT = 0, --月薪
- @ReplyRate TINYINT = 0,
- @Negotiable TINYINT = 0, --1面议,不面议
- @Experience TINYINT = 100, --工作经验,100为未选择
- @Education TINYINT = 0, --最低学历
- @EmpType VARCHAR(10) = '', --工作性质,1全职;3兼职;4实习,
- @KeyWord NVARCHAR(50) = '', --关键词
- @PageNumber INT = 1, --翻页页码
- @CompanySize INT = 0, --企业规模
- @Welfare VARCHAR(50) = '',
- @OnlyOnline INT = 0, --1在线
- @OnlyEnv INT = 0,
- @cvRegion VARCHAR(50) = '',
- @cvJobType VARCHAR(50) = '',
- @ip VARCHAR(15) = '',
- @paMainId INT = 0,
- @JobSearchLogId INT = 0,
- @FilterLogID INT = 0,
- @Source INT = 1, --1-pc+m,10-app
- @ShowFilter INT = 1
-
- CREATE TABLE #t_jobid(Id INT IDENTITY(1, 1), JobId INT)
- CREATE TABLE #t_companyList(Id int NOT NULL, SecondId varchar(10) NULL, Name nvarchar(100) NULL, RealName TINYINT, Lng Decimal(8, 5), Lat DEcimal(8, 5), HasLicence BIT, LogoFile VARCHAR(90), dcRegionId varchar(6) NULL, dcIndustryID smallint NULL, JobNumber int NULL, seq INT IDENTITY(1, 1))
- CREATE TABLE #t_companyTemp(Id INT, AvgSalary INT, LastLogindate DATETIME, seq INT IDENTITY(1, 1))
- CREATE TABLE #FullText(Id INT IDENTITY(1, 1), Priority INT, JobId INT NOT NULL)
- DECLARE @t_filter AS TABLE (FilterType INT, TypeID VARCHAR(10), TypeNumber INT)
- DECLARE @t_top AS TABLE(JobID INT, seq int IDENTITY(1, 1))
- DECLARE @t_jobid AS TABLE(Id INT IDENTITY(1, 1), JobId INT, IsTop BIT)
- DECLARE @PageSize INT = 30, @FillJobId INT = 0, @cpMainResult INT = 0, @KeyJobTypeIds VARCHAR(24) = '', @para VARCHAR(100)
- DECLARE @strJobType AS VARCHAR(2000) = '', @strJobPlace AS VARCHAR(2000) = '', @strCvRegion VARCHAR(MAX) = '', @strCvJobType VARCHAR(MAX) = ''
- DECLARE @filterExpired INT = -30, @jobExpired INT = -1, @Logo VARCHAR(50) = '/content/personal/images/defaultCpImg.png'
- SELECT @Province = para FROM @t_value WHERE name = 'RefreshNo' AND para > 0
- IF @Province > 100
- SELECT @Province = @Province - 100, @OnlyEnv = 1
- SELECT @para = para FROM @t_value WHERE name = 'order' AND para > ''
- IF @para LIKE 'r=%'
- SET @ReplyRate = CONVERT(DECIMAL(4, 2), RIGHT(LEFT(@para, 5), 3)) * 100
- ELSE IF @para LIKE '%p=%'
- SET @paMainId = RIGHT(@para, LEN(@para) - CHARINDEX('p=', @para) - 1)
- SELECT @JobType = para FROM @t_value WHERE name = 'dcJobTypeID' AND para > ''
- SELECT @Region = para FROM @t_value WHERE name = 'dcRegionId' AND para > ''
- SELECT @Industry = para FROM @t_value WHERE name = 'dcIndustryID' AND para > ''
- SELECT @MinSalary = para FROM @t_value WHERE name = 'dcSalaryID' AND para > 0
- --SELECT @MaxSalary = para FROM @t_value WHERE name = 'maxSalary' AND para > 0
- IF @MinSalary > 0
- BEGIN
- IF @MinSalary < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
- SET @MaxSalary = @MinSalary + 1
- ELSE IF @MinSalary BETWEEN 101 AND 106 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
- SELECT @MaxSalary = @MinSalary - 99, @MinSalary = @MinSalary - 99
- ELSE IF @MinSalary BETWEEN 107 AND 113 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
- SELECT @MaxSalary = @MinSalary - 99, @MinSalary = @MinSalary - 100
- ELSE IF @MinSalary BETWEEN 114 AND 120
- SELECT @MaxSalary = @MinSalary - 99, @MinSalary = 17
- END
-
- SELECT @Negotiable = para FROM @t_value WHERE name = 'IsNegotiable' AND para = 1
- SELECT @Experience = para FROM @t_value WHERE name = 'MinExperience' AND para > 0
- SELECT @ReplyRate = para FROM @t_value WHERE name = 'replyrate' AND para > 0
- SELECT @Education = para FROM @t_value WHERE name = 'dcEducationID' AND para > 0
- SELECT @EmpType = para FROM @t_value WHERE name = 'EmployType' AND para > ''
- SELECT @KeyWord = para FROM @t_value WHERE name = 'KeyWord' AND para > ''
- SELECT @PageNumber = para FROM @t_value WHERE name = 'PageNumber' AND LEN(para) > 0 AND ISNUMERIC(para) = 1
- IF EXISTS(SELECT 'x' FROM @t_value WHERE name = 'CompanySizeID' AND LEN(para) > 0 AND ISNUMERIC(para) = 1)
- SELECT @CompanySize = para FROM @t_value WHERE name = 'CompanySizeID'
- SELECT @Welfare = para FROM @t_value WHERE name = 'Welfare' AND para > ''
- SELECT @OnlyOnline = para FROM @t_value WHERE name = 'IsOnline' AND para = 1
- SELECT @cvRegion = para FROM @t_value WHERE name = 'cvRegion' AND para > ''
- SELECT @cvJobType = para FROM @t_value WHERE name = 'cvJobType' AND para > ''
- SELECT @ip = para FROM @t_value WHERE name = 'SessionId' AND para > ''
- IF LEFT(@Region, 1) = 'p'
- SELECT @MapPlace = RIGHT(@Region, LEN(@Region) - 1), @Region = ''
- SELECT @Source = para FROM @t_value WHERE name = 'Source' AND para > 0
- SELECT @ShowFilter = para FROM @t_value WHERE name = 'Type' AND LEN(para) > 0
-
- IF LEN(@Keyword) > 14
- SET @CanReturn = 1
- IF EXISTS(SELECT TOP 1 'x' FROM RefuseIp WITH(NOLOCK) WHERE CHARINDEX(Ip, @ip) > 0)
- SET @CanReturn = 1
- IF CHARINDEX(', 0', @Region) > 0 OR CHARINDEX(', 0', @JobType) > 0
- OR CHARINDEX(', , ', @Region) > 0 OR CHARINDEX(', , ', @JobType) > 0
- OR LEN(@Region) > 35 OR LEN(@JobType) > 25
- SET @CanReturn = 1
- IF @CanReturn = 1
- BEGIN
- SELECT 0 ValidJobNumber
- SELECT TOP 0 * FROM JobTemp
- SELECT TOP 0 * FROM @t_filter
- SELECT TOP 0 * FROM @t_filter
- SELECT TOP 0 * FROM @t_filter
- SELECT TOP 0 * FROM @t_filter
- SELECT TOP 0 * FROM @t_filter
- SELECT TOP 0 * FROM @t_filter
- SELECT TOP 0 * FROM @t_filter
- RETURN
- END
-
- IF CHARINDEX('请填写', @KeyWord) > 0
- SET @KeyWord = ''
- IF LEN(@KeyWord) > 1
- BEGIN
- SET @KeyWord = LTRIM(RTRIM(@Keyword))
- WHILE CHARINDEX(' ', @Keyword) > 0
- SET @KeyWord = REPLACE(@Keyword, ' ', ' ')
- SET @KeyWord = REPLACE(REPLACE(@KeyWord, '''', ''''''), ';', '')
- END
- IF LEN(@KeyWord) < 2
- SET @Keyword = ''
- ----给null值变量赋默认值
- IF @EmpType NOT IN('3', '4')
- SET @EmpType = ''
- IF @MinSalary > 20 OR @MinSalary < 2
- SET @MinSalary = 0
- IF @MaxSalary > 20 OR @MaxSalary < 2
- SET @MaxSalary = 0
- SELECT @JobType = RTRIM(dbo.FormatIDS(@JobType)),
- @Industry = RTRIM(dbo.FormatIDS(@Industry)),
- @Welfare = RTRIM(dbo.FormatIDS(@Welfare)),
- @cvRegion = RTRIM(dbo.FormatIDS(@cvRegion)),
- @cvJobType = RTRIM(dbo.FormatIDS(@cvJobType))
- IF LEN(@Welfare) > 1
- BEGIN
- DECLARE @Welfare_temp VARCHAR(50)
- SET @Welfare_temp = ''
- SELECT @Welfare_temp = @Welfare_temp + a + ',' FROM dbo.fnSplit(@Welfare, ',') WHERE a <= 19 AND LEN(a) < 3
- IF LEN(@Welfare_temp) > 1
- SET @Welfare_temp = LEFT(@Welfare_temp, LEN(@Welfare_temp) - 1)
- SET @Welfare = @Welfare_temp
- END
-
- IF RIGHT(@JobType, 1) = ','
- SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
- IF RIGHT(@Region, 1) = ','
- SET @Region = LEFT(@Region, LEN(@Region) - 1)
- IF RIGHT(@Industry, 1) = ','
- SET @Industry = LEFT(@Industry, LEN(@Industry) - 1)
- --分析参数结束
-
- --记录参数开始
- DECLARE @crDate DATETIME, @inttemp INT
- SELECT TOP 1 @JobSearchLogId = id, @crDate = crDate, @inttemp = Result
- FROM JobSearchLog WITH(NOLOCK)
- WHERE Province = @Province AND JobType = @JobType AND Region = @Region AND MapPlace = @MapPlace AND Industry = @Industry
- AND MinSalary = @MinSalary AND MaxSalary = @MaxSalary AND ReplyRate = @ReplyRate AND Negotiable = @Negotiable AND Experience = @Experience
- AND Education = @Education AND EmpType = @EmpType AND KeyWord = @KeyWord AND CompanySize = @CompanySize
- AND Welfare = @Welfare AND OnlyOnline = @OnlyOnline AND OnlyEnv = @OnlyEnv AND cvRegion = @cvRegion AND cvJobType = @cvJobType
- AND crDate > DATEADD(MINUTE, @jobExpired, GETDATE())
- ORDER BY ID DESC
- --IF @JobSearchLogId > 0
- --BEGIN
- -- IF @inttemp >= 300
- -- BEGIN
- -- IF @crDate < DATEADD(MINUTE, @jobExpired, GETDATE())
- -- SET @JobSearchLogId = 0
- -- END
- -- ELSE
- -- BEGIN
- -- IF @crDate < DATEADD(MINUTE, @jobExpired * 10, GETDATE())
- -- SET @JobSearchLogId = 0
- -- END
- --END
- SELECT TOP 1 @FilterLogId = Id, @ValidJobNumber = Result
- FROM FilterLog WITH(NOLOCK)
- WHERE Province = @Province AND JobType = @JobType AND Region = @Region AND MapPlace = @MapPlace AND Industry = @Industry
- AND MinSalary = @MinSalary AND MaxSalary = @MaxSalary AND ReplyRate = @ReplyRate AND Negotiable = @Negotiable AND Experience = @Experience
- AND Education = @Education AND EmpType = @EmpType AND KeyWord = @KeyWord AND CompanySize = @CompanySize
- AND Welfare = @Welfare AND OnlyOnline = @OnlyOnline AND OnlyEnv = @OnlyEnv
- AND crDate > DATEADD(MINUTE, @filterExpired, GETDATE())
- ORDER BY ID DESC
- --记录参数结束
- --gen sql statement
- IF @FilterLogId = 0 OR @JobSearchLogId = 0
- BEGIN
- --make sql where
- ------生成具体的职位类别,因为职位类别有包含(父子)关系
- ----生成求聘职位
- IF LEN(@JobType) > 0
- BEGIN
- SELECT @strJobType = @strJobType + LTRIM(STR(a.id)) + ', '
- FROM dcJobType a WITH(NOLOCK),
- (SELECT * FROM dbo.fnSplit(@JobType, ',') WHERE a < 9999) b
- WHERE a.Id = b.a
- OR a.ParentId = b.a
- OR a.ParentId2 = b.a
- IF LEN(@strJobType) > 1
- SET @strJobType = LEFT(@strJobType, LEN(@strJobType) - 1)
- END
- ----生成工作地点
- IF @MapPlace > 0
- BEGIN
- DECLARE @Degree 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 = @MapPlace
- IF @Region LIKE '3201%'
- SET @Degree = 1000 / 100000.0
- ELSE
- SET @Degree = 2000 / 100000.0
-
- SET @strJobPlace = 'a.Lng BETWEEN ' + CONVERT(VARCHAR, @Lng - @Degree) +
- ' AND ' + CONVERT(VARCHAR, @Lng + @Degree) +
- ' AND a.Lat BETWEEN ' + CONVERT(VARCHAR, @Lat - @Degree) +
- ' AND ' + CONVERT(VARCHAR, @Lat + @Degree) +
- ' 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)
- END
- ELSE IF LEN(@Region) > 0
- BEGIN
- SELECT @strJobPlace =
- @strJobPlace + ' OR a.dcRegionId ' +
- CASE WHEN LEN(a) = 6
- THEN '= ''' + a + ''''
- ELSE 'LIKE ''' + a + '%'''
- END
- FROM dbo.fnSplit(@Region, ',')
- WHERE LEN(a) IN(2, 4, 6)
- IF LEN(@strJobPlace) > 4
- SET @strJobPlace = RIGHT(@strJobPlace, LEN(@strJobPlace) - 4)
- END
- --从job中搜索数据 开始
- ----组合语句 开始
- --SELECT TOP 2000 a.ID, a.cpMainId, a.dcJobTypeID, a.dcJobTypeIDMinor, a.dcSalaryID, a.dcRegionId, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID
- --SELECT #TOP# a.ID
- SET @SQL='
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID
- WHERE a.Valid = 1
- AND b.Valid = 1'
- ----职位有效,单位新有效
- IF LEN(@Industry) > 0
- SET @Sql = @Sql + '
- AND b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @Industry + '))'
-
- IF @Province > 0
- SET @Sql = @Sql + ' AND b.dcProvinceId = ' + LTRIM(STR(@Province))
- IF @ReplyRate IN(60, 70, 80, 90, 100)
- SET @Sql = @Sql + '
- AND b.ReplyRate >= ' + LEFT(@ReplyRate / 100.0, 3)
- IF @OnlyEnv = 1
- SET @Sql = @Sql + '
- AND b.HasEnvironment = 1'
- ----工作经验要求
- IF @Experience < 100
- SET @Sql = @Sql + '
- AND a.MinExperience = ' + LTRIM(STR(@Experience))
- ----学历要求
- ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
- IF @Education > 0
- IF @Education = 2
- SET @Sql = @Sql + '
- AND a.dcEducationID IN(2, 3, 4)'
- ELSE
- SET @Sql = @Sql + '
- AND a.dcEducationID = ' + LTRIM(STR(@Education))
- ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
- IF LEN(@EmpType) > 0
- SET @Sql = @Sql + '
- AND a.EmployType IN (' + @EmpType + ')'
- IF @CompanySize BETWEEN 1 AND 6
- SET @Sql = @Sql + '
- AND b.dcCompanySizeID = ' + LTRIM(STR(@CompanySize))
- IF LEN(@Welfare) > 0
- SET @Sql = @Sql + '
- AND a.Welfare' + REPLACE(@Welfare, ',', ' = 1 AND a.Welfare') + ' = 1'
-
- IF @OnlyOnline = 1
- SET @Sql = @Sql + '
- AND a.caMainId IN(SELECT caMainId FROM caOnline WITH(NOLOCK) WHERE IsOnline = 1)'
-
- ----职位类别
- IF @strJobType > ''
- SET @Sql = @Sql + '
- AND a.dcJobTypeID IN(' + @strJobType + ')'
- IF LEN(@strJobPlace) > 0
- SET @Sql = @Sql + '
- AND (' + @strJobPlace + ')'
- IF @Negotiable = 1
- SET @Sql = @Sql + '
- AND a.dcSalaryID = 100 ' -- OR a.Negotiable = 1
- ELSE IF @MinSalary > 0 AND @MaxSalary > 0
- SET @Sql = @Sql + '
- AND a.dcSalaryID <= ' + LTRIM(STR(@MaxSalary)) + '
- AND a.dcSalaryIdMax >= ' + LTRIM(STR(@MinSalary))
-
- IF @cvRegion > ''
- BEGIN
- SELECT @strCvRegion =
- @strCvRegion + ' OR a.dcRegionId ' +
- CASE WHEN LEN(a) = 6
- THEN '= ''' + a + ''''
- ELSE 'LIKE ''' + a + '%'''
- END
- FROM dbo.fnSplit(@cvRegion, ',')
- WHERE LEN(a) IN(2, 4, 6)
- SET @strCvRegion = RIGHT(@strCvRegion, LEN(@strCvRegion) - 4)
- END
- IF @cvJobType > ''
- BEGIN
- SELECT @strCvJobType = @strCvJobType + LTRIM(STR(a.id)) + ', '
- FROM dcJobType a WITH(NOLOCK),
- (SELECT * FROM dbo.fnSplit(@cvJobType, ',')) b
- WHERE a.Id = b.a
- OR a.ParentId = b.a
- OR a.ParentId2 = b.a
- IF LEN(@strCvJobType) > 1
- SET @strCvJobType = LEFT(@strCvJobType, LEN(@strCvJobType) - 1)
- END
- SET @Order = ' ORDER BY'
- IF @strCvRegion > ''
- BEGIN
- SET @Order = @Order + ' CASE WHEN ' + @strCvRegion + ' THEN 0 ELSE 2 END'
- IF @strCvJobType > ''
- SET @Order = @Order + '
- + CASE WHEN a.dcJobTypeId IN (' + @strCvJobType + ') THEN 0 ELSE 1 END,
- '
- ELSE
- SET @Order = @Order + ',
- '
- END
- ELSE IF @strCvJobType > ''
- SET @Order = @Order + ' CASE WHEN a.dcJobTypeId IN (' + @strCvJobType + ') THEN 0 ELSE 1 END,
- '
- SET @Order = @Order + ' a.RefreshDate DESC, a.SecondId DESC'
- END
- --gen sql end
-
- --get filter start
- IF @FilterLogID != 0
- BEGIN
- INSERT INTO @t_filter
- SELECT FilterType, TypeId, TypeNumber FROM JobFilter WITH(NOLOCK) WHERE FilterLogID = @FilterLogID
- BEGIN TRY
- UPDATE FilterLog SET ReUseNumber = ReUseNumber + 1 WHERE Id = @FilterLogID
- END TRY
- BEGIN CATCH
- END CATCH
- END
- ELSE
- BEGIN
- --获取符合条件的所有数据
- CREATE TABLE #Filter(
- Id INT IDENTITY(1, 1),
- [JobId] INT,
- [cpMainId] INT,
- [dcRegionId] [VARCHAR](6) NULL,
- [dcJobTypeID] [smallint] NOT NULL,
- [dcSalaryID] [tinyint] NOT NULL,
- [dcEducationID] [tinyint] NOT NULL,
- [MinExperience] [tinyint] NOT NULL,
- [IssueDate] [smalldatetime] NULL,
- [EmployType] [tinyint] NOT NULL,
- [dcCompanySizeID] [tinyint] NULL
- )
- IF @KeyWord = ''
- BEGIN
- SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
- + @Sql + @Order
- INSERT INTO #Filter
- EXEC(@Exe)
- SELECT @Result = @@ROWCOUNT
- END
- ELSE
- BEGIN
- --(1)显示职位名称中包含搜索的关键词的职位列表
- SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
- + @Sql
- + ' AND a.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%'' '
- + @Order
- INSERT INTO #Filter
- EXEC(@Exe)
- SELECT @Result = @@ROWCOUNT
- --(2)显示按照职位类别匹配规则的职位列表
- IF @Result < 2000
- BEGIN
- SELECT @KeyJobTypeIds = LTRIM(STR(id)) + ',' FROM dcJobType WHERE CHARINDEX(@Keyword, Description) > 0
- IF LEN(@KeyJobTypeIds) > 2
- SELECT @KeyJobTypeIds = LEFT(@KeyJobTypeIds, LEN(@KeyJobTypeIds) - 1)
- ELSE
- BEGIN
- SET @KeyJobTypeIds= ''
- SELECT @KeyJobTypeIds = dcJobtypeIds FROM KeyWord2JobType WITH(NOLOCK) WHERE Keyword = @Keyword
- END
- IF @KeyJobTypeIds > ''
- BEGIN
- SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
- + @Sql
- + ' AND a.dcJobTypeID IN(''' + @KeyJobTypeIds + ''')
- AND a.Id NOT IN(SELECT JobId FROM #Filter)'
- + @Order
- INSERT INTO #Filter
- EXEC(@Exe)
- SELECT @Result = @Result + @@ROWCOUNT
- END
- ELSE IF LEN(@Keyword) < 11
- INSERT INTO KeyWordLog(crDate, Keyword) SELECT GETDATE(), @Keyword
- END
-
- --(3)显示企业名称中包含搜索的关键词的职位列表
- IF @Result = 0
- BEGIN
- SET @Exe = 'SELECT DISTINCT TOP 2000 a.cpMainId, AvgSalary,b.LastLogindate '
- + @Sql
- + ' AND b.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%'' '
- + ' ORDER BY b.AvgSalary DESC, b.LastLogindate DESC'
- INSERT INTO #t_companyTemp
- EXEC(@Exe)
- SELECT @Result = @@ROWCOUNT
-
- IF @Result > 0
- BEGIN
- INSERT INTO #t_companyList
- SELECT a.Id, a.SecondId, a.Name, a.RealName, a.Lng, a.Lat, HasLicence, ISNULL(a.LogoFile, @Logo), a.dcRegionId,
- (SELECT TOP 1 dcIndustryId FROM cpIndustry WITH(NOLOCK) WHERE cpIndustry.cpMainID = a.Id) dcIndustryID,
- (SELECT COUNT(*) FROM JobPublish WITH(NOLOCK) WHERE JobPublish.cpMainId = a.Id) JobNumber
- FROM cpMainPublish a WITH(NOLOCK), #t_companyTemp b
- WHERE a.Id = b.Id
- ORDER BY b.seq
- SELECT @cpMainResult = @@ROWCOUNT
- SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
- + @Sql
- + ' AND a.cpMainId IN(SELECT ID FROM #t_companyTemp)'
- + @Order
- INSERT INTO #Filter
- EXEC(@Exe)
- SELECT @Result = @@ROWCOUNT
- END
- END
- ELSE IF @Result < 2000
- BEGIN
- SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
- + @Sql
- + ' AND b.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%''
- AND a.Id NOT IN(SELECT JobId FROM #Filter)'
- + @Order
- INSERT INTO #Filter
- EXEC(@Exe)
- SELECT @Result = @Result + @@ROWCOUNT
- END
-
- --(4)全文搜索匹配的职位列表
- IF @Result < 2000
- BEGIN
- INSERT #FullText
- SELECT TOP 5000 3000 + RANK, [Key]
- FROM FREETEXTTABLE(cpMainJob, *, @KeyWord, 100000) AS KeyJob ORDER BY RANK DESC
- SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
- + REPLACE(@Sql, 'INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID', 'INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID INNER JOIN #FullText ON a.ID = #FullText.JobId')
- + ' AND a.Id NOT IN(SELECT JobId FROM #Filter)'
- + REPLACE(@Order, ' ORDER BY', ' ORDER BY #FullText.Priority,')
- INSERT INTO #Filter
- EXEC(@Exe)
- SELECT @Result = @Result + @@ROWCOUNT
- END
- END
- SET @ValidJobNumber = @Result
-
- INSERT INTO #t_jobid
- SELECT TOP 2000 JobId FROM #Filter ORDER BY Id
- SET @FillJobId = 1
- ----生成筛选数据
- DECLARE @t_filtertemp1 AS TABLE (
- FilterType INT, --1 jobtype,
- TypeID VARCHAR(10),
- TypeNumber INT
- )
- DECLARE @t_filtertemp2 AS TABLE (
- FilterType INT,
- TypeID VARCHAR(10),
- TypeNumber INT
- )
- ----------------------------jobtype
- INSERT INTO @t_filtertemp1
- SELECT 1, dcJobTypeID, COUNT(*)
- FROM #Filter WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- IF LEN(@JobType) = 0
- INSERT INTO @t_filtertemp2
- SELECT 1, LEFT(TypeID, 2), SUM(TypeNumber)
- FROM @t_filtertemp1 GROUP BY LEFT(TypeID, 2)
- ELSE IF LEN(@JobType) = 2
- INSERT INTO @t_filtertemp2
- SELECT 1, TypeID, TypeNumber
- FROM @t_filtertemp1
- WHERE TypeID LIKE @JobType + '__'
- ELSE IF LEN(@JobType) > 4
- BEGIN
- INSERT INTO @t_filtertemp2 SELECT * FROM @t_filtertemp1
- INSERT INTO @t_filtertemp2
- SELECT 1, LEFT(TypeID, 2), SUM(TypeNumber)
- FROM @t_filtertemp1 GROUP BY LEFT(TypeID, 2)
- DELETE @t_filtertemp2 WHERE TypeID NOT IN(SELECT a FROM dbo.fnSplit(@JobType, ','))
- END
-
- INSERT INTO @t_filter SELECT * FROM @t_filtertemp2
- DELETE @t_filtertemp2
- DELETE @t_filtertemp1
- --------------------------region
- IF @Mapplace = 0
- BEGIN
- INSERT INTO @t_filtertemp1
- SELECT 2, dcRegionId, COUNT(*) FROM #Filter WITH(NOLOCK)
- GROUP BY dcRegionId ORDER BY dcRegionId
- ----计算全部地区,2位的数据
- IF LEN(@Region) = 0
- INSERT INTO @t_filtertemp2
- SELECT 2, LEFT(TypeID, 2) TypeID, SUM(TypeNumber) TypeNumber
- FROM @t_filtertemp1 GROUP BY LEFT(TypeID, 2)
- ELSE IF LEN(@Region) = 2
- INSERT INTO @t_filtertemp2
- SELECT 2, LEFT(TypeID, 4) TypeID, SUM(TypeNumber) TypeNumber
- FROM @t_filtertemp1 WHERE LEN(TypeID) >= 4 AND TypeId LIKE @Region + '%'
- GROUP BY LEFT(TypeID, 4)
- ELSE IF LEN(@Region) = 4
- INSERT INTO @t_filtertemp2
- SELECT 2, TypeID, TypeNumber
- FROM @t_filtertemp1 WHERE LEN(TypeID) = 6
- ELSE IF @Region LIKE '%,%'
- BEGIN
- INSERT INTO @t_filtertemp2
- SELECT 2, LEFT(TypeID, 2) TypeID, SUM(TypeNumber) TypeNumber
- FROM @t_filtertemp1 GROUP BY LEFT(TypeID, 2)
- INSERT INTO @t_filtertemp2
- SELECT 2, LEFT(TypeID, 4) TypeID, SUM(TypeNumber) TypeNumber
- FROM @t_filtertemp1 WHERE LEN(TypeID) >= 4
- GROUP BY LEFT(TypeID, 4)
- INSERT INTO @t_filtertemp2 SELECT * FROM @t_filtertemp1 WHERE LEN(TypeID) = 6
- DELETE @t_filtertemp2 WHERE TypeID NOT IN(SELECT a FROM dbo.FnSplit(@Region, ','))
- END
- INSERT INTO @t_filter SELECT * FROM @t_filtertemp2
- --DELETE @t_filtertemp2
- --DELETE @t_filtertemp1
- END
- ----------------------------
- INSERT INTO @t_filter
- SELECT 3, EmployType, COUNT(*)
- FROM #Filter WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO @t_filter
- SELECT 4, CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Filter 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 @t_filter
- SELECT 5, MinExperience, COUNT(*) FROM #Filter WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
- INSERT INTO @t_filter
- SELECT 6, dcCompanySizeID, COUNT(*) FROM #Filter WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO @t_filter
- SELECT 7, dcSalaryID, COUNT(*) FROM #Filter WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
-
- INSERT INTO @t_filter
- SELECT 8, dcIndustryID, COUNT(*)
- FROM #Filter a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)-- INDEX(NonClusteredIndex_cpIndustry_cpMainId))
- WHERE a.cpMainId = b.cpMainId
- GROUP BY b.dcIndustryId ORDER BY b.dcIndustryId
- ----记录筛选数据
- INSERT INTO FilterLog(crDate, Source, ip, Province, JobType, Region, MapPlace, Industry, MinSalary,
- MaxSalary, ReplyRate, Negotiable, Experience, Education, EmpType, KeyWord, CompanySize,
- Welfare, OnlyOnline, OnlyEnv, Result, SqlString, RunTime, DayMinute)
- SELECT GETDATE(), @Source, @ip, @Province, @JobType, @Region, @MapPlace, @Industry, @MinSalary,
- @MaxSalary, @ReplyRate, @Negotiable, @Experience, @Education, @EmpType, @KeyWord, @CompanySize,
- @Welfare, @OnlyOnline, @OnlyEnv, @ValidJobNumber, @Exe, DATEDIFF(MS, @Start, GETDATE()),
- ROUND(CONVERT(DECIMAL(18, 9), GETDATE()) % 1.0 * 60 * 24, 0)
- SET @FilterLogId = @@IDENTITY
- INSERT INTO JobFilter
- SELECT @FilterLogId FilterLogId, * FROM @t_filter
- INSERT INTO CompanyList
- SELECT @FilterLogId FilterLogId, * FROM #t_companyList
- END
- IF @JobSearchLogId > 0
- BEGIN
- UPDATE JobSearchLog SET ReUseNumber = ReUseNumber + 1 WHERE Id = @JobSearchLogId
- END
- ELSE
- BEGIN
- --select jobid
- SET @Result = 0
- IF @FillJobId = 1
- BEGIN
- SELECT @Result = COUNT(*) FROM #t_jobid
- END
- ELSE
- BEGIN
- TRUNCATE TABLE #t_jobid
- IF @KeyWord = ''
- BEGIN
- SET @Exe = 'SELECT TOP 2000 a.Id ' + @Sql + @Order
- INSERT INTO #t_jobid
- EXEC(@Exe)
- SET @Result = @@ROWCOUNT
- END
- ELSE
- BEGIN
- --(1)显示职位名称中包含搜索的关键词的职位列表
- SET @Exe = 'SELECT TOP 2000 a.Id '
- + @Sql
- + ' AND a.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%'' '
- + @Order
- INSERT INTO #t_jobid
- EXEC(@Exe)
- SELECT @Result = @@ROWCOUNT
- --(2)显示按照职位类别匹配规则的职位列表
- IF @Result < 2000
- BEGIN
- SELECT @KeyJobTypeIds = ''
- SELECT @KeyJobTypeIds = LTRIM(STR(id)) + ',' FROM dcJobType WHERE CHARINDEX(@Keyword, Description) > 0
- IF LEN(@KeyJobTypeIds) > 2
- SELECT @KeyJobTypeIds = LEFT(@KeyJobTypeIds, LEN(@KeyJobTypeIds) - 1)
- ELSE
- BEGIN
- SET @KeyJobTypeIds= ''
- SELECT @KeyJobTypeIds = dcJobtypeIds FROM KeyWord2JobType WITH(NOLOCK) WHERE Keyword = @Keyword
- END
-
- IF @KeyJobTypeIds > ''
- BEGIN
- SET @Exe = 'SELECT TOP 2000 a.Id '
- + @Sql
- + ' AND a.dcJobTypeID IN(''' + @KeyJobTypeIds + ''')
- AND a.Id NOT IN(SELECT JobId FROM #t_jobid)'
- + @Order
- INSERT INTO #t_jobid
- EXEC(@Exe)
- SELECT @Result = @Result + @@ROWCOUNT
- END
- END
-
- --(3)显示企业名称中包含搜索的关键词的职位列表
- IF @Result = 0
- BEGIN
- INSERT INTO #t_companyList
- SELECT Id, SecondId, Name, RealName, Lng, Lat, HasLicence, ISNULL(LogoFile, @Logo), dcRegionId, dcIndustryID, JobNumber
- FROM CompanyList WITH(NOLOCK)
- WHERE FilterLogID = @FilterLogID
- ORDER BY seq
- SELECT @cpMainResult = @@ROWCOUNT
-
- SET @Exe = 'SELECT TOP 2000 a.Id '
- + @Sql
- + ' AND a.cpMainId IN(SELECT ID FROM #t_companyList)'
- + @Order
- INSERT INTO #t_jobid
- EXEC(@Exe)
- SELECT @Result = @@ROWCOUNT
- END
- ELSE IF @Result < 2000
- BEGIN
- SET @Exe = 'SELECT TOP 2000 a.Id '
- + @Sql
- + ' AND b.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%''
- AND a.Id NOT IN(SELECT JobId FROM #t_jobid)'
- + @Order
- INSERT INTO #t_jobid
- EXEC(@Exe)
- SELECT @Result = @Result + @@ROWCOUNT
- END
-
- --(4)全文搜索匹配的职位列表
- IF @Result < 2000
- BEGIN
- TRUNCATE TABLE #FullText
- INSERT #FullText
- SELECT TOP 5000 3000 + RANK, [Key]
- FROM FREETEXTTABLE(cpMainJob, *, @KeyWord, 100000) AS KeyJob ORDER BY RANK DESC
- SET @Exe = 'SELECT TOP 2000 a.Id '
- + REPLACE(@Sql, 'INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID', 'INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID INNER JOIN #FullText ON a.ID = #FullText.JobId')
- + ' AND a.Id IN(SELECT TOP 5000 [Key] FROM FREETEXTTABLE(cpMainJob, *, ''' + @KeyWord + ''', 100000) AS KeyJob ORDER BY RANK DESC)
- AND a.Id NOT IN(SELECT JobId FROM #t_jobid)'
- + REPLACE(@Order, ' ORDER BY', ' ORDER BY #FullText.Priority,')
- INSERT INTO #t_jobid
- EXEC(@Exe)
- SELECT @Result = @Result + @@ROWCOUNT
- END
- END
- END
- ----set istop
- IF @KeyWord > ''
- INSERT INTO @t_top
- SELECT TOP 10 a.JobId
- FROM SearchJobTop a WITH(NOLOCK), #t_jobid b
- WHERE b.JobId = a.JobId
- AND EXISTS(SELECT 'x' FROM JobPublish c WITH(NOLOCK) WHERE CHARINDEX(@keyword, c.Name ) > 0 AND c.Id = a.JobId)
- ORDER BY a.OrderType, a.OpenDate DESC
- ELSE
- INSERT INTO @t_top
- SELECT TOP 10 a.JobId
- FROM SearchJobTop a WITH(NOLOCK), #t_jobid b
- WHERE b.JobId = a.JobId
- ORDER BY a.OrderType, a.OpenDate DESC
-
- IF EXISTS(SELECT TOP 1 'x' FROM @t_top)
- DELETE FROM #t_jobid WHERE JobId IN(SELECT JobId FROM @t_top)
-
- ----记录筛选数据
- INSERT INTO JobSearchLog(crDate, Source, ip, Province, JobType, Region, MapPlace, Industry, MinSalary,
- MaxSalary, ReplyRate, Negotiable, Experience, Education, EmpType, KeyWord, CompanySize,
- Welfare, OnlyOnline, OnlyEnv, cvRegion, cvJobType, Result, SqlString, RunTime)
- SELECT GETDATE(), @Source, @ip, @Province, @JobType, @Region, @MapPlace, @Industry, @MinSalary,
- @MaxSalary, @ReplyRate, @Negotiable, @Experience, @Education, @EmpType, @KeyWord, @CompanySize,
- @Welfare, @OnlyOnline, @OnlyEnv, @cvRegion, @cvJobType, @Result, @Exe, DATEDIFF(MS, @Start, GETDATE())
- SET @JobSearchLogId = @@IDENTITY
- IF EXISTS(SELECT TOP 1 'x' FROM @t_top)
- BEGIN
- INSERT INTO JobList
- SELECT @JobSearchLogId JobSearchLogId, JobId, 1 FROM @t_top ORDER BY seq
- INSERT INTO JobList
- SELECT @JobSearchLogId JobSearchLogId, JobId, 0 FROM #t_jobid ORDER BY Id
- END
- ELSE
- BEGIN
- IF @Result > 99
- INSERT INTO JobList
- SELECT @JobSearchLogId JobSearchLogId, JobId, CASE WHEN Id < 4 THEN 1 ELSE 0 END FROM #t_jobid ORDER BY Id
- ELSE
- INSERT INTO JobList
- SELECT @JobSearchLogId JobSearchLogId, JobId, 0 FROM #t_jobid ORDER BY Id
- END
- END
- ----组合语句 结束
- --从job中搜索数据 结束
- ----show tables start
- ----返回查询数量
- DECLARE @ShowCompany INT = 0
- IF @PageNumber = 1
- BEGIN
- IF NOT EXISTS(SELECT TOP 1 'x' FROM #t_companyList)
- INSERT INTO #t_companyList(Id, SecondId, Name, RealName, Lng, Lat, HasLicence, LogoFile, dcRegionId, dcIndustryId, JobNumber)
- SELECT Id, SecondId, Name, RealName, Lng, Lat, HasLicence, ISNULL(LogoFile, @Logo), dcRegionId, dcIndustryId, JobNumber FROM CompanyList WITH(NOLOCK) WHERE FilterLogId = @FilterLogID ORDER BY Seq
-
- SELECT @ShowCompany = COUNT(*) FROM #t_companyList
- END
- SELECT @ValidJobNumber ValidJobNumber, @ShowFilter ShowFilter, @ShowCompany ShowCompany
- ----返回@PageSize行查询结果
- INSERT INTO @t_jobid
- SELECT JobId, IsTop FROM JobList WITH(NOLOCK) WHERE JobSearchLogId = @JobSearchLogId ORDER BY Id
-
- IF @Source = 10
- SELECT TOP (@PageSize) 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, @ValidJobNumber 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 @t_jobid c 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 c.ID >= (@PageNumber - 1) * @PageSize
- ORDER BY c.ID, a.ID DESC
- ELSE
- SELECT TOP (@PageSize) 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,
- 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.RealName, b.UnLimitedDate, b.BalanceDate, b.Balance, b.LogoFile LogoUrl,
- b.MemberType, '' cpIndustry, --STUFF((SELECT ',' + LTRIM(x.dcIndustryid) + ',c' + LTRIM(isnull(y.Category,0)) FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
- c.IsTop, b.IsRefreshed, ISNULL(d.IsOnline, 0) IsOnline, d.IsVi, d.ViPlanId, d.InterviewDate, CASE WHEN b.ReplyRate >= 0.6 THEN b.ReplyRate ELSE NULL END Replyrate,
- (SELECT TOP 1 ID from paAttention WITH(NOLOCK) WHERE AttentionType=2 AND AttentionID=a.ID AND paMainId = @paMainId) AttentionId
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
- INNER JOIN @t_jobid c ON a.id = c.JobID
- LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
- WHERE c.ID >= (@PageNumber - 1) * @PageSize
- ORDER BY c.ID, a.ID DESC
- ----返回统计数量
- IF @ShowFilter = 1
- BEGIN
- IF @Source = 10
- BEGIN
- SELECT 1 PaSearchConditionId, 'JobType' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
- FROM @t_filter a LEFT JOIN dcJobType b ON b.ID = a.TypeId
- WHERE FilterType = 1
- ORDER BY TypeId
- IF @MapPlace = 0
- BEGIN
- --level 3 region
- IF LEN(@Region) > 0
- AND @Region NOT LIKE '%,%'
- AND NOT EXISTS(SELECT TOP 1 'x' FROM dcRegion WHERE ParentID = @Region)
- SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionId = @Region
- ELSE
- SELECT 1 PaSearchConditionId, 'Region' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
- FROM @t_filter a
- LEFT JOIN dcRegion b ON b.ID = a.TypeId
- WHERE FilterType = 2
- ORDER BY TypeId
- END
- SELECT 1 PaSearchConditionId, 'Education' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
- FROM @t_filter a
- LEFT JOIN dcEducation b ON b.ID = a.TypeId
- WHERE FilterType = 4
- ORDER BY CONVERT(INT, TypeId)
- SELECT 1 PaSearchConditionId, 'Experience' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
- FROM @t_filter a
- LEFT JOIN dcOthers b ON b.DetailID = a.TypeId AND Category='职位要求工作经验'
- WHERE FilterType = 5
- ORDER BY CONVERT(INT, TypeId)
- SELECT 1 PaSearchConditionId, 'Salary' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue
- FROM @t_filter
- WHERE FilterType = 7
- ORDER BY CONVERT(INT, TypeId)
- SELECT 1 PaSearchConditionId, 'EmployType' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
- FROM @t_filter a
- LEFT JOIN dcOthers b ON b.DetailID = a.TypeId AND Category='工作性质'
- WHERE FilterType = 3
- ORDER BY CONVERT(INT, TypeId)
- SELECT 1 PaSearchConditionId, 'CompanySize' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
- FROM @t_filter a
- LEFT JOIN dcCompanySize b ON b.ID = a.TypeId
- WHERE FilterType = 6
- ORDER BY CONVERT(INT, TypeId)
- END
- ELSE
- BEGIN
- SELECT 1 PaSearchConditionId, 'JobType' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 1 ORDER BY TypeId
- IF @MapPlace = 0
- BEGIN
- --level 3 region
- IF LEN(@Region) > 0
- AND @Region NOT LIKE '%,%'
- AND NOT EXISTS(SELECT TOP 1 'x' FROM dcRegion WHERE ParentID = @Region)
- SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionId = @Region
- ELSE
- SELECT 1 PaSearchConditionId, 'Region' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 2 ORDER BY TypeId
- END
- SELECT 1 PaSearchConditionId, 'Education' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 4 ORDER BY TypeId
- SELECT 1 PaSearchConditionId, 'Experience' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 5 ORDER BY TypeId
- SELECT 1 PaSearchConditionId, 'Salary' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 7 ORDER BY TypeId
- SELECT 1 PaSearchConditionId, 'EmployType' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 3 ORDER BY TypeId
- SELECT 1 PaSearchConditionId, 'CompanySize' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 6 ORDER BY TypeId
- SELECT 1 PaSearchConditionId, 'Industry' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 8 ORDER BY TypeId
- END
- END
- --如果有companylist列表,则显示
- IF @ShowCompany > 0
- BEGIN
- IF @paMainId > 0
- SELECT Id, SecondId, Name, RealName, Lng, Lat, HasLicence, LogoFile, JobNumber,
- (SELECT FullName FROM dcRegion WHERE Id = dcRegionId) Region,
- (SELECT Description FROM dcIndustry WHERE Id = dcIndustryId) Industry,
- (SELECT TOP 1 ID from paAttention WITH(NOLOCK)
- WHERE AttentionType=1 AND AttentionID = a.ID
- AND paMainId = @paMainId) AttentionId
- FROM #t_CompanyList a
- ORDER BY Seq
- ELSE
- SELECT Id, SecondId, Name, RealName, Lng, Lat, HasLicence, LogoFile, JobNumber, null AttentionId,
- (SELECT FullName FROM dcRegion WHERE Id = dcRegionId) Region,
- (SELECT Description FROM dcIndustry WHERE Id = dcIndustryId) Industry
- FROM #t_CompanyList ORDER BY Seq
- END
- END TRY
- BEGIN CATCH
- INSERT INTO ErrLog
- VALUES(ERROR_NUMBER(), ERROR_SEVERITY(), ERROR_STATE(), ERROR_PROCEDURE(), ERROR_LINE(),
- ERROR_MESSAGE() + ' sql=' + ISNULL(@sql, 'null')
- + ' @order=' + ISNULL(@order, 'null') + ' exe=' + ISNULL(@exe, 'null'), GETDATE())
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procJobPublishSelect2] Script Date: 2018/12/13 19:11:03 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- /*
- go
- DECLARE @json NVARCHAR(MAX) = N'
- {
- "ip":"192.168.1.1",
- "province":"32",
- "JobType":"",
- "region":"32",
- "Negotiable":"0",
- "keyword":"齐鲁 人才",
- "cvJobType":"24",
- "cvregion":"3212"
- }';
- set @json = '{"dcJobTypeID" : "",
- "dcRegionId" : "32",
- "dcIndustryID" : "",
- "dcSalaryID" : "",
- "IsNegotiable" : "",
- "MinExperience" : "",
- "dcEducationID" : "",
- "EmployType" : "",
- "KeyWord" : "请填写关键词或选择职位",
- "KeyType" : "1",
- "Order" : "",
- "RefreshNo" : "32",
- "Type" : "1",
- "PageNumber" : "1",
- "SessionID" : "60.215.144.163",
- "CompanySizeID" : "",
- "JobID" : "0",
- "Welfare" : "",
- "IsOnline" : ""
- }
- '
- exec procJobPublishSelect '[{"dcRegionId":"32","dcIndustryID":"5"}]'
- go
- select * from jsonlist
- */
- CREATE PROCEDURE [dbo].[procJobPublishSelect2]
- (
- @json nVARCHAR(max)
- )
- as
- SET NOCOUNT ON
- DECLARE @Start DATETIME
- SET @Start = GETDATE()
- DECLARE @Sql VARCHAR(MAX), @Order VARCHAR(1000), @Exe VARCHAR(MAX), @Result INT = 0, @CanReturn BIT = 0, @ValidJobNumber INT = 0
- BEGIN TRY
- --分析参数结束开始,约3ms
- DECLARE @t_value AS TABLE (name VARCHAR(20), para VARCHAR(500), seq int);
- INSERT INTO @t_value
- SELECT * FROM OPENJSON(@json);
- DECLARE @Province INT = 32,
- @JobType VARCHAR(50) = '', --职位类别
- @Region VARCHAR(50) = '', --求职地区
- @MapPlace INT = 0,
- @Industry VARCHAR(20) = '', --求职行业
- @MinSalary TINYINT = 0, --月薪
- @MaxSalary TINYINT = 0, --月薪
- @ReplyRate TINYINT = 0,
- @Negotiable TINYINT = 0, --1面议,不面议
- @Experience TINYINT = 100, --工作经验,100为未选择
- @Education TINYINT = 0, --最低学历
- @EmpType VARCHAR(10) = '', --工作性质,1全职;3兼职;4实习,
- @KeyWord NVARCHAR(50) = '', --关键词
- @PageNumber INT = 1, --翻页页码
- @CompanySize INT = 0, --企业规模
- @Welfare VARCHAR(50) = '',
- @OnlyOnline INT = 0, --1在线
- @OnlyEnv INT = 0,
- @cvRegion VARCHAR(50) = '',
- @cvJobType VARCHAR(50) = '',
- @ip VARCHAR(15) = '',
- @paMainId INT = 0,
- @JobSearchLogId INT = 0,
- @FilterLogID INT = 0,
- @Source INT = 1, --1-pc+m,10-app
- @ShowFilter INT = 1
-
- CREATE TABLE #t_jobid(Id INT IDENTITY(1, 1), JobId INT)
- CREATE TABLE #t_companyList(Id int NOT NULL, SecondId varchar(10) NULL, Name nvarchar(100) NULL, RealName TINYINT, Lng Decimal(8, 5), Lat DEcimal(8, 5), HasLicence BIT, LogoFile VARCHAR(90), dcRegionId varchar(6) NULL, dcIndustryID smallint NULL, JobNumber int NULL, seq INT IDENTITY(1, 1))
- CREATE TABLE #t_companyTemp(Id INT, AvgSalary INT, LastLogindate DATETIME, seq INT IDENTITY(1, 1))
- CREATE TABLE #FullText(Id INT IDENTITY(1, 1), Priority INT, JobId INT NOT NULL)
- DECLARE @t_filter AS TABLE (FilterType INT, TypeID VARCHAR(10), TypeNumber INT)
- DECLARE @t_top AS TABLE(JobID INT, seq int IDENTITY(1, 1))
- DECLARE @t_jobid AS TABLE(Id INT IDENTITY(1, 1), JobId INT, IsTop BIT)
- DECLARE @PageSize INT = 30, @FillJobId INT = 0, @cpMainResult INT = 0, @KeyJobTypeIds VARCHAR(24) = '', @para VARCHAR(100)
- DECLARE @strJobType AS VARCHAR(2000) = '', @strJobPlace AS VARCHAR(2000) = '', @strCvRegion VARCHAR(MAX) = '', @strCvJobType VARCHAR(MAX) = ''
- DECLARE @filterExpired INT = -30, @jobExpired INT = -1, @Logo VARCHAR(50) = '/content/personal/images/defaultCpImg.png'
- SELECT @Province = para FROM @t_value WHERE name = 'RefreshNo' AND para > 0
- IF @Province > 100
- SELECT @Province = @Province - 100, @OnlyEnv = 1
- SELECT @para = para FROM @t_value WHERE name = 'order' AND para > ''
- IF @para LIKE 'r=%'
- SET @ReplyRate = CONVERT(DECIMAL(4, 2), RIGHT(LEFT(@para, 5), 3)) * 100
- ELSE IF @para LIKE '%p=%'
- SET @paMainId = RIGHT(@para, LEN(@para) - CHARINDEX('p=', @para) - 1)
- SELECT @JobType = para FROM @t_value WHERE name = 'dcJobTypeID' AND para > ''
- SELECT @Region = para FROM @t_value WHERE name = 'dcRegionId' AND para > ''
- SELECT @Industry = para FROM @t_value WHERE name = 'dcIndustryID' AND para > ''
- SELECT @MinSalary = para FROM @t_value WHERE name = 'dcSalaryID' AND para > 0
- --SELECT @MaxSalary = para FROM @t_value WHERE name = 'maxSalary' AND para > 0
- IF @MinSalary > 0
- BEGIN
- IF @MinSalary < 100 ----从form中搜索,月薪跨2个级别, 是本级和上级别的薪金
- SET @MaxSalary = @MinSalary + 1
- ELSE IF @MinSalary BETWEEN 101 AND 106 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
- SELECT @MaxSalary = @MinSalary - 99, @MinSalary = @MinSalary - 99
- ELSE IF @MinSalary BETWEEN 107 AND 113 ----从筛选结果中点击搜索,月薪只有1个级别,传值时增加100
- SELECT @MaxSalary = @MinSalary - 99, @MinSalary = @MinSalary - 100
- ELSE IF @MinSalary BETWEEN 114 AND 120
- SELECT @MaxSalary = @MinSalary - 99, @MinSalary = 17
- END
-
- SELECT @Negotiable = para FROM @t_value WHERE name = 'IsNegotiable' AND para = 1
- SELECT @Experience = para FROM @t_value WHERE name = 'MinExperience' AND para > 0
- SELECT @ReplyRate = para FROM @t_value WHERE name = 'replyrate' AND para > 0
- SELECT @Education = para FROM @t_value WHERE name = 'dcEducationID' AND para > 0
- SELECT @EmpType = para FROM @t_value WHERE name = 'EmployType' AND para > ''
- SELECT @KeyWord = para FROM @t_value WHERE name = 'KeyWord' AND para > ''
- SELECT @PageNumber = para FROM @t_value WHERE name = 'PageNumber' AND LEN(para) > 0 AND ISNUMERIC(para) = 1
- IF EXISTS(SELECT 'x' FROM @t_value WHERE name = 'CompanySizeID' AND LEN(para) > 0 AND ISNUMERIC(para) = 1)
- SELECT @CompanySize = para FROM @t_value WHERE name = 'CompanySizeID'
- SELECT @Welfare = para FROM @t_value WHERE name = 'Welfare' AND para > ''
- SELECT @OnlyOnline = para FROM @t_value WHERE name = 'IsOnline' AND para = 1
- SELECT @cvRegion = para FROM @t_value WHERE name = 'cvRegion' AND para > ''
- SELECT @cvJobType = para FROM @t_value WHERE name = 'cvJobType' AND para > ''
- SELECT @ip = para FROM @t_value WHERE name = 'SessionId' AND para > ''
- IF LEFT(@Region, 1) = 'p'
- SELECT @MapPlace = RIGHT(@Region, LEN(@Region) - 1), @Region = ''
- SELECT @Source = para FROM @t_value WHERE name = 'Source' AND para > 0
- SELECT @ShowFilter = para FROM @t_value WHERE name = 'Type' AND LEN(para) > 0
-
- IF LEN(@Keyword) > 14
- SET @CanReturn = 1
- IF EXISTS(SELECT TOP 1 'x' FROM RefuseIp WITH(NOLOCK) WHERE CHARINDEX(Ip, @ip) > 0)
- SET @CanReturn = 1
- IF CHARINDEX(', 0', @Region) > 0 OR CHARINDEX(', 0', @JobType) > 0
- OR CHARINDEX(', , ', @Region) > 0 OR CHARINDEX(', , ', @JobType) > 0
- OR LEN(@Region) > 35 OR LEN(@JobType) > 25
- SET @CanReturn = 1
- IF @CanReturn = 1
- BEGIN
- SELECT 0 ValidJobNumber
- SELECT TOP 0 * FROM JobTemp
- SELECT TOP 0 * FROM @t_filter
- SELECT TOP 0 * FROM @t_filter
- SELECT TOP 0 * FROM @t_filter
- SELECT TOP 0 * FROM @t_filter
- SELECT TOP 0 * FROM @t_filter
- SELECT TOP 0 * FROM @t_filter
- SELECT TOP 0 * FROM @t_filter
- RETURN
- END
-
- IF CHARINDEX('请填写', @KeyWord) > 0
- SET @KeyWord = ''
- IF LEN(@KeyWord) > 1
- BEGIN
- SET @KeyWord = LTRIM(RTRIM(@Keyword))
- WHILE CHARINDEX(' ', @Keyword) > 0
- SET @KeyWord = REPLACE(@Keyword, ' ', ' ')
- SET @KeyWord = REPLACE(REPLACE(@KeyWord, '''', ''''''), ';', '')
- END
- IF LEN(@KeyWord) < 2
- SET @Keyword = ''
- ----给null值变量赋默认值
- IF @EmpType NOT IN('3', '4')
- SET @EmpType = ''
- IF @MinSalary > 20 OR @MinSalary < 2
- SET @MinSalary = 0
- IF @MaxSalary > 20 OR @MaxSalary < 2
- SET @MaxSalary = 0
- SELECT @JobType = RTRIM(dbo.FormatIDS(@JobType)),
- @Industry = RTRIM(dbo.FormatIDS(@Industry)),
- @Welfare = RTRIM(dbo.FormatIDS(@Welfare)),
- @cvRegion = RTRIM(dbo.FormatIDS(@cvRegion)),
- @cvJobType = RTRIM(dbo.FormatIDS(@cvJobType))
- IF LEN(@Welfare) > 1
- BEGIN
- DECLARE @Welfare_temp VARCHAR(50)
- SET @Welfare_temp = ''
- SELECT @Welfare_temp = @Welfare_temp + a + ',' FROM dbo.fnSplit(@Welfare, ',') WHERE a <= 19 AND LEN(a) < 3
- IF LEN(@Welfare_temp) > 1
- SET @Welfare_temp = LEFT(@Welfare_temp, LEN(@Welfare_temp) - 1)
- SET @Welfare = @Welfare_temp
- END
-
- IF RIGHT(@JobType, 1) = ','
- SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
- IF RIGHT(@Region, 1) = ','
- SET @Region = LEFT(@Region, LEN(@Region) - 1)
- IF RIGHT(@Industry, 1) = ','
- SET @Industry = LEFT(@Industry, LEN(@Industry) - 1)
- --分析参数结束
-
- --记录参数开始
- DECLARE @crDate DATETIME, @inttemp INT
- SELECT TOP 1 @JobSearchLogId = id, @crDate = crDate, @inttemp = Result
- FROM JobSearchLog WITH(NOLOCK)
- WHERE Province = @Province AND JobType = @JobType AND Region = @Region AND MapPlace = @MapPlace AND Industry = @Industry
- AND MinSalary = @MinSalary AND MaxSalary = @MaxSalary AND ReplyRate = @ReplyRate AND Negotiable = @Negotiable AND Experience = @Experience
- AND Education = @Education AND EmpType = @EmpType AND KeyWord = @KeyWord AND CompanySize = @CompanySize
- AND Welfare = @Welfare AND OnlyOnline = @OnlyOnline AND OnlyEnv = @OnlyEnv AND cvRegion = @cvRegion AND cvJobType = @cvJobType
- AND crDate > DATEADD(MINUTE, @jobExpired, GETDATE())
- ORDER BY ID DESC
- --IF @JobSearchLogId > 0
- --BEGIN
- -- IF @inttemp >= 300
- -- BEGIN
- -- IF @crDate < DATEADD(MINUTE, @jobExpired, GETDATE())
- -- SET @JobSearchLogId = 0
- -- END
- -- ELSE
- -- BEGIN
- -- IF @crDate < DATEADD(MINUTE, @jobExpired * 10, GETDATE())
- -- SET @JobSearchLogId = 0
- -- END
- --END
- SELECT TOP 1 @FilterLogId = Id, @ValidJobNumber = Result
- FROM FilterLog WITH(NOLOCK)
- WHERE Province = @Province AND JobType = @JobType AND Region = @Region AND MapPlace = @MapPlace AND Industry = @Industry
- AND MinSalary = @MinSalary AND MaxSalary = @MaxSalary AND ReplyRate = @ReplyRate AND Negotiable = @Negotiable AND Experience = @Experience
- AND Education = @Education AND EmpType = @EmpType AND KeyWord = @KeyWord AND CompanySize = @CompanySize
- AND Welfare = @Welfare AND OnlyOnline = @OnlyOnline AND OnlyEnv = @OnlyEnv
- AND crDate > DATEADD(MINUTE, @filterExpired, GETDATE())
- ORDER BY ID DESC
- --记录参数结束
- --gen sql statement
- IF @FilterLogId = 0 OR @JobSearchLogId = 0
- BEGIN
- --make sql where
- ------生成具体的职位类别,因为职位类别有包含(父子)关系
- ----生成求聘职位
- IF LEN(@JobType) > 0
- BEGIN
- SELECT @strJobType = @strJobType + LTRIM(STR(a.id)) + ', '
- FROM dcJobType a WITH(NOLOCK),
- (SELECT * FROM dbo.fnSplit(@JobType, ',') WHERE a < 9999) b
- WHERE a.Id = b.a
- OR a.ParentId = b.a
- OR a.ParentId2 = b.a
- IF LEN(@strJobType) > 1
- SET @strJobType = LEFT(@strJobType, LEN(@strJobType) - 1)
- END
- ----生成工作地点
- IF @MapPlace > 0
- BEGIN
- DECLARE @Degree 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 = @MapPlace
- IF @Region LIKE '3201%'
- SET @Degree = 1000 / 100000.0
- ELSE
- SET @Degree = 2000 / 100000.0
-
- SET @strJobPlace = 'a.Lng BETWEEN ' + CONVERT(VARCHAR, @Lng - @Degree) +
- ' AND ' + CONVERT(VARCHAR, @Lng + @Degree) +
- ' AND a.Lat BETWEEN ' + CONVERT(VARCHAR, @Lat - @Degree) +
- ' AND ' + CONVERT(VARCHAR, @Lat + @Degree) +
- ' 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)
- END
- ELSE IF LEN(@Region) > 0
- BEGIN
- SELECT @strJobPlace =
- @strJobPlace + ' OR a.dcRegionId ' +
- CASE WHEN LEN(a) = 6
- THEN '= ''' + a + ''''
- ELSE 'LIKE ''' + a + '%'''
- END
- FROM dbo.fnSplit(@Region, ',')
- WHERE LEN(a) IN(2, 4, 6)
- IF LEN(@strJobPlace) > 4
- SET @strJobPlace = RIGHT(@strJobPlace, LEN(@strJobPlace) - 4)
- END
- --从job中搜索数据 开始
- ----组合语句 开始
- --SELECT TOP 2000 a.ID, a.cpMainId, a.dcJobTypeID, a.dcJobTypeIDMinor, a.dcSalaryID, a.dcRegionId, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID
- --SELECT #TOP# a.ID
- SET @SQL='
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID
- WHERE a.Valid = 1
- AND b.Valid = 1'
- ----职位有效,单位新有效
- IF LEN(@Industry) > 0
- SET @Sql = @Sql + '
- AND b.ID IN (SELECT cpMainID FROM cpIndustry WHERE dcIndustryId in(' + @Industry + '))'
-
- IF @Province > 0
- SET @Sql = @Sql + ' AND b.dcProvinceId = ' + LTRIM(STR(@Province))
- IF @ReplyRate IN(60, 70, 80, 90, 100)
- SET @Sql = @Sql + '
- AND b.ReplyRate >= ' + LEFT(@ReplyRate / 100.0, 3)
- IF @OnlyEnv = 1
- SET @Sql = @Sql + '
- AND b.HasEnvironment = 1'
- ----工作经验要求
- IF @Experience < 100
- SET @Sql = @Sql + '
- AND a.MinExperience = ' + LTRIM(STR(@Experience))
- ----学历要求
- ----'1初中', '2\3\4高中、中技、中专', '5大专', '6本科', '7硕士', '8博士
- IF @Education > 0
- IF @Education = 2
- SET @Sql = @Sql + '
- AND a.dcEducationID IN(2, 3, 4)'
- ELSE
- SET @Sql = @Sql + '
- AND a.dcEducationID = ' + LTRIM(STR(@Education))
- ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
- IF LEN(@EmpType) > 0
- SET @Sql = @Sql + '
- AND a.EmployType IN (' + @EmpType + ')'
- IF @CompanySize BETWEEN 1 AND 6
- SET @Sql = @Sql + '
- AND b.dcCompanySizeID = ' + LTRIM(STR(@CompanySize))
- IF LEN(@Welfare) > 0
- SET @Sql = @Sql + '
- AND a.Welfare' + REPLACE(@Welfare, ',', ' = 1 AND a.Welfare') + ' = 1'
-
- IF @OnlyOnline = 1
- SET @Sql = @Sql + '
- AND a.caMainId IN(SELECT caMainId FROM caOnline WITH(NOLOCK) WHERE IsOnline = 1)'
-
- ----职位类别
- IF @strJobType > ''
- SET @Sql = @Sql + '
- AND a.dcJobTypeID IN(' + @strJobType + ')'
- IF LEN(@strJobPlace) > 0
- SET @Sql = @Sql + '
- AND (' + @strJobPlace + ')'
- IF @Negotiable = 1
- SET @Sql = @Sql + '
- AND a.dcSalaryID = 100 ' -- OR a.Negotiable = 1
- ELSE IF @MinSalary > 0 AND @MaxSalary > 0
- SET @Sql = @Sql + '
- AND a.dcSalaryID <= ' + LTRIM(STR(@MaxSalary)) + '
- AND a.dcSalaryIdMax >= ' + LTRIM(STR(@MinSalary))
-
- IF @cvRegion > ''
- BEGIN
- SELECT @strCvRegion =
- @strCvRegion + ' OR a.dcRegionId ' +
- CASE WHEN LEN(a) = 6
- THEN '= ''' + a + ''''
- ELSE 'LIKE ''' + a + '%'''
- END
- FROM dbo.fnSplit(@cvRegion, ',')
- WHERE LEN(a) IN(2, 4, 6)
- SET @strCvRegion = RIGHT(@strCvRegion, LEN(@strCvRegion) - 4)
- END
- IF @cvJobType > ''
- BEGIN
- SELECT @strCvJobType = @strCvJobType + LTRIM(STR(a.id)) + ', '
- FROM dcJobType a WITH(NOLOCK),
- (SELECT * FROM dbo.fnSplit(@cvJobType, ',')) b
- WHERE a.Id = b.a
- OR a.ParentId = b.a
- OR a.ParentId2 = b.a
- IF LEN(@strCvJobType) > 1
- SET @strCvJobType = LEFT(@strCvJobType, LEN(@strCvJobType) - 1)
- END
- SET @Order = ' ORDER BY'
- IF @strCvRegion > ''
- BEGIN
- SET @Order = @Order + ' CASE WHEN ' + @strCvRegion + ' THEN 0 ELSE 2 END'
- IF @strCvJobType > ''
- SET @Order = @Order + '
- + CASE WHEN a.dcJobTypeId IN (' + @strCvJobType + ') THEN 0 ELSE 1 END,
- '
- ELSE
- SET @Order = @Order + ',
- '
- END
- ELSE IF @strCvJobType > ''
- SET @Order = @Order + ' CASE WHEN a.dcJobTypeId IN (' + @strCvJobType + ') THEN 0 ELSE 1 END,
- '
- SET @Order = @Order + ' a.RefreshDate DESC, a.SecondId DESC'
- END
- --gen sql end
-
- --get filter start
- IF @FilterLogID != 0
- BEGIN
- INSERT INTO @t_filter
- SELECT FilterType, TypeId, TypeNumber FROM JobFilter WITH(NOLOCK) WHERE FilterLogID = @FilterLogID
- BEGIN TRY
- UPDATE FilterLog SET ReUseNumber = ReUseNumber + 1 WHERE Id = @FilterLogID
- END TRY
- BEGIN CATCH
- END CATCH
- END
- ELSE
- BEGIN
- --获取符合条件的所有数据
- CREATE TABLE #Filter(
- Id INT IDENTITY(1, 1),
- [JobId] INT,
- [cpMainId] INT,
- [dcRegionId] [VARCHAR](6) NULL,
- [dcJobTypeID] [smallint] NOT NULL,
- [dcSalaryID] [tinyint] NOT NULL,
- [dcEducationID] [tinyint] NOT NULL,
- [MinExperience] [tinyint] NOT NULL,
- [IssueDate] [smalldatetime] NULL,
- [EmployType] [tinyint] NOT NULL,
- [dcCompanySizeID] [tinyint] NULL
- )
- IF @KeyWord = ''
- BEGIN
- SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
- + @Sql + @Order
- INSERT INTO #Filter
- EXEC(@Exe)
- SELECT @Result = @@ROWCOUNT
- END
- ELSE
- BEGIN
- --(1)显示职位名称中包含搜索的关键词的职位列表
- SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
- + @Sql
- + ' AND a.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%'' '
- + @Order
- INSERT INTO #Filter
- EXEC(@Exe)
- SELECT @Result = @@ROWCOUNT
- --(2)显示按照职位类别匹配规则的职位列表
- IF @Result < 2000
- BEGIN
- SELECT @KeyJobTypeIds = LTRIM(STR(id)) + ',' FROM dcJobType WHERE CHARINDEX(@Keyword, Description) > 0
- IF LEN(@KeyJobTypeIds) > 2
- SELECT @KeyJobTypeIds = LEFT(@KeyJobTypeIds, LEN(@KeyJobTypeIds) - 1)
- ELSE
- BEGIN
- SET @KeyJobTypeIds= ''
- SELECT @KeyJobTypeIds = dcJobtypeIds FROM KeyWord2JobType WITH(NOLOCK) WHERE Keyword = @Keyword
- END
- IF @KeyJobTypeIds > ''
- BEGIN
- SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
- + @Sql
- + ' AND a.dcJobTypeID IN(''' + @KeyJobTypeIds + ''')
- AND a.Id NOT IN(SELECT JobId FROM #Filter)'
- + @Order
- INSERT INTO #Filter
- EXEC(@Exe)
- SELECT @Result = @Result + @@ROWCOUNT
- END
- ELSE IF LEN(@Keyword) < 11
- INSERT INTO KeyWordLog(crDate, Keyword) SELECT GETDATE(), @Keyword
- END
-
- --(3)显示企业名称中包含搜索的关键词的职位列表
- IF @Result = 0
- BEGIN
- SET @Exe = 'SELECT DISTINCT TOP 2000 a.cpMainId, AvgSalary,b.LastLogindate '
- + @Sql
- + ' AND b.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%'' '
- + ' ORDER BY b.AvgSalary DESC, b.LastLogindate DESC'
- INSERT INTO #t_companyTemp
- EXEC(@Exe)
- SELECT @Result = @@ROWCOUNT
-
- IF @Result > 0
- BEGIN
- INSERT INTO #t_companyList
- SELECT a.Id, a.SecondId, a.Name, a.RealName, a.Lng, a.Lat, HasLicence, ISNULL(a.LogoFile, @Logo), a.dcRegionId,
- (SELECT TOP 1 dcIndustryId FROM cpIndustry WITH(NOLOCK) WHERE cpIndustry.cpMainID = a.Id) dcIndustryID,
- (SELECT COUNT(*) FROM JobPublish WITH(NOLOCK) WHERE JobPublish.cpMainId = a.Id) JobNumber
- FROM cpMainPublish a WITH(NOLOCK), #t_companyTemp b
- WHERE a.Id = b.Id
- ORDER BY b.seq
- SELECT @cpMainResult = @@ROWCOUNT
- SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
- + @Sql
- + ' AND a.cpMainId IN(SELECT ID FROM #t_companyTemp)'
- + @Order
- INSERT INTO #Filter
- EXEC(@Exe)
- SELECT @Result = @@ROWCOUNT
- END
- END
- ELSE IF @Result < 2000
- BEGIN
- SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
- + @Sql
- + ' AND b.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%''
- AND a.Id NOT IN(SELECT JobId FROM #Filter)'
- + @Order
- INSERT INTO #Filter
- EXEC(@Exe)
- SELECT @Result = @Result + @@ROWCOUNT
- END
-
- --(4)全文搜索匹配的职位列表
- IF @Result < 2000
- BEGIN
- INSERT #FullText
- SELECT TOP 5000 3000 + RANK, [Key]
- FROM FREETEXTTABLE(cpMainJob, *, @KeyWord, 100000) AS KeyJob ORDER BY RANK DESC
- SET @Exe = 'SELECT a.Id, a.cpMainId, a.dcRegionId, a.dcJobTypeID, a.dcSalaryID, a.dcEducationID, a.MinExperience, a.IssueDate, a.EmployType, b.dcCompanySizeID '
- + REPLACE(@Sql, 'INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID', 'INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID INNER JOIN #FullText ON a.ID = #FullText.JobId')
- + ' AND a.Id NOT IN(SELECT JobId FROM #Filter)'
- + REPLACE(@Order, ' ORDER BY', ' ORDER BY #FullText.Priority,')
- INSERT INTO #Filter
- EXEC(@Exe)
- SELECT @Result = @Result + @@ROWCOUNT
- END
- END
- SET @ValidJobNumber = @Result
-
- INSERT INTO #t_jobid
- SELECT TOP 2000 JobId FROM #Filter ORDER BY Id
- SET @FillJobId = 1
- ----生成筛选数据
- DECLARE @t_filtertemp1 AS TABLE (
- FilterType INT, --1 jobtype,
- TypeID VARCHAR(10),
- TypeNumber INT
- )
- DECLARE @t_filtertemp2 AS TABLE (
- FilterType INT,
- TypeID VARCHAR(10),
- TypeNumber INT
- )
- ----------------------------jobtype
- INSERT INTO @t_filtertemp1
- SELECT 1, dcJobTypeID, COUNT(*)
- FROM #Filter WITH(NOLOCK)
- GROUP BY dcJobTypeID ORDER BY dcJobTypeID
- ----计算全部某职位类别,2, 4位的数据
- IF LEN(@JobType) = 0
- INSERT INTO @t_filtertemp2
- SELECT 1, LEFT(TypeID, 2), SUM(TypeNumber)
- FROM @t_filtertemp1 GROUP BY LEFT(TypeID, 2)
- ELSE IF LEN(@JobType) = 2
- INSERT INTO @t_filtertemp2
- SELECT 1, TypeID, TypeNumber
- FROM @t_filtertemp1
- WHERE TypeID LIKE @JobType + '__'
- ELSE IF LEN(@JobType) > 4
- BEGIN
- INSERT INTO @t_filtertemp2 SELECT * FROM @t_filtertemp1
- INSERT INTO @t_filtertemp2
- SELECT 1, LEFT(TypeID, 2), SUM(TypeNumber)
- FROM @t_filtertemp1 GROUP BY LEFT(TypeID, 2)
- DELETE @t_filtertemp2 WHERE TypeID NOT IN(SELECT a FROM dbo.fnSplit(@JobType, ','))
- END
-
- INSERT INTO @t_filter SELECT * FROM @t_filtertemp2
- DELETE @t_filtertemp2
- DELETE @t_filtertemp1
- --------------------------region
- IF @Mapplace = 0
- BEGIN
- INSERT INTO @t_filtertemp1
- SELECT 2, dcRegionId, COUNT(*) FROM #Filter WITH(NOLOCK)
- GROUP BY dcRegionId ORDER BY dcRegionId
- ----计算全部地区,2位的数据
- IF LEN(@Region) = 0
- INSERT INTO @t_filtertemp2
- SELECT 2, LEFT(TypeID, 2) TypeID, SUM(TypeNumber) TypeNumber
- FROM @t_filtertemp1 GROUP BY LEFT(TypeID, 2)
- ELSE IF LEN(@Region) = 2
- INSERT INTO @t_filtertemp2
- SELECT 2, LEFT(TypeID, 4) TypeID, SUM(TypeNumber) TypeNumber
- FROM @t_filtertemp1 WHERE LEN(TypeID) >= 4 AND TypeId LIKE @Region + '%'
- GROUP BY LEFT(TypeID, 4)
- ELSE IF LEN(@Region) = 4
- INSERT INTO @t_filtertemp2
- SELECT 2, TypeID, TypeNumber
- FROM @t_filtertemp1 WHERE LEN(TypeID) = 6
- ELSE IF @Region LIKE '%,%'
- BEGIN
- INSERT INTO @t_filtertemp2
- SELECT 2, LEFT(TypeID, 2) TypeID, SUM(TypeNumber) TypeNumber
- FROM @t_filtertemp1 GROUP BY LEFT(TypeID, 2)
- INSERT INTO @t_filtertemp2
- SELECT 2, LEFT(TypeID, 4) TypeID, SUM(TypeNumber) TypeNumber
- FROM @t_filtertemp1 WHERE LEN(TypeID) >= 4
- GROUP BY LEFT(TypeID, 4)
- INSERT INTO @t_filtertemp2 SELECT * FROM @t_filtertemp1 WHERE LEN(TypeID) = 6
- DELETE @t_filtertemp2 WHERE TypeID NOT IN(SELECT a FROM dbo.FnSplit(@Region, ','))
- END
- INSERT INTO @t_filter SELECT * FROM @t_filtertemp2
- --DELETE @t_filtertemp2
- --DELETE @t_filtertemp1
- END
- ----------------------------
- INSERT INTO @t_filter
- SELECT 3, EmployType, COUNT(*)
- FROM #Filter WITH(NOLOCK)
- GROUP BY EmployType ORDER BY EmployType
- INSERT INTO @t_filter
- SELECT 4, CASE WHEN dcEducationId IN(2, 3, 4) THEN 2 ELSE dcEducationId END, COUNT(*)
- FROM #Filter 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 @t_filter
- SELECT 5, MinExperience, COUNT(*) FROM #Filter WITH(NOLOCK)
- GROUP BY MinExperience ORDER BY MinExperience
- INSERT INTO @t_filter
- SELECT 6, dcCompanySizeID, COUNT(*) FROM #Filter WITH(NOLOCK)
- GROUP BY dcCompanySizeID ORDER BY dcCompanySizeID
- INSERT INTO @t_filter
- SELECT 7, dcSalaryID, COUNT(*) FROM #Filter WITH(NOLOCK)
- GROUP BY dcSalaryID ORDER BY dcSalaryID
-
- INSERT INTO @t_filter
- SELECT 8, dcIndustryID, COUNT(*)
- FROM #Filter a WITH(NOLOCK), cpIndustry b WITH(NOLOCK)-- INDEX(NonClusteredIndex_cpIndustry_cpMainId))
- WHERE a.cpMainId = b.cpMainId
- GROUP BY b.dcIndustryId ORDER BY b.dcIndustryId
- ----记录筛选数据
- INSERT INTO FilterLog(crDate, Source, ip, Province, JobType, Region, MapPlace, Industry, MinSalary,
- MaxSalary, ReplyRate, Negotiable, Experience, Education, EmpType, KeyWord, CompanySize,
- Welfare, OnlyOnline, OnlyEnv, Result, SqlString, RunTime, DayMinute)
- SELECT GETDATE(), @Source, @ip, @Province, @JobType, @Region, @MapPlace, @Industry, @MinSalary,
- @MaxSalary, @ReplyRate, @Negotiable, @Experience, @Education, @EmpType, @KeyWord, @CompanySize,
- @Welfare, @OnlyOnline, @OnlyEnv, @ValidJobNumber, @Exe, DATEDIFF(MS, @Start, GETDATE()),
- ROUND(CONVERT(DECIMAL(18, 9), GETDATE()) % 1.0 * 60 * 24, 0)
- SET @FilterLogId = @@IDENTITY
- INSERT INTO JobFilter
- SELECT @FilterLogId FilterLogId, * FROM @t_filter
- INSERT INTO CompanyList
- SELECT @FilterLogId FilterLogId, * FROM #t_companyList
- END
- IF @JobSearchLogId > 0
- BEGIN
- UPDATE JobSearchLog SET ReUseNumber = ReUseNumber + 1 WHERE Id = @JobSearchLogId
- END
- ELSE
- BEGIN
- --select jobid
- SET @Result = 0
- IF @FillJobId = 1
- BEGIN
- SELECT @Result = COUNT(*) FROM #t_jobid
- END
- ELSE
- BEGIN
- TRUNCATE TABLE #t_jobid
- IF @KeyWord = ''
- BEGIN
- SET @Exe = 'SELECT TOP 2000 a.Id ' + @Sql + @Order
- INSERT INTO #t_jobid
- EXEC(@Exe)
- SET @Result = @@ROWCOUNT
- END
- ELSE
- BEGIN
- --(1)显示职位名称中包含搜索的关键词的职位列表
- SET @Exe = 'SELECT TOP 2000 a.Id '
- + @Sql
- + ' AND a.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%'' '
- + @Order
- INSERT INTO #t_jobid
- EXEC(@Exe)
- SELECT @Result = @@ROWCOUNT
- --(2)显示按照职位类别匹配规则的职位列表
- IF @Result < 2000
- BEGIN
- SELECT @KeyJobTypeIds = ''
- SELECT @KeyJobTypeIds = LTRIM(STR(id)) + ',' FROM dcJobType WHERE CHARINDEX(@Keyword, Description) > 0
- IF LEN(@KeyJobTypeIds) > 2
- SELECT @KeyJobTypeIds = LEFT(@KeyJobTypeIds, LEN(@KeyJobTypeIds) - 1)
- ELSE
- BEGIN
- SET @KeyJobTypeIds= ''
- SELECT @KeyJobTypeIds = dcJobtypeIds FROM KeyWord2JobType WITH(NOLOCK) WHERE Keyword = @Keyword
- END
-
- IF @KeyJobTypeIds > ''
- BEGIN
- SET @Exe = 'SELECT TOP 2000 a.Id '
- + @Sql
- + ' AND a.dcJobTypeID IN(''' + @KeyJobTypeIds + ''')
- AND a.Id NOT IN(SELECT JobId FROM #t_jobid)'
- + @Order
- INSERT INTO #t_jobid
- EXEC(@Exe)
- SELECT @Result = @Result + @@ROWCOUNT
- END
- END
-
- --(3)显示企业名称中包含搜索的关键词的职位列表
- IF @Result = 0
- BEGIN
- INSERT INTO #t_companyList
- SELECT Id, SecondId, Name, RealName, Lng, Lat, HasLicence, ISNULL(LogoFile, @Logo), dcRegionId, dcIndustryID, JobNumber
- FROM CompanyList WITH(NOLOCK)
- WHERE FilterLogID = @FilterLogID
- ORDER BY seq
- SELECT @cpMainResult = @@ROWCOUNT
-
- SET @Exe = 'SELECT TOP 2000 a.Id '
- + @Sql
- + ' AND a.cpMainId IN(SELECT ID FROM #t_companyList)'
- + @Order
- INSERT INTO #t_jobid
- EXEC(@Exe)
- SELECT @Result = @@ROWCOUNT
- END
- ELSE IF @Result < 2000
- BEGIN
- SET @Exe = 'SELECT TOP 2000 a.Id '
- + @Sql
- + ' AND b.Name LIKE ''%' + REPLACE(@Keyword, ' ', '%') + '%''
- AND a.Id NOT IN(SELECT JobId FROM #t_jobid)'
- + @Order
- INSERT INTO #t_jobid
- EXEC(@Exe)
- SELECT @Result = @Result + @@ROWCOUNT
- END
-
- --(4)全文搜索匹配的职位列表
- IF @Result < 2000
- BEGIN
- TRUNCATE TABLE #FullText
- INSERT #FullText
- SELECT TOP 5000 3000 + RANK, [Key]
- FROM FREETEXTTABLE(cpMainJob, *, @KeyWord, 100000) AS KeyJob ORDER BY RANK DESC
- SET @Exe = 'SELECT TOP 2000 a.Id '
- + REPLACE(@Sql, 'INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID', 'INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID=b.ID INNER JOIN #FullText ON a.ID = #FullText.JobId')
- + ' AND a.Id IN(SELECT TOP 5000 [Key] FROM FREETEXTTABLE(cpMainJob, *, ''' + @KeyWord + ''', 100000) AS KeyJob ORDER BY RANK DESC)
- AND a.Id NOT IN(SELECT JobId FROM #t_jobid)'
- + REPLACE(@Order, ' ORDER BY', ' ORDER BY #FullText.Priority,')
- INSERT INTO #t_jobid
- EXEC(@Exe)
- SELECT @Result = @Result + @@ROWCOUNT
- END
- END
- END
- ----set istop
- IF @KeyWord > ''
- INSERT INTO @t_top
- SELECT TOP 10 a.JobId
- FROM SearchJobTop a WITH(NOLOCK), #t_jobid b
- WHERE b.JobId = a.JobId
- AND EXISTS(SELECT 'x' FROM JobPublish c WITH(NOLOCK) WHERE CHARINDEX(@keyword, c.Name ) > 0 AND c.Id = a.JobId)
- ORDER BY a.OrderType, a.OpenDate DESC
- ELSE
- INSERT INTO @t_top
- SELECT TOP 10 a.JobId
- FROM SearchJobTop a WITH(NOLOCK), #t_jobid b
- WHERE b.JobId = a.JobId
- ORDER BY a.OrderType, a.OpenDate DESC
-
- IF EXISTS(SELECT TOP 1 'x' FROM @t_top)
- DELETE FROM #t_jobid WHERE JobId IN(SELECT JobId FROM @t_top)
-
- ----记录筛选数据
- INSERT INTO JobSearchLog(crDate, Source, ip, Province, JobType, Region, MapPlace, Industry, MinSalary,
- MaxSalary, ReplyRate, Negotiable, Experience, Education, EmpType, KeyWord, CompanySize,
- Welfare, OnlyOnline, OnlyEnv, cvRegion, cvJobType, Result, SqlString, RunTime)
- SELECT GETDATE(), @Source, @ip, @Province, @JobType, @Region, @MapPlace, @Industry, @MinSalary,
- @MaxSalary, @ReplyRate, @Negotiable, @Experience, @Education, @EmpType, @KeyWord, @CompanySize,
- @Welfare, @OnlyOnline, @OnlyEnv, @cvRegion, @cvJobType, @Result, @Exe, DATEDIFF(MS, @Start, GETDATE())
- SET @JobSearchLogId = @@IDENTITY
- IF EXISTS(SELECT TOP 1 'x' FROM @t_top)
- BEGIN
- INSERT INTO JobList
- SELECT @JobSearchLogId JobSearchLogId, JobId, 1 FROM @t_top ORDER BY seq
- INSERT INTO JobList
- SELECT @JobSearchLogId JobSearchLogId, JobId, 0 FROM #t_jobid ORDER BY Id
- END
- ELSE
- BEGIN
- IF @Result > 99
- INSERT INTO JobList
- SELECT @JobSearchLogId JobSearchLogId, JobId, CASE WHEN Id < 4 THEN 1 ELSE 0 END FROM #t_jobid ORDER BY Id
- ELSE
- INSERT INTO JobList
- SELECT @JobSearchLogId JobSearchLogId, JobId, 0 FROM #t_jobid ORDER BY Id
- END
- END
- ----组合语句 结束
- --从job中搜索数据 结束
- ----show tables start
- ----返回查询数量
- DECLARE @ShowCompany INT = 0
- IF @PageNumber = 1
- BEGIN
- IF NOT EXISTS(SELECT TOP 1 'x' FROM #t_companyList)
- INSERT INTO #t_companyList(Id, SecondId, Name, RealName, Lng, Lat, HasLicence, LogoFile, dcRegionId, dcIndustryId, JobNumber)
- SELECT Id, SecondId, Name, RealName, Lng, Lat, HasLicence, ISNULL(LogoFile, @Logo), dcRegionId, dcIndustryId, JobNumber FROM CompanyList WITH(NOLOCK) WHERE FilterLogId = @FilterLogID ORDER BY Seq
-
- SELECT @ShowCompany = COUNT(*) FROM #t_companyList
- END
- SELECT @ValidJobNumber ValidJobNumber, @ShowFilter ShowFilter, @ShowCompany ShowCompany
- ----返回@PageSize行查询结果
- INSERT INTO @t_jobid
- SELECT JobId, IsTop FROM JobList WITH(NOLOCK) WHERE JobSearchLogId = @JobSearchLogId ORDER BY Id
-
- IF @Source = 10
- SELECT TOP (@PageSize) 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, @ValidJobNumber 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 @t_jobid c 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 c.ID >= (@PageNumber - 1) * @PageSize
- ORDER BY c.ID, a.ID DESC
- ELSE
- SELECT TOP (@PageSize) 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,
- 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.RealName, b.UnLimitedDate, b.BalanceDate, b.Balance, b.LogoFile LogoUrl,
- b.MemberType, '' cpIndustry, --STUFF((SELECT ',' + LTRIM(x.dcIndustryid) + ',c' + LTRIM(isnull(y.Category,0)) FROM cpIndustry x,dcIndustry y WHERE x.dcIndustryid = y.id AND x.cpMainid = b.id FOR XML PATH('')),1,1,'') cpIndustry,
- c.IsTop, b.IsRefreshed, ISNULL(d.IsOnline, 0) IsOnline, d.IsVi, d.ViPlanId, d.InterviewDate, CASE WHEN b.ReplyRate >= 0.6 THEN b.ReplyRate ELSE NULL END Replyrate,
- (SELECT TOP 1 ID from paAttention WITH(NOLOCK) WHERE AttentionType=2 AND AttentionID=a.ID AND paMainId = @paMainId) AttentionId
- FROM JobPublish a WITH(NOLOCK)
- INNER JOIN cpMainPublish b WITH(NOLOCK) ON a.cpMainID = b.ID
- INNER JOIN @t_jobid c ON a.id = c.JobID
- LEFT JOIN caOnline d WITH(NOLOCK) ON a.caMainId = d.caMainId
- WHERE c.ID >= (@PageNumber - 1) * @PageSize
- ORDER BY c.ID, a.ID DESC
- ----返回统计数量
- IF @ShowFilter = 1
- BEGIN
- IF @Source = 10
- BEGIN
- SELECT 1 PaSearchConditionId, 'JobType' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
- FROM @t_filter a LEFT JOIN dcJobType b ON b.ID = a.TypeId
- WHERE FilterType = 1
- ORDER BY TypeId
- IF @MapPlace = 0
- BEGIN
- --level 3 region
- IF LEN(@Region) > 0
- AND @Region NOT LIKE '%,%'
- AND NOT EXISTS(SELECT TOP 1 'x' FROM dcRegion WHERE ParentID = @Region)
- SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionId = @Region
- ELSE
- SELECT 1 PaSearchConditionId, 'Region' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
- FROM @t_filter a
- LEFT JOIN dcRegion b ON b.ID = a.TypeId
- WHERE FilterType = 2
- ORDER BY TypeId
- END
- SELECT 1 PaSearchConditionId, 'Education' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
- FROM @t_filter a
- LEFT JOIN dcEducation b ON b.ID = a.TypeId
- WHERE FilterType = 4
- ORDER BY CONVERT(INT, TypeId)
- SELECT 1 PaSearchConditionId, 'Experience' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
- FROM @t_filter a
- LEFT JOIN dcOthers b ON b.DetailID = a.TypeId AND Category='职位要求工作经验'
- WHERE FilterType = 5
- ORDER BY CONVERT(INT, TypeId)
- SELECT 1 PaSearchConditionId, 'Salary' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue
- FROM @t_filter
- WHERE FilterType = 7
- ORDER BY CONVERT(INT, TypeId)
- SELECT 1 PaSearchConditionId, 'EmployType' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
- FROM @t_filter a
- LEFT JOIN dcOthers b ON b.DetailID = a.TypeId AND Category='工作性质'
- WHERE FilterType = 3
- ORDER BY CONVERT(INT, TypeId)
- SELECT 1 PaSearchConditionId, 'CompanySize' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue, b.Description
- FROM @t_filter a
- LEFT JOIN dcCompanySize b ON b.ID = a.TypeId
- WHERE FilterType = 6
- ORDER BY CONVERT(INT, TypeId)
- END
- ELSE
- BEGIN
- SELECT 1 PaSearchConditionId, 'JobType' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 1 ORDER BY TypeId
- IF @MapPlace = 0
- BEGIN
- --level 3 region
- IF LEN(@Region) > 0
- AND @Region NOT LIKE '%,%'
- AND NOT EXISTS(SELECT TOP 1 'x' FROM dcRegion WHERE ParentID = @Region)
- SELECT * FROM dcMapPlace WITH(NOLOCK) WHERE dcRegionId = @Region
- ELSE
- SELECT 1 PaSearchConditionId, 'Region' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 2 ORDER BY TypeId
- END
- SELECT 1 PaSearchConditionId, 'Education' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 4 ORDER BY TypeId
- SELECT 1 PaSearchConditionId, 'Experience' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 5 ORDER BY TypeId
- SELECT 1 PaSearchConditionId, 'Salary' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 7 ORDER BY TypeId
- SELECT 1 PaSearchConditionId, 'EmployType' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 3 ORDER BY TypeId
- SELECT 1 PaSearchConditionId, 'CompanySize' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 6 ORDER BY TypeId
- SELECT 1 PaSearchConditionId, 'Industry' Title, TypeId TitleId, NULL TitleDesc, TypeNumber TitleValue FROM @t_filter WHERE FilterType = 8 ORDER BY TypeId
- END
- END
- --如果有companylist列表,则显示
- IF @ShowCompany > 0
- BEGIN
- IF @paMainId > 0
- SELECT Id, SecondId, Name, RealName, Lng, Lat, HasLicence, LogoFile, JobNumber,
- (SELECT FullName FROM dcRegion WHERE Id = dcRegionId) Region,
- (SELECT Description FROM dcIndustry WHERE Id = dcIndustryId) Industry,
- (SELECT TOP 1 ID from paAttention WITH(NOLOCK)
- WHERE AttentionType=1 AND AttentionID = a.ID
- AND paMainId = @paMainId) AttentionId
- FROM #t_CompanyList a
- ORDER BY Seq
- ELSE
- SELECT Id, SecondId, Name, RealName, Lng, Lat, HasLicence, LogoFile, JobNumber, null AttentionId,
- (SELECT FullName FROM dcRegion WHERE Id = dcRegionId) Region,
- (SELECT Description FROM dcIndustry WHERE Id = dcIndustryId) Industry
- FROM #t_CompanyList ORDER BY Seq
- END
- END TRY
- BEGIN CATCH
- INSERT INTO ErrLog
- VALUES(ERROR_NUMBER(), ERROR_SEVERITY(), ERROR_STATE(), ERROR_PROCEDURE(), ERROR_LINE(),
- ERROR_MESSAGE() + ' sql=' + ISNULL(@sql, 'null')
- + ' @order=' + ISNULL(@order, 'null') + ' exe=' + ISNULL(@exe, 'null'), GETDATE())
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcJobRecommendByPaMainIDUpdate] Script Date: 2018/12/13 19:11:05 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcJobRecommendByPaMainIDUpdate]
- (
- @PaMainID INT,
- @dcJobTypeID VARCHAR(100), --职位类别
- @dcRegionID VARCHAR(100), --求职地区
- @dcIndustryID VARCHAR(100), --求职行业
- @dcSalaryID TINYINT, --月薪
- @MinExperience TINYINT, --工作经验,100为未选择
- @dcEducationID TINYINT, --最低学历
- @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习
- @RowCount SMALLINT, --需要显示的行数
- @Type INT --1猜你喜欢 2小伙伴们都在申请
- )
- AS
- BEGIN
- IF @RowCount = 0
- BEGIN
- SET @RowCount = 20
- END
- --删除后重新生成数据
- DELETE FROM SHORTDB..JobRecommend WHERE PaMainID = @PaMainID AND Type = @Type
- IF @Type = 1
- BEGIN
- SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
- @dcRegionID = RTRIM(dbo.FormatIDS(@dcRegionID)),
- @dcIndustryID = RTRIM(dbo.FormatIDS(@dcIndustryID)),
- @dcSalaryID = ISNULL(@dcSalaryID, 0),
- @MinExperience = ISNULL(@MinExperience, 100),
- @dcEducationID = ISNULL(@dcEducationID, 0),
- @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END
- IF @dcJobTypeID LIKE '%,%,%,%,%,%'
- SET @dcJobTypeID = LEFT(@dcJobTypeID, 2)
- IF @dcRegionID LIKE '%,%,%,%,%,%'
- SET @dcRegionID = LEFT(@dcRegionID, 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 @T_JobPlace AS TABLE(ID INT)
- DECLARE @T_JobType AS TABLE(ID INT)
- DECLARE @JobType AS VARCHAR(3000)
- DECLARE @JobPlace AS VARCHAR(2000)
- DECLARE @SQL AS NVARCHAR(MAX)
- DECLARE @WHERE AS VARCHAR(8000)
- DECLARE @FROM AS VARCHAR(1000)
- 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
- )
- ----生成插入临时表的Sql语句
- SET @SQL = '
- INSERT INTO #Job
- SELECT TOP ' + CONVERT(VARCHAR(3),@RowCount) + ' 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 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 @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 + ')'
- SET @SQL = @SQL + @FROM + @WHERE
- SET @SQL = @SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
- EXEC(@SQL)
- DECLARE @CurrentCount AS SMALLINT
- DECLARE @NeedCount AS SMALLINT
- SELECT @CurrentCount = COUNT(*) FROM #Job
- IF @CurrentCount < @RowCount
- BEGIN
- SET @NeedCount = @RowCount - @CurrentCount
- ----生成插入临时表的Sql语句
- SET @SQL = '
- INSERT INTO #Job
- SELECT TOP ' + CONVERT(VARCHAR(3),@NeedCount) + ' 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 AND a.ID NOT IN(SELECT ID FROM #Job)'
- ----职位类别
- 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 + ')'
- SET @SQL = @SQL + @FROM + @WHERE
- SET @SQL = @SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
- EXEC(@SQL)
- SELECT @CurrentCount = COUNT(*) FROM #Job
- IF @CurrentCount < @RowCount
- BEGIN
- SET @NeedCount = @RowCount - @CurrentCount
- --将工作地点扩大一级
- DECLARE @T_JobPlaceDistinct AS TABLE(ID INT)
- UPDATE @T_JobPlace SET ID = LEFT(ID,LEN(ID)-2) WHERE LEN(ID) > 2
- INSERT INTO @T_JobPlaceDistinct SELECT DISTINCT ID FROM @T_JobPlace
- SELECT @JobPlace = ''
- SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlaceDistinct
- IF LEN(@JobPlace) > 0
- SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
- --将职位类别扩大一级
- UPDATE @T_TEMP SET ID = LEFT(ID,LEN(ID)-2) WHERE LEN(ID) > 2
- DELETE FROM @T_JobType
- 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)
- SELECT @JobType = ''
- SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
- IF RIGHT(@JobType, 1) = ','
- SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
- ----生成插入临时表的Sql语句
- SET @SQL = '
- INSERT INTO #Job
- SELECT TOP ' + CONVERT(VARCHAR(3),@NeedCount) + ' 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 AND a.ID NOT IN(SELECT ID FROM #Job)'
- ----职位类别
- 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 + ')'
- SET @SQL = @SQL + @FROM + @WHERE
- SET @SQL = @SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
- EXEC(@SQL)
- END
- END
- --print '090909'
- INSERT INTO SHORTDB..JobRecommend
- SELECT TOP 20 @PaMainID,a.SecondId EnJobID, a.Name as JobName,b.Name as cpName,a.dcSalaryID,
- a.EmployType,a.dcRegionID,a.dcEducationID,a.MinExperience,a.RefreshDate,b.SecondId EnCpMainID,
- b.dcCompanySizeID,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 WHERE caMainId =a.caMainID), 0) AS IsOnline,1,GETDATE(),b.HasLicence,a.ID,
- a.CaMainiD, b.ReplyRate
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), #Job c WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.ID = c.ID ORDER BY c.RowID
- END
- ELSE
- BEGIN
- SET @dcJobTypeID = dbo.FormatIDS(@dcJobTypeID)
- DECLARE @T_JobType2 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_JobType2
- 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_JobType2
- IF RIGHT(@JobTypeExpect, 1) = ','
- SET @JobTypeExpect = LEFT(@JobTypeExpect, LEN(@JobTypeExpect) - 1)
-
- DECLARE @T_JobPlace2 AS TABLE(ID INT)
- DECLARE @JobPlace2 AS VARCHAR(3000)
- INSERT INTO @T_JobPlace2
- SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
- SELECT @JobPlace2 = ''
- SELECT @JobPlace2 = (@JobPlace2 + ' OR c.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace2
- SELECT @JobPlace2 = (@JobPlace2 + ' OR c.dcRegionID = ''' + LTRIM(STR(LEFT(ID,2)))+'''' )
- FROM @T_JobPlace2 WHERE LEN(ID) > 2
- SELECT @JobPlace2 = (@JobPlace2 + ' OR c.dcRegionID = ''' + LTRIM(STR(LEFT(ID,4)))+'''' )
- FROM @T_JobPlace2 WHERE LEN(ID) > 4
- SET @JobPlace2 = RIGHT(@JobPlace2, LEN(@JobPlace2) -4)
- DECLARE @SQL2 AS VARCHAR(max)
- SET @SQL2 = '
- INSERT INTO SHORTDB..JobRecommend
- SELECT TOP ' + CONVERT(VARCHAR, @RowCount) + ' '+CONVERT(VARCHAR(20),@PaMainID)+',b.SecondID EnJobID, b.Name JobName, c.Name CpName,
- b.dcSalaryID, b.EmployType,b.dcRegionID, b.dcEducationID,b.MinExperience, b.Refreshdate,c.SecondID EnCpMainID,
- c.dcCompanySizeID,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,dbo.GetCaOnlineStatus(b.caMainID) AS IsOnline,2,'''+CONVERT(VARCHAR(30),GETDATE())+''',
- c.HasLicence, b.ID, b.CaMainID, c.ReplyRate
- 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 (' + @JobPlace2 + ')
- ) ORDER BY a.AddDate DESC'
- EXEC (@SQL2)
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcJobRecommendUpdate] Script Date: 2018/12/13 19:11:05 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcJobRecommendUpdate]
- (
- @PaMainID INT,
- @dcJobTypeID VARCHAR(100), --职位类别
- @dcRegionID VARCHAR(100), --求职地区
- @dcIndustryID VARCHAR(100), --求职行业
- @dcSalaryID TINYINT, --月薪
- @MinExperience TINYINT, --工作经验,100为未选择
- @dcEducationID TINYINT, --最低学历
- @EmployType VARCHAR(10), --工作性质,1全职;3兼职;4实习
- @RowCount SMALLINT, --需要显示的行数
- @Type INT --1猜你喜欢 2小伙伴们都在申请
- )
- AS
- BEGIN
- IF @RowCount = 0
- BEGIN
- SET @RowCount = 20
- END
- DECLARE @UpdateDate DATETIME
- SELECT TOP 1 @UpdateDate = UpdateDate
- FROM ShortDB..JobRecommend
- WHERE PaMainID = @PaMainID
- AND Type = @Type
- DECLARE @Minute INT --间隔分钟数
- SELECT @Minute = DATEDIFF(MINUTE, ISNULL(@UpdateDate, GETDATE() - 1), GETDATE())
- IF @Minute IS NULL OR @Minute <= 30
- BEGIN
- print '00'
- --直接查询
- SELECT TOP 20 * FROM SHORTDB..JobRecommend WHERE PaMainID = @PaMainID AND Type = @Type
- END
- ELSE
- BEGIN
- print '11'
- --删除后重新生成数据
- DELETE FROM SHORTDB..JobRecommend WHERE PaMainID = @PaMainID AND Type = @Type
- IF @Type = 1
- BEGIN
- SELECT @dcJobTypeID = RTRIM(dbo.FormatIDS(@dcJobTypeID)),
- @dcRegionID = RTRIM(dbo.FormatIDS(@dcRegionID)),
- @dcIndustryID = RTRIM(dbo.FormatIDS(@dcIndustryID)),
- @dcSalaryID = ISNULL(@dcSalaryID, 0),
- @MinExperience = ISNULL(@MinExperience, 100),
- @dcEducationID = ISNULL(@dcEducationID, 0),
- @EmployType = CASE @EmployType WHEN '2' THEN '1,3' ELSE ISNULL(@EmployType, '') END
- IF @dcJobTypeID LIKE '%,%,%,%,%,%'
- SET @dcJobTypeID = LEFT(@dcJobTypeID, 2)
- IF @dcRegionID LIKE '%,%,%,%,%,%'
- SET @dcRegionID = LEFT(@dcRegionID, 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 @T_JobPlace AS TABLE(ID INT)
- DECLARE @T_JobType AS TABLE(ID INT)
- DECLARE @JobType AS VARCHAR(3000)
- DECLARE @JobPlace AS VARCHAR(2000)
- DECLARE @SQL AS NVARCHAR(MAX)
- DECLARE @WHERE AS VARCHAR(8000)
- DECLARE @FROM AS VARCHAR(1000)
- 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
- )
- ----生成插入临时表的Sql语句
- SET @SQL = '
- INSERT INTO #Job
- SELECT TOP ' + CONVERT(VARCHAR(3),@RowCount) + ' 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 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 @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 + ')'
- SET @SQL = @SQL + @FROM + @WHERE
- SET @SQL = @SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
- EXEC(@SQL)
- DECLARE @CurrentCount AS SMALLINT
- DECLARE @NeedCount AS SMALLINT
- SELECT @CurrentCount = COUNT(*) FROM #Job
- IF @CurrentCount < @RowCount
- BEGIN
- SET @NeedCount = @RowCount - @CurrentCount
- ----生成插入临时表的Sql语句
- SET @SQL = '
-
- INSERT INTO #Job
- SELECT TOP ' + CONVERT(VARCHAR(3),@NeedCount) + ' 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 AND a.ID NOT IN(SELECT ID FROM #Job)'
- ----职位类别
- 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 + ')'
- SET @SQL = @SQL + @FROM + @WHERE
- SET @SQL = @SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
- EXEC(@SQL)
- SELECT @CurrentCount = COUNT(*) FROM #Job
- IF @CurrentCount < @RowCount
- BEGIN
- SET @NeedCount = @RowCount - @CurrentCount
- --将工作地点扩大一级
- DECLARE @T_JobPlaceDistinct AS TABLE(ID INT)
- UPDATE @T_JobPlace SET ID = LEFT(ID,LEN(ID)-2) WHERE LEN(ID) > 2
- INSERT INTO @T_JobPlaceDistinct SELECT DISTINCT ID FROM @T_JobPlace
- SELECT @JobPlace = ''
- SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlaceDistinct
- IF LEN(@JobPlace) > 0
- SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
- --将职位类别扩大一级
- UPDATE @T_TEMP SET ID = LEFT(ID,LEN(ID)-2) WHERE LEN(ID) > 2
- DELETE FROM @T_JobType
- 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)
- SELECT @JobType = ''
- SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
- IF RIGHT(@JobType, 1) = ','
- SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
- ----生成插入临时表的Sql语句
- SET @SQL = '
-
- INSERT INTO #Job
- SELECT TOP ' + CONVERT(VARCHAR(3),@NeedCount) + ' 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 AND a.ID NOT IN(SELECT ID FROM #Job)'
- ----职位类别
- 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 + ')'
- SET @SQL = @SQL + @FROM + @WHERE
- SET @SQL = @SQL + ' ORDER BY a.RefreshDate DESC, a.ID'
- EXEC(@SQL)
- END
- END
- print '090909'
- INSERT INTO SHORTDB..JobRecommend
- SELECT TOP 10 @PaMainID,a.SecondId EnJobID, a.Name as JobName,b.Name as cpName,a.dcSalaryID,
- a.EmployType,a.dcRegionID,a.dcEducationID,a.MinExperience,a.RefreshDate,b.SecondId EnCpMainID,
- b.dcCompanySizeID,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 WHERE caMainId =a.caMainID), 0) AS IsOnline,1,GETDATE(),b.HasLicence,a.ID,
- a.CaMainiD, b.ReplyRate
- FROM JobPublish a WITH(NOLOCK), cpMainPublish b WITH(NOLOCK), #Job c WITH(NOLOCK)
- WHERE a.cpMainID = b.ID AND a.ID = c.ID ORDER BY c.RowID
- END
- ELSE
- BEGIN
- print '0909'
- SET @dcJobTypeID = dbo.FormatIDS(@dcJobTypeID)
- DECLARE @T_JobType2 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_JobType2
- 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_JobType2
- IF RIGHT(@JobTypeExpect, 1) = ','
- SET @JobTypeExpect = LEFT(@JobTypeExpect, LEN(@JobTypeExpect) - 1)
-
- DECLARE @T_JobPlace2 AS TABLE(ID INT)
- DECLARE @JobPlace2 AS VARCHAR(3000)
- INSERT INTO @T_JobPlace2
- SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
- SELECT @JobPlace2 = ''
- SELECT @JobPlace2 = (@JobPlace2 + ' OR c.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace2
- SELECT @JobPlace2 = (@JobPlace2 + ' OR c.dcRegionID = ''' + LTRIM(STR(LEFT(ID,2)))+'''' )
- FROM @T_JobPlace2 WHERE LEN(ID) > 2
- SELECT @JobPlace2 = (@JobPlace2 + ' OR c.dcRegionID = ''' + LTRIM(STR(LEFT(ID,4)))+'''' )
- FROM @T_JobPlace2 WHERE LEN(ID) > 4
- SET @JobPlace2 = RIGHT(@JobPlace2, LEN(@JobPlace2) -4)
- DECLARE @SQL2 AS VARCHAR(max)
- SET @SQL2 = '
- INSERT INTO SHORTDB..JobRecommend
- SELECT TOP ' + CONVERT(VARCHAR, @RowCount) + ' '+CONVERT(VARCHAR(20),@PaMainID)+',b.SecondID EnJobID, b.Name JobName, c.Name CpName,
- b.dcSalaryID, b.EmployType,b.dcRegionID, b.dcEducationID,b.MinExperience, b.Refreshdate,c.SecondID EnCpMainID,
- c.dcCompanySizeID,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,dbo.GetCaOnlineStatus(b.caMainID) AS IsOnline,2,'''+CONVERT(VARCHAR(30),GETDATE())+''',
- c.HasLicence, b.ID, b.CaMainID, c.ReplyRate
- 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 (' + @JobPlace2 + ')
- ) ORDER BY a.AddDate DESC'
- PRINT(@SQL2)
- EXEC (@SQL2)
- END
- SELECT TOP 20 * FROM SHORTDB..JobRecommend WHERE PaMainID = @PaMainID AND Type = @Type
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobRefreshLog_tempSelect] Script Date: 2018/12/13 19:11:06 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- ---职位刷新数预设置,获取可用的职位刷新数(定制刷新)
- ---harry
- ---2017-11-1
- CREATE PROCEDURE [dbo].[procJobRefreshLog_tempSelect]
- (
- @beginDate SMALLDATETIME,
- @endDate SMALLDATETIME,
- @refreshType TINYINT,
- @weekDays CHAR(13),
- @hours VARCHAR(100),
- @minute INT,
- @jobIds VARCHAR(200),
- @caMainId INT,
- @cpMainId INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- --删除2分钟以上同一家企业的数据
- DELETE FROM JobRefreshLog_temp WHERE AddDate < DATEADD(MINUTE, -2, GETDATE()) AND cpMainId = @cpMainId
- DECLARE @sumRemain INT, @InsertRow INT
- SELECT @sumRemain = sum(remainJobRefreshQuota)
- FROM caOrder WITH(NOLOCK)
- WHERE cpMainID = @cpMainId
- AND openDate IS NOT NULL
- AND endDate > GETDATE()
- AND BeginDate < GETDATE()
- AND IsDeleted = 0
- AND OrderType IN(8, 15)
- IF @sumRemain > 0
- BEGIN
- DELETE FROM JobRefreshLog_temp WHERE cpMainId = @cpMainId AND operateMan = @caMainId--清空数据,只能清除自己添加的
- --职位id
- DECLARE @TjobId AS TABLE(jobId INT, jobInfo NVARCHAR(200))
- --周
- DECLARE @Tweek AS TABLE(d INT)
- --时间点
- DECLARE @Thour AS TABLE(hour VARCHAR(10))
- DECLARE @jobId INT, @jobinfo NVARCHAR(200), @hour VARCHAR(10), @weeknum TINYINT
-
- --插入所有数据
- INSERT INTO @TjobId (jobId)
- SELECT * FROM dbo.fnSplit(@jobIds, ',')
- WHERE a IN(SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainId = @cpMainId AND Valid = 1)
- 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
- )
-
- DECLARE @OneDay AS TABLE(RunDate DATETIME)
- DECLARE @AllDay AS TABLE(RunDate DATETIME)
- INSERT INTO @OneDay
- SELECT DATEADD(MINUTE, @Minute, DATEADD(HOUR, CONVERT(INT, a), @beginDate)) FROM dbo.FnSplit(@hours, ',')
- DECLARE @IntervalDay INT
- SET @IntervalDay = 0
- WHILE @IntervalDay <= DATEDIFF(DAY, @BeginDate, @endDate)
- BEGIN
- INSERT INTO @AllDay SELECT DATEADD(DAY, @IntervalDay, RunDate) FROM @OneDay
- SET @IntervalDay = @IntervalDay + 1
- END
-
- IF @refreshType= 2 --按周刷
- BEGIN
- INSERT INTO @Tweek
- SELECT * FROM dbo.fnSplit(@weekDays,',')---1,2,3,4,5,6,7
- --将@Tweek数据更改为sql对应的数据
- UPDATE @Tweek SET d= (
- CASE d
- WHEN 1 THEN 2
- WHEN 2 THEN 3
- WHEN 3 THEN 4
- WHEN 4 THEN 5
- WHEN 5 THEN 6
- WHEN 6 THEN 7
- ELSE 1 END )
-
- --删除不在@Tweek中的数据
- DELETE FROM @AllDay WHERE DATEPART(weekday,RunDate) NOT IN(SELECT d FROM @Tweek)
- END
-
- --每个职位,每天,每时刻
- INSERT INTO JobRefreshLog_temp(jobid, jobInfo, refreshType, preRefreshDateTime, operateMan, cpMainId, AddDate)
- SELECT a.jobId, a.jobinfo, 0, b.RunDate, @caMainId, @cpMainId, GETDATE()
- FROM @AllDay b, @TjobId a
- SELECT @InsertRow = @@ROWCOUNT
- DECLARE @NeedQuota INT, @remainJobRefreshQuota INT, @AllInsertRow INT
-
- SELECT @AllInsertRow =count(*) from jobrefreshlog_temp where cpmainid = @cpmainid and runDateTime is null
- SELECT @NeedQuota = count(*) from jobrefreshlog where cpmainid = @cpmainid and runDateTime is null
- SELECT @remainJobRefreshQuota = sum(remainJobRefreshQuota)
- FROM caorder WITH(NOLOCK)
- WHERE cpmainid = @cpmainid
- AND ordertype in(8, 15) AND isdeleted=0 AND opendate > '' AND getdate() BETWEEN begindate AND enddate
- --计算可用数量
- IF (@NeedQuota +@AllInsertRow)> @remainJobRefreshQuota
- BEGIN
- SELECT (@remainJobRefreshQuota-(@NeedQuota+@AllInsertRow-@InsertRow)) AS availableNumber
- END
- ELSE
- BEGIN
- SELECT (@remainJobRefreshQuota-@NeedQuota) AS availableNumber
- END
- END
- ELSE
- BEGIN
- SELECT 0 AS availableNumber
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobRefreshLog_tempSelectSean] Script Date: 2018/12/13 19:11:07 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- ---职位刷新数预设置,获取可用的职位刷新数(定制刷新)
- ---harry
- ---2017-11-1
- CREATE PROCEDURE [dbo].[procJobRefreshLog_tempSelectSean]
- (
- @beginDate SMALLDATETIME,
- @endDate SMALLDATETIME,
- @refreshType TINYINT,
- @weekDays CHAR(13),
- @hours VARCHAR(100),
- @minute INT,
- @jobIds VARCHAR(200),
- @caMainId INT,
- @cpMainId INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- select 1, getdate()
- --删除2分钟以上同一家企业的数据
- DELETE FROM JobRefreshLog_temp WHERE AddDate < DATEADD(MINUTE, -2, GETDATE()) AND cpMainId = @cpMainId
- DECLARE @sumRemain INT
- SELECT @sumRemain = sum(remainJobRefreshQuota)
- FROM caOrder WITH(NOLOCK)
- WHERE cpMainID = @cpMainId
- AND openDate IS NOT NULL
- AND endDate > GETDATE()
- AND BeginDate < GETDATE()
- AND IsDeleted = 0
- AND OrderType IN(8, 15)
- IF @sumRemain > 0
- BEGIN
- DELETE FROM JobRefreshLog_temp WHERE cpMainId = @cpMainId AND operateMan = @caMainId--清空数据,只能清除自己添加的
- --职位id
- DECLARE @TjobId AS TABLE(jobId INT, jobInfo NVARCHAR(200))
- --周
- DECLARE @Tweek AS TABLE(d INT)
- --时间点
- DECLARE @Thour AS TABLE(hour VARCHAR(10))
- DECLARE @jobId INT, @jobinfo NVARCHAR(200), @hour VARCHAR(10), @weeknum TINYINT
-
- --插入所有数据
- INSERT INTO @TjobId (jobId)
- SELECT * FROM dbo.fnSplit(@jobIds, ',')
- WHERE a IN(SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainId = @cpMainId AND Valid = 1)
- 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
- )
- IF @refreshType = 1 --按天刷
- BEGIN
- DECLARE @OneDay AS TABLE(RunDate DATETIME)
- DECLARE @AllDay AS TABLE(RunDate DATETIME)
- INSERT INTO @OneDay
- SELECT DATEADD(MINUTE, @Minute, DATEADD(HOUR, CONVERT(INT, a), @beginDate)) FROM dbo.FnSplit(@hours, ',')
- DECLARE @IntervalDay INT
- SET @IntervalDay = 0
- WHILE @IntervalDay <= DATEDIFF(DAY, @BeginDate, @endDate)
- BEGIN
- INSERT INTO @AllDay SELECT DATEADD(DAY, @IntervalDay, RunDate) FROM @OneDay
- SET @IntervalDay = @IntervalDay + 1
- END
- --每个职位,每天,每时刻
- INSERT INTO JobRefreshLog_temp(jobid, jobInfo, refreshType, preRefreshDateTime, operateMan, cpMainId, AddDate)
- SELECT a.jobId, a.jobinfo, 0, b.RunDate, @caMainId, @cpMainId, GETDATE()
- FROM @AllDay b, @TjobId a
- END
- -- WHILE CONVERT(DATETIME, @beginDate, 101) <= CONVERT(DATETIME, @endDate, 101)
- -- BEGIN
- -- IF @refreshType = 1--按天刷
- -- BEGIN
- --
- -- --每个职位,每天,每时刻
- -- WHILE EXISTS(SELECT TOP 1 jobId FROM @TjobId)
- -- BEGIN
- -- DELETE FROM @Thour
- -- INSERT INTO @Thour
- -- SELECT * FROM dbo.fnSplit(@hours, ',')
- -- SELECT TOP 1 @jobId = jobid, @jobinfo = jobInfo FROM @TjobId
- -- WHILE EXISTS (SELECT TOP 1 [hour] FROM @Thour)
- -- BEGIN
- -- SELECT TOP 1 @hour = [hour] FROM @Thour
- -- INSERT INTO JobRefreshLog_temp( jobid, jobInfo, refreshType, preRefreshDateTime, operateMan, cpMainId, AddDate)
- -- SELECT @jobId, @jobinfo, 0, CONVERT(DATETIME, CONVERT(VARCHAR(10),@beginDate,120)+' '+@hour+':'+ CONVERT(VARCHAR(10),@minute)), @caMainId, @cpMainId, GETDATE()
- -- DELETE FROM @Thour WHERE hour = @hour
- -- END
- -- DELETE FROM @TjobId WHERE jobid = @jobId
- -- END
- -- END
- -- ELSE
- -- BEGIN --按周刷
- -- INSERT INTO @Tweek
- -- SELECT * FROM dbo.fnSplit(@weekDays,',')---1,2,3,4,5,6,7
- --
- -- --判断时间是否在选择中
- -- SELECT @weeknum =DATEPART(weekday,@beginDate)
- -- SELECT @weeknum =(
- -- CASE @weeknum
- -- WHEN 1 THEN 7
- -- WHEN 2 THEN 1
- -- WHEN 3 THEN 2
- -- WHEN 4 THEN 3
- -- WHEN 5 THEN 4
- -- WHEN 6 THEN 5
- -- ELSE 6 END )
- --
- -- IF EXISTS(SELECT 'x' FROM @Tweek WHERE d = @weeknum )
- -- BEGIN
- -- --每个职位,每天,每时刻
- -- DELETE FROM @TjobId
- -- 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)
- --
- -- WHILE EXISTS (SELECT TOP 1 jobid FROM @TjobId)
- -- BEGIN
- -- SELECT TOP 1 @jobId = jobid, @jobinfo = jobInfo FROM @TjobId
- --
- -- DELETE FROM @Thour
- --
- -- INSERT INTO @Thour
- -- SELECT * FROM dbo.fnSplit(@hours, ',')
- --
- -- WHILE EXISTS (SELECT TOP 1 [hour] FROM @Thour)
- -- BEGIN
- -- SELECT TOP 1 @hour = [hour] FROM @Thour
- -- INSERT INTO JobRefreshLog_temp( jobid, jobInfo, refreshType, preRefreshDateTime, operateMan, cpMainId, AddDate)
- -- SELECT @jobId, @jobinfo, 0, CONVERT(DATETIME, CONVERT(VARCHAR(10),@beginDate,120)+' '+@hour+':'+ CONVERT(VARCHAR(10),@minute)), @caMainId, @cpMainId, GETDATE()
- -- DELETE FROM @Thour WHERE hour = @hour
- -- END
- -- DELETE FROM @TjobId WHERE jobid = @jobId
- -- END
- -- END
- -- END
- -- SELECT @beginDate = DATEADD(DAY, 1, @beginDate)---天数+1
- -- END
- select 2, getdate()
- --获取占用的
- DECLARE @AllQuota INT, @InsertROw INT
- INSERT INTO JobRefreshLog_temp(jobRefreshSetId, jobid, jobInfo, refreshType, preRefreshDateTime, operateMan, cpMainId, AddDate)
- SELECT jobRefreshSetId,jobid, jobInfo, refreshType, preRefreshDateTime, operateMan, cpMainId, GETDATE() FROM jobRefreshLog
- WHERE cpMainId = @cpMainId AND runDateTime IS NULL AND refreshType = 0
- SELECT @InsertROw = @@ROWCOUNT
- select 3, getdate()
- ---分配订单号,优先消耗订单结束时间早的,优分配占用时间早的刷新数
- --获取所有可用的订单
- SELECT ID, remainJobRefreshQuota, EndDate INTO #t 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
- ORDER BY endDate
- SELECT @AllQuota = SUM(remainJobRefreshQuota) FROM #t
- select 4, getdate()
- DECLARE @NeedQuota INT, @caoderId INT, @remainJobRefreshQuota INT
- SELECT @NeedQuota = COUNT(*) FROM JobRefreshLog_temp WHERE cpMainId = @CpMainId AND OrderId IS NULL
- WHILE EXISTS(SELECT TOP 1 id FROM #t)
- BEGIN
- SELECT TOP 1 @caoderId = id, @remainJobRefreshQuota = remainJobRefreshQuota FROM #t ORDER BY endDate
- IF @remainJobRefreshQuota >= @NeedQuota
- BEGIN
- UPDATE JobRefreshLog_temp SET orderId = @caoderId
- WHERE cpMainId = @cpMainId AND ISNULL(orderid, 0) = 0
- SET @NeedQuota = 0
- DELETE FROM #t
- END
- ELSE
- BEGIN
- UPDATE JobRefreshLog_temp SET orderId = @caoderId
- WHERE id IN(SELECT TOP (@remainJobRefreshQuota) Id FROM JobRefreshLog_temp
- WHERE cpMainId = @cpMainId AND ISNULL(orderid, 0) = 0
- ORDER BY preRefreshDateTime)
- SET @NeedQuota = @NeedQuota - @remainJobRefreshQuota
- END
- DELETE FROM #t WHERE id = @caoderId
- END
- IF @NeedQuota > 0
- BEGIN
- SELECT 'zzz', getdate(), @NeedQuota
- RETURN
- END
- select 5, getdate()
- --计算可用的数据
- DECLARE @availableNumber INT, @needNumber INT, @OccupiedNumber INT,@preUsedNumber INT, @OtherUserNeedNumber INT
- SELECT @preUsedNumber=COUNT(1) FROM JobRefreshLog_temp WHERE jobid IN(SELECT jobid FROM @TjobId) AND ISNULL(orderid,0)!=0 AND ISNULL(jobRefreshSetId,0)=0 --本次成功的数量
- SELECT @needNumber=COUNT(1) FROM JobRefreshLog_temp WHERE jobid IN(SELECT jobid FROM @TjobId) AND ISNULL(jobRefreshSetId,0)=0 --本次需要的量
- SELECT @OtherUserNeedNumber=COUNT(1) FROM JobRefreshLog_temp WHERE ISNULL(jobRefreshSetId,0)=0 AND operateMan != @caMainId AND cpMainId = @cpMainId --其他人将要占用的
- select 6, getdate()
- ---计算已经占用的数量
- SELECT @OccupiedNumber= COUNT(1)
- FROM jobRefreshLog
- WHERE runDateTime IS NULL--占用
- AND refreshType= 0 --定制刷新
- AND jobid IN(SELECT id FROM job WHERE valid = 1 AND IsDelete=0 AND IssueEND>=GETDATE() AND cpMainId = @cpMainID)
- select 7, getdate()
- SELECT @availableNumber = @sumRemain - @OccupiedNumber - @OtherUserNeedNumber
- --如果neednumber>preUsedNumber 则返回可用 preUsedNumber; 否则返回@availableNumber
- IF @needNumber> @preUsedNumber
- BEGIN
- SELECT @preUsedNumber AS availableNumber
- END
- ELSE
- BEGIN
- SELECT @availableNumber AS availableNumber
- END
- select 8, getdate()
- END
- ELSE
- BEGIN
- SELECT 0 AS availableNumber
- END
- select 'zzz', getdate()
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobRefreshOldCompanyInsert] Script Date: 2018/12/13 19:11:07 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --职位刷新老用户数据表生成计划任务
- --创建人:harry 2017-10-18
- --规则 vip订单开通时间<刷新数上线时间同时订单未结束的 为老用户
- CREATE PROCEDURE [dbo].[procJobRefreshOldCompanyInsert]
- AS
- BEGIN
- DECLARE @onLineTime DATETIME
- SET @onLineTime='2017-11-30 19:00'
- TRUNCATE TABLE jobRefreshOldCompany
-
- INSERT INTO jobRefreshOldCompany(cpMainId)
- SELECT DISTINCT cpMainId FROM caorder WHERE opendate < @onLineTime AND EndDate > GETDATE() AND ordertype = 8 AND IsDeleted=0
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobReportDataByCaMainIDSelect] Script Date: 2018/12/13 19:11:07 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:获取当前6个月内统计过的职位ID和Name
- --#####################################################
- CREATE PROCEDURE [dbo].[procJobReportDataByCaMainIDSelect]
- (
- @CaMainID INT,
- @AccoutType INT
- )
- AS
- BEGIN TRY
- IF @AccoutType = 1
- BEGIN
- SELECT DISTINCT(jobid),b.*
- FROM ReportDB..jobReportData a WITH(NOLOCK)
- INNER JOIN (
- SELECT id,camainid,cpmainid,name,issuedate,issueend,null deletedate
- FROM Job b WITH(NOLOCK)
- WHERE b.cpmainid=@CaMainID
- AND isdelete=0
- AND issueend > GETDATE()
- ) b ON a.jobid=b.id
- ORDER BY b.issuedate desc
-
- SELECT DISTINCT(jobid),b.*
- FROM ReportDB..jobReportData a WITH(NOLOCK)
- INNER JOIN (
- SELECT id,camainid,cpmainid,name,issuedate,issueend,null deletedate
- FROM Job b WITH(NOLOCK)
- WHERE b.cpmainid=@CaMainID
- AND isdelete=0
- AND issueend < GETDATE() ) b ON a.jobid=b.id
- ORDER BY b.issueend DESC
-
- SELECT DISTINCT(jobid),b.*
- FROM ReportDB..jobReportData a WITH(NOLOCK)
- INNER JOIN (
- SELECT jobid id,camainid,cpmainid,jobname name,issuedate,issueend,deletedate
- FROM JobDeleted b WITH(NOLOCK)
- WHERE b.cpmainid=@CaMainID
- ) b ON a.jobid =b.id
- ORDER BY deletedate DESC
- END
- ELSE IF @AccoutType = 2
- BEGIN
- SELECT DISTINCT(jobid),b.*
- FROM ReportDB..jobReportData a WITH(NOLOCK)
- INNER JOIN (
- SELECT id,camainid,cpmainid,name,issuedate,issueend,null deletedate
- FROM Job b WITH(NOLOCK)
- WHERE b.camainid=@CaMainID
- AND isdelete=0
- AND issueend > getdate()
- ) b ON a.jobid=b.id
- ORDER BY b.issuedate DESC
-
- SELECT DISTINCT(jobid),b.*
- FROM ReportDB..jobReportData a WITH(NOLOCK)
- INNER JOIN (
- SELECT id,camainid,cpmainid,name,issuedate,issueend,null deletedate
- FROM Job b WITH(NOLOCK)
- WHERE b.camainid=@CaMainID
- AND isdelete=0
- AND issueend < GETDATE()
- ) b ON a.jobid=b.id
- ORDER BY b.issueend DESC
-
- SELECT DISTINCT(jobid),b.*
- FROM ReportDB..jobReportData a WITH(NOLOCK)
- INNER JOIN (
- SELECT jobid id,camainid,cpmainid,jobname name,issuedate,issueend,deletedate
- FROM JobDeleted b WITH(NOLOCK)
- WHERE b.camainid=@CaMainID
- ) b ON a.jobid =b.id
- ORDER BY deletedate DESC
- END
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procJobReportDataSumDetailSelect] Script Date: 2018/12/13 19:11:08 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:根据参数从JobReportData表中取得详细数据
- --修改:harry 增加jobidcount 2017-11-23
- --#####################################################
- CREATE PROCEDURE [dbo].[procJobReportDataSumDetailSelect]
- (
- @beginDays INT,
- @endDays INT,
- @jobID INT,
- @cpMainID INT
- )
- AS
- BEGIN TRY
- DECLARE @SQL VARCHAR(MAX)
- SET @SQL = 'SELECT countdate,SUM(applycount) applycount,SUM(viewcount) viewcount,SUM(interview) interview,
- SUM(interviewreply) interviewreply,SUM(interviewresult) interviewresult
- FROM ReportDB..jobReportData Where countdate >= '+CONVERT(VARCHAR(20),@beginDays)+'
- AND countdate <= ' +CONVERT(VARCHAR(20),@endDays)
- IF @jobID > 0
- BEGIN
- SET @SQL = @SQL + ' AND jobID='+CONVERT(VARCHAR(20),@jobID)
- END
- ELSE
- BEGIN
- SET @SQL = @SQL + ' AND jobid in (
- (
- SELECT id FROM Job with(nolock)
- WHERE isdelete=0
- AND cpmainid='+CONVERT(VARCHAR(20),@cpMainID)+'
- ) union (
- SELECT jobid id
- FROM JobDeleted WITH(NOLOCK)
- WHERE cpmainid='+CONVERT(VARCHAR(20),@cpMainID)+'
- )
- )'
- END
- SET @SQL = @SQL + ' AND countdate >= '+CONVERT(VARCHAR(20),@beginDays)+' AND countdate <= '+CONVERT(VARCHAR(20),@endDays)
- SET @SQL = @SQL + ' GROUP BY countdate'
- PRINT(@SQL)
- EXEC(@SQL)
- IF @jobID > 0
- SELECT 1 AS jobCount
-
- SELECT COUNT(distinct jobId) AS jobCount
- FROM ReportDB..jobReportData Where countdate >= @beginDays
- AND countdate <= @endDays
- AND 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
- ))
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procJobReportDataSumSelect] Script Date: 2018/12/13 19:11:08 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:根据参数从JobReportData表中取得汇总数据
- --#####################################################
- CREATE PROCEDURE [dbo].[procJobReportDataSumSelect]
- (
- @beginDays INT,
- @endDays INT,
- @jobID INT,
- @orderBy INT,
- @caMainID INT,
- @AccoutType INT
- )
- AS
- BEGIN TRY
- DECLARE @SQL VARCHAR(MAX)
- SET @SQL = 'SELECT a.jobid,SUM(ApplyCount) ApplyCount,SUM(ViewCount) ViewCount,SUM(interView) interView,
- SUM(interViewReply) interViewReply,SUM(interViewResult) interViewResult,b.id,camainid,cpmainid,name,
- issuedate,issueend,b.IsDelete
- FROM ReportDB..jobReportData a with(nolock)
- INNER JOIN (
- (
- SELECT id,camainid,cpmainid,name,issuedate,issueend,0 IsDelete
- FROM Job with(nolock)
- WHERE isdelete=0
- ) UNION (
- SELECT jobid id,camainid,cpmainid,jobname name,issuedate,issueend,1 IsDelete
- FROM JobDeleted with(nolock)
- )
- ) b ON a.jobid =b.id
- WHERE a.countdate >= '+CONVERT(VARCHAR(20),@beginDays)+' AND a.countdate <= '+CONVERT(VARCHAR(20),@endDays)
- IF @jobID > 0
- BEGIN
- SET @SQL = @SQL + ' AND a.jobID='+CONVERT(VARCHAR(20),@jobID)
- END
- IF @AccoutType = 1
- BEGIN
- SET @SQL = @SQL + ' AND b.cpmainid='+CONVERT(VARCHAR(20),@caMainID)
- END
- ELSE IF @AccoutType = 2
- BEGIN
- SET @SQL = @SQL + ' AND b.camainid='+CONVERT(VARCHAR(20),@caMainID)
- END
- SET @SQL = @SQL + ' GROUP BY a.jobid,b.id,camainid,cpmainid,name,issuedate,issueend,IsDelete'
- IF @orderBy = 11
- BEGIN
- SET @SQL = @SQL + ' ORDER BY b.issuedate DESC'
- END
- ELSE IF @orderBy = 12
- BEGIN
- SET @SQL = @SQL + ' ORDER BY ApplyCount DESC'
- END
- ELSE IF @orderBy = 13
- BEGIN
- SET @SQL = @SQL + ' ORDER BY ViewCount DESC'
- END
- ELSE IF @orderBy = 14
- BEGIN
- SET @SQL = @SQL + ' ORDER BY interView DESC'
- END
- ELSE IF @orderBy = 15
- BEGIN
- SET @SQL = @SQL + ' ORDER BY interViewReply DESC'
- END
- ELSE IF @orderBy = 16
- BEGIN
- SET @SQL = @SQL + ' ORDER BY interViewResult DESC'
- END
- ELSE IF @orderBy = 21
- BEGIN
- SET @SQL = @SQL + ' ORDER BY b.issuedate'
- END
- ELSE IF @orderBy = 22
- BEGIN
- SET @SQL = @SQL + ' ORDER BY ApplyCount'
- END
- ELSE IF @orderBy = 23
- BEGIN
- SET @SQL = @SQL + ' ORDER BY ViewCount'
- END
- ELSE IF @orderBy = 24
- BEGIN
- SET @SQL = @SQL + ' ORDER BY interView'
- END
- ELSE IF @orderBy = 25
- BEGIN
- SET @SQL = @SQL + ' ORDER BY interViewReply'
- END
- ELSE IF @orderBy = 26
- BEGIN
- SET @SQL = @SQL + ' ORDER BY interViewResult'
- END
- PRINT(@SQL)
- EXEC(@SQL)
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procJobReportDetailDataByCaMainIDSelect] Script Date: 2018/12/13 19:11:08 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:根据参数从jobReportDetailData表中取得所有职位的详细数据
- --#####################################################
- CREATE PROCEDURE [dbo].[procJobReportDetailDataByCaMainIDSelect]
- (
- @beginDays INT,
- @endDays INT,
- @caMainID INT,
- @AccoutType INT
- )
- AS
- BEGIN TRY
- IF @AccoutType = 1
- BEGIN
- SELECT SUM(workyears1) workyears1,SUM(workyears2) workyears2,SUM(workyears3) workyears3,
- SUM(workyears4) workyears4,SUM(workyears5) workyears5,SUM(age1) age1,SUM(age2) age2,
- SUM(age3) age3,SUM(age4) age4,SUM(age5) age5,SUM(age6) age6,SUM(degree1) degree1,
- SUM(degree2) degree2,SUM(degree3) degree3,SUM(degree4) degree4,SUM(degree5) degree5,
- SUM(degree6) degree6,SUM(degree7) degree7,SUM(degree8) degree8,SUM(degree9) degree9,
- SUM(salary1) salary1,SUM(salary2) salary2,SUM(salary3) salary3,SUM(salary4) salary4,
- SUM(salary5) salary5,SUM(salary6) salary6,SUM(salary7) salary7,SUM(salary8) salary8,
- SUM(male) male,SUM(female) female,cpmainid
- FROM ReportDB..jobReportDetailData a WITH(NOLOCK)
- INNER JOIN (
- (
- SELECT id,camainid,cpmainid,name,issuedate,issueend
- FROM Job WITH(NOLOCK)
- WHERE isdelete=0
- ) union (
- SELECT jobid id,camainid,cpmainid,jobname name,issuedate,issueend
- FROM JobDeleted WITH(NOLOCK)
- )
- ) b ON a.jobid =b.id
- WHERE CpMainID=@caMainID
- AND a.countdate >= @beginDays
- AND a.countdate <= @endDays GROUP BY cpmainid
- END
- ELSE
- BEGIN
- SELECT SUM(workyears1) workyears1,SUM(workyears2) workyears2,SUM(workyears3) workyears3,
- SUM(workyears4) workyears4,SUM(workyears5) workyears5,SUM(age1) age1,SUM(age2) age2,
- SUM(age3) age3,SUM(age4) age4,SUM(age5) age5,SUM(age6) age6,SUM(degree1) degree1,
- SUM(degree2) degree2,SUM(degree3) degree3,SUM(degree4) degree4,SUM(degree5) degree5,
- SUM(degree6) degree6,SUM(degree7) degree7,SUM(degree8) degree8,SUM(degree9) degree9,
- SUM(salary1) salary1,SUM(salary2) salary2,SUM(salary3) salary3,SUM(salary4) salary4,
- SUM(salary5) salary5,SUM(salary6) salary6,SUM(salary7) salary7,SUM(salary8) salary8,
- SUM(male) male,SUM(female) female,camainid FROM ReportDB..jobReportDetailData a WITH(NOLOCK)
- INNER JOIN (
- (
- SELECT id,camainid,cpmainid,name,issuedate,issueend
- FROM Job WITH(NOLOCK) WHERE isdelete=0
- ) UNION
- (
- SELECT jobid id,camainid,cpmainid,jobname name,issuedate,issueend
- FROM JobDeleted with(nolock)
- )
- ) b ON a.jobid =b.id
- WHERE CaMainID=@caMainID
- AND a.countdate >= @beginDays
- AND a.countdate <= @endDays GROUP BY CaMainID
- END
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procjobReportDetailDataByJobIDSelect] Script Date: 2018/12/13 19:11:09 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.04
- --创建人:Nick
- --说明:根据参数从jobReportDetailData表中取得详细数据
- --#####################################################
- CREATE PROCEDURE [dbo].[procjobReportDetailDataByJobIDSelect]
- (
- @BeginDays INT,
- @EndDays INT,
- @JobID iNT
- )
- AS
- BEGIN TRY
- SELECT a.jobid,SUM(workyears1) workyears1,SUM(workyears2) workyears2,SUM(workyears3) workyears3,
- SUM(workyears4) workyears4,SUM(workyears5) workyears5,SUM(age1) age1,SUM(age2) age2,SUM(age3) age3,
- SUM(age4) age4,SUM(age5) age5,SUM(age6) age6,SUM(degree1) degree1,SUM(degree2) degree2,
- SUM(degree3) degree3,SUM(degree4) degree4,SUM(degree5) degree5,SUM(degree6) degree6,SUM(degree7) degree7,
- SUM(degree8) degree8,SUM(degree9) degree9,SUM(salary1) salary1,SUM(salary2) salary2,SUM(salary3) salary3,
- SUM(salary4) salary4,SUM(salary5) salary5,SUM(salary6) salary6,SUM(salary7) salary7,SUM(salary8) salary8,
- SUM(male) male,SUM(female) female,b.id,camainid,cpmainid,name,issuedate,issueend
- FROM ReportDB..jobReportDetailData a WITH(NOLOCK)
- INNER JOIN (
- (
- SELECT id,camainid,cpmainid,name,issuedate,issueend
- FROM Job WITH(NOLOCK)
- WHERE isdelete=0
- ) UNION (
- SELECT jobid id,camainid,cpmainid,jobname name,issuedate,issueend
- FROM JobDeleted WITH(NOLOCK)
- )
- ) b ON a.jobid =b.id
- WHERE a.jobID=@JobID
- AND a.countdate >= @BeginDays
- AND a.countdate <= @EndDays
- GROUP BY a.jobid,b.id,camainid,cpmainid,name,issuedate,issueend
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcJobSimilarCompareMonthInsert] Script Date: 2018/12/13 19:11:09 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2016.8.1
- --创建人:Peter
- --说明:根据一个月内的投递情况,获取职位相似性
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcJobSimilarCompareMonthInsert]
- AS
- BEGIN
- TRUNCATE TABLE exJobApplyMonthTemp
-
- INSERT INTO exJobApplyMonthTemp (JobId,CvMainID)
- SELECT jobID,CvMainID FROM exjobapply WITH(NOLOCK) WHERE addDate > GETDATE() - 30
-
- SELECT jobID,COUNT(1) cnt INTO #TJobSimilar FROM exJobApplyMonthTemp GROUP BY jobID having COUNT(1) > 1
- DECLARE @JobID INT,@JobCount INT
-
- WHILE EXISTS(SELECT jobID FROM #TJobSimilar)
- BEGIN
- SELECT TOP 1 @JobID = jobID,@JobCount = cnt
- FROM #TJobSimilar
-
- INSERT INTO JobSimilarCompare (JobID,SimilarJobID,JobCount,Pecentage)
- SELECT TOP 3 @JobID,JobID,@JobCount,CAST(COUNT(1) AS FLOAT)*100/@JobCount
- FROM exJobApplyMonthTemp
- WHERE cvmainid IN(
- SELECT cvMainID
- FROM exJobApplyMonthTemp
- WHERE jobid = @JobID)
- AND jobid <> @JobID
- GROUP BY JobID
- ORDER BY COUNT(1) desc
-
- DELETE FROM #TJobSimilar WHERE jobID = @JobID
- END
-
- SELECT cvMainID,COUNT(1) cnt INTO #TCvLimite FROM exJobApplyMonthTemp GROUP BY cvMainID HAVING COUNT(1) > 1
-
- DECLARE @CvMainID INT,@CvAppplyCount INT
- WHILE EXISTS(SELECT CvMainID FROM #TCvLimite)
- BEGIN
- SELECT TOP 1 @CvMainID = cvMainID,@CvAppplyCount = cnt
- FROM #TCvLimite
-
- INSERT INTO CvSimilarCompare (CvMainID,SimilarJobID,JobNum)
- SELECT TOP 10 @CvMainID,JobID,COUNT(1)
- FROM exJobApplyMonthTemp
- WHERE cvMainID IN(
- SELECT TOP 10 CvMainID
- FROM exJobApplyMonthTemp
- WHERE JobID IN(
- SELECT JobID
- FROM exJobApplyMonthTemp
- WHERE CvMainID = @CvMainID)
- AND CvMainID <> @CvMainID
- GROUP BY CvMainID
- ORDER BY COUNT(1) DESC
- )
- AND CvMainID <> @CvMainID
- AND JobID NOT IN(
- SELECT SimilarJobID FROM CvSimilarCompare WITH(NOLOCK) WHERE cvMainID = @CvMainID --推荐过的就不再推荐了
- )
- GROUP BY JobID
- ORDER BY COUNT(1) desc
-
- DELETE FROM #TCvLimite WHERE CvMainID = @CvMainID
- END
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcJobSimilarCompareSelect] Script Date: 2018/12/13 19:11:09 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcJobSimilarCompareSelect]
- (
- @CvMainID INT
- )
- AS
- SET NOCOUNT ON
- BEGIN
- SELECT jobID, COUNT(1) cnt
- INTO #TJobSimilar
- FROM exJobApplyMonthTemp
- WHERE JobID IN(
- SELECT JobID
- FROM exJobApplyMonthTemp
- WHERE CvMainID = @CvMainID)
- GROUP BY jobID
- HAVING COUNT(1) > 1
-
- DECLARE @T AS TABLE(
- JobID INT,
- SimilarJobID INT,
- JobCount INT,
- Pecentage FLOAT,
- SimilarCount INT
- )
-
- DECLARE @JobID INT, @JobCount INT
-
- WHILE EXISTS(SELECT jobID FROM #TJobSimilar)
- BEGIN
- SELECT TOP 1 @JobID = jobID, @JobCount = cnt
- FROM #TJobSimilar
-
- INSERT INTO @T (JobID, SimilarJobID, JobCount, Pecentage, SimilarCount)
- SELECT @JobID, JobID, @JobCount, CAST(COUNT(1) AS FLOAT) * 100 / @JobCount, COUNT(1)
- FROM exJobApplyMonthTemp
- WHERE cvmainid IN(
- SELECT cvMainID
- FROM exJobApplyMonthTemp
- WHERE jobid = @JobID)
- AND jobid <> @JobID
- -- AND EXISTS( --职位必须有效且没被删除
- -- SELECT 'X'
- -- FROM Job WITH(NOLOCK)
- -- WHERE id = exJobApplyMonthTemp.JobID
- -- AND Valid = 1
- -- AND IsDelete = 0
- -- AND IssueEnd > GETDATE())
- -- AND JobID NOT IN( --已经申请过的不再推荐
- -- SELECT JobID
- -- FROM exJobApply WITH(NOLOCK)
- -- WHERE CvMainID = @CvMainID
- -- )
- GROUP BY JobID
- HAVING COUNT(1) > 1
- ORDER BY COUNT(1) desc
-
- DELETE FROM #TJobSimilar WHERE jobID = @JobID
- END
- DELETE FROM @t
- WHERE SimilarJobID IN( --职位必须有效且没被删除
- SELECT Id
- FROM Job WITH(NOLOCK)
- WHERE Valid = 0)
- OR SimilarJobID IN( --已经申请过的不再推荐
- SELECT JobID
- FROM exJobApply WITH(NOLOCK)
- WHERE CvMainID = @CvMainID)
-
- INSERT INTO @T (SimilarJobID, JobCount)
- SELECT TOP 10 JobID, COUNT(1)
- FROM exJobApplyMonthTemp
- WHERE cvMainID IN(
- SELECT TOP 100 CvMainID
- FROM exJobApplyMonthTemp
- WHERE JobID IN(
- SELECT JobID
- FROM exJobApplyMonthTemp
- WHERE CvMainID = @CvMainID)
- AND CvMainID <> @CvMainID
- GROUP BY CvMainID
- ORDER BY COUNT(1) DESC
- )
- AND CvMainID <> @CvMainID
- AND EXISTS( --职位必须有效且没被删除
- SELECT 'X'
- FROM Job WITH(NOLOCK)
- WHERE id = exJobApplyMonthTemp.JobID
- AND Valid = 1
- AND IsDelete = 0
- AND IssueEnd > GETDATE())
- AND JobID NOT IN( --已经申请过的不再推荐
- SELECT JobID
- FROM exJobApply WITH(NOLOCK)
- WHERE CvMainID = @CvMainID
- )
- GROUP BY JobID
- HAVING COUNT(1) > 1
- ORDER BY COUNT(1) desc
-
- SELECT a.*, b.Name JobName, b.SecondID EnJobID, c.Name SimilarJobName, c.SecondID EnSimilarJobID, d.FullName JobRegion, e.FullName SimilarJobRegion
- FROM @T a
- LEFT JOIN Job b WITH(NOLOCK) ON b.ID = a.JobID
- LEFT JOIN Job c WITH(NOLOCK) ON c.ID = a.SimilarJobID
- LEFT JOIN dcRegion d WITH(NOLOCK) ON d.ID = b.dcRegionID
- LEFT JOIN dcRegion e WITH(NOLOCK) ON e.ID = c.dcRegionID
- ORDER BY a.JobId, a.Pecentage DESC
- DROP TABLE #TJobSimilar
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobTagsBySaveInsert] Script Date: 2018/12/13 19:11:10 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --保存职位标签信息
- CREATE PROCEDURE [dbo].[procJobTagsBySaveInsert]
- (
- @JobID INT,
- @JobTags NVARCHAR(100)
- )
- AS
- BEGIN
- IF (SELECT COUNT(1) FROM dbo.Split(@JobTags,'@')) > 5
- BEGIN
- RETURN -1
- END
-
- CREATE TABLE #T
- (
- Tags NVARCHAR(10),
- VerifyDate SMALLDATETIME
- )
-
- INSERT INTO #T(Tags)
- SELECT a
- FROM dbo.Split(@JobTags,'@')
-
- DECLARE @ExistsTags NVARCHAR(MAX)
- SELECT @ExistsTags = 'A轮,水果零食,B轮,帅哥美女,C轮,定期团建,D轮,股权期权,13薪,国企控股,不出差,前瞻行业,扁平化,大厨三餐,寒暑假,朝十晚六,正能量,氛围融洽,不加班,弹性工作,下午茶,挑战高薪,牛人多,创新项目,大平台,环境优雅,健身房,季度加薪,台球桌,阳光团队,妹子多,CBD办公,高晋升,无需打卡,压力小,交通便利,自由互助,苹果电脑,领导Nice'
-
- UPDATE #T
- SET VerifyDate = GETDATE()
- WHERE Tags IN(
- SELECT a
- FROM dbo.Split(@ExistsTags,',')
- )
- OR EXISTS(
- SELECT TOP 1 'X'
- FROM jobTags WITH(NOLOCK)
- WHERE Tags = #T.Tags
- AND VerifyDate IS NOT NULL
- ORDER BY ID
- )
-
- DELETE FROM jobTags
- WHERE JobID = @JobID
-
- INSERT INTO jobTags(JobID,Tags,VerifyDate,AddDate)
- SELECT @JobID,Tags,VerifyDate,GETDATE()
- FROM #T
-
- DROP TABLE #T
-
- RETURN 1
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobTagsByVerifyDelete] Script Date: 2018/12/13 19:11:10 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --职位标签审核不通过
- CREATE PROCEDURE [dbo].[procJobTagsByVerifyDelete]
- (
- @TagsID INT
- )
- AS
- BEGIN
- DELETE FROM jobTags
- WHERE id = @TagsID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobTagsByVerifyUpdate] Script Date: 2018/12/13 19:11:10 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
-
- --职位标签审核
- CREATE PROCEDURE [dbo].[procJobTagsByVerifyUpdate]
- (
- @JobID INT
- )
- AS
- BEGIN
- UPDATE jobTags
- SET VerifyDate = GETDATE()
- WHERE JobID = @JobID
- AND VerifyDate IS NULL
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobTemplateWelfareByIDUpdate] Script Date: 2018/12/13 19:11:10 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.04
- --创建人:Nick
- --说明:保存职位模版的薪酬福利
- --修改:harry2016-3-29:修改job-jobtemplate
- --#####################################################
- CREATE PROCEDURE [dbo].[procJobTemplateWelfareByIDUpdate]
- (
- @Promotion VARCHAR(100),
- @Welfare1 INT,
- @Welfare2 INT,
- @Welfare3 INT,
- @Welfare4 INT,
- @Welfare5 INT,
- @Welfare6 INT,
- @Welfare7 INT,
- @Welfare8 INT,
- @Welfare9 INT,
- @Welfare10 INT,
- @Welfare11 INT,
- @Welfare12 INT,
- @Welfare13 INT,
- @Welfare14 INT,
- @Welfare15 INT,
- @Welfare16 INT,
- @Welfare17 INT,
- @Welfare18 INT,
- @Welfare19 INT,
- @ID INT
- )
- AS
- BEGIN
- UPDATE jobtemplate SET Promotion= @Promotion,
- Welfare1 = @Welfare1,
- Welfare2 = @Welfare2,
- Welfare3 = @Welfare3,
- Welfare4 = @Welfare4,
- Welfare5 = @Welfare5,
- Welfare6 = @Welfare6,
- Welfare7 = @Welfare7,
- Welfare8 = @Welfare8,
- Welfare9 = @Welfare9,
- Welfare10 = @Welfare10,
- Welfare11 = @Welfare11,
- Welfare12 = @Welfare12,
- Welfare13 = @Welfare13,
- Welfare14 = @Welfare14,
- Welfare15 = @Welfare15,
- Welfare16 = @Welfare16,
- Welfare17 = @Welfare17,
- Welfare18 = @Welfare18,
- Welfare19 = @Welfare19
- WHERE ID = @ID
-
- RETURN 1
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcJobToFriendInsert] Script Date: 2018/12/13 19:11:11 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcJobToFriendInsert]
- (
- @Email VARCHAR(50),
- @FriendName VARCHAR(20),
- @FromName VARCHAR(20),
- @IP VARCHAR(15),
- @JobId INT
- )
- AS
- BEGIN
- INSERT INTO MarketDb..JobToFriend(Email, FriendName, FromName, IP, JobId)
- SELECT @Email, @FriendName, @FromName, @IP, @JobId
- RETURN 0
- /*
- IF (SELECT COUNT(*) FROM MarketDb..JobToFriend WITH(NOLOCK)
- WHERE AddDate > GETDATE() - 1
- AND JobId = @JobID
- ) > 20
- RETURN 0
- IF (SELECT COUNT(*) FROM MarketDb..JobToFriend WITH(NOLOCK)
- WHERE AddDate > GETDATE() - 1
- AND IP = @IP
- ) > 30
- RETURN 0
- IF (SELECT COUNT(*) FROM MarketDb..JobToFriend WITH(NOLOCK)
- WHERE AddDate > GETDATE() - 1
- AND FriendName = @FriendName
- ) > 10
- RETURN 0
- IF (SELECT COUNT(*) FROM MarketDb..JobToFriend WITH(NOLOCK)
- WHERE AddDate > GETDATE() - 1
- AND Email = @Email
- ) > 10
- RETURN 0
-
- /*
- IF (SELECT COUNT(*) FROM MarketDb..JobToFriend WITH(NOLOCK)
- WHERE AddDate > GETDATE() - 1
- ) > 2000
- RETURN 0
- */
- RETURN 1
- */
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcJobTypeL1ByParentIdSelect] Script Date: 2018/12/13 19:11:11 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:John
- --说明:获取二级职位类别
- --@parentId 一级职位类别编号
- --修改记录:2014.11.04 增加查询字段
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcJobTypeL1ByParentIdSelect]
- (
- @parentId INT
- )
- AS
- BEGIN TRY
- SELECT a.id,a.description jobtypel0,c.description jobtypel1,b.*
- FROM dcJobTypeCategory a,dcJobTypeMap b,dcJobType c
- WHERE a.Id = b.CategoryId
- AND b.JobTypeId = c.Id
- AND LEN(b.JobTypeId) > 2
- AND a.Id = @parentId
- ORDER BY a.Id,b.OrderBy
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcJobTypeSimilarByIDSelect] Script Date: 2018/12/13 19:11:12 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.4
- --创建人:John
- --说明:获取职位类别的匹配度范围
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcJobTypeSimilarByIDSelect]
- (
- @JobTypeID VARCHAR(1000)
- )
- AS
- BEGIN
- --DECLARE @SQL AS VARCHAR(1000)
- --SET @SQL = 'SELECT * FROM dcjobtypesimilar WITH(NOLOCK) WHERE dcJobTypeId in (0' + @JobTypeID + '0) OR SimilarId in (0' + @JobTypeID + '0)'
- --EXEC(@SQL)
- SELECT TOP 0 0 ID, 0 dcJobTypeId, 0 SimilarId, 0 Coefficient
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcJobuiJobXmlOutSave] Script Date: 2018/12/13 19:11:12 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcJobuiJobXmlOutSave]
- AS
- SET NOCOUNT ON
- BEGIN
- CREATE TABLE #t(
- Id INT IDENTITY(1, 1),
- dcProvinceId TINYINT,
- JobId int NOT NULL,
- CompanyId int NOT NULL,
- EnJobID varchar(12) NULL,
- IssueDate smalldatetime NULL,
- IssueEnd smalldatetime NULL,
- Area nvarchar(20) NULL,
- JobName nvarchar(50) NOT NULL,
- CompanyName varchar(100) NOT NULL,
- JobDemand varchar(max) NULL,
- Brief varchar(6000) NULL,
- Email varchar(50) NOT NULL,
- Education nvarchar(10) NULL,
- Industry varchar(50) NULL,
- Telephone varchar(25) NULL,
- Fax varchar(20) NULL,
- Address nvarchar(60) NOT NULL,
- Zip char(6) NOT NULL,
- HomePage varchar(100) NOT NULL,
- LinkMan nvarchar(6) NULL,
- CompanySize varchar(10) NULL,
- Employtype varchar(6) NOT NULL,
- Experience varchar(7) NULL,
- Salary varchar(12) NOT NULL
- )
- INSERT INTO #t(dcProvinceId, JobId, CompanyId, EnJobID, IssueDate, IssueEnd, Area, JobName, CompanyName, JobDemand, Brief, Email, Education, Industry, Telephone, Fax, Address, Zip, HomePage, LinkMan, CompanySize, Employtype, Experience, Salary)
- SELECT b.dcProvinceID, a.Id JobId, b.Id CompanyId, a.SecondId EnJobID, a.IssueDate, a.IssueEnd + 3 + a.Id % 30,
- (SELECT MapBarName FROM dcRegion WHERE Id = a.dcRegionId) Area,
- a.Name JobName, b.Name CompanyName, a.Responsibility + CHAR(13) + a.Demand JobDemand,
- b.Brief, c.Email, (SELECT Description FROM dcEducation WHERE Id = dcEducationId) Education,
- SPACE(50) Industry,
- c.Telephone, c.Fax, ISNULL(b.Address, '') Address, ISNULL(b.Zip, '') Zip, ISNULL(b.HomePage, '') HomePage,
- CASE WHEN c.IsNameHide = 1 THEN LEFT(c.Name, 1) + CASE WHEN c.Gender = 1 THEN '女士' ELSE '先生' END
- ELSE c.Name
- END LinkMan,
- CASE WHEN b.dcCompanySizeId = 1 THEN '1-49人'
- WHEN b.dcCompanySizeId = 2 THEN '50-99人'
- WHEN b.dcCompanySizeId IN(3, 4) THEN '100-499人'
- WHEN b.dcCompanySizeId = 5 THEN '500-999人'
- WHEN b.dcCompanySizeId = 6 THEN '1000人以上'
- END CompanySize,
- CASE WHEN Employtype = 1 THEN ' 全职'
- WHEN Employtype = 3 THEN '兼职'
- WHEN Employtype = 4 THEN '实习'
- ELSE '不限制'
- END Employtype,
- CASE WHEN MinExperience IN(1, 5) THEN '0-2年'
- WHEN MinExperience = 2 THEN '3-5年'
- WHEN MinExperience = 3 THEN '6-7年'
- WHEN MinExperience = 4 THEN '11-15年'
- WHEN MinExperience = 0 THEN '不限制'
- END Experience,
- CASE WHEN dcSalaryId < 3 THEN '2000以下'
- WHEN dcSalaryId IN(4, 5, 6, 7) THEN '2000-3999'
- WHEN dcSalaryId IN(8, 9) THEN '4000-5999'
- WHEN dcSalaryId IN(10) THEN '6000-7999'
- WHEN dcSalaryId IN(11) THEN '8000-9999'
- WHEN dcSalaryId IN(12) THEN ' 10000-14999'
- WHEN dcSalaryId IN(13) THEN '15000-19999'
- WHEN dcSalaryId IN(14) THEN '20000-29999'
- WHEN dcSalaryId IN(15) THEN '30000-49999'
- WHEN dcSalaryId IN(16, 17) THEN '50000以上'
- ELSE '面议'
- END Salary
- FROM Job a WITH(NOLOCK), cpMain b WITH(NOLOCK), caMain c WITH(NOLOCK)
- WHERE a.cpMainId = b.Id
- AND a.caMainId = c.Id
- AND a.IsDelete = 0
- AND a.Valid = 1
- AND b.Valid = 1
- AND a.IssueEnd > GETDATE()
- AND b.dcProvinceId = LEFT(a.dcRegionId, 2)
- ORDER BY b.dcProvinceId, a.IssueEnd, a.Id
- UPDATE #t SET Industry = (SELECT Description FROM dcIndustry WHERE Id IN(SELECT TOP 1 dcIndustryId FROM cpIndustry WHERE cpMainId = CompanyId))
- TRUNCATE TABLE ShortDb..JobuiJobXmlOut
- INSERT INTO ShortDb..JobuiJobXmlOut(dcProvinceId, JobId, CompanyId, EnJobID, IssueDate, IssueEnd, Area, JobName, CompanyName, JobDemand, Brief, Email, Education, Industry, Telephone, Fax, Address, Zip, HomePage, LinkMan, CompanySize, Employtype, Experience, Salary)
- SELECT dcProvinceId, JobId, CompanyId, EnJobID, IssueDate, IssueEnd, Area, JobName, CompanyName, JobDemand, Brief, Email, Education, Industry, Telephone, Fax, Address, Zip, HomePage, LinkMan, CompanySize, Employtype, Experience, Salary FROM #t ORDER BY ID
- UPDATE a SET a.PageNo = (b.Row + 2999) / 3000
- FROM ShortDb..JobuiJobXmlOut a, (SELECT id, dcProvinceId, ROW_NUMBER() OVER(PARTITION BY dcProvinceId ORDER BY Id) Row FROM ShortDb..JobuiJobXmlOut) b
- WHERE a.Id = b.Id
- DROP TABLE #t
- END
- GO
- /****** Object: StoredProcedure [dbo].[procJobWelfareByIDUpdate] Script Date: 2018/12/13 19:11:13 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.04
- --创建人:Nick
- --说明:保存薪酬福利
- --#####################################################
- CREATE PROCEDURE [dbo].[procJobWelfareByIDUpdate]
- (
- @Promotion VARCHAR(100),
- @Welfare1 INT,
- @Welfare2 INT,
- @Welfare3 INT,
- @Welfare4 INT,
- @Welfare5 INT,
- @Welfare6 INT,
- @Welfare7 INT,
- @Welfare8 INT,
- @Welfare9 INT,
- @Welfare10 INT,
- @Welfare11 INT,
- @Welfare12 INT,
- @Welfare13 INT,
- @Welfare14 INT,
- @Welfare15 INT,
- @Welfare16 INT,
- @Welfare17 INT,
- @Welfare18 INT,
- @Welfare19 INT,
- @ID INT
- )
- AS
- SET NOCOUNT ON
- DECLARE @p VARCHAR(100), @l INT, @L2 INT, @i INT
- SELECT @p = LTRIM(RTRIM(@Promotion))
- SET @L = LEN(@p)
- IF @L > 6 AND CHARINDEX('$', @p) = 0 AND CHARINDEX(',', @p) = 0
- SET @Promotion = ''
- ELSE IF @L > 4
- BEGIN
- SELECT @I = 1, @L2 = 0
- WHILE @I <= @L
- BEGIN
- IF NOT EXISTS(SELECt 'x' FROM CommonChar WHERE CommonChar = SUBSTRING(@P, @i, 1))
- SET @L2 = @L2 + 1
- SET @I = @I + 1
- END
- IF @L2 > 4 OR @L2 * 2 > @L
- SET @Promotion = ''
- IF @L2 * 2 > @L
- SET @Promotion = ''
- END
- ------检查Promotion是否为正常汉字
- BEGIN TRY
- UPDATE JOB
- SET Promotion= @Promotion,
- Welfare1 = @Welfare1,
- Welfare2 = @Welfare2,
- Welfare3 = @Welfare3,
- Welfare4 = @Welfare4,
- Welfare5 = @Welfare5,
- Welfare6 = @Welfare6,
- Welfare7 = @Welfare7,
- Welfare8 = @Welfare8,
- Welfare9 = @Welfare9,
- Welfare10 = @Welfare10,
- Welfare11 = @Welfare11,
- Welfare12 = @Welfare12,
- Welfare13 = @Welfare13,
- Welfare14 = @Welfare14,
- Welfare15 = @Welfare15,
- Welfare16 = @Welfare16,
- Welfare17 = @Welfare17,
- Welfare18 = @Welfare18,
- Welfare19 = @Welfare19
- WHERE ID = @ID
- RETURN 1
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procKpi_IeSelect] Script Date: 2018/12/13 19:11:14 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procKpi_IeSelect]
- AS
- BEGIN
- INSERT INTO Kpi_IeToSales
- select id,title,present,improvement,effect,feasible,ApplyMeasure
- from kpi_ie
- where adddate > '2013-8-1'
- and receiver in(select id from manageruser where deptid=24)
- and (sender in(select id from manageruser where deptid in(3,4,5,19,25,27,28,31,34,36,37,39))
- or sender between 180 and 190)
- AND ApplyMeasure>''
- AND ID NOT IN(select id from Kpi_IeToSales)
- ORDER BY ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procLinkByProvinceidSelect] Script Date: 2018/12/13 19:11:14 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procLinkByProvinceidSelect]
- (
- @Province_Id SMALLINT,
- @Type Smallint
- )
- AS
- BEGIN
- SELECT Id, Text, Link, FileName, nofollow
- FROM Link WITH(NOLOCK)
- WHERE versionId = @Province_Id
- AND Type = @Type
- AND Valid = 1
- AND Orderby >= 100
- AND Deleted = 0
- ORDER BY ORDERby
- END
- GO
- /****** Object: StoredProcedure [dbo].[procLinkByValidSelect] Script Date: 2018/12/13 19:11:14 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:NICK
- --说明:获取友情链接
- --#####################################################
- CREATE PROCEDURE [dbo].[procLinkByValidSelect]
- AS
- BEGIN
- SELECT * FROM Link WITH(NOLOCK) WHERE VersionID = 0 AND Valid = 1 AND Orderby >=100 AND Deleted = 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[procLinkHomepageTextSelect] Script Date: 2018/12/13 19:11:14 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --创建人 Lambo
- --20101009
- --用于首页查询友情链接
- CREATE PROCEDURE [dbo].[procLinkHomepageTextSelect]
- (
- @province_id SMALLINT
- )
- AS
- BEGIN
- SELECT id, text, link, nofollow FROM SearchDb..hplinkDay
- WHERE ProvinceID = @province_id
- AND Category IS NULL
- ORDER BY ID
- /*
- IF @province_id < 100
- SELECT id, text, link, nofollow FROM SearchDb..hplinkDay
- WHERE ProvinceID = @province_id
- ORDER BY ID
- ELSE
- BEGIN
- IF EXISTS(SELECT 'x' FROM SearchDb..hplinkDay WHERE ProvinceID = @province_id)
- SELECT id, text, link, nofollow FROM SearchDb..hplinkDay
- WHERE ProvinceID = @province_id
- ORDER BY ID
- ELSE
- SELECT id, text, link, nofollow FROM SearchDb..hplinkDay
- WHERE ProvinceID = LEFT(@province_id, 2)
- ORDER BY ID
- END
- */
- END
- GO
- /****** Object: StoredProcedure [dbo].[procLinkInsert] Script Date: 2018/12/13 19:11:14 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procLinkInsert]
- @text NVARCHAR(50),
- @link VARCHAR(200),
- @versionid INT,
- @type TINYINT,
- @filename VARCHAR(1000),
- @valid SMALLINT,
- @linkman NVARCHAR(50),
- @telephone VARCHAR(50),
- @email VARCHAR(100),
- @nofollow bit
- AS
- INSERT INTO Link (text,link,versionid,type,filename,valid,linkman,telephone,email,nofollow)
- VALUES(@text,@link,@versionid,@type,@filename,@valid,@linkman,@telephone,@email,@nofollow)
- GO
- /****** Object: StoredProcedure [dbo].[procLinkSelect] Script Date: 2018/12/13 19:11:15 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:NICK
- --说明:获取友情链接
- --#####################################################
- CREATE PROCEDURE [dbo].[procLinkSelect]
- AS
- BEGIN
- SELECT * FROM Link WITH(NOLOCK) WHERE VersionID = 0 AND Valid = 1 AND Orderby < 100 AND Deleted = 0
- END
- GO
- /****** Object: StoredProcedure [dbo].[procLinkSelectByProvinceid] Script Date: 2018/12/13 19:11:15 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procLinkSelectByProvinceid]
- (
- @Province_Id SMALLINT,
- @Type Smallint
- )
- AS
- BEGIN
- SELECT Id, Text, Link, FileName, nofollow
- FROM Link WITH(NOLOCK)
- WHERE versionId = @Province_Id
- AND Type = @Type
- AND Valid = 1
- AND Orderby >= 100
- AND Deleted = 0
- ORDER BY ORDERby
- END
- GO
- /****** Object: StoredProcedure [dbo].[procLinkZhaopinTextSelect] Script Date: 2018/12/13 19:11:15 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --创建人 Lucifer
- --20120213
- --用于分类搜索查询友情链接
- CREATE PROCEDURE [dbo].[procLinkZhaopinTextSelect]
- (
- @province_id SMALLINT,
- @category TINYINT
- )
- AS
- BEGIN
- SELECT id, text, link, nofollow FROM SearchDb..hplinkDay
- WHERE ProvinceID = @province_id
- AND Category=@category
- ORDER BY ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procLotteryCompany50Select] Script Date: 2018/12/13 19:11:15 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:查询最新获奖的单位
- --#####################################################
- CREATE PROCEDURE [dbo].[procLotteryCompany50Select]
- AS
- BEGIN
- SELECT TOP 50 a.*,b.Name,(
- SELECT TOP 1 DetailName
- FROM dcvipdetail
- WHERE id IN (
- SELECT TOP 1 dcfeedetailid
- FROM caOrder
- WHERE id = a.caorderid
- )
- ) ordername
- FROM LotteryCompany a,cpmain b WITH(NOLOCK)
- WHERE a.cpmainid = b.id
- AND CaOrderID IS NOT NULL
- AND Used=1
- AND [Type] <> 9
- AND CaOrderID IS NOT NULL
- ORDER BY a.ID DESC
- END
- GO
- /****** Object: StoredProcedure [dbo].[procLotteryCompanyByCpMainIDSelect] Script Date: 2018/12/13 19:11:15 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:查询本单位获奖记录
- --#####################################################
- CREATE PROCEDURE [dbo].[procLotteryCompanyByCpMainIDSelect]
- (
- @CpMainID INT
- )
- AS
- BEGIN
- SELECT top 20 * FROM LotteryCompany WITH(NOLOCK) WHERE Used=1 AND cpMainID=@CpMainID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procLotteryCompanyCountSelect] Script Date: 2018/12/13 19:11:16 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:
- --#####################################################
- CREATE PROCEDURE [dbo].[procLotteryCompanyCountSelect]
- (
- @CpMainID INT
- )
- AS
- BEGIN
- SELECT COUNT(*) FROM LotteryCompany WHERE cpmainid=@CpMainID and used=0
- END
- GO
- /****** Object: StoredProcedure [dbo].[procLotteryCompanyLoginLogByCpMainIDSelect] Script Date: 2018/12/13 19:11:16 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.5
- --创建人:NICK
- --说明:
- --#####################################################
- CREATE PROCEDURE [dbo].[procLotteryCompanyLoginLogByCpMainIDSelect]
- (
- @CpMainID INT
- )
- AS
- BEGIN
- SELECT * FROM LotteryCompanyLoginLog WITH(NOLOCK) WHERE cpMainID=@CpMainID ORDER BY LoginDate
- END
- GO
- /****** Object: StoredProcedure [dbo].[procMajorClass1000Select] Script Date: 2018/12/13 19:11:16 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:根据字母得到专业信息
- --#####################################################
- CREATE PROCEDURE [dbo].[procMajorClass1000Select]
- AS
- BEGIN TRY
- SELECT * FROM MajorClass WITH(NOLOCK) WHERE istop1000=1 ORDER BY id
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procMajorClass100Select] Script Date: 2018/12/13 19:11:16 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.04
- --创建人:Nick
- --说明:获取专业分类
- --#####################################################
- CREATE PROCEDURE [dbo].[procMajorClass100Select]
- AS
- BEGIN TRY
- SELECT TOP 46 * FROM MajorClass WHERE IsTop100=1
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcMajorClassByFirstLetterSelect] Script Date: 2018/12/13 19:11:17 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:John
- --说明:根据字母得到专业信息
- --@ch 专业信息第一个字母
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcMajorClassByFirstLetterSelect]
- (
- @ch CHAR(1)
- )
- AS
- BEGIN TRY
- SELECT * FROM MajorClass WHERE FirstLetter = @ch
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procMajorClassNameByIDSelect] Script Date: 2018/12/13 19:11:17 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:根据ID获得专业名称
- --#####################################################
- CREATE PROCEDURE [dbo].[procMajorClassNameByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN TRY
- SELECT majorname FROM MajorClass WITH(NOLOCK) WHERE id=@ID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcMajorClassSelect] Script Date: 2018/12/13 19:11:17 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.28
- --创建人:John
- --说明:专业信息分类的列表Xml
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcMajorClassSelect]
- AS
- BEGIN TRY
- SELECT * FROM MajorClass WITH(NOLOCK) ORDER BY id
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcManagerLogByAutoInsert] Script Date: 2018/12/13 19:11:17 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcManagerLogByAutoInsert]
- (
- @ManagerId INT,
- @Ip VARCHAR(15)
- )
- AS
- BEGIN
- INSERT ManagerLog
- SELECT @ManagerId, GETDATE(), @ip, 'autoclick', '', NULL, NULL
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcManagerLogByIpUpdate] Script Date: 2018/12/13 19:11:17 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcManagerLogByIpUpdate]
- (
- @ManagerId INT,
- @Ip VARCHAR(15)
- )
- AS
- SET NOCOUNT ON
- BEGIN
- DECLARE @LoginDate DATETIME, @PrevIp VARCHAR(15)
- SELECT TOP 1 @LoginDate = LoginDate, @PrevIp = Ip FROM ManagerLog WHERE ManagerId = @ManagerId ORDER BY LoginDate DESC
- IF @LoginDate > DATEADD(MINUTE, -5, GETDATE()) AND @PrevIp <> @Ip
- BEGIN
- UPDATE ManagerLog SET Ip = @Ip, InternalIp = @PrevIp WHERE ManagerId = @ManagerId AND @LoginDate = LoginDate
- END
- END
-
- GO
- /****** Object: StoredProcedure [dbo].[procManagerUserAllSelect] Script Date: 2018/12/13 19:11:18 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:获取全部公司用户
- --#####################################################
- CREATE PROCEDURE [dbo].[procManagerUserAllSelect]
- AS
- BEGIN TRY
- SELECT ID, Name, Name_Eng, Title, mobile, Email, Status, Type, Superior
- FROM ManagerUser WITH(NOLOCK)
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcManagerUserByIDSelect] Script Date: 2018/12/13 19:11:18 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.30
- --创建人:Nick
- --说明:获取工位信息
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcManagerUserByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN TRY
- SELECT * FROM ManagerUser WHERE ID=@ID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcManagerUserByServiceStatusSelect] Script Date: 2018/12/13 19:11:18 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcManagerUserByServiceStatusSelect]
- AS
- BEGIN
- SELECT Id, RtxStatus FROM Manageruser WITH(NOLOCK) WHERE ID BETWEEN 180 AND 182 OR ID = 222 OR ID = 223
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcManageruserBySOLStatusUpdate] Script Date: 2018/12/13 19:11:18 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcManageruserBySOLStatusUpdate]
- (
- @ManageruserID SMALLINT,
- @Online TINYINT
- )
- AS
- BEGIN
- UPDATE Manageruser SET SOLStatus = @Online WHERE ID = @ManageruserID
- UPDATE a SET a.IsOnline = b.SOLStatus FROM ChatService a, Manageruser b WHERE a.ManagerUserID = b.ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procManagerUserDeptByIDSelect] Script Date: 2018/12/13 19:11:19 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[procManagerUserDeptByIDSelect]
- (
- @id INT
- )
- AS
- BEGIN
- SELECT a.id,a.name,b.DeptName FROM ManagerUser a WITH(NOLOCK),dept b WITH(NOLOCK) WHERE a.deptid = b.id AND a.id = @id
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcManageruserOnlineStatusUpdate] Script Date: 2018/12/13 19:11:19 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[ProcManageruserOnlineStatusUpdate]
- @ManageruserIDs VARCHAR(MAX)
- AS
- BEGIN
- UPDATE Manageruser SET SOLStatus=1,SOLTime=GETDATE() WHERE ID IN(SELECT a FROM dbo.fnSplit(@ManageruserIDs,','))
- UPDATE Manageruser SET SOLStatus=0 WHERE ID NOT IN(SELECT a FROM dbo.fnSplit(@ManageruserIDs,','))
- UPDATE ChatService SET IsOnline=1 WHERE ManageruserID IN(SELECT a FROM dbo.fnSplit(@ManageruserIDs,','))
- UPDATE ChatService SET IsOnline=0 WHERE ManageruserID NOT IN(SELECT a FROM dbo.fnSplit(@ManageruserIDs,','))
- END
- GO
- /****** Object: StoredProcedure [dbo].[ProcManagerUserRtxStatusSelect] Script Date: 2018/12/13 19:11:19 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.30
- --创建人:Nick
- --说明:获取状态
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcManagerUserRtxStatusSelect]
- (
- @ID INT
- )
- AS
- BEGIN
- IF @ID = 0
- SELECT RtxStatus FROM Manageruser WITH(NOLOCK) WHERE RtxStatus=1 AND type=5
- ELSE
- SELECT rtxstatus FROM ManagerUser WITH(NOLOCK) WHERE id=@ID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procManagerUserSelect] Script Date: 2018/12/13 19:11:19 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:获取公司用户
- --#####################################################
- CREATE PROCEDURE [dbo].[procManagerUserSelect]
- AS
- BEGIN TRY
- SELECT ID, Name, Name_Eng, Title, mobile, Email, Type, Superior
- FROM ManagerUser WITH(NOLOCK)
- WHERE Status < 3
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[ProcManagerUserStatusSelect] Script Date: 2018/12/13 19:11:19 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.10.30
- --创建人:Nick
- --说明:获取状态
- --#####################################################
- CREATE PROCEDURE [dbo].[ProcManagerUserStatusSelect]
- (
- @ID INT
- )
- AS
- BEGIN TRY
- SELECT ID
- FROM manageruser
- WHERE Status < 3
- AND ID=@ID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procManageruserSuperior] Script Date: 2018/12/13 19:11:20 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER OFF
- GO
- CREATE PROCEDURE [dbo].[procManageruserSuperior]
- (
- @sender INT,
- @receiver INT
- )
- AS
- --INSERT INTO procLog SELECT 'procManageruserSuperior', '', GETDATE()
- BEGIN
- DECLARE @superior INT,@r1 INT,@r2 INT,@r3 INT,@s1 INT,@s2 INT,@s3 INT
- SELECT @s1=superior FROM manageruser WITH(nolock) WHERE id=@sender
- SELECT @r1=superior FROM manageruser WITH(nolock) WHERE id=@receiver
- SELECT @s2=superior FROM manageruser WITH(nolock) WHERE id=@s1
- SELECT @r2=superior FROM manageruser WITH(nolock) WHERE id=@r1
- SELECT @s3=superior FROM manageruser WITH(nolock) WHERE id=@s2
- SELECT @r3=superior FROM manageruser WITH(nolock) WHERE id=@r2
- IF @s1=@r1
- SET @superior=@s1
- ELSE IF @s1=@r2
- SET @superior=@s1
- ELSE IF @s2=@r1
- SET @superior=@r1
- ELSE IF @s1=@r3
- SET @superior=@s1
- ELSE IF @r1=@s3
- SET @superior=@r1
- ELSE IF @r2=@s2
- SET @superior=@s2
- ELSE IF @r2=@s3
- SET @superior=@r2
- ELSE IF @s2=@r3
- SET @superior=@s2
- ELSE IF @r3=@s3
- SET @superior=@s3
- ELSE
- SET @superior=1
- SELECT @superior AS superior
- END
- GO
- /****** Object: StoredProcedure [dbo].[procManagerUserSuperiorByIDSelect] Script Date: 2018/12/13 19:11:20 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.10
- --创建人:John
- --说明:获取顾问上级
- --#####################################################
- CREATE PROCEDURE [dbo].[procManagerUserSuperiorByIDSelect]
- (
- @ManagerID INT
- )
- AS
- BEGIN
- SELECT Superior FROM Manageruser WITH(NOLOCK) WHERE ID = @ManagerID
- END
- GO
- /****** Object: StoredProcedure [dbo].[procMapClassByIDSelect] Script Date: 2018/12/13 19:11:20 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.03
- --创建人:Nick
- --说明:根据ID获得专业名称
- --#####################################################
- CREATE PROCEDURE [dbo].[procMapClassByIDSelect]
- (
- @ID INT
- )
- AS
- BEGIN TRY
- SELECT MapName FROM MARKETDB..MapClass WHERE id=@ID
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procMapClassBySubSiteIdSelect] Script Date: 2018/12/13 19:11:20 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- --#####################################################
- --创建时间:2014.11.04
- --创建人:Nick
- --说明:获取职位列表
- --#####################################################
- CREATE PROCEDURE [dbo].[procMapClassBySubSiteIdSelect]
- (
- @dcSubSiteId INT
- )
- AS
- BEGIN TRY
- SELECT * FROM MARKETDB..MapClass WITH(NOLOCK) WHERE dcSubSiteId=@dcSubSiteId
- END TRY
- BEGIN CATCH
- RETURN 0
- END CATCH
- GO
- /****** Object: StoredProcedure [dbo].[procMarketMediaByProvinceIdSelect] Script Date: 2018/12/13 19:11:20 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
|