Commit 56a562b4 authored by yzm's avatar yzm

dx界面完善

parent 37a7ec1c
......@@ -136,6 +136,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!--kafka依赖-->
<dependency>
<groupId>org.springframework.kafka</groupId>
......
......@@ -12,6 +12,8 @@ import com.cx.cn.cxquartz.job.WebSocket;
import com.cx.cn.cxquartz.service.quartz.*;
import com.cx.cn.cxquartz.util.*;
import com.cx.cn.cxquartz.vo.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -22,15 +24,17 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import sun.net.www.protocol.ftp.FtpURLConnection;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;
......@@ -226,8 +230,11 @@ public class ExtController {
String body = exchange.getBody();
if(null==body|| "".equals(body)){
//rtsp地址可能改变,重新获取
String rtsp=getnewRtspVlue(sbtdspsr.getSbbh());
maps.put("rtspvalue", rtsp);
if(!videoid.contains("rtsp")) {
String rtsp = getnewRtspVlue(sbtdspsr.getSbbh());
maps.put("rtspvalue", rtsp);
}
}
else{
JSONObject json = JSONObject.parseObject(exchange.getBody());
......@@ -244,13 +251,7 @@ public class ExtController {
}
try{
//根据rtsp 进行图片获取及存储
TraffAlarmRecord record = new TraffAlarmRecord();
Map<String, Object> transferRecordMap = new HashMap<>();
TraffAlarmRecord traffAlarmRecord = new TraffAlarmRecord();
traffAlarmRecord.setFdid(sbtdspsr.getSbbh());
traffAlarmRecord.setChannelid(Integer.parseInt(String.valueOf(sbtdspsr.getTdbh())));
traffAlarmRecord.setAreaid(Long.parseLong(sbtdspsr.getXzbh()));
int i = 0;
if(imgUrls.size()>0) {
i = 1;
......@@ -271,6 +272,17 @@ public class ExtController {
}
}
}
if(imgUrls.size()==0){
logger.info("no picture data ");
return ResultUtil.success();
}
//根据rtsp 进行图片获取及存储
TraffAlarmRecord record = new TraffAlarmRecord();
Map<String, Object> transferRecordMap = new HashMap<>();
TraffAlarmRecord traffAlarmRecord = new TraffAlarmRecord();
traffAlarmRecord.setFdid(sbtdspsr.getSbbh());
traffAlarmRecord.setChannelid(Integer.parseInt(String.valueOf(sbtdspsr.getTdbh())));
traffAlarmRecord.setAreaid(Long.parseLong(sbtdspsr.getXzbh()));
traffAlarmRecord.setCreatetime(new Date());
traffAlarmRecord.setPushstatus(9);
//免审
......@@ -315,19 +327,25 @@ public String getnewRtspVlue(String devicecode ){
//返回rtsp 地址
if (null != json.get("obj") && !"".equals(json.get("obj"))) {
rtspnewvalue = String.valueOf(json.get("obj"));
//更新sbtdspsr 地址
int result = sbtdspsrService.updateRecogByRtsp(rtspnewvalue, devicecode);
if (result > 0) {
logger.info("更新rtsp success");
} else {
logger.info("设备" + devicecode + "不存在");
if(rtspnewvalue.contains("rtsp")) {
//更新sbtdspsr 地址
int result = sbtdspsrService.updateRecogByRtsp(rtspnewvalue, devicecode);
if (result > 0) {
logger.info("更新rtsp success");
} else {
logger.info("设备" + devicecode + "不存在");
}
}
else {
logger.info("获取失败");
}
}
}
return rtspnewvalue;
}
@RequestMapping(value = "/getRecog", method = RequestMethod.POST)
public String getRecog(HttpServletRequest request, @RequestBody String videoid) {
public String getRecog(@RequestBody String videoid) {
//根据判断监控是否存在,该监控检测的事件是什么
List<Map> mapList = sbtdspsrService.selectRecogByRtsp(videoid);
String model ="1";
......@@ -340,7 +358,10 @@ public String getnewRtspVlue(String devicecode ){
//获得该监控的检测业务与检测范围
for (Map<String, Object> map: mapList) {
for (Map.Entry<String, Object> maps:map.entrySet()) {
if("metatype".equals(maps.getKey())){
if("videoid".equals(maps.getKey())){
videoid = String.valueOf(maps.getValue());
}
else if("metatype".equals(maps.getKey())){
model = String.valueOf(maps.getValue());
}
else if("recordtype".equals(maps.getKey())){
......@@ -365,8 +386,16 @@ public String getnewRtspVlue(String devicecode ){
String basepath = "gstraff/" + videoid+ "/" + DateUtils.formatCurrDayNoSign();
Map<String, Object> map = new HashMap<>();
if(videoid.indexOf("_")<0){
videoid=videoid+"_0";
}
if(videoid.split("_").length<2){
logger.info("监控不存在");
return ResultUtil.success();
}
map.put("sbbh", videoid.split("_")[0]);
map.put("tdbh", 0);
map.put("tdbh", videoid.split("_")[1]);
List<TraffAlarmRecord> traffalarmrecordlist = traffAlarmRecordService.getTraffAlarmRecordByProgress(map);
if(traffalarmrecordlist.size()<1) {
return ResultUtil.success();
......@@ -387,120 +416,122 @@ public String getnewRtspVlue(String devicecode ){
continue;
}
requestEntity = new HttpEntity<>(JSONObject.toJSONString(param), headers);
ResponseEntity<String> response = restTemplate.exchange(recogurl, HttpMethod.POST, requestEntity, String.class);
String body = response.getBody();
JSONObject result = JSONObject.parseObject(body);
if (null != result.get("ret") && result.get("ret").equals("200")) {
//获得返回结果,根据 Metadata.type 判断是人,车,人骑车,并将详细信息入对应的表
List<TraffpictureParam> objectList = (List<TraffpictureParam>) JSONArray.parseArray(String.valueOf(result.get("ObjectList")), TraffpictureParam.class);
//获得 type
//更新 recordalarm 为一分析
traffAlarmRecordService.updateTraffAlarmRecordProcess(transferRecord);
if(objectList.size()<1){
logger.info(" no picturedata ");
continue;
}
//根据结构化统计查询是否超过密度,超过则预警
Code code= codeservice.selectalarmNum(recordtype);
//判断是否统计结构化数据
if(("6".equals(recordtype)||"2".equals(recordtype)))
{
if(null!=code && null!=code.getAlarmnum()&&code.getAlarmnum()>objectList.size())
{
TraffpictureParam traffpictureParam=new TraffpictureParam();
setTraffpictureParam(recordtype, base64Encoder, transferRecord, traffpictureParam);
traffpictureParam.setTargetnum(objectList.size());
//超过则预警
traffpictureParam.setRecordtype(recordtype);
//图片重叠?
traffpictureParam.setImagedata(transferRecord.getImg1path());
traffPictureService.updateTraffpicture(traffpictureParam);
WebSocket.GroupSending(JSONObject.toJSONString(traffpictureParam));
}
}
else {
for (TraffpictureParam traffpictureParam : objectList) {
//根据imageid 获得 base64图片
JSONObject metadata = JSONObject.parseObject(String.valueOf(traffpictureParam.getMetadata()));
JSONObject ObjectBoundingBox=metadata.getJSONObject("ObjectBoundingBox");
if (null == ObjectBoundingBox) {
traffpictureParam.setObjx(metadata.getIntValue("LeftTopX"));
traffpictureParam.setObjy(metadata.getIntValue("LeftTopY"));
traffpictureParam.setObjw(metadata.getIntValue("RightBtmX") - metadata.getIntValue("LeftTopX"));
traffpictureParam.setObjh(metadata.getIntValue("RightBtmY") - metadata.getIntValue("LeftTopY"));
}
else {
traffpictureParam.setObjx(ObjectBoundingBox.getIntValue("X"));
traffpictureParam.setObjy(ObjectBoundingBox.getIntValue("Y"));
traffpictureParam.setObjw(ObjectBoundingBox.getIntValue("W"));
traffpictureParam.setObjh(ObjectBoundingBox.getIntValue("H"));
try {
ResponseEntity<String> response = restTemplate.exchange(recogurl, HttpMethod.POST, requestEntity, String.class);
String body = response.getBody();
JSONObject result = JSONObject.parseObject(body);
if (null != result.get("ret") && result.get("ret").equals("200")) {
//获得返回结果,根据 Metadata.type 判断是人,车,人骑车,并将详细信息入对应的表
List<TraffpictureParam> objectList = (List<TraffpictureParam>) JSONArray.parseArray(String.valueOf(result.get("ObjectList")), TraffpictureParam.class);
//获得 type
//更新 recordalarm 为一分析
traffAlarmRecordService.updateTraffAlarmRecordProcess(transferRecord);
if (objectList.size() < 1) {
logger.info(" no picturedata ");
continue;
}
//根据结构化统计查询是否超过密度,超过则预警
Code code = codeservice.selectalarmNum(recordtype);
//判断是否统计结构化数据
if (("6".equals(recordtype) || "2".equals(recordtype))) {
if (null != code && null != code.getAlarmnum() && code.getAlarmnum() > objectList.size()) {
TraffpictureParam traffpictureParam = new TraffpictureParam();
setTraffpictureParam(recordtype, base64Encoder, transferRecord, traffpictureParam);
traffpictureParam.setTargetnum(objectList.size());
//超过则预警
traffpictureParam.setRecordtype(recordtype);
traffpictureParam.setImagedata(transferRecord.getImg1path());
traffPictureService.updateTraffpicture(traffpictureParam);
WebSocket.GroupSending(JSONObject.toJSONString(traffpictureParam));
}
} else {
for (TraffpictureParam traffpictureParam : objectList) {
//根据imageid 获得 base64图片
JSONObject metadata = JSONObject.parseObject(String.valueOf(traffpictureParam.getMetadata()));
JSONObject ObjectBoundingBox = metadata.getJSONObject("ObjectBoundingBox");
if (null == ObjectBoundingBox) {
traffpictureParam.setObjx(metadata.getIntValue("LeftTopX")+ roiarray[0].intValue());
traffpictureParam.setObjy(metadata.getIntValue("LeftTopY")+roiarray[1].intValue());
traffpictureParam.setObjw(metadata.getIntValue("RightBtmX") - metadata.getIntValue("LeftTopX"));
traffpictureParam.setObjh(metadata.getIntValue("RightBtmY") - metadata.getIntValue("LeftTopY"));
} else {
traffpictureParam.setObjx(ObjectBoundingBox.getIntValue("X")+ roiarray[0].intValue());
traffpictureParam.setObjy(ObjectBoundingBox.getIntValue("Y")+roiarray[1].intValue());
traffpictureParam.setObjw(ObjectBoundingBox.getIntValue("W"));
traffpictureParam.setObjh(ObjectBoundingBox.getIntValue("H"));
}
if (null != metadata && metadata.get("Type").equals(model)) {
traffpictureParam.setMetatype(String.valueOf(metadata.get("Type")));
//规定区域内出现告警对象
setTraffpictureParam(recordtype, base64Encoder, transferRecord, traffpictureParam);
if ("1".equals(metadata.get("Type"))) {
//规定范围内检测到人
Pedestrian meta = JSON.toJavaObject(metadata, Pedestrian.class);
meta.setId(traffpictureParam.getId());
pedestrianService.insertpedestrian(meta);
//新增到事件详情表返回主键
} else if (null != metadata && "2".equals(metadata.get("Type"))) {
//车辆
Traffic meta = JSON.toJavaObject(metadata, Traffic.class);
meta.setId(traffpictureParam.getId());
//新增到车辆详情表
trafficService.insertTraffic(meta);
} else if (null != metadata && "3".equals(metadata.get("Type"))) {
Face meta = JSON.toJavaObject(metadata, Face.class);
meta.setId(traffpictureParam.getId());
faceService.insertFace(meta);
if (null != meta.getFaceBoundingBox()) {
traffpictureParam.setObjx(meta.getFaceBoundingBox().getX()+roiarray[0].intValue());
traffpictureParam.setObjy(meta.getFaceBoundingBox().getY()+roiarray[1].intValue());
traffpictureParam.setObjw(meta.getFaceBoundingBox().getW());
traffpictureParam.setObjh(meta.getFaceBoundingBox().getH());
}
if (null != metadata && metadata.get("Type").equals(model)) {
//规定区域内出现告警对象
setTraffpictureParam(recordtype, base64Encoder, transferRecord, traffpictureParam);
if ("1".equals(metadata.get("Type"))) {
//规定范围内检测到人
Pedestrian meta = JSON.toJavaObject(metadata, Pedestrian.class);
meta.setId(traffpictureParam.getId());
pedestrianService.insertpedestrian(meta);
//新增到事件详情表返回主键
} else if (null != metadata && "2".equals(metadata.get("Type"))) {
//车辆
Traffic meta = JSON.toJavaObject(metadata, Traffic.class);
meta.setId(traffpictureParam.getId());
//新增到车辆详情表
trafficService.insertTraffic(meta);
} else if (null != metadata && "3".equals(metadata.get("Type"))) {
Face meta = JSON.toJavaObject(metadata, Face.class);
meta.setId(traffpictureParam.getId());
faceService.insertFace(meta);
if (null != meta.getFaceBoundingBox()) {
traffpictureParam.setObjx(meta.getFaceBoundingBox().getX());
traffpictureParam.setObjy(meta.getFaceBoundingBox().getY());
traffpictureParam.setObjw(meta.getFaceBoundingBox().getW());
traffpictureParam.setObjh(meta.getFaceBoundingBox().getH());
}
//人骑车
} else if (null != metadata && "4".equals(metadata.get("Type"))) {
PeopleRideBicyc meta = JSON.toJavaObject(metadata, PeopleRideBicyc.class);
meta.setId(traffpictureParam.getId());
peopleridebicycService.insertPeopleRideBicyc(meta);
//人骑车
} else if (null != metadata && "4".equals(metadata.get("Type"))) {
PeopleRideBicyc meta = JSON.toJavaObject(metadata, PeopleRideBicyc.class);
meta.setId(traffpictureParam.getId());
peopleridebicycService.insertPeopleRideBicyc(meta);
}
//更新 traffpicture特征值
try {
ByteArrayInputStream bais = new ByteArrayInputStream(base64Decoder.decodeBuffer(traffpictureParam.getImagedata()));
BufferedImage image = ImageIO.read(bais);
Graphics g = image.getGraphics();
g.setColor(Color.RED);
if (null != traffpictureParam.getObjx() && null != traffpictureParam.getObjy() && null != traffpictureParam.getObjw() && null != traffpictureParam.getObjh())
g.drawRect(traffpictureParam.getObjx(), traffpictureParam.getObjy(), traffpictureParam.getObjw(), traffpictureParam.getObjh());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
ImageIO.write(image, "png", stream);
//上传ftp
Ftp ftp = ftpService.reloadFtp();
String ftputl = FTPUtil.getFtpUrl(ftp) + basepath + "/" + traffpictureParam.getId() + "/imgdata.png";
traffpictureParam.setImagedata(ftputl);
FTPUtil.uploadFile(ftp, basepath + "/" + traffpictureParam.getId(), "imgdata.png", base64Encoder.encode(stream.toByteArray()));
} catch (Exception ex) {
logger.info("base64画框异常:" + ex.toString());
}
traffPictureService.updateTraffpicture(traffpictureParam);
}
//更新 traffpicture特征值
try {
ByteArrayInputStream bais = new ByteArrayInputStream(base64Decoder.decodeBuffer(traffpictureParam.getImagedata()));
BufferedImage image = ImageIO.read(bais);
Graphics g = image.getGraphics();
g.setColor(Color.RED);
if (null != traffpictureParam.getObjx() && null != traffpictureParam.getObjy() && null != traffpictureParam.getObjw() && null != traffpictureParam.getObjh())
g.drawRect(traffpictureParam.getObjx(), traffpictureParam.getObjy(), traffpictureParam.getObjw(), traffpictureParam.getObjh());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
ImageIO.write(image, "png", stream);
//上传ftp
Ftp ftp = ftpService.reloadFtp();
String ftputl = FTPUtil.getFtpUrl(ftp) + basepath + "/" + traffpictureParam.getId() + "/imgdata.png";
traffpictureParam.setImagedata(ftputl);
FTPUtil.uploadFile(ftp, basepath + "/" + traffpictureParam.getId(), "imgdata.png", base64Encoder.encode(stream.toByteArray()));
} catch (Exception ex) {
logger.info("base64画框异常:" + ex.toString());
}
traffPictureService.updateTraffpicture(traffpictureParam);
}
//推送告警
WebSocket.GroupSending(JSONObject.toJSONString(traffpictureParam));
//推送告警
WebSocket.GroupSending(JSONObject.toJSONString(traffpictureParam));
}
}
}
} catch (Exception ex) {
//推送失败
transferRecord.setProcessstatus("-3");
traffAlarmRecordService.updateTraffAlarmRecordProcess(transferRecord);
}
}
return ResultUtil.success();
} else {
......
......@@ -4,10 +4,14 @@ 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.FtpService;
import com.cx.cn.cxquartz.service.quartz.QuartzService;
import com.cx.cn.cxquartz.service.quartz.SbtdspsrService;
import com.cx.cn.cxquartz.util.FTPUtil;
import com.cx.cn.cxquartz.util.FileTransferManager;
import com.cx.cn.cxquartz.util.ResultEnum;
import com.cx.cn.cxquartz.util.ResultUtil;
import com.cx.cn.cxquartz.vo.Ftp;
import com.cx.cn.cxquartz.vo.QuartzTaskRecordsVo;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
......@@ -46,6 +50,9 @@ public class QuartzController {
@Autowired
private RestTemplate restTemplate;
@Autowired
FtpService ftpService;
@RequestMapping(value = "/add/taskpage", method = RequestMethod.GET)
public String addTaskpage() {
return "addtask";
......@@ -55,7 +62,7 @@ public class QuartzController {
@RequestMapping(value = "/add/task", method = RequestMethod.POST)
public String addTask(QuartzTaskInformations taskInformations) {
try {
taskInformations.setSchedulerrule("*/"+taskInformations.getSchedulerrule()+" * * * * ?");
taskInformations.setSchedulerrule("*/" + taskInformations.getSchedulerrule() + " * * * * ?");
String result = quartzService.addTask(taskInformations);
return result;
} catch (Exception e) {
......@@ -67,7 +74,7 @@ public class QuartzController {
@RequestMapping(value = "/edit/taskpage", method = RequestMethod.GET)
public String editTaskpage(Model model, String id) {
QuartzTaskInformations taskInformation = quartzService.getTaskById(id);
taskInformation.setSchedulerrule(taskInformation.getSchedulerrule().replaceAll("\\?","").replaceAll("\\*","").replaceAll("\\/",""));
taskInformation.setSchedulerrule(taskInformation.getSchedulerrule().replaceAll("\\?", "").replaceAll("\\*", "").replaceAll("\\/", ""));
model.addAttribute("taskInformation", taskInformation);
return "updatetask";
}
......@@ -76,11 +83,14 @@ public class QuartzController {
@RequestMapping(value = "/edit/task", method = RequestMethod.POST)
public String editTask(QuartzTaskInformations taskInformations) {
try {
taskInformations.setSchedulerrule("*/"+taskInformations.getSchedulerrule()+" * * * * ?");
taskInformations.setSchedulerrule("*/" + taskInformations.getSchedulerrule() + " * * * * ?");
String result = quartzService.updateTask(taskInformations);
int upresult = sbtdspsrService.updateRecogByRtsp(taskInformations.getRtsp(), taskInformations.getVideoid());
if(null!=taskInformations.getExecuteparamter() && !taskInformations.getExecuteparamter().contains("rtsp:")) {
int upresult = sbtdspsrService.updateRecogByRtsp(taskInformations.getRtsp(), taskInformations.getVideoid());
if (upresult > 0) {
logger.info("更新sbtddspsr squrllj 的值为:"+taskInformations.getExecuteparamter());
logger.info("更新sbtddspsr squrllj 的值为:" + taskInformations.getExecuteparamter());
}
}
return result;
} catch (Exception e) {
......@@ -177,33 +187,42 @@ public class QuartzController {
return "redirect:/";
}
}
@RequestMapping(value = "/getRtsp/{devicecode}", method = RequestMethod.GET)
@RequestMapping(value = "/getRtsp", method = RequestMethod.POST)
@ResponseBody
public String getRTSP(@PathVariable("devicecode") String devicecode) {
public String getRTSP(@RequestBody JSONObject devicecode) {
//判断rtsp 是否过期http://212.129.142.17:8281/gh/device/test?deviceCode=3YSCA44445TFCPX
//判断是否是rtsp 地址
String rtspValue = devicecode.getString("data");
if (!rtspValue.contains("rtsp://")) {
Map<String, String> map = new HashMap<>();
map.put("deviceCode", rtspValue);
ResponseEntity<String> responseEntity = restTemplate.getForEntity(getrtspbyurl + "?deviceCode={deviceCode}", String.class, map);
JSONObject json = JSONObject.parseObject(responseEntity.getBody());
if (null != json.getString("code") && json.getString("code").equals("0")) {
//返回rtsp 地址,更新 sbtdspsr 地址
rtspValue = String.valueOf(json.get("obj"));
}
}
Map<String, String> map = new HashMap<>();
map.put("deviceCode", devicecode);
ResponseEntity<String> responseEntity = restTemplate.getForEntity(getrtspbyurl+"?deviceCode={deviceCode}", String.class, map);
JSONObject json = JSONObject.parseObject(responseEntity.getBody());
if (null != json.getString("code") && json.getString("code").equals("0")) {
//返回rtsp 地址,更新 sbtdspsr 地址
String rtspValue=String.valueOf( json.get("obj"));
//获得抽帧图片
Map maps = new HashMap<>();
maps.put("rtspvalue",rtspValue);
maps.put("refresh",1);
//获得抽帧图片
Map maps = new HashMap<>();
maps.put("rtspvalue", rtspValue);
maps.put("refresh", 1);
try {
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")) {
if (null != jsonresult.getString("ret") && jsonresult.getString("ret").equals("0") && !"".equals(jsonresult.getString("url"))) {
//获得图片地址,存放到ftp上面
return ResultUtil.success( ResultEnum.SUCCESS.getCode(),jsonresult.getString("url")+","+json.get("obj"));
//将图片存储到ftp 上去,jsonresult.getString("url")
Ftp ftp = ftpService.reloadFtp();
String ftpfilepath=FileTransferManager.urlTransToFtp(jsonresult.getString("url"),ftp,"gstraff/picturedemo/");
return ResultUtil.success(ResultEnum.SUCCESS.getCode(), jsonresult.getString("url")+ "," + rtspValue);
}
} else {
logger.info("未获取到监控rtsp");
return ResultUtil.fail();
} catch (Exception ex) {
return ResultUtil.fail();
}
return ResultUtil.success();
}
}
......@@ -5,9 +5,11 @@ 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.service.quartz.SbtdspsrService;
import com.cx.cn.cxquartz.util.ResultEnum;
import com.cx.cn.cxquartz.util.ResultUtil;
import com.cx.cn.cxquartz.vo.QuartzTaskRecordsVo;
import com.cx.cn.cxquartz.vo.Sbtdspsr;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -28,7 +30,7 @@ public class SbtdspsrController {
private static final Logger logger = LoggerFactory.getLogger(SbtdspsrController.class);
@Autowired
private QuartzService quartzService;
private SbtdspsrService sbtdspsrService;
......@@ -37,130 +39,11 @@ public class SbtdspsrController {
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 {
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
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@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";
}
public List<Sbtdspsr> list() {
return sbtdspsrService.list();
/**
* 立即运行一次定时任务
*
* @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:/";
}
}
}
......@@ -11,7 +11,7 @@ import java.util.Map;
@Mapper
public interface SbtdspsrMapper {
List<Sbtdspsr> selectByRtsp( String rtsp);
List<Sbtdspsr> list( );
List<Map> selectRecogByRtsp(String rtsp);
int updateRecogByRtsp(Map map);
}
......@@ -9,4 +9,6 @@ public interface SbtdspsrService {
List<Sbtdspsr> selectByRtsp(String videoid);
List<Map> selectRecogByRtsp(String rtsp);
int updateRecogByRtsp(String rtsp,String devicecode);
List<Sbtdspsr> list();
}
......@@ -35,4 +35,9 @@ public class SbtdspsrImpl implements SbtdspsrService {
return sbtdspsrMapper.updateRecogByRtsp(map);
}
@Override
public List<Sbtdspsr> list() {
return sbtdspsrMapper.list();
}
}
......@@ -20,7 +20,7 @@ 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 CompletionService<String> threadService = new ExecutorCompletionService<String>(ThreadPoolUtil.getPool());
private static final Logger log = LoggerFactory.getLogger(ExtController.class);
/**
* @param transferRecord
......@@ -168,6 +168,36 @@ public class FileTransferManager {
}
}
public static String urlTransToFtp(String url, final Ftp ftp, final String basePath){
threadService.submit(() -> {
try {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setReadTimeout(2000); //延迟连接
connection.setConnectTimeout(3000);
connection.setRequestMethod("GET");
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK || connection.getResponseCode()==HttpURLConnection.HTTP_NOT_MODIFIED) {
InputStream inputStream = connection.getInputStream();
String pname = DateUtils.formatCurrDayNoSign() + ".jpg";
String ftputl = FTPUtil.getFtpUrl(ftp) + basePath+pname;
boolean r = FTPUtil.uploadFile(ftp, basePath, pname,inputStream);
if (r) {
return ftputl;
}
} else {
log.error("connection code: " + connection.getResponseCode());
}
} catch (IOException e) {
System.out.println(e.toString());
log.error(e.toString());
}
return url;
});
try {
return threadService.poll(10, TimeUnit.SECONDS).get();
}catch (Exception ex){
return url;
}
}
}
......@@ -16,8 +16,8 @@ public class RestTemplateConfig {
@Bean
public ClientHttpRequestFactory simpleClientHttpRequestFactory(){
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setConnectTimeout(15000);
factory.setReadTimeout(5000);
factory.setConnectTimeout(150000);
factory.setReadTimeout(150000);
return factory;
}
}
......@@ -10,11 +10,12 @@ public class ImageList {
private Long[] Roi;
private Integer RoiPadding;
// private Integer RoiPadding;
private Integer CropObjectImage;
private Integer CropObjectImagePadding;
private Integer CropObjectImageQuality;
@JSONField(name = "Roi")
public Long[] getRoi() {
return Roi;
}
......@@ -23,13 +24,13 @@ public class ImageList {
Roi = roi;
}
public Integer getRoiPadding() {
return RoiPadding;
}
public void setRoiPadding(Integer roiPadding) {
RoiPadding = roiPadding;
}
// public Integer getRoiPadding() {
// return RoiPadding;
// }
//
// public void setRoiPadding(Integer roiPadding) {
// RoiPadding = roiPadding;
// }
public Integer getCropObjectImage() {
return CropObjectImage;
......@@ -68,7 +69,7 @@ public class ImageList {
public ImageList(String imageID, Long[] roi, Integer roiPadding, Integer cropObjectImage, Integer cropObjectImagePadding, Integer cropObjectImageQuality, String data) {
ImageID = imageID;
Roi = roi;
RoiPadding = roiPadding;
// RoiPadding = roiPadding;
CropObjectImage = cropObjectImage;
CropObjectImagePadding = cropObjectImagePadding;
CropObjectImageQuality = cropObjectImageQuality;
......
......@@ -6,22 +6,22 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
public class Output {
private int SubClass;
//最大行人细类输出个数为1
@JsonIgnore
private int MaxHumanSubClassNum;
//最大车辆细类输出个数为输出全部
@JsonIgnore
private int MaxVehicleSubClassNum;
//最大骑行细类输出个数为3
@JsonIgnore
private int MaxBikeSubClassNum;
// //最大行人细类输出个数为1
// @JsonIgnore
// private int MaxHumanSubClassNum;
//
// //最大车辆细类输出个数为输出全部
// @JsonIgnore
// private int MaxVehicleSubClassNum;
// //最大骑行细类输出个数为3
// @JsonIgnore
// private int MaxBikeSubClassNum;
public Output(int subClass, int maxHumanSubClassNum, int maxVehicleSubClassNum, int maxBikeSubClassNum) {
SubClass = subClass;
MaxHumanSubClassNum = maxHumanSubClassNum;
MaxVehicleSubClassNum = maxVehicleSubClassNum;
MaxBikeSubClassNum = maxBikeSubClassNum;
// MaxHumanSubClassNum = maxHumanSubClassNum;
// MaxVehicleSubClassNum = maxVehicleSubClassNum;
// MaxBikeSubClassNum = maxBikeSubClassNum;
}
public void setSubClass(int SubClass) {
......@@ -32,31 +32,31 @@ public class Output {
public int getSubClass() {
return this.SubClass;
}
public void setMaxHumanSubClassNum(int MaxHumanSubClassNum) {
this.MaxHumanSubClassNum = MaxHumanSubClassNum;
}
@JSONField(name = "MaxHumanSubClassNum")
public int getMaxHumanSubClassNum() {
return this.MaxHumanSubClassNum;
}
public void setMaxVehicleSubClassNum(int MaxVehicleSubClassNum) {
this.MaxVehicleSubClassNum = MaxVehicleSubClassNum;
}
@JSONField(name = "MaxVehicleSubClassNum")
public int getMaxVehicleSubClassNum() {
return this.MaxVehicleSubClassNum;
}
public void setMaxBikeSubClassNum(int MaxBikeSubClassNum) {
this.MaxBikeSubClassNum = MaxBikeSubClassNum;
}
@JSONField(name = "MaxBikeSubClassNum")
public int getMaxBikeSubClassNum() {
return this.MaxBikeSubClassNum;
}
//
// public void setMaxHumanSubClassNum(int MaxHumanSubClassNum) {
// this.MaxHumanSubClassNum = MaxHumanSubClassNum;
// }
//
// @JSONField(name = "MaxHumanSubClassNum")
// public int getMaxHumanSubClassNum() {
// return this.MaxHumanSubClassNum;
// }
//
// public void setMaxVehicleSubClassNum(int MaxVehicleSubClassNum) {
// this.MaxVehicleSubClassNum = MaxVehicleSubClassNum;
// }
//
// @JSONField(name = "MaxVehicleSubClassNum")
// public int getMaxVehicleSubClassNum() {
// return this.MaxVehicleSubClassNum;
// }
//
// public void setMaxBikeSubClassNum(int MaxBikeSubClassNum) {
// this.MaxBikeSubClassNum = MaxBikeSubClassNum;
// }
//
// @JSONField(name = "MaxBikeSubClassNum")
// public int getMaxBikeSubClassNum() {
// return this.MaxBikeSubClassNum;
// }
}
......@@ -68,6 +68,16 @@ public class TraffpictureParam extends Traffpicture {
@JsonIgnore
private Integer objh;
private String metatype;
public String getMetatype() {
return metatype;
}
public void setMetatype(String metatype) {
this.metatype = metatype;
}
public Integer getObjx() {
return objx;
}
......
......@@ -38,15 +38,19 @@ spring:
enabled: true
encoding: UTF-8
mode: HTML
redis:
database: 0
host: 172.16.24.29
port: 6379
#logging:
# level:
# root:
# info
logging:
level:
com.cx.cn.cxquartz.dao:
debug
#logging:
# level:
# com.cx.cn.cxquartz.dao:
# debug
......@@ -12,3 +12,4 @@ file.rtspurl=http://172.16.24.29:8081/getrealcamerasnapshot.php
file.recogurl=http://172.16.24.29:9098/images/recog
redis.cachekey.ftplist=gs:traff:global:cache:ftplist
file.getrtspbyurl=http://212.129.142.17:8281/gh/device/test
......@@ -59,7 +59,7 @@
taskName, schedulerRule, frozenStatus,
executorNo, frozenTime, unfrozenTime,
createTime, lastModifyTime, sendType,
url, executeParamter, timeKey,objectx,objecty,pbjectw,objecth,recordtype,metatype,
url, executeParamter, timeKey,objectx,objecty,objectw,objecth,recordtype,metatype,
rtsp,imgsrc,videoid
)
values (#{id,jdbcType=BIGINT}, #{version,jdbcType=INTEGER}, #{taskno,jdbcType=VARCHAR},
......@@ -70,9 +70,10 @@
#{executeparamter,jdbcType=VARCHAR}, #{timekey,jdbcType=VARCHAR}
, #{objectx,jdbcType=BIGINT}
, #{objecty,jdbcType=BIGINT}
, #{pbjectw,jdbcType=BIGINT}
, #{objectw,jdbcType=BIGINT}
, #{objecth,jdbcType=BIGINT}
, #{recordtype,jdbcType=VARCHAR}
, #{metatype,jdbcType=VARCHAR}
, #{rtsp,jdbcType=VARCHAR}
, #{imgsrc,jdbcType=VARCHAR}
, #{videoid,jdbcType=VARCHAR}
......
......@@ -5,18 +5,43 @@
<result column="sbbh" jdbcType="VARCHAR" property="sbbh"/>
<result column="tdbh" jdbcType="INTEGER" property="tdbh"/>
<result column="xzbh" jdbcType="VARCHAR" property="xzbh"/>
<result column="tdmc" jdbcType="VARCHAR" property="tdmc"/>
</resultMap>
<select id="selectByRtsp" parameterType="java.lang.String" resultType="com.cx.cn.cxquartz.vo.Sbtdspsr">
select * from sbtdspsr where sbbh = #{videoid}
select * from sbtdspsr where sbbh = #{videoid} or squrllj =#{rtsp}
</select>
<select id="selectRecogByRtsp" parameterType="java.lang.String" resultType="java.util.HashMap">
select distinct metatype,recordtype ,objectx,objecty,objectw,objecth from quartz_task_informations where videoid=#{rtsp}
SELECT DISTINCT
metatype,
recordtype,
objectx,
objecty,
objectw,
objecth,(
SELECT
concat( sbbh, '_', tdbh )
FROM
sbtdspsr
WHERE squrllj =#{rtsp}
OR (
sbbh = substring_index( #{rtsp}, '_', 1 )
AND tdbh = substring_index( #{rtsp}, '_',- 1 ))) videoid
FROM
quartz_task_informations
WHERE
videoid =#{rtsp}
OR executeParamter =#{rtsp}
</select>
<update id="updateRecogByRtsp" parameterType="java.util.HashMap" >
update sbtdspsr set squrllj= #{rtsp} where sbbh=#{devicecode}
</update>
<select id="list" resultType="com.cx.cn.cxquartz.vo.Sbtdspsr">
select * from sbtdspsr
</select>
</mapper>
......@@ -110,7 +110,7 @@
</select>
<update id="updateTraffpicture">
update traffpicture set objx=#{objx},objy=#{objy},objw=#{objw},objh=#{objh},imagedata=#{imagedata} where id=#{id}
update traffpicture set objx=#{objx},objy=#{objy},objw=#{objw},objh=#{objh},imagedata=#{imagedata},metatype=#{metatype} where id=#{id}
</update>
......
......@@ -19,6 +19,8 @@
</head>
<body>
<div class="col-md-12 top-20 padding-0">
<input type="hidden" value="false" id="changewidthnot"/>
<input type="hidden" value="false" id="imgsrc"/>
<div class="col-md-12">
<div class="panel">
<div class="panel-body">
......@@ -45,7 +47,7 @@
<div class="form-group"><label
class="col-sm-2 control-label text-right">间隔时间(秒):</label>
<div class="col-sm-10">
<input type="number" min="1" max="60" step="1"
<input type="number" min="1" max="59" step="1"
placeholder="间隔时间"
name="schedulerrule"
id="schedulerrule"
......@@ -76,9 +78,11 @@
<div class="form-group">
<div class="col-sm-10">
<input type="text" name="videoid"
id="videoid" class="form-control" style="width:50%;float: left">
<a id="getrtsp" href=" javascript:void(0)" style="float: left;padding-left: 12px;padding-top: 10px;">获得监控图片</a>
<a id="getwidth" href=" javascript:void(0)" style="padding-left: 12px; padding-top: 10px;">编辑监控范围</a>
id="videoid" class="form-control" style="width:65%;float: left">
<a id="getrtsp" href=" javascript:void(0)"
style="float: left;padding-left: 12px;padding-top: 10px;">获得监控图片</a>
<a id="getwidth" href=" javascript:void(0)"
style="float: left;padding-left: 12px;padding-top: 10px;">编辑监控范围</a>
</div>
</div>
......@@ -172,8 +176,375 @@
<canvas id="draw-canvas" width="600" height="400"
style="border:1px solid #d3d3d3; position: absolute; left: 50%; top: 100px;}">
</canvas>
<script type="text/javascript" th:src="@{/js/canvasutil.js}"></script>
<script type="text/javascript" th:inline="javascript">
class DrawRectangle {
constructor(id, options) {
this.canvas = document.getElementById(id); //canvas标签
this.ctx = this.canvas.getContext('2d');
this.currentR = null; //单前点击的矩形框
this.startX = 0; //开始X坐标
this.startY = 0; //开始Y坐标
this.endX = 0; // 结束X坐标
this.endY = 0; // 结束Y坐标
this.layers = options && options.layers || []; //图层
this.optype = 0; //op操作类型 0 无操作 1 画矩形框 2 拖动矩形框
this.scale = 1; //放大倍数
this.scaleStep = 1.05; //
this.flag = false; //是否点击鼠标的标志
this.type = 0; //鼠标移动类型
this.topDistance = 0; //
this.leftDistance = 0; //
this.ratew = 1;
this.rateh = 1;
this.config = {
width: 600,
height: 400,
dashedColor: 'red', //虚线颜色
solidColor: 'red', //实线颜色
src: null, //图片的路径
}
if (options) {
for (const key in options) {
this.config[key] = options[key]
}
}
this.setImageBackground(this.config.src);
this.canvas.onmouseleave = ()=>
{
this.canvas.onmousedown = null;
this.canvas.onmousemove = null;
this.canvas.onmouseup = null;
}
this.canvas.onmouseenter = ()=>
{
this.canvas.onmousedown = this.mousedown.bind(this);
this.canvas.onmousemove = this.mousemove.bind(this);
document.onmouseup = this.mouseup.bind(this);
}
}
init(cvw, cvh, imgw, imgh) {
var item = this.layers[1];
this.ratew = cvw / imgw;
this.rateh = cvh / imgh;
this.ctx.beginPath();
this.startX = (item.x1) * this.ratew;
this.startY = (item.y1) * this.rateh;
this.endX = (item.x1) * this.ratew + (item.width) * this.ratew;
this.endY = (item.y1) * this.ratew + (item.height) * this.rateh;
this.ctx.rect(this.startX, this.startY, (item.width) * this.ratew, (item.height) * this.rateh);
// this.ctx.rect(item.x1, item.y1, item.width, item.height);
this.ctx.strokeStyle = item.strokeStyle;
this.layers.splice(0, 1, this.fixPosition({
x1: Math.ceil(this.startX),
y1: Math.ceil(this.startY),
x2: Math.ceil(this.endX),
y2: Math.ceil(this.endY),
strokeStyle: this.config.solidColor,
type: this.type
}));
console.log(`item`, item)
this.ctx.stroke();
console.log(`init:`, this.layers);
}
//设置图片为canvas的背景
setImageBackground(src) {
const img = new Image();
img.src = src;
img.onload = ()=>
{
let
actImgW = img.width,
actImgH = img.height,
imgW = actImgW,
imgH = actImgH,
rate = 1,
left = 0,
top = 0,
canvasW = 600,
canvasH = 400;
//因为canvas画布的宽高固定,所以通过判断图片的宽高来进行缩放处理
if (actImgW > canvasW || actImgH > canvasH) {
if (actImgW / actImgH >= canvasW / canvasH) {
imgW = canvasW;
rate = actImgW / canvasW;
imgH = actImgH / rate;
top = (canvasH - imgH) / 2;
} else {
imgH = canvasH;
rate = actImgH / canvasH;
imgW = actImgW / rate;
left = (canvasW - imgW) / 2;
}
} else {
left = (canvasW - imgW) / 2;
top = (canvasH - imgH) / 2;
}
//this.ctx.drawImage(img, left, top, imgW, imgH);
//if (img.labelVos)
//drawRect(this.ctx, img, left, top, rate);
const _this = this;
//img.onload = ()=> {
_this.canvas.width = imgW;
_this.canvas.height = imgH;
_this.config.width = actImgW;
_this.config.height = actImgH;
_this.canvas.style.backgroundImage = "url(" + img.src + ")";
_this.canvas.style.backgroundSize = `${imgW}px ${imgH}px`;
_this.init(imgW, imgH, actImgW, actImgH);
// }
}
}
//左侧拉伸展
resizeLeft(rect) {
this.canvas.style.cursor = "w-resize";
if (this.flag && this.optype == 0) {
this.optype = 3;
}
if (this.flag && this.optype == 3) {
if (!this.currentR) {
this.currentR = rect
}
this.currentR.x1 = this.endX;
this.currentR.width = this.currentR.x2 - this.currentR.x1
}
}
//上边框拉伸
resizeTop(rect) {
this.canvas.style.cursor = "s-resize";
if (this.flag && this.optype == 0) {
this.optype = 4;
}
if (this.flag && this.optype == 4) {
if (!this.currentR) {
this.currentR = rect
}
this.currentR.y1 = this.endY;
this.currentR.height = this.currentR.y2 - this.currentR.y1;
}
}
resizeWidth(rect) {
this.canvas.style.cursor = "w-resize";
if (this.flag && this.optype == 0) {
this.optype = 5;
}
if (this.flag && this.optype == 5) {
if (!this.currentR) {
this.currentR = rect
}
this.currentR.x2 = this.endX;
this.currentR.width = this.currentR.x2 - this.currentR.x1
}
}
resizeHeight(rect) {
this.canvas.style.cursor = "s-resize";
if (this.flag && this.optype == 0) {
this.optype = 6;
}
if (this.flag && this.optype == 6) {
if (!this.currentR) {
this.currentR = rect
}
this.currentR.y2 = this.endY;
this.currentR.height = this.currentR.y2 - this.currentR.y1;
}
}
resizeLT(rect) {
this.canvas.style.cursor = "se-resize";
if (this.flag && this.optype == 0) {
this.optype = 7;
}
if (this.flag && this.optype == 7) {
if (!this.currentR) {
this.currentR = rect
}
this.currentR.x1 = this.endX;
this.currentR.y1 = this.endY;
this.currentR.height = this.currentR.y2 - this.currentR.y1;
this.currentR.width = this.currentR.x2 - this.currentR.x1;
}
}
resizeWH(rect) {
this.canvas.style.cursor = "se-resize";
if (this.flag && this.optype == 0) {
this.optype = 8;
}
if (this.flag && this.optype == 8) {
if (!this.currentR) {
this.currentR = rect
}
this.currentR.x2 = this.endX;
this.currentR.y2 = this.endY;
this.currentR.height = this.currentR.y2 - this.currentR.y1;
this.currentR.width = this.currentR.x2 - this.currentR.x1;
}
}
resizeLH(rect) {
this.canvas.style.cursor = "ne-resize";
if (this.flag && this.optype == 0) {
this.optype = 9;
}
if (this.flag && this.optype == 9) {
if (!this.currentR) {
this.currentR = rect
}
this.currentR.x1 = this.endX;
this.currentR.y2 = this.endY;
this.currentR.height = this.currentR.y2 - this.currentR.y1;
this.currentR.width = this.currentR.x2 - this.currentR.x1;
}
}
resizeWT(rect) {
this.canvas.style.cursor = "ne-resize";
if (this.flag && this.optype == 0) {
this.optype = 10;
}
if (this.flag && this.optype == 10) {
if (!this.currentR) {
this.currentR = rect
}
this.currentR.x2 = this.endX;
this.currentR.y1 = this.endY;
this.currentR.height = this.currentR.y2 - this.currentR.y1
this.currentR.width = this.currentR.x2 - this.currentR.x1
}
}
reshow(x, y, changesmall) {
let allNotIn = 1;
let item = this.layers[0];
this.ctx.beginPath();
console.log(item.x1);
this.ctx.rect(item.x1, item.y1, item.width, item.height);
this.ctx.strokeStyle = item.strokeStyle;
if (this.ctx.isPointInPath(x * this.scale, y * this.scale)) {
this.render(item);
allNotIn = 0;
}
this.ctx.stroke();
if (this.flag && allNotIn && this.optype < 3) {
this.optype = 1;
}
}
render(rect) {
this.canvas.style.cursor = "move";
if (this.flag && this.optype == 0) {
this.optype = 2;
}
if (this.flag && this.optype == 2) {
if (!this.currentR) {
this.currentR = rect
}
this.currentR.x2 += this.endX - this.leftDistance - this.currentR.x1;
this.currentR.x1 += this.endX - this.leftDistance - this.currentR.x1;
this.currentR.y2 += this.endY - this.topDistance - this.currentR.y1;
this.currentR.y1 += this.endY - this.topDistance - this.currentR.y1;
}
}
isPointInRetc(x, y) {
let len = this.layers.length;
for (let i = 0; i < len; i++) {
if (this.layers[i].x1 < x && x < this.layers[i].x2 && this.layers[i].y1 < y && y < this.layers[i].y2) {
return this.layers[i];
}
}
}
fixPosition(position) {
if (position.x1 > position.x2) {
let x = position.x1;
position.x1 = position.x2;
position.x2 = x;
}
if (position.y1 > position.y2) {
let y = position.y1;
position.y1 = position.y2;
position.y2 = y;
}
position.width = position.x2 - position.x1
position.height = position.y2 - position.y1
return position
}
mousedown(e) {
if ($("#changewidthnot").val() == "1") {
this.startX = (e.pageX - this.canvas.offsetLeft) / this.scale;
this.startY = (e.pageY - this.canvas.offsetTop) / this.scale;
this.currentR = this.isPointInRetc(this.startX, this.startY);
if (this.currentR) {
this.leftDistance = this.startX - this.currentR.x1;
this.topDistance = this.startY - this.currentR.y1;
}
this.ctx.strokeRect(this.endX, this.endY, 0, 0);
this.ctx.strokeStyle = this.config.dashedColor;
this.flag = 1;
}
}
mousemove(e) {
if ($("#changewidthnot").val() == "1") {
this.endX = (e.pageX - this.canvas.offsetLeft) / this.scale;
this.endY = (e.pageY - this.canvas.offsetTop) / this.scale;
// console.log(`mousemove`, this.endX, this.endY);
this.ctx.save();
this.ctx.setLineDash([5])
this.canvas.style.cursor = "crosshair";
this.ctx.clearRect(0, 0, this.config.width, this.config.height);
if (this.flag && this.optype == 1) {
this.ctx.strokeRect(this.startX, this.startY, this.endX - this.startX, this.endY - this.startY);
}
this.ctx.restore();
this.reshow(this.endX, this.endY, "1");
}
}
mouseup(e) {
if ($("#changewidthnot").val() == "1") {
if (this.optype == 1) {
this.layers.splice(0, 1, this.fixPosition({
x1: this.startX,
y1: this.startY,
x2: this.endX,
y2: this.endY,
strokeStyle: this.config.solidColor,
type: this.type
}))
var ratew = this.config.width / this.canvas.width;
var rateh = this.config.height / this.canvas.height;
this.layers.splice(1, 1, this.fixPosition({
x1: Math.ceil(this.startX * ratew),
y1: Math.ceil(this.startY * rateh),
x2: Math.ceil(this.endX * ratew),
y2: Math.ceil(this.endY * rateh),
strokeStyle: this.config.solidColor,
type: this.type
}));
} else if (this.optype >= 3) {
this.fixPosition(this.currentR);
}
this.currentR = null;
this.flag = 0;
this.reshow(this.endX, this.endY);
this.optype = 0;
}
}
}
const draw = new DrawRectangle('draw-canvas', {
src: $("#imgsrc").val(),
layers:[{},
......@@ -191,21 +562,26 @@
});
$(function () {
$("#getrtsp").on('click', function (e) {
$.ajax({
url: "/quartz/getRtsp/"+ $("#videoid").val(),
url: "/quartz/getRtsp",
dataType: "json",
type: "get",
type: "post",
contentType: 'application/json',
data: JSON.stringify({data:$("#videoid").val()}),
success: function (result) {
if (result.code == 200) {
if(result.message.indexOf(",")>-1){
$("#executeparamter").val(result.message.split(",")[1]);
if (result.message.indexOf(",") > -1) {
$("#executeparamter").val($("#videoid").val()+"_0");
$("#rtsp").val(result.message.split(",")[1]);
$("#imgsrc").val(result.message.split(",")[0]);
draw.src=result.message.split(",")[0];
$("#imgsrc").val( result.message.split(",")[0]);
draw.src = result.message.split(",")[0];
draw.setImageBackground(result.message.split(",")[0]);
//draw.init();
}
}
else {
alert("超时!");
}
}
});
......@@ -213,7 +589,17 @@
});
$("#getwidth").on('click', function (e) {
if ($("#changewidthnot").val() == "1") {
$("#changewidthnot").val("0");
//$("#draw-canvas").style.cursor = "hand";
}
else {
$("#changewidthnot").val("1");
// $("#draw-canvas").style.cursor = "crosshair";
}
});
$("#savetask").on('click', function (e) {
var taskno = $("#taskno").val();
if(null==taskno || ""==taskno )
......
......@@ -29,14 +29,13 @@
</div>
<div class="col-md-6">
<div class="col-lg-12">
<form action="/index">
<div class="input-group">
<input type="input" class="form-control" aria-label="..." name="name"/>
<input type="input" class="form-control" aria-label="..." id="name"/>
<div class="input-group-btn">
<input type="submit" class="btn btn-3d btn-success" style="box-shadow:none;background-color: #73B18D !important;width:70px;margin-left: 19px;" value="search"/>&nbsp;&nbsp;&nbsp;
<input type="button" id="search" onclick="dosearch()" class="btn btn-3d btn-success" style="box-shadow:none;background-color: #73B18D !important;width:70px;margin-left: 19px;" value="search"/>&nbsp;&nbsp;&nbsp;
</div>
</div>
</form>
</div>
</div>
</div>
......@@ -48,8 +47,7 @@
<th style="text-align:center;vertical-align:middle;">任务名称</th>
<th style="text-align:center;vertical-align:middle;">间隔时间(秒)</th>
<th style="text-align:center;vertical-align:middle;">冻结状态</th>
<th style="text-align:center;vertical-align:middle;">执行方</th>
<th style="text-align:center;vertical-align:middle;">执行方式</th>
<th style="text-align:center;vertical-align:middle;">执行参数</th>
<th style="text-align:center;vertical-align:middle;">创建时间</th>
<th style="text-align:center;vertical-align:middle;">最后修改时间</th>
<th style="text-align:center;vertical-align:middle;">操作</th>
......@@ -66,11 +64,8 @@
<span th:if="${task.frozenstatus eq 'UNFROZEN'}">未冻结</span>
<span th:if="${task.frozenstatus eq 'FROZEN'}" style="color:red;">已冻结</span>
</td>
<td th:text="${task.executorno}"/>
<td>
<span th:if="${task.sendtype eq 'kafka'}">kafka</span>
<span th:if="${task.sendtype eq 'http'}">http</span>
</td>
<td th:text="${task.executeparamter}"/>
<td th:text="${#dates.format(task.createtime,'yyyy-MM-dd HH:mm:ss')}"/>
<td th:text="${#dates.format(task.lastmodifytime,'yyyy-MM-dd HH:mm:ss')}"/>
<td>
......@@ -131,11 +126,12 @@
<script type="text/javascript" th:inline="javascript">
function editpage(id) {
location.href = "/quartz/edit/taskpage?id=" + id;
window.open( "/quartz/edit/taskpage?id=" + id);
}
function addNewTask() {
location.href = "/quartz/add/taskpage/";
window.open( "/quartz/add/taskpage/");
}
function startOrStop(taskNo) {
......@@ -176,6 +172,29 @@
}
});
}
function dosearch(){
$.ajax({
url: "/quartz/list/optionjob?taskNo=" + taskNo,
type: "GET",
dataType: "json",
success: function (result) {
if (result.code == 200) {
alert("success!");
location.href = "/";
} else if (result.code == 6001) {
alert("任务编号为空!");
} else if (result.code == 1003) {
alert("无此定时任务!");
} else {
alert("system error!");
}
}
});
}
</script>
</body>
</html>
......@@ -11,10 +11,12 @@
<link rel="stylesheet" type="text/css" th:href="@{/css/red.css}"/>
<link rel="stylesheet" type="text/css" th:href="@{/css/simple-line-icons.css}"/>
<link rel="stylesheet" type="text/css" th:href="@{/css/style.css}"/>
<style type="text/css">
.col-sm-10 {margin-bottom: 10px}
<style type="text/css">
.col-sm-10 {
margin-bottom: 10px
}
</style>
</style>
</head>
<body>
<div class="col-md-12 top-20 padding-0">
......@@ -49,188 +51,191 @@
id="objecth"/>
<input type="hidden" th:value="${taskInformation.imgsrc}" name="imgsrc"
id="imgsrc"/>
<input type="hidden" value="false" name="imgsrc"
<input type="hidden" value="false" name="changewidthnot"
id="changewidthnot"/>
<input type="hidden" th:value="${taskInformation.rtsp}" name="rtsp"
id="rtsp"/>
<div class="form-group"><label
class="col-sm-2 control-label text-right">任务编号:</label>
<div class="col-sm-10"><input type="text" th:value="${taskInformation.taskno}"
name="taskno"
id="taskno" class="form-control">
</div>
</div>
<div class="form-group"><label
class="col-sm-2 control-label text-right">任务名称:</label>
<div class="col-sm-10"><input type="text" th:value="${taskInformation.taskname}"
name="taskname" id="taskname"
class="form-control"></div>
</div>
<div class="form-group"><label
class="col-sm-2 control-label text-right">间隔时间(秒):</label>
<div class="col-sm-10">
<input type="number" min="1" max="60" step="1"
placeholder="间隔时间"
name="schedulerrule"
th:value="${taskInformation.schedulerrule}"
id="schedulerrule"
class="form-control">
</div>
</div>
<div class="form-group"><label
class="col-sm-2 control-label text-right">冻结状态:</label>
<div class="col-sm-10">
<select class="form-control" id="frozenstatus">
<option th:value="FROZEN"
th:selected="${taskInformation.frozenstatus == 'FROZEN'}">
冻结
</option>
<option th:value="UNFROZEN"
th:selected="${taskInformation.frozenstatus == 'UNFROZEN'}">解冻
</option>
</select>
</div>
</div>
<!--<td>-->
<!--<div class="form-group"><label-->
<!--class="col-sm-2 control-label text-right">执行方:</label>-->
<!--<div class="col-sm-10"><input type="text"-->
<!--th:value="${taskInformation.executorno}"-->
<!--name="executorno" id="executorno"-->
<!--class="form-control"></div>-->
<!--</div>-->
<!--</td>-->
<div class="form-group"><label
class="col-sm-2 control-label text-right">执行方式:</label>
<div class="col-sm-10">
<select class="form-control" id="sendtype">
<option th:value="http"
th:selected="${taskInformation.sendtype == 'http'}">http
</option>
<option th:value="kafka"
th:selected="${taskInformation.sendtype == 'kafka'}">
kafka
</option>
</select>
</div>
</div>
<div class="form-group"><label
class="col-sm-2 control-label text-right">监控id:</label>
</div>
<div class="form-group">
<div class="col-sm-10">
<input type="text" name="videoid" th:value="${taskInformation.videoid}"
id="videoid" class="form-control" style="width:50%;float: left">
<a id="getrtsp" href=" javascript:void(0)" style="float: left;padding-left: 12px;padding-top: 10px;">获得监控图片</a>
<a id="getwidth" href=" javascript:void(0)" style="padding-left: 12px; padding-top: 10px;">编辑监控范围</a>
</div>
</div>
<div class="form-group"><label
class="col-sm-2 control-label text-right">事件类型:</label>
<div class="col-sm-10">
<select class="form-control" id="metatype">
<option th:value="1" th:selected="${taskInformation.metatype == '1'}">
全目标
</option>
<option th:value="2" th:selected="${taskInformation.metatype == '2'}">
行人、骑行、车辆检测识别
</option>
<option th:value="3" th:selected="${taskInformation.metatype == '3'}">
人脸检测识别
</option>
<option th:value="4" th:selected="${taskInformation.metatype == '4'}">
单独行人、骑行检测识别
</option>
<option th:value="5" th:selected="${taskInformation.metatype == '5'}">
单独车辆检测识别
</option>
<option th:value="6" th:selected="${taskInformation.metatype == '6'}">
人脸检测识别(不包含大类检测)
</option>
<option th:value="7" th:selected="${taskInformation.metatype == '7'}">
行人、骑行、人脸
</option>
</select>
</div>
</div>
<div class="form-group"><label
class="col-sm-2 control-label text-right">告警类型:</label>
<div class="col-sm-10">
<select class="form-control" id="recordtype">
<option th:value="1" th:selected="${taskInformation.recordtype == '1'}">
周界入侵
</option>
<option th:value="2" th:selected="${taskInformation.recordtype == '2'}">
人群密度
</option>
<option th:value="3" th:selected="${taskInformation.recordtype == '3'}">
周界越线
</option>
<option th:value="4" th:selected="${taskInformation.recordtype == '4'}">
非机动车未戴头盔
</option>
<option th:value="5" th:selected="${taskInformation.recordtype == '5'}">
非机动车载人
</option>
<option th:value="6" th:selected="${taskInformation.recordtype == '6'}">
结构化统计
</option>
</select>
</div>
</div>
<!--<div class="form-group"><label class="col-sm-2 control-label text-right">人群密度标准:</label>-->
<!--<div class="col-sm-10">-->
<!--<input type="text" th:value="${taskInformation.populationdensity}"-->
<!--name="executorno" id="populationdensity"-->
<!--class="form-control">-->
<!--</div>-->
<!--</div>-->
<div class="form-group"><label
class="col-sm-2 control-label text-right">url:</label>
<div class="col-sm-10"><input type="text" name="url"
th:value="${taskInformation.url}"
id="url" class="form-control"></div>
</div>
<div class="form-group"><label
class="col-sm-2 control-label text-right">执行参数:</label>
<div class="col-sm-10"><input readonly type="text" name="executeparamter"
th:value="${taskInformation.executeparamter}"
id="executeparamter"
class="form-control"></div>
</div>
<div class="form-group"><label
class="col-sm-2 control-label text-right">timeKey:</label>
<div class="col-sm-10"><input type="text"
placeholder="(例如: yyyy-MM-dd HH:mm:ss)"
name="timekey"
th:value="${taskInformation.timekey}"
id="timekey" class="form-control"></div>
</div>
<input type="button" class="btn btn-3d btn-warning" th:onclick="'history.go(-1);'" align="left"
style="float:left;margin-left:120px;box-shadow:none;background-color: #f26c4f !important;width:70px" value="关闭"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" class="btn btn-3d btn-success" id="updatetask" align="right" style="box-shadow:none;background-color: #73B18D !important;width:70px" value="保存"/>
<div class="form-group"><label
class="col-sm-2 control-label text-right">任务编号:</label>
<div class="col-sm-10"><input type="text" th:value="${taskInformation.taskno}"
name="taskno"
id="taskno" class="form-control">
</div>
</div>
<div class="form-group"><label
class="col-sm-2 control-label text-right">任务描述:</label>
<div class="col-sm-10"><input type="text" th:value="${taskInformation.taskname}"
name="taskname" id="taskname"
class="form-control"></div>
</div>
<div class="form-group"><label
class="col-sm-2 control-label text-right">间隔时间(秒):</label>
<div class="col-sm-10">
<input type="number" min="1" max="59" step="1"
placeholder="间隔时间"
name="schedulerrule"
th:value="${taskInformation.schedulerrule}"
id="schedulerrule"
class="form-control">
</div>
</div>
<div class="form-group"><label
class="col-sm-2 control-label text-right">冻结状态:</label>
<div class="col-sm-10">
<select class="form-control" id="frozenstatus">
<option th:value="FROZEN"
th:selected="${taskInformation.frozenstatus == 'FROZEN'}">
冻结
</option>
<option th:value="UNFROZEN"
th:selected="${taskInformation.frozenstatus == 'UNFROZEN'}">解冻
</option>
</select>
</div>
</div>
<!--<td>-->
<!--<div class="form-group"><label-->
<!--class="col-sm-2 control-label text-right">执行方:</label>-->
<!--<div class="col-sm-10"><input type="text"-->
<!--th:value="${taskInformation.executorno}"-->
<!--name="executorno" id="executorno"-->
<!--class="form-control"></div>-->
<!--</div>-->
<!--</td>-->
<div class="form-group"><label
class="col-sm-2 control-label text-right">执行方式:</label>
<div class="col-sm-10">
<select class="form-control" id="sendtype">
<option th:value="http"
th:selected="${taskInformation.sendtype == 'http'}">http
</option>
<option th:value="kafka"
th:selected="${taskInformation.sendtype == 'kafka'}">
kafka
</option>
</select>
</div>
</div>
<div class="form-group"><label
class="col-sm-2 control-label text-right">监控id:</label>
</div>
<div class="form-group">
<div class="col-sm-10">
<input type="text" name="videoid" th:value="${taskInformation.videoid}"
id="videoid" class="form-control" style="width:65%;float: left">
<a id="getrtsp" href=" javascript:void(0)"
style="float: left;padding-left: 12px;padding-top: 10px;">获得监控图片</a>
<a id="getwidth" href=" javascript:void(0)"
style="float: left;padding-left: 12px;padding-top: 10px;">编辑监控范围</a>
</div>
</div>
<div class="form-group"><label
class="col-sm-2 control-label text-right">事件类型:</label>
<div class="col-sm-10">
<select class="form-control" id="metatype">
<option th:value="1" th:selected="${taskInformation.metatype == '1'}">
全目标
</option>
<option th:value="2" th:selected="${taskInformation.metatype == '2'}">
行人、骑行、车辆检测识别
</option>
<option th:value="3" th:selected="${taskInformation.metatype == '3'}">
人脸检测识别
</option>
<option th:value="4" th:selected="${taskInformation.metatype == '4'}">
单独行人、骑行检测识别
</option>
<option th:value="5" th:selected="${taskInformation.metatype == '5'}">
单独车辆检测识别
</option>
<option th:value="6" th:selected="${taskInformation.metatype == '6'}">
人脸检测识别(不包含大类检测)
</option>
<option th:value="7" th:selected="${taskInformation.metatype == '7'}">
行人、骑行、人脸
</option>
</select>
</div>
</div>
<div class="form-group"><label
class="col-sm-2 control-label text-right">告警类型:</label>
<div class="col-sm-10">
<select class="form-control" id="recordtype">
<option th:value="1" th:selected="${taskInformation.recordtype == '1'}">
周界入侵
</option>
<option th:value="2" th:selected="${taskInformation.recordtype == '2'}">
人群密度
</option>
<option th:value="3" th:selected="${taskInformation.recordtype == '3'}">
周界越线
</option>
<option th:value="4" th:selected="${taskInformation.recordtype == '4'}">
非机动车未戴头盔
</option>
<option th:value="5" th:selected="${taskInformation.recordtype == '5'}">
非机动车载人
</option>
<option th:value="6" th:selected="${taskInformation.recordtype == '6'}">
结构化统计
</option>
</select>
</div>
</div>
<!--<div class="form-group"><label class="col-sm-2 control-label text-right">人群密度标准:</label>-->
<!--<div class="col-sm-10">-->
<!--<input type="text" th:value="${taskInformation.populationdensity}"-->
<!--name="executorno" id="populationdensity"-->
<!--class="form-control">-->
<!--</div>-->
<!--</div>-->
<div class="form-group"><label
class="col-sm-2 control-label text-right">url:</label>
<div class="col-sm-10"><input type="text" name="url"
th:value="${taskInformation.url}"
id="url" class="form-control"></div>
</div>
<div class="form-group"><label
class="col-sm-2 control-label text-right">执行参数:</label>
<div class="col-sm-10"><input readonly type="text" name="executeparamter"
th:value="${taskInformation.executeparamter}"
id="executeparamter"
class="form-control">
</div>
<div class="form-group"><label
class="col-sm-2 control-label text-right">timeKey:</label>
<div class="col-sm-10"><input type="text"
placeholder="(例如: yyyy-MM-dd HH:mm:ss)"
name="timekey"
th:value="${taskInformation.timekey}"
id="timekey" class="form-control"></div>
</div>
<input type="button" class="btn btn-3d btn-warning" th:onclick="'history.go(-1);'"
align="left"
style="float:left;margin-left:120px;box-shadow:none;background-color: #f26c4f !important;width:70px"
value="关闭"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" class="btn btn-3d btn-success" id="updatetask" align="right"
style="box-shadow:none;background-color: #73B18D !important;width:70px" value="保存"/>
</form>
<!--</div>-->
</div>
</div>
</div>
......@@ -242,12 +247,12 @@
</canvas>
<script type="text/javascript" th:inline="javascript">
class DrawRectangle{
constructor(id, options){
class DrawRectangle {
constructor(id, options) {
this.canvas = document.getElementById(id); //canvas标签
this.ctx = this.canvas.getContext('2d');
this.currentR = null; //单前点击的矩形框
this.startX =0; //开始X坐标
this.startX = 0; //开始X坐标
this.startY = 0; //开始Y坐标
this.endX = 0; // 结束X坐标
this.endY = 0; // 结束Y坐标
......@@ -256,11 +261,11 @@
this.scale = 1; //放大倍数
this.scaleStep = 1.05; //
this.flag = false; //是否点击鼠标的标志
this.type = 0; //鼠标移动类型
this.topDistance = 0; //
this.leftDistance = 0; //
this.ratew=1;
this.rateh=1;
this.type = 0; //鼠标移动类型
this.topDistance = 0; //
this.leftDistance = 0; //
this.ratew = 1;
this.rateh = 1;
this.config = {
width: 600,
height: 400,
......@@ -274,48 +279,51 @@
}
}
this.setImageBackground(this.config.src);
this.canvas.onmouseleave = () => {
this.canvas.onmouseleave = ()=>
{
this.canvas.onmousedown = null;
this.canvas.onmousemove = null;
this.canvas.onmouseup = null;
}
this.canvas.onmouseenter = ()=> {
this.canvas.onmouseenter = ()=>
{
this.canvas.onmousedown = this.mousedown.bind(this);
this.canvas.onmousemove = this.mousemove.bind(this);
document.onmouseup = this.mouseup.bind(this);
}
}
init(cvw,cvh,imgw,imgh){
var item= this.layers[1];
this.ratew=cvw/imgw;
this.rateh=cvh/imgh;
init(cvw, cvh, imgw, imgh) {
var item = this.layers[1];
this.ratew = cvw / imgw;
this.rateh = cvh / imgh;
this.ctx.beginPath();
this.startX=(item.x1)*this.ratew;
this.startY=(item.y1)*this.rateh;
this.endX=(item.x1)*this.ratew+(item.width)*this.ratew;
this.endY=(item.y1)*this.ratew+(item.height)*this.rateh;
this.ctx.rect(this.startX,this.startY, (item.width)*this.ratew, (item.height)*this.rateh);
this.startX = (item.x1) * this.ratew;
this.startY = (item.y1) * this.rateh;
this.endX = (item.x1) * this.ratew + (item.width) * this.ratew;
this.endY = (item.y1) * this.ratew + (item.height) * this.rateh;
this.ctx.rect(this.startX, this.startY, (item.width) * this.ratew, (item.height) * this.rateh);
// this.ctx.rect(item.x1, item.y1, item.width, item.height);
this.ctx.strokeStyle = item.strokeStyle;
this.layers.splice(0, 1, this.fixPosition({
x1: Math.ceil(this.startX),
y1: Math.ceil(this.startY),
x2: Math.ceil(this.endX ),
x2: Math.ceil(this.endX),
y2: Math.ceil(this.endY),
strokeStyle: this.config.solidColor,
type: this.type
}));
console.log(`item`,item)
console.log(`item`, item)
this.ctx.stroke();
console.log(`init:`,this.layers);
console.log(`init:`, this.layers);
}
//设置图片为canvas的背景
setImageBackground(src){
setImageBackground(src) {
const img = new Image();
img.src = src;
img.onload = () =>{
img.onload = ()=>
{
let
actImgW = img.width,
actImgH = img.height,
......@@ -324,8 +332,8 @@
rate = 1,
left = 0,
top = 0,
canvasW=600,
canvasH=400;
canvasW = 600,
canvasH = 400;
//因为canvas画布的宽高固定,所以通过判断图片的宽高来进行缩放处理
if (actImgW > canvasW || actImgH > canvasH) {
if (actImgW / actImgH >= canvasW / canvasH) {
......@@ -354,7 +362,7 @@
_this.config.height = actImgH;
_this.canvas.style.backgroundImage = "url(" + img.src + ")";
_this.canvas.style.backgroundSize = `${imgW}px ${imgH}px`;
_this.init(imgW,imgH,actImgW,actImgH);
_this.init(imgW, imgH, actImgW, actImgH);
// }
......@@ -362,11 +370,15 @@
}
//左侧拉伸展
resizeLeft (rect) {
resizeLeft(rect) {
this.canvas.style.cursor = "w-resize";
if (this.flag && this.optype == 0) { this.optype = 3; }
if (this.flag && this.optype == 0) {
this.optype = 3;
}
if (this.flag && this.optype == 3) {
if (!this.currentR) { this.currentR = rect }
if (!this.currentR) {
this.currentR = rect
}
this.currentR.x1 = this.endX;
this.currentR.width = this.currentR.x2 - this.currentR.x1
}
......@@ -375,9 +387,13 @@
//上边框拉伸
resizeTop(rect) {
this.canvas.style.cursor = "s-resize";
if (this.flag && this.optype == 0) { this.optype = 4; }
if (this.flag && this.optype == 0) {
this.optype = 4;
}
if (this.flag && this.optype == 4) {
if (!this.currentR) { this.currentR = rect }
if (!this.currentR) {
this.currentR = rect
}
this.currentR.y1 = this.endY;
this.currentR.height = this.currentR.y2 - this.currentR.y1;
}
......@@ -385,9 +401,13 @@
resizeWidth(rect) {
this.canvas.style.cursor = "w-resize";
if (this.flag && this.optype == 0) { this.optype = 5; }
if (this.flag && this.optype == 0) {
this.optype = 5;
}
if (this.flag && this.optype == 5) {
if (!this.currentR) { this.currentR = rect }
if (!this.currentR) {
this.currentR = rect
}
this.currentR.x2 = this.endX;
this.currentR.width = this.currentR.x2 - this.currentR.x1
}
......@@ -395,9 +415,13 @@
resizeHeight(rect) {
this.canvas.style.cursor = "s-resize";
if (this.flag && this.optype == 0) { this.optype = 6; }
if (this.flag && this.optype == 0) {
this.optype = 6;
}
if (this.flag && this.optype == 6) {
if (!this.currentR) { this.currentR = rect }
if (!this.currentR) {
this.currentR = rect
}
this.currentR.y2 = this.endY;
this.currentR.height = this.currentR.y2 - this.currentR.y1;
}
......@@ -405,9 +429,13 @@
resizeLT(rect) {
this.canvas.style.cursor = "se-resize";
if (this.flag && this.optype == 0) { this.optype = 7; }
if (this.flag && this.optype == 0) {
this.optype = 7;
}
if (this.flag && this.optype == 7) {
if (!this.currentR) { this.currentR = rect }
if (!this.currentR) {
this.currentR = rect
}
this.currentR.x1 = this.endX;
this.currentR.y1 = this.endY;
this.currentR.height = this.currentR.y2 - this.currentR.y1;
......@@ -417,9 +445,13 @@
resizeWH(rect) {
this.canvas.style.cursor = "se-resize";
if (this.flag && this.optype == 0) { this.optype = 8; }
if (this.flag && this.optype == 0) {
this.optype = 8;
}
if (this.flag && this.optype == 8) {
if (!this.currentR) { this.currentR = rect }
if (!this.currentR) {
this.currentR = rect
}
this.currentR.x2 = this.endX;
this.currentR.y2 = this.endY;
this.currentR.height = this.currentR.y2 - this.currentR.y1;
......@@ -429,9 +461,13 @@
resizeLH(rect) {
this.canvas.style.cursor = "ne-resize";
if (this.flag && this.optype == 0) { this.optype = 9; }
if (this.flag && this.optype == 0) {
this.optype = 9;
}
if (this.flag && this.optype == 9) {
if (!this.currentR) { this.currentR = rect }
if (!this.currentR) {
this.currentR = rect
}
this.currentR.x1 = this.endX;
this.currentR.y2 = this.endY;
this.currentR.height = this.currentR.y2 - this.currentR.y1;
......@@ -441,9 +477,13 @@
resizeWT(rect) {
this.canvas.style.cursor = "ne-resize";
if (this.flag && this.optype == 0) { this.optype = 10; }
if (this.flag && this.optype == 0) {
this.optype = 10;
}
if (this.flag && this.optype == 10) {
if (!this.currentR) { this.currentR = rect }
if (!this.currentR) {
this.currentR = rect
}
this.currentR.x2 = this.endX;
this.currentR.y1 = this.endY;
this.currentR.height = this.currentR.y2 - this.currentR.y1
......@@ -451,9 +491,9 @@
}
}
reshow(x, y,changesmall) {
reshow(x, y, changesmall) {
let allNotIn = 1;
let item=this.layers[0];
let item = this.layers[0];
this.ctx.beginPath();
console.log(item.x1);
this.ctx.rect(item.x1, item.y1, item.width, item.height);
......@@ -470,12 +510,16 @@
render(rect) {
this.canvas.style.cursor = "move";
if (this.flag && this.optype == 0) { this.optype = 2; }
if (this.flag && this.optype == 0) {
this.optype = 2;
}
if (this.flag && this.optype == 2) {
if (!this.currentR) { this.currentR = rect }
if (!this.currentR) {
this.currentR = rect
}
this.currentR.x2 += this.endX - this.leftDistance - this.currentR.x1;
this.currentR.x1 += this.endX - this.leftDistance - this.currentR.x1;
this.currentR.y2 += this.endY -this.topDistance - this.currentR.y1;
this.currentR.y2 += this.endY - this.topDistance - this.currentR.y1;
this.currentR.y1 += this.endY - this.topDistance - this.currentR.y1;
}
}
......@@ -505,9 +549,9 @@
return position
}
mousedown(e){
if($("#changewidthnot").val()=="1") {
this.startX = (e.pageX -this.canvas.offsetLeft ) / this.scale;
mousedown(e) {
if ($("#changewidthnot").val() == "1") {
this.startX = (e.pageX - this.canvas.offsetLeft) / this.scale;
this.startY = (e.pageY - this.canvas.offsetTop) / this.scale;
this.currentR = this.isPointInRetc(this.startX, this.startY);
if (this.currentR) {
......@@ -520,8 +564,8 @@
}
}
mousemove(e){
if($("#changewidthnot").val()=="1") {
mousemove(e) {
if ($("#changewidthnot").val() == "1") {
this.endX = (e.pageX - this.canvas.offsetLeft) / this.scale;
this.endY = (e.pageY - this.canvas.offsetTop) / this.scale;
// console.log(`mousemove`, this.endX, this.endY);
......@@ -570,25 +614,37 @@
}
}
}
const draw = new DrawRectangle('draw-canvas', {
src: $("#imgsrc").val(),
layers:[{},
layers: [{},
{
"x1": parseInt($("#objectx").val()),
"y1": parseInt($("#objecty").val()),
"x2":parseInt($("#objectx").val())+parseInt($("#objectw").val()),
"y2":parseInt($("#objecty").val())+parseInt($("#objecth").val()),
"width":parseInt($("#objectw").val()),
"height":parseInt($("#objecth").val()),
"strokeStyle":"red",
"type":0
}
"x1": parseInt($("#objectx").val()),
"y1": parseInt($("#objecty").val()),
"x2": parseInt($("#objectx").val()) + parseInt($("#objectw").val()),
"y2": parseInt($("#objecty").val()) + parseInt($("#objecth").val()),
"width": parseInt($("#objectw").val()),
"height": parseInt($("#objecth").val()),
"strokeStyle": "red",
"type": 0
}
]
});
$( function () {
$(function () {
//查询所有监控
$.ajax({
url: "/video/list",
dataType: "json",
type: "get",
success: function (result) {
console.log(result);
}
});
$("#getwidth").on('click', function (e) {
if($("#changewidthnot").val()=="1") {
if ($("#changewidthnot").val() == "1") {
$("#changewidthnot").val("0");
// $("#draw-canvas").style.cursor = "hand";
}
......@@ -600,25 +656,31 @@
});
$("#getrtsp").on('click', function (e) {
$.ajax({
url: "/quartz/getRtsp/"+ $("#videoid").val(),
dataType: "json",
type: "get",
success: function (result) {
if (result.code == 200) {
if(result.message.indexOf(",")>-1){
$("#executeparamter").val($("#videoid").val());
$("#rtsp").val(result.message.split(",")[1]);
$("#imgsrc").val(result.message.split(",")[0]);
draw.src=result.message.split(",")[0];
draw.setImageBackground(result.message.split(",")[0]);
//draw.init();
}
}
}
});
$.ajax({
url: "/quartz/getRtsp",
dataType: "json",
type: "post",
contentType: 'application/json',
data: JSON.stringify({data:$("#videoid").val()}),
success: function (result) {
if (result.code == 200) {
if (result.message.indexOf(",") > -1) {
$("#executeparamter").val($("#videoid").val());
$("#rtsp").val(result.message.split(",")[1]);
$("#imgsrc").val( result.message.split(",")[0]);
draw.src = result.message.split(",")[0];
draw.setImageBackground(result.message.split(",")[0]);
//draw.init();
}
}
else{
alert("超时!");
}
},
error:function (result) {
alert("超时!");
}
});
});
......@@ -659,15 +721,15 @@
"lastmodifytime": lastmodifytime,
"frozentime": frozentime,
"unfrozentime": unfrozentime,
"objectx":object.x1,
"objecty":object.y1,
"objectw":object.width,
"objecth":object.height,
"recordtype":$("#recordtype").val(),
"metatype":$("#metatype").val(),
"rtsp":$("#rtsp").val(),
"imgsrc":$("#imgsrc").val(),
"videoid":$("#videoid").val()
"objectx": object.x1,
"objecty": object.y1,
"objectw": object.width,
"objecth": object.height,
"recordtype": $("#recordtype").val(),
"metatype": $("#metatype").val(),
"rtsp": $("#rtsp").val(),
"imgsrc": $("#imgsrc").val(),
"videoid": $("#videoid").val()
},
success: function (result) {
......@@ -686,9 +748,6 @@
});
</script>
</body>
</html>
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