Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
ba0afae6
Commit
ba0afae6
authored
May 08, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
消除成功接收处理
parent
1d1ae937
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
47 additions
and
35 deletions
+47
-35
ByteHelper.java
...src/main/java/com/yanzuoguang/util/helper/ByteHelper.java
+1
-1
EnumHelper.java
...src/main/java/com/yanzuoguang/util/helper/EnumHelper.java
+1
-1
HttpHelper.java
...src/main/java/com/yanzuoguang/util/helper/HttpHelper.java
+6
-5
LogDate.java
...-base/src/main/java/com/yanzuoguang/util/log/LogDate.java
+15
-15
LogDefault.java
...se/src/main/java/com/yanzuoguang/util/log/LogDefault.java
+6
-5
LogInfo.java
...-base/src/main/java/com/yanzuoguang/util/log/LogInfo.java
+16
-6
TableHeadItem.java
...c/main/java/com/yanzuoguang/util/table/TableHeadItem.java
+2
-2
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/ByteHelper.java
View file @
ba0afae6
...
...
@@ -525,7 +525,7 @@ public class ByteHelper {
*/
public
static
String
logBytes
(
byte
[]
bytes
)
{
int
length
=
bytes
.
length
;
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
(
length
);
for
(
byte
b
:
bytes
)
{
sb
.
append
(
b
);
sb
.
append
(
" "
);
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/EnumHelper.java
View file @
ba0afae6
...
...
@@ -60,7 +60,7 @@ public class EnumHelper {
String
vName
=
vMet
.
getName
();
if
(
"forValue"
.
equals
(
vName
)
&&
vMet
.
getParameterTypes
().
length
==
1
)
{
Class
vTempType
=
vMet
.
getParameterTypes
()[
0
];
//
Class vTempType = vMet.getParameterTypes()[0];
Object
obj
=
vMet
.
invoke
(
null
,
i
);
result
=
(
T
)
obj
;
CacheMethod
.
put
(
vType
,
vMet
);
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/HttpHelper.java
View file @
ba0afae6
...
...
@@ -10,6 +10,7 @@ import java.io.*;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.nio.charset.Charset
;
/**
* HTTP请求工具类
...
...
@@ -28,7 +29,7 @@ public class HttpHelper {
try
{
// 打开URL连接
java
.
net
.
HttpURLConnection
httpConn
=
getConn
(
url
);
return
post
(
httpConn
,
url
,
jsonString
);
return
post
(
httpConn
,
jsonString
);
}
catch
(
Exception
ex
)
{
throw
new
CodeException
(
ex
);
}
...
...
@@ -46,7 +47,7 @@ public class HttpHelper {
// 打开URL连接
java
.
net
.
HttpURLConnection
httpConn
=
getConn
(
url
);
httpConn
.
setRequestProperty
(
"Content-Type"
,
"application/json"
);
return
post
(
httpConn
,
url
,
jsonString
);
return
post
(
httpConn
,
jsonString
);
}
catch
(
Exception
ex
)
{
throw
new
CodeException
(
ex
);
}
...
...
@@ -79,18 +80,18 @@ public class HttpHelper {
/**
* 发送POST请求,当请求失败时,抛出异常或返回空字符串
*
* @param
url 目的地址
* @param
httpConn 链接信息
* @param jsonString 请求参数,json字符串。
* @return 远程响应结果
*/
public
static
String
post
(
HttpURLConnection
httpConn
,
String
url
,
String
jsonString
)
throws
IOException
{
public
static
String
post
(
HttpURLConnection
httpConn
,
String
jsonString
)
throws
IOException
{
// 返回的结果
String
result
=
""
;
// 读取响应输入流
BufferedReader
in
=
null
;
PrintWriter
out
=
null
;
// 处理请求参数
StringBuffer
sb
=
new
StringBuffer
();
//
StringBuffer sb = new StringBuffer();
String
params
=
""
;
try
{
params
=
jsonString
;
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/log/LogDate.java
View file @
ba0afae6
...
...
@@ -11,11 +11,11 @@ import java.util.Date;
* @author Light
*/
public
class
LogDate
{
public
static
int
MinMillSecond
=
1
;
public
static
final
int
MIN_MILL_SECOND
=
1
;
private
StringBuilder
log
=
new
StringBuilder
();
private
Date
start
=
new
Date
();
private
Date
end
=
new
Date
();
private
long
start
=
System
.
currentTimeMillis
();
private
long
end
=
System
.
currentTimeMillis
();
private
double
lastSecond
=
0
;
private
double
totalSecond
=
0
;
...
...
@@ -42,7 +42,7 @@ public class LogDate {
* 开始记录
*/
public
void
begin
()
{
this
.
start
=
new
Date
();
this
.
start
=
System
.
currentTimeMillis
();
}
/**
...
...
@@ -59,8 +59,8 @@ public class LogDate {
* 提交日志,用于跟踪时间
*/
public
void
commit
()
{
this
.
end
=
new
Date
();
double
total
=
this
.
end
.
getTime
()
-
this
.
start
.
getTime
()
;
this
.
end
=
System
.
currentTimeMillis
();
double
total
=
this
.
end
-
this
.
start
;
this
.
lastSecond
=
total
-
this
.
totalSecond
;
this
.
totalSecond
=
total
;
}
...
...
@@ -74,7 +74,7 @@ public class LogDate {
public
void
commit
(
String
tag
,
Object
...
args
)
{
this
.
commit
();
if
(!
StringHelper
.
isEmpty
(
tag
))
{
String
log
=
String
.
format
(
"
\r\n
%s: %f ms 总共: %f ms "
,
String
.
format
(
tag
,
args
),
this
.
lastSecond
,
this
.
totalSecond
);
String
log
=
String
.
format
(
"%s: %f ms 总共: %f ms "
,
String
.
format
(
tag
,
args
),
this
.
lastSecond
,
this
.
totalSecond
);
this
.
log
.
append
(
log
);
}
}
...
...
@@ -83,8 +83,8 @@ public class LogDate {
* 将当前日志对象复位
*/
public
void
clear
()
{
this
.
start
=
new
Date
();
this
.
end
=
new
Date
();
this
.
start
=
System
.
currentTimeMillis
();
this
.
end
=
System
.
currentTimeMillis
();
this
.
lastSecond
=
0
;
this
.
totalSecond
=
0
;
this
.
log
=
new
StringBuilder
();
...
...
@@ -95,7 +95,7 @@ public class LogDate {
*/
public
void
write
()
{
// 执行时间为0的不显示日志
if
(
this
.
totalSecond
>=
M
inMillSecond
)
{
if
(
this
.
totalSecond
>=
M
IN_MILL_SECOND
)
{
String
vLog
=
this
.
log
.
toString
();
if
(!
StringHelper
.
isEmpty
(
vLog
))
{
Log
.
info
(
LogDate
.
class
,
this
.
log
.
toString
());
...
...
@@ -110,7 +110,7 @@ public class LogDate {
* @return
*/
public
StringBuilder
getLog
()
{
return
log
;
return
this
.
log
;
}
/**
...
...
@@ -119,7 +119,7 @@ public class LogDate {
* @return
*/
public
Date
getStart
()
{
return
start
;
return
new
Date
(
this
.
start
)
;
}
/**
...
...
@@ -128,7 +128,7 @@ public class LogDate {
* @return
*/
public
Date
getEnd
()
{
return
end
;
return
new
Date
(
this
.
end
)
;
}
/**
...
...
@@ -137,7 +137,7 @@ public class LogDate {
* @return
*/
public
double
getLastSecond
()
{
return
lastSecond
;
return
this
.
lastSecond
;
}
/**
...
...
@@ -146,6 +146,6 @@ public class LogDate {
* @return
*/
public
double
getTotalSecond
()
{
return
totalSecond
;
return
t
his
.
t
otalSecond
;
}
}
\ No newline at end of file
yzg-util-base/src/main/java/com/yanzuoguang/util/log/LogDefault.java
View file @
ba0afae6
package
com
.
yanzuoguang
.
util
.
log
;
import
com.yanzuoguang.util.helper.DateHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
/**
* 日志处理默认处理函数
...
...
@@ -15,16 +16,16 @@ public class LogDefault implements RunnableLog {
*/
@Override
public
void
run
(
LogInfo
info
)
{
Class
<?>
cls
=
info
.
getCls
();
StringBuilder
sb
=
new
StringBuilder
();
if
(
info
==
null
)
{
return
;
}
String
clsName
=
""
;
if
(
info
.
getCls
()
!=
null
)
{
Class
<?>
cls
=
info
.
getCls
();
String
clsName
=
StringHelper
.
EMPTY
;
if
(
cls
!=
null
)
{
clsName
=
info
.
getCls
().
getSimpleName
();
}
sb
.
append
(
String
.
format
(
"/* %s pid:%d t:%d/%d ms %s %s */ %s"
,
StringBuilder
sb
=
new
StringBuilder
(
String
.
format
(
"/* %s pid:%d t:%d/%d ms %s %s */ %s"
,
DateHelper
.
getDateTimeString
(
"HH:mm:ss.SSS"
,
info
.
getNow
()),
Thread
.
currentThread
().
getId
(),
info
.
getTime
(),
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/log/LogInfo.java
View file @
ba0afae6
...
...
@@ -14,7 +14,7 @@ public class LogInfo {
/**
* 错误发生时间
*/
private
Date
now
;
private
long
now
;
/**
* 标记信息
*/
...
...
@@ -95,9 +95,9 @@ public class LogInfo {
*/
public
LogInfo
(
Class
<?>
cls
,
Date
date
,
Throwable
ex
,
String
msg
)
{
this
.
cls
=
cls
;
this
.
now
=
date
;
this
.
exception
=
ex
;
this
.
message
=
msg
;
this
.
setNow
(
date
)
;
this
.
setException
(
ex
)
;
this
.
setMessage
(
msg
)
;
}
public
Class
<?>
getCls
()
{
...
...
@@ -109,11 +109,21 @@ public class LogInfo {
}
public
Date
getNow
()
{
return
now
;
if
(
this
.
now
==
0
){
return
null
;
}
else
{
return
new
Date
(
this
.
now
);
}
}
public
void
setNow
(
Date
now
)
{
this
.
now
=
now
;
if
(
now
!=
null
){
this
.
now
=
now
.
getTime
()
;
}
else
{
this
.
now
=
0
;
}
}
public
String
getTag
()
{
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/table/TableHeadItem.java
View file @
ba0afae6
...
...
@@ -116,10 +116,10 @@ public class TableHeadItem {
}
public
boolean
isDataColumn
()
{
return
dataColumn
;
return
this
.
dataColumn
;
}
public
void
setDataColumn
(
boolean
dataColumn
)
{
dataColumn
=
dataColumn
;
this
.
dataColumn
=
dataColumn
;
}
}
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