import xml.etree.ElementTree as ET
from typing import Union
from fastapi import FastAPI
import os
import uuid
import re
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel
import pandas as pd
from numpy import float64

def getDjcsDingercj(root, bh, bt, qdbm, debm):
    result = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地", 
    "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]]
    #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
    item = None
    for child in root:
    
        if child.tag == "Dxgcxx":
            for child1 in child:
                Dwgcbh = child1.attrib["Dwgcbh"]
                if Dwgcbh == bh:
                    item = child1
                    break
            ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
    Fywj = None
    for child in item:
        if child.tag == 'Csxm':
            Fywj= child
            break
    Rcjhz = None
    for child in item:
        if child.tag == 'Rcjhz':
            Rcjhz = child
            break
    kv = {}
    for entry in Rcjhz:
        kv[entry.attrib["RcjId"]]=entry

    container = None
    for child in Fywj:
        if child.tag == "DjCs":
            container = child
            break
    zimu = None
    for child in container:
        if child.attrib["Bm"] == qdbm:
            zimu = child
            break
    box = None
    if not zimu:
        return result
    for child in zimu:
        if child.tag == "Csxdezj":
            box = child
            break
    hlmx_parent = None
    for child in box:
        if child.attrib["Debm"] == debm:
            for grandchild in child:
                if grandchild.tag == "Csxdercjhl":
                    hlmx_parent = grandchild
    for child in hlmx_parent:
        result.append([child.attrib["RcjId"], 
        kv[child.attrib["RcjId"]].attrib["RcjBm"], 
        kv[child.attrib["RcjId"]].attrib["Mc"], 
        kv[child.attrib["RcjId"]].attrib["Ggxh"], 
        kv[child.attrib["RcjId"]].attrib["Dw"], 
        kv[child.attrib["RcjId"]].attrib["Dj"], 
        kv[child.attrib["RcjId"]].attrib["Cd"], 
        kv[child.attrib["RcjId"]].attrib["Gycs"], 
        kv[child.attrib["RcjId"]].attrib["Rcjlb"], 
        kv[child.attrib["RcjId"]].attrib["Jgbz"], 
        child.attrib["Rcjhl"], child.attrib["Rcjhj"], "", 
             "", "", ""
        ])

    return result


def getDingercj(root, bh, bt, qdbm, debm):
    result = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地", 
    "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]]
    #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
    item = None
    for child in root:
    
        if child.tag == "Dxgcxx":
            for child1 in child:
                Dwgcbh = child1.attrib["Dwgcbh"]
                if Dwgcbh == bh:
                    item = child1
                    break
            ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
    Fywj = None
    for child in item:
        if child.tag == 'Qdxm':
            Fywj= child
            break
    Rcjhz = None
    for child in item:
        if child.tag == 'Rcjhz':
            Rcjhz = child
            break
    kv = {}
    for entry in Rcjhz:
        kv[entry.attrib["RcjId"]]=entry

    container = None
    for child in Fywj:
        ##child is mx
        if child.tag == "QdBt":
            if child.attrib["Mc"] == bt:
                container = child
                break
    if not container:
        container = Fywj
    zimu = None
    for child in container:
        if child.attrib["Qdbm"] == qdbm:
            zimu = child
            break
    box = None
    if not zimu:
        return result
    for child in zimu:
        if child.tag == "Qdxdezj":
            box = child
            break
    hlmx_parent = None
    for child in box:
        if child.attrib["Debm"] == debm:
            for grandchild in child:
                if grandchild.tag == "Qdxdercjhl":
                    hlmx_parent = grandchild
    for child in hlmx_parent:
        result.append([child.attrib["RcjId"], 
        kv[child.attrib["RcjId"]].attrib["RcjBm"], 
        kv[child.attrib["RcjId"]].attrib["Mc"], 
        kv[child.attrib["RcjId"]].attrib["Ggxh"], 
        kv[child.attrib["RcjId"]].attrib["Dw"], 
        kv[child.attrib["RcjId"]].attrib["Dj"], 
        kv[child.attrib["RcjId"]].attrib["Cd"], 
        kv[child.attrib["RcjId"]].attrib["Gycs"], 
        kv[child.attrib["RcjId"]].attrib["Rcjlb"], 
        kv[child.attrib["RcjId"]].attrib["Jgbz"], 
        child.attrib["Rcjhl"], child.attrib["Rcjhj"], "", 
             "", "", ""
        ])

    return result


def getDjcsQingdanrcj(root, bh, bt, bm):
    result = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地", 
    "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]]
    #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
    item = None
    for child in root:
    
        if child.tag == "Dxgcxx":
            for child1 in child:
                Dwgcbh = child1.attrib["Dwgcbh"]
                if Dwgcbh == bh:
                    item = child1
                    break
            ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
    Fywj = None
    for child in item:
        if child.tag == 'Csxm':
            Fywj= child
            break
    hl_parent = None
    for child in Fywj:
        if child.tag == "DjCs":
            hl_parent = child
    Rcjhz = None
    for child in item:
        if child.tag == 'Rcjhz':
            Rcjhz = child
            break
    kv = {}
    for entry in Rcjhz:
        kv[entry.attrib["RcjId"]]=entry

    zimu = None
    for child in hl_parent:
        if child.attrib["Bm"] == bm:
            zimu = child
            break
    box = None
    if not zimu:
        return result
    for child in zimu:
        if child.tag == "Csxrcjhl":
            box = child
            break
    for child in box:
        result.append([child.attrib["RcjId"], 
        kv[child.attrib["RcjId"]].attrib["RcjBm"], 
        kv[child.attrib["RcjId"]].attrib["Mc"], 
        kv[child.attrib["RcjId"]].attrib["Ggxh"], 
        kv[child.attrib["RcjId"]].attrib["Dw"], 
        kv[child.attrib["RcjId"]].attrib["Dj"], 
        kv[child.attrib["RcjId"]].attrib["Cd"], 
        kv[child.attrib["RcjId"]].attrib["Gycs"], 
        kv[child.attrib["RcjId"]].attrib["Rcjlb"], 
        kv[child.attrib["RcjId"]].attrib["Jgbz"], 
        child.attrib["Rcjhl"], child.attrib["Rcjhj"], child.attrib["Zgjbz"], 
        child.attrib["Zyclbz"], child.attrib["Zcbz"], child.attrib["Sbbz"]
        ])

    return result



def getQingdanTuijian(bh, bt, bm):
    result = [["ID", "定额编号", "工程量名称", "工作内容" ]]
    all = pd.read_csv("QingDanAllInOne.csv")
    bm_ = int(bm) // 1000
    hit = all[all["qdbh"] == str(bm_)]
    for i in range(len(hit)):
        result.append([hit.iloc[i]["index"].item(), hit.iloc[i]["debh"], hit.iloc[i]["gclmc"], hit.iloc[i]["work"]])
    #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])


    return result

def getQingdanrcj(root, bh, bt, bm):
    result = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地", 
    "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]]
    #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
    item = None
    for child in root:
    
        if child.tag == "Dxgcxx":
            for child1 in child:
                Dwgcbh = child1.attrib["Dwgcbh"]
                if Dwgcbh == bh:
                    item = child1
                    break
            ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
    Fywj = None
    for child in item:
        if child.tag == 'Qdxm':
            Fywj= child
            break
    Rcjhz = None
    for child in item:
        if child.tag == 'Rcjhz':
            Rcjhz = child
            break
    kv = {}
    for entry in Rcjhz:
        kv[entry.attrib["RcjId"]]=entry

    container = None
    for child in Fywj:
        ##child is mx
        if child.tag == "QdBt":
            if child.attrib["Mc"] == bt:
                container = child
                break
    if not container:
        container = Fywj
    zimu = None
    for child in container:
        if child.attrib["Qdbm"] == bm:
            zimu = child
            break
    box = None
    if not zimu:
        return result
    for child in zimu:
        if child.tag == "Qdxrcjhl":
            box = child
            break
    for child in box:
        result.append([child.attrib["RcjId"], 
        kv[child.attrib["RcjId"]].attrib["RcjBm"], 
        kv[child.attrib["RcjId"]].attrib["Mc"], 
        kv[child.attrib["RcjId"]].attrib["Ggxh"], 
        kv[child.attrib["RcjId"]].attrib["Dw"], 
        kv[child.attrib["RcjId"]].attrib["Dj"], 
        kv[child.attrib["RcjId"]].attrib["Cd"], 
        kv[child.attrib["RcjId"]].attrib["Gycs"], 
        kv[child.attrib["RcjId"]].attrib["Rcjlb"], 
        kv[child.attrib["RcjId"]].attrib["Jgbz"], 
        child.attrib["Rcjhl"], child.attrib["Rcjhj"], child.attrib["Zgjbz"], 
        child.attrib["Zyclbz"], child.attrib["Zcbz"], child.attrib["Sbbz"]
        ])

    return result

