package com.bidizhaobiao.data.bigdata.base.entity.mongo;

import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import org.mongodb.morphia.annotations.Property;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

@Entity(value = "zhongbiao_extraction", noClassnameStored = true)
public class ZhongBiaoExtraction {

    @Id
    private ObjectId id;
    // 项目名称
    @Property("project_name")
    private String projectName;
    // 项目编号
    @Property("project_code")
    private String projectCode;
    // 项目地址
    @Property("project_addr")
    private String projectAddr;
    // 公告文档发布日期
    @Property("page_time")
    private String pageTime;
    // 项目归属地区
    @Property("area")
    private String area;
    // 项目归属省份
    @Property("province")
    private String province;
    // 项目归属城市
    @Property("city")
    private String city;
    // 项目归属区县
    @Property("district")
    private String district;
    // 项目归属行业分类(小类）
    @Property("industry")
    private String industry;
    // 项目归属行业分类(大类）
    @Property("info_type")
    private String infoType;
    // 文章UUID
    @Property("document_id")
    private String documentId;
    // 文章标题(源标题)
    @Property("document_title")
    private String documentTitle;
    // 招标人
    @Property("tenderee")
    private String tenderee;
    // 招标人地址
    @Property("tenderee_addr")
    private String tendereeAddr;
    // 招标人电话
    @Property("tenderee_phone")
    private String tendereePhone;
    // 招标联系人
    @Property("tenderee_contact")
    private String tendereeContact;
    // 代理机构
    @Property("agency")
    private String agency;
    // 代理机构电话
    @Property("agency_phone")
    private String agencyPhone;
    // 代理联系人
    @Property("agency_contact")
    private String agencyContact;
    // 项目子名称
    @Property("sub_project_name")
    private String subProjectName;
    // 项目子编号
    @Property("sub_project_code")
    private String subProjectCode;
    // 中标人
    @Property("win_tenderer")
    private String winTenderer;
    // 中标价
    @Property("win_bid_price")
    private String winBidPrice;
    // 中标人联系人
    @Property("win_tenderer_manager")
    private String winTendererManager;
    // 中标人联系人电话
    @Property("win_tenderer_phone")
    private String winTendererPhone;
    // 第二中标人
    @Property("second_tenderer")
    private String secondTenderer;
    // 第二中标价
    @Property("second_bid_price")
    private String secondBidPrice;
    // 第二中标人联系人
    @Property("second_tenderer_manager")
    private String secondTendererManager;
    // 第二中标人联系人
    @Property("second_tenderer_phone")
    private String secondTendererPhone;
    // 第三中标人
    @Property("third_tenderer")
    private String thirdTenderer;
    // 第三中标价
    @Property("third_bid_price")
    private String thirdBidPrice;
    // 第三中标人联系人
    @Property("third_tenderer_manager")
    private String thirdTendererManager;
    // 第三中标人联系人
    @Property("third_tenderer_Phone")
    private String thirdTendererPhone;
    // 是否废标
    @Property("is_effective")
    private boolean isEffective;

    /**
     * 公告id
     */
    private String docId;

    private String upgradeStatus;      // 这个属性用于旧数据的升级(null和0：待升级、-1：升级中、1：已升级)

    public ObjectId getId() {
        return id;
    }

    public void setId(ObjectId id) {
        this.id = id;
    }

    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    public String getProjectCode() {
        return projectCode;
    }

    public void setProjectCode(String projectCode) {
        this.projectCode = projectCode;
    }

    public String getProjectAddr() {
        return projectAddr;
    }

    public void setProjectAddr(String projectAddr) {
        this.projectAddr = projectAddr;
    }

    public String getPageTime() {
        return pageTime;
    }

