chore: 移动arkplanner的默认模板到配置文件中,并简单修改了一下输出json格式

This commit is contained in:
MistEO
2022-06-21 22:47:23 +08:00
parent edf74e34c8
commit 2dcdc48caa
5 changed files with 63 additions and 21 deletions

View File

@@ -8,6 +8,7 @@
#include "Controller.h"
#include "TaskData.h"
#include "DepotImageAnalyzer.h"
#include "Resource.h"
bool asst::DepotTask::run()
{
@@ -37,27 +38,27 @@ bool asst::DepotTask::run()
future.wait();
}
auto& templ = Resrc.cfg().get_options().depot_export_template;
json::value info = basic_info_with_what("DepotInfo");
auto& details = info["details"];
// TODO: move it to config file
auto arkplanner_template_opt = json::parse(R"(
{
"@type": "@penguin-statistics/depot",
"items": []
}
)");
auto& arkplanner_data = info["details"]["data"]["arkplanner"];
arkplanner_data = arkplanner_template_opt.value_or(json::value());
auto& arkplanner_data_imtes = arkplanner_data["items"];
auto arkplanner_template_opt = json::parse(templ.ark_planner);
if (arkplanner_template_opt) {
auto& arkplanner = details["arkplanner"];
auto& arkplanner_obj = arkplanner["object"];
arkplanner_obj = arkplanner_template_opt.value();
auto& arkplanner_data_items = arkplanner_obj["items"];
for (const auto& [item_id, item_info] : all_items) {
arkplanner_data_imtes.array_emplace(
json::object({
{ "id", item_id },
{ "have", item_info.quantity },
{ "name", item_info.item_name }
})
);
for (const auto& [item_id, item_info] : all_items) {
arkplanner_data_items.array_emplace(
json::object({
{ "id", item_id },
{ "have", item_info.quantity },
{ "name", item_info.item_name }
})
);
}
arkplanner["data"] = arkplanner_obj.to_string();
}
callback(AsstMsg::SubTaskExtraInfo, info);