def getDjcs(root, id):
    result = []
    #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
    item = None
    for child in root:
    
        if child.tag == "Dxgcxx":
            for child1 in child:
                Dwgcbh = child1.attrib["Dwgcbh"]
                if Dwgcbh == id:
                    item = child1
                    break
            ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
    Fywj = None
    for child in item:
        if child.tag == 'Csxm':
            Fywj= child
            break
    Djcs_parent = None
    for child in Fywj:
        if child.tag == 'DjCs':
            Djcs_parent = child
            break
    
    for child in Djcs_parent:
        ##child is mx {
        result.append({   

                    "序号": child.attrib["Xh"], "清单编码": child.attrib["Bm"], "名称" : child.attrib["Mc"],
                     "项目特征" : child.attrib["Xmtz"], 
                    "计算规则" : child.attrib["Jsgz"], "单位" : child.attrib["Dw"], "数量" : child.attrib["Sl"], 
                    "综合单价" : child.attrib["Zhdj"], "合价" : child.attrib["Zhhj"], "人工费" : child.attrib["Rgf"],
                     "主材费" : child.attrib["Zcf"],
                     "设备费" : child.attrib["Sbf"], "辅材费" : child.attrib["Fcf"], "材料费" : child.attrib["Clf"], 
                    "机械费" : child.attrib["Jxf"], "管理费" : child.attrib["Glf"], "利润"  : child.attrib["Lr"],
                     "暂估价" : child.attrib["Zgj"], "综合人工工日" : child.attrib["Zgr"] })

        __children = []
        zj_parent = None
        for grandchild in child:
            if grandchild.tag == "Csxdezj":
                zj_parent = grandchild
        
        if zj_parent:
            for entry in zj_parent:
                __children.append({
                    "序号": None, "清单编码": entry.attrib["Debm"], "名称" : entry.attrib["Mc"],
                     "项目特征" : None, 
                    "计算规则" : None, "单位" : entry.attrib["Dw"], "数量" : entry.attrib["DwQdSl"], 
                    "综合单价" : entry.attrib["Dj"], "合价" : entry.attrib["Hj"], "人工费" : entry.attrib["Rgf"],
                     "主材费" : entry.attrib["Zcf"],
                     "设备费" : entry.attrib["Sbf"], "辅材费" : entry.attrib["Fcf"], "材料费" : entry.attrib["Clf"], 
                    "机械费" : entry.attrib["Jxf"], "管理费" : entry.attrib["Glf"], "利润"  : entry.attrib["Lr"],
                     "暂估价" : None, "综合人工工日" : None })

        if len(__children) > 0:
            result[-1]["__children"] = __children 



    return result

def getQdmx(root, bh, bt):
    result = []
    #result = [["序号", "清单编码", "名称", "项目特征", "计算规则", "单位", "数量", "综合单价", "合价", "人工费", "主材费", "设备费", "辅材费", "材料费", "机械费", "管理费", "利润" , "暂估价", "综合人工工日", "备注" ]]
    #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
    item = None
    for child in root:
    
        if child.tag == "Dxgcxx":
            for child1 in child:
                Dwgcbh = child1.attrib["Dwgcbh"]
                if Dwgcbh == bh:
                    item = child1
                    break
            ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
    Fywj = None
    for child in item:
        if child.tag == 'Qdxm':
            Fywj= child
            break
    container = None
    for child in Fywj:
        ##child is mx
        print(child.attrib["Mc"])
        if child.tag == "QdBt":
            if child.attrib["Mc"] == bt:
                container = child
                break
    if not container:
        container = Fywj
    for child in container:
        print(child)
        #result = [["序号", "清单编码", "名称", "项目特征", "计算规则", "单位", "数量", "综合单价", "合价", "人工费", "主材费",
        #  "设备费", "辅材费", "材料费", "机械费", "管理费", "利润" , "暂估价", "综合人工工日", "备注" ]]
        result.append({
            "操作" : "",
            "序号": child.attrib["Xh"], "清单编码" : child.attrib["Qdbm"], "名称" : child.attrib["Mc"],"项目特征" : child.attrib["Xmtz"],
            "计算规则" : child.attrib["Jsgz"],
            "单位" : child.attrib["Dw"],
            "数量": child.attrib["Sl"],
            "综合单价" : child.attrib["Zhdj"],
            "合价" : child.attrib["Zhhj"],
            "人工费": child.attrib["Rgf"],
            "主材费" : child.attrib["Zcf"],
            "设备费": child.attrib["Sbf"],
            "辅材费": child.attrib["Fcf"],
            "材料费" : child.attrib["Clf"],
            "机械费" : child.attrib["Jxf"],
            "管理费": child.attrib["Glf"],
            "利润": child.attrib["Lr"],
            "暂估价" : child.attrib["Zgj"],
            "综合人工工日" : child.attrib["Zgr"],
            "备注" : child.attrib["Bz"]}
        )
        for child_zj in child:
            if child_zj.tag == "Qdxdezj":
                for child_mx in child_zj:
                    if child_mx.tag == "QdxdezjMx":
                        parent = result[-1]
                        if "__children" in parent:
                            parent["__children"].append({
                                "操作" : "",
                                "序号": None, "清单编码" : child_mx.attrib["Debm"], "名称" : child_mx.attrib["Mc"],"项目特征" : None,
                                "计算规则" : None,
                                "单位" : child_mx.attrib["Dw"],
                                "数量": child_mx.attrib["DwQdSl"],
                                "综合单价" : child_mx.attrib["Dj"],
                                "合价" : child_mx.attrib["Hj"],
                                "人工费": child_mx.attrib["Rgf"],
                                "主材费" : child_mx.attrib["Zcf"],
                                "设备费": child_mx.attrib["Sbf"],
                                "辅材费": child_mx.attrib["Fcf"],
                                "材料费" : child_mx.attrib["Clf"],
                                "机械费" : child_mx.attrib["Jxf"],
                                "管理费": child_mx.attrib["Glf"],
                                "利润": child_mx.attrib["Lr"],
                                "暂估价" : None,
                                "综合人工工日" : None,
                                "备注" : None}

                            )
                        else:
                            parent["__children"] = [{
                                "操作" : "",
                                "序号": None, "清单编码" : child_mx.attrib["Debm"], "名称" : child_mx.attrib["Mc"],"项目特征" : None,
                                "计算规则" : None,
                                "单位" : child_mx.attrib["Dw"],
                                "数量": child_mx.attrib["DwQdSl"],
                                "综合单价" : child_mx.attrib["Dj"],
                                "合价" : child_mx.attrib["Hj"],
                                "人工费": child_mx.attrib["Rgf"],
                                "主材费" : child_mx.attrib["Zcf"],
                                "设备费": child_mx.attrib["Sbf"],
                                "辅材费": child_mx.attrib["Fcf"],
                                "材料费" : child_mx.attrib["Clf"],
                                "机械费" : child_mx.attrib["Jxf"],
                                "管理费": child_mx.attrib["Glf"],
                                "利润": child_mx.attrib["Lr"],
                                "暂估价" : None,
                                "综合人工工日" : None,
                                "备注" : None}]



    return result
def getQdxm(root, id):
    result = []
    #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
    item = None
    for child in root:
    
        if child.tag == "Dxgcxx":
            for child1 in child:
                Dwgcbh = child1.attrib["Dwgcbh"]
                if Dwgcbh == id:
                    item = child1
                    break
            ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
    Fywj = None
    for child in item:
        if child.tag == 'Qdxm':
            Fywj= child
            break
    
    for child in Fywj:
        ##child is mx
        if child.tag == "QdBt":
            result.append(child.attrib["Mc"])
    if len(result) == 0:
        result.append("Default")
    return result

def getZjcs(root, id):
    result = []
    #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
    item = None
    for child in root:
    
        if child.tag == "Dxgcxx":
            for child1 in child:
                Dwgcbh = child1.attrib["Dwgcbh"]
                if Dwgcbh == id:
                    item = child1
                    break
            ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
    Fywj = None
    for child in item:
        if child.tag == 'Csxm':
            Fywj= child
            break
    Zjcs_parent = None
    for child in Fywj:
        if child.tag == 'ZjCs':
            Zjcs_parent = child
            break
    
    for child in Zjcs_parent:
        ##child is mx {
        result.append({    
                    "序号" : child.attrib["Xh"], "清单编码": child.attrib["Bm"], "名称" : child.attrib["Mc"],
                     "计算基数" : child.attrib["Js"],
                     "计算基础" : child.attrib["Jsjc"], "费率" : child.attrib["Fl"],
                      "金额" : child.attrib["Je"], "项目类别" : child.attrib["Xmlb"]})
        __children = []
        for grandchild in child:
            __children.append({
                    "序号" : None, "清单编码": None, "名称" : grandchild.attrib["Mc"],
                     "计算基数" : grandchild.attrib["Js"],
                     "计算基础" : grandchild.attrib["Jsjc"], "费率" : grandchild.attrib["Fl"],
                      "金额" : grandchild.attrib["Je"], "项目类别" : grandchild.attrib["Xmlb"]})

        if len(__children) > 0:
            result[-1]["__children"] = __children 



    return result

