Commit cb17f35f authored by 刘乐's avatar 刘乐

1, 新增接口

parent 52f38d22
#include "CivHydrFuncInter.h" #include "CivHydrFuncInter.h"
#include "CivHydrCalc.h" #include "CivHydrCalc.h"
#include "CivDbConnection.h"
bool DLLEXPORT simulation(char* uri, char* netName, char* flag) bool DLLEXPORT simulation(char* uri, char* netName, char* flag)
...@@ -24,3 +25,11 @@ bool DLLEXPORT simulation(char* uri, char* netName, char* flag) ...@@ -24,3 +25,11 @@ bool DLLEXPORT simulation(char* uri, char* netName, char* flag)
delete calc; delete calc;
return msg; return msg;
} }
bool DLLEXPORT getDataByInterval(char* uri, char* netName, char* date, char* interval)
{
CivDbConnection* dbConn = new CivDbConnection(uri);
bool flag = dbConn->updateLinkByInterval(date, interval);
delete dbConn;
return flag;
}
\ No newline at end of file
...@@ -13,6 +13,15 @@ extern "C" { ...@@ -13,6 +13,15 @@ extern "C" {
*/ */
bool DLLEXPORT simulation(char* uri, char* netName,char* flag); bool DLLEXPORT simulation(char* uri, char* netName,char* flag);
/**
*@brief 获取管网计算特定时段的结果
*@uri: 管网数据库连接
*@netName: 管网名
*@date: 日期
*@interval: 时段,整数
*/
bool DLLEXPORT getDataByInterval(char* uri, char* netName, char* date, char* interval);
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif
......
...@@ -164,19 +164,8 @@ bool CivDbConnection::updateNode(const NodeResultItems& nodeItems) ...@@ -164,19 +164,8 @@ bool CivDbConnection::updateNode(const NodeResultItems& nodeItems)
return false; return false;
} }
os << "UPDATE "<< TransUTFCoding(PIPENODE) <<" AS tb1 set (" << TransUTFCoding("总水头") << "," << TransUTFCoding("压力") << "," // 更新管网数据表
<< TransUTFCoding("实际需水量") << ")=(select " << TransUTFCoding(filedNames.dHead)<<"," if (!updateNodeByInterval(CurrentDate, CurrentHour))
<< TransUTFCoding(filedNames.dPressure)<<","<< TransUTFCoding(filedNames.dDemand)
<<" from "<<TransUTFCoding(NODERESULTTABLE)<<" AS tb2 where tb1."
<<TransUTFCoding(filedNames.Number)<<"= tb2."<< TransUTFCoding(filedNames.Number) <<" AND tb2."
<< TransUTFCoding(filedNames.dDate)<<"='"<<CurrentDate<<"' AND tb2."<< TransUTFCoding(filedNames.dInterval)
<<"="<<CurrentHour<<")";
std::string updateSql = os.str();
std::cout << updateSql << std::endl;
os.clear();
os.str("");
if (!execSql(updateSql))
return false; return false;
return true; return true;
...@@ -250,85 +239,88 @@ bool CivDbConnection::updateLink(const LinkResultItems& lineItems) ...@@ -250,85 +239,88 @@ bool CivDbConnection::updateLink(const LinkResultItems& lineItems)
return false; return false;
} }
if (!updateLinkByInterval(CurrentDate, CurrentHour))
return false;
{ return true;
// 2, 参数值 }
size_t total = lineItems.size();
/* bool CivDbConnection::updateNodeByInterval(StrQuote currDate, StrQuote interval)
update {
表一 if (!isValid())
set return false;
表一的字段 = 表2的字段
from std::stringstream os;
表一, NodeFieldName filedNames;
表二
where os << "UPDATE "
表一.Id = 表二.Id << TransUTFCoding(PIPENODE) << " AS tb1 set ("
<< TransUTFCoding("总水头") << ","
Str szNo = "编号"; << TransUTFCoding("压力") << ","
Str dFlow = " 流量"; << TransUTFCoding("实际需水量") << ")=(select "
Str nFlowDirect = "流向"; << TransUTFCoding(filedNames.dHead) << ","
Str dVelocity="流速"; << TransUTFCoding(filedNames.dPressure) << ","
Str dHeadloss="水头损失"; << TransUTFCoding(filedNames.dDemand) << " from "
Str dUnitHeadloss="单位水头损"; << TransUTFCoding(NODERESULTTABLE) << " AS tb2 where tb1."
Str dFromNodHeadloss="上点水头"; << TransUTFCoding(filedNames.Number) << "= tb2."
Str dToNodHeadloss="本点水头"; << TransUTFCoding(filedNames.Number) << " AND tb2."
Str dLocalHeadloss="局部水头损"; << TransUTFCoding(filedNames.dDate) << "='" << currDate << "' AND tb2."
Str dFrictionHeadloss="摩擦水头损"; << TransUTFCoding(filedNames.dInterval) << "=" << interval << ")";
Str szStatus="状态";
Str dDate = "时间"; std::string updateSql = os.str();
Str dInterval = "时段"; std::cout << updateSql << std::endl;
*/ os.clear();
//os<< "update public."<< TransUTFCoding(PIPELINE)<<" as tb1 set("<< TransUTFCoding(filedNames.dFlow) os.str("");
// << TransUTFCoding(filedNames.dVelocity)<<TransUTFCoding(filedNames.dUnitHeadloss)<<TransUTFCoding(filedNames.dHeadloss) if (!execSql(updateSql))
// <<TransUTFCoding(filedNames.dFrictionHeadloss)<<","<<TransUTFCoding(filedNames.dFromNodHeadloss)<<"," return false;
// <<TransUTFCoding(filedNames.dToNodHeadloss)<<","<<TransUTFCoding(filedNames.dLocalHeadloss);
//for (int i = 0; i < total; i++) return true;
//{ }
// LinkResultItem item = lineItems[i];
// char sql[512] = "update public.管段 as tb1 set("; bool CivDbConnection::updateLinkByInterval(StrQuote currDate, StrQuote interval)
// strcat_s(sql, "流量"); {
// strcat_s(sql, ",流速"); if (!isValid())
// strcat_s(sql, ",单位水头损"); return false;
// strcat_s(sql, ",水头总损失");
// strcat_s(sql, ",摩擦水头损"); std::stringstream os;
// strcat_s(sql, ",上点水头"); LinkFiledName filedNames;
// strcat_s(sql, ",本点水头");
// strcat_s(sql, ",局部水头损");
// strcat_s(sql, ")"); os << "UPDATE "
// strcat_s(sql, "=("); << TransUTFCoding(PIPELINE) << " AS tb1 set ("
<< TransUTFCoding("流量") << ","
// // 拼接值 << TransUTFCoding("流速") << ","
// strcat_s(sql, std::to_string(item.dFlow).c_str()); << TransUTFCoding("单位水头损") <<","
// strcat_s(sql, ","); << TransUTFCoding("水头总损失")<< ","
// strcat_s(sql, std::to_string(item.dVelocity).c_str()); << TransUTFCoding("摩擦水头损")<<","
// strcat_s(sql, ","); << TransUTFCoding("上点水头")<<","
// strcat_s(sql, std::to_string(item.dUnitHeadloss).c_str()); << TransUTFCoding("本点水头")<<","
// strcat_s(sql, ","); << TransUTFCoding("局部水头损")
// strcat_s(sql, std::to_string(item.dHeadloss).c_str()); <<")=(select "
// strcat_s(sql, ","); << TransUTFCoding(filedNames.dFlow) << ","
// strcat_s(sql, std::to_string(item.dFrictionHeadloss).c_str()); << TransUTFCoding(filedNames.dVelocity) << ","
// strcat_s(sql, ","); << TransUTFCoding(filedNames.dUnitHeadloss)<<","
// strcat_s(sql, std::to_string(item.dFromNodHeadloss).c_str()); << TransUTFCoding(filedNames.dFrictionHeadloss) << ","
// strcat_s(sql, ","); << TransUTFCoding(filedNames.dFromNodHeadloss) << ","
// strcat_s(sql, std::to_string(item.dToNodHeadloss).c_str()); << TransUTFCoding(filedNames.dToNodHeadloss) << ","
// strcat_s(sql, ","); << TransUTFCoding(filedNames.dLocalHeadloss) << " from "
// strcat_s(sql, std::to_string(item.dLocalHeadloss).c_str()); << TransUTFCoding(PIPERESULTTABLE) << " AS tb2 where tb1."
// strcat_s(sql, ")where tb1.\""); << TransUTFCoding(filedNames.szNo) << "= tb2."
// strcat_s(sql, "编号"); << TransUTFCoding(filedNames.szNo) << " AND tb2."
// strcat_s(sql, "\"='"); << TransUTFCoding(filedNames.dDate) << "='" << currDate << "' AND tb2."
// strcat_s(sql, item.szNo); << TransUTFCoding(filedNames.dInterval) << "=" << interval << ")";
// strcat_s(sql, "'");
std::string updateSql = os.str();
// // 中文转码 std::cout << updateSql << std::endl;
// const std::string finalSql = TransUTFCoding(sql); os.clear();
// if (!execSql(finalSql)) os.str("");
// return false; if (!execSql(updateSql))
return false;
}
return true; return true;
} }
Componets CivDbConnection::getComponets(StrQuote tableName) Componets CivDbConnection::getComponets(StrQuote tableName)
{ {
if (!isValid()) if (!isValid())
......
...@@ -62,6 +62,8 @@ public: ...@@ -62,6 +62,8 @@ public:
bool deleteByDate(StrQuote table, StrQuote filedName, StrQuote fieldValue); bool deleteByDate(StrQuote table, StrQuote filedName, StrQuote fieldValue);
bool updateNodeByInterval(StrQuote currDate, StrQuote interval);
bool updateLinkByInterval(StrQuote currDate, StrQuote interval);
/** /**
*@brief 更新点表数据 *@brief 更新点表数据
*@nodeItems:需要更新的值 *@nodeItems:需要更新的值
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment