Exemple #1
0
 def get(self):
     ret = {'status': 1, 'message': ''}
     try:
         company_id = str2int(self.get_argument('company_id', ''))
         site_id = str2int(self.get_argument('site_id', ''))
         if not (company_id and site_id):
             raise InvalidParamError(u'提交参数错误!')
         try:
             handler = SiteConfig.GetTaskHandler(company_id, site_id, None)
             try:
                 # 开始登陆
                 handler.login()
                 # 反馈结果
                 if handler.status == HANDLE_STATUS.SUCCESS:
                     ret['status'] = 100
                     # 增加201轮询指令
                     DBTask.newSchedule(company_id, site_id)
                 else:
                     ret['message'] = handler.message
             except BaseException as e:
                 raise UnHandleRuntimeError(e)
                 logger.error(u'Web服务请求异常,原因:{}'.format(e))
         except BaseError as e:
             ret['message'] = e.message
     finally:
         logger.debug(ret)
         self.write(json.dumps(ret))
Exemple #2
0
 def pack_resume_search(self, conditions):
     params = {}
     hidparams = {}
     hidparams['KEYWORDTYPE'] = '0'
     hidparams['KEYWORD'] = ''
     hidparams['LASTMODIFYSEL'] = '5'
     hidparams['AGE'] = ''
     hidparams['SEX'] = '99'
     hidparams['TOPDEGREE'] = ''
     hidparams['EXPECTSALARY'] = '01|99'
     hidparams['WORKYEAR'] = '0|99'
     hidparams['LASTMODIFYSEL'] = '5'
     hidparams['WORKINDUSTRY1'] = ''
     for cond in conditions:
         if not cond.condition_val: continue
         if cond.condition_type == 'keywords':
             hidparams['KEYWORD'] = cond.condition_val.decode('utf-8')
         elif cond.condition_type == 'education':
             hidparams['TOPDEGREE'] = dict_infos('WY:Degree', cond.condition_val, '|')
         elif cond.condition_type == 'update':
             if cond.condition_val <= 2:
                 hidparams['LASTMODIFYSEL'] = '1'
             elif cond.condition_val == 3:
                 hidparams['LASTMODIFYSEL'] = '2'
             elif cond.condition_val == 4:
                 hidparams['LASTMODIFYSEL'] = '3'
             elif cond.condition_val == 5:
                 hidparams['LASTMODIFYSEL'] = '4'
             elif cond.condition_val <= 7:
                 hidparams['LASTMODIFYSEL'] = '5'
             else:
                 hidparams['LASTMODIFYSEL'] = '2016'
         elif cond.condition_type == 'age':
             hidparams['AGE'] = cond.condition_val.replace('#', '|')
         elif cond.condition_type == 'area':
             # 包含期望工作地点
             params['chkExpectJobArea'] = 'on'
             hidparams['AREA'] = dict_info('WY:Area', cond.condition_val)['id']
         elif cond.condition_type == 'industry':
             # WORKINDUSTRY1#计算机软件|01$互联网/电子商务|32
             hidparams['WORKINDUSTRY1'] = dict_info_all('WY:Industry', cond.condition_val, '$', '|')
         elif cond.condition_type == 'sex':
             hidparams['SEX'] = dict_info('WY:Gender', cond.condition_val)['id']
         elif cond.condition_type == 'salary':
             min_salary = str2int(cond.condition_val.split('#')[0])
             max_salary = str2int(cond.condition_val.split('#')[1])
             hidparams['EXPECTSALARY'] = '|'.join([
                 self.__GetNearbyMinSalary(min_salary),
                 self.__GetNearbyMaxSalary(max_salary)
             ])
     hidValue = u'*'.join(u'#'.join([key, value]) for key, value in hidparams.items())
     params['hidValue'] = hidValue
     return params
Exemple #3
0
 def post(self):
     ret = {'status': 1, 'message': ''}
     try:
         site_id = str2int(self.get_argument('site_id', ''))
         member_name = self.get_argument('member_name', '')
         login_name = self.get_argument('login_name', '')
         session = self.get_argument('sessionid', '')
         # 中文解码
         member_name = unquote(member_name.encode('gbk'))
         login_name = unquote(login_name.encode('gbk'))
         #
         if session:
             if site_id and login_name:
                 messages = decryptBindPasswd('zpb', session).split(':')
                 if len(messages) == 2:
                     companyid = messages[0]
                     if Bind.unBind(companyid, site_id, member_name,
                                    login_name):
                         ret['status'] = 0
                         ret['message'] = u'账号解绑成功!'
                         DBTask.newSchedule(companyid, site_id, False)
                     else:
                         ret['message'] = u'账号解绑失败,账号尚未绑定!'
                 else:
                     ret['message'] = u'非法的请求!'
             else:
                 ret['message'] = u'非法的请求,提交参数不全!'
         else:
             ret['message'] = u'非法的请求!'
     finally:
         logger.debug(ret)
         self.write(json.dumps(ret))
