Commit e70c7e93 authored by 刘乐's avatar 刘乐

1, 类拆分

parent 2b546d06
......@@ -38,21 +38,6 @@ void CivConTrackTest::test(char* uri)
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)
{
......
......@@ -35,14 +35,6 @@ public:
virtual void test(char* uri);
};
/**
获取时段数据
*/
class CivConGetDataTest :public CivHydrTest
{
public:
virtual void test(char* uri);
};
/**
获取水力分析报告测试
......
......@@ -14,12 +14,12 @@ using namespace std;
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);
// 测试水力
/*CivTestContext context(new CivConHydrTest());
context.contextTest(findUri);*/
CivTestContext context(new CivConHydrTest());
context.contextTest(findUri);
// 测试水质
/*CivTestContext context(new CivConQuaTest());
......@@ -57,15 +57,7 @@ int main(int argc, char* argv[])
/* CivTestContext context(new CivWaterSupplyScopeTest());
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();
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 "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;
}
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
#include "epanet2.h"
/**
彊제셕炬잚
......@@ -6,13 +7,25 @@
class CivHydrCompute
{
public:
CivHydrCompute();
explicit CivHydrCompute(char* inp,char* rptFile,char* binFile);
/**
*@brief 水质计算
*@param fileName 计算的inp文件名
*/
bool qualityCompute(char* fileName);
*@brief 彊醴셕炬
*/
bool qualityCompute();
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 @@
#include "CivHydrSimulation.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)
{
......
......@@ -67,15 +67,6 @@ extern "C" {
*/
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)
}
#endif
......
This diff is collapsed.
......@@ -3,115 +3,40 @@
#include "CivNewInp.h"
class CivDbConn;
/**
水力模拟计算类
水力模拟计算类
*/
class CivHydrSimulation
{
public:
explicit CivHydrSimulation();
explicit CivHydrSimulation(CivDbConn* dbConn);
~CivHydrSimulation();
/**
*@brief 注册数据库
*@param dbConn 连接数据库指针
*@brief 水力模拟
*/
void registDb(CivDbConn* dbConn);
/**
*@brief 水力模拟
*/
bool hdyrSimulation();
/**
*@brief 瞬时计算
*/
bool hdyrInstantSimulation();
bool hdyrCompute();
/**
*@brief 水质模拟,水龄,化学物质
*/
*@brief 水质模拟,水龄,化学物质
*/
bool qualitySimulation();
/**
*@brief 获取分析结果
*@return 分析结果字符串
*/
std::string getAnalysisResults();
/**
*@brief 追踪分析,本质仍然式水质分析
*@param snNode:追踪的节点号
*@param hours: 小时数
*/
bool trackingSimulation(char* snNode, int hours);
void getDataByTime(int time ,NodeResultItems& nodeItems, LinkResultItems& linkItems);
bool trackingSimulation(char* snNode, int hours, std::string& jsonResult);
/**
*@brief 导出inp文件
*@param analyType: 水质分析类型:水龄,追踪,化合物,none
*@param qulityName: 追踪节点值,或者化合物质
*/
bool convertInp(const QualityAnalyType analyType, const std::string& qulityName);
/**
*@brief 获取追踪结果值
*@param hours:追踪的小时数
*/
*@brief 获取追踪结果值
*@param hours:追踪的小时数
*/
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:
CivDbConn* mDbConn;
CivSimulResultCache mResultCache; // 存储模拟结果缓存类
QualityAnalyType mQuaLityType = ANALYSIS_RESERVE;
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 "CivAssembly.h"
#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;
}
CivNewInp* CivBuilder::getNewInp()
CivNewInp* CivInpBuilder::getNewInp()
{
return mNewInp;
}
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()
{
ASSERT(mDbConn, mNewInp)
CivNode node;
if (!mDbConn->getNode(node))
return;
......
#ifndef _CIVINPEXPOTER_H
#define _CIVINPEXPOTER_H
#include "CivPgConn.h"
#include "CivNewInp.h"
/**
*
*/
class CivBuilder
class CivInpBuilder
{
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(CivDbConn* dbConn);
~CivInpBuilder();
virtual ~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 buildPipe();
virtual void buildTank();
......@@ -83,9 +35,12 @@ public:
virtual void buildRules();
virtual void buildDemands();
private:
CivDbConn* mDbConn;
CivNewInp* getNewInp();
protected:
CivNewInp* mNewInp;
};
#endif // !_CIVINPEXPOTER_H
......
......@@ -8,4 +8,9 @@ CivInpConvertor::CivInpConvertor(const std::string& uri)
CivInpConvertor::~CivInpConvertor()
{
}
char* CivInpConvertor::getInp()
{
}
\ No newline at end of file
......@@ -7,23 +7,10 @@
class CivInpConvertor
{
public:
CivInpConvertor(const std::string& uri);
explicit CivInpConvertor(const std::string& uri);
~CivInpConvertor();
/*
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()); }
char* getInp();
private:
std::string mInpFile; // inp文件名
std::string mRptFile; // 报告文件名
std::string mBinFile;// 二进制文件名
};
\ No newline at end of file
#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()
{
......
#pragma once
#include "CivBuilder.h"
#include "CivInpBuilder.h"
/**
ģתinpļ
*/
class CivProjInpBuilder :public CivBuilder
class CivProjInpBuilder :public CivInpBuilder
{
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 buildPipe();
virtual void buildTank();
......
......@@ -153,12 +153,13 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\pandaDbManager\CivCommonUtils.cpp" />
<ClCompile Include="CivBaseInpBuilder.cpp" />
<ClCompile Include="CivGraphFactory.cpp" />
<ClCompile Include="CivHydDataType.cpp" />
<ClCompile Include="CivHydrCompute.cpp" />
<ClCompile Include="CivHydrFuncInter.cpp" />
<ClCompile Include="CivHydrSimulation.cpp" />
<ClCompile Include="CivBuilder.cpp" />
<ClCompile Include="CivInpBuilder.cpp" />
<ClCompile Include="CivInpConvertor.cpp" />
<ClCompile Include="CivInpDirector.cpp" />
<ClCompile Include="CivNewInp.cpp" />
......@@ -171,13 +172,14 @@
<ClCompile Include="CivTrackingAnalysis.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="CivBaseInpBuilder.h" />
<ClInclude Include="CivGraphFactory.h" />
<ClInclude Include="CivGraphList.h" />
<ClInclude Include="CivHydDataType.h" />
<ClInclude Include="CivHydrCompute.h" />
<ClInclude Include="CivHydrFuncInter.h" />
<ClInclude Include="CivHydrSimulation.h" />
<ClInclude Include="CivBuilder.h" />
<ClInclude Include="CivInpBuilder.h" />
<ClInclude Include="CivInpConvertor.h" />
<ClInclude Include="CivInpDirector.h" />
<ClInclude Include="CivNewInp.h" />
......
......@@ -21,9 +21,6 @@
<ClCompile Include="..\pandaDbManager\CivCommonUtils.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivBuilder.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivInpDirector.cpp">
<Filter>源文件</Filter>
</ClCompile>
......@@ -66,6 +63,12 @@
<ClCompile Include="CivOptSchedSimulation.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivBaseInpBuilder.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivInpBuilder.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="CivHydrFuncInter.h">
......@@ -74,9 +77,6 @@
<ClInclude Include="CivNewInp.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivBuilder.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivInpDirector.h">
<Filter>头文件</Filter>
</ClInclude>
......@@ -119,5 +119,11 @@
<ClInclude Include="CivOptSchedSimulation.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivInpBuilder.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivBaseInpBuilder.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
......@@ -3,6 +3,7 @@
#include "CivTypes.h"
#include <list>
#pragma warning(disable:4251)
#define DBEXPORT __declspec(dllexport)
class CivAssembly;
......@@ -68,7 +69,7 @@ public:
/*
水池类型
水池类型
*/
class DBEXPORT CivTank:public CivAssembly
{
......@@ -98,15 +99,6 @@ class DBEXPORT CivValve :public CivAssembly
public:
typedef struct Table
{
/*
阀门的ID标签
起始节点ID
终止节点ID
直径,mm(英寸)
阀门类型
阀门设置
局部损失系数
*/
Str ID;
Str Node1;
Str Node2;
......@@ -117,6 +109,7 @@ public:
} ValveTable;
void addItem(const ValveTable& table);
std::list<ValveTable> mTables;
};
......@@ -190,7 +183,6 @@ class DBEXPORT CivCoordinates :public CivAssembly
public:
typedef struct Table
{
// ; ;Node X-Coord Y-Coord
Str ID;
Str XCoord;
Str YCoord;
......@@ -372,8 +364,8 @@ public:
/*
X坐标
Y坐标
双引号中的标签文本
锚定节点的ID标签(可选)
双引号中的标签文本
锚定节点的ID标签(可选)
*/
Str XCoord;
Str YCoord;
......
......@@ -51,11 +51,6 @@ public:
*/
virtual bool tableExist(StrQuote tableName) = 0;
/**
*@brief 创建表格
*/
virtual bool createTable(CivTableTemp& temp) =0 ;
/**
*@brief 根据字段值条件删除数据
*@param table:表
......@@ -104,7 +99,6 @@ public:
const std::vector<std::string>& fileds,
std::vector< std::map<std::string, std::string>>& result) = 0;
virtual void checkHyDrNetTable() = 0;
// 获取当前执行错误信息
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()
bool CivInpDbHelper::getNode(CivNode& node)
{
CivJunctionTableTemp::JunctionTable nodeTable;
std::vector<std::string> fields = { nodeTable.thePoint,nodeTable.elev, nodeTable.demand, nodeTable.pattern };
JunctionTable nodeTableFields;
std::vector<std::string> fields =
{
nodeTableFields.sn,
nodeTableFields.elev,
nodeTableFields.demand,
nodeTableFields.demandPattern
};
std::vector<std::map<std::string,std::string>> resultVector;
mDbConn->query(PUMP, fields, resultVector);
......@@ -29,10 +35,10 @@ bool CivInpDbHelper::getNode(CivNode& node)
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;
nodeTable.ID = map.find(nodeTableFields.sn)->second;
nodeTable.Elev = map.find(nodeTableFields.elev)->second;
nodeTable.Demand = map.find(nodeTableFields.baseDemand)->second;
nodeTable.PatternId = map.find(nodeTableFields.demandPattern)->second;
node.addItem(nodeTable);
}
......@@ -41,16 +47,16 @@ bool CivInpDbHelper::getNode(CivNode& node)
bool CivInpDbHelper::getPipe(CivPipe& pipes)
{
CivPipeTableTemp::PipeTable pipeTable;
PipeTable pipeTable;
std::vector<std::string> fields = {
pipeTable.snNo,
pipeTable.lastPoint,
pipeTable.thePoint,
pipeTable.startPoint,
pipeTable.endPoint,
pipeTable.length,
pipeTable.diameter,
pipeTable.friction,
pipeTable.localHeadLoss,
pipeTable.localLoss,
pipeTable.status
};
......@@ -65,12 +71,12 @@ bool CivInpDbHelper::getPipe(CivPipe& pipes)
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.Node1 = map.find(pipeTable.startPoint)->second;
pipe.Node2 = map.find(pipeTable.endPoint)->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.MinorLoss = map.find(pipeTable.localLoss)->second;
pipe.Status = map.find(pipeTable.status)->second;
pipes.addItem(pipe);
......@@ -80,17 +86,17 @@ bool CivInpDbHelper::getPipe(CivPipe& pipes)
bool CivInpDbHelper::getTank(CivTank& tanks)
{
CivTankTableTemp::TankTable tankTable;
TankTable tankTable;
std::vector<std::string> fields = {
tankTable.thePoint,
tankTable.sn,
tankTable.elev,
tankTable.initLevel,
tankTable.lowLevel,
tankTable.highLevel,
tankTable.minLevel,
tankTable.maxLevel,
tankTable.diametor,
tankTable.capacity,
tankTable.volCurve
tankTable.minVolume,
tankTable.volumeCurve
};
std::vector<std::map<std::string, std::string>> resultVector;
......@@ -102,14 +108,14 @@ bool CivInpDbHelper::getTank(CivTank& tanks)
CivTank::TankTable tank;
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.InitLevel = map.find(tankTable.initLevel)->second;
tank.MinLevel = map.find(tankTable.lowLevel)->second;
tank.MaxLevel = map.find(tankTable.highLevel)->second;
tank.MinLevel = map.find(tankTable.minLevel)->second;
tank.MaxLevel = map.find(tankTable.maxLevel)->second;
tank.Diameter = map.find(tankTable.diametor)->second;
tank.MinVol = map.find(tankTable.capacity)->second;
tank.VolCurve = map.find(tankTable.volCurve)->second;
tank.MinVol = map.find(tankTable.minVolume)->second;
tank.VolCurve = map.find(tankTable.volumeCurve)->second;
tanks.addItem(tank);
}
......@@ -118,15 +124,15 @@ bool CivInpDbHelper::getTank(CivTank& tanks)
bool CivInpDbHelper::getValve(CivValve& valves)
{
CivValveTableTemp::ValveTable vaveTable;
ValveTable vaveTable;
std::vector<std::string> fields = {
vaveTable.id,
vaveTable.sn,
vaveTable.startPoint,
vaveTable.endPoint,
vaveTable.diameter,
vaveTable.length,
vaveTable.type,
vaveTable.setting,
vaveTable.loss
vaveTable.lossCoeff
};
std::vector<std::map<std::string, std::string>> resultVector;
......@@ -138,13 +144,13 @@ bool CivInpDbHelper::getValve(CivValve& valves)
CivValve::ValveTable vave;
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.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.Setting = map.find(vaveTable.setting)->second;
vave.MinorLoss = map.find(vaveTable.loss)->second;
vave.MinorLoss = map.find(vaveTable.lossCoeff)->second;
valves.addItem(vave);
}
......@@ -153,9 +159,9 @@ bool CivInpDbHelper::getValve(CivValve& valves)
bool CivInpDbHelper::getPumps(CivPumps& pumps)
{
CivPumpTableTemp::PumpTable pmTable;
PumpTable pmTable;
std::vector<std::string> fields = {
pmTable.thePoint,
pmTable.sn,
pmTable.startPoint,
pmTable.endPoint,
pmTable.headCurve
......@@ -170,7 +176,7 @@ bool CivInpDbHelper::getPumps(CivPumps& pumps)
CivPumps::PumpTable pump;
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.Node2 = map.find(pmTable.endPoint)->second;
pump.Parameters = map.find(pmTable.headCurve)->second;
......@@ -182,11 +188,11 @@ bool CivInpDbHelper::getPumps(CivPumps& pumps)
bool CivInpDbHelper::getReservoirs(CivReservoirs& reservoirs)
{
CivResourcesTableTemp::ResourcesTable restemTable;
ResourcesTable restemTable;
std::vector<std::string> fields = {
restemTable.thePoint,
restemTable.head,
restemTable.sn,
restemTable.totalHead,
restemTable.headPattern
};
......@@ -199,8 +205,8 @@ bool CivInpDbHelper::getReservoirs(CivReservoirs& reservoirs)
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.ID = map.find(restemTable.sn)->second;
resTable.Head = map.find(restemTable.totalHead)->second;
resTable.Pattern = map.find(restemTable.headPattern)->second;
reservoirs.addItem(resTable);
......@@ -215,10 +221,10 @@ bool CivInpDbHelper::getEmitters(CivEmitters& emitter)
bool CivInpDbHelper::getCoordinates(CivCoordinates& coord)
{
CivJunctionTableTemp::JunctionTable nodeTable;
JunctionTable nodeTable;
std::vector<std::string> fields = {
nodeTable.thePoint,
nodeTable.sn,
nodeTable.xCoord,
nodeTable.yCoord
};
......@@ -251,7 +257,7 @@ bool CivInpDbHelper::getMixing(CivMixing& mixing)
bool CivInpDbHelper::getParameter(std::vector<CivParameter>& params)
{
CivParametorTableTemp::ParametorTable restemTable;
ParametorTable restemTable;
std::vector<std::string> fields = {
restemTable.name,
......@@ -295,7 +301,7 @@ bool CivInpDbHelper::getParameter(std::vector<CivParameter>& params)
bool CivInpDbHelper::getPatterns(CivPatterns& patterns)
{
CivPatternTableTemp::PatternTable patternTable;
PatternTable patternTable;
std::vector<std::string> fields = {
patternTable.modelName,
......@@ -323,12 +329,12 @@ bool CivInpDbHelper::getPatterns(CivPatterns& patterns)
bool CivInpDbHelper::getCurves(CivCurves& curves)
{
CivCurveTableTemp::CurveTable curveTable;
CurveTable curveTable;
std::vector<std::string> fields = {
curveTable.CurveName,
curveTable.CurveType,
curveTable.CurveData
curveTable.CurveName,
curveTable.CurveType,
curveTable.CurveData
};
std::vector<std::map<std::string, std::string>> resultVector;
......@@ -367,9 +373,9 @@ bool CivInpDbHelper::getStatus(CivStatus& status)
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;
mDbConn->query(PIPENODE, fields, resultVector);
......
......@@ -15,195 +15,31 @@ CivInpHelperAbs::~CivInpHelperAbs()
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
......@@ -214,32 +50,6 @@ bool CivInpHelperAbs::getEmitters(CivEmitters& emitter)
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;
}
......@@ -250,102 +60,20 @@ bool CivInpHelperAbs::getMixing(CivMixing& mixing)
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;
}
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;
}
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;
}
......@@ -366,25 +94,6 @@ bool CivInpHelperAbs::getStatus(CivStatus& status)
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;
}
......
......@@ -4,12 +4,11 @@
class CivConnection;
/**
תinpݿ
תinpݿ
*/
class CivInpHelperAbs
{
public:
explicit CivInpHelperAbs(CivConnection* dbConn);
virtual ~CivInpHelperAbs();
......
......@@ -317,7 +317,7 @@ bool CivPgConn::getPipe(CivPipe& pipe)
sql.append(",");
sql.append(pipeTable.status);
sql.append(" from ");
sql.append(PIPELINE)
sql.append(PIPELINE);
std::string utf8Sql = TransUTFCoding(sql);
if (!execSql(utf8Sql))
......@@ -469,7 +469,6 @@ bool CivPgConn::getPumps(CivPumps& pump)
std::string utf8Sql = TransUTFCoding(sql);
if (!execSql(utf8Sql))
{
/* CivSysLog::getInstance()->error(mLastError, "CivPgConn", __FUNCTION__);*/
return false;
}
......@@ -491,11 +490,11 @@ bool CivPgConn::getPumps(CivPumps& pump)
bool CivPgConn::getReservoirs(CivReservoirs& reservoirs)
{
CivResourcesTableTemp::ResourcesTable restemTable;
ResourcesTable restemTable;
//;ID Head Pattern
std::string sql = "select ";
sql.append(restemTable.thePoint);
sql.append(restemTable.sn);
sql.append(",");
sql.append(restemTable.head);
sql.append(",");
......@@ -566,7 +565,6 @@ bool CivPgConn::getCoordinates(CivCoordinates& coord)
if (!execSql(sql))
{
CivSysLog::getInstance()->error(mLastError, "CivPgConn", __FUNCTION__);
return false;
}
......@@ -867,88 +865,4 @@ bool CivPgConn::getValuesFromTableByCondition(
PQclear(mResult);
return true;
}
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);
}
}
}
\ No newline at end of file
......@@ -53,14 +53,6 @@ public:
bool getLabels(CivLabels& labels) override;
bool getTags(CivTags& tags) override;
/**
*@brief 创建表格
*@param tableName: 表名
*@param schema:
*@param tableType:表类型,点结果,线结果
*/
bool createTable(CivTableTemp& temp) override;
/**
*@brief 根据字段值条件删除数据
*@param table:表
......@@ -90,8 +82,6 @@ public:
const std::string& condition,
const std::vector<std::string>& fileds,
std::vector< std::map<std::string, std::string>>& result) override;
void checkHyDrNetTable() override;
private:
PGconn* mConn; // 连接对象
......
This diff is collapsed.
This diff is collapsed.
#include "CivTrackingResultCache.h"
#include "CivPgConn.h"
#include "CivConnection.h"
void CivTrackingResultCache::cacheInfoFromDb(CivDbConn* dbConn)
void CivTrackingResultCache::cacheInfoFromDb(CivConnection* dbConn)
{
if (dbConn == nullptr)
return;
......@@ -54,7 +54,7 @@ void CivTrackingResultCache::transformToJsonStr(std::string jsonStr)
jsonStr.append("}");
}
void CivTrackingResultCache::cacheJunctionInfoFromDb(CivDbConn* dbConn)
void CivTrackingResultCache::cacheJunctionInfoFromDb(CivConnection* dbConn)
{
if (dbConn == nullptr)
return;
......@@ -66,10 +66,10 @@ void CivTrackingResultCache::cacheJunctionInfoFromDb(CivDbConn* dbConn)
fileds.push_back("ST_X(geom) as xCoord");
fileds.push_back("ST_Y(geom) as yCoord");
if (!dbConn->getFieldValueFromTable(PIPENODE, fileds, nodeResult))
/*if (!dbConn->getFieldValueFromTable(PIPENODE, fileds, nodeResult))
{
return;
}
}*/
// 缓存节点数据
int rows = nodeResult.size();
......@@ -90,7 +90,7 @@ void CivTrackingResultCache::cacheJunctionInfoFromDb(CivDbConn* dbConn)
}
void CivTrackingResultCache::cachePipeInfoFromDb(CivDbConn* dbConn)
void CivTrackingResultCache::cachePipeInfoFromDb(CivConnection* dbConn)
{
if (dbConn == nullptr)
return;
......@@ -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_Y(ST_EndPoint(ST_GeometryN(geom, 1))) as endY");
if (!dbConn->getFieldValueFromTable(PIPELINE,fileds, pipeResult))
/*if (!dbConn->getFieldValueFromTable(PIPELINE,fileds, pipeResult))
{
return;
}
}*/
// 缓存节点数据
int rows = pipeResult.size();
......
......@@ -3,7 +3,7 @@
#include <string>
#include <vector>
class CivDbConn;
class CivConnection;
#define CACHEEXPORT __declspec(dllexport)
// 节点
......@@ -34,7 +34,7 @@ public:
*@brief 缓存数据库的信息
*@param dbConn 数据库连接
*/
void cacheInfoFromDb(CivDbConn* dbConn);
void cacheInfoFromDb(CivConnection* dbConn);
/**
*@brief 缓存信息转json字符串
......@@ -61,13 +61,13 @@ private:
*@brief 缓存数据库的节点数据
*@param dbConn 数据库连接
*/
void cacheJunctionInfoFromDb(CivDbConn* dbConn);
void cacheJunctionInfoFromDb(CivConnection* dbConn);
/**
*@brief 缓存数据管段信息
*@param dbConn
*/
void cachePipeInfoFromDb(CivDbConn* dbConn);
void cachePipeInfoFromDb(CivConnection* dbConn);
private:
std::map<std::string, Junctions> mNodeCache; // 节点信息缓存
......
......@@ -150,9 +150,7 @@
</Link>
<PostBuildEvent>
<Command>copy CivTypes.h $(OutDir)..\include /y
copy CivPgConn.h $(OutDir)..\include /y
copy CivAssembly.h $(OutDir)..\include /y
copy CivDbConn.h $(OutDir)..\include /y
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
......@@ -160,12 +158,8 @@ copy CivDbConn.h $(OutDir)..\include /y
<ClInclude Include="CivAssembly.h" />
<ClInclude Include="CivCommonUtils.h" />
<ClInclude Include="CivConnection.h" />
<ClInclude Include="CivDbConn.h" />
<ClInclude Include="CivDbUtils.h" />
<ClInclude Include="CivInpDbHelper.h" />
<ClInclude Include="CivInpHelperAbs.h" />
<ClInclude Include="CivMaintainModel.h" />
<ClInclude Include="CivPgConn.h" />
<ClInclude Include="CivPgDbConnection.h" />
<ClInclude Include="CivProjInpDbHelper.h" />
<ClInclude Include="CivSimuResDbHelper.h" />
......@@ -177,16 +171,11 @@ copy CivDbConn.h $(OutDir)..\include /y
<ClCompile Include="CivAssembly.cpp" />
<ClCompile Include="CivCommonUtils.cpp" />
<ClCompile Include="CivConnection.cpp" />
<ClCompile Include="CivDbConn.cpp" />
<ClCompile Include="CivDbUtils.cpp" />
<ClCompile Include="CivInpDbHelper.cpp" />
<ClCompile Include="CivInpHelperAbs.cpp" />
<ClCompile Include="CivMaintainModel.cpp" />
<ClCompile Include="CivPgConn.cpp" />
<ClCompile Include="CivPgDbConnection.cpp" />
<ClCompile Include="CivProjInpDbHelper.cpp" />
<ClCompile Include="CivSimuResDbHelper.cpp" />
<ClCompile Include="CivTableTemp.cpp" />
<ClCompile Include="CivTrackingResultCache.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
......
......@@ -24,12 +24,6 @@
<ClInclude Include="CivCommonUtils.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivDbConn.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivPgConn.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivAssembly.h">
<Filter>头文件</Filter>
</ClInclude>
......@@ -39,9 +33,6 @@
<ClInclude Include="CivConnection.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivMaintainModel.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivPgDbConnection.h">
<Filter>头文件</Filter>
</ClInclude>
......@@ -57,23 +48,11 @@
<ClInclude Include="CivSimuResDbHelper.h">
<Filter>源文件</Filter>
</ClInclude>
<ClInclude Include="CivDbUtils.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CivTableTemp.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivCommonUtils.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivDbConn.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivPgConn.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivAssembly.cpp">
<Filter>源文件</Filter>
</ClCompile>
......@@ -83,9 +62,6 @@
<ClCompile Include="CivConnection.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivMaintainModel.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivPgDbConnection.cpp">
<Filter>源文件</Filter>
</ClCompile>
......@@ -101,8 +77,5 @@
<ClCompile Include="CivSimuResDbHelper.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivDbUtils.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</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 @@
<ImportLibrary>$(OutDir)..\lib\$(TargetName).lib</ImportLibrary>
</Link>
<PostBuildEvent>
<Command>copy CivSysLog.h $(OutDir)..\include /y</Command>
<Command>copy CivSysLog.h $(OutDir)..\include /y
copy CivCsvReader.h $(OutDir)..\include /y</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="CivCsvReader.h" />
<ClInclude Include="CivSysLog.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="CivCsvReader.cpp" />
<ClCompile Include="CivSysLog.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
......
......@@ -18,10 +18,16 @@
<ClInclude Include="CivSysLog.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivCsvReader.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CivSysLog.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivCsvReader.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</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