|
@@ -0,0 +1,220 @@
|
|
|
|
+//package com.huimv.video.dhicc.timmer;
|
|
|
|
+//
|
|
|
|
+//import com.alibaba.fastjson.JSON;
|
|
|
|
+//import com.dahuatech.hutool.http.Method;
|
|
|
|
+//import com.dahuatech.icc.exception.ClientException;
|
|
|
|
+//import com.dahuatech.icc.oauth.http.DefaultClient;
|
|
|
|
+//import com.dahuatech.icc.oauth.http.IClient;
|
|
|
|
+//import com.dahuatech.icc.oauth.model.v202010.GeneralRequest;
|
|
|
|
+//import com.dahuatech.icc.oauth.model.v202010.GeneralResponse;
|
|
|
|
+//import com.huimv.video.dhicc.entity.IccEventRecord;
|
|
|
|
+//import com.huimv.video.dhicc.icc.CommonConstant;
|
|
|
|
+//import com.huimv.video.dhicc.mapper.SysTelecomMapper;
|
|
|
|
+//import com.huimv.video.dhicc.service.IIccEventRecordService;
|
|
|
|
+//import com.huimv.video.dhicc.service.ISysTelecomEventService;
|
|
|
|
+//import net.sf.json.JSONObject;
|
|
|
|
+//import org.apache.commons.io.FileUtils;
|
|
|
|
+//import org.apache.http.HttpResponse;
|
|
|
|
+//import org.apache.http.client.methods.HttpGet;
|
|
|
|
+//import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
|
|
|
+//import org.apache.http.conn.ssl.SSLContextBuilder;
|
|
|
|
+//import org.apache.http.conn.ssl.TrustStrategy;
|
|
|
|
+//import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
|
+//import org.apache.http.impl.client.HttpClients;
|
|
|
|
+//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+//import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
+//import org.springframework.stereotype.Component;
|
|
|
|
+//import javax.net.ssl.SSLContext;
|
|
|
|
+//import javax.servlet.http.HttpServletResponse;
|
|
|
|
+//import java.io.File;
|
|
|
|
+//import java.io.IOException;
|
|
|
|
+//import java.io.InputStream;
|
|
|
|
+//import java.io.OutputStream;
|
|
|
|
+//import java.security.cert.CertificateException;
|
|
|
|
+//import java.security.cert.X509Certificate;
|
|
|
|
+//import java.text.SimpleDateFormat;
|
|
|
|
+//import java.util.*;
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//import static com.huimv.video.dhicc.icc.CommonConstant.IPAndPort;
|
|
|
|
+//
|
|
|
|
+///**
|
|
|
|
+// * Icc事件同步到这里
|
|
|
|
+// */
|
|
|
|
+//@Component
|
|
|
|
+//public class GetRecordFromIcc {
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+// //访问时间的接口 将数据存到本地 但是这张表需要存 人员信息图片 车辆通过图片 事件图片三种基本的信息
|
|
|
|
+// //需要明白的是 事件来自于这里 但是 这里只存储时间在两天之内的数据 实际上来说这里可以存储的数据需要合理设计
|
|
|
|
+// //前端访问的接口还是不能变 我们不对齐做任何的改变 只是通过传入的开始结束时间来判断是从本地拿数据 还是从牧场拿数据
|
|
|
|
+// //首先拿三天的数据过来再说
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+// @Autowired
|
|
|
|
+// private SysTelecomMapper sysTelecomMapper;
|
|
|
|
+//
|
|
|
|
+// @Autowired
|
|
|
|
+// private ISysTelecomEventService sysTelecomEventService;
|
|
|
|
+//
|
|
|
|
+// @Autowired
|
|
|
|
+// private IIccEventRecordService iccEventRecordService ;
|
|
|
|
+//
|
|
|
|
+// //每小时执行一次
|
|
|
|
+// // @Scheduled(cron = " 0 */59 * * * ? ")
|
|
|
|
+// @Scheduled(cron = " 0/5 * * * * ? ")
|
|
|
|
+// private void getDataFromLocalIcc() throws ClientException, IOException {
|
|
|
|
+// //这个地方拿出EVENT 数组 进行数据的判断 后面for循环一旦存在就抛弃
|
|
|
|
+//
|
|
|
|
+// //返回所有的事件 的集合 包括死猪和洗消和大门 --分页参数
|
|
|
|
+// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+// Calendar c = Calendar.getInstance();
|
|
|
|
+// Date date = new Date();
|
|
|
|
+// c.setTime(date);
|
|
|
|
+// c.set(Calendar.HOUR, 0);
|
|
|
|
+// c.set(Calendar.MINUTE, 0);
|
|
|
|
+// c.set(Calendar.SECOND, 0);
|
|
|
|
+// Date A = c.getTime();
|
|
|
|
+// String formatA = format.format(A);
|
|
|
|
+// c.set(Calendar.HOUR, +24);
|
|
|
|
+// Date d = c.getTime();
|
|
|
|
+// String formatD = format.format(d);
|
|
|
|
+// Map<String, Object> params = new HashMap<>();
|
|
|
|
+// params.put("alarmStartDateString",formatA);
|
|
|
|
+// params.put("alarmEndDateString",formatD);
|
|
|
|
+// params.put("pageNum",1);
|
|
|
|
+// params.put("pageSize",10000);//足够大 包含时间段内所有的事件
|
|
|
|
+// params.put("alarmType",303);
|
|
|
|
+// params.put("dbType",0);
|
|
|
|
+// params.put("deviceCategory",1);
|
|
|
|
+// String[] nodeCodeList= CommonConstant.AllChannle;
|
|
|
|
+// params.put("nodeCodeList",nodeCodeList);
|
|
|
|
+// //String URL = "/evo-apigw/evo-event/1.2.0/alarm-record/page"; //获取事件URL post请求
|
|
|
|
+// String URL = "/evo-apigw/evo-event/1.2.0/alarm-record/page"; //获取事件URL post请求
|
|
|
|
+// IClient iClient = new DefaultClient();
|
|
|
|
+// String NewUrl = URL;
|
|
|
|
+// //这种已经在配置文件里面安排了账号ip以及密码
|
|
|
|
+// GeneralRequest generalRequest = new GeneralRequest(NewUrl, Method.POST);
|
|
|
|
+// System.out.println(NewUrl);
|
|
|
|
+// generalRequest.header("Content-Type", " application/json");
|
|
|
|
+// generalRequest.body(JSON.toJSONString(params));
|
|
|
|
+// GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
|
|
|
|
+// JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
|
|
|
|
+// JSONObject jsonObject01 = (JSONObject) jsonObject.get("data");
|
|
|
|
+// List<Map> ss1= (List<Map>) jsonObject01.get("pageData");
|
|
|
|
+//// JSONArray jsonArray = JSONArray.fromObject(pageData);
|
|
|
|
+//// List<IccEventRecord> ss = JSONArray.toList(jsonArray) ;//处理 for循环 需要有对应
|
|
|
|
+// System.out.println();
|
|
|
|
+// /* for (IccEventRecord s : ss) {
|
|
|
|
+// System.out.println(s.getAlarmPicture());
|
|
|
|
+// }
|
|
|
|
+//*/
|
|
|
|
+// for (Object o : ss1) {
|
|
|
|
+// System.out.println(o);
|
|
|
|
+// IccEventRecord iccEventRecord = new IccEventRecord();
|
|
|
|
+// iccEventRecord.setEventId )
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+// iccEventRecordService.save(iccEventRecord);
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+// public static void getAndSave(String access_token , String alarmPicture ,String fileName , HttpServletResponse response) throws IOException {
|
|
|
|
+// HttpResponse httpResponse = null;
|
|
|
|
+// try {
|
|
|
|
+// CloseableHttpClient buildSSLCloseableHttpClient = buildSSLCloseableHttpClient();
|
|
|
|
+// System.setProperty("jsse.enableSNIExtension", "false");
|
|
|
|
+// HttpGet httpGet = new HttpGet(
|
|
|
|
+// //事件的图片
|
|
|
|
+// IPAndPort+"/evo-pic/"+alarmPicture+"?token="+access_token+"&oss_addr=172.16.3.223:8925" );
|
|
|
|
+//
|
|
|
|
+// httpResponse = buildSSLCloseableHttpClient.execute(httpGet);
|
|
|
|
+// } catch (Exception e) {
|
|
|
|
+// // TODO Auto-generated catch block
|
|
|
|
+// e.printStackTrace();
|
|
|
|
+// }
|
|
|
|
+// System.out.println("返回图片");
|
|
|
|
+// response.setContentLength(28539);
|
|
|
|
+// response.setHeader("Content-Type"," image/jpeg");
|
|
|
|
+// response.setHeader("Accept-Ranges","bytes");
|
|
|
|
+// //流在这里
|
|
|
|
+// //可以 图片存储成功//只要当前目录存在 就可以实现存储图片
|
|
|
|
+// File outFile = new File( "D:\\test\\12.jpg");
|
|
|
|
+// //拷贝文件到输出文件对象
|
|
|
|
+// FileUtils.copyInputStreamToFile( httpResponse.getEntity().getContent(), outFile);
|
|
|
|
+// InputStream content = httpResponse.getEntity().getContent();
|
|
|
|
+//
|
|
|
|
+// OutputStream out = null;
|
|
|
|
+// try {
|
|
|
|
+// out = response.getOutputStream();
|
|
|
|
+// int len = 0;
|
|
|
|
+// byte[] b = new byte[1024];
|
|
|
|
+// while ((len = content.read(b)) != -1) {
|
|
|
|
+// out.write(b, 0, len);
|
|
|
|
+// }
|
|
|
|
+// out.flush();
|
|
|
|
+// } catch (IOException e) {
|
|
|
|
+// e.printStackTrace();
|
|
|
|
+// } finally {
|
|
|
|
+// try {
|
|
|
|
+// if (out != null) {
|
|
|
|
+// out.close();
|
|
|
|
+// }
|
|
|
|
+// } catch (Exception e) {
|
|
|
|
+// e.printStackTrace();
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+// private static CloseableHttpClient buildSSLCloseableHttpClient()
|
|
|
|
+// throws Exception {
|
|
|
|
+// SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null,
|
|
|
|
+// new TrustStrategy() {
|
|
|
|
+// // 信任所有
|
|
|
|
+// public boolean isTrusted(X509Certificate[] chain,
|
|
|
|
+// String authType) throws CertificateException {
|
|
|
|
+// return true;
|
|
|
|
+// }
|
|
|
|
+// }).build();
|
|
|
|
+// SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
|
|
|
|
+// sslContext, new String[] { "TLSv1.2" }, null,
|
|
|
|
+// SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
|
|
|
+// return HttpClients.custom().setSSLSocketFactory(sslsf).build();
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|