lzq 2025-11-12 18:28:08 +08:00
parent 73872bb212
commit d4c76462fa
19 changed files with 439 additions and 300 deletions

View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.31)
project(deviceAccessLayer)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(PACKAGE_DIRS
${CMAKE_CURRENT_LIST_DIR}/lib/openssl
${CMAKE_CURRENT_LIST_DIR}/lib/HCNetSDK

View File

@ -62,6 +62,15 @@
"soundColumn": "1",
"vidicon": "1"
},
{
"name": "进前置-2",
"sn": "33c05713-8a909b35",
"ip": "192.168.120.247",
"io": 0,
"platformScale": "2",
"soundColumn": "3",
"vidicon": "3"
},
{
"name": "进",
"sn": "25ec7559-74125e77",
@ -71,6 +80,15 @@
"soundColumn": "2",
"vidicon": "1"
},
{
"name": "进-2",
"sn": "2f062d64-1a240f67",
"ip": "192.168.120.242",
"io": 0,
"platformScale": "2",
"soundColumn": "4",
"vidicon": "3"
},
{
"name": "出前置",
"sn": "351b2406-6fae5ab5",
@ -80,6 +98,15 @@
"soundColumn": "2",
"vidicon": "2"
},
{
"name": "出前置-2",
"sn": "973c0ea9-256d9e08",
"ip": "192.168.120.252",
"io": 0,
"platformScale": "2",
"soundColumn": "4",
"vidicon": "4"
},
{
"name": "出",
"sn": "34fc9ce5-8b091060",
@ -88,18 +115,43 @@
"platformScale": "1",
"soundColumn": "1",
"vidicon": "2"
},
{
"name": "出-2",
"sn": "5835526e-9537e25c",
"ip": "192.168.120.241",
"io": 0,
"platformScale": "2",
"soundColumn": "3",
"vidicon": "4"
}
],
"platformScales": [
{
"sn": "1",
"name": "地磅",
"delay": 5,
"sample": 20,
"retries": 30,
"weight": 200.0,
"port": "COM2",
"baudRate": 1200,
"byteSize": 8,
"parity": 0,
"stopBits": 0
},
{
"sn": "2",
"name": "地磅-2",
"delay": 5,
"sample": 20,
"retries": 30,
"weight": 200.0,
"port": "COM3",
"baudRate": 1200,
"byteSize": 8,
"parity": 0,
"stopBits": 0
}
],
"soundColumns": [
@ -114,12 +166,26 @@
"name": "音柱2",
"server": "http://192.168.120.237:80",
"path": "/v1/speech"
},
{
"sn": "3",
"name": "音柱3",
"server": "http://192.168.120.221:80",
"path": "/v1/speech"
},
{
"sn": "4",
"name": "音柱4",
"server": "http://192.168.120.224:80",
"path": "/v1/speech"
}
],
"vidicons": [
{
"sn": "1",
"name": "摄像头1",
"type": 0,
"ip": "192.168.120.245",
"port": 8000,
"username": "admin",
@ -128,10 +194,28 @@
{
"sn": "2",
"name": "摄像头2",
"type": 0,
"ip": "192.168.120.244",
"port": 8000,
"username": "admin",
"passwd": "gk147258"
},
{
"sn": "3",
"name": "摄像头3",
"ip": "192.168.120.248",
"port": 8000,
"username": "admin",
"passwd": "Ab147258"
},
{
"sn": "4",
"name": "摄像头4",
"ip": "192.168.120.236",
"port": 8000,
"username": "admin",
"passwd": "Ab147258"
}
]
}

View File