def getZcbfwf(root, id):
    result = [["序号", "名称", "项目价值", "服务内容", "计算基础", "费率", "金额"]]
    #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
    item = None
    for child in root:
    
        if child.tag == "Dxgcxx":
            for child1 in child:
                Dwgcbh = child1.attrib["Dwgcbh"]
                if Dwgcbh == id:
                    item = child1
                    break
            ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
    Fywj = None
    for child in item:
        if child.tag == 'Zcbfwf':
            Fywj= child
            break
    for child in Fywj:
            result.append(
                [child.attrib["Xh"], 
            child.attrib["Mc"],  child.attrib["Xmjz"], child.attrib["Fwnr"], child.attrib["Jsjc"],
            child.attrib["Fl"], child.attrib["Je"]]
            )
    return result

def getRcjhz(root, id):
    result = [[ "ID", "编码", "名称", "规格型号", "单位", "数量", "单价", "合价", "产地", 
    "供应厂商", "人材机类别", "主要材料标志", "主材标志", "设备标志", "甲供标志", "暂估价标志"]]


    for child in root:
    
        if child.tag == "Dxgcxx":
            for child1 in child:
                Dwgcbh = child1.attrib["Dwgcbh"]
                if Dwgcbh == id:
                    item = child1
                    break
            ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
    Fywj = None
    for child in item:
        if child.tag == 'Rcjhz':
            Fywj= child
            break
    for child in Fywj:
            result.append(
                [
            child.attrib["RcjId"],  child.attrib["RcjBm"], child.attrib["Mc"], child.attrib["Ggxh"],
            child.attrib["Dw"], child.attrib["Sl"], child.attrib["Dj"], child.attrib["Hj"], 
            child.attrib["Cd"], child.attrib["Gycs"], child.attrib["Rcjlb"],
            child.attrib["Zyclbz"], child.attrib["Zcbz"], child.attrib["Sbbz"], child.attrib["Jgbz"],
            child.attrib["Zgjbz"]]
            )
    return result  

def getFbrgycl(root, id):
    result = [["序号", "ID", "材料编号", "名称", "规格型号", "单位", "数量", "单价", "合价", "交货方式", "送达地点", "备注"]]


    for child in root:
    
        if child.tag == "Dxgcxx":
            for child1 in child:
                Dwgcbh = child1.attrib["Dwgcbh"]
                if Dwgcbh == id:
                    item = child1
                    break
            ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
    Fywj = None
    for child in item:
        if child.tag == 'Fbrgycl':
            Fywj= child
            break
    for child in Fywj:
            result.append(
                [child.attrib["Xh"], 
            child.attrib["RcjId"],  child.attrib["Clbh"], child.attrib["Mc"], child.attrib["Ggxh"],
            child.attrib["Dw"], child.attrib["Sl"], child.attrib["Dj"], child.attrib["Hj"], child.attrib["Jhfs"],
            child.attrib["Sddd"], child.attrib["Bz"]]
            )
    return result   

def getJrg(root, id):
    result = [["序号", "名称", "金额", "类别"]]
    #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
    item = None
    for child in root:
    
        if child.tag == "Dxgcxx":
            for child1 in child:
                Dwgcbh = child1.attrib["Dwgcbh"]
                if Dwgcbh == id:
                    item = child1
                    break
            ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
    Fywj = None
    for child in item:
        if child.tag == 'Jrg':
            Fywj= child
            break
    for child in Fywj:
            result.append(
                [child.attrib["Xh"], 
            child.attrib["Mc"],  child.attrib["Je"], child.attrib["Lb"]]
            )
    return result 

def getZlje(root, id):
    result = [["序号", "名称", "单位", "暂定金额", "备注"]]
    #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
    item = None
    for child in root:
    
        if child.tag == "Dxgcxx":
            for child1 in child:
                Dwgcbh = child1.attrib["Dwgcbh"]
                if Dwgcbh == id:
                    item = child1
                    break
            ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
    Fywj = None
    for child in item:
        if child.tag == 'Zlje':
            Fywj= child
            break
    for child in Fywj:
            result.append(
                [child.attrib["Xh"], 
            child.attrib["Mc"],   child.attrib["Dw"], child.attrib["Zdje"], child.attrib["Bz"]]
            )
    return result  

def getQtxm(root, id):
    result = []
    #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
    item = None
    for child in root:
    
        if child.tag == "Dxgcxx":
            for child1 in child:
                Dwgcbh = child1.attrib["Dwgcbh"]
                if Dwgcbh == id:
                    item = child1
                    break
            ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
    Fywj = None
    for child in item:
        if child.tag == 'Qtxm':
            Fywj= child
            break
    for child in Fywj:
        ##child is mx
        xh = child.attrib["Xh"]
        if "." in xh:
            count = 0
            for entry in xh:
                if entry == ".":
                    count = count + 1
            if count == 1:
                parent = result[-1]
                if "__children" in parent:
                    children = parent["__children"]
                    children.append(

                      {"序号":xh, "名称": child.attrib["Mc"], 
                       "金额": child.attrib["Je"],  "项目类别" : child.attrib["Xmlb"], "备注" : child.attrib["Bz"]}
                    )
                else:
                    parent["__children"] = [
                {"序号":xh, "名称": child.attrib["Mc"], 
                 "金额": child.attrib["Je"],  "项目类别" : child.attrib["Xmlb"], "备注" : child.attrib["Bz"]}]
                    

        else:
            result.append(
                {"序号":xh, "名称": child.attrib["Mc"], 
            "金额": child.attrib["Je"],  "项目类别" : child.attrib["Xmlb"], "备注" : child.attrib["Bz"]}
            )
    return result    

def getGfsj(root, id):
    result = []
    #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
    item = None
    for child in root:
    
        if child.tag == "Dxgcxx":
            for child1 in child:
                Dwgcbh = child1.attrib["Dwgcbh"]
                if Dwgcbh == id:
                    item = child1
                    break
            ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
    Fywj = None
    for child in item:
        if child.tag == 'Gfsj':
            Fywj= child
            break
    for child in Fywj:
        ##child is mx
        xh = child.attrib["Xh"]
        if "." in xh:
            count = 0
            for entry in xh:
                if entry == ".":
                    count = count + 1
            if count == 1:
                parent = result[-1]
                if "__children" in parent:
                    children = parent["__children"]
                    children.append({"序号":xh, "名称": child.attrib["Mc"], "取费基数": child.attrib["Qfjs"], "计算基础": child.attrib["Jsjc"], "金额": child.attrib["Je"],  "类别" : child.attrib["Fyxlb"]})
                else:
                    parent["__children"] = [{"序号":xh, "名称": child.attrib["Mc"], "取费基数": child.attrib["Qfjs"], "计算基础": child.attrib["Jsjc"], "金额": child.attrib["Je"],  "类别" : child.attrib["Fyxlb"]}]
            elif count == 2:
                parent = result[-1]
                if "__children" in parent:
                    parent = parent["__children"][-1]
                    print(parent)
                    if "__children" in parent:
                        children = parent["__children"]
                        children.append({"序号":xh, "名称": child.attrib["Mc"], "取费基数": child.attrib["Qfjs"], "计算基础": child.attrib["Jsjc"], "金额": child.attrib["Je"],  "类别" : child.attrib["Fyxlb"]})
                        
                    else:
                        parent["__children"] = [{"序号":xh, "名称": child.attrib["Mc"], "取费基数": child.attrib["Qfjs"], "计算基础": child.attrib["Jsjc"], "金额": child.attrib["Je"],  "类别" : child.attrib["Fyxlb"]}]
                    

        else:
            ###["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
            result.append({"序号":xh, "名称": child.attrib["Mc"], "取费基数": child.attrib["Qfjs"], "计算基础": child.attrib["Jsjc"], "金额": child.attrib["Je"],  "类别" : child.attrib["Fyxlb"]})



    return result

