#include "projectinfo.h"
#include "QDebug"


QJsonObject ProjectInfo::toObject()
{
    QJsonObject ret;
    ret.insert("goods_id",goods_id);
    ret.insert("batch_no",batch_no);
    ret.insert("category",category);
    ret.insert("product_type_code",product_type_code);
    ret.insert("spec_role",spec_role);
    ret.insert("denier",denier);
    ret.insert("dtex",dtex);
    ret.insert("fiber",fiber);
    ret.insert("specs",specs);
    ret.insert("color",color);
    ret.insert("twist_type",twist_type);
    ret.insert("bucket_color",bucket_color);
    ret.insert("box_weight",box_weight);
    ret.insert("bucket_weight",bucket_weight);
    ret.insert("machine_no",machine_no);
    ret.insert("carton_type",carton_type);
    ret.insert("limit_number",limit_number);
    ret.insert("bucket_number",bucket_number);
    ret.insert("cake_float",cake_float);
    ret.insert("box_float",box_float);
    ret.insert("box_rule",box_rule);
    ret.insert("customer",customer);
    ret.insert("remark",remark);
    ret.insert("is_disable",is_disable);
    ret.insert("create_time",create_time);
    ret.insert("modified_time",modified_time);
    return ret;
}

QSharedPointer<ProjectInfo> ProjectInfo::fromObject(const QJsonObject & obj)
{
    QString name = obj.value("batch_no").toString();
    if(name.isEmpty()) return QSharedPointer<ProjectInfo>();
    QSharedPointer<ProjectInfo> info(new ProjectInfo());
    info->dtex = obj.value("detx").toString();

    info->goods_id = obj.value("goods_id").toInt();
    info->batch_no = name;
    info->category = obj.value("category").toString();
    info->product_type_code = obj.value("product_type_code").toString();
    info->spec_role = obj.value("spec_role").toString();
    info->denier = obj.value("denier").toString();
    info->fiber = obj.value("fiber").toString();
    info->specs = obj.value("specs").toString();
    info->color = obj.value("color").toString();
    info->twist_type = obj.value("twist_type").toString();
    info->bucket_color = obj.value("bucket_color").toString();
    info->box_weight = obj.value("box_weight").toString();
    info->bucket_weight = obj.value("bucket_weight").toString();
    info->machine_no = obj.value("machine_no").toString();
    info->carton_type = obj.value("carton_type").toString();
    info->limit_number = obj.value("limit_number").toString();
    info->bucket_number = obj.value("bucket_number").toString();
    info->cake_float = obj.value("cake_float").toString();
    info->box_float = obj.value("box_float").toString();
    info->box_rule = obj.value("box_rule").toString();
    info->customer = obj.value("customer").toString();
    info->tel = obj.value("tel").toString();
    info->remark = obj.value("remark").toString();
    info->is_disable  = obj.value("is_disable").toBool();
    info->create_time = obj.value("create_time").toInt();
    info->modified_time = obj.value("modified_time").toInt();
    return info;
}