@ -7,7 +7,7 @@ namespace zsy
{
HANDLE Application::STOP_EVENT = CreateEvent(nullptr, TRUE, FALSE, nullptr);
std::shared_ptr<ThreadPool> Application::threadPool = nullptr;
// std::shared_ptr<ThreadPool> Application::threadPool = nullptr;
std::shared_ptr<EventManager> Application::eventManager = nullptr;
std::shared_ptr<HttpSvr> Application::httpSvr = nullptr;
std::shared_ptr<MqttSvr> Application::mqttSvr = nullptr;
@ -38,8 +38,7 @@ namespace zsy
{
LOGGER_ERROR("配置文件加载失败,请检查配置文件是否有误,{}", e.what());
exit(1);
}
catch (...)
} catch (...)
{
LOGGER_ERROR("未知异常,配置文件加载失败");
exit(1);
@ -66,7 +65,7 @@ namespace zsy
} catch (const std::exception &e)
{
LOGGER_ERROR("PID 文件删除失败:{}", e.what());
}catch (...)
} catch (...)
{
LOGGER_ERROR("未知异常PID 文件删除失败");
}
@ -91,7 +90,7 @@ namespace zsy
{
pid = {};
LOGGER_ERROR("PID 写入失败:{}", e.what());
}catch (...)
} catch (...)
{
pid = {};
LOGGER_ERROR("未知异常PID 写入失败");
@ -113,7 +112,7 @@ namespace zsy
LOGGER_INFO("等待...");
std::this_thread::sleep_for(std::chrono::milliseconds(appProperties.delay * 1000));
}
threadPool = std::make_shared<ThreadPool>("通用线程池");
// threadPool = std::make_shared<ThreadPool>("通用线程池");
eventManager = std::make_shared<EventManager>();
@ -121,7 +120,10 @@ namespace zsy
oss = std::make_shared<OSS>(config);
// mqttSvr = std::make_shared<MqttSvr>();
if (appProperties.embedMqtt)
{
mqttSvr = std::make_shared<MqttSvr>();
}
mqttCliHolder = std::make_shared<MqttCliHolder>(config, eventManager);

View File

@ -15,6 +15,7 @@ namespace zsy
bool daemon{false};
uint32_t delay{0};
std::string name;
bool embedMqtt{false};
};
inline void from_json(const nlohmann::json &j, AppProperties &o)
@ -22,6 +23,7 @@ namespace zsy
PARSE_JSON(daemon, o.daemon);
PARSE_JSON(delay, o.delay);
PARSE_JSON(name, o.name);
PARSE_JSON(embedMqtt, o.embedMqtt);
}
class Application
@ -40,7 +42,7 @@ namespace zsy
void writePid();
public:
static std::shared_ptr<ThreadPool> threadPool;
// static std::shared_ptr<ThreadPool> threadPool;
static std::shared_ptr<EventManager> eventManager;

View File

@ -19,6 +19,8 @@ namespace zsy
virtual std::string sn() = 0;
virtual std::string name() = 0;
virtual std::shared_ptr<std::istream> resolvePhoto(const std::string &imageFile) = 0;
};
} // zsy

View File