Exemple #4
0
 def post(self):
     ret = {'status': 1, 'message': ''}
     try:
         email_host = self.get_argument('host', '')
         email_port = str2int(self.get_argument('port', '110'))
         user_code = self.get_argument('usercode', '')
         user_pswd = self.get_argument('password', '')
         ssl = self.get_argument('ssl', False)
         session = self.get_argument('sessionid', '')
         if email_port == 0:
             email_port = 110
         if session:
             if email_host and email_port and user_code and user_pswd:
                 messages = decryptBindPasswd('zpb', session).split(':')
                 if len(messages) == 2:
                     companyid = messages[0]
                     res = EmailConf.newAndSave(companyid, email_host,
                                                email_port, ssl, user_code,
                                                user_pswd)
                     # 反馈结果
                     if res:
                         ret['status'] = 0
                         ret['message'] = u'账号绑定成功!'
                     else:
                         ret['message'] = u'内部服务错误!'
                 else:
                     ret['message'] = u'非法的请求!'
             else:
                 ret['message'] = u'非法的请求,提交参数不全!'
         else:
             ret['message'] = u'非法的请求!'
     finally:
         logger.debug(ret)
         self.write(json.dumps(ret))
Exemple #5
0
 def getSiteNameById(siteid):
     if isinstance(siteid, basestring):
         siteid = str2int(siteid)
     if SiteConfig._SITE.has_key(siteid):
         return SiteConfig._SITE[siteid]['name']
     else:
         return siteid
Exemple #6
0
 def pack_resume_search(self, conditions):
     params = {}
     params['SF_1_1_7'] = '4,9'
     for cond in conditions:
         if not cond.condition_val: continue
         if cond.condition_type == 'keywords':
             params['SF_1_1_1'] = cond.condition_val
         elif cond.condition_type == 'education':
             min_edu = cond.condition_val.split('#')[0]
             max_edu = cond.condition_val.split('#')[1]
             params['SF_1_1_5'] = ','.join([
                 self.__edu_dict[min_edu],
                 self.__edu_dict[max_edu]
             ])
         elif cond.condition_type == 'update':
             params['SF_1_1_7'] = '{},9'.format(cond.condition_val)
         elif cond.condition_type == 'age':
             params['SF_1_1_8'] = cond.condition_val.replace('#', ',')
         elif cond.condition_type == 'area':
             # 居住地点 SF_1_1_18为期望工作地点
             params['SF_1_1_6'] = dict_info('RD2:Area', cond.condition_val)['id']
         elif cond.condition_type == 'industry':
             params['SF_1_1_3'] = dict_infos('RD2:Industry', cond.condition_val, ';')
         elif cond.condition_type == 'sex':
             params['SF_1_1_9'] = dict_info('RD2:Gender', cond.condition_val)['id']
         elif cond.condition_type == 'salary':
             minmax = cond.condition_val.split('#')
             if len(minmax) == 2:
                 minsalary = str2int(minmax[0])
                 maxsalary = str2int(minmax[1]) if minmax[1] != '' else 25000
                 avg = int(round(minsalary + maxsalary) / 2)
                 pay = getSalaryIdBySalaryValue(avg)
                 params['SF_1_1_20'] = dict_info('RD2:MonthPay', pay)['id']
     # 去重
     params['exclude'] = '1'
     # 每页数量
     params['pageSize'] = '60'
     # 排序
     params['orderBy'] = 'DATE_MODIFIED,1'
     return params
