Commit ab0f72c6 authored by 刘乐's avatar 刘乐

1, 接口调试

parent b2d67b34
......@@ -6,6 +6,7 @@
#include "time.h"
#include "string.h"
using namespace std;
int main(int argc, char* argv[])
{
......@@ -24,6 +25,7 @@ int main(int argc, char* argv[])
bool msg = simulation(findUri, net, flag);
std::cout << msg << std::endl;
// bool flag = getDataByInterval(findUri,'2020-06-18',)
return 0;
}
\ No newline at end of file
......@@ -15,6 +15,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EPNAET2", "EPNAET2\EPNAET2.
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "funcDemo", "funcDemo\funcDemo.vcxproj", "{6A4F723D-C24B-4B16-A230-9C39A379F082}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pandasUtils", "pandasUtils\pandasUtils.vcxproj", "{7786A13A-338A-4D91-B6BF-DC751E55F018}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -65,6 +67,16 @@ Global
{6A4F723D-C24B-4B16-A230-9C39A379F082}.Release|x64.Build.0 = Release|x64
{6A4F723D-C24B-4B16-A230-9C39A379F082}.Release|x86.ActiveCfg = Release|Win32
{6A4F723D-C24B-4B16-A230-9C39A379F082}.Release|x86.Build.0 = Release|Win32
{7786A13A-338A-4D91-B6BF-DC751E55F018}.Debug|Any CPU.ActiveCfg = Debug|Win32
{7786A13A-338A-4D91-B6BF-DC751E55F018}.Debug|x64.ActiveCfg = Debug|x64
{7786A13A-338A-4D91-B6BF-DC751E55F018}.Debug|x64.Build.0 = Debug|x64
{7786A13A-338A-4D91-B6BF-DC751E55F018}.Debug|x86.ActiveCfg = Debug|Win32
{7786A13A-338A-4D91-B6BF-DC751E55F018}.Debug|x86.Build.0 = Debug|Win32
{7786A13A-338A-4D91-B6BF-DC751E55F018}.Release|Any CPU.ActiveCfg = Release|Win32
{7786A13A-338A-4D91-B6BF-DC751E55F018}.Release|x64.ActiveCfg = Release|x64
{7786A13A-338A-4D91-B6BF-DC751E55F018}.Release|x64.Build.0 = Release|x64
{7786A13A-338A-4D91-B6BF-DC751E55F018}.Release|x86.ActiveCfg = Release|Win32
{7786A13A-338A-4D91-B6BF-DC751E55F018}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -3,6 +3,7 @@
#include "CivTypes.h"
#include "Epanet2.h"
#include "CivInp.h"
#include "../pandaDbManager/CivCommonUtils.h"
#include <time.h>
#include <iostream>
......@@ -50,6 +51,7 @@ bool CivHydrCalc::hydrSimulation(char* fileName, char* rptFile, char* binOutFile
float dHStep;
ENGetVal(4, &dHStep);
bool isFirst = true;
// 计算
do
......@@ -72,7 +74,8 @@ bool CivHydrCalc::hydrSimulation(char* fileName, char* rptFile, char* binOutFile
ENnextH(&tstep);
if (isFirst)
{
mDbConn->deleteByDate(NODERESULTTABLE, "日期", currentDate());
mDbConn->deleteByDate(NODERESULTTABLE, "日期", CurrentDate);
mDbConn->deleteByDate(PIPERESULTTABLE, "日期", CurrentDate);
isFirst = false;
}
// 获取当前节点和管段数据
......@@ -80,7 +83,9 @@ bool CivHydrCalc::hydrSimulation(char* fileName, char* rptFile, char* binOutFile
getLinkResult(iTime);
iTime++;
} while (tstep > 0);
(void)mDbConn->updateNodeByInterval(CurrentDate, CurrentHour);
(void)mDbConn->updateLinkByInterval(CurrentDate,CurrentHour);
return true;
}
......@@ -112,6 +117,7 @@ bool CivHydrCalc::exportInp(char* fileName)
for (int i=0;i<total;i++)
{
std::string table = tables[i];
std::cout << table << std::endl;
if (PIPELINE == table)
continue;
......@@ -121,7 +127,7 @@ bool CivHydrCalc::exportInp(char* fileName)
// 设置曲线
Componets curves = mDbConn->getComponets(CURVETABLE);
// Componets curves = mDbConn->getComponets(CURVETABLE);
// 初始化参数
Options options;
......@@ -175,7 +181,7 @@ void CivHydrCalc::assemble(const std::string& table, CivInp& inp)
auto iter = filter.find(PIPELINE);
if (iter != filter.end())
{
auto lineFilter = filter.find(PIPELINE)->second;
auto lineFilter = iter->second;
if (lineFilter.count(number) > 0)
continue;
}
......@@ -453,21 +459,17 @@ void CivHydrCalc::assemble(const std::string& table, CivInp& inp)
}
}
std::string CivHydrCalc::currentDate()
bool CivHydrCalc::getDataByInterval(char* date, char* interval)
{
time_t rawtime;
struct tm* timeinfo;
char s[100];
time(&rawtime);
if (!mDbConn->updateNodeByInterval(date, interval))
return false;
timeinfo = localtime(&rawtime);
time_t tick = mktime(timeinfo);
strftime(s, sizeof(s), "%Y-%m-%d", timeinfo);
if (!mDbConn->updateLinkByInterval(date, interval))
return false;
return s;
return true;
}
void CivHydrCalc::getNodeResult(short time)
{
int nNodeCount;
......@@ -495,6 +497,8 @@ void CivHydrCalc::getNodeResult(short time)
ENgetnodevalue(i, EN_MAXVOLUME, &nodeItem.dTankMaxVolume);
// 液位高度
ENgetnodevalue(i, EN_TANKLEVEL, &nodeItem.dTankLevel);
nodeItem.dInterval = time;
nodeItems.push_back(nodeItem);
......
......@@ -30,6 +30,8 @@ public:
*/
bool qualitySimulation(char* inpFile, char* rptFile, char* binOutFile);
bool getDataByInterval( char* date, char* interval);
/**
*@brief 导出inp文件
*/
......@@ -41,7 +43,6 @@ private:
*@inp: inp文件对象
*/
void assemble(const std::string& table, CivInp& inp);
std::string currentDate();
/*
*@brief 获取节点计算结果
*@time: 时间
......
#include "CivHydrFuncInter.h"
#include "CivHydrCalc.h"
#include "CivDbConnection.h"
bool DLLEXPORT simulation(char* uri, char* netName, char* flag)
{
......@@ -26,10 +24,10 @@ bool DLLEXPORT simulation(char* uri, char* netName, char* flag)
return msg;
}
bool DLLEXPORT getDataByInterval(char* uri,char* date, char* interval)
bool DLLEXPORT getDataByInterval(char* uri, char* date, char* interval)
{
CivDbConnection* dbConn = new CivDbConnection(uri);
bool flag = dbConn->updateLinkByInterval(date, interval);
delete dbConn;
CivHydrCalc* calc = new CivHydrCalc(uri, "");
bool flag = calc->getDataByInterval(date, interval);
delete calc;
return flag;
}
\ No newline at end of file
......@@ -19,7 +19,7 @@ extern "C" {
*@date: 日期
*@interval: 时段,整数
*/
bool DLLEXPORT getDataByInterval(char* uri,char* date, char* interval);
bool DLLEXPORT getDataByInterval(char* uri, char* date, char* interval);
#if defined(__cplusplus)
}
......
......@@ -152,6 +152,7 @@
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\pandaDbManager\CivCommonUtils.cpp" />
<ClCompile Include="CivComponent.cpp" />
<ClCompile Include="CivHydrCalc.cpp" />
<ClCompile Include="CivHydrFuncInter.cpp" />
......
......@@ -27,6 +27,9 @@
<ClCompile Include="CivHydrFuncInter.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="..\pandaDbManager\CivCommonUtils.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="CivHydrCalc.h">
......
......@@ -95,5 +95,34 @@ std::string CivCommonUtils::currentHour()
time_t tick = mktime(timeinfo);
strftime(s, sizeof(s), "%H", timeinfo);
return s;
std::string res = lstrip(s,'0');
return res;
}
std::string CivCommonUtils::lstrip(char aa[], char c)
{
int i = 0, j = 0, k = 0, z = 0;
k = strlen(aa);
z = k - 1;
while (aa[z] == c)
{
--z;
}
int x = 0, y = 0;
while (aa[y] == c)
{
y++;
}
char bb[256];
int leng = 0;
for (x = y; x < z + 1; x++)
{
bb[leng] = aa[x];
leng++;
}
std::string res = bb;
return res;
}
\ No newline at end of file
......@@ -6,7 +6,7 @@
// 字符串转编码
#define TransUTFCoding(name) CivCommonUtils::string_To_UTF8(name)
#define UTFTransCoding(name) CivCommonUtils::UTF8_To_string(name)
// 当前系统日期
#define CurrentDate CivCommonUtils::currentDate()
......@@ -41,6 +41,8 @@ public:
static std::string currentHour();
static std::string lstrip(char str[],char c);
///**
//*@brief 将json字符串解析为
//*/
......
......@@ -74,7 +74,7 @@ Tables CivDbConnection::getTables(StrQuote netName,StrQuote schema)
for (int j = 0; j < columns; j++)
{
char* item =PQgetvalue(mResult, i, j);
std::string ss = CivCommonUtils::UTF8_To_string(item);
std::string ss = UTFTransCoding(item);
tables.push_back(ss);
}
}
......@@ -113,7 +113,7 @@ bool CivDbConnection::updateNode(const NodeResultItems& nodeItems)
if (createTable(NODERESULTTABLE, "public", NODE_TABLE))
{
os << "INSERT INTO public."<< NODERESULTTABLE<<" ( ";
os <<filedNames.Number<<",";
os << filedNames.Number<<",";
os<< filedNames.dDemand << ",";
os<< filedNames.dHead<<",";
os<< filedNames.dElevation<< ",";
......@@ -146,7 +146,7 @@ bool CivDbConnection::updateNode(const NodeResultItems& nodeItems)
os << item.dTankVolume << ",";
os <<"'"<< CurrentDate <<"',";
os << item.dInterval<<",";
os << "'"<<CurrentTime<<"'";
os << "'"<< CurrentTime <<"'";
if (i == (total - 1))
{
os << ")";
......@@ -157,17 +157,12 @@ bool CivDbConnection::updateNode(const NodeResultItems& nodeItems)
}
}
std::string sql = TransUTFCoding(preSql) + os.str();
os.clear();
os.str("");
if (!execSql(sql))
return false;
}
// 更新管网数据表
if (!updateNodeByInterval(CurrentDate, CurrentHour))
return false;
return true;
}
......@@ -200,9 +195,10 @@ bool CivDbConnection::updateLink(const LinkResultItems& lineItems)
os<< ") VALUES";
std::string preSql = os.str();
os.flush();
os.clear();
os.str("");
// 2, 参数值
size_t total = lineItems.size();
......@@ -222,7 +218,7 @@ bool CivDbConnection::updateLink(const LinkResultItems& lineItems)
os<< "'"<<TransUTFCoding(item.szStatus)<<"'"<<",";
os <<"'"<< CurrentDate << "',";
os<< item.dInterval<<",";
os <<"'" <<CurrentTime<<"'";
os <<"'" << CurrentTime <<"'";
if (i == (total - 1))
os << ")";
else
......@@ -231,7 +227,6 @@ bool CivDbConnection::updateLink(const LinkResultItems& lineItems)
std::string utf8Sql = TransUTFCoding(preSql);
std::string sql = utf8Sql + os.str();
os.flush();
os.clear();
os.str("");
......@@ -239,9 +234,7 @@ bool CivDbConnection::updateLink(const LinkResultItems& lineItems)
return false;
}
if (!updateLinkByInterval(CurrentDate, CurrentHour))
return false;
return true;
}
......@@ -253,24 +246,26 @@ bool CivDbConnection::updateNodeByInterval(StrQuote currDate, StrQuote interval)
std::stringstream os;
NodeFieldName filedNames;
os << "UPDATE "
<< TransUTFCoding(PIPENODE) << " AS tb1 set ("
<< TransUTFCoding("总水头") << ","
os << "UPDATE "
<< TransUTFCoding(PIPENODE) << " AS tb1 set ("
<< TransUTFCoding("总水头") << ","
<< TransUTFCoding("压力") << ","
<< TransUTFCoding("实际需水量") << ")=(select "
<< TransUTFCoding(filedNames.dHead) << ","
<< TransUTFCoding(filedNames.dPressure) << ","
<< TransUTFCoding(filedNames.dDemand) << " from "
<< TransUTFCoding("实际需水量")
<< ")=( "
<< "tb2." << TransUTFCoding(filedNames.dHead) << ","
<< "tb2." << TransUTFCoding(filedNames.dPressure) << ","
<< "tb2." << TransUTFCoding(filedNames.dDemand) << ")" << " from "
<< TransUTFCoding(NODERESULTTABLE) << " AS tb2 where tb1."
<< TransUTFCoding(filedNames.Number) << "= tb2."
<< TransUTFCoding(filedNames.Number) << " AND tb2."
<< TransUTFCoding(filedNames.dDate) << "='" << currDate << "' AND tb2."
<< TransUTFCoding(filedNames.dInterval) << "=" << interval << ")";
<< TransUTFCoding(filedNames.dInterval) << "=" << interval;
std::string updateSql = os.str();
std::cout << updateSql << std::endl;
os.clear();
os.str("");
if (!execSql(updateSql))
return false;
......@@ -285,7 +280,6 @@ bool CivDbConnection::updateLinkByInterval(StrQuote currDate, StrQuote interval)
std::stringstream os;
LinkFiledName filedNames;
os << "UPDATE "
<< TransUTFCoding(PIPELINE) << " AS tb1 set ("
<< TransUTFCoding("流量") << ","
......@@ -296,24 +290,26 @@ bool CivDbConnection::updateLinkByInterval(StrQuote currDate, StrQuote interval)
<< TransUTFCoding("上点水头")<<","
<< TransUTFCoding("本点水头")<<","
<< TransUTFCoding("局部水头损")
<<")=(select "
<< TransUTFCoding(filedNames.dFlow) << ","
<< TransUTFCoding(filedNames.dVelocity) << ","
<< TransUTFCoding(filedNames.dUnitHeadloss)<<","
<< TransUTFCoding(filedNames.dFrictionHeadloss) << ","
<< TransUTFCoding(filedNames.dFromNodHeadloss) << ","
<< TransUTFCoding(filedNames.dToNodHeadloss) << ","
<< TransUTFCoding(filedNames.dLocalHeadloss) << " from "
<<")=( "
<< "tb2." <<TransUTFCoding(filedNames.dFlow) << ","
<< "tb2." << TransUTFCoding(filedNames.dVelocity) << ","
<< "tb2." << TransUTFCoding(filedNames.dUnitHeadloss)<<","
<< "tb2." << TransUTFCoding(filedNames.dHeadloss)<<","
<< "tb2." << TransUTFCoding(filedNames.dFrictionHeadloss) << ","
<< "tb2." << TransUTFCoding(filedNames.dFromNodHeadloss) << ","
<< "tb2." << TransUTFCoding(filedNames.dToNodHeadloss) << ","
<< "tb2." << TransUTFCoding(filedNames.dLocalHeadloss) <<")"<< " from "
<< TransUTFCoding(PIPERESULTTABLE) << " AS tb2 where tb1."
<< TransUTFCoding(filedNames.szNo) << "= tb2."
<< TransUTFCoding(filedNames.szNo) << "= tb2."
<< TransUTFCoding(filedNames.szNo) << " AND tb2."
<< TransUTFCoding(filedNames.dDate) << "='" << currDate << "' AND tb2."
<< TransUTFCoding(filedNames.dInterval) << "=" << interval << ")";
<< TransUTFCoding(filedNames.dDate) << "='" << currDate << "' AND tb2."
<< TransUTFCoding(filedNames.dInterval) << "=" << interval;
std::string updateSql = os.str();
std::cout << updateSql << std::endl;
os.clear();
os.str("");
if (!execSql(updateSql))
return false;
......@@ -380,8 +376,8 @@ void CivDbConnection::getData(PGresult* result, Componets& comp)
char* item = PQgetvalue(result, i, j);
char* fieldName = PQfname(result, j); // 获取列表字段名
std::string itemStr = CivCommonUtils::UTF8_To_string(item);
std::string fieldStr = CivCommonUtils::UTF8_To_string(fieldName);
std::string itemStr = UTFTransCoding(item);
std::string fieldStr = UTFTransCoding(fieldName);
node.insert(std::pair<std::string, std::string>(fieldStr, itemStr));
}
......@@ -502,7 +498,7 @@ Componets CivDbConnection::getLikelyPipes(StrQuote tableName)
{
Componet componet = nodes[i];
Str bendianhao = componet.find("本点号")->second;
if (bendianhao.empty() || bendianhao == "")
if (bendianhao.empty() )
{
Str ID = componet.find("id")->second;
Str type = mValvesMap.find(tableName)->second;
......@@ -515,70 +511,17 @@ Componets CivDbConnection::getLikelyPipes(StrQuote tableName)
Str code = componet.find("code")->second;
// 跟点
Componets lines = getLineByCode(PIPELINE, code);
size_t lTotal = lines.size();
for (int j = 0; j < lTotal; j++)
if (lTotal == 2)
{
Componet lin = lines[j];
Str fromCode = lin.find("from_code")->second;
Str toCode = lin.find("to_code")->second;
Componets codeNodes;
if (fromCode == code)
{
size_t size = tables.size();
for (int i = 0; i < size; i++)
{
codeNodes = getNodeByCode(tables[i], toCode);
if (codeNodes.size() > 0)
break;
}
if (codeNodes.size() > 0)
{
Componet comp = codeNodes[0];
Str pointNo = comp.find("本点号")->second;
nodes[i]["本点号"] = pointNo;
}
}
else if (toCode == code)
{
size_t size = tables.size();
Str currTable;
for (int i = 0; i < size; i++)
{
currTable = tables[i];
codeNodes = getNodeByCode(tables[i], fromCode);
if (codeNodes.size() > 0)
break;
}
// 查询
// codeNodes = getNodeByCode(PIPENODE, fromCode);
if (codeNodes.size() > 0)
{
Componet comp = codeNodes[0];
Str pointNo = comp.find("本点号")->second;
if (currTable == RESIVOIR || currTable == TANK)
{
// 水源必须为起点:点转换为管线过程需要纠正方向
Str lastPoint = nodes[i]["本点号"];
nodes[i]["本点号"] = pointNo;
if (nodes[i]["上点号"].empty())
nodes[i]["上点号"] = lastPoint;
}
else
{
nodes[i]["上点号"] = pointNo;
}
}
}
Componet lin = lines[0];
nodes[i]["上点号"] = lin.find("本点号")->second;
nodes[i]["本点号"] = lin.find("上点号")->second;
Str diameter = lin.find("管径")->second;
nodes[i]["管径"] = diameter;
......@@ -697,6 +640,7 @@ bool CivDbConnection::execSql(std::string sql)
mResult = PQexec(mConn, sql.c_str());
char* error = PQresultErrorMessage(mResult);
std::string errorStr = error;
if ( !errorStr.empty())
{
mLastError = error;
......
......@@ -199,13 +199,13 @@ struct NodeFieldName
{
Str Number = "本点号";
Str dFlow = "流量";
Str dHead = " 水头";
Str dPressure=" 压力";
Str dElevation=" 标高";
Str dDemand=" 实际需水量";
Str dTankVolume=" 水池容量";
Str dTankMaxVolume=" 水池最大容量";
Str dTankLevel=" 液位高度";
Str dHead = "水头";
Str dPressure="压力";
Str dElevation="标高";
Str dDemand="实际需水量";
Str dTankVolume="水池容量";
Str dTankMaxVolume="水池最大容量";
Str dTankLevel="液位高度";
Str dQuality = "水质";
Str dDate = "日期";
Str dInterval = "时段";
......@@ -215,7 +215,7 @@ struct NodeFieldName
struct LinkFiledName
{
Str szNo = "编号";
Str dFlow = " 流量";
Str dFlow = "流量";
Str nFlowDirect = "流向";
Str dVelocity="流速";
Str dHeadloss="水头损失";
......
......@@ -144,7 +144,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libpq.lib;json_vc71_libmt.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>libpq.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OUTDIR)..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ImportLibrary>$(OutDir)..\lib\$(TargetName).lib</ImportLibrary>
</Link>
......
......@@ -21,10 +21,10 @@
<ClInclude Include="CivTypes.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivCommonUtils.h">
<ClInclude Include="CivTableTemp.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivTableTemp.h">
<ClInclude Include="CivCommonUtils.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
......@@ -32,10 +32,10 @@
<ClCompile Include="CivDbConnection.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivCommonUtils.cpp">
<ClCompile Include="CivTableTemp.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivTableTemp.cpp">
<ClCompile Include="CivCommonUtils.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
......
#include "CivCommonUtils.h"
#include <Windows.h>
#include <wchar.h>
#include <time.h>
std::string string_To_UTF8(const std::string& str)
{
int nwLen = ::MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0);
wchar_t* pwBuf = new wchar_t[nwLen + 1]; //一定要加1,不然会出现尾巴
ZeroMemory(pwBuf, nwLen * 2 + 2);
::MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length(), pwBuf, nwLen);
int nLen = ::WideCharToMultiByte(CP_UTF8, 0, pwBuf, -1, NULL, NULL, NULL, NULL);
char* pBuf = new char[nLen + 1];
ZeroMemory(pBuf, nLen + 1);
::WideCharToMultiByte(CP_UTF8, 0, pwBuf, nwLen, pBuf, nLen, NULL, NULL);
std::string strRet(pBuf);
delete[]pwBuf;
delete[]pBuf;
pwBuf = NULL;
pBuf = NULL;
return strRet;
}
std::string UTF8_To_string(const std::string& str)
{
int nwLen = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, NULL, 0);
wchar_t* pwBuf = new wchar_t[nwLen + 1]; //一定要加1,不然会出现尾巴
memset(pwBuf, 0, nwLen * 2 + 2);
MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), pwBuf, nwLen);
int nLen = WideCharToMultiByte(CP_ACP, 0, pwBuf, -1, NULL, NULL, NULL, NULL);
char* pBuf = new char[nLen + 1];
memset(pBuf, 0, nLen + 1);
WideCharToMultiByte(CP_ACP, 0, pwBuf, nwLen, pBuf, nLen, NULL, NULL);
std::string strRet = pBuf;
delete[]pBuf;
delete[]pwBuf;
pBuf = NULL;
pwBuf = NULL;
return strRet;
}
//std::map<std::string, std::string> CivCommonUtils::parseJson(std::string jsonStr)
//{
// std::map<std::string, std::string> map;
//
// return map;
//}
std::string currentTime()
{
time_t rawtime;
struct tm* timeinfo;
char s[100];
time(&rawtime);
timeinfo = localtime(&rawtime);
time_t tick = mktime(timeinfo);
strftime(s, sizeof(s), "%Y-%m-%d %H:%M:%S", timeinfo);
return s;
}
std::string currentDate()
{
time_t rawtime;
struct tm* timeinfo;
char s[100];
time(&rawtime);
timeinfo = localtime(&rawtime);
time_t tick = mktime(timeinfo);
strftime(s, sizeof(s), "%Y-%m-%d", timeinfo);
return s;
}
std::string currentHour()
{
time_t rawtime;
struct tm* timeinfo;
char s[100];
time(&rawtime);
timeinfo = localtime(&rawtime);
time_t tick = mktime(timeinfo);
strftime(s, sizeof(s), "%H", timeinfo);
std::string res = lstrip(s,'0');
return res;
}
std::string lstrip(char aa[], char c)
{
int i = 0, j = 0, k = 0, z = 0;
k = strlen(aa);
z = k - 1;
while (aa[z] == c)
{
--z;
}
int x = 0, y = 0;
while (aa[y] == c)
{
y++;
}
char bb[256];
int leng = 0;
for (x = y; x < z + 1; x++)
{
bb[leng] = aa[x];
}
std::string res = bb;
return res;
}
\ No newline at end of file
#pragma once
#include<string>
#include<map>
// #include<json/reader.h>
#define LIBEXPORT extern
// 字符串转编码
#define TransUTFCoding(name) string_To_UTF8(name)
#define UTFTransCoding(name) UTF8_To_string(name)
// 当前系统日期
#define CurrentDate currentDate()
// 获取当前系统时间
#define CurrentTime currentTime()
#define CurrentHour currentHour()
// std:string转UTF8
LIBEXPORT std::string string_To_UTF8(const std::string& str);
/**
* UTF8转std:string
* 转换过程:先将utf8转双字节Unicode编码,
* 再通过WideCharToMultiByte将宽字符转换为多字节。
*/
LIBEXPORT std::string UTF8_To_string(const std::string& str);
/**
*@brief 获取系统当前时间
*/
LIBEXPORT std::string currentTime();
/**
*@brief 获取系统当前日期
*/
LIBEXPORT std::string currentDate();
LIBEXPORT std::string currentHour();
LIBEXPORT std::string lstrip(char str[], char c);
<?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">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{7786a13a-338a-4d91-b6bf-dc751e55f018}</ProjectGuid>
<RootNamespace>pandasUtils</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>..\..\hModelProgram\lib</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>copy CivCommonUtils.h $(OutDir)..\include /y</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="CivCommonUtils.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="CivCommonUtils.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="CivCommonUtils.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CivCommonUtils.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>
\ No newline at end of file
e:\work\workspace\hydraulicmodelcode\hydraulicmodel\pandasutils\x64\release\pandasutils.pdb
e:\work\workspace\hydraulicmodelcode\hydraulicmodel\pandasutils\x64\release\civcommonutils.obj
e:\work\workspace\hydraulicmodelcode\hmodelprogram\lib\pandasutils.lib
e:\work\workspace\hydraulicmodelcode\hydraulicmodel\pandasutils\..\..\hmodelprogram\lib\pandasutils.lib
e:\work\workspace\hydraulicmodelcode\hydraulicmodel\pandasutils\x64\release\pandasutils.tlog\cl.command.1.tlog
e:\work\workspace\hydraulicmodelcode\hydraulicmodel\pandasutils\x64\release\pandasutils.tlog\cl.read.1.tlog
e:\work\workspace\hydraulicmodelcode\hydraulicmodel\pandasutils\x64\release\pandasutils.tlog\cl.write.1.tlog
e:\work\workspace\hydraulicmodelcode\hydraulicmodel\pandasutils\x64\release\pandasutils.tlog\lib-link.read.1.tlog
e:\work\workspace\hydraulicmodelcode\hydraulicmodel\pandasutils\x64\release\pandasutils.tlog\lib-link.write.1.tlog
e:\work\workspace\hydraulicmodelcode\hydraulicmodel\pandasutils\x64\release\pandasutils.tlog\lib.command.1.tlog
d:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(453,5): warning MSB8004: Output 目录未以斜杠结尾。 此生成实例将添加斜杠,因为必须有这个斜杠才能正确计算 Output 目录。
CivCommonUtils.cpp
E:\work\workspace\hydraulicModelCode\hydraulicModel\pandasUtils\CivCommonUtils.cpp(13,77): warning C4267: “参数”: 从“size_t”转换到“int”,可能丢失数据
E:\work\workspace\hydraulicModelCode\hydraulicModel\pandasUtils\CivCommonUtils.cpp(36,76): warning C4267: “参数”: 从“size_t”转换到“int”,可能丢失数据
E:\work\workspace\hydraulicModelCode\hydraulicModel\pandasUtils\CivCommonUtils.cpp(107,19): warning C4267: “=”: 从“size_t”转换到“int”,可能丢失数据
pandasUtils.vcxproj -> E:\work\workspace\hydraulicModelCode\hydraulicModel\pandasUtils\..\..\hModelProgram\lib\pandasUtils.lib
已复制 1 个文件。
B^E:\WORK\WORKSPACE\HYDRAULICMODELCODE\HYDRAULICMODEL\PANDASUTILS\CIVCOMMONUTILS.CPP
B^E:\WORK\WORKSPACE\HYDRAULICMODELCODE\HYDRAULICMODEL\PANDASUTILS\CIVCOMMONUTILS.CPP
B^E:\WORK\WORKSPACE\HYDRAULICMODELCODE\HYDRAULICMODEL\PANDASUTILS\CIVCOMMONUTILS.CPP
B^E:\WORK\WORKSPACE\HYDRAULICMODELCODE\HYDRAULICMODEL\PANDASUTILS\X64\RELEASE\CIVCOMMONUTILS.OBJ
B^E:\WORK\WORKSPACE\HYDRAULICMODELCODE\HYDRAULICMODEL\PANDASUTILS\X64\RELEASE\CIVCOMMONUTILS.OBJ
B^E:\WORK\WORKSPACE\HYDRAULICMODELCODE\HYDRAULICMODEL\PANDASUTILS\X64\RELEASE\CIVCOMMONUTILS.OBJ
PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.26.28801:TargetPlatformVersion=10.0.18362.0:
Release|x64|E:\work\workspace\hydraulicModelCode\hydraulicModel\|
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