@ -47,20 +47,27 @@ namespace zsy
auto body = req.body;
LOGGER_INFO("收到车牌识别结果:{}", body);
auto [succ,recognizeResult] = GenericBarrier::parseRecognizeResult(body);
auto [succ,recognizeResult,name,sn] = GenericBarrier::parseRecognizeResult(body);
if (succ)
{
Application::threadPool->submit([recognizeResult]
std::jthread t([recognizeResult,name,sn]
{
LOGGER_INFO("正在处理车牌识别结果:{} {}", name, sn);
RecognizeProcessor::process(recognizeResult);
LOGGER_INFO("车牌识别结果处理完成");
});
t.detach();
/*Application::threadPool->submit([recognizeResult,name,sn]
{
LOGGER_INFO("正在处理车牌识别结果:{} {}", name, sn);
RecognizeProcessor::process(recognizeResult);
LOGGER_INFO("车牌识别结果处理完成");
});*/
}
} catch (std::exception &e)
{
LOGGER_ERROR("车牌识别结果处理失败: {}", e.what());
}
catch (...)
} catch (...)
{
LOGGER_ERROR("未知异常,车牌识别结果处理失败");
}
@ -117,13 +124,18 @@ namespace zsy
return config.sn;
}
std::string GenericBarrier::name()
{
return config.name;
}
std::shared_ptr<std::istream> GenericBarrier::resolvePhoto(const std::string &imageFile)
{
auto content = SysUtil::base64_decode(imageFile);
return std::make_shared<std::istringstream>(content, std::ios_base::in | std::ios_base::binary);
}
std::tuple<bool, std::shared_ptr<RecognizeData> > GenericBarrier::parseRecognizeResult(const std::string &jsonStr)
std::tuple<bool, std::shared_ptr<RecognizeData>, std::string, std::string> GenericBarrier::parseRecognizeResult(const std::string &jsonStr)
{
try
{
@ -134,7 +146,7 @@ namespace zsy
if (!barrier)
{
LOGGER_ERROR("未找到对应的道闸");
return std::make_tuple(false, nullptr);
return std::make_tuple(false, nullptr, "", "");
}
auto image_file = result.alarmInfoPlate.result.plateResult.imageFile;
auto license = result.alarmInfoPlate.result.plateResult.license;
@ -146,22 +158,23 @@ namespace zsy
)
{
LOGGER_ERROR("车牌识别结果解析失败或车牌为:“无”");
return std::make_tuple(false, nullptr);
return std::make_tuple(false, nullptr, "", "");
}
return std::make_tuple(true, std::make_shared<RecognizeData>(
barrier->isFront(),
sn,
license,
barrier->resolvePhoto(image_file)
));
),
barrier->name(), barrier->sn());
} catch (std::exception &e)
{
LOGGER_ERROR("未找到车牌识别结果:{}", e.what());
return std::make_tuple(false, nullptr);
}catch (...)
return std::make_tuple(false, nullptr, "", "");
} catch (...)
{
LOGGER_ERROR("未知异常,未找到车牌识别结果");
return std::make_tuple(false, nullptr);
return std::make_tuple(false, nullptr, "", "");
}
}

View File

@ -154,9 +154,11 @@ namespace zsy
std::string sn() override;
std::string name() override;
std::shared_ptr<std::istream> resolvePhoto(const std::string &imageFile) override;
static std::tuple<bool, std::shared_ptr<RecognizeData> > parseRecognizeResult(const std::string &jsonStr);
static std::tuple<bool, std::shared_ptr<RecognizeData>, std::string, std::string> parseRecognizeResult(const std::string &jsonStr);
};
} // zsy

View File

@ -0,0 +1,129 @@
#include "color_format.h"
namespace zsy
{
ColorFormat::ColorFormat(const bool console) : console(console)
{
}
ColorFormat::ColorFormat() : console(true)
{
}
void ColorFormat::format(const spdlog::details::log_msg &msg, const std::tm &tm_time, spdlog::memory_buf_t &dest)
{
if (!console)
{
const auto str = txt(msg);
const auto c_str = str->c_str();
dest.append(c_str, c_str + str->size());
return;
}
switch (msg.level)
{
case spdlog::level::trace:
{
const auto begin = ANSI_BLACK;
dest.append(begin, begin + 5);
}
break;
case spdlog::level::debug:
{
const auto begin = ANSI_GREEN;
dest.append(begin, begin + 5);
}
break;
case spdlog::level::info:
{
const auto begin = ANSI_BLUE;
dest.append(begin, begin + 5);
}
break;
case spdlog::level::warn:
{
const auto begin = ANSI_YELLOW;
dest.append(begin, begin + 5);
}
break;
case spdlog::level::err:
{
const auto begin = ANSI_RED;
dest.append(begin, begin + 5);
}
break;
case spdlog::level::critical:
{
const auto begin = ANSI_BRIGHT_RED;
dest.append(begin, begin + 5);
}
break;
default: ;
}
const auto str = txt(msg);
const auto c_str = str->c_str();
dest.append(c_str, c_str + str->size());
const auto begin = ANSI_NONE;
dest.append(begin, begin + 4);
}
LogMsgFormat::LogMsgFormat(const bool console) : ColorFormat(console)
{
}
LogMsgFormat::LogMsgFormat() : ColorFormat(true)
{
}
std::unique_ptr<spdlog::custom_flag_formatter> LogMsgFormat::clone() const
{
return spdlog::details::make_unique < LogMsgFormat > (console);
}
std::unique_ptr<std::string> LogMsgFormat::txt(const spdlog::details::log_msg &msg)
{
std::string result;
result.reserve(msg.payload.size());
for (const char ch: msg.payload)
{
result += ch;
}
return std::make_unique<std::string>(std::move(result));
}
LogLevelFormat::LogLevelFormat(const bool console) : ColorFormat(console)
{
}
LogLevelFormat::LogLevelFormat() : ColorFormat(true)
{
}
std::unique_ptr<spdlog::custom_flag_formatter> LogLevelFormat::clone() const
{
return spdlog::details::make_unique < LogLevelFormat > (console);
}
std::unique_ptr<std::string> LogLevelFormat::txt(const spdlog::details::log_msg &msg)
{
switch (msg.level)
{
case spdlog::level::trace:
return std::make_unique<std::string>("TRACE");
case spdlog::level::debug:
return std::make_unique<std::string>("DEBUG");
case spdlog::level::info:
return std::make_unique<std::string>("INFO ");
case spdlog::level::warn:
return std::make_unique<std::string>("WARN ");
case spdlog::level::err:
return std::make_unique<std::string>("ERROR");
case spdlog::level::critical:
return std::make_unique<std::string>("CRTCL");
default:
return std::make_unique<std::string>("DEFLT");
}
}
}

