API创建/更新员工联系电话

这段代码展示了如何使用Oracle E-Business Suite (EBS) 的HR_PHONE_API模块来创建或更新员工的联系电话详情。通过调用create_or_update_phone API,输入包括电话类型、电话号码、父ID(员工ID)和有效日期,输出返回电话ID和对象版本号。
DECLARE 
       ln_phone_id                              PER_PHONES.PHONE_ID%TYPE; 
       ln_object_version_number    PER_PHONES.OBJECT_VERSION_NUMBER%TYPE; 
 

BEGIN 
   -- Create or Update Employee Phone Detail 
   -- ----------------------------------------------------------- 
    hr_phone_api.create_or_update_phone 
    (   -- Input data elements 
        -- ----------------------------- 
        p_date_from                             => TO_DATE('13-JUN-2011'), 
        p_phone_type                          => 'W1', 
        p_phone_number                   => '9999999', 
        p_parent_id                              => 32979, 
        p_parent_table                         => 'PER_ALL_PEOPLE_F', 
        p_effective_date                       => TO_DATE('13-JUN-2011'), 
        -- Output data elements 
        -- -------------------------------- 
        p_phone_id                              => ln_phone_id, 
        p_object_version_number    => ln_object_version_number 
     ); 
  
 COMMIT; 


EXCEPTION 
      WHEN OTHERS THEN 
                    ROLLBACK; 
                     dbms_output.put_line(SQLERRM); 
END; 


