def __another_info__(brand_and_agency: dict, company: Company): # 公司融资轮次 company.financing_round = brand_and_agency.get("round", "未知") # 公司竟品信息 company.competitions = brand_and_agency.get("jingpinName", []) # 公司logo company.logo = brand_and_agency.get("logo") # 公司简介 company.company_desc = brand_and_agency.get("intro")
async def do_copy_company(race_cid, new_race_cid, user_cid): """ 复制单位 :param race_cid: :param new_race_cid: :param user_cid: :return: """ if not race_cid or not new_race_cid or not user_cid: raise Exception('miss parameters') old_company_cursor = Company.find( { 'race_cid': race_cid }, read_preference=ReadPreference.PRIMARY).batch_size(32) new_company_list = [] while await old_company_cursor.fetch_next: company = old_company_cursor.next_object() new_company = copy.deepcopy(company) new_company.cid = get_new_cid() new_company.race_cid = new_race_cid new_company.updated_id = user_cid new_company_list.append(new_company) await Company.insert_many(new_company_list)
def get_race_mapping_info(info: MemberStatisticInfo): """ 获取行政区域信息、公司单位、当前关卡 :param info: :return: """ race_cid = info.race_cid member_cid = info.member_cid city_name_list, district_name_list = get_address(race_cid) check_point_cids, _checkpoint_map = get_checkpoint_cid_list(race_cid) race_mapping = RaceMapping.sync_find_one({'race_cid': race_cid, 'member_cid': member_cid, 'auth_address.province': {'$ne': None}, 'auth_address.city': {"$in": city_name_list}, 'auth_address.district': {"$in": district_name_list}}) if race_mapping: info.province = race_mapping.auth_address.get('province') info.city = race_mapping.auth_address.get('city') info.district = race_mapping.auth_address.get('district') info.town = race_mapping.auth_address.get('town') info.mobile = race_mapping.mobile info.check_point_cid = race_mapping.race_check_point_cid if race_mapping.race_check_point_cid: info.check_point_index = _checkpoint_map[race_mapping.race_check_point_cid] else: info.check_point_index = 1 # 单位信息 if race_mapping.company_cid: company = Company.sync_get_by_cid(race_mapping.company_cid) info.company_cid = company.cid info.company_name = company.title return True else: return False
def __copy_extras__(src: dict, company: Company): company.homepage = src.get('websiteList', '-') company.register_code = src.get('regNumber', '-') company.organization_code = src.get('orgNumber', '-') company.english_name = src.get('property3', '-') company.authorization = src.get('regInstitute', '-') company.actual_capital = src.get('actualCapital', '缺省') company.industry = src.get('industry', '-') company.used_name = src.get('historyNames', '-')
def start(): keywords = globals().get('keywords') for keyword in keywords: raw_companies = qcc_client.search(keyword) log.info('正在处理爬取[%s]' % keyword) # company对象 company = Company() for raw_company in raw_companies: company.keyword = keyword # 组装公司信息 manager.assembly(company, raw_company) raw_company_detail = qcc_client.search_detail( raw_company.get('KeyNo')) # 补充公司详细信息 manager.assembly_detail(company, raw_company_detail) log.info(company) log.info('completed')
def assembly_detail(cls, company: Company, raw_company_detail: dict): company.homepage = raw_company_detail.get('WebSite', '-')[0:30] company.register_code = raw_company_detail.get('No', '-') company.organization_code = raw_company_detail.get('OrgNo', '-') company.english_name = raw_company_detail.get('EnglishName', '-') company.authorization = raw_company_detail.get('BelongOrg', '-') company.actual_capital = raw_company_detail.get('RealCapi', '缺省') company.industry = raw_company_detail.get('Industry', dict()).get('Industry', '-') company.used_name = raw_company_detail.get('OriginalName', '-')
def create_or_update(data): q = session.query(Company).filter_by(name=data['name']) company = q.first() if not company: company = Company(**data) session.add(company) session.commit() else: q.update(data)
def __post_process__(self): """""" if not self.src: return todos = self.src for t in todos: detail = Request(TycEntApi.format(eid=t.get("id")), proxy=True, headers=REQUEST_HEADERS).data if not detail: continue detail = json.loads(detail) if detail.get("state") == 'ok': td = detail.get("data", {}) company = Company() company.keyword = self.keyword # 复制主体信息 TycClient.TycEntHelper.__copy_props__(t, company) # 复制公司组织代码、注册资本 TycClient.TycEntHelper.__copy_extras__(td, company) self.companies.append(company)
async def post(self): r_dict = {'code': 0} race_cid = self.get_argument('race_cid', '') unit_id = None try: title = self.get_argument('title', None) status = self.get_argument('status', None) # 状态 code = self.get_argument('code', None) if title and code: unit_count = await Company.count( dict(record_flag=1, code=code, race_cid=race_cid)) if unit_count > 0: r_dict['code'] = -3 else: if status == 'on': status = STATUS_UNIT_MANAGER_ACTIVE else: status = STATUS_UNIT_MANAGER_INACTIVE unit = Company(title=title, code=code) unit.race_cid = race_cid unit.status = status unit.created_dt = datetime.datetime.now() unit.updated_id = self.current_user.oid unit_id = await unit.save() r_dict['code'] = 1 else: if not title: r_dict['code'] = -1 if not code: r_dict['code'] = -2 except Exception: # 如果因为网络问题等其他问题导致前端展示添加不正确但是数据已经保存到数据库了,应该删除掉 if unit_id: await Company.delete_by_ids([unit_id]) logger.error(traceback.format_exc()) return r_dict
def __copy_props__(src: dict, target: Company): target.id = src.get('id', '-') target.name = src.get('name', '-').replace('<em>', '').replace('</em>', '') target.representative = src.get('legalPersonName', '-') target.address = src.get('regLocation', '-') target.region = src.get('base', '-') target.city = src.get('city', '-') target.district = src.get('district', '-') target.biz_status = src.get('regStatus', '-') target.credit_code = src.get('creditCode', '-') target.email = src.get('emails', ['-']).split(';')[0].replace('\t', '') target.phone = src.get('phoneNum', '-') target.biz_scope = src.get('businessScope', '-') target.company_type = src.get('companyOrgType', '-').replace('\t', '') target.taxpayer_code = src.get('creditCode', '-') target.registered_capital = src.get('regCapital', '-') target.lat_long = str({ 'lat': src.get('latitude', '-'), 'long': src.get('longitude', '-') }) target.setup_time = src.get('estiblishTime', '-')[0:10]
def deal_member_without_history(race_cid, daily_code): """ 处理报名活动但未答题的会员 :param race_cid: :param daily_code: :return: """ city_name_list, district_name_list = get_address(race_cid) checkpoint_cid, _checkpoint_map = get_checkpoint_cid_list(race_cid) start_date = str2datetime(daily_code, '%Y%m%d').replace(hour=0, minute=0, second=0, microsecond=0) end_date = start_date + datetime.timedelta(days=1) member_cid_with_history = MemberCheckPointHistory.sync_distinct( "member_cid", { 'check_point_cid': { '$in': checkpoint_cid }, 'created_dt': { '$gte': start_date, '$lt': end_date } }) race_member_match = MatchStage({ "race_cid": race_cid, 'member_cid': { '$nin': member_cid_with_history }, 'auth_address.city': { "$in": city_name_list }, 'auth_address.district': { "$in": district_name_list }, 'created_dt': { '$gte': start_date, '$lt': end_date } }) member_group = GroupStage({'member_cid': '$member_cid'}, auth_address={'$first': '$auth_address'}, company_cid={'$first': '$company_cid'}, mobile={'$first': '$mobile'}, created_dt={'$first': '$created_dt'}) member_project = ProjectStage( **{ 'cid': '$cid', 'member_cid': '$_id.member_cid', 'auth_address': '$auth_address', 'mobile': '$mobile', 'created_dt': '$created_dt', 'company_cid': '$company_cid' }) member_without_history = RaceMapping.sync_aggregate( [race_member_match, member_group, member_project]).batch_size(4) member_amount_map = get_red_packet_info(race_cid, start_date, end_date) red_member_cid_list = member_amount_map.keys() member_no_history_list = [] count = 0 while True: try: stat = member_without_history.next() count += 1 if stat.member_cid in red_member_cid_list: continue # 根据member_cid查对应的member信息 temp_member = Member.sync_get_by_cid(stat.member_cid) if not temp_member: print("no history未找到对应member_cid:%s" % stat.member_cid) continue info_special = MemberStatisticInfo() info_special.is_special_user = 1 info_special.race_cid = race_cid info_special.member_cid = stat.member_cid info_special.daily_code = format(stat.created_dt, '%Y%m%d') info_special.nick_name = temp_member.nick_name info_special.open_id = temp_member.open_id if stat.mobile: info_special.mobile = stat.mobile else: info_special.mobile = temp_member.mobile info_special.first_time_login = temp_member.created_dt info_special.enter_times = 1 info_special.answer_times = 0 info_special.true_answer_times = 0 info_special.is_final_passed = 0 info_special.is_new_user = 1 info_special.grant_red_packet_amount = 0.0 info_special.grant_red_packet_count = 0 info_special.draw_red_packet_count = 0 info_special.draw_red_packet_amount = 0.0 info_special.province = stat.auth_address.get('province') info_special.city = stat.auth_address.get('city') info_special.district = stat.auth_address.get('district') info_special.town = stat.auth_address.get('town') info_special.check_point_cid = stat.race_check_point_cid if stat.race_check_point_cid: info_special.check_point_index = _checkpoint_map[ stat.race_check_point_cid] else: info_special.check_point_index = 1 if stat.company_cid: company = Company.sync_get_by_cid(stat.company_cid) info_special.company_cid = company.cid info_special.company_name = company.title member_no_history_list.append(info_special) # logger.info("Success without history: member_cid:%s is_final_Pass:%s" % (info_special.member_cid,info_special.is_final_passed)) if len(member_no_history_list) % 500 == 0: MemberStatisticInfo.sync_insert_many(member_no_history_list) member_no_history_list = [] except StopIteration: break except CursorNotFound: member_without_history = RaceMapping.sync_aggregate( [race_member_match, member_group, member_project]).skip(count).batch_size(4) except Exception as e: logger.info( "Fail: without history daily_code:%s,member_cid:%s,race_cid: %s" % (info_special.daily_code, info_special.member_cid, race_cid)) if len(member_no_history_list) > 0: MemberStatisticInfo.sync_insert_many(member_no_history_list)
def export_race_member_base_information(prov_match, title, district_title_list): """ 导出参与人数,通关人数,正确率top100的个人信息(手机号码) :param workbook: :return: """ now = format(datetime.datetime.now(), "%Y-%m-%d%H:%M") excel_title = "六安市活动统计{time}.xlsx".format(time=now) workbook = xlsxwriter.Workbook(excel_title) sheet = workbook.add_worksheet("{title}会员信息统计".format(title=title)) data_center_format = workbook.add_format({ 'valign': 'vcenter', 'align': 'center', 'font_name': 'Microsoft YaHei', 'border': 1 }) # sheet = generate_excel_head(sheet, data_center_format) sheet.merge_range(0, 0, 0, 1, '昵称', data_center_format) sheet.write_string(0, 2, '城市', data_center_format) sheet.write_string(0, 3, '地区', data_center_format) sheet.merge_range(0, 4, 0, 5, '手机号码', data_center_format) sheet.write_string(0, 6, "正确率", data_center_format) lookup_stage = LookupStage(Member, 'member_cid', 'cid', 'member_list') add_fields_stage = AddFieldsStage( t_accuracy={ '$cond': { 'if': { '$eq': ['$total_count', 0] }, 'then': 0, 'else': { '$divide': ['$total_correct', '$total_count'] } } }) prov_race_mapping_cursor = RaceMapping.sync_aggregate([ MatchStage(prov_match), lookup_stage, add_fields_stage, MatchStage({'member_list': { "$ne": [] }}) ]) num = 1 # total_member_list = [] sheet.write_string(0, 7, '单位/乡镇') while True: try: race_mapping = prov_race_mapping_cursor.next() if race_mapping: if race_mapping.member_list and race_mapping.auth_address.get( 'city') == "六安市" and race_mapping.auth_address.get( 'district') in district_title_list: member = race_mapping.member_list[0] # if member.cid not in total_member_list: # total_member_list.append(member.cid) # if race_mapping.auth_address.get('district') in district_title_list: sheet.merge_range(num, 0, num, 1, member.nick_name, data_center_format) sheet.write_string(num, 2, race_mapping.auth_address.get('city'), data_center_format) sheet.write_string( num, 3, race_mapping.auth_address.get('district'), data_center_format) sheet.merge_range(num, 4, num, 5, str(race_mapping.mobile), data_center_format) sheet.write_number(num, 6, round(race_mapping.t_accuracy, 2), data_center_format) if race_mapping.company_cid: company = Company.sync_find_one( {'cid': race_mapping.company_cid}) if company: sheet.write_string(num, 7, company.title) elif race_mapping.auth_address.get('town'): sheet.write_string( num, 7, race_mapping.auth_address.get('town')) num += 1 else: continue except StopIteration: break # 六安市的最后一关关卡 city_last_checkpoint_cid, _, _, _ = get_export_param( "CA755167DEA9AA89650D11C10FAA5413") print(city_last_checkpoint_cid) pass_sheet = workbook.add_worksheet("{title}通关会员信息统计".format(title=title)) # pass_sheet = generate_excel_head(pass_sheet, data_center_format) pass_sheet.merge_range(0, 0, 0, 1, '昵称', data_center_format) pass_sheet.write_string(0, 2, '城市', data_center_format) pass_sheet.write_string(0, 3, '地区', data_center_format) pass_sheet.merge_range(0, 4, 0, 5, '手机号码', data_center_format) pass_sheet.write_string(0, 6, "正确率", data_center_format) pass_sheet.write_string(0, 7, "单位或乡镇", data_center_format) check_point_lookup = LookupStage( MemberCheckPointHistory, let={'primary_cid': '$member_cid'}, as_list_name='history_list', pipeline=[ { '$match': { '$expr': { '$and': [{ '$eq': ['$member_cid', '$$primary_cid'] }, { '$eq': ['$status', 1] }, { '$eq': ['$check_point_cid', city_last_checkpoint_cid] }] } } }, ]) add_fields_stage = AddFieldsStage( t_accuracy={ '$cond': { 'if': { '$eq': ['$total_count', 0] }, 'then': 0, 'else': { '$divide': ['$total_correct', '$total_count'] } } }) match_checkpoint_stage = MatchStage({'history_list': {'$ne': []}}) pass_race_mapping_cursor = RaceMapping.sync_aggregate([ MatchStage(prov_match), check_point_lookup, match_checkpoint_stage, lookup_stage, add_fields_stage ]) position = 1 _total_pass_list = [] while True: try: pass_race_mapping = pass_race_mapping_cursor.next() if pass_race_mapping: if pass_race_mapping.member_list: member = pass_race_mapping.member_list[0] if member.cid not in _total_pass_list: _total_pass_list.append(member.cid) else: continue if pass_race_mapping.auth_address.get( 'district' ) in district_title_list and pass_race_mapping.auth_address.get( 'city' ) == "六安市" and pass_race_mapping.auth_address.get( 'district') in district_title_list: pass_sheet.merge_range(position, 0, position, 1, member.nick_name, data_center_format) pass_sheet.write_string( position, 2, pass_race_mapping.auth_address.get('city'), data_center_format) pass_sheet.write_string( position, 3, pass_race_mapping.auth_address.get('district'), data_center_format) pass_sheet.merge_range(position, 4, position, 5, str(pass_race_mapping.mobile), data_center_format) pass_sheet.write_number( position, 6, round(pass_race_mapping.t_accuracy, 2), data_center_format) if pass_race_mapping.company_cid: company = Company.sync_find_one( {'cid': pass_race_mapping.company_cid}) if company: pass_sheet.write_string( position, 7, company.title) elif pass_race_mapping.auth_address.get('town'): sheet.write_string( num, 7, pass_race_mapping.auth_address.get('town')) position += 1 else: continue except StopIteration: break print("information calc end ------------------") workbook.close()
def __post_process__(self): if not self.src: return company_list = self.src for company in company_list: company_entity = Company() # 公司检索的关键字 company_entity.keyword = self.keyword # 公司主体基本信息 self.EntityHelper.__basic_info__(company, company_entity) def is_equal(b_and_a): return company.get('id') == b_and_a.get('graphId') try: # 公司主体融资阶段、竟品信息 brand_and_agency = filter(is_equal, self.brand_and_agencies).__next__() self.EntityHelper.__another_info__(brand_and_agency, company_entity) except: logging.warning('竟品信息获取失败!') pass """ 公司详情 """ detail_resp = Request(TycPortraitApi.format(eid=company.get("id")), proxy=True, headers=REQUEST_HEADERS).data if detail_resp: company_portrait = json.loads(detail_resp) # 公司详情补充信息 if company_portrait.get("state") == 'ok': self.EntityHelper.__additional__( company_portrait.get("data", {}), company_entity) shareholder_request_body = { "graphId": company.get("id"), "hkVersion": 1, "typeList": { "shareHolder": { "pageNum": 1, "pageSize": 20, "required": "true" } } } """ 股东信息 """ shareholder_resp = Request(TycShareholderPostApi, method='post', json=shareholder_request_body, proxy=True, headers=REQUEST_HEADERS).data if shareholder_resp: company_shareholder = json.loads(shareholder_resp) # 公司详情补充信息 if company_shareholder.get("state") == 'ok': self.EntityHelper.__shareholder__( company_shareholder.get("data", {}).get("shareHolder", {}), company_entity) manager_request_body = { "graphId": company.get("id"), "hkVersion": 1, "typeList": { "companyStaff": { "pageNum": 1, "pageSize": 20, "required": "true" } } } """ 高管信息 """ manager_resp = Request(TycEnterpriseManagerPostApi, method='post', json=manager_request_body, proxy=True, headers=REQUEST_HEADERS).data if manager_resp: company_manager = json.loads(manager_resp) # 公司详情补充信息 if company_manager.get("state") == 'ok': self.EntityHelper.__company_manager__( company_manager.get("data", {}).get("companyStaff", {}), company_entity) self.companies.append(company_entity)
def __additional__(src: dict, company: Company): # 公司英文名 company.english_name = src.get('property3') if not company.english_name: company.english_name = src.get('nameEn', '-') # 公司注册机构 company.register_institute = src.get('regInstitute', '-') # 公司网站地址集 company.websites = src.get('websiteList', '-') # 公司实缴资本 company.actual_capital = src.get('actualCapital', '缺省') # 公司曾用名 company.used_name = src.get('historyNames', '-') # 公司员工人数 company.staffs = src.get('socialStaffNum', None) if not company.staffs: company.staffs = src.get('staffNum', 1) # 公司纳税地址 company.tax_address = src.get('taxAddress', None) if not company.tax_address: company.tax_address = src.get('regLocation', '-') # 公司纳税银行 company.taxpayer_bank = src.get('taxBankName', '-') # 公司涉足领域标签 company.portraits = src.get('portray', []) if not company.logo: company.logo = src.get('logo') if not company.company_desc: company.company_desc = src.get('baseInfo', '-')
def __basic_info__(src: dict, target: Company): # 公司外部系统ID target.id = src.get('id', '-') # 公司名称 target.name = src.get('name', '-').replace('<em>', '').replace('</em>', '') # 公司简称 target.short_name = src.get('alias', '-') # 公司法人 target.representative = src.get('legalPersonName', '-') # 公司成立时间 target.found_time = src.get('estiblishTime', '-')[0:10] # 公司地址 target.company_address = src.get('regLocation', '-') # 公司注册地址 target.register_address = src.get('regLocation', '-') # 公司所在省份,例:浙江,北京,广东 target.province = src.get('base', '-') # 公司所在市 target.city = src.get('city', '-') # 公司所在区 target.district = src.get('district', '-') # 公司经营状态 target.biz_status = src.get('regStatus', '-') # 公司地址经纬度坐标 target.geoloc = str({ 'latitude': src.get('latitude', '-'), 'longitude': src.get('longitude', '-') }) # 公司邮箱列表 target.emails = src.get('emails', ['-']).split(';')[0].replace('\t', '') # 公司联系方式列表 target.phones = src.get('phoneList', []) # 公司联系方式 target.contact = src.get('phoneNum', '-') # 公司经营范围 target.biz_scope = src.get('businessScope', '-') # 公司类型 target.company_type = src.get('companyOrgType', '-').replace('\t', '') # 公司质量分数 target.score = src.get('orginalScore', 0) # 公司注册资本 target.register_capital = src.get('regCapital', '-') # 公司统一社会信用代码 target.credit_code = src.get('creditCode', '-') # 公司纳税号 target.taxpayer_code = src.get('taxCode') if not target.taxpayer_code: target.taxpayer_code = target.credit_code # 公司注册号 target.register_code = src.get('regNumber', '-') # 公司组织机构代码 target.organization_code = src.get('orgNumber', '-') # 公司标签列表 target.tags = src.get('labelListV2', []) # 公司行业分类 target.industry = src.get('categoryStr', '-')
async def __subject_import_excel(self, race_cid, excel_file_content): result_code = 1 # 所有单位的编号 unit_code_list = await Company.distinct('code', { 'race_cid': race_cid, 'record_flag': 1 }) book = xlrd.open_workbook(file_contents=excel_file_content) # 获得第一个表的信息 sheet = book.sheet_by_index(0) unit_list = [] row_list = [] title_list = [] for ind, col in enumerate(sheet.row_values(0)): if col: title_list.append(col) # 判断表头是否正确 if len(title_list) != 2: result_code = 2 return result_code # 拿到所有的行数据 for rownum in range(1, sheet.nrows): row_list.append([col for col in sheet.row_values(rownum)]) # 上传文件中有一些已经存在过的,需要删除,重新覆盖 delete_unit_oid_list = [] if row_list: for i, row_data in enumerate(row_list): code_repeat = False # 单位编码 unit_code = str(self.__get_replace_data(row_data[0], 2)) # 单位编码不能超过16位 if not unit_code or len(unit_code) > 16: continue else: reg = re.compile(r'^[a-zA-Z0-9]*$') if not bool(reg.match(unit_code)): continue if unit_code in unit_code_list: unit = await Company.find_one(dict(code=unit_code)) # 上传文件中有编码重复的行,只添加一个 if unit: delete_unit_oid_list.append(unit.oid) await unit.delete() else: code_repeat = True unit = Company() unit.race_cid = race_cid unit.code = unit_code unit.title = str(row_data[1])[:-2] if not isinstance( row_data[1], str) else row_data[1] unit.status = STATUS_UNIT_MANAGER_ACTIVE unit_code_list.append(unit_code) if not code_repeat: unit_list.append(unit) if len(unit_list) == 500: await Company.insert_many(unit_list) unit_list = [] if unit_list: await Company.insert_many(unit_list) await Company.delete_by_ids(delete_unit_oid_list) return result_code
async def post(self): """ 注册weid,其中kyc认证部分暂时忽略,后续可自行调整 :return: """ r_dict = {'respBody': '', 'errorCode': 200, 'errorMessage': 'success'} category = int(self.get_i_argument('category')) if category == 0: stuId = self.get_i_argument('stuId') name = self.get_i_argument('name') school = self.get_i_argument('school') id_card = self.get_i_argument('id_card') try: res = requests.post(host, json=Args.register_weid).json() print(res) _, tx_hash = fisco_client.fisco_add_data( 'insertStudent', [res['respBody'], stuId, id_card, name, school]) student = Student() student.weid = res['respBody'] student.school = school student.name = name student.stuId = stuId student.idCard = id_card student.tx_hash = tx_hash await student.save() r_dict['respBody'] = res['respBody'] except Exception: logger.error(traceback.format_exc()) return r_dict elif category == 1: name = self.get_i_argument('name') location = self.get_i_argument('location') business = self.get_i_argument('business') try: res = requests.post(host, json=Args.register_weid).json() print(res) _, tx_hash = fisco_client.fisco_add_data( 'insertCompany', [res['respBody'], name, location, business]) company = Company() company.name = name company.location = location company.business = business company.weid = res['respBody'] company.tx_hash = tx_hash await company.save() r_dict['respBody'] = res['respBody'] except Exception: logger.error(traceback.format_exc()) return r_dict else: name = self.get_i_argument('name') school = self.get_i_argument('school') teacher_id = self.get_i_argument('teacher_id') try: res = requests.post(host, json=Args.register_weid).json() # fisco_client.fisco_add_data('insetCompany', [name, location, business, res['respBody']]) teacher = Teacher() teacher.weid = res['respBody'] teacher.school = school teacher.name = name teacher.teacher_id = teacher_id await teacher.save() res['user_cid'] = teacher.cid res['category'] = 2 r_dict['respBody'] = res['respBody'] except Exception: pass return r_dict
def assembly(cls, company: Company, raw_company: dict): company.name = raw_company.get('Name', '-') company.representative = raw_company.get('OperName', '-') company.address = raw_company.get('Address', '-') company.region = raw_company.get('AreaCode', '-') # todo company.city = raw_company.get('AreaCode', '-') # todo company.district = raw_company.get('AreaCode', '-') # todo company.biz_status = raw_company.get('Status', '-') company.credit_code = raw_company.get('CreditCode', '-') company.email = raw_company.get('Email', '-') company.phone = raw_company.get('ContactNumber', '-') company.biz_scope = raw_company.get('Scope', '-') company.company_type = raw_company.get('EconKind', '-') company.taxpayer_code = raw_company.get('CreditCode', '-') company.registered_capital = raw_company.get('RegistCapi', '-') company.lat_long = str({ 'lat': raw_company.get('X', '-'), 'long': raw_company.get('Y', '-') }) company.setup_time = raw_company.get('StartDate', '-')