Exemple #1
0
def update_to_basic(count, info, cursor, connect, gs_basic_id, uuid):
	name, code = info[1], info[2]
	legal_person, status, start_date = info[3], info[4], info[5]
	position = info[6]
	provin = config.province
	legal_person, investor, runner, responser = judge_position(legal_person,position)
	
	if count == 0:
		m = hashlib.md5()
		m.update(code)
		id = m.hexdigest()
		updated = deal_html_code.get_before_date()
		cursor.execute(insert_string, ((id, provin, name, code, code, legal_person,responser, investor, runner,start_date, status, updated)))
		gs_basic_id = connect.insert_id()
		connect.commit()
		return gs_basic_id
	elif count == 1:
		if code.startswith("9"):
			cursor.execute(update_ccode, (gs_basic_id, code, name, legal_person, responser, investor, runner, status, start_date, uuid,gs_basic_id))
			connect.commit()
		else:
			cursor.execute(update_string, (
				gs_basic_id, name, legal_person, responser, investor, runner, status, start_date, uuid, gs_basic_id))
			connect.commit()
		return 0
Exemple #2
0
 def update_to_db(self, info, gs_basic_id):
     name, ccode, status, types = info["name"], info["code"], info[
         "status"], info["types"]
     legal_person, runner, investor, responser = info["legal_person"], info[
         "runner"], info["investor"], info["runner"]
     reg_date, appr_date, reg_amount, start_date = info["reg_date"], info[
         "appr_date"], info["reg_amount"], info["start_date"]
     end_date, reg_zone, reg_address, scope = info["end_date"], info[
         "reg_zone"], info["reg_address"], info["scope"]
     jj_type = info["jj_type"]
     HOST, USER, PASSWD, DB, PORT = config.HOST, config.USER, config.PASSWD, config.DB, config.PORT
     connect, cursor = Connect_to_DB().ConnectDB(HOST, USER, PASSWD, DB,
                                                 PORT)
     flag = 0
     try:
         if ccode != '':
             # 这里时间更新为一个月前,是因为,是过更新为当天,普通用户就无法使用更新功能了
             updated_time = deal_html_code.get_before_date()
             row_count = cursor.execute(
                 update_string,
                 (gs_basic_id, name, ccode, status, types, jj_type,
                  legal_person, responser, investor, runner, reg_date,
                  appr_date, reg_amount, start_date, end_date, reg_zone,
                  reg_address, scope, updated_time, gs_basic_id))
             logging.info('update basic :%s' % row_count)
             connect.commit()
         else:
             updated_time = deal_html_code.get_before_date()
             row_count = cursor.execute(
                 update_string1,
                 (gs_basic_id, name, status, types, jj_type, legal_person,
                  responser, investor, runner, reg_date, appr_date,
                  reg_amount, start_date, end_date, reg_zone, reg_address,
                  scope, updated_time, gs_basic_id))
             logging.info('update basic :%s' % row_count)
             connect.commit()
     except Exception, e:
         print "basic error:%s" % e
         logging.error("basic error:%s" % e)
         flag = 100000006
Exemple #3
0
def insert_to_basic(information, cursor, connect, province):

    company = information[0][1]
    status = information[0][2]
    code = information[0][3]
    leader = information[0][4]
    dates = information[0][5]
    legal_person, investor, runner, responser = judge_position(leader)
    m = hashlib.md5()
    m.update(code)
    id = m.hexdigest()
    uuid = 'S'
    #将更新时间设置为当前时间减去30天,便于用户更新
    updated = deal_html_code.get_before_date()
    cursor.execute(insert_string,
                   ((uuid, id, province, company, code, code, legal_person,
                     investor, runner, responser, dates, status, updated)))
    gs_basic_id = connect.insert_id()
    connect.commit()
    return gs_basic_id
Exemple #4
0
    def update_to_basic(self, count, info, cursor, connect, gs_basic_id, uuid):
        name, code = info["company"], info["code"]
        legal_person, status, start_date = info["legal_person"], info[
            "status"], info["reg_date"]
        provin = config.province
        legal_person, investor, runner, responser = info["legal_person"], info[
            "investor"], info["runner"], info["responser"]

        if count == 0:
            # 利用相应的包对code进行MD5加密
            m = hashlib.md5()
            m.update(code)
            id = m.hexdigest()
            # 将时间更新为一个月以前的时间,方便用户进行点击更新
            updated = deal_html_code.get_before_date()
            cursor.execute(
                insert_string,
                ((id, provin, name, code, code, legal_person, investor, runner,
                  responser, start_date, status, updated)))
            gs_basic_id = connect.insert_id()
            connect.commit()
            return gs_basic_id
        elif count == 1:
            # 如果code是以9开头的则更新ccode
            if code.startswith("9"):
                cursor.execute(
                    update_ccode,
                    (gs_basic_id, code, name, legal_person, responser,
                     investor, runner, status, start_date, uuid, gs_basic_id))
                connect.commit()
            else:
                # 如果不是则不更新ccode
                cursor.execute(
                    update_string,
                    (gs_basic_id, name, legal_person, responser, investor,
                     runner, status, start_date, uuid, gs_basic_id))
                connect.commit()
            return 0