View File

@ -0,0 +1,67 @@
#ifndef DEVICE_CTRL_COLOR_FORMAT_H
#define DEVICE_CTRL_COLOR_FORMAT_H
#include <spdlog/sinks/base_sink.h>
#include "spdlog/pattern_formatter.h"
#define ANSI_NONE "\033[0m"
#define ANSI_BLACK "\033[30m"
#define ANSI_RED "\033[31m"
#define ANSI_GREEN "\033[32m"
#define ANSI_YELLOW "\033[33m"
#define ANSI_BLUE "\033[34m"
#define ANSI_MAGENTA "\033[35m"
#define ANSI_CYAN "\033[36m"
#define ANSI_WHITE "\033[37m"
#define ANSI_BRIGHT_BLACK "\033[90m"
#define ANSI_BRIGHT_RED "\033[91m"
#define ANSI_BRIGHT_GREEN "\033[92m"
#define ANSI_BRIGHT_YELLOW "\033[93m"
#define ANSI_BRIGHT_BLUE "\033[94m"
#define ANSI_BRIGHT_MAGENTA "\033[95m"
#define ANSI_BRIGHT_CYAN "\033[96m"
#define ANSI_BRIGHT_WHITE "\033[97m"
namespace zsy
{
class ColorFormat : public spdlog::custom_flag_formatter
{
protected:
bool console;
public:
explicit ColorFormat(bool console);
ColorFormat();
void format(const spdlog::details::log_msg &msg, const std::tm &tm_time, spdlog::memory_buf_t &dest) override;
virtual std::unique_ptr<std::string> txt(const spdlog::details::log_msg &msg) = 0;
};
class LogMsgFormat final : public ColorFormat
{
public:
explicit LogMsgFormat(bool console);
LogMsgFormat();
std::unique_ptr<std::string> txt(const spdlog::details::log_msg &msg) override;
std::unique_ptr<custom_flag_formatter> clone() const override;
};
class LogLevelFormat final : public ColorFormat
{
public:
explicit LogLevelFormat(bool console);
LogLevelFormat();
std::unique_ptr<std::string> txt(const spdlog::details::log_msg &msg) override;
std::unique_ptr<custom_flag_formatter> clone() const override;
};
}
#endif //DEVICE_CTRL_COLOR_FORMAT_H

View File

