main.py 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302
  1. import os
  2. from docx.shared import Pt
  3. import math
  4. import Levenshtein
  5. import json
  6. #采购文件有 pdf、doc、docx
  7. aaa = [['条款号', None, '评审因素', '评审标准', None],
  8. ['2.1.\n1', '形式评\n审标准', '报价人名称', '与营业执照、资质证书一致', None],
  9. [None, None, '报价函签字盖章', '有法定代表人或其委托代理人签字或加盖单位章', None],
  10. [None, None, '报价文件格式', '符合五章“报价文件格式”的要求', None],
  11. [None, None, '报价唯一', '只能有一个有效报价', None],
  12. ['2.1.\n2', '资格评\n审标准', '营业执照', '具备有效的营业执照', None],
  13. [None, None, '资质等级', '符合报价邀请函第3项规定', None],
  14. [None, None, '项目经理', '符合报价邀请函第3项规定', None],
  15. [None, None, '财务要求', '符合报价邀请函第3项规定', None],
  16. [None, None, '业绩要求', '符合报价邀请函第3项规定', None],
  17. [None, None, '其他要求', '符合报价邀请函第3项规定', None],
  18. [None, None, '评标价基准值计算方法', '以所有通过初步评审的投标人评标价算术平均值×0.97作为本次评审的评标价基准值B。并应满足计算规则:\n(1)当参与计算的投标人超过5家时去掉一个最高评标价和一个最低评标价;\n(2)当同一企业集团多家所属企业(单位)参与本项目投标时,取其中最低评标价参与评标价基准值计算,无论', None],
  19. [None, None, '', '该价格是否在步骤(1)中被筛选掉;\n(3)依据(1)、(2)规则计算B值后,如参与计算的投标人不少于3名,去掉评标价高于B值×130%(含)的评标价,重新按本步骤计算一轮B值。\n投标人评标价:指各投标人经算术错误修正后的投标报价(含增值税)。', None],
  20. ['2.1.\n3', '响应性\n评审\n标准', '报价', '符合采购文件规定', None],
  21. [None, None, '报价内容', '符合采购文件规定', None],
  22. [None, None, '服务期', '符合采购文件规定', None],
  23. [None, None, '报价有效期', '符合采购文件规定', None],
  24. [None, None, '报价保证金', '符合采购文件规定', None],
  25. [None, None, '权利义务', '符合第三章“合同条款及格式”规定', None],
  26. [None, None, '已标价的报价表', '符合采购文件规定', None],
  27. [None, None, '服务标准和要求', '符合采购文件规定', None],
  28. ['条款号', None, '条款内容', '编列内容', None],
  29. ['2.2.1', None, '评分权重构成(100%)', '商务部分:20%\n报价部分:30%\n技术部分:50%', None],
  30. ['2.2.2', None, '评审基准价计算方法', '所有初步评审合格的报价人中最低报价作为评审基\n准价。税率不一致时以不含税价作为报 价人评审价。', None],
  31. ['2.2.3', None, '报价的偏差率\n计算公式', '偏差率(Di)=100% ×(不含税报价−评审基准价)/\n评审基准价', None],
  32. ['条款号', None, '评分因素', '评分标准', '权重'],
  33. ['2.2.\n4(1)', '商务部\n分评分', '报价文件的完整性', '检查报价文件在内容与项目上的完整性,针\n对报价人提出的非实质性商务偏差,评价其', '3%'],
  34. ['', '标准\n(20%)', '', '是否合理,是否会损害采购人的利益和未来\n的合同执行。评分结果分为A~D四个档次。', ''],
  35. [None, None, '信用评价', '根据三峡集团公司最新发布的年度供应商\n信用评价结果进行统一评分,A、B、C三个\n等级信用得分分别 为100、85、70分。如报\n价人初次进入三峡集团公司报价,由评审小\n组根据其以往业绩及在其他单位的合同履\n约情况合理确定本次 评审信用等级。', '3%'],
  36. [None, None, '财务状况', '评价报价人财务状况。评分结果分为A~D\n四个档次。', '1%'],
  37. [None, None, '业绩', '结合本项目的要求对投标人提供的历史业\n绩进行评价(相似度\\可借鉴性\\维护作业经\n验\\业绩数量)。评分结果分为A~D四个\n档次', '10%'],
  38. [None, None, '报价的合理性', '对主要报价进行合理性评审。评分结果分为\nA~D四个档次。', '3%'],
  39. ['2.2.\n4(2)', '报价评\n分标准\n(30%)', '价格得分', '满足谈判文件要求且最终报价最低的供应\n商的价格为评审基准价,其价格 分为满分。\n其他供应商的价格分统一按照下列公式计\n算:\n报价得分=(评审基准价÷最后报价)×价\n格权值×100', '30%'],
  40. ['2.2.\n4(3)', '技术部\n分评分\n标准\n(50%)', '资源配置', '1、管理人员配置;\n2、专业技术人员配置;\n3、其它资源配置。\n评分结果分为A~D四个档次。', '25%'],
  41. [None, None, '实施方案', '1、整体施工方案及对本项目的重难点分析;\n2、施工程序及进度保障措施;\n3、质量保障措施;\n4、安全文明施工计划。\n评分结果分为A~D四个档次。', '20%'],
  42. [None, None, '应急保障能力', '1、列明项目实施中可能出现的突发事件及\n相应的应急措施;\n2、应急响应时效及相应的保障措施。\n评分结果分为A~D四个档次。', '5%']]
  43. keys = ['形式评', '资格评', '响应性', '商务部', '报价评', '技术部']
  44. #评审因素
  45. index_list = []
  46. _aaa = []
  47. for i in range(len(aaa)):
  48. a = aaa[i]
  49. if a[1] and a[1].split('\n')[0] in keys:
  50. index_list.append(i)
  51. if a[0] == '条款号':
  52. continue
  53. if a[-1] and a[-1] and i < len(aaa) - 1 and aaa[i+1][-1] == '': #not a[3][-2:] in ['规定', '档次', '次。'] and len(index_list) > 2:
  54. #print(a, aaa[i+1])
  55. for j in range(len(a)):
  56. try:
  57. aaa[i][j] = aaa[i][j] + aaa[i+1][j]
  58. aaa[i+1][j] = ''
  59. except:
  60. pass
  61. if a[2] and a[2] and i < len(aaa) - 1 and aaa[i+1][2] == '':
  62. for j in range(len(a)):
  63. try:
  64. aaa[i][j] = aaa[i][j] + aaa[i+1][j]
  65. aaa[i+1][j] = ''
  66. except:
  67. pass
  68. for i in range(len(aaa)):
  69. falg = 0
  70. for j in range(len(aaa[i])):
  71. if aaa[i][j]:
  72. falg = 1
  73. break
  74. if falg == 0:
  75. continue
  76. print(aaa[i])
  77. print(index_list)
  78. #采购文件
  79. #跨页表格合并
  80. #1、上下内容合并
  81. #2、缺失项合并
  82. # 第3列、第5列 重新为空的,但是上一行不为空的大概率需要做2行合并操作
  83. #采购文件-报价模板
  84. #技术规范
  85. #工作量区域定位
  86. #技术规范 的工作量清单数据抽取
  87. #表头信息?
  88. #报价功能项 结构化数据抽取
  89. #
  90. #工作量表头需要固定死 ["序号","项目名称","工作内容","单位","数量","规格"]
  91. aaa = [["水轮发电机组11", None, None, None, None, None],
  92. ["序号","项目名称","工作内容","单位","数量","备 注"],
  93. ["水轮发电机组", None, None, None, None, None],
  94. ["1","水轮发电机组并网监测及同期过程状态评价理论体系和算法研究","内容包括:1)水轮发电机组开机过程动态性能评估体系及算法研究,提交报告1份;2)水轮发电机组同期过程状态评价体系及算法研究,提交报告1份;3)水轮发电机组在网监测体系及算法研究,提交报告1份;具体要求详见6.2.1。","项","1"],
  95. ["2","硬件装置制作","硬件装置为定制设备,安装在盘柜内,嵌入式安装;硬件装置主要由信号采集单元、主控制器单元、人机接口单元和应用接口单元组成;具体要求见6.2.2。","项","1",""],
  96. ["3","工程师站采购","笔记本式工作站,工程师站承担硬件装置开发应用和高级应用两个功能。具体要求见6.2.3。","项","1",""],
  97. ["4","嵌入式软件开发及测试","嵌入式软件是在硬件装置上独立运行,包括数据采集处理、存储、显示、传输等功能;具体要求见6.2.2。","项","1",""],
  98. ["5","高级应用开发及测试","高级应用软件应包含硬件装置的全部数据存储和显示功能以及相应工况的高级应用分析报表功能;相应工况的高级应用分析报表功能包括但不限于水轮发电机组开机过程动态性能分析及报表功能、水轮发电机组同期过程状态评价及报表功能、水轮发电机组在网性能监测分析及报表功能;具体要求见6.2.3。","项","1", '']]
  99. aaa1 = [["序号","项目名称","对应表格","产品价格","含税价"],
  100. ["1","电源电站直流系统(共1套)","表1.1","",""],
  101. ["2","右岸电站机组直流系统(共4套)","表1.2×4","",""],
  102. ["3","右岸电站公用直流系统(共1套)","表1.3","",""],
  103. ["4","右岸电站光纤接口设备直流系统(共1套)","表1.4","",""],
  104. ["5","地下电站GIS直流配电柜(共1套)","表1.5","",""],
  105. ["6","地下电站公用直流配电及UPS柜(共1套)","表1.6","",""],
  106. ["7","蓄电池组","表1.7","",""],
  107. ["8","其他项目","表1.8","",""],
  108. ["","总结", None,"", ""]]
  109. #备注列向左新增2列,分别为费用综合单价、合计
  110. #新增一行 合计,
  111. # 报价清单生成
  112. def quotation_table(workload_table, project_name):
  113. if workload_table:
  114. for i in range(1, len(workload_table)):
  115. _flag_length = len(workload_table[i])
  116. for j in range(_flag_length, len(workload_table[0])):
  117. if workload_table[i][-1] == None:
  118. workload_table[i].append(None)
  119. else:
  120. workload_table[i].append('')
  121. # print(len(workload_table))
  122. beg = -1
  123. for i in range(len(workload_table)):
  124. if '序号' in workload_table[i]:
  125. beg = i
  126. break
  127. if beg == -1:
  128. return [], []
  129. if '备注' in workload_table[beg]:
  130. _index = workload_table[beg].index('备注')
  131. else:
  132. _index = len(workload_table[beg]) - 1
  133. sub_total_flag = 0
  134. unit_price_flag = 0
  135. for i in range(len(workload_table[beg])):
  136. if '合价' in workload_table[beg][i] or '含税价' in workload_table[beg][i] :
  137. sub_total_flag = 1
  138. _index = i
  139. break
  140. if sub_total_flag == 0:
  141. workload_table[beg].insert(_index, '含税合价(元)')
  142. # print(_index)
  143. for j in range(beg+1, len(workload_table)):
  144. # print(workload_table[j])
  145. # print(j, workload_table[j][_index], workload_table[j][_index-1])
  146. if workload_table[j][_index] == None or (workload_table[j][_index] == workload_table[j][_index-1] and workload_table[j][_index]):
  147. workload_table[j].insert(_index, workload_table[j][_index])
  148. else:
  149. workload_table[j].insert(_index, '')
  150. for j in range(0, beg):
  151. # print(workload_table[j])
  152. # print(j, workload_table[j][_index], workload_table[j][_index-1])
  153. if workload_table[j][_index] == None or (workload_table[j][_index] == workload_table[j][_index-1] and workload_table[j][_index]):
  154. workload_table[j].insert(_index, workload_table[j][_index])
  155. else:
  156. workload_table[j].insert(_index, '')
  157. for i in range(len(workload_table[beg])):
  158. if '单价' in workload_table[beg][i] or '产品价格' in workload_table[beg][i]:
  159. unit_price_flag = i
  160. _index = i
  161. break
  162. if unit_price_flag == 0:
  163. workload_table[beg].insert(_index, '含税单价(元)')
  164. for j in range(beg+1, len(workload_table)):
  165. if workload_table[j][_index] == None or (workload_table[j][_index] == workload_table[j][_index-1] and workload_table[j][_index]):
  166. workload_table[j].insert(_index, workload_table[j][_index])
  167. else:
  168. workload_table[j].insert(_index, '')
  169. for j in range(0, beg):
  170. if workload_table[j][_index] == None or (workload_table[j][_index] == workload_table[j][_index-1] and workload_table[j][_index]):
  171. workload_table[j].insert(_index, workload_table[j][_index])
  172. else:
  173. workload_table[j].insert(_index, '')
  174. unit_price_flag = workload_table[beg].index('含税单价(元)')
  175. # print(_index, workload_table[0])
  176. total_array = ["合计:"]
  177. for i in range(beg+1, unit_price_flag):
  178. total_array.append(None)
  179. total_array.append("")
  180. for i in range(unit_price_flag+1, len(aaa[0])):
  181. total_array.append(None)
  182. workload_table.append(total_array)
  183. else:
  184. workload_table = []
  185. table_head = ["序号","项目名称","工作内容","单位","数量", '含税单价(元)', '含税合价(元)',"备注"]
  186. unit_price_flag = table_head.index('含税单价(元)')
  187. workload_table.append(table_head)
  188. for i in range(1,6):
  189. table_rows = [str(i)]
  190. for j in range(1,len(table_head)):
  191. table_rows.append('')
  192. workload_table.append(table_rows)
  193. total_array = ["合计:"]
  194. for i in range(1, unit_price_flag):
  195. total_array.append(None)
  196. total_array.append("")
  197. # print(unit_price_flag)
  198. for i in range(unit_price_flag+1, len(table_head[0])):
  199. total_array.append(None)
  200. workload_table.append(total_array)
  201. # print(aaa)
  202. table_1 = [["序号","项目名称","不含税合价(元)","税率(%)","增值税额(元)","含税总价(元)","备注"],["1", project_name, "", "", "", "", ""],["总报价:",None,None,None,None,"",""]]
  203. return table_1, workload_table
  204. #
  205. # 表标题或者表格前标题:工程量清单、材料清单、工作量清单、报价明细表、主要配置(含备品备件、专用工器具)
  206. # 表头:费用、单价、价格、含税价、单价、合价、估算工程量、单位
  207. table_1, workload_table = quotation_table(aaa, '水轮发电机组维修')
  208. print(table_1, workload_table)
  209. from docx import Document
  210. # 加载现有的Word文档
  211. doc = Document()
  212. # 添加一个表格,3行4列
  213. r = len(table_1)
  214. c = len(table_1[0])
  215. doc.add_heading('表1 报价汇总表',level=3)
  216. table = doc.add_table(rows=r, cols=c)
  217. # 设置表格样式(可选)
  218. table.style = 'Table Grid'
  219. # 填充表格数据
  220. data = table_1
  221. # 将数据填入表格
  222. for row_idx, row_data in enumerate(data):
  223. row = table.rows[row_idx]
  224. y = 0
  225. for col_idx, cell_data in enumerate(row_data):
  226. if row_data[col_idx] == None:
  227. table.cell(row_idx, y).merge(table.cell(row_idx, col_idx))
  228. else:
  229. cell = row.cells[col_idx]
  230. cell.text = cell_data
  231. y = col_idx
  232. # 添加一个表格,3行4列
  233. r = len(workload_table)
  234. c = len(workload_table[0])
  235. doc.add_paragraph("\n")
  236. doc.add_heading('表2 分项报价表',level=3)
  237. table = doc.add_table(rows=r, cols=c)
  238. # 设置表格样式(可选)
  239. table.style = 'Table Grid'
  240. # 填充表格数据
  241. data = workload_table
  242. # 遍历每个cell,设置宽度
  243. for row_idx in range(r):
  244. for col_idx in range(c):
  245. if col_idx in [1, 2, 3]:
  246. row = table.rows[row_idx]
  247. cell = row.cells[col_idx]
  248. cell.width = Pt(100) # 设置宽度为100磅
  249. if col_idx in [0]:
  250. row = table.rows[row_idx]
  251. cell = row.cells[col_idx]
  252. cell.width = Pt(20) # 设置宽度为20磅
  253. # 将数据填入表格
  254. for row_idx, row_data in enumerate(data):
  255. row = table.rows[row_idx]
  256. y = 0
  257. for col_idx, cell_data in enumerate(row_data):
  258. if row_data[col_idx] == None:
  259. table.cell(row_idx, y).merge(table.cell(row_idx, col_idx))
  260. else:
  261. cell = row.cells[col_idx]
  262. cell.text = cell_data
  263. y = col_idx
  264. # 保存文档
  265. doc.save('example.docx')
  266. import openpyxl
  267. #分项工程和单价
  268. #分部分项工程和单价措施项目清单与计价表
  269. #本页小计、分部小计、合计
  270. #全费用综合单价分析表
  271. #小计、未计价材料费、清单全费用综合单价
  272. #详细评审
  273. # 商务部分
  274. # 报价抽取 # 报价信息
  275. # 业绩定位及抽取 # 近年类似项目业绩
  276. # 财务状况定位及抽取 # 近年财务状况表
  277. # 业绩
  278. # 报价的合理性
  279. # 技术部分
  280. #
  281. #报价得分计算
  282. #demo
  283. aaa = """
  284. 当0<Di≤3%时,每高1%扣1分;
  285. 当3%<Di≤6%时,每高1%扣1.5分;
  286. 当6%<Di,每高1%扣2分;
  287. 当-3%<Di≤0时,不扣分;
  288. 当-6%<Di≤-3%时,每低1%扣0.5分;
  289. 当-9%<Di≤-6%时,每低1%扣1分;
  290. 当Di≤-9%时,每低1%扣1.5分;
  291. 满分为100分,最低得60分。
  292. """
  293. aaa = """
  294. 报价得分=(评审基准价÷最终报价)×100
  295. """
  296. import re
  297. #评标价算术平均值\评审价最低价与次低价算术平均值\最低评审价
  298. #去掉一个最高评标价和一个最低评标价
  299. #去掉评审价高于B值
  300. #demo
  301. aaa1 = """以所有通过初步评审的评审价最低价与次低价算术平均值×0.97作为本次评审的评标价基准值B。
  302. 并应满足计算规则:
  303. (1)当参与计算的投标人超过5家时去掉一个最高评标价和一个最低评标价;
  304. (2)当同一企业集团多家所属企业(单位)参与本项目投标时,取其中最低评标价参与评标价基准值计算,无论该价格是否在步骤(1)中被筛选掉;
  305. 评标价为经算术错误修正后的投标报价(不含增值税)。
  306. (3)依据(1)、(2)规则计算B值后,如参与计算的报价人不少于3名,去掉评审价高于B值×130%(含)的评标价,重新按本步骤计算B值。本步骤仅计算一次。"""
  307. aaa = """
  308. 当0<Di≤3%时,每高1%扣1分;
  309. 当3%<Di≤6%时,每高1%扣1.5分;
  310. 当6%<Di,每高1%扣2分;
  311. 当-3%<Di≤0时,不扣分;
  312. 当-6%<Di≤-3%时,每低1%扣0.5分;
  313. 当-9%<Di≤-6%时,每低1%扣1分;
  314. 当Di≤-9%时,每低1%扣1.5分;
  315. 满分为100分,最低得60分。"""
  316. #基准值计算方式
  317. def reference_value(datas, key_word):
  318. if key_word == '评标价算术平均值':
  319. value = sum(datas)/len(datas)
  320. elif key_word == '评审价最低价与次低价算术平均值':
  321. total_list.sort()
  322. value = sum(datas[:2])/2.0
  323. elif key_word == '最低评审价':
  324. value = min(datas)
  325. else:
  326. value = min(datas)
  327. # print(datas, value)
  328. return value
  329. import copy
  330. total_list = [95,93,92,90,99,117,119]
  331. #基准值计算
  332. def reference_value_count(total_list, aaa):
  333. total_list_new = copy.copy(total_list)
  334. coefficient_data = 1.0
  335. reference_word = '最低评审价'
  336. aaa = re.sub('\n', '', aaa)
  337. aaa = re.sub('。|;|;', '\n', aaa)
  338. for a in aaa.split('\n'):
  339. # print('coefficient_data', coefficient_data)
  340. if re.findall('^当', a) and re.findall('\d%', a):
  341. break
  342. B_data = re.findall('评标价算术平均值|评审价最低价与次低价算术平均值|最低评审价', a)
  343. if B_data:
  344. reference_word = B_data[0]
  345. coefficient = re.findall('\d\.?\d*', a)
  346. if coefficient:
  347. coefficient_data = float(coefficient[0])
  348. value = reference_value(total_list, reference_word)
  349. value = value * coefficient_data
  350. if re.findall('去掉一个最高评标价和一个最低评标价', a):
  351. num_list = re.findall('超过\d+家时', a)
  352. if not num_list:
  353. num = 5
  354. else:
  355. num = int(num_list[0][2:-2])
  356. if len(total_list) >= num:
  357. total_list.sort()
  358. # print(total_list)
  359. total_list = total_list[1:-1]
  360. value = reference_value(total_list, reference_word)
  361. value = value * coefficient_data
  362. elif re.findall('去掉评审价高于B值', a):
  363. num_word = re.findall('\d+%', a)
  364. num_data = 130
  365. if num_list:
  366. num_data = int(num_word[0][:-1])
  367. num_list = re.findall('不少于\d名', a)
  368. if not num_list:
  369. num = 3
  370. else:
  371. num = int(num_list[0][3:-1])
  372. value_new = value * num_data/100
  373. # print('x'*10, value, value_new)
  374. new_total_list = []
  375. if len(total_list) >= num:
  376. # print(value_new)
  377. for i in range(len(total_list)):
  378. if total_list[i] > value_new:
  379. continue
  380. new_total_list.append(total_list[i])
  381. value = reference_value(new_total_list, reference_word)
  382. value = value * coefficient_data
  383. # print(value)
  384. try:
  385. value
  386. except:
  387. value = reference_value(total_list, "评标价算术平均值")
  388. return value
  389. #计算每多或少一个百分百扣分多少
  390. def score_dict_count(aaa):
  391. score_json = {}
  392. aaa = re.sub('\n', '', aaa)
  393. aaa = re.sub('。|;|;', '\n', aaa)
  394. for a in aaa.split('\n'):
  395. if not a:
  396. continue
  397. if re.findall('^报价得分=(评审基准价÷最终报价)', a):
  398. for i in range(-100, 100):
  399. score_json[i] = 1
  400. score_json[0] = 1
  401. break
  402. if not re.findall('^[当满]', a):
  403. continue
  404. num_list = re.findall('0|-?\d+%', a.split(',')[0])
  405. score = re.findall('\d\.?\d*分', a.split(',')[1])
  406. if num_list[0] == '0':
  407. num_list[0] = 0
  408. else:
  409. num_list[0] = int(num_list[0][:-1])
  410. if len(num_list) > 1:
  411. if num_list[1] == '0':
  412. num_list[1] = 0
  413. else:
  414. num_list[1] = int(num_list[1][:-1])
  415. else:
  416. if num_list[0] < 0:
  417. num_list.append(-100)
  418. num_list[1] = num_list[0]
  419. num_list[0] = -100
  420. else:
  421. num_list.append(100)
  422. if not score:
  423. score = 0
  424. else:
  425. score = float(score[0][:-1])
  426. for x in range(num_list[0]+1, num_list[1]+1):
  427. #print(x)
  428. score_json[x] = score
  429. #print(num_list, score)
  430. min_score_flag = re.findall('最低得\d+分', str(aaa))
  431. if min_score_flag:
  432. min_score_flag = float(re.findall('\d+', min_score_flag[0])[0])
  433. else:
  434. min_score_flag = 60.0
  435. print(score_json)
  436. return score_json, min_score_flag
  437. B = 95
  438. A = 105
  439. #单个企业报价得分
  440. def company_score(A, B, score_json, min_score_flag):
  441. ratio = (A-B)/B*100
  442. sum_score = 0
  443. # print(ratio)
  444. if ratio < 0:
  445. for i in range(int(ratio), 0+1):
  446. sum_score = sum_score + score_json[i]
  447. else:
  448. for i in range(0, int(ratio) + 1):
  449. sum_score = sum_score + score_json[i]
  450. # print(A,B, sum_score)
  451. sum_score = 100.0 - sum_score
  452. if sum_score < min_score_flag:
  453. sum_score = min_score_flag
  454. # print(A,B, sum_score)
  455. return sum_score
  456. score_json, min_score_flag = score_dict_count(aaa)
  457. company_score(A, B, score_json, min_score_flag)
  458. company_score(97, B, score_json, min_score_flag)
  459. company_score(136, B, score_json, min_score_flag)
  460. company_score(B, B, score_json, min_score_flag)
  461. value = reference_value_count(total_list, aaa1)
  462. company_list = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
  463. print('x'*20, value)
  464. for i in range(len(company_list)):
  465. print('投标人'+company_list[i], '报价部分得分为', company_score(total_list[i], value, score_json, min_score_flag))
  466. # 索引表
  467. # 商务、技术评审因素在标书页码位置区域
  468. # 标书标题抽取;
  469. # 评审因素与标书标题一一对应。
  470. # 采购文件->投标人资格要求及评审因素信息抽取,带星★条款获取
  471. # 一一定位
  472. # 投标人名称 -> 资格、资质证书
  473. # 报价函 -> 报价函、投标函
  474. # 业绩 -> 近年类似项目业绩
  475. # 财务要求 -> 审计报告、财务状况表
  476. # 信誉要求 -> 供应商信用评价、信用评价
  477. # 信用 -> 供应商信用评价、信用评价
  478. # 投标人资质 -> 资格、资质
  479. # 项目经理 -> 主要负责人、项目经理、项目业绩、项目经验、项目经历
  480. # 投标报价 -> 工程量报价
  481. #
  482. # 目录
  483. # 评分索引表、评分对照表、索引表 #不同评审因素对应页面
  484. CN_NUM = {
  485. '〇' : 0, '一' : 1, '二' : 2, '三' : 3, '四' : 4, '五' : 5, '六' : 6, '七' : 7, '八' : 8, '九' : 9, '零' : 0,
  486. '壹' : 1, '贰' : 2, '叁' : 3, '肆' : 4, '伍' : 5, '陆' : 6, '柒' : 7, '捌' : 8, '玖' : 9, '貮' : 2, '两' : 2,
  487. }
  488. CN_UNIT = {
  489. '十' : 10,
  490. '拾' : 10,
  491. '百' : 100,
  492. '佰' : 100,
  493. '千' : 1000,
  494. '仟' : 1000,
  495. '万' : 10000,
  496. '萬' : 10000,
  497. '亿' : 100000000,
  498. '億' : 100000000,
  499. '兆' : 1000000000000,
  500. }
  501. #大写转数字
  502. def chinese_to_arabic(cn:str) -> int:
  503. if len(re.findall('\d', cn)) == len(cn):
  504. return int(cn)
  505. #print(type(cn), cn)
  506. unit = 0 # current
  507. ldig = [] # digest
  508. for cndig in reversed(cn):
  509. if cndig in CN_UNIT:
  510. unit = CN_UNIT.get(cndig)
  511. if unit == 10000 or unit == 100000000:
  512. ldig.append(unit)
  513. unit = 1
  514. else:
  515. dig = CN_NUM.get(cndig)
  516. if unit:
  517. dig *= unit
  518. unit = 0
  519. ldig.append(dig)
  520. if unit == 10:
  521. ldig.append(10)
  522. val, tmp = 0, 0
  523. #print(ldig)
  524. for x in reversed(ldig):
  525. #print('x',x)
  526. if x == 10000 or x == 100000000:
  527. val += tmp * x
  528. tmp = 0
  529. else:
  530. tmp += x
  531. val += tmp
  532. return val
  533. # 读取目录
  534. # def get_directory():
  535. # line = open('data_1.json', 'r', encoding='utf-8').read()
  536. json_data = {"calMethod": """
  537. 当0<Di≤3%时,每高1%扣1分;
  538. 当3%<Di≤6%时,每高1%扣1.5分;
  539. 当6%<Di,每高1%扣2分;
  540. 当-3%<Di≤0时,不扣分;
  541. 当-6%<Di≤-3%时,每低1%扣0.5分;
  542. 当-9%<Di≤-6%时,每低1%扣1分;
  543. 当Di≤-9%时,每低1%扣1.5分;
  544. 满分为100分,最低得60分。""",
  545. "scoreWeight":"30%",
  546. "quoteRes": [
  547. {
  548. "proNum": "序号",
  549. "projectName": "资料收集及整理",
  550. "unit": "项",
  551. "quantity": "14.76",
  552. "suppliers": [
  553. {
  554. "name": "供应商A",
  555. "taxRate": "13%",
  556. "supplier": {
  557. "finalQuote": {
  558. "unitPrice": "875.00",
  559. "totalPrice": "12915.00"
  560. },
  561. "taxCompareRes": {
  562. "theoryValue": "12915.00",
  563. "deviation": "0.00"
  564. },
  565. "finalExcludeTaxPrice": {
  566. "unitPrice": "774.34",
  567. "totalPrice": "11429.20"
  568. }
  569. }
  570. },
  571. {
  572. "name": "供应商B",
  573. "taxRate": "13%",
  574. "supplier": {
  575. "finalQuote": {
  576. "unitPrice": "672.00",
  577. "totalPrice": "9918.72"
  578. },
  579. "taxCompareRes": {
  580. "theoryValue": "9918.72",
  581. "deviation": "0.00"
  582. },
  583. "finalExcludeTaxPrice": {
  584. "unitPrice": "594.69",
  585. "totalPrice": "8777.63"
  586. }
  587. }
  588. },
  589. {
  590. "name": "供应商C",
  591. "taxRate": "9%",
  592. "supplier": {
  593. "finalQuote": {
  594. "unitPrice": "800.00",
  595. "totalPrice": "11808.00"
  596. },
  597. "taxCompareRes": {
  598. "theoryValue": "11808.00",
  599. "deviation": "0.00"
  600. },
  601. "finalExcludeTaxPrice": {
  602. "unitPrice": "733.94",
  603. "totalPrice": "10833.03"
  604. }
  605. }
  606. }
  607. ]
  608. }
  609. ],
  610. "calQuoteRes": {
  611. "avgPrice": "3270233.96",
  612. "benchmarkPrice": "3270233.96",
  613. "suppliers": [
  614. {
  615. "name": "供应商A",
  616. "supplier": {
  617. "taxIncludedTotal": "3913250.00",
  618. "taxExcludedTotal": "3691745.28",
  619. "deviationRate": "12.889%",
  620. "score": "70.333",
  621. "finalScore": "21.10"
  622. }
  623. },
  624. {
  625. "name": "供应商B",
  626. "supplier": {
  627. "taxIncludedTotal": "3534213.00",
  628. "taxExcludedTotal": "3334163.21",
  629. "deviationRate": "1.955%",
  630. "score": "98.045",
  631. "finalScore": "29.41"
  632. }
  633. },
  634. {
  635. "name": "供应商C",
  636. "supplier": {
  637. "taxIncludedTotal": "3206304.72",
  638. "taxExcludedTotal": "3206304.72",
  639. "deviationRate": "-1.955%",
  640. "score": "100",
  641. "finalScore": "30.00"
  642. }
  643. }
  644. ]
  645. }
  646. }
  647. def quote_review_result(json_data):
  648. score_weight = json_data['scoreWeight']
  649. score_weight = float(score_weight[:-1])*0.01
  650. # company = '12'
  651. total_list = []
  652. for i in range(len(json_data['calQuoteRes']['suppliers'])):
  653. total_list.append(float(json_data['calQuoteRes']['suppliers'][i]['taxExcludedTotal']))
  654. value = reference_value_count(total_list, json_data['calMethod'])
  655. score_json, min_score = score_dict_count(json_data['calMethod'])
  656. _json_cal_quote_res = {"avgPrice":"%.2f"%(float(sum(total_list))/len(total_list)), 'benchmarkPrice':"%.2f"%(value), 'suppliers':[]}
  657. for i in range(len(json_data['calQuoteRes']['suppliers'])):
  658. score = company_score(float(json_data['calQuoteRes']['suppliers'][i]['taxExcludedTotal']), value, score_json, min_score)
  659. # print(score, json_data['calQuoteRes']['suppliers'][i])
  660. _json_cal_quote_res['suppliers'].append({"name":json_data['calQuoteRes']['suppliers'][i]['name'], "taxIncludedTotal":json_data['calQuoteRes']['suppliers'][i]['taxIncludedTotal'], "taxExcludedTotal":json_data['calQuoteRes']['suppliers'][i]['taxExcludedTotal'],'deviationRate':"%.2f"%((float(json_data['calQuoteRes']['suppliers'][i]['taxExcludedTotal'])-value)/value*100) + '%', "score":"%.2f"%(score), "finalScore":"%.2f"%(score*score_weight)})
  661. print(_json_cal_quote_res)
  662. _json_quote_res = []
  663. quoteRes = json_data['quoteRes']
  664. for y in range(len(quoteRes)):
  665. _ = {"proNum":quoteRes[y]["proNum"],"projectName":quoteRes[y]["projectName"],"unit":quoteRes[y]["unit"], "quantity":quoteRes[y]["quantity"], "suppliers":[]}
  666. suppliers_list = []
  667. for x in range(len(quoteRes[y]['suppliers'])):
  668. supplier = {}
  669. supplier['name'] = quoteRes[y]['suppliers'][x]['name']
  670. supplier['taxRate'] = quoteRes[y]['suppliers'][x]['taxRate']
  671. taxRate = float(supplier['taxRate'][:-1])*0.01
  672. supplier['finalQuote'] = {}
  673. supplier['finalQuote']['unitPrice'] = quoteRes[y]['suppliers'][x]['finalQuote']['unitPrice']
  674. supplier['finalQuote']['totalPrice'] = quoteRes[y]['suppliers'][x]['finalQuote']['totalPrice']
  675. supplier['taxCompareRes'] = {}
  676. supplier['taxCompareRes']['theoryValue'] = "%.2f"%(float(quoteRes[y]['suppliers'][x]['finalQuote']['unitPrice']) * float(_['quantity']))
  677. supplier['taxCompareRes']['deviation'] = "%.2f"%(float(supplier['taxCompareRes']['theoryValue']) - float(quoteRes[y]['suppliers'][x]['finalQuote']['totalPrice']))
  678. supplier['finalExcludeTaxPrice'] = {}
  679. supplier['finalExcludeTaxPrice']['unitPrice'] = "%.2f"%(float(quoteRes[y]['suppliers'][x]['finalQuote']['unitPrice']) / (1+taxRate))
  680. supplier['finalExcludeTaxPrice']['totalPrice'] = "%.2f"%(float(supplier['finalExcludeTaxPrice']['unitPrice']) * float(_['quantity']))
  681. suppliers_list.append(supplier)
  682. _['suppliers'] = suppliers_list
  683. _json_quote_res.append(_)
  684. print(_json_quote_res)
  685. result_json = {}
  686. result_json['calMethod'] = json_data['calMethod']
  687. result_json['scoreWeight'] = json_data['scoreWeight']
  688. result_json['quoteRes'] = _json_quote_res
  689. result_json['calQuoteRes'] = _json_cal_quote_res
  690. print(result_json)
  691. return [result_json]
  692. # quote_review_result(json_data)
  693. jjj = [
  694. {
  695. "calMethod": "当0<Di≤3%时,每高1%扣1分;\n当3%<Di≤6%时,每高1%扣2分;\n当6%<Di,每高1%扣3分;\n当-3%<Di≤0时,不扣分;\n当-6%<Di≤-3%时,每低1%扣1分;\n当-9%<Di≤-6%时,每低1%扣2分;\n当Di≤-9%时,每低1%扣3分;\n满分为100分,最低得60分。\n上述计分按分段累进计算,当入围报价人评审价与评审价基准值B比例值(偏差率)处于分段计算区间内时,分段计算按内插法等比例计扣分。",
  696. "scoreWeight": "30%",
  697. "quoteRes": [
  698. {
  699. "proNum": "一",
  700. "projectName": "设备1",
  701. "unit": "m2",
  702. "quantity": "14.76",
  703. "suppliers": [
  704. {
  705. "name": "供应商A",
  706. "taxRate": "13%",
  707. "finalQuote": {
  708. "unitPrice": "875.00",
  709. "totalPrice": "12915.00"
  710. },
  711. "taxCompareRes": {
  712. "theoryValue": "12915.00",
  713. "deviation": "0.00"
  714. },
  715. "finalExcludeTaxPrice": {
  716. "unitPrice": "774.34",
  717. "totalPrice": "11429.20"
  718. }
  719. },
  720. {
  721. "name": "供应商B",
  722. "taxRate": "13%",
  723. "finalQuote": {
  724. "unitPrice": "672.00",
  725. "totalPrice": "9918.72"
  726. },
  727. "taxCompareRes": {
  728. "theoryValue": "9918.72",
  729. "deviation": "0.00"
  730. },
  731. "finalExcludeTaxPrice": {
  732. "unitPrice": "594.69",
  733. "totalPrice": "8777.63"
  734. }
  735. },
  736. {
  737. "name": "供应商C",
  738. "taxRate": "9%",
  739. "finalQuote": {
  740. "unitPrice": "800.00",
  741. "totalPrice": "11808.00"
  742. },
  743. "taxCompareRes": {
  744. "theoryValue": "11808.00",
  745. "deviation": "0.00"
  746. },
  747. "finalExcludeTaxPrice": {
  748. "unitPrice": "733.94",
  749. "totalPrice": "10833.03"
  750. }
  751. },
  752. {
  753. "name": "供应商D",
  754. "taxRate": "9%",
  755. "finalQuote": {
  756. "unitPrice": "850.00",
  757. "totalPrice": "12546.00"
  758. },
  759. "taxCompareRes": {
  760. "theoryValue": "12546.00",
  761. "deviation": "0.00"
  762. },
  763. "finalExcludeTaxPrice": {
  764. "unitPrice": "773.50",
  765. "totalPrice": "11416.86"
  766. }
  767. },
  768. {
  769. "name": "供应商E",
  770. "taxRate": "13%",
  771. "finalQuote": {
  772. "unitPrice": "672.00",
  773. "totalPrice": "9918.72"
  774. },
  775. "taxCompareRes": {
  776. "theoryValue": "9918.72",
  777. "deviation": "0.00"
  778. },
  779. "finalExcludeTaxPrice": {
  780. "unitPrice": "594.69",
  781. "totalPrice": "8777.63"
  782. }
  783. }
  784. ]
  785. },
  786. {
  787. "proNum": "二",
  788. "projectName": "设备2",
  789. "unit": "套",
  790. "quantity": "2",
  791. "suppliers": [
  792. {
  793. "name": "供应商A",
  794. "taxRate": "13%",
  795. "finalQuote": {
  796. "unitPrice": "10000.00",
  797. "totalPrice": "20000.00"
  798. },
  799. "taxCompareRes": {
  800. "theoryValue": "20000.00",
  801. "deviation": "0.00"
  802. },
  803. "finalExcludeTaxPrice": {
  804. "unitPrice": "8700.00",
  805. "totalPrice": "17400.00"
  806. }
  807. },
  808. {
  809. "name": "供应商B",
  810. "taxRate": "13%",
  811. "finalQuote": {
  812. "unitPrice": "11000.00",
  813. "totalPrice": "22000.00"
  814. },
  815. "taxCompareRes": {
  816. "theoryValue": "22000.00",
  817. "deviation": "0.00"
  818. },
  819. "finalExcludeTaxPrice": {
  820. "unitPrice": "9570.00",
  821. "totalPrice": "19140.00"
  822. }
  823. },
  824. {
  825. "name": "供应商C",
  826. "taxRate": "9%",
  827. "finalQuote": {
  828. "unitPrice": "10000.00",
  829. "totalPrice": "20000.00"
  830. },
  831. "taxCompareRes": {
  832. "theoryValue": "20000.00",
  833. "deviation": "0.00"
  834. },
  835. "finalExcludeTaxPrice": {
  836. "unitPrice": "9100.00",
  837. "totalPrice": "18200.00"
  838. }
  839. },
  840. {
  841. "name": "供应商D",
  842. "taxRate": "9%",
  843. "finalQuote": {
  844. "unitPrice": "9000.00",
  845. "totalPrice": "18000.00"
  846. },
  847. "taxCompareRes": {
  848. "theoryValue": "18000.00",
  849. "deviation": "0.00"
  850. },
  851. "finalExcludeTaxPrice": {
  852. "unitPrice": "8190.00",
  853. "totalPrice": "16380.00"
  854. }
  855. },
  856. {
  857. "name": "供应商E",
  858. "taxRate": "13%",
  859. "finalQuote": {
  860. "unitPrice": "11000.00",
  861. "totalPrice": "22000.00"
  862. },
  863. "taxCompareRes": {
  864. "theoryValue": "22000.00",
  865. "deviation": "0.00"
  866. },
  867. "finalExcludeTaxPrice": {
  868. "unitPrice": "9570.00",
  869. "totalPrice": "19140.00"
  870. }
  871. }
  872. ]
  873. }
  874. ],
  875. "calQuoteRes": {
  876. "avgPrice": "28393.96",
  877. "benchmarkPrice": "28393.96",
  878. "suppliers": [
  879. {
  880. "name": "供应商A",
  881. "taxIncludedTotal": "32915.00",
  882. "taxExcludedTotal": "28829.20",
  883. "deviationRate": "0.01533",
  884. "score": "90.333",
  885. "finalScore": "28.00"
  886. },
  887. {
  888. "name": "供应商B",
  889. "taxIncludedTotal": "31918.72",
  890. "taxExcludedTotal": "27917.63",
  891. "deviationRate": "-0.01677",
  892. "score": "80.333",
  893. "finalScore": "24.10"
  894. },
  895. {
  896. "name": "供应商C",
  897. "taxIncludedTotal": "31808.00",
  898. "taxExcludedTotal": "29033.03",
  899. "deviationRate": "0.0225",
  900. "score": "70.667",
  901. "finalScore": "21.10"
  902. },
  903. {
  904. "name": "供应商D",
  905. "taxIncludedTotal": "30546.00",
  906. "taxExcludedTotal": "27796.00",
  907. "deviationRate": "0.02105",
  908. "score": "75.00",
  909. "finalScore": "22.50"
  910. },
  911. {
  912. "name": "供应商E",
  913. "taxIncludedTotal": "31918.72",
  914. "taxExcludedTotal": "27917.63",
  915. "deviationRate": "-0.01677",
  916. "score": "80.333",
  917. "finalScore": "24.10"
  918. }
  919. ]
  920. }
  921. }
  922. ]
  923. quote_review_result(jjj[0])
  924. # 招标文件中评审方法中评审因素表
  925. # 清标-报价部分表格抽取
  926. # 分项报价表
  927. # 单价 全费用综合单价
  928. # 合价 合价
  929. # 单位 单位
  930. # 数量 数量、工程量、工作量
  931. # 名称 项目名称、名称
  932. # 报价汇总表
  933. # 税率 增值税税率
  934. # 总价 含税总价、含税报价
  935. # 增值税 增值税金额、增值税额
  936. # 不含税总价 不含税合价
  937. # 投标文件
  938. # table 表头,表格跨页
  939. # 计算ocr识别文本与标准信息的相似度
  940. def text_sim(word, black_lists):
  941. _json = {}
  942. for word_key in black_lists:
  943. # print(word_key.lower(), word)
  944. if word_key == word or word_key in word:
  945. return word_key
  946. sim_score = Levenshtein.ratio(word_key.lower(), word)
  947. if(sim_score > 0.9):
  948. return word_key
  949. _json[word_key] = sim_score
  950. datas = sorted(_json.items(), key=lambda x:x[1], reverse=True)
  951. # print('xx'*10, datas)
  952. return datas[0][0]
  953. black_lists = ['商务部分评分标准', '技术部分评分标准', '报价评分标准']
  954. print(text_sim('商务评分标准',black_lists))
  955. def get_money_score(aaa, bidderUnit, key_word_list):
  956. name = ''
  957. # for i in range(len(json_lines['para_nodes'])):
  958. # if json_lines['para_nodes'][i]['node_type'] == 'table':
  959. # aaa = json_lines['para_nodes'][i]['text']
  960. # print(lines)
  961. # aaa = """|||权重|中水北方勘测公司|长江勘测公司|中国电建中南院|北桥中七|\n|商务部分评分标准(15%)|信用评价|3%|100|100|100|100|\n|商务部分评分标准(15%)|财务状况|1%|87|98|93|81|\n|商务部分评分标准(15%)|报价合理性|3%|85|94|85|84|\n|商务部分评分标准(15%)|以往类似项目业绩、经验|7%|85|95|94|82|\n|商务部分评分标准(15%)|报价文件涉密内容检查|1%|100|100|100|100|\n|报价评分标准(35%)|价格得分|35%|||||\n|技术部分评分标准(50%)|总体方案|7%|83|94|85|82|\n|技术部分评分标准(50%)|外墙设计|20%|83|95|84|0|\n|技术部分评分标准(50%)|内部设计|15%|82|93|81|0|\n|技术部分评分标准(50%)|园区设计|8%|0|94|0|0|\n|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|"""
  962. aaa_list = aaa.split('\n')
  963. _beg = -1
  964. _row_index = -1
  965. for i in range(len(aaa_list)):
  966. aaa_list[i] = aaa_list[i][1:-1].split('|')
  967. for i in range(len(aaa_list)):
  968. if '权重' in aaa_list[i]:
  969. _row_index = aaa_list[i].index('权重')
  970. _beg = i
  971. break
  972. for i in range(len(aaa_list)):
  973. if '权重' in aaa_list[i]:
  974. continue
  975. category = text_sim(aaa_list[i][0], key_word_list.keys())
  976. scoringFactors = text_sim(aaa_list[i][1], key_word_list[category].keys())
  977. percentage = key_word_list[category][scoringFactors]
  978. aaa_list[i][0] = category
  979. aaa_list[i][1] = scoringFactors
  980. aaa_list[i][2] = percentage
  981. # print(aaa_list)
  982. json_array = {}
  983. for j in range(_row_index+1, len(aaa_list[_beg])):
  984. # print(aaa_list[_beg][j])
  985. company = text_sim(aaa_list[_beg][j], bidderUnit)
  986. aaa_list[_beg][j] = company
  987. json_array[company] = []
  988. for j in range(_beg+1, len(aaa_list)):
  989. if '专家签字' in str(aaa_list[j]) or '专家' in str(aaa_list[j]):
  990. break
  991. for x in range(_row_index+1, len(aaa_list[_beg])):
  992. json_array[aaa_list[_beg][x]].append(aaa_list[j][:_row_index+1] + [aaa_list[j][x]])
  993. # print(json.dumps(json_array, ensure_ascii=False))
  994. code = 0
  995. ok = True
  996. if code != 0:
  997. code = 1
  998. ok = False
  999. json_data = {
  1000. "code":code,
  1001. "name":name,
  1002. "msg":"",
  1003. "data":json_array,
  1004. "ok":ok
  1005. }
  1006. # print(json.dumps(json_data, ensure_ascii=False))
  1007. return json_data
  1008. aaa = """|||权重|中水北方勘测公司|长江勘测公司|中国电建中南院|北桥中七|\n|商务部分评分标准(15%)|信用评价|3%|100|100|100|100|\n|商务部分评分标准(15%)|财务状兄|1%|87|98|93|81|\n|商务部分评分标准(15%)|报价合理性|3%|85|94|85|84|\n|商务部分评分标准(15%)|以往类似项目业绩、经验|7%|85|95|94|82|\n|商务部分评分标准(15%)|报价文件涉密内容检查|1%|100|100|100|100|\n|报价评分标准(35%)|价格得分|35%|||||\n|技术部分评分标准(50%)|总体方案|7%|83|94|85|82|\n|技术部分评分标准(50%)|外墙设计|20%|83|95|84|0|\n|技术部分评分标准(50%)|内部设计|15%|82|93|81|0|\n|技术部分评分标准(50%)|园区设计|8%|0|94|0|0|\n|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|"""
  1009. aaa1 = """|||权重|中水北方勘测公司|长江勘测公司|中国电建中南院|北桥中七|\n|商务部分评分标准(15%)|信用评价|3%|93|93|93|93|\n|商务部分评分标准(15%)|财务状况|1%|88|88|88|88|\n|商务部分评分标准(15%)|报价合理性|3%|88|99|88|99|\n|商务部分评分标准(15%)|以往类似项目业绩、经验|7%|97|94|83|86|\n|商务部分评分标准(15%)|报价文件涉密内容检查|1%|104|103|101|102|\n|报价评分标准(35%)|价格得分|35%|||||\n|技术部分评分标准(50%)|总体方案|7%|71|93|65|77|\n|技术部分评分标准(50%)|外墙设计|20%|88|55|88|20|\n|技术部分评分标准(50%)|内部设计|15%|80|90|80|10|\n|技术部分评分标准(50%)|园区设计|8%|10|194|20|30|\n|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|"""
  1010. aaa2 = """|||权重|中水北方勘测公司|长江勘测公司|中国电建中南院|苏州派维斯|\n|商务部分评分标准(15%)|信用评价|3%|91|93|95|97|\n|商务部分评分标准(15%)|财务状况|1%|89|90|91|92|\n|商务部分评分标准(15%)|报价合理性|3%|88|99|88|99|\n|商务部分评分标准(15%)|以往类似项目业绩、经验|7%|87|94|63|56|\n|商务部分评分标准(15%)|报价文件涉密内容检查|1%|114|113|111|112|\n|报价评分标准(35%)|价格得分|35%|||||\n|技术部分评分标准(50%)|总体方案|7%|72|97|68|78|\n|技术部分评分标准(50%)|外墙设计|20%|88|57|88|30|\n|技术部分评分标准(50%)|内部设计|15%|88|99|83|20|\n|技术部分评分标准(50%)|园区设计|8%|09|11|22|33|\n|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|专家签字:杨明2024年3月26日|"""
  1011. quoteCheck = [
  1012. { "name":"商务部分评分标准",
  1013. "businessScoringCriteria": [
  1014. {
  1015. "scoringFactors": "信用评价",
  1016. "scoringStandard ": "与营业执照(法人证书)一致",
  1017. "percentage": "3%",
  1018. "expertAdvice": "专家意见",
  1019. "suppliers": [
  1020. {
  1021. "name": "供应商A",
  1022. "supplier": "供应商A的算法输出结果..."
  1023. },
  1024. {
  1025. "name": "供应商B",
  1026. "supplier": "供应商B的算法输出结果..."
  1027. },
  1028. {
  1029. "name": "供应商C",
  1030. "supplier": "供应商C的算法输出结果..."
  1031. }
  1032. ]
  1033. },
  1034. {
  1035. "scoringFactors": "财务状况",
  1036. "scoringStandard ": "与营业执照(法人证书)一致",
  1037. "percentage": "3%"
  1038. },
  1039. {
  1040. "scoringFactors": "报价合理性",
  1041. "scoringStandard ": "与营业执照(法人证书)一致",
  1042. "percentage": "3%"
  1043. },
  1044. {
  1045. "scoringFactors": "以往类似项目业绩、经验",
  1046. "scoringStandard ": "与营业执照(法人证书)一致",
  1047. "percentage": "3%"
  1048. },
  1049. {
  1050. "scoringFactors": "报价文件涉密内容检查",
  1051. "scoringStandard ": "与营业执照(法人证书)一致",
  1052. "percentage": "3%"
  1053. }
  1054. ]
  1055. },
  1056. { "name":"报价评分标准",
  1057. "quoteScoringCriteria": [
  1058. {
  1059. "scoringFactors": "价格得分",
  1060. "scoringStandard ": "当0<Di≤3%时,每高1%扣1分;",
  1061. "percentage": "35%",
  1062. "expertAdvice": "专家意见",
  1063. "suppliers": [
  1064. {
  1065. "name": "供应商A",
  1066. "supplier": "供应商A的算法输出结果..."
  1067. },
  1068. {
  1069. "name": "供应商B",
  1070. "supplier": "供应商B的算法输出结果..."
  1071. },
  1072. {
  1073. "name": "供应商C",
  1074. "supplier": "供应商C的算法输出结果..."
  1075. }
  1076. ]
  1077. }
  1078. ]
  1079. },
  1080. {"name":"技术部分评分标准",
  1081. "techPartScoringCriteria": [
  1082. {
  1083. "scoringFactors": "总体方案",
  1084. "scoringStandard ": "对报价人提供的总体服务方案的全面性...",
  1085. "percentage": "7%"
  1086. },
  1087. {
  1088. "scoringFactors": "外墙设计",
  1089. "scoringStandard ": "与营业执照(法人证书)一致",
  1090. "percentage": "20%"
  1091. },
  1092. {
  1093. "scoringFactors": "内部设计",
  1094. "scoringStandard ": "与营业执照(法人证书)一致",
  1095. "percentage": "15%"
  1096. },
  1097. {
  1098. "scoringFactors": "园区设计",
  1099. "scoringStandard ": "与营业执照(法人证书)一致",
  1100. "percentage": "8%"
  1101. }
  1102. ]
  1103. }
  1104. ]
  1105. bidderUnit = ["中水北方勘测公司", "长江勘测公司", "中国电建中南院", "北桥中七", "苏州派维斯科技有限公司"]
  1106. def quote_check_score(quoteCheck=quoteCheck, bidderUnit=bidderUnit):
  1107. # 获取输入的quoteCheck的内容,不同模块的评审因素字段
  1108. key_word_list = {}
  1109. for y in range(len(quoteCheck)):
  1110. name = quoteCheck[y]['name']
  1111. if name == '商务部分评分标准':
  1112. key = 'businessScoringCriteria'
  1113. elif name == '报价评分标准':
  1114. key = 'quoteScoringCriteria'
  1115. elif name == '技术部分评分标准':
  1116. key = 'techPartScoringCriteria'
  1117. key_word_list[name] = {}
  1118. for j in range(len(quoteCheck[y][key])):
  1119. key_word_list[name][quoteCheck[y][key][j]['scoringFactors']] = quoteCheck[y][key][j]['percentage']
  1120. print(key_word_list)
  1121. json_data = get_money_score(aaa, bidderUnit, key_word_list)
  1122. json_data['name'] = '张三'
  1123. json_data_1 = get_money_score(aaa1, bidderUnit, key_word_list)
  1124. json_data_1['name'] = '李四'
  1125. json_data_2 = get_money_score(aaa2, bidderUnit, key_word_list)
  1126. json_data_2['name'] = '王五1'
  1127. print(json_data)
  1128. json_array = [json_data, json_data_1, json_data_2]
  1129. name_list = []
  1130. for i in range(len(json_array)):
  1131. name_list.append(json_array[i]['name'])
  1132. result_json = {"detail":[{"category": "商务部分评分标准","factorsList":[]}, {"category": "报价评分标准","factorsList":[]}, {"category": "技术部分评分标准","factorsList":[]}]}
  1133. for i in range(len(json_array)):
  1134. json_data = json_array[i]
  1135. name = json_data['name']
  1136. for k in json_data['data']:
  1137. company = k
  1138. data = json_data['data'][k]
  1139. category = ''
  1140. json_list = []
  1141. _beg = -1
  1142. for y in data:
  1143. if category != y[0]:
  1144. category = y[0]
  1145. for j in range(len(result_json["detail"])):
  1146. if result_json["detail"][j]['category'] == category or result_json["detail"][j]['category'] in category:
  1147. _beg = j
  1148. break
  1149. # print(company, name, y)
  1150. scoringFactors = y[1]
  1151. percentage = y[2] # 占比
  1152. score = y[3] #得分
  1153. try:
  1154. result_json["detail"][_beg]["factorsList"][0]
  1155. except:
  1156. result_json["detail"][_beg]["factorsList"].append({"scoringFactors":scoringFactors, "percentage":percentage,"suppliers":[]})
  1157. _sed_beg = -1
  1158. for xx in range(len(result_json["detail"][_beg]['factorsList'])):
  1159. if result_json["detail"][_beg]['factorsList'][xx]['scoringFactors'] == scoringFactors or result_json["detail"][_beg]['factorsList'][xx]['scoringFactors'] in scoringFactors:
  1160. _sed_beg = xx
  1161. break
  1162. if _sed_beg == -1:
  1163. result_json["detail"][_beg]["factorsList"].append({"scoringFactors":scoringFactors, "percentage":percentage,"suppliers":[]})
  1164. _sed_beg = len(result_json["detail"][_beg]["factorsList"]) - 1
  1165. suppliers_beg = -1
  1166. for xx in range(len(result_json["detail"][_beg]['factorsList'][_sed_beg]['suppliers'])):
  1167. if result_json["detail"][_beg]['factorsList'][_sed_beg]['suppliers'][xx]["name"] == company or company in result_json["detail"][_beg]['factorsList'][_sed_beg]['suppliers'][xx]["name"] :
  1168. suppliers_beg = xx
  1169. break
  1170. if suppliers_beg == -1:
  1171. result_json["detail"][_beg]['factorsList'][_sed_beg]['suppliers'].append({"name":company,"grade":"", "scores":[],"avgScore":"","percentScore":''})
  1172. suppliers_beg = len(result_json["detail"][_beg]['factorsList'][_sed_beg]['suppliers']) - 1
  1173. for j in range(len(name_list)):
  1174. result_json["detail"][_beg]['factorsList'][_sed_beg]['suppliers'][suppliers_beg]['scores'].append({"name":name_list[j], "score":""})
  1175. name_beg = -1
  1176. for xx in range(len(result_json["detail"][_beg]['factorsList'][_sed_beg]['suppliers'][suppliers_beg]['scores'])):
  1177. if result_json["detail"][_beg]['factorsList'][_sed_beg]['suppliers'][suppliers_beg]['scores'][xx]["name"] == name:
  1178. result_json["detail"][_beg]['factorsList'][_sed_beg]['suppliers'][suppliers_beg]['scores'][xx]["score"] = score
  1179. name_beg = xx
  1180. break
  1181. # print(company, name, y, _sed_beg, suppliers_beg, name_beg)
  1182. # print(result_json)
  1183. _json = {'code':0, 'ok':True, 'data':result_json, 'msg':'成功'}
  1184. print(json.dumps(_json, ensure_ascii=False))
  1185. return result_json