def getBjhz(root, id):
    print(root)
    print(id)
    result = []
    #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
    item = None
    for child in root:
    
        if child.tag == "Dxgcxx":
            for child1 in child:
                Dwgcbh = child1.attrib["Dwgcbh"]
                if Dwgcbh == id:
                    item = child1
                    break
            ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
    print(item)
    Fywj = None
    for child in item:
        if child.tag == 'Fywj':
            Fywj= child
            break
    for child in Fywj:
        ##child is mx
        xh = child.attrib["Xh"]
        if "." in xh:
            count = 0
            for entry in xh:
                if entry == ".":
                    count = count + 1
            if count == 1:
                parent = result[-1]
                if "__children" in parent:
                    children = parent["__children"]
                    children.append({"序号":xh, "名称": child.attrib["Mc"], "金额": child.attrib["Je"],   "暂估价" : child.attrib["Zgj"], "类别" : child.attrib["Fyxlb"]})
                else:
                    parent["__children"] = [{"序号":xh, "名称": child.attrib["Mc"], "金额": child.attrib["Je"],   "暂估价" : child.attrib["Zgj"], "类别" : child.attrib["Fyxlb"]}]
            elif count == 2:
                parent = result[-1]
                if "__children" in parent:
                    parent = parent["__children"][-1]
                    print(parent)
                    if "__children" in parent:
                        children = parent["__children"]
                        children.append({"序号":xh, "名称": child.attrib["Mc"], "金额": child.attrib["Je"],   "暂估价" : child.attrib["Zgj"], "类别" : child.attrib["Fyxlb"]})
                        
                    else:
                        parent["__children"] = [{"序号":xh, "名称": child.attrib["Mc"], "金额": child.attrib["Je"],   "暂估价" : child.attrib["Zgj"], "类别" : child.attrib["Fyxlb"]}]
                    

        else:
            ###"序号", "名称", "金额", "暂估价", "类别"]
            result.append({"序号":xh, "名称": child.attrib["Mc"], "金额": child.attrib["Je"], 
             "暂估价" : child.attrib["Zgj"], "类别" : child.attrib["Fyxlb"]})



    return result



def processDes(dataframe, from_, end, level):
    result = []
    for i  in range(from_, end):
        item = dataframe.iloc[i]
        fbcch = str(item['fbcch'])
        if fbcch == str(level):
            entry = {"id": str(item["ID"]), "label": str(item["zjbt"])}
            next = i + 1
            while next < end and str(dataframe.iloc[next]["fbcch"]) != str(level):
                next = next + 1
            entry["children"] = processDes(dataframe, i + 1, next, level + 1)
            result.append(entry)
    return result

def processPbs(dataframe, from_, end, level):
    result = []
    for i  in range(from_, end):
        item = dataframe.iloc[i]
        fbcch = str(item['fbcch'])
        if fbcch == str(level):
            entry = {"id": str(item["ID"]), "label": str(item["flmc"]), "data": item["pblbh"]}
            next = i + 1
            while next < end and str(dataframe.iloc[next]["fbcch"]) != str(level):
                next = next + 1
            entry["children"] = processPbs(dataframe, i + 1, next, level + 1)
            result.append(entry)
    return result

def getDes(value):
    if value == 10:
        shu = pd.read_csv("de/tj/JD_DingEShu.csv")
    elif value == 20:
        shu = pd.read_csv("de/sz/JD_DingEShu.csv")
    elif value == 30:
        shu = pd.read_csv("de/az/JD_DingEShu.csv")
    elif value == 40:
        shu = pd.read_csv("de/yl/JD_DingEShu.csv")
    elif value == 50:
        shu = pd.read_csv("de/xstj/JD_DingEShu.csv")
    else:
        shu = pd.read_csv("de/xsaz/JD_DingEShu.csv")
    length = len(shu)
    return processDes(shu, 1, length, 2)
def getPbs(value):
    if value == 10:
        shu = pd.read_csv("de/tj/JD_PeiBiFLB.csv")
    else: 
        shu = pd.read_csv("de/sz/JD_PeiBiFLB.csv")
    length = len(shu)
    return processPbs(shu, 0, length, 1)

def getDeXilie(value, id):
    print(type(id))
    if value == 10:
        shu = pd.read_csv("de/tj/JD_DingEShu.csv")
    elif value == 20:
        shu = pd.read_csv("de/sz/JD_DingEShu.csv")
    elif value == 30:
        shu = pd.read_csv("de/az/JD_DingEShu.csv")
    elif value == 40:
        shu = pd.read_csv("de/yl/JD_DingEShu.csv")
    elif value == 50:
        shu = pd.read_csv("de/xstj/JD_DingEShu.csv")
    else:
        shu = pd.read_csv("de/xsaz/JD_DingEShu.csv")
    hit = shu[shu["ID"]==int(id)]
    print(hit)
    if len(hit) == 0:
        return []
    hit0 = hit.iloc[0]
    index = str(hit0['zjh'])
    print("index=" + index)
    if value == 10:
        gj = pd.read_csv("de/tj/JD_DanWeiGJ.csv")
        filtered = gj[gj["YSDELBH"]==int(index)]
    elif value == 20:
        gj = pd.read_csv("de/sz/JD_DanWeiGJ.csv")
        filtered = gj[gj["YSDELBH"]==(index)]
    elif value == 30:
        gj = pd.read_csv("de/az/JD_DanWeiGJ.csv")
        filtered = gj[gj["YSDELBH"]==(index)]
    elif value == 40:
        gj = pd.read_csv("de/yl/JD_DanWeiGJ.csv")
        filtered = gj[gj["YSDELBH"]==int(index)]
    elif value == 50:
        gj = pd.read_csv("de/xstj/JD_DanWeiGJ.csv")
        filtered = gj[gj["YSDELBH"]==int(index)]
    else:
        gj = pd.read_csv("de/xsaz/JD_DanWeiGJ.csv")
        filtered = gj[gj["YSDELBH"]==int(index)]
    return filtered.to_json(force_ascii=False)

def getPbxl(name):
    shu = pd.read_csv("de/tj/JD_PeiBiFLB.csv")
    hit = shu[shu["ID"]==int(name)]
    print(hit)
    if len(hit) == 0:
        return []
    hit0 = hit.iloc[0]
    index = str(hit0['pblbh'])
    index_list = index.split(";")
    gj = pd.read_csv("de/tj/JD_PeiBi.csv")
    filtered = gj[gj["PBBH"].str.startswith(tuple(index_list))]
    return filtered.to_json(force_ascii=False)


def getSingleDeXilie(zhuanye, debh):
    if zhuanye == 10:
        A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_tj(debh)
        if A1:
            return A1, A2, A3, A4, A5, A6, A7, 10
        else:
            A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_sz(debh)
            return A1, A2, A3, A4,A5, A6, A7, 20
    elif zhuanye == 20:##shizheng
        A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_sz(debh)
        if A1:
            return A1, A2, A3, A4, A5, A6, A7, 20
        else:
            A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_tj(debh)
            if A1:
                return A1, A2, A3, A4, A5, A6, A7, 10
            else:
                A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_az(debh)
                return A1, A2, A3, A4, A5, A6, A7, 30
    elif zhuanye == 30:##anzhuang
        A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_az(debh)
        return A1, A2, A3, A4, A5, A6, A7, 30
    elif zhuanye == 40:##yuanlin
        A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_yl(debh)
        return A1, A2, A3, A4, A5, A6, A7,  40  
    elif zhuanye == 50: ## xiushan tujian
        A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_xstj(debh)
        if A1:
            return A1, A2, A3, A4, A5, A6, A7, 50
        else:
            A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_tj(debh)
            return A1, A2, A3, A4,A5, A6, A7, 10
    else:
        A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_xsaz(debh)
        if A1:
            return A1, A2, A3, A4, A5, A6, A7, 60
        else:
            A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_az(debh)
            return A1, A2, A3, A4,A5, A6, A7, 30


