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
47fefcec
Commit
47fefcec
authored
Aug 13, 2019
by
李辅翼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v10
parent
bc49983b
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
31 deletions
+40
-31
src/main/java/com/hikcreate/controller/PicController.java
+10
-0
src/main/java/com/hikcreate/drv_photo_pic/Vehicle.java
+2
-0
src/main/java/com/hikcreate/drv_photo_pic/impl/DrvPhotoImpl.java
+3
-3
src/main/java/com/hikcreate/drv_photo_pic/impl/VehicleImpl.java
+16
-23
src/main/java/com/hikcreate/schedul/PicSchedule.java
+4
-1
src/main/java/com/hikcreate/service/fdfs/service/impl/FileServiceImpl.java
+5
-4
No files found.
src/main/java/com/hikcreate/controller/PicController.java
View file @
47fefcec
...
...
@@ -67,6 +67,16 @@ public class PicController {
}
/**
* 同步指定时间段车辆图片数据
*/
@GetMapping
(
"/getVehPicStage"
)
public
void
getVehPicStage
(
@RequestParam
(
"start"
)
String
start
,
@RequestParam
(
"end"
)
String
end
){
vehicle
.
getVehPicStage
(
start
,
end
);
}
/**
* 车辆增量图片
*/
@GetMapping
(
"/getIncrementVehPic"
)
...
...
src/main/java/com/hikcreate/drv_photo_pic/Vehicle.java
View file @
47fefcec
...
...
@@ -6,4 +6,6 @@ public interface Vehicle {
void
getIncrementVehPic
();
void
insertVehPicByCar
(
String
hphm
,
String
hpzl
);
void
getVehPicStage
(
String
start
,
String
end
);
}
src/main/java/com/hikcreate/drv_photo_pic/impl/DrvPhotoImpl.java
View file @
47fefcec
...
...
@@ -193,7 +193,7 @@ public class DrvPhotoImpl implements DrvPhoto {
hbaseConn
=
ConnectionFactory
.
createConnection
(
hbaseConf
);
driverPhotoTablename
=
TableName
.
valueOf
(
driverPhotoTableStr
);
driverPhototable
=
hbaseConn
.
getTable
(
driverPhotoTablename
);
String
sql
=
"select * from GYJG.DRV_PHOTO where ZP is not null and fzjg
is not null
and sfzmhm is not null "
+
String
sql
=
"select * from GYJG.DRV_PHOTO where ZP is not null and fzjg
='贵A'
and sfzmhm is not null "
+
"and to_char(GXSJ,'yyyy-mm-dd')>='"
+
start
+
"' and to_char(GXSJ,'yyyy-mm-dd')<'"
+
end
+
"'"
;
Connection
connection
=
DriverManager
.
getConnection
(
url
,
username
,
password
);
PreparedStatement
pstm
=
connection
.
prepareStatement
(
sql
);
...
...
@@ -211,13 +211,13 @@ public class DrvPhotoImpl implements DrvPhoto {
}
}
private
static
void
saveToHbase
(
ResultSet
resultSet
,
FileService
fileService
)
throws
Exception
{
private
s
ynchronized
s
tatic
void
saveToHbase
(
ResultSet
resultSet
,
FileService
fileService
)
throws
Exception
{
paramResultSet
(
resultSet
);
//判断图片是否已经存入fastdfs
colValue
=
new
String
[
2
];
String
rowkey
=
sfzmhm
;
boolean
flag1
=
SqlHelp
.
getFlag
(
rowkey
,
driverPhototable
,
colValue
,
gxsj
);
logger
.
info
(
flag1
+
"================"
);
//
logger.info(flag1+"================");
if
(
flag1
)
{
Put
put
=
new
Put
(
rowkey
.
getBytes
());
put
.
addColumn
(
"info"
.
getBytes
(),
"sfzmhm"
.
getBytes
(),
sfzmhm
.
getBytes
());
...
...
src/main/java/com/hikcreate/drv_photo_pic/impl/VehicleImpl.java
View file @
47fefcec
...
...
@@ -3,11 +3,9 @@ package com.hikcreate.drv_photo_pic.impl;
import
com.hikcreate.drv_photo_pic.Vehicle
;
import
com.hikcreate.service.fdfs.service.FileService
;
import
com.hikcreate.utils.DateUtil
;
import
javafx.scene.control.Tab
;
import
oracle.sql.BLOB
;
import
org.apache.hadoop.conf.Configuration
;
import
org.apache.hadoop.hbase.HBaseConfiguration
;
import
org.apache.hadoop.hbase.KeyValue
;
import
org.apache.hadoop.hbase.TableName
;
import
org.apache.hadoop.hbase.client.*
;
import
org.slf4j.Logger
;
...
...
@@ -15,7 +13,6 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
redis.clients.jedis.ZParams
;
import
java.io.IOException
;
import
java.sql.*
;
...
...
@@ -74,7 +71,7 @@ public class VehicleImpl implements Vehicle {
Connection
connection
=
DriverManager
.
getConnection
(
url
,
username
,
password
);
lastTime
=
DateUtil
.
formatDate
(
DateUtil
.
getPastDate
(
DateUtil
.
parseDate
(
endTime
),
roundDay
));
sql
=
"select * from GYJG.VEH_PICTURE where to_char(GXSJ,'yyyy-mm-dd')>=? and to_char(GXSJ,'yyyy-mm-dd')<? "
+
" and ZP is not null and
HPHM is not null and HPZL is not null
"
;
" and ZP is not null and
XH is not null
"
;
PreparedStatement
pstm
=
connection
.
prepareStatement
(
sql
);
pstm
.
setString
(
1
,
lastTime
);
pstm
.
setString
(
2
,
endTime
);
...
...
@@ -99,7 +96,7 @@ public class VehicleImpl implements Vehicle {
*/
@Override
public
void
getIncrementVehPic
()
{
String
sql
=
"select * from GYJG.VEH_PICTURE where GXSJ between sysdate-
3 and sysdate and ZP is not null and fzjg is not null and sfzmhm
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
);
}
...
...
@@ -114,6 +111,18 @@ public class VehicleImpl implements Vehicle {
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"
;
getPic
(
sql
);
}
private
void
getPic
(
String
sql
)
{
getHbaseVioPicTable
();
...
...
@@ -167,25 +176,9 @@ public class VehicleImpl implements Vehicle {
hpzl
=
resultSet
.
getString
(
"HPZL"
);
zp
=
(
BLOB
)
resultSet
.
getBlob
(
"ZP"
);
gxsj
=
resultSet
.
getString
(
"GXSJ"
);
String
rowkey
=
hphm
+
"#"
+
hpzl
;
String
rowkey
=
xh
;
colValue
=
new
String
[
2
];
boolean
flag
=
SqlHelp
.
getFlag
(
rowkey
,
vehPicTable
,
colValue
,
gxsj
);
// boolean flag1 = true;
// Get get = new Get(rowkey.getBytes());
// get.addColumn("info".getBytes(), "picUrl".getBytes());
// get.addColumn("info".getBytes(), "gxsj".getBytes());
// Result result = vehPicTable.get(get);
// for (KeyValue value : result.raw()) {
// if ("picUrl".equals(new String(value.getQualifierArray()))) {
// colValue[0] = new String(value.getValue());
// }
// if ("gxsj".equals(value.getQualifierArray())) {
// colValue[1] = new String(value.getValue());
// }
// }
// if (colValue[0] != null && gxsj.substring(0, 19).compareTo(colValue[1].substring(0, 19)) < 0) {
// flag1 = false;
// }
if
(
flag
)
{
Put
put
=
new
Put
(
rowkey
.
getBytes
());
put
.
addColumn
(
"info"
.
getBytes
(),
"xh"
.
getBytes
(),
(
xh
==
null
?
"null"
:
xh
).
getBytes
());
...
...
@@ -197,7 +190,7 @@ public class VehicleImpl implements Vehicle {
put
.
addColumn
(
"info"
.
getBytes
(),
"picUrl"
.
getBytes
(),
picUrl
.
getBytes
());
vehPicTable
.
put
(
put
);
}
}
catch
(
Exception
e
)
{
}
catch
(
IOException
|
SQL
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
src/main/java/com/hikcreate/schedul/PicSchedule.java
View file @
47fefcec
...
...
@@ -44,7 +44,10 @@ public class PicSchedule {
vioPic
.
getIncrementVioPic
(
DateUtil
.
formatDate
(
DateUtil
.
getPastDate
(
new
Date
(),-
pastDay
)),
date
);
}
@Scheduled
(
cron
=
"0 0 10 * * *"
)
/**
* 每天早上9点同步机动车的增量数据
*/
// @Scheduled(cron = "0 0 9 * * *")
public
void
getIncrementVehPic
(){
vehicle
.
getIncrementVehPic
();
}
...
...
src/main/java/com/hikcreate/service/fdfs/service/impl/FileServiceImpl.java
View file @
47fefcec
...
...
@@ -3,7 +3,6 @@ package com.hikcreate.service.fdfs.service.impl;
import
com.github.tobato.fastdfs.service.FastFileStorageClient
;
import
com.hikcreate.service.fdfs.FastDFSClient
;
import
com.hikcreate.service.fdfs.service.FileService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
org.slf4j.Logger
;
...
...
@@ -21,13 +20,11 @@ public class FileServiceImpl implements FileService {
@Resource
private
FastDFSClient
fastDFSClient
;
@Autowired
private
FastFileStorageClient
storageClient
;
@Override
public
synchronized
String
uploadFile
(
byte
[]
file
,
String
fileName
)
{
try
{
Thread
.
sleep
(
20
0
);
Thread
.
sleep
(
7
0
);
//将文件上装到fast文件服务器上,成功则返回文件保存的路径
String
path
=
fastDFSClient
.
uploadFile
(
file
,
fileName
);
if
(!
StringUtils
.
hasText
(
path
))
{
...
...
@@ -39,6 +36,7 @@ public class FileServiceImpl implements FileService {
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
logger
.
error
(
"Upload Img Error, msg ={}"
,
e
);
uploadFile
(
file
,
fileName
);
throw
new
RuntimeException
(
"上传图片失败"
);
}
}
...
...
@@ -56,4 +54,7 @@ public class FileServiceImpl implements FileService {
logger
.
info
(
e
.
toString
());
}
}
}
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