@ -1,8 +1,8 @@
#include "daily_and_size_sink.h"
#include <ctime>
#include <regex>
#include "date_util.h"
#include <charconv>
#include <regex>
#include "utils/date_util.h"
namespace zsy
{
@ -22,7 +22,6 @@ namespace zsy
fileHelper.open(basePath + "\\" + baseFilename + baseExt, false);
}
void DailyAndSizeSink::rotateFile()
{
auto current_date = DateUtil::format(Ymd_);
@ -71,9 +70,25 @@ namespace zsy
if (std::regex_match(filename, match, file_pattern))
{
std::string date_str = match[1].str();
std::chrono::sys_days date;
std::istringstream tstr(date_str);
tstr >> std::chrono::parse("%F", date);
int year, month, day;
char dash1, dash2;
// 解析字符串格式YYYY-MM-DD
std::istringstream iss(date_str);
if (!(iss >> year >> dash1 >> month >> dash2 >> day) || dash1 != '-' || dash2 != '-')
{
throw std::invalid_argument("无效的日期格式,需为 YYYY-MM-DD");
}
std::chrono::year_month_day ymd(std::chrono::year{year},
std::chrono::month{(unsigned) month}, std::chrono::day{(unsigned) day});
if (!ymd.ok())
{
throw std::invalid_argument("无效的日期");
}
std::chrono::sys_days date{ymd};
if (date < cutoff_time)
{
std::filesystem::remove(entry.path());
@ -87,7 +102,6 @@ namespace zsy
}
}
void DailyAndSizeSink::sink_it_(const spdlog::details::log_msg &msg)
{
spdlog::memory_buf_t formatted;
@ -104,19 +118,6 @@ namespace zsy
fileHelper.flush();
}
/*std::string DailyAndSizeSink::today()
{
auto now = std::chrono::system_clock::now();
time_t current_time = std::chrono::system_clock::to_time_t(now);
tm local_tm{};
localtime_s(&local_tm, &current_time);
char buffer[11];
std::strftime(buffer, sizeof(buffer), "%F", &local_tm);
return std::string(buffer);
}*/
uint32_t DailyAndSizeSink::lastIndex()
{
uint32_t index = 0;
@ -152,4 +153,4 @@ namespace zsy
}
return size;
}
}
}

View File

@ -28,20 +28,18 @@ namespace zsy
void cleanOldFiles();
// std::string today();
uint32_t lastIndex();
uintmax_t lastSize();
public:
DailyAndSizeSink( const std::string &filename, size_t maxSize, int32_t maxDays);
DailyAndSizeSink(const std::string &filename, size_t maxSize, int32_t maxDays);
protected:
void sink_it_(const spdlog::details::log_msg &msg) override;
void flush_() override;
};
}
#endif //DAILY_AND_SIZE_SINK_H
#endif //DAILY_AND_SIZE_SINK_H

View File

@ -16,7 +16,7 @@ namespace zsy
}
}
EventManager::EventManager(): threadPool(std::make_shared<ThreadPool>("事件线程池", 10))
EventManager::EventManager()
{
}
@ -63,9 +63,5 @@ namespace zsy
LOGGER_ERROR("事件处理异常:{}", name);
}
}
/*threadPool->submit([list, name, data]
{
});*/
}
} // zsy

View File

@ -1,10 +1,11 @@
#ifndef EVENT_MANAGER_H
#define EVENT_MANAGER_H
#include <mutex>
#include <shared_mutex>
#include <string>
#include <nlohmann/json.hpp>
#include "thread_pool.h"
// #include "thread_pool.h"
namespace zsy
{
@ -32,7 +33,7 @@ namespace zsy
private:
std::unordered_map<std::string, HandlerList> handlers;
std::shared_mutex handlersMutex;
std::shared_ptr<ThreadPool> threadPool;
// std::shared_ptr<ThreadPool> threadPool;
};
} // zsy

View File