Exemple #7
0
 def post(self):
     ret = {'status': 1, 'message': ''}
     try:
         site_id = str2int(self.get_argument('site_id', ''))
         member_name = self.get_argument('member_name', '')
         login_name = self.get_argument('login_name', '')
         login_pswd = self.get_argument('login_pswd', '')
         # 中文解码
         member_name = unquote(member_name.encode('gbk'))
         login_name = unquote(login_name.encode('gbk'))
         #
         session = self.get_argument('sessionid', '')
         try:
             if not session:
                 raise InvalidParamError(u'非法的请求!')
             if not (site_id and login_name and login_pswd):
                 raise InvalidParamError(u'非法的请求!')
             messages = decryptBindPasswd('zpb', session).split(':')
             if len(messages) != 2:
                 raise InvalidParamError(u'非法的请求!')
             companyid = messages[0]
             handler = SiteConfig.GetTaskHandler(0, site_id, None)
             # 登录密码解密
             password = decryptBindPasswd(login_name, login_pswd)
             if not password:
                 raise InvalidParamError(u'登录账号或密码错误!')
             try:
                 # 开始登陆
                 (res,
                  message) = handler.innerlogin(member_name, login_name,
                                                password)
                 # 反馈结果
                 if res:
                     if Bind.newAndSave(companyid, site_id, member_name,
                                        login_name, login_pswd):
                         ret['status'] = 0
                         ret['message'] = u'账号绑定成功!'
                     else:
                         ret['status'] = 0
                         ret['message'] = u'账号已绑定!'
                     DBTask.newSchedule(companyid, site_id)
                 else:
                     ret['message'] = message
             except BaseException as e:
                 raise UnHandleRuntimeError(e)
                 logger.error(u'Web服务请求异常,原因:{}'.format(e))
         except BaseError as e:
             ret['message'] = e.message
     finally:
         logger.debug(ret)
         self.write(json.dumps(ret))
