Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
flink_warehouse_rt
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
data
flink_warehouse_rt
Commits
cff26cf1
Commit
cff26cf1
authored
Mar 06, 2020
by
xuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add code annotation
parent
e3680b80
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
81 deletions
+81
-81
DateUtils.java
warehouseutils/src/main/java/com/gmei/utils/DateUtils.java
+9
-0
GmKafkaConsumer.java
...seutils/src/main/java/com/gmei/utils/GmKafkaConsumer.java
+9
-0
JDBCUtils.java
warehouseutils/src/main/java/com/gmei/utils/JDBCUtils.java
+9
-0
StringUtils.java
warehouseutils/src/main/java/com/gmei/utils/StringUtils.java
+54
-81
No files found.
warehouseutils/src/main/java/com/gmei/utils/DateUtils.java
View file @
cff26cf1
...
@@ -3,6 +3,15 @@ package com.gmei.utils;
...
@@ -3,6 +3,15 @@ package com.gmei.utils;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
/**
* ClassName: com.gmei.utils.DateUtils
* Function: TODO ADD FUNCTION.
* Reason: 日期工具类
* Date: 2020-03-03 00:00:00
*
* @author sjxuwei
* @since JDK 1.8
*/
public
class
DateUtils
{
public
class
DateUtils
{
public
static
long
changeDateToLong
(
String
time
,
SimpleDateFormat
simpleDateFormat
)
throws
ParseException
{
public
static
long
changeDateToLong
(
String
time
,
SimpleDateFormat
simpleDateFormat
)
throws
ParseException
{
return
simpleDateFormat
.
parse
(
time
).
getTime
();
return
simpleDateFormat
.
parse
(
time
).
getTime
();
...
...
warehouseutils/src/main/java/com/gmei/utils/GmKafkaConsumer.java
View file @
cff26cf1
...
@@ -9,6 +9,15 @@ import java.text.ParseException;
...
@@ -9,6 +9,15 @@ import java.text.ParseException;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Properties
;
import
java.util.Properties
;
/**
* ClassName: com.gmei.utils.GmKafkaConsumer
* Function: TODO ADD FUNCTION.
* Reason: 定义kafka数据源,必须定制schama
* Date: 2020-03-03 00:00:00
*
* @author sjxuwei
* @since JDK 1.8
*/
public
class
GmKafkaConsumer
{
public
class
GmKafkaConsumer
{
private
String
topic
;
private
String
topic
;
private
Properties
prop
;
private
Properties
prop
;
...
...
warehouseutils/src/main/java/com/gmei/utils/JDBCUtils.java
View file @
cff26cf1
...
@@ -5,6 +5,15 @@ import java.sql.ResultSet;
...
@@ -5,6 +5,15 @@ import java.sql.ResultSet;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Statement
;
/**
* ClassName: com.gmei.utils.JDBCUtils
* Function: TODO ADD FUNCTION.
* Reason: jdbc工具类
* Date: 2020-03-03 00:00:00
*
* @author sjxuwei
* @since JDK 1.8
*/
public
class
JDBCUtils
{
public
class
JDBCUtils
{
synchronized
public
static
void
close
(
Connection
connection
,
Statement
statement
,
ResultSet
resultSet
)
throws
SQLException
{
synchronized
public
static
void
close
(
Connection
connection
,
Statement
statement
,
ResultSet
resultSet
)
throws
SQLException
{
if
(
connection
!=
null
){
if
(
connection
!=
null
){
...
...
warehouseutils/src/main/java/com/gmei/utils/StringUtils.java
View file @
cff26cf1
...
@@ -8,89 +8,24 @@ import java.security.NoSuchAlgorithmException;
...
@@ -8,89 +8,24 @@ import java.security.NoSuchAlgorithmException;
import
java.util.zip.GZIPInputStream
;
import
java.util.zip.GZIPInputStream
;
import
java.util.zip.GZIPOutputStream
;
import
java.util.zip.GZIPOutputStream
;
/**
* ClassName: com.gmei.utils.StringUtils
* Function: TODO ADD FUNCTION.
* Reason: String工具类
* Date: 2020-03-03 00:00:00
*
* @author sjxuwei
* @since JDK 1.8
*/
public
class
StringUtils
{
public
class
StringUtils
{
/**
/**
* 使用gzip进行压缩
* Function: TODO ADD FUNCTION.
*/
* Reason: 获得数据md5
public
static
String
gzip
(
String
primStr
)
{
* Date: 2020-03-03 00:00:00
if
(
primStr
==
null
||
primStr
.
length
()
==
0
)
{
return
primStr
;
}
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
GZIPOutputStream
gzip
=
null
;
try
{
gzip
=
new
GZIPOutputStream
(
out
);
gzip
.
write
(
primStr
.
getBytes
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
gzip
!=
null
)
{
try
{
gzip
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
return
new
sun
.
misc
.
BASE64Encoder
().
encode
(
out
.
toByteArray
());
}
/**
* <p>Description:使用gzip进行解压缩</p>
*
*
* @
param compressedStr
* @
author sjxuwei
* @
return
* @
since JDK 1.8
*/
*/
public
static
String
gunzip
(
String
compressedStr
)
{
if
(
compressedStr
==
null
)
{
return
null
;
}
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
ByteArrayInputStream
in
=
null
;
GZIPInputStream
ginzip
=
null
;
byte
[]
compressed
=
null
;
String
decompressed
=
null
;
try
{
compressed
=
new
sun
.
misc
.
BASE64Decoder
().
decodeBuffer
(
compressedStr
);
in
=
new
ByteArrayInputStream
(
compressed
);
ginzip
=
new
GZIPInputStream
(
in
);
byte
[]
buffer
=
new
byte
[
1024
];
int
offset
=
-
1
;
while
((
offset
=
ginzip
.
read
(
buffer
))
!=
-
1
)
{
out
.
write
(
buffer
,
0
,
offset
);
}
decompressed
=
out
.
toString
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
ginzip
!=
null
)
{
try
{
ginzip
.
close
();
}
catch
(
IOException
e
)
{
}
}
if
(
in
!=
null
)
{
try
{
in
.
close
();
}
catch
(
IOException
e
)
{
}
}
if
(
out
!=
null
)
{
try
{
out
.
close
();
}
catch
(
IOException
e
)
{
}
}
}
return
decompressed
;
}
public
static
String
getStringMd5
(
byte
[]
bytes
)
throws
NoSuchAlgorithmException
{
public
static
String
getStringMd5
(
byte
[]
bytes
)
throws
NoSuchAlgorithmException
{
MessageDigest
md5
=
MessageDigest
.
getInstance
(
"MD5"
);
MessageDigest
md5
=
MessageDigest
.
getInstance
(
"MD5"
);
byte
[]
digest
=
md5
.
digest
(
bytes
);
byte
[]
digest
=
md5
.
digest
(
bytes
);
...
@@ -105,11 +40,26 @@ public class StringUtils {
...
@@ -105,11 +40,26 @@ public class StringUtils {
return
hexValue
.
toString
();
return
hexValue
.
toString
();
}
}
/**
* Function: TODO ADD FUNCTION.
* Reason: 判断对象是否为NULL
* Date: 2020-03-03 00:00:00
*
* @author sjxuwei
* @since JDK 1.8
*/
public
static
boolean
isObjectNull
(
Object
object
){
public
static
boolean
isObjectNull
(
Object
object
){
return
(
object
==
null
);
return
(
object
==
null
);
}
}
/**
* Function: TODO ADD FUNCTION.
* Reason: 将为NULL的对象转换为长度为0的字符串
* Date: 2020-03-03 00:00:00
*
* @author sjxuwei
* @since JDK 1.8
*/
public
static
String
changeNullTolength0
(
Object
object
){
public
static
String
changeNullTolength0
(
Object
object
){
if
(
object
==
null
){
if
(
object
==
null
){
return
""
;
return
""
;
...
@@ -118,6 +68,14 @@ public class StringUtils {
...
@@ -118,6 +68,14 @@ public class StringUtils {
}
}
}
}
/**
* Function: TODO ADD FUNCTION.
* Reason: 将为NULL的对象转换成double类型
* Date: 2020-03-03 00:00:00
*
* @author sjxuwei
* @since JDK 1.8
*/
public
static
Double
isNullToDouble
(
Object
object
){
public
static
Double
isNullToDouble
(
Object
object
){
if
(
object
==
null
){
if
(
object
==
null
){
return
0.0
;
return
0.0
;
...
@@ -130,6 +88,14 @@ public class StringUtils {
...
@@ -130,6 +88,14 @@ public class StringUtils {
}
}
}
}
/**
* Function: TODO ADD FUNCTION.
* Reason: 从参数中获取第一个不为NULL并且长度大于0的字符串,否则返回长度为0的字符串
* Date: 2020-03-03 00:00:00
*
* @author sjxuwei
* @since JDK 1.8
*/
public
static
String
getNotNull
(
String
...
str
){
public
static
String
getNotNull
(
String
...
str
){
for
(
String
s
:
str
){
for
(
String
s
:
str
){
if
(
s
!=
null
&&
s
.
length
()
>
0
){
if
(
s
!=
null
&&
s
.
length
()
>
0
){
...
@@ -139,7 +105,14 @@ public class StringUtils {
...
@@ -139,7 +105,14 @@ public class StringUtils {
return
""
;
return
""
;
}
}
/**
* Function: TODO ADD FUNCTION.
* Reason: 如果参数1的长度为0则取第二个参数的值
* Date: 2020-03-03 00:00:00
*
* @author sjxuwei
* @since JDK 1.8
*/
public
static
String
changeLength0toOther
(
String
str1
,
String
str2
){
public
static
String
changeLength0toOther
(
String
str1
,
String
str2
){
if
(
str1
.
length
()
==
0
){
if
(
str1
.
length
()
==
0
){
return
str2
;
return
str2
;
...
...
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