@ -1,8 +1,12 @@
#include <spdlog/spdlog.h>
#include <spdlog/sinks/stdout_color_sinks.h>
// #include <spdlog/sinks/daily_file_sink.h>
#include "sys_util.h"
#include "daily_and_size_sink.h"
#include <spdlog/pattern_formatter.h>
#include "color_format.h"
#define CONSOLE_PATTERN ANSI_MAGENTA"%Y-%m-%d %H:%M:%S.%e" ANSI_NONE" %l" ANSI_BLUE" %=6t %s:%#" ANSI_BLUE" [%!]" ANSI_NONE" ===> %v"
#define FILE_PATTERN "%Y-%m-%d %H:%M:%S.%e %l %=6t %s:%# [%!] ===> %v"
namespace zsy
{
@ -16,18 +20,26 @@ namespace zsy
50 * 1024 * 1024,
15
);
file_sink->set_level(spdlog::level::info);
file_sink->set_pattern("%Y-%m-%d %H:%M:%S.%e %=7l %=10t %s [%! %#]: %v");
constexpr auto level = static_cast<spdlog::level::level_enum>(SPDLOG_ACTIVE_LEVEL);
auto file_formatter = std::make_unique<spdlog::pattern_formatter>();
file_formatter->add_flag<LogLevelFormat>('l', false)
.set_pattern(FILE_PATTERN);
file_sink->set_formatter(std::move(file_formatter));
auto console_formatter = std::make_unique<spdlog::pattern_formatter>();
console_formatter->add_flag<LogLevelFormat>('l')
.add_flag<LogMsgFormat>('v')
.set_pattern(CONSOLE_PATTERN);
const auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
console_sink->set_level(spdlog::level::info);
console_sink->set_pattern("%Y-%m-%d %H:%M:%S.%e %=7l %=10t %s [%! %#]: %v");
console_sink->set_formatter(std::move(console_formatter));
spdlog::sinks_init_list sinks = {console_sink, file_sink};
auto logger = std::make_shared<spdlog::logger>("zsy", sinks);
logger->flush_on(spdlog::level::info);
spdlog::set_default_logger(logger);
return logger;
auto logger_ = std::make_shared<spdlog::logger>("zsy", sinks);
logger_->set_level(level);
logger_->flush_on(level);
spdlog::set_default_logger(logger_);
return logger_;
}();
return logger;
}

View File

@ -180,7 +180,7 @@ namespace zsy
std::wstring wstr = str_a_w(astr);
size_t size = wstr.size() + 1;
auto result = std::make_shared<wchar_t[]>(size);
auto result = std::unique_ptr <wchar_t[]>(new wchar_t[size], std::default_delete<wchar_t[]>());
wcscpy_s(result.get(), size, wstr.c_str());
return result;
}
@ -194,7 +194,7 @@ namespace zsy
std::string utf8 = str_w_a(wstr);
size_t size = utf8.size() + 1;
auto result = std::make_shared<char[]>(size);
auto result = std::unique_ptr<char[]>(new char[size], std::default_delete<char[]>());
strcpy_s(result.get(), size, utf8.c_str());
return result;
}

View File

@ -42,8 +42,7 @@ namespace zsy
} catch (const std::exception &e)
{
LOGGER_ERROR("MQTT{} 连接失败:{}", config.clientId, e.what());
}
catch (...)
} catch (...)
{
LOGGER_ERROR("MQTT{} 连接失败", config.clientId);
}
@ -83,8 +82,7 @@ namespace zsy
std::unique_lock lock(status_mtx);
status = 0;
LOGGER_ERROR("MQTT 连接失败:{}", SysUtil::str_w_a(SysUtil::str_a_w(std::string(e.what()),"GBK" )));
}
catch (...)
} catch (...)
{
std::unique_lock lock(status_mtx);
status = 0;
@ -145,7 +143,11 @@ namespace zsy
auto topic = topic_.to_string();
auto payload = payload_.to_string();
LOGGER_INFO("MQTT 收到消息,设备名称:{}ID{},主题:{},消息内容:{}", config.name, config.clientId, topic, payload);
eventManager->publish(config.clientId + "/" + topic, payload);
std::jthread t([em = eventManager, cid = config.clientId, topic, payload]
{
em->publish(cid + "/" + topic, payload);
});
t.detach();
return true;
}
@ -156,12 +158,6 @@ namespace zsy
void MqttCli::publish(std::string topic, std::string payload, uint8_t qos)
{
/*std::shared_lock<std::shared_mutex> lock(status_mtx);
if (status == 0)
{
LOGGER_ERROR("MQTT 未连接,无法发布消息:{}", config.clientId);
return;
}*/
cli->publish(topic, payload, static_cast<MQTT_NS::qos>(qos));
}

View File

