#include "hblastrecord.h"

#include <QJsonArray>

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

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

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

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

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

QString HBlastRecord::getProjectName() const { return projectName; }

void HBlastRecord::setProjectName(const QString &newProjectName) { projectName = newProjectName; }

QString HBlastRecord::getProjectHtid() const { return projectHtid; }

void HBlastRecord::setProjectHtid(const QString &newProjectHtid) { projectHtid = newProjectHtid; }

QString HBlastRecord::getProjectXmbh() const { return projectXmbh; }

void HBlastRecord::setProjectXmbh(const QString &newProjectXmbh) { projectXmbh = newProjectXmbh; }

QString HBlastRecord::getOperatorName() const { return operatorName; }

void HBlastRecord::setOperatorName(const QString &newOperatorName) {
    operatorName = newOperatorName;
}

QString HBlastRecord::getPhone() const { return phone; }

void HBlastRecord::setPhone(const QString &newPhone) { phone = newPhone; }

QString HBlastRecord::getOperatorIdentity() const { return operatorIdentity; }

void HBlastRecord::setOperatorIdentity(const QString &newOperatorIdentity) {
    operatorIdentity = newOperatorIdentity;
}

QString HBlastRecord::getEquipmentSn() const { return equipmentSn; }

void HBlastRecord::setEquipmentSn(const QString &newEquipmentSn) { equipmentSn = newEquipmentSn; }

QString HBlastRecord::getCompanyCode() const { return companyCode; }

void HBlastRecord::setCompanyCode(const QString &newCompanyCode) { companyCode = newCompanyCode; }

QString HBlastRecord::getAppVersion() const { return appVersion; }

void HBlastRecord::setAppVersion(const QString &newAppVersion) { appVersion = newAppVersion; }

QString HBlastRecord::getLongitude() const { return longitude; }

void HBlastRecord::setLongitude(const QString &newLongitude) { longitude = newLongitude; }

QString HBlastRecord::getLatitude() const { return latitude; }

void HBlastRecord::setLatitude(const QString &newLatitude) { latitude = newLatitude; }

int HBlastRecord::getEquipmentCount() const { return equipmentCount; }

void HBlastRecord::setEquipmentCount(const int newEquipmentCount) {
    equipmentCount = newEquipmentCount;
}

int HBlastRecord::getRegDetCount() const { return regDetCount; }

void HBlastRecord::setRegDetCount(int newRegDetCount) { regDetCount = newRegDetCount; }

int HBlastRecord::getErrorDetCount() const { return errorDetCount; }

void HBlastRecord::setErrorDetCount(const int newErrorDetCount) {
    errorDetCount = newErrorDetCount;
}

QDateTime HBlastRecord::getBlastAt() const { return blastAt; }

void HBlastRecord::setBlastAt(const QDateTime &newBlastAt) { blastAt = newBlastAt; }

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

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

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

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

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

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

void HBlastRecord::setIsOfflineBlast(bool isOfflineBlast) { isOfflineBlast = isOfflineBlast; }
bool HBlastRecord::getIsOfflineBlast() const { return isOfflineBlast; }

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

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

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

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

void HBlastRecord::setEquipmentRecords(const QList<HBlastEquipmentRecord *> records) {
    equipmentRecords = records;
}
QList<HBlastEquipmentRecord *> HBlastRecord::getEquipmentRecords() const {
    return equipmentRecords;
}

QJsonObject HBlastRecord::ToJson() {
    QJsonObject json;
    json["uuid"] = this->getUuid();
    json["project_name"] = this->getProjectName();
    json["project_htid"] = this->getProjectHtid();
    json["project_xmbh"] = this->getProjectXmbh();
    json["operator_name"] = this->getOperatorName();
    json["phone"] = this->getPhone();
    json["operator_identity"] = this->getOperatorIdentity();
    json["equipment_sn"] = this->getEquipmentSn();
    json["company_code"] = this->getCompanyCode();
    json["app_version"] = this->getAppVersion();
    json["blast_longitude"] = this->getLongitude();
    json["blast_latitude"] = this->getLatitude();
    json["equipment_count"] = QString::number(this->getEquipmentCount());
    json["reg_deto_count"] = QString::number(this->getRegDetCount());
    json["error_deto_count"] = QString::number(this->getErrorDetCount());
    json["blast_time"] = this->getBlastAt().toString(Qt::ISODateWithMs);
    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 equipmentArray;
    for (const auto &record : this->getEquipmentRecords()) {
        if (record) {
            equipmentArray.append(record->ToJson());
        }
    }
    json["regs"] = equipmentArray;

    return json;
}
