Commit 37a7ec1c authored by yzm's avatar yzm

bug

parent fb73cb9a
......@@ -64,6 +64,7 @@ public class ExtController {
@Value("${file.recogurl}")
private String recogurl;
@Value("${file.getrtspbyurl}")
private String getrtspbyurl;
......@@ -202,15 +203,21 @@ public class ExtController {
}
@RequestMapping(value = "/getRTSP/{photonum}", method = RequestMethod.POST)
public String getrtsp(@RequestBody String rtspValue,
public String getrtsp(@RequestBody String videoid,
@PathVariable("photonum") Integer photonum) {
//根据videoID查询 rtsp 值
List<Sbtdspsr> sbtdspsrlist=sbtdspsrService.selectByRtsp(videoid);
if (sbtdspsrlist.size() == 0) {
logger.info("设备不存在");
return ResultUtil.success();
}
Sbtdspsr sbtdspsr = sbtdspsrlist.get(0);
//尝试抽取第一张图片
List<Sbtdspsr> sbtdspsrlist=new ArrayList<>();
List<String> imgUrls = new ArrayList<>();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
Map<String, Object> maps = new HashMap<String, Object>();
maps.put("rtspvalue", rtspValue);
maps.put("rtspvalue", sbtdspsr.getSqurllj());
maps.put("refresh", 1);
HttpEntity<String> formEntity = new HttpEntity<>(null, headers);
try {
......@@ -219,24 +226,24 @@ public class ExtController {
String body = exchange.getBody();
if(null==body|| "".equals(body)){
//rtsp地址可能改变,重新获取
rtspValue=getnewRtspVlue(rtspValue);
String rtsp=getnewRtspVlue(sbtdspsr.getSbbh());
maps.put("rtspvalue", rtsp);
}
else{
rtspValue=getnewRtspVlue(rtspValue);
JSONObject json = JSONObject.parseObject(exchange.getBody());
if (null != json.getString("ret") && json.getString("ret").equals("0")) {
//获得图片地址
imgUrls.add(json.getString("url"));
}
}
}catch (Exception ex)
{
//rtsp地址可能改变,重新获取
rtspValue=getnewRtspVlue(rtspValue);
String rtsp=getnewRtspVlue(sbtdspsr.getSbbh());
maps.put("rtspvalue", rtsp);
}
sbtdspsrlist = sbtdspsrService.selectByRtsp(rtspValue);
if (sbtdspsrlist.size() == 0) {
ResultUtil.success();
} else {
try{
Sbtdspsr sbtdspsr = sbtdspsrlist.get(0);
//根据rtsp 进行图片获取及存储
TraffAlarmRecord record = new TraffAlarmRecord();
Map<String, Object> transferRecordMap = new HashMap<>();
......@@ -268,18 +275,17 @@ public class ExtController {
traffAlarmRecord.setPushstatus(9);
//免审
traffAlarmRecord.setCheckstatus(9);
//未提取特征
traffAlarmRecord.setProcessstatus("-2");
//存储到ftp 上去
for (int k = 0; k < imgUrls.size(); k++) {
TraffAlarmRecordFromImgEnum.valueOf("IMG" + k).setImg(traffAlarmRecord, imgUrls.get(k));
}
String basepath = "gstraff/" + traffAlarmRecord.getFdid() + (traffAlarmRecord.getChannelid() < 10 ? "0" + traffAlarmRecord.getChannelid() : traffAlarmRecord.getChannelid()) + "/" + DateUtils.formatCurrDayNoSign();
Ftp ftp = ftpService.reloadFtp();
//入表
Long recordid = Long.parseLong(String.valueOf(traffAlarmRecordService.inserTraffAlarmRecord(traffAlarmRecord)));
traffAlarmRecordService.inserTraffAlarmRecord(traffAlarmRecord);
FileTransferManager.fetchUrlsFromRecord(traffAlarmRecord, transferRecordMap);
String basepath = "gstraff/" + traffAlarmRecord.getFdid() + (traffAlarmRecord.getChannelid() < 10 ? "0" + traffAlarmRecord.getChannelid() : traffAlarmRecord.getChannelid()) + "/" + DateUtils.formatCurrDayNoSign();
List<TransferResult> results = FileTransferManager.transferFile(transferRecordMap, ftp, basepath);
// logger.info("缓存数据上传结果:" + results.toString());
TraffAlarmRecord recordBak = FileTransferManager.traffAlarmRecordUrlUpdate(results);
......@@ -289,20 +295,18 @@ public class ExtController {
traffAlarmRecord.setImg4path(recordBak.getImg4path());
traffAlarmRecord.setImg5path(recordBak.getImg5path());
traffAlarmRecord.setVideopath(recordBak.getVideopath());
//未提取特征
traffAlarmRecord.setProcessstatus("-2");
//更新图片地址
traffAlarmRecordService.updateTraffAlarmRecordUrl(traffAlarmRecord);
return ResultUtil.success();
} catch(Exception e){
logger.error("ext/getRTSPr-->error" + e.toString());
}
}
return ResultUtil.success();
}
public String getnewRtspVlue(String rtspValue ){
public String getnewRtspVlue(String devicecode ){
String rtspnewvalue="";
String[] codearray = rtspValue.split("\\?")[0].split("/");
if (codearray.length > 3) {
String devicecode = codearray[3].replace("_1", "");
Map<String, String> map = new HashMap<>();
map.put("deviceCode", devicecode);
ResponseEntity<String> responseEntity = restTemplate.getForEntity(getrtspbyurl+"?deviceCode={deviceCode}", String.class, map);
......@@ -310,31 +314,23 @@ public String getnewRtspVlue(String rtspValue ){
if (null != json.getString("code") && json.getString("code").equals("0")) {
//返回rtsp 地址
if (null != json.get("obj") && !"".equals(json.get("obj"))) {
rtspnewvalue=String.valueOf(json.get("obj"));
rtspnewvalue = String.valueOf(json.get("obj"));
//更新sbtdspsr 地址
int result = sbtdspsrService.updateRecogByRtsp(rtspnewvalue, devicecode);
if (result > 0) {
logger.info("更新rtsp success");
//更新task rtsp 地址
map.clear();
map.put("nrtsp",rtspnewvalue);
map.put("ortsp",rtspValue);
quartzService.UpdateExecuteParam(map);
} else {
logger.info("设备" + devicecode + "不存在");
}
}
}
}
return rtspValue;
return rtspnewvalue;
}
@RequestMapping(value = "/getRecog", method = RequestMethod.POST)
public String getRecog(HttpServletRequest request, @RequestBody String rtspValue) {
public String getRecog(HttpServletRequest request, @RequestBody String videoid) {
//根据判断监控是否存在,该监控检测的事件是什么
List<Map> mapList = sbtdspsrService.selectRecogByRtsp(rtspValue);
List<Map> mapList = sbtdspsrService.selectRecogByRtsp(videoid);
String model ="1";
String videoid = "";
String recordtype ="1";
//图片框选出来的范围
Long[] roiarray=new Long[4];
......@@ -343,13 +339,8 @@ public String getnewRtspVlue(String rtspValue ){
//获得该监控的检测业务与检测范围
for (Map<String, Object> map: mapList) {
String state =null;
Integer state_id = null;
for (Map.Entry<String, Object> maps:map.entrySet()) {
if("videoid".equals(maps.getKey())){
videoid = String.valueOf(maps.getValue());
}
else if("metatype".equals(maps.getKey())){
if("metatype".equals(maps.getKey())){
model = String.valueOf(maps.getValue());
}
else if("recordtype".equals(maps.getKey())){
......@@ -375,13 +366,12 @@ public String getnewRtspVlue(String rtspValue ){
Map<String, Object> map = new HashMap<>();
map.put("sbbh", videoid.split("_")[0]);
map.put("tdbh", videoid.split("_")[1]);
map.put("tdbh", 0);
List<TraffAlarmRecord> traffalarmrecordlist = traffAlarmRecordService.getTraffAlarmRecordByProgress(map);
if(traffalarmrecordlist.size()<1) {
return ResultUtil.success();
}
BASE64Decoder base64Decoder = new BASE64Decoder();
int count = 0;
//开启多线程
//调用结构化服务,获得图片返回结果
HttpHeaders headers = new HttpHeaders();
......@@ -389,8 +379,7 @@ public String getnewRtspVlue(String rtspValue ){
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
HttpEntity<String> requestEntity = null;
for (TraffAlarmRecord transferRecord : traffalarmrecordlist) {
count = 0;
GoalStructureParam param = FileTransferManager.getGoalStructureParam(count,roiarray,
GoalStructureParam param = FileTransferManager.getGoalStructureParam(roiarray,
Integer.parseInt(model == null ? "1" : "".equals(model) ? "1" : model
), base64Encoder, transferRecord);
if (param.getImageList().size() < 1) {
......@@ -431,80 +420,86 @@ public String getnewRtspVlue(String rtspValue ){
}
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"));
}
if (null != metadata && metadata.get("Type").equals(model)) {
//规定区域内出现告警对象
setTraffpictureParam(recordtype, base64Encoder, transferRecord, traffpictureParam);
if ("1".equals(metadata.get("Type")))
{
if ("1".equals(metadata.get("Type"))) {
//规定范围内检测到人
Pedestrian meta = JSON.toJavaObject(metadata, Pedestrian.class);
meta.setId(traffpictureParam.getId());
pedestrianService.insertpedestrian(meta);
//新增到事件详情表返回主键
traffpictureParam.setObjx(meta.getObjectBoundingBox().getX());
traffpictureParam.setObjy(meta.getObjectBoundingBox().getY());
traffpictureParam.setObjw(meta.getObjectBoundingBox().getW());
traffpictureParam.setObjh(meta.getObjectBoundingBox().getH());
} else if (null != metadata && "2".equals(metadata.get("Type")))
{
} else if (null != metadata && "2".equals(metadata.get("Type"))) {
//车辆
Traffic meta = JSON.toJavaObject(metadata, Traffic.class);
meta.setId(traffpictureParam.getId());
//新增到车辆详情表
trafficService.insertTraffic(meta);
if (null != meta.getObjectBoundingBox()) {
traffpictureParam.setObjx(meta.getObjectBoundingBox().getX());
traffpictureParam.setObjy(meta.getObjectBoundingBox().getY());
traffpictureParam.setObjw(meta.getObjectBoundingBox().getW());
traffpictureParam.setObjh(meta.getObjectBoundingBox().getH());
}
} 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")))
{
} else if (null != metadata && "4".equals(metadata.get("Type"))) {
PeopleRideBicyc meta = JSON.toJavaObject(metadata, PeopleRideBicyc.class);
meta.setId(traffpictureParam.getId());
peopleridebicycService.insertPeopleRideBicyc(meta);
traffpictureParam.setObjx(meta.getObjectBoundingBox().getX());
traffpictureParam.setObjy(meta.getObjectBoundingBox().getY());
traffpictureParam.setObjw(meta.getObjectBoundingBox().getW());
traffpictureParam.setObjh(meta.getObjectBoundingBox().getH());
}
//更新 traffpicture特征值
try {
ByteArrayInputStream bais = new ByteArrayInputStream(base64Decoder.decodeBuffer(traffpictureParam.getImagedata()));
BufferedImage image = ImageIO.read(bais);
Graphics g = image.getGraphics();
g.setColor(Color.GREEN);
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";
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()));
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));
}
}
}
}
}
return ResultUtil.success();
......
......@@ -33,6 +33,11 @@ public class IndexController {
try {
List<QuartzTaskInformations> taskList = quartzService.getTaskList(taskNo, currentPage);
for(QuartzTaskInformations task:taskList)
{
task.setSchedulerrule(task.getSchedulerrule().replaceAll("\\?","").replaceAll("\\*","").replaceAll("\\/",""));
}
int current = Integer.parseInt(currentPage);
Page<QuartzTaskInformations> page = new Page(taskList, taskList.size(), current);
model.addAttribute("taskList", taskList);
......
......@@ -5,6 +5,7 @@ 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.service.quartz.SbtdspsrService;
import com.cx.cn.cxquartz.util.ResultEnum;
import com.cx.cn.cxquartz.util.ResultUtil;
import com.cx.cn.cxquartz.vo.QuartzTaskRecordsVo;
......@@ -39,6 +40,9 @@ public class QuartzController {
@Value("${file.rtspurl}")
private String rtspurl;
@Autowired
private SbtdspsrService sbtdspsrService;
@Autowired
private RestTemplate restTemplate;
......@@ -51,6 +55,7 @@ public class QuartzController {
@RequestMapping(value = "/add/task", method = RequestMethod.POST)
public String addTask(QuartzTaskInformations taskInformations) {
try {
taskInformations.setSchedulerrule("*/"+taskInformations.getSchedulerrule()+" * * * * ?");
String result = quartzService.addTask(taskInformations);
return result;
} catch (Exception e) {
......@@ -62,6 +67,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("\\/",""));
model.addAttribute("taskInformation", taskInformation);
return "updatetask";
}
......@@ -70,7 +76,12 @@ public class QuartzController {
@RequestMapping(value = "/edit/task", method = RequestMethod.POST)
public String editTask(QuartzTaskInformations taskInformations) {
try {
taskInformations.setSchedulerrule("*/"+taskInformations.getSchedulerrule()+" * * * * ?");
String result = quartzService.updateTask(taskInformations);
int upresult = sbtdspsrService.updateRecogByRtsp(taskInformations.getRtsp(), taskInformations.getVideoid());
if (upresult > 0) {
logger.info("更新sbtddspsr squrllj 的值为:"+taskInformations.getExecuteparamter());
}
return result;
} catch (Exception e) {
logger.error("/edit/task exception={}", e);
......@@ -173,27 +184,26 @@ public class QuartzController {
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);
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 地址
//返回rtsp 地址,更新 sbtdspsr 地址
String rtspValue=String.valueOf( json.get("obj"));
//获得抽帧图片
Map maps = new HashMap<>();
maps.put("rtspvalue",String.valueOf( json.get("obj")));
maps.put("rtspvalue",rtspValue);
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")) {
//获得图片地址
//获得图片地址,存放到ftp上面
return ResultUtil.success( ResultEnum.SUCCESS.getCode(),jsonresult.getString("url")+","+json.get("obj"));
}
} else {
logger.info("未获取到监控rtsp");
}
logger.error("rtsp 不存在-->");
return ResultUtil.fail();
return ResultUtil.success();
}
}
......@@ -42,8 +42,6 @@ public class SbtdspsrController {
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);
......
package com.cx.cn.cxquartz.service.quartz;
import com.cx.cn.cxquartz.vo.Sbtdspsr;
import java.util.List;
import java.util.Map;
public interface SbtdspsrService {
List selectByRtsp( String rtsp);
List<Sbtdspsr> selectByRtsp(String videoid);
List<Map> selectRecogByRtsp(String rtsp);
int updateRecogByRtsp(String rtsp,String devicecode);
}
......@@ -17,9 +17,9 @@ public class SbtdspsrImpl implements SbtdspsrService {
@Autowired
private SbtdspsrMapper sbtdspsrMapper;
public List<Sbtdspsr> selectByRtsp(String rtsp)
public List<Sbtdspsr> selectByRtsp(String videoid)
{
return sbtdspsrMapper.selectByRtsp(rtsp);
return sbtdspsrMapper.selectByRtsp(videoid);
}
@Override
......
......@@ -47,7 +47,7 @@ public class FileTransferManager {
connection.setReadTimeout(2000); //延迟连接
connection.setConnectTimeout(3000);
connection.setRequestMethod("GET");
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK || connection.getResponseCode()==HttpURLConnection.HTTP_NOT_MODIFIED) {
InputStream inputStream = connection.getInputStream();
String pname = DateUtils.formatCurrDayNoSign() + "_" + recordid + "_0000_" + key.replace("path", "");
String fileName = pname + filesuff;
......@@ -141,7 +141,7 @@ public class FileTransferManager {
return record;
}
public static GoalStructureParam getGoalStructureParam(int count,Long[] roiarray, int model, BASE64Encoder base64Encoder, TraffAlarmRecord transferRecord) {
public static GoalStructureParam getGoalStructureParam(Long[] roiarray, int model, BASE64Encoder base64Encoder, TraffAlarmRecord transferRecord) {
//获得图片进行分析
GoalStructureParam param = new GoalStructureParam();
param.setOutput(new Output(1, 1, -1, 3));
......
......@@ -11,10 +11,10 @@ mybatis:
spring:
datasource:
url: jdbc:mysql://localhost:3306/imagepro?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
# url: jdbc:mysql://192.168.168.212:3306/imagepro?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
#username: zn06
#password: znznzn8
# url: jdbc:mysql://172.16.24.153:3306/imagepro?useUnicode=true&characterEncoding=utf-8&useSSL=false
url: jdbc:mysql://172.16.24.29:3306/imagepro?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: 123456
driver-class-name: com.mysql.jdbc.Driver
......
......@@ -5,7 +5,10 @@ file.alarmurl=http://www.zjwwzf.cn/xzzfSpv/ext/alarm/camera
#file.rtspurl=http://172.16.24.153:8081/getrealcamerasnapshot.php
#file.recogurl=http://172.16.24.153:9098/images/recog
file.rtspurl=http://localhost:8089/getrealcamerasnapshot
file.recogurl=http://localhost:8089/images/recog
#file.rtspurl=http://localhost:8089/getrealcamerasnapshot
#file.recogurl=http://localhost:8089/images/recog
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
......@@ -7,12 +7,12 @@
<result column="xzbh" jdbcType="VARCHAR" property="xzbh"/>
</resultMap>
<select id="selectByRtsp" parameterType="java.lang.String" resultMap="BaseResultMap">
select sbbh,tdbh,xzbh from sbtdspsr where squrllj = #{rtsp}
<select id="selectByRtsp" parameterType="java.lang.String" resultType="com.cx.cn.cxquartz.vo.Sbtdspsr">
select * from sbtdspsr where sbbh = #{videoid}
</select>
<select id="selectRecogByRtsp" parameterType="java.lang.String" resultType="java.util.HashMap">
select distinct concat(videoid,'_0')videoid ,metatype,recordtype ,objectx,objecty,objectw,objecth from quartz_task_informations where rtsp=#{rtsp}
select distinct metatype,recordtype ,objectx,objecty,objectw,objecth from quartz_task_informations where videoid=#{rtsp}
</select>
<update id="updateRecogByRtsp" parameterType="java.util.HashMap" >
......
......@@ -115,6 +115,7 @@
<if test="img4path!=null">img4path=#{img4path},</if>
<if test="img5path!=null">img5path=#{img5path},</if>
<if test="videopath!=null">videopath=#{videopath},</if>
<if test="processstatus!=null">processstatus=#{processstatus},</if>
</trim>
WHERE recordid=#{recordid}
</update>
......
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;
}
}
}
\ No newline at end of file
......@@ -12,6 +12,10 @@
<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>
</head>
<body>
<div class="col-md-12 top-20 padding-0">
......@@ -23,22 +27,32 @@
</div>
<div class="col-md-6" style="padding-left:10px;">
<form action="#" method="post">
<div class="form-group"><label class="col-sm-2 control-label text-right">任务编号:</label>
<div class="col-sm-10"><input type="text" name="taskno" id="taskno" class="form-control">
<div class="form-group"><label
class="col-sm-2 control-label text-right">任务编号:</label>
<div class="col-sm-10"><input type="text"
name="taskno"
id="taskno" class="form-control">
</div>
</div>
<br/> <br/> <br/>
<div class="form-group"><label class="col-sm-2 control-label text-right">任务名称:</label>
<div class="col-sm-10"><input type="text" name="taskname" id="taskname"
<div class="form-group"><label
class="col-sm-2 control-label text-right">任务名称:</label>
<div class="col-sm-10"><input type="text"
name="taskname" id="taskname"
class="form-control"></div>
</div>
<br/> <br/>
<div class="form-group"><label class="col-sm-2 control-label text-right">定时配置规则:</label>
<div class="col-sm-10"><input type="text" placeholder="(例如: * /5 * * * * ? 每5秒执行一次)"
name="schedulerrule" id="schedulerrule" class="form-control">
<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"
id="schedulerrule"
class="form-control">
</div>
</div>
<br/> <br/>
<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">
......@@ -47,57 +61,196 @@
</div>
</div>
<br/> <br/>
<div class="form-group"><label class="col-sm-2 control-label text-right">执行方:</label>
<div class="col-sm-10"><input type="text" name="executorno" id="executorno"
class="form-control"></div>
</div>
<br/> <br/>
<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" >http</option>
<option th:value="kafka" >kafka</option>
</select>
</div>
</div>
<br/> <br/>
<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" id="url" class="form-control"></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"
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"
全目标
</option>
<option th:value="2">
行人、骑行、车辆检测识别
</option>
<option th:value="3" >
人脸检测识别
</option>
<option th:value="4" >
单独行人、骑行检测识别
</option>
<option th:value="5">
单独车辆检测识别
</option>
<option th:value="6">
人脸检测识别(不包含大类检测)
</option>
<option th:value="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">
周界入侵
</option>
<option th:value="2">
人群密度
</option>
<option th:value="3">
周界越线
</option>
<option th:value="4">
非机动车未戴头盔
</option>
<option th:value="5">
非机动车载人
</option>
<option th:value="6">
结构化统计
</option>
</select>
</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"
id="url" class="form-control"></div>
</div>
<br/> <br/>
<div class="form-group"><label class="col-sm-2 control-label text-right">执行参数:</label>
<div class="col-sm-10"><input type="text" name="executeparamter" id="executeparamter"
<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"
id="executeparamter"
class="form-control"></div>
</div>
<br/><br/>
<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" id="timekey" 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"
id="timekey" class="form-control"></div>
</div>
<br/> <br/><br/>
<input type="button" class="btn btn-3d btn-danger" th:onclick="'history.go(-1);'" align="left"
style="float:left;margin-left:700px;" value="关闭"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" class="btn btn-3d btn-success" id="savetask" align="right" value="保存"/>
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="savetask" align="right" style="box-shadow:none;background-color: #73B18D !important;width:70px" value="保存"/>
</form>
</div>
</div>
</div>
</div>
</div>
<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">
const draw = new DrawRectangle('draw-canvas', {
src: $("#imgsrc").val(),
layers:[{},
{
"x1":null ,
"y1":null,
"x2":null,
"y2":null,
"width":null,
"height":null,
"strokeStyle":"red",
"type":0
}
]
});
$(function () {
$("#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(result.message.split(",")[1]);
$("#rtsp").val(result.message.split(",")[1]);
$("#imgsrc").val(result.message.split(",")[0]);
draw.src=result.message.split(",")[0];
draw.setImageBackground(result.message.split(",")[0]);
}
}
}
});
});
$("#savetask").on('click', function (e) {
var taskno = $("#taskno").val();
if(null==taskno || ""==taskno )
{
alert("请输入任务编号!");
return;
}
var taskname = $("#taskname").val();
var schedulerrule = $("#schedulerrule").val();
if(null==schedulerrule || ""==schedulerrule )
{
alert("请输入间隔时间!");
return;
}
var frozenstatus = $("#frozenstatus").val();
var executorno = $("#executorno").val();
var sendtype = $("#sendtype").val();
var videoid = $("#videoid").val()
if(null==videoid || ""==videoid )
{
alert("请输入监控id!");
return;
}
var url = $("#url").val();
var executeparamter = $("#executeparamter").val();
if(null==executeparamter || ""==executeparamter )
{
alert("请输入执行参数!");
return;
}
var timekey = $("#timekey").val();
object = draw.layers[1];
if(null==object.x1 || null==object.x2 ||null==object.width ||null==object.height )
{
alert("请确定图片检测范围!");
return;
}
$.ajax({
url: "/quartz/add/task",
dataType: "json",
......@@ -111,7 +264,16 @@
"sendtype": sendtype,
"url": url,
"executeparamter": executeparamter,
"timekey": timekey
"timekey": timekey,
"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
},
success: function (result) {
if (result.code == 200) {
......
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>定时任务新增页面</title>
<!-- jquery -->
<script type="text/javascript" th:src="@{/js/jquery.min.js}"></script>
<link rel="stylesheet" type="text/css" th:href="@{/css/animate.min.css}"/>
<link rel="stylesheet" type="text/css" th:href="@{/css/bootstrap.min.css}"/>
<link rel="stylesheet" type="text/css" th:href="@{/css/font-awesome.min.css}"/>
<link rel="stylesheet" type="text/css" th:href="@{/css/mediaelementplayer.css}"/>
<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}"/>
</head>
<body>
<div class="col-md-12 top-20 padding-0">
<div class="col-md-12">
<div class="panel">
<div class="panel-body">
<div class="panel-heading">
<h4>新增定时任务项</h4>
</div>
<div class="col-md-6" style="padding-left:10px;">
<form action="#" method="post">
<div class="form-group"><label class="col-sm-2 control-label text-right">任务编号:</label>
<div class="col-sm-10"><input type="text" name="taskno" id="taskno" class="form-control">
</div>
</div>
<br/> <br/> <br/>
<div class="form-group"><label class="col-sm-2 control-label text-right">任务名称:</label>
<div class="col-sm-10"><input type="text" name="taskname" id="taskname"
class="form-control"></div>
</div>
<br/> <br/>
<div class="form-group"><label class="col-sm-2 control-label text-right">定时配置规则:</label>
<div class="col-sm-10"><input type="text" placeholder="(例如: * /5 * * * * ? 每5秒执行一次)"
name="schedulerrule" id="schedulerrule" class="form-control">
</div>
</div>
<br/> <br/>
<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" selected="selected" disabled="disabled">冻结</option>
</select>
</div>
</div>
<br/> <br/>
<div class="form-group"><label class="col-sm-2 control-label text-right">执行方:</label>
<div class="col-sm-10"><input type="text" name="executorno" id="executorno"
class="form-control"></div>
</div>
<br/> <br/>
<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" >http</option>
<option th:value="kafka" >kafka</option>
</select>
</div>
</div>
<br/> <br/>
<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" id="url" class="form-control"></div>
</div>
<br/> <br/>
<div class="form-group"><label class="col-sm-2 control-label text-right">执行参数:</label>
<div class="col-sm-10"><input type="text" name="executeparamter" id="executeparamter"
class="form-control"></div>
</div>
<br/><br/>
<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" id="timekey" class="form-control"></div>
</div>
<br/> <br/><br/>
<input type="button" class="btn btn-3d btn-danger" th:onclick="'history.go(-1);'" align="left"
style="float:left;margin-left:700px;" value="关闭"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" class="btn btn-3d btn-success" id="savetask" align="right" value="保存"/>
</form>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" th:inline="javascript">
$(function () {
$("#savetask").on('click', function (e) {
var taskno = $("#taskno").val();
var taskname = $("#taskname").val();
var schedulerrule = $("#schedulerrule").val();
var frozenstatus = $("#frozenstatus").val();
var executorno = $("#executorno").val();
var sendtype = $("#sendtype").val();
var url = $("#url").val();
var executeparamter = $("#executeparamter").val();
var timekey = $("#timekey").val();
$.ajax({
url: "/quartz/add/task",
dataType: "json",
type: "POST",
data: {
"taskno": taskno,
"taskname": taskname,
"schedulerrule": schedulerrule,
"frozenstatus": frozenstatus,
"executorno": executorno,
"sendtype": sendtype,
"url": url,
"executeparamter": executeparamter,
"timekey": timekey
},
success: function (result) {
if (result.code == 200) {
alert("添加成功!");
location.href = "/";
} else if (result.code == 1001) {
alert("该任务编号已经存在");
}
else {
alert("system error");
}
}
})
});
});
</script>
</body>
</html>
......@@ -23,7 +23,7 @@
<hr/>
<div class="col-md-6" style="padding-left:10px;">
<form action="import" method="post">
<input type="button" class="btn btn-raised btn-success" onclick="addNewTask()"
<input type="button" class="btn btn-3d btn-success" style="box-shadow:none;background-color: #73B18D !important;width:70px" onclick="addNewTask()"
value="新增定时任务"/>
</form>
</div>
......@@ -33,7 +33,7 @@
<div class="input-group">
<input type="input" class="form-control" aria-label="..." name="name"/>
<div class="input-group-btn">
<input type="submit" class="btn btn-raised btn-success" value="search"/>&nbsp;&nbsp;&nbsp;
<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;
</div>
</div>
</form>
......@@ -46,7 +46,7 @@
<tr>
<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;">定时配置cron</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>
......@@ -76,15 +76,15 @@
<td>
<span th:if="${task.frozenstatus eq 'UNFROZEN'}"> <input type="button"
class="btn btn-3d btn-danger"
value="暂停"
value="暂停" style="box-shadow:none;background-color: #f26c4f !important;width:70px"
th:onclick="'javascript:startOrStop('+${task.taskno}+')'"/>&nbsp;</span>
<span th:if="${task.frozenstatus eq 'FROZEN'}"> <input type="button"
class="btn btn-3d btn-success"
value="启动"
value="启动" style="box-shadow:none;background-color: #73B18D !important;width:70px"
th:onclick="'javascript:startOrStop('+${task.taskno}+')'"/>&nbsp;</span>
<input type="button" class="btn btn-3d btn-success"
<input type="button" class="btn btn-3d btn-success" style="box-shadow:none;background-color: #73B18D !important;width:70px"
th:onclick="'javascript:runRightNow('+${task.taskno}+')'" value="立刻运行一次"/>
<input type="button" class="btn btn-3d btn-success"
<input type="button" class="btn btn-3d btn-success" style="box-shadow:none;background-color: #73B18D !important;width:70px"
th:onclick="'javascript:editpage('+${task.id}+')'" value="修改"/>
</td>
</tr>
......
......@@ -11,6 +11,10 @@
<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>
</head>
<body>
<div class="col-md-12 top-20 padding-0">
......@@ -67,9 +71,10 @@
</div>
<div class="form-group"><label
class="col-sm-2 control-label text-right">定时配置规则:</label>
<div class="col-sm-10"><input type="text"
placeholder="(例如: * /5 * * * * ? 每5秒执行一次)"
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"
......@@ -126,10 +131,9 @@
<div class="form-group">
<div class="col-sm-10">
<input type="text" name="videoid" th:value="${taskInformation.videoid}"
id="videoid" class="form-control">
<a id="getrtsp" href=" javascript:void(0)">获得监控图片</a>
<a id="getwidth" href=" javascript:void(0)">编辑监控范围</a>
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>
......@@ -222,9 +226,9 @@
id="timekey" class="form-control"></div>
</div>
<input type="button" class="btn btn-3d btn-danger" th:onclick="'history.go(-1);'" align="left"
style="float:left;margin-left:700px;" value="关闭"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" class="btn btn-3d btn-success" id="updatetask" align="right" value="保存"/>
<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>
......@@ -234,8 +238,9 @@
</div>
<canvas id="draw-canvas" width="600" height="400"
style="border:1px solid #d3d3d3; position: absolute; right: 100px; top: 100px;}">
style="border:1px solid #d3d3d3; position: absolute; left: 50%; top: 100px;}">
</canvas>
<script type="text/javascript" th:inline="javascript">
class DrawRectangle{
constructor(id, options){
......@@ -353,7 +358,7 @@
// }
}
}
}
//左侧拉伸展
......@@ -497,19 +502,13 @@
}
position.width = position.x2 - position.x1
position.height = position.y2 - position.y1
<!--if (position.width < 50 || position.height < 50) {-->
<!--position.width = 60;-->
<!--position.height = 60;-->
<!--position.x2 += position.x1 + 60;-->
<!--position.y2 += position.y1 + 60;-->
<!--}-->
return position
}
mousedown(e){
if($("#changewidthnot").val()=="1") {
this.startX = (e.pageX - $("#draw-canvas").offset().left) / this.scale;
this.startY = (e.pageY - $("#draw-canvas").offset().top) / this.scale;
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;
......@@ -523,8 +522,8 @@
mousemove(e){
if($("#changewidthnot").val()=="1") {
this.endX = (e.pageX - $("#draw-canvas").offset().left) / this.scale;
this.endY = (e.pageY - $("#draw-canvas").offset().top) / this.scale;
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])
......@@ -571,7 +570,6 @@
}
}
}
const draw = new DrawRectangle('draw-canvas', {
src: $("#imgsrc").val(),
layers:[{},
......@@ -582,22 +580,21 @@
"y2":parseInt($("#objecty").val())+parseInt($("#objecth").val()),
"width":parseInt($("#objectw").val()),
"height":parseInt($("#objecth").val()),
"strokeStyle":"green",
"strokeStyle":"red",
"type":0
}
]
});
$( function () {
$("#getwidth").on('click', function (e) {
if($("#changewidthnot").val()=="1") {
$("#changewidthnot").val("0");
$("#draw-canvas").style.cursor = "hand";
// $("#draw-canvas").style.cursor = "hand";
}
else {
$("#changewidthnot").val("1");
$("#draw-canvas").style.cursor = "crosshair";
// $("#draw-canvas").style.cursor = "crosshair";
}
});
......@@ -610,7 +607,7 @@
success: function (result) {
if (result.code == 200) {
if(result.message.indexOf(",")>-1){
$("#executeparamter").val(result.message.split(",")[1]);
$("#executeparamter").val($("#videoid").val());
$("#rtsp").val(result.message.split(",")[1]);
$("#imgsrc").val(result.message.split(",")[0]);
draw.src=result.message.split(",")[0];
......
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