Commit 37a7ec1c authored by yzm's avatar yzm

bug

parent fb73cb9a
...@@ -64,6 +64,7 @@ public class ExtController { ...@@ -64,6 +64,7 @@ public class ExtController {
@Value("${file.recogurl}") @Value("${file.recogurl}")
private String recogurl; private String recogurl;
@Value("${file.getrtspbyurl}") @Value("${file.getrtspbyurl}")
private String getrtspbyurl; private String getrtspbyurl;
...@@ -202,15 +203,21 @@ public class ExtController { ...@@ -202,15 +203,21 @@ public class ExtController {
} }
@RequestMapping(value = "/getRTSP/{photonum}", method = RequestMethod.POST) @RequestMapping(value = "/getRTSP/{photonum}", method = RequestMethod.POST)
public String getrtsp(@RequestBody String rtspValue, public String getrtsp(@RequestBody String videoid,
@PathVariable("photonum") Integer photonum) { @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<>(); List<String> imgUrls = new ArrayList<>();
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8); headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
Map<String, Object> maps = new HashMap<String, Object>(); Map<String, Object> maps = new HashMap<String, Object>();
maps.put("rtspvalue", rtspValue); maps.put("rtspvalue", sbtdspsr.getSqurllj());
maps.put("refresh", 1); maps.put("refresh", 1);
HttpEntity<String> formEntity = new HttpEntity<>(null, headers); HttpEntity<String> formEntity = new HttpEntity<>(null, headers);
try { try {
...@@ -219,24 +226,24 @@ public class ExtController { ...@@ -219,24 +226,24 @@ public class ExtController {
String body = exchange.getBody(); String body = exchange.getBody();
if(null==body|| "".equals(body)){ if(null==body|| "".equals(body)){
//rtsp地址可能改变,重新获取 //rtsp地址可能改变,重新获取
rtspValue=getnewRtspVlue(rtspValue); String rtsp=getnewRtspVlue(sbtdspsr.getSbbh());
maps.put("rtspvalue", rtsp);
} }
else{ else{
rtspValue=getnewRtspVlue(rtspValue);
JSONObject json = JSONObject.parseObject(exchange.getBody()); JSONObject json = JSONObject.parseObject(exchange.getBody());
imgUrls.add(json.getString("url")); if (null != json.getString("ret") && json.getString("ret").equals("0")) {
//获得图片地址
imgUrls.add(json.getString("url"));
}
} }
}catch (Exception ex) }catch (Exception ex)
{ {
//rtsp地址可能改变,重新获取 //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{ try{
Sbtdspsr sbtdspsr = sbtdspsrlist.get(0);
//根据rtsp 进行图片获取及存储 //根据rtsp 进行图片获取及存储
TraffAlarmRecord record = new TraffAlarmRecord(); TraffAlarmRecord record = new TraffAlarmRecord();
Map<String, Object> transferRecordMap = new HashMap<>(); Map<String, Object> transferRecordMap = new HashMap<>();
...@@ -268,18 +275,17 @@ public class ExtController { ...@@ -268,18 +275,17 @@ public class ExtController {
traffAlarmRecord.setPushstatus(9); traffAlarmRecord.setPushstatus(9);
//免审 //免审
traffAlarmRecord.setCheckstatus(9); traffAlarmRecord.setCheckstatus(9);
//未提取特征
traffAlarmRecord.setProcessstatus("-2");
//存储到ftp 上去 //存储到ftp 上去
for (int k = 0; k < imgUrls.size(); k++) { for (int k = 0; k < imgUrls.size(); k++) {
TraffAlarmRecordFromImgEnum.valueOf("IMG" + k).setImg(traffAlarmRecord, imgUrls.get(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(); Ftp ftp = ftpService.reloadFtp();
//入表 //入表
Long recordid = Long.parseLong(String.valueOf(traffAlarmRecordService.inserTraffAlarmRecord(traffAlarmRecord))); traffAlarmRecordService.inserTraffAlarmRecord(traffAlarmRecord);
FileTransferManager.fetchUrlsFromRecord(traffAlarmRecord, transferRecordMap); 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); List<TransferResult> results = FileTransferManager.transferFile(transferRecordMap, ftp, basepath);
// logger.info("缓存数据上传结果:" + results.toString()); // logger.info("缓存数据上传结果:" + results.toString());
TraffAlarmRecord recordBak = FileTransferManager.traffAlarmRecordUrlUpdate(results); TraffAlarmRecord recordBak = FileTransferManager.traffAlarmRecordUrlUpdate(results);
...@@ -289,52 +295,42 @@ public class ExtController { ...@@ -289,52 +295,42 @@ public class ExtController {
traffAlarmRecord.setImg4path(recordBak.getImg4path()); traffAlarmRecord.setImg4path(recordBak.getImg4path());
traffAlarmRecord.setImg5path(recordBak.getImg5path()); traffAlarmRecord.setImg5path(recordBak.getImg5path());
traffAlarmRecord.setVideopath(recordBak.getVideopath()); traffAlarmRecord.setVideopath(recordBak.getVideopath());
//未提取特征
traffAlarmRecord.setProcessstatus("-2");
//更新图片地址 //更新图片地址
traffAlarmRecordService.updateTraffAlarmRecordUrl(traffAlarmRecord); traffAlarmRecordService.updateTraffAlarmRecordUrl(traffAlarmRecord);
return ResultUtil.success(); return ResultUtil.success();
} catch(Exception e){ } catch(Exception e){
logger.error("ext/getRTSPr-->error" + e.toString()); logger.error("ext/getRTSPr-->error" + e.toString());
} }
}
return ResultUtil.success(); return ResultUtil.success();
} }
public String getnewRtspVlue(String rtspValue ){ public String getnewRtspVlue(String devicecode ){
String rtspnewvalue=""; String rtspnewvalue="";
String[] codearray = rtspValue.split("\\?")[0].split("/"); Map<String, String> map = new HashMap<>();
if (codearray.length > 3) { map.put("deviceCode", devicecode);
String devicecode = codearray[3].replace("_1", ""); ResponseEntity<String> responseEntity = restTemplate.getForEntity(getrtspbyurl+"?deviceCode={deviceCode}", String.class, map);
Map<String, String> map = new HashMap<>(); JSONObject json = JSONObject.parseObject(responseEntity.getBody());
map.put("deviceCode", devicecode); if (null != json.getString("code") && json.getString("code").equals("0")) {
ResponseEntity<String> responseEntity = restTemplate.getForEntity(getrtspbyurl+"?deviceCode={deviceCode}", String.class, map); //返回rtsp 地址
JSONObject json = JSONObject.parseObject(responseEntity.getBody()); if (null != json.get("obj") && !"".equals(json.get("obj"))) {
if (null != json.getString("code") && json.getString("code").equals("0")) { rtspnewvalue = String.valueOf(json.get("obj"));
//返回rtsp 地址 //更新sbtdspsr 地址
if (null != json.get("obj") && !"".equals(json.get("obj"))) { int result = sbtdspsrService.updateRecogByRtsp(rtspnewvalue, devicecode);
rtspnewvalue=String.valueOf(json.get("obj")); if (result > 0) {
//更新sbtdspsr 地址 logger.info("更新rtsp success");
int result = sbtdspsrService.updateRecogByRtsp(rtspnewvalue, devicecode); } else {
if (result > 0) { logger.info("设备" + devicecode + "不存在");
logger.info("更新rtsp success"); }
//更新task rtsp 地址
map.clear();
map.put("nrtsp",rtspnewvalue);
map.put("ortsp",rtspValue);
quartzService.UpdateExecuteParam(map);
} else {
logger.info("设备" + devicecode + "不存在");
} }
} }
} return rtspnewvalue;
}
return rtspValue;
} }
@RequestMapping(value = "/getRecog", method = RequestMethod.POST) @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 model ="1";
String videoid = "";
String recordtype ="1"; String recordtype ="1";
//图片框选出来的范围 //图片框选出来的范围
Long[] roiarray=new Long[4]; Long[] roiarray=new Long[4];
...@@ -343,13 +339,8 @@ public String getnewRtspVlue(String rtspValue ){ ...@@ -343,13 +339,8 @@ public String getnewRtspVlue(String rtspValue ){
//获得该监控的检测业务与检测范围 //获得该监控的检测业务与检测范围
for (Map<String, Object> map: mapList) { for (Map<String, Object> map: mapList) {
String state =null;
Integer state_id = null;
for (Map.Entry<String, Object> maps:map.entrySet()) { for (Map.Entry<String, Object> maps:map.entrySet()) {
if("videoid".equals(maps.getKey())){ if("metatype".equals(maps.getKey())){
videoid = String.valueOf(maps.getValue());
}
else if("metatype".equals(maps.getKey())){
model = String.valueOf(maps.getValue()); model = String.valueOf(maps.getValue());
} }
else if("recordtype".equals(maps.getKey())){ else if("recordtype".equals(maps.getKey())){
...@@ -375,13 +366,12 @@ public String getnewRtspVlue(String rtspValue ){ ...@@ -375,13 +366,12 @@ public String getnewRtspVlue(String rtspValue ){
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("sbbh", videoid.split("_")[0]); map.put("sbbh", videoid.split("_")[0]);
map.put("tdbh", videoid.split("_")[1]); map.put("tdbh", 0);
List<TraffAlarmRecord> traffalarmrecordlist = traffAlarmRecordService.getTraffAlarmRecordByProgress(map); List<TraffAlarmRecord> traffalarmrecordlist = traffAlarmRecordService.getTraffAlarmRecordByProgress(map);
if(traffalarmrecordlist.size()<1) { if(traffalarmrecordlist.size()<1) {
return ResultUtil.success(); return ResultUtil.success();
} }
BASE64Decoder base64Decoder = new BASE64Decoder(); BASE64Decoder base64Decoder = new BASE64Decoder();
int count = 0;
//开启多线程 //开启多线程
//调用结构化服务,获得图片返回结果 //调用结构化服务,获得图片返回结果
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
...@@ -389,8 +379,7 @@ public String getnewRtspVlue(String rtspValue ){ ...@@ -389,8 +379,7 @@ public String getnewRtspVlue(String rtspValue ){
headers.setContentType(MediaType.APPLICATION_JSON_UTF8); headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
HttpEntity<String> requestEntity = null; HttpEntity<String> requestEntity = null;
for (TraffAlarmRecord transferRecord : traffalarmrecordlist) { for (TraffAlarmRecord transferRecord : traffalarmrecordlist) {
count = 0; GoalStructureParam param = FileTransferManager.getGoalStructureParam(roiarray,
GoalStructureParam param = FileTransferManager.getGoalStructureParam(count,roiarray,
Integer.parseInt(model == null ? "1" : "".equals(model) ? "1" : model Integer.parseInt(model == null ? "1" : "".equals(model) ? "1" : model
), base64Encoder, transferRecord); ), base64Encoder, transferRecord);
if (param.getImageList().size() < 1) { if (param.getImageList().size() < 1) {
...@@ -431,77 +420,83 @@ public String getnewRtspVlue(String rtspValue ){ ...@@ -431,77 +420,83 @@ public String getnewRtspVlue(String rtspValue ){
} }
else { else {
for (TraffpictureParam traffpictureParam : objectList) { for (TraffpictureParam traffpictureParam : objectList) {
//根据imageid 获得 base64图片 //根据imageid 获得 base64图片
JSONObject metadata = JSONObject.parseObject(String.valueOf(traffpictureParam.getMetadata())); 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)) { if (null != metadata && metadata.get("Type").equals(model)) {
//规定区域内出现告警对象 //规定区域内出现告警对象
setTraffpictureParam(recordtype, base64Encoder, transferRecord, traffpictureParam); setTraffpictureParam(recordtype, base64Encoder, transferRecord, traffpictureParam);
if ("1".equals(metadata.get("Type"))) if ("1".equals(metadata.get("Type"))) {
{
//规定范围内检测到人 //规定范围内检测到人
Pedestrian meta = JSON.toJavaObject(metadata, Pedestrian.class); Pedestrian meta = JSON.toJavaObject(metadata, Pedestrian.class);
meta.setId(traffpictureParam.getId()); meta.setId(traffpictureParam.getId());
pedestrianService.insertpedestrian(meta); 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); Traffic meta = JSON.toJavaObject(metadata, Traffic.class);
meta.setId(traffpictureParam.getId()); meta.setId(traffpictureParam.getId());
//新增到车辆详情表 //新增到车辆详情表
trafficService.insertTraffic(meta); trafficService.insertTraffic(meta);
if (null != meta.getObjectBoundingBox()) {
traffpictureParam.setObjx(meta.getObjectBoundingBox().getX()); } else if (null != metadata && "3".equals(metadata.get("Type"))) {
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); Face meta = JSON.toJavaObject(metadata, Face.class);
meta.setId(traffpictureParam.getId()); meta.setId(traffpictureParam.getId());
faceService.insertFace(meta); faceService.insertFace(meta);
traffpictureParam.setObjx(meta.getFaceBoundingBox().getX()); if (null != meta.getFaceBoundingBox()) {
traffpictureParam.setObjy(meta.getFaceBoundingBox().getY()); traffpictureParam.setObjx(meta.getFaceBoundingBox().getX());
traffpictureParam.setObjw(meta.getFaceBoundingBox().getW()); traffpictureParam.setObjy(meta.getFaceBoundingBox().getY());
traffpictureParam.setObjh(meta.getFaceBoundingBox().getH()); 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); PeopleRideBicyc meta = JSON.toJavaObject(metadata, PeopleRideBicyc.class);
meta.setId(traffpictureParam.getId()); meta.setId(traffpictureParam.getId());
peopleridebicycService.insertPeopleRideBicyc(meta); peopleridebicycService.insertPeopleRideBicyc(meta);
traffpictureParam.setObjx(meta.getObjectBoundingBox().getX());
traffpictureParam.setObjy(meta.getObjectBoundingBox().getY());
traffpictureParam.setObjw(meta.getObjectBoundingBox().getW());
traffpictureParam.setObjh(meta.getObjectBoundingBox().getH());
} }
//更新 traffpicture特征值 //更新 traffpicture特征值
try { try {
ByteArrayInputStream bais = new ByteArrayInputStream(base64Decoder.decodeBuffer(traffpictureParam.getImagedata())); ByteArrayInputStream bais = new ByteArrayInputStream(base64Decoder.decodeBuffer(traffpictureParam.getImagedata()));
BufferedImage image = ImageIO.read(bais); BufferedImage image = ImageIO.read(bais);
Graphics g = image.getGraphics(); Graphics g = image.getGraphics();
g.setColor(Color.GREEN); g.setColor(Color.RED);
g.drawRect(traffpictureParam.getObjx(), traffpictureParam.getObjy(), traffpictureParam.getObjw(), traffpictureParam.getObjh()); 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(); ByteArrayOutputStream stream = new ByteArrayOutputStream();
ImageIO.write(image, "png", stream); ImageIO.write(image, "png", stream);
//上传ftp //上传ftp
Ftp ftp = ftpService.reloadFtp(); 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); 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) { } catch (Exception ex) {
logger.info("base64画框异常:" + ex.toString()); logger.info("base64画框异常:" + ex.toString());
} }
traffPictureService.updateTraffpicture(traffpictureParam); traffPictureService.updateTraffpicture(traffpictureParam);
//推送告警
WebSocket.GroupSending(JSONObject.toJSONString(traffpictureParam));
} }
//推送告警
WebSocket.GroupSending(JSONObject.toJSONString(traffpictureParam));
} }
} }
} }
......
...@@ -33,6 +33,11 @@ public class IndexController { ...@@ -33,6 +33,11 @@ public class IndexController {
try { try {
List<QuartzTaskInformations> taskList = quartzService.getTaskList(taskNo, currentPage); List<QuartzTaskInformations> taskList = quartzService.getTaskList(taskNo, currentPage);
for(QuartzTaskInformations task:taskList)
{
task.setSchedulerrule(task.getSchedulerrule().replaceAll("\\?","").replaceAll("\\*","").replaceAll("\\/",""));
}
int current = Integer.parseInt(currentPage); int current = Integer.parseInt(currentPage);
Page<QuartzTaskInformations> page = new Page(taskList, taskList.size(), current); Page<QuartzTaskInformations> page = new Page(taskList, taskList.size(), current);
model.addAttribute("taskList", taskList); model.addAttribute("taskList", taskList);
......
...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.cx.cn.cxquartz.bean.QuartzTaskErrors; import com.cx.cn.cxquartz.bean.QuartzTaskErrors;
import com.cx.cn.cxquartz.bean.QuartzTaskInformations; import com.cx.cn.cxquartz.bean.QuartzTaskInformations;
import com.cx.cn.cxquartz.service.quartz.QuartzService; 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.ResultEnum;
import com.cx.cn.cxquartz.util.ResultUtil; import com.cx.cn.cxquartz.util.ResultUtil;
import com.cx.cn.cxquartz.vo.QuartzTaskRecordsVo; import com.cx.cn.cxquartz.vo.QuartzTaskRecordsVo;
...@@ -39,6 +40,9 @@ public class QuartzController { ...@@ -39,6 +40,9 @@ public class QuartzController {
@Value("${file.rtspurl}") @Value("${file.rtspurl}")
private String rtspurl; private String rtspurl;
@Autowired
private SbtdspsrService sbtdspsrService;
@Autowired @Autowired
private RestTemplate restTemplate; private RestTemplate restTemplate;
...@@ -51,6 +55,7 @@ public class QuartzController { ...@@ -51,6 +55,7 @@ public class QuartzController {
@RequestMapping(value = "/add/task", method = RequestMethod.POST) @RequestMapping(value = "/add/task", method = RequestMethod.POST)
public String addTask(QuartzTaskInformations taskInformations) { public String addTask(QuartzTaskInformations taskInformations) {
try { try {
taskInformations.setSchedulerrule("*/"+taskInformations.getSchedulerrule()+" * * * * ?");
String result = quartzService.addTask(taskInformations); String result = quartzService.addTask(taskInformations);
return result; return result;
} catch (Exception e) { } catch (Exception e) {
...@@ -62,6 +67,7 @@ public class QuartzController { ...@@ -62,6 +67,7 @@ public class QuartzController {
@RequestMapping(value = "/edit/taskpage", method = RequestMethod.GET) @RequestMapping(value = "/edit/taskpage", method = RequestMethod.GET)
public String editTaskpage(Model model, String id) { public String editTaskpage(Model model, String id) {
QuartzTaskInformations taskInformation = quartzService.getTaskById(id); QuartzTaskInformations taskInformation = quartzService.getTaskById(id);
taskInformation.setSchedulerrule(taskInformation.getSchedulerrule().replaceAll("\\?","").replaceAll("\\*","").replaceAll("\\/",""));
model.addAttribute("taskInformation", taskInformation); model.addAttribute("taskInformation", taskInformation);
return "updatetask"; return "updatetask";
} }
...@@ -70,7 +76,12 @@ public class QuartzController { ...@@ -70,7 +76,12 @@ public class QuartzController {
@RequestMapping(value = "/edit/task", method = RequestMethod.POST) @RequestMapping(value = "/edit/task", method = RequestMethod.POST)
public String editTask(QuartzTaskInformations taskInformations) { public String editTask(QuartzTaskInformations taskInformations) {
try { try {
taskInformations.setSchedulerrule("*/"+taskInformations.getSchedulerrule()+" * * * * ?");
String result = quartzService.updateTask(taskInformations); String result = quartzService.updateTask(taskInformations);
int upresult = sbtdspsrService.updateRecogByRtsp(taskInformations.getRtsp(), taskInformations.getVideoid());
if (upresult > 0) {
logger.info("更新sbtddspsr squrllj 的值为:"+taskInformations.getExecuteparamter());
}
return result; return result;
} catch (Exception e) { } catch (Exception e) {
logger.error("/edit/task exception={}", e); logger.error("/edit/task exception={}", e);
...@@ -173,27 +184,26 @@ public class QuartzController { ...@@ -173,27 +184,26 @@ public class QuartzController {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("deviceCode", devicecode); 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> responseEntity = restTemplate.getForEntity(getrtspbyurl+"?deviceCode={deviceCode}", String.class, map);
// ResponseEntity<String> exchange = restTemplate.exchange(getrtspbyurl + "?deviceCode={deviceCode}",
// HttpMethod.GET, null, String.class, map);
JSONObject json = JSONObject.parseObject(responseEntity.getBody()); JSONObject json = JSONObject.parseObject(responseEntity.getBody());
if (null != json.getString("code") && json.getString("code").equals("0")) { if (null != json.getString("code") && json.getString("code").equals("0")) {
//返回rtsp 地址 //返回rtsp 地址,更新 sbtdspsr 地址
String rtspValue=String.valueOf( json.get("obj"));
//获得抽帧图片 //获得抽帧图片
Map maps = new HashMap<>(); Map maps = new HashMap<>();
maps.put("rtspvalue",String.valueOf( json.get("obj"))); maps.put("rtspvalue",rtspValue);
maps.put("refresh",1); maps.put("refresh",1);
ResponseEntity<String> result = restTemplate.exchange(rtspurl + "?url={rtspvalue}&refresh={refresh}", ResponseEntity<String> result = restTemplate.exchange(rtspurl + "?url={rtspvalue}&refresh={refresh}",
HttpMethod.GET, null, String.class, maps); HttpMethod.GET, null, String.class, maps);
JSONObject jsonresult = JSONObject.parseObject(result.getBody()); 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")) {
//获得图片地址 //获得图片地址,存放到ftp上面
return ResultUtil.success( ResultEnum.SUCCESS.getCode(),jsonresult.getString("url")+","+json.get("obj")); return ResultUtil.success( ResultEnum.SUCCESS.getCode(),jsonresult.getString("url")+","+json.get("obj"));
} }
} else { } else {
logger.info("未获取到监控rtsp"); logger.info("未获取到监控rtsp");
} }
logger.error("rtsp 不存在-->"); return ResultUtil.success();
return ResultUtil.fail();
} }
} }
...@@ -42,8 +42,6 @@ public class SbtdspsrController { ...@@ -42,8 +42,6 @@ public class SbtdspsrController {
public String addTask(QuartzTaskInformations taskInformations) { public String addTask(QuartzTaskInformations taskInformations) {
try { try {
String result = quartzService.addTask(taskInformations); String result = quartzService.addTask(taskInformations);
//任务添加到任务中
quartzService.addTask(taskInformations);
return result; return result;
} catch (Exception e) { } catch (Exception e) {
logger.error("/add/task exception={}", e); logger.error("/add/task exception={}", e);
......
package com.cx.cn.cxquartz.service.quartz; package com.cx.cn.cxquartz.service.quartz;
import com.cx.cn.cxquartz.vo.Sbtdspsr;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public interface SbtdspsrService { public interface SbtdspsrService {
List selectByRtsp( String rtsp); List<Sbtdspsr> selectByRtsp(String videoid);
List<Map> selectRecogByRtsp(String rtsp); List<Map> selectRecogByRtsp(String rtsp);
int updateRecogByRtsp(String rtsp,String devicecode); int updateRecogByRtsp(String rtsp,String devicecode);
} }
...@@ -17,9 +17,9 @@ public class SbtdspsrImpl implements SbtdspsrService { ...@@ -17,9 +17,9 @@ public class SbtdspsrImpl implements SbtdspsrService {
@Autowired @Autowired
private SbtdspsrMapper sbtdspsrMapper; private SbtdspsrMapper sbtdspsrMapper;
public List<Sbtdspsr> selectByRtsp(String rtsp) public List<Sbtdspsr> selectByRtsp(String videoid)
{ {
return sbtdspsrMapper.selectByRtsp(rtsp); return sbtdspsrMapper.selectByRtsp(videoid);
} }
@Override @Override
......
...@@ -47,7 +47,7 @@ public class FileTransferManager { ...@@ -47,7 +47,7 @@ public class FileTransferManager {
connection.setReadTimeout(2000); //延迟连接 connection.setReadTimeout(2000); //延迟连接
connection.setConnectTimeout(3000); connection.setConnectTimeout(3000);
connection.setRequestMethod("GET"); 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(); InputStream inputStream = connection.getInputStream();
String pname = DateUtils.formatCurrDayNoSign() + "_" + recordid + "_0000_" + key.replace("path", ""); String pname = DateUtils.formatCurrDayNoSign() + "_" + recordid + "_0000_" + key.replace("path", "");
String fileName = pname + filesuff; String fileName = pname + filesuff;
...@@ -141,7 +141,7 @@ public class FileTransferManager { ...@@ -141,7 +141,7 @@ public class FileTransferManager {
return record; 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(); GoalStructureParam param = new GoalStructureParam();
param.setOutput(new Output(1, 1, -1, 3)); param.setOutput(new Output(1, 1, -1, 3));
......
...@@ -11,10 +11,10 @@ mybatis: ...@@ -11,10 +11,10 @@ mybatis:
spring: spring:
datasource: 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 #username: zn06
#password: znznzn8 #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 username: root
password: 123456 password: 123456
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
......
...@@ -5,7 +5,10 @@ file.alarmurl=http://www.zjwwzf.cn/xzzfSpv/ext/alarm/camera ...@@ -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.rtspurl=http://172.16.24.153:8081/getrealcamerasnapshot.php
#file.recogurl=http://172.16.24.153:9098/images/recog #file.recogurl=http://172.16.24.153:9098/images/recog
file.rtspurl=http://localhost:8089/getrealcamerasnapshot #file.rtspurl=http://localhost:8089/getrealcamerasnapshot
file.recogurl=http://localhost:8089/images/recog #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 redis.cachekey.ftplist=gs:traff:global:cache:ftplist
file.getrtspbyurl=http://212.129.142.17:8281/gh/device/test file.getrtspbyurl=http://212.129.142.17:8281/gh/device/test
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
<result column="xzbh" jdbcType="VARCHAR" property="xzbh"/> <result column="xzbh" jdbcType="VARCHAR" property="xzbh"/>
</resultMap> </resultMap>
<select id="selectByRtsp" parameterType="java.lang.String" resultMap="BaseResultMap"> <select id="selectByRtsp" parameterType="java.lang.String" resultType="com.cx.cn.cxquartz.vo.Sbtdspsr">
select sbbh,tdbh,xzbh from sbtdspsr where squrllj = #{rtsp} select * from sbtdspsr where sbbh = #{videoid}
</select> </select>
<select id="selectRecogByRtsp" parameterType="java.lang.String" resultType="java.util.HashMap"> <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> </select>
<update id="updateRecogByRtsp" parameterType="java.util.HashMap" > <update id="updateRecogByRtsp" parameterType="java.util.HashMap" >
......
...@@ -115,6 +115,7 @@ ...@@ -115,6 +115,7 @@
<if test="img4path!=null">img4path=#{img4path},</if> <if test="img4path!=null">img4path=#{img4path},</if>
<if test="img5path!=null">img5path=#{img5path},</if> <if test="img5path!=null">img5path=#{img5path},</if>
<if test="videopath!=null">videopath=#{videopath},</if> <if test="videopath!=null">videopath=#{videopath},</if>
<if test="processstatus!=null">processstatus=#{processstatus},</if>
</trim> </trim>
WHERE recordid=#{recordid} WHERE recordid=#{recordid}
</update> </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 @@ ...@@ -12,6 +12,10 @@
<link rel="stylesheet" type="text/css" th:href="@{/css/red.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/simple-line-icons.css}"/>
<link rel="stylesheet" type="text/css" th:href="@{/css/style.css}"/> <link rel="stylesheet" type="text/css" th:href="@{/css/style.css}"/>
<style type="text/css">
.col-sm-10 {margin-bottom: 10px}
</style>
</head> </head>
<body> <body>
<div class="col-md-12 top-20 padding-0"> <div class="col-md-12 top-20 padding-0">
...@@ -23,22 +27,32 @@ ...@@ -23,22 +27,32 @@
</div> </div>
<div class="col-md-6" style="padding-left:10px;"> <div class="col-md-6" style="padding-left:10px;">
<form action="#" method="post"> <form action="#" method="post">
<div class="form-group"><label class="col-sm-2 control-label text-right">任务编号:</label> <div class="form-group"><label
<div class="col-sm-10"><input type="text" name="taskno" id="taskno" class="form-control"> 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>
</div> </div>
<br/> <br/> <br/>
<div class="form-group"><label class="col-sm-2 control-label text-right">任务名称:</label> <div class="form-group"><label
<div class="col-sm-10"><input type="text" name="taskname" id="taskname" 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> class="form-control"></div>
</div> </div>
<br/> <br/>
<div class="form-group"><label class="col-sm-2 control-label text-right">定时配置规则:</label> <div class="form-group"><label
<div class="col-sm-10"><input type="text" placeholder="(例如: * /5 * * * * ? 每5秒执行一次)" class="col-sm-2 control-label text-right">间隔时间(秒):</label>
name="schedulerrule" id="schedulerrule" class="form-control"> <div class="col-sm-10">
<input type="number" min="1" max="60" step="1"
placeholder="间隔时间"
name="schedulerrule"
id="schedulerrule"
class="form-control">
</div> </div>
</div> </div>
<br/> <br/>
<div class="form-group"><label class="col-sm-2 control-label text-right">冻结状态:</label> <div class="form-group"><label class="col-sm-2 control-label text-right">冻结状态:</label>
<div class="col-sm-10"> <div class="col-sm-10">
<select class="form-control" id="frozenstatus"> <select class="form-control" id="frozenstatus">
...@@ -47,63 +61,202 @@ ...@@ -47,63 +61,202 @@
</div> </div>
</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="form-group"><label class="col-sm-2 control-label text-right">执行方式:</label>
<div class="col-sm-10"> <div class="col-sm-10">
<select class="form-control" id="sendtype"> <select class="form-control" id="sendtype">
<option th:value="http" >http</option> <option th:value="http" >http</option>
<option th:value="kafka" >kafka</option>
</select> </select>
</div> </div>
</div> </div>
<br/> <br/>
<div class="form-group"><label class="col-sm-2 control-label text-right">url:</label> <div class="form-group"><label
<div class="col-sm-10"><input type="text" name="url" id="url" class="form-control"></div> 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> </div>
<br/> <br/>
<div class="form-group"><label class="col-sm-2 control-label text-right">执行参数:</label> <div class="form-group"><label
<div class="col-sm-10"><input type="text" name="executeparamter" id="executeparamter" 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> class="form-control"></div>
</div> </div>
<br/><br/>
<div class="form-group"><label class="col-sm-2 control-label text-right">timeKey:</label> <div class="form-group"><label
<div class="col-sm-10"><input type="text" placeholder="(例如: yyyy-MM-dd HH:mm:ss)" class="col-sm-2 control-label text-right">timeKey:</label>
name="timekey" id="timekey" class="form-control"></div> <div class="col-sm-10"><input type="text"
placeholder="(例如: yyyy-MM-dd HH:mm:ss)"
name="timekey"
id="timekey" class="form-control"></div>
</div> </div>
<br/> <br/><br/>
<input type="button" class="btn btn-3d btn-danger" th:onclick="'history.go(-1);'" align="left" <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; 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" value="保存"/> <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> </form>
</div> </div>
</div> </div>
</div> </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"> <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 () { $(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) { $("#savetask").on('click', function (e) {
var taskno = $("#taskno").val(); var taskno = $("#taskno").val();
if(null==taskno || ""==taskno )
{
alert("请输入任务编号!");
return;
}
var taskname = $("#taskname").val(); var taskname = $("#taskname").val();
var schedulerrule = $("#schedulerrule").val(); var schedulerrule = $("#schedulerrule").val();
if(null==schedulerrule || ""==schedulerrule )
{
alert("请输入间隔时间!");
return;
}
var frozenstatus = $("#frozenstatus").val(); var frozenstatus = $("#frozenstatus").val();
var executorno = $("#executorno").val(); var executorno = $("#executorno").val();
var sendtype = $("#sendtype").val(); var sendtype = $("#sendtype").val();
var videoid = $("#videoid").val()
if(null==videoid || ""==videoid )
{
alert("请输入监控id!");
return;
}
var url = $("#url").val(); var url = $("#url").val();
var executeparamter = $("#executeparamter").val(); var executeparamter = $("#executeparamter").val();
if(null==executeparamter || ""==executeparamter )
{
alert("请输入执行参数!");
return;
}
var timekey = $("#timekey").val(); var timekey = $("#timekey").val();
object = draw.layers[1];
if(null==object.x1 || null==object.x2 ||null==object.width ||null==object.height )
{
alert("请确定图片检测范围!");
return;
}
$.ajax({ $.ajax({
url: "/quartz/add/task", url: "/quartz/add/task",
dataType: "json", dataType: "json",
type: "POST", type: "POST",
data: { data: {
"taskno": taskno, "taskno": taskno,
"taskname": taskname, "taskname": taskname,
"schedulerrule": schedulerrule, "schedulerrule": schedulerrule,
"frozenstatus": frozenstatus, "frozenstatus": frozenstatus,
...@@ -111,7 +264,16 @@ ...@@ -111,7 +264,16 @@
"sendtype": sendtype, "sendtype": sendtype,
"url": url, "url": url,
"executeparamter": executeparamter, "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) { success: function (result) {
if (result.code == 200) { 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 @@ ...@@ -23,7 +23,7 @@
<hr/> <hr/>
<div class="col-md-6" style="padding-left:10px;"> <div class="col-md-6" style="padding-left:10px;">
<form action="import" method="post"> <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="新增定时任务"/> value="新增定时任务"/>
</form> </form>
</div> </div>
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<div class="input-group"> <div class="input-group">
<input type="input" class="form-control" aria-label="..." name="name"/> <input type="input" class="form-control" aria-label="..." name="name"/>
<div class="input-group-btn"> <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>
</div> </div>
</form> </form>
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
<tr> <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;">任务名称</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> <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 @@ ...@@ -76,15 +76,15 @@
<td> <td>
<span th:if="${task.frozenstatus eq 'UNFROZEN'}"> <input type="button" <span th:if="${task.frozenstatus eq 'UNFROZEN'}"> <input type="button"
class="btn btn-3d btn-danger" 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> th:onclick="'javascript:startOrStop('+${task.taskno}+')'"/>&nbsp;</span>
<span th:if="${task.frozenstatus eq 'FROZEN'}"> <input type="button" <span th:if="${task.frozenstatus eq 'FROZEN'}"> <input type="button"
class="btn btn-3d btn-success" 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> 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="立刻运行一次"/> 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="修改"/> th:onclick="'javascript:editpage('+${task.id}+')'" value="修改"/>
</td> </td>
</tr> </tr>
......
...@@ -11,6 +11,10 @@ ...@@ -11,6 +11,10 @@
<link rel="stylesheet" type="text/css" th:href="@{/css/red.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/simple-line-icons.css}"/>
<link rel="stylesheet" type="text/css" th:href="@{/css/style.css}"/> <link rel="stylesheet" type="text/css" th:href="@{/css/style.css}"/>
<style type="text/css">
.col-sm-10 {margin-bottom: 10px}
</style>
</head> </head>
<body> <body>
<div class="col-md-12 top-20 padding-0"> <div class="col-md-12 top-20 padding-0">
...@@ -67,9 +71,10 @@ ...@@ -67,9 +71,10 @@
</div> </div>
<div class="form-group"><label <div class="form-group"><label
class="col-sm-2 control-label text-right">定时配置规则:</label> class="col-sm-2 control-label text-right">间隔时间(秒):</label>
<div class="col-sm-10"><input type="text" <div class="col-sm-10">
placeholder="(例如: * /5 * * * * ? 每5秒执行一次)" <input type="number" min="1" max="60" step="1"
placeholder="间隔时间"
name="schedulerrule" name="schedulerrule"
th:value="${taskInformation.schedulerrule}" th:value="${taskInformation.schedulerrule}"
id="schedulerrule" id="schedulerrule"
...@@ -126,10 +131,9 @@ ...@@ -126,10 +131,9 @@
<div class="form-group"> <div class="form-group">
<div class="col-sm-10"> <div class="col-sm-10">
<input type="text" name="videoid" th:value="${taskInformation.videoid}" <input type="text" name="videoid" th:value="${taskInformation.videoid}"
id="videoid" class="form-control"> id="videoid" class="form-control" style="width:50%;float: left">
<a id="getrtsp" href=" javascript:void(0)">获得监控图片</a> <a id="getrtsp" href=" javascript:void(0)" style="float: left;padding-left: 12px;padding-top: 10px;">获得监控图片</a>
<a id="getwidth" href=" javascript:void(0)">编辑监控范围</a> <a id="getwidth" href=" javascript:void(0)" style="padding-left: 12px; padding-top: 10px;">编辑监控范围</a>
</div> </div>
</div> </div>
...@@ -222,9 +226,9 @@ ...@@ -222,9 +226,9 @@
id="timekey" class="form-control"></div> id="timekey" class="form-control"></div>
</div> </div>
<input type="button" class="btn btn-3d btn-danger" th:onclick="'history.go(-1);'" align="left" <input type="button" class="btn btn-3d btn-warning" th:onclick="'history.go(-1);'" align="left"
style="float:left;margin-left:700px;" value="关闭"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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" value="保存"/> <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> </form>
<!--</div>--> <!--</div>-->
</div> </div>
...@@ -234,10 +238,11 @@ ...@@ -234,10 +238,11 @@
</div> </div>
<canvas id="draw-canvas" width="600" height="400" <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> </canvas>
<script type="text/javascript" th:inline="javascript"> <script type="text/javascript" th:inline="javascript">
class DrawRectangle{ class DrawRectangle{
constructor(id, options){ constructor(id, options){
this.canvas = document.getElementById(id); //canvas标签 this.canvas = document.getElementById(id); //canvas标签
this.ctx = this.canvas.getContext('2d'); this.ctx = this.canvas.getContext('2d');
...@@ -282,7 +287,7 @@ ...@@ -282,7 +287,7 @@
} }
init(cvw,cvh,imgw,imgh){ init(cvw,cvh,imgw,imgh){
var item= this.layers[1]; var item= this.layers[1];
this.ratew=cvw/imgw; this.ratew=cvw/imgw;
this.rateh=cvh/imgh; this.rateh=cvh/imgh;
this.ctx.beginPath(); this.ctx.beginPath();
...@@ -304,45 +309,45 @@ ...@@ -304,45 +309,45 @@
console.log(`item`,item) console.log(`item`,item)
this.ctx.stroke(); this.ctx.stroke();
console.log(`init:`,this.layers); console.log(`init:`,this.layers);
} }
//设置图片为canvas的背景 //设置图片为canvas的背景
setImageBackground(src){ setImageBackground(src){
const img = new Image(); const img = new Image();
img.src = src; img.src = src;
img.onload = () =>{ img.onload = () =>{
let let
actImgW = img.width, actImgW = img.width,
actImgH = img.height, actImgH = img.height,
imgW = actImgW, imgW = actImgW,
imgH = actImgH, imgH = actImgH,
rate = 1, rate = 1,
left = 0, left = 0,
top = 0, top = 0,
canvasW=600, canvasW=600,
canvasH=400; canvasH=400;
//因为canvas画布的宽高固定,所以通过判断图片的宽高来进行缩放处理 //因为canvas画布的宽高固定,所以通过判断图片的宽高来进行缩放处理
if (actImgW > canvasW || actImgH > canvasH) { if (actImgW > canvasW || actImgH > canvasH) {
if (actImgW / actImgH >= canvasW / canvasH) { if (actImgW / actImgH >= canvasW / canvasH) {
imgW = canvasW; imgW = canvasW;
rate = actImgW / canvasW; rate = actImgW / canvasW;
imgH = actImgH / rate; imgH = actImgH / rate;
top = (canvasH - imgH) / 2; top = (canvasH - imgH) / 2;
} else { } else {
imgH = canvasH; imgH = canvasH;
rate = actImgH / canvasH; rate = actImgH / canvasH;
imgW = actImgW / rate; imgW = actImgW / rate;
left = (canvasW - imgW) / 2; left = (canvasW - imgW) / 2;
} }
} else { } else {
left = (canvasW - imgW) / 2; left = (canvasW - imgW) / 2;
top = (canvasH - imgH) / 2; top = (canvasH - imgH) / 2;
} }
//this.ctx.drawImage(img, left, top, imgW, imgH); //this.ctx.drawImage(img, left, top, imgW, imgH);
//if (img.labelVos) //if (img.labelVos)
//drawRect(this.ctx, img, left, top, rate); //drawRect(this.ctx, img, left, top, rate);
const _this = this; const _this = this;
//img.onload = ()=> { //img.onload = ()=> {
_this.canvas.width = imgW; _this.canvas.width = imgW;
_this.canvas.height = imgH; _this.canvas.height = imgH;
_this.config.width = actImgW; _this.config.width = actImgW;
...@@ -350,10 +355,10 @@ ...@@ -350,10 +355,10 @@
_this.canvas.style.backgroundImage = "url(" + img.src + ")"; _this.canvas.style.backgroundImage = "url(" + img.src + ")";
_this.canvas.style.backgroundSize = `${imgW}px ${imgH}px`; _this.canvas.style.backgroundSize = `${imgW}px ${imgH}px`;
_this.init(imgW,imgH,actImgW,actImgH); _this.init(imgW,imgH,actImgW,actImgH);
// } // }
} }
} }
//左侧拉伸展 //左侧拉伸展
...@@ -497,19 +502,13 @@ ...@@ -497,19 +502,13 @@
} }
position.width = position.x2 - position.x1 position.width = position.x2 - position.x1
position.height = position.y2 - position.y1 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 return position
} }
mousedown(e){ mousedown(e){
if($("#changewidthnot").val()=="1") { if($("#changewidthnot").val()=="1") {
this.startX = (e.pageX - $("#draw-canvas").offset().left) / this.scale; this.startX = (e.pageX -this.canvas.offsetLeft ) / this.scale;
this.startY = (e.pageY - $("#draw-canvas").offset().top) / this.scale; this.startY = (e.pageY - this.canvas.offsetTop) / this.scale;
this.currentR = this.isPointInRetc(this.startX, this.startY); this.currentR = this.isPointInRetc(this.startX, this.startY);
if (this.currentR) { if (this.currentR) {
this.leftDistance = this.startX - this.currentR.x1; this.leftDistance = this.startX - this.currentR.x1;
...@@ -523,8 +522,8 @@ ...@@ -523,8 +522,8 @@
mousemove(e){ mousemove(e){
if($("#changewidthnot").val()=="1") { if($("#changewidthnot").val()=="1") {
this.endX = (e.pageX - $("#draw-canvas").offset().left) / this.scale; this.endX = (e.pageX - this.canvas.offsetLeft) / this.scale;
this.endY = (e.pageY - $("#draw-canvas").offset().top) / this.scale; this.endY = (e.pageY - this.canvas.offsetTop) / this.scale;
// console.log(`mousemove`, this.endX, this.endY); // console.log(`mousemove`, this.endX, this.endY);
this.ctx.save(); this.ctx.save();
this.ctx.setLineDash([5]) this.ctx.setLineDash([5])
...@@ -571,7 +570,6 @@ ...@@ -571,7 +570,6 @@
} }
} }
} }
const draw = new DrawRectangle('draw-canvas', { const draw = new DrawRectangle('draw-canvas', {
src: $("#imgsrc").val(), src: $("#imgsrc").val(),
layers:[{}, layers:[{},
...@@ -582,22 +580,21 @@ ...@@ -582,22 +580,21 @@
"y2":parseInt($("#objecty").val())+parseInt($("#objecth").val()), "y2":parseInt($("#objecty").val())+parseInt($("#objecth").val()),
"width":parseInt($("#objectw").val()), "width":parseInt($("#objectw").val()),
"height":parseInt($("#objecth").val()), "height":parseInt($("#objecth").val()),
"strokeStyle":"green", "strokeStyle":"red",
"type":0 "type":0
} }
] ]
}); });
$( function () { $( function () {
$("#getwidth").on('click', function (e) { $("#getwidth").on('click', function (e) {
if($("#changewidthnot").val()=="1") { if($("#changewidthnot").val()=="1") {
$("#changewidthnot").val("0"); $("#changewidthnot").val("0");
$("#draw-canvas").style.cursor = "hand"; // $("#draw-canvas").style.cursor = "hand";
} }
else { else {
$("#changewidthnot").val("1"); $("#changewidthnot").val("1");
$("#draw-canvas").style.cursor = "crosshair"; // $("#draw-canvas").style.cursor = "crosshair";
} }
}); });
...@@ -610,7 +607,7 @@ ...@@ -610,7 +607,7 @@
success: function (result) { success: function (result) {
if (result.code == 200) { if (result.code == 200) {
if(result.message.indexOf(",")>-1){ if(result.message.indexOf(",")>-1){
$("#executeparamter").val(result.message.split(",")[1]); $("#executeparamter").val($("#videoid").val());
$("#rtsp").val(result.message.split(",")[1]); $("#rtsp").val(result.message.split(",")[1]);
$("#imgsrc").val(result.message.split(",")[0]); $("#imgsrc").val(result.message.split(",")[0]);
draw.src=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