Commit 3db85554 by 李辅翼

v6

parent 17b690fa
...@@ -94,5 +94,16 @@ public class PicController { ...@@ -94,5 +94,16 @@ public class PicController {
vioPic.getIncrementVioPic(DateUtil.formatDate(DateUtil.getPastDate(new Date(),-past)),date); vioPic.getIncrementVioPic(DateUtil.formatDate(DateUtil.getPastDate(new Date(),-past)),date);
} }
@GetMapping("/testIncVioPic")
public void testIncVioPic(@RequestParam("start") String start,@RequestParam("end") String end) {
String date = DateUtil.getDate();
vioPic.getIncrementVioPic(start,end);
}
@GetMapping("/delAllVioPic")
public void delAllVioPic(@RequestParam("past") int past){
vioPic.delAllVioPic();
}
} }
...@@ -2,4 +2,6 @@ package com.hikcreate.drv_photo_pic; ...@@ -2,4 +2,6 @@ package com.hikcreate.drv_photo_pic;
public interface VioPic { public interface VioPic {
void getIncrementVioPic(String startDay,String endDay); void getIncrementVioPic(String startDay,String endDay);
void delAllVioPic();
} }
package com.hikcreate.drv_photo_pic.impl; package com.hikcreate.drv_photo_pic.impl;
import com.github.tobato.fastdfs.exception.FdfsServerException;
import com.hikcreate.drv_photo_pic.VioPic; import com.hikcreate.drv_photo_pic.VioPic;
import com.hikcreate.entity.PicByte; import com.hikcreate.entity.PicByte;
import com.hikcreate.service.fdfs.service.FileService; import com.hikcreate.service.fdfs.service.FileService;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*; import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
...@@ -67,6 +69,7 @@ public class VioPicImpl implements VioPic { ...@@ -67,6 +69,7 @@ public class VioPicImpl implements VioPic {
private static String hphm; private static String hphm;
private static String hpzl; private static String hpzl;
private static String wfsj; private static String wfsj;
private static String wfxw;
private static String url1; private static String url1;
private static String url2; private static String url2;
private static String url3; private static String url3;
...@@ -102,18 +105,19 @@ public class VioPicImpl implements VioPic { ...@@ -102,18 +105,19 @@ public class VioPicImpl implements VioPic {
headers = new HttpHeaders(); headers = new HttpHeaders();
method = HttpMethod.POST; method = HttpMethod.POST;
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
long count=0L; long count = 0L;
loop1: loop1:
while (resultSet.next()) { while (resultSet.next()) {
count=count+1; count = count + 1;
logger.info("数据库查询出东西了------------"+count); logger.info("数据库查询出东西了------------" + count);
hphm = resultSet.getString("hphm"); hphm = resultSet.getString("hphm");
hpzl = resultSet.getString("hpzl"); hpzl = resultSet.getString("hpzl");
wfsj = resultSet.getString("wfsj"); wfsj = resultSet.getString("wfsj");
wfxw = resultSet.getString("wfxw");
url1 = resultSet.getString("url1"); url1 = resultSet.getString("url1");
url2 = resultSet.getString("url2"); url2 = resultSet.getString("url2");
url3 = resultSet.getString("url3"); url3 = resultSet.getString("url3");
rowkey = hphm + "#" + hpzl + "#" + wfsj; rowkey = hphm + "#" + hpzl + "#" + wfsj+"#"+wfxw;
Get get = new Get(rowkey.getBytes()); Get get = new Get(rowkey.getBytes());
put = new Put(rowkey.getBytes()); put = new Put(rowkey.getBytes());
get.addColumn(Bytes.toBytes("useful"), Bytes.toBytes("ftpUrl1")); get.addColumn(Bytes.toBytes("useful"), Bytes.toBytes("ftpUrl1"));
...@@ -250,6 +254,42 @@ public class VioPicImpl implements VioPic { ...@@ -250,6 +254,42 @@ public class VioPicImpl implements VioPic {
} }
} }
/**
* 删除所有图片
*/
@Override
public void delAllVioPic() {
hbaseConf = HBaseConfiguration.create();
hbaseConf.set("hbase.zookeeper.property.clientPort", hbaseAddress);
hbaseConf.set("hbase.zookeeper.quorum", hbaseZkQuorum);
try {
hbaseConn = ConnectionFactory.createConnection(hbaseConf);
vioTableName = TableName.valueOf(vioTableStr);
vioTable = hbaseConn.getTable(vioTableName);
Scan scan = new Scan();
scan.addColumn("useful".getBytes(),"fastDfsUrl1".getBytes());
scan.addColumn("useful".getBytes(),"fastDfsUrl2".getBytes());
scan.addColumn("useful".getBytes(),"fastDfsUrl3".getBytes());
scan.addColumn("useful".getBytes(),"fastDfsUrl4".getBytes());
scan.addColumn("useful".getBytes(),"fastDfsUrl5".getBytes());
scan.addColumn("useful".getBytes(),"fastDfsUrl6".getBytes());
ResultScanner scanner = vioTable.getScanner(scan);
for(Result result:scanner){
for(KeyValue value:result.raw()){
try {
fileService.deleteFile(new String(value.getValue()));
}catch (Exception e){
logger.info(e.toString());
}
logger.info("删除图片+++++++"+new String(value.getValue())+"----------"+new String(value.getQualifier()));
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
private static void putData(String hbaseFtpCol, String hbaseFastCol, String url, String ftpUrl, FileService fileService) { private static void putData(String hbaseFtpCol, String hbaseFastCol, String url, String ftpUrl, FileService fileService) {
//存fastDfs //存fastDfs
......
...@@ -34,7 +34,7 @@ public class PicSchedule { ...@@ -34,7 +34,7 @@ public class PicSchedule {
/** /**
* 每天早上10点同步违法增量数据 * 每天早上10点同步违法增量数据
*/ */
@Scheduled(cron = "0 0 10 * * *") @Scheduled(cron = "0 0 11 * * *")
public void getIncrementVioPic(){ public void getIncrementVioPic(){
String date = DateUtil.getDate(); String date = DateUtil.getDate();
vioPic.getIncrementVioPic(DateUtil.formatDate(DateUtil.getPastDate(new Date(),-pastDay)),date); vioPic.getIncrementVioPic(DateUtil.formatDate(DateUtil.getPastDate(new Date(),-pastDay)),date);
......
...@@ -62,4 +62,13 @@ public class FastDFSClient { ...@@ -62,4 +62,13 @@ public class FastDFSClient {
String path = fileUrl.substring(idx + 1); String path = fileUrl.substring(idx + 1);
return storageClient.downloadFile(group, path, new DownloadByteArray()); return storageClient.downloadFile(group, path, new DownloadByteArray());
} }
/**
* 删除数据
*
* @param path
* @throws IOException
*/
public void deleteFile(String path) {
storageClient.deleteFile(path);
}
} }
...@@ -22,4 +22,7 @@ public interface FileService { ...@@ -22,4 +22,7 @@ public interface FileService {
*/ */
byte[] downloadFile(String path); byte[] downloadFile(String path);
void deleteFile(String path);
} }
...@@ -45,4 +45,9 @@ public class FileServiceImpl implements FileService { ...@@ -45,4 +45,9 @@ public class FileServiceImpl implements FileService {
public byte[] downloadFile(String path) { public byte[] downloadFile(String path) {
return fastDFSClient.download(path); return fastDFSClient.download(path);
} }
@Override
public void deleteFile(String path) {
fastDFSClient.deleteFile(path);
}
} }
...@@ -30,7 +30,7 @@ hbase.driverlicense.table=drv:drivinglicense ...@@ -30,7 +30,7 @@ hbase.driverlicense.table=drv:drivinglicense
hbase.vio.table=vio:vio_violation hbase.vio.table=vio:vio_violation
#hive----sql #hive----sql
increment.vio.pic.sql=SELECT a.ccarnumber hphm,a.clicensetype hpzl,b.wfsj wfsj,a.cpic1path url1,a.cpic2path url2,a.cpic3path url3 from (SELECT * from kakou.vio_violation_pic_his_ods WHERE substr(export_time,0,10)<=? and substr(export_time,0,10)>?) a INNER JOIN (SELECT * from default.vio_surveil_all WHERE clbj='0') b WHERE a.ccarnumber=b.hphm and a.clicensetype=b.hpzl and substr(a.dillegaldate,0,16)=substr(b.wfsj,0,16) increment.vio.pic.sql=SELECT a.ccarnumber hphm,a.clicensetype hpzl,b.wfsj wfsj,b.wfxw wfxw,a.cpic1path url1,a.cpic2path url2,a.cpic3path url3 from (SELECT * from kakou.vio_violation_pic_his_ods WHERE substr(export_time,0,10)<=? and substr(export_time,0,10)>?) a INNER JOIN (SELECT * from default.vio_surveil_all WHERE clbj='0') b WHERE a.ccarnumber=b.hphm and a.clicensetype=b.hpzl and substr(a.dillegaldate,0,16)=substr(b.wfsj,0,16) and a.coffense=b.wfxw
pastDay=10 pastDay=10
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