Commit 7ec8ba1d authored by yzm's avatar yzm

init

parents
/target/
!.mvn/wrapper/maven-wrapper.jar
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/build/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
\ No newline at end of file
长兴县博物馆,每天8:30和15:00抽取监控截图,上传至服务器
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.quartz.cn</groupId>
<artifactId>VideoofCultural</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<description>视频截图推送</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<skipTests>true</skipTests>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--mybatis-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.1</version>
</dependency>
<!--druid连接池-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.15-beta2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>2.9.6</version>
</dependency>
<!--quartz依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.6</version>
</dependency>
<!-- redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!--kafka依赖-->
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<!-- HttpClient依赖 -->
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.28</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
package com.cx.cn.cxquartz;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class CXQuartzApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(CXQuartzApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(CXQuartzApplication.class);
}
}
package com.cx.cn.cxquartz.bean;
public class PatrolCtrlAlarm {
private String cameraCode;
private String cameraName;
private String time;
private String type;
private String file;
public String getCameraCode() {
return cameraCode;
}
public void setCameraCode(String cameraCode) {
this.cameraCode = cameraCode;
}
public String getCameraName() {
return cameraName;
}
public void setCameraName(String cameraName) {
this.cameraName = cameraName;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getFile() {
return file;
}
public void setFile(String file) {
this.file = file;
}
}
package com.cx.cn.cxquartz.bean;
public class PatrolCtrlRecord {
private String cameraCode;
private String cameraName;
private String patrolTime;
private String recordSrc;
private String file;
private String deviceid;
public String getDeviceid() {
return deviceid;
}
public void setDeviceid(String deviceid) {
this.deviceid = deviceid;
}
public String getCameraCode() {
return cameraCode;
}
public void setCameraCode(String cameraCode) {
this.cameraCode = cameraCode;
}
public String getCameraName() {
return cameraName;
}
public void setCameraName(String cameraName) {
this.cameraName = cameraName;
}
public String getPatrolTime() {
return patrolTime;
}
public void setPatrolTime(String patrolTime) {
this.patrolTime = patrolTime;
}
public String getRecordSrc() {
return recordSrc;
}
public void setRecordSrc(String recordSrc) {
this.recordSrc = recordSrc;
}
public String getFile() {
return file;
}
public void setFile(String file) {
this.file = file;
}
}
package com.cx.cn.cxquartz.bean;
public class PictureTime {
String deviceid;
String lasttime;
public String getDeviceid() {
return deviceid;
}
public void setDeviceid(String deviceid) {
this.deviceid = deviceid;
}
public String getLasttime() {
return lasttime;
}
public void setLasttime(String lasttime) {
this.lasttime = lasttime;
}
}
package com.cx.cn.cxquartz.bean;
public class QuartzTaskErrors {
private Long id;
private String taskexecuterecordid;
private String errorkey;
private Long createtime;
private Long lastmodifytime;
private String errorvalue;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTaskexecuterecordid() {
return taskexecuterecordid;
}
public void setTaskexecuterecordid(String taskexecuterecordid) {
this.taskexecuterecordid = taskexecuterecordid == null ? null : taskexecuterecordid.trim();
}
public String getErrorkey() {
return errorkey;
}
public void setErrorkey(String errorkey) {
this.errorkey = errorkey == null ? null : errorkey.trim();
}
public Long getCreatetime() {
return createtime;
}
public void setCreatetime(Long createtime) {
this.createtime = createtime;
}
public Long getLastmodifytime() {
return lastmodifytime;
}
public void setLastmodifytime(Long lastmodifytime) {
this.lastmodifytime = lastmodifytime;
}
public String getErrorvalue() {
return errorvalue;
}
public void setErrorvalue(String errorvalue) {
this.errorvalue = errorvalue == null ? null : errorvalue.trim();
}
}
package com.cx.cn.cxquartz.bean;
public class QuartzTaskInformations {
private Long id;
private Integer version;
private String taskno;
private String taskname;
private String schedulerrule;
private String frozenstatus;
private String executorno;
private Long frozentime;
private Long unfrozentime;
private Long createtime;
private Long lastmodifytime;
private String sendtype;
private String url;
private String executeparamter;
private String timekey;
private Long objectx;
private Long objecty;
private Long objectw;
private Long objecth;
private String recordtype;
private String metatype;
private String imgsrc;
private String rtsp;
private String videoid;
public String getVideoid() {
return videoid;
}
public void setVideoid(String videoid) {
this.videoid = videoid;
}
public String getImgsrc() {
return imgsrc;
}
public void setImgsrc(String imgsrc) {
this.imgsrc = imgsrc;
}
public String getRtsp() {
return rtsp;
}
public void setRtsp(String rtsp) {
this.rtsp = rtsp;
}
public String getMetatype() {
return metatype;
}
public void setMetatype(String metatype) {
this.metatype = metatype;
}
public Long getObjectx() {
return objectx;
}
public void setObjectx(Long objectx) {
this.objectx = objectx;
}
public Long getObjecty() {
return objecty;
}
public void setObjecty(Long objecty) {
this.objecty = objecty;
}
public Long getObjectw() {
return objectw;
}
public void setObjectw(Long objectw) {
this.objectw = objectw;
}
public Long getObjecth() {
return objecth;
}
public void setObjecth(Long objecth) {
this.objecth = objecth;
}
public String getRecordtype() {
return recordtype;
}
public void setRecordtype(String recordtype) {
this.recordtype = recordtype;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}
public String getTaskno() {
return taskno;
}
public void setTaskno(String taskno) {
this.taskno = taskno == null ? null : taskno.trim();
}
public String getTaskname() {
return taskname;
}
public void setTaskname(String taskname) {
this.taskname = taskname == null ? null : taskname.trim();
}
public String getSchedulerrule() {
return schedulerrule;
}
public void setSchedulerrule(String schedulerrule) {
this.schedulerrule = schedulerrule == null ? null : schedulerrule.trim();
}
public String getFrozenstatus() {
return frozenstatus;
}
public void setFrozenstatus(String frozenstatus) {
this.frozenstatus = frozenstatus == null ? null : frozenstatus.trim();
}
public String getExecutorno() {
return executorno;
}
public void setExecutorno(String executorno) {
this.executorno = executorno == null ? null : executorno.trim();
}
public Long getFrozentime() {
return frozentime;
}
public void setFrozentime(Long frozentime) {
this.frozentime = frozentime;
}
public Long getUnfrozentime() {
return unfrozentime;
}
public void setUnfrozentime(Long unfrozentime) {
this.unfrozentime = unfrozentime;
}
public Long getCreatetime() {
return createtime;
}
public void setCreatetime(Long createtime) {
this.createtime = createtime;
}
public Long getLastmodifytime() {
return lastmodifytime;
}
public void setLastmodifytime(Long lastmodifytime) {
this.lastmodifytime = lastmodifytime;
}
public String getSendtype() {
return sendtype;
}
public void setSendtype(String sendtype) {
this.sendtype = sendtype == null ? null : sendtype.trim();
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url == null ? null : url.trim();
}
public String getExecuteparamter() {
return executeparamter;
}
public void setExecuteparamter(String executeparamter) {
this.executeparamter = executeparamter == null ? null : executeparamter.trim();
}
public String getTimekey() {
return timekey;
}
public void setTimekey(String timekey) {
this.timekey = timekey == null ? null : timekey.trim();
}
}
package com.cx.cn.cxquartz.bean;
public class QuartzTaskRecords {
private Long id;
private String taskno;
private String timekeyvalue;
private Long executetime;
private String taskstatus;
private Integer failcount;
private String failreason;
private Long createtime;
private Long lastmodifytime;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTaskno() {
return taskno;
}
public void setTaskno(String taskno) {
this.taskno = taskno == null ? null : taskno.trim();
}
public String getTimekeyvalue() {
return timekeyvalue;
}
public void setTimekeyvalue(String timekeyvalue) {
this.timekeyvalue = timekeyvalue == null ? null : timekeyvalue.trim();
}
public Long getExecutetime() {
return executetime;
}
public void setExecutetime(Long executetime) {
this.executetime = executetime;
}
public String getTaskstatus() {
return taskstatus;
}
public void setTaskstatus(String taskstatus) {
this.taskstatus = taskstatus == null ? null : taskstatus.trim();
}
public Integer getFailcount() {
return failcount;
}
public void setFailcount(Integer failcount) {
this.failcount = failcount;
}
public String getFailreason() {
return failreason;
}
public void setFailreason(String failreason) {
this.failreason = failreason == null ? null : failreason.trim();
}
public Long getCreatetime() {
return createtime;
}
public void setCreatetime(Long createtime) {
this.createtime = createtime;
}
public Long getLastmodifytime() {
return lastmodifytime;
}
public void setLastmodifytime(Long lastmodifytime) {
this.lastmodifytime = lastmodifytime;
}
}
package com.cx.cn.cxquartz.bean;
public class User {
String id;
String loginName;
String loginCode;
String area1;
String areaName;
String organCode;
String organName;
String types;
String tatus;
String addTime;
String token;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLoginName() {
return loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
public String getLoginCode() {
return loginCode;
}
public void setLoginCode(String loginCode) {
this.loginCode = loginCode;
}
public String getArea1() {
return area1;
}
public void setArea1(String area1) {
this.area1 = area1;
}
public String getAreaName() {
return areaName;
}
public void setAreaName(String areaName) {
this.areaName = areaName;
}
public String getOrganCode() {
return organCode;
}
public void setOrganCode(String organCode) {
this.organCode = organCode;
}
public String getOrganName() {
return organName;
}
public void setOrganName(String organName) {
this.organName = organName;
}
public String getTypes() {
return types;
}
public void setTypes(String types) {
this.types = types;
}
public String getTatus() {
return tatus;
}
public void setTatus(String tatus) {
this.tatus = tatus;
}
public String getAddTime() {
return addTime;
}
public void setAddTime(String addTime) {
this.addTime = addTime;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
}
package com.cx.cn.cxquartz.config;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.*;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
// @Configuration
@EnableCaching //开启注解
public class RedisConfig extends CachingConfigurerSupport {
/**
* retemplate相关配置
*
* @param factory
* @return
*/
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
// 配置连接工厂
template.setConnectionFactory(factory);
//使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值(默认使用JDK的序列化方式)
Jackson2JsonRedisSerializer jacksonSeial = new Jackson2JsonRedisSerializer(Object.class);
ObjectMapper om = new ObjectMapper();
// 指定要序列化的域,field,get和set,以及修饰符范围,ANY是都有包括private和public
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// 指定序列化输入的类型,类必须是非final修饰的,final修饰的类,比如String,Integer等会跑出异常
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jacksonSeial.setObjectMapper(om);
// 值采用json序列化
template.setValueSerializer(jacksonSeial);
//使用StringRedisSerializer来序列化和反序列化redis的key值
template.setKeySerializer(new StringRedisSerializer());
// 设置hash key 和value序列化模式
template.setHashKeySerializer(new StringRedisSerializer());
template.setHashValueSerializer(jacksonSeial);
template.afterPropertiesSet();
return template;
}
/**
* 对hash类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForHash();
}
/**
* 对redis字符串类型数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public ValueOperations<String, Object> valueOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForValue();
}
@Bean
public JedisConnectionFactory redisConnectionFactory() {
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
jedisConnectionFactory.setHostName("<server-hostname-here>");
jedisConnectionFactory.setPort(6379);
jedisConnectionFactory.setPassword("<server-password-here>");
jedisConnectionFactory.afterPropertiesSet();
return jedisConnectionFactory;
}
/**
* 对链表类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForList();
}
/**
* 对无序集合类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForSet();
}
/**
* 对有序集合类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForZSet();
}
}
package com.cx.cn.cxquartz.config;
import com.cx.cn.cxquartz.job.WebSocket;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
@Configuration
public class WebSocketConfig {
/**
* ServerEndpointExporter 作用
*
* 这个Bean会自动注册使用@ServerEndpoint注解声明的websocket endpoint
*
* @return
*/
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
}
\ No newline at end of file
This diff is collapsed.
package com.cx.cn.cxquartz.controller;
import com.alibaba.fastjson.JSONObject;
import com.cx.cn.cxquartz.bean.QuartzTaskErrors;
import com.cx.cn.cxquartz.bean.QuartzTaskInformations;
import com.cx.cn.cxquartz.service.quartz.QuartzService;
import com.cx.cn.cxquartz.util.ResultEnum;
import com.cx.cn.cxquartz.util.ResultUtil;
import com.cx.cn.cxquartz.vo.QuartzTaskRecordsVo;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/quartz")
public class QuartzController {
private static final Logger logger = LoggerFactory.getLogger(QuartzController.class);
@Autowired
private QuartzService quartzService;
@Value("${file.getrtspbyurl}")
private String getrtspbyurl;
@Value("${file.rtspurl}")
private String rtspurl;
@Autowired
private RestTemplate restTemplate;
@RequestMapping(value = "/add/taskpage", method = RequestMethod.GET)
public String addTaskpage() {
return "addtask";
}
@ResponseBody
@RequestMapping(value = "/add/task", method = RequestMethod.POST)
public String addTask(QuartzTaskInformations taskInformations) {
try {
String result = quartzService.addTask(taskInformations);
return result;
} catch (Exception e) {
logger.error("/add/task exception={}", e);
return ResultUtil.fail();
}
}
@RequestMapping(value = "/edit/taskpage", method = RequestMethod.GET)
public String editTaskpage(Model model, String id) {
QuartzTaskInformations taskInformation = quartzService.getTaskById(id);
model.addAttribute("taskInformation", taskInformation);
return "updatetask";
}
@ResponseBody
@RequestMapping(value = "/edit/task", method = RequestMethod.POST)
public String editTask(QuartzTaskInformations taskInformations) {
try {
String result = quartzService.updateTask(taskInformations);
return result;
} catch (Exception e) {
logger.error("/edit/task exception={}", e);
return ResultUtil.fail();
}
}
/**
* 启动 或者 暂定定时任务
*
* @param taskNo
* @return
*/
@ResponseBody
@RequestMapping(value = "/list/optionjob", method = RequestMethod.GET)
public String optionJob(String taskNo) {
logger.info("");
if (StringUtils.isEmpty(taskNo)) {
return ResultUtil.success(ResultEnum.PARAM_EMPTY.getCode(), ResultEnum.PARAM_EMPTY.getMessage());
}
try {
return quartzService.startJob(taskNo);
} catch (Exception e) {
logger.error("/list/optionjob exception={}", e);
return ResultUtil.fail();
}
}
/**
* 定时任务执行情况
*
* @param taskNo
* @param model
* @return
*/
@RequestMapping(value = "/taskrecords", method = RequestMethod.GET)
public String taskRecordsPage(@RequestParam(value = "taskno", required = false) String taskNo, Model model) {
logger.info("");
try {
if (StringUtils.isEmpty(taskNo)) {
return "redirect:/";
}
List<QuartzTaskRecordsVo> quartzTaskRecords = quartzService.taskRecords(taskNo);
model.addAttribute("quartzTaskRecords", quartzTaskRecords);
} catch (Exception e) {
logger.error("");
return "redirect:/";
}
return "taskrecords";
}
/**
* 立即运行一次定时任务
*
* @param taskNo
* @param model
* @return
*/
@ResponseBody
@RequestMapping(value = "/runtask/rightnow", method = RequestMethod.GET)
public String runTaskRightNow(@RequestParam(value = "taskno", required = false) String taskNo, Model model) {
logger.info("");
try {
if (StringUtils.isEmpty(taskNo)) {
return ResultUtil.success(ResultEnum.PARAM_EMPTY.getCode(), ResultEnum.PARAM_EMPTY.getMessage());
}
return quartzService.runTaskRightNow(taskNo);
} catch (Exception e) {
logger.error("");
return ResultUtil.success(ResultEnum.FAIL.getCode(), ResultEnum.FAIL.getMessage());
}
}
/**
* 定时任务失败详情
*
* @param recordId
* @param model
* @return
*/
@RequestMapping(value = "/task/errors", method = RequestMethod.GET)
public String detailTaskErrors(@RequestParam(value = "recordid", required = false) String recordId, Model model) {
logger.info("");
try {
if (StringUtils.isEmpty(recordId)) {
return ResultUtil.success(ResultEnum.PARAM_EMPTY.getCode(), ResultEnum.PARAM_EMPTY.getMessage());
}
QuartzTaskErrors taskErrors = quartzService.detailTaskErrors(recordId);
model.addAttribute("taskErrors", taskErrors);
return "taskerrors";
} catch (Exception e) {
logger.error("");
return "redirect:/";
}
}
@RequestMapping(value = "/getRtsp/{devicecode}", method = RequestMethod.GET)
@ResponseBody
public String getRTSP(@PathVariable("devicecode") String devicecode) {
//判断rtsp 是否过期http://212.129.142.17:8281/gh/device/test?deviceCode=3YSCA44445TFCPX
Map<String, String> map = new HashMap<>();
map.put("deviceCode", devicecode);
ResponseEntity<String> responseEntity = restTemplate.getForEntity("http://212.129.142.17:8281/gh/device/test?deviceCode={deviceCode}", String.class, map);
// ResponseEntity<String> exchange = restTemplate.exchange(getrtspbyurl + "?deviceCode={deviceCode}",
// HttpMethod.GET, null, String.class, map);
JSONObject json = JSONObject.parseObject(responseEntity.getBody());
if (null != json.getString("code") && json.getString("code").equals("0")) {
//返回rtsp 地址
//获得抽帧图片
Map maps = new HashMap<>();
maps.put("rtspvalue",String.valueOf( json.get("obj")));
maps.put("refresh",1);
ResponseEntity<String> result = restTemplate.exchange(rtspurl + "?url={rtspvalue}&refresh={refresh}",
HttpMethod.GET, null, String.class, maps);
JSONObject jsonresult = JSONObject.parseObject(result.getBody());
if (null != jsonresult.getString("ret") && jsonresult.getString("ret").equals("0")) {
//获得图片地址
return ResultUtil.success( ResultEnum.SUCCESS.getCode(),jsonresult.getString("url")+","+json.get("obj"));
}
} else {
logger.info("未获取到监控rtsp");
}
logger.error("rtsp 不存在-->");
return ResultUtil.fail();
}
}
package com.cx.cn.cxquartz.controller;
import com.cx.cn.cxquartz.bean.QuartzTaskErrors;
import com.cx.cn.cxquartz.bean.QuartzTaskInformations;
import com.cx.cn.cxquartz.service.quartz.QuartzService;
import com.cx.cn.cxquartz.service.quartz.QuartzTaskRecordsService;
import com.cx.cn.cxquartz.util.ResultEnum;
import com.cx.cn.cxquartz.util.ResultUtil;
import com.cx.cn.cxquartz.vo.QuartzTaskRecordsVo;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@Controller
@RequestMapping("/video")
public class SbtdspsrController {
private static final Logger logger = LoggerFactory.getLogger(SbtdspsrController.class);
@Autowired
private QuartzService quartzService;
@RequestMapping(value = "/getSbtdspsrbyrtsp", method = RequestMethod.GET)
public String addTaskpage() {
return "addtask";
}
@ResponseBody
@RequestMapping(value = "/add/task", method = RequestMethod.POST)
public String addTask(QuartzTaskInformations taskInformations) {
try {
String result = quartzService.addTask(taskInformations);
//任务添加到任务中
quartzService.addTask(taskInformations);
return result;
} catch (Exception e) {
logger.error("/add/task exception={}", e);
return ResultUtil.fail();
}
}
@RequestMapping(value = "/edit/taskpage", method = RequestMethod.GET)
public String editTaskpage(Model model, String id) {
QuartzTaskInformations taskInformation = quartzService.getTaskById(id);
model.addAttribute("taskInformation", taskInformation);
return "updatetask";
}
@ResponseBody
@RequestMapping(value = "/edit/task", method = RequestMethod.POST)
public String editTask(QuartzTaskInformations taskInformations) {
try {
QuartzTaskInformations resultTaskInformations= quartzService.getTaskById(taskInformations.getTaskno());
String result = quartzService.updateTask(taskInformations);
//判断corn 是否改变,改变重新生成任务
if(!resultTaskInformations.getSchedulerrule().equals(taskInformations.getSchedulerrule())) {
//重新启动,重新发布新的任务
quartzService.startJob(taskInformations.getTaskno());
}
return result;
} catch (Exception e) {
logger.error("/edit/task exception={}", e);
return ResultUtil.fail();
}
}
/**
* 启动 或者 暂定定时任务
*
* @param taskNo
* @return
*/
@ResponseBody
@RequestMapping(value = "/list/optionjob", method = RequestMethod.GET)
public String optionJob(String taskNo) {
logger.info("");
if (StringUtils.isEmpty(taskNo)) {
return ResultUtil.success(ResultEnum.PARAM_EMPTY.getCode(), ResultEnum.PARAM_EMPTY.getMessage());
}
try {
return quartzService.startJob(taskNo);
} catch (Exception e) {
logger.error("/list/optionjob exception={}", e);
return ResultUtil.fail();
}
}
/**
* 定时任务执行情况
*
* @param taskNo
* @param model
* @return
*/
@RequestMapping(value = "/taskrecords", method = RequestMethod.GET)
public String taskRecordsPage(@RequestParam(value = "taskno", required = false) String taskNo, Model model) {
logger.info("");
try {
if (StringUtils.isEmpty(taskNo)) {
return "redirect:/";
}
List<QuartzTaskRecordsVo> quartzTaskRecords = quartzService.taskRecords(taskNo);
model.addAttribute("quartzTaskRecords", quartzTaskRecords);
} catch (Exception e) {
logger.error("");
return "redirect:/";
}
return "taskrecords";
}
/**
* 立即运行一次定时任务
*
* @param taskNo
* @param model
* @return
*/
@ResponseBody
@RequestMapping(value = "/runtask/rightnow", method = RequestMethod.GET)
public String runTaskRightNow(@RequestParam(value = "taskno", required = false) String taskNo, Model model) {
logger.info("");
try {
if (StringUtils.isEmpty(taskNo)) {
return ResultUtil.success(ResultEnum.PARAM_EMPTY.getCode(), ResultEnum.PARAM_EMPTY.getMessage());
}
return quartzService.runTaskRightNow(taskNo);
} catch (Exception e) {
logger.error("");
return ResultUtil.success(ResultEnum.FAIL.getCode(), ResultEnum.FAIL.getMessage());
}
}
/**
* 定时任务失败详情
*
* @param recordId
* @param model
* @return
*/
@RequestMapping(value = "/task/errors", method = RequestMethod.GET)
public String detailTaskErrors(@RequestParam(value = "recordid", required = false) String recordId, Model model) {
logger.info("");
try {
if (StringUtils.isEmpty(recordId)) {
return ResultUtil.success(ResultEnum.PARAM_EMPTY.getCode(), ResultEnum.PARAM_EMPTY.getMessage());
}
QuartzTaskErrors taskErrors = quartzService.detailTaskErrors(recordId);
model.addAttribute("taskErrors", taskErrors);
return "taskerrors";
} catch (Exception e) {
logger.error("");
return "redirect:/";
}
}
}
package com.cx.cn.cxquartz.dao;
import com.cx.cn.cxquartz.vo.Face;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author wjj
* @since 2021-04-29
*/
@Mapper
public interface FaceMapper {
int insertFace(Face face);
}
package com.cx.cn.cxquartz.dao;
import com.cx.cn.cxquartz.vo.Pedestrian;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author wjj
* @since 2021-04-29
*/
@Mapper
public interface PedestrianMapper {
int insertpedestrian(Pedestrian pedestrian);
}
package com.cx.cn.cxquartz.dao;
import com.cx.cn.cxquartz.vo.PeopleRideBicyc;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author wjj
* @since 2021-04-29
*/
@Mapper
public interface PeopleridebicycMapper {
int insertPeopleRideBicyc( PeopleRideBicyc peopleridebicyc);
}
package com.cx.cn.cxquartz.dao;
import com.cx.cn.cxquartz.bean.QuartzTaskErrors;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface QuartzTaskErrorsMapper {
int deleteByPrimaryKey(Long id);
int insert(QuartzTaskErrors record);
int insertSelective(QuartzTaskErrors record);
QuartzTaskErrors selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(QuartzTaskErrors record);
int updateByPrimaryKeyWithBLOBs(QuartzTaskErrors record);
int updateByPrimaryKey(QuartzTaskErrors record);
QuartzTaskErrors detailTaskErrors(String recordId);
}
package com.cx.cn.cxquartz.dao;
import com.cx.cn.cxquartz.bean.PatrolCtrlAlarm;
import com.cx.cn.cxquartz.bean.PatrolCtrlRecord;
import com.cx.cn.cxquartz.bean.PictureTime;
import com.cx.cn.cxquartz.bean.QuartzTaskInformations;
import com.cx.cn.cxquartz.vo.Sbtdspsr;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
@Mapper
public interface QuartzTaskInformationsMapper {
int deleteByPrimaryKey(Long id);
int insert(QuartzTaskInformations record);
int insertSelective(QuartzTaskInformations record);
QuartzTaskInformations selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(QuartzTaskInformations record);
int updateByPrimaryKey(QuartzTaskInformations record);
List<QuartzTaskInformations> selectList(Map<String, Object> map);
Integer selectByTaskNo(String taskNo);
QuartzTaskInformations getTaskByTaskNo(String taskNo);
List<QuartzTaskInformations> getUnfrozenTasks(String status);
int insertRecord(PatrolCtrlRecord record);
int insertAlarm(PatrolCtrlAlarm alarm);
List<PictureTime> findLastPicTime();
List< PatrolCtrlRecord> queryCameraCode(List<String> ids);
List<Sbtdspsr> selectByRtsp(String rtsp);
}
package com.cx.cn.cxquartz.dao;
import com.cx.cn.cxquartz.bean.QuartzTaskRecords;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface QuartzTaskRecordsMapper {
int deleteByPrimaryKey(Long id);
long insert(QuartzTaskRecords record);
int insertSelective(QuartzTaskRecords record);
QuartzTaskRecords selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(QuartzTaskRecords record);
int updateByPrimaryKey(QuartzTaskRecords record);
List<QuartzTaskRecords> getTaskRecordsByTaskNo(String taskNo);
}
package com.cx.cn.cxquartz.dao;
import com.cx.cn.cxquartz.vo.Sbtdspsr;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@Mapper
public interface SbtdspsrMapper {
List<Sbtdspsr> selectByRtsp( String rtsp);
List<Map> selectRecogByRtsp(String rtsp);
}
package com.cx.cn.cxquartz.dao;
import com.cx.cn.cxquartz.vo.Storageserver;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface StorageServerMapper {
List<Storageserver> queryStorageServerAll(Storageserver storageServer);
}
\ No newline at end of file
package com.cx.cn.cxquartz.dao;
import com.cx.cn.cxquartz.vo.TraffAlarmRecord;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import java.util.List;
import java.util.Map;
@Mapper
public interface TraffAlarmRecordMapper {
int inserTraffAlarmRecord(TraffAlarmRecord traffalarmrecord);
int selectmax();
int updateTraffAlarmRecordUrl(TraffAlarmRecord traffalarmrecord);
List<TraffAlarmRecord> getTraffAlarmRecordByProgress(Map<String, Object> map);
int updateTraffAlarmRecordProcess(TraffAlarmRecord traffalarmrecord);
}
\ No newline at end of file
package com.cx.cn.cxquartz.dao;
import com.cx.cn.cxquartz.vo.TraffpictureParam;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface TraffPictureMapper {
int inserTraffpicture(TraffpictureParam traffalarmrecord);
int updateTraffpicture(TraffpictureParam traffalarmrecord);
String queryimgpath(TraffpictureParam traffpicture);
}
\ No newline at end of file
package com.cx.cn.cxquartz.dao;
import com.cx.cn.cxquartz.vo.Traffic;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author wjj
* @since 2021-04-29
*/@Mapper
public interface TrafficMapper {
int insertTraffic(Traffic traffic);
}
package com.cx.cn.cxquartz.job;
import com.cx.cn.cxquartz.bean.QuartzTaskInformations;
import com.cx.cn.cxquartz.service.quartz.QuartzService;
import com.cx.cn.cxquartz.util.CommonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.concurrent.atomic.AtomicInteger;
@Component
public class KafkaListener {
@Autowired
private QuartzService quartzService;
private static final Logger logger = LoggerFactory.getLogger(KafkaListener.class);
private AtomicInteger atomicInteger;
public void messageConsumerHandler(String content) {
logger.info("监听到消息:{}", content);
atomicInteger = new AtomicInteger(0);
String id = "";
String taskNo = "";
try {
// message格式 ---------> taskNo:id:executeParameter;
String[] split = ":".split(content);
id = split[1];
taskNo = split[0];
//TODO kafka逻辑
} catch (Exception ex) {
logger.error("");
atomicInteger.incrementAndGet();
quartzService.addTaskErrorRecord(id, taskNo + ":" + ex.getMessage(), CommonUtil.getExceptionDetail(ex));
}
quartzService.updateRecordById(atomicInteger.get(), Long.parseLong(id));
QuartzTaskInformations quartzTaskInformation = new QuartzTaskInformations();
quartzTaskInformation.setId(Long.parseLong(id));
quartzTaskInformation.setLastmodifytime(System.currentTimeMillis());
quartzService.updateTask(quartzTaskInformation);
}
}
package com.cx.cn.cxquartz.job;
import com.cx.cn.cxquartz.bean.QuartzTaskInformations;
import com.cx.cn.cxquartz.bean.QuartzTaskRecords;
import com.cx.cn.cxquartz.service.quartz.QuartzService;
import com.cx.cn.cxquartz.service.quartz.impl.QuartzServiceImpl;
import com.cx.cn.cxquartz.util.ApplicationContextHolder;
import com.cx.cn.cxquartz.util.CommonUtil;
import com.cx.cn.cxquartz.util.HttpClientUtil;
import com.cx.cn.cxquartz.util.ResultEnum;
import org.apache.commons.lang.StringUtils;
import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.atomic.AtomicInteger;
@DisallowConcurrentExecution
public class QuartzMainJobFactory implements Job {
private static Logger logger = LoggerFactory.getLogger(QuartzMainJobFactory.class);
private AtomicInteger atomicInteger;
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
atomicInteger = new AtomicInteger(0);
JobDataMap jobDataMap = jobExecutionContext.getMergedJobDataMap();
String id = jobDataMap.getString("id");
String taskNo = jobDataMap.getString("taskNo");
String executorNo = jobDataMap.getString("executorNo");
String sendType = jobDataMap.getString("sendType");
String url = jobDataMap.getString("url");
String executeParameter = jobDataMap.getString("executeParameter");
logger.info("定时任务被执行:taskNo={},executorNo={},sendType={},url={},executeParameter={}", taskNo, executorNo, sendType, url, executeParameter);
QuartzService quartzService = (QuartzServiceImpl) ApplicationContextHolder.getBean("quartzServiceImpl");
QuartzTaskRecords records = null;
try {
//保存定时任务的执行记录
records = quartzService.addTaskRecords(taskNo);
if (null == records || !ResultEnum.INIT.name().equals(records.getTaskstatus())) {
logger.info("taskNo={}保存执行记录失败", taskNo);
return;
}
if (ResultEnum.HTTP.getMessage().equals(sendType)) {
try {
String result = HttpClientUtil.doPost(url, "text/json", executeParameter);
logger.info("taskNo={},sendtype={}执行结果result{}", taskNo, sendType, result);
if (StringUtils.isEmpty(result)) {
throw new RuntimeException("taskNo=" + taskNo + "http方式返回null");
}
} catch (Exception ex) {
logger.error("");
throw ex;
}
} else if (ResultEnum.KAFKA.getMessage().equals(sendType)) {
try {
String message = new StringBuffer(taskNo).append(":").append(id).append(":").append(executeParameter).toString();
quartzService.sendMessage(message);
logger.info("taskNo={},sendtype={}推送至kafka成功", taskNo, sendType);
} catch (Exception ex) {
logger.error("");
throw ex;
}
}
} catch (Exception ex) {
logger.error("");
atomicInteger.incrementAndGet();
quartzService.addTaskErrorRecord(records.getId().toString(), taskNo + ":" + ex.getMessage(), CommonUtil.getExceptionDetail(ex));
}
quartzService.updateRecordById(atomicInteger.get(), records.getId());
QuartzTaskInformations quartzTaskInformation = new QuartzTaskInformations();
quartzTaskInformation.setId(Long.parseLong(id));
quartzTaskInformation.setLastmodifytime(System.currentTimeMillis());
quartzService.updateTask(quartzTaskInformation);
}
}
package com.cx.cn.cxquartz.job;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@Component
@ServerEndpoint("/websocket/{name}")
public class WebSocket {
/**
* 与某个客户端的连接对话,需要通过它来给客户端发送消息
*/
private Session session;
/**
* 标识当前连接客户端的用户名
*/
private String name;
/**
* 用于存所有的连接服务的客户端,这个对象存储是安全的
*/
private static ConcurrentHashMap<String, WebSocket> webSocketSet = new ConcurrentHashMap<>();
@OnOpen
public void OnOpen(Session session, @PathParam(value = "name") String name) {
this.session = session;
this.name = name;
// name是用来表示唯一客户端,如果需要指定发送,需要指定发送通过name来区分
webSocketSet.put(name, this);
}
@OnClose
public void OnClose() {
webSocketSet.remove(this.name);
}
@OnError
public void OnError(@PathParam("name") String name, Throwable throwable, Session session) {
webSocketSet.remove(name);
}
@OnMessage
public void OnMessage(String message) {
//判断是否需要指定发送,具体规则自定义
if(message.indexOf("HEARTBEAT")>=0){
Map map=new HashMap();
map.put("type","HEARTBEAT");
map.put("ts",new Date().getTime());
AppointSending(name, JSONObject.toJSONString(map));
}
}
/**
* 群发
*
* @param message
*/
public static void GroupSending(String message) {
for (String name : webSocketSet.keySet()) {
try {
if (null != webSocketSet.get(name) && null != webSocketSet.get(name).session && null != webSocketSet.get(name).session.getBasicRemote())
webSocketSet.get(name).session.getBasicRemote().sendText(message);
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 指定发送
*
* @param name
* @param message
*/
public void AppointSending(String name, String message) {
if (null != webSocketSet.get(name) && null != webSocketSet.get(name).session && null != webSocketSet.get(name).session.getBasicRemote()) {
synchronized (webSocketSet.get(name).session) {
try {
webSocketSet.get(name).session.getBasicRemote().sendText(message);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
package com.cx.cn.cxquartz.service.quartz;
import com.cx.cn.cxquartz.dao.StorageServerMapper;
import com.cx.cn.cxquartz.vo.Storageserver;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Service
public class CacheLoadService {
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Value("${redis.cachekey.ftplist}")
private String ftplistkey;
@Autowired
private StorageServerMapper storageServerMapper;
public boolean loadFtpCache() {
try {
Storageserver server = new Storageserver();
server.setServerstatus(0);//�����õ�
server.setServertype("ftp");
List<Storageserver> storageServers = storageServerMapper.queryStorageServerAll(server);
if (!storageServers.isEmpty() && storageServers.size() > 0) {
stringRedisTemplate.opsForValue().set(ftplistkey, new Gson().toJson(storageServers),60, TimeUnit.SECONDS);
} else {
System.out.println("storageServers.isEmpty");
}
return true;
} catch (Exception e) {
System.out.println(e.toString());
return false;
}
}
}
package com.cx.cn.cxquartz.service.quartz;
import com.cx.cn.cxquartz.bean.PatrolCtrlAlarm;
import com.cx.cn.cxquartz.bean.PatrolCtrlRecord;
import com.cx.cn.cxquartz.bean.*;
public interface ExtService {
int insertRecord(PatrolCtrlRecord record);
int insertAlarm(PatrolCtrlAlarm alarm);
}
package com.cx.cn.cxquartz.service.quartz;
import com.cx.cn.cxquartz.vo.Face;
/**
* <p>
* 服务类
* </p>
*
* @author wjj
* @since 2021-04-29
*/
public interface FaceService {
int insertFace(Face face);
}
package com.cx.cn.cxquartz.service.quartz;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.cx.cn.cxquartz.controller.IndexController;
import com.cx.cn.cxquartz.util.RedisEnum;
import com.cx.cn.cxquartz.vo.Ftp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* ftpַȡ߷
* @author cp
*/
@Service
public class FtpService {
private static final Logger log = LoggerFactory.getLogger(FtpService.class);
@Autowired
private StringRedisTemplate stringRedisTemplate;
private List<Ftp> ftpList;
@Autowired
CacheLoadService cacheLoadService;
@Autowired
public FtpService(StringRedisTemplate stringRedisTemplate) {
try {
this.ftpList = getFtpList(stringRedisTemplate.opsForValue().get(RedisEnum.FTPLIST.getValue()));
}catch (Exception e){
log.error("ftpListȡʧ:"+e.toString());
}
}
public Ftp reloadFtp() {
try {
cacheLoadService.loadFtpCache();
if(null==stringRedisTemplate.opsForValue().get(RedisEnum.FTPLIST.getValue())){
cacheLoadService.loadFtpCache();
}
ftpList = getFtpList(stringRedisTemplate.opsForValue().get(RedisEnum.FTPLIST.getValue()));
}catch (Exception e){
log.error("ftpListȡʧ:"+e.toString());
}
Long count = null;
try {
count = stringRedisTemplate.opsForValue().increment(RedisEnum.FTPLIST_INDEX.getValue(), 1L);
} catch (Exception e) {
log.error("ȡredis FtpIndex쳣" + e.toString());
}
if (count == null) {
count = 0L;
}
long index = count % ftpList.size();
return ftpList.get((int) index);
}
private List<Ftp> getFtpList(String ftpJson) {
JSONArray jsonArr = JSONObject.parseArray(ftpJson);
List<Ftp> ftpList = new ArrayList<>();
for (int i = 0; i < jsonArr.size(); i++) {
Ftp ftp = new Ftp();
JSONObject jsonObject = jsonArr.getJSONObject(i);
ftp.setFtpIp(jsonObject.getString("serveip"));
ftp.setFtpPort(jsonObject.getInteger("serverport"));
ftp.setFtpUsername(jsonObject.getString("serveruser"));
ftp.setFtpPassword(jsonObject.getString("serverpassword"));
ftpList.add(ftp);
}
return ftpList;
}
}
package com.cx.cn.cxquartz.service.quartz;
import com.cx.cn.cxquartz.vo.Pedestrian;
/**
* <p>
* 服务类
* </p>
*
* @author wjj
* @since 2021-04-29
*/
public interface PedestrianService {
int insertpedestrian(Pedestrian pedestrian);
}
package com.cx.cn.cxquartz.service.quartz;
import com.cx.cn.cxquartz.vo.PeopleRideBicyc;
/**
* <p>
* 服务类
* </p>
*
* @author wjj
* @since 2021-04-29
*/
public interface PeopleridebicycService {
int insertPeopleRideBicyc( PeopleRideBicyc peopleridebicyc);
}
package com.cx.cn.cxquartz.service.quartz;
import com.cx.cn.cxquartz.bean.*;
import com.cx.cn.cxquartz.vo.QuartzTaskRecordsVo;
import org.quartz.SchedulerException;
import java.util.List;
public interface QuartzService {
String addTask(QuartzTaskInformations quartzTaskInformations);
List<QuartzTaskInformations> getTaskList(String taskNo, String currentPage);
QuartzTaskInformations getTaskById(String id);
String updateTask(QuartzTaskInformations quartzTaskInformations);
String startJob(String taskNo) throws SchedulerException;
void initLoadOnlineTasks();
void sendMessage(String message);
QuartzTaskRecords addTaskRecords(String taskNo);
Integer updateRecordById(Integer count, Long id);
Integer updateModifyTimeById(QuartzTaskInformations quartzTaskInformations);
Integer addTaskErrorRecord(String id, String errorKey, String errorValue);
List<QuartzTaskRecordsVo> taskRecords(String taskNo);
String runTaskRightNow(String taskNo);
QuartzTaskErrors detailTaskErrors(String recordId);
Integer insertRecord(PatrolCtrlRecord record);
Integer insertAlarm(PatrolCtrlAlarm alarm);
List<PictureTime> findLastPicTime();
List< PatrolCtrlRecord> queryCameraCode(List<String> ids);
}
package com.cx.cn.cxquartz.service.quartz;
import com.cx.cn.cxquartz.bean.QuartzTaskErrors;
public interface QuartzTaskErrorsService {
Integer addTaskErrorRecord(QuartzTaskErrors quartzTaskErrors);
QuartzTaskErrors detailTaskErrors(String recordId);
}
package com.cx.cn.cxquartz.service.quartz;
import com.cx.cn.cxquartz.bean.PatrolCtrlAlarm;
import com.cx.cn.cxquartz.bean.PatrolCtrlRecord;
import com.cx.cn.cxquartz.bean.PictureTime;
import com.cx.cn.cxquartz.bean.QuartzTaskInformations;
import java.util.List;
public interface QuartzTaskInformationsService {
String insert(QuartzTaskInformations quartzTaskInformations);
List<QuartzTaskInformations> selectList(String taskNo, String currentPage);
QuartzTaskInformations getTaskById(String id);
String updateTask(QuartzTaskInformations quartzTaskInformations);
QuartzTaskInformations getTaskByTaskNo(String taskNo);
Integer updateStatusById(QuartzTaskInformations quartzTaskInformations);
List<QuartzTaskInformations> getUnnfrozenTasks(String status);
Integer updateModifyTimeById(QuartzTaskInformations quartzTaskInformations);
Integer insertRecord(PatrolCtrlRecord record);
Integer insertAlarm(PatrolCtrlAlarm alarm);
List<PictureTime> findLastPicTime();
List< PatrolCtrlRecord> queryCameraCode(List<String> ids);
}
package com.cx.cn.cxquartz.service.quartz;
import com.cx.cn.cxquartz.bean.QuartzTaskRecords;
import java.util.List;
public interface QuartzTaskRecordsService {
long addTaskRecords(QuartzTaskRecords quartzTaskRecords);
Integer updateTaskRecords(QuartzTaskRecords quartzTaskRecords);
List<QuartzTaskRecords> listTaskRecordsByTaskNo(String taskNo);
}
package com.cx.cn.cxquartz.service.quartz;
import java.util.List;
import java.util.Map;
public interface SbtdspsrService {
List selectByRtsp( String rtsp);
List<Map> selectRecogByRtsp(String rtsp);
}
package com.cx.cn.cxquartz.service.quartz;
import com.cx.cn.cxquartz.vo.TraffAlarmRecord;
import java.util.List;
import java.util.Map;
public interface TraffAlarmRecordService {
int inserTraffAlarmRecord(TraffAlarmRecord traffalarmrecord);
int selectmax();
int updateTraffAlarmRecordUrl(TraffAlarmRecord record);
int updateTraffAlarmRecordProcess(TraffAlarmRecord recordid);
List<TraffAlarmRecord> getTraffAlarmRecordByProgress(Map<String, Object> map);
}
package com.cx.cn.cxquartz.service.quartz;
import com.cx.cn.cxquartz.vo.TraffpictureParam;
public interface TraffPictureService {
int inserTraffpicture( TraffpictureParam traffpicture);
int updateTraffpicture( TraffpictureParam traffpicture);
String queryimgpath(TraffpictureParam traffpicture);
}
package com.cx.cn.cxquartz.service.quartz;
import com.cx.cn.cxquartz.vo.Traffic;
/**
* <p>
* 服务类
* </p>
*
* @author wjj
* @since 2021-04-29
*/
public interface TrafficService {
int insertTraffic(Traffic traffic);
}
package com.cx.cn.cxquartz.service.quartz.impl;
import com.cx.cn.cxquartz.bean.PatrolCtrlAlarm;
import com.cx.cn.cxquartz.bean.PatrolCtrlRecord;
import com.cx.cn.cxquartz.service.quartz.ExtService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ExtServiceImpl implements ExtService {
private static final Logger logger = LoggerFactory.getLogger(ExtServiceImpl.class);
@Autowired
private ExtService extService;
@Override
public int insertAlarm(PatrolCtrlAlarm alarm) {
int result = extService.insertAlarm(alarm);
return result;
}
/**
* 新增图片
*
* @param record
* @returnString
*/
@Override
public int insertRecord(PatrolCtrlRecord record) {
int result = extService.insertRecord(record);
return result;
}
}
package com.cx.cn.cxquartz.service.quartz.impl;
import com.cx.cn.cxquartz.dao.FaceMapper;
import com.cx.cn.cxquartz.service.quartz.FaceService;
import com.cx.cn.cxquartz.vo.Face;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author wjj
* @since 2021-04-29
*/
@Service
public class FaceServiceImpl implements FaceService {
@Autowired
private FaceMapper faceMapper;
@Override
public int insertFace(Face face) {
return faceMapper.insertFace(face);
}
}
package com.cx.cn.cxquartz.service.quartz.impl;
import com.cx.cn.cxquartz.dao.PedestrianMapper;
import com.cx.cn.cxquartz.service.quartz.PedestrianService;
import com.cx.cn.cxquartz.vo.Pedestrian;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author wjj
* @since 2021-04-29
*/
@Service
public class PedestrianServiceImpl implements PedestrianService {
@Autowired
private PedestrianMapper pedestrianMapper;
@Override
public int insertpedestrian(Pedestrian pedestrian) {
return pedestrianMapper.insertpedestrian(pedestrian);
}
}
package com.cx.cn.cxquartz.service.quartz.impl;
import com.cx.cn.cxquartz.dao.PeopleridebicycMapper;
import com.cx.cn.cxquartz.service.quartz.PeopleridebicycService;
import com.cx.cn.cxquartz.vo.PeopleRideBicyc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author wjj
* @since 2021-04-29
*/
@Service
public class PeopleridebicycServiceImpl implements PeopleridebicycService {
@Autowired
private PeopleridebicycMapper peopleridebicycMapper;
@Override
public int insertPeopleRideBicyc(PeopleRideBicyc peopleridebicyc) {
return peopleridebicycMapper.insertPeopleRideBicyc( peopleridebicyc);
}
}
package com.cx.cn.cxquartz.service.quartz.impl;
import com.cx.cn.cxquartz.bean.QuartzTaskErrors;
import com.cx.cn.cxquartz.dao.QuartzTaskErrorsMapper;
import com.cx.cn.cxquartz.service.quartz.QuartzTaskErrorsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class QuartzTaskErrorsServiceImpl implements QuartzTaskErrorsService {
@Autowired
private QuartzTaskErrorsMapper quartzTaskErrorsMapper;
@Override
public Integer addTaskErrorRecord(QuartzTaskErrors quartzTaskErrors) {
return quartzTaskErrorsMapper.insert(quartzTaskErrors);
}
@Override
public QuartzTaskErrors detailTaskErrors(String recordId) {
return quartzTaskErrorsMapper.detailTaskErrors(recordId);
}
}
package com.cx.cn.cxquartz.service.quartz.impl;
import com.cx.cn.cxquartz.bean.PatrolCtrlAlarm;
import com.cx.cn.cxquartz.bean.PatrolCtrlRecord;
import com.cx.cn.cxquartz.bean.PictureTime;
import com.cx.cn.cxquartz.bean.QuartzTaskInformations;
import com.cx.cn.cxquartz.dao.QuartzTaskInformationsMapper;
import com.cx.cn.cxquartz.service.quartz.QuartzTaskInformationsService;
import com.cx.cn.cxquartz.util.ResultEnum;
import com.cx.cn.cxquartz.util.ResultUtil;
import com.cx.cn.cxquartz.vo.Sbtdspsr;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class QuartzTaskInformationsServiceImpl implements QuartzTaskInformationsService {
@Autowired
private QuartzTaskInformationsMapper quartzTaskInformationsMapper;
@Override
public String insert(QuartzTaskInformations quartzTaskInformations) {
String taskNo = quartzTaskInformations.getTaskno();
quartzTaskInformations.setVersion(0);
quartzTaskInformations.setCreatetime(System.currentTimeMillis());
quartzTaskInformations.setLastmodifytime(System.currentTimeMillis());
Integer count = quartzTaskInformationsMapper.selectByTaskNo(taskNo);
//判断是否重复任务编号
if (count > 0) {
return ResultUtil.success(ResultEnum.TASKNO_EXIST.getCode(), ResultEnum.TASKNO_EXIST.getMessage());
}
int insert = quartzTaskInformationsMapper.insert(quartzTaskInformations);
if (insert < 1) {
return ResultUtil.success(ResultEnum.FAIL.getCode(), ResultEnum.FAIL.getMessage());
}
return ResultUtil.success(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMessage());
}
@Override
public List<QuartzTaskInformations> selectList(String taskNo, String currentPage) {
Map<String, Object> map = new HashMap<>();
Integer start = Integer.parseInt(currentPage);
map.put("taskNo", taskNo);
map.put("startIndex", 10 * (start - 1));
return quartzTaskInformationsMapper.selectList(map);
}
@Override
public QuartzTaskInformations getTaskById(String id) {
return quartzTaskInformationsMapper.selectByPrimaryKey(Long.parseLong(id));
}
@Override
public String updateTask(QuartzTaskInformations quartzTaskInformations) {
Integer count = quartzTaskInformationsMapper.selectByTaskNo(quartzTaskInformations.getTaskno());
//判断是否重复任务编号
if (count >= 2) {
return ResultUtil.success(ResultEnum.TASKNO_EXIST.getCode(), ResultEnum.TASKNO_EXIST.getMessage());
}
//设置解冻时间或冻结时间及最后修改时间
if (ResultEnum.FROZEN.name().equals(quartzTaskInformations.getFrozenstatus())) {
quartzTaskInformations.setFrozentime(System.currentTimeMillis());
} else if (ResultEnum.UNFROZEN.name().equals(quartzTaskInformations.getFrozenstatus())) {
quartzTaskInformations.setUnfrozentime(System.currentTimeMillis());
}
quartzTaskInformations.setLastmodifytime(System.currentTimeMillis());
int updateCount = quartzTaskInformationsMapper.updateByPrimaryKeySelective(quartzTaskInformations);
//乐观锁控制并发修改
if (updateCount < 1) {
return ResultUtil.success(ResultEnum.UPDATE_FAIL.getCode(), ResultEnum.UPDATE_FAIL.getMessage());
}
return ResultUtil.success(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMessage());
}
@Override
public QuartzTaskInformations getTaskByTaskNo(String taskNo) {
return quartzTaskInformationsMapper.getTaskByTaskNo(taskNo);
}
@Override
public Integer updateStatusById(QuartzTaskInformations quartzTaskInformations) {
return quartzTaskInformationsMapper.updateByPrimaryKeySelective(quartzTaskInformations);
}
@Override
public List<QuartzTaskInformations> getUnnfrozenTasks(String status) {
return quartzTaskInformationsMapper.getUnfrozenTasks(status);
}
@Override
public Integer updateModifyTimeById(QuartzTaskInformations quartzTaskInformations) {
return quartzTaskInformationsMapper.updateByPrimaryKeySelective(quartzTaskInformations);
}
@Override
public Integer insertRecord(PatrolCtrlRecord record) {
return quartzTaskInformationsMapper.insertRecord(record);
}
@Override
public Integer insertAlarm(PatrolCtrlAlarm alarm) {
return quartzTaskInformationsMapper.insertAlarm(alarm);
}
@Override
public List<PictureTime> findLastPicTime() {
return quartzTaskInformationsMapper.findLastPicTime();
}
@Override
public List<PatrolCtrlRecord> queryCameraCode(List<String> ids){
return quartzTaskInformationsMapper.queryCameraCode(ids);
}
}
package com.cx.cn.cxquartz.service.quartz.impl;
import com.cx.cn.cxquartz.bean.QuartzTaskRecords;
import com.cx.cn.cxquartz.dao.QuartzTaskRecordsMapper;
import com.cx.cn.cxquartz.service.quartz.QuartzTaskRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class QuartzTaskRecordsServiceImpl implements QuartzTaskRecordsService {
@Autowired
private QuartzTaskRecordsMapper quartzTaskRecordsMapper;
@Override
public long addTaskRecords(QuartzTaskRecords quartzTaskRecords) {
return quartzTaskRecordsMapper.insert(quartzTaskRecords);
}
@Override
public Integer updateTaskRecords(QuartzTaskRecords quartzTaskRecords) {
return quartzTaskRecordsMapper.updateByPrimaryKeySelective(quartzTaskRecords);
}
public List<QuartzTaskRecords> listTaskRecordsByTaskNo(String taskNo) {
return quartzTaskRecordsMapper.getTaskRecordsByTaskNo(taskNo);
}
;
}
package com.cx.cn.cxquartz.service.quartz.impl;
import com.cx.cn.cxquartz.dao.SbtdspsrMapper;
import com.cx.cn.cxquartz.service.quartz.SbtdspsrService;
import com.cx.cn.cxquartz.vo.Sbtdspsr;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public class SbtdspsrImpl implements SbtdspsrService {
@Autowired
private SbtdspsrMapper sbtdspsrMapper;
public List<Sbtdspsr> selectByRtsp(String rtsp)
{
return sbtdspsrMapper.selectByRtsp(rtsp);
}
@Override
public List<Map> selectRecogByRtsp(String rtsp) {
return sbtdspsrMapper.selectRecogByRtsp(rtsp);
}
}
package com.cx.cn.cxquartz.service.quartz.impl;
import com.cx.cn.cxquartz.dao.TraffAlarmRecordMapper;
import com.cx.cn.cxquartz.service.quartz.TraffAlarmRecordService;
import com.cx.cn.cxquartz.vo.TraffAlarmRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public class TraffAlarmRecordImpl implements TraffAlarmRecordService {
@Autowired
private TraffAlarmRecordMapper traffAlarmRecordMapper;
public int inserTraffAlarmRecord(TraffAlarmRecord traffalarmrecord){
return traffAlarmRecordMapper.inserTraffAlarmRecord(traffalarmrecord);
}
public int selectmax(){
return traffAlarmRecordMapper.selectmax();
}
public int updateTraffAlarmRecordUrl(TraffAlarmRecord record){
return traffAlarmRecordMapper.updateTraffAlarmRecordUrl(record);
}
public int updateTraffAlarmRecordProcess(TraffAlarmRecord traffalarmrecord){
return traffAlarmRecordMapper.updateTraffAlarmRecordProcess(traffalarmrecord);
}
public List<TraffAlarmRecord> getTraffAlarmRecordByProgress(Map<String, Object> map){
return traffAlarmRecordMapper.getTraffAlarmRecordByProgress( map);
}
}
package com.cx.cn.cxquartz.service.quartz.impl;
import com.cx.cn.cxquartz.dao.TrafficMapper;
import com.cx.cn.cxquartz.service.quartz.TrafficService;
import com.cx.cn.cxquartz.vo.Traffic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author wjj
* @since 2021-04-29
*/
@Service
public class TrafficServiceImpl implements TrafficService {
@Autowired
TrafficMapper trafficMapper;
@Override
public int insertTraffic(Traffic traffic) {
return trafficMapper.insertTraffic(traffic);
}
}
package com.cx.cn.cxquartz.service.quartz.impl;
import com.cx.cn.cxquartz.dao.TraffPictureMapper;
import com.cx.cn.cxquartz.service.quartz.TraffPictureService;
import com.cx.cn.cxquartz.vo.TraffpictureParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author wjj
* @since 2021-04-29
*/
@Service
public class TraffpictureServiceImpl implements TraffPictureService{
@Autowired
private TraffPictureMapper traffPictureMapper;
@Override
public int inserTraffpicture(TraffpictureParam traffpicture) {
return traffPictureMapper.inserTraffpicture(traffpicture);
}
@Override
public int updateTraffpicture(TraffpictureParam traffpicture) {
return traffPictureMapper.updateTraffpicture(traffpicture);
}
@Override
public String queryimgpath(TraffpictureParam traffpicture) {
return traffPictureMapper.queryimgpath(traffpicture);
}
}
package com.cx.cn.cxquartz.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class AdminInterceptor implements HandlerInterceptor {
/**
* 在请求处理之前进行调用(Controller方法调用之前)
*/
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
// System.out.println("执行了TestInterceptor的preHandle方法");
try {
//
// //统一拦截(查询当前session是否存在user)(这里user会在每次登陆成功后,写入session)
// String token = (String) request.getSession().getAttribute("token");
// RestTemplate restTemplate = new RestTemplate();
// HttpHeaders headers = new HttpHeaders();
// headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
// ResponseEntity<String> result = null;
// if (null == token) {
// //登录
//// String jsontoken= dologin(restTemplate,headers);
//// request.getSession().setAttribute("token",jsontoken);
// }
// else{//验证权限
// headers.add("access-token", request.getSession().getAttribute("token").toString());
// ResponseEntity<Map> response_result = restTemplate.exchange(
// "http://www.zjwwzf.cn/xzzfSpv/ext/auth/verify.do",
// HttpMethod.GET,
// new HttpEntity<String>(headers),
// Map.class,
// new HashMap<>());
// Map<Object,Object> bodyresult = response_result.getBody();
// if(null!=bodyresult.get("status") && !String.valueOf(bodyresult.get("status")).equals("0")){
// String jsontoken= dologin(restTemplate,headers);
// request.getSession().setAttribute("token",jsontoken);
// }
// }
} catch (Exception e) {
e.printStackTrace();
}
return true;//如果设置为false时,被请求时,拦截器执行到此处将不会继续操作
//如果设置为true时,请求将会继续执行后面的操作
}
/**
* 请求处理之后进行调用,但是在视图被渲染之前(Controller方法调用之后)
*/
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) {
// System.out.println("执行了TestInterceptor的postHandle方法");
}
/**
* 在整个请求结束之后被调用,也就是在DispatcherServlet 渲染了对应的视图之后执行(主要是用于进行资源清理工作)
*/
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
// System.out.println("执行了TestInterceptor的afterCompletion方法");
}
public String dologin(RestTemplate restTemplate,HttpHeaders headers){
MultiValueMap<String, String> mulmap = new LinkedMultiValueMap<>();
mulmap.add("userName", "guest");
mulmap.add("password", "e10adc3949ba59abbe56e057f20f883e");
HttpEntity<MultiValueMap<String, String>> req = new HttpEntity<>(mulmap, headers);
//执行HTTP请求
ResponseEntity<String> result = restTemplate.exchange("http://www.zjwwzf.cn/xzzfSpv/open/auth/login.do", HttpMethod.POST, req, String.class);
String body = result.getBody();
JSONObject json = JSONObject.parseObject(result.getBody());
JSONObject jsontoken = JSONObject.parseObject(json.get("data").toString());
return String.valueOf(jsontoken.get("token"));
}
}
package com.cx.cn.cxquartz.util;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
* 类描述:获取Spring代理类(上下文)
*/
@Component
public class ApplicationContextHolder implements ApplicationContextAware {
private static ApplicationContext context;
@Override
public void setApplicationContext(ApplicationContext applicationcontext)
throws BeansException {
ApplicationContextHolder.context = applicationcontext;
}
public static Object getBean(String beanName) {
return context.getBean(beanName);
}
}
package com.cx.cn.cxquartz.util;
import com.cx.cn.cxquartz.bean.PictureTime;
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.List;
public class CommonUtil {
/**
* 获取具体的异常信息
*
* @param ex
* @return
*/
public static String getExceptionDetail(Exception ex) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
try {
ex.printStackTrace(pw);
return sw.toString();
} finally {
pw.close();
}
}
public static void removeFinishFiles( List<File> jsonFile, List<PictureTime> picturses)
{
if (picturses.size() > 0) {
//根据每个设备最新的时间进行过滤D:\imp\VideoPic\202009021049435991_0\20200906\112004.jpeg
String filetime = "";
for (int i = 0; i < jsonFile.size(); i++) {
String[] str = jsonFile.get(i).getAbsolutePath().split("\\\\");
for (PictureTime pic : picturses) {
filetime = str[str.length - 2] + str[str.length - 1].replace(".jpeg", "");
if (str[str.length - 3].equals(pic.getDeviceid())
&& pic.getLasttime().compareTo(filetime) != -1) {
jsonFile.remove(i--);
}
}
}
}
}
}
package com.cx.cn.cxquartz.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;
public class DateUtils {
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();
}
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();
}
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();
}
}
This diff is collapsed.
package com.cx.cn.cxquartz.util;
import com.cx.cn.cxquartz.controller.ExtController;
import com.cx.cn.cxquartz.vo.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.misc.BASE64Encoder;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletionService;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.TimeUnit;
public class FileTransferManager {
private static CompletionService<TransferResult> completionService = new ExecutorCompletionService<TransferResult>(ThreadPoolUtil.getPool());
private static CompletionService<PictureResult> threadService = new ExecutorCompletionService<PictureResult>(ThreadPoolUtil.getPool());
private static final Logger log = LoggerFactory.getLogger(ExtController.class);
/**
* @param transferRecord
* @param ftp
* @param basePath
* @return
* @throws Exception
*/
public static List<TransferResult> transferFile(final Map<String, Object> transferRecord, final Ftp ftp, final String basePath) throws Exception {
Integer ret = 0;
final Long recordid = Long.parseLong(transferRecord.get("recordid").toString());
int count = 0;
for (String key : transferRecord.keySet()) {
if (key.equals("img1path") || key.equals("img2path")
|| key.equals("img3path") || key.equals("img4path")
|| key.equals("img5path")) {
final String url = transferRecord.get(key).toString();
count++;
completionService.submit(() -> {
TransferResult result = new TransferResult(recordid, key, url, "", false);
try {
String filesuff = "videopath".equals(key) ? ".mp4" : ".jpg";
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setReadTimeout(2000); //延迟连接
connection.setConnectTimeout(3000);
connection.setRequestMethod("GET");
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
InputStream inputStream = connection.getInputStream();
String pname = DateUtils.formatCurrDayNoSign() + "_" + recordid + "_0000_" + key.replace("path", "");
String fileName = pname + filesuff;
String ftputl = FTPUtil.getFtpUrl(ftp) + basePath + "/" + fileName;
boolean r = FTPUtil.uploadFile(ftp, basePath, fileName, inputStream);
result.setResult(r);
if (r) {
result.setImgpath(ftputl);
}
// log.info("callable thread:" +result.toString());
} else {
log.error("connection code: " + connection.getResponseCode() + " ," + result.toString());
}
} catch (IOException e) {
System.out.println(e.toString());
log.error(e.toString());
}
return result;
});
}
}
List<TransferResult> listret = new ArrayList<>();
for (int i = 0; i < count; i++) {
listret.add(completionService.poll(10, TimeUnit.SECONDS).get());
}
return listret;
}
public static void fetchUrlsFromRecord(TraffAlarmRecord record, Map<String, Object> transferRecord) {
if (record == null || record.getRecordid() == null) {
return;
}
transferRecord.put("recordid", record.getRecordid());
if (record.getImg1path() == null && record.getImg1urlfrom() != null) {
transferRecord.put("img1path", record.getImg1urlfrom());
}
if (record.getImg2path() == null && record.getImg2urlfrom() != null) {
transferRecord.put("img2path", record.getImg2urlfrom());
}
if (record.getImg3path() == null && record.getImg3urlfrom() != null) {
transferRecord.put("img3path", record.getImg3urlfrom());
}
if (record.getImg4path() == null && record.getImg4urlfrom() != null) {
transferRecord.put("img4path", record.getImg4urlfrom());
}
if (record.getImg5path() == null && record.getImg5urlfrom() != null) {
transferRecord.put("img5path", record.getImg5urlfrom());
}
if (record.getVideopath() == null && record.getVideourlfrom() != null) {
transferRecord.put("videopath", record.getVideourlfrom());
}
}
public static TraffAlarmRecord traffAlarmRecordUrlUpdate(List<TransferResult> results) throws Exception {
TraffAlarmRecord record = new TraffAlarmRecord();
for (TransferResult result : results) {
record.setRecordid(result.getRecordid());
if (result.getResult()) {
switch (result.getPathvalue()) {
case "img1path":
record.setImg1path(result.getImgpath());
break;
case "img2path":
record.setImg2path(result.getImgpath());
break;
case "img3path":
record.setImg3path(result.getImgpath());
break;
case "img4path":
record.setImg4path(result.getImgpath());
break;
case "img5path":
record.setImg5path(result.getImgpath());
break;
case "videopath":
record.setVideopath(result.getImgpath());
break;
default:
break;
}
}
}
return record;
}
public static GoalStructureParam getGoalStructureParam(int count,Long[] roiarray, int model, BASE64Encoder base64Encoder, TraffAlarmRecord transferRecord) {
//获得图片进行分析
GoalStructureParam param = new GoalStructureParam();
param.setOutput(new Output(1, 1, -1, 3));
param.setModel(model);
param.setApiout("1");////打开1400标准输出,默认可以不填
List<ImageList> list = new ArrayList<>();
getImageList("1",roiarray, base64Encoder, list, transferRecord.getImg1path());
getImageList("2", roiarray,base64Encoder, list, transferRecord.getImg2path());
getImageList("3", roiarray,base64Encoder, list, transferRecord.getImg3path());
getImageList("4",roiarray, base64Encoder, list, transferRecord.getImg4path());
getImageList("5", roiarray,base64Encoder, list, transferRecord.getImg5path());
param.setImageList(list);
return param;
}
private static void getImageList(String id,Long[] roiarray, BASE64Encoder base64Encoder, List<ImageList> list, String img1path) {
if (null != img1path && !"".equals(img1path)) {
byte[] Img = FTPUtil.getFtpPicBytes(img1path);
if (Img != null) {
list.add(new ImageList(id,roiarray,20,1,20,100,base64Encoder.encode(Img).replaceAll("\r|\n", "")));
}
}
}
}
package com.cx.cn.cxquartz.util;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HttpClientUtil {
private static Logger log = LoggerFactory.getLogger(HttpClientUtil.class);
private static final String ENCODING = "UTF-8";
private static final int CONNECTION_TIME_OUT = 3000;
private static final int SO_TIME_OUT = 100000;
private static final boolean STALE_CHECK_ENABLED = true;
private static final boolean TCP_NO_DELAY = true;
private static final int DEFAULT_MAX_CONNECTIONS_PER_HOST = 100;
private static final int MAX_TOTAL_CONNECTIONS = 1000;
private static final HttpConnectionManager connectionManager;
public static final HttpClient client;
static {
HttpConnectionManagerParams params = loadHttpConfFromFile();
connectionManager = new MultiThreadedHttpConnectionManager();
connectionManager.setParams(params);
client = new HttpClient(connectionManager);
}
private static HttpConnectionManagerParams loadHttpConfFromFile() {
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setConnectionTimeout(CONNECTION_TIME_OUT);
params.setStaleCheckingEnabled(STALE_CHECK_ENABLED);
params.setTcpNoDelay(TCP_NO_DELAY);
params.setSoTimeout(SO_TIME_OUT);
params.setDefaultMaxConnectionsPerHost(DEFAULT_MAX_CONNECTIONS_PER_HOST);
params.setMaxTotalConnections(MAX_TOTAL_CONNECTIONS);
params.setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(0, false));
return params;
}
/**
* get请求
*
* @param url
* @return
*/
public static String doGet(String url) {
String result = null;
try {
GetMethod getMethod = new GetMethod(url);
client.executeMethod(getMethod);
result = getMethod.getResponseBodyAsString();
} catch (Exception e) {
log.error("httpclient get request url=" + url + ",exception=" + e);
}
return result;
}
public static String doPost(String url, String contentType, String content) throws Exception {
PostMethod method = new PostMethod(url);
method.addRequestHeader("Connection", "Keep-Alive");
method.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(0, false));
try {
method.setRequestEntity(new ByteArrayRequestEntity(content.getBytes(ENCODING)));
method.addRequestHeader("Content-Type", contentType);
int statusCode = client.executeMethod(method);
if (statusCode != HttpStatus.SC_OK) {
return null;
}
byte[] ret = method.getResponseBody();
if (ret == null)
return null;
return new String(ret, ENCODING);
} finally {
method.releaseConnection();
}
}
}
package com.cx.cn.cxquartz.util;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class LoginConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
//注册TestInterceptor拦截器
InterceptorRegistration registration = registry.addInterceptor(new AdminInterceptor());
registration.addPathPatterns("/**"); //所有路径都被拦截
registration.excludePathPatterns( //添加不拦截路径
"/**/*.html", //html静态资源
"/**/*.js", //js静态资源
"/**/*.css", //css静态资源
"/**/*.woff",
"/**/*.ttf"
);
}
}
package com.cx.cn.cxquartz.util;
import java.io.Serializable;
import java.util.List;
public class Page<T> implements Serializable {
private static final long serialVersionUID = 130050641959720183L;
private List<T> list; //数据集合
private int totalRecord; //总记录数
private int currentPage; //当前页
private int pageSize; //每页大小
private int startIndex;
private int totalPage; //总页数
private int previousPage; //前一页
private int nextPage; //下一页
public List<T> getList() {
return list;
}
public void setList(List<T> list) {
this.list = list;
}
public int getTotalRecord() {
return totalRecord;
}
public void setTotalRecord(int totalRecord) {
this.totalRecord = list.size();
}
public int getCurrentPage() {
return currentPage;
}
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = 10;
}
public int getStartIndex() {
return startIndex;
}
public void setStartIndex(int startIndex) {
this.startIndex = pageSize * (currentPage-1);
}
public void setTotalPage(int totalPage) {
if(this.totalRecord % this.pageSize == 0) {
this.totalPage = this.totalRecord / this.pageSize;
}else {
this.totalPage = this.totalRecord / this.pageSize + 1;
}
}
public void setPreviousPage(int previousPage) {
if(this.totalRecord % this.pageSize == 0) {
this.totalPage = this.totalRecord / this.pageSize;
}else {
this.totalPage = this.totalRecord / this.pageSize + 1;
}
}
public void setNextPage(int nextPage) {
if(this.currentPage + 1 > this.totalPage) {
this.nextPage = this.totalPage;
}else {
this.nextPage = this.currentPage + 1;
}
}
public int getTotalPage() {
return totalPage;
}
public int getPreviousPage() {
return previousPage;
}
public int getNextPage() {
return nextPage;
}
@Override
public String toString() {
return "Page{" +
"list=" + list +
", totalRecord=" + totalRecord +
", currentPage=" + currentPage +
", pageSize=" + pageSize +
", startIndex=" + startIndex +
", totalPage=" + totalPage +
", previousPage=" + previousPage +
", nextPage=" + nextPage +
'}';
}
public Page(List<T> list, int totalRecord, int currentPage) {
this.list = list;
this.totalRecord = totalRecord;
this.currentPage = currentPage;
}
}
package com.cx.cn.cxquartz.util;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.List;
public class RecursiveGetJsonData {
private static List<Object> list = new ArrayList<Object>(); //公共的的数据池
private String rootDir;//根目录
private List<File> jsonFileList = new ArrayList<File>();//公共的数据区域 找到的文件数据
public List<File> getJsonFileList() {
return jsonFileList;
}
public void setJsonFileList(List<File> jsonFileList) {
this.jsonFileList = jsonFileList;
}
public RecursiveGetJsonData(String rootDir) {
this.setRootDir(rootDir);
}
public RecursiveGetJsonData() { // 空构造方法
}
/**
* rootDir 根目录
* fileNameEndFlag 问价结尾标识
*
* @param rootDir
*/
public void getDataFromFile(String rootDir, final String fileNameEndFlag) {
File rootFile = new File(rootDir);
FileFilter filter = new FileFilter() { //文件后缀过滤
@Override
public boolean accept(File file) {
String fileName = file.getName();
if (fileName != null && fileName != "" && fileName.endsWith(fileNameEndFlag)) {
return true;
}
return false;
}
};
if (rootFile.isDirectory()) { //如果是目录
File[] listFiles = rootFile.listFiles(filter); // 满足条件的文件装入公共数据区
if (null != listFiles && listFiles.length > 0) {
jsonFileList.addAll(Arrays.asList(listFiles)); //Arrays 将数组转化为List集合
}
File[] list = rootFile.listFiles();
if (null != list && list.length > 0) {
for (int i = 0; i < list.length; i++) {
if (list[i].isDirectory()) {
getDataFromFile(list[i].getAbsolutePath(), fileNameEndFlag); //递归调用方法
}
}
}
}
}
public String ImageToBase64ByLocal(File file) {
InputStream in = null;
byte[] data = null;
// 读取图片字节数组
try {
//获取图片路径
in = new FileInputStream(file.getPath());
data = new byte[in.available()];
in.read(data);
in.close();
} catch (IOException e) {
return null;
}
return Base64.getEncoder().encodeToString(data);
}
public String getRootDir() {
return rootDir;
}
public void setRootDir(String rootDir) {
this.rootDir = rootDir;
}
public static List<Object> getList() {
return list;
}
public static void setList(List<Object> list) {
RecursiveGetJsonData.list = list;
}
}
package com.cx.cn.cxquartz.util;
/**
* 通用序列枚举类
* @author cp
*/
public enum RedisEnum {
/**
* 支队心跳
*/
DETACHMENT_HEART_BEATS("gs:traff:detachment:heartbeats"),
/**
* FTP List
*/
FTPLIST("gs:traff:global:cache:ftplist"),
/**
* ftp index
*/
FTPLIST_INDEX("gs:traff:global:cache:ftplistindex");
private String value;
RedisEnum(String value){
this.value =value;
}
public String getValue() {
return value;
}
}
package com.cx.cn.cxquartz.util;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate(ClientHttpRequestFactory factory){
return new RestTemplate(factory);
}
@Bean
public ClientHttpRequestFactory simpleClientHttpRequestFactory(){
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setConnectTimeout(15000);
factory.setReadTimeout(5000);
return factory;
}
}
package com.cx.cn.cxquartz.util;
public class Result<T> {
private Integer code;
private String message;
private T data;
public Result(ResultEnum resultEnum) {
this.code = resultEnum.getCode();
this.message = resultEnum.getMessage();
}
public Result(ResultEnum resultEnum, T data) {
this.code = resultEnum.getCode();
this.message = resultEnum.getMessage();
this.data = data;
}
public Result(Integer code, String message) {
this.code = code;
this.message = message;
}
public Result(Integer code, String message, T data) {
this.code = code;
this.message = message;
this.data = data;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}
package com.cx.cn.cxquartz.util;
public enum ResultEnum {
SUCCESS(200,"success"),
FAIL(500,"system error"),
INIT(600,"record init"),
TASKNO_EXIST(1001,"该任务编号已经存在"),
PARAM_EMPTY(6001,"parameter is empty"),
FROZEN(10001,"FROZEN"),
UNFROZEN(10002,"UNFROZEN"),
RUN_NOW_FAIL(7001,"立即运行失败"),
HTTP(10003,"http"),
KAFKA(10004,"kafka"),
UPDATE_FAIL(1002,"更新失败"),
NO_DATA(1003,"无此定时任务编号");
private Integer code;
private String message;
public Integer getCode() {
return code;
}
public String getMessage() {
return message;
}
ResultEnum(Integer code, String message) {
this.code = code;
this.message = message;
}
}
package com.cx.cn.cxquartz.util;
import com.google.gson.Gson;
public class ResultUtil<T> {
public static String success() {
Result result = new Result(ResultEnum.SUCCESS);
return new Gson().toJson(result);
}
public static String success(Object obj) {
Result result = new Result(ResultEnum.SUCCESS, obj);
return new Gson().toJson(result);
}
public static String fail() {
Result result = new Result(ResultEnum.FAIL);
return new Gson().toJson(result);
}
public static String success(Integer code, String message) {
Result result = new Result(code, message);
return new Gson().toJson(result);
}
}
package com.cx.cn.cxquartz.util;
import java.util.concurrent.*;
import java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy;
public class ThreadPoolUtil {
private static BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(5000);
private static final ExecutorService pool =new ThreadPoolExecutor(10, 30, 2L, TimeUnit.MINUTES,
queue , Executors.defaultThreadFactory(), new CallerRunsPolicy());
private static final ScheduledExecutorService schedulepool = Executors.newScheduledThreadPool(2);
public static ScheduledExecutorService getSchedulePool() {
return schedulepool;
}
public static ExecutorService getPool() {
return pool;
}
public static int getQueueSize(){
return queue.size();
}
public static void executeSchedule(Runnable thread){
getSchedulePool().execute(thread);
}
public static void execute(Runnable thread){
getPool().execute(thread);
}
}
package com.cx.cn.cxquartz.util;
import com.cx.cn.cxquartz.vo.TraffAlarmRecord;
/**
* TraffAlarmRecord4��������ͼƬXԴ��ַ
* @author cp
*/
public enum TraffAlarmRecordFromImgEnum implements TraffAlarmRecordImg {
/**
* ����ͼƬ���õ�ַ
*/
IMG0 {
@Override
public void setImg(TraffAlarmRecord traffAlarmRecord, String img) {
traffAlarmRecord.setImg1urlfrom(img);
}
},
IMG1 {
@Override
public void setImg(TraffAlarmRecord traffAlarmRecord, String img) {
traffAlarmRecord.setImg2urlfrom(img);
}
},
IMG2 {
@Override
public void setImg(TraffAlarmRecord traffAlarmRecord, String img) {
traffAlarmRecord.setImg3urlfrom(img);
}
},
IMG3 {
@Override
public void setImg(TraffAlarmRecord traffAlarmRecord, String img) {
traffAlarmRecord.setImg4urlfrom(img);
}
},
IMG4 {
@Override
public void setImg(TraffAlarmRecord traffAlarmRecord, String img) {
traffAlarmRecord.setImg5urlfrom(img);
}
}
}
package com.cx.cn.cxquartz.util;
import com.cx.cn.cxquartz.vo.TraffAlarmRecord;
/**
* TraffAlarmRecordͼƬӿ
* @author cp
*/
public interface TraffAlarmRecordImg {
void setImg(TraffAlarmRecord traffAlarmRecord, String img);
}
package com.cx.cn.cxquartz.util;
import java.util.UUID;
public class UUIDUtils {
/**
* UUID
* @return String32λUUID
*/
public static String createuuid() {
return UUID.randomUUID().toString().replaceAll("-", "");
}
}
package com.cx.cn.cxquartz.vo;
import com.fasterxml.jackson.annotation.JsonIgnore;
public class Face {
@JsonIgnore
private Long id;
private String Type;
private FaceBoundingBox FaceBoundingBox;
private HeadBoundingBox HeadBoundingBox;
private String Gender;
private String Age;
private String HasGlasses;
private String HasHat;
private String HasMask;
private String HairStyle;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public void setType(String Type) {
this.Type = Type;
}
public String getType() {
return Type;
}
public void setFaceBoundingBox(FaceBoundingBox FaceBoundingBox) {
this.FaceBoundingBox = FaceBoundingBox;
}
public FaceBoundingBox getFaceBoundingBox() {
return FaceBoundingBox;
}
public void setHeadBoundingBox(HeadBoundingBox HeadBoundingBox) {
this.HeadBoundingBox = HeadBoundingBox;
}
public HeadBoundingBox getHeadBoundingBox() {
return HeadBoundingBox;
}
public void setGender(String Gender) {
this.Gender = Gender;
}
public String getGender() {
return Gender;
}
public void setAge(String Age) {
this.Age = Age;
}
public String getAge() {
return Age;
}
public void setHasGlasses(String HasGlasses) {
this.HasGlasses = HasGlasses;
}
public String getHasGlasses() {
return HasGlasses;
}
public void setHasHat(String HasHat) {
this.HasHat = HasHat;
}
public String getHasHat() {
return HasHat;
}
public void setHasMask(String HasMask) {
this.HasMask = HasMask;
}
public String getHasMask() {
return HasMask;
}
public void setHairStyle(String HairStyle) {
this.HairStyle = HairStyle;
}
public String getHairStyle() {
return HairStyle;
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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