Update L3 product category selection to work better for tdwr

This commit is contained in:
AdenKoperczak 2025-03-14 12:10:58 -04:00
parent 504cde0e8b
commit 6509fc7043
3 changed files with 38 additions and 6 deletions

View file

@ -73,8 +73,9 @@ Level2Product GetLevel2Product(const std::string& name);
const std::string& GetLevel3CategoryName(Level3ProductCategory category);
const std::string& GetLevel3CategoryDescription(Level3ProductCategory category);
const std::string&
GetLevel3CategoryDefaultProduct(Level3ProductCategory category);
std::string
GetLevel3CategoryDefaultProduct(Level3ProductCategory category,
const Level3ProductCategoryMap& categoryMap);
Level3ProductCategory GetLevel3Category(const std::string& categoryName);
Level3ProductCategory
GetLevel3CategoryByProduct(const std::string& productName);

View file

@ -298,9 +298,27 @@ const std::string& GetLevel3CategoryDescription(Level3ProductCategory category)
return level3CategoryDescription_.at(category);
}
const std::string&
GetLevel3CategoryDefaultProduct(Level3ProductCategory category)
std::string
GetLevel3CategoryDefaultProduct(Level3ProductCategory category,
const Level3ProductCategoryMap& categoryMap)
{
const auto& productsIt = categoryMap.find(category);
if (productsIt == categoryMap.cend())
{
return level3CategoryDefaultAwipsId_.at(category);
}
const auto& productsSiteHas = productsIt->second;
const auto& productList = level3CategoryProductList_.at(category);
for (auto& product : productList)
{
const auto& tiltsIt = productsSiteHas.find(product);
if (tiltsIt != productsSiteHas.cend() && tiltsIt->second.size() > 0)
{
return tiltsIt->second[0];
}
}
return level3CategoryDefaultAwipsId_.at(category);
}