Esempio n. 1
0
 def update_to_db(self, info, gs_basic_id):
     remark = 0
     try:
         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)
         name, ccode, status, types = info[0], info[1], info[2], info[3]
         legal_person, reg_date, appr_date, reg_amount = info[4], info[
             5], info[6], info[7]
         start_date, end_date, reg_zone, reg_address = info[8], info[
             9], info[10], info[11]
         scope, del_date = info[12], info[13]
         updated_time = time.strftime("%Y-%m-%d %H:%M:%S",
                                      time.localtime(time.time()))
         row_count = cursor.execute(
             update_string, (gs_basic_id, name, ccode, status, types,
                             legal_person, reg_date, appr_date, reg_amount,
                             start_date, end_date, reg_zone, reg_address,
                             scope, del_date, updated_time, gs_basic_id))
         connect.commit()
     except Exception, e:
         cursor.close()
         connect.close()
         logging.error("basic error:%s" % e)
         remark = 100000006
Esempio n. 2
0
 def update_to_db(self, information, gs_basic_id):
     insert_flag, update_flag = 0, 0
     remark = 0
     total = len(information)
     try:
         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)
         for key in information.keys():
             person_name = str(information[key][0])
             position = str(information[key][1])
             rows = cursor.execute(select_string,
                                   (gs_basic_id, person_name, position))
             if int(rows) == 1:
                 gs_clear_id = cursor.fetchall()[0][0]
                 updated_time = time.strftime("%Y-%m-%d %H:%M:%S",
                                              time.localtime(time.time()))
                 count = cursor.execute(
                     update_string,
                     (gs_clear_id, updated_time, gs_clear_id))
                 update_flag += count
                 connect.commit()
             elif rows == 0:
                 updated_time = time.strftime("%Y-%m-%d %H:%M:%S",
                                              time.localtime(time.time()))
                 count = cursor.execute(
                     insert_string,
                     (gs_basic_id, person_name, position, updated_time))
                 insert_flag += count
                 connect.commit()
     except Exception, e:
         cursor.close()
         connect.close()
         remark = 100000006
         logging.error("clear error: %s" % e)
Esempio n. 3
0
    def update_to_db(self, information, gs_basic_id):
        insert_flag, update_flag = 0, 0
        flag = 0
        total = len(information)
        try:
            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)
            for key in information.keys():
                types, result = information[key][0], information[key][1]
                check_date, gov_dept = information[key][2], information[key][3]

                count = cursor.execute(select_check,
                                       (gs_basic_id, check_date, types))
                if count == 0:
                    updated_time = time.strftime("%Y-%m-%d %H:%M:%S",
                                                 time.localtime(time.time()))

                    rows_count = cursor.execute(
                        check_string, (gs_basic_id, types, result, check_date,
                                       gov_dept, updated_time))
                    insert_flag += rows_count
                    connect.commit()
        except Exception, e:
            cursor.close()
            connect.close()
            flag = 100000006
            logging.error("check error: %s" % e)
Esempio n. 4
0
	def update_to_db(self, info, gs_basic_id):
		insert_flag, update_flag = 0, 0
		remark = 0
		total = len(info)
		source = 0
		try:
			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)
			for key in info.keys():
				name, code, filename, start_date = info[key][0], info[key][1], info[key][2], info[key][3]
				end_date, content, gov_dept = info[key][4], info[key][5], info[key][6]
				status = info[key][7]
				count = cursor.execute(select_string, (gs_basic_id, filename, code, start_date, end_date))
				m = hashlib.md5()
				m.update(code)
				id = m.hexdigest()
				
				if count == 0:
					updated_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
					rows_count = cursor.execute(permit_string, (
						gs_basic_id, id, name, code, filename, start_date, end_date, content, gov_dept, status, source,
						updated_time))
					insert_flag += rows_count
					connect.commit()
		
		except Exception, e:
			cursor.close()
			connect.close()
			remark = 100000006
			logging.error("permit error: %s" % e)
Esempio n. 5
0
    def update_to_db(self, info, gs_basic_id):
        insert_flag, update_flag = 0, 0
        remark = 0
        total = len(info)
        try:
            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)
            for key in info.keys():
                equityNo, pledgor, pledBLicNo = info[key][0], info[key][
                    1], info[key][2]
                impAm, impOrg, impOrgBLicNo = info[key][3], info[key][4], info[
                    key][5]
                equPleDate, publicDate, type = info[key][6], info[key][
                    7], info[key][8]

                count = cursor.execute(select_stock, (gs_basic_id, equityNo))

                if count == 0:
                    updated_time = time.strftime("%Y-%m-%d %H:%M:%S",
                                                 time.localtime(time.time()))
                    rows_count = cursor.execute(
                        stock_string,
                        (gs_basic_id, equityNo, pledgor, pledBLicNo, impAm,
                         impOrg, impOrgBLicNo, equPleDate, publicDate, type,
                         updated_time))
                    insert_flag += rows_count
                    connect.commit()
                elif int(count) == 1:
                    # print equityNo
                    gs_stock_id = cursor.fetchall()[0][0]
                    updated_time = time.strftime("%Y-%m-%d %H:%M:%S",
                                                 time.localtime(time.time()))

                    rows_count = cursor.execute(
                        update_stock,
                        (gs_basic_id, pledgor, pledBLicNo, impAm, impOrg,
                         impOrgBLicNo, equPleDate, publicDate, type,
                         updated_time, gs_stock_id))
                    # print rows_count
                    update_flag += rows_count
                    connect.commit()
        except Exception, e:
            cursor.close()
            connect.close()
            remark = 100000001
            # print "stock error:", e
            logging.error("stock error: %s" % e)
