Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
huangzhicong
/
SmartCanteen
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6617adfb
authored
Mar 17, 2020
by
pye52
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'new_master' into new_for_phone
parents
518ec14a
7eb29a76
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
app/src/main/java/com/bgycc/smartcanteen/command/LogCommandHandler.java
+9
-9
No files found.
app/src/main/java/com/bgycc/smartcanteen/command/LogCommandHandler.java
View file @
6617adfb
...
...
@@ -8,7 +8,6 @@ import com.bgycc.smartcanteen.entity.CommandResponse;
import
com.blankj.utilcode.util.FileUtils
;
import
com.blankj.utilcode.util.LogUtils
;
import
com.blankj.utilcode.util.PathUtils
;
import
com.blankj.utilcode.util.Utils
;
import
com.blankj.utilcode.util.ZipUtils
;
import
com.google.gson.Gson
;
...
...
@@ -37,11 +36,12 @@ import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG;
public
class
LogCommandHandler
extends
CommandHandler
{
private
static
final
String
BOOT_LOG
=
"system"
;
private
static
final
String
ZIP_FILE
=
"log.zip"
;
private
static
final
String
UPLOAD_DIR
=
File
.
separator
+
"upload_log"
;
private
static
final
String
UPLOAD_DIR
=
"upload_log"
;
private
static
final
long
DEFAULT_DELAY
=
1000
;
private
volatile
boolean
start
=
false
;
private
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
,
Locale
.
getDefault
());
private
SimpleDateFormat
parseFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
,
Locale
.
getDefault
());
private
SimpleDateFormat
nameFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
,
Locale
.
getDefault
());
private
String
deviceSN
;
private
CommandLog
commandLog
;
...
...
@@ -83,12 +83,12 @@ public class LogCommandHandler extends CommandHandler {
startTime
=
null
;
endTime
=
null
;
try
{
startTime
=
f
ormat
.
parse
(
data
.
getStartTime
());
startTime
=
parseF
ormat
.
parse
(
data
.
getStartTime
());
}
catch
(
ParseException
e
)
{
LogUtils
.
w
(
TAG
,
"日志上传,起始时间解析失败: "
+
data
.
toString
(),
e
);
}
try
{
endTime
=
f
ormat
.
parse
(
data
.
getEndTime
());
endTime
=
parseF
ormat
.
parse
(
data
.
getEndTime
());
}
catch
(
ParseException
e
)
{
LogUtils
.
w
(
TAG
,
"日志上传,结束时间解析失败: "
+
data
.
toString
(),
e
);
}
...
...
@@ -117,7 +117,7 @@ public class LogCommandHandler extends CommandHandler {
}
Thread
.
sleep
(
DEFAULT_DELAY
);
File
zip
=
new
File
(
Utils
.
getApp
().
getCacheDir
()
+
File
.
separator
+
ZIP_FILE
);
File
zip
=
new
File
(
PathUtils
.
getExternalStoragePath
()
+
File
.
separator
+
ZIP_FILE
);
try
{
wait
(
"开始压缩"
,
40
);
ZipUtils
.
zipFile
(
uploadDir
,
zip
);
...
...
@@ -143,7 +143,7 @@ public class LogCommandHandler extends CommandHandler {
}
private
File
tempDirInit
()
{
File
dir
=
new
File
(
Utils
.
getApp
().
getCacheDir
()
+
UPLOAD_DIR
);
File
dir
=
new
File
(
PathUtils
.
getExternalStoragePath
()
+
File
.
separator
+
UPLOAD_DIR
);
if
(
dir
.
exists
())
{
// 清空临时文件夹
FileUtils
.
delete
(
dir
);
...
...
@@ -183,8 +183,8 @@ public class LogCommandHandler extends CommandHandler {
SCApi
api
=
SCRetrofit
.
createApi
(
client
);
CommandLog
.
CommandLogData
data
=
commandLog
.
getData
();
String
fileNameForServer
=
data
.
getLogType
()
+
f
ormat
.
format
(
startTime
)
+
f
ormat
.
format
(
endTime
)
+
nameF
ormat
.
format
(
startTime
)
+
nameF
ormat
.
format
(
endTime
)
+
deviceSN
+
".zip"
;
fileNameForServer
=
fileNameForServer
.
replace
(
" "
,
"_"
);
LogUtils
.
d
(
TAG
,
"开始上传日志: "
+
fileNameForServer
);
...
...
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