92 lines
4.1 KiB
Python
92 lines
4.1 KiB
Python
import xlrd
|
|
|
|
from Modules.Company.CompanyObject import BasicBusinessInfo
|
|
from Modules.Company.CompanyUtils import CommonUtils, ExcelSheetParser
|
|
|
|
|
|
class BasicBusinessInfoImpl(BasicBusinessInfo):
|
|
|
|
def parse_excel_and_create_company(self, file):
|
|
""""""
|
|
|
|
work_book = xlrd.open_workbook(file_contents=file.read())
|
|
|
|
for sheet in work_book.sheets():
|
|
|
|
if sheet.name == '企业信息':
|
|
data = ExcelSheetParser(sheet=sheet).parse_sheet1()
|
|
|
|
data['参保人数'] = int(data['参保人数'])
|
|
|
|
self.dict_to_set(instance=BasicBusinessInfo, data=data)
|
|
|
|
# elif sheet.name == '高管股东信息':
|
|
# data1, data2 = parse_gua_sheet2(sheet)
|
|
# for i in data1:
|
|
# i['企业名称'] = company
|
|
# if cid:
|
|
# i['cid'] = cid
|
|
# col_2.update_one({"高管姓名": i['姓名'], "企业名称": i['企业名称']}, {"$set": i}, upsert=True)
|
|
# for i in data2:
|
|
# i['企业名称'] = company
|
|
# if cid:
|
|
# i['cid'] = cid
|
|
# col_3.update_one({"股东名称": i['股东名称'], "企业名称": i['企业名称']}, {"$set": i}, upsert=True)
|
|
#
|
|
# elif sheet.name == '经营情况':
|
|
# data = parse_gua_sheet3(sheet)
|
|
# for i in data:
|
|
# i['企业名称'] = company
|
|
# i['所在省份'] = province
|
|
# if cid:
|
|
# i['cid'] = cid
|
|
# col_4.update_one({"年度": i['年度'], "企业名称": i['企业名称']}, {"$set": i}, upsert=True)
|
|
#
|
|
# elif sheet.name == '客户信息':
|
|
# data = parse_gua_sheet4(sheet)
|
|
# for i in data:
|
|
# i['担保企业'] = company
|
|
# if cid:
|
|
# i['cid'] = cid
|
|
# col_5.update_one({"年度": i['年度'], "客户名称": i['客户名称'], "担保企业": i['担保企业']}, {"$set": i}, upsert=True)
|
|
#
|
|
# elif sheet.name == '区域分布':
|
|
# data = parse_gua_sheet5(sheet)
|
|
# for i in data:
|
|
# i['担保企业'] = company
|
|
# if cid:
|
|
# i['cid'] = cid
|
|
# col_6.update_one({"年度": i['年度'], "地区": i['地区'], "担保企业": i['担保企业']}, {"$set": i}, upsert=True)
|
|
#
|
|
# elif sheet.name == '行业分布':
|
|
# data = parse_gua_sheet5(sheet)
|
|
# for i in data:
|
|
# i['担保企业'] = company
|
|
# if cid:
|
|
# i['cid'] = cid
|
|
# col_7.update_one({"年度": i['年度'], "所属行业": i['所属行业'], "担保企业": i['担保企业']}, {"$set": i}, upsert=True)
|
|
#
|
|
# elif sheet.name == '担保金额分布':
|
|
# data = parse_gua_sheet6(sheet)
|
|
# for i in data:
|
|
# i['担保企业'] = company
|
|
# if cid:
|
|
# i['cid'] = cid
|
|
# col_8.update_one({"年度": i['年度'], "担保企业": i['担保企业']}, {"$set": i}, upsert=True)
|
|
#
|
|
# elif sheet.name == '资产负债表':
|
|
# data = parse_gua_sheet7(sheet)
|
|
# for i in data:
|
|
# i['企业名称'] = company
|
|
# if cid:
|
|
# i['cid'] = cid
|
|
# col_9.update_one({"年度": i['年度'], "企业名称": i['企业名称']}, {"$set": i}, upsert=True)
|
|
#
|
|
# elif sheet.name == '利润表':
|
|
# data = parse_gua_sheet8(sheet)
|
|
# for i in data:
|
|
# i['企业名称'] = company
|
|
# if cid:
|
|
# i['cid'] = cid
|
|
# col_10.update_one({"年度": i['年度'], "企业名称": i['企业名称']}, {"$set": i}, upsert=True)
|