设备占用提示

master
lzq 2026-01-05 11:48:25 +08:00
parent 72b3f05f58
commit 9012b447a0
2 changed files with 37 additions and 2 deletions

View File

@ -11,6 +11,24 @@ namespace zsy
{ {
const std::string &sn = data->sn; const std::string &sn = data->sn;
const std::string &license = data->license; const std::string &license = data->license;
{
std::lock_guard<std::mutex> lock(tasks_mutex);
if (tasks.contains(sn))
{
if (auto oldLicense = tasks.at(sn); oldLicense == license)
{
LOGGER_INFO("重复识别:{}、{}", sn, oldLicense);
} else
{
Application::deviceHolder->getSoundColumn(sn)->play("请等待前车业务完成后重新识别");
LOGGER_INFO("当前道闸正在处理:{}、{}", sn, oldLicense);
}
return;
} else
{
tasks[sn] = license;
}
}
try try
{ {
std::jthread t; std::jthread t;
@ -31,11 +49,23 @@ namespace zsy
return; return;
} }
addition_process(reportPassResult.data.orderNo, data); addition_process(reportPassResult.data.orderNo, data);
{
std::lock_guard<std::mutex> lock(tasks_mutex);
tasks.erase(sn);
}
} catch (std::exception &e) } catch (std::exception &e)
{ {
{
std::lock_guard<std::mutex> lock(tasks_mutex);
tasks.erase(sn);
}
LOGGER_ERROR("车牌识别结果处理失败: {}", e.what()); LOGGER_ERROR("车牌识别结果处理失败: {}", e.what());
} catch (...) } catch (...)
{ {
{
std::lock_guard<std::mutex> lock(tasks_mutex);
tasks.erase(sn);
}
LOGGER_ERROR("未知异常,车牌识别结果处理失败"); LOGGER_ERROR("未知异常,车牌识别结果处理失败");
} }
} }

View File

@ -1,7 +1,9 @@
#ifndef RECOGNIZE_PROCESSOR_H #ifndef RECOGNIZE_PROCESSOR_H
#define RECOGNIZE_PROCESSOR_H #define RECOGNIZE_PROCESSOR_H
#include <memory> #include <memory>
#include <mutex>
#include <string> #include <string>
#include <unordered_map>
#include "barrier/barrier.h" #include "barrier/barrier.h"
@ -11,9 +13,12 @@ namespace zsy
class RecognizeProcessor class RecognizeProcessor
{ {
public: public:
inline static std::unordered_map<std::string, std::string> tasks;
inline static std::mutex tasks_mutex;
static void process(std::shared_ptr<RecognizeData> data); static void process(std::shared_ptr<RecognizeData> data);
static void addition_process(const std::string &orderNo,std::shared_ptr<RecognizeData> data); static void addition_process(const std::string &orderNo, std::shared_ptr<RecognizeData> data);
}; };
} // zsy } // zsy