changes 修改部分生成代码

This commit is contained in:
彭森 2024-03-11 14:31:34 +08:00
parent bc074605cb
commit be4c5ac433
20 changed files with 1441 additions and 233 deletions

View File

@ -1,5 +1,11 @@
# -*- coding: utf-8 -*-
import io
import json
import os
import time
import requests
from PIL import Image
from docx import Document
from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
from docxtpl import DocxTemplate
@ -9,6 +15,7 @@ from starlette.background import BackgroundTask
from starlette.responses import FileResponse
from App.Schemas import ReportSchemas
from Utils.OpenaiUtils.api import get_openai_response
router = APIRouter(
prefix="/api/report_generation"
@ -20,7 +27,7 @@ def del_file(path):
# 文件路径
file_template = os.path.join(os.getcwd(), 'Utils', 'File', 'template', '信用报告模板.docx')
file_template = os.path.join(os.getcwd(), 'Utils', 'File', 'template', '信用报告模板v2.docx')
file_path = os.path.join(os.getcwd(), 'Utils', 'File', 'generate', '信用报告.docx')
@ -41,6 +48,57 @@ def func(schemas: ReportSchemas.ReportData):
report_content = schemas.dict()
file_name = '{}信用报告.docx'.format(report_content.get('企业名称'))
# 处理联系电话过长的问题,先把字符串根据逗号分为列表,前五个拼接为一个字符串,中间加一个换行符,后面的拼接为一个字符串
contact_phone = report_content.get('联系电话')
contact_phone = contact_phone.split(',')
contact_phone_begin = contact_phone[:5]
contact_phone_end = contact_phone[5:]
contact_phone_begin = ','.join(contact_phone_begin)
contact_phone_end = ','.join(contact_phone_end)
report_content['联系电话'] = contact_phone_begin + '\n' + contact_phone_end
# 处理经营范围样式问题字符串前33个字符为一行后面每38个字符为一行每行最后添加换行符
business_scope = report_content.get('经营范围')
report_content['经营范围'] = business_scope[:33] + '\n' + '\n'.join(
[business_scope[i:i + 38] for i in range(33, len(business_scope), 38)])
# 读取json文件
with open(os.path.join(os.getcwd(), 'Utils', 'OpenaiUtils', 'prompt.json'), 'r', encoding='gbk') as f:
report_json = json.load(f)
def openai_api():
history = report_content.get('历史沿革')
history_prompt = report_json.get('历史沿革')
if history != '-':
history_prompt = history + history_prompt
history_by_chatgpt = get_openai_response(history_prompt)
report_content['历史沿革'] = history_by_chatgpt
shareholding = report_content.get('股权结构')
shareholding_prompt = report_json.get('股权结构')
if shareholding != '-':
shareholding_prompt = shareholding + shareholding_prompt
shareholding_by_chatgpt = get_openai_response(shareholding_prompt)
report_content['股权结构'] = shareholding_by_chatgpt
executives = report_content.get('高管信息')
executives_prompt = report_json.get('高管信息')
if executives != '--' and executives != '-' and executives is not None:
executives_prompt = executives + executives_prompt
executives_by_chatgpt = get_openai_response(executives_prompt)
report_content['高管信息'] = executives_by_chatgpt
last_prompt = report_json.get('管理制度与报告结论')
last_prompt = str(report_content) + last_prompt
last_by_chatgpt = get_openai_response(last_prompt)
if last_by_chatgpt:
last_by_chatgpt = json.loads(last_by_chatgpt)
report_content['管理制度'] = last_by_chatgpt.get('管理制度')
report_content['报告结论'] = last_by_chatgpt.get('报告结论')
# 调用openai api优化填报数据
openai_api()
# 替换除表格以外的数据
doc.render(report_content)
doc.save(file_path)
@ -66,10 +124,40 @@ def func(schemas: ReportSchemas.ReportData):
current_row = len(table.rows) - 1
for r_i in range(len(brand_data[brand_index])):
if r_i == 1:
pic_path = os.path.join(os.getcwd(), 'Utils', 'File', 'picture', 'SB.jpg')
pic = table.cell(current_row, r_i).paragraphs[0].add_run().add_picture(pic_path)
pic.width = Inches(0.9)
pic.height = Inches(0.9)
# 获取图片路径
pic_url = brand_data[brand_index][r_i]
# 根据链接下载图片到本地
try:
pic_response = requests.get(pic_url)
# 保存图片
if pic_response.status_code == 200:
def get_pic_type():
content_type = pic_response.headers.get('Content-Type')
image_type = content_type.split('/')[-1].upper()
return '.' + image_type
pic_type = get_pic_type()
pic_name = str(time.time()) + pic_type
pic_path = os.path.join(os.getcwd(), 'Utils', 'File', 'picture', pic_name)
with open(pic_path, 'wb') as f:
f.write(pic_response.content)
try:
table.cell(current_row, r_i).paragraphs[0].add_run().add_picture(pic_path,
width=Inches(
0.9),
height=Inches(
0.9))
except Exception as e:
with Image.open(pic_path) as img:
img_byte_arr = io.BytesIO()
img.save(img_byte_arr, format='JPEG')
img_byte_arr.seek(0) # 重置流的位置
table.cell(current_row, r_i).paragraphs[0].add_run().add_picture(
img_byte_arr, width=Inches(0.9), height=Inches(0.9))
# 删除本地图片
os.remove(pic_path)
except Exception as e:
continue
else:
table.cell(current_row, r_i).text = str(brand_data[brand_index][r_i])
for section in table.cell(current_row, r_i).paragraphs:
@ -77,6 +165,7 @@ def func(schemas: ReportSchemas.ReportData):
block.font.size = Pt(9)
table.cell(current_row, r_i).vertical_alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
table.cell(current_row, r_i).paragraphs[0].alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
elif table.rows[0].cells[0].text == '申请日':
if report_content.get('专利信息'):
patent_data = []
@ -223,4 +312,3 @@ def func(schemas: ReportSchemas.ReportData):
task = BackgroundTask(del_file, file_path)
return FileResponse(file_path, filename=file_name, media_type='application/octet-stream', background=task)

View File

@ -0,0 +1,526 @@
# -*- coding: utf-8 -*-
import io
import json
import os
import re
import time
import requests
from PIL import Image
from docx import Document
from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
from docx.oxml import parse_xml, OxmlElement
from docx.oxml.ns import nsdecls
from docxtpl import DocxTemplate
from fastapi import APIRouter, Depends, HTTPException
from docx.shared import Pt, Inches
from starlette.background import BackgroundTask
from starlette.responses import FileResponse
from App.Schemas import ReportSchemas, ReportV2Schemas, ReportV3Schemas
from Utils.OpenaiUtils.api import get_openai_response
router = APIRouter(
prefix="/api/report_generation_v3"
)
def del_file(path):
os.remove(path)
# 文件路径
file_template = os.path.join(os.getcwd(), 'Utils', 'File', 'template', '信用报告模板_v3.docx')
file_path = os.path.join(os.getcwd(), 'Utils', 'File', 'generate', '信用报告.docx')
@router.post("/generate_report", summary="生成word报告v2", tags=["报告生成v2"])
def func(schemas: ReportV3Schemas.ReportData):
# 获取报告模板
doc = DocxTemplate(file_template)
# 获取填报数据
report_content = schemas.dict()
file_name = '{}信用报告.docx'.format(report_content.get('企业名称'))
# 处理联系电话过长的问题,先把字符串根据逗号分为列表,前五个拼接为一个字符串,中间加一个换行符,后面的拼接为一个字符串
contact_phone = report_content.get('联系电话')
contact_phone = contact_phone.split(',')
if len(contact_phone) > 5:
contact_phone_begin = contact_phone[:5]
contact_phone_end = contact_phone[5:]
contact_phone_begin = ','.join(contact_phone_begin)
contact_phone_end = ','.join(contact_phone_end)
report_content['联系电话'] = contact_phone_begin + '\n' + contact_phone_end
# 处理经营范围样式问题字符串前33个字符为一行后面每38个字符为一行每行最后添加换行符
business_scope = report_content.get('经营范围')
if len(business_scope) > 33:
report_content['经营范围'] = business_scope[:33] + '\n' + '\n'.join(
[business_scope[i:i + 38] for i in range(33, len(business_scope), 38)])
# 读取openai_api相关prompt—json文件
with open(os.path.join(os.getcwd(), 'Utils', 'OpenaiUtils', 'prompt.json'), 'r', encoding='gbk') as f:
report_json = json.load(f)
def openai_api():
history = report_content.get('历史沿革')
history_prompt = report_json.get('历史沿革')
if history != '-':
history_prompt = history + history_prompt
history_by_chatgpt = get_openai_response(history_prompt)
report_content['历史沿革'] = history_by_chatgpt
shareholding = report_content.get('股权结构')
shareholding_prompt = report_json.get('股权结构')
if shareholding != '-':
shareholding_prompt = shareholding + shareholding_prompt
shareholding_by_chatgpt = get_openai_response(shareholding_prompt)
report_content['股权结构'] = shareholding_by_chatgpt
executives = report_content.get('高管信息')
executives_prompt = report_json.get('高管信息')
if executives != '--' and executives != '-' and executives is not None:
executives_prompt = executives + executives_prompt
executives_by_chatgpt = get_openai_response(executives_prompt)
report_content['高管信息'] = executives_by_chatgpt
last_prompt = report_json.get('管理制度与报告结论')
last_prompt = str(report_content) + last_prompt
last_by_chatgpt = get_openai_response(last_prompt)
if last_by_chatgpt:
last_by_chatgpt = json.loads(last_by_chatgpt)
report_content['管理制度'] = last_by_chatgpt.get('管理制度')
report_content['报告结论'] = last_by_chatgpt.get('报告结论')
# 调用openai api优化填报数据
# openai_api()
# 替换除表格以外的数据
try:
doc.render(report_content)
doc.save(file_path)
# 处理表格数据
file = Document(file_path)
tables = file.tables
tables_to_keep = list()
# 处理表格数据
for table in tables:
# 商标信息
if table.rows[0].cells[0].text == '申请日期':
if report_content.get('商标信息'):
brand_data = []
for item in report_content.get('商标信息'):
row = []
for key in item:
row.append(item[key])
brand_data.append(row)
for brand_index in range(0, len(brand_data)):
# 表格新增一行,并将背景颜色设为白色
table.add_row()
# 当前行
current_row = len(table.rows) - 1
for r_i in range(len(brand_data[brand_index])):
if r_i == 1:
# 获取图片路径
pic_url = brand_data[brand_index][r_i]
# 根据链接下载图片到本地
try:
pic_response = requests.get(pic_url)
# 保存图片
if pic_response.status_code == 200:
def get_pic_type():
content_type = pic_response.headers.get('Content-Type')
image_type = content_type.split('/')[-1].upper()
return '.' + image_type
pic_type = get_pic_type()
pic_name = str(time.time()) + pic_type
pic_path = os.path.join(os.getcwd(), 'Utils', 'File', 'picture', pic_name)
with open(pic_path, 'wb') as f:
f.write(pic_response.content)
try:
table.cell(current_row, r_i).paragraphs[0].add_run().add_picture(pic_path,
width=Inches(
0.9),
height=Inches(
0.9))
except Exception as e:
with Image.open(pic_path) as img:
img_byte_arr = io.BytesIO()
img.save(img_byte_arr, format='JPEG')
img_byte_arr.seek(0) # 重置流的位置
table.cell(current_row, r_i).paragraphs[0].add_run().add_picture(
img_byte_arr, width=Inches(0.9), height=Inches(0.9))
# 删除本地图片
os.remove(pic_path)
except Exception as e:
continue
else:
table.cell(current_row, r_i).text = str(brand_data[brand_index][r_i])
for section in table.cell(current_row, r_i).paragraphs:
for block in section.runs:
block.font.size = Pt(9)
table.cell(current_row, r_i).vertical_alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
table.cell(current_row, r_i).paragraphs[0].alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
# 专利信息
elif table.rows[0].cells[0].text == '申请日':
if report_content.get('专利信息'):
patent_data = []
for item in report_content.get('专利信息'):
row = []
for key in item:
row.append(item[key])
patent_data.append(row)
for patent_index in range(0, len(patent_data)):
table.add_row()
# 当前行
current_row = len(table.rows) - 1
for r_i in range(len(patent_data[patent_index])):
table.cell(current_row, r_i).text = str(patent_data[patent_index][r_i])
for section in table.cell(current_row, r_i).paragraphs:
for block in section.runs:
block.font.size = Pt(9)
table.cell(current_row, r_i).vertical_alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
table.cell(current_row, r_i).paragraphs[0].alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
cell = table.cell(current_row, r_i)
shading_elm = parse_xml(r'<w:shd {} w:fill="FFFFFF"/>'.format(nsdecls('w')))
cell._element.get_or_add_tcPr().append(shading_elm)
# 软件著作权
elif table.rows[0].cells[0].text == '批准日期':
if report_content.get('软件著作权'):
software_data = []
for item in report_content.get('软件著作权'):
row = []
for key in item:
row.append(item[key])
software_data.append(row)
for software_index in range(0, len(software_data)):
table.add_row()
# 当前行
current_row = len(table.rows) - 1
for r_i in range(len(software_data[software_index])):
table.cell(current_row, r_i).text = str(software_data[software_index][r_i])
for section in table.cell(current_row, r_i).paragraphs:
for block in section.runs:
block.font.size = Pt(9)
table.cell(current_row, r_i).vertical_alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
table.cell(current_row, r_i).paragraphs[0].alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
cell = table.cell(current_row, r_i)
shading_elm = parse_xml(r'<w:shd {} w:fill="FFFFFF"/>'.format(nsdecls('w')))
cell._element.get_or_add_tcPr().append(shading_elm)
# 主要供应商情况
elif table.rows[0].cells[0].text == '序号' and table.rows[0].cells[1].text == '供应商名称':
if report_content.get('主要供应商情况'):
supplier_data = []
for index, item in enumerate(report_content.get('主要供应商情况')):
row = []
for key in item:
row.append(item[key])
supplier_data.append(row)
for supplier_index in range(0, len(supplier_data)):
table.add_row()
# 当前行
current_row = len(table.rows) - 1
for r_i in range(len(supplier_data[supplier_index])):
table.cell(current_row, r_i).text = str(supplier_data[supplier_index][r_i])
for section in table.cell(current_row, r_i).paragraphs:
for block in section.runs:
block.font.size = Pt(9)
table.cell(current_row, r_i).vertical_alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
table.cell(current_row, r_i).paragraphs[0].alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
cell = table.cell(current_row, r_i)
shading_elm = parse_xml(r'<w:shd {} w:fill="FFFFFF"/>'.format(nsdecls('w')))
cell._element.get_or_add_tcPr().append(shading_elm)
# 主要客户情况
elif table.rows[0].cells[0].text == '序号' and table.rows[0].cells[1].text == '客户名称':
if report_content.get('主要客户情况'):
customer_data = []
for index, item in enumerate(report_content.get('主要客户情况')):
row = []
for key in item:
row.append(item[key])
customer_data.append(row)
for customer_index in range(0, len(customer_data)):
table.add_row()
# 当前行
current_row = len(table.rows) - 1
for r_i in range(len(customer_data[customer_index])):
table.cell(current_row, r_i).text = str(customer_data[customer_index][r_i])
for section in table.cell(current_row, r_i).paragraphs:
for block in section.runs:
block.font.size = Pt(9)
table.cell(current_row, r_i).vertical_alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
table.cell(current_row, r_i).paragraphs[0].alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
cell = table.cell(current_row, r_i)
shading_elm = parse_xml(r'<w:shd {} w:fill="FFFFFF"/>'.format(nsdecls('w')))
cell._element.get_or_add_tcPr().append(shading_elm)
# 招投标情况
elif table.rows[0].cells[0].text == '发布时间':
if report_content.get('招投标情况'):
tender_data = []
for item in report_content.get('招投标情况'):
row = []
for key in item:
row.append(item[key])
tender_data.append(row)
for tender_index in range(0, len(tender_data)):
table.add_row()
# 当前行
current_row = len(table.rows) - 1
for r_i in range(len(tender_data[tender_index])):
table.cell(current_row, r_i).text = str(tender_data[tender_index][r_i])
for section in table.cell(current_row, r_i).paragraphs:
for block in section.runs:
block.font.size = Pt(9)
table.cell(current_row, r_i).vertical_alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
table.cell(current_row, r_i).paragraphs[0].alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
cell = table.cell(current_row, r_i)
shading_elm = parse_xml(r'<w:shd {} w:fill="FFFFFF"/>'.format(nsdecls('w')))
cell._element.get_or_add_tcPr().append(shading_elm)
# 竞争对手
elif table.rows[0].cells[0].text == '竞争对手':
if report_content.get('竞争对手'):
competitor_data = []
for item in report_content.get('竞争对手'):
row = []
for key in item:
row.append(item[key])
competitor_data.append(row)
for competitor_index in range(0, len(competitor_data)):
table.add_row()
# 当前行
current_row = len(table.rows) - 1
for r_i in range(len(competitor_data[competitor_index])):
table.cell(current_row, r_i).text = str(competitor_data[competitor_index][r_i])
for section in table.cell(current_row, r_i).paragraphs:
for block in section.runs:
block.font.size = Pt(9)
table.cell(current_row, r_i).vertical_alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
table.cell(current_row, r_i).paragraphs[0].alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
cell = table.cell(current_row, r_i)
shading_elm = parse_xml(r'<w:shd {} w:fill="FFFFFF"/>'.format(nsdecls('w')))
cell._element.get_or_add_tcPr().append(shading_elm)
# 股权出质
elif table.rows[0].cells[0].text == '公示日期':
if report_content.get('股权出质'):
equity_pledge_data = []
for item in report_content.get('股权出质'):
row = []
for key in item:
row.append(item[key])
equity_pledge_data.append(row)
for equity_pledge_index in range(0, len(equity_pledge_data)):
table.add_row()
# 当前行
current_row = len(table.rows) - 1
for r_i in range(len(equity_pledge_data[equity_pledge_index])):
table.cell(current_row, r_i).text = str(equity_pledge_data[equity_pledge_index][r_i])
for section in table.cell(current_row, r_i).paragraphs:
for block in section.runs:
block.font.size = Pt(9)
table.cell(current_row, r_i).vertical_alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
table.cell(current_row, r_i).paragraphs[0].alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
cell = table.cell(current_row, r_i)
shading_elm = parse_xml(r'<w:shd {} w:fill="FFFFFF"/>'.format(nsdecls('w')))
cell._element.get_or_add_tcPr().append(shading_elm)
# 质押明细
elif table.rows[0].cells[0].text == '质押笔数':
if report_content.get('质押明细'):
pledge_detail_data = []
for item in report_content.get('质押明细'):
row = []
for key in item:
row.append(item[key])
pledge_detail_data.append(row)
for pledge_detail_index in range(0, len(pledge_detail_data)):
table.add_row()
# 当前行
current_row = len(table.rows) - 1
for r_i in range(len(pledge_detail_data[pledge_detail_index])):
table.cell(current_row, r_i).text = str(pledge_detail_data[pledge_detail_index][r_i])
for section in table.cell(current_row, r_i).paragraphs:
for block in section.runs:
block.font.size = Pt(9)
table.cell(current_row, r_i).vertical_alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
table.cell(current_row, r_i).paragraphs[0].alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
cell = table.cell(current_row, r_i)
shading_elm = parse_xml(r'<w:shd {} w:fill="FFFFFF"/>'.format(nsdecls('w')))
cell._element.get_or_add_tcPr().append(shading_elm)
# 被执行人
elif table.rows[0].cells[0].text == '案号':
if report_content.get('被执行人'):
executed_person_data = []
for item in report_content.get('被执行人'):
row = []
for key in item:
row.append(item[key])
executed_person_data.append(row)
for executed_person_index in range(0, len(executed_person_data)):
table.add_row()
# 当前行
current_row = len(table.rows) - 1
for r_i in range(len(executed_person_data[executed_person_index])):
table.cell(current_row, r_i).text = str(executed_person_data[executed_person_index][r_i])
for section in table.cell(current_row, r_i).paragraphs:
for block in section.runs:
block.font.size = Pt(9)
table.cell(current_row, r_i).vertical_alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
table.cell(current_row, r_i).paragraphs[0].alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
cell = table.cell(current_row, r_i)
shading_elm = parse_xml(r'<w:shd {} w:fill="FFFFFF"/>'.format(nsdecls('w')))
cell._element.get_or_add_tcPr().append(shading_elm)
# 在表格的最后添加一行,最后一行的第一列为合计,第二列为执行标的金额合计值,第三第四为-
table.add_row()
current_row = len(table.rows) - 1
table.cell(current_row, 0).text = '合计'
# 获取被执行人合计,循环执行标的金额,将金额相加
executed_person_total = 0
for item in report_content.get('被执行人'):
# 用正则提取执行标的中的数字
mount = re.findall(r'\d+', item.get('执行标的'))
if mount:
executed_person_total += float(mount[0])
table.cell(current_row, 1).text = str(executed_person_total)
for i in range(2, 4):
table.cell(current_row, i).text = '-'
# 主要财务数据
elif table.rows[0].cells[0].text == '指标名称' and '资产负债表' in table.rows[1].cells[0].text:
finance_data = report_content.get('主要财务数据')
years = list(finance_data.keys())
result = [years]
for k in finance_data[years[0]]:
row = [k]
for y in years:
row.append(finance_data[y][k])
result.append(row)
result[0].insert(0, '指标名称')
def insert_before(result_, keyword, to_insert):
for res in result_:
if res[0] == keyword:
result_.insert(result_.index(res), to_insert)
break
# 使用函数进行插入操作
insert_before(result, '流动资产', ['资产负债表', '', '', ''])
insert_before(result, '营业总收入', ['利润表', '', '', ''])
insert_before(result, '销售商品提供劳务收到的现金', ['现金流量表', '', '', ''])
rows = len(table.rows)
cols = len(table.columns)
for row in range(rows):
for col in range(cols):
if table.cell(row, col).text == '资产负债表' or table.cell(row,
col).text == '利润表' or table.cell(
row, col).text == '现金流量表':
continue
if col != 0:
table.cell(row, col).text = str(result[row][col])
table.cell(row, col).vertical_alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
table.cell(row, col).paragraphs[0].alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
for section in table.cell(row, col).paragraphs:
for block in section.runs:
block.font.size = Pt(9)
# 主要财务指标分析
elif table.rows[0].cells[0].text == '指标名称' and '净资产收益率' in table.rows[1].cells[0].text:
finance_analysis = report_content.get('主要财务指标分析')
years = list(finance_analysis.keys())
result = [years]
for k in finance_analysis[years[0]]:
row = [k]
for y in years:
row.append(finance_analysis[y][k])
result.append(row)
result[0].insert(0, '指标名称')
rows = len(table.rows)
cols = len(table.columns)
for row in range(rows):
for col in range(cols):
if col != 0:
table.cell(row, col).text = str(result[row][col])
table.cell(row, col).vertical_alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
table.cell(row, col).paragraphs[0].alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
for section in table.cell(row, col).paragraphs:
for block in section.runs:
block.font.size = Pt(9)
# 删除数据为空的表格
for table in tables:
if table.rows[0].cells[0].text == '申请日期' and not report_content.get('商标信息'):
tables_to_keep.append(table)
# 专利信息
elif table.rows[0].cells[0].text == '申请日' and not report_content.get('专利信息'):
tables_to_keep.append(table)
# 软件著作权
elif table.rows[0].cells[0].text == '批准日期' and not report_content.get('软件著作权'):
tables_to_keep.append(table)
# 主要供应商情况
elif table.rows[0].cells[0].text == '序号' and table.rows[0].cells[
1].text == '供应商名称' and not report_content.get('主要供应商情况'):
tables_to_keep.append(table)
# 主要客户情况
elif table.rows[0].cells[0].text == '序号' and table.rows[0].cells[
1].text == '客户名称' and not report_content.get('主要客户情况'):
tables_to_keep.append(table)
# 招投标情况
elif table.rows[0].cells[0].text == '发布时间' and not report_content.get('招投标情况'):
tables_to_keep.append(table)
# 竞争对手
elif table.rows[0].cells[0].text == '竞争对手' and not report_content.get('竞争对手'):
tables_to_keep.append(table)
# 股权出质
elif table.rows[0].cells[0].text == '公示日期' and not report_content.get('股权出质'):
tables_to_keep.append(table)
# 质押明细
elif table.rows[0].cells[0].text == '质押笔数' and not report_content.get('质押明细'):
tables_to_keep.append(table)
# 被执行人
elif table.rows[0].cells[0].text == '案号' and not report_content.get('被执行人'):
tables_to_keep.append(table)
# 删除表格
for table in tables_to_keep:
tbl = table._element
tbl.getparent().remove(tbl)
# 新增文字
for para in file.paragraphs:
if para.text == "2.3 技术成果" and not report_content.get('商标信息'):
new_paragraph = file.add_paragraph("截止报告日,未查询到相关信息。")
index = para._element.getparent().index(para._element)
para._element.getparent().insert(index + 1, new_paragraph._element)
elif para.text == "2.4 软件著作权" and not report_content.get('软件著作权'):
new_paragraph = file.add_paragraph("截止报告日,未查询到相关信息。")
index = para._element.getparent().index(para._element)
para._element.getparent().insert(index + 1, new_paragraph._element)
elif para.text == "2.5 主要供应商情况" and not report_content.get('主要供应商情况'):
new_paragraph = file.add_paragraph("截止报告日,未查询到相关信息。")
index = para._element.getparent().index(para._element)
para._element.getparent().insert(index + 1, new_paragraph._element)
elif para.text == "2.6 招投标情况" and not report_content.get('招投标情况'):
new_paragraph = file.add_paragraph("截止报告日,未查询到相关信息。")
index = para._element.getparent().index(para._element)
para._element.getparent().insert(index + 1, new_paragraph._element)
if not report_content.get('软件著作权'):
for para in file.paragraphs:
if para.text == '说明技术成果包括专利、商标、科技进步奖、工法、QC 小组活动成果、参与制定标准等。':
p = para._element
p.getparent().remove(p)
file.save(file_path)
task = BackgroundTask(del_file, file_path)
return FileResponse(file_path, filename=file_name, media_type='application/octet-stream', background=task)
except Exception as e:
del_file(file_path)
print(e)
raise HTTPException(status_code=500, detail="生成报告失败")

View File

@ -19,10 +19,10 @@ def del_file(path):
@router.post("/model_score_reusult", summary="提交模型打分所需数据返回评级结果", tags=["评级结果"])
async def func(background_tasks: BackgroundTasks, schemas: ModelSchemas.ModelScoreData):
# 复制一份文件到指定文件夹
temp_file = os.path.join(os.getcwd(), 'Utils', 'File', 'template', '中小商业企业信用模型.xlsx')
temp_file = os.path.join(os.getcwd(), 'Utils', 'File', 'template', '中小商业企业信用模型v2.xlsx')
dst_folder = os.path.join(os.getcwd(), 'Utils', 'File', 'generate')
shutil.copy(temp_file, dst_folder)
path = os.path.join(os.getcwd(), 'Utils', 'File', 'generate', '中小商业企业信用模型.xlsx')
path = os.path.join(os.getcwd(), 'Utils', 'File', 'generate', '中小商业企业信用模型v2.xlsx')
# 打开模型excel
wb = load_workbook(path)
# 将经营问卷填入文件
@ -42,7 +42,7 @@ async def func(background_tasks: BackgroundTasks, schemas: ModelSchemas.ModelSco
# 财务问卷填入文件
financial_sheet = wb['财务问卷']
financial_data = schemas.财务问卷.dict()
financial_sheet_rows = financial_sheet.max_row - 5
financial_sheet_rows = financial_sheet.max_row - 3
for j in range(2, financial_sheet_rows + 1):
key_cell = 'B{}'.format(j)
val1_cell = 'C{}'.format(j)
@ -57,9 +57,9 @@ async def func(background_tasks: BackgroundTasks, schemas: ModelSchemas.ModelSco
financial_sheet[val2_cell] = value[1]
financial_sheet[val3_cell] = value[2]
audit = financial_data.get('是否审计')
financial_sheet['B35'] = audit
financial_sheet['C33'] = audit
firm = financial_data.get('会计事务所')
financial_sheet['B36'] = firm
financial_sheet['C34'] = firm
# 背调数据填入文件
backtrack_sheet = wb['背调接口']
@ -95,7 +95,7 @@ async def func(background_tasks: BackgroundTasks, schemas: ModelSchemas.ModelSco
index_data = [
{"指标": row[2].value, "数值": row[3].value, "单位": row[4].value,
"权重": row[7].value, "得分": row[8].value} for row in sheet_01.iter_rows()]
index_data = index_data[2:42]
index_data = index_data[1:42]
rating_result = {
"级别": sheet_01.cell(43, 6).value,

View File

@ -32,11 +32,11 @@ class Business(BaseModel):
员工日均工作时长: Union[int, float]
年度因公伤亡人次: int
人民币开户银行名称: str
人民币开户银行账号: str
人民币开户银行账号: Union[int, float, str]
外币开户银行名称: str
外币开户银行账号: str
贷款卡编号: str
经营场所建筑面积: str
外币开户银行账号: Union[int, float, str]
贷款卡编号: Union[int, float, str]
经营场所建筑面积: Union[int, float, str]
经营场所位置: str
经营场所权属关系: str
拥有质量管理制度: str
@ -56,41 +56,48 @@ class Business(BaseModel):
客户有效投诉次数: int
投诉解决次数: int
投诉响应时间: Union[int, float]
专业委员会名称: str
专业委员会数量: Union[int, float]
生产人员人数: Union[int, float]
拥有投融资管理制度: str
拥有信息披露制度: str
拥有合规管理制度: str
拥有数据管理制度: str
class Financial(BaseModel):
货币资金: List[float]
应收账款: List[float]
其他应收款: List[float]
预付款项: List[float]
存货: List[float]
流动资产合计: List[float]
非流动资产合计: List[float]
固定资产原价: List[float]
累计折旧: List[float]
固定资产净额: List[float]
固定资产总计: List[float]
无形资产及其他资产合计: List[float]
资产总计: List[float]
短期借款: List[float]
应付票据: List[float]
应付账款: List[float]
预收账款: List[float]
应付利息: List[float]
其他应付款: List[float]
流动负债合计: List[float]
长期借款: List[float]
应付债券: List[float]
非流动负债合计: List[float]
负债合计: List[float]
未分配利润: List[float]
所有者权益合计: List[float]
营业收入: List[float]
营业成本: List[float]
利息费用: List[float]
货币资金: List[Union[float, None]]
应收账款: List[Union[float, None]]
其他应收款: List[Union[float, None]]
预付款项: List[Union[float, int]]
存货: List[Union[float, int]]
流动资产合计: List[Union[float, int]]
非流动资产合计: List[Union[float, None]]
固定资产原价: List[Union[float, None]]
累计折旧: List[Union[float, None]]
固定资产净额: List[Union[float, None]]
固定资产总计: List[Union[float, None]]
无形资产及其他资产合计: List[Union[float, None]]
资产总计: List[Union[float, int]]
短期借款: List[Union[float, None]]
应付票据: List[Union[float, None]]
应付账款: List[Union[float, None]]
预收账款: List[Union[float, None]]
应付利息: List[Union[float, None]]
其他应付款: List[Union[float, None]]
流动负债合计: List[Union[float, int]]
长期借款: List[Union[float, None]]
应付债券: List[Union[float, None]]
非流动负债合计: List[Union[float, None]]
负债合计: List[Union[float, int]]
未分配利润: List[Union[float, None]]
所有者权益合计: List[Union[float, None]]
营业收入: List[Union[float, int]]
营业成本: List[Union[float, int]]
利息费用: List[Union[float, int]]
净利润: List[float]
是否审计: str
会计事务所: str
会计事务所: Union[str, None]
class Backtrack(BaseModel):

View File

@ -95,11 +95,11 @@ class ReportData(BaseModel):
合计占比: str
高管构成: str
人民币开户银行名称: str
人民币开户银行账号: str
人民币开户银行账号: Union[int, float, str]
外币开户银行名称: str
外币开户银行账号: str
外币开户银行账号: Union[int, float, str]
贷款卡编号: str
经营场所建筑面积: str
经营场所建筑面积: Union[int, float, str]
经营场所位置: str
经营场所权属关系: str
工商信用记录: str

View File

@ -0,0 +1,230 @@
# -*- coding: utf-8 -*-
from typing import Union, List
from pydantic import BaseModel
class Trademark(BaseModel):
申请日期: str
商标: str
商标名称: str
注册号: str
类别: str
流程状态: str
class Patent(BaseModel):
申请日: str
专利名称: str
专利类型: str
专利状态: str
申请号: str
公开号: str
公开日: str
发明人: str
class SoftwareCopyright(BaseModel):
批准日期: str
软件全称: str
软件简称: str
登记号: str
分类号: str
版本号: str
class Supplier(BaseModel):
报告期: str
供应商名称: str
采购金额: str
采购占比: str
class Custom(BaseModel):
报告期: str
客户名称: str
销售金额: str
销售占比: str
class Bidding(BaseModel):
发布时间: str
标题: str
采购人: str
class Competitor(BaseModel):
竞争对手: str
同业竞品: str
class EquityPledge(BaseModel):
股权出质设立登记日期: str
登记编号: str
出质人: str
出质股权标的企业: str
出质股权数额: str
状态: str
# 抵押明细
class PledgeDetail(BaseModel):
质押笔数: str
质押股数: str
质押比例: str
质押市值: str
# 被执行人
class ExecutedPerson(BaseModel):
案号: str
执行法院: str
立案日期: str
执行标的: str
# 主要财务数据
class MainFinancialData(BaseModel):
报告期: str
流动资产: str
固定资产: str
长期股权投资: str
资产总计: str
流动负债: str
非流动负债: str
负债合计: str
实收资本: str
资本公积金: str
盈余公积金: str
未分配利润: str
营业总收入: str
营业总成本: str
营业利润: str
利润总额: str
净利润: str
销售商品提供劳务收到的现金: str
经营活动现金净流量: str
购建固定无形长期资产支付的现金: str
投资支付的现金: str
投资活动现金净流量: str
筹资活动现金净流量: str
# 主要财务指标分析
class MainFinancialIndexData(BaseModel):
报告期: str
净资产收益率: str
总资产收益率: str
销售毛利率: str
资产负债率: str
总资产周转率: str
销售商品和劳务收到现金营业收入: str
class ReportData(BaseModel):
# 首页
企业名称: str
年份: str
月份: str
# 通知书
报告编号: str
信用级别: str
证书编码: str
有效日期: str
通知书日期: str
# 评级机构声明
申明日期: str
# 基本信息
所属国民经济行业: str
企业中文名称: str
英文名称: str
工商注册号: str
组织机构代码: str
统一社会信用代码: str
注册资本: str
企业类型: str
注册地址: str
成立日期: str
核准日期: str
营业期限终止日期: str
法定代表人: str
经营地址: str
邮政编码: str
联系人: str
联系电话: str
传真号码: str
电子邮箱: str
企业网址: str
经营范围: str
主营业务: str
主要产品: str
# 历史沿革
历史沿革: str
# 股权结构
股权结构: str
# 人员构成
销售人数: str
销售占比: str
技术服务人数: str
技术服务占比: str
生产人数: str
生产占比: str
管职人数: str
管职占比: str
本科及以上人数: str
本科及以上占比: str
专科及以下人数: str
专科及以下占比: str
合计人数: str
合计占比: str
# 高管构成
高管构成: str
# 银行/金融信息
人民币开户银行名称: str
人民币开户银行账号: Union[int, float, str]
外币开户银行名称: str
外币开户银行账号: Union[int, float, str]
贷款卡编号: str
# 经营场所
经营场所建筑面积: Union[int, float, str]
经营场所位置: str
经营场所权属关系: str
# 主要资质
主要资质: str
# 技术成果-商标信息
商标信息: List[Trademark]
# 技术成果-专利信息
专利信息: List[Patent]
# 软件著作权
软件著作权: List[SoftwareCopyright]
# 主要供应商情况
主要供应商情况: List[Supplier]
# 主要客户情况
主要客户情况: List[Custom]
# 招投标情况
招投标情况: List[Bidding]
# 经营风险-竞争对手
竞争对手: List[Competitor]
# 经营风险-股权出质
股权出质: List[EquityPledge]
# 经营风险-质押明细
质押明细: List[PledgeDetail]
# 信用风险
工商信用记录: str
海关信用记录: str
税务信用记录: str
银行信用记录: str
生产安全信息: str
社会责任实施: str
# 司法风险-被执行人
被执行人: List[ExecutedPerson]
# 司法风险-历史司法风险
历史失信被执行人: int
历史被执行人: int
历史限制消费令: int
# 财务表现-主要财务数据
主要财务数据: List[MainFinancialData]
主要财务指标分析: List[MainFinancialIndexData]
# 优化提升建议
优化提升建议: str
# 企业信用等级评价评审报告结论
企业信用等级评价评审报告结论: str

View File

@ -0,0 +1,227 @@
# -*- coding: utf-8 -*-
from typing import Union, List
from pydantic import BaseModel
class Trademark(BaseModel):
申请日期: str
商标: str
商标名称: str
注册号: str
类别: str
流程状态: str
class Patent(BaseModel):
申请日: str
专利名称: str
专利类型: str
专利状态: str
申请号: str
公开号: str
公开日: str
发明人: str
class SoftwareCopyright(BaseModel):
批准日期: str
软件全称: str
软件简称: str
登记号: str
分类号: str
版本号: str
class Supplier(BaseModel):
序号: str
供应商名称: str
当年采购额: str
class Custom(BaseModel):
序号: str
客户名称: str
当年销售金额: str
class Bidding(BaseModel):
发布时间: str
标题: str
采购人: str
class Competitor(BaseModel):
竞争对手: str
同业竞品: str
class EquityPledge(BaseModel):
公示日期: str
登记编号: str
出质人出质股权标的企业: str
出质股权数额: str
状态: str
# 抵押明细
class PledgeDetail(BaseModel):
质押笔数: str
质押股数: str
质押比例: str
质押市值: str
# 被执行人
class ExecutedPerson(BaseModel):
案号: str
执行法院: str
立案日期: str
执行标的: str
# 主要财务数据
class MainFinancialData(BaseModel):
报告期: str
流动资产: str
固定资产: str
长期股权投资: str
资产总计: str
流动负债: str
非流动负债: str
负债合计: str
实收资本: str
资本公积金: str
盈余公积金: str
未分配利润: str
营业总收入: str
营业总成本: str
营业利润: str
利润总额: str
净利润: str
销售商品提供劳务收到的现金: str
经营活动现金净流量: str
购建固定无形长期资产支付的现金: str
投资支付的现金: str
投资活动现金净流量: str
筹资活动现金净流量: str
# 主要财务指标分析
class MainFinancialIndexData(BaseModel):
报告期: str
净资产收益率: str
总资产收益率: str
销售毛利率: str
资产负债率: str
总资产周转率: str
销售商品和劳务收到现金营业收入: str
class ReportData(BaseModel):
# 首页
企业名称: str
年份: str
月份: str
# 通知书
报告编号: str
信用级别: str
证书编码: str
有效日期: str
通知书日期: str
# 评级机构声明
申明日期: str
# 基本信息
所属国民经济行业: str
企业中文名称: str
英文名称: str
工商注册号: str
组织机构代码: str
统一社会信用代码: str
注册资本: str
企业类型: str
注册地址: str
成立日期: str
核准日期: str
营业期限终止日期: str
法定代表人: str
经营地址: str
邮政编码: str
联系人: str
联系电话: str
传真号码: str
电子邮箱: str
企业网址: str
经营范围: str
主营业务: str
主要产品: str
# 历史沿革
历史沿革: str
# 股权结构
股权结构: str
# 人员构成
销售人数: str
销售占比: str
技术服务人数: str
技术服务占比: str
生产人数: str
生产占比: str
管职人数: str
管职占比: str
本科及以上人数: str
本科及以上占比: str
专科及以下人数: str
专科及以下占比: str
合计人数: str
合计占比: str
# 高管构成
高管构成: str
# 银行/金融信息
人民币开户银行名称: str
人民币开户银行账号: Union[int, float, str]
外币开户银行名称: str
外币开户银行账号: Union[int, float, str]
贷款卡编号: str
# 经营场所
经营场所建筑面积: Union[int, float, str]
经营场所位置: str
经营场所权属关系: str
# 主要资质
主要资质: str
# 技术成果-商标信息
商标信息: List[Trademark]
# 技术成果-专利信息
专利信息: List[Patent]
# 软件著作权
软件著作权: List[SoftwareCopyright]
# 主要供应商情况
主要供应商情况: List[Supplier]
# 主要客户情况
主要客户情况: List[Custom]
# 招投标情况
招投标情况: List[Bidding]
# 经营风险-竞争对手
竞争对手: List[Competitor]
# 经营风险-股权出质
股权出质: List[EquityPledge]
# 经营风险-质押明细
质押明细: List[PledgeDetail]
# 信用风险
工商信用记录: str
海关信用记录: str
税务信用记录: str
银行信用记录: str
生产安全信息: str
社会责任实施: str
# 司法风险-被执行人
被执行人: List[ExecutedPerson]
# 司法风险-历史司法风险
历史失信被执行人: int
历史被执行人: int
历史限制消费令: int
# 财务表现-主要财务数据
主要财务数据: dict
主要财务指标分析: dict
# 优化提升建议
优化提升建议: str
# 企业信用等级评价评审报告结论
企业信用等级评价评审报告结论: str

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 KiB

View File

@ -1,205 +1,301 @@
{
"企业名称": "中炬高新技术实业(集团)股份有限公司",
"年份": "二三",
"月份": "",
"报告编号": "中小商协[2023]0111号",
"企业名称": "江苏智能科技有限公司",
"年份": "",
"月份": "",
"报告编号": "JSAIC20221215",
"信用级别": "AAA",
"证书编码": "201703411100345",
"有效日期": "二〇二三年七月二十五日至二〇二四年七月二十五日",
"通知书日期": "二〇二三年七月二十五日",
"申明日期": "二〇二三年七月二十五日",
"所属国民经济行业": "计算机、通信和其他电子设备制造业",
"企业中文名称": "中炬高新技术实业(集团)股份有限公司",
"英文名称": "Jonjee Hi-Tech Industrial And Commercial Holding Co.,Ltd.",
"工商注册号": "440000000000276",
"组织机构代码": "19035710-6",
"统一社会信用代码": "91442000190357106Y",
"注册资本": "78537.595万人民币",
"企业类型": "其他股份有限公司(上市)",
"注册地址": "中山市中山火炬高技术产业开发区",
"成立日期": "1993-01-16",
"核准日期": "2022-11-28",
"营业期限终止日期": "无固定期限",
"法定代表人": "何华",
"经营地址": "中山市中山火炬高技术产业开发区",
"邮政编码": "528400",
"联系人": "何华",
"联系电话": "0760-85596818",
"传真号码": "0760-85596818",
"电子邮箱": "jonjee@jonjee.com",
"企业网址": "www.jonjee.com",
"经营范围": "城市基础设施的投资房地产开发物业管理二次供水服务高新技术产业投资开发实业投资设备租赁技术咨询信息咨询。销售工业生产资料不含金银、小轿车及危险化学品百货五金、交电、化工不含危险化学品针、纺织品建筑材料。自营和代理除国家组织统一联合经营的出口商品和国家实行核定公司经营的进口商品以外的其它商品及技术的进出口业务经营进料加工和“三来一补”业务经营对销贸易和转口贸易99外经贸政审函字588号文经营依法须经批准的项目经相关部门批准后方可开展经营活动。(依法须经批准的项目,经相关部门批准后方可开展经营活动)",
"主营业务": "公司致力于资产经营和资本运营,投资范围涉及调味品及健康食品业、国家级高新区开发与招商、房地产业、汽车配件业等领域, 目前核心业务为调味品及健康食品、园区综合开发。",
"主要产品": "酱油、鸡粉(精)、蚝油、酱类、料酒、醋类、食用油、腐乳、味精、汁类、火锅底料等。",
"历史沿革": [
{
"变更日期": "2022-11-28",
"变更项目": "出资额变更",
"变更后": "中国工商银行广东省信托投资公司 0.000000万;\n\n中国信达信托投资公司 0.000000万;\n\n中山市设备租赁公司 0.000000万;\n\n中山火炬高新技术产业集团公司 0.000000万;\n\n中山市信联房地产投资公司 0.000000万;\n\n中国工商银行北京市信托投资公司 0.000000万;\n\n中山市建设实业公司 0.000000万;\n\n中国工商银行信托投资公司 0.000000万;\n\n流通股 79663.719400万"
}
],
"股权结构": "中炬高新技术实业集团股份有限公司股东由中山火炬集团有限公司、中山润田投资有限公司共同出资组成其中中山火炬集团有限公司持股8542.55万股出资比例10.88%中山润田投资有限公司持股7521.63万股出资比例9.58%。",
"销售人数": "12",
"销售占比": "12%",
"技术服务人数": "36",
"技术服务占比": "36%",
"生产人数": "24",
"生产占比": "24%",
"管职人数": "15",
"管职占比": "15%",
"本科及以上人数": "46",
"本科及以上占比": "51%",
"专科人数": "33",
"专科占比": "49%",
"合计人数": "100",
"证书编码": "320000202212150001",
"有效日期": "二零二四年三月四日至二零二七年三月三日",
"通知书日期": "二〇二四年三月四日",
"申明日期": "二〇二四年三月四日",
"所属国民经济行业": "软件和信息技术服务业",
"企业中文名称": "江苏智能科技有限公司",
"英文名称": "Jiangsu Intelligent Technology Co., Ltd.",
"工商注册号": "320100000123456",
"组织机构代码": "12345678",
"统一社会信用代码": "91320100MA1XXXXX1X",
"注册资本": "20000000",
"企业类型": "有限责任公司(自然人投资或控股)",
"注册地址": "江苏省南京市栖霞区和燕路18号",
"成立日期": "2010-05-15",
"核准日期": "2010-05-20",
"营业期限终止日期": "2030-05-14",
"法定代表人": "张伟",
"经营地址": "江苏省南京市秦淮区中华门外大街6号绿地之窗B座",
"邮政编码": "210001",
"联系人": "王红",
"联系电话": "025-88776655",
"传真号码": "025-88776677",
"电子邮箱": "info@jsintelligent.com",
"企业网址": "www.jsintelligent.com",
"经营范围": "计算机软硬件的技术开发、技术服务;系统集成;数据处理;计算机维修及网络工程服务;销售自行开发的产品;机电设备安装工程;电子产品的生产、加工;货物及技术进出口业务。",
"主营业务": "智能制造系统集成、工业软件开发",
"主要产品": "智能车间管理系统,机器视觉检测系统,工业机器人集成系统",
"历史沿革": "江苏智能科技有限公司前身为2010年5月在南京市注册成立的有限责任公司,2015年完成股权重组后,进入快速发展期,先后在南京、苏州、无锡设立分支机构,业务范围覆盖江苏、上海、安徽、浙江等地区。",
"股权结构": "法人股东:江智控股集团有限公司(60%),自然人股东:张伟(30%),王红(10%)",
"销售人数": "85",
"销售占比": "25%",
"技术服务人数": "120",
"技术服务占比": "35%",
"生产人数": "65",
"生产占比": "19%",
"管职人数": "70",
"管职占比": "21%",
"本科及以上人数": "240",
"本科及以上占比": "71%",
"专科及以下人数": "100",
"专科及以下占比": "29%",
"合计人数": "340",
"合计占比": "100%",
"高管构成": "公司董事长何华女士出生于1973年8月现年45岁硕士学历。自2021年5月起至今一直担任中炬高新技术实业集团股份有限公司法人代表兼董事长职务。",
"人民币开户银行名称": "北京农商银行石景山支行",
"人民币开户银行账号": "0301050103000014583",
"外币开户银行名称": "-",
"外币开户银行账号": "-",
"贷款卡编号": "-",
"经营场所建筑面积": "3700平方米",
"经营场所位置": "市区",
"高管构成": "总经理:张伟,副总经理:王红/李军/赵勇,财务总监:孙强,技术总监:刘敏",
"人民币开户银行名称": "中国工商银行南京城东支行",
"人民币开户银行账号": "1234567890123456789",
"外币开户银行名称": "中国银行南京分行",
"外币开户银行账号": "123456789012",
"贷款卡编号": "6212345678901234",
"经营场所建筑面积": 12500,
"经营场所位置": "江苏省南京秦淮中华门外大街6号绿地之窗B座",
"经营场所权属关系": "租赁",
"工商信用记录": "工商A类企业",
"海关信用记录": "一般信用企业",
"税务信用记录": "国税连续三年A级",
"银行信用记录": "良好",
"法院信用记录": "-",
"生产安全信息": "-",
"社会责任实施": "2014年6月荣获教育装备海南扶贫援建工程优秀捐赠企业",
"企业资质": "1、质量管理体系认证证书、环境管理体系认证证书、职业健康安全管理体系认证证书",
"主要资质": "ISO9001质量管理体系认证,ISO27001信息安全管理体系认证,CMMI3级认证,安防工程企业设计施工维修能力证书",
"商标信息": [
{
"申请日期": "2017-04-17",
"商标": "",
"商标名称": "全息教育",
"注册号": "3532152048",
"类别": "教育娱乐服务",
"流程状态": "其他"
"申请日期": "2015-03-10",
"商标": "智驾",
"商标名称": "智驾及图",
"注册号": "12345678",
"类别": "第9类",
"流程状态": "已注册"
},
{
"申请日期": "2018-09-25",
"商标": "智因",
"商标名称": "智因及图",
"注册号": "23456789",
"类别": "第42类",
"流程状态": "已注册"
}
],
"专利信息": [
{
"申请日": "2017-08-18",
"专利名称": "一种双层耐磨鞋底及其加工工艺",
"申请日": "2016-07-01",
"专利名称": "一种基于机器视觉的缺陷检测方法",
"专利类型": "发明专利",
"专利状态": "实质审查",
"申请号": "CN202211735107.1",
"公开(公布)号": "CN116076831A",
"公开(公布)日": "2023-05-09",
"发明人": "吴荣照、黄茂盛、何芳、文明"
"专利状态": "已授权",
"申请号": "201610123456.X",
"公开号": "105123456",
"公开日": "2018-01-15",
"发明人": "刘敏,王红,赵勇"
},
{
"申请日": "2020-03-10",
"专利名称": "一种工业机器人控制系统",
"专利类型": "实用新型专利",
"专利状态": "已授权",
"申请号": "202020123456.X",
"公开号": "209876543",
"公开日": "2020-09-01",
"发明人": "李军,孙强"
}
],
"软件著作权": [
{
"批准日期": "2023-02-17",
"软件全称": "数字自然公园保护信息系统",
"软件简称": "-",
"登记号": "2023SR0256130",
"分类号": "-",
"版本号": "V1.0"
"批准日期": "2019-06-15",
"软件全称": "智驾车间管理系统软件",
"软件简称": "智驾管理系统",
"登记号": "2019SR0987654",
"分类号": "D063.92",
"版本号": "V1.5"
},
{
"批准日期": "2021-11-01",
"软件全称": "智因工业软件集成平台",
"软件简称": "智因平台",
"登记号": "2021SR6543210",
"分类号": "D063.4",
"版本号": "V2.0"
}
],
"主要供应商情况": [
{
"供应商名称": "北京成城众信科技有限公司",
"主工采购产品种类": "*",
"年平均采购额(万)": "125.84"
"序号": "1",
"供应商名称": "南京智盟电子科技有限公司",
"当年采购额": "5200000"
},
{
"序号": "2",
"供应商名称": "上海科锐智能装备有限公司",
"当年采购额": "8100000"
}
],
"主要客户情况": [
{
"序号": "1",
"客户名称": "江苏沃尔核材料有限公司",
"当年销售金额": "11500000"
},
{
"序号": "2",
"客户名称": "南京中车浦镇车辆有限公司",
"当年销售金额": "9800000"
}
],
"招投标情况": [
{
"发布时间": "2017-07-18",
"标题": "城中区2014年标准化结余资金采购项目(包二)复审中标公告中标公告",
"采购人": "城中教育局"
"发布时间": "2023-01-05",
"标题": "某航空公司生产车间机器视觉检测系统采购项目",
"采购人": "中航工业集团"
},
{
"发布时间": "2023-03-18",
"标题": "某电子厂机器人自动化生产线集成项目",
"采购人": "海信视像科技集团"
}
],
"主要财务数据": {
"2020年": {
"货币资金": "50000",
"应收账款": "20000",
"其他应收款": "10000",
"预付账款": "5000",
"存货": "30000",
"流动资产合计": "105000",
"非流动资产合计": "20000",
"固定资产原价": "50000",
"减:累计折旧": "20000",
"固定资产净额": "30000",
"固定资产总计": "30000",
"无形资产及其他资产合计": "5000",
"资产合计": "130000",
"短期借款": "10000",
"应付票据": "5000",
"应付账款": "20000",
"预收账款": "5000",
"应付利息": "1000",
"其他应付款": "10000",
"流动负债合计": "41000",
"长期借款": "20000",
"应付债券": "0",
"非流动负债合计": "20000",
"负债合计": "61000",
"未分配利润": "69000",
"所有者权益合计": "69000"
"竞争对手": [
{
"竞争对手": "南京智能系统集成有限公司",
"同业竞品": "智能制造系统集成解决方案"
},
"2021年": {
"货币资金": "70000",
"应收账款": "30000",
"其他应收款": "15000",
"预付账款": "8000",
"存货": "40000",
"流动资产合计": "163000",
"非流动资产合计": "25000",
"固定资产原价": "60000",
"减:累计折旧": "25000",
"固定资产净额": "35000",
"固定资产总计": "35000",
"无形资产及其他资产合计": "10000",
"资产合计": "188000",
"短期借款": "15000",
"应付票据": "8000",
"应付账款": "30000",
"预收账款": "10000",
"应付利息": "2000",
"其他应付款": "15000",
"流动负债合计": "62000",
"长期借款": "30000",
"应付债券": "0",
"非流动负债合计": "30000",
"负债合计": "92000",
"未分配利润": "96000",
"所有者权益合计": "96000"
{
"竞争对手": "苏州润智数字科技有限公司",
"同业竞品": "工业软件开发及系统集成服务"
}
],
"股权出质": [
{
"公示日期": "2020-08-10",
"登记编号": "123456789",
"出质人出质股权标的企业": "张伟/江苏智能科技有限公司",
"出质股权数额": "20%",
"状态": "有效"
}
],
"质押明细": [
{
"质押笔数": "1",
"质押股数": "4000000",
"质押比例": "20%",
"质押市值": "16000000"
}
],
"工商信用记录": "诚信经营,无不良记录",
"海关信用记录": "进出口信用良好",
"税务信用记录": "依法纳税,无欠税情况",
"银行信用记录": "信用记录良好,无不良记录",
"法院信用记录": "无涉诉情况",
"生产安全信息": "严格执行国家安全生产法律法规,建立健全安全生产管理制度和操作规程,定期开展安全生产教育培训。近三年未发生重大安全生产事故。",
"社会责任实施": "热心公益事业,积极参与社区建设,组织员工志愿者开展环保、扶贫、助残等公益活动。连续多年获评文明单位称号。",
"被执行人": [
{
"案号": "(2021)苏01执758号",
"执行标的": "180000元",
"执行法院": "南京市浦口区人民法院",
"立案日期": "2021-06-15"
}
],
"历史失信被执行人": 0,
"历史被执行人": 0,
"历史限制消费令": 0,
"主要财务数据": {
"2023年": {
"流动资产": "68920000",
"固定资产": "28510000",
"长期股权投资": "5680000",
"资产总计": "117930000",
"流动负债": "39650000",
"非流动负债": "12960000",
"负债合计": "52610000",
"实收资本": "20000000",
"资本公积金": "15000000",
"盈余公积金": "4870000",
"未分配利润": "25450000",
"营业总收入": "152760000",
"营业总成本": "122000000",
"营业利润": "18950000",
"利润总额": "19670000",
"净利润": "16750000",
"销售商品提供劳务收到的现金": "143890000",
"经营活动现金净流量": "30175000",
"购建固定无形长期资产支付的现金": "9650000",
"投资支付的现金": "2180000",
"投资活动现金净流量": "-11830000",
"筹资活动现金净流量": "-5725000"
},
"2022年": {
"货币资金": "90000",
"应收账款": "40000",
"其他应收款": "20000",
"预付账款": "10000",
"存货": "50000",
"流动资产合计": "210000",
"非流动资产合计": "30000",
"固定资产原价": "70000",
"减:累计折旧": "30000",
"固定资产净额": "40000",
"固定资产总计": "40000",
"无形资产及其他资产合计": "15000",
"资产合计": "240000",
"短期借款": "20000",
"应付票据": "10000",
"应付账款": "40000",
"预收账款": "15000",
"应付利息": "3000",
"其他应付款": "20000",
"流动负债合计": "78000",
"长期借款": "40000",
"应付债券": "0",
"非流动负债合计": "40000",
"负债合计": "118000",
"未分配利润": "122000",
"所有者权益合计": "122000"
"流动资产": "68920000",
"固定资产": "28510000",
"长期股权投资": "5680000",
"资产总计": "117930000",
"流动负债": "39650000",
"非流动负债": "12960000",
"负债合计": "52610000",
"实收资本": "20000000",
"资本公积金": "15000000",
"盈余公积金": "4870000",
"未分配利润": "25450000",
"营业总收入": "152760000",
"营业总成本": "122000000",
"营业利润": "18950000",
"利润总额": "19670000",
"净利润": "16750000",
"销售商品提供劳务收到的现金": "143890000",
"经营活动现金净流量": "30175000",
"购建固定无形长期资产支付的现金": "9650000",
"投资支付的现金": "2180000",
"投资活动现金净流量": "-11830000",
"筹资活动现金净流量": "-5725000"
},
"2021年": {
"流动资产": "51280000",
"固定资产": "27930000",
"长期股权投资": "1560000",
"资产总计": "95160000",
"流动负债": "28760000",
"非流动负债": "7850000",
"负债合计": "36610000",
"实收资本": "20000000",
"资本公积金": "10000000",
"盈余公积金": "3460000",
"未分配利润": "25090000",
"营业总收入": "129400000",
"营业总成本": "105600000",
"营业利润": "15820000",
"利润总额": "16530000",
"净利润": "14150000",
"销售商品提供劳务收到的现金": "118720000",
"经营活动现金净流量": "23475000",
"购建固定无形长期资产支付的现金": "5970000",
"投资支付的现金": "960000",
"投资活动现金净流量": "-6930000",
"筹资活动现金净流量": "-7450000"
}
}
}
},
"主要财务指标分析": {
"2023年": {
"净资产收益率": "18.35%",
"总资产收益率": "14.21%",
"销售毛利率": "26.75%",
"资产负债率": "44.59%",
"总资产周转率": "1.30",
"销售商品和劳务收到现金营业收入": "94.22%"
},
"2022年": {
"净资产收益率": "18.35%",
"总资产收益率": "14.21%",
"销售毛利率": "26.75%",
"资产负债率": "44.59%",
"总资产周转率": "1.30",
"销售商品和劳务收到现金营业收入": "94.22%"
},
"2021年": {
"净资产收益率": "19.28%",
"总资产收益率": "14.84%",
"销售毛利率": "25.18%",
"资产负债率": "38.47%",
"总资产周转率": "1.36",
"销售商品和劳务收到现金营业收入": "91.73%"
}
},
"优化提升建议": "1.继续保持研发投入,加强核心技术积累;2.加大市场开拓力度,拓展国际市场;3.加强内部管理,提高生产效率。",
"企业信用等级评价评审报告结论": "根据上述分析示例公司的信用等级为AA。"
}

Binary file not shown.

Binary file not shown.

View File

27
Utils/OpenaiUtils/api.py Normal file
View File

@ -0,0 +1,27 @@
from openai import OpenAI
import os
# 获取环境变量中的 OpenAI API 密钥
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
client = OpenAI(
base_url="https://api.chatgptid.net/v1",
api_key="sk-gsCcEZI5vSy6yE4M26650f1149104e0f82A571C82f0f3809"
)
def get_openai_response(prompt):
# 使用新的 API 接口
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": prompt}
]
)
# 打印完整响应和生成的文本
if response.choices:
return response.choices[0].message.content
# 调用函数测试
# get_openai_response("如何描述一家企业的历史沿革?")

View File

@ -0,0 +1,7 @@
{
"历史沿革": "我正准备一份公司评级报告,需要对以下企业的历史沿革进行简洁、准确的总结。请根据提供的数据,概述公司的主要发展历程和重要里程碑,以便在报告的历史沿革模块中使用。注意 数字需保留两位小数并带上货币单位。",
"股权结构": "我正在准备一份公司评级报告,需要对以下企业的股权结构进行总结。请根据提供的数据,简明地概述公司的主要股东及其持股比例,以及这些股权分布如何影响公司的控制权和经营决策。",
"高管构成": "我正在为一份公司评级报告编写高管摘要,需要对上面数据中高管的个人资料进行简明、客观的总结。每位高管的总结应突出他们在当前职位中最重要的成就、经验和资质。请为每位高管提供适合纳入公司评级报告的结构化总结。",
"主要资质": "我正在编写一份公司评级报告,根据上面数据中企业的主要资质数据进行简洁且全面的总结。请根据提供的资质信息,总结出公司的核心优势和行业地位,以便在报告的企业资质模块中使用。",
"优化提升建议与报告结论": "我正在编写一份公司评级报告,需要根据上面提供的数据,生成给该公司评级报告中优化提升建议部分(100-200字)和企业信用等级评价评审报告结论部分的相关内容(200-300字),返回的内容请在段落开头缩进两个空格,并且用JSON键值对的形式返回,例如{优化提升建议: 优化提升建议,报告结论:相关描述}。我将用于评级报告,因此请避免不必要的详细描述。"
}

View File

@ -3,7 +3,7 @@ import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from App.Router import ReportRouter, ScoreRouter
from App.Router import ReportRouter, ScoreRouter, ReportV2Router
app = FastAPI(
title="中小商业企业信用评级",
@ -19,7 +19,7 @@ app.add_middleware(
)
app.include_router(ScoreRouter.router)
app.include_router(ReportRouter.router)
app.include_router(ReportV2Router.router)
if __name__ == '__main__':
uvicorn.run(app, host="0.0.0.0", port=8010)

View File

@ -1,15 +1,15 @@
uvicorn
docx==0.2.4
docxtpl==0.16.7
fastapi==0.100.1
fastapi==0.109.2
numpy==1.24.2
openpyxl==3.1.2
pandas==1.5.3
pydantic==1.10.9
pydantic==2.6.0
PyJWT==2.8.0
pymongo==4.3.3
requests==2.28.2
SQLAlchemy==2.0.0
pymongo==4.6.1
requests
SQLAlchemy
pymysql
python-multipart
xlwings==0.30.10
xlwings==0.30.13