def getSingleDeXilie_xsaz(debh):
    id = None
    bz_selected = []
    bz_selected2 = []
    if "附注" in debh:
        position = debh.find("附注")
        debh = debh[:position]
    if "*" in debh:
        position = debh.find("*")
        debh = debh[:position]
    if debh.endswith("换"):
        debh = debh[:-1]
    if "[" in debh:
        position = debh.find("[")
        debh = debh[:position-1]
    gj = pd.read_csv("de/xsaz/JD_DanWeiGJ.csv")
    filtered = gj[gj["DEBH"]==debh]
    print(filtered)
    if len(filtered) > 0:
        index = (filtered.iloc[0]["YSDELBH"])
        shu = pd.read_csv("de/xsaz/JD_DingEShu.csv")
        hit = shu[shu["zjh"]==index]
        if len(hit) > 0:
            id = hit.iloc[0]["ID"]
        beizhu = str(filtered.iloc[0]["BZBH"])
        if 'nan' in beizhu:
            pass
        else:
            beizhus = beizhu.split(";")
            print(beizhus)
            bzfile = pd.read_csv("de/xsaz/JD_BeiZhuZK.csv")
            bzfile2 = pd.read_csv("de/xsaz/JD_BeiZhuFK.csv", dtype=str)
            bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)] 
            bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)] 
    else:
        return None, None, None, None, None, None, None
    ####rengong
    rgde = []
    rg = pd.read_csv("de/xsaz/JD_GuJiaRG.csv")
    filtered1 = rg[rg["DEBH"]==debh]
    for i in range(len(filtered1)):
        rgde_ = {}
        gr = filtered1.iloc[i]["RGR"]##gongri
        gf = filtered1.iloc[i]["RGF"]##gongfei
        rcjID = filtered1.iloc[i]["RcjID"]
        detail = pd.read_csv("de/xsaz/JD_CaiLiaoK.csv")
        filtered2 = detail[detail["RcjID"]==rcjID]
        if len(filtered2) > 0:
            CLBH = filtered2.iloc[0]["CLBH"]
            CLMC = filtered2.iloc[0]["CLMC"]
            JLDW = filtered2.iloc[0]["JLDW"]
            YSJG = filtered2.iloc[0]["YSJG"]
            rgde_["CLBH"] = CLBH
            rgde_["CLMC"] = CLMC
            rgde_["JLDW"] = JLDW
            rgde_["YSJG"] = YSJG.item()
            rgde_["gr"] = gr.item()
            rgde_["gf"] = gf.item()
        rgde.append(rgde_)
    ##print(rgde)
    ####jixie
    jxde = []
    jx = pd.read_csv("de/xsaz/JD_GuJiaJX.csv")
    filtered1 = jx[jx["DEBH"]==debh]
    for i in range(len(filtered1)):
        jxde_ = {}
        sl = filtered1.iloc[i]["SL"]##shuliang
        hj = filtered1.iloc[i]["HJ"]##hejia
        rcjID = filtered1.iloc[i]["RcjID"]
        detail = pd.read_csv("de/xsaz/JD_JiXieK.csv")
        filtered2 = detail[detail["RcjID"]==rcjID]
        if len(filtered2) > 0:
            jxbh = filtered2.iloc[0]["jxbh"]
            jxmc = filtered2.iloc[0]["jxmc"]
            DW = filtered2.iloc[0]["DW"]
            tbdj = filtered2.iloc[0]["tbdj"]
            jxde_["jxbh"] = jxbh
            jxde_["jxmc"] = jxmc
            jxde_["DW"] = DW
            jxde_["tbdj"] = tbdj.item()
            jxde_["sl"] = sl.item()
            jxde_["hj"] = hj.item()
        jxde.append(jxde_)
    ####cailiao
    clde = []
    cl = pd.read_csv("de/xsaz/JD_GuJiaCL.csv")
    filtered1 = cl[cl["DEBH"]==debh]
    for i in range(len(filtered1)):
        clde_ = {}
        SL = filtered1.iloc[i]["SL"]##shuliang
        HJ = filtered1.iloc[i]["HJ"]##hejia
        rcjID = filtered1.iloc[i]["RcjID"]
        detail = pd.read_csv("de/xsaz/JD_CaiLiaoK.csv")
        filtered2 = detail[detail["RcjID"]==rcjID]
        if len(filtered2) > 0:
            CLBH = filtered2.iloc[0]["CLBH"]
            CLMC = filtered2.iloc[0]["CLMC"]
            JLDW = filtered2.iloc[0]["JLDW"]
            YSJG = filtered2.iloc[0]["YSJG"]
            clde_["CLBH"] = CLBH
            clde_["CLMC"] = CLMC
            clde_["JLDW"] = JLDW
            clde_["YSJG"] = YSJG.item()
            clde_["SL"] = SL.item()
            clde_["HJ"] = HJ.item()
            clde.append(clde_)
        else:
            detail = pd.read_csv("de/xsaz/JD_PeiBi.csv")
            filtered2 = detail[detail["RcjID"]==rcjID]
            if len(filtered2) > 0:
                CLBH = filtered2.iloc[0]["PBBH"]
                CLMC = filtered2.iloc[0]["PBMC"]
                JLDW = filtered2.iloc[0]["DW"]
                YSJG = filtered2.iloc[0]["PBDJ"]
                clde_["CLBH"] = CLBH.item()
                clde_["CLMC"] = CLMC
                clde_["JLDW"] = JLDW
                clde_["YSJG"] = YSJG.item()
                clde_["SL"] = SL.item()
                clde_["HJ"] = HJ.item()
                clde.append(clde_)
    return filtered.to_json(force_ascii=False), id, rgde, jxde, clde, bz_selected.to_json(force_ascii=False) if len(bz_selected) > 0 else None, bz_selected2.to_json(force_ascii=False) if len(bz_selected2) > 0 else None





def getSingleDeXilie_xstj(debh):
    id = None
    bz_selected = []
    bz_selected2 = []
    if "附注" in debh:
        position = debh.find("附注")
        debh = debh[:position]
    if "*" in debh:
        position = debh.find("*")
        debh = debh[:position]
    if debh.endswith("换"):
        debh = debh[:-1]
    if "[" in debh:
        position = debh.find("[")
        debh = debh[:position-1]
    gj = pd.read_csv("de/xstj/JD_DanWeiGJ.csv")
    filtered = gj[gj["DEBH"]==debh]
    print(filtered)
    if len(filtered) > 0:
        index = (filtered.iloc[0]["YSDELBH"])
        shu = pd.read_csv("de/xstj/JD_DingEShu.csv")
        hit = shu[shu["zjh"]==index]
        if len(hit) > 0:
            id = hit.iloc[0]["ID"]
        beizhu = str(filtered.iloc[0]["BZBH"])
        if 'nan' in beizhu:
            pass
        else:
            beizhus = beizhu.split(";")
            print(beizhus)
            bzfile = pd.read_csv("de/xstj/JD_BeiZhuZK.csv")
            bzfile2 = pd.read_csv("de/xstj/JD_BeiZhuFK.csv", dtype=str)
            bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)] 
            bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)] 
    else:
        return None, None, None, None, None, None, None
    ####rengong
    rgde = []
    rg = pd.read_csv("de/xstj/JD_GuJiaRG.csv")
    filtered1 = rg[rg["DEBH"]==debh]
    for i in range(len(filtered1)):
        rgde_ = {}
        gr = filtered1.iloc[i]["RGR"]##gongri
        gf = filtered1.iloc[i]["RGF"]##gongfei
        rcjID = filtered1.iloc[i]["RcjID"]
        detail = pd.read_csv("de/xstj/JD_CaiLiaoK.csv")
        filtered2 = detail[detail["RcjID"]==rcjID]
        if len(filtered2) > 0:
            CLBH = filtered2.iloc[0]["CLBH"]
            CLMC = filtered2.iloc[0]["CLMC"]
            JLDW = filtered2.iloc[0]["JLDW"]
            YSJG = filtered2.iloc[0]["YSJG"]
            rgde_["CLBH"] = CLBH
            rgde_["CLMC"] = CLMC
            rgde_["JLDW"] = JLDW
            rgde_["YSJG"] = YSJG.item()
            rgde_["gr"] = gr.item()
            rgde_["gf"] = gf.item()
        rgde.append(rgde_)
    ##print(rgde)
    ####jixie
    jxde = []
    jx = pd.read_csv("de/xstj/JD_GuJiaJX.csv")
    filtered1 = jx[jx["DEBH"]==debh]
    for i in range(len(filtered1)):
        jxde_ = {}
        sl = filtered1.iloc[i]["SL"]##shuliang
        hj = filtered1.iloc[i]["HJ"]##hejia
        rcjID = filtered1.iloc[i]["RcjID"]
        detail = pd.read_csv("de/xstj/JD_JiXieK.csv")
        filtered2 = detail[detail["RcjID"]==rcjID]
        if len(filtered2) > 0:
            jxbh = filtered2.iloc[0]["jxbh"]
            jxmc = filtered2.iloc[0]["jxmc"]
            DW = filtered2.iloc[0]["DW"]
            tbdj = filtered2.iloc[0]["tbdj"]
            jxde_["jxbh"] = jxbh
            jxde_["jxmc"] = jxmc
            jxde_["DW"] = DW
            jxde_["tbdj"] = tbdj.item()
            jxde_["sl"] = sl.item()
            jxde_["hj"] = hj.item()
        jxde.append(jxde_)
    ####cailiao
    clde = []
    cl = pd.read_csv("de/xstj/JD_GuJiaCL.csv")
    filtered1 = cl[cl["DEBH"]==debh]
    for i in range(len(filtered1)):
        clde_ = {}
        SL = filtered1.iloc[i]["SL"]##shuliang
        HJ = filtered1.iloc[i]["HJ"]##hejia
        rcjID = filtered1.iloc[i]["RcjID"]
        detail = pd.read_csv("de/xstj/JD_CaiLiaoK.csv")
        filtered2 = detail[detail["RcjID"]==rcjID]
        if len(filtered2) > 0:
            CLBH = filtered2.iloc[0]["CLBH"]
            CLMC = filtered2.iloc[0]["CLMC"]
            JLDW = filtered2.iloc[0]["JLDW"]
            YSJG = filtered2.iloc[0]["YSJG"]
            clde_["CLBH"] = CLBH
            clde_["CLMC"] = CLMC
            clde_["JLDW"] = JLDW
            clde_["YSJG"] = YSJG.item()
            clde_["SL"] = SL.item()
            clde_["HJ"] = HJ.item()
            clde.append(clde_)
        else:
            detail = pd.read_csv("de/xstj/JD_PeiBi.csv")
            filtered2 = detail[detail["RcjID"]==rcjID]
            if len(filtered2) > 0:
                CLBH = filtered2.iloc[0]["PBBH"]
                CLMC = filtered2.iloc[0]["PBMC"]
                JLDW = filtered2.iloc[0]["DW"]
                YSJG = filtered2.iloc[0]["PBDJ"]
                clde_["CLBH"] = CLBH.item()
                clde_["CLMC"] = CLMC
                clde_["JLDW"] = JLDW
                clde_["YSJG"] = YSJG.item()
                clde_["SL"] = SL.item()
                clde_["HJ"] = HJ.item()
                clde.append(clde_)
    return filtered.to_json(force_ascii=False), id, rgde, jxde, clde, bz_selected.to_json(force_ascii=False) if len(bz_selected) > 0 else None, bz_selected2.to_json(force_ascii=False) if len(bz_selected2) > 0 else None


