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
2d761682
Commit
2d761682
authored
Aug 22, 2019
by
李辅翼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v14
parent
57157a55
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
102 additions
and
12 deletions
+102
-12
src/main/java/com/hikcreate/controller/PicController.java
+11
-0
src/main/java/com/hikcreate/drv_photo_pic/Vehicle.java
+2
-0
src/main/java/com/hikcreate/drv_photo_pic/impl/VehicleImpl.java
+71
-7
src/main/java/com/hikcreate/service/fdfs/service/FileService.java
+4
-1
src/main/java/com/hikcreate/service/fdfs/service/impl/FileServiceImpl.java
+14
-4
No files found.
src/main/java/com/hikcreate/controller/PicController.java
View file @
2d761682
...
...
@@ -122,6 +122,17 @@ public class PicController {
}
}
/**
* 删除Hbase机动车表所有数据
* @param table
* @param maxrow
* @param minrow
*/
@GetMapping
(
"/deleteAllVehPic"
)
public
void
deleteAllVehPic
(
@RequestParam
(
"table"
)
String
table
,
@RequestParam
(
"maxrow"
)
String
maxrow
,
@RequestParam
(
"minrow"
)
String
minrow
){
vehicle
.
deleteAllVehPic
(
table
,
maxrow
,
minrow
);
}
@GetMapping
(
"/drvPhotoHis"
)
public
void
getHisDrvPhoto
(
@RequestParam
(
"time"
)
String
time
,
HttpServletResponse
response
)
{
...
...
src/main/java/com/hikcreate/drv_photo_pic/Vehicle.java
View file @
2d761682
...
...
@@ -10,4 +10,6 @@ public interface Vehicle {
void
getVehPicStage
(
String
start
,
String
end
);
void
insertVehPicByXh
(
String
xh
);
void
deleteAllVehPic
(
String
table
,
String
maxrow
,
String
minrow
);
}
src/main/java/com/hikcreate/drv_photo_pic/impl/VehicleImpl.java
View file @
2d761682
...
...
@@ -9,6 +9,7 @@ import org.apache.hadoop.conf.Configuration;
import
org.apache.hadoop.hbase.HBaseConfiguration
;
import
org.apache.hadoop.hbase.TableName
;
import
org.apache.hadoop.hbase.client.*
;
import
org.apache.hadoop.hbase.util.Bytes
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -18,6 +19,8 @@ import org.springframework.stereotype.Service;
import
java.io.IOException
;
import
java.sql.*
;
import
java.sql.Connection
;
import
java.util.Iterator
;
import
java.util.Map
;
@Service
(
"vehicleImpl"
)
public
class
VehicleImpl
implements
Vehicle
{
...
...
@@ -149,6 +152,55 @@ public class VehicleImpl implements Vehicle {
getPic
(
sql
);
}
@Override
public
void
deleteAllVehPic
(
String
table1
,
String
maxrow
,
String
minrow
)
{
org
.
apache
.
hadoop
.
hbase
.
client
.
Connection
connection
=
null
;
Table
table
=
null
;
try
{
Configuration
conf
=
HBaseConfiguration
.
create
();
conf
.
set
(
"hbase.zookeeper.property.clientPort"
,
hbaseAddress
);
conf
.
set
(
"hbase.zookeeper.quorum"
,
hbaseZkQuorum
);
connection
=
ConnectionFactory
.
createConnection
(
conf
);
table
=
connection
.
getTable
(
TableName
.
valueOf
(
table1
));
Scan
scan
=
new
Scan
();
scan
.
setStartRow
(
Bytes
.
toBytes
(
minrow
));
scan
.
setStopRow
(
Bytes
.
toBytes
(
maxrow
));
ResultScanner
rs
=
table
.
getScanner
(
scan
);
Iterator
<
Result
>
it
=
rs
.
iterator
();
while
(
it
.
hasNext
())
{
Result
r
=
it
.
next
();
Map
<
byte
[],
byte
[]>
map
=
r
.
getFamilyMap
(
Bytes
.
toBytes
(
"info"
));
String
url
=
Bytes
.
toString
(
map
.
get
(
Bytes
.
toBytes
(
"picUrl"
)));
try
{
fileService
.
deleteFile
(
url
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
Delete
delete
=
new
Delete
(
r
.
getRow
());
table
.
delete
(
delete
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
connection
!=
null
){
try
{
connection
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
if
(
table
!=
null
){
try
{
table
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
private
void
getPic
(
String
sql
)
{
org
.
apache
.
hadoop
.
hbase
.
client
.
Connection
hbaseConn
=
null
;
...
...
@@ -211,11 +263,12 @@ public class VehicleImpl implements Vehicle {
if
(
picResult
.
getI
()
==
2
)
{
try
{
fileService
.
deleteFile
(
picResult
.
getUrl
());
Delete
delete
=
new
Delete
(
rowkey
.
getBytes
());
vehPicTable
.
delete
(
delete
);
}
catch
(
Exception
e
)
{
logger
.
info
(
xh
);
logger
.
info
(
xh
+
"---------------------"
+
picResult
.
getUrl
()
);
e
.
printStackTrace
();
}
finally
{
Delete
delete
=
new
Delete
(
rowkey
.
getBytes
());
vehPicTable
.
delete
(
delete
);
}
}
Put
put
=
new
Put
(
rowkey
.
getBytes
());
...
...
@@ -224,7 +277,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
=
uploadFile
(
bytes
,
xh
+
".jpeg"
,
xh
);
String
picUrl
=
uploadFile
(
bytes
,
xh
+
".jpeg"
,
xh
);
put
.
addColumn
(
"info"
.
getBytes
(),
"picUrl"
.
getBytes
(),
picUrl
.
getBytes
());
vehPicTable
.
put
(
put
);
}
...
...
@@ -235,16 +288,27 @@ public class VehicleImpl implements Vehicle {
}
private
String
uploadFile
(
byte
[]
file
,
String
fileName
,
String
xh
)
{
private
String
uploadFile
(
byte
[]
file
,
String
fileName
,
String
xh
)
{
String
url
;
try
{
url
=
fileService
.
uploadFile
(
file
,
fileName
);
}
catch
(
Exception
e
)
{
logger
.
info
(
"---------------"
+
xh
);
logger
.
info
(
"---------------"
+
xh
);
e
.
printStackTrace
();
url
=
uploadFile
(
file
,
fileName
,
xh
);
url
=
uploadFile
(
file
,
fileName
,
xh
);
}
return
url
;
// int count=0;
// while ("false".equals(url)){
// url=fileService.uploadFile(file, fileName);
// count++;
// if(count>10){
// logger.info("---------------" + xh);
// }
// }
}
...
...
src/main/java/com/hikcreate/service/fdfs/service/FileService.java
View file @
2d761682
package
com
.
hikcreate
.
service
.
fdfs
.
service
;
import
java.io.IOException
;
/**
* @author 赵东
* @create 2019/3/22 13:39
...
...
@@ -12,7 +14,7 @@ public interface FileService {
* @param fileName
* @return
*/
String
uploadFile
(
byte
[]
file
,
String
fileName
)
throws
Exception
;
String
uploadFile
(
byte
[]
file
,
String
fileName
)
throws
IOException
,
Interrupted
Exception
;
/**
* 下载文件
...
...
@@ -25,4 +27,5 @@ public interface FileService {
void
deleteFile
(
String
path
);
}
src/main/java/com/hikcreate/service/fdfs/service/impl/FileServiceImpl.java
View file @
2d761682
...
...
@@ -9,6 +9,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
/**
* @author 赵东
...
...
@@ -22,17 +23,26 @@ public class FileServiceImpl implements FileService {
@Override
public
synchronized
String
uploadFile
(
byte
[]
file
,
String
fileName
)
throws
Exception
{
public
synchronized
String
uploadFile
(
byte
[]
file
,
String
fileName
)
throws
IOException
,
InterruptedException
{
Thread
.
sleep
(
10
);
//将文件上装到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
];
// try {
// Thread.sleep(10);
// //将文件上装到fast文件服务器上,成功则返回文件保存的路径
// String path = fastDFSClient.uploadFile(file, fileName);
// if (!StringUtils.hasText(path)) {
// logger.error("Upload Img Error");
// }
// return "/group" + path.split("group")[1];
// } catch (Exception e) {
// e.printStackTrace();
// return "false";
// }
}
@Override
...
...
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