Commit 1edfd17c authored by wangjinjing's avatar wangjinjing

定时推送取消,图片压缩

parent 11b8e2a7
...@@ -167,6 +167,26 @@ ...@@ -167,6 +167,26 @@
<artifactId>poi</artifactId> <artifactId>poi</artifactId>
<version>3.8-beta5</version> <version>3.8-beta5</version>
</dependency> </dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>2.9.6</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>net.coobird</groupId>
<artifactId>thumbnailator</artifactId>
<version>0.4.8</version>
</dependency>
</dependencies> </dependencies>
<repositories> <repositories>
......
package im.zhaojun.common.config;
import im.zhaojun.system.model.ResultObj;
import im.zhaojun.system.model.Traffalarmrecord;
import im.zhaojun.system.model.VideoDeviceTraffic;
import im.zhaojun.system.service.EventWriteService;
import im.zhaojun.system.service.TraffFlowService;
import im.zhaojun.system.service.TraffalarmrecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Calendar;
import java.util.List;
@Slf4j
//@Component
//@Configuration
//@EnableScheduling
public class ScheduleTaskConfig {
@Autowired
TraffFlowService traffFlowService;
@Autowired
TraffalarmrecordService traffalarmrecordService;
@Autowired
EventWriteService eventWriteService;
/***
* 每2分钟执行一次查询事件推送给广达
*/
// @Scheduled(cron = "0 */2 * * * ?")
private void sendToguangdaEvent() {
//查询所有未推送的数据
List<Traffalarmrecord> resultlist = traffalarmrecordService.getTraffalarmrecordBystatus();
for (Traffalarmrecord record : resultlist) {
try {
ResultObj obj = eventWriteService.updateAndAutoSendEvent(record);
log.error( "2 min send to guangda result"+obj.getMsg()+obj.getStatus());
} catch (Exception ex) {
log.error(record.getRecordid() + " send to guangda fail" + ex.toString());
}
}
}
/***
* 每5分钟执行一次查询车流推送给广达
*/
@Scheduled(cron = "0 */5 * * * ?")
private void sendToguangdaDevice() {
log.info("fiveflow sendto guangda" );
//查询所有未推送的数据
List<VideoDeviceTraffic> trafflist = traffFlowService.getfiveFlowByVideoid(null);
if(trafflist.size()>0) {
log.info("fiveflow" + trafflist.get(0).toString());
traffFlowService.sendMessages(trafflist);
}
}
// @Scheduled(cron = "0 30/5 6-19 * * ?")//每隔5分钟统计当天目前为止的数据
// private void statistoday() {
// //判断是否为空表
// //执行查询存在更新,不存在新增
// log.info("每隔5分钟");
// Integer result= traffFlowService.insertOrUpdatevehicleTodaystatistic();
// log.info("today"+result);
//
// }
}
...@@ -37,7 +37,7 @@ public class WebSocketConfig { ...@@ -37,7 +37,7 @@ public class WebSocketConfig {
alarmMapper.insert(alarm); alarmMapper.insert(alarm);
} }
} catch (Exception ex) { } catch (Exception ex) {
log.info("websocket error"+ex.toString());
} }
......
package im.zhaojun.common.util;
import org.joda.time.DateTime;
import org.joda.time.Days;
import org.joda.time.Months;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import java.util.Date;
/**
* ʱ���ʽת���� 2019.10.23
* @author cp
*/
public class DateUtil {
private static final DateTimeFormatter YMD_HMS = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
private static final DateTimeFormatter YMDHMS = DateTimeFormat.forPattern("yyyyMMddHHmmss");
private static final DateTimeFormatter YMD = DateTimeFormat.forPattern("yyyyMMdd");
private static final DateTimeFormatter Y_M_D = DateTimeFormat.forPattern("yyyy-MM-dd");
public static String formatCurrDate(){
return formatCurrDateByType(YMD_HMS);
}
public static String formatCurrDateNoSign(){
return formatCurrDateByType(YMDHMS);
}
public static String formatCurrDateYMD(){
return formatCurrDateByType(Y_M_D);
}
public static String formatCurrDayNoSign(){
return formatCurrDateByType(YMD);
}
public static Date parseDate(String date){
return DateTime.parse(date,YMD_HMS).toDate();
}
public static Date parseDateNoSign(String date){
return DateTime.parse(date,YMDHMS).toDate();
}
public static String getYesterday(int day){
Date date= addDay(new Date(),day);
return new DateTime(date).toString(YMD_HMS);
}
public static String getlastMonth(int month){
Date date= addMonth(new Date(),month);
return new DateTime(date).toString(YMD_HMS);
}
public static String formatDate(Date date){
return new DateTime(date).toString(YMD_HMS);
}
public static String formatDateToNoSign(Date date){
return new DateTime(date).toString(YMDHMS);
}
public static String formatDateToNoSign(String date){
return DateTime.parse(date,YMD_HMS).toString(YMDHMS);
}
private static String formatCurrDateByType(DateTimeFormatter dateTimeFormatter){
return DateTime.now().toString(dateTimeFormatter);
}
public static Date addMinutes(Date date, int minutes) {
return new DateTime(date).plusMinutes(minutes).toDate();
}
public static Date addDay(Date date, int day) {
if(day == 0){
return date;
}
return new DateTime(date).plusDays(day).toDate();
}
public static Date addMonth(Date date, int month) {
if(month == 0){
return date;
}
return new DateTime(date).plusMonths(month).toDate();
}
/**
* ����ʱ����������
* @param date1 ʱ��1
* @param date2 ʱ��2
* @return ����
*/
public static int diffMonth(Date date1, Date date2) {
if (date1 == null || date2 == null) {
return 0;
}
DateTime dt1 = new DateTime(date1);
DateTime dt2 = new DateTime(date2);
return Months.monthsBetween(dt1, dt2).getMonths();
}
/**
* ����ʱ����������
* @param date1 ʱ��1
* @param date2 ʱ��2
* @return ����
*/
public static int diffDay(Date date1, Date date2) {
if (date1 == null || date2 == null) {
return 0;
}
DateTime dt1 = new DateTime(date1);
DateTime dt2 = new DateTime(date2);
return Days.daysBetween(dt1, dt2).getDays();
}
}
...@@ -245,6 +245,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { ...@@ -245,6 +245,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
cal.add(Calendar.DAY_OF_MONTH, day); cal.add(Calendar.DAY_OF_MONTH, day);
return sdf.format(cal.getTime()); return sdf.format(cal.getTime());
} }
public static String getlastDayTimeY_M_D(Date newDate,Integer day) { public static String getlastDayTimeY_M_D(Date newDate,Integer day) {
SimpleDateFormat sdf = null; SimpleDateFormat sdf = null;
sdf = threadLocal.get(); sdf = threadLocal.get();
...@@ -265,4 +266,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { ...@@ -265,4 +266,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
&& (c1.get(Calendar.MONTH) == c2.get(Calendar.MONTH)) && (c1.get(Calendar.MONTH) == c2.get(Calendar.MONTH))
&& (c1.get(Calendar.DAY_OF_MONTH) == c2.get(Calendar.DAY_OF_MONTH)); && (c1.get(Calendar.DAY_OF_MONTH) == c2.get(Calendar.DAY_OF_MONTH));
} }
} }
\ No newline at end of file
package im.zhaojun.common.util;
import im.zhaojun.system.model.Ftp;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;
import org.apache.poi.util.IOUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import sun.misc.BASE64Decoder;
import javax.annotation.PostConstruct;
import java.io.*;
import java.net.MalformedURLException;
import java.net.SocketException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@SuppressWarnings("all")
@Component
public class FTPUtil {
@Value("${ftp.host}")
private String ftpHost ;
private List<Ftp> ftps = new ArrayList<Ftp>();
@PostConstruct
private void initHostMap(){
if(ftpHost==null){
log.error("ftp�洢��δ���ã���������");
log.error("ftp�洢��δ���ã���������");
return;
}
}
public static void downLoadFile(String path, OutputStream toClient) {
BufferedInputStream bis = null;
InputStream is = null;
try {
if (path.toUpperCase().indexOf("FTP") != -1) {
String tempUrl = path;
tempUrl = tempUrl.replaceAll("\\\\", "/");
URL url = new URL(tempUrl);
is = url.openStream();
bis = new BufferedInputStream(is);
IOUtils.copy(bis, toClient);
return;
}
} catch (Exception e) {
log.error("FTP����ͼƬ����", e);
} finally {
IOUtils.closeQuietly(toClient);
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(bis);
}
}
public static byte[] getFtpPicBytes(String path) {
URL url = null;
try {
url = new URL(path);
} catch (MalformedURLException e) {
log.error("FTP URL error"+e.toString());
return null;
}
byte[] buffer = null;
try {
InputStream is = url.openStream();
if(null!=is) {
ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
byte[] b = new byte[1000];
int n;
while ((n = is.read(b)) != -1) {
bos.write(b, 0, n);
}
buffer = bos.toByteArray();
}
}catch (Exception e) {
log.error("FTPerror", e);
}
return buffer;
}
public static boolean uploadFile(Ftp ftpUrl, String path, String filename, String inputImg) {
boolean flag = true;
FTPClient ftpClient = null;
ByteArrayInputStream input = null;
try {
if (inputImg == null) {
return false;
}
//base64����
BASE64Decoder decoder = new BASE64Decoder();
byte[] b_img = decoder.decodeBuffer(inputImg);
input = new ByteArrayInputStream(b_img);
ftpClient = connectServer(ftpUrl);
//new ByteArrayInputStream
if (ftpClient.isConnected()) {
changeWorkingDirectory(ftpClient, path);
flag = ftpClient.storeFile(filename, input);
if (flag) {
// log.info("FTP�ϴ��ļ��ɹ���");
} else {
flag = false;
log.info("FTP�ϴ��ļ�ʧ�ܣ�");
}
}
} catch (Exception e) {
flag = false;
log.error("FTP�ļ��ϴ�ʧ�ܣ�", e.toString());
} finally {
IOUtils.closeQuietly(input);
closeConnect(ftpClient);
}
return flag;
}
public static boolean uploadFile(Ftp ftpUrl, String path, String filename, InputStream input){
boolean flag = true;
FTPClient ftpClient = null;
try {
ftpClient = connectServer(ftpUrl);
if (ftpClient.isConnected()) {
changeWorkingDirectory(ftpClient, path);
flag = ftpClient.storeFile(filename, input);
if (flag) {
// log.info("FTP upload success��");
} else {
log.info("FTP upload fail��");
}
} else {
flag = false;
// log.info("FTP server refused connection ��");
}
} catch (IOException e) {
flag = false;
log.error("FTP upload fail��", e);
} catch (Exception e) {
flag = false;
log.error("FTP upload fail��", e);
} finally {
IOUtils.closeQuietly(input);
closeConnect(ftpClient);
}
return flag;
}
/*
* �õ������ļ��е�FTP��������ַ
*/
public static String getFtpUrl(Ftp ftpUrl) {
StringBuffer buffer = new StringBuffer();
buffer.append("ftp://");
String ftpUsername = ftpUrl.getFtpUsername();
if (ftpUsername != null && ftpUsername.trim().length() > 0) {
buffer.append(ftpUsername);
buffer.append(":");
buffer.append(ftpUrl.getFtpPassword());
buffer.append("@");
}
buffer.append(ftpUrl.getFtpIp());
if (ftpUrl.getFtpPort() != null) {
buffer.append(":");
buffer.append(ftpUrl.getFtpPort());
}
buffer.append("/");
return buffer.toString();
}
/**
* @param ftpUrl
* @return
* @throws Exception
* @description ɾ��ftp�ϵ��ļ�
* @author sunw
*/
public static boolean deleteFileFromFtpUrl(String ftpUrl) throws Exception {
boolean flag = false;
if (null == ftpUrl || StringUtils.isBlank(ftpUrl)) {
throw new Exception("ftpUrl����");
}
Map<String, String> result = getFtpInfoMapByFullPath(ftpUrl);
String ftpUser = result.get("ftpUser");
String ftpPassword = result.get("ftpPassword");
String ftpIp = result.get("ftpIp");
String ftpPort = result.get("ftpPort");
String fileName = result.get("fileName");
String path = result.get("path");
Ftp ftp = FTPUtil.getFtpUrlObj(ftpIp, ftpPort, ftpUser, ftpPassword);
FTPClient ftpClient = connectServer(ftp);
if (null == ftpClient) {
throw new Exception("ftp��¼ʧ�� ");
} else {
String fullPath = (null == path || "".equals(path.trim())) ? fileName : (path + "/" + fileName);
try {
flag = ftpClient.deleteFile(fullPath);
} catch (Exception e) {
e.printStackTrace();
}
}
return flag;
}
/**
* @param ftpUrlStr
* @return
* @throws Exception
* @author sunw ͨ��ͼƬ·��
* ���ftpuser,ftppassword,ftpip,ftpport,��fpt�ϵ��ļ�·��,�ļ�realname
*/
private static Map<String, String> getFtpInfoMapByFullPath(String ftpUrlStr) throws Exception {
if (null == ftpUrlStr || "".equals(ftpUrlStr.trim())) {
throw new Exception("ftpstr����");
}
ftpUrlStr = ftpUrlStr.replaceAll("\\\\", "/");
ftpUrlStr = changeUrlCharater(ftpUrlStr);
String array[] = ftpUrlStr.split("/");
String[] ftpUserPasswordAndIpPort = array[2].split("@");
String[] ftpUserAndPassword = ftpUserPasswordAndIpPort[0].split(":");
String[] ftpIpAndPort = ftpUserPasswordAndIpPort[1].split(":");
String ftpUser = ftpUserAndPassword[0];
String ftpPassword = ftpUserAndPassword[1];
String ftpIp = ftpIpAndPort[0];
String ftpPort = ftpIpAndPort.length > 1 ? ftpIpAndPort[1] : "";
String fileName = array[array.length - 1];// ������
Map<String, String> resultMap = new HashMap<String, String>();
resultMap.put("ftpUser", ftpUser);
resultMap.put("ftpPassword", ftpPassword);
resultMap.put("ftpIp", ftpIp);
resultMap.put("ftpPort", ftpPort);
resultMap.put("fileName", fileName);
String path = "";
for (int i = 3; i < array.length - 1; i++) {
if (i != array.length - 2) {
path += array[i] + "/";
} else {
path += array[i];
}
}
resultMap.put("path", path);
return resultMap;
}
public static void main(String[] args) {
String temp = "ftp://vpftp:zn7070@10.10.10.207:21/2018/0101.jpg";
try {
boolean flag = deleteFileFromFtpUrl(temp);
System.out.println(flag);
} catch (Exception e) {
System.out.println("ɾ���ļ�ʧ��");
}
// String [] strSplit = temp.split("/");
// for(int i = 0 ; i < strSplit.length ; i++) {
// System.out.println(i+" = " + strSplit[i]);
// }
}
public static String changeUrlCharater(String tempUrl) {
tempUrl = tempUrl.replaceAll("%", "%25").replaceAll("#", "%23").replaceAll("\\+", "%2B").replaceAll("&", "%26");
tempUrl = tempUrl.replaceAll("=", "%3D").replaceAll("\\?", "%3F");
return tempUrl;
}
/**
* ���ӵ�������
*/
private static FTPClient connectServer(Ftp ftpUrl) {
FTPClient ftpClient = null;
try {
ftpClient = new FTPClient();
ftpClient.setControlEncoding("utf-8");
if (ftpUrl.getFtpPort() != null) {
ftpClient.setDefaultPort(ftpUrl.getFtpPort());
}
ftpClient.connect(ftpUrl.getFtpIp());
ftpClient.login(ftpUrl.getFtpUsername(), ftpUrl.getFtpPassword());
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
ftpClient.enterLocalPassiveMode();
// ftpClient.setFileTransferMode(FTP.STREAM_TRANSFER_MODE);
ftpClient.setBufferSize(10240);
int reply = ftpClient.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
ftpClient.disconnect();
System.err.println("FTP server refused connection.");
log.info("FTP ����ܾ����ӣ�");
}
} catch (SocketException e) {
log.error("��¼ftp������ " + ftpUrl.getFtpIp() + " ʧ��,���ӳ�ʱ��", e);
} catch (IOException e) {
log.error("��¼ftp������ " + ftpUrl.getFtpIp() + " ʧ�ܣ�FTP�������޷��򿪣�", e);
}
return ftpClient;
}
/**
* �ر�����
*/
private static void closeConnect(FTPClient ftpClient) {
try {
if (ftpClient != null) {
if (ftpClient.isConnected() == true) {
ftpClient.logout();
}
ftpClient.disconnect();
}
} catch (Exception e) {
log.error("�ر�ftp����ʧ��", e);
}
}
/**
* ���뵽��������ij��Ŀ¼��
*
* @param directory
*/
private static void changeWorkingDirectory(FTPClient ftpClient, String directory) throws Exception {
try {
if(directory.contains("\\")){
directory = directory.replaceAll("\\\\","/");
}
String splitType = "/";
ftpClient.changeWorkingDirectory(splitType);
String[] subPathArray = directory.split(splitType);
for (String subPath : subPathArray) {
ftpClient.makeDirectory(subPath);
ftpClient.changeWorkingDirectory(subPath);
}
} catch (IOException ioe) {
log.error("�ı�ftp����·��ʧ��", ioe);
}
}
/**
* ת��[ISO-8859-1 -> GBK] ��ͬ��ƽ̨��Ҫ��ͬ��ת��
*
* @param obj
* @return ""
*/
private static String iso8859togbk(Object obj) {
try {
if (obj == null) {
return "";
}
return new String(obj.toString().getBytes("iso-8859-1"), "GBK");
} catch (Exception e) {
return "";
}
}
public static Ftp getFtpUrlObj(String ftpIp, String ftpPort, String ftpUser, String ftpPassword) {
Ftp ftpUrl = new Ftp();
ftpUrl.setFtpIp(ftpIp);
if (ftpPort != null) {
ftpUrl.setFtpPort(Integer.parseInt(ftpPort));
}
ftpUrl.setFtpUsername(ftpUser);
ftpUrl.setFtpPassword(ftpPassword);
return ftpUrl;
}
}
package im.zhaojun.common.util;
import cn.hutool.core.codec.Base64Encoder;
import net.coobird.thumbnailator.Thumbnails;
import sun.misc.BASE64Decoder;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class ResizeImage {
public static String resizeImageTo40K( byte[] bytes) {
InputStream stream =new ByteArrayInputStream(bytes);
BufferedImage src=null;
try {
src= ImageIO.read(stream);
if(null!=src) {
BufferedImage output = Thumbnails.of(src).size(src.getWidth() / 3, src.getHeight() / 3).asBufferedImage();
String base64 = imageToBase64(output);
if (base64.length() - base64.length() / 8 * 2 > 15000) {
output = Thumbnails.of(output).scale(1 / (base64.length() / 15000)).asBufferedImage();
base64 = imageToBase64(output);
}
return base64;
}
} catch (Exception e) {
return imageToBase64(src);
}
return imageToBase64(src);
}
public static String imageToBase64(BufferedImage bufferedImage) {
if(null==bufferedImage) return null;
Base64Encoder encoder = new Base64Encoder();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
ImageIO.write(bufferedImage, "jpg", baos);
} catch (IOException e) {
}
return new String(encoder.encode((baos.toByteArray())).replaceAll("\r\n",""));
}
private static InputStream BaseToInputStream(String base64string) {
ByteArrayInputStream stream = null;
try {
BASE64Decoder decoder = new BASE64Decoder();
byte[] bytes1 = decoder.decodeBuffer(base64string);
stream = new ByteArrayInputStream(bytes1);
} catch (Exception e) {
// TODO: handle exception
}
return stream;
}
}
package im.zhaojun.common.util;
import lombok.Getter;
/**
* ͨ���ַ���ö����
* @author cp
*/
@Getter
public enum StringEnum {
/**
* �ַ�������
*/
ONE("1");
private String value;
StringEnum(String value){
this.value =value;
}
}
package im.zhaojun.common.util;
import com.alibaba.fastjson.JSONObject;
import im.zhaojun.system.model.DeviceWriteParam;
import im.zhaojun.system.model.SbtdspsrParam;
import im.zhaojun.system.model.Traffdevicewriteresult;
import org.apache.commons.lang3.StringUtils;
/**
* @author chenl
* @version 1.0
* @date 2020/3/15 22:13
*
* deviceID;
* deviceType;
* deviceName;
* regionID;
* deviceStatus;
* deviceSupplier;
* dataType;
* locationType;
* locationX;
* locationY;
* locationEndX;
* locationEndY;
*/
public class TransHelper {
public static DeviceWriteParam transDevice(SbtdspsrParam sbtdspsr, int dataType){
DeviceWriteParam param = new DeviceWriteParam();
Long sbtdbh = sbtdspsr.getTdbh();
param.setDeviceID(sbtdspsr.getSbbh() + ( sbtdbh >= 10 ? sbtdbh : "0" + sbtdbh));
param.setDeviceName(sbtdspsr.getTdmc());
param.setRegionID(sbtdspsr.getXzbh());
param.setDeviceStatus(1);
param.setDeviceSupplier(sbtdspsr.getSbcsName());
param.setDataType(dataType);
JSONObject jsonObject = JSONObject.parseObject(sbtdspsr.getDeviceconfig());
if(jsonObject.get("RoadType")!=null){
param.setRoadType(Integer.parseInt(jsonObject.get("RoadType").toString()));
}
if(jsonObject.get("DeviceType")!=null && StringUtils.isNotBlank(jsonObject.get("DeviceType").toString())){
param.setDeviceType(jsonObject.get("DeviceType").toString());
}
if(jsonObject.get("DeviceDirection")!=null){
param.setDeviceDirection(Integer.parseInt(jsonObject.get("DeviceDirection").toString()));
}
if(jsonObject.get("StartNumK")!=null){
param.setStartNumK(Integer.parseInt(jsonObject.get("StartNumK").toString()));
}
if(jsonObject.get("StartNumM")!=null){
param.setStartNumM(Integer.parseInt(jsonObject.get("StartNumM").toString()));
}
if(jsonObject.get("RoadNum")!=null && StringUtils.isNotBlank(jsonObject.get("RoadNum").toString())){
param.setRoadNum(jsonObject.get("RoadNum").toString());
}
if(jsonObject.get("LocationDesc")!=null && StringUtils.isNotBlank(jsonObject.get("LocationDesc").toString())){
param.setLocationDesc(jsonObject.get("LocationDesc").toString());
}
if(jsonObject.get("Toll")!=null){
param.setToll(Integer.parseInt(jsonObject.get("Toll").toString()));
}
if(jsonObject.get("LocationID")!=null && StringUtils.isNotBlank(jsonObject.get("LocationID").toString())){
param.setLocationID(jsonObject.get("LocationID").toString());
}
if(jsonObject.get("ServiceArea")!=null){
param.setServiceArea(Integer.parseInt(jsonObject.get("ServiceArea").toString()));
}
//�����ѵ����շ�վ������λ������
if(jsonObject.get("RampToll")!=null){
param.setRampToll(Integer.parseInt(jsonObject.get("RampToll").toString()));
}
if(jsonObject.get("RampServiceArea")!=null){
param.setRampServiceArea(Integer.parseInt(jsonObject.get("RampServiceArea").toString()));
}
if(jsonObject.get("RampHubRoad")!=null && StringUtils.isNotBlank(jsonObject.get("RampHubRoad").toString())){
param.setRampHubRoad(jsonObject.get("RampHubRoad").toString());
}
if(jsonObject.get("RampHubDirection")!=null){
param.setRampHubDirection(Integer.parseInt(jsonObject.get("RampHubDirection").toString()));
}
// param.setLocationType();
// param.setLocationX();
// param.setLocationY();
// param.setLocationEndX();
// param.setLocationEndY();
return param;
}
public static Traffdevicewriteresult transDeviceWriteResult(SbtdspsrParam sbtdspsr) {
Traffdevicewriteresult param = new Traffdevicewriteresult();
param.setSbbh(sbtdspsr.getSbbh());
param.setTdbh(sbtdspsr.getTdbh());
return param;
}
public static Traffdevicewriteresult transDeviceWriteResult(SbtdspsrParam sbtdspsr, Long pushstatus, String pushdesc) {
Traffdevicewriteresult param = new Traffdevicewriteresult();
param.setSbbh(sbtdspsr.getSbbh());
param.setTdbh(sbtdspsr.getTdbh());
param.setPushstatus(pushstatus);
param.setPushcount(1L);
param.setXzbh(sbtdspsr.getXzbh());
param.setPushdesc(pushdesc);
return param;
}
public static Traffdevicewriteresult transDeviceWriteResult(SbtdspsrParam sbtdspsr, Long pushstatus, String pushdesc, Long pushcount) {
Traffdevicewriteresult param = new Traffdevicewriteresult();
param.setSbbh(sbtdspsr.getSbbh());
param.setTdbh(sbtdspsr.getTdbh());
param.setPushstatus(pushstatus);
param.setPushdesc(pushdesc);
param.setPushdesc(pushdesc);
param.setXzbh(sbtdspsr.getXzbh());
param.setPushcount(pushcount);
return param;
}
}
...@@ -4,24 +4,14 @@ import com.github.pagehelper.PageInfo; ...@@ -4,24 +4,14 @@ import com.github.pagehelper.PageInfo;
import im.zhaojun.common.util.PageResultBean; import im.zhaojun.common.util.PageResultBean;
import im.zhaojun.common.util.ResultBean; import im.zhaojun.common.util.ResultBean;
import im.zhaojun.system.model.*; import im.zhaojun.system.model.*;
import im.zhaojun.system.service.EventWriteService;
import im.zhaojun.system.service.TraffdevicewriteresultService; import im.zhaojun.system.service.TraffdevicewriteresultService;
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.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
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 java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
@RestController @RestController
@RequestMapping("/traffresult") @RequestMapping("/traffresult")
...@@ -35,12 +25,16 @@ public class TraffdevicewriteresultController { ...@@ -35,12 +25,16 @@ public class TraffdevicewriteresultController {
@Value("${devicesend.url}") @Value("${devicesend.url}")
String devicesendurl; String devicesendurl;
@Value("${devicesend.timeout}") @Value("${devicesend.timeout}")
private Integer timeout; private Integer timeout;
@Autowired @Autowired
private RestTemplate restTemplate; private RestTemplate restTemplate;
@Autowired
private EventWriteService eventWriteService;
/** /**
* 查询推送成功分页 * 查询推送成功分页
*/ */
...@@ -64,38 +58,17 @@ public class TraffdevicewriteresultController { ...@@ -64,38 +58,17 @@ public class TraffdevicewriteresultController {
/** /**
* 推送数据到推送平台 */ * 推送数据到推送平台 */
@PostMapping("/sendEvents") @PostMapping("/sendEvents")
public List<ResultObj> sendEvents(@RequestParam("recordid") String recordid){ public List<ResultObj> sendEvents(@RequestBody List<Traffalarmrecord> recordidlist){
List<ResultObj> resultObj =new ArrayList<>();
MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<String, Object>(); return eventWriteService.sendAllMessage(recordidlist);
paramMap.add("recordid", recordid);
try {
resultObj =(List<ResultObj> ) CompletableFuture.supplyAsync(() -> restTemplate.postForObject(eventsendurl, paramMap, List.class)).get(timeout, TimeUnit.SECONDS);
}catch (TimeoutException e) {
resultObj.add(ResultObj.error(ResponseEnum.E_1008.getCode(), ResponseEnum.E_1008.getMsg()));
} catch (Exception e) {
resultObj.add(ResultObj.error(ResponseEnum.E_9999.getCode(), e.toString()));
}
return resultObj;
} }
/** /**
* 推送数据到推送平台 */ * 推送数据到推送平台 */
@PostMapping("/sendDevices") @PostMapping("/sendDevices")
public List<ResultObj> sendDevices(@RequestParam("xhs") String xhs){ public List<ResultObj> sendDevices(@RequestBody List<SbtdspsrParams> sbtdspsrlist){
List<ResultObj> resultObj =new ArrayList<>(); return traffdevicewriteresultService.sendDevices(sbtdspsrlist);
MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<String, Object>();
paramMap.add("xhs", xhs);
try {
resultObj =(List<ResultObj> ) CompletableFuture.supplyAsync(() -> restTemplate.postForObject(devicesendurl, paramMap, List.class)).get(timeout, TimeUnit.SECONDS);
}catch (TimeoutException e) {
resultObj.add(ResultObj.error(ResponseEnum.E_1008.getCode(), ResponseEnum.E_1008.getMsg()));
} catch (Exception e) {
resultObj.add(ResultObj.error(ResponseEnum.E_9999.getCode(), e.toString()));
}
return resultObj;
} }
...@@ -144,7 +117,4 @@ public class TraffdevicewriteresultController { ...@@ -144,7 +117,4 @@ public class TraffdevicewriteresultController {
return ResultBean.success(); return ResultBean.success();
} }
} }
\ No newline at end of file
package im.zhaojun.system.mapper;
import im.zhaojun.system.model.Sbtdspsr;
import im.zhaojun.system.model.SbtdspsrParam;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.additional.dialect.oracle.InsertListMapper;
import tk.mybatis.mapper.common.BaseMapper;
import tk.mybatis.mapper.common.ConditionMapper;
import java.util.List;
public interface SbtdspsrMapper extends BaseMapper<Sbtdspsr>, ConditionMapper<Sbtdspsr>, InsertListMapper<Sbtdspsr> {
String getMinUpdateTime();
String getMaxUpdateTime();
/**
* ��ȡ����ʱ���ڵ��豸��Ϣ
* @param startTime ��ʼʱ��
* @param endTime ����ʱ��
* @return �豸��Ϣlist
*/
List<Sbtdspsr> getSbtdspsrList(@Param("startTime") String startTime, @Param("endTime") String endTime);
List<Sbtdspsr> selectAllSbbhAndTdbh(@Param("xzbh") String xzbh);
List<Sbtdspsr> selectBySbbh(@Param("sbbh") String sbbh, @Param("tdbh") Integer tdbh);
List<SbtdspsrParam> selectDeviceWrite();
}
\ No newline at end of file
package im.zhaojun.system.mapper;
import im.zhaojun.system.model.Vehicle;
import im.zhaojun.system.model.Vehicles;
import im.zhaojun.system.model.VideoDeviceTraffic;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
@Mapper
public interface TraffFlowMapper {
int add(Vehicles excelModel);
int insertlist(Vehicle vehiclesdetail);
List<Map> selectFiveAndDayFlow(String videoid);
List<Map> selectFiveAndTypeDayFlow(String videoid);
List<VideoDeviceTraffic> getfiveFlowByVideoid(String videoid);
Integer statisVehiclesByDay();
Integer deleteBeforeTwoMonthVehiclesDetails();
Integer deleteVehiclesByDay();
Integer insertOrUpdatevehicleTodaystatistic();
String selectSbtddspsrRtspByVideoid(String videoid);
List<VideoDeviceTraffic> getTraffVicleBystatus();
}
...@@ -24,4 +24,27 @@ public interface TraffalarmrecordMapper extends BaseMapper<Traffalarmrecord>, Co ...@@ -24,4 +24,27 @@ public interface TraffalarmrecordMapper extends BaseMapper<Traffalarmrecord>, Co
@Param("userAccount") String userAccount, @Param("pushstatus") Integer pushstatus, @Param("userAccount") String userAccount, @Param("pushstatus") Integer pushstatus,
@Param("page") Integer page, @Param("rows") Integer rows); @Param("page") Integer page, @Param("rows") Integer rows);
int updateTraffAlarmRecordUrl(Traffalarmrecord record);
int updatePushEvent(Traffalarmrecord traffalarmrecord);
int inserTraffAlarmRecord(Traffalarmrecord traffalarmrecord);
int selectmax();
Integer statisTraffalarmrecordstatByDay();
Integer updateTraffAlarmRectificationType(Traffalarmrecord traffalarmrecord);
Integer selectExitsTraffAlarm(Traffalarmrecord traffalarmrecord);
Integer selectInChecktimeTraffAlarm(Traffalarmrecord traffalarmrecord);
Integer updateInworkRectifytimeTraffAlarm(Traffalarmrecord traffalarmrecord);
String seletManualStatus();
List<Traffalarmrecord> getTraffalarmrecordBystatus();
} }
\ No newline at end of file
package im.zhaojun.system.model;
import java.util.HashMap;
import java.util.Map;
/**
* @author chenl
* @version 1.0
* @date 2020/3/15 10:47
*/
public class CodeConst {
//�豸ע��
public static final Integer device_regist = 1;
//�豸����
public static final Integer device_update = 2;
//�豸�¼�
public static final Integer device_remove = 3;
//״̬����
public static final Integer device_report = 4;
private static Map<Integer, String> eventType = new HashMap<>();
private static Map<String, Integer> eventTypeQZ = new HashMap<>();
static {
eventType.put(1, "�쳣ͣ��");
eventType.put(2, "����/�ǻ���������");
eventType.put(3, "����/����");
eventType.put(4, "ӵ��");
eventType.put(5, "��ͨ�¼�(�¹ʷ���)");
eventType.put(6, "��������-��");
eventType.put(7, "��������-ѩ");
eventType.put(8, "�̻𱨾�");
eventType.put(9, "������");
eventType.put(10, "�ܼ��ȹ���");
eventType.put(11, "�쳣��ʻ");
eventType.put(12, "·���ϰ���");
eventType.put(13, "��·ʩ��");
eventType.put(14, "ӵ�½���");
eventType.put(15, "�����");
eventType.put(16, "�����¼�");
eventType.put(17, "��ͨ�¼�(�¹������³�)");
eventType.put(18, "�����¼�");
}
static {
eventTypeQZ.put("congestion", 4);// 'congestion', '��ͨӵ�¼��'
eventTypeQZ.put("not_congestion", 14);// 'not_congestion', 'ӵ�½���'
eventTypeQZ.put("illegal_parking", 1);// 'illegal_parking', '�����쳣ͣʻ���'
eventTypeQZ.put("wrong_direction", 3);// 'wrong_direction', '����/����'
eventTypeQZ.put("no_motor_ban", 2);// 'no_motor_ban', '����/�ǻ�����������'
eventTypeQZ.put("slow_deive", 11);// 'slow_deive', '�����쳣���м��'
eventTypeQZ.put("not_slow_deive", 15);// 'not_slow_deive', '�����'
eventTypeQZ.put("single_slow_drive", 11);// 'single_slow_drive', '���ٹ�·���������쳣���м��'
eventTypeQZ.put("accident", 5);// 'accident', '���ٹ�·��ͨ�¹ʼ��'
eventTypeQZ.put("roadworks", 13);// 'roadworks', '���ٹ�·��·ʩ�����'
eventTypeQZ.put("roadworks_out_of_line", 19);// 'roadworks_out_of_line', '���ٹ�·ʩ��Υ����'
eventTypeQZ.put("severe_weather", 6);// 'severe_weather', '������������ѩ�����'
eventTypeQZ.put("low_visibility", 10);// 'low_visibility', '��ͨ������'
eventTypeQZ.put("abandoned_object", 12);// 'abandoned_object', '·���ϰ�����'
eventTypeQZ.put("tunnel_fire", 8);// 'tunnel_fire', '���ٹ�·���������'
eventTypeQZ.put("tunnel_smoke", 9);// 'tunnel_smoke', '���ٹ�·���������'
eventTypeQZ.put("outside_fire", 8);// 'outside_fire', '��ͨ���������'
eventTypeQZ.put("outside_smoke", 9);// 'outside_smoke', '��ͨ����������'
}
public static String getEventType(int type) {
if (eventType.containsKey(type)) {
return eventType.get(type);
}
return null;
}
public static Integer getEventTypeQZ(String type) {
if (eventTypeQZ.containsKey(type)) {
Integer code = eventTypeQZ.get(type);
return code == null ? 18 : code;
}
return 18;
}
}
package im.zhaojun.system.model;
import lombok.Data;
@Data
public class DeviceWriteParam {
private String deviceID;
private String DeviceType;
private String deviceName;
private String regionID;
private Integer deviceStatus;
private String deviceSupplier;
private Integer dataType;
private Integer RoadType;
private String locationType;
private String locationX;
private String locationY;
private String locationEndX;
private String locationEndY;
private Integer DeviceDirection;
private Integer StartNumK;
private Integer StartNumM;
private String RoadNum;
private String LocationDesc;
private Integer toll;
private String locationID;
private Integer serviceArea;
private Integer rampToll;
private Integer rampServiceArea;
private String rampHubRoad;
private Integer rampHubDirection;
}
package im.zhaojun.system.model;
import lombok.Data;
/**
* @author chenl
* @version 1.0
* @date 2020/3/15 22:18
*/
public class EventWriteParam {
private String eventID;
private String eventSource;
private String eventType;
private String occurTime;
private Long regionID;
private String eventDeviceID;
private String eventSupplier;
private String locationType;
private String locationX;
private String locationY;
private String locationEndX;
private String locationEndY;
private String eventProof1;
private String eventProof2;
private String eventProof3;
private String eventProof4;
private String eventProof5;
private String eventvideo1;
@Override
public String toString() {
return "EventWriteParam{" +
"eventID='" + eventID + '\'' +
", eventSource='" + eventSource + '\'' +
", eventType='" + eventType + '\'' +
", occurTime='" + occurTime + '\'' +
", regionID=" + regionID +
", eventDeviceID='" + eventDeviceID + '\'' +
", eventSupplier='" + eventSupplier + '\'' +
", locationType='" + locationType + '\'' +
", locationX='" + locationX + '\'' +
", locationY='" + locationY + '\'' +
", locationEndX='" + locationEndX + '\'' +
", locationEndY='" + locationEndY + '\'' +
", eventProof1='" + eventProof1 + '\'' +
", eventProof2='" + eventProof2 + '\'' +
", eventProof3='" + eventProof3 + '\'' +
", eventProof4='" + eventProof4 + '\'' +
", eventProof5='" + eventProof5 + '\'' +
", eventvideo1='" + eventvideo1 + '\'' +
'}';
}
public String getEventID() {
return eventID;
}
public void setEventID(String eventID) {
this.eventID = eventID;
}
public String getEventSource() {
return eventSource;
}
public void setEventSource(String eventSource) {
this.eventSource = eventSource;
}
public String getEventType() {
return eventType;
}
public void setEventType(String eventType) {
this.eventType = eventType;
}
public String getOccurTime() {
return occurTime;
}
public void setOccurTime(String occurTime) {
this.occurTime = occurTime;
}
public Long getRegionID() {
return regionID;
}
public void setRegionID(Long regionID) {
this.regionID = regionID;
}
public String getEventDeviceID() {
return eventDeviceID;
}
public void setEventDeviceID(String eventDeviceID) {
this.eventDeviceID = eventDeviceID;
}
public String getEventSupplier() {
return eventSupplier;
}
public void setEventSupplier(String eventSupplier) {
this.eventSupplier = eventSupplier;
}
public String getLocationType() {
return locationType;
}
public void setLocationType(String locationType) {
this.locationType = locationType;
}
public String getLocationX() {
return locationX;
}
public void setLocationX(String locationX) {
this.locationX = locationX;
}
public String getLocationY() {
return locationY;
}
public void setLocationY(String locationY) {
this.locationY = locationY;
}
public String getLocationEndX() {
return locationEndX;
}
public void setLocationEndX(String locationEndX) {
this.locationEndX = locationEndX;
}
public String getLocationEndY() {
return locationEndY;
}
public void setLocationEndY(String locationEndY) {
this.locationEndY = locationEndY;
}
public String getEventProof1() {
return eventProof1;
}
public void setEventProof1(String eventProof1) {
this.eventProof1 = eventProof1;
}
public String getEventProof2() {
return eventProof2;
}
public void setEventProof2(String eventProof2) {
this.eventProof2 = eventProof2;
}
public String getEventProof3() {
return eventProof3;
}
public void setEventProof3(String eventProof3) {
this.eventProof3 = eventProof3;
}
public String getEventProof4() {
return eventProof4;
}
public void setEventProof4(String eventProof4) {
this.eventProof4 = eventProof4;
}
public String getEventProof5() {
return eventProof5;
}
public void setEventProof5(String eventProof5) {
this.eventProof5 = eventProof5;
}
public String getEventvideo1() {
return eventvideo1;
}
public void setEventvideo1(String eventvideo1) {
this.eventvideo1 = eventvideo1;
}
}
package im.zhaojun.system.model;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Ftp {
private String ftpIp;
private Integer ftpPort;
private String ftpUsername;
private String ftpPassword;
@Override
public String toString() {
return "Ftp{" +
"ftpIp='" + ftpIp + '\'' +
", ftpPort=" + ftpPort +
", ftpUsername='" + ftpUsername + '\'' +
", ftpPassword='" + ftpPassword + '\'' +
'}';
}
}
package im.zhaojun.system.model;
import lombok.Data;
import java.io.Serializable;
@Data
public class SbtdspsrParam extends Sbtdspsr implements Serializable {
private String sbcsName;
private String deviceconfig;
}
\ No newline at end of file
...@@ -45,6 +45,7 @@ public class SbtdspsrParams extends Sbtdspsr { ...@@ -45,6 +45,7 @@ public class SbtdspsrParams extends Sbtdspsr {
private String xztreename; private String xztreename;
private String deviceconfig; private String deviceconfig;
private String devicetype;
private Integer page; private Integer page;
private Integer limit; private Integer limit;
......
...@@ -5,8 +5,6 @@ import lombok.Setter; ...@@ -5,8 +5,6 @@ import lombok.Setter;
import java.util.Date; import java.util.Date;
@Getter
@Setter
public class SbtdspsrResult extends Sbtdspsr { public class SbtdspsrResult extends Sbtdspsr {
/** /**
* ����ʱ�� * ����ʱ��
...@@ -45,4 +43,69 @@ public class SbtdspsrResult extends Sbtdspsr { ...@@ -45,4 +43,69 @@ public class SbtdspsrResult extends Sbtdspsr {
private String xztreename; private String xztreename;
private String devicetype; private String devicetype;
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public Long getPushstatus() {
return pushstatus;
}
public void setPushstatus(Long pushstatus) {
this.pushstatus = pushstatus;
}
public String getPushdesc() {
return pushdesc;
}
public void setPushdesc(String pushdesc) {
this.pushdesc = pushdesc;
}
public Long getPushcount() {
return pushcount;
}
public void setPushcount(Long pushcount) {
this.pushcount = pushcount;
}
@Override
public String getXzbh() {
return xzbh;
}
@Override
public void setXzbh(String xzbh) {
this.xzbh = xzbh;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getXztreename() {
return xztreename;
}
public void setXztreename(String xztreename) {
this.xztreename = xztreename;
}
public String getDevicetype() {
return devicetype;
}
public void setDevicetype(String devicetype) {
this.devicetype = devicetype;
}
} }
package im.zhaojun.system.model;
import lombok.Data;
import java.util.Date;
@Data
public class Vehicle {
private String id;
private String type;
private String video_id;
private Date create_time;
private Long direction;
private Long classification_confidence;
private String ruleTag;
}
package im.zhaojun.system.model;
import java.util.Date;
public class VideoDeviceTraffic {
private String deviceId;
private String deviceName;
private Date dateTime;
private String ssjg;
private String speed;
private String flowRate;
private String fx;
private String fxmc;
private String sjly;
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public Date getDateTime() {
return dateTime;
}
public void setDateTime(Date dateTime) {
this.dateTime = dateTime;
}
public String getSsjg() {
return ssjg;
}
public void setSsjg(String ssjg) {
this.ssjg = ssjg;
}
public String getSpeed() {
return speed;
}
public void setSpeed(String speed) {
this.speed = speed;
}
public String getFlowRate() {
return flowRate;
}
public void setFlowRate(String flowRate) {
this.flowRate = flowRate;
}
public String getFx() {
return fx;
}
public void setFx(String fx) {
this.fx = fx;
}
public String getFxmc() {
return fxmc;
}
public void setFxmc(String fxmc) {
this.fxmc = fxmc;
}
public String getSjly() {
return sjly;
}
public void setSjly(String sjly) {
this.sjly = sjly;
}
@Override
public String toString() {
return "VideoDeviceTraffic{" +
"deviceId='" + deviceId + '\'' +
", deviceName='" + deviceName + '\'' +
", dateTime=" + dateTime +
", ssjg='" + ssjg + '\'' +
", speed='" + speed + '\'' +
", flowRate='" + flowRate + '\'' +
", fx='" + fx + '\'' +
", fxmc='" + fxmc + '\'' +
", sjly='" + sjly + '\'' +
'}';
}
}
package im.zhaojun.system.model;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class WriteResultObj {
private String data;
private String message;
private Integer status;
public WriteResultObj(){}
public WriteResultObj(Integer status, String message) {
this.message = message;
this.status = status;
}
@Override
public String toString() {
return "WriteResultObj{" +
"data=" + data +
", message='" + message + '\'' +
", status=" + status +
'}';
}
}
package im.zhaojun.system.service;
import im.zhaojun.common.util.*;
import im.zhaojun.system.mapper.SbtdspsrMapper;
import im.zhaojun.system.mapper.TraffalarmrecordMapper;
import im.zhaojun.system.model.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import sun.misc.BASE64Encoder;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
@Slf4j
@Service
public class EventWriteService {
private static final String EVENT_SOURCE = "2";
private static final String EVENT_SUPPLIER = "zksy";
private static final String CONTAINS_EXIST = "交通事件已存在";
@Autowired
private RestTemplate restTemplate;
@Value("${qingzhi.eventwrite.url}")
private String url;
@Value("${qingzhi.eventwrite.timeout}")
private Integer timeout;
@Autowired
private SbtdspsrMapper sbtdspsrMapper;
@Value("${qingzhi.redis.token}")
private String qztoken;
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Value("${alarmrecord.check.push.enable}")
private String checkPushEnable;
@Value("${alarmrecord.check.push.recordtype}")
private String recordtype;
@Autowired
private TraffalarmrecordMapper traffalarmrecordMapper;
private static CompletionService<ResultObj> completionService = new ExecutorCompletionService<ResultObj>(ThreadPoolUtil.getPool());
private ResultObj sendMessage(Traffalarmrecord traffalarmrecord) throws InterruptedException, ExecutionException, TimeoutException {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
HttpEntity<Traffalarmrecord> requestEntity = new HttpEntity<>(traffalarmrecord, headers);
return restTemplate.postForObject(url, requestEntity, ResultObj.class);
}
public List<ResultObj> sendAllMessage(List<Traffalarmrecord> traffalarmrecord) {
List<ResultObj> objlist = new ArrayList<>();
for (Traffalarmrecord record : traffalarmrecord) {
ResultObj obj = updateAndSendEvent(record);
obj.setData(record.getRecordid());
objlist.add(obj);
}
return objlist;
}
public ResultObj updateAndSendEvent(Traffalarmrecord traffalarmrecord) {
Long starttime = System.currentTimeMillis();
EventWriteParam eventWriteParam = new EventWriteParam();
eventWriteParam.setEventID(String.valueOf(traffalarmrecord.getRecordid()));
eventWriteParam.setEventSource(EVENT_SOURCE);
eventWriteParam.setRegionID(traffalarmrecord.getAreaid());
eventWriteParam.setEventType(traffalarmrecord.getRecordtype());
eventWriteParam.setOccurTime(DateUtil.formatDateToNoSign(traffalarmrecord.getRecordtime()));
//获得外部编号
List<Sbtdspsr> sbtdspsr = sbtdspsrMapper.selectBySbbh(traffalarmrecord.getFdid(),traffalarmrecord.getChannelid());
if (sbtdspsr.isEmpty()) {
return ResultObj.error(ResponseEnum.E_1002.getCode(), "设备为:" + traffalarmrecord.getFdid() + ",通道为:" + traffalarmrecord.getChannelid() + "未录入(备案)");
}
eventWriteParam.setEventDeviceID(sbtdspsr.get(0).getWbbh());
eventWriteParam.setEventSupplier(EVENT_SUPPLIER);
BASE64Encoder base64Encoder = new BASE64Encoder();
if(traffalarmrecord.getImg1path() != null ){
byte[] Img= FTPUtil.getFtpPicBytes(traffalarmrecord.getImg1path());
eventWriteParam.setEventProof1(ResizeImage.resizeImageTo40K(Img));
}
if(traffalarmrecord.getImg2path() != null ){
byte[] Img=FTPUtil.getFtpPicBytes(traffalarmrecord.getImg2path());
eventWriteParam.setEventProof2(ResizeImage.resizeImageTo40K(Img));
}
if(traffalarmrecord.getImg3path() != null ) {
byte[] Img = FTPUtil.getFtpPicBytes(traffalarmrecord.getImg3path());
eventWriteParam.setEventProof3(ResizeImage.resizeImageTo40K(Img));
}
if(traffalarmrecord.getImg4path() != null ) {
byte[] Img = FTPUtil.getFtpPicBytes(traffalarmrecord.getImg4path());
eventWriteParam.setEventProof4(ResizeImage.resizeImageTo40K(Img));
}
if(traffalarmrecord.getImg5path() != null ) {
byte[] Img = FTPUtil.getFtpPicBytes(traffalarmrecord.getImg5path());
eventWriteParam.setEventProof5(ResizeImage.resizeImageTo40K(Img));
}
// if(traffalarmrecord.getVideopath() != null ) {
// byte[] video = FTPUtil.getFtpPicBytes(traffalarmrecord.getVideopath());
// eventWriteParam.setEventvideo1(video != null ? base64Encoder.encode(video) : null);
// }
//String strBase64 = new BASE64Encoder().encode(FTPUtil.getFtpPicBytes(strings.get(i).get("PICPATH1").toString()));
WriteResultObj writeResultObj;
Long endtime = System.currentTimeMillis();
try {
writeResultObj = sendMessage(eventWriteParam);
} catch (TimeoutException e) {
log.error("事件推送eventwrite - sendEvent 请求超时:"+"事件="+traffalarmrecord.toString()+",错误原因=" + e.toString()+",请求总消耗时长"+(endtime-starttime)+"毫秒,"+writeInfoStr(eventWriteParam));
return ResultObj.error(ResponseEnum.E_1008.getCode(), ResponseEnum.E_1008.getMsg());
} catch (Exception e) {
log.error("事件推送eventwrite - sendEve" +
"nt 请求异常:"+"事件="+traffalarmrecord.toString()+",错误原因=" + e.toString()+",请求总消耗时长"+(endtime-starttime)+"毫秒,"+writeInfoStr(eventWriteParam));
return ResultObj.error(ResponseEnum.E_9999.getCode(), e.toString());
}
log.info("事件推送eventwrite - sendEvent 请求成功:"+"事件="+traffalarmrecord.toString()+",请求总消耗时长"+(endtime-starttime)+"毫秒,"+writeInfoStr(eventWriteParam));
dealResult(writeResultObj, traffalarmrecord);
return ResultObj.error(writeResultObj.getStatus(), writeResultObj.getMessage(), writeResultObj.getData());
}
private String writeInfoStr(EventWriteParam eventWriteParam){
return "图片1Base64长度:"+(eventWriteParam.getEventProof1()!=null?eventWriteParam.getEventProof1().length():0)+","
+"图片2Base64长度:"+(eventWriteParam.getEventProof2()!=null?eventWriteParam.getEventProof2().length():0)+","
+"图片3Base64长度:"+(eventWriteParam.getEventProof3()!=null?eventWriteParam.getEventProof3().length():0)+","
+"图片4Base64长度:"+(eventWriteParam.getEventProof4()!=null?eventWriteParam.getEventProof4().length():0)+","
+"图片5Base64长度:"+(eventWriteParam.getEventProof5()!=null?eventWriteParam.getEventProof5().length():0)+","
+"视频流Base64长度:"+(eventWriteParam.getEventvideo1()!=null?eventWriteParam.getEventvideo1().length():0)+"。";
}
private WriteResultObj sendMessage(EventWriteParam eventWriteParam) throws InterruptedException, ExecutionException, TimeoutException {
log.info("events+"+eventWriteParam.toString());
eventWriteParam.setEventType(String.valueOf(CodeConst.getEventTypeQZ(eventWriteParam.getEventType())));
List<EventWriteParam> list = new ArrayList<>();
list.add(eventWriteParam);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
String token = stringRedisTemplate.opsForValue().get(qztoken);
headers.add("token", token);
HttpEntity<List<EventWriteParam>> requestEntity = new HttpEntity<>(list, headers);
return restTemplate.postForObject(url, requestEntity, WriteResultObj.class);
}
private void dealResult(WriteResultObj writeResultObj, Traffalarmrecord traffalarmrecord) {
Traffalarmrecord condition = new Traffalarmrecord();
condition.setRecordid(traffalarmrecord.getRecordid());
String message = writeResultObj.getMessage();
boolean successFlag = writeResultObj.getStatus() == ResponseEnum.SUCCESS.getCode();
condition.setPushdesc(message);
log.info("更新推送转态setPushstatus(1)");
/* 失败但是因为数据已存在 */
if (!successFlag && StringUtils.isNotBlank(message) && message.contains(CONTAINS_EXIST)) {
condition.setPushstatus(1);
traffalarmrecordMapper.updatePushEvent(condition);
return;
}
/* 成功 */
if (successFlag) {
condition.setPushstatus(0);
traffalarmrecordMapper.updatePushEvent(condition);
return;
}
/* 其他失败 */
condition.setPushstatus(1);
traffalarmrecordMapper.updatePushEvent(condition);
}
public ResultObj updateAndSendEvents(List<Traffalarmrecord> traffalarmrecord) {
int error = 0;
int success = 0;
for (Traffalarmrecord ta : traffalarmrecord) {
ResultObj resultObj = updateAndSendEvent(ta);
String message = resultObj.getMsg();
boolean successFlag = resultObj.getStatus() == ResponseEnum.SUCCESS.getCode() || (StringUtils.isNotBlank(message) && message.contains(CONTAINS_EXIST));
/* 成功 */
if (successFlag) {
success++;
continue;
}
error++;
}
return ResultObj.error(ResponseEnum.SUCCESS.getCode(), "成功" + success + "条|失败" + error + "条");
}
public ResultObj updateAndAutoSendEvent(Traffalarmrecord traffalarmrecord) {
if (recordtype.equals("1")) {
//过滤掉工程类的
if(traffalarmrecord.getRecordtype().equalsIgnoreCase("roadworks") || traffalarmrecord.getRecordtype().equalsIgnoreCase("roadworks_out_of_line"))
return ResultObj.ok();
}
if (!StringEnum.ONE.getValue().equals(checkPushEnable)) {
/* 自动推送开关是否开启 */
return ResultObj.ok("记录recordid:" + traffalarmrecord.getRecordid() + ",推送开关[未启用],将不会推送");
}
return updateAndSendEvent(traffalarmrecord);
}
}
package im.zhaojun.system.service;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct;
import java.lang.reflect.Type;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Service
@Slf4j
public class QingZhiLoginCacheService {
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Value("${qingzhi.redis.token}")
private String qztoken;
@Value("${qingzhi.login.username}")
private String username;
@Value("${qingzhi.login.password}")
private String password;
@Value("${qingzhi.login.url}")
private String url;
@Value("${qingzhi.login.keepaliveurl}")
private String keepaliveurl;
@PostConstruct
public void printConfig(){
log.info("config params:"+ "redis key:" + qztoken +" ,username:"+username+ " ,password:"+password+ " ,url:"+url+ " ,keepaliveurl:"+keepaliveurl);
}
public String keepAlive() {
String token=null;
try {
String tokencache = stringRedisTemplate.opsForValue().get(qztoken);
if (tokencache != null) {
token= doKeepAlive(tokencache);
} else {
tokencache = loginServer(url, username, password);
if (tokencache != null) {
token=doKeepAlive(tokencache);
}
}
} catch (Exception e) {
System.out.println(e.toString());
log.error(e.getMessage());
}
return token;
}
private String doKeepAlive(String token) {
HttpHeaders headers = getHttpHeaders();
headers.add("token",token);
HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
RestTemplate client = new RestTemplate();
ResponseEntity<String> request = client.exchange((keepaliveurl+"?token="+token), HttpMethod.GET, requestEntity, String.class);
String newToken = getTokenData(request);
if (newToken != null) {
// log.info("doKeepAlive response " + request.getBody());
stringRedisTemplate.opsForValue().set(qztoken, newToken, 2, TimeUnit.MINUTES);
} else {
log.error("doKeepAlive response " + "empty...");
}
return newToken;
}
private String loginServer(String url, String username, String password) {
HttpHeaders headers = getHttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
RestTemplate client = new RestTemplate();
ResponseEntity<String> response = client.getForEntity((url+"?username="+username+"&password="+password),String.class);
return getTokenData(response);
}
private HttpHeaders getHttpHeaders() {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
return headers;
}
private String getTokenData(ResponseEntity<String> response){
try {
if (response != null && response.getBody() != null && response.getBody().contains("status")) {
String ret = response.getBody();
Gson gson = new Gson();
Type stringStringMap = new TypeToken<Map<String, String>>() {
}.getType();
Map<String, String> map = gson.fromJson(ret, stringStringMap);
if (map != null && map.get("data").length() > 10 && Integer.parseInt(map.get("status")) ==200) {
return map.get("data");
} else {
log.error("getTokenData error :" + response.getBody());
}
} else {
log.error("getTokenData empty...");
}
}catch (Exception e){
System.out.println(e.toString());
log.error(e.getMessage());
}
return null;
}
}
package im.zhaojun.system.service;
import im.zhaojun.system.mapper.TraffFlowMapper;
import im.zhaojun.system.model.ResultObj;
import im.zhaojun.system.model.Vehicle;
import im.zhaojun.system.model.Vehicles;
import im.zhaojun.system.model.VideoDeviceTraffic;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
@Slf4j
@Service
public class TraffFlowService {
@Autowired
private TraffFlowMapper traffFlowMapper;
@Autowired
private RestTemplate restTemplate;
@Value("${qingzhi.eventwrite.timeout}")
private Integer timeout;
@Value("${qingzhi.deviceTraffic.url}")
private String url;
@Autowired
QingZhiLoginCacheService qingZhiLoginCacheService;
public void saveTraffFlow(Vehicles vehicles) {
traffFlowMapper.add(vehicles);
}
public int saveTraffFlowDetail(Vehicle vehiclesdetail) {
return traffFlowMapper.insertlist(vehiclesdetail);
}
public List<Map> selectFiveAndDayFlow(String videoid) {
return traffFlowMapper.selectFiveAndDayFlow(videoid);
}
public List<Map> selectFiveAndTypeDayFlow(String videoid) {
return traffFlowMapper.selectFiveAndTypeDayFlow(videoid);
}
public Integer statisVehiclesByDay() {
return traffFlowMapper.statisVehiclesByDay();
}
public void deleteBeforeTwoMonthVehicles() {
traffFlowMapper.deleteBeforeTwoMonthVehiclesDetails();
}
public void deleteVehiclesByDay() {
traffFlowMapper.deleteVehiclesByDay();
}
public Integer insertOrUpdatevehicleTodaystatistic() {
return traffFlowMapper.insertOrUpdatevehicleTodaystatistic();
}
public String selectSbtddspsrRtspByVideoid(String videoid) {
return traffFlowMapper.selectSbtddspsrRtspByVideoid(videoid);
}
public List<VideoDeviceTraffic> getfiveFlowByVideoid(String videoid) {
return traffFlowMapper.getfiveFlowByVideoid(videoid);
}
public List<VideoDeviceTraffic> getTraffVicleBystatus() {
return traffFlowMapper.getTraffVicleBystatus();
}
public void sendMessage(VideoDeviceTraffic videoDeviceTraffic){
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
//判断token
String token= qingZhiLoginCacheService.keepAlive();
headers.add("token", token);
HttpEntity<VideoDeviceTraffic> requestEntity = new HttpEntity<>(videoDeviceTraffic, headers);
try{
ResultObj obj= CompletableFuture.supplyAsync(() -> restTemplate.postForObject(url, requestEntity, ResultObj.class)).get(timeout,TimeUnit.SECONDS);
log.info("send device result "+obj.getMsg());
}catch (Exception ex){
log.error(videoDeviceTraffic.getDeviceId()+videoDeviceTraffic.getDateTime()+":"+ex.toString());
}
}
public void sendMessages(List<VideoDeviceTraffic> list){
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
//判断token
String token= qingZhiLoginCacheService.keepAlive();
headers.add("token", token);
HttpEntity<List<VideoDeviceTraffic>> requestEntity = new HttpEntity<>(list, headers);
try{
ResultObj obj= CompletableFuture.supplyAsync(() -> restTemplate.postForObject(url, requestEntity, ResultObj.class)).get(timeout,TimeUnit.SECONDS);
log.info("send devicelist to guangda result "+obj.getMsg());
}catch (Exception ex){
log.error("send devicelist to guangda error:"+ex.toString());
}
}
}
\ No newline at end of file
package im.zhaojun.system.service;
import im.zhaojun.system.mapper.TraffalarmrecordMapper;
import im.zhaojun.system.model.Traffalarmrecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class TraffalarmrecordService {
@Autowired
private TraffalarmrecordMapper traffalarmrecordMapper;
public Integer statisTraffalarmrecordstatByDay() {
return traffalarmrecordMapper.statisTraffalarmrecordstatByDay();
}
public List<Traffalarmrecord> getTraffalarmrecordBystatus() {
return traffalarmrecordMapper.getTraffalarmrecordBystatus();
}
}
\ No newline at end of file
package im.zhaojun.system.service; package im.zhaojun.system.service;
import cn.hutool.json.JSONUtil;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import im.zhaojun.common.util.DateUtils; import im.zhaojun.common.util.DateUtils;
import im.zhaojun.common.util.ThreadPoolUtil;
import im.zhaojun.common.util.TransHelper;
import im.zhaojun.system.mapper.SbtdspsrMapper;
import im.zhaojun.system.mapper.TraffdevicewriteresultMapper; import im.zhaojun.system.mapper.TraffdevicewriteresultMapper;
import im.zhaojun.system.model.*; import im.zhaojun.system.model.*;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
...@@ -17,11 +21,11 @@ import org.springframework.web.client.RestTemplate; ...@@ -17,11 +21,11 @@ import org.springframework.web.client.RestTemplate;
import tk.mybatis.mapper.entity.Condition; import tk.mybatis.mapper.entity.Condition;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
@Service @Service
@Slf4j @Slf4j
...@@ -29,25 +33,34 @@ public class TraffdevicewriteresultService { ...@@ -29,25 +33,34 @@ public class TraffdevicewriteresultService {
@Autowired @Autowired
private RestTemplate restTemplate; private RestTemplate restTemplate;
@Value("${qingzhi.devicewrite.url}") @Value("${qingzhi.devicewrite.url}")
private String url; private String url;
@Value("${qingzhi.devicewrite.timeout}") @Value("${qingzhi.devicewrite.timeout}")
private Integer timeout; private Integer timeout;
@Value("${qingzhi.devicewritesupplier.name}")
String devicesupplier;
@Value("${qingzhi.devicewrite.url}")
String devicewriteurl;
@Autowired
SbtdspsrMapper sbtdspsrMapper;
@Autowired @Autowired
private TraffdevicewriteresultMapper traffdevicewriteresultMapper; private TraffdevicewriteresultMapper traffdevicewriteresultMapper;
/** /**
* 询分页 * ��ѯ��ҳ
*/ */
public List<SbtdspsrResult> querySbtdspsrResultByPage(SbtdspsrParams sbtdspsr) { public List<SbtdspsrResult> querySbtdspsrResultByPage(SbtdspsrParams sbtdspsr) {
PageHelper.startPage(sbtdspsr.getPage(), sbtdspsr.getLimit()); PageHelper.startPage(sbtdspsr.getPage(), sbtdspsr.getLimit());
return traffdevicewriteresultMapper.querySbtdspsrResultByPage(sbtdspsr); return traffdevicewriteresultMapper.querySbtdspsrResultByPage(sbtdspsr);
} }
/** /**
* 询分页 * ��ѯ��ҳ
*/ */
public List<Traffdevicewriteresult> queryTraffdevicewriteresultByPage(TraffdevicewriteresultParams traffdevicewriteresult) { public List<Traffdevicewriteresult> queryTraffdevicewriteresultByPage(TraffdevicewriteresultParams traffdevicewriteresult) {
PageHelper.startPage(traffdevicewriteresult.getPage(), traffdevicewriteresult.getLimit()); PageHelper.startPage(traffdevicewriteresult.getPage(), traffdevicewriteresult.getLimit());
...@@ -90,7 +103,7 @@ public class TraffdevicewriteresultService { ...@@ -90,7 +103,7 @@ public class TraffdevicewriteresultService {
} }
/** /**
* 添加 * ���
*/ */
public ResultObj saveTraffdevicewriteresult(Traffdevicewriteresult traffdevicewriteresult) { public ResultObj saveTraffdevicewriteresult(Traffdevicewriteresult traffdevicewriteresult) {
traffdevicewriteresultMapper.insertSelective(traffdevicewriteresult); traffdevicewriteresultMapper.insertSelective(traffdevicewriteresult);
...@@ -98,28 +111,28 @@ public class TraffdevicewriteresultService { ...@@ -98,28 +111,28 @@ public class TraffdevicewriteresultService {
} }
/** /**
* 批量添加 * �������
*/ */
public void saveTraffdevicewriteresultList(List<Traffdevicewriteresult> traffdevicewriteresultList) { public void saveTraffdevicewriteresultList(List<Traffdevicewriteresult> traffdevicewriteresultList) {
traffdevicewriteresultMapper.insertList(traffdevicewriteresultList); traffdevicewriteresultMapper.insertList(traffdevicewriteresultList);
} }
/** /**
* 更新 * ����
*/ */
public void updateTraffdevicewriteresult(Traffdevicewriteresult traffdevicewriteresult) { public void updateTraffdevicewriteresult(Traffdevicewriteresult traffdevicewriteresult) {
traffdevicewriteresultMapper.updateByPrimaryKeySelective(traffdevicewriteresult); traffdevicewriteresultMapper.updateByPrimaryKeySelective(traffdevicewriteresult);
} }
/** /**
* 删除 * ɾ��
*/ */
public void deleteTraffdevicewriteresult(Traffdevicewriteresult traffdevicewriteresult) { public void deleteTraffdevicewriteresult(Traffdevicewriteresult traffdevicewriteresult) {
traffdevicewriteresultMapper.deleteByPrimaryKey(traffdevicewriteresult); traffdevicewriteresultMapper.deleteByPrimaryKey(traffdevicewriteresult);
} }
/** /**
* 量删除 * ����ɾ��
*/ */
public void deleteTraffdevicewriteresultList(List<Traffdevicewriteresult> traffdevicewriteresultList) { public void deleteTraffdevicewriteresultList(List<Traffdevicewriteresult> traffdevicewriteresultList) {
for (Traffdevicewriteresult traffdevicewriteresult : traffdevicewriteresultList) { for (Traffdevicewriteresult traffdevicewriteresult : traffdevicewriteresultList) {
...@@ -127,27 +140,260 @@ public class TraffdevicewriteresultService { ...@@ -127,27 +140,260 @@ public class TraffdevicewriteresultService {
} }
} }
public ResultObj sendDevices(List<String> xhs) { @Autowired
List<SbtdspsrParams> sbtdspsrs = traffdevicewriteresultMapper.querySbtdspsrByXh(xhs); QingZhiLoginCacheService qingZhiLoginCacheService;
ResultObj resultObj;
private static CompletionService<ResultObj> threadService = new ExecutorCompletionService<ResultObj>(ThreadPoolUtil.getPool());
public List<ResultObj> sendDevices(List<SbtdspsrParams> sbtdspsrlist) {
log.info("senddevice begin");
List<ResultObj> resultlist=new ArrayList<>();
for (SbtdspsrParams val : sbtdspsrlist) {
log.info("senddevice val"+val.getSbbh());
Traffdevicewriteresult param=new Traffdevicewriteresult();
ResultObj obj = sendToGuangda(val, param);
obj.setData(val.getXh());
log.info("ResultObj====="+obj.toString());
resultlist.add(obj);
}
return resultlist;
}
public ResultObj sendToGuangda(SbtdspsrParams val, Traffdevicewriteresult param) {
if (val.getXzbh() == null) {
log.error("deviceWritePost {} : regist remsg...", "设备所属单位机构编码必填");
return ResultObj.error(ResponseEnum.E_1002.getCode(), "设备所属单位机构编码必填");
} else if (val.getDeviceconfig() == null) {
log.error("deviceWritePost {} : regist remsg...", "请impn先配置设备推送配置");
return ResultObj.error(ResponseEnum.E_1002.getCode(), "请impn先配置设备推送配置");
} else {
//转成第三方对象
log.info("senddevice transer");
DeviceWriteParam item = JSONUtil.toBean(val.getDeviceconfig(), DeviceWriteParam.class);
item.setDeviceID(val.getWbbh());
item.setDeviceName(val.getTdmc());
item.setRegionID(val.getXzbh());
item.setDeviceStatus(1);
item.setDeviceSupplier(devicesupplier);
item.setDataType(1);
WriteResultObj writeResultObj=null;
try { try {
resultObj = sendAllMessage(sbtdspsrs); //调用第三方的restful
} catch (TimeoutException e) { log.error("调用第三方的restful" + item.toString());
log.error("Deviceswrite - sendDevicess 请求超时:" + e.toString()); writeResultObj = deviceWritePost(item);
}
catch (TimeoutException e) {
log.error("eventwrite - sendEvents 请求超时:" + e.toString());
return ResultObj.error(ResponseEnum.E_1008.getCode(), ResponseEnum.E_1008.getMsg()); return ResultObj.error(ResponseEnum.E_1008.getCode(), ResponseEnum.E_1008.getMsg());
} catch (Exception e) { } catch (Exception e) {
log.error("Deviceswrite - sendDevicess 异常:" + e.toString()); log.error("eventwrite - sendEvents 异常:" + e.toString());
return ResultObj.error(ResponseEnum.E_9999.getCode(), e.toString()); //return ResultObj.error(ResponseEnum.E_9999.getCode(), e.toString());
}
if (writeResultObj == null) {
return ResultObj.error(ResponseEnum.E_9999.getCode(), "token凭证获取失败");
}
log.info("eventwrite - sendEvents success update database " );
param.setSbbh(val.getSbbh());
param.setTdbh(val.getTdbh());
Traffdevicewriteresult traffdevicewriteresult = traffdevicewriteresultMapper.selectOne(param);
param.setPushdesc(writeResultObj.getMessage());
param.setXzbh(val.getXzbh());
param.setPushcount(1L);
if (writeResultObj.getStatus() == 200) {
param.setPushstatus(Long.valueOf(0));
} else {
param.setPushstatus(Long.valueOf(1));
}
//数据库记录操作
if (traffdevicewriteresult == null) {
traffdevicewriteresultMapper.insertSelective(param);
} else {
if (null!=traffdevicewriteresult.getPushstatus()&& traffdevicewriteresult.getPushstatus() == 0) {
param.setPushstatus(Long.valueOf(0));
param.setPushcount(traffdevicewriteresult.getPushcount() + 1);
}
traffdevicewriteresultMapper.updateByPrimaryKeySelective(param);
}
if (writeResultObj.getStatus() == 200) {
param.setPushstatus(Long.valueOf(0));
return ResultObj.ok(writeResultObj.getStatus());
} else {
param.setPushstatus(Long.valueOf(1));
return ResultObj.error(writeResultObj.getStatus(), writeResultObj.getMessage());
}
}
}
public ResultObj updateAndRegist(SbtdspsrParam sbtdspsr) {
ResultObj res;
String pushdesc;
long pushstatus = 0;
assert sbtdspsr != null;
if (sbtdspsr.getXzbh() == null) {
res = ResultObj.error(ResponseEnum.E_1002.getCode(), "设备所属单位机构编码必填");
log.error("deviceWritePost {} : regist remsg...", "设备所属单位机构编码必填");
} else if (sbtdspsr.getDeviceconfig() == null) {
res = ResultObj.error(ResponseEnum.E_1002.getCode(), "请impn先配置设备推送配置");
log.error("deviceWritePost {} : regist remsg...", "请impn先配置设备推送配置");
} else {
res = doDeviceWriteGetResultObj(sbtdspsr);
}
if (res.getStatus() == 200) {
pushdesc = res.getData().toString();
} else {
pushdesc = res.getMsg();
pushstatus = 1;
}
//数据库记录操作
Traffdevicewriteresult traffdevicewriteresult = traffdevicewriteresultMapper.selectOne(TransHelper.transDeviceWriteResult(sbtdspsr));
if (traffdevicewriteresult == null) {
traffdevicewriteresultMapper.insertSelective(TransHelper.transDeviceWriteResult(sbtdspsr, pushstatus, pushdesc));
} else {
if (traffdevicewriteresult.getPushstatus() == 0) {
pushstatus = 0;
}
traffdevicewriteresultMapper.updateByPrimaryKeySelective(TransHelper.transDeviceWriteResult(sbtdspsr, pushstatus, pushdesc, traffdevicewriteresult.getPushcount() + 1));
}
return res;
}
public ResultObj registall(HttpServletResponse response) {
response.setContentType("text/html;charset=utf-8");
String ret;
int count, susscee = 0, fail = 0;
List<SbtdspsrParam> list = sbtdspsrMapper.selectDeviceWrite();
count = list.size();
try {
write(response, "共查询出需要写入的设备" + count + "条");
} catch (IOException e) {
log.error("设备批量写入 registall -->>io异常" + e.toString());
} }
return resultObj; for (SbtdspsrParam val : list) {
try {
write(response, "--->>>开始写入第" + (susscee + fail + 1) + "条,剩余" + (count - susscee - fail - 1) + "条。设备编号:" + val.getSbbh() + ",通道编号:" + val.getTdbh() + ",设备名称:" + val.getTdmc());
ResultObj regest = updateAndRegist(val);
if (regest.getStatus() == 200) {
susscee++;
write(response, "<<<---写入成功:" + regest.getData());
} else {
fail++;
write(response, "<<<---写入失败:" + regest.getMsg());
}
} catch (IOException e) {
log.error("设备批量写入 registall -->>io异常" + e.toString());
}
}
ret = "查询出需要设备写入的设备数:" + count + "条,其中成功" + susscee + "条,失败" + fail + "条";
try {
write(response, ret);
} catch (IOException e) {
log.error("设备批量写入 registall -->>io异常" + e.toString());
}
return ResultObj.ok(ret);
}
public ResultObj update(SbtdspsrParam sbtdspsr) {
DeviceWriteParam param = TransHelper.transDevice(sbtdspsr, CodeConst.device_update);
WriteResultObj writeResultObj = new WriteResultObj(); //deviceWritePost(param);
if (writeResultObj.getStatus() == 200) {
return ResultObj.ok(writeResultObj.getMessage());
}
return ResultObj.error(writeResultObj.getStatus(), writeResultObj.getMessage());
}
public ResultObj remove(SbtdspsrParam sbtdspsr) {
DeviceWriteParam param = TransHelper.transDevice(sbtdspsr, CodeConst.device_remove);
WriteResultObj writeResultObj = new WriteResultObj(); //deviceWritePost(param);
if (writeResultObj.getStatus() == 200) {
return ResultObj.ok(writeResultObj.getMessage());
}
return ResultObj.error(writeResultObj.getStatus(), writeResultObj.getMessage());
}
public ResultObj report(SbtdspsrParam sbtdspsr) {
DeviceWriteParam param = TransHelper.transDevice(sbtdspsr, CodeConst.device_report);
WriteResultObj writeResultObj = new WriteResultObj(); //deviceWritePost(param);
if (writeResultObj.getStatus() == 200) {
return ResultObj.ok(writeResultObj.getMessage());
}
return ResultObj.error(writeResultObj.getStatus(), writeResultObj.getMessage());
} }
private ResultObj sendAllMessage(List<SbtdspsrParams> sbtdspsrs) throws InterruptedException, ExecutionException, TimeoutException { private WriteResultObj deviceWritePost(DeviceWriteParam param) throws TimeoutException, InterruptedException,Exception{
log.info("senddevice====="+param.toString());
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
// String token = stringRedisTemplate.opsForValue().get(qztoken);
// if (token == null) {
//登录
// log.info("login", qztoken);
String token= qingZhiLoginCacheService.keepAlive();
log.error("deviceWritePost {} : redis token empty..", token);
// return null;
// }
log.info("qztoken send guangda token", token);
headers.setContentType(MediaType.APPLICATION_JSON_UTF8); headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
HttpEntity<List<SbtdspsrParams>> requestEntity = new HttpEntity<>(sbtdspsrs, headers); headers.add("token", token);//
return CompletableFuture.supplyAsync(() -> restTemplate.postForObject(url, requestEntity, ResultObj.class)).get(timeout, TimeUnit.MILLISECONDS); List<DeviceWriteParam> list = new ArrayList<>();
list.add(param);
HttpEntity<List<DeviceWriteParam>> requestEntity = new HttpEntity<>(list, headers);
WriteResultObj writeResultObj = CompletableFuture.supplyAsync(() -> restTemplate.postForObject(devicewriteurl, requestEntity, WriteResultObj.class)).get(timeout, TimeUnit.SECONDS);
log.info("qztoken send guangda result", writeResultObj.toString());
return writeResultObj;
} }
private ResultObj doDeviceWriteGetResultObj(SbtdspsrParam sbtdspsr) {
ResultObj res;
sbtdspsr.setSbcsName(devicesupplier);
//组装请求数据
DeviceWriteParam param = TransHelper.transDevice(sbtdspsr, CodeConst.device_regist);
WriteResultObj writeResultObj;
try {
//发送请求返回结果
writeResultObj = deviceWritePost(param);
if (writeResultObj == null) {
writeResultObj = new WriteResultObj(ResponseEnum.E_9999.getCode(), "token凭证获取失败");
}
} catch (TimeoutException e) {
log.error("devicewrite - sendEvent 请求超时:" + e.toString());
writeResultObj = new WriteResultObj(ResponseEnum.E_1008.getCode(), ResponseEnum.E_1008.getMsg());
} catch (Exception e) {
log.error("devicewrite - sendEvent 异常:" + e.toString());
writeResultObj = new WriteResultObj(ResponseEnum.E_9999.getCode(), e.toString());
}
//判断成功还是失败
if (writeResultObj.getStatus() == 200) {
res = ResultObj.ok(writeResultObj.getMessage());
// log.info("deviceWritePost {} : regist remsg...Data=" + param.toString(), writeResultObj.toString());
} else {
res = ResultObj.error(writeResultObj.getStatus(), writeResultObj.getMessage());
log.error("deviceWritePost {} : regist remsg...Data=" + param.toString(), writeResultObj.toString());
}
return res;
}
private void write(HttpServletResponse response, String content) throws IOException {
response.getWriter().write(content + "<br/>");
response.flushBuffer();
response.getWriter().flush();
}
public ResultObj updateAndRegists(List<SbtdspsrParam> sbtdspsrs) {
int error = 0;
int success = 0;
for (SbtdspsrParam ta : sbtdspsrs) {
ResultObj resultObj = updateAndRegist(ta);
boolean successFlag = resultObj.getStatus() == ResponseEnum.SUCCESS.getCode();
/* 成功 */
if (successFlag) {
success++;
continue;
}
error++;
}
return ResultObj.error(ResponseEnum.SUCCESS.getCode(), "成功" + success + "条|失败" + error + "条");
}
} }
\ No newline at end of file
...@@ -64,3 +64,7 @@ spring.profiles.path= D:/hzjt_service/imp/config/im/hzjt.properties ...@@ -64,3 +64,7 @@ spring.profiles.path= D:/hzjt_service/imp/config/im/hzjt.properties
exportcolumn=\u8BBE\u5907\u7F16\u53F7,\u901A\u9053\u7F16\u53F7,\u8BBE\u5907\u540D\u79F0,\u533A\u57DF\u7F16\u53F7,\u533A\u57DF\u540D\u79F0,\u544A\u8B66\u65F6\u95F4,\u544A\u8B66\u7B49\u7EA7,\u544A\u8B66\u540D\u79F0 exportcolumn=\u8BBE\u5907\u7F16\u53F7,\u901A\u9053\u7F16\u53F7,\u8BBE\u5907\u540D\u79F0,\u533A\u57DF\u7F16\u53F7,\u533A\u57DF\u540D\u79F0,\u544A\u8B66\u65F6\u95F4,\u544A\u8B66\u7B49\u7EA7,\u544A\u8B66\u540D\u79F0
enexportcolumn=sbbh,tdbh,tdmc,xzbh,xzmc,recordtime,recordlevel,recordname enexportcolumn=sbbh,tdbh,tdmc,xzbh,xzmc,recordtime,recordlevel,recordname
alarmrecord.check.push.enable=1
alarmrecord.check.push.recordtype=1
qingzhi.devicewritesupplier.name=zksy
qingzhi.deviceTraffic.url=http://33.50.1.213:38080/api/jtldpt/impld/videoDeviceTraffic
\ No newline at end of file
<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="im.zhaojun.system.mapper.SbtdspsrMapper">
<resultMap id="BaseResultMap" type="im.zhaojun.system.model.Sbtdspsr">
<!--
WARNING - @mbg.generated
-->
<result column="XH" jdbcType="VARCHAR" property="xh"/>
<result column="SBBH" jdbcType="VARCHAR" property="sbbh"/>
<result column="TDBH" jdbcType="DECIMAL" property="tdbh"/>
<result column="TDLX" jdbcType="DECIMAL" property="tdlx"/>
<result column="WBBH" jdbcType="VARCHAR" property="wbbh"/>
<result column="TDMC" jdbcType="VARCHAR" property="tdmc"/>
<result column="TDMCPY" jdbcType="VARCHAR" property="tdmcpy"/>
<result column="TDZT" jdbcType="DECIMAL" property="tdzt"/>
<result column="TDAZWZ" jdbcType="VARCHAR" property="tdazwz"/>
<result column="JD" jdbcType="VARCHAR" property="jd"/>
<result column="WD" jdbcType="VARCHAR" property="wd"/>
<result column="TPWZX" jdbcType="DECIMAL" property="tpwzx"/>
<result column="TPWZY" jdbcType="DECIMAL" property="tpwzy"/>
<result column="SPBMGS" jdbcType="DECIMAL" property="spbmgs"/>
<result column="SPXSGS" jdbcType="DECIMAL" property="spxsgs"/>
<result column="SSSPSFZZF" jdbcType="DECIMAL" property="ssspsfzzf"/>
<result column="SPZT" jdbcType="DECIMAL" property="spzt"/>
<result column="LXZT" jdbcType="DECIMAL" property="lxzt"/>
<result column="LXSFZZF" jdbcType="DECIMAL" property="lxsfzzf"/>
<result column="SPZL" jdbcType="DECIMAL" property="spzl"/>
<result column="GJZJG" jdbcType="DECIMAL" property="gjzjg"/>
<result column="ML" jdbcType="DECIMAL" property="ml"/>
<result column="SPMLYXGS" jdbcType="DECIMAL" property="spmlyxgs"/>
<result column="SFZCPTZKZ" jdbcType="DECIMAL" property="sfzcptzkz"/>
<result column="ZXCCZBH" jdbcType="VARCHAR" property="zxcczbh"/>
<result column="ZXCCXE" jdbcType="DECIMAL" property="zxccxe"/>
<result column="ZXCCYYRL" jdbcType="DECIMAL" property="zxccyyrl"/>
<result column="ZXCCSYRL" jdbcType="DECIMAL" property="zxccsyrl"/>
<result column="LXBLTS" jdbcType="DECIMAL" property="lxblts"/>
<result column="SFQY" jdbcType="DECIMAL" property="sfqy"/>
<result column="JLBH" jdbcType="VARCHAR" property="jlbh"/>
<result column="FXMS" jdbcType="VARCHAR" property="fxms"/>
<result column="JBMS" jdbcType="VARCHAR" property="jbms"/>
<result column="XZBH" jdbcType="VARCHAR" property="xzbh"/>
<result column="GGBH" jdbcType="VARCHAR" property="ggbh"/>
<result column="ZNBH" jdbcType="VARCHAR" property="znbh"/>
<result column="LXFS" jdbcType="DECIMAL" property="lxfs"/>
<result column="JPKZDH" jdbcType="VARCHAR" property="jpkzdh"/>
<result column="JDPX" jdbcType="DECIMAL" property="jdpx"/>
<result column="SFZNFXJD" jdbcType="DECIMAL" property="sfznfxjd"/>
<result column="ZNFXLX" jdbcType="VARCHAR" property="znfxlx"/>
<result column="SQMS" jdbcType="DECIMAL" property="sqms"/>
<result column="SQURLLJ" jdbcType="VARCHAR" property="squrllj"/>
<result column="SSMLXZ" jdbcType="DECIMAL" property="ssmlxz"/>
<result column="LXMLXZ" jdbcType="DECIMAL" property="lxmlxz"/>
<result column="ZBURLLJ" jdbcType="VARCHAR" property="zburllj"/>
<result column="ZBDK" jdbcType="DECIMAL" property="zbdk"/>
<result column="DQX" jdbcType="DECIMAL" property="dqx"/>
<result column="XQX" jdbcType="DECIMAL" property="xqx"/>
<result column="KQX" jdbcType="DECIMAL" property="kqx"/>
<result column="PQX" jdbcType="DECIMAL" property="pqx"/>
<result column="LXHFQX" jdbcType="DECIMAL" property="lxhfqx"/>
<result column="LXXZQX" jdbcType="DECIMAL" property="lxxzqx"/>
<result column="LXDJQX" jdbcType="DECIMAL" property="lxdjqx"/>
<result column="SFZLX" jdbcType="DECIMAL" property="sfzlx"/>
<result column="SFZX" jdbcType="DECIMAL" property="sfzx"/>
<result column="HB" jdbcType="VARCHAR" property="hb"/>
<result column="JMCJ" jdbcType="VARCHAR" property="jmcj"/>
<result column="SJ" jdbcType="VARCHAR" property="sj"/>
<result column="LXLRCYFS" jdbcType="DECIMAL" property="lxlrcyfs"/>
<result column="KHDOSDXSNR" jdbcType="VARCHAR" property="khdosdxsnr"/>
<result column="KHDOSDXSWZ" jdbcType="VARCHAR" property="khdosdxswz"/>
<result column="CJRY" jdbcType="VARCHAR" property="cjry"/>
<result column="CJRQ" jdbcType="VARCHAR" property="cjrq"/>
<result column="XGRY" jdbcType="VARCHAR" property="xgry"/>
<result column="XGRQ" jdbcType="VARCHAR" property="xgrq"/>
<result column="BZ" jdbcType="VARCHAR" property="bz"/>
<result column="KZ1" jdbcType="DECIMAL" property="kz1"/>
<result column="KZ2" jdbcType="DECIMAL" property="kz2"/>
<result column="KZ3" jdbcType="VARCHAR" property="kz3"/>
<result column="KZ4" jdbcType="VARCHAR" property="kz4"/>
</resultMap>
<select id="selectAllSbbhAndTdbh" resultType="im.zhaojun.system.model.Sbtdspsr">
SELECT XH,SBBH,TDBH FROM SBTDSPSR WHERE XZBH like #{xzbh} || '%'
</select>
<select id="selectBySbbh" resultType="im.zhaojun.system.model.Sbtdspsr">
SELECT A.* FROM SBTDSPSR A where sbbh=#{sbbh} and tdbh=#{tdbh}
</select>
<select id="selectDeviceWrite" resultType="im.zhaojun.system.model.SbtdspsrParam">
SELECT A.*,C.remark1 AS deviceconfig FROM SBTDSPSR A
LEFT JOIN TRAFFDEVICEWRITERESULT B ON A.SBBH = B.SBBH AND A.TDBH = B.TDBH
LEFT JOIN TRAFFDEVICECONFIG C ON C.FDID = A.SBBH AND C.CHANNELID = A.TDBH
WHERE B.PUSHSTATUS != 0 OR B.PUSHDESC IS NULL
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="im.zhaojun.system.mapper.TraffalarmrecordMapper">
<update id="updateTraffAlarmRecordUrl" parameterType="im.zhaojun.system.model.Traffalarmrecord">
UPDATE traffalarmrecord
set retrytime= sysdate,
retrycount= retrycount+1
<trim prefix="," suffixOverrides=",">
<if test="img1path!=null">img1path=#{img1path},</if>
<if test="img2path!=null">img2path=#{img2path},</if>
<if test="img3path!=null">img3path=#{img3path},</if>
<if test="img4path!=null">img4path=#{img4path},</if>
<if test="img5path!=null">img5path=#{img5path},</if>
<if test="videopath!=null">videopath=#{videopath},</if>
<if test="pushstatus!=null">pushstatus=#{pushstatus},</if>
</trim>
WHERE recordid=#{recordid}
</update>
<update id="updatePushEvent" parameterType="im.zhaojun.system.model.Traffalarmrecord">
UPDATE traffalarmrecord
set PUSHSTATUS = #{pushstatus},
PUSHDESC = #{pushdesc},
PUSHCOUNT= CASE WHEN PUSHCOUNT IS NULL THEN 1 ELSE PUSHCOUNT + 1 END,
PUSHDATE= sysdate
WHERE RECORDID = #{recordid}
</update>
<insert id="inserTraffAlarmRecord">
insert into traffalarmrecord
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="recordid != null">recordid,</if>
<if test="algotype != null">algotype,</if>
<if test="areaid != null">areaid,</if>
<if test="fdid != null">fdid,</if>
<if test="channelid != null">channelid,</if>
<if test="channeletype != null">channeletype,</if>
<if test="channelname != null">channelname ,</if>
<if test="recordtime != null">recordtime,</if>
<if test="recordtype != null">recordtype,</if>
<if test="location != null">location,</if>
<if test="img1urlfrom != null">img1urlfrom,</if>
<if test="img1path != null">img1path,</if>
<if test="img2urlfrom != null">img2urlfrom,</if>
<if test="img2path != null">img2path,</if>
<if test="img3urlfrom != null">img3urlfrom,</if>
<if test="img3path != null">img3path,</if>
<if test="img4urlfrom != null">img4urlfrom,</if>
<if test="img4path != null">img4path,</if>
<if test="img5urlfrom != null">img5urlfrom,</if>
<if test="img5path != null">img5path,</if>
<if test="videourlfrom != null">videourlfrom,</if>
<if test="videopath != null">videopath,</if>
<if test="retrytime != null">retrytime,</if>
<if test="retrycount != null">retrycount,</if>
<if test="recordlevel != null">recordlevel,</if>
<if test="checkstatus != null">checkstatus,</if>
<if test="creator != null">creator,</if>
<if test="createtime != null">createtime,</if>
<if test="updator != null">updator,</if>
<if test="updatetime != null">updatetime,</if>
<if test="remark != null">remark,</if>
<if test="pushstatus != null">pushstatus,</if>
<if test="pushdesc != null">pushdesc,</if>
<if test="processstatus != null">processstatus,</if>
<if test="objlable != null">objlable,</if>
<if test="rectificationtype != null">rectificationtype ,</if>
<if test="manualstatus != null">manualstatus ,</if>
</trim>
<trim prefix="select" suffix="from dual" suffixOverrides=",">
<if test="recordid != null">#{recordid},</if>
<if test="algotype != null">#{algotype},</if>
<if test="areaid != null">#{areaid},</if>
<if test="fdid != null">#{fdid},</if>
<if test="channelid != null">#{ channelid},</if>
<if test="channeletype != null">#{channeletype},</if>
<if test="channelname != null">#{ channelname },</if>
<if test="recordtime != null">#{ recordtime},</if>
<if test="recordtype != null">#{ recordtype},</if>
<if test="location != null">#{ location},</if>
<if test="img1urlfrom != null">#{img1urlfrom},</if>
<if test="img1path != null">#{ img1path},</if>
<if test="img2urlfrom != null">#{img2urlfrom},</if>
<if test="img2path != null">#{ img2path},</if>
<if test="img3urlfrom != null">#{img3urlfrom},</if>
<if test="img3path != null">#{ img3path},</if>
<if test="img4urlfrom != null">#{img4urlfrom},</if>
<if test="img4path != null">#{ img4path},</if>
<if test="img5urlfrom != null">#{img5urlfrom},</if>
<if test="img5path != null">#{img5path},</if>
<if test="videourlfrom != null">#{videourlfrom},</if>
<if test="videopath != null">#{videopath},</if>
<if test="retrytime != null">#{retrytime},</if>
<if test="retrycount != null">#{retrycount},</if>
<if test="recordlevel != null">#{recordlevel,jdbcType=INTEGER},</if>
<if test="checkstatus != null">#{checkstatus,jdbcType=INTEGER},</if>
<if test="creator != null">#{creator},</if>
<if test="createtime != null">#{createtime},</if>
<if test="updator != null">#{updator},</if>
<if test="updatetime != null">#{updatetime},</if>
<if test="remark != null">#{remark},</if>
<if test="pushstatus != null">#{pushstatus},</if>
<if test="pushdesc != null">#{pushdesc},</if>
<if test="processstatus != null">#{processstatus},</if>
<if test="objlable != null">#{objlable},</if>
<if test="rectificationtype != null">#{rectificationtype},</if>
<if test="manualstatus != null">#{manualstatus,jdbcType=INTEGER},</if>
</trim>
</insert>
<select id="selectmax" resultType="java.lang.Integer">
select nvl(max(recordid),0)+1 from traffalarmrecord
</select>
<insert id="statisTraffalarmrecordstatByDay">
insert into TRAFFALARMRECORDSTATE
SELECT A.FDID,CHANNELID, to_char(A.RECORDTIME,'yyyy-MM-DD')countdate,count(*) totalcount,recordtype eventtype,areaid,
(select B.TDMC from SBTDSPSR B where A.FDID=B.SBBH and CHANNELID=B.TDBH and rownum=1)tdmc,
(select C.NAME from T_CODE C where C.KEY=UPPER(RECORDTYPE)and rownum=1 ) eventtypename,
(SELECT DEPT_NAME FROM Dept d where d.dept_id=a.areaid and rownum=1)areaname,
sum( case when pushstatus is null or pushstatus=9 then 1 else 0 end)nopush,
sum( case when pushstatus =0 then 1 else 0 end)successpush,
sum( case when pushstatus =1 then 1 else 0 end)failpush
FROM TRAFFALARMRECORD A
where A.RECORDTIME>=TRUNC(SYSDATE-1)
and A.RECORDTIME<![CDATA[ < ]]>TRUNC(SYSDATE)
group by to_char(A.RECORDTIME,'yyyy-MM-DD'),recordtype,A.FDID,CHANNELID,areaid
</insert>
<update id="updateTraffAlarmRectificationType" parameterType="im.zhaojun.system.model.Traffalarmrecord">
UPDATE TRAFFALARMRECORD
<set>
<if test="processstatus != null">
rectificationtype=1,
</if>
</set>
from TRAFFALARMRECORD a,
(select * from TRAFFALARMRECORD a,(select * from TRAFFALARMRECORD b where
recordid=#{recordid,jdbcType=VARCHAR} )b
where a.fdid =b.fdid and a.channelid=b.channelid
AND ( a.recordtime<![CDATA[ <= ]]> b.recordtime-10/1440)
AND recordtype in ('roadworks_out_of_line','roadworks'))b
where recordtype in('illegal_parking','no_motor_ban') and a.fdid =b.fdid and a.channelid=b.channelid
</update>
<!--<select id="selectExitsTraffAlarm" parameterType="com.hzjt.domain.Traffalarmrecord" resultType="java.lang.Integer">-->
<!--select count(1) from TRAFFALARMRECORD a,t_code b where a.recordtype=#{recordtype,jdbcType=VARCHAR}-->
<!--and a.recordtype=LOWER (b.key)and recordtime>=sysdate-(b.REPEATTIME)/(24*60)-->
<!--and a.fdid=#{fdid,jdbcType=VARCHAR}-->
<!--and a.channelid=#{channelid,jdbcType=VARCHAR}-->
<!--</select>-->
<select id="selectInChecktimeTraffAlarm" parameterType="im.zhaojun.system.model.Traffalarmrecord" resultType="java.lang.Integer">
select count(1) from videochecktime a,t_code b where
a.FDID=#{fdid,jdbcType=VARCHAR}
and a.CHANNELID=#{channelid,jdbcType=VARCHAR}
and a.RECORDTYPE=#{recordtype,jdbcType=VARCHAR}
and a.RECORDTYPE=lower(b.key)
and LASTCHECKTIME+(b.PUSHCHECKTIME)/1440 <![CDATA[ >= ]]>#{recordtime,jdbcType=TIMESTAMP}
and LASTCHECKTIME <![CDATA[ < ]]>#{recordtime,jdbcType=TIMESTAMP}
</select>
<update id="updateInworkRectifytimeTraffAlarm" parameterType="im.zhaojun.system.model.Traffalarmrecord">
update TRAFFALARMRECORD set rectificationtype=1,recordtype='roadworks'
where fdid=#{fdid,jdbcType=VARCHAR}
and channelid=#{channelid,jdbcType=VARCHAR}
and recordtime>=#{recordtime,jdbcType=TIMESTAMP}-(select b.RECTIFYTIME from t_code b where recordtype=LOWER (b.key) )/1440
and recordtime<![CDATA[ < ]]>#{recordtime,jdbcType=TIMESTAMP}
and recordtype in ('illegal_parking','no_motor_ban')
</update>
<select id="seletManualStatus" resultType="java.lang.String">
select name from t_code where type=4
</select>
<select id="getTraffalarmrecordBystatus" resultType="im.zhaojun.system.model.Traffalarmrecord">
select * from TRAFFALARMRECORD where pushstatus=9
</select>
<select id="getfiveFlowByVideoid" resultType="im.zhaojun.system.model.VideoDeviceTraffic">
SELECT
wbbh deviceId,
CONCAT (CONCAT(b.sbbh, '_'), b.tdbh),
tdmc deviceName,
SYSDATE dateTime,
xzbh ssjg,
flow flowRate,
'1' fx,
'' fxmc,
'zksy' sjly
FROM
sbtdspsr b
LEFT JOIN (
SELECT
NVL (COUNT(*), 0) flow,
video_id
FROM
vehicle
WHERE
ruletag = '1'
AND CREATE_TIME >= SYSDATE - 5 / 1440
GROUP BY
video_id
) A ON video_id = CONCAT (CONCAT(b.sbbh, '_'), b.tdbh)
UNION ALL
SELECT
wbbh deviceId,
CONCAT (CONCAT(b.sbbh, '_'), b.tdbh),
tdmc deviceName,
SYSDATE dateTime,
xzbh ssjg,
flow flowRate,
'2' fx,
'' fxmc,
'zksy' sjly
FROM
sbtdspsr b
LEFT JOIN (
SELECT
NVL (COUNT(*), 0) flow,
video_id
FROM
vehicle
WHERE
ruletag = '2'
AND CREATE_TIME >= SYSDATE - 5 / 1440
GROUP BY
video_id
) A ON video_id = CONCAT (CONCAT(b.sbbh, '_'), b.tdbh)
</select>
</mapper>
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="im.zhaojun.system.mapper.TraffdevicewriteresultMapper"> <mapper namespace="im.zhaojun.system.mapper.TraffdevicewriteresultMapper">
<select id="querySbtdspsrResultByPage" resultType="im.zhaojun.system.model.SbtdspsrResult"> <select id="querySbtdspsrResultByPage" resultType="im.zhaojun.system.model.SbtdspsrParams">
select ta.*, select ta.*,
a.createtime, a.createtime,
a.pushstatus, a.pushstatus,
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
a.remark, a.remark,
a.pushdesc, a.pushdesc,
p.dept_name as xztreename, p.dept_name as xztreename,
b.devicechecktype devicetype b.devicechecktype devicetype,
b.remark1 deviceconfig
from sbtdspsr ta from sbtdspsr ta
inner join traffdevicewriteresult a inner join traffdevicewriteresult a
on a.sbbh = ta.sbbh on a.sbbh = ta.sbbh
......
...@@ -192,7 +192,7 @@ let vue_sjcx = new Vue({ ...@@ -192,7 +192,7 @@ let vue_sjcx = new Vue({
construction: '2', construction: '2',
objlabel: objlabels, objlabel: objlabels,
processstatus: processstatus, processstatus: processstatus,
rectificationtype:'', rectificationtype:vue_sjcx.clzt_select1=='2'?'':vue_sjcx.clzt_select1,
}; };
if(exportornot==0){ if(exportornot==0){
$.ajax({ $.ajax({
...@@ -228,7 +228,7 @@ let vue_sjcx = new Vue({ ...@@ -228,7 +228,7 @@ let vue_sjcx = new Vue({
} }
}, onPageClicked: function (event, originalEvent, type, page) { //异步换页 }, onPageClicked: function (event, originalEvent, type, page) { //异步换页
//请求加载数据 //请求加载数据
vue_sjcx.query(page, false); vue_sjcx.query(page, false,0);
} }
}); });
} }
......
...@@ -145,9 +145,8 @@ let vue_ts = new Vue({ ...@@ -145,9 +145,8 @@ let vue_ts = new Vue({
url: "/traffresult/sendDevices", url: "/traffresult/sendDevices",
dataType: "json", dataType: "json",
type: "POST", type: "POST",
data: { contentType: 'application/json',
xhs: arrs, data: JSON.stringify(vue_ts.data_table_ts),
},
success: function (result) { success: function (result) {
if (result.length > 0) { if (result.length > 0) {
result.forEach((item, index)=> { result.forEach((item, index)=> {
......
...@@ -211,13 +211,17 @@ let vue_ts = new Vue({ ...@@ -211,13 +211,17 @@ let vue_ts = new Vue({
vue_sjcx.state_arr.forEach((item, index)=> { vue_sjcx.state_arr.forEach((item, index)=> {
arrs = arrs + item + ','; arrs = arrs + item + ',';
}); });
$.ajax({ $.ajax({
url: "/traffresult/sendEvents", url: "/traffresult/sendEvents",
headers: {
'Content-Type': 'application/json'
},
dataType: "json", dataType: "json",
type: "POST", type: "POST",
data: { data:JSON.stringify(vue_ts.data_table_ts),
recordid: arrs,
},
success: function (result) { success: function (result) {
if (result.length > 0) { if (result.length > 0) {
result.forEach((item, index)=> { result.forEach((item, index)=> {
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<option value="2">重复事件</option> <option value="2">重复事件</option>
</select> </select>
<span class="pub-span" style="margin-left: 10px;">自动刷新</span> <span class="pub-span" style="margin-left: 10px;">自动刷新</span>
<input type="checkbox" id="push" @click="zdsx" style="width: 17px;height: 17px;margin-top: 16px;"/> <input type="checkbox" id="push" @click="zdsx" checked style="width: 17px;height: 17px;margin-top: 16px;"/>
<span class="glyphicon glyphicon-th-list table-class" <span class="glyphicon glyphicon-th-list table-class"
:style="{'color':!show?'#368ff3 !important':''}" @click="qh_tab(1)"></span> :style="{'color':!show?'#368ff3 !important':''}" @click="qh_tab(1)"></span>
<span class="glyphicon glyphicon-th table-class" <span class="glyphicon glyphicon-th table-class"
......
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