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
240b7ef8
Commit
240b7ef8
authored
Aug 20, 2019
by
李辅翼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v14
parent
dfd34c63
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
33 additions
and
24 deletions
+33
-24
src/main/java/com/hikcreate/controller/PicController.java
+3
-1
src/main/java/com/hikcreate/drv_photo_pic/impl/DrvPhotoImpl.java
+0
-3
src/main/java/com/hikcreate/drv_photo_pic/impl/VehicleImpl.java
+19
-2
src/main/java/com/hikcreate/drv_photo_pic/impl/VioPicImpl.java
+2
-3
src/main/java/com/hikcreate/schedul/PicSchedule.java
+2
-2
src/main/java/com/hikcreate/service/fdfs/service/FileService.java
+1
-1
src/main/java/com/hikcreate/service/fdfs/service/impl/FileServiceImpl.java
+5
-11
src/main/resources/application.properties
+1
-1
No files found.
src/main/java/com/hikcreate/controller/PicController.java
View file @
240b7ef8
...
...
@@ -88,8 +88,10 @@ public class PicController {
* 根据车牌号和车牌类型插入图片
*/
@GetMapping
(
"/insertVehPicByCar"
)
public
void
insertVehPicByCar
(
@RequestParam
(
"hphm"
)
String
hphm
,
@RequestParam
(
"hpzl"
)
String
hpzl
){
@ResponseBody
public
ResponseEntity
insertVehPicByCar
(
@RequestParam
(
"hphm"
)
String
hphm
,
@RequestParam
(
"hpzl"
)
String
hpzl
){
vehicle
.
insertVehPicByCar
(
hphm
,
hpzl
);
return
new
ResponseEntity
(
"sucess"
,
HttpStatus
.
OK
);
}
/**
...
...
src/main/java/com/hikcreate/drv_photo_pic/impl/DrvPhotoImpl.java
View file @
240b7ef8
...
...
@@ -19,12 +19,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.io.BufferedInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.sql.*
;
import
java.sql.Connection
;
import
java.util.Date
;
import
java.util.zip.CRC32
;
...
...
src/main/java/com/hikcreate/drv_photo_pic/impl/VehicleImpl.java
View file @
240b7ef8
...
...
@@ -102,8 +102,10 @@ public class VehicleImpl implements Vehicle {
*/
@Override
public
void
insertVehPicByCar
(
String
hphm
,
String
hpzl
)
{
String
sql
=
"select * from GYJG.VEH_PICTURE where HPHM='"
+
hphm
+
"' and HPZL='"
+
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
+
"'"
;
getPic
(
sql
);
}
/**
...
...
@@ -139,6 +141,9 @@ public class VehicleImpl implements Vehicle {
while
(
resultSet
.
next
())
{
saveToHbase
(
resultSet
,
fileService
);
}
resultSet
.
close
();
pstm
.
close
();
connection
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
...
...
@@ -193,7 +198,7 @@ public class VehicleImpl implements Vehicle {
put
.
addColumn
(
"info"
.
getBytes
(),
"hpzl"
.
getBytes
(),
(
hpzl
==
null
?
"null"
:
hpzl
).
getBytes
());
put
.
addColumn
(
"info"
.
getBytes
(),
"gxsj"
.
getBytes
(),
(
gxsj
==
null
?
"null"
:
gxsj
).
getBytes
());
byte
[]
bytes
=
SqlHelp
.
blobToByteZp
(
zp
);
String
picUrl
=
fileService
.
uploadFile
(
bytes
,
xh
+
".jpeg"
);
String
picUrl
=
uploadFile
(
bytes
,
xh
+
".jpeg"
);
put
.
addColumn
(
"info"
.
getBytes
(),
"picUrl"
.
getBytes
(),
picUrl
.
getBytes
());
vehPicTable
.
put
(
put
);
}
...
...
@@ -203,6 +208,18 @@ public class VehicleImpl implements Vehicle {
}
private
String
uploadFile
(
byte
[]
file
,
String
fileName
){
String
url
;
try
{
url
=
fileService
.
uploadFile
(
file
,
fileName
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
url
=
uploadFile
(
file
,
fileName
);
}
return
url
;
}
private
void
getHbaseVioPicTable
()
{
hbaseConf
=
HBaseConfiguration
.
create
();
...
...
src/main/java/com/hikcreate/drv_photo_pic/impl/VioPicImpl.java
View file @
240b7ef8
...
...
@@ -299,9 +299,8 @@ public class VioPicImpl implements VioPic {
for
(
Map
.
Entry
<
String
,
byte
[]>
entry
:
map
.
entrySet
())
{
if
(
url
.
startsWith
(
"ftp"
)
||
url
.
startsWith
(
"http"
))
{
String
[]
arr
=
url
.
split
(
"/"
);
// logger.info("_-------------" + url);
String
fastDfsUrl
=
fileService
.
uploadFile
(
entry
.
getValue
(),
arr
[
arr
.
length
-
1
].
split
(
"jpg"
)[
0
]
+
"jpg"
);
put
.
addColumn
(
"info"
.
getBytes
(),
hbaseFastCol
.
getBytes
(),
fastDfsUrl
.
getBytes
());
// String fastDfsUrl = fileService.uploadFile(entry.getValue(), arr[arr.length - 1].split("jpg")[0] + "jpg");
// put.addColumn("info".getBytes(), hbaseFastCol.getBytes(), fastDfsUrl.getBytes());
put
.
addColumn
(
"info"
.
getBytes
(),
hbaseFtpCol
.
getBytes
(),
url
.
getBytes
());
isPut
=
true
;
}
else
{
...
...
src/main/java/com/hikcreate/schedul/PicSchedule.java
View file @
240b7ef8
...
...
@@ -29,7 +29,7 @@ public class PicSchedule {
/**
* 每天早上10点同步驾驶人头像增量数据
*/
@Scheduled
(
cron
=
"0 0 10 * * *"
)
//
@Scheduled(cron = "0 0 10 * * *")
public
void
getIncrementDrvPhoto
(){
drvPhoto
.
getIncrementDrvPhoto
();
}
...
...
@@ -47,7 +47,7 @@ public class PicSchedule {
/**
* 每天早上9点同步机动车的增量数据
*/
@Scheduled
(
cron
=
"0 0 9 * * *"
)
//
@Scheduled(cron = "0 0 9 * * *")
public
void
getIncrementVehPic
(){
vehicle
.
getIncrementVehPic
();
}
...
...
src/main/java/com/hikcreate/service/fdfs/service/FileService.java
View file @
240b7ef8
...
...
@@ -12,7 +12,7 @@ public interface FileService {
* @param fileName
* @return
*/
String
uploadFile
(
byte
[]
file
,
String
fileName
);
String
uploadFile
(
byte
[]
file
,
String
fileName
)
throws
Exception
;
/**
* 下载文件
...
...
src/main/java/com/hikcreate/service/fdfs/service/impl/FileServiceImpl.java
View file @
240b7ef8
...
...
@@ -22,23 +22,17 @@ public class FileServiceImpl implements FileService {
@Override
public
synchronized
String
uploadFile
(
byte
[]
file
,
String
fileName
)
{
try
{
Thread
.
sleep
(
7
0
);
public
synchronized
String
uploadFile
(
byte
[]
file
,
String
fileName
)
throws
Exception
{
Thread
.
sleep
(
1
0
);
//将文件上装到fast文件服务器上,成功则返回文件保存的路径
String
path
=
fastDFSClient
.
uploadFile
(
file
,
fileName
);
if
(!
StringUtils
.
hasText
(
path
))
{
logger
.
error
(
"Upload Img Error"
);
}
logger
.
info
(
"Upload Img Success. path {}"
,
(
"/group"
+
path
.
split
(
"group"
)[
1
]));
return
"/group"
+
path
.
split
(
"group"
)[
1
];
}
catch
(
Exception
e
)
{
// e.printStackTrace();
logger
.
error
(
"Upload Img Error, msg ={}"
,
e
);
return
uploadFile
(
file
,
fileName
);
// throw new RuntimeException("上传图片失败");
}
}
@Override
...
...
@@ -49,6 +43,7 @@ public class FileServiceImpl implements FileService {
@Override
public
void
deleteFile
(
String
path
)
{
try
{
logger
.
info
(
"删除图片:"
+
path
);
fastDFSClient
.
deleteFile
(
path
);
}
catch
(
Exception
e
)
{
logger
.
info
(
e
.
toString
());
...
...
@@ -56,5 +51,4 @@ public class FileServiceImpl implements FileService {
}
}
src/main/resources/application.properties
View file @
240b7ef8
...
...
@@ -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
84
server.port
=
80
92
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