From a7df0e1d5521248302e5437a1cf7b14c29b3cbaa Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 05 九月 2025 13:55:31 +0800
Subject: [PATCH] 1.CParam增加站点名称,以便将来知道Glass的工艺参数来自哪台机;

---
 SourceCode/Bond/Servo/RecipeManager.cpp |   80 +++++++++++++++++++++++++++------------
 1 files changed, 55 insertions(+), 25 deletions(-)

diff --git a/SourceCode/Bond/Servo/RecipeManager.cpp b/SourceCode/Bond/Servo/RecipeManager.cpp
index db65214..bc44b96 100644
--- a/SourceCode/Bond/Servo/RecipeManager.cpp
+++ b/SourceCode/Bond/Servo/RecipeManager.cpp
@@ -480,13 +480,13 @@
 	return m_pDB->executeQuery(query.str());
 }
 
-bool RecipeManager::addDeviceRecipe(const std::string& deviceName, int nRecipeID, const std::string& strRecipeName) {
-	if (!m_pDB || deviceName.empty() || nRecipeID <= 0 || strRecipeName.empty()) { 
+bool RecipeManager::addDeviceRecipe(const std::string& strDeviceName, int nID, const std::string& strName, const std::string& strPara) {
+	if (!m_pDB || strDeviceName.empty() || nID <= 0 || strName.empty() || strPara.empty()) {
 		return false;
 	}
 
 	std::ostringstream sql;
-	sql << "CREATE TABLE IF NOT EXISTS " << deviceName << "_Recipes ("
+	sql << "CREATE TABLE IF NOT EXISTS " << strDeviceName << "_Recipes ("
 		<< "recipe_id INTEGER PRIMARY KEY,"
 		<< "recipe_name TEXT NOT NULL,"
 		<< "recipe_para TEXT NOT NULL"
@@ -494,34 +494,48 @@
 	m_pDB->executeQuery(sql.str());
 
 	std::ostringstream ins;
-	ins << "INSERT OR REPLACE INTO " << deviceName << "_Recipes (recipe_id, recipe_name) VALUES ("
-		<< nRecipeID << ", '" << strRecipeName << "');";
+	ins << "INSERT OR REPLACE INTO " << strDeviceName
+		<< "_Recipes (recipe_id, recipe_name, recipe_para) VALUES ("
+		<< nID << ", '" << strName << "', '" << strPara << "');";
 
 	std::lock_guard<std::recursive_mutex> lk(m_mutex);
 	return m_pDB->executeQuery(ins.str());
 }
 
-bool RecipeManager::updateDeviceRecipe(const std::string& deviceName, int nRecipeID, const std::string& newName) {
-	if (!m_pDB || deviceName.empty() || nRecipeID <= 0 || newName.empty()) { 
+bool RecipeManager::updateDeviceRecipeName(const std::string& strDeviceName, int nID, const std::string& strNewName) {
+	if (!m_pDB || strDeviceName.empty() || nID <= 0 || strNewName.empty()) {
 		return false;
 	}
 
 	std::ostringstream sql;
-	sql << "UPDATE " << deviceName << "_Recipes SET recipe_name='" << newName
-		<< "' WHERE recipe_id=" << nRecipeID << ";";
+	sql << "UPDATE " << strDeviceName << "_Recipes SET recipe_name='" << strNewName
+		<< "' WHERE recipe_id=" << nID << ";";
 
 	std::lock_guard<std::recursive_mutex> lk(m_mutex);
 	return m_pDB->executeQuery(sql.str());
 }
 
-std::string RecipeManager::getDeviceRecipeName(const std::string& deviceName, int nRecipeID) {
-	if (!m_pDB || deviceName.empty() || nRecipeID <= 0) {
+bool RecipeManager::updateDeviceRecipePara(const std::string& strDeviceName, int nID, const std::string& strNewPara) {
+	if (!m_pDB || strDeviceName.empty() || nID <= 0) {
+		return false;
+	}
+
+	std::ostringstream sql;
+	sql << "UPDATE " << strDeviceName << "_Recipes SET recipe_para='" << strNewPara
+		<< "' WHERE recipe_id=" << nID << ";";
+
+	std::lock_guard<std::recursive_mutex> lk(m_mutex);
+	return m_pDB->executeQuery(sql.str());
+}
+
+std::string RecipeManager::getDeviceRecipeName(const std::string& strDeviceName, int nID) {
+	if (!m_pDB || strDeviceName.empty() || nID <= 0) {
 		return "";
 	}
 
 	std::ostringstream sql;
-	sql << "SELECT recipe_name FROM " << deviceName << "_Recipes "
-		<< "WHERE recipe_id=" << nRecipeID << " LIMIT 1;";
+	sql << "SELECT recipe_name FROM " << strDeviceName << "_Recipes "
+		<< "WHERE recipe_id=" << nID << " LIMIT 1;";
 
 	auto rows = m_pDB->fetchResults(sql.str());
 	if (!rows.empty() && !rows[0].empty()) {
@@ -530,26 +544,42 @@
 	return "";
 }
 
-bool RecipeManager::deleteDeviceRecipe(const std::string& deviceName, int nRecipeID) {
-	if (!m_pDB || deviceName.empty() || nRecipeID <= 0) { 
+std::string RecipeManager::getDeviceRecipePara(const std::string& strDeviceName, int nID) {
+	if (!m_pDB || strDeviceName.empty() || nID <= 0) {
+		return "";
+	}
+
+	std::ostringstream sql;
+	sql << "SELECT recipe_para FROM " << strDeviceName << "_Recipes "
+		<< "WHERE recipe_id=" << nID << " LIMIT 1;";
+
+	auto rows = m_pDB->fetchResults(sql.str());
+	if (!rows.empty() && !rows[0].empty()) {
+		return rows[0][0];
+	}
+	return "";
+}
+
+bool RecipeManager::deleteDeviceRecipe(const std::string& strDeviceName, int nID) {
+	if (!m_pDB || strDeviceName.empty() || nID <= 0) {
 		return false;
 	}
 
 	std::ostringstream sql;
-	sql << "DELETE FROM " << deviceName << "_Recipes WHERE recipe_id=" << nRecipeID << ";";
+	sql << "DELETE FROM " << strDeviceName << "_Recipes WHERE recipe_id=" << nID << ";";
 
 	std::lock_guard<std::recursive_mutex> lk(m_mutex);
 	return m_pDB->executeQuery(sql.str());
 }
 
-std::vector<std::pair<int, std::string>> RecipeManager::getDeviceRecipes(const std::string& deviceName) {
+std::vector<std::pair<int, std::string>> RecipeManager::getDeviceRecipes(const std::string& strDeviceName) {
 	std::vector<std::pair<int, std::string>> out;
-	if (!m_pDB || deviceName.empty()) { 
+	if (!m_pDB || strDeviceName.empty()) {
 		return out;
 	}
 
 	std::ostringstream sql;
-	sql << "SELECT recipe_id, recipe_name FROM " << deviceName << "_Recipes ORDER BY recipe_id;";
+	sql << "SELECT recipe_id, recipe_name FROM " << strDeviceName << "_Recipes ORDER BY recipe_id;";
 
 	auto rows = m_pDB->fetchResults(sql.str());
 	for (const auto& r : rows) {
@@ -580,13 +610,13 @@
 
 	addRecipe(recipe);
 
-	addDeviceRecipe("Bonder1", 101, "鏍囧噯宸ヨ壓");
-	addDeviceRecipe("Bonder1", 102, "鏀硅壇宸ヨ壓");
-	addDeviceRecipe("Bonder1", 103, "楂橀�熸ā寮�");
+	addDeviceRecipe("Bonder1", 101, "鏍囧噯宸ヨ壓", "");
+	addDeviceRecipe("Bonder1", 102, "鏀硅壇宸ヨ壓", "");
+	addDeviceRecipe("Bonder1", 103, "楂橀�熸ā寮�", "");
 
-	addDeviceRecipe("Bonder2", 101, "鏍囧噯宸ヨ壓");
-	addDeviceRecipe("Bonder2", 102, "鏀硅壇宸ヨ壓");
-	addDeviceRecipe("Bonder2", 103, "楂橀�熸ā寮�");
+	addDeviceRecipe("Bonder2", 101, "鏍囧噯宸ヨ壓", "");
+	addDeviceRecipe("Bonder2", 102, "鏀硅壇宸ヨ壓", "");
+	addDeviceRecipe("Bonder2", 103, "楂橀�熸ā寮�", "");
 }
 
 bool RecipeManager::readRecipeFile(const std::string& filename) {

--
Gitblit v1.9.3