from BaseDataMaintenance.model.ots.BaseModel import BaseModel
import json

preproject_tenderee = "tenderee"
preproject_product = "product"
preproject_may_begin = "may_begin" #预测开始时间
preproject_may_end = "may_end"# 预测结束时间
preproject_crtime = "crtime" #创建时间
preproject_type = "type"#"0-周期项目,1-采购意向"
preproject_prob = "prob"#概率
preproject_avg_period = "avg_period"#平均周期
preproject_min_period = "min_period"#最小周期
preproject_max_period = "max_period"#最大周期
preproject_periods = "periods" #周期数
preproject_json_docids = "json_docids"#历史项目,格式["1,2,3","4,5,6"],一个字符串代表同一个项目
preproject_province = "province"
preproject_city = "city"
preproject_district = "district"
preproject_last_project_name = "last_project_name"
preproject_project_name = "project_name" #此次项目名称
preproject_last_page_time = "last_page_time"
preproject_last_bidding_budget = "last_bidding_budget"#上次预算
preproject_bidding_budget = "bidding_budget"#此次预算
preproject_last_bidway = "last_bidway"
preproject_last_win_tenderer = "last_win_tenderer"#上次中标人
preproject_last_win_bid_price = "last_win_bid_price"#上次中标金额
preproject_last_agency = "last_agency"#上次代理
preproject_demand = "demand"#此次需求
preproject_last_tenderee_contact = "last_tenderee_contact" #上次采购联系人
preproject_last_tenderee_phone = "last_tenderee_phone"
preproject_uuid = "uuid"
preproject_has_bidfile="has_bidfile"

preproject_last_doctitle = "last_doctitle"
preproject_last_win_tenderer_contact = "last_win_tenderer_contact"
preproject_last_win_tenderer_phone = "last_win_tenderer_phone"



class Preproject(BaseModel):

    def __init__(self,_dict):

        for k,v in _dict.items():
            self.setValue(k,v,True)
        self.table_name = "preproject"

    def getPrimary_keys(self):
        return [preproject_tenderee,preproject_product,preproject_may_begin,preproject_may_end]


    def getAttribute_turple(self):
        _list = []
        for _key in self.getAttribute_keys():
            if _key=="all_columns":
                continue
            _v = self.getProperties().get(_key)
            if _v is not None:
                if isinstance(_v,list):
                    _v = json.dumps(_v)
                _list.append((_key,_v))
        return _list



if __name__=="__main__":
    pass