    public void setPageTime(String pageTime) {
        this.pageTime = pageTime;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getIndustry() {
        return industry;
    }

    public void setIndustry(String industry) {
        this.industry = industry;
    }

    public String getDocumentId() {
        return documentId;
    }

    public void setDocumentId(String documentId) {
        this.documentId = documentId;
    }

    public String getDocumentTitle() {
        return documentTitle;
    }

    public void setDocumentTitle(String documentTitle) {
        this.documentTitle = documentTitle;
    }

    public String getTenderee() {
        return tenderee;
    }

    public void setTenderee(String tenderee) {
        this.tenderee = tenderee;
    }

    public String getTendereeAddr() {
        return tendereeAddr;
    }

    public void setTendereeAddr(String tendereeAddr) {
        this.tendereeAddr = tendereeAddr;
    }

    public String getTendereePhone() {
        return tendereePhone;
    }

    public void setTendereePhone(String tendereePhone) {
        this.tendereePhone = tendereePhone;
    }

    public String getTendereeContact() {
        return tendereeContact;
    }

    public void setTendereeContact(String tendereeContact) {
        this.tendereeContact = tendereeContact;
    }

    public String getAgency() {
        return agency;
    }

    public void setAgency(String agency) {
        this.agency = agency;
    }

    public String getAgencyPhone() {
        return agencyPhone;
    }

    public void setAgencyPhone(String agencyPhone) {
        this.agencyPhone = agencyPhone;
    }

    public String getAgencyContact() {
        return agencyContact;
    }

    public void setAgencyContact(String agencyContact) {
        this.agencyContact = agencyContact;
    }

    public String getSubProjectName() {
        return subProjectName;
    }

    public void setSubProjectName(String subProjectName) {
        this.subProjectName = subProjectName;
    }

    public String getSubProjectCode() {
        return subProjectCode;
    }

    public void setSubProjectCode(String subProjectCode) {
        this.subProjectCode = subProjectCode;
    }

    public String getWinTenderer() {
        return winTenderer;
    }

    public void setWinTenderer(String winTenderer) {
        this.winTenderer = winTenderer;
    }

    public String getWinBidPrice() {
        return winBidPrice;
    }

    public void setWinBidPrice(String winBidPrice) {
        this.winBidPrice = winBidPrice;
    }

    public String getWinTendererManager() {
        return winTendererManager;
    }

    public void setWinTendererManager(String winTendererManager) {
        this.winTendererManager = winTendererManager;
    }

    public String getSecondTenderer() {
        return secondTenderer;
    }

    public void setSecondTenderer(String secondTenderer) {
        this.secondTenderer = secondTenderer;
    }

    public String getSecondBidPrice() {
        return secondBidPrice;
    }

    public void setSecondBidPrice(String secondBidPrice) {
        this.secondBidPrice = secondBidPrice;
    }

    public String getSecondTendererManager() {
        return secondTendererManager;
    }

    public void setSecondTendererManager(String secondTendererManager) {
        this.secondTendererManager = secondTendererManager;
    }

    public String getThirdTenderer() {
        return thirdTenderer;
    }

    public void setThirdTenderer(String thirdTenderer) {
        this.thirdTenderer = thirdTenderer;
    }

    public String getThirdBidPrice() {
        return thirdBidPrice;
    }

    public void setThirdBidPrice(String thirdBidPrice) {
        this.thirdBidPrice = thirdBidPrice;
    }

    public String getThirdTendererManager() {
        return thirdTendererManager;
    }

    public void setThirdTendererManager(String thirdTendererManager) {
        this.thirdTendererManager = thirdTendererManager;
    }

    public void setIsEffective(boolean isEffective) {
        this.isEffective = isEffective;
    }

    public String getInfoType() {
        return infoType;
    }

    public void setInfoType(String infoType) {
        this.infoType = infoType;
    }

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getDistrict() {
        return district;
    }

    public void setDistrict(String district) {
        this.district = district;
    }

    public String getWinTendererPhone() {
        return winTendererPhone;
    }

    public void setWinTendererPhone(String winTendererPhone) {
        this.winTendererPhone = winTendererPhone;
    }

    public String getSecondTendererPhone() {
        return secondTendererPhone;
    }

    public void setSecondTendererPhone(String secondTendererPhone) {
        this.secondTendererPhone = secondTendererPhone;
    }

    public String getThirdTendererPhone() {
        return thirdTendererPhone;
    }

    public void setThirdTendererPhone(String thirdTendererPhone) {
        this.thirdTendererPhone = thirdTendererPhone;
    }

    public String getDocId() {
        return docId;
    }

    public void setDocId(String docId) {
        this.docId = docId;
    }

    public String getUpgradeStatus() {
        return upgradeStatus;
    }

    public void setUpgradeStatus(String upgradeStatus) {
        this.upgradeStatus = upgradeStatus;
    }

    public void addAll(ZhongBiaoExtraction zhongBiaoExtraction)  {
        try {
            Field[] newFields = zhongBiaoExtraction.getClass().getDeclaredFields();
            Field[] thisFields = this.getClass().getDeclaredFields();
            for (Field newField : newFields) {
                String newFieldName = newField.getName();

                if (newFieldName.equals("id")) {
                    continue;
                }

                for (Field thisField : thisFields) {
                    String thisFieldName = thisField.getName();
                    if (thisFieldName.equals(newFieldName)) {
                        thisField.setAccessible(true);
                        newField.setAccessible(true);
                        if (newField.get(zhongBiaoExtraction) != null) {
                            Method thisMethod = this.getClass().getMethod("set" + thisFieldName.substring(0, 1).toUpperCase() + thisFieldName.substring(1), newField.getType());
                            thisMethod.invoke(this, newField.get(zhongBiaoExtraction));
                        }
                        break;
                    }
                }
            }
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
}