Exemple #5
0
def update_to_basic(count, information, cursor, connect, gs_basic_id, uuid):
    province = 'BEJ'
    if '企业名称' in information.keys():
        name = information[u"企业名称"]
    elif '名称' in information.keys():
        name = information[u"名称"]
    if '统一社会信用代码' in information.keys():
        code = information["code"]
        ccode = information[u"统一社会信用代码"]
    elif '注册号' in information.keys():
        code = information[u"注册号"]
        ccode = ''
    elif '统一社会信用代码/注册号' in information.keys():
        code = information[u"统一社会信用代码/注册号"]
        pattern = re.compile('^91.*|92.*|93.*')
        ccode = re.findall(pattern, code)
        if len(ccode) == 0:
            ccode = ''
        elif len(ccode) == 1:
            ccode = ccode[0]
    if '登记状态' in information.keys():
        status = information[u"登记状态"]
    elif '企业状态' in information.keys():
        status = information[u"企业状态"]
    elif '经营状态' in information.keys():
        status = information[u'经营状态']
    if '类型' in information.keys():
        types = information[u'类型']
    elif "公司类型" in information.keys():
        types = information[u'公司类型']

    if '法定代表人' in information.keys():
        legal_person = information[u"法定代表人"]
        responser = None
        investor = None
        runner = None
    elif '经营者' in information.keys():
        runner = information[u"经营者"]
        legal_person = None
        responser = None
        investor = None
    elif '负责人' in information.keys():
        responser = information[u'负责人']
        runner = None
        legal_person = None
        investor = None
    elif '投资人' in information.keys():
        investor = information[u"投资人"]
        responser = None
        runner = None
        legal_person = None
    elif '投资人姓名' in information.keys():
        investor = information[u"投资人"]
        responser = None
        runner = None
        legal_person = None
    elif '执行事务合伙人' in information.keys():
        legal_person = information[u"执行事务合伙人"]
        list = re.split(u'、', legal_person)
        legal_person = list[0] + '等'
        investor = None
        runner = None
        responser = None
    elif u"法定代表人姓名" in information.keys():
        legal_person = information[u"法定代表人姓名"]
        responser = None
        investor = None
        runner = None

    if '成立日期' in information.keys():
        sign_date = information[u"成立日期"]
        sign_date = sign_date
        # print sign_date
    elif '注册日期' in information.keys():
        sign_date = information[u"注册日期"]
        sign_date = sign_date
    else:
        sign_date = None
    if '注册资本' in information.keys():
        reg_amount = information[u"注册资本"]
    elif '成员出资额' in information.keys():
        reg_amount = information[u"成员出资额"]
    else:
        reg_amount = None
    if '核准日期' in information.keys():
        appr_date = information[u"核准日期"]
    else:
        appr_date = None
    if '营业期限自' in information.keys():
        start_date = information[u"营业期限自"]
    elif '合伙期限自' in information.keys():
        start_date = information[u"合伙期限至"]
    else:
        start_date = None
    if '营业期限至' in information.keys():
        end_date = information[u"营业期限至"]
    elif '合伙期限至' in information.keys():
        end_date = information[u"合伙期限至"]
    else:
        end_date = None
    if end_date == '':
        end_date = None
    if '登记机关' in information.keys():
        reg_zone = information[u"登记机关"]
    elif '发照机关' in information.keys():
        reg_zone = information[u"发照机关"]
    if '住所' in information.keys():
        reg_address = information[u"住所"]
    elif '经营场所' in information.keys():
        reg_address = information[u"经营场所"]
    elif '主要经营场所' in information.keys():
        reg_address = information[u"主要经营场所"]
    elif '营业场所' in information.keys():
        reg_address = information[u"营业场所"]
    elif '企业住所' in information.keys():
        reg_address = information[u"企业住所"]
    if '业务范围' in information.keys():
        scope = information[u"业务范围"]
    elif '经营范围' in information.keys():
        scope = information[u"经营范围"]
    if code == '' and ccode != '':
        code = ccode
    if count == 0:
        if code == '' and ccode != '':
            m = hashlib.md5()
            m.update(ccode)
            id = m.hexdigest()
        elif ccode == '' and code != '':
            m = hashlib.md5()
            m.update(code)
            id = m.hexdigest()
        elif code != '' and ccode != '':
            m = hashlib.md5()
            m.update(code)
            id = m.hexdigest()
        updated_time = deal_html_code.get_before_date()
        row_count = cursor.execute(
            insert_string,
            (id, province, name, code, ccode, status, types, legal_person,
             responser, investor, runner, sign_date, appr_date, reg_amount,
             start_date, end_date, reg_zone, reg_address, scope, uuid,
             updated_time))
        basic_id = connect.insert_id()
        connect.commit()

        logging.info('insert basic :%s' % row_count)
    elif count == 1:
        basic_id = 0
        row_count = cursor.execute(
            update_string,
            (gs_basic_id, name, ccode, status, types, legal_person, responser,
             investor, runner, sign_date, appr_date, reg_amount, start_date,
             end_date, reg_zone, reg_address, scope, uuid, gs_basic_id))
        connect.commit()
        logging.info('update basic :%s' % row_count)
    return basic_id