设备占用提示

master
lzq 2026-01-06 13:23:52 +08:00
parent 9012b447a0
commit 96c71f29d3
4 changed files with 24 additions and 33 deletions

View File

@ -53,7 +53,29 @@ namespace zsy
std::jthread t([recognizeResult,name,sn] std::jthread t([recognizeResult,name,sn]
{ {
LOGGER_INFO("正在处理车牌识别结果:{}、{}、{}", recognizeResult->license, name, sn); LOGGER_INFO("正在处理车牌识别结果:{}、{}、{}", recognizeResult->license, name, sn);
{
std::lock_guard<std::mutex> lock(tasks_mutex);
if (tasks.contains(sn))
{
if (auto oldLicense = tasks.at(sn); oldLicense == recognizeResult->license)
{
LOGGER_INFO("重复识别:{}、{}", sn, oldLicense);
} else
{
Application::deviceHolder->getSoundColumn(sn)->play("请等待前车业务完成后重新识别");
LOGGER_INFO("当前道闸正在处理:{}、{}", sn, oldLicense);
}
return;
} else
{
tasks[sn] = recognizeResult->license;
}
}
RecognizeProcessor::process(recognizeResult); RecognizeProcessor::process(recognizeResult);
{
std::lock_guard<std::mutex> lock(tasks_mutex);
tasks.erase(sn);
}
LOGGER_INFO("车牌识别结果处理完成"); LOGGER_INFO("车牌识别结果处理完成");
}); });
t.detach(); t.detach();

View File

@ -144,7 +144,8 @@ namespace zsy
class GenericBarrier : public Barrier class GenericBarrier : public Barrier
{ {
BarrierProperties config; BarrierProperties config;
inline static std::unordered_map<std::string, std::string> tasks;
inline static std::mutex tasks_mutex;
public: public:
explicit GenericBarrier(const BarrierProperties &config); explicit GenericBarrier(const BarrierProperties &config);

View File

@ -11,24 +11,6 @@ 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;
@ -49,23 +31,11 @@ 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

@ -13,8 +13,6 @@ 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);