@ -12,7 +12,7 @@
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/composite_key.hpp>
#include <thread>
namespace zsy
{

View File

@ -13,10 +13,15 @@ namespace zsy
const std::string &license = data->license;
try
{
std::jthread t;
if (data->isFront)
{
Application::threadPool->submit([sn] { Application::deviceHolder->getSoundColumn(sn)->play("欢迎光临"); });
t = std::jthread([sn]
{
Application::deviceHolder->getSoundColumn(sn)->play("欢迎光临");
});
}
t.detach();
// 上报 1
auto reportPassResult = Application::reportSvr->reportPass(license, sn);
@ -29,8 +34,7 @@ namespace zsy
} catch (std::exception &e)
{
LOGGER_ERROR("车牌识别结果处理失败: {}", e.what());
}
catch (...)
} catch (...)
{
LOGGER_ERROR("未知异常,车牌识别结果处理失败");
}
@ -42,14 +46,19 @@ namespace zsy
const std::string &license = data->license;
std::shared_ptr<std::istream> frontImageFile = data->imageFile;
// 上报结果 type 不为 0播放语音 2 并读地磅,拍车斗并上传
Application::threadPool->submit([sn] { Application::deviceHolder->getSoundColumn(sn)->play("正在称重,请稍后"); });
std::jthread t([sn]
{
Application::deviceHolder->getSoundColumn(sn)->play("正在称重,请稍后");
});
auto weight = Application::deviceHolder->getPlatformScale(sn)->reading();
std::string date = DateUtil::format(Ymd);
auto photoId = Snowflake::genIdStr();
auto bodyImageFile = Application::deviceHolder->getVidicon(sn)->photograph();
auto [carFrontUrlSucc,carFrontUrl] = Application::oss->upload(date + "/" + "front_" + photoId + ".jpg", frontImageFile);
auto [carBodyUrlSucc,carBodyUrl] = Application::oss->upload(date + "/" + "body_" + photoId + ".jpg", bodyImageFile);

View File

