#include "hblastregrecord.h"

#include <QJsonArray>

HBlastEquipmentRecord::HBlastEquipmentRecord(QObject *parent) : QObject(parent) {}

qint64 HBlastEquipmentRecord::getId() const { return id; }

void HBlastEquipmentRecord::setId(qint64 newId) { id = newId; }

QString HBlastEquipmentRecord::getUuid() const { return uuid; }

void HBlastEquipmentRecord::setUuid(const QString &newUuid) { uuid = newUuid; }

QString HBlastEquipmentRecord::getEquipSn() const { return equipSn; }

void HBlastEquipmentRecord::setEquipSn(const QString &newEquipSn) { equipSn = newEquipSn; }

QString HBlastEquipmentRecord::getEquipVersion() const { return equipVersion; }

void HBlastEquipmentRecord::setEquipVersion(const QString &newEquipVersion) {
    equipVersion = newEquipVersion;
}

int HBlastEquipmentRecord::getRegDetoCount() const { return regDetoCount; }

void HBlastEquipmentRecord::setRegDetoCount(int newRegDetoCount) { regDetoCount = newRegDetoCount; }

int HBlastEquipmentRecord::getErrorDetoCount() const { return errorDetoCount; }

void HBlastEquipmentRecord::setErrorDetoCount(int newErrorDetoCount) {
    errorDetoCount = newErrorDetoCount;
}

QString HBlastEquipmentRecord::getAfterTestBusV() const { return afterTestBusV; }

void HBlastEquipmentRecord::setAfterTestBusV(const QString &newAfterTestBusV) {
    afterTestBusV = newAfterTestBusV;
}

QString HBlastEquipmentRecord::getAfterTestBusI() const { return afterTestBusI; }

void HBlastEquipmentRecord::setAfterTestBusI(const QString &newAfterTestBusI) {
    afterTestBusI = newAfterTestBusI;
}

QString HBlastEquipmentRecord::getBusLeakageCurrentI() const { return busLeakageCurrentI; }

void HBlastEquipmentRecord::setBusLeakageCurrentI(const QString &newBusLeakageCurrentI) {
    busLeakageCurrentI = newBusLeakageCurrentI;
}

QString HBlastEquipmentRecord::getNetChargedV() const { return netChargedV; }

void HBlastEquipmentRecord::setNetChargedV(const QString &newNetChargedV) {
    netChargedV = newNetChargedV;
}

QString HBlastEquipmentRecord::getNetChargedI() const { return netChargedI; }

void HBlastEquipmentRecord::setNetChargedI(const QString &newNetChargedI) {
    netChargedI = newNetChargedI;
}

QString HBlastEquipmentRecord::getBeforeBlastingV() const { return beforeBlastingV; }

void HBlastEquipmentRecord::setBeforeBlastingV(const QString &newBeforeBlastingV) {
    beforeBlastingV = newBeforeBlastingV;
}

QString HBlastEquipmentRecord::getBeforeBlastingI() const { return beforeBlastingI; }

void HBlastEquipmentRecord::setBeforeBlastingI(const QString &newBeforeBlastingI) {
    beforeBlastingI = newBeforeBlastingI;
}

QString HBlastEquipmentRecord::getRecordUUID() const { return recordUuid; }

void HBlastEquipmentRecord::setRecordUuid(const QString &newRecordUuid) {
    recordUuid = newRecordUuid;
}

QDateTime HBlastEquipmentRecord::getCreatedAt() const { return createdAt; }

void HBlastEquipmentRecord::setCreatedAt(const QDateTime &newCreatedAt) {
    createdAt = newCreatedAt;
}

QDateTime HBlastEquipmentRecord::getUpdatedAt() const { return updatedAt; }

void HBlastEquipmentRecord::setUpdatedAt(const QDateTime &newUpdatedAt) {
    updatedAt = newUpdatedAt;
}

QDateTime HBlastEquipmentRecord::getDeletedAt() const { return deletedAt; }

void HBlastEquipmentRecord::setDeletedAt(const QDateTime &newDeletedAt) {
    deletedAt = newDeletedAt;
}

qint64 HBlastEquipmentRecord::getCreateBy() const { return createBy; }

void HBlastEquipmentRecord::setCreateBy(qint64 newCreateBy) { createBy = newCreateBy; }

qint64 HBlastEquipmentRecord::getUpdateBy() const { return updateBy; }

void HBlastEquipmentRecord::setUpdateBy(qint64 newUpdateBy) { updateBy = newUpdateBy; }

void HBlastEquipmentRecord::setDetRecords(QList<HBlastRecordDet *> data) { detRecords = data; }
QList<HBlastRecordDet *> HBlastEquipmentRecord::getDetRecords() const { return detRecords; }

QJsonObject HBlastEquipmentRecord::ToJson() {
    QJsonObject json;
    // json["id"] = this->getId();
    json["uuid"] = this->getUuid();
    json["equipment_sn"] = this->getEquipSn();
    json["equipment_version"] = this->getEquipVersion();
    json["reg_deto_count"] = QString::number(this->getRegDetoCount());
    json["error_deto_count"] = QString::number(this->getErrorDetoCount());
    json["after_test_bus_v"] = this->getAfterTestBusV();
    json["after_test_bus_i"] = this->getAfterTestBusI();
    json["bus_leakage_current_i"] = this->getBusLeakageCurrentI();
    json["net_charged_v"] = this->getNetChargedV();
    json["net_charged_i"] = this->getNetChargedI();
    json["before_blasting_v"] = this->getBeforeBlastingV();
    json["before_blasting_i"] = this->getBeforeBlastingI();

    json["record_uuid"] = this->getRecordUUID();
    json["created_at"] = this->getCreatedAt().toString(Qt::ISODateWithMs);
    json["updated_at"] = this->getUpdatedAt().toString(Qt::ISODateWithMs);
    json["deleted_at"] = this->getDeletedAt().toString(Qt::ISODateWithMs);
    json["create_by"] = this->getCreateBy();
    json["update_by"] = this->getUpdateBy();

    QJsonArray detArray;
    for (const auto &det : this->getDetRecords()) {
        if (det) {
            detArray.append(det->ToJson());
        }
    }
    json["dets"] = detArray;

    return json;
}
