diff --git a/softwareDirectory/AutoVerScheme/basecommonapi.cpp b/softwareDirectory/AutoVerScheme/basecommonapi.cpp index 46799f1..941287b 100644 --- a/softwareDirectory/AutoVerScheme/basecommonapi.cpp +++ b/softwareDirectory/AutoVerScheme/basecommonapi.cpp @@ -915,7 +915,7 @@ //二等铂电阻温度计标准装置 DataList=BaseCommonApi::getDeviceMeasureItemDataResistanceThermometer(deviceCatoryName,CliTable[0].id,HeadList); case 13: - //示波器标准装置 = 13 + //示波器标准装置 DataList=BaseCommonApi::getDeviceOscilloscopeCalibration(deviceCatoryName,CliTable[0].id,HeadList); break; @@ -4883,3 +4883,52 @@ return QString::number(value, 'f', decimalPlaces); // 使用固定点表示法,并指定小数位数 } +//【查询】角色 根据分类id +QList getDeviceRoleBydeviceId(QString cateory_id) +{ + QList result; + QSqlQuery query; + query.prepare("SELECT * FROM zd_device_role WHERE cateory_id = :cateory_id "); + query.bindValue(":cateory_id",cateory_id); + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + DeviceRole role; + role.id = query.value("id").toString(); + role.belong_vername = query.value("belong_vername").toString(); + role.belong_checkname = query.value("belong_checkname").toString(); + role.cateory_id = query.value("cateory_id").toString(); + role.device_id = query.value("device_id").toString(); + role.device_type = query.value("device_type").toString(); + role.role = query.value("role").toString(); + role.create_time = query.value("create_time").toDateTime(); + role.update_time = query.value("update_time").toDateTime(); + result.append(role); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + return result; +} +//【新增】角色 +bool InsertDeviceRole(DeviceRole role) +{ + QSqlQuery query; + query.prepare("INSERT INTO zd_device_role (id,belong_vername,belong_checkname,cateory_id,device_id,device_type,role,create_time,update_time) " + " VALUES(:id,:belong_vername,:belong_checkname,:cateory_id,:device_id,:device_type,:role,:create_time,:update_time)"); + QString currentDateTime = QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"); + query.bindValue(":id", role.id); + query.bindValue(":belong_vername", role.belong_vername); + query.bindValue(":belong_checkname", role.belong_checkname); + query.bindValue(":cateory_id", role.cateory_id); + query.bindValue(":device_id", role.device_id); + query.bindValue(":device_type", role.device_type); + query.bindValue(":role", role.role); + query.bindValue(":create_time", currentDateTime); + query.bindValue(":update_time", currentDateTime); + bool isSuccess = query.exec(); + if (!isSuccess) { + qDebug() << "Insert data failed: " << query.lastError().text(); + } + return isSuccess; +} diff --git a/softwareDirectory/AutoVerScheme/basecommonapi.cpp b/softwareDirectory/AutoVerScheme/basecommonapi.cpp index 46799f1..941287b 100644 --- a/softwareDirectory/AutoVerScheme/basecommonapi.cpp +++ b/softwareDirectory/AutoVerScheme/basecommonapi.cpp @@ -915,7 +915,7 @@ //二等铂电阻温度计标准装置 DataList=BaseCommonApi::getDeviceMeasureItemDataResistanceThermometer(deviceCatoryName,CliTable[0].id,HeadList); case 13: - //示波器标准装置 = 13 + //示波器标准装置 DataList=BaseCommonApi::getDeviceOscilloscopeCalibration(deviceCatoryName,CliTable[0].id,HeadList); break; @@ -4883,3 +4883,52 @@ return QString::number(value, 'f', decimalPlaces); // 使用固定点表示法,并指定小数位数 } +//【查询】角色 根据分类id +QList getDeviceRoleBydeviceId(QString cateory_id) +{ + QList result; + QSqlQuery query; + query.prepare("SELECT * FROM zd_device_role WHERE cateory_id = :cateory_id "); + query.bindValue(":cateory_id",cateory_id); + bool isSuccess = query.exec(); + if (isSuccess) { + while (query.next()) { + DeviceRole role; + role.id = query.value("id").toString(); + role.belong_vername = query.value("belong_vername").toString(); + role.belong_checkname = query.value("belong_checkname").toString(); + role.cateory_id = query.value("cateory_id").toString(); + role.device_id = query.value("device_id").toString(); + role.device_type = query.value("device_type").toString(); + role.role = query.value("role").toString(); + role.create_time = query.value("create_time").toDateTime(); + role.update_time = query.value("update_time").toDateTime(); + result.append(role); + } + } else { + qDebug() << "Query execution failed: " << query.lastError().text(); + } + return result; +} +//【新增】角色 +bool InsertDeviceRole(DeviceRole role) +{ + QSqlQuery query; + query.prepare("INSERT INTO zd_device_role (id,belong_vername,belong_checkname,cateory_id,device_id,device_type,role,create_time,update_time) " + " VALUES(:id,:belong_vername,:belong_checkname,:cateory_id,:device_id,:device_type,:role,:create_time,:update_time)"); + QString currentDateTime = QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"); + query.bindValue(":id", role.id); + query.bindValue(":belong_vername", role.belong_vername); + query.bindValue(":belong_checkname", role.belong_checkname); + query.bindValue(":cateory_id", role.cateory_id); + query.bindValue(":device_id", role.device_id); + query.bindValue(":device_type", role.device_type); + query.bindValue(":role", role.role); + query.bindValue(":create_time", currentDateTime); + query.bindValue(":update_time", currentDateTime); + bool isSuccess = query.exec(); + if (!isSuccess) { + qDebug() << "Insert data failed: " << query.lastError().text(); + } + return isSuccess; +} diff --git a/softwareDirectory/AutoVerScheme/basecommonapi.h b/softwareDirectory/AutoVerScheme/basecommonapi.h index 9bc333b..e8632cb 100644 --- a/softwareDirectory/AutoVerScheme/basecommonapi.h +++ b/softwareDirectory/AutoVerScheme/basecommonapi.h @@ -1190,6 +1190,20 @@ QDateTime create_time; QDateTime update_time; }; +//角色 +class DeviceRole +{ +public: + QString id;//角色表id + QString belong_vername;//检定装置名称字典 + QString belong_checkname;//核查装置名称字典 + QString cateory_id;//分类id + QString device_id;//设备id + QString device_type;//被检0 | 标准1 + QString role;//角色 + QDateTime create_time; + QDateTime update_time; +}; enum class SyncRunStatus { @@ -1457,6 +1471,10 @@ static QString formatDoubleWithEffectiveDigits(double value, int effectiveDigits); //保留小数点后几位 static QString formatDoubleWithDecimalPlaces(double value, int decimalPlaces); + //【查询】角色 根据分类id + static QList getDeviceRoleBydeviceId(QString cateory_id); + //【新增】角色 + static bool InsertDeviceRole(DeviceRole role); };