def getSingleDeXilie_yl(debh):
    id = None
    bz_selected = []
    bz_selected2 = []
    if "附注" in debh:
        position = debh.find("附注")
        debh = debh[:position]
    if "*" in debh:
        position = debh.find("*")
        debh = debh[:position]
    if debh.endswith("换"):
        debh = debh[:-1]
    if "[" in debh:
        position = debh.find("[")
        debh = debh[:position-1]
    gj = pd.read_csv("de/yl/JD_DanWeiGJ.csv")
    filtered = gj[gj["DEBH"]==debh]
    print(filtered)
    if len(filtered) > 0:
        index = (filtered.iloc[0]["YSDELBH"])
        shu = pd.read_csv("de/yl/JD_DingEShu.csv")
        hit = shu[shu["zjh"]==index]
        if len(hit) > 0:
            id = hit.iloc[0]["ID"]
        beizhu = str(filtered.iloc[0]["BZBH"])
        if 'nan' in beizhu:
            pass
        else:
            beizhus = beizhu.split(";")
            print(beizhus)
            bzfile = pd.read_csv("de/yl/JD_BeiZhuZK.csv")
            bzfile2 = pd.read_csv("de/yl/JD_BeiZhuFK.csv", dtype=str)
            bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)] 
            bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)] 
    else:
        return None, None, None, None, None, None, None
    ####rengong
    rgde = []
    rg = pd.read_csv("de/yl/JD_GuJiaRG.csv")
    filtered1 = rg[rg["DEBH"]==debh]
    for i in range(len(filtered1)):
        rgde_ = {}
        gr = filtered1.iloc[i]["RGR"]##gongri
        gf = filtered1.iloc[i]["RGF"]##gongfei
        rcjID = filtered1.iloc[i]["RcjID"]
        detail = pd.read_csv("de/yl/JD_CaiLiaoK.csv")
        filtered2 = detail[detail["RcjID"]==rcjID]
        if len(filtered2) > 0:
            CLBH = filtered2.iloc[0]["CLBH"]
            CLMC = filtered2.iloc[0]["CLMC"]
            JLDW = filtered2.iloc[0]["JLDW"]
            YSJG = filtered2.iloc[0]["YSJG"]
            rgde_["CLBH"] = CLBH
            rgde_["CLMC"] = CLMC
            rgde_["JLDW"] = JLDW
            rgde_["YSJG"] = YSJG.item()
            rgde_["gr"] = gr.item()
            rgde_["gf"] = gf.item()
        rgde.append(rgde_)
    ##print(rgde)
    ####jixie
    jxde = []
    jx = pd.read_csv("de/yl/JD_GuJiaJX.csv")
    filtered1 = jx[jx["DEBH"]==debh]
    for i in range(len(filtered1)):
        jxde_ = {}
        sl = filtered1.iloc[i]["SL"]##shuliang
        hj = filtered1.iloc[i]["HJ"]##hejia
        rcjID = filtered1.iloc[i]["RcjID"]
        detail = pd.read_csv("de/yl/JD_JiXieK.csv")
        filtered2 = detail[detail["RcjID"]==rcjID]
        if len(filtered2) > 0:
            jxbh = filtered2.iloc[0]["jxbh"]
            jxmc = filtered2.iloc[0]["jxmc"]
            DW = filtered2.iloc[0]["DW"]
            tbdj = filtered2.iloc[0]["tbdj"]
            jxde_["jxbh"] = jxbh
            jxde_["jxmc"] = jxmc
            jxde_["DW"] = DW
            jxde_["tbdj"] = tbdj.item()
            jxde_["sl"] = sl.item()
            jxde_["hj"] = hj.item()
        jxde.append(jxde_)
    ####cailiao
    clde = []
    cl = pd.read_csv("de/yl/JD_GuJiaCL.csv")
    filtered1 = cl[cl["DEBH"]==debh]
    for i in range(len(filtered1)):
        clde_ = {}
        SL = filtered1.iloc[i]["SL"]##shuliang
        HJ = filtered1.iloc[i]["HJ"]##hejia
        rcjID = filtered1.iloc[i]["RcjID"]
        detail = pd.read_csv("de/yl/JD_CaiLiaoK.csv")
        filtered2 = detail[detail["RcjID"]==rcjID]
        if len(filtered2) > 0:
            CLBH = filtered2.iloc[0]["CLBH"]
            CLMC = filtered2.iloc[0]["CLMC"]
            JLDW = filtered2.iloc[0]["JLDW"]
            YSJG = filtered2.iloc[0]["YSJG"]
            clde_["CLBH"] = CLBH
            clde_["CLMC"] = CLMC
            clde_["JLDW"] = JLDW
            clde_["YSJG"] = YSJG.item()
            clde_["SL"] = SL.item()
            clde_["HJ"] = HJ.item()
            clde.append(clde_)
        else:
            detail = pd.read_csv("de/yl/JD_PeiBi.csv")
            filtered2 = detail[detail["RcjID"]==rcjID]
            if len(filtered2) > 0:
                CLBH = filtered2.iloc[0]["PBBH"]
                CLMC = filtered2.iloc[0]["PBMC"]
                JLDW = filtered2.iloc[0]["DW"]
                YSJG = filtered2.iloc[0]["PBDJ"]
                clde_["CLBH"] = CLBH.item()
                clde_["CLMC"] = CLMC
                clde_["JLDW"] = JLDW
                clde_["YSJG"] = YSJG.item()
                clde_["SL"] = SL.item()
                clde_["HJ"] = HJ.item()
                clde.append(clde_)
    return filtered.to_json(force_ascii=False), id, rgde, jxde, clde, bz_selected.to_json(force_ascii=False) if len(bz_selected) > 0 else None, bz_selected2.to_json(force_ascii=False) if len(bz_selected2) > 0 else None



