Commit 6e13faf4 authored by 刘乐's avatar 刘乐

水力模型文档更新,数据库连接修复

parent b5aaae5e
...@@ -36,7 +36,7 @@ void CivConTrackTest::test(char* uri) ...@@ -36,7 +36,7 @@ void CivConTrackTest::test(char* uri)
*/ */
void CivConGetDataTest::test(char* uri) void CivConGetDataTest::test(char* uri)
{ {
const char* date = "2020-07-13"; const char* date = "2020-07-17";
char* dates = const_cast<char*>(date); char* dates = const_cast<char*>(date);
const char* interval = "4"; const char* interval = "4";
......
#pragma once #pragma once
/* /**
ͼ ͼ
*/ */
template<class Item> template<class Item>
......
...@@ -238,11 +238,11 @@ void CivInpBuilder::buildCurves() ...@@ -238,11 +238,11 @@ void CivInpBuilder::buildCurves()
{ {
ASSERT(mDbConn, mNewInp) ASSERT(mDbConn, mNewInp)
CivCurves curves; /*CivCurves curves;
if (!mDbConn->getCurves(curves)) if (!mDbConn->getCurves(curves))
return; return;
mNewInp->setCurves(curves); mNewInp->setCurves(curves);*/
} }
void CivInpBuilder::buildStatus() void CivInpBuilder::buildStatus()
......
...@@ -57,6 +57,7 @@ bool DLLEXPORT getDataByInterval(char* uri, char* date, char* interval) ...@@ -57,6 +57,7 @@ bool DLLEXPORT getDataByInterval(char* uri, char* date, char* interval)
delete dbConn; delete dbConn;
return false; return false;
} }
delete dbConn;
return true; return true;
} }
......
...@@ -269,6 +269,7 @@ bool CivHydrSimulation::qualitySimulation() ...@@ -269,6 +269,7 @@ bool CivHydrSimulation::qualitySimulation()
bool CivHydrSimulation::trackingSimulation(char* snNode, int hour) bool CivHydrSimulation::trackingSimulation(char* snNode, int hour)
{ {
CivSysLog::getInstance()->error("开始水质分析计算", "qualitySimulation", __FUNCTION__); CivSysLog::getInstance()->error("开始水质分析计算", "qualitySimulation", __FUNCTION__);
setQualityAnalyType(ANALYSIS_TRACE);
if (!convertInp(ANALYSIS_TRACE, snNode)) if (!convertInp(ANALYSIS_TRACE, snNode))
{ {
CivSysLog::getInstance()->error("写入inp文件失败", "qualitySimulation", __FUNCTION__); CivSysLog::getInstance()->error("写入inp文件失败", "qualitySimulation", __FUNCTION__);
...@@ -605,10 +606,15 @@ void CivHydrSimulation::getNodeQuality(short time) ...@@ -605,10 +606,15 @@ void CivHydrSimulation::getNodeQuality(short time)
// 编号 // 编号
ENgetnodeid(i, No); ENgetnodeid(i, No);
float* quality = (float*)malloc(sizeof(float)); float* quality = (float*)malloc(sizeof(float));
// 水质 // 水质
ENgetnodevalue(i, EN_QUALITY, quality); ENgetnodevalue(i, EN_QUALITY, quality);
mResultCache.addNodeQuality(*quality, time, No); int trueQuality = *quality;
if (mQuaLityType == ANALYSIS_TRACE)
trueQuality *= 100;
mResultCache.addNodeQuality(trueQuality, time, No);
free(quality); free(quality);
} }
} }
...@@ -633,7 +639,12 @@ void CivHydrSimulation::getLinkQuality(short time) ...@@ -633,7 +639,12 @@ void CivHydrSimulation::getLinkQuality(short time)
// 水质 // 水质
ENgetlinkvalue(i, EN_LINKQUAL, quality); ENgetlinkvalue(i, EN_LINKQUAL, quality);
mResultCache.addLinkQuality(*quality, time, lnkNo);
int trueQuality = *quality;
if (mQuaLityType == ANALYSIS_TRACE)
trueQuality *= 100;
mResultCache.addLinkQuality(trueQuality, time, lnkNo);
} }
free(typeCode); free(typeCode);
free(quality); free(quality);
......
...@@ -74,6 +74,8 @@ public: ...@@ -74,6 +74,8 @@ public:
*/ */
bool brushingResult(); bool brushingResult();
void setQualityAnalyType(QualityAnalyType analyType) { mQuaLityType = analyType; }
/* /*
inp文件名,输出文件名,二进制文件名设置和获取 inp文件名,输出文件名,二进制文件名设置和获取
*/ */
...@@ -98,7 +100,7 @@ private: ...@@ -98,7 +100,7 @@ private:
private: private:
CivDbConn* mDbConn; CivDbConn* mDbConn;
CivSimulResultCache mResultCache; // 存储模拟结果缓存类 CivSimulResultCache mResultCache; // 存储模拟结果缓存类
QualityAnalyType mQuaLityType = ANALYSIS_RESERVE;
std::string mInpFile; // inp文件名 std::string mInpFile; // inp文件名
std::string mRptFile; // 报告文件名 std::string mRptFile; // 报告文件名
std::string mBinFile;// 二进制文件名 std::string mBinFile;// 二进制文件名
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
CivDbConn::CivDbConn() CivDbConn::CivDbConn()
{ {
mIsOpen = false;
} }
CivDbConn::~CivDbConn() CivDbConn::~CivDbConn()
......
...@@ -14,7 +14,7 @@ CivPgConn::CivPgConn(char* uri) ...@@ -14,7 +14,7 @@ CivPgConn::CivPgConn(char* uri)
CivPgConn::~CivPgConn() CivPgConn::~CivPgConn()
{ {
if (mConn != NULL) if (mConn != nullptr)
{ {
PQfinish(mConn); PQfinish(mConn);
} }
...@@ -22,9 +22,6 @@ CivPgConn::~CivPgConn() ...@@ -22,9 +22,6 @@ CivPgConn::~CivPgConn()
bool CivPgConn::deleteByField(StrQuote table, StrQuote filedName, StrQuote fieldValue) bool CivPgConn::deleteByField(StrQuote table, StrQuote filedName, StrQuote fieldValue)
{ {
if (!isValid())
return false;
char delSql[256] = "delete from public.\""; char delSql[256] = "delete from public.\"";
strcat_s(delSql, table.c_str()); strcat_s(delSql, table.c_str());
strcat_s(delSql, "\" where "); strcat_s(delSql, "\" where ");
...@@ -47,9 +44,6 @@ bool CivPgConn::deleteByField(StrQuote table, StrQuote filedName, StrQuote field ...@@ -47,9 +44,6 @@ bool CivPgConn::deleteByField(StrQuote table, StrQuote filedName, StrQuote field
bool CivPgConn::updateNodeByInterval(StrQuote currDate, StrQuote interval) bool CivPgConn::updateNodeByInterval(StrQuote currDate, StrQuote interval)
{ {
if (!isValid())
return false;
std::stringstream os; std::stringstream os;
NodeFieldName filedNames; NodeFieldName filedNames;
...@@ -57,11 +51,14 @@ bool CivPgConn::updateNodeByInterval(StrQuote currDate, StrQuote interval) ...@@ -57,11 +51,14 @@ bool CivPgConn::updateNodeByInterval(StrQuote currDate, StrQuote interval)
<< PIPENODE << " AS tb1 set (" << PIPENODE << " AS tb1 set ("
<< "总水头"<< "," << "总水头"<< ","
<< "压力"<< "," << "压力"<< ","
<< "实际需水量" << "实际需水量"<<","
<<"水质"
<< ")=( " << ")=( "
<< "tb2." << filedNames.dHead << "," << "tb2." << filedNames.dHead << ","
<< "tb2." << filedNames.dPressure << "," << "tb2." << filedNames.dPressure << ","
<< "tb2." << filedNames.dDemand<< ")" << " from " << "tb2." << filedNames.dDemand <<","
<< "tb2." << filedNames.dQuality << ")"
<< " from "
<< NODERESULTTABLE<< " AS tb2 where tb1." << NODERESULTTABLE<< " AS tb2 where tb1."
<< filedNames.Number << "= tb2." << filedNames.Number << "= tb2."
<<filedNames.Number << " AND tb2." <<filedNames.Number << " AND tb2."
...@@ -84,9 +81,6 @@ bool CivPgConn::updateNodeByInterval(StrQuote currDate, StrQuote interval) ...@@ -84,9 +81,6 @@ bool CivPgConn::updateNodeByInterval(StrQuote currDate, StrQuote interval)
bool CivPgConn::updateLinkByInterval(StrQuote currDate, StrQuote interval) bool CivPgConn::updateLinkByInterval(StrQuote currDate, StrQuote interval)
{ {
if (!isValid())
return false;
std::stringstream os; std::stringstream os;
LinkFiledName filedNames; LinkFiledName filedNames;
...@@ -99,7 +93,8 @@ bool CivPgConn::updateLinkByInterval(StrQuote currDate, StrQuote interval) ...@@ -99,7 +93,8 @@ bool CivPgConn::updateLinkByInterval(StrQuote currDate, StrQuote interval)
<< "摩擦水头损"<< "," << "摩擦水头损"<< ","
<< "上点水头"<< "," << "上点水头"<< ","
<< "本点水头"<< "," << "本点水头"<< ","
<< "局部水头损" << "局部水头损"<<","
<<"水质"
<< ")=( " << ")=( "
<< "tb2." << filedNames.dFlow<< "," << "tb2." << filedNames.dFlow<< ","
<< "tb2." << filedNames.dVelocity<< "," << "tb2." << filedNames.dVelocity<< ","
...@@ -108,7 +103,9 @@ bool CivPgConn::updateLinkByInterval(StrQuote currDate, StrQuote interval) ...@@ -108,7 +103,9 @@ bool CivPgConn::updateLinkByInterval(StrQuote currDate, StrQuote interval)
<< "tb2." << filedNames.dFrictionHeadloss<< "," << "tb2." << filedNames.dFrictionHeadloss<< ","
<< "tb2." << filedNames.dFromNodHeadloss<< "," << "tb2." << filedNames.dFromNodHeadloss<< ","
<< "tb2." << filedNames.dToNodHeadloss<< "," << "tb2." << filedNames.dToNodHeadloss<< ","
<< "tb2." << filedNames.dLocalHeadloss<< ")" << " from " << "tb2." << filedNames.dLocalHeadloss<<","
<<" tb2."<< filedNames.dQuality<< ")"
<< " from "
<< PIPERESULTTABLE<< " AS tb2 where tb1." << PIPERESULTTABLE<< " AS tb2 where tb1."
<< filedNames.szNo<< "= tb2." << filedNames.szNo<< "= tb2."
<< filedNames.szNo<< " AND tb2." << filedNames.szNo<< " AND tb2."
...@@ -324,9 +321,9 @@ bool CivPgConn::execSql(StrQuote sql) ...@@ -324,9 +321,9 @@ bool CivPgConn::execSql(StrQuote sql)
if (sql.empty()) if (sql.empty())
return false; return false;
if (!open()) if (!isValid())
return false; open();
mResult = PQexec(mConn, sql.c_str()); mResult = PQexec(mConn, sql.c_str());
char* error = PQresultErrorMessage(mResult); char* error = PQresultErrorMessage(mResult);
std::string errorStr = error; std::string errorStr = error;
...@@ -483,6 +480,7 @@ bool CivPgConn::getTank(CivTank& tank) ...@@ -483,6 +480,7 @@ bool CivPgConn::getTank(CivTank& tank)
bool CivPgConn::getValve(CivValve& valve) bool CivPgConn::getValve(CivValve& valve)
{ {
CivValveTableTemp::ValveTable vaveTable; CivValveTableTemp::ValveTable vaveTable;
//;ID Node1 Node2 Length Diameter Roughness MinorLoss Status //;ID Node1 Node2 Length Diameter Roughness MinorLoss Status
...@@ -532,6 +530,7 @@ bool CivPgConn::getValve(CivValve& valve) ...@@ -532,6 +530,7 @@ bool CivPgConn::getValve(CivValve& valve)
bool CivPgConn::getPumps(CivPumps& pump) bool CivPgConn::getPumps(CivPumps& pump)
{ {
CivPumpTableTemp::PumpTable pmTable; CivPumpTableTemp::PumpTable pmTable;
//;ID Node1 Node2 Length Diameter Roughness MinorLoss Status //;ID Node1 Node2 Length Diameter Roughness MinorLoss Status
...@@ -946,7 +945,6 @@ bool CivPgConn::getValuesFromTableByCondition( ...@@ -946,7 +945,6 @@ bool CivPgConn::getValuesFromTableByCondition(
void CivPgConn::checkHyDrNetTable() void CivPgConn::checkHyDrNetTable()
{ {
// 创建曲线表 // 创建曲线表
CivCurveTableTemp temp; CivCurveTableTemp temp;
if (!tableExist(temp.name())) if (!tableExist(temp.name()))
......
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