Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
familyMart_takeaway
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guanghui.cui
familyMart_takeaway
Commits
c7a4adb9
Commit
c7a4adb9
authored
Mar 21, 2018
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
时间戳转换
parent
4632a17e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
2 deletions
+27
-2
base/BaseDefine.h
+3
-0
src/JsonModule.cpp
+3
-1
src/main.cpp
+1
-1
utility/utility.cpp
+16
-0
utility/utility.h
+4
-0
No files found.
base/BaseDefine.h
View file @
c7a4adb9
...
...
@@ -93,5 +93,7 @@
//推送类型
#define ODS_PUSH_TYPE_HEARTBEAT 3 //心跳
#define ODS_PUSH_TYPE_STOCKWARN 1006 //库存预警
#define ODS_PUSH_TYPE_COMMON 1017 //通用预警
#define ODS_PUSH_TYPE_COMMON_BACK 1018 //通用预警返回
#endif
\ No newline at end of file
src/JsonModule.cpp
View file @
c7a4adb9
#include "JsonModule.h"
#include "../utility/utility.h"
#include "../3rdParty/rapidjson/rapidjson.h"
#include "../3rdParty/rapidjson/document.h"
#include "../3rdParty/rapidjson/reader.h"
...
...
@@ -1425,7 +1426,8 @@ void JsonModule::_getStockWarnObj(IN const char* json,OUT stockWarnObj &warn_obj
}
rapidjson
::
Value
&
alertTime
=
document
[
"alertTime"
];
detail
.
alertTime
=
alertTime
.
GetString
();
int64_t
iDatetime
=
alertTime
.
GetInt64
();
detail
.
alertTime
=
getdatetime
(
iDatetime
);
warn_obj
.
vecProducts
.
push_back
(
detail
);
}
...
...
src/main.cpp
View file @
c7a4adb9
...
...
@@ -195,7 +195,7 @@ int main()
/// 注册回调函数
el
::
Helpers
::
installPreRollOutCallback
(
logRolloutHandler
);
LOG
(
INFO
)
<<
"---------software start---------"
;
LOG
(
INFO
)
<<
"---------software start---------
.
"
;
//sqlite初始化
if
(
!
sqlite
.
initSQLite
()){
...
...
utility/utility.cpp
View file @
c7a4adb9
...
...
@@ -6,6 +6,7 @@
#include <iconv.h>
#include <string.h>
#include <sys/time.h>
#include <chrono>
#ifdef WIN32
#include <Windows.h>
...
...
@@ -107,3 +108,17 @@ int64_t timestamp_seconds()
gettimeofday
(
&
tv
,
NULL
);
return
tv
.
tv_sec
;
}
std
::
string
getdatetime
(
int64_t
timestamp
)
{
std
::
string
strDate
;
int64_t
milli
=
timestamp
+
(
int64_t
)
8
*
60
*
60
*
1000
;
//此处转化为东八区北京时间,如果是其它时区需要按需求修改
auto
mTime
=
std
::
chrono
::
milliseconds
(
milli
);
auto
tp
=
std
::
chrono
::
time_point
<
std
::
chrono
::
system_clock
,
std
::
chrono
::
milliseconds
>
(
mTime
);
auto
tt
=
std
::
chrono
::
system_clock
::
to_time_t
(
tp
);
std
::
tm
*
now
=
std
::
gmtime
(
&
tt
);
char
datetime
[
64
];
sprintf
(
datetime
,
"%4d%02d%02d%02d%02d%02d"
,
now
->
tm_year
+
1900
,
now
->
tm_mon
+
1
,
now
->
tm_mday
,
now
->
tm_hour
,
now
->
tm_min
,
now
->
tm_sec
);
strDate
=
datetime
;
return
strDate
;
}
\ No newline at end of file
utility/utility.h
View file @
c7a4adb9
...
...
@@ -19,4 +19,7 @@ int64_t timestamp_seconds();
//获取时间戳(毫秒)
int64_t
timestamps_milliseconds
();
//根据时间戳获取时间
std
::
string
getdatetime
(
int64_t
timestamp
);
#endif
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment