Commit 47fefcec by 李辅翼

v10

parent bc49983b
......@@ -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")
......
......@@ -6,4 +6,6 @@ public interface Vehicle {
void getIncrementVehPic();
void insertVehPicByCar(String hphm, String hpzl);
void getVehPicStage(String start, String end);
}
......@@ -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 synchronized static 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());
......
......@@ -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 | SQLException e) {
e.printStackTrace();
}
......
......@@ -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();
}
......
......@@ -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(200);
Thread.sleep(70);
//将文件上装到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());
}
}
}
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