def getSingleDeXilie_az(debh):
    id = None
    bz_selected = []
    bz_selected2 = []
    if "附注" in debh:
        position = debh.find("附注")
        debh = debh[:position]
    if "*" in debh:
        position = debh.find("*")
        debh = debh[:position]
    if debh.endswith("换"):
        debh = debh[:-1]
    if "[" in debh:
        position = debh.find("[")
        debh = debh[:position-1]
    gj = pd.read_csv("de/az/JD_DanWeiGJ.csv")
    filtered = gj[gj["DEBH"]==debh]
    print(filtered)
    if len(filtered) > 0:
        index = (filtered.iloc[0]["YSDELBH"])
        shu = pd.read_csv("de/az/JD_DingEShu.csv")
        hit = shu[shu["zjh"]==index]
        if len(hit) > 0:
            id = hit.iloc[0]["ID"]
        beizhu = str(filtered.iloc[0]["BZBH"])
        if 'nan' in beizhu:
            pass
        else:
            beizhus = beizhu.split(";")
            print(beizhus)
            bzfile = pd.read_csv("de/az/JD_BeiZhuZK.csv")
            bzfile2 = pd.read_csv("de/az/JD_BeiZhuFK.csv", dtype=str)
            bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)] 
            bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)] 
    else:
        return None, None, None, None, None, None, None
    ####rengong
    rgde = []
    rg = pd.read_csv("de/az/JD_GuJiaRG.csv")
    filtered1 = rg[rg["DEBH"]==debh]
    for i in range(len(filtered1)):
        rgde_ = {}
        gr = filtered1.iloc[i]["RGR"]##gongri
        gf = filtered1.iloc[i]["RGF"]##gongfei
        rcjID = filtered1.iloc[i]["RcjID"]
        detail = pd.read_csv("de/az/JD_CaiLiaoK.csv")
        filtered2 = detail[detail["RcjID"]==rcjID]
        if len(filtered2) > 0:
            CLBH = filtered2.iloc[0]["CLBH"]
            CLMC = filtered2.iloc[0]["CLMC"]
            JLDW = filtered2.iloc[0]["JLDW"]
            YSJG = filtered2.iloc[0]["YSJG"]
            rgde_["CLBH"] = CLBH
            rgde_["CLMC"] = CLMC
            rgde_["JLDW"] = JLDW
            rgde_["YSJG"] = YSJG
            rgde_["gr"] = gr
            rgde_["gf"] = gf
        rgde.append(rgde_)
    ##print(rgde)
    ####jixie
    jxde = []
    jx = pd.read_csv("de/az/JD_GuJiaJX.csv")
    filtered1 = jx[jx["DEBH"]==debh]
    for i in range(len(filtered1)):
        jxde_ = {}
        sl = filtered1.iloc[i]["SL"]##shuliang
        hj = filtered1.iloc[i]["HJ"]##hejia
        rcjID = filtered1.iloc[i]["RcjID"]
        detail = pd.read_csv("de/az/JD_JiXieK.csv")
        filtered2 = detail[detail["RcjID"]==rcjID]
        if len(filtered2) > 0:
            jxbh = filtered2.iloc[0]["jxbh"]
            jxmc = filtered2.iloc[0]["jxmc"]
            DW = filtered2.iloc[0]["DW"]
            tbdj = filtered2.iloc[0]["tbdj"]
            jxde_["jxbh"] = jxbh
            jxde_["jxmc"] = jxmc
            jxde_["DW"] = DW
            jxde_["tbdj"] = tbdj
            jxde_["sl"] = sl
            jxde_["hj"] = hj
        jxde.append(jxde_)
    ####cailiao
    clde = []
    cl = pd.read_csv("de/az/JD_GuJiaCL.csv")
    filtered1 = cl[cl["DEBH"]==debh]
    for i in range(len(filtered1)):
        clde_ = {}
        SL = filtered1.iloc[i]["SL"]##shuliang
        HJ = filtered1.iloc[i]["HJ"]##hejia
        rcjID = filtered1.iloc[i]["RcjID"]
        detail = pd.read_csv("de/az/JD_CaiLiaoK.csv")
        filtered2 = detail[detail["RcjID"]==rcjID]
        if len(filtered2) > 0:
            CLBH = filtered2.iloc[0]["CLBH"]
            CLMC = filtered2.iloc[0]["CLMC"]
            JLDW = filtered2.iloc[0]["JLDW"]
            YSJG = filtered2.iloc[0]["YSJG"]
            clde_["CLBH"] = CLBH
            clde_["CLMC"] = CLMC
            clde_["JLDW"] = JLDW
            clde_["YSJG"] = YSJG
            clde_["SL"] = SL
            clde_["HJ"] = HJ
            clde.append(clde_)
        else:
            detail = pd.read_csv("de/az/JD_PeiBi.csv")
            filtered2 = detail[detail["RcjID"]==rcjID]
            if len(filtered2) > 0:
                CLBH = filtered2.iloc[0]["PBBH"]
                CLMC = filtered2.iloc[0]["PBMC"]
                JLDW = filtered2.iloc[0]["DW"]
                YSJG = filtered2.iloc[0]["PBDJ"]
                clde_["CLBH"] = CLBH
                clde_["CLMC"] = CLMC
                clde_["JLDW"] = JLDW
                clde_["YSJG"] = YSJG
                clde_["SL"] = SL
                clde_["HJ"] = HJ
                clde.append(clde_)
    return filtered.to_json(force_ascii=False), id, rgde, jxde, clde, bz_selected.to_json(force_ascii=False) if len(bz_selected) > 0 else None, bz_selected2.to_json(force_ascii=False) if len(bz_selected2) > 0 else None



def getSingleDeXilie_sz(debh):
    id = None
    bz_selected = []
    bz_selected2 = []
    if "附注" in debh:
        position = debh.find("附注")
        debh = debh[:position]
    if "*" in debh:
        position = debh.find("*")
        debh = debh[:position]
    if debh.endswith("换"):
        debh = debh[:-1]
    if "[" in debh:
        position = debh.find("[")
        debh = debh[:position-1]
    gj = pd.read_csv("de/sz/JD_DanWeiGJ.csv")
    filtered = gj[gj["DEBH"]==debh]
    print(filtered)
    if len(filtered) > 0:
        index = (filtered.iloc[0]["YSDELBH"])
        shu = pd.read_csv("de/sz/JD_DingEShu.csv")
        hit = shu[shu["zjh"]==index]
        if len(hit) > 0:
            id = hit.iloc[0]["ID"]
        beizhu = str(filtered.iloc[0]["BZBH"])
        if 'nan' in beizhu:
            pass
        else:
            beizhus = beizhu.split(";")
            print(beizhus)
            bzfile = pd.read_csv("de/sz/JD_BeiZhuZK.csv")
            bzfile2 = pd.read_csv("de/sz/JD_BeiZhuFK.csv", dtype=str)
            bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)] 
            bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)] 
    else:
        return None, None, None, None, None, None, None
    ####rengong
    rgde = []
    rg = pd.read_csv("de/sz/JD_GuJiaRG.csv")
    filtered1 = rg[rg["DEBH"]==debh]
    for i in range(len(filtered1)):
        rgde_ = {}
        gr = filtered1.iloc[i]["RGR"]##gongri
        gf = filtered1.iloc[i]["RGF"]##gongfei
        rcjID = filtered1.iloc[i]["RcjID"]
        detail = pd.read_csv("de/sz/JD_CaiLiaoK.csv")
        filtered2 = detail[detail["RcjID"]==rcjID]
        if len(filtered2) > 0:
            CLBH = filtered2.iloc[0]["CLBH"]
            CLMC = filtered2.iloc[0]["CLMC"]
            JLDW = filtered2.iloc[0]["JLDW"]
            YSJG = filtered2.iloc[0]["YSJG"]
            rgde_["CLBH"] = CLBH
            rgde_["CLMC"] = CLMC
            rgde_["JLDW"] = JLDW
            rgde_["YSJG"] = YSJG
            rgde_["gr"] = gr
            rgde_["gf"] = gf
        rgde.append(rgde_)
    ##print(rgde)
    ####jixie
    jxde = []
    jx = pd.read_csv("de/sz/JD_GuJiaJX.csv")
    filtered1 = jx[jx["DEBH"]==debh]
    for i in range(len(filtered1)):
        jxde_ = {}
        sl = filtered1.iloc[i]["SL"]##shuliang
        hj = filtered1.iloc[i]["HJ"]##hejia
        rcjID = filtered1.iloc[i]["RcjID"]
        detail = pd.read_csv("de/sz/JD_JiXieK.csv")
        filtered2 = detail[detail["RcjID"]==rcjID]
        if len(filtered2) > 0:
            jxbh = filtered2.iloc[0]["jxbh"]
            jxmc = filtered2.iloc[0]["jxmc"]
            DW = filtered2.iloc[0]["DW"]
            tbdj = filtered2.iloc[0]["tbdj"]
            jxde_["jxbh"] = jxbh
            jxde_["jxmc"] = jxmc
            jxde_["DW"] = DW
            jxde_["tbdj"] = tbdj
            jxde_["sl"] = sl
            jxde_["hj"] = hj
        jxde.append(jxde_)
    ####cailiao
    clde = []
    cl = pd.read_csv("de/sz/JD_GuJiaCL.csv")
    filtered1 = cl[cl["DEBH"]==debh]
    for i in range(len(filtered1)):
        clde_ = {}
        SL = filtered1.iloc[i]["SL"]##shuliang
        HJ = filtered1.iloc[i]["HJ"]##hejia
        rcjID = filtered1.iloc[i]["RcjID"]
        detail = pd.read_csv("de/sz/JD_CaiLiaoK.csv")
        filtered2 = detail[detail["RcjID"]==rcjID]
        if len(filtered2) > 0:
            CLBH = filtered2.iloc[0]["CLBH"]
            CLMC = filtered2.iloc[0]["CLMC"]
            JLDW = filtered2.iloc[0]["JLDW"]
            YSJG = filtered2.iloc[0]["YSJG"]
            clde_["CLBH"] = CLBH
            clde_["CLMC"] = CLMC
            clde_["JLDW"] = JLDW
            clde_["YSJG"] = YSJG
            clde_["SL"] = SL
            clde_["HJ"] = HJ
            clde.append(clde_)
        else:
            detail = pd.read_csv("de/sz/JD_PeiBi.csv")
            filtered2 = detail[detail["RcjID"]==rcjID]
            if len(filtered2) > 0:
                CLBH = filtered2.iloc[0]["PBBH"]
                CLMC = filtered2.iloc[0]["PBMC"]
                JLDW = filtered2.iloc[0]["DW"]
                YSJG = filtered2.iloc[0]["PBDJ"]
                clde_["CLBH"] = CLBH
                clde_["CLMC"] = CLMC
                clde_["JLDW"] = JLDW
                clde_["YSJG"] = YSJG
                clde_["SL"] = SL
                clde_["HJ"] = HJ
                clde.append(clde_)
    return filtered.to_json(force_ascii=False), id, rgde, jxde, clde, bz_selected.to_json(force_ascii=False) if len(bz_selected) > 0 else None, bz_selected2.to_json(force_ascii=False) if len(bz_selected2) > 0 else None
        
        