@ -1,220 +1,45 @@
{
"name" : "dal",
"version-string" : "1.0.0",
"builtin-baseline" : "3421943bfdef53a1d16404e98b5b487112c59df2",
"dependencies" : [ {
"name" : "boost-algorithm",
"version>=" : "1.88.0"
}, {
"name" : "boost-align",
"version>=" : "1.88.0"
}, {
"name" : "boost-any",
"version>=" : "1.88.0"
}, {
"name" : "boost-array",
"version>=" : "1.88.0"
}, {
"name" : "boost-asio",
"version>=" : "1.88.0"
}, {
"name" : "boost-assert",
"version>=" : "1.88.0"
}, {
"name" : "boost-atomic",
"version>=" : "1.88.0"
}, {
"name" : "boost-bind",
"version>=" : "1.88.0"
}, {
"name" : "boost-chrono",
"version>=" : "1.88.0"
}, {
"name" : "boost-cmake",
"version>=" : "1.88.0"
}, {
"name" : "boost-concept-check",
"version>=" : "1.88.0"
}, {
"name" : "boost-config",
"version>=" : "1.88.0"
}, {
"name" : "boost-container-hash",
"version>=" : "1.88.0"
}, {
"name" : "boost-container",
"version>=" : "1.88.0"
}, {
"name" : "boost-context",
"version>=" : "1.88.0"
}, {
"name" : "boost-conversion",
"version>=" : "1.88.0"
}, {
"name" : "boost-core",
"version>=" : "1.88.0"
}, {
"name" : "boost-date-time",
"version>=" : "1.88.0"
}, {
"name" : "boost-describe",
"version>=" : "1.88.0"
}, {
"name" : "boost-detail",
"version>=" : "1.88.0"
}, {
"name" : "boost-exception",
"version>=" : "1.88.0"
}, {
"name" : "boost-function-types",
"version>=" : "1.88.0"
}, {
"name" : "boost-function",
"version>=" : "1.88.0"
}, {
"name" : "boost-functional",
"version>=" : "1.88.0"
}, {
"name" : "boost-fusion",
"version>=" : "1.88.0"
}, {
"name" : "boost-headers",
"version>=" : "1.88.0"
}, {
"name" : "boost-integer",
"version>=" : "1.88.0"
}, {
"name" : "boost-intrusive",
"version>=" : "1.88.0"
}, {
"name" : "boost-io",
"version>=" : "1.88.0"
}, {
"name" : "boost-iterator",
"version>=" : "1.88.0"
}, {
"name" : "boost-lexical-cast",
"version>=" : "1.88.0"
}, {
"name" : "boost-move",
"version>=" : "1.88.0"
}, {
"name" : "boost-mp11",
"version>=" : "1.88.0"
}, {
"name" : "boost-mpl",
"version>=" : "1.88.0"
}, {
"name" : "boost-multi-index",
"version>=" : "1.88.0"
}, {
"name" : "boost-numeric-conversion",
"version>=" : "1.88.0"
}, {
"name" : "boost-optional",
"version>=" : "1.88.0"
}, {
"name" : "boost-pool",
"version>=" : "1.88.0"
}, {
"name" : "boost-predef",
"version>=" : "1.88.0"
}, {
"name" : "boost-preprocessor",
"version>=" : "1.88.0"
}, {
"name" : "boost-program-options",
"version>=" : "1.88.0"
}, {
"name" : "boost-range",
"version>=" : "1.88.0"
}, {
"name" : "boost-ratio",
"version>=" : "1.88.0"
}, {
"name" : "boost-regex",
"version>=" : "1.88.0"
}, {
"name" : "boost-smart-ptr",
"version>=" : "1.88.0"
}, {
"name" : "boost-static-assert",
"version>=" : "1.88.0"
}, {
"name" : "boost-system",
"version>=" : "1.88.0"
}, {
"name" : "boost-thread",
"version>=" : "1.88.0"
}, {
"name" : "boost-throw-exception",
"version>=" : "1.88.0"
}, {
"name" : "boost-tokenizer",
"version>=" : "1.88.0"
}, {
"name" : "boost-tuple",
"version>=" : "1.88.0"
}, {
"name" : "boost-type-erasure",
"version>=" : "1.88.0"
}, {
"name" : "boost-type-index",
"version>=" : "1.88.0"
}, {
"name" : "boost-type-traits",
"version>=" : "1.88.0"
}, {
"name" : "boost-typeof",
"version>=" : "1.88.0"
}, {
"name" : "boost-uninstall",
"version>=" : "1.88.0"
}, {
"name" : "boost-unordered",
"version>=" : "1.88.0"
}, {
"name" : "boost-utility",
"version>=" : "1.88.0"
}, {
"name" : "boost-variant2",
"version>=" : "1.88.0"
}, {
"name" : "boost-vmd",
"version>=" : "1.88.0"
}, {
"name" : "boost-winapi",
"version>=" : "1.88.0"
}, {
"name" : "mqtt-cpp",
"version>=" : "13.2.1"
}, {
"name" : "vcpkg-boost",
"version>=" : "2025-03-29"
}, {
"name" : "vcpkg-cmake-config",
"version>=" : "2024-05-23"
}, {
"name" : "vcpkg-cmake",
"version>=" : "2024-04-23"
}, {
"name" : "nlohmann-json",
"version>=" : "3.12.0"
}, {
"name" : "spdlog",
"version>=" : "1.15.3"
}, {
"name" : "cpp-httplib",
"version>=" : "0.20.1"
}, {
"name" : "cppcodec",
"version>=" : "0.2#4"
}, {
"name" : "icu",
"version>=" : "74.2#5"
} ],
"overrides" : [ {
"name" : "cpp-httplib",
"version" : "0.10.3"
} ]
"name": "dal",
"version-string": "1.0.0",
"builtin-baseline": "e3ed41868d5034bc608eaaa58383cd6ecdbb5ffb",
"dependencies": [
{
"name": "boost-asio",
"version>=": "1.88.0"
},
{
"name": "mqtt-cpp",
"version>=": "13.2.1"
},
{
"name" : "boost-array",
"version>=" : "1.88.0"
},
{
"name": "nlohmann-json",
"version>=": "3.12.0"
},
{
"name": "spdlog",
"version>=": "1.15.3"
},
{
"name": "cpp-httplib",
"version>=": "0.20.1"
},
{
"name": "cppcodec",
"version>=": "0.2#4"
},
{
"name": "icu",
"version>=": "74.2#5"
}
],
"overrides": [
{
"name": "cpp-httplib",
"version": "0.10.3"
}
]
}