Commit 0e2e5b41 by 李辅翼

v14

parent 4a56114c
...@@ -59,13 +59,6 @@ ...@@ -59,13 +59,6 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!--<dependency>-->
<!--<groupId>oracle</groupId>-->
<!--<artifactId>ojdbc6</artifactId>-->
<!--<version>11.2.0.3</version>-->
<!--<scope>system</scope>-->
<!--<systemPath>${project.basedir}/src/main/resources/lib/ojdbc6-11.2.0.3.jar</systemPath>-->
<!--</dependency>-->
<dependency> <dependency>
<groupId>com.oracle</groupId> <groupId>com.oracle</groupId>
...@@ -74,29 +67,6 @@ ...@@ -74,29 +67,6 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>1.1.0-cdh5.15.1</version>
<exclusions>
<exclusion>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-annotation_1.0_spec</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jaspic_1.0_spec</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
...@@ -109,19 +79,6 @@ ...@@ -109,19 +79,6 @@
<dependency> <dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
<exclusions>
<exclusion>
<artifactId>log4j-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId> <artifactId>fastjson</artifactId>
<version>1.2.51</version> <version>1.2.51</version>
......
...@@ -3,22 +3,18 @@ package com.hikcreate.controller; ...@@ -3,22 +3,18 @@ package com.hikcreate.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hikcreate.drv_photo_pic.DrvPhoto; import com.hikcreate.drv_photo_pic.DrvPhoto;
import com.hikcreate.drv_photo_pic.Vehicle; import com.hikcreate.drv_photo_pic.Vehicle;
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 com.hikcreate.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import javax.imageio.stream.FileImageOutputStream; import javax.imageio.stream.FileImageOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.springframework.http.*; import org.springframework.http.*;
...@@ -33,8 +29,6 @@ import org.springframework.http.*; ...@@ -33,8 +29,6 @@ import org.springframework.http.*;
@RequestMapping("/pic") @RequestMapping("/pic")
public class PicController { public class PicController {
@Autowired
private VioPic vioPic;
@Autowired @Autowired
private DrvPhoto drvPhoto; private DrvPhoto drvPhoto;
...@@ -114,10 +108,7 @@ public class PicController { ...@@ -114,10 +108,7 @@ public class PicController {
} }
@GetMapping("/testIncVioPic")
public void testIncVioPic(@RequestParam("start") String start,@RequestParam("end") String end) {
vioPic.getIncrementVioPic(start,end);
}
...@@ -197,18 +188,6 @@ public class PicController { ...@@ -197,18 +188,6 @@ public class PicController {
} }
} }
@GetMapping("/testIncVio")
public void testFastDfs(@RequestParam("past") int past) {
String date = DateUtil.getDate();
vioPic.getIncrementVioPic(DateUtil.formatDate(DateUtil.getPastDate(new Date(),-past)),date);
}
@GetMapping("/delAllVioPic")
public void delAllVioPic(@RequestParam("past") int past){
vioPic.delAllVioPic();
}
} }
package com.hikcreate.drv_photo_pic;
public interface VioPic {
void getIncrementVioPic(String startDay,String endDay);
void delAllVioPic();
}
...@@ -6,11 +6,9 @@ import com.hikcreate.drv_photo_pic.DrvPhoto; ...@@ -6,11 +6,9 @@ import com.hikcreate.drv_photo_pic.DrvPhoto;
import com.hikcreate.entity.PicResult; import com.hikcreate.entity.PicResult;
import com.hikcreate.service.fdfs.service.FileService; import com.hikcreate.service.fdfs.service.FileService;
import com.hikcreate.utils.DateUtil; import com.hikcreate.utils.DateUtil;
import com.hikcreate.utils.redis.RedisClientUtil;
import oracle.sql.BLOB; import oracle.sql.BLOB;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
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.slf4j.Logger; import org.slf4j.Logger;
...@@ -33,8 +31,6 @@ import java.util.zip.CRC32; ...@@ -33,8 +31,6 @@ import java.util.zip.CRC32;
@Service("drvPhotoImpl") @Service("drvPhotoImpl")
public class DrvPhotoImpl implements DrvPhoto { public class DrvPhotoImpl implements DrvPhoto {
@Autowired
private RedisClientUtil redisClientUtil;
private static Logger logger = LoggerFactory.getLogger(DrvPhotoImpl.class); private static Logger logger = LoggerFactory.getLogger(DrvPhotoImpl.class);
@Value("${url}") @Value("${url}")
...@@ -89,7 +85,7 @@ public class DrvPhotoImpl implements DrvPhoto { ...@@ -89,7 +85,7 @@ public class DrvPhotoImpl implements DrvPhoto {
try { try {
hbaseConn = ConnectionFactory.createConnection(hbaseConf); hbaseConn = ConnectionFactory.createConnection(hbaseConf);
endTime = time; endTime = time;
startTime=SqlHelp.getStartTime("select min(GXSJ) mtime from GYJG.DRV_PHOTO",url,username,password); startTime = SqlHelp.getStartTime("select min(GXSJ) mtime from GYJG.DRV_PHOTO", url, username, password);
//循环获取图片 //循环获取图片
String sql; String sql;
String lastTime; String lastTime;
...@@ -214,23 +210,23 @@ public class DrvPhotoImpl implements DrvPhoto { ...@@ -214,23 +210,23 @@ public class DrvPhotoImpl implements DrvPhoto {
//判断图片是否已经存入fastdfs //判断图片是否已经存入fastdfs
colValue = new String[2]; colValue = new String[2];
String rowkey = sfzmhm; String rowkey = sfzmhm;
PicResult picResult=SqlHelp.getFlag(rowkey,driverPhototable,colValue,gxsj); PicResult picResult = SqlHelp.getFlag(rowkey, driverPhototable, colValue, gxsj);
if (picResult.getI()!=0) { if (picResult.getI() != 0) {
if(picResult.getI()==2){ if (picResult.getI() == 2) {
fileService.deleteFile(picResult.getUrl()); fileService.deleteFile(picResult.getUrl());
} }
Put put = new Put(rowkey.getBytes()); Put put = new Put(rowkey.getBytes());
put.addColumn("info".getBytes(), "sfzmhm".getBytes(), sfzmhm.getBytes()); put.addColumn("info".getBytes(), "sfzmhm".getBytes(), sfzmhm.getBytes());
byte[] bytes1=SqlHelp.blobToByteZp(zp); byte[] bytes1 = SqlHelp.blobToByteZp(zp);
String picUrl = fileService.uploadFile(bytes1, sfzmhm + ".jpeg"); String picUrl = fileService.uploadFile(bytes1, sfzmhm + ".jpeg");
put.addColumn("info".getBytes(), "sfzmhm".getBytes(), (sfzmhm==null?"null":sfzmhm).getBytes()); put.addColumn("info".getBytes(), "sfzmhm".getBytes(), (sfzmhm == null ? "null" : sfzmhm).getBytes());
put.addColumn("info".getBytes(), "picUrl".getBytes(), picUrl.getBytes()); put.addColumn("info".getBytes(), "picUrl".getBytes(), picUrl.getBytes());
put.addColumn("info".getBytes(), "gxsj".getBytes(), (gxsj==null?"null":gxsj).getBytes()); put.addColumn("info".getBytes(), "gxsj".getBytes(), (gxsj == null ? "null" : gxsj).getBytes());
put.addColumn("info".getBytes(), "xzqh".getBytes(), (xzqh==null?"null":xzqh).getBytes()); put.addColumn("info".getBytes(), "xzqh".getBytes(), (xzqh == null ? "null" : xzqh).getBytes());
put.addColumn("info".getBytes(), "flag".getBytes(), (flag==null?"null":flag).getBytes()); put.addColumn("info".getBytes(), "flag".getBytes(), (flag == null ? "null" : flag).getBytes());
put.addColumn("info".getBytes(), "xh".getBytes(), (xh==null?"null":xh).getBytes()); put.addColumn("info".getBytes(), "xh".getBytes(), (xh == null ? "null" : xh).getBytes());
put.addColumn("info".getBytes(), "rksj".getBytes(), (rksj==null?"null":rksj).getBytes()); put.addColumn("info".getBytes(), "rksj".getBytes(), (rksj == null ? "null" : rksj).getBytes());
put.addColumn("info".getBytes(), "fzjg".getBytes(), (fzjg==null?"null":fzjg).getBytes()); put.addColumn("info".getBytes(), "fzjg".getBytes(), (fzjg == null ? "null" : fzjg).getBytes());
driverPhototable.put(put); driverPhototable.put(put);
} }
} }
...@@ -246,7 +242,7 @@ public class DrvPhotoImpl implements DrvPhoto { ...@@ -246,7 +242,7 @@ public class DrvPhotoImpl implements DrvPhoto {
} }
} }
private void closeTable(){ private void closeTable() {
if (driverPhototable != null) { if (driverPhototable != null) {
try { try {
driverPhototable.close(); driverPhototable.close();
...@@ -275,7 +271,6 @@ public class DrvPhotoImpl implements DrvPhoto { ...@@ -275,7 +271,6 @@ public class DrvPhotoImpl implements DrvPhoto {
} }
public static void main(String[] args) { public static void main(String[] args) {
// String url="http://193.5.103.124:8083/5251522281554187435986/2019/06/07/11/zhbrt193313019kk/11495774795494205.jpg?fid=156008-358BE80027-2E8B5C6-B190C";
String url = "ftp://vion6:vion6@52.1.113.218:21/193.2.117.66/kk/2019-07-06/18/2019070618541777800022598.jpg"; String url = "ftp://vion6:vion6@52.1.113.218:21/193.2.117.66/kk/2019-07-06/18/2019070618541777800022598.jpg";
String[] arr = url.split("/"); String[] arr = url.split("/");
System.out.println(arr[arr.length - 1].split("jpg")[0] + "jpg"); System.out.println(arr[arr.length - 1].split("jpg")[0] + "jpg");
......
...@@ -229,7 +229,6 @@ public class VehicleImpl implements Vehicle { ...@@ -229,7 +229,6 @@ public class VehicleImpl implements Vehicle {
} }
private String uploadFile(byte[] file, String fileName) { private String uploadFile(byte[] file, String fileName) {
String url; String url;
try { try {
......
...@@ -2,7 +2,6 @@ package com.hikcreate.schedul; ...@@ -2,7 +2,6 @@ package com.hikcreate.schedul;
import com.hikcreate.drv_photo_pic.DrvPhoto; import com.hikcreate.drv_photo_pic.DrvPhoto;
import com.hikcreate.drv_photo_pic.Vehicle; import com.hikcreate.drv_photo_pic.Vehicle;
import com.hikcreate.drv_photo_pic.VioPic;
import com.hikcreate.utils.DateUtil; import com.hikcreate.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -17,8 +16,6 @@ public class PicSchedule { ...@@ -17,8 +16,6 @@ public class PicSchedule {
@Autowired @Autowired
private DrvPhoto drvPhoto; private DrvPhoto drvPhoto;
@Autowired @Autowired
private VioPic vioPic;
@Autowired
private Vehicle vehicle; private Vehicle vehicle;
@Value("${pastDay}") @Value("${pastDay}")
...@@ -35,14 +32,6 @@ public class PicSchedule { ...@@ -35,14 +32,6 @@ public class PicSchedule {
} }
/**
* 每天早上10点同步违法增量数据
*/
// @Scheduled(cron = "0 0 11 * * *")
public void getIncrementVioPic(){
String date = DateUtil.getDate();
vioPic.getIncrementVioPic(DateUtil.formatDate(DateUtil.getPastDate(new Date(),-pastDay)),date);
}
/** /**
* 每天早上9点同步机动车的增量数据 * 每天早上9点同步机动车的增量数据
......
...@@ -30,7 +30,7 @@ public class FileServiceImpl implements FileService { ...@@ -30,7 +30,7 @@ public class FileServiceImpl implements FileService {
if (!StringUtils.hasText(path)) { if (!StringUtils.hasText(path)) {
logger.error("Upload Img Error"); logger.error("Upload Img Error");
} }
logger.info("Upload Img Success. path {}", ("/group" + path.split("group")[1])); // logger.info("Upload Img Success. path {}", ("/group" + path.split("group")[1]));
return "/group" + path.split("group")[1]; return "/group" + path.split("group")[1];
} }
...@@ -43,10 +43,11 @@ public class FileServiceImpl implements FileService { ...@@ -43,10 +43,11 @@ public class FileServiceImpl implements FileService {
@Override @Override
public void deleteFile(String path) { public void deleteFile(String path) {
try { try {
logger.info("删除图片:" + path); // logger.info("删除图片:" + path);
fastDFSClient.deleteFile(path); fastDFSClient.deleteFile(path);
} catch (Exception e) { } catch (Exception e) {
deleteFile(path); // e.printStackTrace();
logger.error(e.toString());
} }
} }
......
package com.hikcreate.utils.redis;
import org.springframework.util.StringUtils;
import redis.clients.jedis.JedisCluster;
/**
* Copyright (C)
* All rights reserved
* <p>
* 项目名称 : RTComputation
* 项目描述:
* <p>
* com.zcreator.bigdata.rtc.common.redis
* <p>
* created by guangzhong.wgz
* date time 2018/11/22
**/
public class RedisBuilder {
/**
* @param hosts
* @return
*/
public static synchronized RedisClient getRedisClient(String hosts) {
if (StringUtils.isEmpty(hosts)) {
throw new RuntimeException("hosts is empty");
}
JedisCluster jedisCluster = RedisUtils.getClusterClient(hosts);
return new RedisClient(jedisCluster);
}
}
package com.hikcreate.utils.redis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* @auther: lifuyi
* @date: 2019/1/31 10:53
* @description:
*/
@Component
public class RedisClientUtil {
@Value("${redis.server}")
private static String redisServer;
@Autowired
private static RedisClient redisClient;
public static RedisClient getRedisClient() {
if (redisClient == null) {
synchronized (RedisClientUtil.class) {
redisClient = RedisBuilder.getRedisClient(redisServer);
}
}
return redisClient;
}
}
package com.hikcreate.utils.redis;
import org.springframework.util.StringUtils;
import redis.clients.jedis.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
public class RedisUtils {
// 非切片连接池
private static JedisPool jedisPool;
// 非切片连接池
private static JedisSentinelPool jedisSentinelPool;
// 切片连接池
private static ShardedJedisPool shardedJedisPool;
private static JedisPoolConfig config;
private static JedisCluster jedisCluster;
static {
config = new JedisPoolConfig();
config.setMaxTotal(20);
config.setMaxIdle(5);
config.setMaxWaitMillis(1000l);
config.setTestOnBorrow(false);
config.setJmxEnabled(true);
}
public static Jedis getJedisSentinelPool() {
if (jedisSentinelPool == null) {
synchronized (RedisUtils.class) {
if (jedisSentinelPool == null) {
// JedisSentinelPool 初始化
String masterName = "cdh6";
//sentinel地址集合
Set<String> set = new HashSet<>();
set.add("10.1.80.4:26379");
set.add("10.1.80.5:26379");
set.add("10.1.80.7:26379");
jedisSentinelPool = new JedisSentinelPool(masterName, set, config);
}
}
}
return jedisSentinelPool.getResource();
}
public static Jedis getJedis() {
if (jedisPool == null) {
synchronized (RedisUtils.class) {
Set<HostAndPort> jedisClusterNodes = new HashSet<>();
jedisClusterNodes.add(new HostAndPort("10.1.80.8", 6379));
JedisCluster jc = new JedisCluster(jedisClusterNodes);
}
}
return jedisPool.getResource();
}
public static ShardedJedis getShardedJedis() {
//初始化非切片池
List<JedisShardInfo> shards = new ArrayList<>();
shards.add(new JedisShardInfo("cd1", 6379, "master"));
shards.add(new JedisShardInfo("cd2", 6379, "master"));
shards.add(new JedisShardInfo("cd3", 6379, "master"));
shards.add(new JedisShardInfo("cd4", 6379, "master"));
shards.add(new JedisShardInfo("cd5", 6379, "master"));
shards.add(new JedisShardInfo("cd6", 6379, "master"));
shards.add(new JedisShardInfo("cd7", 6379, "master"));
shards.add(new JedisShardInfo("cd8", 6379, "master"));
shardedJedisPool = new ShardedJedisPool(config, shards);
ShardedJedis shardedJedis = shardedJedisPool.getResource();
return shardedJedis;
}
public static JedisCluster getClusterClient(String hosts) {
if (jedisCluster == null) {
synchronized (RedisUtils.class) {
if (jedisCluster == null) {
if (StringUtils.isEmpty(hosts)) {
throw new RuntimeException("hosts is empty");
}
Set<HostAndPort> jedisClusterNodes = new HashSet<>();
String[] hostStr = hosts.split(",");
Stream.of(hostStr).forEach(host -> {
String args[] = host.split(":");
if (args.length != 2) {
throw new RuntimeException("host format error");
}
jedisClusterNodes.add(new HostAndPort(args[0], Integer.parseInt(args[1])));
});
jedisCluster = new JedisCluster(jedisClusterNodes);
}
}
}
return jedisCluster;
}
public static void getOne() {
Jedis jedis = new Jedis("cdh1");
jedis.set("foo", "bar");
String value = jedis.get("foo");
}
}
\ No newline at end of file
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