// #include "faceprocessor.h" // #include <QDebug> // #include <QFile> // #include "arcsoft_face_sdk.h" // #include "amcomdef.h" // #include "asvloffscreen.h" // #include "merror.h" // FaceProcessor::FaceProcessor(QObject *parent) : QObject(parent) // { // initialize();//清理资源释放虹软引擎 // } // FaceProcessor::~FaceProcessor() // { // if (m_engine) { // ASFUninitEngine(m_engine); // m_engine = nullptr; // } // } // //激活虹软SDK的成员函数m_appId m_sdkKey被激活 // bool FaceProcessor::activateSDK() // { // MRESULT res = ASFActivation( // const_cast<char*>(m_appId.toUtf8().constData()), // const_cast<char*>(m_sdkKey.toUtf8().constData()) // ); // if (res != MOK && res != MERR_ASF_ALREADY_ACTIVATED) { // qCritical() << "虹软SDK激活失败,错误码:" << res; // return false; // } // return true; // } // //初始化人脸处理引擎成员 // bool FaceProcessor::initialize() // { // if (m_initialized) return true; // // 激活SDK // if (!activateSDK()) { // return false; // } // // 初始化引擎人脸检测和人脸识别 // MInt32 mask = ASF_FACE_DETECT | ASF_FACERECOGNITION; // MRESULT res = ASFInitEngine( // ASF_DETECT_MODE_IMAGE, // 图片模式 // ASF_OP_0_ONLY, // 仅0度方向 // 30, // 最小人脸尺寸(像素) // 10, // 最大人脸数 // mask, // 功能掩码 // &m_engine // 引擎句柄 // ); // if (res != MOK) { // qCritical() << "引擎初始化失败,错误码:" << res; // return false; // } // m_initialized = true; // qDebug() << "虹软人脸引擎初始化成功"; // return true; // } // ASVLOFFSCREEN FaceProcessor::createOffscreen(const QImage &image) // { // // 转换为BGR888格式(虹软要求) // QImage processedImg = image.convertToFormat(QImage::Format_BGR888); // // 调整尺寸以满足虹软要求(宽4倍数,高2倍数) // int newWidth = processedImg.width() - (processedImg.width() % 4); // int newHeight = processedImg.height() - (processedImg.height() % 2); // if (newWidth != processedImg.width() || newHeight != processedImg.height()) { // processedImg = processedImg.scaled(newWidth, newHeight, // Qt::IgnoreAspectRatio, // Qt::SmoothTransformation); // } // //图像设置 // ASVLOFFSCREEN offscreen = {0};//成员清零 // offscreen.u32PixelArrayFormat = ASVL_PAF_RGB24_B8G8R8;//图像格式24位BGR格式 // offscreen.i32Width = processedImg.width();//图像宽度 // offscreen.i32Height = processedImg.height();//图像高度 // offscreen.pi32Pitch[0] = processedImg.bytesPerLine();//图像每行的字节数 // offscreen.ppu8Plane[0] = (MUInt8*)processedImg.bits();//图像数据起始位置的指针 // return offscreen; // } // //从指定图像路径提取人脸特征 // bool FaceProcessor::extractFaceFeature(const QString &imagePath, QByteArray &featureData) // { // //初始化 // if (!m_initialized) { // if (!initialize()) return false; // } // // 加载图像 // QImage img(imagePath); // if (img.isNull()) { // qWarning() << "无法加载图片:" << imagePath; // return false; // } // // 创建虹软图像结构 // ASVLOFFSCREEN offscreen = createOffscreen(img); // // 人脸检测 // ASF_MultiFaceInfo detectedFaces = {0}; // MRESULT res = ASFDetectFacesEx(m_engine, &offscreen, &detectedFaces); // if (res != MOK) { // qWarning() << "人脸检测失败,错误码:" << res; // return false; // } // if (detectedFaces.faceNum == 0) { // qWarning() << "未检测到人脸:" << imagePath; // return false; // } // // 只处理第一个人脸 // ASF_SingleFaceInfo faceInfo = { // detectedFaces.faceRect[0], // detectedFaces.faceOrient[0] // }; // // 提取特征 // ASF_FaceFeature asfFeature = {0}; // res = ASFFaceFeatureExtractEx(m_engine, &offscreen, &faceInfo, &asfFeature); // if (res != MOK) { // qWarning() << "特征提取失败,错误码:" << res; // return false; // } // // 复制特征数据 // featureData = QByteArray(reinterpret_cast<char*>(asfFeature.feature), asfFeature.featureSize); // // 释放虹软分配的内存 // if (asfFeature.feature) { // free(asfFeature.feature); // } // return true; // } // #include "facerecognitionserver.h" // #include <QJsonDocument> // #include <QJsonObject> // #include <QJsonArray> // #include <QHttpServer> // #include <QDebug> // #include <QSqlQuery> // #include <QSqlError> // #include <QUrlQuery> // #include <QDateTime> // //用于处理人脸识别的Http服务器 // FaceRecognitionServer::FaceRecognitionServer(QSqlDatabase &db, QObject *parent) // : QObject(parent), m_db(db) // { // // 检查数据库连接 // if (!m_db.isOpen()) { // qCritical() << "Database is not open!"; // return; // } else { // qDebug() << "Database connected successfully"; // } // // 配置路由:将GET请求到/verifyFace路径的请求映射到处理函数 // // 人脸验证接口 // server.route("/verifyFace", QHttpServerRequest::Method::Get, // [this](const QHttpServerRequest &request) { // return handleFaceVerification(request); // }); // // 事件上报接口 配置事件上报接口的路由 // server.route("/reportEvent", QHttpServerRequest::Method::Get, // [this](const QHttpServerRequest &request) { // return handleEventReport(request); // }); // // 用户管理接口配置获取所有用户信息的APL路由 // server.route("/api/users", QHttpServerRequest::Method::Get, // [this](const QHttpServerRequest &request) { // return handleGetAllUsers(request); // }); // //配置带路径参数的用户查询路由 // server.route("/api/user/<arg>", QHttpServerRequest::Method::Get, // [this](const QString &id, const QHttpServerRequest &request) { // return handleGetUserById(id, request); // }); // //配置通过查询参数查询用户的路由 // server.route("/api/user", QHttpServerRequest::Method::Get, // [this](const QHttpServerRequest &request) { // return handleGetUserByEmployeeId(request); // }); // //配置添加用户的API路由 // server.route("/api/user/add", QHttpServerRequest::Method::Post, // [this](const QHttpServerRequest &request) { // return handleAddUser(request); // }); // //配置更新用户的API路由 // server.route("/api/user/update", QHttpServerRequest::Method::Put, // [this](const QHttpServerRequest &request) { // return handleUpdateUser(request); // }); // //配置删除用户的API路由 // server.route("/api/user/delete", QHttpServerRequest::Method::Delete, // [this](const QHttpServerRequest &request) { // return handleDeleteUser(request); // }); // //配置获取日志的API路由 // server.route("/api/logs", QHttpServerRequest::Method::Get, // [this](const QHttpServerRequest &request) { // return handleGetLogs(request); // }); // // 启动服务器监听8091端口 // if (server.listen(QHostAddress::Any, 8091)) { // qDebug() << "Server started on port 8091";//输出服务器启动成功 // qDebug() << "Available endpoints:";//可用API端点 // qDebug() << " GET /verifyFace";//列出人脸验证端点 // qDebug() << " GET /reportEvent";//列出事件上报端点 // qDebug() << " GET /api/users";//列出获取所有用户端点 // qDebug() << " GET /api/user/<id>";//列出根据ID获取用户端点 // qDebug() << " GET /api/user?employeed=<employeeId>";//列出根据工号查询用户端点 // qDebug() << " POST /api/user/add";//列出添加用户端点 // qDebug() << " PUT /api/user/update";//列出更新用户端点 // qDebug() << " DELETE /api/user/delete";//列出删除用户端点 // } else { // qCritical() << "Failed to start server"; // } // } // FaceRecognitionServer::~FaceRecognitionServer() { // // 析构时不关闭数据库,由外部管理 // } // // 获取所有用户 // QJsonObject FaceRecognitionServer::handleGetAllUsers(const QHttpServerRequest &request) { // QJsonObject response;//创建用于构建JSON响应的对象 // QSqlQuery query(m_db);//创建使用成员数据库连接的SQL查询对象 // //准备SQL查询多表连接查询获取用户以及关联的信息 // query.prepare("SELECT c.ChannelNumberID, c.EquipmentID, u.Account , u.CreateTime , u.WorkerID , u.UserID , u.Username , u.Password , u.UpdateTime , u.FaceFeature " // "FROM User u " // "INNER JOIN Instrument i ON u.UserID = i.UserID " // "INNER JOIN Channel c ON i.InstrumentID = c.InstrumentID"); // if (!query.exec()) { // response["code"] = 500; // response["message"] = "Database error: " + query.lastError().text(); // return response; // } // //创建JSON数组用于存储用户列表 // QJsonArray users; // //遍历查询每一行 // while (query.next()) { // QJsonObject user;//为每个用户创建JSON对象 // int channelNumberID = query.value("ChannelNumberID").toInt();//获取通道编号ID // int addressId = channelNumberID / 25 +1; //计算地址板ID // int lockId = channelNumberID % 25; //计算锁号 // // QString cabinetId = QString("%1_%2").arg(addressId, 2, 10, QChar('0')).arg(lockId, 2, 10, QChar('0')); // int equipmentID = channelNumberID / 200 + 1;//计算设备柜ID // int channelNum = channelNumberID % 200;//计算通道 // QString cabinetId = QString::number(equipmentID) + "号柜" + QString::number(channelNum) + "号箱";//构建柜号描述字符串 // user["addressId"] = addressId;//设置用户的addressId字段 // user["cabinetId"] = cabinetId;//设置柜号ID字段 // user["cardId"] = query.value("Account").toString();//设置卡号字段 // user["createTime"] = query.value("CreateTime").toLongLong();//设置创建时间段 // user["employeeId"] = query.value("WorkerID").toString();//设置员工工号 // user["featureCode"] = query.value("FaceFeature").toString();//人脸特征 // user["id"] = query.value("UserID").toInt();//用户ID // user["lockId"] = lockId;//锁号字段 // user["name"] = query.value("Username").toString();//用户名字段 // user["password"] = query.value("Password").toString();//设置密码字段 // user["phone"] = "";//设置电话 数据库中没有 // user["updateTime"] = query.value("UpdateTime").toString();//更新时间 // users.append(user);//添加到数组 // } // response["code"] = 200;//响应码200则成功 // response["data"] = users;//用户为响应数字 // response["message"] = "操作成功"; // return response; // } // // 根据ID获取用户 // QJsonObject FaceRecognitionServer::handleGetUserById(const QString &id, const QHttpServerRequest &request) { // QJsonObject response; // bool ok; // int userId = id.toInt(&ok); // //设置响应码400 设置无效用户ID // if (!ok) { // response["code"] = 400; // response["message"] = "Invalid user ID"; // return response; // } // //根据用户ID查询SQL语句 // QSqlQuery query(m_db); // query.prepare("SELECT c.ChannelNumberID, u.Account , u.CreateTime , u.WorkerID , u.UserID , u.Username , u.Password , u.UpdateTime , u.FaceFeature " // "FROM User u " // "INNER JOIN Instrument i ON u.UserID = i.UserID " // "INNER JOIN Channel c ON i.InstrumentID = c.InstrumentID " // "WHERE u.UserID = :id"); // query.bindValue(":id", userId);//绑定用户ID参数到SQL // //执行查询响应码404(未找到) // if (!query.exec() || !query.next()) { // response["code"] = 404; // response["message"] = "User not found"; // return response; // } // QJsonObject user;//创建用户JSON对象 // //计算柜号信息 // int channelNumberID = query.value("ChannelNumberID").toInt(); // int addressId = channelNumberID / 25 +1; //板ID // int lockId = channelNumberID % 25; //锁号 // // QString cabinetId = QString("%1_%2").arg(addressId, 2, 10, QChar('0')).arg(lockId, 2, 10, QChar('0')); // int equipmentID = channelNumberID / 200 + 1; // int channelNum = channelNumberID % 200; // QString cabinetId = QString::number(equipmentID) + "号柜" + QString::number(channelNum) + "号箱"; // //设置用户对象的各个字段 // user["addressId"] = addressId; // user["cabinetId"] = cabinetId; // user["cardId"] = query.value("Account").toString(); // user["createTime"] = query.value("CreateTime").toLongLong(); // user["password"] = query.value("Password").toString(); // user["phone"] = ""; // user["updateTime"] = query.value("UpdateTime").toString(); // //构建响应返回 // response["code"] = 200; // response["data"] = user; // response["message"] = "操作成功"; // return response; // } // // 根据工号获取用户 // QJsonObject FaceRecognitionServer::handleGetUserByEmployeeId(const QHttpServerRequest &request) { // QJsonObject response; // QUrlQuery queryParams(request.url().query());//解析url // QString employeeId = queryParams.queryItemValue("employeeId");//获取employeeID // if (employeeId.isEmpty()) { // response["code"] = 400; // response["message"] = "Missing employee ID"; // return response; // } // //根据工号查询的SQL语句 // QSqlQuery query(m_db); // query.prepare("SELECT c.ChannelNumberID, u.Account, u.CreateTime, u.WorkerID, u.UserID, u.Username, u.Password, u.UpdateTime, u.FaceFeature " // "FROM User u " // "INNER JOIN Instrument i ON u.UserID = i.UserID " // "INNER JOIN Channel c ON i.InstrumentID = c.InstrumentID " // "WHERE u.WorkerID = :workerID"); // // query.prepare("SELECT * FROM User WHERE UserID = :id"); // query.bindValue(":workerID", employeeId);//绑定工号参数 // if (!query.exec() || !query.next()) { // response["code"] = 404; // response["message"] = "User not found"; // return response; // } // //创建用户JSON对象并填充 // QJsonObject user; // int channelNumberID = query.value("ChannelNumberID").toInt(); // int addressId = channelNumberID / 25 +1; //板ID // int lockId = channelNumberID % 25; //锁号 // // QString cabinetId = QString("%1_%2").arg(addressId, 2, 10, QChar('0')).arg(lockId, 2, 10, QChar('0')); // int equipmentID = channelNumberID / 200 + 1; // int channelNum = channelNumberID % 200; // QString cabinetId = QString::number(equipmentID) + "号柜" + QString::number(channelNum) + "号箱"; // user["addressId"] = addressId; // user["cabinetId"] = cabinetId; // user["cardId"] = query.value("Account").toString(); // user["createTime"] = query.value("CreateTime").toLongLong(); // user["employeeId"] = query.value("WorkerID").toString(); // user["featureCode"] = query.value("FaceFeature").toString(); // user["id"] = query.value("UserID").toInt(); // user["lockId"] = lockId; // user["name"] = query.value("Username").toString(); // user["password"] = query.value("Password").toString(); // user["phone"] = ""; // user["updateTime"] = query.value("UpdateTime").toString(); // response["code"] = 200; // response["data"] = user; // response["message"] = "操作成功"; // return response; // } // // 添加用户 // QJsonObject FaceRecognitionServer::handleAddUser(const QHttpServerRequest &request) { // QJsonObject response; // auto jsonDoc = QJsonDocument::fromJson(request.body());//解析JSON文档 // if (jsonDoc.isNull() || !jsonDoc.isObject()) { // response["code"] = 400; // response["message"] = "Invalid JSON format"; // return response; // } // QJsonObject userData = jsonDoc.object();//获取JSON对象 // QJsonObject user;//创建用于响应的用户对象 // qDebug() << "id:" << userData["id"].toInt() << "name:" << userData["name"].toString() << "employeeId:" << userData["employeeId"].toString() // << "cardId:" << userData["cardId"].toString() << "password:" << userData["password"].toString() // << "featureCode:" << userData["featureCode"].toString() << "cabinetId:" << userData["cabinetId"].toString(); // //准备插入用户的SQL语句 // QSqlQuery query(m_db); // query.prepare("INSERT INTO User (Username, WorkerID, Account, Password, FaceFeature) " // "VALUES (:name, :employeeId, :cardId, :password, :featureCode)"); // //绑定用户数据到SQL // query.bindValue(":name", userData["name"].toString()); // query.bindValue(":employeeId", userData["employeeId"].toString()); // query.bindValue(":cardId", userData["cardId"].toString()); // query.bindValue(":password", userData["password"].toString()); // query.bindValue(":featureCode", userData["featureCode"].toString()); // if (!query.exec()) { // response["code"] = 500; // response["message"] = "Failed to add user: " + query.lastError().text(); // return response; // } // // 获取刚插入的用户ID // qint64 userID = query.lastInsertId().toLongLong(); // user["id"] = userID;//将新用户ID响应到对象中 // response["code"] = 200; // response["data"] = user; // response["message"] = "添加用户成功"; // return response; // } // // 更新用户 // QJsonObject FaceRecognitionServer::handleUpdateUser(const QHttpServerRequest &request) { // QJsonObject response;//获取更新用户ID // auto jsonDoc = QJsonDocument::fromJson(request.body()); // if (jsonDoc.isNull() || !jsonDoc.isObject()) { // response["code"] = 400; // response["message"] = "Invalid JSON format"; // return response; // } // QJsonObject userData = jsonDoc.object(); // QJsonObject user; // int userId = userData["id"].toInt(); // //输出调试信息 // qDebug() << "id:" << userData["id"].toInt() << "name:" << userData["name"].toString() << "employeeId:" << userData["employeeId"].toString() // << "cardId:" << userData["cardId"].toString() << "password:" << userData["password"].toString() // << "featureCode:" << userData["featureCode"].toString() << "cabinetId:" << userData["cabinetId"].toString(); // //准备更新用户的SQL语句 // QSqlQuery query(m_db); // query.prepare("UPDATE User SET " // "Username = :name, " // "WorkerID = :employeeId, " // "Account = :cardId, " // "Password = :password, " // "FaceFeature = :featureCode " // "WHERE UserID = :id"); // //绑定更新参数和用户ID // query.bindValue(":name", userData["name"].toString()); // query.bindValue(":employeeId", userData["employeeId"].toString()); // query.bindValue(":cardId", userData["cardId"].toString()); // query.bindValue(":password", userData["password"].toString()); // query.bindValue(":featureCode", userData["featureCode"].toString()); // query.bindValue(":id", userId); // //执行更新操作 // if (!query.exec()) { // response["code"] = 500; // response["message"] = "Failed to update user: " + query.lastError().text(); // return response; // } // //检查是否有行被更新 // if (query.numRowsAffected() == 0) { // response["code"] = 404; // response["message"] = "User not found"; // return response; // } // //设置响应中的用户ID // user["id"] = userId; // response["code"] = 200; // response["data"] = user; // response["message"] = "更新用户成功"; // return response; // } // // 删除用户 // #if 0 // QJsonObject FaceRecognitionServer::handleDeleteUser(const QHttpServerRequest &request) { // QJsonObject response; // QUrlQuery queryParams(request.url().query()); // QString idParam = queryParams.queryItemValue("id"); // QString employeeIdParam = queryParams.queryItemValue("employeeId"); // if (idParam.isEmpty() && employeeIdParam.isEmpty()) { // response["code"] = 400; // response["message"] = "Missing id or employeeId parameter"; // return response; // } // QSqlQuery query(m_db); // if (!idParam.isEmpty()) { // bool ok; // int userId = idParam.toInt(&ok); // if (!ok) { // response["code"] = 400; // response["message"] = "Invalid id parameter"; // return response; // } // query.prepare("DELETE FROM User WHERE UserID = :id"); // query.bindValue(":id", userId); // } else { // query.prepare("DELETE FROM User WHERE WorkerID = :employeeId"); // query.bindValue(":employeeId", employeeIdParam); // } // if (!query.exec()) { // response["code"] = 500; // response["message"] = "Failed to delete user: " + query.lastError().text(); // return response; // } // if (query.numRowsAffected() == 0) { // response["code"] = 404; // response["message"] = "User not found"; // return response; // } // response["code"] = 200; // response["message"] = "User deleted successfully"; // return response; // } // #else // QJsonObject FaceRecognitionServer::handleDeleteUser(const QHttpServerRequest &request) { // QJsonObject response; // QUrlQuery queryParams(request.url().query()); // QString idParam = queryParams.queryItemValue("id"); // QString employeeIdParam = queryParams.queryItemValue("employeeId"); // if (idParam.isEmpty() && employeeIdParam.isEmpty()) { // response["code"] = 400; // response["message"] = "Missing id or employeeId parameter"; // return response; // } // // 开始事务处理 // m_db.transaction(); // try { // // 查找用户ID // int userId = -1; // QSqlQuery findUserQuery(m_db); // //提供ID参数 // if (!idParam.isEmpty()) { // bool ok; // userId = idParam.toInt(&ok); // if (!ok) { // throw std::runtime_error("Invalid id parameter"); // } // } else { // findUserQuery.prepare("SELECT UserID FROM User WHERE WorkerID = :employeeId"); // findUserQuery.bindValue(":employeeId", employeeIdParam); // //查询判断 // if (!findUserQuery.exec()) { // throw std::runtime_error("Failed to find user: " + findUserQuery.lastError().text().toStdString()); // } // //未找到用户 // if (!findUserQuery.next()) { // throw std::runtime_error("User not found"); // } // //查询中获取用户ID // userId = findUserQuery.value("UserID").toInt(); // } // // 1. 查找用户关联的仪器 // QVector<int> instrumentIds; // QSqlQuery instrumentQuery(m_db); // instrumentQuery.prepare("SELECT InstrumentID FROM Instrument WHERE UserID = :userId"); // instrumentQuery.bindValue(":userId", userId); // if (!instrumentQuery.exec()) { // throw std::runtime_error("Failed to find instruments: " + instrumentQuery.lastError().text().toStdString()); // } // //将仪器ID添加到向量中 // while (instrumentQuery.next()) { // instrumentIds.append(instrumentQuery.value("InstrumentID").toInt()); // } // // 2. 处理每个仪器的通道 // for (int instrumentId : instrumentIds) { // // 查找仪器关联的通道 // QSqlQuery channelQuery(m_db); // channelQuery.prepare("SELECT ChannelNumberID FROM Channel WHERE InstrumentID = :instrumentId"); // channelQuery.bindValue(":instrumentId", instrumentId); // //查询仪器通道 // if (!channelQuery.exec()) { // throw std::runtime_error("Failed to find channels: " + channelQuery.lastError().text().toStdString()); // } // while (channelQuery.next()) { // int channelNumberId = channelQuery.value("ChannelNumberID").toInt(); // // 更新通道状态为可用准备更新通道状态为可用的SQL语句 // QSqlQuery updateQuery(m_db); // updateQuery.prepare("UPDATE ChannelNum SET Status = 1 WHERE ChannelNumberID = :channelNumberId"); // updateQuery.bindValue(":channelNumberId", channelNumberId); // if (!updateQuery.exec()) { // throw std::runtime_error("Failed to update channel status: " + updateQuery.lastError().text().toStdString()); // } // } // // 删除仪器关联的通道 // QSqlQuery deleteChannelQuery(m_db); // deleteChannelQuery.prepare("DELETE FROM Channel WHERE InstrumentID = :instrumentId"); // deleteChannelQuery.bindValue(":instrumentId", instrumentId); // if (!deleteChannelQuery.exec()) { // throw std::runtime_error("Failed to delete channels: " + deleteChannelQuery.lastError().text().toStdString()); // } // } // // 3. 删除用户关联的仪器 // if (!instrumentIds.isEmpty()) { // QSqlQuery deleteInstrumentQuery(m_db); // deleteInstrumentQuery.prepare("DELETE FROM Instrument WHERE UserID = :userId"); // deleteInstrumentQuery.bindValue(":userId", userId); // if (!deleteInstrumentQuery.exec()) { // throw std::runtime_error("Failed to delete instruments: " + deleteInstrumentQuery.lastError().text().toStdString()); // } // } // // 4. 删除用户 // QSqlQuery deleteUserQuery(m_db); // deleteUserQuery.prepare("DELETE FROM User WHERE UserID = :userId"); // deleteUserQuery.bindValue(":userId", userId); // if (!deleteUserQuery.exec()) { // throw std::runtime_error("Failed to delete user: " + deleteUserQuery.lastError().text().toStdString()); // } // if (deleteUserQuery.numRowsAffected() == 0) { // throw std::runtime_error("User not found"); // } // // 提交事务 // m_db.commit(); // response["code"] = 200; // response["message"] = "删除用户成功"; // } // //捕获异常 // catch (const std::exception& e) { // // 回滚事务 // m_db.rollback(); // response["code"] = 500; // response["message"] = QString("Failed to delete user: %1").arg(e.what()); // } // return response; // } // #endif // //处理获取日志 // QJsonObject FaceRecognitionServer::handleGetLogs(const QHttpServerRequest &request) { // // 2025-07-14 10:21:00 -> 毫秒时间戳 // //创建目标日期事件对象 转换为毫秒时间戳 // // qint64 ts202507141021 = QDateTime::currentDateTime().toMSecsSinceEpoch(); // QDateTime targetDateTime = QDateTime::fromString("2025-07-13 12:00:00", "yyyy-MM-dd HH:mm:ss"); // qint64 ts202507141021 = targetDateTime.toMSecsSinceEpoch(); // QJsonArray data;//创建日志数据数组 // for (int i = 0; i < 10000; i++) { // // 构造一条日志 // QJsonObject log1; // log1["id"] = 16048 + i;//ID // log1["cabinetId"] = "一号柜-01号箱";//柜号 // log1["createTime"] = ts202507141021;//时间戳 // log1["updateTime"] = ts202507141021; // log1["employeeId"] = "888";//工号 // log1["name"] = "张三";//名字 // log1["operation"] = "take"; // take操作类型取仪器 / still // log1["type"] = "face"; // password / face / swipe人脸认证 // log1["status"] = "success"; // success / fail操作状态(成功) // log1["isSent"] = true; // 已同步状态 // log1["param"] = "faceId=12345"; //参数 // log1["remark"] = "正常取仪器"; //备注信息 // data.append(log1);//日志对象添加到数组 // } // // 构造一条日志 // QJsonObject log2; // log2["id"] = 1005; // log2["cabinetId"] = "A08"; // log2["createTime"] = ts202507141021; // log2["updateTime"] = ts202507141021; // log2["employeeId"] = "889"; // log2["name"] = "李四"; // log2["operation"] = "take"; // take / still // log2["type"] = "face"; // password / face / swipe // log2["status"] = "success"; // success / fail // log2["isSent"] = true; // 已同步 // log2["param"] = "faceId=12345"; // log2["remark"] = "正常取仪器"; // // 构造一条日志 // QJsonObject log3; // log3["id"] = 1006; // log3["cabinetId"] = "A08"; // log3["createTime"] = ts202507141021; // log3["updateTime"] = ts202507141021; // log3["employeeId"] = "890"; // log3["name"] = "王五"; // log3["operation"] = "take"; // take / still // log3["type"] = "face"; // password / face / swipe // log3["status"] = "success"; // success / fail // log3["isSent"] = true; // 已同步 // log3["param"] = "faceId=12345"; // log3["remark"] = "正常取仪器"; // // 如需多条,可继续追加额外的日志记录添加到数组 // data.append(log2); // data.append(log3); // // 标准返回格式JSON响应 // QJsonObject response; // response["code"] = 200; // response["message"] = "success"; // response["data"] = data; // return response; // } // // 人脸验证处理(保留原有实现) // QJsonObject FaceRecognitionServer::handleFaceVerification(const QHttpServerRequest &request) { // // 保留原有实现...; // QJsonObject response; // 创建一个空的 QJsonObject // return response; // } // // 事件上报处理(保留原有实现) // QJsonObject FaceRecognitionServer::handleEventReport(const QHttpServerRequest &request) { // // 保留原有实现... // QJsonObject response; // 创建一个空的 QJsonObject // return response; // } // // 人脸验证逻辑(模拟实现) // bool FaceRecognitionServer::verifyFaceFeature(const QString &featureCode, QString &userId) { // // 模拟实现... // return true; // } // // 卡号验证逻辑(模拟实现) // bool FaceRecognitionServer::verifyCard(const QString &cardNumber, const QString &password, QString &userId) { // // 模拟实现... // return true; // } 利用QT6根据这两个代码写一个人脸系统
最新发布
09-29
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值