Commit 93fd6516 authored by 刘乐's avatar 刘乐

1 dd

parent d635cb68
......@@ -142,7 +142,7 @@ copy epanet2.h $(OutDir)..\include /y</Command>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<Optimization>MaxSpeed</Optimization>
<Optimization>Disabled</Optimization>
<WholeProgramOptimization>true</WholeProgramOptimization>
</ClCompile>
<Link>
......
......@@ -18,7 +18,7 @@ int main(int argc, char* argv[])
char* findUri = const_cast<char*>(uri);
// 测试水力
/*CivTestContext context(new CivConHydrTest());
/* CivTestContext context(new CivConHydrTest());
context.contextTest(findUri);*/
// 测试水质
......
......@@ -338,6 +338,11 @@ void CivHydrCompute::saveResult(const std::string& uri)
mResultCache.save(uri);
}
void CivHydrCompute::cacheCodeSn(const std::string& uri)
{
mResultCache.getCodeToSnMap(uri);
}
void CivHydrCompute::getTrackingResult(const std::string& uri,std::string& jsonResult)
{
PipeCoords pipeCoords;
......
......@@ -25,6 +25,7 @@ public:
*@param uri 数据库连接地址
*/
void saveResult(const std::string& uri);
void cacheCodeSn(const std::string& uri);
void getTrackingResult(const std::string& uri,std::string& jsonResult);
......
......@@ -18,10 +18,12 @@ bool CivHydrSimulation::hdyrSimulation()
if (inpFileS.empty())
return false;
mHydrCompute.cacheCodeSn(mUri);
if (!mHydrCompute.hdyrCompute())
{
return false;
}
mHydrCompute.saveResult(mUri);
return true;
......@@ -31,14 +33,14 @@ bool CivHydrSimulation::qualitySimulation()
{
CivInpConvertor convertor(mUri);
std::string inpFileS = convertor.convertBaseInp();
if (inpFileS.empty())
if (inpFileS.empty() || inpFileS == "")
return false;
mHydrCompute.cacheCodeSn(mUri);
if (!mHydrCompute.qualityCompute())
{
return false;
}
mHydrCompute.saveResult(mUri);
return true;
......
......@@ -39,7 +39,7 @@ std::string CivInpConvertor::convertPorjInp(
if (builder->getNewInp(inpFile))
{
delete builder;
return NULL;
return "";
}
delete builder;
......@@ -63,7 +63,7 @@ std::string CivInpConvertor::convertBaseInp()
if (!builder->getNewInp(inpFile))
{
delete builder;
return NULL;
return "";
}
delete builder;
......
......@@ -26,13 +26,18 @@ void CivSimulResultCache::addLinkQuality(float quality, int interval,const std::
mLinkItemsMap[interval][sNo].dQuality = quality;
}
void CivSimulResultCache::addNodeItems(int internal,const NodeResultItem& nodeItem)
void CivSimulResultCache::addNodeItems(int internal,NodeResultItem& nodeItem)
{
if (mNodeCodeSnMap.find(nodeItem.szNo) != mNodeCodeSnMap.end())
nodeItem.code = mNodeCodeSnMap.find(nodeItem.szNo)->second;
mNodeItemsMap[internal][nodeItem.szNo] = nodeItem;
}
void CivSimulResultCache::addLinkItems(int interval,const LinkResultItem& linkItem)
void CivSimulResultCache::addLinkItems(int interval,LinkResultItem& linkItem)
{
if(mLineCodeSnMap.find(linkItem.szNo)!= mLineCodeSnMap.end())
linkItem.code = mLineCodeSnMap.find(linkItem.szNo)->second;
mLinkItemsMap[interval][linkItem.szNo] = linkItem;
}
......@@ -101,3 +106,10 @@ void CivSimulResultCache::getPipeItemByInterval(int time, LinkResultItems& linkI
if (iter != mLinkItemsMap.end())
linkItems = iter->second;
}
void CivSimulResultCache::getCodeToSnMap(const std::string& uri)
{
CivSimulResDbHelper helper(uri);
helper.getNodeCodeSnMap(mNodeCodeSnMap);
helper.getLinCodeSnMap(mLineCodeSnMap);
}
......@@ -33,13 +33,13 @@ public:
*@brief 缓存节点水力模拟情况
*@param nodeItem:节点水力结果值
*/
void addNodeItems(int interval,const NodeResultItem& nodeItem);
void addNodeItems(int interval,NodeResultItem& nodeItem);
/**
*@brief 缓存管线水力模拟情况
*@param linkItem:管线模拟结果
*/
void addLinkItems(int interval,const LinkResultItem& linkItem);
void addLinkItems(int interval,LinkResultItem& linkItem);
/**
*@brief 释放缓存的结果值
......@@ -54,9 +54,13 @@ public:
void getAllPipeCoords(const std::string& uri,PipeCoords& pipeCoords);
void getNodeItemByInterval(int time, NodeResultItems& nodeItem);
void getPipeItemByInterval(int time, LinkResultItems& linkItem);
void getCodeToSnMap(const string& uri);
private:
map<int, NodeResultItems> mNodeItemsMap; // 模拟
map<int, LinkResultItems> mLinkItemsMap; // 计算的
map<int, TankResultItems> mTankItemsMap;
map<string, string> mNodeCodeSnMap;
map<string, string> mLineCodeSnMap;
};
#endif // !CIVSIMULRESULTCACHE_H
......@@ -12,7 +12,9 @@ CivConnection::~CivConnection()
}
bool CivConnection::update(const std::string& table, const std::map<std::string, std::string>& result, const std::string& where)
bool CivConnection::update(const std::string& table,
const std::map<std::string, std::string>& result,
const std::string& where)
{
std::string sql = "update " + table + "set ";
......@@ -94,7 +96,8 @@ bool CivConnection::insertBulk(const std::string& table,
}
bool CivConnection::insert(const std::string& table, const std::map<std::string, std::string>& result)
bool CivConnection::insert(const std::string& table,
const std::map<std::string, std::string>& result)
{
if (table.empty() || result.size() <= 0)
return false;
......@@ -127,7 +130,10 @@ bool CivConnection::insert(const std::string& table, const std::map<std::string,
return true;
}
bool CivConnection::query(const std::string& table, const std::vector<std::string>& fields, std::vector<std::map<std::string,std::string>>& result, const std::string& where)
bool CivConnection::query(const std::string& table,
const std::vector<std::string>& fields,
std::vector<std::map<std::string,std::string>>& result,
const std::string& where)
{
//1 拼接sql语句
if (fields.size() <= 0 || table.empty())
......
......@@ -7,7 +7,7 @@
CivInpDbHelper::CivInpDbHelper(const std::string& uri)
:CivInpHelperAbs(uri)
{
mCondtion = "where " + PROJFILED + " is null or " + PROJFILED + "=\"\"";
mCondtion = " " + PROJFILED + " is null or " + PROJFILED + "=''";
}
CivInpDbHelper::~CivInpDbHelper()
......
......@@ -16,7 +16,7 @@ CivProjInpDbHelper::~CivProjInpDbHelper()
void CivProjInpDbHelper::setProjCode(const std::string& projCode)
{
mPorjCode = projCode;
std::string mCondition = PROJFILED + " = " + projCode + "or "+PROJFILED +" is null or "+ PROJFILED +"=\"\"";
std::string mCondition = PROJFILED + " = " + projCode + "or "+PROJFILED +" is null or "+ PROJFILED +"=''";
}
bool CivProjInpDbHelper::getNode(CivNode& node)
......
......@@ -4,6 +4,7 @@
struct ResultItem
{
std::string code;
char szNo[64];
std::string dDate;
std::string dTime;
......
#include "CivSimulResDbHelper.h"
#include "CivPgDbConnection.h"
#include "CivTypes.h"
#include "CivTableFields.h"
#include "CivCommonUtils.h"
......@@ -9,9 +10,10 @@ CivSimulResDbHelper::CivSimulResDbHelper(const std::string& uri)
mConn->connect(uri);
NodeResultTableField tableFields;
mNodeFields =
mNodeFields =
{
tableFields.Number,
"code",
//tableFields.Number,
tableFields.dDemand,
tableFields.dPressure,
tableFields.dQuality,
......@@ -24,7 +26,8 @@ CivSimulResDbHelper::CivSimulResDbHelper(const std::string& uri)
//
PipeResultTableField pipeFields;
mLinkFileds = {
pipeFields.szNo,
"code",
//pipeFields.szNo,
pipeFields.dFlow,
pipeFields.dVelocity,
pipeFields.dUnitHeadloss,
......@@ -50,7 +53,7 @@ bool CivSimulResDbHelper::insertNodes(const NodeResultItems& nodeitems)
{
NodeResultItem nodeItem = iter->second;
std::string sn = nodeItem.szNo;
std::string sn = nodeItem.code;
std::vector<std::string> vecRes =
{
"\'"+sn+"\'",
......@@ -82,7 +85,7 @@ bool CivSimulResDbHelper::insertLinks(const LinkResultItems& linkMap)
for (auto iter = linkMap.begin(); iter != linkMap.end(); iter++)
{
LinkResultItem linkItem = iter->second;
std::string sn = linkItem.szNo;
std::string sn = linkItem.code;
std::string status = linkItem.szStatus;
std::vector<std::string> vecRes =
{
......@@ -165,4 +168,50 @@ void CivSimulResDbHelper::getAllPipeCoords(PipeCoords& pipeCoords)
pipeCoord.endY = nodeInfo.find("endy")->second;
pipeCoords[key] = pipeCoord;
}
}
void CivSimulResDbHelper::getLinCodeSnMap(std::map<std::string, std::string>& map)
{
std::vector<std::string> fileds = {
"\"编号\"",
"\"code\""
};
std::vector<std::map<std::string, std::string>> res;
if (!mConn->query(PIPELINE, fileds, res))
return;
size_t total = res.size();
for (int i = 0; i < total; i++)
{
std::map<std::string, std::string> nodeInfo = res[i];
PipeCoord pipeCoord;
std::string sn = nodeInfo.find("编号")->second;
std::string code = nodeInfo.find("code")->second;
map[sn] = code;
}
}
void CivSimulResDbHelper::getNodeCodeSnMap(std::map<std::string, std::string>& map)
{
std::vector<std::string> fileds = {
"\"本点号\"",
"\"code\""
};
std::vector<std::map<std::string, std::string>> res;
if (!mConn->query(PIPENODE, fileds, res))
return;
size_t total = res.size();
for (int i = 0; i < total; i++)
{
std::map<std::string, std::string> nodeInfo = res[i];
PipeCoord pipeCoord;
std::string sn = nodeInfo.find("本点号")->second;
std::string code = nodeInfo.find("code")->second;
map[sn] = code;
}
}
\ No newline at end of file
......@@ -18,7 +18,8 @@ public:
virtual void getAllNodeCoords(NodeCoords& nodeCoords);
virtual void getAllPipeCoords(PipeCoords& pipeCoords);
virtual void getLinCodeSnMap(std::map<std::string, std::string>& map);
virtual void getNodeCodeSnMap(std::map<std::string, std::string>& map);
private:
std::vector<std::string> mNodeFields;
std::vector<std::string> mLinkFileds;
......
......@@ -35,3 +35,15 @@ void CivSimulResHelperAbs::getAllPipeCoords(PipeCoords& pipeCoords)
{
}
void CivSimulResHelperAbs::getLinCodeSnMap(std::map<std::string, std::string>& map)
{
}
void CivSimulResHelperAbs::getNodeCodeSnMap(std::map<std::string, std::string>& map)
{
}
......@@ -21,6 +21,8 @@ public:
virtual void getAllNodeCoords(NodeCoords& nodeCoords);
virtual void getAllPipeCoords(PipeCoords& pipeCoords);
virtual void getLinCodeSnMap(std::map<std::string, std::string>& map);
virtual void getNodeCodeSnMap(std::map<std::string, std::string>& map);
protected:
CivConnection* mConn = nullptr;
......
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