def getSingleDeXilie_tj(debh):
    id = None
    bz_selected = []
    bz_selected2 = []
       

    if "附注" in debh:
        position = debh.find("附注")
        debh = debh[:position]
    if "*" in debh:
        position = debh.find("*")
        debh = debh[:position]
    if debh.endswith("换"):
        debh = debh[:-1]
    if "[" in debh:
        position = debh.find("[")
        debh = debh[:position-1]
    gj = pd.read_csv("de/tj/JD_DanWeiGJ.csv")
    filtered = gj[gj["DEBH"]==debh]
    print(filtered)
    if len(filtered) > 0:
        index = int(filtered.iloc[0]["YSDELBH"])
        shu = pd.read_csv("de/tj/JD_DingEShu.csv")
        hit = shu[shu["zjh"]==index]
        if len(hit) > 0:
            id = hit.iloc[0]["ID"]
        beizhu = str(filtered.iloc[0]["BZBH"])
        if 'nan' in beizhu:
            pass
        else:
            beizhus = beizhu.split(";")
            print(beizhus)
            bzfile = pd.read_csv("de/tj/JD_BeiZhuZK.csv")
            bzfile2 = pd.read_csv("de/tj/JD_BeiZhuFK.csv", dtype=str)
            bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)] 
            bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)]
    else:
        return None, None, None, None, None, None, None
    ####rengong
    rgde = []
    rg = pd.read_csv("de/tj/JD_GuJiaRG.csv")
    filtered1 = rg[rg["DEBH"]==debh]
    for i in range(len(filtered1)):
        rgde_ = {}
        gr = filtered1.iloc[i]["RGR"]##gongri
        gf = filtered1.iloc[i]["RGF"]##gongfei
        rcjID = filtered1.iloc[i]["RcjID"]
        detail = pd.read_csv("de/tj/JD_CaiLiaoK.csv")
        filtered2 = detail[detail["RcjID"]==rcjID]
        if len(filtered2) > 0:
            CLBH = filtered2.iloc[0]["CLBH"]
            CLMC = filtered2.iloc[0]["CLMC"]
            JLDW = filtered2.iloc[0]["JLDW"]
            YSJG = filtered2.iloc[0]["YSJG"]
            rgde_["CLBH"] = CLBH
            rgde_["CLMC"] = CLMC
            rgde_["JLDW"] = JLDW
            rgde_["YSJG"] = YSJG.item() if type(YSJG) == float64 else YSJG
            rgde_["gr"] = gr.item() if type(gr) == float64 else gr
            rgde_["gf"] = gf.item() if type(gf) == float64 else gf
        rgde.append(rgde_)
    ##print(rgde)
    ####jixie
    jxde = []
    jx = pd.read_csv("de/tj/JD_GuJiaJX.csv")
    filtered1 = jx[jx["DEBH"]==debh]
    for i in range(len(filtered1)):
        jxde_ = {}
        sl = filtered1.iloc[i]["SL"]##shuliang
        hj = filtered1.iloc[i]["HJ"]##hejia
        rcjID = filtered1.iloc[i]["RcjID"]
        detail = pd.read_csv("de/tj/JD_JiXieK.csv")
        filtered2 = detail[detail["RcjID"]==rcjID]
        if len(filtered2) > 0:
            jxbh = filtered2.iloc[0]["jxbh"]
            jxmc = filtered2.iloc[0]["jxmc"]
            DW = filtered2.iloc[0]["DW"]
            tbdj = filtered2.iloc[0]["tbdj"]
            jxde_["jxbh"] = jxbh
            jxde_["jxmc"] = jxmc
            jxde_["DW"] = DW
            jxde_["tbdj"] = tbdj.item() if type(tbdj) == float64 else tbdj
            jxde_["sl"] = sl.item() if type(sl) == float64 else sl
            jxde_["hj"] = hj.item() if type(hj) == float64 else hj
        jxde.append(jxde_)
    ####cailiao
    clde = []
    cl = pd.read_csv("de/tj/JD_GuJiaCL.csv")
    filtered1 = cl[cl["DEBH"]==debh]
    for i in range(len(filtered1)):
        clde_ = {}
        SL = filtered1.iloc[i]["SL"]##shuliang
        HJ = filtered1.iloc[i]["HJ"]##hejia
        rcjID = filtered1.iloc[i]["RcjID"]
        detail = pd.read_csv("de/tj/JD_CaiLiaoK.csv")
        filtered2 = detail[detail["RcjID"]==rcjID]
        if len(filtered2) > 0:
            CLBH = filtered2.iloc[0]["CLBH"]
            CLMC = filtered2.iloc[0]["CLMC"]
            JLDW = filtered2.iloc[0]["JLDW"]
            YSJG = filtered2.iloc[0]["YSJG"]
            clde_["CLBH"] = CLBH
            clde_["CLMC"] = CLMC
            clde_["JLDW"] = JLDW
            clde_["YSJG"] = YSJG
            clde_["SL"] = SL
            clde_["HJ"] = HJ
            clde.append(clde_)
        else:
            detail = pd.read_csv("de/tj/JD_PeiBi.csv")
            filtered2 = detail[detail["RcjID"]==rcjID]
            if len(filtered2) > 0:
                CLBH = filtered2.iloc[0]["PBBH"]
                CLMC = filtered2.iloc[0]["PBMC"]
                JLDW = filtered2.iloc[0]["DW"]
                YSJG = filtered2.iloc[0]["PBDJ"]
                clde_["CLBH"] = CLBH
                clde_["CLMC"] = CLMC
                clde_["JLDW"] = JLDW
                clde_["YSJG"] = YSJG
                clde_["SL"] = SL
                clde_["HJ"] = HJ
                clde.append(clde_)
    return filtered.to_json(force_ascii=False), id, rgde, jxde, clde, bz_selected.to_json(force_ascii=False) if len(bz_selected) > 0 else None, bz_selected2.to_json(force_ascii=False) if len(bz_selected2) > 0 else None

def getDwgc(root, id, Zylb):
    result = []
    #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
    item = None
    for child in root:
    
        if child.tag == "Dxgcxx":
            for child1 in child:
                Dwgcbh = child1.attrib["Dwgcbh"]
                if Dwgcbh == id:
                    item = child1
                    break
            ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
    id = id + "Zylb" + Zylb
    for child in item:
        if child.tag == "Fywj":
            result.append({"id": id + "bao jia hui zong", "label": "报价汇总表"})
        elif child.tag == "Gfsj":
            result.append({"id": id + "gui fei shui jin", "label": "规费税金"})
        elif child.tag == "Qdxm":
            result.append({"id": id + "qing dan xiang mu", "label": "清单项目"})
        elif child.tag == "Csxm":
            result.append({"id": id + "cuo shi xiang mu", "label": "措施项目"})
        elif child.tag == "Qtxm":
            result.append({"id": id +"qi ta xiang mu", "label": "其他项目"})
        elif child.tag == "Zlje":
            result.append({"id": id +"zan lie jin e", "label": "暂列金额"})
        elif child.tag == "Clzg":
            result.append({"id": id +"cai liao zan gu jia", "label": "材料暂估价"})
        elif child.tag == "Zygczg":
            result.append({"id": id + "zhuan ye gong cheng zan gu jia", "label": "专业工程暂估价"})
        elif child.tag == "Jrg":
            result.append({"id": id + "ji ri gong", "label": "计日工"})
        elif child.tag == "Zcbfwf":
            result.append({"id": id + "zong cheng bao fu wu fei", "label": "总承包服务费"})
        elif child.tag == "Zjxmjdkzffj":
            result.append({"id": id + "zong jia xiang mu jin du kuan zhi fu fen jie", "label": "总价项目进度款支付分解"})
        elif child.tag == "Fbrgycl":
            result.append({"id": id + "fa bao ren gong ying cai liao", "label": "发包人供应材料"})
        elif child.tag == "Cbrgycl":
            result.append({"id": id + "cheng bao ren gong ying cai liao", "label": "承包人供应材料"})
        elif child.tag == "Rcjhz":
            result.append({"id": id + "ren cai ji hui zong", "label": "人材机汇总"})
        else:
            print(child.tag)
            print("WARNING####################################################################")
    return result