Esempio n. 6
0
def get_info(code, ccode, gs_basic_id):
    # 正则匹配判断code 或者ccode 根据哪个进行查询
    pattern = re.compile(r'^9.*')
    result1 = re.findall(pattern, code)
    result2 = re.findall(pattern, ccode)
    if len(result1) == 0 and len(result2) == 0:
        string = code
    elif len(result1) == 1:
        string = code
    elif len(result2) == 1:
        string = ccode
    else:
        pass
    idname, flag, cookies = get_keyid(string)
    flag, items = get_search_info(idname, cookies)
    if flag == 1:
        org, id, seq_id, name = get_keyword(items)
    elif flag == 100000003:
        idname, flag, cookies = get_keyid(string)
        flag, items = get_search_info(idname, cookies)
        if flag == 1:
            org, id, seq_id, name = get_keyword(items)
        elif flag == 100000003:
            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)
            select_string = select_name % gs_basic_id
            cursor.execute(select_string)
            name = cursor.fetchall()[0][0]
            name = deal_html_code.remove_space(name)
            cursor.close()
            connect.close()
            idname, flag, cookies = get_keyid(name)
            flag, items = get_search_info(idname, cookies)
            org, id, seq_id, se_name = get_keyword(items)
            # 用来判断数据库中的公司名字跟搜索到的名字是否一致
            if name != se_name:
                flag = 100000003
                org, id, seq_id = 0, 0, 0
    print_info(org, id, seq_id, flag)
Esempio n. 7
0
    def update_to_db(self, information, gs_basic_id):
        insert_flag, update_flag = 0, 0
        remark = 0
        total = len(information)
        try:
            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)
            string = update_string % gs_basic_id
            cursor.execute(string)
            connect.commit()
            cursor.close()
            connect.close()
            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)
            for key in information.keys():
                name = str(information[key][0])
                position = information[key][1]
                rows = cursor.execute(select_string, (gs_basic_id, name))
                # print name,position

                if int(rows) >= 1:
                    # gs_person_id = cursor.fetchall()[0][0]
                    sign = 0
                    for gs_person_id, pos in cursor.fetchall():
                        if pos == position:
                            sign = 1
                            updated_time = time.strftime(
                                "%Y-%m-%d %H:%M:%S",
                                time.localtime(time.time()))
                            count = cursor.execute(
                                update_quit,
                                (updated_time, gs_basic_id, gs_person_id))
                            connect.commit()
                        # update_flag += count
                        elif pos == None and position != None:
                            updated_time = time.strftime(
                                "%Y-%m-%d %H:%M:%S",
                                time.localtime(time.time()))
                            count = cursor.execute(
                                person_string, (gs_person_id, position,
                                                updated_time, gs_person_id))
                            update_flag += count
                            connect.commit()
                            sign = 0
                    if sign == 0:
                        source = 1
                        updated_time = time.strftime(
                            "%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
                        count = cursor.execute(insert_string,
                                               (gs_basic_id, name, position,
                                                source, updated_time))
                        insert_flag += count
                        connect.commit()
                    else:
                        pass
                elif rows == 0:
                    source = 1
                    updated_time = time.strftime("%Y-%m-%d %H:%M:%S",
                                                 time.localtime(time.time()))
                    count = cursor.execute(
                        insert_string,
                        (gs_basic_id, name, position, source, updated_time))
                    insert_flag += count
                    connect.commit()
        except Exception, e:
            remark = 100000006
            logging.error("person error: %s" % e)
Esempio n. 8
0
    def update_to_db(self, info, gs_basic_id):
        cate = 0
        insert_flag, update_flag = 0, 0
        remark = 0
        total = len(info)
        try:
            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)
            string = update_share % gs_basic_id
            cursor.execute(string)
            connect.commit()
            cursor.close()
            connect.close()
            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)
            for key in info.keys():
                name, license_code, license_type = info[key][0], info[key][
                    1], info[key][2]
                types, ra_date, ra_ways, true_amount = info[key][3], info[key][
                    4], info[key][5], info[key][6]
                reg_amount, ta_ways, ta_date = info[key][7], info[key][
                    8], info[key][9]

                country, address = info[key][10], info[key][11]
                iv_basic_id = 0
                if name != '' or name != None:
                    pattern = re.compile('.*公司.*|.*中心.*|.*集团.*|.*企业.*')
                    result = re.findall(pattern, name)
                    if len(result) == 0:
                        iv_basic_id = 0
                    else:
                        select_unique = select_name % name
                        number = cursor.execute(select_unique)
                        if number == 0:
                            iv_basic_id = 0
                        elif int(number) == 1:
                            iv_basic_id = cursor.fechall[0][0]
                else:
                    iv_basic_id = 0

                count = cursor.execute(select_string,
                                       (gs_basic_id, name, types, cate))

                if count == 0:
                    updated_time = time.strftime("%Y-%m-%d %H:%M:%S",
                                                 time.localtime(time.time()))
                    rows_count = cursor.execute(
                        share_string,
                        (gs_basic_id, name, cate, types, license_type,
                         license_code, ra_date, ra_ways, true_amount,
                         reg_amount, ta_ways, ta_date, country, address,
                         iv_basic_id, updated_time))
                    insert_flag += rows_count
                    connect.commit()
                elif int(count) == 1:
                    updated_time = time.strftime("%Y-%m-%d %H:%M:%S",
                                                 time.localtime(time.time()))
                    gs_shareholder_id = cursor.fetchall()[0][0]
                    cursor.execute(
                        update_quit,
                        (updated_time, gs_shareholder_id, gs_basic_id))
                    connect.commit()
        except Exception, e:
            remark = 100000006
            logging.error("shareholder error:%s" % e)