Commit 12ac51d2 authored by 刘乐's avatar 刘乐

删掉荣冗余的部分

parent 2dd32d84
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(36,5): warning MSB4211: 正在首次将属性“IntermediateOutputPath”设置为某个值,但已在“C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets (35,5)”处使用了该属性。
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(337,5): warning MSB4211: 正在首次将属性“CleanFile”设置为某个值,但已在“C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets (35,5)”处使用了该属性。
StdAfx.cpp
D:\work\hydr\hydraulicModel\DuiLib\Core\UIManager.h(45,2): warning C4091: “typedef ”: 没有声明变量时忽略“DuiLib::EVENTTYPE_UI”的左侧
UIActiveX.cpp
UIButton.cpp
D:\work\hydr\hydraulicModel\DuiLib\Control\UIButton.cpp(127,35): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
UICheckBox.cpp
UICombo.cpp
UIDateTime.cpp
D:\work\hydr\hydraulicModel\DuiLib\Control\UIDateTime.cpp(297,35): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
UIEdit.cpp
D:\work\hydr\hydraulicModel\DuiLib\Control\UIEdit.cpp(288,35): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
UIGifAnim.cpp
D:\work\hydr\hydraulicModel\DuiLib\Control\UIGifAnim.cpp(1,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
UILabel.cpp
UIList.cpp
D:\work\hydr\hydraulicModel\DuiLib\Control\UIList.cpp(1781,44): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
D:\work\hydr\hydraulicModel\DuiLib\Control\UIList.cpp(2417,48): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
UIOption.cpp
UIProgress.cpp
UIRichEdit.cpp
UIScrollBar.cpp
UISlider.cpp
D:\work\hydr\hydraulicModel\DuiLib\Control\UISlider.cpp(212,36): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
UIText.cpp
D:\work\hydr\hydraulicModel\DuiLib\Control\UIText.cpp(52,37): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
UITreeView.cpp
UIWebBrowser.cpp
UIBase.cpp
UIContainer.cpp
UIControl.cpp
D:\work\hydr\hydraulicModel\DuiLib\Core\UIControl.cpp(832,40): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
正在生成代码...
正在编译...
UIDlgBuilder.cpp
UIManager.cpp
D:\work\hydr\hydraulicModel\DuiLib\Core\UIManager.cpp(1045,39): warning C4838: 从“DWORD”转换到“LONG”需要收缩转换
D:\work\hydr\hydraulicModel\DuiLib\Core\UIManager.cpp(1045,48): warning C4838: 从“DWORD”转换到“LONG”需要收缩转换
UIMarkup.cpp
UIRender.cpp
D:\work\hydr\hydraulicModel\DuiLib\Core\UIRender.cpp(1196,61): warning C4838: 从“int”转换到“COLOR16”需要收缩转换
D:\work\hydr\hydraulicModel\DuiLib\Core\UIRender.cpp(1196,86): warning C4838: 从“int”转换到“COLOR16”需要收缩转换
D:\work\hydr\hydraulicModel\DuiLib\Core\UIRender.cpp(1196,111): warning C4838: 从“int”转换到“COLOR16”需要收缩转换
D:\work\hydr\hydraulicModel\DuiLib\Core\UIRender.cpp(1197,66): warning C4838: 从“int”转换到“COLOR16”需要收缩转换
D:\work\hydr\hydraulicModel\DuiLib\Core\UIRender.cpp(1197,92): warning C4838: 从“int”转换到“COLOR16”需要收缩转换
D:\work\hydr\hydraulicModel\DuiLib\Core\UIRender.cpp(1197,118): warning C4838: 从“int”转换到“COLOR16”需要收缩转换
UIChildLayout.cpp
UIHorizontalLayout.cpp
D:\work\hydr\hydraulicModel\DuiLib\Layout\UIHorizontalLayout.cpp(313,37): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
UITabLayout.cpp
UITileLayout.cpp
UIVerticalLayout.cpp
D:\work\hydr\hydraulicModel\DuiLib\Layout\UIVerticalLayout.cpp(306,37): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
UIlib.cpp
UIDelegate.cpp
Utils.cpp
WinImplBase.cpp
正在生成代码...
stb_image.c
XUnzip.cpp
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(1316,5): warning MSB8012: TargetPath(D:\work\hydr\hydraulicModel\DuiLib\.\Build\Release\DuiLib.dll) 与 Linker 的 OutputFile 属性值(D:\work\hydr\hydraulicModel\bin\DuiLib.dll)不匹配。这可能导致项目生成不正确。若要更正此问题,请确保 $(OutDir)、$(TargetName) 和 $(TargetExt) 属性值与 %(Link.OutputFile) 中指定的值匹配。
正在创建库 ../Lib/DuiLib.lib 和对象 ../Lib/DuiLib.exp
StdAfx.obj : error LNK2019: 无法解析的外部符号 "public: virtual __thiscall CWndShadow::~CWndShadow(void)" (??1CWndShadow@@UAE@XZ),函数 "public: virtual void * __thiscall CWndShadow::`vector deleting destructor'(unsigned int)" (??_ECWndShadow@@UAEPAXI@Z) 中引用了该符号
..\bin\DuiLib.dll : fatal error LNK1120: 1 个无法解析的外部命令
B^D:\WORK\HYDR\HYDRAULICMODEL\DUILIB\STDAFX.CPP
B^D:\WORK\HYDR\HYDRAULICMODEL\DUILIB\STDAFX.CPP
B^D:\WORK\HYDR\HYDRAULICMODEL\DUILIB\STDAFX.CPP
PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.27.29110:TargetPlatformVersion=10.0.18362.0:
Release|Win32|D:\work\hydr\hydraulicModel\|
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
......@@ -21,24 +21,23 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}</ProjectGuid>
<RootNamespace>DuiLib</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='UnicodeRelease|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v120_xp</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='UnicodeDebug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v120_xp</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v120_xp</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
......@@ -69,35 +68,31 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>11.0.61030.0</_ProjectFileVersion>
<_ProjectFileVersion>16.0.30523.133</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>..\..\hModelProgram\Program\</OutDir>
<IntDir>..\temp\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
<OutDir>.\Build\Release\</OutDir>
<IntDir>.\Build\Release\</IntDir>
<LinkIncremental>false</LinkIncremental>
<GenerateManifest>false</GenerateManifest>
<EmbedManifest>false</EmbedManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>.\Build\Debug\</OutDir>
<IntDir>.\Build\Debug\</IntDir>
<LinkIncremental>false</LinkIncremental>
<GenerateManifest>false</GenerateManifest>
<EmbedManifest>false</EmbedManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='UnicodeDebug|Win32'">
<OutDir>.\Build\Debug_u\</OutDir>
<IntDir>.\Build\Debug_u\</IntDir>
<LinkIncremental>false</LinkIncremental>
<GenerateManifest>false</GenerateManifest>
<EmbedManifest>false</EmbedManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='UnicodeRelease|Win32'">
<OutDir>.\Build\Release_u\</OutDir>
<IntDir>.\Build\Release_u\</IntDir>
<LinkIncremental>false</LinkIncremental>
<GenerateManifest>false</GenerateManifest>
<EmbedManifest>false</EmbedManifest>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Midl>
......@@ -118,34 +113,24 @@
<PrecompiledHeaderOutputFile>.\Build\Release/DuiLib.pch</PrecompiledHeaderOutputFile>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalIncludeDirectories>./;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0406</Culture>
</ResourceCompile>
<Link>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<OutputFile>../bin/DuiLib.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>.\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<BaseAddress>0x11000000</BaseAddress>
<ImportLibrary>$(OutDir)..\lib\$(TargetName).lib</ImportLibrary>
<ImportLibrary>../Lib/DuiLib.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>.\Release/DuiLib.bsc</OutputFile>
</Bscmake>
<PostBuildEvent>
<Command>copy /y $(ProjectDir)*.h $(OutDir)..\include\
copy /y $(ProjectDir)Core\*.h $(OutDir)..\include\Core
copy /y $(ProjectDir)Control\*.h $(OutDir)..\include\Control
copy /y $(ProjectDir)Layout\*.h $(OutDir)..\include\Layout
copy /y $(ProjectDir)Utils\*.h $(OutDir)..\include\Utils
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Midl>
......@@ -265,7 +250,35 @@ copy /y $(ProjectDir)Utils\*.h $(OutDir)..\include\Utils
</Bscmake>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Control\UIActiveX.cpp" />
<ClCompile Include="Control\UIButton.cpp" />
<ClCompile Include="Control\UICheckBox.cpp" />
<ClCompile Include="Control\UICombo.cpp" />
<ClCompile Include="Control\UIDateTime.cpp" />
<ClCompile Include="Control\UIEdit.cpp" />
<ClCompile Include="Control\UIGifAnim.cpp" />
<ClCompile Include="Control\UILabel.cpp" />
<ClCompile Include="Control\UIList.cpp" />
<ClCompile Include="Control\UIOption.cpp" />
<ClCompile Include="Control\UIProgress.cpp" />
<ClCompile Include="Control\UIRichEdit.cpp" />
<ClCompile Include="Control\UIScrollBar.cpp" />
<ClCompile Include="Control\UISlider.cpp" />
<ClCompile Include="Control\UIText.cpp" />
<ClCompile Include="Control\UITreeView.cpp" />
<ClCompile Include="Control\UIWebBrowser.cpp" />
<ClCompile Include="Core\UIBase.cpp" />
<ClCompile Include="Core\UIContainer.cpp" />
<ClCompile Include="Core\UIControl.cpp" />
<ClCompile Include="Core\UIDlgBuilder.cpp" />
<ClCompile Include="Core\UIManager.cpp" />
<ClCompile Include="Core\UIMarkup.cpp" />
<ClCompile Include="Core\UIRender.cpp" />
<ClCompile Include="Layout\UIChildLayout.cpp" />
<ClCompile Include="Layout\UIHorizontalLayout.cpp" />
<ClCompile Include="Layout\UITabLayout.cpp" />
<ClCompile Include="Layout\UITileLayout.cpp" />
<ClCompile Include="Layout\UIVerticalLayout.cpp" />
<ClCompile Include="StdAfx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeaderOutputFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Build\Debug/DuiLib.pch</PrecompiledHeaderOutputFile>
......@@ -275,7 +288,6 @@ copy /y $(ProjectDir)Utils\*.h $(OutDir)..\include\Utils
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='UnicodeRelease|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="UIlib.cpp" />
<ClCompile Include="Utils\WinImplBase.cpp" />
<ClCompile Include="Utils\stb_image.c">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
......@@ -288,7 +300,7 @@ copy /y $(ProjectDir)Utils\*.h $(OutDir)..\include\Utils
</ClCompile>
<ClCompile Include="Utils\UIDelegate.cpp" />
<ClCompile Include="Utils\Utils.cpp" />
<ClCompile Include="Utils\WndShadow.cpp" />
<ClCompile Include="Utils\WinImplBase.cpp" />
<ClCompile Include="Utils\XUnzip.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
......@@ -299,59 +311,8 @@ copy /y $(ProjectDir)Utils\*.h $(OutDir)..\include\Utils
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='UnicodeRelease|Win32'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Core\UIBase.cpp" />
<ClCompile Include="Core\UIContainer.cpp" />
<ClCompile Include="Core\UIControl.cpp" />
<ClCompile Include="Core\UIDlgBuilder.cpp" />
<ClCompile Include="Core\UIManager.cpp" />
<ClCompile Include="Core\UIMarkup.cpp" />
<ClCompile Include="Core\UIRender.cpp" />
<ClCompile Include="Layout\UIChildLayout.cpp" />
<ClCompile Include="Layout\UIHorizontalLayout.cpp" />
<ClCompile Include="Layout\UITabLayout.cpp" />
<ClCompile Include="Layout\UITileLayout.cpp" />
<ClCompile Include="Layout\UIVerticalLayout.cpp" />
<ClCompile Include="Control\UIActiveX.cpp" />
<ClCompile Include="Control\UIButton.cpp" />
<ClCompile Include="Control\UICheckBox.cpp" />
<ClCompile Include="Control\UICombo.cpp" />
<ClCompile Include="Control\UIDateTime.cpp" />
<ClCompile Include="Control\UIEdit.cpp" />
<ClCompile Include="Control\UIGifAnim.cpp" />
<ClCompile Include="Control\UILabel.cpp" />
<ClCompile Include="Control\UIList.cpp" />
<ClCompile Include="Control\UIOption.cpp" />
<ClCompile Include="Control\UIProgress.cpp" />
<ClCompile Include="Control\UIRichEdit.cpp" />
<ClCompile Include="Control\UIScrollBar.cpp" />
<ClCompile Include="Control\UISlider.cpp" />
<ClCompile Include="Control\UIText.cpp" />
<ClCompile Include="Control\UIWebBrowser.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Control\UITreeView.h" />
<ClInclude Include="StdAfx.h" />
<ClInclude Include="UIlib.h" />
<ClInclude Include="Utils\downloadmgr.h" />
<ClInclude Include="Utils\FlashEventHandler.h" />
<ClInclude Include="Utils\stb_image.h" />
<ClInclude Include="Utils\UIDelegate.h" />
<ClInclude Include="Utils\Utils.h" />
<ClInclude Include="Utils\WebBrowserEventHandler.h" />
<ClInclude Include="Utils\WinImplBase.h" />
<ClInclude Include="Core\UIBase.h" />
<ClInclude Include="Core\UIContainer.h" />
<ClInclude Include="Core\UIControl.h" />
<ClInclude Include="Core\UIDefine.h" />
<ClInclude Include="Core\UIDlgBuilder.h" />
<ClInclude Include="Core\UIManager.h" />
<ClInclude Include="Core\UIMarkup.h" />
<ClInclude Include="Core\UIRender.h" />
<ClInclude Include="Layout\UIChildLayout.h" />
<ClInclude Include="Layout\UIHorizontalLayout.h" />
<ClInclude Include="Layout\UITabLayout.h" />
<ClInclude Include="Layout\UITileLayout.h" />
<ClInclude Include="Layout\UIVerticalLayout.h" />
<ClInclude Include="Control\UIActiveX.h" />
<ClInclude Include="Control\UIButton.h" />
<ClInclude Include="Control\UICheckBox.h" />
......@@ -367,8 +328,30 @@ copy /y $(ProjectDir)Utils\*.h $(OutDir)..\include\Utils
<ClInclude Include="Control\UIScrollBar.h" />
<ClInclude Include="Control\UISlider.h" />
<ClInclude Include="Control\UIText.h" />
<ClInclude Include="Control\UITreeView.h" />
<ClInclude Include="Control\UIWebBrowser.h" />
<ClInclude Include="Utils\WndShadow.h" />
<ClInclude Include="Core\UIBase.h" />
<ClInclude Include="Core\UIContainer.h" />
<ClInclude Include="Core\UIControl.h" />
<ClInclude Include="Core\UIDefine.h" />
<ClInclude Include="Core\UIDlgBuilder.h" />
<ClInclude Include="Core\UIManager.h" />
<ClInclude Include="Core\UIMarkup.h" />
<ClInclude Include="Core\UIRender.h" />
<ClInclude Include="Layout\UIChildLayout.h" />
<ClInclude Include="Layout\UIHorizontalLayout.h" />
<ClInclude Include="Layout\UITabLayout.h" />
<ClInclude Include="Layout\UITileLayout.h" />
<ClInclude Include="Layout\UIVerticalLayout.h" />
<ClInclude Include="StdAfx.h" />
<ClInclude Include="UIlib.h" />
<ClInclude Include="Utils\downloadmgr.h" />
<ClInclude Include="Utils\FlashEventHandler.h" />
<ClInclude Include="Utils\stb_image.h" />
<ClInclude Include="Utils\UIDelegate.h" />
<ClInclude Include="Utils\Utils.h" />
<ClInclude Include="Utils\WebBrowserEventHandler.h" />
<ClInclude Include="Utils\WinImplBase.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
......
......@@ -2,39 +2,39 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{7d17d310-9655-4640-9d72-abb7c0fe0bc6}</UniqueIdentifier>
<UniqueIdentifier>{5b27eb95-a601-4dda-af77-f2776f1ebf19}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter>
<Filter Include="Source Files\Utils">
<UniqueIdentifier>{1e313975-0756-4625-a65a-297ff225ada1}</UniqueIdentifier>
<UniqueIdentifier>{f89c670d-3c5c-4a83-9cd3-d9a450e04f9f}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Core">
<UniqueIdentifier>{f7184c42-483c-41c1-a76d-59a5a9f76ee4}</UniqueIdentifier>
<UniqueIdentifier>{14f59ead-5602-45a3-958e-36dfaecf4cf4}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Layout">
<UniqueIdentifier>{3e8f088f-a5b6-40e1-8042-40354cc25b8d}</UniqueIdentifier>
<UniqueIdentifier>{8298e5f9-fb12-4bd6-9994-85fa350e9745}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Control">
<UniqueIdentifier>{eaa8f7be-293a-46de-834f-071a9a441a28}</UniqueIdentifier>
<UniqueIdentifier>{20efef9d-1462-4f6f-96a6-c40bd63d2e70}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{44fffdff-1307-447a-873d-d0cc2e94a7ce}</UniqueIdentifier>
<UniqueIdentifier>{f7ba34b1-ba61-405a-916a-322aff7191a3}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
<Filter Include="Header Files\Utils">
<UniqueIdentifier>{2f0ac3de-1412-4d51-a46c-59a70d45e4b5}</UniqueIdentifier>
<UniqueIdentifier>{4e21ae8a-9b4d-4b54-8ad8-a3d4eafb767e}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Core">
<UniqueIdentifier>{f7a96342-a157-41bb-a57d-d283f6a9b11e}</UniqueIdentifier>
<UniqueIdentifier>{0c40e815-995c-4ace-8b97-27e8d5c46dd2}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Layout">
<UniqueIdentifier>{7e3238a6-3b1f-4c5a-9454-15ebb7dd7290}</UniqueIdentifier>
<UniqueIdentifier>{223f4dc0-41f9-4aac-8275-2ff4da55c9fe}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Control">
<UniqueIdentifier>{9d25d6fa-9ff9-4ebd-a5a9-20302dd1c58a}</UniqueIdentifier>
<UniqueIdentifier>{5a864c61-53d3-4bc2-959f-712e055c5c14}</UniqueIdentifier>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{c6069066-0c47-4447-90dc-5ca0e3e72cc6}</UniqueIdentifier>
<UniqueIdentifier>{1a004266-89c5-4c79-a130-cdf4071e5184}</UniqueIdentifier>
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
</Filter>
</ItemGroup>
......@@ -54,6 +54,9 @@
<ClCompile Include="Utils\Utils.cpp">
<Filter>Source Files\Utils</Filter>
</ClCompile>
<ClCompile Include="Utils\WinImplBase.cpp">
<Filter>Source Files\Utils</Filter>
</ClCompile>
<ClCompile Include="Utils\XUnzip.cpp">
<Filter>Source Files\Utils</Filter>
</ClCompile>
......@@ -111,6 +114,9 @@
<ClCompile Include="Control\UIEdit.cpp">
<Filter>Source Files\Control</Filter>
</ClCompile>
<ClCompile Include="Control\UIGifAnim.cpp">
<Filter>Source Files\Control</Filter>
</ClCompile>
<ClCompile Include="Control\UILabel.cpp">
<Filter>Source Files\Control</Filter>
</ClCompile>
......@@ -135,19 +141,10 @@
<ClCompile Include="Control\UIText.cpp">
<Filter>Source Files\Control</Filter>
</ClCompile>
<ClCompile Include="Control\UIWebBrowser.cpp">
<Filter>Source Files\Control</Filter>
</ClCompile>
<ClCompile Include="Control\UIGifAnim.cpp">
<ClCompile Include="Control\UITreeView.cpp">
<Filter>Source Files\Control</Filter>
</ClCompile>
<ClCompile Include="Utils\WndShadow.cpp">
<Filter>Source Files\Utils</Filter>
</ClCompile>
<ClCompile Include="Utils\WinImplBase.cpp">
<Filter>Source Files\Utils</Filter>
</ClCompile>
<ClCompile Include="Control\UITreeView.cpp">
<ClCompile Include="Control\UIWebBrowser.cpp">
<Filter>Source Files\Control</Filter>
</ClCompile>
</ItemGroup>
......@@ -236,6 +233,9 @@
<ClInclude Include="Control\UIEdit.h">
<Filter>Header Files\Control</Filter>
</ClInclude>
<ClInclude Include="Control\UIGifAnim.h">
<Filter>Header Files\Control</Filter>
</ClInclude>
<ClInclude Include="Control\UILabel.h">
<Filter>Header Files\Control</Filter>
</ClInclude>
......@@ -260,16 +260,10 @@
<ClInclude Include="Control\UIText.h">
<Filter>Header Files\Control</Filter>
</ClInclude>
<ClInclude Include="Control\UIWebBrowser.h">
<Filter>Header Files\Control</Filter>
</ClInclude>
<ClInclude Include="Control\UIGifAnim.h">
<ClInclude Include="Control\UITreeView.h">
<Filter>Header Files\Control</Filter>
</ClInclude>
<ClInclude Include="Utils\WndShadow.h">
<Filter>Header Files\Utils</Filter>
</ClInclude>
<ClInclude Include="Control\UITreeView.h">
<ClInclude Include="Control\UIWebBrowser.h">
<Filter>Header Files\Control</Filter>
</ClInclude>
</ItemGroup>
......
......@@ -3,7 +3,6 @@
namespace DuiLib
{
enum UILIB_RESOURCETYPE
{
UILIB_FILE=1, // 来自磁盘文件
......
......@@ -8,12 +8,35 @@ CivHydrTest::~CivHydrTest()
}
void CivNetTopoTest::test(char* uri)
{
char error[256];
bool res = netTopo(uri, error);
std::cout << "测试结果" << res << std::endl;
}
void CivResdualChrolmeTest::test(char* uri)
{
// {"startTime":'',"endTime":'',"水池":[{"code":'',"余氯量":},{"code":'',"余氯量":}]}
std::string conditionMap = "{\"TK0000001\":50,\"TK0000002\":100}";
std::string startTimeStr = "2021-01-19 00:00:00";
std::string endTimeStr = "2021-01-19 24:00:00";
char* condition = const_cast<char*>(conditionMap.c_str());
char* startTime = const_cast<char*>(startTimeStr.c_str());
char* endTime = const_cast<char*>(endTimeStr.c_str());
char error[250];
bool res = residualChlorineAnalysis(uri, startTime, endTime,condition, error);
std::cout << "测试结果" << res << std::endl;
std::cout << error << std::endl;
}
// 优化调度测试
void CivOptSchedulingTest::test(char* uri)
{
std::string condtionMap = "{\"bcdd358e-1925-47be-8e20-d93999e33c1c\":{\"min\":30, \"max\" : 40}, \
\"fd605205-c10e-4f7e-81a4-89c88166e763\" : {\"min\":50, \"max\" : 60}, \"c446cc2c-4110-406a-bda1-4f9544e38cb4\" : {\"min\":70, \"max\" : 80}}";
// std::string condtionMap = "{\"JD0000159\":{\"min\":20,\"max\":48},\"JD0000324\":{\"min\":20,\"max\":48},\"JD0000416\":{\"min\":20,\"max\":48},\"JD0000422\":{\"min\":20,\"max\":48},\"JD0000457\":{\"min\":20,\"max\":48},\"JD0000532\":{\"min\":20,\"max\":48},\"JD0000538\":{\"min\":20,\"max\":48},\"JD0000582\":{\"min\":20,\"max\":48},\"JD0000648\":{\"min\":20,\"max\":48},\"JD0000652\":{\"min\":20,\"max\":48},\"JD0000665\":{\"min\":20,\"max\":48},\"JD0000703\":{\"min\":20,\"max\":48},\"JD0000724\":{\"min\":20,\"max\":48}}";
int time = 17;
char* condition = const_cast<char*>(condtionMap.c_str());
......@@ -110,10 +133,10 @@ void CivProjSimulationTest::test(char* uri)
{
// 追踪节点编号
char projCode[512];
strcpy(projCode, "aedbda8f-29fd-40ef-bb7e-961eed178f35");
strcpy(projCode, "e9443d7f-d05b-4768-94b7-084a5d0fe3ba");
char time[512];
strcpy(time, "2020-12-14 15:00:00");
strcpy(time, "2021-1-27 11:00:00");
bool isSucc = projSimulation(uri, projCode, time);
......
......@@ -8,6 +8,20 @@ public:
virtual ~CivHydrTest();
};
// 拓扑维护
class CivNetTopoTest :public CivHydrTest
{
public:
virtual void test(char* uri);
};
// 余氯分析测试
class CivResdualChrolmeTest :public CivHydrTest
{
public:
virtual void test(char* uri);
};
// 优化调度测试
class CivOptSchedulingTest :public CivHydrTest
{
......
......@@ -62,6 +62,8 @@ int main(int argc, char* argv[])
cout << "\t6.水源供水范围分析\n";
cout << "\t7.方案模拟\n";
cout << "\t8.优化调度测试\n";
cout << "\t9.余氯分析测试\n";
cout << "\t10.拓扑维护测试\n";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
int test_no;
......@@ -112,6 +114,17 @@ int main(int argc, char* argv[])
context.setHydrTest(new CivOptSchedulingTest());
context.contextTest(findUri);
break;
case 9: // 8 优化调度测试
context.setHydrTest(new CivResdualChrolmeTest());
context.contextTest(findUri);
break;
case 10: // 拓扑维护
context.setHydrTest(new CivNetTopoTest());
context.contextTest(findUri);
break;
default:
cout << "输入测试号错误!" << endl;
break;
......@@ -120,5 +133,7 @@ int main(int argc, char* argv[])
cout << (end - start)/1000 << endl;
}
return 0;
}
\ No newline at end of file
......@@ -22,10 +22,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pandaWaterCore", "pandaWate
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pandaInpCore", "pandaInpCore\pandaInpCore.vcxproj", "{1363870B-C5EC-4A75-B73E-3D71F6D60052}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DuiLib", "DuiLib\DuiLib.vcxproj", "{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pandaWater", "pandaWater\pandaWater.vcxproj", "{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -218,44 +214,6 @@ Global
{1363870B-C5EC-4A75-B73E-3D71F6D60052}.UnicodeRelease|x64.Build.0 = Release|x64
{1363870B-C5EC-4A75-B73E-3D71F6D60052}.UnicodeRelease|x86.ActiveCfg = Release|Win32
{1363870B-C5EC-4A75-B73E-3D71F6D60052}.UnicodeRelease|x86.Build.0 = Release|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|Any CPU.ActiveCfg = Debug|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|x64.ActiveCfg = Debug|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|x86.ActiveCfg = Debug|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|x86.Build.0 = Debug|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|Any CPU.ActiveCfg = Release|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|x64.ActiveCfg = Release|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|x86.ActiveCfg = Release|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|x86.Build.0 = Release|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeDebug|Any CPU.ActiveCfg = UnicodeDebug|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeDebug|x64.ActiveCfg = UnicodeDebug|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeDebug|x86.ActiveCfg = UnicodeDebug|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeDebug|x86.Build.0 = UnicodeDebug|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeRelease|Any CPU.ActiveCfg = UnicodeRelease|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeRelease|x64.ActiveCfg = UnicodeRelease|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeRelease|x86.ActiveCfg = UnicodeRelease|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeRelease|x86.Build.0 = UnicodeRelease|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Debug|Any CPU.ActiveCfg = Debug|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Debug|x64.ActiveCfg = Debug|x64
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Debug|x64.Build.0 = Debug|x64
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Debug|x86.ActiveCfg = Debug|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Debug|x86.Build.0 = Debug|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Release|Any CPU.ActiveCfg = Release|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Release|x64.ActiveCfg = Release|x64
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Release|x64.Build.0 = Release|x64
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Release|x86.ActiveCfg = Release|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Release|x86.Build.0 = Release|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeDebug|Any CPU.ActiveCfg = Debug|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeDebug|Any CPU.Build.0 = Debug|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeDebug|x64.ActiveCfg = Debug|x64
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeDebug|x64.Build.0 = Debug|x64
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeDebug|x86.ActiveCfg = Debug|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeDebug|x86.Build.0 = Debug|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeRelease|Any CPU.ActiveCfg = Debug|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeRelease|Any CPU.Build.0 = Debug|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeRelease|x64.ActiveCfg = Release|x64
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeRelease|x64.Build.0 = Release|x64
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeRelease|x86.ActiveCfg = Release|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeRelease|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
#pragma once
/**
ڽӱ
*/
template<typename T>
class Bag {
public:
T operator[](int i)
{
}
};
#pragma once
#include <string>
#include "Iterator.h"
/**
无向图定义
*/
template<typename T,typename V>
class Graph {
explicit Graph(int v);
// 定点数
int V() const
{
return mV;
}
// 边数
int E() const;
{
return mE;
}
void addEdage(int v, int w)
{
}
Iterator<T> adj(V v);
std::string toString();
private:
int mV; // 顶点数目
int mE; // 边的数目
};
#pragma once
/**
*/
template<class T>
class Iterator {
public:
Iterator(T* p, int c) :data(p), len(c) {}
int valid() const
{
return len > 0;
}
T next()
{
--len;
return *data++;
}
private:
T* data;
int len;
};
......@@ -152,9 +152,12 @@ copy OptScheduling.h $(OutDir)..\include /y</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Bag.h" />
<ClInclude Include="FirstOptScheduling.h" />
<ClInclude Include="GenAlg.h" />
<ClInclude Include="Genome.h" />
<ClInclude Include="Graph.h" />
<ClInclude Include="Iterator.h" />
<ClInclude Include="OptScheduling.h" />
<ClInclude Include="pandaAlgorithm.h" />
<ClInclude Include="SecondOptScheduling.h" />
......
......@@ -33,6 +33,15 @@
<ClInclude Include="SecondOptScheduling.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Graph.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Iterator.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Bag.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="OptScheduling.cpp">
......
#include "CivDynamicCompute.h"
#include "epanet2.h"
#include "types.h"
#include "CivSysLog.h"
#include "StringUtils.h"
#include<map>
#include<string>
#include <regex>
CivDynamicCompute::CivDynamicCompute()
{
mRptFile = "test.rpt";
mBinFile = "test.bin";
}
bool CivDynamicCompute::openFile(ConstStringRef fileName)
{
char inpFile[256];
strcpy_s(inpFile, fileName.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__);
mErrcode = ENopen(inpFile, rptFile, binFile);
if (mErrcode > 0)
{
CivSysLog::getInstance()->error("ENopen 失败", "CivHydrCompute", __FUNCTION__);
ENclose();
return false;
}
if (ENopenH() > 0)
{
CivSysLog::getInstance()->error("ENopenH 失败", "CivHydrCompute", __FUNCTION__);
ENclose();
return false;
}
// 将所有节点水质清零
resetQuality();
return true;
}
bool CivDynamicCompute::beginCompute()
{
return true;
}
void CivDynamicCompute::endCompute()
{
ENcloseH();
ENclose();
}
void CivDynamicCompute::updatePumpSpeed(ConstStringRef pcode, float speeds)
{
}
bool CivDynamicCompute::compute(int startTime, int endTime)
{
short hydCode = 1;
long t(0), tstep(0);
int iTime(0);
int errcode = 0;
if (ENinitH(EN_SAVE) > 0)
{
CivSysLog::getInstance()->error("ENinitH 失败", "CivHydrCompute", __FUNCTION__);
ENclose();
return false;
}
float dHStep;
ENGetVal(4, &dHStep);
do
{
if (ENrunH(&t) > 100) // 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;
}
if (iTime == startTime)
{
std::map<std::string, float>::iterator iter = mWaterSourcesMap.begin();
for (; iter != mWaterSourcesMap.end(); iter++)
{
addWaterResiChlorine(iter->first, iter->second);
}
}
// 满足条件保存
if (iTime>=startTime && iTime<=endTime)
{
saveResult(iTime);
}
iTime++;
ENstepQ(&tstep);
} while (tstep > 0);
ENcloseQ();
ENclose();
return true;
}
bool CivDynamicCompute::saveResult(int iTime)
{
// 计算节点
int nNodeCount;
ENgetcount(EN_NODECOUNT, &nNodeCount);
std::map<std::string, float> qualityMap;
for (int i = 1; i <= nNodeCount; i++)
{
char szNo[256];
ENgetnodeid(i, szNo);// 编号
float quality;
ENgetnodevalue(i, EN_QUALITY, &quality); // 获取水质
qualityMap.insert(std::pair<std::string, double>(szNo, quality));
}
std::string ontheHourStr = onTheHour(iTime);
mSimulQualityMap.insert(std::pair<std::string, std::map<std::string, float>>(ontheHourStr, qualityMap));
return true;
}
std::string CivDynamicCompute::onTheHour(int iTime)
{
if (iTime < 0 || iTime>24)
return "";
std::string repStr;
if (iTime < 10)
repStr = "0" + std::to_string(iTime) + ":00:00";
else
repStr = std::to_string(iTime) + ":00:00";
std::string dateHour = mStartTime;
std::vector<std::string> strVec;
StringUtils::split(mStartTime, strVec);
if (strVec.size() <= 0)
return mStartTime;
std::string dateStr = strVec[0];
repStr = std::to_string(iTime) + ":00:00";
return dateStr +" "+repStr;
}
void CivDynamicCompute::addWaterResiChlorine(const std::string& pid, float density)
{
int nLinkCount;
ENgetcount(EN_NODECOUNT, &nLinkCount);
for (int i = 1; i <= nLinkCount; i++)
{
// 获取节点类型
char id[128];
ENgetnodeid(i, id);
// 根据id添加余氯量
if (strcmp(id, pid.c_str()) == 0)
{
ENsetnodevalue(i, EN_INITQUAL, density);
}
}
}
void CivDynamicCompute::updateQuality(const std::map<std::string, float>& waterSources)
{
mWaterSourcesMap = waterSources;
}
void CivDynamicCompute::resetQuality()
{
int nNodeCount;
ENgetcount(EN_NODECOUNT, &nNodeCount);
for (int i = 1; i <= nNodeCount; i++)
{
ENsetnodevalue(i, EN_INITQUAL, 0);
}
}
void CivDynamicCompute::simulResult(std::map<std::string, std::map<std::string, float>>& resultMap) const
{
resultMap = mSimulQualityMap;
}
\ No newline at end of file
#pragma once
#include <string>
#include <map>
/**
水力动态计算类
*/
class CivDynamicCompute
{
public:
typedef std::string String;
typedef String& StringRef;
typedef const StringRef ConstStringRef;
CivDynamicCompute();
/**
* @brief 加载inp文件
* @param [fileName] inp文件名
* @return 打开加载inp文件成功返回True,否则返回False
*/
bool openFile(ConstStringRef fileName);
/**
* @brief 开始执行水质计算,做一些初始化工作
*/
bool beginCompute();
/**
* @brief 结束水质计算,做一些清理工作
*/
void endCompute();
/**
* @brief 获取某个四段某个时段的
* @param [startTime] 开始时间
* @param [endTime] 结束时刻
*/
bool compute(int startTime, int endTime);
/**
* @brief 更新水泵的转速比
* @param [pcode] 水泵标识
* @param [speeds] 转速比数值
*/
void updatePumpSpeed(ConstStringRef pcode, float speeds);
/**
* @brief 需要更新的水池的水质
* @param [waterSources] 水源编号和水质
*/
void updateQuality(const std::map<std::string, float>& waterSources);
void setStartTime(const std::string& startTime) { mStartTime = startTime; }
void setEndTime(const std::string& endTime) { mEndTime = endTime; }
/**
*@brief 获取模拟结果
* @param[resultMap] 存储模拟的结果
*/
void simulResult(std::map<std::string, std::map<std::string, float>>& resultMap) const;
private:
/**
* @brief 给水源添加余氯量
* @param [sourceType] 水源类型,水池或者水库
* @param [pid] 水源的编码
* @param [density] 余氯浓度
*/
void addWaterResiChlorine(const std::string& pid, float density);
/**
*@brief 初始化水质,将所有节点水质初始化为0
*/
void resetQuality();
/**
* @brief 保存模拟结果
* @param 需要保存哪个时段的数据
*/
bool saveResult(int iTime);
/**
*@brief 获取整点时刻
*/
std::string onTheHour(int iTime);
private:
String mRptFile;
String mBinFile;
String mInpFile;
int mErrcode;
std::string mStartTime;
std::string mEndTime;
// 水质模拟结果
std::map<std::string, std::map<std::string, float>> mSimulQualityMap;
// 水池水质
std::map<std::string, float> mWaterSourcesMap; // 水质
};
......@@ -75,6 +75,7 @@ public:
private:
std::string mSN;// 编号
std::string mLength; // 管长
float mFlow;
std::string mStartX;
std::string mStartY;
......
......@@ -75,11 +75,6 @@ bool CivHydrCompute::qualityCompute()
ENnextH(&tstep);
iTime++;
// 获取当前节点和管段数据
getNodeResult(iTime);
getLinkResult(iTime);
} while (tstep > 0);
ENcloseH();
......@@ -380,7 +375,11 @@ void CivHydrCompute::getLinkResult(short time)
case EN_PIPE:
{
ENgetlinkid(i, linkItem.szNo); // 编号
ENgetlinkvalue(i, EN_FLOW, &linkItem.dFlow);// 流量
float flow;
ENgetlinkvalue(i, EN_FLOW, &flow);// 流量
linkItem.dFlow = std::abs(flow);
ENgetlinkvalue(i, EN_VELOCITY, &linkItem.dVelocity);// 流速
ENgetlinkvalue(i, EN_HEADLOSS, &linkItem.dHeadloss);// 水头损失
......@@ -418,32 +417,56 @@ void CivHydrCompute::getLinkResult(short time)
void CivHydrCompute::getNodeQuality(short time)
{
if (time <= 0)
return;
time -= 1;
// 计算节点
int nNodeCount;
ENgetcount(EN_NODECOUNT, &nNodeCount);
int* typeCode = (int*)malloc(sizeof(int));
std::string nowDate;
std::string nowTime;
dateAndTime(time, nowDate, nowTime);
for (int i = 1; i <= nNodeCount; i++)
{
ENgetnodetype(i, typeCode);
if (*typeCode == EN_JUNCTION)
switch (*typeCode)
{
char No[35];
ENgetnodeid(i, No);// 编号
float quality;
ENgetnodevalue(i, EN_QUALITY, &quality); // 水质
case EN_JUNCTION: // 用户节点
{
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_QUALITY, &nodeItem.dQuality); // 水质
mResultCache.addNodeQuality(quality, time, No);
nodeItem.dDate = nowDate;
nodeItem.dTime = nowTime;
nodeItem.dModifyTime = CurrentTime;
mResultCache.addNodeItems(time, nodeItem);
}
break;
case EN_TANK: // 水厂
{
}
break;
default:
break;
}
}
free(typeCode);
}
void CivHydrCompute::getLinkQuality(short time)
{
if (time <= 0)
return;
......@@ -451,18 +474,59 @@ void CivHydrCompute::getLinkQuality(short time)
int nLinkCount;
ENgetcount(EN_LINKCOUNT, &nLinkCount);
int* typeCode = (int*)malloc(sizeof(int));
std::string nowDate;
std::string nowTime;
dateAndTime(time, nowDate, nowTime);
for (int i = 1; i <= nLinkCount; i++)
{
LinkResultItem linkItem;
ENgetlinktype(i, typeCode);
if (*typeCode != EN_PIPE)
continue;
char lnkNo[35];
ENgetlinkid(i, lnkNo);// 编号
float quality;
ENgetlinkvalue(i, EN_LINKQUAL, &quality);// 水质
switch (*typeCode)
{
case EN_PIPE:
{
ENgetlinkid(i, linkItem.szNo); // 编号
float flow;
ENgetlinkvalue(i, EN_FLOW, &flow);// 流量
if(flow<0)
linkItem.dFlow = std::abs(flow);
ENgetlinkvalue(i, EN_VELOCITY, &linkItem.dVelocity);// 流速
ENgetlinkvalue(i, EN_HEADLOSS, &linkItem.dHeadloss);// 水头损失
ENgetlinkvalue(i, EN_LINKQUAL, &linkItem.dQuality);// 水质
// 状态
float fState = 0;
ENgetlinkvalue(i, EN_STATUS, &fState);
if ((int)fState == 0)
strcpy_s(linkItem.szStatus, "关闭");
else
strcpy_s(linkItem.szStatus, "开启");
linkItem.dDate = nowDate;
linkItem.dTime = nowTime;
linkItem.dModifyTime = CurrentTime;
// 放到缓存类中
mResultCache.addLinkItems(time, linkItem);
}
break;
case EN_PUMP:
{
ENgetlinkid(i, linkItem.szNo); // 编号
ENgetlinkvalue(i, EN_ENERGY, &linkItem.dFlow);// 水泵耗能
}
break;
default:
break;
}
mResultCache.addLinkQuality(quality, time, lnkNo);
}
free(typeCode);
}
......
......@@ -8,7 +8,7 @@
class CivHydrCompute
{
public:
explicit CivHydrCompute();
CivHydrCompute();
/**
*@brief 水质计算
......
......@@ -6,6 +6,11 @@
#include "CivProjSimulation.h"
#include "JsonParseObject.h"
#include "CivOptSchedEngine.h"
#include "CivInpConvertor.h"
#include "CivDynamicCompute.h"
#include "CivPumpHelper.h"
#include "CivHydrTableHelper.h"
#include "StringUtils.h"
bool PANDANALYSIS_API hdyrSimulation(char* uri)
{
......@@ -170,12 +175,77 @@ bool PANDANALYSIS_API optimalSchedulingSimulation(char* uri, char* condition, in
return true;
}
bool PANDANALYSIS_API residualChlorineAnalysis(char* uri, char* conditionMap,char* error)
bool PANDANALYSIS_API residualChlorineAnalysis(char* uri, char* startTime, char* endTime, char* conditionMap,char* error)
{
std::string uriStr = uri;
std::string conditionMapStr = conditionMap;
std::string startTimeStr = startTime;
std::string endTimeStr = endTime;
std::string result;
struct ConditionStruct conditionStruct;
JsonParseObject jsonParseObj;
jsonParseObj.parse(conditionMapStr);
jsonParseObj.read(conditionStruct);
if (conditionStruct.mCondMap.size() <= 0)
{
result = "输入的json字符串有错误!";
return false;
}
// 转inp文件
CivInpConvertor conventor(uriStr);
std::string inpFile = conventor.convertResidualInp();
// 调用计算接口
CivDynamicCompute dynCompute;
if (!dynCompute.openFile(inpFile))
{
result = "打开inp文件失败";
return false;
}
dynCompute.setStartTime(startTimeStr);
dynCompute.setEndTime(endTimeStr);
dynCompute.updateQuality(conditionStruct.mCondMap);
// 解析开始和结束时间
int start = StringUtils::parseInt(startTimeStr);
int end = StringUtils::parseInt(endTimeStr);
// 开始执行加u三
if (!dynCompute.compute(start, end))
{
result = "计算失败!";
return false;
}
// 计算成功后,读取计算值更新到数据库
std::map<std::string, std::map<std::string, float>> resultMap;
dynCompute.simulResult(resultMap);
if (resultMap.size() <= 0)
{
result = "出现位置错误,,没有获取到模拟值!";
return false;
}
// 链接数据库,更新数据
CivPumpHelper pumpHelper(uriStr);
if (!pumpHelper.updateDatas("节点模拟值", resultMap))
{
result = "存储数据失败!";
return false;
}
//
return true;
}
bool PANDANALYSIS_API netTopo(char* uri, char* error)
{
CivHydrTableHelper hydrHelper(uri);
return hydrHelper.mainTain();
}
\ No newline at end of file
......@@ -71,12 +71,21 @@ extern "C" {
bool PANDANALYSIS_API optimalSchedulingSimulation(char* uri, char* condition, int timeInterval, char* result);
/**
*@brief 优化调度模拟
* @brief 余氯分析模拟
* @param [in] uri:condition
* @param [in] startTime:startTime
* @param [in] endTime:condition
* @param [in] condition:约束条件, 格式: json字符串 {"startTime":'',"endTime":'',"水池":[{"code":'',"余氯量":},{"code":'',"余氯量":}]}
* @param [error] 错误警告
* @param [error] 输出值,错误警告
*/
bool PANDANALYSIS_API residualChlorineAnalysis(char* uri,char* startTime,char* endTime, char* conditionMap,char* error);
/**
* @brief 管网拓扑,二次维护
* @param [in] uri:condition
* @param [error] 输出值,错误警告
*/
bool PANDANALYSIS_API residualChlorineAnalysis(char* uri, char* conditionMap,char* error);
bool PANDANALYSIS_API netTopo(char* uri, char* error);
#if defined(__cplusplus)
}
#endif
......
......@@ -66,23 +66,23 @@ bool CivHydrSimulation::qualitySimulation()
CivSysLog::getInstance()->info("计算成功", "CivSysLog", __FUNCTION__);
// 余氯计算
inpFileS = convertor.convertResidualInp();
mHydrCompute.setInpFile(inpFileS);
mHydrCompute.setRptFile("test.rpt");
mHydrCompute.setBinFile("test.bin");
if (inpFileS.empty() || inpFileS == "")
{
CivSysLog::getInstance()->error("转inp文件失败", "CivSysLog", __FUNCTION__);
return false;
}
if (!mHydrCompute.chlorineCompute())
{
CivSysLog::getInstance()->error("计算失败", "CivSysLog", __FUNCTION__);
return false;
}
//// 余氯计算
//inpFileS = convertor.convertResidualInp();
//mHydrCompute.setInpFile(inpFileS);
//mHydrCompute.setRptFile("test.rpt");
//mHydrCompute.setBinFile("test.bin");
//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);
return true;
......
#include "CivInpProject.h"
CivInpProject::CivInpProject()
{
}
CivInpProject::~CivInpProject()
{
}
bool CivInpProject::writeToFile(const string& filename)
{
return true;
}
\ No newline at end of file
#pragma once
#include <string>
using namespace std;
/*
ݿinpļ
*/
class CivInpProject
{
public:
explicit CivInpProject();
~CivInpProject();
bool writeToFile(const string& filename);
private:
};
......@@ -239,7 +239,6 @@ void CivProjSimulation::getProjLinkResult()
ENgetlinkvalue(i, EN_HEADLOSS, &linkItem.dHeadloss);// 水头损失
mProjCache.addPipeHeadLoss(linkItem.szNo, linkItem.dHeadloss);
}
free(typeCode);
}
......@@ -285,7 +284,11 @@ void CivProjSimulation::getLinkResult()
continue;
ENgetlinkid(i, linkItem.szNo); // 编号
ENgetlinkvalue(i, EN_FLOW, &linkItem.dFlow);// 流量
float flow;
ENgetlinkvalue(i, EN_FLOW, &flow);// 流量
linkItem.dFlow = std::abs(flow);
ENgetlinkvalue(i, EN_VELOCITY, &linkItem.dVelocity);// 流速
ENgetlinkvalue(i, EN_HEADLOSS, &linkItem.dHeadLoss);// 水头损失
......
......@@ -39,7 +39,6 @@ bool CivSchedulingCompute::openFile(const string& inpFILE)
return false;
}
return true;
}
......@@ -51,8 +50,6 @@ bool CivSchedulingCompute::saveInpFile(char* inpFile)
return true;
}
bool CivSchedulingCompute::calculate()
{
short hydCode = 1;
......@@ -98,42 +95,9 @@ bool CivSchedulingCompute::calculate()
default:
break;
}
//if (linkType != EN_PUMP || linkType != EN_PBV)
// continue;
//switch (mChdulingType)
//{
//case PumpScheduling& EN_PUMP:
//{
// if (linkType != EN_PUMP)
// continue;
// char id[128] = "";
// ENgetlinkid(i, id);
// map<string,float>::iterator iter = mPumpSpeed.find(id);
// if (iter == mPumpSpeed.end())
// continue;
// // 更新水泵的转速
// ENsetlinkvalue(i, EN_STATUS, iter->second );
//}
// break;
//case PBVScheduling& EN_PBV:
//{
// if (linkType != EN_PBV)
// continue;
//}
// break;
//default:
// break;
//}
}
do
{
if (ENrunH(&t) > 100) // errcode > 100 是错误
{
ENclose();
......@@ -181,7 +145,6 @@ void CivSchedulingCompute::setMonitors(const vector<string>& monitor)
void CivSchedulingCompute::saveResult(int time)
{
// 计算节点
int nNodeCount;
ENgetcount(EN_NODECOUNT, &nNodeCount);
......
......@@ -98,12 +98,12 @@ bool CivTrackingAnalysis::createGraphFrom()
continue;
}
std::string endcode = endCodeiter->second;
// 获取管段终点坐标值
CivGraphJunction graphJunction2(endcode);
int index2 = mGraph->getVertexIndex(graphJunction2);
CivGraphJunction endJunction = mGraph->getData(index2);
if (sStartjuction.getHead() > endJunction.getHead())
{
CivGraphEdage edAge(pipeTable.code, pipeTable.Length, { sStartjuction.getXCoord(),sStartjuction.getYCoord(),endJunction.getXCoord(),endJunction.getYCoord() });
......
......@@ -158,6 +158,7 @@ copy pandaAnalysis.h $(OutDir)..\include /y</Command>
<ClCompile Include="CivBaseInpBuilder.cpp" />
<ClCompile Include="CivBreakPipeAnalysis.cpp" />
<ClCompile Include="CivCloseValveProj.cpp" />
<ClCompile Include="CivDynamicCompute.cpp" />
<ClCompile Include="CivHydDataType.cpp" />
<ClCompile Include="CivHydrCompute.cpp" />
<ClCompile Include="CivHydrFuncInter.cpp" />
......@@ -165,7 +166,6 @@ copy pandaAnalysis.h $(OutDir)..\include /y</Command>
<ClCompile Include="CivInpBuilder.cpp" />
<ClCompile Include="CivInpConvertor.cpp" />
<ClCompile Include="CivInpDirector.cpp" />
<ClCompile Include="CivInpProject.cpp" />
<ClCompile Include="CivNewInp.cpp" />
<ClCompile Include="CivOptSchedEngine.cpp" />
<ClCompile Include="CivProjInpBuilder.cpp" />
......@@ -182,6 +182,7 @@ copy pandaAnalysis.h $(OutDir)..\include /y</Command>
<ClInclude Include="CivBaseInpBuilder.h" />
<ClInclude Include="CivBreakPipeAnalysis.h" />
<ClInclude Include="CivCloseValveProj.h" />
<ClInclude Include="CivDynamicCompute.h" />
<ClInclude Include="CivGraphList.h" />
<ClInclude Include="CivHydDataType.h" />
<ClInclude Include="CivHydrCompute.h" />
......@@ -190,7 +191,6 @@ copy pandaAnalysis.h $(OutDir)..\include /y</Command>
<ClInclude Include="CivInpBuilder.h" />
<ClInclude Include="CivInpConvertor.h" />
<ClInclude Include="CivInpDirector.h" />
<ClInclude Include="CivInpProject.h" />
<ClInclude Include="CivNewInp.h" />
<ClInclude Include="CivOptSchedEngine.h" />
<ClInclude Include="CivProjInpBuilder.h" />
......
......@@ -63,9 +63,6 @@
<ClCompile Include="CivCloseValveProj.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivInpProject.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivStopWaterAnalysis.cpp">
<Filter>源文件</Filter>
</ClCompile>
......@@ -81,6 +78,9 @@
<ClCompile Include="CivReportReader.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivDynamicCompute.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="CivHydrFuncInter.h">
......@@ -131,9 +131,6 @@
<ClInclude Include="CivStopWaterAnalysis.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivInpProject.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivCloseValveProj.h">
<Filter>头文件</Filter>
</ClInclude>
......@@ -158,5 +155,8 @@
<ClInclude Include="CivReportReader.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivDynamicCompute.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
......@@ -7,7 +7,11 @@ void CivNode::addItem(const NodeTable& table)
void CivPipe::addItem(const PipesTable& table)
{
auto iter = std::find(mTables.begin(), mTables.end(), table);
if (iter == mTables.end())
{
mTables.push_back(table);
}
}
void CivTank::addItem(const TankTable& table)
......
......@@ -65,6 +65,11 @@ public:
Str MinorLoss;
Str Status;
Str code;
bool operator==(const Table& other)
{
return ID == other.ID;
}
} PipesTable;
void addItem(const PipesTable& table);
......
#include "CivHydrTableHelper.h"
#include "CivTableFields.h"
#include "CivCommonUtils.h"
#include "CivPgDbConnection.h"
CivHydrTableHelper::CivHydrTableHelper(const std::string& uri)
{
mConn = new CivPgDbConnection();
......@@ -20,7 +18,7 @@ CivHydrTableHelper::~CivHydrTableHelper()
bool CivHydrTableHelper::mainTain()
{
//unTopoMaintain();
unTopoMaintain();
// 管网组件
updateAssem(TABLE_NODE, std::string("本点号"), "JD");
......@@ -40,6 +38,7 @@ bool CivHydrTableHelper::mainTain()
if (!topoMaintain())
return false;
return true;
}
......@@ -73,7 +72,7 @@ void CivHydrTableHelper::updateAssem(const std::string& table, const std::string
sql = sql.substr(0, sql.length() - 1);
sql += ") as tmp(id, \""+ filed +"\") where "+ table +".id = tmp.id; ";
if (mConn && mConn->execSql(sql))
if (mConn && !mConn->execSql(sql))
{
mErrInfo = mConn->getLastError();
return;
......@@ -99,6 +98,8 @@ bool CivHydrTableHelper::topoMaintain()
topoMainTable(PROJ_TABLE_PIPE, TABLE_NODE, std::string("起始节点"), std::string("本点号"), std::string("from_code"));
topoMainTable(PROJ_TABLE_PIPE, TABLE_NODE, std::string("终止节点"), std::string("本点号"), std::string("to_code"));
topoMainTable(PROJ_TABLE_PIPE, TABLE_NODE, std::string("起始节点"), std::string("本点号"), std::string("to_code"));
topoMainTable(PROJ_TABLE_PIPE, TABLE_NODE, std::string("终止节点"), std::string("本点号"), std::string("from_code"));
topoMainTable(PROJ_TABLE_PIPE, TABLE_RESERVOIR, std::string("起始节点"), std::string("本点号"), std::string("from_code"));
topoMainTable(PROJ_TABLE_PIPE, TABLE_TANK, std::string("起始节点"), std::string("本点号"), std::string("from_code"));
topoMainTable(PROJ_TABLE_PIPE, TABLE_VALVE, std::string("起始节点"), std::string("本点号"), std::string("from_code"));
......@@ -112,17 +113,43 @@ bool CivHydrTableHelper::topoMaintain()
topoMainTable(PROJ_TABLE_PIPE, PROJ_TABLE_VALVE, std::string("终止节点"), std::string("本点号"), std::string("to_code"));
// 处理方案和阀门的拓扑关系
topoLikelyPipe(TABLE_PIPE, TABLE_VALVE, std::string("起始节点"), std::string("to_code"));
topoLikelyPipe(TABLE_PIPE, TABLE_VALVE, std::string("终止节点"), std::string("from_code"));
topoValve(TABLE_PIPE, TABLE_VALVE,"终止节点", "from_code", "to_code");
topoValve(TABLE_PIPE, TABLE_VALVE, "起始节点", "to_code", "from_code");
topoLikelyPipe(PROJ_TABLE_PIPE, TABLE_VALVE, std::string("起始节点"), std::string("to_code"));
topoLikelyPipe(PROJ_TABLE_PIPE, TABLE_VALVE, std::string("终止节点"), std::string("from_code"));
topoValve(TABLE_PIPE, TABLE_VALVE, "起始节点", "to_code", "from_code", TABLE_RESERVOIR);
topoValve(TABLE_PIPE, TABLE_VALVE, "起始节点", "to_code", "from_code",TABLE_TANK);
topoLikelyPipe(TABLE_PIPE, PROJ_TABLE_VALVE, std::string("起始节点"), std::string("to_code"));
topoLikelyPipe(TABLE_PIPE, PROJ_TABLE_VALVE, std::string("终止节点"), std::string("from_code"));
// 方案管段与
topoValve(PROJ_TABLE_PIPE, TABLE_VALVE, "终止节点", "from_code", "to_code");
topoValve(PROJ_TABLE_PIPE, TABLE_VALVE, "起始节点", "to_code", "from_code");
return true;
topoValve(PROJ_TABLE_PIPE, PROJ_TABLE_VALVE, "终止节点", "from_code", "to_code");
topoValve(PROJ_TABLE_PIPE, PROJ_TABLE_VALVE, "起始节点", "to_code", "from_code");
topoValve(TABLE_PIPE, PROJ_TABLE_VALVE, "终止节点", "from_code", "to_code");
topoValve(TABLE_PIPE, PROJ_TABLE_VALVE, "起始节点", "to_code", "from_code");
topoValve(TABLE_PIPE, TABLE_VALVE, "起始节点", "to_code", "from_code", TABLE_RESERVOIR);
topoValve(TABLE_PIPE, TABLE_VALVE, "起始节点", "to_code", "from_code", TABLE_TANK);
topoValve(PROJ_TABLE_PIPE, PROJ_TABLE_VALVE, "起始节点", "to_code", "from_code", PROJ_TABLE_RESERVOIR);
topoValve(PROJ_TABLE_PIPE, PROJ_TABLE_VALVE, "起始节点", "to_code", "from_code", PROJ_TABLE_TANK);
// 水泵拓扑维护
topoPump(TABLE_PIPE, TABLE_PUMP, "起始节点", "from_code", "to_code", TABLE_TANK);
// topoPump(TABLE_PIPE, TABLE_PUMP, "起始节点", "from_code", "to_code", TABLE_RESERVOIR);
topoPump(TABLE_PIPE, TABLE_PUMP, "终止节点", "to_code", "from_code", TABLE_NODE);
//topoPump(TABLE_PIPE, TABLE_PUMP, "起始节点", "from_code", "to_code", TABLE_TANK);
//topoPump(TABLE_PIPE, TABLE_PUMP, "起始节点", "from_code", "to_code", TABLE_NODE);
//topoPump(TABLE_PIPE, TABLE_PUMP, "终止节点", "to_code", "from_code", TABLE_NODE);
//topoPump(PROJ_TABLE_PIPE, PROJ_TABLE_PUMP, "起始节点", "from_code", "to_code", TABLE_NODE);
//topoPump(PROJ_TABLE_PIPE, PROJ_TABLE_PUMP, "终止节点", "to_code", "from_code", TABLE_NODE);
//topoPump(PROJ_TABLE_PIPE, PROJ_TABLE_PUMP, "起始节点", "from_code", "to_code", PROJ_TABLE_RESERVOIR);
//topoPump(PROJ_TABLE_PIPE, PROJ_TABLE_PUMP, "起始节点", "from_code", "to_code", PROJ_TABLE_TANK);
return true;
}
bool CivHydrTableHelper::unTopoMaintain()
......@@ -132,6 +159,14 @@ bool CivHydrTableHelper::unTopoMaintain()
unTopoTable(TABLE_RESERVOIR, { std::string("本点号")});
unTopoTable(TABLE_TANK, { std::string("本点号") });
unTopoTable(TABLE_VALVE, { std::string("本点号"),std::string("起始节点"),std::string("终止节点") });
unTopoTable(TABLE_PUMP, { "本点号","起始节点","终止节点"});
unTopoTable(PROJ_TABLE_NODE, { std::string("本点号") });
unTopoTable(PROJ_TABLE_PIPE, { std::string("编号"),std::string("起始节点"),std::string("终止节点") });
unTopoTable(PROJ_TABLE_RESERVOIR, { std::string("本点号") });
unTopoTable(PROJ_TABLE_TANK, { std::string("本点号") });
unTopoTable(PROJ_TABLE_VALVE, { std::string("本点号"),std::string("起始节点"),std::string("终止节点") });
unTopoTable(PROJ_TABLE_PUMP, { "本点号","起始节点","终止节点" });
return true;
}
......@@ -145,7 +180,6 @@ bool CivHydrTableHelper::topoMainTable(const std::string& sourceTable,
SET \"" + pipesn + "\" = cqt.\"" + nodeSn + "\" FROM \"" + targetTable + "\" cqt WHERE \
\""+sourceTable+"\".\"" + code + "\" = cqt.\"code\"";
if (mConn && !mConn->execSql(sql))
{
mErrInfo = mConn->getLastError();
......@@ -158,7 +192,7 @@ bool CivHydrTableHelper::topoMainTable(const std::string& sourceTable,
bool CivHydrTableHelper::topoLikelyPipe(const std::string& pipeTable, const std::string& nodeTable, const std::string& filed, const std::string& tocode)
{
std::string sql = "update \""+nodeTable+"\" as pu set \""+filed+"\" = \
(select pipe.\"编号\" from \""+pipeTable+"\" as pipe where pipe.\""+tocode+"\"=pu.\"code\") where exists (select 1 from \""+pipeTable+"\" as pipe1 where pipe1.\""+tocode+"\"=pu.\"code\")";
(select pipe.\"编号\" from \""+pipeTable+"\" as pipe where pipe.\""+tocode+"\"=pu.\"code\") ";
if (mConn && !mConn->execSql(sql))
{
......@@ -169,16 +203,18 @@ bool CivHydrTableHelper::topoLikelyPipe(const std::string& pipeTable, const std:
return true;
}
bool CivHydrTableHelper::topoValve(const std::string& sn,
bool CivHydrTableHelper::topoValve(const std::string& pipeTable,
const std::string& valveTable,
const std::string& sn,
const std::string& fromcode,
const std::string& tocode)
const std::string& tocode,
const std::string& nodeTable)
{
std::string sql = "update \"";
sql.append(TABLE_VALVE);
sql.append(valveTable);
sql.append("\" set \"" + sn + "\" = dd.\"本点号\"\
from(select node.\"本点号\" \"本点号\", node.\"code\" \"nodecode\", tt.\"code\" \"vacode\" from \
\""+TABLE_NODE+"\" node, (select t2.\""+tocode+"\" \""+tocode+"\", t1.\"code\" \"code\" from \""+TABLE_PIPE+"\" t2, \""+TABLE_VALVE+"\" t1 where t2.\""+fromcode+"\" = t1.\"code\") tt\
\""+ nodeTable +"\" node, (select t2.\""+tocode+"\" \""+tocode+"\", t1.\"code\" \"code\" from \""+ pipeTable +"\" t2, \""+ valveTable +"\" t1 where t2.\""+fromcode+"\" = t1.\"code\") tt\
where node.\"code\" = tt.\""+tocode+"\") dd\
where \"code\" = dd.\"vacode\"");
......@@ -189,7 +225,9 @@ bool CivHydrTableHelper::topoValve(const std::string& sn,
return false;
}
return false;
return true;
}
bool CivHydrTableHelper::unTopoTable(const std::string& table, const std::vector<std::string>& fields)
......@@ -218,7 +256,6 @@ bool CivHydrTableHelper::unTopoTable(const std::string& table, const std::vector
return false;
}
void CivHydrTableHelper::getCodeToSn(const std::string& code, std::string& sn)
{
std::string sql = "select \"本点号\" from 节点 where code = '" + code+"'";
......@@ -240,3 +277,48 @@ void CivHydrTableHelper::getCodeToSn(const std::string& code, std::string& sn)
sn = res[0].find("本点号")->second;
return;
}
bool CivHydrTableHelper::topoPump(
const std::string& pipeTable,
const std::string& pumpTable,
const std::string& sn,
const std::string& fromcode,
const std::string& tocode,
const std::string& nodeTable)
{
std::string psql = "update \""+ pumpTable +"\" set \""+sn+"\" = gg.\"本点号\" from (select node.\"本点号\",bb.\"vcode\" from \"水池\" as node,\
(select pipe.\""+fromcode+"\" as fromcode, a.\"code\" vcode from \""+pipeTable+"\" as pipe inner join \""+ pumpTable +"\" as a on pipe.\""+tocode+"\" = a.\"code\")bb\
where node.\"code\" = bb.\"fromcode\") gg\
where \"code\" = gg.\"vcode\" ";
std::string pumpSQL = "update \"水泵\" set \"起始节点\" = gg.\"本点号\" from (select node.\"本点号\",bb.\"vcode\" from \"水池\" as node,\
(select pipe.\"from_code\" as fromcode, a.\"code\" vcode from \"管段\" as pipe inner join \"水泵\" as a on pipe.\"to_code\" = a.\"code\")bb\
where node.\"code\" = bb.\"fromcode\") gg\
where \"code\" = gg.\"vcode\" ";
if (mConn && !mConn->execSql(pumpSQL))
{
mErrInfo = mConn->getLastError();
return false;
}
std::string sedpumpSQL = "update \"水泵\" set \"终止节点\" = gg.\"本点号\" from (select node.\"本点号\",bb.\"vcode\" from \"节点\" as node,\
(select pipe.\"to_code\" as tocode, a.\"code\" vcode from \"管段\" as pipe inner join \"水泵\" as a on pipe.\"from_code\" = a.\"code\")bb\
where node.\"code\" = bb.\"tocode\") gg\
where \"code\" = gg.\"vcode\"; ";
if (mConn && !mConn->execSql(sedpumpSQL))
{
mErrInfo = mConn->getLastError();
return false;
}
return true;
}
std::string CivHydrTableHelper::splicingPumpSql(const std::string& pumpTable, const std::string& nodetable)
{
std::string sql = "";
return sql;
}
......@@ -38,10 +38,26 @@ private:
/**
*@brief 拓扑维护阀门,需要特殊处理
*/
bool topoValve(const std::string& sn,const std::string& fromcode,const std::string& tocode );
bool topoValve(const std::string& pipeTable,
const std::string& valveTable,
const std::string& sn,
const std::string& fromcode,
const std::string& tocode,
const std::string& nodeTable="节点" );
bool topoLikelyPipe(const std::string& pipeTable, const std::string& nodeTable,
const std::string& filed, const std::string& tocode);
bool topoPump(const std::string& pipeTable,
const std::string& pumpTable,
const std::string& sn,
const std::string& fromcode,
const std::string& tocode,
const std::string& nodeTable);
// 拼接维护水泵的sql语句
std::string inline splicingPumpSql(const std::string& pumpTable,const std::string& nodetable);
private:
std::vector<std::string> mNecessTables;
std::map<std::string, std::string> mNeedTableMap;
......
......@@ -322,55 +322,7 @@ void CivInpDbHelper::handlePump()
bool CivInpDbHelper::handleValves2()
{
std::string sql = "SELECT A.*,B.* FROM\
(\
SELECT\
node.\"本点号\",\
node.\"横坐标\" AS 阀门横坐标,\
node.\"纵坐标\" AS 阀门纵坐标,\
node.\"固定状态\" AS 阀门固定状态,\
node.\"类型\" AS 阀门类型,\
node.\"设置\" AS 阀门设置,\
node.\"水损系数\" AS 阀门水损系数,\
pipe.编号 AS 上游管段编号,\
pipe.\"管长\" AS 上游管长,\
pipe.\"管径\" AS 上游管径,\
pipe.\"摩阻系数\" AS 上游管段摩阻系数,\
junc.\"本点号\" AS 上游节点,\
junc.\"code\" AS 上游节点code,\
junc.\"高程\" AS 上游节点高程,\
junc.\"需水量模式\" AS 上游节点蓄水量模式,\
junc.\"基本需水量\" as 上游节点基本需水量,\
junc.\"横坐标\" AS 上游节点横坐标,\
junc.\"纵坐标\" AS 上游节点纵坐标,\
junc.\"初始水质\" AS 上游节点初始水质\
FROM\
阀门 AS node, 管段 AS pipe, 节点 as junc\
WHERE\
pipe.\"from_code\" = node.\"code\" AND pipe.\"to_code\" = junc.\"code\"\
) A,\
(\
SELECT\
pipe.编号 AS 下游管段编号,\
pipe.\"管长\" AS 下游管段管长,\
pipe.\"管径\" AS 下游管段管径,\
pipe.\"摩阻系数\" AS 下游管段摩阻系数,\
node.\"本点号\",\
junc.\"本点号\" AS 下游节点,\
junc.\"code\" AS 上游节点code,\
junc.\"高程\" AS 下游节点高程,\
junc.\"需水量模式\" AS 下游节点蓄水量模式,\
junc.\"基本需水量\" as 下游节点基本需水量,\
junc.\"横坐标\" AS 下游节点横坐标,\
junc.\"纵坐标\" AS 下游节点纵坐标,\
junc.\"初始水质\" AS 下游节点初始水质\
FROM\
阀门 AS node, 管段 AS pipe, 节点 as junc\
WHERE\
pipe.\"to_code\" = node.\"code\" AND pipe.\"from_code\" = junc.\"code\"\
) B\
WHERE\
A.\"本点号\" = b.\"本点号\"";
std::string sql = splicingSql("节点");
if (!mDbConn->execSql(sql))
{
......@@ -382,6 +334,16 @@ bool CivInpDbHelper::handleValves2()
std::vector<std::map<std::string, std::string>> valvesPipes;
mDbConn->queryResult(valvesPipes);
// 非
std::string sql2 = splicingSql("水库","0","1");
if (!mDbConn->execSql(sql2))
{
std::string error = mDbConn->getLastError();
return false;
}
mDbConn->queryResult(valvesPipes);
// 总个数
size_t total = valvesPipes.size();
for (int i = 0; i < total; i++)
......@@ -434,8 +396,8 @@ bool CivInpDbHelper::handleValves2()
startNodeTable.Demand = "0";
// 两点之间直线
double vupperXcoord = (atof(upperNodeXcoord.c_str()) - atof(vaXcoord.c_str()))/5+atof(vaXcoord.c_str());
double vupperYcoord = (atof(upperNodeYcoord.c_str()) - atof(vaYcoord.c_str()))/5 + atof(vaYcoord.c_str());
double vupperXcoord = (atof(upperNodeXcoord.c_str()) - atof(vaXcoord.c_str()))/10+atof(vaXcoord.c_str());
double vupperYcoord = (atof(upperNodeYcoord.c_str()) - atof(vaYcoord.c_str()))/10 + atof(vaYcoord.c_str());
// 节点坐标
startNodeCoord.ID = "VUP" + vaSzNo;
......@@ -455,8 +417,8 @@ bool CivInpDbHelper::handleValves2()
mCoords.push_back(startNodeCoord);
// 两点之间直线
double vdownXcoord = (atof(donwNodeXcoord.c_str()) - atof(vaXcoord.c_str())) / 5 + atof(vaXcoord.c_str());
double vdownYcoord = (atof(donwNodeYcoord.c_str()) - atof(vaYcoord.c_str())) / 5 + atof(vaYcoord.c_str());
double vdownXcoord = (atof(donwNodeXcoord.c_str()) - atof(vaXcoord.c_str())) / 10 + atof(vaXcoord.c_str());
double vdownYcoord = (atof(donwNodeYcoord.c_str()) - atof(vaYcoord.c_str())) / 10 + atof(vaYcoord.c_str());
// 终止节点坐标信息
endNodeCoord.ID = "VDW" + vaSzNo;
......@@ -541,3 +503,72 @@ void CivInpDbHelper::handleValve()
handleValves2();
return;
}
std::string CivInpDbHelper::splicingSql(const std::string& rightTable, const std::string& demandName , const std::string& demandPattern)
{
std::string upcondition;
std::string downcondition;
if (rightTable == "节点")
{
upcondition = "pipe.\"from_code\" = node.\"code\" AND pipe.\"to_code\" = junc.\"code\"";
downcondition = "pipe.\"to_code\" = node.\"code\" AND pipe.\"from_code\" = junc.\"code\"";
}
else
{
upcondition = "(pipe.\"to_code\" = node.\"code\"\
AND pipe.\"from_code\" = junc.\"code\") or\
(pipe.\"from_code\" = node.\"code\"\
AND pipe.\"to_code\" = junc.\"code\")";
downcondition = "(pipe.\"to_code\" = node.\"code\"\
AND pipe.\"from_code\" = junc.\"code\") or\
(pipe.\"from_code\" = node.\"code\"\
AND pipe.\"to_code\" = junc.\"code\")";
}
std::string sql2 = "SELECT A.*, B.* FROM (SELECT\
node.\"本点号\",\
node.\"横坐标\" AS 阀门横坐标,\
node.\"纵坐标\" AS 阀门纵坐标,\
node.\"固定状态\" AS 阀门固定状态,\
node.\"类型\" AS 阀门类型,\
node.\"设置\" AS 阀门设置,\
node.\"水损系数\" AS 阀门水损系数,\
pipe.编号 AS 上游管段编号,\
pipe.\"管长\" AS 上游管长,\
pipe.\"管径\" AS 上游管径,\
pipe.\"摩阻系数\" AS 上游管段摩阻系数,\
junc.\"本点号\" AS 上游节点,\
junc.\"code\" AS 上游节点code,\
junc.\"高程\" AS 上游节点高程,\
"+ demandPattern + " AS 上游节点蓄水量模式,\
"+demandName + " AS 上游节点基本需水量,\
junc.\"横坐标\" AS 上游节点横坐标,\
junc.\"纵坐标\" AS 上游节点纵坐标,\
junc.\"初始水质\" AS 上游节点初始水质\
FROM\
阀门 AS node, 管段 AS pipe, "+rightTable+" AS junc\
WHERE "+ upcondition+") A,\
(\
SELECT\
pipe.编号 AS 下游管段编号,\
pipe.\"管长\" AS 下游管段管长,\
pipe.\"管径\" AS 下游管段管径,\
pipe.\"摩阻系数\" AS 下游管段摩阻系数,\
node.\"本点号\",\
junc.\"本点号\" AS 下游节点,\
junc.\"code\" AS 上游节点code,\
junc.\"高程\" AS 下游节点高程,\
junc.\"需水量模式\" AS 下游节点蓄水量模式,\
junc.\"基本需水量\" AS 下游节点基本需水量,\
junc.\"横坐标\" AS 下游节点横坐标,\
junc.\"纵坐标\" AS 下游节点纵坐标,\
junc.\"初始水质\" AS 下游节点初始水质\
FROM\
阀门 AS node, 管段 AS pipe, 节点 AS junc\
WHERE "+downcondition+") B\
WHERE\
A.\"本点号\" = b.\"本点号\"";
return sql2;
}
\ No newline at end of file
......@@ -28,4 +28,6 @@ public:
private:
bool handleValves2();
std::string splicingSql(const std::string& rightTable,const std::string& demandName="需水量模式",const std::string& demandPattern = "基本需水量");
};
#include "CivProjInpDbHelper.h"
#include "CivConnection.h"
#include "CivTableFields.h"
#include <algorithm>
CivProjInpDbHelper::CivProjInpDbHelper(const std::string& uri)
:CivInpHelperAbs(uri)
......@@ -21,411 +22,6 @@ void CivProjInpDbHelper::setProjCode(const std::string& projCode)
void CivProjInpDbHelper::handlePump()
{
// 处理水泵连接的管段
}
void CivProjInpDbHelper::sortProjDeatil()
{
// 查找方案详情表修改的属性
std::string detailSql = "select detail.\"code\",detail.\"图层\",detail.\"属性\",detail.\"属性原值\",detail.\"属性新值\"\
from \"方案详情表\" as detail where \"方案编码\"='" + mPorjCode +"' and \"操作类型\"=1";
if (!mDbConn->execSql(detailSql))
return;
std::vector<std::map<std::string, std::string>> detailVec;
mDbConn->queryResult(detailVec);
size_t detailVecSize = detailVec.size();
// 将方案详情表查出来的数据
for (int i = 0; i < detailVecSize; i++)
{
std::map<std::string, std::string> tempMap = detailVec[i];
std::string layerName = tempMap.find("图层")->second;
mDetailMap[layerName].push_back(tempMap);
}
}
std::string CivProjInpDbHelper::splicingConditions(const std::string& layer)
{
std::string condition = "\"code\" not in(select \"code\" from \"方案详情表\" \
where \"方案编码\" = '" + mPorjCode + "' and \"图层\" = '"+ layer +"' and \"操作类型\"=0)";
return condition;
}
void CivProjInpDbHelper::handleValve()
{
// 查出方案详情表的信息
sortProjDeatil();
// 抽取相同字符串部分
std::string baseSql = "select pipe.\"编号\", ('UP' || pipe.\"起始节点\") as \"起始节点\", pipe.\"终止节点\", \
pipe.\"管长\", pipe.\"管径\",\
pipe.\"摩阻系数\" ,pipe.\"局损系数\"";
//阀门的下游管段
std::string dwPipeSql = baseSql + "from \"管段\" as pipe where "+splicingConditions("阀门")+" and (pipe.\"from_layer\" ='阀门' or pipe.\"from_layer\" ='方案阀门' ) \
union "+baseSql+" from \"方案管段\" as pipe where pipe.\"方案编码\" ='"+mPorjCode+"' and (pipe.\"from_layer\" ='阀门' or pipe.\"from_layer\" ='方案阀门' ) ";
if (!mDbConn->execSql(dwPipeSql))
return;
std::vector<std::map<std::string, std::string>> upPipes;
mDbConn->queryResult(upPipes);
size_t total = upPipes.size();
for (int i = 0; i < total; i++)
{
std::map<std::string, std::string> pipe = upPipes[i];
CivPipe::Table pipeStruct;
pipeStruct.ID = pipe.find("编号")->second;
pipeStruct.code = pipe.find("code")->second;
pipeStruct.Node1 = pipe.find("起始节点")->second;
pipeStruct.Node2 = pipe.find("终止节点")->second;
pipeStruct.Length = pipe.find("管长")->second;
pipeStruct.Diameter = pipe.find("管径")->second;
pipeStruct.Roughness = pipe.find("摩阻系数")->second;
pipeStruct.Status = "Open";
pipeStruct.MinorLoss = pipe.find("局损系数")->second;
mPipesVec.push_back(pipeStruct);
}
// 阀门的上游管段
std::string baseSql2 = "select pipe.\"编号\", pipe.\"起始节点\", ('DW' || pipe.\"终止节点\") as \"终止节点\", \
pipe.\"管长\", pipe.\"管径\", \pipe.\"摩阻系数\",pipe.\"局损系数\"";
std::string upPipeSql = baseSql2 + " from \"管段\" as pipe where " +splicingConditions("阀门")+" and (pipe.\"to_layer\" = '阀门' or pipe.\"to_layer\" = '方案阀门') \
union " +baseSql2 + " from \"方案管段\" as pipe where pipe.\"方案编码\" ='" + mPorjCode + "' and (pipe.\"to_layer\" = '阀门' or pipe.\"to_layer\" = '方案阀门') " ;
if (!mDbConn->execSql(upPipeSql))
return;
std::vector<std::map<std::string, std::string>> downPipes;
mDbConn->queryResult(downPipes);
size_t dtotal = downPipes.size();
for (int i = 0; i < dtotal; i++)
{
std::map<std::string, std::string> pipe = downPipes[i];
CivPipe::Table pipeStruct;
pipeStruct.ID = pipe.find("编号")->second;
pipeStruct.code = pipe.find("code")->second;
pipeStruct.Node1 = pipe.find("起始节点")->second;
pipeStruct.Node2 = pipe.find("终止节点")->second;
pipeStruct.Length = pipe.find("管长")->second;
pipeStruct.Diameter = pipe.find("管径")->second;
pipeStruct.Roughness = pipe.find("摩阻系数")->second;
pipeStruct.Status = "Open";
pipeStruct.MinorLoss = pipe.find("局损系数")->second;
mPipesVec.push_back(pipeStruct);
}
// 阀门信息
std::string startSql = "SELECT va.\"code\",'UP' || va.\"本点号\" AS \"本点号\", vnode.\"高程\", vnode.\"基本需水量\", vnode.\"需水量模式\" \
, (va.\"横坐标\" + 1) AS \"横坐标\", (va.\"纵坐标\" + 1) AS \"纵坐标\", va.\"本点号\" as \"阀门本点号\", \
va.\"类型\" as \"阀门类型\", ('UP' || va.\"本点号\") as \"阀门起始节点\",\
va.\"直径\" as \"阀门直径\", va.\"固定状态\" as \"阀门状态\", va.\"设置\" as \"阀门设置\", va.\"水损系数\"\
FROM \"阀门\" va, ( \
SELECT node.\"本点号\", node.\"高程\", node.\"基本需水量\", node.\"需水量模式\", node.\"横坐标\", node.\"纵坐标\", va.\"终止节点\" \
FROM \"节点\" node, ( \
SELECT pipe.\"起始节点\", pipe.\"终止节点\" FROM \"管段\" pipe \
WHERE pipe.\"to_layer\" = '阀门' \
and \"code\" not in( \
select \"code\" from \"方案详情表\" \
where \"图层\" = '管段' and \"操作类型\" = 0 and \"方案编码\" = '" + mPorjCode + "' \
) \
union \
select pipe.\"起始节点\", pipe.\"终止节点\" FROM \"方案管段\" pipe where pipe.\"to_layer\" = '阀门' and \"方案编码\" = '" + mPorjCode + "' \
) va \
WHERE node.\"本点号\" = va.\"起始节点\" and node.\"code\" not in(select \"code\" from \"方案详情表\" \
where \"图层\" = '节点' and \"操作类型\" = 0 and \"方案编码\" = '" + mPorjCode + "') \
union \
SELECT node.\"本点号\", node.\"高程\", node.\"基本需水量\", node.\"需水量模式\", node.\"横坐标\", node.\"纵坐标\", va.\"终止节点\" \
FROM \"方案节点\" node, ( \
SELECT pipe.\"起始节点\", pipe.\"终止节点\" FROM \"管段\" pipe \
WHERE pipe.\"to_layer\" = '阀门' \
and \"code\" not in( \
select \"code\" from \"方案详情表\" \
where \"图层\" = '管段' and \"操作类型\" = 0 and \"方案编码\" = '" + mPorjCode + "' \
) \
union \
select pipe.\"起始节点\", pipe.\"终止节点\" FROM \"方案管段\" pipe where pipe.\"to_layer\" = '阀门' and \"方案编码\" = '" + mPorjCode + "' \
) va \
WHERE node.\"本点号\" = va.\"起始节点\" and node.\"方案编码\" = '" + mPorjCode + "' \
) vnode \
WHERE vnode.\"终止节点\" = va.\"本点号\" and va.\"code\" not in(select \"code\" from \"方案详情表\" \
where \"图层\" = '阀门' and \"操作类型\" = 0 and \"方案编码\" = '" + mPorjCode + "') \
union \
SELECT va.\"code\", 'UP' || va.\"本点号\" AS \"本点号\", vnode.\"高程\", vnode.\"基本需水量\", vnode.\"需水量模式\" \
, (va.\"横坐标\" +1) AS \"横坐标\", (va.\"纵坐标\" + 1) AS \"纵坐标\", va.\"本点号\" as \"阀门本点号\", \
va.\"类型\" as \"阀门类型\", ('UP' || va.\"本点号\") as \"阀门起始节点\", \
va.\"直径\" as \"阀门直径\", va.\"固定状态\" as \"阀门状态\", va.\"设置\" as \"阀门设置\", va.\"水损系数\" \
FROM \"方案阀门\" va, ( \
SELECT node.\"本点号\", node.\"高程\", node.\"基本需水量\", node.\"需水量模式\", node.\"横坐标\", node.\"纵坐标\", va.\"终止节点\" \
FROM \"节点\" node, ( \
SELECT pipe.\"起始节点\", pipe.\"终止节点\" FROM \"管段\" pipe \
WHERE pipe.\"to_layer\" = '阀门' \
and \"code\" not in( \
select \"code\" from \"方案详情表\" \
where \"图层\" = '管段' and \"操作类型\" = 0 and \"方案编码\" = '" + mPorjCode + "' \
) \
union \
select pipe.\"起始节点\", pipe.\"终止节点\" FROM \"方案管段\" pipe where pipe.\"to_layer\" = '阀门' and \"方案编码\" = '" + mPorjCode + "' \
) va \
WHERE node.\"本点号\" = va.\"起始节点\" and node.\"code\" not in(select \"code\" from \"方案详情表\" \
where \"图层\" = '节点' and \"操作类型\" = 0 and \"方案编码\" = '" + mPorjCode + "') \
union \
SELECT node.\"本点号\", node.\"高程\", node.\"基本需水量\", node.\"需水量模式\", node.\"横坐标\", node.\"纵坐标\", va.\"终止节点\" \
FROM \"方案节点\" node, ( \
SELECT pipe.\"起始节点\", pipe.\"终止节点\" FROM \"管段\" pipe \
WHERE pipe.\"to_layer\" = '阀门' \
and \"code\" not in( \
select \"code\" from \"方案详情表\" \
where \"图层\" = '管段' and \"操作类型\" = 0 and \"方案编码\" = '" + mPorjCode + "' \
) \
union \
select pipe.\"起始节点\", pipe.\"终止节点\" FROM \"方案管段\" pipe where pipe.\"to_layer\" = '阀门' and \"方案编码\" = '" + mPorjCode + "' \
) va \
WHERE node.\"本点号\" = va.\"起始节点\" and node.\"方案编码\" = '" + mPorjCode + "' \
) vnode \
WHERE vnode.\"终止节点\" = va.\"本点号\" and va.\"方案编码\" = '" + mPorjCode + "'";
if (!mDbConn->execSql(startSql))
return;
std::vector<std::map<std::string, std::string>> valvesVec;
mDbConn->queryResult(valvesVec);
// 找出节点图层修改的值
std::vector<std::map<std::string, std::string>> valvesDetailVec;
auto iter = mDetailMap.find("阀门");
if (iter != mDetailMap.end())
valvesDetailVec = iter->second;
std::map<std::string, CivValve::ValveTable> valveTableMap;
std::map<std::string, CivPipe::PipesTable> pipeTableMap;
size_t valvsSize = valvesVec.size();
for (int i = 0; i < valvsSize; i++)
{
std::map<std::string, std::string> valveMap = valvesVec[i];
// 构造节点
CivNode::NodeTable nodeTable;
std::string szNo = valveMap.find("本点号")->second;
nodeTable.ID = szNo;
nodeTable.Elev = valveMap.find("高程")->second;
std::string patternID = valveMap.find("需水量模式")->second;
std::string demand = valveMap.find("基本需水量")->second;
handleDelayPattern(demand, patternID, nodeTable.Demand, nodeTable.PatternId);
mNodeVec.push_back(nodeTable);
// 节点坐标
CivCoordinates::CoordTable coordTable;
coordTable.ID = szNo;
coordTable.XCoord = valveMap.find("横坐标")->second;
coordTable.YCoord = valveMap.find("纵坐标")->second;
mCoords.push_back(coordTable);
std::string valveSn = valveMap.find("阀门本点号")->second;
std::string valveType = valveMap.find("阀门类型")->second;
std::string valveStatus = valveMap.find("阀门状态")->second;
std::string code = valveMap.find("code")->second;
// 根据code匹配
for (int i = 0; i < valvesDetailVec.size(); i++)
{
auto detailMap = valvesDetailVec[i];
//code 不匹配,继续下一次循环查找
auto codeIter = detailMap.find("code");
if (codeIter == detailMap.end())
continue;
// 详情表code 与原管网code不想等, 不符合条件
if (codeIter->second == code)
continue;
// 根据属性修改对应的值
std::string attri = detailMap.find("属性")->second;
std::string newValue = detailMap.find("属性新值")->second;
if (attri == "固定状态")
{
valveStatus = newValue;
}
}
if (valveType == "BV") // 止回阀,转成管段
{
CivPipe::Table pipeStruct;
pipeStruct.ID = valveSn;
pipeStruct.Node1 = szNo;
pipeStruct.Length = "2";
pipeStruct.Diameter = valveMap.find("阀门直径")->second;
pipeStruct.Roughness = std::string("130");//valveMap.find("摩阻系数")->second;
pipeStruct.Status = (valveStatus== "开") ? "CV" : "Open";
pipeStruct.MinorLoss = "0";
auto pter = std::make_pair(valveSn, pipeStruct);
pipeTableMap.insert(pter);
}
else
{
// 阀门
CivValve::ValveTable valveTable;
valveTable.ID = valveSn;
valveTable.Node1 = szNo;
valveTable.Diameter = valveMap.find("阀门直径")->second;
valveTable.Type = valveType;
valveTable.Setting = valveMap.find("阀门设置")->second;
valveTable.MinorLoss = valveMap.find("水损系数")->second;
valveTableMap.insert(std::make_pair(szNo, valveTable));
// 阀门状态组件
CivStatus::StatusTable statusTable;
statusTable.ID = valveSn;
statusTable.Setting = valveStatus;
mStatusVec.push_back(statusTable);
}
}
//--构造阀门终止节点
std::string vaEndSql = "SELECT 'DW' || va.\"本点号\" AS \"本点号\", vnode.\"高程\", vnode.\"基本需水量\", vnode.\"需水量模式\"\
, (va.\"横坐标\" - 1) AS \"横坐标\", (va.\"纵坐标\" - 1) AS \"纵坐标\", va.\"本点号\" as \"阀门本点号\",\
va.\"类型\" as \"阀门类型\", ('DW' || va.\"本点号\") as \"阀门终止节点\"\
FROM \"阀门\" va, (\
SELECT node.\"本点号\", node.\"高程\", node.\"基本需水量\", node.\"需水量模式\", node.\"横坐标\", node.\"纵坐标\", va.\"起始节点\"\
FROM \"节点\" node, (\
SELECT pipe.\"编号\", pipe.\"起始节点\", pipe.\"终止节点\", pipe.\"管长\", pipe.\"管径\", pipe.\"摩阻系数\"\
FROM \"管段\" pipe\
WHERE pipe.\"from_layer\" = '阀门' and pipe.\"code\"\
not in(select \"code\" from \"方案详情表\" where \"图层\" = '管段' and \"操作类型\" = 0 and \"方案编码\" = '"+mPorjCode +"')\
union\
SELECT pipe.\"编号\", pipe.\"起始节点\", pipe.\"终止节点\", pipe.\"管长\", pipe.\"管径\", pipe.\"摩阻系数\"\
FROM \"方案管段\" pipe\
WHERE pipe.\"from_layer\" = '阀门' and pipe.\"方案编码\" = '"+mPorjCode +"'\
) va \
WHERE node.\"本点号\" = va.\"终止节点\" and node.\"code\"\
not in(select \"code\" from \"方案详情表\" where \"图层\" = '管段' and \"操作类型\" = 0 and \"方案编码\" = '"+mPorjCode +"')\
union\
SELECT node.\"本点号\", node.\"高程\", node.\"基本需水量\", node.\"需水量模式\", node.\"横坐标\", node.\"纵坐标\", va.\"起始节点\"\
FROM \"方案节点\" node, (\
SELECT pipe.\"编号\", pipe.\"起始节点\", pipe.\"终止节点\", pipe.\"管长\", pipe.\"管径\", pipe.\"摩阻系数\"\
FROM \"管段\" pipe\
WHERE pipe.\"from_layer\" = '阀门' and pipe.\"code\"\
not in(select \"code\" from \"方案详情表\" where \"图层\" = '管段' and \"操作类型\" = 0 and \"方案编码\" = '"+mPorjCode +"')\
union\
SELECT pipe.\"编号\", pipe.\"起始节点\", pipe.\"终止节点\", pipe.\"管长\", pipe.\"管径\", pipe.\"摩阻系数\"\
FROM \"方案管段\" pipe\
WHERE pipe.\"from_layer\" = '阀门' and pipe.\"方案编码\" = '"+mPorjCode +"'\
) va\
WHERE node.\"本点号\" = va.\"终止节点\" and node.\"方案编码\" = '"+mPorjCode +"'\
) vnode\
WHERE vnode.\"起始节点\" = va.\"本点号\"\
and va.\"code\" not in(select \"code\" from \"方案详情表\" where \"图层\" = '阀门' and \"操作类型\" = 0 and \"方案编码\" = '"+mPorjCode +"')\
union\
SELECT 'DW' || va.\"本点号\" AS \"本点号\", vnode.\"高程\", vnode.\"基本需水量\", vnode.\"需水量模式\"\
, (va.\"横坐标\" - 1) AS \"横坐标\", (va.\"纵坐标\" -1) AS \"纵坐标\", va.\"本点号\" as \"阀门本点号\",\
va.\"类型\" as \"阀门类型\", ('DW' || va.\"本点号\") as \"阀门终止节点\"\
FROM \"方案阀门\" va, (\
SELECT node.\"本点号\", node.\"高程\", node.\"基本需水量\", node.\"需水量模式\", node.\"横坐标\", node.\"纵坐标\", va.\"起始节点\"\
FROM \"节点\" node, (\
SELECT pipe.\"编号\", pipe.\"起始节点\", pipe.\"终止节点\", pipe.\"管长\", pipe.\"管径\", pipe.\"摩阻系数\"\
FROM \"管段\" pipe\
WHERE pipe.\"from_layer\" = '阀门' and pipe.\"code\"\
not in(select \"code\" from \"方案详情表\" where \"图层\" = '管段' and \"操作类型\" = 0 and \"方案编码\" = '"+mPorjCode +"')\
union\
SELECT pipe.\"编号\", pipe.\"起始节点\", pipe.\"终止节点\", pipe.\"管长\", pipe.\"管径\", pipe.\"摩阻系数\"\
FROM \"方案管段\" pipe\
WHERE pipe.\"from_layer\" = '阀门' and pipe.\"方案编码\" = '"+mPorjCode +"'\
) va\
WHERE node.\"本点号\" = va.\"终止节点\" and node.\"code\"\
not in(select \"code\" from \"方案详情表\" where \"图层\" = '管段' and \"操作类型\" = 0 and \"方案编码\" = '"+mPorjCode +"')\
union\
SELECT node.\"本点号\", node.\"高程\", node.\"基本需水量\", node.\"需水量模式\", node.\"横坐标\", node.\"纵坐标\", va.\"起始节点\"\
FROM \"方案节点\" node, (\
SELECT pipe.\"编号\", pipe.\"起始节点\", pipe.\"终止节点\", pipe.\"管长\", pipe.\"管径\", pipe.\"摩阻系数\"\
FROM \"管段\" pipe\
WHERE pipe.\"from_layer\" = '阀门' and pipe.\"code\"\
not in(select \"code\" from \"方案详情表\" where \"图层\" = '管段' and \"操作类型\" = 0 and \"方案编码\" = '"+mPorjCode +"')\
union\
SELECT pipe.\"编号\", pipe.\"起始节点\", pipe.\"终止节点\", pipe.\"管长\", pipe.\"管径\", pipe.\"摩阻系数\"\
FROM \"方案管段\" pipe\
WHERE pipe.\"from_layer\" = '阀门' and pipe.\"方案编码\" = '"+mPorjCode +"'\
) va\
WHERE node.\"本点号\" = va.\"终止节点\" and node.\"方案编码\" = '"+mPorjCode +"'\
) vnode\
WHERE vnode.\"起始节点\" = va.\"本点号\" and va.\"方案编码\" = '"+mPorjCode +"'";
if (!mDbConn->execSql(vaEndSql))
return;
std::vector<std::map<std::string, std::string>> valvesEndVec;
mDbConn->queryResult(valvesEndVec);
size_t endVecSize = valvesEndVec.size();
for (int i = 0; i < endVecSize; i++)
{
std::map<std::string, std::string> valveMap = valvesEndVec[i];
// 构造节点
CivNode::NodeTable nodeTable;
std::string szNo = valveMap.find("本点号")->second;
nodeTable.ID = szNo;
nodeTable.Elev = valveMap.find("高程")->second;
std::string patternID = valveMap.find("需水量模式")->second;
std::string demand = valveMap.find("基本需水量")->second;
handleDelayPattern(demand, patternID, nodeTable.Demand, nodeTable.PatternId);
mNodeVec.push_back(nodeTable);
// 节点坐标
CivCoordinates::CoordTable coordTable;
coordTable.ID = szNo;
coordTable.XCoord = valveMap.find("横坐标")->second;
coordTable.YCoord = valveMap.find("纵坐标")->second;
mCoords.push_back(coordTable);
std::string valveSn = valveMap.find("阀门本点号")->second;
std::string valveType = valveMap.find("阀门类型")->second;
if (valveType == "BV") // 止回阀,转成管段
{
auto iter = pipeTableMap.find(valveSn);
if (iter != pipeTableMap.end())
{
pipeTableMap[valveSn].Node2 = szNo;
mPipesVec.push_back(iter->second);
}
}
else
{
// 阀门
auto iter = valveTableMap.find(valveSn);
if (iter != valveTableMap.end())
{
valveTableMap[valveSn].Node2 = szNo;
mValuvesVec.push_back(iter->second);
}
}
}
}
bool CivProjInpDbHelper::getNode(CivNode& node)
......@@ -435,9 +31,9 @@ bool CivProjInpDbHelper::getNode(CivNode& node)
std::string sql = "select \"code\", \"本点号\", \"高程\", \"基本需水量\", \"需水量模式\", \"横坐标\",\"纵坐标\" \
from \"节点\" where\
\"code\" not in(select det.\"code\" from \"方案详情表\" as det where det.\"方案编码\" = '"+mPorjCode+"' and \"图层\" = '节点' and \"操作类型\"=0)\
\"code\" not in(select det.\"code\" from \"方案详情表\" as det where det.\"方案编码\" = '" + mPorjCode + "' and \"图层\" = '节点' and \"操作类型\"=0)\
union select \"code\", \"本点号\", \"高程\", \"基本需水量\", \"需水量模式\", \"横坐标\",\"纵坐标\" \
from \"方案节点\" where \"方案编码\" = '"+ mPorjCode +"' ";
from \"方案节点\" where \"方案编码\" = '" + mPorjCode + "' ";
if (!mDbConn->execSql(sql))
return false;
......@@ -508,12 +104,55 @@ bool CivProjInpDbHelper::getNode(CivNode& node)
{
node.addItem(mNodeVec[i]);
}
}
return true;
void CivProjInpDbHelper::sortProjDeatil()
{
// 查找方案详情表修改的属性
std::string detailSql = "select detail.\"code\",detail.\"图层\",detail.\"属性\",detail.\"属性原值\",detail.\"属性新值\"\
from \"方案详情表\" as detail where \"方案编码\"='" + mPorjCode +"' and \"操作类型\"=1";
if (!mDbConn->execSql(detailSql))
return;
std::vector<std::map<std::string, std::string>> detailVec;
mDbConn->queryResult(detailVec);
size_t detailVecSize = detailVec.size();
// 将方案详情表查出来的数据
for (int i = 0; i < detailVecSize; i++)
{
std::map<std::string, std::string> tempMap = detailVec[i];
std::string layerName = tempMap.find("图层")->second;
mDetailMap[layerName].push_back(tempMap);
}
}
std::string CivProjInpDbHelper::splicingConditions(const std::string& layer)
{
std::string condition = "\"code\" not in(select \"code\" from \"方案详情表\" \
where \"方案编码\" = '" + mPorjCode + "' and \"图层\" = '"+ layer +"' and \"操作类型\"=0)";
return condition;
}
void CivProjInpDbHelper::handleValve()
{
sortProjDeatil();
handleValves2();
return ;
}
bool CivProjInpDbHelper::getPipe(CivPipe& pipes)
{
// 加上处理阀门和水泵产生的虚拟管段
for (int i = 0; i < mPipesVec.size(); i++)
{
pipes.addItem(mPipesVec[i]);
}
PipeTable pipeTable;
std::string sql = "select \"code\",\"编号\",\"起始节点\",\"终止节点\",\"管长\",\"管径\",\"摩阻系数\",\"局损系数\",\"初始状态\"\
......@@ -595,11 +234,7 @@ bool CivProjInpDbHelper::getPipe(CivPipe& pipes)
pipes.addItem(pipe);
}
// 加上处理阀门和水泵产生的虚拟管段
for (int i = 0; i < mPipesVec.size(); i++)
{
pipes.addItem(mPipesVec[i]);
}
return true;
}
......@@ -806,7 +441,7 @@ bool CivProjInpDbHelper::getReservoirs(CivReservoirs& reservoirs)
// 找出节点图层修改的值
std::vector<std::map<std::string, std::string>> resourceDetailVec;
auto iter = mDetailMap.find(PIPENODE);
auto iter = mDetailMap.find(RESIVOIR);
if (iter != mDetailMap.end())
resourceDetailVec = iter->second;
......@@ -947,3 +582,338 @@ std::string CivProjInpDbHelper::genSql(const std::string& table)
{
return "";
}
std::string CivProjInpDbHelper::genSqlView(
const std::string& table,
const std::string& projTable,
const std::vector<std::string>& fieldsVec,
const std::string& projCode)
{
int total = fieldsVec.size();
if (total <= 0)
return "";
std::string fields1;
std::string fileds2;
for (int i = 0; i < total; i++)
{
fields1.append("\""+fieldsVec[i]+"\"");
fields1.append(",");
fileds2.append("node.\""+ fieldsVec[i] +"\"");
fileds2.append(",");
}
fields1 = fields1.substr(0, fields1.length() - 1);
fileds2 = fileds2.substr(0, fileds2.length() - 1);
std::string sql = " SELECT "+ fields1 +" FROM \""+table+"\" EXCEPT SELECT "+fileds2+" FROM \""+ table +"\" as node,\"方案详情表\" as detail where detail.\"图层\" = '" + table + "' and detail.\"方案编码\" = '"+ projCode +"' and detail.\"操作类型\"=0 and node.code =detail.\"code\"";
std::string sql2 = " SELECT " + fields1 + " FROM \""+projTable+"\" as tb WHERE tb.\"方案编码\"='"+ projCode +"'";
return sql +" UNION "+ sql2;
}
std::string CivProjInpDbHelper::splicingSql(const std::string& rightTable, const std::string& demandName, const std::string& demandPattern)
{
// 阀门sqlview视图
std::vector<std::string> valveFiledVec;
valveFiledVec.push_back("code");
valveFiledVec.push_back("本点号");
valveFiledVec.push_back("横坐标");
valveFiledVec.push_back("纵坐标");
valveFiledVec.push_back("固定状态");
valveFiledVec.push_back("类型");
valveFiledVec.push_back("设置");
valveFiledVec.push_back("水损系数");
valveFiledVec.push_back("起始节点");
valveFiledVec.push_back("终止节点");
std::string valveView = genSqlView(TABLE_VALVE, PROJ_TABLE_VALVE, valveFiledVec, mPorjCode);
// 管段sqlview视图
std::vector<std::string> pipeFiledVec;
pipeFiledVec.push_back("编号");
pipeFiledVec.push_back("管长");
pipeFiledVec.push_back("管径");
pipeFiledVec.push_back("摩阻系数");
pipeFiledVec.push_back("from_code");
pipeFiledVec.push_back("to_code");
pipeFiledVec.push_back("code");
std::string pipeView = genSqlView(TABLE_PIPE, PROJ_TABLE_PIPE, pipeFiledVec, mPorjCode);
std::string upcondition;
std::string downcondition;
// 节点的sqlview视图
std::vector<std::string> nodeFiledVec;
nodeFiledVec.push_back("本点号");
nodeFiledVec.push_back("code");
nodeFiledVec.push_back("高程");
nodeFiledVec.push_back("需水量模式");
nodeFiledVec.push_back("基本需水量");
nodeFiledVec.push_back("横坐标");
nodeFiledVec.push_back("纵坐标");
nodeFiledVec.push_back("初始水质");
std::string nodeView = genSqlView(TABLE_NODE, PROJ_TABLE_NODE, nodeFiledVec, mPorjCode);
std::string otherView;
if (rightTable == "节点")
{
upcondition = "pipe.\"from_code\" = node.\"code\" AND pipe.\"to_code\" = junc.\"code\"";
downcondition = "pipe.\"to_code\" = node.\"code\" AND pipe.\"from_code\" = junc.\"code\"";
otherView = nodeView;
}
else
{
upcondition = "(pipe.\"to_code\" = node.\"code\"\
AND pipe.\"from_code\" = junc.\"code\") or\
(pipe.\"from_code\" = node.\"code\"\
AND pipe.\"to_code\" = junc.\"code\")";
downcondition = "(pipe.\"to_code\" = node.\"code\"\
AND pipe.\"from_code\" = junc.\"code\") or\
(pipe.\"from_code\" = node.\"code\"\
AND pipe.\"to_code\" = junc.\"code\")";
std::vector<std::string> otherFiledVec;
otherFiledVec.push_back("本点号");
otherFiledVec.push_back("code");
otherFiledVec.push_back("高程");
otherFiledVec.push_back("横坐标");
otherFiledVec.push_back("纵坐标");
otherFiledVec.push_back("初始水质");
otherView = genSqlView(rightTable, "方案" + rightTable, otherFiledVec, mPorjCode);
}
std::string sql2 = "SELECT A.*, B.* FROM (SELECT\
node.\"本点号\",\
node.\"横坐标\" AS 阀门横坐标,\
node.\"纵坐标\" AS 阀门纵坐标,\
node.\"固定状态\" AS 阀门固定状态,\
node.\"类型\" AS 阀门类型,\
node.\"设置\" AS 阀门设置,\
node.\"水损系数\" AS 阀门水损系数,\
pipe.编号 AS 上游管段编号,\
pipe.\"管长\" AS 上游管长,\
pipe.\"管径\" AS 上游管径,\
pipe.\"摩阻系数\" AS 上游管段摩阻系数,\
junc.\"本点号\" AS 上游节点,\
junc.\"code\" AS \"上游节点code\",\
junc.\"高程\" AS 上游节点高程,\
" + demandPattern + " AS 上游节点蓄水量模式,\
" + demandName + " AS 上游节点基本需水量,\
junc.\"横坐标\" AS 上游节点横坐标,\
junc.\"纵坐标\" AS 上游节点纵坐标,\
junc.\"初始水质\" AS 上游节点初始水质\
FROM ("+ valveView + ")node, ("+pipeView+") pipe,( " + otherView + ") junc\
WHERE " + upcondition + ") A,\
(\
SELECT\
pipe.编号 AS 下游管段编号,\
pipe.\"管长\" AS 下游管段管长,\
pipe.\"管径\" AS 下游管段管径,\
pipe.\"摩阻系数\" AS 下游管段摩阻系数,\
node.\"本点号\",\
junc.\"本点号\" AS 下游节点,\
junc.\"code\" AS \"上游节点code\",\
junc.\"高程\" AS 下游节点高程,\
junc.\"需水量模式\" AS 下游节点蓄水量模式,\
junc.\"基本需水量\" AS 下游节点基本需水量,\
junc.\"横坐标\" AS 下游节点横坐标,\
junc.\"纵坐标\" AS 下游节点纵坐标,\
junc.\"初始水质\" AS 下游节点初始水质\
FROM (" + valveView + ")node, (" + pipeView + ") pipe,(" + nodeView + ") junc\
WHERE " + downcondition + ") B\
WHERE\
A.\"本点号\" = b.\"本点号\"";
return sql2;
}
bool CivProjInpDbHelper::handleValves2()
{
std::string sql = splicingSql("节点");
if (!mDbConn->execSql(sql))
{
std::string error = mDbConn->getLastError();
return false;
}
// 查询与阀门关联的管段,和节点
std::vector<std::map<std::string, std::string>> valvesPipes;
mDbConn->queryResult(valvesPipes);
// 非
std::string sql2 = splicingSql("水库", "0", "1");
if (!mDbConn->execSql(sql2))
{
std::string error = mDbConn->getLastError();
return false;
}
mDbConn->queryResult(valvesPipes);
// 找出节点图层修改的值
std::vector<std::map<std::string, std::string>> valvesDetailVec;
auto iter = mDetailMap.find("阀门");
if (iter != mDetailMap.end())
valvesDetailVec = iter->second;
// 总个数
size_t total = valvesPipes.size();
for (int i = 0; i < total; i++)
{
std::map<std::string, std::string> valvePipe = valvesPipes[i];
std::string vaSzNo = valvePipe.find("本点号")->second;
std::string vaXcoord = valvePipe.find("阀门横坐标")->second;
std::string vaYcoord = valvePipe.find("阀门纵坐标")->second;
std::string vaStatus = valvePipe.find("阀门固定状态")->second;
std::string vaType = valvePipe.find("阀门类型")->second;
std::string vaSetting = valvePipe.find("阀门设置")->second;
std::string vaLoss = valvePipe.find("阀门水损系数")->second;
std::string upperPipeSzNo = valvePipe.find("上游管段编号")->second;
std::string upperPipeCode = valvePipe.find("上游管段code")->second;
std::string upperPipeLength = valvePipe.find("上游管长")->second;
std::string upperPipeDiametor = valvePipe.find("上游管径")->second;
std::string upperPipeFriction = valvePipe.find("下游管段摩阻系数")->second;
std::string upperNodeSz = valvePipe.find("上游节点")->second;
std::string upperNodeHeight = valvePipe.find("上游节点高程")->second;
std::string upperNodePattern = valvePipe.find("上游节点蓄水量模式")->second;
std::string upperNodeDemand = valvePipe.find("上游节点基本需水量")->second;
std::string upperNodeXcoord = valvePipe.find("上游节点横坐标")->second;
std::string upperNodeYcoord = valvePipe.find("上游节点纵坐标")->second;
std::string upperNodeQuality = valvePipe.find("上游节点初始水质")->second;
std::string donwPipeSz = valvePipe.find("下游管段编号")->second;
std::string donwPipeCode = valvePipe.find("下游管段code")->second;
std::string donwPipeLength = valvePipe.find("下游管段管长")->second;
std::string donwPipeDiametor = valvePipe.find("下游管段管径")->second;
std::string downPipeFraction = valvePipe.find("下游管段摩阻系数")->second;
std::string donwNodeSz = valvePipe.find("下游节点")->second;
std::string donwNodeHeight = valvePipe.find("下游节点高程")->second;
std::string donwNodePattern = valvePipe.find("下游节点蓄水量模式")->second;
std::string donwNodeDemand = valvePipe.find("下游节点基本需水量")->second;
std::string donwNodeXcoord = valvePipe.find("下游节点横坐标")->second;
std::string donwNodeYcoord = valvePipe.find("下游节点纵坐标")->second;
std::string donwNodeQuality = valvePipe.find("下游节点初始水质")->second;
// 判断阀门类型
std::string upperVaType = vaType;
std::transform(vaType.begin(), vaType.begin(), vaType.end(), ::toupper);
// 阀门需要构造两个虚拟节点,两个节点尽可能接近
CivNode::NodeTable startNodeTable;
CivCoordinates::CoordTable startNodeCoord; // 节点坐标
// 节点信息
startNodeTable.ID = "VUP" + vaSzNo;
startNodeTable.Elev = upperNodeHeight;
startNodeTable.Demand = "0";
// 两点之间直线
double vupperXcoord = (atof(upperNodeXcoord.c_str()) - atof(vaXcoord.c_str())) / 5 + atof(vaXcoord.c_str());
double vupperYcoord = (atof(upperNodeYcoord.c_str()) - atof(vaYcoord.c_str())) / 5 + atof(vaYcoord.c_str());
// 节点坐标
startNodeCoord.ID = "VUP" + vaSzNo;
startNodeCoord.XCoord = std::to_string(vupperXcoord);
startNodeCoord.YCoord = std::to_string(vupperYcoord);
// 终止节点构造
CivNode::NodeTable endNodeTable; // 终止节点
CivCoordinates::CoordTable endNodeCoord; // 终止节点坐标
// 终止节点信息
endNodeTable.ID = "VDW" + vaSzNo;
endNodeTable.Elev = upperNodeHeight;
endNodeTable.Demand = "0";
mNodeVec.push_back(startNodeTable);
mCoords.push_back(startNodeCoord);
// 两点之间直线
double vdownXcoord = (atof(donwNodeXcoord.c_str()) - atof(vaXcoord.c_str())) / 5 + atof(vaXcoord.c_str());
double vdownYcoord = (atof(donwNodeYcoord.c_str()) - atof(vaYcoord.c_str())) / 5 + atof(vaYcoord.c_str());
// 终止节点坐标信息
endNodeCoord.ID = "VDW" + vaSzNo;
endNodeCoord.XCoord = std::to_string(vdownXcoord);
endNodeCoord.YCoord = std::to_string(vdownYcoord);
mNodeVec.push_back(endNodeTable);
mCoords.push_back(endNodeCoord);
// 构造上游管段的
CivPipe::PipesTable upperPipeTable;
CivPipe::PipesTable downPipeTable;
// 上游管段属性
upperPipeTable.code = upperPipeCode;
upperPipeTable.ID = upperPipeSzNo;
upperPipeTable.Node1 = upperNodeSz;
upperPipeTable.Node2 = startNodeTable.ID;
upperPipeTable.Length = upperPipeLength;
upperPipeTable.Diameter = upperPipeDiametor;
upperPipeTable.Roughness = upperPipeFriction;
upperPipeTable.Status = "Open";
upperPipeTable.MinorLoss = vaLoss;
// 下游管段属性
downPipeTable.code = donwPipeCode;
downPipeTable.ID = donwPipeSz;
downPipeTable.Node1 = endNodeTable.ID;
downPipeTable.Node2 = donwNodeSz;
downPipeTable.Length = donwPipeLength;
downPipeTable.Diameter = donwPipeDiametor;
downPipeTable.Roughness = upperPipeFriction;
downPipeTable.Status = "Open";
downPipeTable.MinorLoss = vaLoss;
mPipesVec.push_back(downPipeTable);
mPipesVec.push_back(upperPipeTable);
// 普通阀门等效于管段
if (upperVaType == "BV")
{
// 构造一条虚拟管段
CivPipe::PipesTable vPipeTable;
vPipeTable.ID = "VG" + vaSzNo;
vPipeTable.Node1 = startNodeTable.ID;
vPipeTable.Node2 = endNodeTable.ID;
vPipeTable.Length = donwPipeLength;
vPipeTable.Diameter = donwPipeDiametor;
vPipeTable.Roughness = upperPipeFriction;
vPipeTable.Status = (vaStatus == "Close")?"CV":"Open";
vPipeTable.MinorLoss = vaLoss;
mPipesVec.push_back(vPipeTable);
}
else
{
// 阀门
CivValve::ValveTable valveTable;
valveTable.ID = vaSzNo;
valveTable.Node1 = startNodeTable.ID;
valveTable.Node2 = endNodeTable.ID;
valveTable.Diameter = upperPipeDiametor;
valveTable.Type = vaType;
valveTable.Setting = vaSetting;
valveTable.MinorLoss = vaLoss;
mValuvesVec.push_back(valveTable);
// 阀门状态组件
CivStatus::StatusTable statusTable;
statusTable.ID = vaSzNo;
statusTable.Setting = vaStatus;
mStatusVec.push_back(statusTable);
}
}
}
\ No newline at end of file
#pragma once
#include "CivAssembly.h"
#include "CivInpHelperAbs.h"
#include <memory>
#include "pandaDbManager.h"
/**
* 增加
......@@ -30,6 +32,17 @@ private:
// 将方案详情表查出的数据按图层分类
void sortProjDeatil();
std::string splicingSql(const std::string& rightTable,
const std::string& demandName = "需水量模式",
const std::string& demandPattern = "基本需水量");
// 根据方案编码生成对应,联合图层的视图sql语句
std::string inline genSqlView(const std::string& table,
const std::string& projTable,
const std::vector<std::string>& fieldsVec,
const std::string& projCode);
/**
*@brief 根据图层动态生成需要查询详情表条件
*/
......@@ -37,6 +50,8 @@ private:
std::string inline genSql(const std::string& table);
bool handleValves2();
std::string mPorjCode;
std::string mCondition;
......
#include "CivPumpHelper.h"
#include "CivPgDbConnection.h"
#include "StringUtils.h"
#include <set>
CivPumpHelper::CivPumpHelper(const string& uri)
......@@ -143,3 +144,201 @@ void CivPumpHelper::getMonitors(vector<string>& monitors,map<string,string>& mon
}
}
}
bool CivPumpHelper::updateDatas(const std::string& tablename,
const std::map<std::string, std::map<std::string, float>>& resultMap)
{
if (tablename.empty())
return false;
if (resultMap.size() <= 0)
return false;
bool resBool = true;
std::map<std::string, std::map<std::string, float>>::const_iterator iter = resultMap.cbegin();
// 缓存节点图层本点号和code 的映射
std::map<std::string, std::string> snToCodeMap;
snToCode("节点", snToCodeMap);
for (; iter != resultMap.cend(); iter++)
{
std::string key = iter->first;
std::map<std::string, float> resmap = iter->second;
std::vector<std::string> dateStrVec;
StringUtils::split(key, dateStrVec);
std::string dateStr;
if (dateStrVec.size() > 1)
dateStr = dateStrVec[0];
// 判断该条件下是否存在数据
std::string sesql = "select \"id\" from "+tablename +" where \"时间点\"='"+key+"'";
if (!mConn->execSql(sesql))
continue;
std::vector<std::map<std::string, std::string>> vecMap;
mConn->queryResult(vecMap);
if (vecMap.size() <= 0 || vecMap[0].size() < 0)
{
// 数据库没数据需要直接插入操作
std::string sql = "INSERT INTO " + tablename + "(日期,时间点,code,余氯) VALUES";
std::map<std::string, float>::const_iterator const_iter = resmap.cbegin();
for (; const_iter != resmap.cend(); const_iter++)
{
std::string keyStr = const_iter->first;
float valStr = const_iter->second;
std::map<std::string, std::string>::iterator keyIter = snToCodeMap.find(keyStr);
if (keyIter != snToCodeMap.end())
{
keyStr = keyIter->second;
}
else
{
continue;
}
sql.append("(");
sql.append("'" + dateStr + "'");
sql.append("'" + key + "'");
sql.append("'" + keyStr + "'");
sql.append(std::to_string(valStr));
sql.append("),");
}
sql = sql.substr(0, sql.size() - 1);
if (!mConn->execSql(sql))
{
resBool = false;
break;
}
}
else // 数据库存在数据则需要更新
{
std::string sql = "update " + tablename +" set \"余氯\" = data_table.vals ";
std::map<std::string, float>::const_iterator const_iter = resmap.cbegin();
std::string codeArr = "array[";
std::string valArr = "array[";
std::string timeArr = "array[";
for (; const_iter != resmap.cend(); const_iter++)
{
std::string keyStr = const_iter->first;
float valStr = const_iter->second;
std::map<std::string, std::string>::iterator keyIter = snToCodeMap.find(keyStr);
if (keyIter != snToCodeMap.end())
{
keyStr = keyIter->second;
}
else
{
continue;
}
// 编码
codeArr.append("'" + keyStr + "',");
// 值
valArr.append(std::to_string(valStr) + ",");
}
std::string codeArrStr = codeArr.substr(0, codeArr.length() - 1);
std::string valArrStr = valArr.substr(0, valArr.length() - 1);
codeArrStr.append("]");
valArrStr.append("]");
sql.append("from (select unnest(");
sql.append(codeArrStr);
sql.append(") as codes,");
// 拼接余氯值
sql.append("unnest(");
sql.append(valArrStr);
sql.append(") as vals) as data_table");
sql.append(" where "+tablename+".\"时间点\" = ' "+key+"'");
sql.append(" and "+ tablename+".\"code\" = data_table.codes");
if (!mConn->execSql(sql))
{
resBool = false;
break;
}
}
}
return resBool;
}
void CivPumpHelper::codeToSn(const std::string& tablename,
std::map<std::string, std::string>& resmap)
{
baseCommonCache(tablename, resmap, CodeToSn);
}
void CivPumpHelper::snToCode(const std::string& tablename,
std::map<std::string, std::string>& resmap)
{
baseCommonCache(tablename, resmap, SnToCode);
}
void CivPumpHelper::baseCommonCache(const std::string& tablename, std::map<std::string, std::string>& resmap, CacheType cacheType)
{
std::string sql;
if (tablename == "管段")
{
sql = "select \"编号\",\"code\" from " + tablename;
}
else
{
sql = "select \"本点号\",\"code\" from " + tablename;
}
if (mConn && !mConn->execSql(sql))
{
return;
}
std::vector<std::map<std::string, std::string>> res;
mConn->queryResult(res);
if (res.size() <= 0)
{
return;
}
//
int total = res.size();
for (int i = 0; i < total; i++)
{
std::map<std::string, std::string> resultMap = res[i];
std::map<std::string, std::string>::const_iterator const_iter = resultMap.cbegin();
std::string key;
std::string val;
for (; const_iter != resultMap.cend(); const_iter++)
{
if(const_iter->first == "code")
key = const_iter->second;
else
val = const_iter->second;
}
switch (cacheType)
{
case CodeToSn:
resmap.insert(std::pair<std::string, std::string>(key, val));
break;
case SnToCode:
resmap.insert(std::pair<std::string, std::string>(val, key));
break;
default:
break;
}
}
return;
}
\ No newline at end of file
......@@ -15,6 +15,11 @@ class CivConnection;
class PANDADBMANAGER_API CivPumpHelper
{
public:
enum CacheType
{
SnToCode,
CodeToSn
};
explicit CivPumpHelper(const string& uri);
~CivPumpHelper();
......@@ -31,6 +36,12 @@ public:
void getPumpStations(vector<PumpStation>& stations);
void getMonitors(vector<string>& monitors, map<string, string>& monitorMap);
bool updateDatas(const std::string& tablename, const std::map<std::string, std::map<std::string, float>>& resultMap);
void codeToSn(const std::string& tablename, std::map<std::string, std::string>& resmap);
void snToCode(const std::string& tablename, std::map<std::string, std::string>& resmap);
private:
void baseCommonCache(const std::string& tablename, std::map<std::string, std::string>& resmap, CacheType cacheType);
private:
CivConnection* mConn = nullptr;
......
......@@ -15,8 +15,8 @@ struct ResultItem
char szNo[64];
std::string dDate;
std::string dTime;
float dQuality;
float dChlorine;
float dQuality = 0;
float dChlorine = 0;
std::string dModifyTime;
};
......@@ -34,6 +34,7 @@ struct LinkResultItem:public ResultItem
{
char szStatus[32];
float dFlow;
float dDrection = 1;
float dVelocity;
float dHeadloss;// 单位水损
};
......
......@@ -10,4 +10,7 @@ public:
CivInpExporter();
~CivInpExporter();
private:
};
......@@ -30,3 +30,6 @@
#define s_BACKDROP "[BACK"
#define s_TAGS "[TAGS"
#define s_END "[END"
......@@ -6,6 +6,12 @@
class CivInpVector
{
public:
enum VectorType
{
Point,
Line,
Other
};
CivInpVector();
~CivInpVector();
......
#include <iostream>
#include "CivInpImpoter.h"
int main(char* argc, char** argv)
{
CivInpImpoter importer;
if (!importer.load("D:\\work\\hydr\\hModelProgram\\Program\\test.inp"))
{
}
getchar();
return 0;
}
\ No newline at end of file
......@@ -150,7 +150,7 @@
<ClInclude Include="CivInpObserver.h" />
<ClInclude Include="CivInpSubject.h" />
<ClInclude Include="CivInpVector.h" />
<ClInclude Include="CivTypes.h" />
<ClInclude Include="CivInpTypes.h" />
<ClInclude Include="pandaInpCore.h" />
</ItemGroup>
<ItemGroup>
......@@ -159,7 +159,6 @@
<ClCompile Include="CivInpObserver.cpp" />
<ClCompile Include="CivInpSubject.cpp" />
<ClCompile Include="CivInpVector.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
......
......@@ -30,9 +30,6 @@
<ClCompile Include="CivInpExporter.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>头文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="CivInpExporter.h">
......@@ -53,7 +50,7 @@
<ClInclude Include="pandaInpCore.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivTypes.h">
<ClInclude Include="CivInpTypes.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
......
......@@ -58,6 +58,24 @@ void JsonParseObject::read(map<string, vector<double>>& resMap)
}
}
void JsonParseObject::read(Condition& resMap)
{
if (!mResultJson)
return;
cJSON* parent = mResultJson->child;
if (!parent)
return;
while (parent)
{
string key = parent->string;
double Val = parent->valuedouble;
resMap.mCondMap.insert(std::pair<std::string, double>(key, Val));
parent = parent->next;
}
}
void JsonParseObject::clear()
{
cJSON_Delete(mResultJson);
......
......@@ -8,6 +8,11 @@ using namespace std;
class cJSON;
typedef struct ConditionStruct
{
std::map<std::string, float> mCondMap;
}Condition;
/**
json解析对象
*/
......@@ -22,6 +27,7 @@ public:
void parse(string& jsonStr);
void read(map<string, string>& resMap);
void read(Condition& resMap);
void read(map<string, vector<double>>& resMap);
......
......@@ -27,3 +27,26 @@ void StringUtils::trim(std::string & s)
s.erase(s.find_last_not_of(" ") + 1);
}
}
int StringUtils::parseInt(std::string& s)
{
std::vector<std::string> sVec;
split(s, sVec);
int res = -1;
if (sVec.size() <1)
return -1;
std::string ss = sVec[1];
std::vector<std::string> ssVec;
split(ss, ssVec,":");
if (ssVec.size() >0)
{
std::string temp = ssVec[0];
res = std::atoi(temp.c_str());
}
return res;
}
......@@ -23,4 +23,10 @@ public:
*@param [in] s 源字符串
*/
static void trim(std::string& s);
/**
*@brief 解析字符串里的整数值
*@param [in] s 源字符串
*/
static int parseInt(std::string& s);
};
#include <windows.h>
#include <objbase.h>
#include <zmouse.h>
#include "MainFrameWnd.h"
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow)
......@@ -12,7 +13,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*l
HRESULT Hr = ::CoInitialize(NULL);
if (FAILED(Hr)) return 0;
C360SafeFrameWnd* pFrame = new C360SafeFrameWnd();
MainFrameWnd* pFrame = new MainFrameWnd();
if (pFrame == NULL) return 0;
pFrame->Create(NULL, _T("360ȫʿ"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 800, 572);
pFrame->CenterWindow();
......
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
......@@ -134,7 +134,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;UILIB_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(OUTDIR)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(OUTDIR)..\include;$(OUTDIR)..\include\Control;$(OUTDIR)..\include\Utils;$(OUTDIR)..\include\Layout;$(OUTDIR)..\include\Core;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
......
......@@ -28,5 +28,5 @@ void CivFeature::addAttributes(const CivAttributes& attributes)
std::string CivFeature::params() const
{
return "";
}
......@@ -14,6 +14,7 @@ public:
explicit CivFeature(const CivGeometry& geom );
CivFeature() = default;
~CivFeature();
/**
* @brief 要素的几何体
* @param [geo] 几何体
......
......@@ -12,7 +12,7 @@ CivGeometry::~CivGeometry()
CivGeometry CivGeometry::fromWktext(const std::string& json)
{
return CivGeometry(GeometryType::Point);
}
String CivGeometry::toJson() const
......
......@@ -36,7 +36,7 @@ CivVariant::CivVariant(float f)
CivVariant::Type CivVariant::type() const
{
return Type::Null;
}
int CivVariant::userType() const
......@@ -53,7 +53,7 @@ const char* CivVariant::typeName() const
bool CivVariant::canConvert(int targetTypeId) const
{
return true;
}
bool CivVariant::convert(int targetTypeId)
......@@ -119,7 +119,7 @@ CivVariant::Type CivVariant::nameToType(const char* name)
return Type::Bool;
}
void* CivVariant::data()
void CivVariant::data()
{
}
......
......@@ -44,7 +44,7 @@ public:
static const char* typeToName(int typeId);
static Type nameToType(const char* name);
void* data();
void data();
const void* constData() const;
inline const void* data() const { return constData(); }
......
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