Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
ftp_pic
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
李辅翼
ftp_pic
Commits
4a56114c
Commit
4a56114c
authored
Aug 20, 2019
by
李辅翼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v14
parent
240b7ef8
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
50 deletions
+58
-50
src/main/java/com/hikcreate/drv_photo_pic/impl/VehicleImpl.java
+53
-45
src/main/java/com/hikcreate/entity/PicResult.java
+2
-2
src/main/java/com/hikcreate/schedul/PicSchedule.java
+1
-1
src/main/java/com/hikcreate/service/fdfs/service/impl/FileServiceImpl.java
+1
-1
src/main/resources/application.properties
+1
-1
No files found.
src/main/java/com/hikcreate/drv_photo_pic/impl/VehicleImpl.java
View file @
4a56114c
...
...
@@ -43,12 +43,8 @@ public class VehicleImpl implements Vehicle {
private
static
String
startTime
;
private
static
String
endTime
;
private
static
TableName
vehPicTableName
;
private
static
Table
vehPicTable
;
private
static
String
[]
colValue
;
private
static
Configuration
hbaseConf
;
private
static
org
.
apache
.
hadoop
.
hbase
.
client
.
Connection
hbaseConn
;
/**
* 全量车辆图片
...
...
@@ -57,8 +53,15 @@ public class VehicleImpl implements Vehicle {
*/
@Override
public
void
getHisVehPic
(
String
time
)
{
getHbaseVioPicTable
();
org
.
apache
.
hadoop
.
hbase
.
client
.
Connection
hbaseConn
=
null
;
Table
vehPicTable
=
null
;
try
{
Configuration
hbaseConf
=
HBaseConfiguration
.
create
();
hbaseConf
.
set
(
"hbase.zookeeper.property.clientPort"
,
hbaseAddress
);
hbaseConf
.
set
(
"hbase.zookeeper.quorum"
,
hbaseZkQuorum
);
hbaseConn
=
ConnectionFactory
.
createConnection
(
hbaseConf
);
TableName
vehPicTableName
=
TableName
.
valueOf
(
vehPicTableStr
);
vehPicTable
=
hbaseConn
.
getTable
(
vehPicTableName
);
endTime
=
time
;
startTime
=
SqlHelp
.
getStartTime
(
"select min(GXSJ) mtime from GYJG.VEH_PICTURE"
,
url
,
username
,
password
);
String
lastTime
;
...
...
@@ -73,7 +76,7 @@ public class VehicleImpl implements Vehicle {
pstm
.
setString
(
2
,
endTime
);
ResultSet
resultSet
=
pstm
.
executeQuery
();
while
(
resultSet
.
next
())
{
saveToHbase
(
resultSet
,
fileService
);
saveToHbase
(
resultSet
,
fileService
,
vehPicTable
);
}
endTime
=
lastTime
;
resultSet
.
close
();
...
...
@@ -82,7 +85,20 @@ public class VehicleImpl implements Vehicle {
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
closeHbase
();
if
(
hbaseConn
!=
null
)
{
try
{
hbaseConn
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
if
(
vehPicTable
!=
null
)
{
try
{
vehPicTable
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
...
...
@@ -91,71 +107,72 @@ public class VehicleImpl implements Vehicle {
*/
@Override
public
void
getIncrementVehPic
()
{
String
sql
=
"select * from GYJG.VEH_PICTURE where GXSJ between sysdate-10 and sysdate and ZP is not null and XH is not null"
;
String
sql
=
"select * from GYJG.VEH_PICTURE where GXSJ between sysdate-10 and sysdate and ZP is not null and XH is not null"
;
getPic
(
sql
);
}
/**
* 根据车牌号获取图片
*
* @param hphm
* @param hpzl
*/
@Override
public
void
insertVehPicByCar
(
String
hphm
,
String
hpzl
)
{
String
sql
=
"select b.XH xh,b.HPHM hphm,b.HPZL hpzl,b.ZP zp,b.GXSJ gxsj from ZCKJ.VM_VEHICLE_GY a inner join GYJG.VEH_PICTURE b "
+
"on a.XH=b.XH where a.HPHM='"
+
hphm
+
"' and a.HPZL='"
+
hpzl
+
"'"
;
"on a.XH=b.XH where a.HPHM='"
+
hphm
+
"' and a.HPZL='"
+
hpzl
+
"'"
;
getPic
(
sql
);
}
/**
* 同步指定时间段的增量图片
*
* @param start
* @param end
*/
@Override
public
void
getVehPicStage
(
String
start
,
String
end
)
{
String
sql
=
"select * from GYJG.VEH_PICTURE where "
+
"to_char(GXSJ,'yyyy-mm-dd')>'"
+
start
+
"' and to_char(GXSJ,'yyyy-mm-dd')<='"
+
end
+
"' and ZP is not null and XH is not null"
;
String
sql
=
"select * from GYJG.VEH_PICTURE where "
+
"to_char(GXSJ,'yyyy-mm-dd')>'"
+
start
+
"' and to_char(GXSJ,'yyyy-mm-dd')<='"
+
end
+
"' and ZP is not null and XH is not null"
;
getPic
(
sql
);
}
/**
* 根据序号插入图片
*
* @param xh
*/
@Override
public
void
insertVehPicByXh
(
String
xh
)
{
String
sql
=
"select * from GYJG.VEH_PICTURE where XH='"
+
xh
+
"'"
;
String
sql
=
"select * from GYJG.VEH_PICTURE where XH='"
+
xh
+
"'"
;
getPic
(
sql
);
}
private
void
getPic
(
String
sql
)
{
getHbaseVioPicTable
();
org
.
apache
.
hadoop
.
hbase
.
client
.
Connection
hbaseConn
=
null
;
Table
vehPicTable
=
null
;
try
{
Configuration
hbaseConf
=
HBaseConfiguration
.
create
();
hbaseConf
.
set
(
"hbase.zookeeper.property.clientPort"
,
hbaseAddress
);
hbaseConf
.
set
(
"hbase.zookeeper.quorum"
,
hbaseZkQuorum
);
hbaseConn
=
ConnectionFactory
.
createConnection
(
hbaseConf
);
TableName
vehPicTableName
=
TableName
.
valueOf
(
vehPicTableStr
);
vehPicTable
=
hbaseConn
.
getTable
(
vehPicTableName
);
Class
.
forName
(
"oracle.jdbc.OracleDriver"
);
Connection
connection
=
DriverManager
.
getConnection
(
url
,
username
,
password
);
PreparedStatement
pstm
=
connection
.
prepareStatement
(
sql
);
ResultSet
resultSet
=
pstm
.
executeQuery
();
ResultSet
resultSet
=
pstm
.
executeQuery
();
while
(
resultSet
.
next
())
{
saveToHbase
(
resultSet
,
fileService
);
saveToHbase
(
resultSet
,
fileService
,
vehPicTable
);
}
resultSet
.
close
();
pstm
.
close
();
connection
.
close
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
closeHbase
();
}
}
/**
* 关闭hbase
*/
private
void
closeHbase
()
{
if
(
hbaseConn
!=
null
)
{
try
{
hbaseConn
.
close
();
...
...
@@ -171,14 +188,17 @@ public class VehicleImpl implements Vehicle {
}
}
}
}
/**
* 存储图片
*
* @param resultSet
* @param fileService
* @param vehPicTable
*/
private
synchronized
void
saveToHbase
(
ResultSet
resultSet
,
FileService
fileService
)
{
private
synchronized
void
saveToHbase
(
ResultSet
resultSet
,
FileService
fileService
,
Table
vehPicTable
)
{
try
{
String
xh
=
resultSet
.
getString
(
"XH"
);
String
hphm
=
resultSet
.
getString
(
"HPHM"
);
...
...
@@ -188,8 +208,8 @@ public class VehicleImpl implements Vehicle {
String
rowkey
=
xh
;
colValue
=
new
String
[
2
];
PicResult
picResult
=
SqlHelp
.
getFlag
(
rowkey
,
vehPicTable
,
colValue
,
gxsj
);
if
(
picResult
.
getI
()
!=
0
)
{
if
(
picResult
.
getI
()==
2
)
{
if
(
picResult
.
getI
()
!=
0
)
{
if
(
picResult
.
getI
()
==
2
)
{
fileService
.
deleteFile
(
picResult
.
getUrl
());
}
Put
put
=
new
Put
(
rowkey
.
getBytes
());
...
...
@@ -208,30 +228,18 @@ public class VehicleImpl implements Vehicle {
}
private
String
uploadFile
(
byte
[]
file
,
String
fileName
){
private
String
uploadFile
(
byte
[]
file
,
String
fileName
)
{
String
url
;
try
{
url
=
fileService
.
uploadFile
(
file
,
fileName
);
url
=
fileService
.
uploadFile
(
file
,
fileName
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
url
=
uploadFile
(
file
,
fileName
);
url
=
uploadFile
(
file
,
fileName
);
}
return
url
;
}
private
void
getHbaseVioPicTable
()
{
hbaseConf
=
HBaseConfiguration
.
create
();
hbaseConf
.
set
(
"hbase.zookeeper.property.clientPort"
,
hbaseAddress
);
hbaseConf
.
set
(
"hbase.zookeeper.quorum"
,
hbaseZkQuorum
);
try
{
hbaseConn
=
ConnectionFactory
.
createConnection
(
hbaseConf
);
vehPicTableName
=
TableName
.
valueOf
(
vehPicTableStr
);
vehPicTable
=
hbaseConn
.
getTable
(
vehPicTableName
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
src/main/java/com/hikcreate/entity/PicResult.java
View file @
4a56114c
...
...
@@ -6,6 +6,6 @@ import java.io.Serializable;
@Data
public
class
PicResult
implements
Serializable
{
int
i
;
String
url
;
public
int
i
;
public
String
url
;
}
src/main/java/com/hikcreate/schedul/PicSchedule.java
View file @
4a56114c
...
...
@@ -29,7 +29,7 @@ public class PicSchedule {
/**
* 每天早上10点同步驾驶人头像增量数据
*/
//
@Scheduled(cron = "0 0 10 * * *")
@Scheduled
(
cron
=
"0 0 10 * * *"
)
public
void
getIncrementDrvPhoto
(){
drvPhoto
.
getIncrementDrvPhoto
();
}
...
...
src/main/java/com/hikcreate/service/fdfs/service/impl/FileServiceImpl.java
View file @
4a56114c
...
...
@@ -46,7 +46,7 @@ public class FileServiceImpl implements FileService {
logger
.
info
(
"删除图片:"
+
path
);
fastDFSClient
.
deleteFile
(
path
);
}
catch
(
Exception
e
)
{
logger
.
info
(
e
.
toString
()
);
deleteFile
(
path
);
}
}
...
...
src/main/resources/application.properties
View file @
4a56114c
...
...
@@ -20,7 +20,7 @@ fdfs.tracker-list[1] = 172.16.25.26:22122
fdfs.pool.max-total
=
153
fdfs.pool.max-wait-millis
=
102
#˿
server.port
=
80
92
server.port
=
80
84
hbase.zookeeper.property.clientPort
=
2181
hbase.zookeeper.quorum
=
172.16.25.25,172.16.25.28,172.16.25.24,172.16.25.26,172.16.25.27
...
...
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