Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hydraulicModel
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘乐
hydraulicModel
Commits
aafa2bec
Commit
aafa2bec
authored
Aug 26, 2020
by
刘乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1, 最新版
parent
73a9973d
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
439 additions
and
103 deletions
+439
-103
CivHydrTest.cpp
funcDemo/CivHydrTest.cpp
+3
-3
main.cpp
funcDemo/main.cpp
+4
-4
CivHydrCompute.cpp
pandaAnalysis/CivHydrCompute.cpp
+165
-25
CivHydrCompute.h
pandaAnalysis/CivHydrCompute.h
+4
-0
CivHydrSimulation.cpp
pandaAnalysis/CivHydrSimulation.cpp
+18
-0
CivInpBuilder.cpp
pandaAnalysis/CivInpBuilder.cpp
+5
-0
CivInpBuilder.h
pandaAnalysis/CivInpBuilder.h
+1
-0
CivInpConvertor.cpp
pandaAnalysis/CivInpConvertor.cpp
+31
-16
CivInpConvertor.h
pandaAnalysis/CivInpConvertor.h
+8
-0
CivSimulResultCache.cpp
pandaAnalysis/CivSimulResultCache.cpp
+24
-0
CivSimulResultCache.h
pandaAnalysis/CivSimulResultCache.h
+5
-0
CivConnection.cpp
pandaDbManager/CivConnection.cpp
+9
-10
CivHydrTableHelper.cpp
pandaDbManager/CivHydrTableHelper.cpp
+10
-21
CivInpDbHelper.cpp
pandaDbManager/CivInpDbHelper.cpp
+101
-6
CivInpHelperAbs.cpp
pandaDbManager/CivInpHelperAbs.cpp
+6
-0
CivInpHelperAbs.h
pandaDbManager/CivInpHelperAbs.h
+9
-1
CivPgDbConnection.cpp
pandaDbManager/CivPgDbConnection.cpp
+5
-2
CivSimuResStruct.h
pandaDbManager/CivSimuResStruct.h
+8
-0
CivSimulResDbHelper.cpp
pandaDbManager/CivSimulResDbHelper.cpp
+18
-15
CivTableFields.h
pandaDbManager/CivTableFields.h
+5
-0
No files found.
funcDemo/CivHydrTest.cpp
View file @
aafa2bec
...
@@ -24,7 +24,7 @@ void CivConTrackTest::test(char* uri)
...
@@ -24,7 +24,7 @@ void CivConTrackTest::test(char* uri)
char
result
[
1024
*
512
];
char
result
[
1024
*
512
];
char
sn
[
64
];
char
sn
[
64
];
strcpy_s
(
sn
,
"
ffd0f63d-b8c3-4354-aea5-aedc52cb8e16
"
);
strcpy_s
(
sn
,
"
5fbaaf9e-dfcf-4e97-9fb1-31d03293f654
"
);
int
succ
=
trackingSimulation
(
uri
,
sn
,
6
,
result
);
int
succ
=
trackingSimulation
(
uri
,
sn
,
6
,
result
);
...
@@ -36,7 +36,7 @@ void CivUpstreamTrackingTest::test(char* uri)
...
@@ -36,7 +36,7 @@ void CivUpstreamTrackingTest::test(char* uri)
{
{
// 追踪节点编号
// 追踪节点编号
char
sn
[
64
];
char
sn
[
64
];
strcpy
(
sn
,
"
ffd0f63d-b8c3-4354-aea5-aedc52cb8e16
"
);
strcpy
(
sn
,
"
5fbaaf9e-dfcf-4e97-9fb1-31d03293f654
"
);
char
result
[
1024
*
128
];
char
result
[
1024
*
128
];
...
@@ -54,7 +54,7 @@ void CivDownStreamTrackingTest::test(char* uri)
...
@@ -54,7 +54,7 @@ void CivDownStreamTrackingTest::test(char* uri)
{
{
// 追踪节点编号
// 追踪节点编号
char
sn
[
64
];
char
sn
[
64
];
strcpy
(
sn
,
"
3997f59b-91ae-44e1-be89-c23b6b330909
"
);
strcpy
(
sn
,
"
5fbaaf9e-dfcf-4e97-9fb1-31d03293f654
"
);
char
result
[
1024
*
512
];
char
result
[
1024
*
512
];
...
...
funcDemo/main.cpp
View file @
aafa2bec
...
@@ -22,8 +22,8 @@ int main(int argc, char* argv[])
...
@@ -22,8 +22,8 @@ int main(int argc, char* argv[])
context.contextTest(findUri);*/
context.contextTest(findUri);*/
// 测试水质
// 测试水质
CivTestContext
context
(
new
CivConQuaTest
());
/*
CivTestContext context(new CivConQuaTest());
context
.
contextTest
(
findUri
);
context.contextTest(findUri);
*/
// 测试追踪分析
// 测试追踪分析
...
@@ -35,8 +35,8 @@ int main(int argc, char* argv[])
...
@@ -35,8 +35,8 @@ int main(int argc, char* argv[])
context.contextTest(findUri);*/
context.contextTest(findUri);*/
// 下游追踪
// 下游追踪
/*
CivTestContext context(new CivDownStreamTrackingTest());
CivTestContext
context
(
new
CivDownStreamTrackingTest
());
context.contextTest(findUri);
*/
context
.
contextTest
(
findUri
);
// 水源供水范围分析
// 水源供水范围分析
...
...
pandaAnalysis/CivHydrCompute.cpp
View file @
aafa2bec
...
@@ -188,6 +188,108 @@ bool CivHydrCompute::hdyrCompute()
...
@@ -188,6 +188,108 @@ bool CivHydrCompute::hdyrCompute()
return
true
;
return
true
;
}
}
bool
CivHydrCompute
::
chlorineCompute
()
{
// 运行水质运算需要先进行水力运算,没有直接采用ENSolveH 是为了考虑减压阀的压力曲线设置
long
t
(
0
),
tstep
(
0
);
int
iTime
(
0
);
int
errcode
=
0
;
char
inpFile
[
128
];
strcpy_s
(
inpFile
,
mInFile
.
c_str
());
char
rptFile
[
128
];
strcpy_s
(
rptFile
,
mRptFile
.
c_str
());
char
binFile
[
128
];
strcpy_s
(
binFile
,
mBinFile
.
c_str
());
CivSysLog
::
getInstance
()
->
info
(
"打开inp文件"
,
"CivHydrCompute"
,
__FUNCTION__
);
errcode
=
ENopen
(
inpFile
,
rptFile
,
binFile
);
if
(
errcode
>
0
)
{
CivSysLog
::
getInstance
()
->
error
(
"ENopen 失败"
,
"CivHydrCompute"
,
__FUNCTION__
);
ENclose
();
return
false
;
}
if
(
ENopenH
()
>
0
)
{
CivSysLog
::
getInstance
()
->
error
(
"ENopenH 失败"
,
"CivHydrCompute"
,
__FUNCTION__
);
ENclose
();
return
false
;
}
if
(
ENinitH
(
EN_SAVE
)
>
0
)
{
CivSysLog
::
getInstance
()
->
error
(
"ENinitH 失败"
,
"CivHydrCompute"
,
__FUNCTION__
);
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
++
;
}
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
;
}
iTime
++
;
// 获取水质模拟结果
getNodeChlorine
(
iTime
);
getLinkChlorine
(
iTime
);
ENstepQ
(
&
tstep
);
}
while
(
tstep
>
0
);
ENcloseQ
();
ENclose
();
CivSysLog
::
getInstance
()
->
info
(
"ENclose"
,
"CivHydrCompute"
,
__FUNCTION__
);
return
true
;
}
void
CivHydrCompute
::
dateAndTime
(
int
time
,
std
::
string
&
nowDate
,
std
::
string
&
nowTime
)
void
CivHydrCompute
::
dateAndTime
(
int
time
,
std
::
string
&
nowDate
,
std
::
string
&
nowTime
)
{
{
CivDate
civDate
;
CivDate
civDate
;
...
@@ -219,7 +321,7 @@ void CivHydrCompute::getNodeResult(short time)
...
@@ -219,7 +321,7 @@ void CivHydrCompute::getNodeResult(short time)
// 计算节点
// 计算节点
int
nNodeCount
;
int
nNodeCount
;
ENgetcount
(
EN_NODECOUNT
,
&
nNodeCount
);
ENgetcount
(
EN_NODECOUNT
,
&
nNodeCount
);
//
int* typeCode = (int*)malloc(sizeof(int));
int
*
typeCode
=
(
int
*
)
malloc
(
sizeof
(
int
));
std
::
string
nowDate
;
std
::
string
nowDate
;
std
::
string
nowTime
;
std
::
string
nowTime
;
...
@@ -227,22 +329,10 @@ void CivHydrCompute::getNodeResult(short time)
...
@@ -227,22 +329,10 @@ void CivHydrCompute::getNodeResult(short time)
for
(
int
i
=
1
;
i
<=
nNodeCount
;
i
++
)
for
(
int
i
=
1
;
i
<=
nNodeCount
;
i
++
)
{
{
//ENgetlinktype(i, typeCode);
ENgetnodetype
(
i
,
typeCode
);
//if (*typeCode == EN_TANK || *typeCode== EN_RESERVOIR)
if
(
*
typeCode
!=
EN_JUNCTION
)
//{
continue
;
// TankResultItem tankItem;
//
// ENgetnodeid(i, tankItem.szNo);// 编号
// ENgetnodevalue(i, EN_TANKVOLUME, &tankItem.dTankVolume); // 水池容量
// ENgetnodevalue(i, EN_MAXVOLUME, &tankItem.dTankMaxVolume); // 水池最大容量
// ENgetnodevalue(i, EN_TANKLEVEL, &tankItem.dTankLevel); // 液位高度
// tankItem.dDate = nowDate;
// tankItem.dTime = nowTime;
// tankItem.dModifyTime = CurrentTime;
//}
//else
//{
NodeResultItem
nodeItem
;
NodeResultItem
nodeItem
;
ENgetnodeid
(
i
,
nodeItem
.
szNo
);
// 编号
ENgetnodeid
(
i
,
nodeItem
.
szNo
);
// 编号
...
@@ -254,10 +344,10 @@ void CivHydrCompute::getNodeResult(short time)
...
@@ -254,10 +344,10 @@ void CivHydrCompute::getNodeResult(short time)
nodeItem
.
dDate
=
nowDate
;
nodeItem
.
dDate
=
nowDate
;
nodeItem
.
dTime
=
nowTime
;
nodeItem
.
dTime
=
nowTime
;
nodeItem
.
dModifyTime
=
CurrentTime
;
nodeItem
.
dModifyTime
=
CurrentTime
;
mResultCache
.
addNodeItems
(
time
,
nodeItem
);
mResultCache
.
addNodeItems
(
time
,
nodeItem
);
// }
}
}
//
free(typeCode);
free
(
typeCode
);
}
}
void
CivHydrCompute
::
getLinkResult
(
short
time
)
void
CivHydrCompute
::
getLinkResult
(
short
time
)
...
@@ -305,17 +395,22 @@ void CivHydrCompute::getNodeQuality(short time)
...
@@ -305,17 +395,22 @@ void CivHydrCompute::getNodeQuality(short time)
int
nNodeCount
;
int
nNodeCount
;
ENgetcount
(
EN_NODECOUNT
,
&
nNodeCount
);
ENgetcount
(
EN_NODECOUNT
,
&
nNodeCount
);
float
*
quality
=
(
float
*
)
malloc
(
sizeof
(
floa
t
));
int
*
typeCode
=
(
int
*
)
malloc
(
sizeof
(
in
t
));
for
(
int
i
=
1
;
i
<=
nNodeCount
;
i
++
)
for
(
int
i
=
1
;
i
<=
nNodeCount
;
i
++
)
{
ENgetnodetype
(
i
,
typeCode
);
if
(
*
typeCode
==
EN_JUNCTION
)
{
{
char
No
[
35
];
char
No
[
35
];
ENgetnodeid
(
i
,
No
);
// 编号
ENgetnodeid
(
i
,
No
);
// 编号
ENgetnodevalue
(
i
,
EN_QUALITY
,
quality
);
// 水质
float
quality
;
ENgetnodevalue
(
i
,
EN_QUALITY
,
&
quality
);
// 水质
mResultCache
.
addNodeQuality
(
*
quality
,
time
,
No
);
mResultCache
.
addNodeQuality
(
quality
,
time
,
No
);
}
}
free
(
quality
);
}
free
(
typeCode
);
}
}
void
CivHydrCompute
::
getLinkQuality
(
short
time
)
void
CivHydrCompute
::
getLinkQuality
(
short
time
)
...
@@ -339,6 +434,51 @@ void CivHydrCompute::getLinkQuality(short time)
...
@@ -339,6 +434,51 @@ void CivHydrCompute::getLinkQuality(short time)
free
(
typeCode
);
free
(
typeCode
);
}
}
void
CivHydrCompute
::
getNodeChlorine
(
short
time
)
{
int
nNodeCount
;
ENgetcount
(
EN_NODECOUNT
,
&
nNodeCount
);
int
*
typeCode
=
(
int
*
)
malloc
(
sizeof
(
int
));
for
(
int
i
=
1
;
i
<=
nNodeCount
;
i
++
)
{
ENgetnodetype
(
i
,
typeCode
);
if
(
*
typeCode
!=
EN_JUNCTION
)
continue
;
char
No
[
35
];
ENgetnodeid
(
i
,
No
);
// 编号
float
quality
;
ENgetnodevalue
(
i
,
EN_QUALITY
,
&
quality
);
// 水质
mResultCache
.
addNodeChlorine
(
quality
,
time
,
No
);
}
free
(
typeCode
);
}
void
CivHydrCompute
::
getLinkChlorine
(
short
time
)
{
int
nLinkCount
;
ENgetcount
(
EN_LINKCOUNT
,
&
nLinkCount
);
int
*
typeCode
=
(
int
*
)
malloc
(
sizeof
(
int
));
for
(
int
i
=
1
;
i
<=
nLinkCount
;
i
++
)
{
ENgetlinktype
(
i
,
typeCode
);
if
(
*
typeCode
!=
EN_PIPE
)
continue
;
char
lnkNo
[
35
];
ENgetlinkid
(
i
,
lnkNo
);
// 编号
float
quality
;
ENgetlinkvalue
(
i
,
EN_LINKQUAL
,
&
quality
);
// 水质
mResultCache
.
addLinkChlorine
(
quality
,
time
,
lnkNo
);
}
free
(
typeCode
);
}
void
CivHydrCompute
::
saveResult
(
const
std
::
string
&
uri
)
void
CivHydrCompute
::
saveResult
(
const
std
::
string
&
uri
)
{
{
...
...
pandaAnalysis/CivHydrCompute.h
View file @
aafa2bec
...
@@ -15,6 +15,7 @@ public:
...
@@ -15,6 +15,7 @@ public:
*/
*/
bool
qualityCompute
();
bool
qualityCompute
();
bool
chlorineCompute
();
/**
/**
*@brief 水力计算
*@brief 水力计算
*/
*/
...
@@ -36,9 +37,12 @@ private:
...
@@ -36,9 +37,12 @@ private:
void
getLinkResult
(
short
time
);
void
getLinkResult
(
short
time
);
void
getNodeQuality
(
short
time
);
void
getNodeQuality
(
short
time
);
void
getLinkQuality
(
short
time
);
void
getLinkQuality
(
short
time
);
void
getNodeChlorine
(
short
time
);
void
getLinkChlorine
(
short
time
);
void
dateAndTime
(
int
time
,
std
::
string
&
date
,
std
::
string
&
nowtime
);
void
dateAndTime
(
int
time
,
std
::
string
&
date
,
std
::
string
&
nowtime
);
CivSimulResultCache
mResultCache
;
CivSimulResultCache
mResultCache
;
std
::
string
mInFile
;
std
::
string
mInFile
;
std
::
string
mRptFile
;
std
::
string
mRptFile
;
std
::
string
mBinFile
;
std
::
string
mBinFile
;
...
...
pandaAnalysis/CivHydrSimulation.cpp
View file @
aafa2bec
...
@@ -34,7 +34,11 @@ bool CivHydrSimulation::qualitySimulation()
...
@@ -34,7 +34,11 @@ bool CivHydrSimulation::qualitySimulation()
{
{
CivSysLog
::
getInstance
()
->
info
(
"开始水质模拟"
,
"CivSysLog"
,
__FUNCTION__
);
CivSysLog
::
getInstance
()
->
info
(
"开始水质模拟"
,
"CivSysLog"
,
__FUNCTION__
);
CivSysLog
::
getInstance
()
->
info
(
"开始转inp文件"
,
"CivSysLog"
,
__FUNCTION__
);
CivSysLog
::
getInstance
()
->
info
(
"开始转inp文件"
,
"CivSysLog"
,
__FUNCTION__
);
CivInpConvertor
convertor
(
mUri
);
CivInpConvertor
convertor
(
mUri
);
// convertor.maintainTopo();
std
::
string
inpFileS
=
convertor
.
convertBaseInp
();
std
::
string
inpFileS
=
convertor
.
convertBaseInp
();
if
(
inpFileS
.
empty
()
||
inpFileS
==
""
)
if
(
inpFileS
.
empty
()
||
inpFileS
==
""
)
{
{
...
@@ -54,6 +58,19 @@ bool CivHydrSimulation::qualitySimulation()
...
@@ -54,6 +58,19 @@ bool CivHydrSimulation::qualitySimulation()
CivSysLog
::
getInstance
()
->
info
(
"计算成功"
,
"CivSysLog"
,
__FUNCTION__
);
CivSysLog
::
getInstance
()
->
info
(
"计算成功"
,
"CivSysLog"
,
__FUNCTION__
);
// 余氯计算
inpFileS
=
convertor
.
convertResidualInp
();
if
(
inpFileS
.
empty
()
||
inpFileS
==
""
)
{
CivSysLog
::
getInstance
()
->
error
(
"转inp文件失败"
,
"CivSysLog"
,
__FUNCTION__
);
return
false
;
}
if
(
!
mHydrCompute
.
chlorineCompute
())
{
CivSysLog
::
getInstance
()
->
error
(
"计算失败"
,
"CivSysLog"
,
__FUNCTION__
);
return
false
;
}
mHydrCompute
.
saveResult
(
mUri
);
mHydrCompute
.
saveResult
(
mUri
);
return
true
;
return
true
;
...
@@ -62,6 +79,7 @@ bool CivHydrSimulation::qualitySimulation()
...
@@ -62,6 +79,7 @@ bool CivHydrSimulation::qualitySimulation()
bool
CivHydrSimulation
::
trackingSimulation
(
char
*
snNode
,
int
hours
,
std
::
string
&
jsonResult
)
bool
CivHydrSimulation
::
trackingSimulation
(
char
*
snNode
,
int
hours
,
std
::
string
&
jsonResult
)
{
{
CivInpConvertor
convertor
(
mUri
);
CivInpConvertor
convertor
(
mUri
);
std
::
string
inpFileS
=
convertor
.
convertTrackInp
(
snNode
,
std
::
to_string
(
hours
));
std
::
string
inpFileS
=
convertor
.
convertTrackInp
(
snNode
,
std
::
to_string
(
hours
));
if
(
inpFileS
.
empty
())
if
(
inpFileS
.
empty
())
return
false
;
return
false
;
...
...
pandaAnalysis/CivInpBuilder.cpp
View file @
aafa2bec
...
@@ -80,6 +80,11 @@ void CivInpBuilder::setQuality(const std::string& name, const std::string& val)
...
@@ -80,6 +80,11 @@ void CivInpBuilder::setQuality(const std::string& name, const std::string& val)
mInitQuality
.
addItem
({
name
,
val
});
mInitQuality
.
addItem
({
name
,
val
});
}
}
void
CivInpBuilder
::
setQualityType
(
CivInpHelperAbs
::
QualityType
type
)
{
mHelper
->
setQualityType
(
type
);
}
void
CivInpBuilder
::
buildCurves
()
void
CivInpBuilder
::
buildCurves
()
{
{
}
}
...
...
pandaAnalysis/CivInpBuilder.h
View file @
aafa2bec
...
@@ -34,6 +34,7 @@ public:
...
@@ -34,6 +34,7 @@ public:
void
setReaction
(
const
std
::
string
&
name
,
const
std
::
string
&
val
);
void
setReaction
(
const
std
::
string
&
name
,
const
std
::
string
&
val
);
void
setQuality
(
const
std
::
string
&
name
,
const
std
::
string
&
val
);
void
setQuality
(
const
std
::
string
&
name
,
const
std
::
string
&
val
);
void
setQualityType
(
CivInpHelperAbs
::
QualityType
type
);
void
resetAllToZero
();
void
resetAllToZero
();
/**
/**
*@brief 返回装成的inp文件名
*@brief 返回装成的inp文件名
...
...
pandaAnalysis/CivInpConvertor.cpp
View file @
aafa2bec
...
@@ -16,16 +16,20 @@ CivInpConvertor::~CivInpConvertor()
...
@@ -16,16 +16,20 @@ CivInpConvertor::~CivInpConvertor()
}
}
std
::
string
CivInpConvertor
::
convertPorjInp
(
bool
CivInpConvertor
::
maintainTopo
()
const
std
::
string
&
projCode
,
const
std
::
string
&
start
)
{
{
CivHydrTableHelper
helper
(
mUri
);
CivHydrTableHelper
helper
(
mUri
);
if
(
!
helper
.
mainTain
())
if
(
!
helper
.
mainTain
())
{
{
return
""
;
return
false
;
}
}
return
true
;
}
std
::
string
CivInpConvertor
::
convertPorjInp
(
const
std
::
string
&
projCode
,
const
std
::
string
&
start
)
{
CivProjInpBuilder
*
builder
=
new
CivProjInpBuilder
(
mUri
);
CivProjInpBuilder
*
builder
=
new
CivProjInpBuilder
(
mUri
);
builder
->
setProjCode
(
projCode
);
builder
->
setProjCode
(
projCode
);
builder
->
setTimes
(
"Duration"
,
"0"
);
builder
->
setTimes
(
"Duration"
,
"0"
);
...
@@ -48,11 +52,6 @@ std::string CivInpConvertor::convertPorjInp(
...
@@ -48,11 +52,6 @@ std::string CivInpConvertor::convertPorjInp(
std
::
string
CivInpConvertor
::
convertBaseInp
()
std
::
string
CivInpConvertor
::
convertBaseInp
()
{
{
CivHydrTableHelper
helper
(
mUri
);
if
(
!
helper
.
mainTain
())
{
return
""
;
}
CivInpBuilder
*
builder
=
new
CivBaseInpBuilder
(
mUri
);
CivInpBuilder
*
builder
=
new
CivBaseInpBuilder
(
mUri
);
CivInpDirector
director
;
CivInpDirector
director
;
...
@@ -74,10 +73,10 @@ std::string CivInpConvertor::convertTrackInp(const std::string& sn,
...
@@ -74,10 +73,10 @@ std::string CivInpConvertor::convertTrackInp(const std::string& sn,
const
std
::
string
&
hours
)
const
std
::
string
&
hours
)
{
{
CivHydrTableHelper
helper
(
mUri
);
CivHydrTableHelper
helper
(
mUri
);
if
(
!
helper
.
mainTain
())
//
if (!helper.mainTain())
{
//
{
return
""
;
//
return "";
}
//
}
std
::
string
codeTosn
;
std
::
string
codeTosn
;
helper
.
getCodeToSn
(
sn
,
codeTosn
);
helper
.
getCodeToSn
(
sn
,
codeTosn
);
...
@@ -104,14 +103,30 @@ std::string CivInpConvertor::convertTrackInp(const std::string& sn,
...
@@ -104,14 +103,30 @@ std::string CivInpConvertor::convertTrackInp(const std::string& sn,
std
::
string
CivInpConvertor
::
convertAnalysisInp
()
std
::
string
CivInpConvertor
::
convertAnalysisInp
()
{
{
CivHydrTableHelper
helper
(
mUri
);
CivInpBuilder
*
builder
=
new
CivBaseInpBuilder
(
mUri
);
if
(
!
helper
.
mainTain
())
builder
->
setTimes
(
"Duration"
,
"1"
);
CivInpDirector
director
;
director
.
setBuilder
(
builder
);
director
.
create
();
std
::
string
inpFile
=
CivCommonUtils
::
getExePath
()
+
"
\\
test.inp"
;
if
(
!
builder
->
getNewInp
(
inpFile
))
{
{
delete
builder
;
return
""
;
return
""
;
}
}
delete
builder
;
return
inpFile
;
}
std
::
string
CivInpConvertor
::
convertResidualInp
()
{
CivInpBuilder
*
builder
=
new
CivBaseInpBuilder
(
mUri
);
CivInpBuilder
*
builder
=
new
CivBaseInpBuilder
(
mUri
);
builder
->
setTimes
(
"Duration"
,
"1"
);
builder
->
setQualityType
(
CivInpHelperAbs
::
Chlorine
);
builder
->
setOption
(
"Quality"
,
"Chlorine mg/L"
);
CivInpDirector
director
;
CivInpDirector
director
;
director
.
setBuilder
(
builder
);
director
.
setBuilder
(
builder
);
...
...
pandaAnalysis/CivInpConvertor.h
View file @
aafa2bec
...
@@ -12,6 +12,8 @@ public:
...
@@ -12,6 +12,8 @@ public:
explicit
CivInpConvertor
(
const
std
::
string
&
uri
);
explicit
CivInpConvertor
(
const
std
::
string
&
uri
);
~
CivInpConvertor
();
~
CivInpConvertor
();
bool
maintainTopo
();
/**
/**
*@brief 转成方案模拟的inp文件
*@brief 转成方案模拟的inp文件
*@param projCode 方案编码
*@param projCode 方案编码
...
@@ -34,6 +36,11 @@ public:
...
@@ -34,6 +36,11 @@ public:
std
::
string
convertAnalysisInp
();
std
::
string
convertAnalysisInp
();
/**
* 余氯分析
*/
std
::
string
convertResidualInp
();
private
:
private
:
std
::
string
mUri
;
std
::
string
mUri
;
};
};
\ No newline at end of file
pandaAnalysis/CivSimulResultCache.cpp
View file @
aafa2bec
...
@@ -116,3 +116,27 @@ void CivSimulResultCache::getCodeToSnMap(const std::string& uri)
...
@@ -116,3 +116,27 @@ void CivSimulResultCache::getCodeToSnMap(const std::string& uri)
helper
.
getNodeCodeSnMap
(
mNodeCodeSnMap
);
helper
.
getNodeCodeSnMap
(
mNodeCodeSnMap
);
helper
.
getLinCodeSnMap
(
mLineCodeSnMap
);
helper
.
getLinCodeSnMap
(
mLineCodeSnMap
);
}
}
void
CivSimulResultCache
::
addNodeChlorine
(
float
quality
,
int
interval
,
const
string
&
sNo
)
{
if
(
mNodeItemsMap
.
find
(
interval
)
==
mNodeItemsMap
.
end
())
return
;
auto
nodeMap
=
mNodeItemsMap
.
find
(
interval
)
->
second
;
if
(
nodeMap
.
find
(
sNo
)
==
nodeMap
.
end
())
return
;
mNodeItemsMap
[
interval
][
sNo
].
dChlorine
=
quality
;
}
void
CivSimulResultCache
::
addLinkChlorine
(
float
quality
,
int
interval
,
const
string
&
sNo
)
{
if
(
mLinkItemsMap
.
find
(
interval
)
==
mLinkItemsMap
.
end
())
return
;
auto
linkMap
=
mLinkItemsMap
.
find
(
interval
)
->
second
;
if
(
linkMap
.
find
(
sNo
)
==
linkMap
.
end
())
return
;
mLinkItemsMap
[
interval
][
sNo
].
dChlorine
=
quality
;
}
pandaAnalysis/CivSimulResultCache.h
View file @
aafa2bec
...
@@ -29,6 +29,11 @@ public:
...
@@ -29,6 +29,11 @@ public:
*/
*/
void
addLinkQuality
(
float
quality
,
int
interval
,
const
string
&
sNo
);
void
addLinkQuality
(
float
quality
,
int
interval
,
const
string
&
sNo
);
void
addNodeChlorine
(
float
quality
,
int
interval
,
const
string
&
sNo
);
void
addLinkChlorine
(
float
quality
,
int
interval
,
const
string
&
sNo
);
/**
/**
*@brief 缓存节点水力模拟情况
*@brief 缓存节点水力模拟情况
*@param nodeItem:节点水力结果值
*@param nodeItem:节点水力结果值
...
...
pandaDbManager/CivConnection.cpp
View file @
aafa2bec
...
@@ -29,9 +29,8 @@ bool CivConnection::update(const std::string& table,
...
@@ -29,9 +29,8 @@ bool CivConnection::update(const std::string& table,
}
}
sql
=
sql
.
substr
(
0
,
sql
.
length
()
-
1
);
sql
=
sql
.
substr
(
0
,
sql
.
length
()
-
1
);
std
::
string
utf8Sql
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
if
(
!
execSql
(
utf8S
ql
))
if
(
!
execSql
(
s
ql
))
return
false
;
return
false
;
return
true
;
return
true
;
...
@@ -43,8 +42,8 @@ bool CivConnection::del(const std::string& table, const std::string& where)
...
@@ -43,8 +42,8 @@ bool CivConnection::del(const std::string& table, const std::string& where)
return
false
;
return
false
;
std
::
string
sql
=
"delete from "
+
table
+
" where "
+
where
;
std
::
string
sql
=
"delete from "
+
table
+
" where "
+
where
;
std
::
string
utf8Sql
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
if
(
!
execSql
(
utf8S
ql
))
if
(
!
execSql
(
s
ql
))
return
false
;
return
false
;
return
true
;
return
true
;
...
@@ -86,9 +85,9 @@ bool CivConnection::insertBulk(const std::string& table,
...
@@ -86,9 +85,9 @@ bool CivConnection::insertBulk(const std::string& table,
}
}
sql
=
sql
.
substr
(
0
,
sql
.
length
()
-
1
);
sql
=
sql
.
substr
(
0
,
sql
.
length
()
-
1
);
std
::
string
utf8Sql
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
//2 执行插入操作
//2 执行插入操作
if
(
!
execSql
(
utf8S
ql
))
if
(
!
execSql
(
s
ql
))
return
false
;
return
false
;
return
true
;
return
true
;
...
@@ -121,9 +120,9 @@ bool CivConnection::insert(const std::string& table,
...
@@ -121,9 +120,9 @@ bool CivConnection::insert(const std::string& table,
sql
.
append
(
") VALUES"
);
sql
.
append
(
") VALUES"
);
sql
.
append
(
vals
);
sql
.
append
(
vals
);
std
::
string
utf8Sql
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
//2 执行插入操作
//2 执行插入操作
if
(
!
execSql
(
utf8S
ql
))
if
(
!
execSql
(
s
ql
))
return
false
;
return
false
;
return
true
;
return
true
;
...
@@ -156,9 +155,9 @@ bool CivConnection::query(const std::string& table,
...
@@ -156,9 +155,9 @@ bool CivConnection::query(const std::string& table,
sql
.
append
(
where
);
sql
.
append
(
where
);
}
}
std
::
string
utf8Sql
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
// 2 执行sql语句
// 2 执行sql语句
if
(
!
execSql
(
utf8S
ql
))
if
(
!
execSql
(
s
ql
))
{
{
return
false
;
return
false
;
}
}
...
...
pandaDbManager/CivHydrTableHelper.cpp
View file @
aafa2bec
...
@@ -20,7 +20,7 @@ CivHydrTableHelper::~CivHydrTableHelper()
...
@@ -20,7 +20,7 @@ CivHydrTableHelper::~CivHydrTableHelper()
bool
CivHydrTableHelper
::
mainTain
()
bool
CivHydrTableHelper
::
mainTain
()
{
{
unTopoMaintain
();
//
unTopoMaintain();
// 节点
// 节点
updateAssem
(
TABLE_NODE
,
std
::
string
(
"本点号"
),
"JD"
);
updateAssem
(
TABLE_NODE
,
std
::
string
(
"本点号"
),
"JD"
);
updateAssem
(
TABLE_PIPE
,
std
::
string
(
"编号"
),
"GD"
);
updateAssem
(
TABLE_PIPE
,
std
::
string
(
"编号"
),
"GD"
);
...
@@ -79,20 +79,12 @@ bool CivHydrTableHelper::topoMaintain()
...
@@ -79,20 +79,12 @@ bool CivHydrTableHelper::topoMaintain()
topoMainTable
(
TABLE_PIPE
,
TABLE_NODE
,
std
::
string
(
"终止节点"
),
std
::
string
(
"本点号"
),
std
::
string
(
"to_code"
));
topoMainTable
(
TABLE_PIPE
,
TABLE_NODE
,
std
::
string
(
"终止节点"
),
std
::
string
(
"本点号"
),
std
::
string
(
"to_code"
));
topoMainTable
(
TABLE_PIPE
,
TABLE_RESERVOIR
,
std
::
string
(
"起始节点"
),
std
::
string
(
"本点号"
),
std
::
string
(
"from_code"
));
topoMainTable
(
TABLE_PIPE
,
TABLE_RESERVOIR
,
std
::
string
(
"起始节点"
),
std
::
string
(
"本点号"
),
std
::
string
(
"from_code"
));
topoMainTable
(
TABLE_PIPE
,
TABLE_TANK
,
std
::
string
(
"起始节点"
),
std
::
string
(
"本点号"
),
std
::
string
(
"from_code"
));
topoMainTable
(
TABLE_PIPE
,
TABLE_TANK
,
std
::
string
(
"起始节点"
),
std
::
string
(
"本点号"
),
std
::
string
(
"from_code"
));
topoMainTable
(
TABLE_PIPE
,
TABLE_VALVEE
,
std
::
string
(
"起始节点"
),
std
::
string
(
"本点号"
),
std
::
string
(
"from_code"
));
topoMainTable
(
TABLE_PIPE
,
TABLE_VALVEE
,
std
::
string
(
"终止节点"
),
std
::
string
(
"本点号"
),
std
::
string
(
"to_code"
));
topoValve
(
std
::
string
(
"起始节点"
),
std
::
string
(
"from_code"
),
std
::
string
(
"to_code"
));
topoValve
(
std
::
string
(
"起始节点"
),
std
::
string
(
"from_code"
),
std
::
string
(
"to_code"
));
topoValve
(
std
::
string
(
"终止节点"
),
std
::
string
(
"to_code"
),
std
::
string
(
"from_code"
));
topoValve
(
std
::
string
(
"终止节点"
),
std
::
string
(
"to_code"
),
std
::
string
(
"from_code"
));
std
::
string
delSql
=
std
::
string
(
"update
\"
管段
\"
\
set
\"
起始节点
\"
= null,
\"
终止节点
\"
= null \
from
\"
阀门
\"
t1 where\
\"
to_code
\"
= t1.
\"
code
\"
or
\"
from_code
\"
= t1.
\"
code
\"
"
);
std
::
string
utfsql
=
CivCommonUtils
::
string_To_UTF8
(
delSql
);
if
(
mConn
&&
!
mConn
->
execSql
(
utfsql
))
{
mErrInfo
=
mConn
->
getLastError
();
return
false
;
}
return
true
;
return
true
;
}
}
...
@@ -118,8 +110,7 @@ bool CivHydrTableHelper::topoMainTable(const std::string& sourceTable,
...
@@ -118,8 +110,7 @@ bool CivHydrTableHelper::topoMainTable(const std::string& sourceTable,
\"
"
+
sourceTable
+
"
\"
.
\"
"
+
code
+
"
\"
= cqt.
\"
code
\"
"
;
\"
"
+
sourceTable
+
"
\"
.
\"
"
+
code
+
"
\"
= cqt.
\"
code
\"
"
;
std
::
string
utfsql
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
if
(
mConn
&&
!
mConn
->
execSql
(
sql
))
if
(
mConn
&&
!
mConn
->
execSql
(
utfsql
))
{
{
mErrInfo
=
mConn
->
getLastError
();
mErrInfo
=
mConn
->
getLastError
();
return
false
;
return
false
;
...
@@ -141,9 +132,7 @@ bool CivHydrTableHelper::topoValve(const std::string& sn,
...
@@ -141,9 +132,7 @@ bool CivHydrTableHelper::topoValve(const std::string& sn,
where
\"
code
\"
= dd.
\"
vacode
\"
"
);
where
\"
code
\"
= dd.
\"
vacode
\"
"
);
std
::
string
utfsql
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
if
(
mConn
&&
!
mConn
->
execSql
(
sql
))
if
(
mConn
&&
!
mConn
->
execSql
(
utfsql
))
{
{
mErrInfo
=
mConn
->
getLastError
();
mErrInfo
=
mConn
->
getLastError
();
return
false
;
return
false
;
...
@@ -169,8 +158,8 @@ bool CivHydrTableHelper::unTopoTable(const std::string& table, const std::vector
...
@@ -169,8 +158,8 @@ bool CivHydrTableHelper::unTopoTable(const std::string& table, const std::vector
}
}
sql
=
sql
.
substr
(
0
,
sql
.
length
()
-
1
);
sql
=
sql
.
substr
(
0
,
sql
.
length
()
-
1
);
std
::
string
utfsql
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
if
(
mConn
&&
!
mConn
->
execSql
(
utf
sql
))
if
(
mConn
&&
!
mConn
->
execSql
(
sql
))
{
{
mErrInfo
=
mConn
->
getLastError
();
mErrInfo
=
mConn
->
getLastError
();
return
false
;
return
false
;
...
@@ -182,8 +171,8 @@ bool CivHydrTableHelper::unTopoTable(const std::string& table, const std::vector
...
@@ -182,8 +171,8 @@ bool CivHydrTableHelper::unTopoTable(const std::string& table, const std::vector
void
CivHydrTableHelper
::
getCodeToSn
(
const
std
::
string
&
code
,
std
::
string
&
sn
)
void
CivHydrTableHelper
::
getCodeToSn
(
const
std
::
string
&
code
,
std
::
string
&
sn
)
{
{
std
::
string
sql
=
"select
\"
本点号
\"
from 节点 where code = '"
+
code
+
"'"
;
std
::
string
sql
=
"select
\"
本点号
\"
from 节点 where code = '"
+
code
+
"'"
;
std
::
string
utfsql
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
if
(
mConn
&&
!
mConn
->
execSql
(
utf
sql
))
if
(
mConn
&&
!
mConn
->
execSql
(
sql
))
{
{
mErrInfo
=
mConn
->
getLastError
();
mErrInfo
=
mConn
->
getLastError
();
return
;
return
;
...
...
pandaDbManager/CivInpDbHelper.cpp
View file @
aafa2bec
...
@@ -50,6 +50,77 @@ bool CivInpDbHelper::getPipe(CivPipe& pipes)
...
@@ -50,6 +50,77 @@ bool CivInpDbHelper::getPipe(CivPipe& pipes)
{
{
PipeTable
pipeTable
;
PipeTable
pipeTable
;
// 注意去重
// 查找与阀门像连的管段
std
::
string
sql
=
"select pipe.
\"
编号
\"
,pipe.
\"
起始节点
\"
,pipe.
\"
终止节点
\"
, \
pipe.
\"
管长
\"
, pipe.
\"
管径
\"
,pipe.
\"
摩阻系数
\"
,pipe.
\"
局损系数
\"
,pipe.
\"
初始状态
\"
,va.
\"
本点号
\"
, pipe.
\"
code
\"
,\
va.
\"
类型
\"
from
\"
管段
\"
as pipe,
\"
阀门
\"
as va where pipe.
\"
起始节点
\"
= va.
\"
本点号
\"
\
or pipe.
\"
终止节点
\"
= va.
\"
本点号
\"
order by
\"
本点号
\"
"
;
if
(
!
mDbConn
->
execSql
(
sql
))
{
return
false
;
}
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
string
>>
resultMap
;
mDbConn
->
queryResult
(
resultMap
);
int
toal
=
resultMap
.
size
();
std
::
string
repeatSn
;
std
::
string
repeatVaType
;
std
::
string
starNode
;
std
::
string
endNode
;
// 存储已拼接的管段CODE,为下面去重
std
::
set
<
std
::
string
>
filterSet
;
for
(
int
i
=
0
;
i
<
toal
;
i
++
)
{
std
::
map
<
std
::
string
,
std
::
string
>
tempMap
=
resultMap
[
i
];
std
::
string
sn
=
tempMap
.
find
(
"本点号"
)
->
second
;
std
::
string
vaType
=
tempMap
.
find
(
"类型"
)
->
second
;
std
::
string
pipeCode
=
tempMap
.
find
(
pipeTable
.
code
)
->
second
;
filterSet
.
insert
(
pipeCode
);
if
(
sn
==
repeatSn
&&
repeatVaType
==
vaType
&&
repeatVaType
==
"BV"
)
{
CivPipe
::
PipesTable
pipe
;
pipe
.
ID
=
tempMap
.
find
(
pipeTable
.
snNo
)
->
second
;
std
::
string
secondStartNode
=
tempMap
.
find
(
pipeTable
.
startPoint
)
->
second
;
std
::
string
secondEndNode
=
tempMap
.
find
(
pipeTable
.
endPoint
)
->
second
;
if
(
starNode
==
repeatSn
)
{
pipe
.
Node1
=
secondStartNode
;
pipe
.
Node2
=
endNode
;
}
else
if
(
endNode
==
repeatSn
)
{
pipe
.
Node1
=
starNode
;
pipe
.
Node2
=
secondEndNode
;
}
pipe
.
Length
=
tempMap
.
find
(
pipeTable
.
length
)
->
second
;
pipe
.
Diameter
=
tempMap
.
find
(
pipeTable
.
diameter
)
->
second
;
pipe
.
Roughness
=
tempMap
.
find
(
pipeTable
.
friction
)
->
second
;
pipe
.
MinorLoss
=
tempMap
.
find
(
pipeTable
.
localLoss
)
->
second
;
pipe
.
Status
=
tempMap
.
find
(
pipeTable
.
status
)
->
second
;
pipes
.
addItem
(
pipe
);
}
repeatVaType
=
vaType
;
repeatSn
=
sn
;
starNode
=
tempMap
.
find
(
pipeTable
.
startPoint
)
->
second
;
endNode
=
tempMap
.
find
(
pipeTable
.
endPoint
)
->
second
;
}
std
::
vector
<
std
::
string
>
fields
=
{
std
::
vector
<
std
::
string
>
fields
=
{
pipeTable
.
snNo
,
pipeTable
.
snNo
,
pipeTable
.
startPoint
,
pipeTable
.
startPoint
,
...
@@ -63,7 +134,18 @@ bool CivInpDbHelper::getPipe(CivPipe& pipes)
...
@@ -63,7 +134,18 @@ bool CivInpDbHelper::getPipe(CivPipe& pipes)
};
};
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
string
>>
resultVector
;
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
string
>>
resultVector
;
mDbConn
->
query
(
PIPELINE
,
fields
,
resultVector
,
mCondtion
);
std
::
string
condition
=
"
\"
code
\"
not in ("
;
for
(
auto
iter
=
filterSet
.
begin
();
iter
!=
filterSet
.
end
();
iter
++
)
{
std
::
string
code
=
*
iter
;
condition
.
append
(
"'"
+
code
+
"'"
);
condition
.
append
(
","
);
}
condition
=
condition
.
substr
(
0
,
condition
.
length
()
-
1
);
condition
.
append
(
")"
);
mDbConn
->
query
(
PIPELINE
,
fields
,
resultVector
,
condition
);
size_t
total
=
resultVector
.
size
();
size_t
total
=
resultVector
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
for
(
int
i
=
0
;
i
<
total
;
i
++
)
...
@@ -146,6 +228,10 @@ bool CivInpDbHelper::getValve(CivValve& valves)
...
@@ -146,6 +228,10 @@ 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
];
std
::
string
vaType
=
map
.
find
(
vaveTable
.
type
)
->
second
;
if
(
vaType
==
"BV"
)
continue
;
vave
.
ID
=
map
.
find
(
vaveTable
.
sn
)
->
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
;
...
@@ -259,8 +345,6 @@ bool CivInpDbHelper::getCoordinates(CivCoordinates& coord)
...
@@ -259,8 +345,6 @@ bool CivInpDbHelper::getCoordinates(CivCoordinates& coord)
return
true
;
return
true
;
}
}
bool
CivInpDbHelper
::
getQuality
(
CivQuality
&
quality
)
bool
CivInpDbHelper
::
getQuality
(
CivQuality
&
quality
)
{
{
JunctionTable
nodeTable
;
JunctionTable
nodeTable
;
...
@@ -268,7 +352,8 @@ bool CivInpDbHelper::getQuality(CivQuality& quality)
...
@@ -268,7 +352,8 @@ bool CivInpDbHelper::getQuality(CivQuality& quality)
std
::
vector
<
std
::
string
>
fields
=
std
::
vector
<
std
::
string
>
fields
=
{
{
nodeTable
.
sn
,
nodeTable
.
sn
,
nodeTable
.
initQuality
nodeTable
.
initQuality
,
nodeTable
.
chlorine
};
};
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
string
>>
resultVector
;
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
string
>>
resultVector
;
...
@@ -282,8 +367,18 @@ bool CivInpDbHelper::getQuality(CivQuality& quality)
...
@@ -282,8 +367,18 @@ bool CivInpDbHelper::getQuality(CivQuality& quality)
CivQuality
::
QualityTable
quliTable
;
CivQuality
::
QualityTable
quliTable
;
std
::
map
<
std
::
string
,
std
::
string
>
map
=
resultVector
[
i
];
std
::
map
<
std
::
string
,
std
::
string
>
map
=
resultVector
[
i
];
quliTable
.
ID
=
map
.
find
(
fields
[
0
])
->
second
;
quliTable
.
ID
=
map
.
find
(
nodeTable
.
sn
)
->
second
;
quliTable
.
InitQuality
=
map
.
find
(
fields
[
1
])
->
second
;;
switch
(
mQualityType
)
{
case
Chlorine
:
quliTable
.
InitQuality
=
map
.
find
(
nodeTable
.
chlorine
)
->
second
;
break
;
case
Age
:
default
:
quliTable
.
InitQuality
=
map
.
find
(
nodeTable
.
initQuality
)
->
second
;
break
;
}
quality
.
addItem
(
quliTable
);
quality
.
addItem
(
quliTable
);
}
}
...
...
pandaDbManager/CivInpHelperAbs.cpp
View file @
aafa2bec
...
@@ -7,6 +7,7 @@ CivInpHelperAbs::CivInpHelperAbs(const std::string& uri)
...
@@ -7,6 +7,7 @@ CivInpHelperAbs::CivInpHelperAbs(const std::string& uri)
{
{
mDbConn
=
new
CivPgDbConnection
();
mDbConn
=
new
CivPgDbConnection
();
mDbConn
->
connect
(
uri
);
mDbConn
->
connect
(
uri
);
mQualityType
=
Age
;
}
}
CivInpHelperAbs
::~
CivInpHelperAbs
()
CivInpHelperAbs
::~
CivInpHelperAbs
()
...
@@ -180,3 +181,8 @@ void CivInpHelperAbs::getSnToCode(std::map<std::string, std::string>& coord)
...
@@ -180,3 +181,8 @@ void CivInpHelperAbs::getSnToCode(std::map<std::string, std::string>& coord)
}
}
void
CivInpHelperAbs
::
setQualityType
(
QualityType
qualiType
)
{
mQualityType
=
qualiType
;
}
pandaDbManager/CivInpHelperAbs.h
View file @
aafa2bec
...
@@ -10,6 +10,13 @@ class CivConnection;
...
@@ -10,6 +10,13 @@ class CivConnection;
class
INPDLLEXPORT
CivInpHelperAbs
class
INPDLLEXPORT
CivInpHelperAbs
{
{
public
:
public
:
// 水质模拟时间
enum
QualityType
{
Age
,
// 水龄
Chlorine
// 余氯
};
explicit
CivInpHelperAbs
(
const
std
::
string
&
uri
);
explicit
CivInpHelperAbs
(
const
std
::
string
&
uri
);
virtual
~
CivInpHelperAbs
();
virtual
~
CivInpHelperAbs
();
...
@@ -36,7 +43,8 @@ public:
...
@@ -36,7 +43,8 @@ public:
bool
getMixing
(
CivMixing
&
mixing
);
bool
getMixing
(
CivMixing
&
mixing
);
bool
getParameter
(
std
::
vector
<
CivParameter
>&
param
);
bool
getParameter
(
std
::
vector
<
CivParameter
>&
param
);
bool
getEmitters
(
CivEmitters
&
emitter
);
bool
getEmitters
(
CivEmitters
&
emitter
);
void
setQualityType
(
QualityType
qualiType
);
protected
:
protected
:
QualityType
mQualityType
;
CivConnection
*
mDbConn
;
CivConnection
*
mDbConn
;
};
};
pandaDbManager/CivPgDbConnection.cpp
View file @
aafa2bec
...
@@ -58,15 +58,18 @@ bool CivPgDbConnection::queryResult(std::vector<std::map<std::string,std::string
...
@@ -58,15 +58,18 @@ bool CivPgDbConnection::queryResult(std::vector<std::map<std::string,std::string
bool
CivPgDbConnection
::
execSql
(
const
std
::
string
&
sql
)
bool
CivPgDbConnection
::
execSql
(
const
std
::
string
&
sql
)
{
{
if
(
!
mConn
)
if
(
!
mConn
||
sql
.
empty
()
)
return
false
;
return
false
;
mResult
=
PQexec
(
mConn
,
sql
.
c_str
());
std
::
string
utf8Sql
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
mResult
=
PQexec
(
mConn
,
utf8Sql
.
c_str
());
std
::
string
errorStr
=
PQresultErrorMessage
(
mResult
);
std
::
string
errorStr
=
PQresultErrorMessage
(
mResult
);
if
(
!
errorStr
.
empty
())
if
(
!
errorStr
.
empty
())
{
{
mLastError
=
errorStr
;
mLastError
=
errorStr
;
std
::
cout
<<
mLastError
<<
std
::
endl
;
PQclear
(
mResult
);
PQclear
(
mResult
);
return
false
;
return
false
;
}
}
...
...
pandaDbManager/CivSimuResStruct.h
View file @
aafa2bec
...
@@ -2,6 +2,13 @@
...
@@ -2,6 +2,13 @@
#include<string>
#include<string>
#include<map>
#include<map>
// 水质模拟时间
enum
QualityType
{
Age
,
// 水龄
Chlorine
// 余氯
};
struct
ResultItem
struct
ResultItem
{
{
std
::
string
code
;
std
::
string
code
;
...
@@ -9,6 +16,7 @@ struct ResultItem
...
@@ -9,6 +16,7 @@ struct ResultItem
std
::
string
dDate
;
std
::
string
dDate
;
std
::
string
dTime
;
std
::
string
dTime
;
float
dQuality
;
float
dQuality
;
float
dChlorine
;
std
::
string
dModifyTime
;
std
::
string
dModifyTime
;
};
};
...
...
pandaDbManager/CivSimulResDbHelper.cpp
View file @
aafa2bec
...
@@ -20,7 +20,8 @@ CivSimulResDbHelper::CivSimulResDbHelper(const std::string& uri)
...
@@ -20,7 +20,8 @@ CivSimulResDbHelper::CivSimulResDbHelper(const std::string& uri)
tableFields
.
dHead
,
tableFields
.
dHead
,
tableFields
.
dDate
,
tableFields
.
dDate
,
tableFields
.
dInterval
,
tableFields
.
dInterval
,
tableFields
.
dModifyTime
tableFields
.
dModifyTime
,
tableFields
.
chlorine
};
};
//
//
...
@@ -35,7 +36,8 @@ CivSimulResDbHelper::CivSimulResDbHelper(const std::string& uri)
...
@@ -35,7 +36,8 @@ CivSimulResDbHelper::CivSimulResDbHelper(const std::string& uri)
pipeFields
.
szStatus
,
pipeFields
.
szStatus
,
pipeFields
.
dDate
,
pipeFields
.
dDate
,
pipeFields
.
dInterval
,
pipeFields
.
dInterval
,
pipeFields
.
dModifyTime
pipeFields
.
dModifyTime
,
pipeFields
.
chlorine
};
};
}
}
...
@@ -63,7 +65,7 @@ bool CivSimulResDbHelper::insertNodes(const NodeResultItems& nodeitems)
...
@@ -63,7 +65,7 @@ bool CivSimulResDbHelper::insertNodes(const NodeResultItems& nodeitems)
vecRes
.
push_back
(
"
\'
"
+
nodeItem
.
dDate
+
"
\'
"
);
vecRes
.
push_back
(
"
\'
"
+
nodeItem
.
dDate
+
"
\'
"
);
vecRes
.
push_back
(
"
\'
"
+
nodeItem
.
dTime
+
"
\'
"
);
vecRes
.
push_back
(
"
\'
"
+
nodeItem
.
dTime
+
"
\'
"
);
vecRes
.
push_back
(
"
\'
"
+
CurrentTime
+
"
\'
"
);
vecRes
.
push_back
(
"
\'
"
+
CurrentTime
+
"
\'
"
);
vecRes
.
push_back
(
std
::
to_string
(
nodeItem
.
dChlorine
));
vecVec
.
push_back
(
vecRes
);
vecVec
.
push_back
(
vecRes
);
condition
=
"
\'
"
+
nodeItem
.
dTime
+
"
\'
"
;
condition
=
"
\'
"
+
nodeItem
.
dTime
+
"
\'
"
;
}
}
...
@@ -86,18 +88,19 @@ bool CivSimulResDbHelper::insertLinks(const LinkResultItems& linkMap)
...
@@ -86,18 +88,19 @@ bool CivSimulResDbHelper::insertLinks(const LinkResultItems& linkMap)
LinkResultItem
linkItem
=
iter
->
second
;
LinkResultItem
linkItem
=
iter
->
second
;
std
::
string
sn
=
linkItem
.
code
;
std
::
string
sn
=
linkItem
.
code
;
std
::
string
status
=
linkItem
.
szStatus
;
std
::
string
status
=
linkItem
.
szStatus
;
std
::
vector
<
std
::
string
>
vecRes
=
std
::
vector
<
std
::
string
>
vecRes
;
{
"
\'
"
+
sn
+
"
\'
"
,
vecRes
.
push_back
(
"
\'
"
+
sn
+
"
\'
"
);
std
::
to_string
(
linkItem
.
dFlow
),
vecRes
.
push_back
(
std
::
to_string
(
linkItem
.
dFlow
));
std
::
to_string
(
linkItem
.
dVelocity
),
vecRes
.
push_back
(
std
::
to_string
(
linkItem
.
dVelocity
));
std
::
to_string
(
linkItem
.
dHeadloss
),
vecRes
.
push_back
(
std
::
to_string
(
linkItem
.
dHeadloss
));
std
::
to_string
(
linkItem
.
dQuality
),
vecRes
.
push_back
(
std
::
to_string
(
linkItem
.
dQuality
));
"
\'
"
+
status
+
"
\'
"
,
vecRes
.
push_back
(
"
\'
"
+
status
+
"
\'
"
);
"
\'
"
+
linkItem
.
dDate
+
"
\'
"
,
vecRes
.
push_back
(
"
\'
"
+
linkItem
.
dDate
+
"
\'
"
);
"
\'
"
+
linkItem
.
dTime
+
"
\'
"
,
vecRes
.
push_back
(
"
\'
"
+
linkItem
.
dTime
+
"
\'
"
);
"
\'
"
+
CurrentTime
+
"
\'
"
vecRes
.
push_back
(
"
\'
"
+
CurrentTime
+
"
\'
"
);
};
vecRes
.
push_back
(
std
::
to_string
(
linkItem
.
dChlorine
));
vecVec
.
push_back
(
vecRes
);
vecVec
.
push_back
(
vecRes
);
condition
=
"
\'
"
+
linkItem
.
dTime
+
"
\'
"
;
condition
=
"
\'
"
+
linkItem
.
dTime
+
"
\'
"
;
}
}
...
...
pandaDbManager/CivTableFields.h
View file @
aafa2bec
...
@@ -54,6 +54,7 @@ typedef struct JunctionTableFileds
...
@@ -54,6 +54,7 @@ typedef struct JunctionTableFileds
Str
totalHead
=
"水头"
;
Str
totalHead
=
"水头"
;
Str
pressure
=
"压力"
;
Str
pressure
=
"压力"
;
Str
quality
=
"水质"
;
Str
quality
=
"水质"
;
Str
chlorine
=
"余氯"
;
}
JunctionTable
;
}
JunctionTable
;
/**
/**
...
@@ -84,6 +85,7 @@ typedef struct PipeTableFields
...
@@ -84,6 +85,7 @@ typedef struct PipeTableFields
Str
status
=
"状态"
;
Str
status
=
"状态"
;
Str
quality
=
"水质"
;
Str
quality
=
"水质"
;
Str
leakWater
=
"漏水量"
;
Str
leakWater
=
"漏水量"
;
Str
chlorine
=
"余氯"
;
}
PipeTable
;
}
PipeTable
;
/**
/**
...
@@ -157,6 +159,7 @@ typedef struct ResourcesTableFileds
...
@@ -157,6 +159,7 @@ typedef struct ResourcesTableFileds
Str
flow
=
"流量"
;
Str
flow
=
"流量"
;
Str
totalHead
=
"总水头"
;
Str
totalHead
=
"总水头"
;
Str
quality
=
"水质"
;
Str
quality
=
"水质"
;
Str
chlorine
=
"余氯"
;
}
ResourcesTable
;
}
ResourcesTable
;
/**
/**
...
@@ -194,6 +197,7 @@ typedef struct NodeResultTableField
...
@@ -194,6 +197,7 @@ typedef struct NodeResultTableField
Str
dDate
=
"日期"
;
Str
dDate
=
"日期"
;
Str
dInterval
=
"时间点"
;
Str
dInterval
=
"时间点"
;
Str
dModifyTime
=
"修改时间"
;
Str
dModifyTime
=
"修改时间"
;
Str
chlorine
=
"余氯"
;
}
NodeResultTable
;
}
NodeResultTable
;
/**
/**
...
@@ -211,6 +215,7 @@ typedef struct PipeResultTableField
...
@@ -211,6 +215,7 @@ typedef struct PipeResultTableField
Str
dDate
=
"日期"
;
Str
dDate
=
"日期"
;
Str
dInterval
=
"时间点"
;
Str
dInterval
=
"时间点"
;
Str
dModifyTime
=
"修改时间"
;
Str
dModifyTime
=
"修改时间"
;
Str
chlorine
=
"余氯"
;
}
PipeResultTable
;
}
PipeResultTable
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment