util.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import xml.etree.ElementTree as ET
  2. from typing import Union
  3. from fastapi import FastAPI
  4. import os
  5. import uuid
  6. import re
  7. from fastapi.middleware.cors import CORSMiddleware
  8. from pydantic import BaseModel
  9. import pandas as pd
  10. from numpy import float64
  11. def huizongrcj(data):
  12. huizong = {}
  13. result = [
  14. [ "ID", "编码", "名称", "规格型号", "单位", "数量", "单价", "合价", "产地",
  15. "供应厂商", "人材机类别", "主要材料标志", "主材标志", "设备标志", "甲供标志", "暂估价标志"]]
  16. for entry in data:
  17. bm = entry[1]
  18. name = entry[2]
  19. danwei = entry[4]
  20. key = bm + name + danwei
  21. if key in huizong:
  22. huizong[key].append(entry)
  23. else:
  24. huizong[key] = [entry]
  25. for key,value in huizong.items():
  26. result_hl = 0
  27. for i in range(0, len(value)):
  28. result_hl = result_hl + float(value[i][10])
  29. result_dj = float(value[0][5])
  30. result_hj = result_hl * result_dj
  31. result.append([value[0][0], value[0][1], value[0][2], value[0][3], value[0][4], result_hl,
  32. value[0][5], result_hj, value[0][6], value[0][7], value[0][8], value[0][13],
  33. value[0][14], value[0][15], value[0][9], value[0][12]])
  34. return result