Exemple #8
0
def AssembelResumeByJson(js):
    """
    : params json js
    : return (bool, str, bool)->(处理状态,错误原因或简历ID,是否新简历)
    """
    # 噪声过滤
    if js['Sex'] == '' and js['Age'] == '':
        if js['LastUpdate'] == '199001':
            return (False, u'非法的简历!', False)
        if js['siteid'] == 0:
            return (False, u'非法的简历!', False)
    #
    session = DBInstance.session
    try:
        # 强制刷新简历(用於付费简历下载)
        force = js.get('force', False)
        (ret, rm) = ResumeBase.queryAndCreate(session, js['companyid'], js['siteid'], js['websiteresumeid'], js['apply_time'])
        if not ret and not force:
            return (True, rm.resume_code, False)
        # 填充简历
        rm.apply_job_status = 0
        rm.apply_job_id = 0
        # 简历关联的职位ID,用最新的覆盖
        if js['jobid']:
            rm.from_site_jobcode = js['jobid']
        if not rm.from_site_jobcode:
            rm.from_site_jobcode = ''
        # 来源可能制定本系统关联职位ID(imp_local_file)
        if js['apply_job_id']:
            rm.apply_job_id = js['apply_job_id']
            rm.apply_job_status = 1
        else:
            # 依据招聘平台职位ID查找本系统职位ID
            if rm.from_site_jobcode:
                jobid = JobSyncDistribute.queryJobIdByThirdJobCode(rm.company_id, rm.from_site_id, rm.from_site_jobcode)
                if jobid:
                    rm.apply_job_status = 1
                    rm.apply_job_id = jobid
        # 判定简历投递时间
        if rm.apply_job_status == 1:
            if rm.apply_time <= dateAdd(day=-7):
                rm.pre_apply_job_id = rm.apply_job_id
                rm.apply_job_id = 0
                rm.apply_job_status = 0
        #
        rm.resume_type = js['Type']
        rm.resume_grade = js['ResumeGrade']
        rm.married_status = js['Married']
        rm.id_no = js['IDNO']
        rm.get_encouragement = js['Encouragement'].replace('\r\n', '<br />')
        rm.join_team = js['Team'].replace('\r\n', '<br />')
        rm.volunteer_info = js['Volunteer']
        rm.graduate_year = str2int(js['Graduatetime'][0: 4])
        rm.graduate_month = str2int(js['Graduatetime'][5: 7])
        rm.begin_work_year = str2int(js['Beginworktime'][0: 4])
        rm.begin_work_month = str2int(js['Beginworktime'][5: 7])
        rm.last_update = js['LastUpdate']
        rm.third_score = js['Score']
        rm.certificate_name = js['Certificate'].replace('\r\n', '<br />')
        rm.person_memo = js['Personal'].replace('\r\n', '<br />')
        rm.lesson_name = js['Lesson']
        rm.computer_level = js['Computer']
        rm.english_level = js['English']
        rm.graduate_school = js['School']
        rm.school_rankings = js['SchoolRankings']
        rm.addr_postcode = js['PostCode']
        rm.speciality_name = js['Speciality']
        rm.contact_addr = js['Address']
        rm.native_place = js['Jiguan']
        rm.national_name = js['National']
        rm.nationality_name = js['Nationality']
        rm.birth_day = js['Birth']
        # 来源于简历搜索器(简历解析服务器返回结果有噪声)
        if js['source'] == 9:
            if rm.source is None or rm.source == 9:
                rm.person_name = ''
                rm.family_name = ''
        else:
            rm.person_name = js['Name']
            rm.family_name = js['FamilyName']
        #
        rm.person_href = js['Href']
        rm.hope_title = js['Title']
        rm.hope_title2 = js['Title2']
        rm.title_standard = js['TitleStandard']
        rm.aim_institution = js['AimInstitution']
        rm.person_age = str2int(js['Age'])
        rm.person_sex = js['Sex']
        rm.body_high = js['High']
        rm.body_weight = js['Weight']
        if js['Mobile']:
            rm.mobile_no = js['Mobile']
        if rm.mobile_no is None:
            rm.mobile_no = ''
        if js['Phone']:
            rm.other_phone = js['Phone']
        if rm.other_phone is None:
            rm.other_phone = ''
        rm.fax_no = js['Fax']
        if js['Email']:
            rm.email_addr = js['Email']
        if rm.email_addr is None:
            rm.email_addr = ''
        if rm.email_addr == '*****@*****.**':
            rm.email_addr = ''
        rm.now_location = js['NowLocation']
        rm.hope_location = js['Forwardlocation']
        rm.high_education = js['Education']
        if rm.high_education == u'大專':
            rm.high_education = u'大专'
        rm.high_edu_id = getEduHighId(rm.high_education)
        rm.advance_degree = js['AdvancedDegree']
        rm.exp_name = ''
        rm.now_vocation = js['Vocation']
        rm.hope_vocation = js['ForwardVocation']
        rm.vocation_standard = js['VocationStandard']
        rm.now_salary = js['Salary']
        rm.hope_salary = js['AimSalary']
        rm.political_name = js['Political']
        rm.start_from = js['StartFrom']
        rm.apply_switch = js['Switch']
        rm.qq_no = js['QQ']
        rm.student_type = js['StudentType']
        rm.photo_url = js['PhotoUrl']
        rm.apply_letter = js['AppLetter']
        rm.last_company = js['LastCompany']
        rm.last_title = js['LastTitle']
        rm.overseas_work = js['OverseasWork']
        rm.job_hope_frequency = js['JobHoppingFrequency']
        rm.integrity_ratio = js['Integrity']
        rm.work_type = js['WorkType']
        rm.birth_date = getBirthDay(js['Birth'])
        rm.work_years = str2int(js['Experience'])
        rm.source = js.get('source', 0)
        rm.matching_degree = js.get('matching', 0)
        rm.is_valid = 'T'
        rm.modify_user = '******'
        rm.modify_time = datetime.today()
        session.add(rm)
        # 简历扩展
        rext = ResumeExtend()
        rext.resume_code = rm.resume_code
        rext.org_resume = fmtHtml(js['Original'])
        rext.edu_detail_full = js['EducationDetail'].replace('\r\n', '<br />')
        rext.exp_detail_full = js['ExperienceDetail'].replace('\r\n', '<br />')
        rext.train_detail_full = js['Training'].replace('\r\n', '<br />')
        rext.proj_detail_full = js['Project'].replace('\r\n', '<br />')
        rext.skill_detail_full = js['Skill'].replace('\r\n', '<br />')
        rext.is_valid = 'T'
        rext.create_user = '******'
        rext.create_time = datetime.today()
        session.add(rext)
        #
        if js['EducationInfo']:
            for (idx, item) in enumerate(js['EducationInfo']):
                redu = ResumeEdu()
                redu.resume_code = rm.resume_code
                redu.start_date = item['StartDate']
                redu.end_date = item['EndDate']
                redu.school_name = item['School']
                redu.major_name = item['Speciality']
                redu.adv_degree = item['AdvancedDegree']
                redu.diplomas_name = item['Education']
                redu.depart_name = item['Department']
                redu.edu_summary = item['Summary'].replace('\r\n', '<br />')
                redu.is_studii = item['IsStudii']
                redu.is_valid = 'T'
                session.add(redu)
                # 异步增加百科超链接
                dtc.async('zpb.business.model.hyperlink.AppendSchoolLink', redu.school_name)
        #
        if js['ExperienceInfo']:
            for (idx, item) in enumerate(js['ExperienceInfo']):
                rexp = ResumeExp()
                rexp.resume_code = rm.resume_code
                rexp.start_date = item['StartDate']
                rexp.end_date = item['EndDate']
                rexp.periods_of_time = item['PeriodsOfTime']
                # 最近工作的时间长度写入resume_base表
                if idx == 0:
                    rm.periods_of_time = rexp.periods_of_time
                rexp.company_name = item['Company']
                rexp.work_location = item['Location']
                rexp.vocation_name = item['Vocation']
                rexp.company_scale = item['Size']
                rexp.company_type = item['Type']
                rexp.depart_name = item['Department']
                rexp.work_title = item['Title']
                rexp.salary_name = item['Salary']
                rexp.work_summary = item['Summary'].replace('\r\n', '<br />')
                rexp.leader_name = item['Leader']
                rexp.underling_num = str2int(item['UnderlingNumber'])
                rexp.leaving_reason = item['ReasonOfLeaving']
                rexp.is_valid = 'T'
                session.add(rexp)
                # 异步增加百科超链接
                dtc.async('zpb.business.model.hyperlink.AppendCompanyLink', rexp.company_name)
        #
        if js['TrainingInfo']:
            for item in js['TrainingInfo']:
                rtra = ResumeTrain()
                rtra.resume_code = rm.resume_code
                rtra.start_date = item['StartDate']
                rtra.end_date = item['EndDate']
                rtra.train_institution = item['TrainingInstitution']
                rtra.train_location = item['TrainingLocation']
                rtra.train_course = item['TrainingCourse'].replace('\r\n', '<br />')
                rtra.train_certificate = item['Certificate']
                rtra.train_desc = item['DescriptionInDetails'].replace('\r\n', '<br />')
                rtra.is_valid = 'T'
                session.add(rtra)
        #
        if js['ProjectInfo']:
            for item in js['ProjectInfo']:
                rpro = ResumeProject()
                rpro.resume_code = rm.resume_code
                rpro.start_date = item['StartDate']
                rpro.end_date = item['EndDate']
                rpro.project_name = item['ProjectName']
                rpro.work_title = item['Title']
                rpro.proj_desc = item['ProjectDescription'].replace('\r\n', '<br />')
                rpro.work_responsibility = item['Responsibilities'].replace('\r\n', '<br />')
                rpro.is_valid = 'T'
                session.add(rpro)
        #
        if js['LanguagesSkills']:
            for item in js['LanguagesSkills']:
                rlan = ResumeLang()
                rlan.resume_code = rm.resume_code
                rlan.lang_name = item['Languages']
                rlan.listen_speak = item['ListeningSpeakingSkills']
                rlan.write_read = item['ReadingWritingSkills']
                rlan.lang_score = item['Score']
                rlan.lang_skill = item['Skills']
                rlan.is_valid = 'T'
                session.add(rlan)
        #
        if js['ITSkills']:
            for item in js['ITSkills']:
                rit = ResumeIT()
                rit.resume_code = rm.resume_code
                rit.skill_name = item['SkillType']
                rit.use_time = item['TimeOfUse']
                rit.competency_level = item['CompetencyLevel']
                rit.is_valid = 'T'
                session.add(rit)
        #
        if js['GradeOfEnglish']:
            item = js['GradeOfEnglish']
            if item['NameOfCertificate']:
                reng = ResumeEnglish()
                reng.resume_code = rm.resume_code
                reng.certificate_name = item['NameOfCertificate']
                reng.certificate_score = item['Score']
                reng.rec_date = item['ReceivingDate']
                reng.is_valid = 'T'
                session.add(reng)
        session.commit()
        resume_code = rm.resume_code
        return (True, resume_code, True)
    except BaseException as e:
        session.rollback()
        logger.error(u'简历解析失败,原因:{}'.format(e))
        return (False, u'简历解析失败!', False)
    finally:
        session.close()
Exemple #9
0
 def _getSiteById(siteid):
     if isinstance(siteid, basestring):
         siteid = str2int(siteid)
     if SiteConfig._SITE.has_key(siteid):
         return SiteConfig._SITE[siteid]