Commit e70c7e93 authored by 刘乐's avatar 刘乐

1, 类拆分

parent 2b546d06
...@@ -38,21 +38,6 @@ void CivConTrackTest::test(char* uri) ...@@ -38,21 +38,6 @@ void CivConTrackTest::test(char* uri)
std::cout << "测试结果:" << succ << std::endl; std::cout << "测试结果:" << succ << std::endl;
} }
/**
获取时段数据
*/
void CivConGetDataTest::test(char* uri)
{
const char* date = "2020-07-17";
char* dates = const_cast<char*>(date);
const char* interval = "4";
char* intervals = const_cast<char*>(interval);
bool isSucces = getDataByInterval(uri, dates, intervals);
std::cout << "测试结果:" << isSucces << std::endl;
};
void CivConGetRptTest::test(char* uri) void CivConGetRptTest::test(char* uri)
{ {
......
...@@ -35,14 +35,6 @@ public: ...@@ -35,14 +35,6 @@ public:
virtual void test(char* uri); virtual void test(char* uri);
}; };
/**
获取时段数据
*/
class CivConGetDataTest :public CivHydrTest
{
public:
virtual void test(char* uri);
};
/** /**
获取水力分析报告测试 获取水力分析报告测试
......
...@@ -14,12 +14,12 @@ using namespace std; ...@@ -14,12 +14,12 @@ using namespace std;
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
const char* uri = "host=192.168.19.100 port=5432 dbname=JinXian user=postgres password=admin"; const char* uri = "host=192.168.12.7 port=5432 dbname=tese1111 user=postgres password=admin";
char* findUri = const_cast<char*>(uri); char* findUri = const_cast<char*>(uri);
// 测试水力 // 测试水力
/*CivTestContext context(new CivConHydrTest()); CivTestContext context(new CivConHydrTest());
context.contextTest(findUri);*/ context.contextTest(findUri);
// 测试水质 // 测试水质
/*CivTestContext context(new CivConQuaTest()); /*CivTestContext context(new CivConQuaTest());
...@@ -57,15 +57,7 @@ int main(int argc, char* argv[]) ...@@ -57,15 +57,7 @@ int main(int argc, char* argv[])
/* CivTestContext context(new CivWaterSupplyScopeTest()); /* CivTestContext context(new CivWaterSupplyScopeTest());
context.contextTest(findUri);*/ context.contextTest(findUri);*/
int base = 10000001;
std::vector<std::string> vec;
for (int i = base; i < base + 730; i++)
{
std::string res = std::to_string(i);
res ="JD"+ res.substr(1, res.length());
vec.push_back(res);
std::cout << res << std::endl;
}
getchar(); getchar();
return 0; return 0;
......
#include "CivBaseInpBuilder.h"
#include "CivInpBuilder.h"
#include "CivTypes.h"
#include "CivAssembly.h"
#define ASSERT(A,B) if ((A) == nullptr || (B) == nullptr) return;
CivBaseInpBuilder::CivBaseInpBuilder()
:CivInpBuilder() mNewInp(new CivNewInp())
{
}
CivBaseInpBuilder::~CivBaseInpBuilder()
{
delete mNewInp;
}
CivNewInp* CivBaseInpBuilder::getNewInp()
{
return mNewInp;
}
CivBaseInpBuilder::CivBaseInpBuilder()
{
}
void CivBaseInpBuilder::buildNode()
{
CivNode node;
if (!mDbConn->getNode(node))
return;
mNewInp->setNode(node);
}
void CivBaseInpBuilder::buildPipe()
{
ASSERT(mDbConn, mNewInp)
CivPipe pipe;
if (!mDbConn->getPipe(pipe))
return;
mNewInp->setPipes(pipe);
}
void CivBaseInpBuilder::buildTank()
{
ASSERT(mDbConn, mNewInp)
CivTank tank;
if (!mDbConn->getTank(tank))
return;
mNewInp->setTank(tank);
}
void CivBaseInpBuilder::buildVavle()
{
ASSERT(mDbConn, mNewInp)
CivValve valve;
if (!mDbConn->getValve(valve))
return;
mNewInp->setValves(valve);
}
void CivBaseInpBuilder::buildPump()
{
ASSERT(mDbConn, mNewInp)
CivPumps valve;
if (!mDbConn->getPumps(valve))
return;
mNewInp->setPumps(valve);
}
void CivBaseInpBuilder::buildReservoir()
{
ASSERT(mDbConn, mNewInp)
CivReservoirs res;
if (!mDbConn->getReservoirs(res))
return;
mNewInp->setReservoirs(res);
}
void CivBaseInpBuilder::buildEmitter()
{
ASSERT(mDbConn, mNewInp)
CivEmitters emmiters;
if (!mDbConn->getEmitters(emmiters))
return;
mNewInp->setEmitters(emmiters);
}
void CivBaseInpBuilder::buildPatterns()
{
ASSERT(mDbConn, mNewInp)
CivPatterns pattern;
if (!mDbConn->getPatterns(pattern))
return;
mNewInp->setPatterns(pattern);
}
void CivBaseInpBuilder::buildParamter()
{
ASSERT(mDbConn, mNewInp)
std::vector<CivParameter> parameters;
if (!mDbConn->getParameter(parameters))
return;
size_t total = parameters.size();
for (int i = 0; i < total; i++)
{
CivParameter param = parameters[i];
mNewInp->setParamter(param, param.mType);
}
}
void CivBaseInpBuilder::buildCoordnates()
{
ASSERT(mDbConn, mNewInp)
CivCoordinates coords;
if (!mDbConn->getCoordinates(coords))
return;
mNewInp->setCoordnates(coords);
}
void CivBaseInpBuilder::buildVertices()
{
return;
}
void CivBaseInpBuilder::buildLabels()
{
ASSERT(mDbConn, mNewInp)
CivLabels labels;
if (!mDbConn->getLabels(labels))
return;
mNewInp->setLabels(labels);
}
void CivBaseInpBuilder::buildTags()
{
ASSERT(mDbConn, mNewInp)
CivTags tag;
if (!mDbConn->getTags(tag))
return;
mNewInp->setTags(tag);
}
void CivBaseInpBuilder::buildBackDrop()
{
return;
}
void CivBaseInpBuilder::buildQuality()
{
ASSERT(mDbConn, mNewInp)
CivQuality quality;
if (!mDbConn->getQuality(quality))
return;
mNewInp->setQuality(quality);
}
void CivBaseInpBuilder::buildSources()
{
ASSERT(mDbConn, mNewInp)
CivSources sources;
if (!mDbConn->getSources(sources))
return;
mNewInp->setSources(sources);
}
void CivBaseInpBuilder::buildMixing()
{
ASSERT(mDbConn, mNewInp)
CivMixing mixing;
if (!mDbConn->getMixing(mixing))
return;
mNewInp->setMixing(mixing);
}
void CivBaseInpBuilder::buildCurves()
{
ASSERT(mDbConn, mNewInp)
/*CivCurves curves;
if (!mDbConn->getCurves(curves))
return;
mNewInp->setCurves(curves);*/
}
void CivBaseInpBuilder::buildStatus()
{
ASSERT(mDbConn, mNewInp)
CivStatus status;
if (!mDbConn->getStatus(status))
return;
mNewInp->setStatus(status);
}
void CivBaseInpBuilder::buildControls()
{
}
void CivBaseInpBuilder::buildRules()
{
}
void CivBaseInpBuilder::buildDemands()
{
ASSERT(mDbConn, mNewInp)
CivDemands mand;
if (!mDbConn->getDemands(mand))
return;
mNewInp->setDemands(mand);
}
\ No newline at end of file
#pragma once
#include "CivInpBuilder.h"
/**
* inpļ
*/
class CivBaseInpBuilder :public CivInpBuilder
{
public:
explicit CivBaseInpBuilder();
~CivBaseInpBuilder();
virtual void buildNode();
virtual void buildPipe();
virtual void buildTank();
virtual void buildVavle();
virtual void buildPump();
virtual void buildReservoir();
virtual void buildEmitter();
virtual void buildPatterns();
virtual void buildParamter();
virtual void buildCoordnates();
virtual void buildVertices();
virtual void buildLabels();
virtual void buildTags();
virtual void buildBackDrop();
virtual void buildQuality();
virtual void buildSources();
virtual void buildMixing();
virtual void buildCurves();
virtual void buildStatus();
virtual void buildControls();
virtual void buildRules();
virtual void buildDemands();
};
#include "CivHydrCompute.h" #include "CivHydrCompute.h"
#include "CivTypes.h"
CivHydrCompute::CivHydrCompute() CivHydrCompute::CivHydrCompute(char* inp, char* rptFile, char* binFile)
:mInpFile(inp),mRptFile(rptFile),mBinFile(binFile)
{ {
} }
bool CivHydrCompute::qualityCompute(char* fileName) bool CivHydrCompute::qualityCompute()
{ {
// 运行水质运算需要先进行水力运算,没有直接采用ENSolveH 是为了考虑减压阀的压力曲线设置
long t(0), tstep(0);
int iTime(0);
int errcode = 0;
errcode = ENopen(mInpFile, mRptFile, mBinFile);
if (errcode > 0)
{
ENclose();
return false;
}
if (ENopenH() > 0)
{
ENclose();
return false;
}
if (ENinitH(EN_SAVE) > 0)
{
ENclose();
return false;
}
do
{
int nLinkCount;
ENgetcount(EN_LINKCOUNT, &nLinkCount);
/*for (int i = 1; i <= nLinkCount; i++)
{
int linkType;
char id[128] = "";
ENgetlinktype(i, &linkType);
ENgetlinkid(i, id);
}*/
errcode = ENrunH(&t); // errcode > 100 是错误
if (errcode > 100)
{
ENcloseH();
ENclose();
return false;
}
ENnextH(&tstep);
iTime++;
// 获取当前节点和管段数据
getNodeResult(iTime);
getLinkResult(iTime);
} while (tstep > 0);
ENcloseH();
// 进行水质分析
ENopenQ();
ENinitQ(1);
t = 0;
tstep = 0;
iTime = 0;
do
{
errcode = ENrunQ(&t); // errcode > 100 是错误
if (errcode > 100)
{
ENcloseQ();
ENclose();
return false;
}
// 获取水质模拟结果
getNodeQuality(iTime);
getLinkQuality(iTime);
ENstepQ(&tstep);
iTime++;
} while (tstep > 0);
ENcloseQ();
ENclose();
return true; return true;
} }
bool CivHydrCompute::hdyrCompute(char* inpFile) bool CivHydrCompute::hdyrCompute()
{ {
return true; short hydCode = 1;
long t(0), tstep(0);
int iTime(0);
int errcode = 0;
errcode = ENopen(mInpFile, mRptFile, mBinFile);
if (errcode > 0)
{
ENclose();
return false;
}
if (ENopenH() > 0)
{
ENclose();
return false;
}
if (ENinitH(0) > 0)
{
ENclose();
return false;
}
float dHStep;
ENGetVal(4, &dHStep);
do
{
int nLinkCount;
ENgetcount(EN_LINKCOUNT, &nLinkCount);
/*for (int i = 1; i <= nLinkCount; i++)
{
int linkType;
char id[128] = "";
ENgetlinktype(i, &linkType);
ENgetlinkid(i, id);
}*/
if (ENrunH(&t) > 100) // errcode > 100 是错误
{
ENclose();
return false;
}
ENnextH(&tstep);
// 获取当前节点和管段数据
getNodeResult(iTime);
getLinkResult(iTime);
iTime++;
} while (tstep > 0);
ENcloseH();
ENclose();
return true;
}
void CivHydrCompute::getNodeResult(short time)
{
// 计算节点
int nNodeCount;
ENgetcount(EN_NODECOUNT, &nNodeCount);
int* typeCode = (int*)malloc(sizeof(int));
for (int i = 1; i <= nNodeCount; i++)
{
ENgetlinktype(i, typeCode);
if (*typeCode == EN_TANK || *typeCode== EN_RESERVOIR)
{
continue;
}
NodeResultItem nodeItem;
// 编号
ENgetnodeid(i, nodeItem.szNo);
// 水头
ENgetnodevalue(i, EN_HEAD, &nodeItem.dHead);
// 压力
ENgetnodevalue(i, EN_PRESSURE, &nodeItem.dPressure);
// 标高
ENgetnodevalue(i, EN_ELEVATION, &nodeItem.dElevation);
// 实际需水量
ENgetnodevalue(i, EN_DEMAND, &nodeItem.dDemand);
// 水池容量
ENgetnodevalue(i, EN_TANKVOLUME, &nodeItem.dTankVolume);
// 水池最大容量
ENgetnodevalue(i, EN_MAXVOLUME, &nodeItem.dTankMaxVolume);
// 液位高度
ENgetnodevalue(i, EN_TANKLEVEL, &nodeItem.dTankLevel);
nodeItem.dInterval = time;
// 放到缓存类中
//mResultCache.addNodeItems(nodeItem);
}
free(typeCode);
// 计算的水池
int tankCount;
}
void CivHydrCompute::getLinkResult(short time)
{
int nLinkCount;
ENgetcount(EN_LINKCOUNT, &nLinkCount);
for (int i = 1; i <= nLinkCount; i++)
{
LinkResultItem linkItem;
int* typeCode = (int*)malloc(sizeof(int));
ENgetlinktype(i, typeCode);
if (*typeCode != EN_PIPE)
{
free(typeCode);
continue;
}
free(typeCode);
// 编号
ENgetlinkid(i, linkItem.szNo);
// 流量
ENgetlinkvalue(i, EN_FLOW, &linkItem.dFlow);
// 流向
linkItem.nFlowDirect = (linkItem.dFlow >= 0) ? 0 : 1;
// 流速
ENgetlinkvalue(i, EN_VELOCITY, &linkItem.dVelocity);
// 水头损失
ENgetlinkvalue(i, EN_HEADLOSS, &linkItem.dHeadloss);
// 状态
float fState = 0;
ENgetlinkvalue(i, EN_STATUS, &fState);
if ((int)fState == 0)
strcpy_s(linkItem.szStatus, "关闭");
else
strcpy_s(linkItem.szStatus, "开启");
linkItem.dInterval = time;
// 放到缓存类中
// mResultCache.addLinkItems(linkItem);
}
}
void CivHydrCompute::getNodeQuality(short time)
{
int nNodeCount;
ENgetcount(EN_NODECOUNT, &nNodeCount);
float* quality = (float*)malloc(sizeof(float));
for (int i = 1; i <= nNodeCount; i++)
{
char No[35];
// 编号
ENgetnodeid(i, No);
// 水质
ENgetnodevalue(i, EN_QUALITY, quality);
// mResultCache.addNodeQuality(*quality, time, No);
}
free(quality);
}
void CivHydrCompute::getLinkQuality(short time)
{
int nLinkCount;
ENgetcount(EN_LINKCOUNT, &nLinkCount);
int* typeCode = (int*)malloc(sizeof(int));
for (int i = 1; i <= nLinkCount; i++)
{
if (*typeCode != EN_PIPE)
continue;
ENgetlinktype(i, typeCode);
char lnkNo[35];
// 编号
ENgetlinkid(i, lnkNo);
float quality;
// 水质
ENgetlinkvalue(i, EN_LINKQUAL, &quality);
}
free(typeCode);
} }
\ No newline at end of file
#pragma once #pragma once
#include "epanet2.h"
/** /**
彊제셕炬잚 彊제셕炬잚
...@@ -6,13 +7,25 @@ ...@@ -6,13 +7,25 @@
class CivHydrCompute class CivHydrCompute
{ {
public: public:
CivHydrCompute(); explicit CivHydrCompute(char* inp,char* rptFile,char* binFile);
/** /**
*@brief 水质计算 *@brief 彊醴셕炬
*@param fileName 计算的inp文件名 */
*/ bool qualityCompute();
bool qualityCompute(char* fileName);
bool hdyrCompute(char* inpFile); /**
*@brief 彊제셕炬
*/
bool hdyrCompute();
private:
void getNodeResult(short time);
void getLinkResult(short time);
void getNodeQuality(short time);
void getLinkQuality(short time);
char* mInpFile;
char* mRptFile;
char* mBinFile;
}; };
...@@ -6,30 +6,6 @@ ...@@ -6,30 +6,6 @@
#include "CivHydrSimulation.h" #include "CivHydrSimulation.h"
#include "CivTrackingAnalysis.h" #include "CivTrackingAnalysis.h"
bool FUNEXPORT getDataByInterval(char* uri, char* date, char* interval)
{
CivDbConn* dbConn = new CivPgConn(uri);
if (!dbConn->open())
{
delete dbConn;
return false;
}
if (!dbConn->updateNodeByInterval(date, interval))
{
delete dbConn;
return false;
}
if (!dbConn->updateLinkByInterval(date, interval))
{
delete dbConn;
return false;
}
delete dbConn;
return true;
}
bool FUNEXPORT modelMatation(char* uri) bool FUNEXPORT modelMatation(char* uri)
{ {
......
...@@ -67,15 +67,6 @@ extern "C" { ...@@ -67,15 +67,6 @@ extern "C" {
*/ */
bool FUNEXPORT trackingSimulation(char* uri, char* sN, int hours,char* result); bool FUNEXPORT trackingSimulation(char* uri, char* sN, int hours,char* result);
/**
*@brief 获取管网计算特定时段的结果
*@param uri: 管网数据库连接uri
*@param date: 日期
*@param interval: 时段,整数
*@return 成功,失败
*/
bool FUNEXPORT getDataByInterval(char* uri, char* date, char* interval);
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif
......
...@@ -5,302 +5,22 @@ ...@@ -5,302 +5,22 @@
#include "CivInpDirector.h" #include "CivInpDirector.h"
#include "CivSysLog.h" #include "CivSysLog.h"
#include "epanet2.h" #include "epanet2.h"
#include "../pandaDbManager/CivCommonUtils.h"
#include "CivTrackingResultCache.h" #include "CivTrackingResultCache.h"
CivHydrSimulation::CivHydrSimulation() CivHydrSimulation::CivHydrSimulation()
:mDbConn(nullptr),
mInpFile("test.inp"),
mRptFile("test.rpt"),
mBinFile("test.bin")
{ {
} }
CivHydrSimulation::CivHydrSimulation(CivDbConn* dbConn)
:mDbConn(dbConn),
mInpFile("test.inp"),
mRptFile("test.rpt"),
mBinFile("test.bin")
{
if (dbConn)
dbConn->checkHyDrNetTable();
}
CivHydrSimulation::~CivHydrSimulation() CivHydrSimulation::~CivHydrSimulation()
{ {
} }
char* CivHydrSimulation::getInpFile()
{
return const_cast<char*>(mInpFile.c_str());
}
void CivHydrSimulation::setInpFile(const std::string& inpFile)
{
mInpFile = inpFile;
}
char* CivHydrSimulation::getRptFile()
{
return const_cast<char*>(mRptFile.c_str());
}
void CivHydrSimulation::setRptFile(const std::string& rptFile)
{
mRptFile = rptFile;
}
char* CivHydrSimulation::getBinFile()
{
return const_cast<char*>(mBinFile.c_str());
}
std::string CivHydrSimulation::getAnalysisResults()
{
std::string result;
std::ifstream myfile(getRptFile());
if (myfile.is_open())
{
return result;
}
while (!myfile.eof())
{
myfile >> result;
}
myfile.close();
return result;
}
void CivHydrSimulation::setBinFile(const std::string& binFile)
{
mBinFile = binFile;
}
void CivHydrSimulation::registDb(CivDbConn* dbConn)
{
mDbConn = dbConn;
if (mDbConn)
mDbConn->checkHyDrNetTable();
}
bool CivHydrSimulation::convertInp(const QualityAnalyType analyType, const std::string& qulityName)
{
CivBuilder* builder = new CivInpBuilder();
builder->setQualityType(analyType, qulityName);
builder->registDb(mDbConn);
CivInpDirector director;
director.setBuilder(builder);
director.create();
CivNewInp* newInp = builder->getNewInp();
char* inpFileName = getInpFile();
if (inpFileName
&& (*inpFileName !='\0')
&& !newInp->writeToFile(inpFileName))
{
delete builder;
return false;
}
delete builder;
return true;
}
bool CivHydrSimulation::hdyrCompute()
{
short hydCode = 1;
long t(0), tstep(0);
int iTime(0);
int errcode = 0;
char* fileName = getInpFile();
char* rptFile = getRptFile();
char* binOutFile = getBinFile();
errcode = ENopen(fileName, rptFile, binOutFile);
if (errcode > 0)
{
ENclose();
CivSysLog::getInstance()->error("ENopen inp 失败", "CivHydrCalc", __FUNCTION__);
return false;
}
CivSysLog::getInstance()->info("ENopen inp 成功", "CivHydrCalc", __FUNCTION__);
if (ENopenH() > 0)
{
ENclose();
CivSysLog::getInstance()->error("ENopenH inp 失败", "CivHydrCalc", __FUNCTION__);
return false;
}
if (ENinitH(0) > 0)
{
ENclose();
CivSysLog::getInstance()->error("ENinitH inp 失败", "CivHydrCalc", __FUNCTION__);
return false;
}
CivSysLog::getInstance()->info("ENinitH inp 成功", "CivHydrCalc", __FUNCTION__);
float dHStep;
ENGetVal(4, &dHStep);
// 计算
do
{
int nLinkCount;
ENgetcount(EN_LINKCOUNT, &nLinkCount);
/*for (int i = 1; i <= nLinkCount; i++)
{
int linkType;
char id[128] = "";
ENgetlinktype(i, &linkType);
ENgetlinkid(i, id);
}*/
if (ENrunH(&t) > 100) // errcode > 100 是错误
{
ENclose();
return false;
}
ENnextH(&tstep);
// 获取当前节点和管段数据
getNodeResult(iTime);
getLinkResult(iTime);
iTime++;
} while (tstep > 0);
ENcloseH();
ENclose();
return true;
}
void CivHydrSimulation::getDataByTime(int time, NodeResultItems& nodeItems, LinkResultItems& linkItems)
{
mResultCache.getResultByTime(time, nodeItems, linkItems);
}
bool CivHydrSimulation::hdyrInstantSimulation()
{
CivBuilder* builder = new CivInpBuilder();
builder->setDuration(0);
builder->setQualityType(ANALYSIS_RESERVE, "");
builder->registDb(mDbConn);
CivInpDirector director;
director.setBuilder(builder);
director.create();
CivNewInp* newInp = builder->getNewInp();
char* inpFileName = getInpFile();
if (inpFileName && (*inpFileName != '\0') && !newInp->writeToFile(inpFileName))
{
delete builder;
return false;
}
delete builder;
// 水力计算
if (!hdyrCompute())
{
CivSysLog::getInstance()->error("水力分析结果存储失败", "CivHydrCalc", __FUNCTION__);
return false;
}
return true;
}
bool CivHydrSimulation::hdyrSimulation() bool CivHydrSimulation::hdyrSimulation()
{ {
CivBuilder* builder = new CivInpBuilder();
builder->setQualityType(ANALYSIS_RESERVE, "");
builder->registDb(mDbConn);
CivInpDirector director;
director.setBuilder(builder);
director.create();
CivNewInp* newInp = builder->getNewInp();
char* inpFileName = getInpFile();
if (inpFileName && (*inpFileName != '\0') && !newInp->writeToFile(inpFileName))
{
delete builder;
return false;
}
delete builder;
// 水力计算
if (!hdyrCompute())
{
CivSysLog::getInstance()->error("水力分析结果存储失败", "CivHydrCalc", __FUNCTION__);
return false;
}
//模拟数据刷新
if (!brushingResult())
{
CivSysLog::getInstance()->error("水力分析结果存储失败", "CivHydrCalc", __FUNCTION__);
return false;
}
return true;
}
bool CivHydrSimulation::brushingResult()
{
clearSamePeriodValue(mDbConn, CurrentDate);
// 更新数据
if (!mResultCache.updateToDb(mDbConn))
{
CivSysLog::getInstance()->error("水力分析结果存储失败", "CivHydrCalc", __FUNCTION__);
return false;
}
// 更新管网数据库数据
// updateLastestDataToGisNet(mDbConn, "0");
return true;
}
bool CivHydrSimulation::clearSamePeriodValue(CivDbConn* dbConn, const std::string& date)
{
if (dbConn == nullptr)
return false;
dbConn->deleteByField(NODERESULTTABLE, "日期", date);
dbConn->deleteByField(PIPERESULTTABLE, "日期", date);
return true;
}
bool CivHydrSimulation::updateLastestDataToGisNet(CivDbConn* dbConn, const std::string& time)
{
if (dbConn == nullptr)
return false;
dbConn->updateLinkByInterval(CurrentDate, time);
dbConn->updateNodeByInterval(CurrentDate, time);
return true; return true;
} }
...@@ -331,130 +51,8 @@ bool CivHydrSimulation::qualitySimulation() ...@@ -331,130 +51,8 @@ bool CivHydrSimulation::qualitySimulation()
return true; return true;
} }
bool CivHydrSimulation::trackingSimulation(char* snNode, int hour) bool CivHydrSimulation::trackingSimulation(char* snNode, int hours,std::string& jsonResult)
{ {
CivSysLog::getInstance()->error("开始水质分析计算", "qualitySimulation", __FUNCTION__);
setQualityAnalyType(ANALYSIS_TRACE);
if (!convertInp(ANALYSIS_TRACE, snNode))
{
CivSysLog::getInstance()->error("写入inp文件失败", "qualitySimulation", __FUNCTION__);
return false;
}
CivSysLog::getInstance()->info("写入inp成功", "qualitySimulation", __FUNCTION__);
// 水质计算
if (!qualityCompute())
{
CivSysLog::getInstance()->error("追踪分析计算失败", "CivHydrCalc", __FUNCTION__);
return false;
}
return true;
}
bool CivHydrSimulation::qualityCompute()
{
// 运行水质运算需要先进行水力运算,没有直接采用ENSolveH 是为了考虑减压阀的压力曲线设置
long t(0), tstep(0);
int iTime(0);
int errcode = 0;
char* fileName = getInpFile();
char* rptFile = getRptFile();
char* binOutFile = getBinFile();
errcode = ENopen(fileName, rptFile, binOutFile);
if (errcode > 0)
{
ENclose();
CivSysLog::getInstance()->error("ENopen inp 失败", "CivHydrCalc", __FUNCTION__);
return false;
}
CivSysLog::getInstance()->info("ENopen inp 成功", "CivHydrCalc", __FUNCTION__);
if (ENopenH() > 0)
{
ENclose();
CivSysLog::getInstance()->error("ENopenH inp 失败", "CivHydrCalc", __FUNCTION__);
return false;
}
if (ENinitH(EN_SAVE) > 0)
{
ENclose();
CivSysLog::getInstance()->error("ENinitH inp 失败", "CivHydrCalc", __FUNCTION__);
return false;
}
CivSysLog::getInstance()->info("ENinitH inp 成功", "CivHydrCalc", __FUNCTION__);
do
{
int nLinkCount;
ENgetcount(EN_LINKCOUNT, &nLinkCount);
/*for (int i = 1; i <= nLinkCount; i++)
{
int linkType;
char id[128] = "";
ENgetlinktype(i, &linkType);
ENgetlinkid(i, id);
}*/
errcode = ENrunH(&t); // errcode > 100 是错误
if (errcode > 100)
{
ENcloseH();
ENclose();
return false;
}
ENnextH(&tstep);
iTime++;
if (mQuaLityType == ANALYSIS_TRACE)
continue;
// 获取当前节点和管段数据
getNodeResult(iTime);
getLinkResult(iTime);
} while (tstep > 0);
ENcloseH();
// 进行水质分析
ENopenQ();
ENinitQ(1);
t = 0;
tstep = 0;
iTime = 0;
do
{
errcode = ENrunQ(&t); // errcode > 100 是错误
if (errcode > 100)
{
ENcloseQ();
ENclose();
return false;
}
// 获取水质模拟结果
getNodeQuality(iTime);
getLinkQuality(iTime);
ENstepQ(&tstep);
iTime++;
} while (tstep > 0);
ENcloseQ();
ENclose();
CivSysLog::getInstance()->info("结束水质分析计算", "CivHydrCalc", __FUNCTION__);
return true; return true;
} }
...@@ -463,7 +61,7 @@ void CivHydrSimulation::getTrackingResult(int hours, std::string& jsonResult) ...@@ -463,7 +61,7 @@ void CivHydrSimulation::getTrackingResult(int hours, std::string& jsonResult)
// 缓存节点和管段空间信息 // 缓存节点和管段空间信息
CivTrackingResultCache trackingCache; CivTrackingResultCache trackingCache;
trackingCache.cacheInfoFromDb(mDbConn); // trackingCache.cacheInfoFromDb(mDbConn);
jsonResult.append("["); jsonResult.append("[");
for (int i = 0; i < hours; i++) for (int i = 0; i < hours; i++)
...@@ -494,208 +92,10 @@ void CivHydrSimulation::getTrackingResult(int hours, std::string& jsonResult) ...@@ -494,208 +92,10 @@ void CivHydrSimulation::getTrackingResult(int hours, std::string& jsonResult)
jsonResult = jsonResult.substr(0, jsonResult.length() - 1); jsonResult = jsonResult.substr(0, jsonResult.length() - 1);
jsonResult.append("],"); jsonResult.append("],");
} }
//std::stringstream stream;
//for (int i = 0; i < hours; i++)
//{
// NodeResultItems nodeItemsMap;
// LinkResultItems linkItemsMap;
// mResultCache.getResultByTime(i, nodeItemsMap, linkItemsMap);
//
// // 追踪管段编号
// auto linkIter = linkItemsMap.begin();
// size_t total = linkItemsMap.size();
// int index = 1;
// jsonResult.append("[");
// while (linkIter != linkItemsMap.end())
// {
// if (linkIter->second.dQuality > 0)
// {
// std::string sn = linkIter->first;
//
// Pipes pipe;
// trackingCache.getPipeInfoBySn(sn, pipe);
// jsonResult.append("[[");
// jsonResult.append(pipe.startX);
// jsonResult.append(",");
// jsonResult.append(pipe.startY);
// jsonResult.append("],[");
// jsonResult.append(pipe.endX);
// jsonResult.append(",");
// jsonResult.append(pipe.endY);
// jsonResult.append("]],");
// }
// linkIter++;
// }
// jsonResult = jsonResult.substr(0, jsonResult.length() - 1);
// jsonResult.append("],");
//}
jsonResult = jsonResult.substr(0, jsonResult.length() - 1); jsonResult = jsonResult.substr(0, jsonResult.length() - 1);
jsonResult.append("]"); jsonResult.append("]");
} }
void CivHydrSimulation::getNodeResult(short time)
{
int nNodeCount;
ENgetcount(EN_NODECOUNT, &nNodeCount);
for (int i = 1; i <= nNodeCount; i++)
{
NodeResultItem nodeItem;
// 编号
ENgetnodeid(i, nodeItem.szNo);
// 流量
ENgetnodevalue(i, EN_DEMAND, &nodeItem.dFlow);
// 水头
ENgetnodevalue(i, EN_HEAD, &nodeItem.dHead);
// 压力
ENgetnodevalue(i, EN_PRESSURE, &nodeItem.dPressure);
// 标高
ENgetnodevalue(i, EN_ELEVATION, &nodeItem.dElevation);
// 实际需水量
ENgetnodevalue(i, EN_DEMAND, &nodeItem.dDemand);
// 水池容量
ENgetnodevalue(i, EN_TANKVOLUME, &nodeItem.dTankVolume);
// 水池最大容量
ENgetnodevalue(i, EN_MAXVOLUME, &nodeItem.dTankMaxVolume);
// 液位高度
ENgetnodevalue(i, EN_TANKLEVEL, &nodeItem.dTankLevel);
nodeItem.dInterval = time;
// 放到缓存类中
mResultCache.addNodeItems(nodeItem);
}
}
void CivHydrSimulation::getLinkResult(short time)
{
int nLinkCount;
ENgetcount(EN_LINKCOUNT, &nLinkCount);
for (int i = 1; i <= nLinkCount; i++)
{
LinkResultItem linkItem;
int* typeCode = (int*)malloc(sizeof(int));
ENgetlinktype(i, typeCode);
if (*typeCode != EN_PIPE)
{
free(typeCode);
continue;
}
free(typeCode);
// 编号
ENgetlinkid(i, linkItem.szNo);
// 流量
ENgetlinkvalue(i, EN_FLOW, &linkItem.dFlow);
// 流向
linkItem.nFlowDirect = (linkItem.dFlow >= 0) ? 0 : 1;
// 流速
ENgetlinkvalue(i, EN_VELOCITY, &linkItem.dVelocity);
// 水头损失
ENgetlinkvalue(i, EN_HEADLOSS, &linkItem.dHeadloss);
// 单位水头损失
float dPipeLen = 0.0f;;
ENgetlinkvalue(i, EN_LENGTH, &dPipeLen);
linkItem.dUnitHeadloss = (linkItem.dHeadloss / dPipeLen) * 1000;
// 获取上点和本点
int node1 = 0;
int node2 = 0;
ENgetlinknodes(i, &node1, &node2);
// 上点水头
ENgetnodevalue(node1, EN_HEAD, &linkItem.dFromNodHeadloss);
// 本点水头
ENgetnodevalue(node2, EN_HEAD, &linkItem.dToNodHeadloss);
// 局部水头损失
float fCoeff;
ENgetlinkvalue(i, EN_MINORLOSS, &fCoeff);
double dMinorloss = fCoeff * linkItem.dHeadloss;
linkItem.dLocalHeadloss = dMinorloss;// 局部水头损失
// 摩擦水头损失
linkItem.dFrictionHeadloss = linkItem.dHeadloss - linkItem.dLocalHeadloss;// 局部水头损失
// 状态
float fState = 0;
ENgetlinkvalue(i, EN_STATUS, &fState);
if ((int)fState == 0)
strcpy_s(linkItem.szStatus, "关闭");
else
strcpy_s(linkItem.szStatus, "开启");
linkItem.dInterval = time;
// 放到缓存类中
mResultCache.addLinkItems(linkItem);
}
}
void CivHydrSimulation::getNodeQuality(short time)
{
if (mQuaLityType == ANALYSIS_TRACE)
{
return;
}
int nNodeCount;
ENgetcount(EN_NODECOUNT, &nNodeCount);
float* quality = (float*)malloc(sizeof(float));
for (int i = 1; i <= nNodeCount; i++)
{
char No[35];
// 编号
ENgetnodeid(i, No);
// 水质
ENgetnodevalue(i, EN_QUALITY, quality);
mResultCache.addNodeQuality(*quality, time, No);
}
free(quality);
}
void CivHydrSimulation::getLinkQuality(short time)
{
int nLinkCount;
ENgetcount(EN_LINKCOUNT, &nLinkCount);
int* typeCode = (int*)malloc(sizeof(int));
float* quality = (float*)malloc(sizeof(float));
for (int i = 1; i <= nLinkCount; i++)
{
ENgetlinktype(i, typeCode);
if (*typeCode != EN_PIPE)
{
continue;
}
char lnkNo[35];
// 编号
ENgetlinkid(i, lnkNo);
// 水质
ENgetlinkvalue(i, EN_LINKQUAL, quality);
if (mQuaLityType != ANALYSIS_TRACE )
{
mResultCache.addLinkQuality(*quality, time, lnkNo);
continue;
}
if (*quality > 0)
{
mTrackLinkSns[time].push_back(lnkNo);
}
}
free(typeCode);
free(quality);
}
...@@ -3,115 +3,40 @@ ...@@ -3,115 +3,40 @@
#include "CivNewInp.h" #include "CivNewInp.h"
class CivDbConn; class CivDbConn;
/** /**
水力模拟计算类 水力模拟计算类
*/ */
class CivHydrSimulation class CivHydrSimulation
{ {
public: public:
explicit CivHydrSimulation(); explicit CivHydrSimulation();
explicit CivHydrSimulation(CivDbConn* dbConn);
~CivHydrSimulation(); ~CivHydrSimulation();
/** /**
*@brief 注册数据库 *@brief 水力模拟
*@param dbConn 连接数据库指针
*/ */
void registDb(CivDbConn* dbConn);
/**
*@brief 水力模拟
*/
bool hdyrSimulation(); bool hdyrSimulation();
/** /**
*@brief 瞬时计算 *@brief 水质模拟,水龄,化学物质
*/ */
bool hdyrInstantSimulation();
bool hdyrCompute();
/**
*@brief 水质模拟,水龄,化学物质
*/
bool qualitySimulation(); bool qualitySimulation();
/**
*@brief 获取分析结果
*@return 分析结果字符串
*/
std::string getAnalysisResults();
/** /**
*@brief 追踪分析,本质仍然式水质分析 *@brief 追踪分析,本质仍然式水质分析
*@param snNode:追踪的节点号 *@param snNode:追踪的节点号
*@param hours: 小时数 *@param hours: 小时数
*/ */
bool trackingSimulation(char* snNode, int hours); bool trackingSimulation(char* snNode, int hours, std::string& jsonResult);
void getDataByTime(int time ,NodeResultItems& nodeItems, LinkResultItems& linkItems);
/** /**
*@brief 导出inp文件 *@brief 获取追踪结果值
*@param analyType: 水质分析类型:水龄,追踪,化合物,none *@param hours:追踪的小时数
*@param qulityName: 追踪节点值,或者化合物质 */
*/
bool convertInp(const QualityAnalyType analyType, const std::string& qulityName);
/**
*@brief 获取追踪结果值
*@param hours:追踪的小时数
*/
void getTrackingResult(int hours, std::string& result); void getTrackingResult(int hours, std::string& result);
/**
*@brief 同一天只保留最后一次模拟的结果值,须清除当前之前模拟的结果值
*@param dbConn: 数据库连接对象指针
*@param date: 日期
*/
bool clearSamePeriodValue(CivDbConn* dbConn, const std::string& date);
/**
*@brief 及时更新最新模拟的数据到gis管网模型中,默认更新零时刻
*@param dbConn: 数据库连接对象指针
*@param time: 时段
*/
bool updateLastestDataToGisNet(CivDbConn* dbConn,const std::string& time);
/**
*@brief 刷新最新的模拟的数据
*/
bool brushingResult();
void setQualityAnalyType(QualityAnalyType analyType) { mQuaLityType = analyType; }
/*
inp文件名,输出文件名,二进制文件名设置和获取
*/
inline void setInpFile(const std::string& inpFile);
inline void setRptFile(const std::string& rptFile);
inline void setBinFile(const std::string& binFile);
private:
inline char* getRptFile();
inline char* getInpFile();
inline char* getBinFile();
/**
*@brief 水质计算服务
*/
bool qualityCompute();
void getNodeResult(short time);
void getLinkResult(short time);
void getNodeQuality(short time);
void getLinkQuality(short time);
private: private:
CivDbConn* mDbConn;
CivSimulResultCache mResultCache; // 存储模拟结果缓存类 CivSimulResultCache mResultCache; // 存储模拟结果缓存类
QualityAnalyType mQuaLityType = ANALYSIS_RESERVE;
std::map<int,std::vector<std::string>> mTrackLinkSns; std::map<int,std::vector<std::string>> mTrackLinkSns;
std::string mInpFile; // inp文件名
std::string mRptFile; // 报告文件名
std::string mBinFile;// 二进制文件名
}; };
#include "CivBuilder.h" #include "CivInpBuilder.h"
#include "CivTypes.h" #include "CivTypes.h"
#include "CivAssembly.h" #include "CivAssembly.h"
#define ASSERT(A,B) if ((A) == nullptr || (B) == nullptr) return; #define ASSERT(A,B) if ((A) == nullptr || (B) == nullptr) return;
CivBuilder::CivBuilder():mNewInp(new CivNewInp()) CivInpBuilder::CivInpBuilder():mNewInp(new CivNewInp())
{ {
} }
CivBuilder::~CivBuilder() CivInpBuilder::~CivInpBuilder()
{ {
delete mNewInp; delete mNewInp;
} }
CivNewInp* CivBuilder::getNewInp() CivNewInp* CivInpBuilder::getNewInp()
{ {
return mNewInp; return mNewInp;
} }
CivInpBuilder::CivInpBuilder() CivInpBuilder::CivInpBuilder()
:mDbConn(nullptr)
{ {
} }
CivInpBuilder::CivInpBuilder(CivDbConn* dbConn)
:mDbConn(dbConn)
{
}
CivInpBuilder::~CivInpBuilder()
{
}
void CivInpBuilder::setQualityType(const QualityAnalyType analyType, const std::string& qulityName)
{
mNewInp->setQualityType(analyType, qulityName);
}
void CivInpBuilder::setDuration(int duration)
{
mNewInp->setDuration(duration);
}
void CivInpBuilder::registDb(CivDbConn* dbConn)
{
mDbConn = dbConn;
}
void CivInpBuilder::buildNode() void CivInpBuilder::buildNode()
{ {
ASSERT(mDbConn, mNewInp)
CivNode node; CivNode node;
if (!mDbConn->getNode(node)) if (!mDbConn->getNode(node))
return; return;
......
#ifndef _CIVINPEXPOTER_H #ifndef _CIVINPEXPOTER_H
#define _CIVINPEXPOTER_H #define _CIVINPEXPOTER_H
#include "CivPgConn.h"
#include "CivNewInp.h" #include "CivNewInp.h"
/** /**
* *
*/ */
class CivBuilder class CivInpBuilder
{ {
public: public:
CivBuilder();
virtual ~CivBuilder();
virtual void setQualityType(const QualityAnalyType analyType, const std::string& qulityName) = 0;
virtual void setDuration(int duration) = 0;
virtual void registDb(CivDbConn* dbConn)=0;
virtual void buildNode() = 0;
virtual void buildPipe() = 0;
virtual void buildTank() = 0;
virtual void buildVavle() = 0;
virtual void buildPump() = 0;
virtual void buildReservoir() = 0;
virtual void buildEmitter() = 0;
virtual void buildPatterns() = 0;
virtual void buildParamter() = 0;
virtual void buildCoordnates() = 0;
virtual void buildVertices() = 0;
virtual void buildLabels() = 0;
virtual void buildTags() = 0;
virtual void buildBackDrop() = 0;
virtual void buildQuality() = 0;
virtual void buildSources() = 0;
virtual void buildMixing() = 0;
virtual void buildCurves() = 0;
virtual void buildStatus() = 0;
virtual void buildControls() = 0;
virtual void buildRules() = 0;
virtual void buildDemands() = 0;
CivNewInp* getNewInp();
protected:
CivNewInp* mNewInp;
};
/**
* 导出inp文件类
*/
class CivInpBuilder:public CivBuilder
{
public:
explicit CivInpBuilder(); explicit CivInpBuilder();
explicit CivInpBuilder(CivDbConn* dbConn); virtual ~CivInpBuilder();
~CivInpBuilder();
virtual void setQualityType(const QualityAnalyType analyType, const std::string& qulityName);
virtual void setDuration(int duration);
// 注册数据库连接
virtual void registDb(CivDbConn* dbConn);
virtual void buildNode(); virtual void buildNode();
virtual void buildPipe(); virtual void buildPipe();
virtual void buildTank(); virtual void buildTank();
...@@ -83,9 +35,12 @@ public: ...@@ -83,9 +35,12 @@ public:
virtual void buildRules(); virtual void buildRules();
virtual void buildDemands(); virtual void buildDemands();
private: CivNewInp* getNewInp();
CivDbConn* mDbConn;
protected:
CivNewInp* mNewInp;
}; };
#endif // !_CIVINPEXPOTER_H #endif // !_CIVINPEXPOTER_H
......
...@@ -8,4 +8,9 @@ CivInpConvertor::CivInpConvertor(const std::string& uri) ...@@ -8,4 +8,9 @@ CivInpConvertor::CivInpConvertor(const std::string& uri)
CivInpConvertor::~CivInpConvertor() CivInpConvertor::~CivInpConvertor()
{ {
}
char* CivInpConvertor::getInp()
{
} }
\ No newline at end of file
...@@ -7,23 +7,10 @@ ...@@ -7,23 +7,10 @@
class CivInpConvertor class CivInpConvertor
{ {
public: public:
CivInpConvertor(const std::string& uri); explicit CivInpConvertor(const std::string& uri);
~CivInpConvertor(); ~CivInpConvertor();
char* getInp();
/*
inp文件名,输出文件名,二进制文件名设置和获取
*/
void setInpFile(const std::string& inpFile) { mInpFile = inpFile; }
void setRptFile(const std::string& rptFile) { mRptFile = rptFile; }
void setBinFile(const std::string& binFile) { mBinFile = binFile; }
char* getRptFile() { return const_cast<char*>(mInpFile.c_str()); }
char* getInpFile(){ return const_cast<char*>(mRptFile.c_str()); }
char* getBinFile(){ return const_cast<char*>(mBinFile.c_str()); }
private: private:
std::string mInpFile; // inp文件名
std::string mRptFile; // 报告文件名
std::string mBinFile;// 二进制文件名
}; };
\ No newline at end of file
#include "CivProjInpBuilder.h" #include "CivProjInpBuilder.h"
void CivProjInpBuilder::setQualityType(
const QualityAnalyType analyType,
const std::string& qulityName)
{
}
void CivProjInpBuilder::setDuration(int duration)
{
mNewInp->setDuration(10);
}
void CivProjInpBuilder::registDb(CivDbConn* dbConn)
{
}
void CivProjInpBuilder::buildNode() void CivProjInpBuilder::buildNode()
{ {
......
#pragma once #pragma once
#include "CivBuilder.h" #include "CivInpBuilder.h"
/** /**
ģתinpļ ģתinpļ
*/ */
class CivProjInpBuilder :public CivBuilder class CivProjInpBuilder :public CivInpBuilder
{ {
public: public:
virtual void setQualityType(const QualityAnalyType analyType, const std::string& qulityName);
virtual void setDuration(int duration);
virtual void registDb(CivDbConn* dbConn);
virtual void buildNode(); virtual void buildNode();
virtual void buildPipe(); virtual void buildPipe();
virtual void buildTank(); virtual void buildTank();
......
...@@ -153,12 +153,13 @@ ...@@ -153,12 +153,13 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\pandaDbManager\CivCommonUtils.cpp" /> <ClCompile Include="..\pandaDbManager\CivCommonUtils.cpp" />
<ClCompile Include="CivBaseInpBuilder.cpp" />
<ClCompile Include="CivGraphFactory.cpp" /> <ClCompile Include="CivGraphFactory.cpp" />
<ClCompile Include="CivHydDataType.cpp" /> <ClCompile Include="CivHydDataType.cpp" />
<ClCompile Include="CivHydrCompute.cpp" /> <ClCompile Include="CivHydrCompute.cpp" />
<ClCompile Include="CivHydrFuncInter.cpp" /> <ClCompile Include="CivHydrFuncInter.cpp" />
<ClCompile Include="CivHydrSimulation.cpp" /> <ClCompile Include="CivHydrSimulation.cpp" />
<ClCompile Include="CivBuilder.cpp" /> <ClCompile Include="CivInpBuilder.cpp" />
<ClCompile Include="CivInpConvertor.cpp" /> <ClCompile Include="CivInpConvertor.cpp" />
<ClCompile Include="CivInpDirector.cpp" /> <ClCompile Include="CivInpDirector.cpp" />
<ClCompile Include="CivNewInp.cpp" /> <ClCompile Include="CivNewInp.cpp" />
...@@ -171,13 +172,14 @@ ...@@ -171,13 +172,14 @@
<ClCompile Include="CivTrackingAnalysis.cpp" /> <ClCompile Include="CivTrackingAnalysis.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="CivBaseInpBuilder.h" />
<ClInclude Include="CivGraphFactory.h" /> <ClInclude Include="CivGraphFactory.h" />
<ClInclude Include="CivGraphList.h" /> <ClInclude Include="CivGraphList.h" />
<ClInclude Include="CivHydDataType.h" /> <ClInclude Include="CivHydDataType.h" />
<ClInclude Include="CivHydrCompute.h" /> <ClInclude Include="CivHydrCompute.h" />
<ClInclude Include="CivHydrFuncInter.h" /> <ClInclude Include="CivHydrFuncInter.h" />
<ClInclude Include="CivHydrSimulation.h" /> <ClInclude Include="CivHydrSimulation.h" />
<ClInclude Include="CivBuilder.h" /> <ClInclude Include="CivInpBuilder.h" />
<ClInclude Include="CivInpConvertor.h" /> <ClInclude Include="CivInpConvertor.h" />
<ClInclude Include="CivInpDirector.h" /> <ClInclude Include="CivInpDirector.h" />
<ClInclude Include="CivNewInp.h" /> <ClInclude Include="CivNewInp.h" />
......
...@@ -21,9 +21,6 @@ ...@@ -21,9 +21,6 @@
<ClCompile Include="..\pandaDbManager\CivCommonUtils.cpp"> <ClCompile Include="..\pandaDbManager\CivCommonUtils.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="CivBuilder.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivInpDirector.cpp"> <ClCompile Include="CivInpDirector.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
...@@ -66,6 +63,12 @@ ...@@ -66,6 +63,12 @@
<ClCompile Include="CivOptSchedSimulation.cpp"> <ClCompile Include="CivOptSchedSimulation.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="CivBaseInpBuilder.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivInpBuilder.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="CivHydrFuncInter.h"> <ClInclude Include="CivHydrFuncInter.h">
...@@ -74,9 +77,6 @@ ...@@ -74,9 +77,6 @@
<ClInclude Include="CivNewInp.h"> <ClInclude Include="CivNewInp.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="CivBuilder.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivInpDirector.h"> <ClInclude Include="CivInpDirector.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
...@@ -119,5 +119,11 @@ ...@@ -119,5 +119,11 @@
<ClInclude Include="CivOptSchedSimulation.h"> <ClInclude Include="CivOptSchedSimulation.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="CivInpBuilder.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivBaseInpBuilder.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "CivTypes.h" #include "CivTypes.h"
#include <list> #include <list>
#pragma warning(disable:4251) #pragma warning(disable:4251)
#define DBEXPORT __declspec(dllexport) #define DBEXPORT __declspec(dllexport)
class CivAssembly; class CivAssembly;
...@@ -68,7 +69,7 @@ public: ...@@ -68,7 +69,7 @@ public:
/* /*
水池类型 水池类型
*/ */
class DBEXPORT CivTank:public CivAssembly class DBEXPORT CivTank:public CivAssembly
{ {
...@@ -98,15 +99,6 @@ class DBEXPORT CivValve :public CivAssembly ...@@ -98,15 +99,6 @@ class DBEXPORT CivValve :public CivAssembly
public: public:
typedef struct Table typedef struct Table
{ {
/*
阀门的ID标签
起始节点ID
终止节点ID
直径,mm(英寸)
阀门类型
阀门设置
局部损失系数
*/
Str ID; Str ID;
Str Node1; Str Node1;
Str Node2; Str Node2;
...@@ -117,6 +109,7 @@ public: ...@@ -117,6 +109,7 @@ public:
} ValveTable; } ValveTable;
void addItem(const ValveTable& table); void addItem(const ValveTable& table);
std::list<ValveTable> mTables; std::list<ValveTable> mTables;
}; };
...@@ -190,7 +183,6 @@ class DBEXPORT CivCoordinates :public CivAssembly ...@@ -190,7 +183,6 @@ class DBEXPORT CivCoordinates :public CivAssembly
public: public:
typedef struct Table typedef struct Table
{ {
// ; ;Node X-Coord Y-Coord
Str ID; Str ID;
Str XCoord; Str XCoord;
Str YCoord; Str YCoord;
...@@ -372,8 +364,8 @@ public: ...@@ -372,8 +364,8 @@ public:
/* /*
X坐标 X坐标
Y坐标 Y坐标
双引号中的标签文本 双引号中的标签文本
锚定节点的ID标签(可选) 锚定节点的ID标签(可选)
*/ */
Str XCoord; Str XCoord;
Str YCoord; Str YCoord;
......
...@@ -51,11 +51,6 @@ public: ...@@ -51,11 +51,6 @@ public:
*/ */
virtual bool tableExist(StrQuote tableName) = 0; virtual bool tableExist(StrQuote tableName) = 0;
/**
*@brief 创建表格
*/
virtual bool createTable(CivTableTemp& temp) =0 ;
/** /**
*@brief 根据字段值条件删除数据 *@brief 根据字段值条件删除数据
*@param table:表 *@param table:表
...@@ -104,7 +99,6 @@ public: ...@@ -104,7 +99,6 @@ public:
const std::vector<std::string>& fileds, const std::vector<std::string>& fileds,
std::vector< std::map<std::string, std::string>>& result) = 0; std::vector< std::map<std::string, std::string>>& result) = 0;
virtual void checkHyDrNetTable() = 0;
// 获取当前执行错误信息 // 获取当前执行错误信息
Str getLastError() const; Str getLastError() const;
......
#include "CivDbUtils.h"
#include "CivConnection.h"
CivConnection* CivDbUtils::getConnection()
{
return nullptr;
}
\ No newline at end of file
#pragma once
class CivConnection;
/**
ݿ
*/
class CivDbUtils
{
public:
static CivConnection* getConnection();
};
...@@ -16,9 +16,15 @@ CivInpDbHelper::~CivInpDbHelper() ...@@ -16,9 +16,15 @@ CivInpDbHelper::~CivInpDbHelper()
bool CivInpDbHelper::getNode(CivNode& node) bool CivInpDbHelper::getNode(CivNode& node)
{ {
CivJunctionTableTemp::JunctionTable nodeTable; JunctionTable nodeTableFields;
std::vector<std::string> fields = { nodeTable.thePoint,nodeTable.elev, nodeTable.demand, nodeTable.pattern }; std::vector<std::string> fields =
{
nodeTableFields.sn,
nodeTableFields.elev,
nodeTableFields.demand,
nodeTableFields.demandPattern
};
std::vector<std::map<std::string,std::string>> resultVector; std::vector<std::map<std::string,std::string>> resultVector;
mDbConn->query(PUMP, fields, resultVector); mDbConn->query(PUMP, fields, resultVector);
...@@ -29,10 +35,10 @@ bool CivInpDbHelper::getNode(CivNode& node) ...@@ -29,10 +35,10 @@ bool CivInpDbHelper::getNode(CivNode& node)
std::map<std::string, std::string> map = resultVector[i]; std::map<std::string, std::string> map = resultVector[i];
CivNode::NodeTable nodeTable; CivNode::NodeTable nodeTable;
nodeTable.ID = map.find(nodeTable.ID)->second; nodeTable.ID = map.find(nodeTableFields.sn)->second;
nodeTable.Elev = map.find(nodeTable.Elev)->second; nodeTable.Elev = map.find(nodeTableFields.elev)->second;
nodeTable.Demand = map.find(nodeTable.Demand)->second; nodeTable.Demand = map.find(nodeTableFields.baseDemand)->second;
nodeTable.PatternId = map.find(nodeTable.PatternId)->second; nodeTable.PatternId = map.find(nodeTableFields.demandPattern)->second;
node.addItem(nodeTable); node.addItem(nodeTable);
} }
...@@ -41,16 +47,16 @@ bool CivInpDbHelper::getNode(CivNode& node) ...@@ -41,16 +47,16 @@ bool CivInpDbHelper::getNode(CivNode& node)
bool CivInpDbHelper::getPipe(CivPipe& pipes) bool CivInpDbHelper::getPipe(CivPipe& pipes)
{ {
CivPipeTableTemp::PipeTable pipeTable; PipeTable pipeTable;
std::vector<std::string> fields = { std::vector<std::string> fields = {
pipeTable.snNo, pipeTable.snNo,
pipeTable.lastPoint, pipeTable.startPoint,
pipeTable.thePoint, pipeTable.endPoint,
pipeTable.length, pipeTable.length,
pipeTable.diameter, pipeTable.diameter,
pipeTable.friction, pipeTable.friction,
pipeTable.localHeadLoss, pipeTable.localLoss,
pipeTable.status pipeTable.status
}; };
...@@ -65,12 +71,12 @@ bool CivInpDbHelper::getPipe(CivPipe& pipes) ...@@ -65,12 +71,12 @@ bool CivInpDbHelper::getPipe(CivPipe& pipes)
std::map<std::string, std::string> map = resultVector[i]; std::map<std::string, std::string> map = resultVector[i];
pipe.ID = map.find(pipeTable.snNo)->second; pipe.ID = map.find(pipeTable.snNo)->second;
pipe.Node1 = map.find(pipeTable.lastPoint)->second; pipe.Node1 = map.find(pipeTable.startPoint)->second;
pipe.Node2 = map.find(pipeTable.thePoint)->second; pipe.Node2 = map.find(pipeTable.endPoint)->second;
pipe.Length = map.find(pipeTable.length)->second; pipe.Length = map.find(pipeTable.length)->second;
pipe.Diameter = map.find(pipeTable.diameter)->second; pipe.Diameter = map.find(pipeTable.diameter)->second;
pipe.Roughness = map.find(pipeTable.friction)->second; pipe.Roughness = map.find(pipeTable.friction)->second;
pipe.MinorLoss = map.find(pipeTable.localHeadLoss)->second; pipe.MinorLoss = map.find(pipeTable.localLoss)->second;
pipe.Status = map.find(pipeTable.status)->second; pipe.Status = map.find(pipeTable.status)->second;
pipes.addItem(pipe); pipes.addItem(pipe);
...@@ -80,17 +86,17 @@ bool CivInpDbHelper::getPipe(CivPipe& pipes) ...@@ -80,17 +86,17 @@ bool CivInpDbHelper::getPipe(CivPipe& pipes)
bool CivInpDbHelper::getTank(CivTank& tanks) bool CivInpDbHelper::getTank(CivTank& tanks)
{ {
CivTankTableTemp::TankTable tankTable; TankTable tankTable;
std::vector<std::string> fields = { std::vector<std::string> fields = {
tankTable.thePoint, tankTable.sn,
tankTable.elev, tankTable.elev,
tankTable.initLevel, tankTable.initLevel,
tankTable.lowLevel, tankTable.minLevel,
tankTable.highLevel, tankTable.maxLevel,
tankTable.diametor, tankTable.diametor,
tankTable.capacity, tankTable.minVolume,
tankTable.volCurve tankTable.volumeCurve
}; };
std::vector<std::map<std::string, std::string>> resultVector; std::vector<std::map<std::string, std::string>> resultVector;
...@@ -102,14 +108,14 @@ bool CivInpDbHelper::getTank(CivTank& tanks) ...@@ -102,14 +108,14 @@ bool CivInpDbHelper::getTank(CivTank& tanks)
CivTank::TankTable tank; CivTank::TankTable tank;
std::map<std::string, std::string>map = resultVector[i]; std::map<std::string, std::string>map = resultVector[i];
tank.ID = map.find(tankTable.thePoint)->second; tank.ID = map.find(tankTable.sn)->second;
tank.Elev = map.find(tankTable.elev)->second; tank.Elev = map.find(tankTable.elev)->second;
tank.InitLevel = map.find(tankTable.initLevel)->second; tank.InitLevel = map.find(tankTable.initLevel)->second;
tank.MinLevel = map.find(tankTable.lowLevel)->second; tank.MinLevel = map.find(tankTable.minLevel)->second;
tank.MaxLevel = map.find(tankTable.highLevel)->second; tank.MaxLevel = map.find(tankTable.maxLevel)->second;
tank.Diameter = map.find(tankTable.diametor)->second; tank.Diameter = map.find(tankTable.diametor)->second;
tank.MinVol = map.find(tankTable.capacity)->second; tank.MinVol = map.find(tankTable.minVolume)->second;
tank.VolCurve = map.find(tankTable.volCurve)->second; tank.VolCurve = map.find(tankTable.volumeCurve)->second;
tanks.addItem(tank); tanks.addItem(tank);
} }
...@@ -118,15 +124,15 @@ bool CivInpDbHelper::getTank(CivTank& tanks) ...@@ -118,15 +124,15 @@ bool CivInpDbHelper::getTank(CivTank& tanks)
bool CivInpDbHelper::getValve(CivValve& valves) bool CivInpDbHelper::getValve(CivValve& valves)
{ {
CivValveTableTemp::ValveTable vaveTable; ValveTable vaveTable;
std::vector<std::string> fields = { std::vector<std::string> fields = {
vaveTable.id, vaveTable.sn,
vaveTable.startPoint, vaveTable.startPoint,
vaveTable.endPoint, vaveTable.endPoint,
vaveTable.diameter, vaveTable.length,
vaveTable.type, vaveTable.type,
vaveTable.setting, vaveTable.setting,
vaveTable.loss vaveTable.lossCoeff
}; };
std::vector<std::map<std::string, std::string>> resultVector; std::vector<std::map<std::string, std::string>> resultVector;
...@@ -138,13 +144,13 @@ bool CivInpDbHelper::getValve(CivValve& valves) ...@@ -138,13 +144,13 @@ bool CivInpDbHelper::getValve(CivValve& valves)
CivValve::ValveTable vave; CivValve::ValveTable vave;
std::map<std::string, std::string> map = resultVector[i]; std::map<std::string, std::string> map = resultVector[i];
vave.ID = map.find(vaveTable.id)->second; vave.ID = map.find(vaveTable.sn)->second;
vave.Node1 = map.find(vaveTable.startPoint)->second; vave.Node1 = map.find(vaveTable.startPoint)->second;
vave.Node2 = map.find(vaveTable.endPoint)->second; vave.Node2 = map.find(vaveTable.endPoint)->second;
vave.Diameter = map.find(vaveTable.diameter)->second; vave.Diameter = map.find(vaveTable.length)->second;
vave.Type = map.find(vaveTable.type)->second; vave.Type = map.find(vaveTable.type)->second;
vave.Setting = map.find(vaveTable.setting)->second; vave.Setting = map.find(vaveTable.setting)->second;
vave.MinorLoss = map.find(vaveTable.loss)->second; vave.MinorLoss = map.find(vaveTable.lossCoeff)->second;
valves.addItem(vave); valves.addItem(vave);
} }
...@@ -153,9 +159,9 @@ bool CivInpDbHelper::getValve(CivValve& valves) ...@@ -153,9 +159,9 @@ bool CivInpDbHelper::getValve(CivValve& valves)
bool CivInpDbHelper::getPumps(CivPumps& pumps) bool CivInpDbHelper::getPumps(CivPumps& pumps)
{ {
CivPumpTableTemp::PumpTable pmTable; PumpTable pmTable;
std::vector<std::string> fields = { std::vector<std::string> fields = {
pmTable.thePoint, pmTable.sn,
pmTable.startPoint, pmTable.startPoint,
pmTable.endPoint, pmTable.endPoint,
pmTable.headCurve pmTable.headCurve
...@@ -170,7 +176,7 @@ bool CivInpDbHelper::getPumps(CivPumps& pumps) ...@@ -170,7 +176,7 @@ bool CivInpDbHelper::getPumps(CivPumps& pumps)
CivPumps::PumpTable pump; CivPumps::PumpTable pump;
std::map<std::string, std::string> map = resultVector[i]; std::map<std::string, std::string> map = resultVector[i];
pump.ID = map.find(pmTable.thePoint)->second; pump.ID = map.find(pmTable.sn)->second;
pump.Node1 = map.find(pmTable.startPoint)->second; pump.Node1 = map.find(pmTable.startPoint)->second;
pump.Node2 = map.find(pmTable.endPoint)->second; pump.Node2 = map.find(pmTable.endPoint)->second;
pump.Parameters = map.find(pmTable.headCurve)->second; pump.Parameters = map.find(pmTable.headCurve)->second;
...@@ -182,11 +188,11 @@ bool CivInpDbHelper::getPumps(CivPumps& pumps) ...@@ -182,11 +188,11 @@ bool CivInpDbHelper::getPumps(CivPumps& pumps)
bool CivInpDbHelper::getReservoirs(CivReservoirs& reservoirs) bool CivInpDbHelper::getReservoirs(CivReservoirs& reservoirs)
{ {
CivResourcesTableTemp::ResourcesTable restemTable; ResourcesTable restemTable;
std::vector<std::string> fields = { std::vector<std::string> fields = {
restemTable.thePoint, restemTable.sn,
restemTable.head, restemTable.totalHead,
restemTable.headPattern restemTable.headPattern
}; };
...@@ -199,8 +205,8 @@ bool CivInpDbHelper::getReservoirs(CivReservoirs& reservoirs) ...@@ -199,8 +205,8 @@ bool CivInpDbHelper::getReservoirs(CivReservoirs& reservoirs)
CivReservoirs::ReservoirsTable resTable; CivReservoirs::ReservoirsTable resTable;
std::map<std::string, std::string> map = resultVector[i]; std::map<std::string, std::string> map = resultVector[i];
resTable.ID = map.find(restemTable.thePoint)->second; resTable.ID = map.find(restemTable.sn)->second;
resTable.Head = map.find(restemTable.head)->second; resTable.Head = map.find(restemTable.totalHead)->second;
resTable.Pattern = map.find(restemTable.headPattern)->second; resTable.Pattern = map.find(restemTable.headPattern)->second;
reservoirs.addItem(resTable); reservoirs.addItem(resTable);
...@@ -215,10 +221,10 @@ bool CivInpDbHelper::getEmitters(CivEmitters& emitter) ...@@ -215,10 +221,10 @@ bool CivInpDbHelper::getEmitters(CivEmitters& emitter)
bool CivInpDbHelper::getCoordinates(CivCoordinates& coord) bool CivInpDbHelper::getCoordinates(CivCoordinates& coord)
{ {
CivJunctionTableTemp::JunctionTable nodeTable; JunctionTable nodeTable;
std::vector<std::string> fields = { std::vector<std::string> fields = {
nodeTable.thePoint, nodeTable.sn,
nodeTable.xCoord, nodeTable.xCoord,
nodeTable.yCoord nodeTable.yCoord
}; };
...@@ -251,7 +257,7 @@ bool CivInpDbHelper::getMixing(CivMixing& mixing) ...@@ -251,7 +257,7 @@ bool CivInpDbHelper::getMixing(CivMixing& mixing)
bool CivInpDbHelper::getParameter(std::vector<CivParameter>& params) bool CivInpDbHelper::getParameter(std::vector<CivParameter>& params)
{ {
CivParametorTableTemp::ParametorTable restemTable; ParametorTable restemTable;
std::vector<std::string> fields = { std::vector<std::string> fields = {
restemTable.name, restemTable.name,
...@@ -295,7 +301,7 @@ bool CivInpDbHelper::getParameter(std::vector<CivParameter>& params) ...@@ -295,7 +301,7 @@ bool CivInpDbHelper::getParameter(std::vector<CivParameter>& params)
bool CivInpDbHelper::getPatterns(CivPatterns& patterns) bool CivInpDbHelper::getPatterns(CivPatterns& patterns)
{ {
CivPatternTableTemp::PatternTable patternTable; PatternTable patternTable;
std::vector<std::string> fields = { std::vector<std::string> fields = {
patternTable.modelName, patternTable.modelName,
...@@ -323,12 +329,12 @@ bool CivInpDbHelper::getPatterns(CivPatterns& patterns) ...@@ -323,12 +329,12 @@ bool CivInpDbHelper::getPatterns(CivPatterns& patterns)
bool CivInpDbHelper::getCurves(CivCurves& curves) bool CivInpDbHelper::getCurves(CivCurves& curves)
{ {
CivCurveTableTemp::CurveTable curveTable; CurveTable curveTable;
std::vector<std::string> fields = { std::vector<std::string> fields = {
curveTable.CurveName, curveTable.CurveName,
curveTable.CurveType, curveTable.CurveType,
curveTable.CurveData curveTable.CurveData
}; };
std::vector<std::map<std::string, std::string>> resultVector; std::vector<std::map<std::string, std::string>> resultVector;
...@@ -367,9 +373,9 @@ bool CivInpDbHelper::getStatus(CivStatus& status) ...@@ -367,9 +373,9 @@ bool CivInpDbHelper::getStatus(CivStatus& status)
bool CivInpDbHelper::getQuality(CivQuality& quality) bool CivInpDbHelper::getQuality(CivQuality& quality)
{ {
CivJunctionTableTemp::JunctionTable nodeTable; JunctionTable nodeTable;
std::vector<std::string> fields = { nodeTable.thePoint,nodeTable.initQuality }; std::vector<std::string> fields = { nodeTable.sn,nodeTable.initQuality };
std::vector<std::map<std::string, std::string>> resultVector; std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PIPENODE, fields, resultVector); mDbConn->query(PIPENODE, fields, resultVector);
......
...@@ -15,195 +15,31 @@ CivInpHelperAbs::~CivInpHelperAbs() ...@@ -15,195 +15,31 @@ CivInpHelperAbs::~CivInpHelperAbs()
bool CivInpHelperAbs::getNode(CivNode& node) bool CivInpHelperAbs::getNode(CivNode& node)
{ {
CivJunctionTableTemp::JunctionTable nodeTable;
std::vector<std::string> fields = { nodeTable.thePoint,nodeTable.elev, nodeTable.demand, nodeTable.pattern };
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PUMP, fields, resultVector);
// 编辑包装结果
size_t total = resultVector.size();
for (int i = 0; i < total; i++)
{
std::map<std::string, std::string> map = resultVector[i];
CivNode::NodeTable nodeTable;
nodeTable.ID = map.find(nodeTable.ID)->second;
nodeTable.Elev = map.find(nodeTable.Elev)->second;
nodeTable.Demand = map.find(nodeTable.Demand)->second;
nodeTable.PatternId = map.find(nodeTable.PatternId)->second;
node.addItem(nodeTable);
}
return true; return true;
} }
bool CivInpHelperAbs::getPipe(CivPipe& pipes) bool CivInpHelperAbs::getPipe(CivPipe& pipes)
{ {
CivPipeTableTemp::PipeTable pipeTable;
std::vector<std::string> fields = {
pipeTable.snNo,
pipeTable.lastPoint,
pipeTable.thePoint,
pipeTable.length,
pipeTable.diameter,
pipeTable.friction,
pipeTable.localHeadLoss,
pipeTable.status
};
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PUMP, fields, resultVector);
size_t total = resultVector.size();
for (int i = 0; i < total; i++)
{
CivPipe::PipesTable pipe;
std::map<std::string, std::string> map = resultVector[i];
pipe.ID = map.find(pipeTable.snNo)->second;
pipe.Node1 = map.find(pipeTable.lastPoint)->second;
pipe.Node2 = map.find(pipeTable.thePoint)->second;
pipe.Length = map.find(pipeTable.length)->second;
pipe.Diameter = map.find(pipeTable.diameter)->second;
pipe.Roughness = map.find(pipeTable.friction)->second;
pipe.MinorLoss = map.find(pipeTable.localHeadLoss)->second;
pipe.Status = map.find(pipeTable.status)->second;
pipes.addItem(pipe);
}
return true; return true;
} }
bool CivInpHelperAbs::getTank(CivTank& tanks) bool CivInpHelperAbs::getTank(CivTank& tanks)
{ {
CivTankTableTemp::TankTable tankTable;
std::vector<std::string> fields = {
tankTable.thePoint,
tankTable.elev,
tankTable.initLevel,
tankTable.lowLevel,
tankTable.highLevel,
tankTable.diametor,
tankTable.capacity,
tankTable.volCurve
};
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PUMP, fields, resultVector);
size_t total = resultVector.size();
for (int i = 0; i < total; i++)
{
CivTank::TankTable tank;
std::map<std::string, std::string>map = resultVector[i];
tank.ID = map.find(tankTable.thePoint)->second;
tank.Elev = map.find(tankTable.elev)->second;
tank.InitLevel = map.find(tankTable.initLevel)->second;
tank.MinLevel = map.find(tankTable.lowLevel)->second;
tank.MaxLevel = map.find(tankTable.highLevel)->second;
tank.Diameter = map.find(tankTable.diametor)->second;
tank.MinVol = map.find(tankTable.capacity)->second;
tank.VolCurve = map.find(tankTable.volCurve)->second;
tanks.addItem(tank);
}
return true; return true;
} }
bool CivInpHelperAbs::getValve(CivValve& valves) bool CivInpHelperAbs::getValve(CivValve& valves)
{ {
CivValveTableTemp::ValveTable vaveTable;
std::vector<std::string> fields = {
vaveTable.id,
vaveTable.startPoint,
vaveTable.endPoint,
vaveTable.diameter,
vaveTable.type,
vaveTable.setting,
vaveTable.loss
};
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PUMP, fields, resultVector);
size_t totals = resultVector.size();
for (int i = 0; i < totals; i++)
{
CivValve::ValveTable vave;
std::map<std::string, std::string> map = resultVector[i];
vave.ID = map.find(vaveTable.id)->second;
vave.Node1 = map.find(vaveTable.startPoint)->second;
vave.Node2 = map.find(vaveTable.endPoint)->second;
vave.Diameter = map.find(vaveTable.diameter)->second;
vave.Type = map.find(vaveTable.type)->second;
vave.Setting = map.find(vaveTable.setting)->second;
vave.MinorLoss = map.find(vaveTable.loss)->second;
valves.addItem(vave);
}
return true; return true;
} }
bool CivInpHelperAbs::getPumps(CivPumps& pumps) bool CivInpHelperAbs::getPumps(CivPumps& pumps)
{ {
CivPumpTableTemp::PumpTable pmTable;
std::vector<std::string> fields = {
pmTable.thePoint,
pmTable.startPoint,
pmTable.endPoint,
pmTable.headCurve
};
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PUMP, fields, resultVector);
size_t totals = resultVector.size();
for (int i = 0; i < totals; i++)
{
CivPumps::PumpTable pump;
std::map<std::string, std::string> map = resultVector[i];
pump.ID = map.find(pmTable.thePoint)->second;
pump.Node1 = map.find(pmTable.startPoint)->second;
pump.Node2 = map.find(pmTable.endPoint)->second;
pump.Parameters = map.find(pmTable.headCurve)->second;
pumps.addItem(pump);
}
return true; return true;
} }
bool CivInpHelperAbs::getReservoirs(CivReservoirs& reservoirs) bool CivInpHelperAbs::getReservoirs(CivReservoirs& reservoirs)
{ {
CivResourcesTableTemp::ResourcesTable restemTable;
std::vector<std::string> fields = {
restemTable.thePoint,
restemTable.head,
restemTable.headPattern
};
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PUMP, fields, resultVector);
size_t totals = resultVector.size();
for (int i = 0; i < totals; i++)
{
CivReservoirs::ReservoirsTable resTable;
std::map<std::string, std::string> map = resultVector[i];
resTable.ID = map.find(restemTable.thePoint)->second;
resTable.Head = map.find(restemTable.head)->second;
resTable.Pattern = map.find(restemTable.headPattern)->second;
reservoirs.addItem(resTable);
}
return true; return true;
} }
...@@ -214,32 +50,6 @@ bool CivInpHelperAbs::getEmitters(CivEmitters& emitter) ...@@ -214,32 +50,6 @@ bool CivInpHelperAbs::getEmitters(CivEmitters& emitter)
bool CivInpHelperAbs::getCoordinates(CivCoordinates& coord) bool CivInpHelperAbs::getCoordinates(CivCoordinates& coord)
{ {
CivJunctionTableTemp::JunctionTable nodeTable;
std::vector<std::string> fields = {
nodeTable.thePoint,
nodeTable.xCoord,
nodeTable.yCoord
};
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PIPENODE, fields, resultVector);
mDbConn->query(TANK, fields, resultVector);
mDbConn->query(RESIVOIR, fields, resultVector);
size_t totals = resultVector.size();
for (int i = 0; i < totals; i++)
{
CivCoordinates::CoordTable coordTable;
std::map<std::string, std::string> map = resultVector[i];
coordTable.ID = map.find(fields[0])->second;
coordTable.XCoord = map.find(fields[1])->second;
coordTable.YCoord = map.find(fields[2])->second;
coord.addItem(coordTable);
}
return true; return true;
} }
...@@ -250,102 +60,20 @@ bool CivInpHelperAbs::getMixing(CivMixing& mixing) ...@@ -250,102 +60,20 @@ bool CivInpHelperAbs::getMixing(CivMixing& mixing)
bool CivInpHelperAbs::getParameter(std::vector<CivParameter>& params) bool CivInpHelperAbs::getParameter(std::vector<CivParameter>& params)
{ {
CivParametorTableTemp::ParametorTable restemTable;
std::vector<std::string> fields = {
restemTable.name,
restemTable.val,
restemTable.type
};
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(OPTIONTTABLE, fields, resultVector);
std::map<std::string, std::vector<CivParameter::ParamTable>> tempMap;
for (int i = 0; i < resultVector.size(); i++)
{
CivParameter::ParamTable pTable;
std::map<std::string, std::string> map = resultVector[i];
pTable.name = map.find(fields[0])->second;
pTable.val = map.find(fields[1])->second;
std::string type = map.find(fields[2])->second;
tempMap[type].push_back(pTable);
}
// 遍历临时存储的数据拼接参数对象
for (auto iter = tempMap.begin(); iter != tempMap.end(); iter++)
{
CivParameter param;
std::string type = iter->first;
std::vector<CivParameter::ParamTable> paramTables = iter->second;
param.setType(type);
int total = paramTables.size();
for (int i = 0; i < total; i++)
param.addItem(paramTables[i]);
params.push_back(param);
}
return true; return true;
} }
bool CivInpHelperAbs::getPatterns(CivPatterns& patterns) bool CivInpHelperAbs::getPatterns(CivPatterns& patterns)
{ {
CivPatternTableTemp::PatternTable patternTable;
std::vector<std::string> fields = {
patternTable.modelName,
patternTable.modelData,
patternTable.modelType
};
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PATTERNTABLE, fields, resultVector);
size_t totals = resultVector.size();
for (int i = 0; i < totals; i++)
{
std::map<std::string, std::string> map = resultVector[i];
CivPatterns::PatternTable pTable;
pTable.name = map.find(fields[0])->second;
pTable.val = map.find(fields[1])->second;
patterns.addItem(pTable);
}
return true; return true;
} }
bool CivInpHelperAbs::getCurves(CivCurves& curves) bool CivInpHelperAbs::getCurves(CivCurves& curves)
{ {
CivCurveTableTemp::CurveTable curveTable;
std::vector<std::string> fields = {
curveTable.CurveName,
curveTable.CurveType,
curveTable.CurveData
};
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PATTERNTABLE, fields, resultVector);
size_t totals = resultVector.size();
for (int i = 0; i < totals; i++)
{
CivCurves::CurvesTable cTable;
std::map<std::string, std::string> map = resultVector[i];
cTable.ID = map.find(fields[0])->second;
cTable.XCoord = map.find(fields[1])->second;
cTable.YCoord = map.find(fields[2])->second;
curves.addItem(cTable);
}
return true; return true;
} }
...@@ -366,25 +94,6 @@ bool CivInpHelperAbs::getStatus(CivStatus& status) ...@@ -366,25 +94,6 @@ bool CivInpHelperAbs::getStatus(CivStatus& status)
bool CivInpHelperAbs::getQuality(CivQuality& quality) bool CivInpHelperAbs::getQuality(CivQuality& quality)
{ {
CivJunctionTableTemp::JunctionTable nodeTable;
std::vector<std::string> fields = { nodeTable.thePoint,nodeTable.initQuality };
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PIPENODE, fields, resultVector);
size_t totals = resultVector.size();
for (int i = 0; i < totals; i++)
{
CivQuality::QualityTable quliTable;
std::map<std::string, std::string> map = resultVector[i];
quliTable.ID = map.find(fields[0])->second;
quliTable.InitQuality = map.find(fields[1])->second;;
quality.addItem(quliTable);
}
return true; return true;
} }
......
...@@ -4,12 +4,11 @@ ...@@ -4,12 +4,11 @@
class CivConnection; class CivConnection;
/** /**
תinpݿ תinpݿ
*/ */
class CivInpHelperAbs class CivInpHelperAbs
{ {
public: public:
explicit CivInpHelperAbs(CivConnection* dbConn); explicit CivInpHelperAbs(CivConnection* dbConn);
virtual ~CivInpHelperAbs(); virtual ~CivInpHelperAbs();
......
...@@ -317,7 +317,7 @@ bool CivPgConn::getPipe(CivPipe& pipe) ...@@ -317,7 +317,7 @@ bool CivPgConn::getPipe(CivPipe& pipe)
sql.append(","); sql.append(",");
sql.append(pipeTable.status); sql.append(pipeTable.status);
sql.append(" from "); sql.append(" from ");
sql.append(PIPELINE) sql.append(PIPELINE);
std::string utf8Sql = TransUTFCoding(sql); std::string utf8Sql = TransUTFCoding(sql);
if (!execSql(utf8Sql)) if (!execSql(utf8Sql))
...@@ -469,7 +469,6 @@ bool CivPgConn::getPumps(CivPumps& pump) ...@@ -469,7 +469,6 @@ bool CivPgConn::getPumps(CivPumps& pump)
std::string utf8Sql = TransUTFCoding(sql); std::string utf8Sql = TransUTFCoding(sql);
if (!execSql(utf8Sql)) if (!execSql(utf8Sql))
{ {
/* CivSysLog::getInstance()->error(mLastError, "CivPgConn", __FUNCTION__);*/
return false; return false;
} }
...@@ -491,11 +490,11 @@ bool CivPgConn::getPumps(CivPumps& pump) ...@@ -491,11 +490,11 @@ bool CivPgConn::getPumps(CivPumps& pump)
bool CivPgConn::getReservoirs(CivReservoirs& reservoirs) bool CivPgConn::getReservoirs(CivReservoirs& reservoirs)
{ {
CivResourcesTableTemp::ResourcesTable restemTable; ResourcesTable restemTable;
//;ID Head Pattern //;ID Head Pattern
std::string sql = "select "; std::string sql = "select ";
sql.append(restemTable.thePoint); sql.append(restemTable.sn);
sql.append(","); sql.append(",");
sql.append(restemTable.head); sql.append(restemTable.head);
sql.append(","); sql.append(",");
...@@ -566,7 +565,6 @@ bool CivPgConn::getCoordinates(CivCoordinates& coord) ...@@ -566,7 +565,6 @@ bool CivPgConn::getCoordinates(CivCoordinates& coord)
if (!execSql(sql)) if (!execSql(sql))
{ {
CivSysLog::getInstance()->error(mLastError, "CivPgConn", __FUNCTION__);
return false; return false;
} }
...@@ -867,88 +865,4 @@ bool CivPgConn::getValuesFromTableByCondition( ...@@ -867,88 +865,4 @@ bool CivPgConn::getValuesFromTableByCondition(
PQclear(mResult); PQclear(mResult);
return true; return true;
} }
\ No newline at end of file
void CivPgConn::checkHyDrNetTable()
{
// 创建曲线表
CivCurveTableTemp temp;
if (!tableExist(temp.name()))
{
createTable(temp);
}
// 参数表
CivParametorTableTemp paraTemp;
if (!tableExist(paraTemp.name()))
{
createTable(paraTemp);
}
// 模式表
CivPatternTableTemp patternTemp;
if (!tableExist(patternTemp.name()))
{
createTable(patternTemp);
}
// 结果点表
CivNodeResultTableTemp nodeTemp;
if (!tableExist(nodeTemp.name()))
{
createTable(nodeTemp);
}
// 结果线表
CivPipeResultTableTemp pipeTemp;
if (!tableExist(pipeTemp.name()))
{
createTable(pipeTemp);
}
// 方案电表
CivProjNodeTableTemp projeNodeTemp;
if (!tableExist(projeNodeTemp.name()))
{
createTable(projeNodeTemp);
}
//方案线表
CivProjPipeTableTemp projPipeTemp;
if (!tableExist(projPipeTemp.name()))
{
createTable(projPipeTemp);
}
// 方案表
CivProjTableTemp projTemp;
if (!tableExist(projTemp.name()))
{
createTable(projTemp);
}
// 监测点压力
CivMonitorPressureTableTemp pressureTemp;
if (!tableExist(pressureTemp.name()))
{
createTable(pressureTemp);
}
// 监测点流量
CivMonitorFlowTableTemp flowTemp;
if (!tableExist(flowTemp.name()))
{
createTable(flowTemp);
}
// 监测点水质表
CivMonitorQualityTableTemp qualityTemp;
if (!tableExist(qualityTemp.name()))
{
createTable(qualityTemp);
}
}
...@@ -53,14 +53,6 @@ public: ...@@ -53,14 +53,6 @@ public:
bool getLabels(CivLabels& labels) override; bool getLabels(CivLabels& labels) override;
bool getTags(CivTags& tags) override; bool getTags(CivTags& tags) override;
/**
*@brief 创建表格
*@param tableName: 表名
*@param schema:
*@param tableType:表类型,点结果,线结果
*/
bool createTable(CivTableTemp& temp) override;
/** /**
*@brief 根据字段值条件删除数据 *@brief 根据字段值条件删除数据
*@param table:表 *@param table:表
...@@ -90,8 +82,6 @@ public: ...@@ -90,8 +82,6 @@ public:
const std::string& condition, const std::string& condition,
const std::vector<std::string>& fileds, const std::vector<std::string>& fileds,
std::vector< std::map<std::string, std::string>>& result) override; std::vector< std::map<std::string, std::string>>& result) override;
void checkHyDrNetTable() override;
private: private:
PGconn* mConn; // 连接对象 PGconn* mConn; // 连接对象
......
#include "CivTableTemp.h"
#include "CivDbConn.h"
CivTableTemp::CivTableTemp()
{
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_INT, "int"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_INTEGER,"integer"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_DOUBLE, "double precision"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_VARCHAR, "varchar(32)"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_VARCHAR64, "varchar(64)"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_VARCHAR128, "varchar(128)"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_VARCHAR256,"varchar(256)"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_BOOLEAN, "boolean"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_CHARACTER_VARYING,"character varying"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_DATETIME, "timestamp"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_JSON, "json"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_DATE, "date"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_GEOM_POINT,"geometry(Point,4326)"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_GEOM_LINE, "geometry(MultiLineString,4326)"));
}
CivTableTemp::~CivTableTemp()
{
}
void CivTableTemp::addProperty(Str fileName, FieldType filedType)
{
FieldProperty prop = { fileName ,mFieldTyepMap.find(filedType)->second};
mPropertys.push_back(prop);
}
Str CivTableTemp::createSql()
{
if (mPropertys.size() <= 0)
return Str();
std::string sql = "create table ";
sql.append(mTableName);
sql.append("(id serial primary key");
size_t total = mPropertys.size();
for (int i = 0; i < total; i++)
{
FieldProperty property = mPropertys[i];
sql.append(",");
sql.append("\""+property.mFiledName+"\"");
sql.append(" ");
sql.append(property.mFieldType);
}
sql.append(")");
return sql;
}
bool CivTableTemp::updateToDb(CivDbConn* dbConn)
{
if (dbConn == nullptr)
return false;
Str sql = createSql();
return true;
}
CivJunctionTableTemp::CivJunctionTableTemp(Str tableName)
{
setName(PIPENODE);
TableFileds fileds;
addProperty(fileds.ID ,CivTableTemp::FILED_VARCHAR);// "id";
addProperty(fileds.geom ,CivTableTemp::FILED_VARCHAR);// "geom";
addProperty(fileds.thePoint ,CivTableTemp::FILED_VARCHAR);// "本点号";
addProperty(fileds.xCoord ,CivTableTemp::FILED_VARCHAR);// "横坐标";
addProperty(fileds.yCoord ,CivTableTemp::FILED_VARCHAR);// "纵坐标";
addProperty(fileds.elev ,CivTableTemp::FILED_VARCHAR);// "高程";
addProperty(fileds.demand ,CivTableTemp::FILED_VARCHAR);// "需水量";
addProperty(fileds.pattern ,CivTableTemp::FILED_VARCHAR);// "需水量模式";
addProperty(fileds.head ,CivTableTemp::FILED_VARCHAR);// "总水头";
addProperty(fileds.freeHead ,CivTableTemp::FILED_VARCHAR);// "自由水头";
addProperty(fileds.actualDemand ,CivTableTemp::FILED_VARCHAR);// "实际需水量";
addProperty(fileds.code ,CivTableTemp::FILED_VARCHAR);// "code";
addProperty(fileds.createUser ,CivTableTemp::FILED_VARCHAR);// "create_user";
addProperty(fileds.modifyUser ,CivTableTemp::FILED_VARCHAR);// "modify_user";
addProperty(fileds.createTime ,CivTableTemp::FILED_VARCHAR);// "create_time";
addProperty(fileds. modifyTime ,CivTableTemp::FILED_VARCHAR);// "modify_time";
addProperty(fileds.symbolAngle ,CivTableTemp::FILED_VARCHAR);// "symbol_angle";
addProperty(fileds.compType ,CivTableTemp::FILED_VARCHAR);// "组分类型";
addProperty(fileds.pressure ,CivTableTemp::FILED_VARCHAR);// "压力";
addProperty(fileds.quality ,CivTableTemp::FILED_VARCHAR);// "水质";
};
/**
管线表模板
*/
CivPipeTableTemp::CivPipeTableTemp() :CivTableTemp()
{
setName(PIPELINE);
TableFileds fileds;
addProperty(fileds.ID ,CivTableTemp::FILED_VARCHAR);// "id";
addProperty(fileds.geom ,CivTableTemp::FILED_VARCHAR);// "geom";
addProperty(fileds.snNo ,CivTableTemp::FILED_VARCHAR);// "编号";
addProperty(fileds.thePoint ,CivTableTemp::FILED_VARCHAR);// "上点号";
addProperty(fileds.lastPoint ,CivTableTemp::FILED_VARCHAR);// "本点号";
addProperty(fileds.length ,CivTableTemp::FILED_VARCHAR);// "管长";
addProperty(fileds.material ,CivTableTemp::FILED_VARCHAR);// "管材";
addProperty(fileds.diameter ,CivTableTemp::FILED_VARCHAR);// "管径";
addProperty(fileds.friction ,CivTableTemp::FILED_VARCHAR);// "摩阻系数";
addProperty(fileds.localLoss ,CivTableTemp::FILED_VARCHAR);// "局部损失系";
addProperty(fileds.initStatus ,CivTableTemp::FILED_VARCHAR);// "初始状态";
addProperty(fileds.buryingTime ,CivTableTemp::FILED_VARCHAR);// "埋设时间";
addProperty(fileds.flow ,CivTableTemp::FILED_VARCHAR);// "流量";
addProperty(fileds.velocity ,CivTableTemp::FILED_VARCHAR);// "流速";
addProperty(fileds.unitHeadLoss ,CivTableTemp::FILED_VARCHAR);// "单位水头损";
addProperty(fileds.headLoss ,CivTableTemp::FILED_VARCHAR);// "水头总损失";
addProperty(fileds.unitPressLoss ,CivTableTemp::FILED_VARCHAR);// "单位压力损";
addProperty(fileds.pressLoss ,CivTableTemp::FILED_VARCHAR);// "压力总损失";
addProperty(fileds.lastHead ,CivTableTemp::FILED_VARCHAR);// "上点水头";
addProperty(fileds.theHead ,CivTableTemp::FILED_VARCHAR);// "本点水头";
addProperty(fileds.lastPress ,CivTableTemp::FILED_VARCHAR);// "上点压力";
addProperty(fileds.thePress ,CivTableTemp::FILED_VARCHAR);// "本点压力";
addProperty(fileds.localHeadLoss ,CivTableTemp::FILED_VARCHAR);// "局部水头损";
addProperty(fileds.fracHeadLoss ,CivTableTemp::FILED_VARCHAR);// "摩擦水头损";
addProperty(fileds.status ,CivTableTemp::FILED_VARCHAR);// "状态";
addProperty(fileds.guid ,CivTableTemp::FILED_VARCHAR);// "guid";
addProperty(fileds.code ,CivTableTemp::FILED_VARCHAR);// "code";
addProperty(fileds.fromCode ,CivTableTemp::FILED_VARCHAR);// "from_code";
addProperty(fileds.fromLayer ,CivTableTemp::FILED_VARCHAR);// "from_layer";
addProperty(fileds.toCode ,CivTableTemp::FILED_VARCHAR);// "to_code";
addProperty(fileds.toLayer ,CivTableTemp::FILED_VARCHAR);// "to_layer";
addProperty(fileds.createUser ,CivTableTemp::FILED_VARCHAR);// "create_user";
addProperty(fileds.modifyUser ,CivTableTemp::FILED_VARCHAR);// "modify_user";
addProperty(fileds.createTime ,CivTableTemp::FILED_VARCHAR);// "create_time";
addProperty(fileds.modifyTime ,CivTableTemp::FILED_VARCHAR);// "modify_time";
addProperty(fileds.remarks ,CivTableTemp::FILED_VARCHAR);// "备注";
addProperty(fileds.quality ,CivTableTemp::FILED_VARCHAR);// "水质";
}
/**
水泵
*/
CivPumpTableTemp::CivPumpTableTemp() :CivTableTemp()
{
setName(PUMP);
TableFileds fileds;
addProperty(fileds.ID, CivTableTemp::FILED_VARCHAR);// "id";
addProperty(fileds.geom, CivTableTemp::FILED_VARCHAR);// "geom";
addProperty(fileds.thePoint, CivTableTemp::FILED_VARCHAR);// "本点号";
addProperty(fileds.xCoord, CivTableTemp::FILED_VARCHAR);// "横坐标";
addProperty(fileds.yCoord, CivTableTemp::FILED_VARCHAR);// "纵坐标";
addProperty(fileds.startPoint, CivTableTemp::FILED_VARCHAR);// "起始节点";
addProperty(fileds.endPoint, CivTableTemp::FILED_VARCHAR);// "终止节点";
addProperty(fileds.curve, CivTableTemp::FILED_VARCHAR);// "水泵曲线";
addProperty(fileds.ratio, CivTableTemp::FILED_VARCHAR);// "转速比";
addProperty(fileds.flow, CivTableTemp::FILED_VARCHAR);// "流量";
addProperty(fileds.headCurve, CivTableTemp::FILED_VARCHAR);// "扬程曲线";
addProperty(fileds.status, CivTableTemp::FILED_VARCHAR);// "状态";
addProperty(fileds.code, CivTableTemp::FILED_VARCHAR);// "code";
addProperty(fileds.createUser, CivTableTemp::FILED_VARCHAR);// "create_user";
addProperty(fileds.modifyUser, CivTableTemp::FILED_VARCHAR);// "modify_user";
addProperty(fileds.createTime, CivTableTemp::FILED_VARCHAR);// "create_time";
addProperty(fileds.modifyTime, CivTableTemp::FILED_VARCHAR);// "modify_time";
addProperty(fileds.SymbolAngle, CivTableTemp::FILED_VARCHAR);// "symbol_angle";
addProperty(fileds.compType, CivTableTemp::FILED_VARCHAR);// "组分类型";
addProperty(fileds.power, CivTableTemp::FILED_VARCHAR);// "功率";
}
/**
水池
*/
CivTankTableTemp::CivTankTableTemp() :CivTableTemp()
{
setName(TANK);
TableFileds fileds;
addProperty(fileds.ID ,CivTableTemp::FILED_VARCHAR);// "id";
addProperty(fileds.geom ,CivTableTemp::FILED_VARCHAR);// "geom";
addProperty(fileds.thePoint ,CivTableTemp::FILED_VARCHAR);// "本点号";
addProperty(fileds.xCoord ,CivTableTemp::FILED_VARCHAR);// "横坐标";
addProperty(fileds.yCoord ,CivTableTemp::FILED_VARCHAR);// "纵坐标";
addProperty(fileds.elev ,CivTableTemp::FILED_VARCHAR);// "高程";
addProperty(fileds.diametor ,CivTableTemp::FILED_VARCHAR);// "直径";
addProperty(fileds.baseLevel ,CivTableTemp::FILED_VARCHAR);// "基础水位";
addProperty(fileds.initLevel ,CivTableTemp::FILED_VARCHAR);// "初始水位";
addProperty(fileds.highLevel ,CivTableTemp::FILED_VARCHAR);// "最高水位";
addProperty(fileds.lowLevel ,CivTableTemp::FILED_VARCHAR);// "最低水位";
addProperty(fileds.flowIn ,CivTableTemp::FILED_VARCHAR);// "输入流量";
addProperty(fileds.flowOut ,CivTableTemp::FILED_VARCHAR);// "输出流量";
addProperty(fileds.leveHeight ,CivTableTemp::FILED_VARCHAR);// "液位高度";
addProperty(fileds.capacity ,CivTableTemp::FILED_VARCHAR);// "容量";
addProperty(fileds.percentage ,CivTableTemp::FILED_VARCHAR);// "装满水池百";
addProperty(fileds.status ,CivTableTemp::FILED_VARCHAR);// "状态";
addProperty(fileds.code ,CivTableTemp::FILED_VARCHAR);// "code";
addProperty(fileds.createUser ,CivTableTemp::FILED_VARCHAR);// "create_user";
addProperty(fileds.modifyUser ,CivTableTemp::FILED_VARCHAR);// "modify_user";
addProperty(fileds.createTime ,CivTableTemp::FILED_VARCHAR);// "create_time";
addProperty(fileds.modifyTime ,CivTableTemp::FILED_VARCHAR);// "modify_time";
addProperty(fileds.SymbolAngle ,CivTableTemp::FILED_VARCHAR);// "symbol_angle";
addProperty(fileds.compType ,CivTableTemp::FILED_VARCHAR);// "组分类型";
}
/**
水库
*/
CivResourcesTableTemp::CivResourcesTableTemp() :CivTableTemp()
{
setName(RESIVOIR);
TableFileds fileds;
addProperty(fileds.ID ,CivTableTemp::FILED_VARCHAR);// "id";
addProperty(fileds.geom ,CivTableTemp::FILED_VARCHAR);// "geom";
addProperty(fileds.thePoint ,CivTableTemp::FILED_VARCHAR);// "本点号";
addProperty(fileds.xCoord ,CivTableTemp::FILED_VARCHAR);// "横坐标";
addProperty(fileds.yCoord ,CivTableTemp::FILED_VARCHAR);// "纵坐标";
addProperty(fileds.headPattern ,CivTableTemp::FILED_VARCHAR);// "水头模式曲";
addProperty(fileds.elev ,CivTableTemp::FILED_VARCHAR);// "高程";
addProperty(fileds.head ,CivTableTemp::FILED_VARCHAR);// "水头";
addProperty(fileds.flow ,CivTableTemp::FILED_VARCHAR);// "流出流量";
addProperty(fileds.code ,CivTableTemp::FILED_VARCHAR);// "code";
addProperty(fileds.createUser ,CivTableTemp::FILED_VARCHAR);// "create_user";
addProperty(fileds.modifyUser ,CivTableTemp::FILED_VARCHAR);// "modify_user";
addProperty(fileds.createTime ,CivTableTemp::FILED_VARCHAR);// "create_time";
addProperty(fileds.modifyTime ,CivTableTemp::FILED_VARCHAR);// "modify_time";
addProperty(fileds.SymbolAngle ,CivTableTemp::FILED_VARCHAR);// "symbol_angle";
addProperty(fileds.compType ,CivTableTemp::FILED_VARCHAR);// "组分类型";
}
/**
阀门
*/
CivValveTableTemp::CivValveTableTemp() :CivTableTemp()
{
setName(VALVE);
TableFileds fileds;
addProperty(fileds.id ,CivTableTemp::FILED_VARCHAR);// "本点号";
addProperty(fileds.geom ,CivTableTemp::FILED_VARCHAR);// "geom";
addProperty(fileds.xCoord ,CivTableTemp::FILED_VARCHAR);// "横坐标";
addProperty(fileds.yCoord ,CivTableTemp::FILED_VARCHAR);// "纵坐标";
addProperty(fileds.startPoint ,CivTableTemp::FILED_VARCHAR);// "起始节点";
addProperty(fileds.endPoint ,CivTableTemp::FILED_VARCHAR);// "终止节点";
addProperty(fileds.diameter ,CivTableTemp::FILED_VARCHAR);// "直径";
addProperty(fileds.status ,CivTableTemp::FILED_VARCHAR);// "状态";
addProperty(fileds.type ,CivTableTemp::FILED_VARCHAR);// "阀门类型";
addProperty(fileds.setting ,CivTableTemp::FILED_VARCHAR);// "阀门设置";
addProperty(fileds.loss ,CivTableTemp::FILED_VARCHAR);// "损失系数";
addProperty(fileds.flow ,CivTableTemp::FILED_VARCHAR);// "流量 ";
addProperty(fileds.veclocity ,CivTableTemp::FILED_VARCHAR);// "流速";
addProperty(fileds.headLoss ,CivTableTemp::FILED_VARCHAR);// "水头损失";
addProperty(fileds.code ,CivTableTemp::FILED_VARCHAR);// "code";
addProperty(fileds.createUser ,CivTableTemp::FILED_VARCHAR);// "create_user";
addProperty(fileds.modityUser ,CivTableTemp::FILED_VARCHAR);// "modify_user";
addProperty(fileds.createTime ,CivTableTemp::FILED_VARCHAR);// "create_time";
addProperty(fileds.modifyTime ,CivTableTemp::FILED_VARCHAR);// "modify_time";
addProperty(fileds.symbolAngle ,CivTableTemp::FILED_VARCHAR);// "symbol_angle";
addProperty(fileds.compType ,CivTableTemp::FILED_VARCHAR);// "组分类型";
}
/**
节点模拟结果存储表
*/
CivNodeResultTableTemp::CivNodeResultTableTemp() :CivTableTemp()
{
setName(NODERESULTTABLE);
NodeResultTable nodeTable;
addProperty(nodeTable.Number, CivTableTemp::FILED_VARCHAR);
addProperty(nodeTable.dPressure, CivTableTemp::FILED_DOUBLE);
addProperty(nodeTable.dHead, CivTableTemp::FILED_DOUBLE);
addProperty(nodeTable.dElevation, CivTableTemp::FILED_DOUBLE);
addProperty(nodeTable.dDemand, CivTableTemp::FILED_DOUBLE);
addProperty(nodeTable.dTankVolume, CivTableTemp::FILED_DOUBLE);
addProperty(nodeTable.dTankMaxVolume, CivTableTemp::FILED_DOUBLE);
addProperty(nodeTable.dTankLevel, CivTableTemp::FILED_DOUBLE);
addProperty(nodeTable.dQuality, CivTableTemp::FILED_DOUBLE);
addProperty(nodeTable.dDate, CivTableTemp::FILED_DATE);
addProperty(nodeTable.dInterval, CivTableTemp::FILED_INT);
addProperty(nodeTable.dModifyTime, CivTableTemp::FILED_DATETIME);
}
/**
模拟结果线表
*/
CivPipeResultTableTemp::CivPipeResultTableTemp() :CivTableTemp()
{
setName(PIPERESULTTABLE);
TableField pipeFileds;
addProperty(pipeFileds.szNo, CivTableTemp::FILED_VARCHAR);
addProperty(pipeFileds.dFlow, CivTableTemp::FILED_DOUBLE);
addProperty(pipeFileds.nFlowDirect, CivTableTemp::FILED_INT);
addProperty(pipeFileds.dVelocity, CivTableTemp::FILED_DOUBLE);
addProperty(pipeFileds.dHeadloss, CivTableTemp::FILED_DOUBLE);
addProperty(pipeFileds.dUnitHeadloss, CivTableTemp::FILED_DOUBLE);
addProperty(pipeFileds.dFromNodHeadloss, CivTableTemp::FILED_DOUBLE);
addProperty(pipeFileds.dToNodHeadloss, CivTableTemp::FILED_DOUBLE);
addProperty(pipeFileds.dLocalHeadloss, CivTableTemp::FILED_DOUBLE);
addProperty(pipeFileds.dFrictionHeadloss, CivTableTemp::FILED_DOUBLE);
addProperty(pipeFileds.szStatus, CivTableTemp::FILED_VARCHAR);
addProperty(pipeFileds.dQuality, CivTableTemp::FILED_DOUBLE);
addProperty(pipeFileds.dDate, CivTableTemp::FILED_DATE);
addProperty(pipeFileds.dInterval, CivTableTemp::FILED_INT);
addProperty(pipeFileds.dModifyTime, CivTableTemp::FILED_DATETIME);
}
/**
模式表
*/
CivPatternTableTemp::CivPatternTableTemp() :CivTableTemp()
{
setName(PATTERNTABLE);
TableField fileds;
addProperty(fileds.modelName, CivTableTemp::FILED_VARCHAR);
addProperty(fileds.modelData, CivTableTemp::FILED_VARCHAR64);
addProperty(fileds.modelType, CivTableTemp::FILED_INTEGER);
}
/**
参数表
*/
CivParametorTableTemp::CivParametorTableTemp() :CivTableTemp()
{
setName(OPTIONTTABLE);
TableField fileds;
addProperty(fileds.name, CivTableTemp::FILED_VARCHAR);
addProperty(fileds.val, CivTableTemp::FILED_VARCHAR);
addProperty(fileds.type, CivTableTemp::FILED_VARCHAR);
addProperty(fileds.netName, CivTableTemp::FILED_VARCHAR64);
}
/**
曲线表
*/
CivCurveTableTemp::CivCurveTableTemp() :CivTableTemp()
{
setName(CURVETABLE);
TableField fileds;
addProperty(fileds.CurveName, CivTableTemp::FILED_VARCHAR64);
addProperty(fileds.CurveType, CivTableTemp::FILED_INTEGER);
addProperty(fileds.CurveData, CivTableTemp::FILED_VARCHAR256);
}
/**
方案点表
*/
CivProjNodeTableTemp::CivProjNodeTableTemp() :CivTableTemp()
{
setName(PROJNODETABLE);
TableField fileds;
addProperty(fileds.ProjCode, CivTableTemp::FILED_VARCHAR64);
addProperty(fileds.ProjType, CivTableTemp::FILED_INT);
addProperty(fileds.ProjGeom, CivTableTemp::FILED_GEOM_POINT);
addProperty(fileds.ProjSn, CivTableTemp::FILED_VARCHAR64);
addProperty(fileds.ProjXcoord, CivTableTemp::FILED_DOUBLE);
addProperty(fileds.ProjYcoord, CivTableTemp::FILED_DOUBLE);
addProperty(fileds.ProjDesc, CivTableTemp::FILED_CHARACTER_VARYING);
addProperty(fileds.ProjLabel, CivTableTemp::FILED_VARCHAR64);
addProperty(fileds.ProElev, CivTableTemp::FILED_DOUBLE);
addProperty(fileds.ProjBaseDemand, CivTableTemp::FILED_DOUBLE);
addProperty(fileds.ProjPattern, CivTableTemp::FILED_VARCHAR64);
addProperty(fileds.ProjDemandType, CivTableTemp::FILED_VARCHAR64);
addProperty(fileds.ProjDiffuserCoeff, CivTableTemp::FILED_DOUBLE);
addProperty(fileds.ProjInitQuality, CivTableTemp::FILED_DOUBLE);
addProperty(fileds.ProjSourceQuality, CivTableTemp::FILED_DOUBLE);
addProperty(fileds.ProjDmaID, CivTableTemp::FILED_VARCHAR64);
addProperty(fileds.ProjDemand, CivTableTemp::FILED_DOUBLE);
addProperty(fileds.ProjConsumption, CivTableTemp::FILED_DOUBLE);
addProperty(fileds.ProjLackWater, CivTableTemp::FILED_DOUBLE);
addProperty(fileds.ProjLackWaterPer, CivTableTemp::FILED_DOUBLE);
addProperty(fileds.ProjTotalWater, CivTableTemp::FILED_DOUBLE);
addProperty(fileds.ProjTotalHead, CivTableTemp::FILED_DOUBLE);
addProperty(fileds.ProjPressure, CivTableTemp::FILED_DOUBLE);
addProperty(fileds.ProjQuality, CivTableTemp::FILED_DOUBLE);
}
/**
方案线表
*/
CivProjPipeTableTemp::CivProjPipeTableTemp() : CivTableTemp()
{
setName(PROJPIPETABLE);
TableField fileds;
addProperty(fileds.ProjCode , CivTableTemp::FILED_VARCHAR64);// "方案名";
addProperty(fileds.ProjType , CivTableTemp::FILED_BOOLEAN);// "修改类型";
addProperty(fileds.ProjGeom , CivTableTemp::FILED_GEOM_LINE);// "Geom";
addProperty(fileds.ProjSn , CivTableTemp::FILED_VARCHAR64);// "编号";
addProperty(fileds.ProjStartID , CivTableTemp::FILED_VARCHAR64);// "起始节点";
addProperty(fileds.ProjEndID , CivTableTemp::FILED_VARCHAR64);// "终止节点";
addProperty(fileds.ProjDesc , CivTableTemp::FILED_CHARACTER_VARYING);// "描述";
addProperty(fileds.ProjLabel , CivTableTemp::FILED_VARCHAR64);// "标签";
addProperty(fileds.ProjLength , CivTableTemp::FILED_DOUBLE);// "管长";
addProperty(fileds.ProjDiameter , CivTableTemp::FILED_DOUBLE);// "管径";
addProperty(fileds.ProjMaterial , CivTableTemp::FILED_VARCHAR64);// "管材";
addProperty(fileds.ProjFractionCoeff , CivTableTemp::FILED_DOUBLE);// "摩阻系数";
addProperty(fileds.ProjLoclLossCoeff , CivTableTemp::FILED_DOUBLE);// "局损系数";
addProperty(fileds.ProjInitStatus , CivTableTemp::FILED_VARCHAR64);// "初始状态";
addProperty(fileds.ProjMainstreamCoeff , CivTableTemp::FILED_DOUBLE);// "主流系数";
addProperty(fileds.ProjWallCoeff , CivTableTemp::FILED_DOUBLE);// "管壁系数";
addProperty(fileds.ProjLeakageCoeff1 , CivTableTemp::FILED_DOUBLE);// "漏水系数1";
addProperty(fileds.ProLeakageCoeff2 , CivTableTemp::FILED_DOUBLE);// "漏水系数2";
addProperty(fileds.ProjDmaID , CivTableTemp::FILED_VARCHAR64);// "DMAID";
addProperty(fileds.ProjFlow , CivTableTemp::FILED_DOUBLE);// "流量";
addProperty(fileds.ProjVelocity , CivTableTemp::FILED_DOUBLE);// "流速";
addProperty(fileds.ProjUnitLoss , CivTableTemp::FILED_DOUBLE);// "单位水损";
addProperty(fileds.ProjStatus , CivTableTemp::FILED_DOUBLE);// "状态";
addProperty(fileds.ProjQuality , CivTableTemp::FILED_DOUBLE);// "水质";
addProperty(fileds.ProjWaterLeakage , CivTableTemp::FILED_DOUBLE);// "漏水量";
}
/**
方案表
*/
CivProjTableTemp::CivProjTableTemp() : CivTableTemp()
{
setName(PROJTABLE);
TableField fileds;
addProperty(fileds.ProjName , CivTableTemp::FILED_VARCHAR64);// "方案名";
addProperty(fileds.ProjCode , CivTableTemp::FILED_VARCHAR64);// "方案编号";
addProperty(fileds.ProjType , CivTableTemp::FILED_VARCHAR64);// "方案类型";
addProperty(fileds.ProjCreator , CivTableTemp::FILED_VARCHAR64);// "创建人";
addProperty(fileds.ProjAddTime , CivTableTemp::FILED_DATETIME);// "创建时间";
addProperty(fileds.ProjUpdateTime , CivTableTemp::FILED_DATETIME);// "更新时间";
addProperty(fileds.ProjTime , CivTableTemp::FILED_DATETIME);// "方案时间";
addProperty(fileds.ProjScore , CivTableTemp::FILED_VARCHAR64);// "评分";
addProperty(fileds.ProDescribe , CivTableTemp::FILED_VARCHAR64);// "评价";
addProperty(fileds.ProjEvaluate , CivTableTemp::FILED_VARCHAR64);// "评估";
addProperty(fileds.ProjDemand , CivTableTemp::FILED_DOUBLE);// "水量调整";
addProperty(fileds.ProjWorkCode , CivTableTemp::FILED_VARCHAR64);// "作业编号";
addProperty(fileds.ProjDetection , CivTableTemp::FILED_VARCHAR64);// "关注检测点";
}
/**
压力监测表
*/
CivMonitorPressureTableTemp::CivMonitorPressureTableTemp() : CivTableTemp()
{
setName(PRESSURETABLE);
TableField fileds;
addProperty(fileds.MonitorScard, CivTableTemp::FILED_VARCHAR64);// "SCADAID";
addProperty(fileds.MonitorXCoord, CivTableTemp::FILED_DOUBLE);// "横坐标";
addProperty(fileds.MonitorYCoord, CivTableTemp::FILED_DOUBLE);// "纵坐标 ";
addProperty(fileds.MonitorDesc, CivTableTemp::FILED_CHARACTER_VARYING);// "描述";
addProperty(fileds.MonitorLabel, CivTableTemp::FILED_VARCHAR64);// "标签";
addProperty(fileds.MonitorNode, CivTableTemp::FILED_VARCHAR64);// "节点ID ";
addProperty(fileds.MonitorMonitor, CivTableTemp::FILED_DOUBLE);// "检测值 ";
addProperty(fileds.MonitorCalc, CivTableTemp::FILED_DOUBLE);// "计算值 ";
addProperty(fileds.MonitorError, CivTableTemp::FILED_DOUBLE);// "误差";
addProperty(fileds.MonitorMonitorAverage, CivTableTemp::FILED_DOUBLE);// "检测平均值";
addProperty(fileds.MonitorCalcAverage, CivTableTemp::FILED_DOUBLE);// "计算平均值";
addProperty(fileds.MonitorErrorAverage, CivTableTemp::FILED_DOUBLE);// "平均误差 ";
addProperty(fileds.MonitorAbsErrirAverage, CivTableTemp::FILED_DOUBLE);// "平均绝对误差";
addProperty(fileds.MonitorSquareError, CivTableTemp::FILED_DOUBLE);// "均方根误差";
addProperty(fileds.MonitorErrorFlu, CivTableTemp::FILED_DOUBLE);// "误差波动";
addProperty(fileds.MonitorNashCoeff, CivTableTemp::FILED_DOUBLE);// "纳什系数";
addProperty(fileds.MonitorScore, CivTableTemp::FILED_DOUBLE);// "分数";
addProperty(fileds.MonitorReliability, CivTableTemp::FILED_VARCHAR64);// "可靠度";
}
/*
流量监测表
*/
CivMonitorFlowTableTemp::CivMonitorFlowTableTemp() : CivTableTemp()
{
setName(FLOWTABLE);
TableField fileds;
addProperty(fileds.MonitorScard, CivTableTemp::FILED_VARCHAR64);// "SCADAID";
addProperty(fileds.MonitorXCoord, CivTableTemp::FILED_DOUBLE);// "横坐标";
addProperty(fileds.MonitorYCoord, CivTableTemp::FILED_DOUBLE);// "纵坐标 ";
addProperty(fileds.MonitorDesc, CivTableTemp::FILED_VARCHAR64);// "描述";
addProperty(fileds.MonitorLabel, CivTableTemp::FILED_VARCHAR64);// "标签";
addProperty(fileds.MonitorPipe, CivTableTemp::FILED_VARCHAR64);// "节点ID";
addProperty(fileds.MonitorMonitor, CivTableTemp::FILED_DOUBLE);// "检测值 ";
addProperty(fileds.MonitorCalc, CivTableTemp::FILED_DOUBLE);// "计算值 ";
addProperty(fileds.MonitorError, CivTableTemp::FILED_DOUBLE);// "误差";
addProperty(fileds.MonitorMonitorAverage, CivTableTemp::FILED_DOUBLE);// "检测平均值";
addProperty(fileds.MonitorCalcAverage, CivTableTemp::FILED_DOUBLE);// "计算平均值";
addProperty(fileds.MonitorErrorAverage, CivTableTemp::FILED_DOUBLE);// "平均误差 ";
addProperty(fileds.MonitorAbsErrirAverage, CivTableTemp::FILED_DOUBLE);// "平均绝对误差";
addProperty(fileds.MonitorSquareError, CivTableTemp::FILED_DOUBLE);// "均方根误差";
addProperty(fileds.MonitorErrorFlu, CivTableTemp::FILED_DOUBLE);// "误差波动";
addProperty(fileds.MonitorNashCoeff, CivTableTemp::FILED_DOUBLE);// "纳什系数";
addProperty(fileds.MonitorScore, CivTableTemp::FILED_DOUBLE);// "分数";
addProperty(fileds.MonitorReliability, CivTableTemp::FILED_VARCHAR64);// "可靠度";
}
/*
水质检测表
*/
CivMonitorQualityTableTemp::CivMonitorQualityTableTemp() : CivTableTemp()
{
setName(QUALITYTABLE);
TableField fileds;
addProperty(fileds.MonitorScard, CivTableTemp::FILED_VARCHAR64);// "SCADAID";
addProperty(fileds.MonitorXCoord, CivTableTemp::FILED_DOUBLE);// "横坐标";
addProperty(fileds.MonitorYCoord, CivTableTemp::FILED_DOUBLE);// "纵坐标 ";
addProperty(fileds.MonitorDesc, CivTableTemp::FILED_CHARACTER_VARYING);// "描述";
addProperty(fileds.MonitorLabel, CivTableTemp::FILED_VARCHAR64);// "标签";
addProperty(fileds.MonitorNode, CivTableTemp::FILED_VARCHAR64);// "节点ID ";
addProperty(fileds.MonitorMonitor, CivTableTemp::FILED_DOUBLE); // "检测值 ";
addProperty(fileds.MonitorCalc, CivTableTemp::FILED_DOUBLE); // "计算值 ";
addProperty(fileds.MonitorError, CivTableTemp::FILED_DOUBLE); // "误差";
addProperty(fileds.MonitorMonitorAverage, CivTableTemp::FILED_DOUBLE); // "检测平均值";
addProperty(fileds.MonitorCalcAverage, CivTableTemp::FILED_DOUBLE); // "计算平均值";
addProperty(fileds.MonitorErrorAverage, CivTableTemp::FILED_DOUBLE); // "平均误差 ";
addProperty(fileds.MonitorAbsErrirAverage, CivTableTemp::FILED_DOUBLE); // "平均绝对误差";
addProperty(fileds.MonitorSquareError, CivTableTemp::FILED_DOUBLE); // "均方根误差";
addProperty(fileds.MonitorErrorFlu, CivTableTemp::FILED_DOUBLE); // "误差波动";
addProperty(fileds.MonitorNashCoeff, CivTableTemp::FILED_DOUBLE); // "纳什系数";
addProperty(fileds.MonitorScore, CivTableTemp::FILED_DOUBLE); // "分数";
addProperty(fileds.MonitorReliability, CivTableTemp::FILED_VARCHAR64); // "可靠度";
}
...@@ -7,593 +7,395 @@ ...@@ -7,593 +7,395 @@
#include "CivTypes.h" #include "CivTypes.h"
struct FieldProperty
{
std::string mFiledName; //字段名
std::string mFieldType; // 字段类型
};
#define FiledPropertys std::vector<FieldProperty>
class CivDbConn;
/**
* 数据库表模板
*/
class CivTableTemp
{
public:
// 字段类型
enum FieldType {
FILED_INT,
FILED_INTEGER,
FILED_DOUBLE,
FILED_VARCHAR,
FILED_VARCHAR64,
FILED_VARCHAR128,
FILED_VARCHAR256,
FILED_BOOLEAN,
FILED_CHARACTER_VARYING,
FILED_DATETIME,
FILED_JSON,
FILED_DATE,
FILED_GEOM_POINT,
FILED_GEOM_LINE
};
explicit CivTableTemp();
~CivTableTemp();
// 返回创建表的sql语句
Str createSql();
/*
* @brief 表名
*/
Str name() const { return mTableName; }
void setName(StrQuote name) { mTableName = name; }
/**
*@brief 添加字段属性
*@fileName:字段名
*@filedType:字段类型
*/
void addProperty(std::string fileName, FieldType filedType);
/**
*@brief 数据库创建模板表
*@dbConn: 数据库连接对象
*/
bool updateToDb(CivDbConn* dbConn);
protected:
Str mTableName; // 表名
FiledPropertys mPropertys; // 字段和字段属性
std::map< FieldType, Str> mFieldTyepMap;
};
/** /**
节点表模板 节点表模板
*/ */
class CivJunctionTableTemp :public CivTableTemp typedef struct JunctionTableFileds
{ {
public: Str sn = "本点号";
// 字段名 Str xCoord = "横坐标";
typedef struct TableFileds Str yCoord = "纵坐标";
{ Str desc = "描述";
Str ID = "id"; Str label = "标签";
Str geom = "geom"; Str elev = "高程";
Str thePoint = "本点号"; Str baseDemand = "基本需水量";
Str xCoord = "横坐标"; Str demandPattern = "需水量模式";
Str yCoord = "纵坐标"; Str demandType = "需水量类型";
Str elev = "高程"; Str emiterCoffe = "扩散器系数";
Str demand = "需水量"; Str initQuality = "初始水质";
Str pattern = "需水量模式"; Str sourceQuality = "源头水质";
Str head = "总水头"; Str dmaId = "DMAID";
Str freeHead = "自由水头"; Str demand = "实际需水量";
Str actualDemand = "实际需水量"; Str waterConsump = "用水量";
Str code = "code"; Str waterShortage = "用水缺额";
Str createUser = "create_user"; Str waterShortageP = "用水缺额(%)";
Str modifyUser = "modify_user"; Str totalWater = "总水量";
Str createTime = "create_time"; Str totalHead = "总水头";
Str modifyTime = "modify_time"; Str pressure = "压力";
Str symbolAngle = "symbol_angle"; Str quality = "水质";
Str compType = "组分类型"; }JunctionTable;
Str pressure = "压力";
Str quality = "水质";
Str initQuality = "初始水质";
}JunctionTable;
explicit CivJunctionTableTemp(Str tableName);
};
/** /**
管线表模板 管线表模板
*/ */
class CivPipeTableTemp :public CivTableTemp typedef struct PipeTableFields
{ {
public: Str snNo = "编号";
// 字段名 Str startPoint = "起始节点";
typedef struct TableFileds Str endPoint = "终止节点";
{ Str des = "描述";
Str ID = "id"; Str label = "标签";
Str geom = "geom"; Str length = "管长";
Str snNo = "编号"; Str material = "管材";
Str thePoint = "本点号"; Str diameter = "管径";
Str lastPoint = "上点号"; Str friction = "摩阻系数";
Str length = "管长"; Str localLoss = "局损系数";
Str material = "管材"; Str initStatus = "初始状态";
Str diameter = "管径"; Str mainCoffe = "主流系数";
Str friction = "摩阻系数"; Str pipeCoffe = "管壁系数";
Str localLoss = "局部损失系"; Str leakCoffe1 = "漏水系数1";
Str initStatus = "初始状态"; Str leakCoffe2 = "漏水系数2";
Str buryingTime = "埋设时间"; Str dmaID = "DMAID";
Str flow = "流量"; Str flow = "流量";
Str velocity = "流速"; Str velocity = "流速";
Str unitHeadLoss = "单位水头损"; Str unitHeadLoss = "单位水损";
Str headLoss = "水头总损失"; Str status = "状态";
Str unitPressLoss = "单位压力损"; Str quality = "水质";
Str pressLoss = "压力总损失"; Str leakWater = "漏水量";
Str lastHead = "上点水头"; }PipeTable;
Str theHead = "本点水头";
Str lastPress = "上点压力";
Str thePress = "本点压力";
Str localHeadLoss = "局部水头损";
Str fracHeadLoss = "摩擦水头损";
Str status = "状态";
Str guid = "guid";
Str code = "code";
Str fromCode = "from_code";
Str fromLayer = "from_layer";
Str toCode = "to_code";
Str toLayer = "to_layer";
Str createUser = "create_user";
Str modifyUser = "modify_user";
Str createTime = "create_time";
Str modifyTime = "modify_time";
Str remarks = "备注";
Str quality = "水质";
}PipeTable;
explicit CivPipeTableTemp();
};
/** /**
水泵 水泵
*/ */
class CivPumpTableTemp :public CivTableTemp
{
public:
typedef struct TableFileds
{
Str ID = "id";
Str geom = "geom";
Str thePoint = "本点号";
Str xCoord = "横坐标";
Str yCoord = "纵坐标";
Str startPoint = "起始节点";
Str endPoint = "终止节点";
Str curve = "水泵曲线";
Str ratio = "转速比";
Str flow = "流量";
Str headCurve = "扬程曲线";
Str status = "状态";
Str code = "code";
Str createUser = "create_user";
Str modifyUser = "modify_user";
Str createTime = "create_time";
Str modifyTime = "modify_time";
Str SymbolAngle = "symbol_angle";
Str compType = "组分类型";
Str power = "功率";
} PumpTable;
explicit CivPumpTableTemp();
};
typedef struct PumpTableFileds
{
Str startPoint = "起始节点";
Str endPoint = "终止节点";
Str sn = "本点号";
Str desc = "描述";
Str label = "标签";
Str headCurve = "水泵曲线";
Str power = "功率";
Str ratio = "转速比";
Str pattern = "模式";
Str initStatus = "初始状态";
Str efficCurve = "效率曲线";
Str powerPrice = "能量价格";
Str pricePattern = "价格模式";
Str flow = "流量";
Str headLoss = "水损";
Str quality = "水质";
Str status = "状态";
} PumpTable;
/** /**
水池 水池
*/ */
class CivTankTableTemp :public CivTableTemp typedef struct TankTableFileds
{ {
public: Str sn = "本点号";
typedef struct TableFileds Str xCoord = "横坐标";
{ Str yCoord = "纵坐标";
Str ID = "id"; Str desc = "描述";
Str geom = "geom"; Str label = "标签";
Str thePoint = "本点号"; Str elev = "高程";
Str xCoord = "横坐标"; Str initLevel = "初始水位";
Str yCoord = "纵坐标"; Str minLevel = "最低水位";
Str elev = "高程"; Str maxLevel = "最高水位";
Str diametor = "直径"; Str diametor = "直径";
Str baseLevel = "基础水位"; Str minVolume = "最小容积";
Str initLevel= "初始水位"; Str volumeCurve = "容积曲线";
Str highLevel = "最高水位"; Str mixedCore = "混合分数";
Str lowLevel = "最低水位"; Str mixedPattern = "混合模式";
Str flowIn = "输入流量"; Str reaCoffe = "反应系数";
Str flowOut = "输出流量"; Str initQuality = "初始水质";
Str leveHeight = "液位高度"; Str sourceQuality = "源头水质";
Str capacity = "容量"; Str flow = "流量";
Str volCurve = "容积曲线"; Str totalHead = "总水头";
Str percentage = "装满水池百"; Str currLevel = "当前水位";
Str status = "状态"; Str quality = "水质";
Str code = "code";
Str createUser = "create_user"; }TankTable;
Str modifyUser = "modify_user";
Str createTime = "create_time";
Str modifyTime = "modify_time";
Str SymbolAngle = "symbol_angle";
Str compType = "组分类型";
}TankTable;
explicit CivTankTableTemp();
};
/** /**
水库 水库
*/ */
class CivResourcesTableTemp :public CivTableTemp typedef struct ResourcesTableFileds
{ {
public: Str sn = "本点号";
typedef struct TableFileds Str xCoord = "横坐标";
{ Str yCoord = "纵坐标";
Str ID = "id"; Str headPattern = "水头模式";
Str geom = "geom"; Str initQuality = "初始水质";
Str thePoint = "本点号"; Str sourceQuality = "源头水质";
Str xCoord = "横坐标"; Str elev = "高程";
Str yCoord = "纵坐标"; Str label = "标签";
Str headPattern = "水头模式曲"; Str desc = "描述";
Str elev = "高程"; Str flow = "流量";
Str head = "水头"; Str totalHead = "总水头";
Str flow = "流出流量"; Str quality = "水质";
Str code = "code"; }ResourcesTable;
Str createUser = "create_user";
Str modifyUser = "modify_user";
Str createTime = "create_time";
Str modifyTime = "modify_time";
Str SymbolAngle = "symbol_angle";
Str compType = "组分类型";
}ResourcesTable;
explicit CivResourcesTableTemp();
};
/** /**
阀门 阀门
*/ */
class CivValveTableTemp :public CivTableTemp typedef struct ValveTableFileds
{ {
public: Str sn = "本点号";
typedef struct TableFileds Str startPoint = "起始节点";
{ Str endPoint = "终止节点";
Str id = "本点号"; Str length = "直径";
Str geom = "geom"; Str type = "类型";
Str xCoord = "横坐标"; Str setting = "设置";
Str yCoord = "纵坐标"; Str lossCoeff = "水损系数";
Str startPoint = "起始节点"; Str fixedState = "固定状态";
Str endPoint = "终止节点"; Str flow = "流量";
Str diameter = "直径"; Str velocity = "流速";
Str status = "状态"; Str headLoss = "水头损失";
Str type = "阀门类型"; Str quality = "水质";
Str setting = "阀门设置"; Str state = "状态";
Str loss = "损失系数"; }ValveTable;
Str flow = "流量 ";
Str veclocity = "流速";
Str headLoss = "水头损失";
Str code= "code";
Str createUser= "create_user" ;
Str modityUser = "modify_user";
Str createTime= "create_time";
Str modifyTime = "modify_time" ;
Str symbolAngle= "symbol_angle";
Str compType = "组分类型";
}ValveTable;
explicit CivValveTableTemp();
};
/** /**
节点模拟结果存储表 节点模拟结果存储表
*/ */
class CivNodeResultTableTemp :public CivTableTemp
typedef struct NodeResultTableField
{ {
public: Str Number = "本点号";
typedef struct TableField Str dHead = "水头";
{ Str dPressure = "压力";
Str Number = "本点号"; Str dElevation = "标高";
Str dHead = "水头"; Str dDemand = "实际需水量";
Str dPressure = "压力"; Str dTankVolume = "水池容量";
Str dElevation = "标高"; Str dTankMaxVolume = "水池最大容量";
Str dDemand = "实际需水量"; Str dTankLevel = "液位高度";
Str dTankVolume = "水池容量"; Str dQuality = "水质";
Str dTankMaxVolume = "水池最大容量"; Str dDate = "日期";
Str dTankLevel = "液位高度"; Str dInterval = "时段";
Str dQuality = "水质"; Str dModifyTime = "修改时间";
Str dDate = "日期"; } NodeResultTable;
Str dInterval = "时段";
Str dModifyTime = "修改时间";
} NodeResultTable;
explicit CivNodeResultTableTemp();
};
/** /**
模拟结果线表 模拟结果线表
*/ */
class CivPipeResultTableTemp :public CivTableTemp
typedef struct PipeResultTableField
{ {
public: Str szNo = "编号";
typedef struct TableField Str dFlow = "流量";
{ Str nFlowDirect = "流向";
Str szNo = "编号"; Str dVelocity = "流速";
Str dFlow = "流量"; Str dHeadloss = "水头损失";
Str nFlowDirect = "流向"; Str dUnitHeadloss = "单位水头损";
Str dVelocity = "流速"; Str dFromNodHeadloss = "上点水头";
Str dHeadloss = "水头损失"; Str dToNodHeadloss = "本点水头";
Str dUnitHeadloss = "单位水头损"; Str dLocalHeadloss = "局部水头损";
Str dFromNodHeadloss = "上点水头"; Str dFrictionHeadloss = "摩擦水头损";
Str dToNodHeadloss = "本点水头"; Str szStatus = "状态";
Str dLocalHeadloss = "局部水头损"; Str dQuality = "水质";
Str dFrictionHeadloss = "摩擦水头损"; Str dDate = "日期";
Str szStatus = "状态"; Str dInterval = "时段";
Str dQuality = "水质"; Str dModifyTime = "修改时间";
Str dDate = "日期"; }PipeResultTable;
Str dInterval = "时段";
Str dModifyTime = "修改时间";
}PipeResultTable;
explicit CivPipeResultTableTemp();
};
/** /**
模式表 模式表
*/ */
class CivPatternTableTemp :public CivTableTemp
typedef struct PatternTableField
{ {
public: Str modelName = "模式名";
typedef struct TableField Str modelType = "类型";
{ Str modelData = "模式值";
Str modelName = "model_name"; } PatternTable;
Str modelType = "model_type";
Str modelData = "model_data";
} PatternTable;
enum PatternType
{
PATTERN_DEMAND,// 需水量模式
PATTERN_PRESS// 压力模式
};
explicit CivPatternTableTemp();
};
/** /**
参数表 参数表
*/ */
class CivParametorTableTemp :public CivTableTemp typedef struct ParametorTableField
{ {
public: Str name = "参数名";
typedef struct TableField Str val = "参数值";
{ Str type = "类型";
Str name = "参数名"; }ParametorTable;
Str val = "参数值";
Str type = "参数类型";
Str netName = "管网名";
}ParametorTable;
explicit CivParametorTableTemp();
};
/** /**
曲线表 曲线表
*/ */
class CivCurveTableTemp :public CivTableTemp typedef struct CurveTableField
{ {
public: Str CurveName = "曲线名";
typedef struct TableField Str CurveType = "类型";
{ Str CurveData = "曲线值";
Str CurveName = "curve_name"; }CurveTable;
Str CurveType = "curve_type";
Str CurveData = "curve_data";
}CurveTable;
// 曲线类型
enum CurveType
{
CURVE_ELEV,// 水泵扬程与流量
CURVE_EFFIC,//水泵效率与流量
CURVE_VOLUME,// 水池容积与水深
CURVE_HEADLOSS //常规阀门的水头损失与流量
};
explicit CivCurveTableTemp();
};
/** /**
方案点表 方案点表
*/ */
class CivProjNodeTableTemp :public CivTableTemp typedef struct ProjNodeTableField
{ {
public: Str ProjCode = "方案编号";
typedef struct TableField Str ProjType = "修改类型";
{ Str ProjSn = "本点号";
Str ProjCode = "方案编号"; Str ProjXcoord = "横坐标";
Str ProjType = "修改类型"; Str ProjYcoord = "纵坐标 ";
Str ProjGeom = "geom"; Str ProjDesc = "描述";
Str ProjSn = "本点号"; Str ProjLabel = "标签";
Str ProjXcoord = "横坐标"; Str ProElev = "高程";
Str ProjYcoord = "纵坐标 "; Str ProjBaseDemand = "基本需水量";
Str ProjDesc = "描述"; Str ProjPattern = "需水量模式";
Str ProjLabel = "标签"; Str ProjDemandType = "需水量类型";
Str ProElev = "高程"; Str ProjDiffuserCoeff = "扩散器系数";
Str ProjBaseDemand = "基本需水量"; Str ProjInitQuality = "初始水质 ";
Str ProjPattern = "需水量模式"; Str ProjSourceQuality = "源头水质 ";
Str ProjDemandType = "需水量类型"; Str ProjDmaID = "DMAID";
Str ProjDiffuserCoeff = "扩散器系数"; Str ProjDemand = "实际需水量";
Str ProjInitQuality = "初始水质 "; Str ProjConsumption = "用水量";
Str ProjSourceQuality = "源头水质 "; Str ProjLackWater = "用水缺额";
Str ProjDmaID = "DMAID"; Str ProjLackWaterPer = "用水缺额(%)";
Str ProjDemand = "实际需水量"; Str ProjTotalWater = "总水量";
Str ProjConsumption = "用水量"; Str ProjTotalHead = "总水头";
Str ProjLackWater = "用水缺额"; Str ProjPressure = "压力";
Str ProjLackWaterPer = "用水缺额(%)"; Str ProjQuality = "水质";
Str ProjTotalWater = "总水量";
Str ProjTotalHead = "总水头"; }ProjNodeTable;
Str ProjPressure = "压力";
Str ProjQuality = "水质";
}ProjNodeTable;
explicit CivProjNodeTableTemp();
};
/** /**
方案线表 方案线表
*/ */
class CivProjPipeTableTemp :public CivTableTemp
typedef struct ProjPipeTableField
{ {
public: Str ProjCode = "方案名";
typedef struct TableField Str ProjType = "修改类型";
{ Str ProjSn = "编号";
Str ProjCode = "方案名"; Str ProjStartID = "起始节点";
Str ProjType = "修改类型"; Str ProjEndID = "终止节点";
Str ProjGeom = "Geom"; Str ProjDesc = "描述";
Str ProjSn = "编号"; Str ProjLabel= "标签";
Str ProjStartID = "起始节点"; Str ProjLength = "管长";
Str ProjEndID = "终止节点"; Str ProjDiameter = "管径";
Str ProjDesc = "描述"; Str ProjMaterial = "管材";
Str ProjLabel= "标签"; Str ProjFractionCoeff = "摩阻系数";
Str ProjLength = "管长"; Str ProjLoclLossCoeff = "局损系数";
Str ProjDiameter = "管径"; Str ProjInitStatus = "初始状态";
Str ProjMaterial = "管材"; Str ProjMainstreamCoeff = "主流系数";
Str ProjFractionCoeff = "摩阻系数"; Str ProjWallCoeff = "管壁系数";
Str ProjLoclLossCoeff = "局损系数"; Str ProjLeakageCoeff1 = "漏水系数1";
Str ProjInitStatus = "初始状态"; Str ProLeakageCoeff2 = "漏水系数2";
Str ProjMainstreamCoeff = "主流系数"; Str ProjDmaID = "DMAID";
Str ProjWallCoeff = "管壁系数"; Str ProjFlow = "流量";
Str ProjLeakageCoeff1 = "漏水系数1"; Str ProjVelocity = "流速";
Str ProLeakageCoeff2 = "漏水系数2"; Str ProjUnitLoss = "单位水损";
Str ProjDmaID = "DMAID"; Str ProjStatus = "状态";
Str ProjFlow = "流量"; Str ProjQuality = "水质";
Str ProjVelocity = "流速"; Str ProjWaterLeakage = "漏水量";
Str ProjUnitLoss = "单位水损"; }ProjPipeTable;
Str ProjStatus = "状态";
Str ProjQuality = "水质";
Str ProjWaterLeakage = "漏水量";
}ProjPipeTable;
explicit CivProjPipeTableTemp();
};
/** /**
方案表 方案表
*/ */
class CivProjTableTemp :public CivTableTemp
typedef struct ProjTableField
{ {
public: Str ProjName = "方案名";
typedef struct TableField Str ProjCode = "方案编号";
{ Str ProjType = "方案类型";
Str ProjName = "方案名"; Str ProjCreator = "创建人";
Str ProjCode = "方案编号"; Str ProjAddTime = "创建时间";
Str ProjType = "方案类型"; Str ProjUpdateTime = "更新时间";
Str ProjCreator = "创建人"; Str ProjTime = "方案时间";
Str ProjAddTime = "创建时间"; Str ProjScore = "评分";
Str ProjUpdateTime = "更新时间"; Str ProDescribe = "评价";
Str ProjTime = "方案时间"; Str ProjEvaluate = "评估";
Str ProjScore = "评分"; Str ProjDemand = "水量调整";
Str ProDescribe = "评价"; Str ProjWorkCode = "作业编号";
Str ProjEvaluate = "评估"; Str ProjDetection = "关注检测点";
Str ProjDemand = "水量调整"; }ProjTable;
Str ProjWorkCode = "作业编号";
Str ProjDetection = "关注检测点";
}ProjTable;
explicit CivProjTableTemp();
};
/** /**
检测压力表 检测压力表
*/ */
class CivMonitorPressureTableTemp :public CivTableTemp typedef struct MonitorPressureTableField
{ {
public: Str MonitorScard = "SCADAID";
typedef struct TableField Str MonitorXCoord = "横坐标";
{ Str MonitorYCoord = "纵坐标 ";
Str MonitorScard = "SCADAID"; Str MonitorDesc = "描述";
Str MonitorXCoord = "横坐标"; Str MonitorLabel = "标签";
Str MonitorYCoord = "纵坐标 "; Str MonitorNode = "节点ID ";
Str MonitorDesc = "描述"; Str MonitorMonitor = "检测值 ";
Str MonitorLabel = "标签"; Str MonitorCalc = "计算值 ";
Str MonitorNode = "节点ID "; Str MonitorError = "误差";
Str MonitorMonitor = "检测值 "; Str MonitorMonitorAverage = "检测平均值";
Str MonitorCalc = "计算值 "; Str MonitorCalcAverage = "计算平均值";
Str MonitorError = "误差"; Str MonitorErrorAverage = "平均误差 ";
Str MonitorMonitorAverage = "检测平均值"; Str MonitorAbsErrirAverage = "平均绝对误差";
Str MonitorCalcAverage = "计算平均值"; Str MonitorSquareError = "均方根误差";
Str MonitorErrorAverage = "平均误差 "; Str MonitorErrorFlu = "误差波动";
Str MonitorAbsErrirAverage = "平均绝对误差"; Str MonitorNashCoeff = "纳什系数";
Str MonitorSquareError = "均方根误差"; Str MonitorScore = "分数";
Str MonitorErrorFlu = "误差波动"; Str MonitorReliability = "可靠度";
Str MonitorNashCoeff = "纳什系数";
Str MonitorScore = "分数"; }MonitorPressureTable;
Str MonitorReliability = "可靠度";
}MonitorPressureTable;
explicit CivMonitorPressureTableTemp();
};
/** /**
检测流量表 检测流量表
*/ */
class CivMonitorFlowTableTemp :public CivTableTemp typedef struct MonitorFlowTableField
{ {
public: Str MonitorScard = "SCADAID";
typedef struct TableField Str MonitorXCoord = "横坐标";
{ Str MonitorYCoord = "纵坐标 ";
Str MonitorScard = "SCADAID"; Str MonitorDesc = "描述";
Str MonitorXCoord = "横坐标"; Str MonitorLabel = "标签";
Str MonitorYCoord = "纵坐标 "; Str MonitorPipe= "管段ID ";
Str MonitorDesc = "描述"; Str MonitorMonitor = "检测值 ";
Str MonitorLabel = "标签"; Str MonitorCalc = "计算值 ";
Str MonitorPipe= "管段ID "; Str MonitorError = "误差";
Str MonitorMonitor = "检测值 "; Str MonitorMonitorAverage = "检测平均值";
Str MonitorCalc = "计算值 "; Str MonitorCalcAverage = "计算平均值";
Str MonitorError = "误差"; Str MonitorErrorAverage = "平均误差 ";
Str MonitorMonitorAverage = "检测平均值"; Str MonitorAbsErrirAverage = "平均绝对误差";
Str MonitorCalcAverage = "计算平均值"; Str MonitorSquareError = "均方根误差";
Str MonitorErrorAverage = "平均误差 "; Str MonitorErrorFlu = "误差波动";
Str MonitorAbsErrirAverage = "平均绝对误差"; Str MonitorNashCoeff = "纳什系数";
Str MonitorSquareError = "均方根误差"; Str MonitorScore = "分数";
Str MonitorErrorFlu = "误差波动"; Str MonitorReliability = "可靠度";
Str MonitorNashCoeff = "纳什系数"; }MonitorFlowTable;
Str MonitorScore = "分数";
Str MonitorReliability = "可靠度"; typedef struct MonitorQualityTableField
}MonitorFlowTable;
explicit CivMonitorFlowTableTemp();
};
/**
检测水质表
*/
class CivMonitorQualityTableTemp :public CivTableTemp
{ {
public: Str MonitorScard = "SCADAID";
typedef struct TableField Str MonitorXCoord = "横坐标";
{ Str MonitorYCoord = "纵坐标 ";
Str MonitorScard = "SCADAID"; Str MonitorDesc = "描述";
Str MonitorXCoord = "横坐标"; Str MonitorLabel = "标签";
Str MonitorYCoord = "纵坐标 "; Str MonitorNode = "节点ID ";
Str MonitorDesc = "描述"; Str MonitorMonitor = "检测值 ";
Str MonitorLabel = "标签"; Str MonitorCalc = "计算值 ";
Str MonitorNode = "节点ID "; Str MonitorError = "误差";
Str MonitorMonitor = "检测值 "; Str MonitorMonitorAverage = "检测平均值";
Str MonitorCalc = "计算值 "; Str MonitorCalcAverage = "计算平均值";
Str MonitorError = "误差"; Str MonitorErrorAverage = "平均误差 ";
Str MonitorMonitorAverage = "检测平均值"; Str MonitorAbsErrirAverage = "平均绝对误差";
Str MonitorCalcAverage = "计算平均值"; Str MonitorSquareError = "均方根误差";
Str MonitorErrorAverage = "平均误差 "; Str MonitorErrorFlu = "误差波动";
Str MonitorAbsErrirAverage = "平均绝对误差"; Str MonitorNashCoeff = "纳什系数";
Str MonitorSquareError = "均方根误差"; Str MonitorScore = "分数";
Str MonitorErrorFlu = "误差波动"; Str MonitorReliability = "可靠度";
Str MonitorNashCoeff = "纳什系数"; }MonitorQualityTable;
Str MonitorScore = "分数";
Str MonitorReliability = "可靠度";
}MonitorQualityTable;
explicit CivMonitorQualityTableTemp();
};
#endif // !CIVTABLETEMP_H #endif // !CIVTABLETEMP_H
......
#include "CivTrackingResultCache.h" #include "CivTrackingResultCache.h"
#include "CivPgConn.h" #include "CivConnection.h"
void CivTrackingResultCache::cacheInfoFromDb(CivDbConn* dbConn) void CivTrackingResultCache::cacheInfoFromDb(CivConnection* dbConn)
{ {
if (dbConn == nullptr) if (dbConn == nullptr)
return; return;
...@@ -54,7 +54,7 @@ void CivTrackingResultCache::transformToJsonStr(std::string jsonStr) ...@@ -54,7 +54,7 @@ void CivTrackingResultCache::transformToJsonStr(std::string jsonStr)
jsonStr.append("}"); jsonStr.append("}");
} }
void CivTrackingResultCache::cacheJunctionInfoFromDb(CivDbConn* dbConn) void CivTrackingResultCache::cacheJunctionInfoFromDb(CivConnection* dbConn)
{ {
if (dbConn == nullptr) if (dbConn == nullptr)
return; return;
...@@ -66,10 +66,10 @@ void CivTrackingResultCache::cacheJunctionInfoFromDb(CivDbConn* dbConn) ...@@ -66,10 +66,10 @@ void CivTrackingResultCache::cacheJunctionInfoFromDb(CivDbConn* dbConn)
fileds.push_back("ST_X(geom) as xCoord"); fileds.push_back("ST_X(geom) as xCoord");
fileds.push_back("ST_Y(geom) as yCoord"); fileds.push_back("ST_Y(geom) as yCoord");
if (!dbConn->getFieldValueFromTable(PIPENODE, fileds, nodeResult)) /*if (!dbConn->getFieldValueFromTable(PIPENODE, fileds, nodeResult))
{ {
return; return;
} }*/
// 缓存节点数据 // 缓存节点数据
int rows = nodeResult.size(); int rows = nodeResult.size();
...@@ -90,7 +90,7 @@ void CivTrackingResultCache::cacheJunctionInfoFromDb(CivDbConn* dbConn) ...@@ -90,7 +90,7 @@ void CivTrackingResultCache::cacheJunctionInfoFromDb(CivDbConn* dbConn)
} }
void CivTrackingResultCache::cachePipeInfoFromDb(CivDbConn* dbConn) void CivTrackingResultCache::cachePipeInfoFromDb(CivConnection* dbConn)
{ {
if (dbConn == nullptr) if (dbConn == nullptr)
return; return;
...@@ -104,10 +104,10 @@ void CivTrackingResultCache::cachePipeInfoFromDb(CivDbConn* dbConn) ...@@ -104,10 +104,10 @@ void CivTrackingResultCache::cachePipeInfoFromDb(CivDbConn* dbConn)
fileds.push_back("ST_X(ST_EndPoint(ST_GeometryN(geom, 1))) as endX"); fileds.push_back("ST_X(ST_EndPoint(ST_GeometryN(geom, 1))) as endX");
fileds.push_back("ST_Y(ST_EndPoint(ST_GeometryN(geom, 1))) as endY"); fileds.push_back("ST_Y(ST_EndPoint(ST_GeometryN(geom, 1))) as endY");
if (!dbConn->getFieldValueFromTable(PIPELINE,fileds, pipeResult)) /*if (!dbConn->getFieldValueFromTable(PIPELINE,fileds, pipeResult))
{ {
return; return;
} }*/
// 缓存节点数据 // 缓存节点数据
int rows = pipeResult.size(); int rows = pipeResult.size();
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
class CivDbConn; class CivConnection;
#define CACHEEXPORT __declspec(dllexport) #define CACHEEXPORT __declspec(dllexport)
// 节点 // 节点
...@@ -34,7 +34,7 @@ public: ...@@ -34,7 +34,7 @@ public:
*@brief 缓存数据库的信息 *@brief 缓存数据库的信息
*@param dbConn 数据库连接 *@param dbConn 数据库连接
*/ */
void cacheInfoFromDb(CivDbConn* dbConn); void cacheInfoFromDb(CivConnection* dbConn);
/** /**
*@brief 缓存信息转json字符串 *@brief 缓存信息转json字符串
...@@ -61,13 +61,13 @@ private: ...@@ -61,13 +61,13 @@ private:
*@brief 缓存数据库的节点数据 *@brief 缓存数据库的节点数据
*@param dbConn 数据库连接 *@param dbConn 数据库连接
*/ */
void cacheJunctionInfoFromDb(CivDbConn* dbConn); void cacheJunctionInfoFromDb(CivConnection* dbConn);
/** /**
*@brief 缓存数据管段信息 *@brief 缓存数据管段信息
*@param dbConn *@param dbConn
*/ */
void cachePipeInfoFromDb(CivDbConn* dbConn); void cachePipeInfoFromDb(CivConnection* dbConn);
private: private:
std::map<std::string, Junctions> mNodeCache; // 节点信息缓存 std::map<std::string, Junctions> mNodeCache; // 节点信息缓存
......
...@@ -150,9 +150,7 @@ ...@@ -150,9 +150,7 @@
</Link> </Link>
<PostBuildEvent> <PostBuildEvent>
<Command>copy CivTypes.h $(OutDir)..\include /y <Command>copy CivTypes.h $(OutDir)..\include /y
copy CivPgConn.h $(OutDir)..\include /y
copy CivAssembly.h $(OutDir)..\include /y copy CivAssembly.h $(OutDir)..\include /y
copy CivDbConn.h $(OutDir)..\include /y
</Command> </Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
...@@ -160,12 +158,8 @@ copy CivDbConn.h $(OutDir)..\include /y ...@@ -160,12 +158,8 @@ copy CivDbConn.h $(OutDir)..\include /y
<ClInclude Include="CivAssembly.h" /> <ClInclude Include="CivAssembly.h" />
<ClInclude Include="CivCommonUtils.h" /> <ClInclude Include="CivCommonUtils.h" />
<ClInclude Include="CivConnection.h" /> <ClInclude Include="CivConnection.h" />
<ClInclude Include="CivDbConn.h" />
<ClInclude Include="CivDbUtils.h" />
<ClInclude Include="CivInpDbHelper.h" /> <ClInclude Include="CivInpDbHelper.h" />
<ClInclude Include="CivInpHelperAbs.h" /> <ClInclude Include="CivInpHelperAbs.h" />
<ClInclude Include="CivMaintainModel.h" />
<ClInclude Include="CivPgConn.h" />
<ClInclude Include="CivPgDbConnection.h" /> <ClInclude Include="CivPgDbConnection.h" />
<ClInclude Include="CivProjInpDbHelper.h" /> <ClInclude Include="CivProjInpDbHelper.h" />
<ClInclude Include="CivSimuResDbHelper.h" /> <ClInclude Include="CivSimuResDbHelper.h" />
...@@ -177,16 +171,11 @@ copy CivDbConn.h $(OutDir)..\include /y ...@@ -177,16 +171,11 @@ copy CivDbConn.h $(OutDir)..\include /y
<ClCompile Include="CivAssembly.cpp" /> <ClCompile Include="CivAssembly.cpp" />
<ClCompile Include="CivCommonUtils.cpp" /> <ClCompile Include="CivCommonUtils.cpp" />
<ClCompile Include="CivConnection.cpp" /> <ClCompile Include="CivConnection.cpp" />
<ClCompile Include="CivDbConn.cpp" />
<ClCompile Include="CivDbUtils.cpp" />
<ClCompile Include="CivInpDbHelper.cpp" /> <ClCompile Include="CivInpDbHelper.cpp" />
<ClCompile Include="CivInpHelperAbs.cpp" /> <ClCompile Include="CivInpHelperAbs.cpp" />
<ClCompile Include="CivMaintainModel.cpp" />
<ClCompile Include="CivPgConn.cpp" />
<ClCompile Include="CivPgDbConnection.cpp" /> <ClCompile Include="CivPgDbConnection.cpp" />
<ClCompile Include="CivProjInpDbHelper.cpp" /> <ClCompile Include="CivProjInpDbHelper.cpp" />
<ClCompile Include="CivSimuResDbHelper.cpp" /> <ClCompile Include="CivSimuResDbHelper.cpp" />
<ClCompile Include="CivTableTemp.cpp" />
<ClCompile Include="CivTrackingResultCache.cpp" /> <ClCompile Include="CivTrackingResultCache.cpp" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
......
...@@ -24,12 +24,6 @@ ...@@ -24,12 +24,6 @@
<ClInclude Include="CivCommonUtils.h"> <ClInclude Include="CivCommonUtils.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="CivDbConn.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivPgConn.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivAssembly.h"> <ClInclude Include="CivAssembly.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
...@@ -39,9 +33,6 @@ ...@@ -39,9 +33,6 @@
<ClInclude Include="CivConnection.h"> <ClInclude Include="CivConnection.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="CivMaintainModel.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivPgDbConnection.h"> <ClInclude Include="CivPgDbConnection.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
...@@ -57,23 +48,11 @@ ...@@ -57,23 +48,11 @@
<ClInclude Include="CivSimuResDbHelper.h"> <ClInclude Include="CivSimuResDbHelper.h">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="CivDbUtils.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="CivTableTemp.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivCommonUtils.cpp"> <ClCompile Include="CivCommonUtils.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="CivDbConn.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivPgConn.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivAssembly.cpp"> <ClCompile Include="CivAssembly.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
...@@ -83,9 +62,6 @@ ...@@ -83,9 +62,6 @@
<ClCompile Include="CivConnection.cpp"> <ClCompile Include="CivConnection.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="CivMaintainModel.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivPgDbConnection.cpp"> <ClCompile Include="CivPgDbConnection.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
...@@ -101,8 +77,5 @@ ...@@ -101,8 +77,5 @@
<ClCompile Include="CivSimuResDbHelper.cpp"> <ClCompile Include="CivSimuResDbHelper.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="CivDbUtils.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
#include "CivCsvReader.h"
CivCsvReader::CivCsvReader(const char* path)
{
_csvInput.open(path);
}
void CivCsvReader::readOnLoad()
{
string line;
// ȡͷ
int index = 0;
while (getline(_csvInput, line))
{
istringstream sin(line);
vector<string> fields;
string field;
while (getline(sin, field, ','))
{
if (index == 0)
mHeaders.push_back(field);
else
fields.push_back(field);
}
if (index > 0)
mVecVec.push_back(fields);
index++;
}
}
vector<string> CivCsvReader::getHeaders()
{
return mHeaders;
}
void CivCsvReader::readByColumn(int column, vector<string>& vec)
{
for (int i = 0; i < mVecVec.size(); i++)
{
vector<string> temp =mVecVec[i];
if (column > temp.size())
return;
vec.push_back(temp[column]);
}
}
void CivCsvReader::readByRow(int row, vector<string>& vec)
{
if (mVecVec.size() < row)
return;
vec = mVecVec[row];
}
int CivCsvReader::getRows()
{
return mVecVec.size();
}
int CivCsvReader::getColumns()
{
if (mVecVec.size() <= 0)
return 0;
return mVecVec[0].size();
}
#pragma once
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#define CSVEXPORT __declspec(dllexport)
using namespace std;
class CSVEXPORT CivCsvReader
{
public:
explicit CivCsvReader(const char*);
void readOnLoad();
void readByColumn(int column, vector<string>& vec);
void readByRow(int row, vector<string>& vec);
// ȡ
int getRows();
// ȡ
int getColumns();
vector<string> getHeaders();
private:
ifstream _csvInput;
vector<vector<string>> mVecVec;
vector<string> mHeaders;
};
...@@ -141,13 +141,16 @@ ...@@ -141,13 +141,16 @@
<ImportLibrary>$(OutDir)..\lib\$(TargetName).lib</ImportLibrary> <ImportLibrary>$(OutDir)..\lib\$(TargetName).lib</ImportLibrary>
</Link> </Link>
<PostBuildEvent> <PostBuildEvent>
<Command>copy CivSysLog.h $(OutDir)..\include /y</Command> <Command>copy CivSysLog.h $(OutDir)..\include /y
copy CivCsvReader.h $(OutDir)..\include /y</Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="CivCsvReader.h" />
<ClInclude Include="CivSysLog.h" /> <ClInclude Include="CivSysLog.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="CivCsvReader.cpp" />
<ClCompile Include="CivSysLog.cpp" /> <ClCompile Include="CivSysLog.cpp" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
......
...@@ -18,10 +18,16 @@ ...@@ -18,10 +18,16 @@
<ClInclude Include="CivSysLog.h"> <ClInclude Include="CivSysLog.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="CivCsvReader.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="CivSysLog.cpp"> <ClCompile Include="CivSysLog.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="CivCsvReader.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
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