Commit 240b7ef8 by 李辅翼

v14

parent dfd34c63
......@@ -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);
}
/**
......
......@@ -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;
......
......@@ -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();
......
......@@ -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 {
......
......@@ -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();
}
......
......@@ -12,7 +12,7 @@ public interface FileService {
* @param fileName
* @return
*/
String uploadFile(byte[] file, String fileName);
String uploadFile(byte[] file, String fileName) throws Exception;
/**
* 下载文件
......
......@@ -22,23 +22,17 @@ public class FileServiceImpl implements FileService {
@Override
public synchronized String uploadFile(byte[] file, String fileName) {
try {
Thread.sleep(70);
public synchronized String uploadFile(byte[] file, String fileName) throws Exception {
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];
} 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 {
}
}
......@@ -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=8084
server.port=8092
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment