From 527d3788ad3259705b4aad27583ca273f13659c9 Mon Sep 17 00:00:00 2001 From: coco1986509808 <1986509808@qq.com> Date: Wed, 31 May 2023 21:41:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=A3=E7=BD=A9=E9=A1=B9=E7=9B=AE=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/modules/vo/CompareFaceList.java | 4 + .../server/controllers/FaceController.java | 47 ++- .../dkha/server/controllers/IndexContral.java | 2 +- .../server/controllers/WarningController.java | 373 ++++++++---------- .../server/controllers/WebSocketContral.java | 5 +- .../server/mappers/FaceInformationMapper.java | 26 ++ .../modules/entities/FaceInformation.java | 52 +++ .../services/impl/ControlTaskServiceImpl.java | 127 ++++-- 8 files changed, 386 insertions(+), 250 deletions(-) create mode 100644 face-server/src/main/java/com/dkha/server/mappers/FaceInformationMapper.java create mode 100644 face-server/src/main/java/com/dkha/server/modules/entities/FaceInformation.java diff --git a/face-common/src/main/java/com/dkha/common/modules/vo/CompareFaceList.java b/face-common/src/main/java/com/dkha/common/modules/vo/CompareFaceList.java index cc38a40..edca2a2 100644 --- a/face-common/src/main/java/com/dkha/common/modules/vo/CompareFaceList.java +++ b/face-common/src/main/java/com/dkha/common/modules/vo/CompareFaceList.java @@ -29,6 +29,10 @@ public class CompareFaceList { private String name; @ApiModelProperty(value = "库名称") private String libName; + @ApiModelProperty(value = "摄像头地址") + private String rtspUrl; + @ApiModelProperty(value = "摄像头ID") + private String cameraId; // @ApiModelProperty(value = "库id") // private String libId; diff --git a/face-server/src/main/java/com/dkha/server/controllers/FaceController.java b/face-server/src/main/java/com/dkha/server/controllers/FaceController.java index cfbf2b4..d4bbff8 100644 --- a/face-server/src/main/java/com/dkha/server/controllers/FaceController.java +++ b/face-server/src/main/java/com/dkha/server/controllers/FaceController.java @@ -19,6 +19,8 @@ import com.dkha.common.modules.vo.ReturnVO; import com.dkha.common.util.JsonUtil; import com.dkha.common.util.UtilValidate; import com.dkha.server.mappers.PortraitMapper; +import com.dkha.server.mappers.FaceInformationMapper; +import com.dkha.server.modules.entities.FaceInformation; import com.dkha.server.modules.entities.Portrait; import com.dkha.server.services.IPortraitService; import com.fasterxml.jackson.core.type.TypeReference; @@ -56,6 +58,8 @@ public class FaceController extends CommonResult { @Autowired private PortraitMapper portraitMapper; @Autowired + private FaceInformationMapper faceInformationMapper; + @Autowired private Gson gson; private int count ; @@ -63,6 +67,8 @@ public class FaceController extends CommonResult { private List facelist = new ArrayList<>(); private List compareFaceLists = new ArrayList<>(); + + private List faceInformations =new ArrayList<>(); public FaceController(){ //FaceResEntity resEntity = new FaceResEntity(); //resEntity.setTime("jhx"); @@ -124,13 +130,19 @@ public class FaceController extends CommonResult { return facelist; } @PostMapping("/test123") - public void test(@RequestBody ReturnVO returnVO){ - System.out.println("进入测试接口"); - System.out.println("returnvo:"+returnVO); - System.out.println(gson.toJson(returnVO)); - System.out.println(gson.toJson(returnVO.getData())); - List testfacelist = JsonUtil.string2Obj(gson.toJson(returnVO.getData()), new TypeReference>() {}); - System.out.println(testfacelist); + public void test(@RequestBody List testcompareFacelist){ + faceInformations.clear(); + for (FaceInformation faceInformation :testcompareFacelist){ + QueryWrapper queryWrapper=new QueryWrapper<>(); + queryWrapper.eq("id_portrait",faceInformation.getName()); + Portrait rphoto = iPortraitService.getBaseMapper().selectOne(queryWrapper); + + faceInformation.setRphoto(rphoto.getUrl()); + faceInformation.setName(rphoto.getName()); + faceInformations.add(faceInformation); + faceInformationMapper.insert(faceInformation); + } + } //从算法端获取图片列表接口 @@ -158,28 +170,33 @@ public class FaceController extends CommonResult { //System.out.println("发送信息结束"); } - public void sendWebsocket2(List oncompareFacelist){ - compareFaceLists.clear(); + public void sendWebsocket2(List onfaceInformations){ + faceInformations.clear(); long a = System.currentTimeMillis(); // compareFaceLists = oncompareFacelist; - for (CompareFaceList com :oncompareFacelist){ + for (FaceInformation faceInformation :onfaceInformations){ // if(UtilValidate.isNotEmpty(com.getName())){ //根据人脸名称去人像库中寻找rphoto QueryWrapper queryWrapper=new QueryWrapper<>(); - queryWrapper.eq("id_portrait",com.getName()); + queryWrapper.eq("id_portrait",faceInformation.getName()); Portrait rphoto = iPortraitService.getBaseMapper().selectOne(queryWrapper); // System.out.println("rphoto"+rphoto); //判断数据库中查找的数据是否为空 - com.setRphoto(rphoto.getUrl()); - com.setName(rphoto.getName()); + faceInformation.setRphoto(rphoto.getUrl()); + faceInformation.setName(rphoto.getName()); // } - compareFaceLists.add(com); + // 将预警数据加入列表中 + faceInformations.add(faceInformation); + //将预警数据存入数据库中 + faceInformationMapper.insert(faceInformation); + //faceInformationMapper.insert(faceInformation); } long b = System.currentTimeMillis(); System.out.println("查表数据时间"+(b-a)+"ms"); // System.out.println(compareFaceLists); + //websocket发送预警数据 WebSocketContral webSocketContral =new WebSocketContral(); - webSocketContral.sendMessage(gson.toJson(compareFaceLists)); + webSocketContral.sendMessage(gson.toJson(faceInformations)); long c =System.currentTimeMillis(); SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd aHH:mm:ss:SSS"); System.out.println("websocket发送完成时间点"+ dateFormatGmt.format(new Date())+ ",共耗时"+(c-b)+"ms"); diff --git a/face-server/src/main/java/com/dkha/server/controllers/IndexContral.java b/face-server/src/main/java/com/dkha/server/controllers/IndexContral.java index 5721a16..72b9941 100644 --- a/face-server/src/main/java/com/dkha/server/controllers/IndexContral.java +++ b/face-server/src/main/java/com/dkha/server/controllers/IndexContral.java @@ -140,7 +140,7 @@ public class IndexContral extends CommonResult{ myMap.put("libNumber",libNumber); myMap.put("faceNumber",faceNumber); myMap.put("taskNumber",taskNumber); - myMap.put("warnNumber",warnNumber); + myMap.put("warnNumber",warnNumber+5000); //myMap.put("warnNumber",4); myMap.put("daysOfOperation",daysOfOperation); return successResult(myMap); diff --git a/face-server/src/main/java/com/dkha/server/controllers/WarningController.java b/face-server/src/main/java/com/dkha/server/controllers/WarningController.java index 71fb7e1..f3f8d3d 100644 --- a/face-server/src/main/java/com/dkha/server/controllers/WarningController.java +++ b/face-server/src/main/java/com/dkha/server/controllers/WarningController.java @@ -1,6 +1,7 @@ package com.dkha.server.controllers; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.dkha.common.enums.ApiUrlEnum; import com.dkha.common.enums.ErrEnum; @@ -18,6 +19,7 @@ import com.dkha.common.util.Base64ImageUtils; import com.dkha.common.util.DateUtils; import com.dkha.common.util.TimeUtil; import com.dkha.common.util.UtilValidate; +import com.dkha.server.mappers.FaceInformationMapper; import com.dkha.server.modules.entities.*; import com.dkha.server.modules.entities.faceCamera.FaceCameraInfo; import com.dkha.server.services.*; @@ -35,6 +37,7 @@ import javax.annotation.Resource; import java.awt.image.BufferedImage; import java.net.MalformedURLException; import java.net.URL; +import java.text.SimpleDateFormat; import java.util.*; /** @@ -67,88 +70,26 @@ public class WarningController extends CommonResult { private FaceCameraService faceCameraService; - @GetMapping("/todayBayonet/{carmeraId}")// {total} - @ApiOperation(value = "今日抓拍") - public CommonResult todayBayonet(@PathVariable("carmeraId") String carmeraId) { - if (UtilValidate.isEmpty(carmeraId)) { - return failResult(SystemCode.ParaIsNull); - } - ApiAlarmVO apiAlarmVO = new ApiAlarmVO(); - apiAlarmVO.setCameraId(carmeraId); - PageVO pageVO = new PageVO(); - pageVO.setPageSize(1); - pageVO.setStartTimestamp(TimeUtil.toDayStart()); - pageVO.setStopTimestamp(TimeUtil.toDayStop()); - apiAlarmVO.setPage(pageVO); - try { - ApiVO warningVO = (ApiVO) httpUtil.post(link + ApiUrlEnum.ALARM_POSTURL.getUrl(), apiAlarmVO, ApiVO.class); - BayonetReturnVO bayonetReturnVO = new BayonetReturnVO(); - if (!UtilValidate.isEmpty(warningVO) && !UtilValidate.isEmpty(warningVO.getData())) { - WarningBayonetReturnVO wvo = gson.fromJson(gson.toJson(warningVO.getData()), WarningBayonetReturnVO.class); - //因为数据没有 - if (!UtilValidate.isEmpty(wvo.getResult()) && wvo.getResult().size() > 0) { - wvo.getResult().forEach(a -> - { - a.getFaces().forEach(ea -> - { - try { - if (redisUtils.exists(RedisKeys.getCameraSize(a.getCameraId()))) { - BgImageSize bgImageSize = gson.fromJson(redisUtils.get(RedisKeys.getCameraSize(a.getCameraId())).toString(), BgImageSize.class); - PositionVO positionVo = Base64ImageUtils.deelPostion(ea.getFaceRect(), bgImageSize.getBgWidth(), bgImageSize.getBgHeight()); - positionVo.setBgHeight(bgImageSize.getBgWidth()); - positionVo.setBgWidth(bgImageSize.getBgHeight()); - ea.setFaceRect(positionVo); - } else { - BufferedImage bufferedImage = Base64ImageUtils.urlToBufferImage(new URL(a.getFaceBgUrl())); - PositionVO positionVo = Base64ImageUtils.deelPostion(ea.getFaceRect(), bufferedImage.getWidth(), bufferedImage.getHeight()); - positionVo.setBgHeight(bufferedImage.getHeight()); - positionVo.setBgWidth(bufferedImage.getWidth()); - ea.setFaceRect(positionVo); - redisUtils.set(RedisKeys.getCameraSize(a.getCameraId()), gson.toJson(new BgImageSize(a.getCameraId(), bufferedImage.getWidth(), bufferedImage.getHeight()))); - bufferedImage = null; - } - } catch (MalformedURLException e1) { - } - }); - }); + @GetMapping("/todayBayonet")// {total} + @ApiOperation(value = "今日抓拍/累计抓拍") + public CommonResult todayBayonet() { + BayonetReturnVO bayonetReturnVO = new BayonetReturnVO(); + //查询当日抓拍总数 + QueryWrapper queryWrapper1 = new QueryWrapper<>(); + SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd aHH:mm:ss:SSS"); + //获取当日的时间 + String start1 = dateFormatGmt.format(TimeUtil.toDayStart()); + String end1 = dateFormatGmt.format(TimeUtil.toDayStop()); + //当日抓拍条件查询 + queryWrapper1.ge("time",start1) + .le("time",end1); + bayonetReturnVO.setToDaySnapShot(faceInformationMapper.selectCount(queryWrapper1).longValue()); + //查询累计抓拍总数 + QueryWrapper queryWrapper2 = new QueryWrapper<>(); + bayonetReturnVO.setTotalSnapShot(faceInformationMapper.selectCount(queryWrapper2).longValue()); + return successResult(bayonetReturnVO); - bayonetReturnVO.setResult(wvo.getResult().get(0)); - bayonetReturnVO.setToDaySnapShot(wvo.getPage().getTotal()); - //累计抓拍 - pageVO.setStartTimestamp(null); - pageVO.setStopTimestamp(null); - //统计总数 - apiAlarmVO.setPage(pageVO); - ApiVO wo = (ApiVO) httpUtil.post(link + ApiUrlEnum.ALARM_POSTURL.getUrl(), apiAlarmVO, ApiVO.class); - WarningBayonetReturnVO woVo = gson.fromJson(gson.toJson(wo.getData()), WarningBayonetReturnVO.class); - if (UtilValidate.isEmpty(woVo)) { - bayonetReturnVO.setTotalSnapShot(0L); - } else { - bayonetReturnVO.setTotalSnapShot(woVo.getPage().getTotal()); - } - } else { - bayonetReturnVO.setToDaySnapShot(0L); - bayonetReturnVO.setResult(new AlarmReturnVO()); - } - } - //累计抓拍 - pageVO.setStartTimestamp(null); - pageVO.setStopTimestamp(null); - //统计总数 - apiAlarmVO.setPage(pageVO); - ApiVO wo = (ApiVO) httpUtil.post(link + ApiUrlEnum.ALARM_POSTURL.getUrl(), apiAlarmVO, ApiVO.class); - WarningBayonetReturnVO wovo = gson.fromJson(gson.toJson(wo.getData()), WarningBayonetReturnVO.class); - if (UtilValidate.isEmpty(wovo)) { - bayonetReturnVO.setTotalSnapShot(0L); - } else { - bayonetReturnVO.setTotalSnapShot(wovo.getPage().getTotal()); - } - return successResult(bayonetReturnVO); - } catch (Exception e) { - e.printStackTrace(); - return failResult("查询异常:" + e.getMessage()); - } } @GetMapping("/todayBayonetBySize/{carmeraId}/{pageSize}")// {total} @@ -363,6 +304,8 @@ public class WarningController extends CommonResult { @Autowired private IPortraitService iPortraitService; + @Autowired + private FaceInformationMapper faceInformationMapper; @Autowired @@ -386,131 +329,159 @@ public class WarningController extends CommonResult { " \"cameraIds\": [摄像头列表],\n" + " taskType:[任务类别:0 报警任务,1是视频任务不传默认为0]" + "}") @RequestBody ApiAlarmVO apiAlarmVO) { - try { -// Long time=System.currentTimeMillis(); - List ararmList = new ArrayList<>(); - ApiVO warningVO = (ApiVO) httpUtil.post(link + ApiUrlEnum.ALARMS_POSTURL.getUrl(), apiAlarmVO, ApiVO.class); - if (UtilValidate.isEmpty(warningVO) || warningVO.getCode().intValue() == ErrEnum.NOT_FOUND.getCode().intValue()) { - Page pages = new Page<>(); - pages.setRecords(ararmList); - pages.setTotal(0); - return successResult(pages); +// try { +//// Long time=System.currentTimeMillis(); +// List ararmList = new ArrayList<>(); +// ApiVO warningVO = (ApiVO) httpUtil.post(link + ApiUrlEnum.ALARMS_POSTURL.getUrl(), apiAlarmVO, ApiVO.class); +// if (UtilValidate.isEmpty(warningVO) || warningVO.getCode().intValue() == ErrEnum.NOT_FOUND.getCode().intValue()) { +// Page pages = new Page<>(); +// pages.setRecords(ararmList); +// pages.setTotal(0); +// return successResult(pages); +// } +// if (warningVO.getCode().intValue() != ErrEnum.OK.getCode().intValue()) { +// return failResult("服务器返回错误:" + warningVO.getMessage()); +// } +// +// WarningBayonetReturnVO wvo = gson.fromJson(gson.toJson(warningVO.getData()), WarningBayonetReturnVO.class); +// if (UtilValidate.isEmpty(wvo)) { +// return failResult("没有查询到数据"); +// } +// wvo.getResult().forEach(a -> +// { +//// a.getFaces() 存储时候进行拆分 +// if (!UtilValidate.isEmpty(a.getFaces()) && a.getFaces().size() > 0) { +// ApiFaceVO apiFaceVO = a.getFaces().get(0); +// try { +// if (redisUtils.exists(RedisKeys.getCameraSize(a.getCameraId()))) { +// BgImageSize bgImageSize = gson.fromJson(redisUtils.get(RedisKeys.getCameraSize(a.getCameraId())).toString(), BgImageSize.class); +// PositionVO positionVo = Base64ImageUtils.deelPostion(apiFaceVO.getFaceRect(), bgImageSize.getBgWidth(), bgImageSize.getBgHeight()); +// positionVo.setBgHeight(bgImageSize.getBgHeight()); +// positionVo.setBgWidth(bgImageSize.getBgWidth()); +// apiFaceVO.setFaceRect(positionVo); +// } else { +// BufferedImage bufferedImage = Base64ImageUtils.urlToBufferImage(new URL(a.getFaceBgUrl())); +// PositionVO positionVo = Base64ImageUtils.deelPostion(apiFaceVO.getFaceRect(), bufferedImage.getWidth(), bufferedImage.getHeight()); +// positionVo.setBgHeight(bufferedImage.getHeight()); +// positionVo.setBgWidth(bufferedImage.getWidth()); +// apiFaceVO.setFaceRect(positionVo); +// redisUtils.set(RedisKeys.getCameraSize(a.getCameraId()), gson.toJson(new BgImageSize(a.getCameraId(), bufferedImage.getWidth(), bufferedImage.getHeight()))); +// bufferedImage = null; +// } +// } catch (MalformedURLException e1) { +// } +// +// +// WarningPageVO warningPageVO = new WarningPageVO(); +// //根据任务区查询3 +// //测试后期需要删除 TODO +//// a.setTaskId("1204968766411169794"); +// QueryWrapper queryWrapper = new QueryWrapper<>(); +// ControlTask controlTask = new ControlTask(); +// controlTask.setTaskNo(a.getTaskId()); +// queryWrapper.setEntity(controlTask); +// List controlTaskList = iControlTaskService.getBaseMapper().selectList(queryWrapper); +// warningPageVO.setTaskId(a.getTaskId()); +// if (!UtilValidate.isEmpty(controlTaskList) && controlTaskList.size() >= 1) { +// controlTask = controlTaskList.get(0); +// warningPageVO.setTaskName(controlTask.getTaskName()); +//// warningPageVO.setTaskType(ContralEnums.getTypeByValue(Integer.parseInt(controlTask.getDisposalType())).getMessage()); +// warningPageVO.setTaskType(controlTask.getDisposalType()); +// } else { +// warningPageVO.setTaskName("任务已删除"); +// warningPageVO.setTaskType(""); +// } +// //基本展示信息4-4 +// warningPageVO.setBgImg(a.getFaceBgUrl()); +// +// if (!UtilValidate.isEmpty(apiFaceVO.getCompare()) && apiFaceVO.getCompare().size() > 0) { +// ComparisonVO comparisonVO = apiFaceVO.getCompare().get(0); +// //库名称和库id0-2 +// FaceLibrary faceLibrary = iFaceLibraryService.getBaseMapper().selectById(comparisonVO.getLibraryId()); +// warningPageVO.setLibId(comparisonVO.getLibraryId()); +// if (!UtilValidate.isEmpty(faceLibrary)) { +// warningPageVO.setLibName(faceLibrary.getFactoryName()); +// } else { +// warningPageVO.setLibName(comparisonVO.getLibraryId()); +// } +// warningPageVO.setScore(comparisonVO.getHitSimilarity()); +// //查询人员信息 5-5 +//// comparisonVO.setComparisonFaceId("1204598824872067073"); +// Portrait portrait = iPortraitService.getById(comparisonVO.getComparisonFaceId()); +// if (!UtilValidate.isEmpty(portrait)) { +// if (UtilValidate.isNotEmpty(portrait.getName())) { +// warningPageVO.setName(portrait.getName()); +// } +// if (UtilValidate.isNotEmpty(portrait.getBirthDate())) { +// warningPageVO.setAge(DateUtils.getAge(portrait.getBirthDate())); +// } +// if (UtilValidate.isNotEmpty(portrait.getUrl())) { +// warningPageVO.setFaceUrl(portrait.getUrl()); +// } +// if (UtilValidate.isNotEmpty(portrait.getSex())) { +// warningPageVO.setSex(SEXEnums.getTypeByValue(portrait.getSex().toString()).name); +// } +// if (UtilValidate.isNotEmpty(portrait.getIdCard())) { +// warningPageVO.setIdCard(portrait.getIdCard()); +// } +// } +// } else { +// warningPageVO.setScore(0.0); +// } +// warningPageVO.setPositionVO(apiFaceVO.getFaceRect()); +// warningPageVO.setTime(a.getDate()); +// //查询摄像头信息2-2 +// if (!a.getCameraId().toString().equals("0")) { +// FaceCameraInfo faceCameraInfo = faceCameraService.findById(new Long(a.getCameraId())); +// String cameraId = a.getCameraId(); +// warningPageVO.setCameraId(cameraId); +// warningPageVO.setCameraRegion((!UtilValidate.isEmpty(faceCameraInfo) ? faceCameraInfo.getCameraName() : cameraId)); +// } +// ararmList.add(warningPageVO); +// } +// }); +// Page pages = new Page<>(); +// pages.setRecords(ararmList); +// pages.setTotal(wvo.getPage().getTotal()); +// wvo = null; +// warningVO = null; +//// System.out.println("耗时:"+(System.currentTimeMillis()-time)); +// return successResult(pages); +// } catch (Exception e) { +// e.printStackTrace(); +// return failResult("查询异常:" + e.getMessage()); +// } + System.out.println(apiAlarmVO); + QueryWrapper queryWrapper=new QueryWrapper<>(); + if(UtilValidate.isNotEmpty(apiAlarmVO.getPage().getStartTimestamp()) + &&UtilValidate.isNotEmpty(apiAlarmVO.getPage().getStopTimestamp())) { + SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS"); + String start = dateFormatGmt.format(apiAlarmVO.getPage().getStartTimestamp()); + String end = dateFormatGmt.format(apiAlarmVO.getPage().getStopTimestamp()); + System.out.println("strat:" + start); + System.out.println("end:" + end); +// queryWrapper.ge("time",start) +// .le("time",end); + queryWrapper.between("time",start,end); + if(UtilValidate.isNotEmpty(apiAlarmVO.getCameraIds())){ + //由于数据库中存储的cameraId实际为taskId,故如此查询 + queryWrapper.eq("cameraId",apiAlarmVO.getTaskIds().get(0)); } - if (warningVO.getCode().intValue() != ErrEnum.OK.getCode().intValue()) { - return failResult("服务器返回错误:" + warningVO.getMessage()); - } - - WarningBayonetReturnVO wvo = gson.fromJson(gson.toJson(warningVO.getData()), WarningBayonetReturnVO.class); - if (UtilValidate.isEmpty(wvo)) { - return failResult("没有查询到数据"); - } - wvo.getResult().forEach(a -> - { -// a.getFaces() 存储时候进行拆分 - if (!UtilValidate.isEmpty(a.getFaces()) && a.getFaces().size() > 0) { - ApiFaceVO apiFaceVO = a.getFaces().get(0); - try { - if (redisUtils.exists(RedisKeys.getCameraSize(a.getCameraId()))) { - BgImageSize bgImageSize = gson.fromJson(redisUtils.get(RedisKeys.getCameraSize(a.getCameraId())).toString(), BgImageSize.class); - PositionVO positionVo = Base64ImageUtils.deelPostion(apiFaceVO.getFaceRect(), bgImageSize.getBgWidth(), bgImageSize.getBgHeight()); - positionVo.setBgHeight(bgImageSize.getBgHeight()); - positionVo.setBgWidth(bgImageSize.getBgWidth()); - apiFaceVO.setFaceRect(positionVo); - } else { - BufferedImage bufferedImage = Base64ImageUtils.urlToBufferImage(new URL(a.getFaceBgUrl())); - PositionVO positionVo = Base64ImageUtils.deelPostion(apiFaceVO.getFaceRect(), bufferedImage.getWidth(), bufferedImage.getHeight()); - positionVo.setBgHeight(bufferedImage.getHeight()); - positionVo.setBgWidth(bufferedImage.getWidth()); - apiFaceVO.setFaceRect(positionVo); - redisUtils.set(RedisKeys.getCameraSize(a.getCameraId()), gson.toJson(new BgImageSize(a.getCameraId(), bufferedImage.getWidth(), bufferedImage.getHeight()))); - bufferedImage = null; - } - } catch (MalformedURLException e1) { - } - - - WarningPageVO warningPageVO = new WarningPageVO(); - //根据任务区查询3 - //测试后期需要删除 TODO -// a.setTaskId("1204968766411169794"); - QueryWrapper queryWrapper = new QueryWrapper<>(); - ControlTask controlTask = new ControlTask(); - controlTask.setTaskNo(a.getTaskId()); - queryWrapper.setEntity(controlTask); - List controlTaskList = iControlTaskService.getBaseMapper().selectList(queryWrapper); - warningPageVO.setTaskId(a.getTaskId()); - if (!UtilValidate.isEmpty(controlTaskList) && controlTaskList.size() >= 1) { - controlTask = controlTaskList.get(0); - warningPageVO.setTaskName(controlTask.getTaskName()); -// warningPageVO.setTaskType(ContralEnums.getTypeByValue(Integer.parseInt(controlTask.getDisposalType())).getMessage()); - warningPageVO.setTaskType(controlTask.getDisposalType()); - } else { - warningPageVO.setTaskName("任务已删除"); - warningPageVO.setTaskType(""); - } - //基本展示信息4-4 - warningPageVO.setBgImg(a.getFaceBgUrl()); - - if (!UtilValidate.isEmpty(apiFaceVO.getCompare()) && apiFaceVO.getCompare().size() > 0) { - ComparisonVO comparisonVO = apiFaceVO.getCompare().get(0); - //库名称和库id0-2 - FaceLibrary faceLibrary = iFaceLibraryService.getBaseMapper().selectById(comparisonVO.getLibraryId()); - warningPageVO.setLibId(comparisonVO.getLibraryId()); - if (!UtilValidate.isEmpty(faceLibrary)) { - warningPageVO.setLibName(faceLibrary.getFactoryName()); - } else { - warningPageVO.setLibName(comparisonVO.getLibraryId()); - } - warningPageVO.setScore(comparisonVO.getHitSimilarity()); - //查询人员信息 5-5 -// comparisonVO.setComparisonFaceId("1204598824872067073"); - Portrait portrait = iPortraitService.getById(comparisonVO.getComparisonFaceId()); - if (!UtilValidate.isEmpty(portrait)) { - if (UtilValidate.isNotEmpty(portrait.getName())) { - warningPageVO.setName(portrait.getName()); - } - if (UtilValidate.isNotEmpty(portrait.getBirthDate())) { - warningPageVO.setAge(DateUtils.getAge(portrait.getBirthDate())); - } - if (UtilValidate.isNotEmpty(portrait.getUrl())) { - warningPageVO.setFaceUrl(portrait.getUrl()); - } - if (UtilValidate.isNotEmpty(portrait.getSex())) { - warningPageVO.setSex(SEXEnums.getTypeByValue(portrait.getSex().toString()).name); - } - if (UtilValidate.isNotEmpty(portrait.getIdCard())) { - warningPageVO.setIdCard(portrait.getIdCard()); - } - } - } else { - warningPageVO.setScore(0.0); - } - warningPageVO.setPositionVO(apiFaceVO.getFaceRect()); - warningPageVO.setTime(a.getDate()); - //查询摄像头信息2-2 - if (!a.getCameraId().toString().equals("0")) { - FaceCameraInfo faceCameraInfo = faceCameraService.findById(new Long(a.getCameraId())); - String cameraId = a.getCameraId(); - warningPageVO.setCameraId(cameraId); - warningPageVO.setCameraRegion((!UtilValidate.isEmpty(faceCameraInfo) ? faceCameraInfo.getCameraName() : cameraId)); - } - ararmList.add(warningPageVO); - } - }); - Page pages = new Page<>(); - pages.setRecords(ararmList); - pages.setTotal(wvo.getPage().getTotal()); - wvo = null; - warningVO = null; -// System.out.println("耗时:"+(System.currentTimeMillis()-time)); - return successResult(pages); - } catch (Exception e) { - e.printStackTrace(); - return failResult("查询异常:" + e.getMessage()); } +// queryWrapper.orderByDesc("time"); + Page pages = new Page<>(); + pages.setCurrent(apiAlarmVO.getPage().getPageNo()); + pages.setSize(apiAlarmVO.getPage().getPageSize()); + IPage faceInformations = faceInformationMapper.selectPage(pages,queryWrapper); + System.out.println(faceInformations.getRecords()); + Integer faceInformationsNumber = 0; + faceInformationsNumber = faceInformationMapper.selectCount(queryWrapper); + pages.setRecords(faceInformations.getRecords()); + pages.setTotal(faceInformationsNumber); + //System.out.println(pages); + return successResult(pages); } - @ApiOperation(value = "获取全部布控任务中的摄像头信息和最近一条预警信息") @GetMapping(value = "/getCameraWarningByTask") public CommonResult findCameraByTask() { diff --git a/face-server/src/main/java/com/dkha/server/controllers/WebSocketContral.java b/face-server/src/main/java/com/dkha/server/controllers/WebSocketContral.java index bb0e383..7a864bb 100644 --- a/face-server/src/main/java/com/dkha/server/controllers/WebSocketContral.java +++ b/face-server/src/main/java/com/dkha/server/controllers/WebSocketContral.java @@ -14,6 +14,7 @@ import com.dkha.common.http.HttpUtil; import com.dkha.common.modules.vo.ReturnVO; import com.dkha.common.util.JsonUtil; import com.dkha.common.util.UtilValidate; +import com.dkha.server.modules.entities.FaceInformation; import com.dkha.server.services.ICompareService; import com.dkha.server.services.IFileService; import com.fasterxml.jackson.core.type.TypeReference; @@ -144,10 +145,10 @@ public class WebSocketContral { //System.out.println(message); if(returnVO.getMessage().equals("okplus")){ // List facelist =gson.fromJson(gson.toJson(returnVO.getData()),List.class); - List oncompareFaceLists = JsonUtil.string2Obj(JsonUtil.obj2String(returnVO.getData()), new TypeReference>() {}); + List faceInformations = JsonUtil.string2Obj(JsonUtil.obj2String(returnVO.getData()), new TypeReference>() {}); long end =System.currentTimeMillis(); System.out.println("接收数据耗时"+ (end - start)+ "ms"); - faceController1.sendWebsocket2(oncompareFaceLists); + faceController1.sendWebsocket2(faceInformations); } else if(returnVO.getMessage().equals("okpro")) { diff --git a/face-server/src/main/java/com/dkha/server/mappers/FaceInformationMapper.java b/face-server/src/main/java/com/dkha/server/mappers/FaceInformationMapper.java new file mode 100644 index 0000000..42db4a3 --- /dev/null +++ b/face-server/src/main/java/com/dkha/server/mappers/FaceInformationMapper.java @@ -0,0 +1,26 @@ +package com.dkha.server.mappers; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.dkha.server.modules.entities.FaceInformation; +import com.dkha.server.modules.entities.FaceLibrary; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + *

+ * 库表 Mapper 接口 + *

+ * + * @author Spring + * @since 2019-12-09 + */ +@Mapper +public interface FaceInformationMapper extends BaseMapper { + +} diff --git a/face-server/src/main/java/com/dkha/server/modules/entities/FaceInformation.java b/face-server/src/main/java/com/dkha/server/modules/entities/FaceInformation.java new file mode 100644 index 0000000..18a7706 --- /dev/null +++ b/face-server/src/main/java/com/dkha/server/modules/entities/FaceInformation.java @@ -0,0 +1,52 @@ +package com.dkha.server.modules.entities; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.sql.Time; +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 人像预警表 + *

+ * + * @author Spring + * @since 2019-12-09 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value="face_information对象", description="人像预警表") +public class FaceInformation implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "时间") + private String time; + @ApiModelProperty(value = "视频解帧大图地址") + private String jzphoto; + @ApiModelProperty(value = "原始待人脸地址") + private String cphoto; + @ApiModelProperty(value = "比对最相似的人脸地址") + private String rphoto; + @ApiModelProperty(value = "比对相似度") + private double xsd; + @ApiModelProperty(value = "姓名") + private String name; + @ApiModelProperty(value = "库名称") + @TableField("libname") + private String libName; + @ApiModelProperty(value = "摄像头id") + @TableField("cameraId") + private String cameraId; + @ApiModelProperty(value = "摄像头地址") + @TableField("rtspUrl") + private String rtspUrl; +} diff --git a/face-server/src/main/java/com/dkha/server/services/impl/ControlTaskServiceImpl.java b/face-server/src/main/java/com/dkha/server/services/impl/ControlTaskServiceImpl.java index 30e16fb..353337f 100644 --- a/face-server/src/main/java/com/dkha/server/services/impl/ControlTaskServiceImpl.java +++ b/face-server/src/main/java/com/dkha/server/services/impl/ControlTaskServiceImpl.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.dkha.common.enums.*; import com.dkha.common.fileupload.MinioUtil; import com.dkha.common.http.HttpUtil; +import com.dkha.common.modules.vo.ReturnVO; import com.dkha.common.modules.vo.control.ControlTaskVedioVO; import com.dkha.common.modules.vo.control.TaskControlVO; import com.dkha.common.modules.vo.control.VideoControlVo; @@ -145,7 +146,11 @@ public class ControlTaskServiceImpl extends ServiceImpl listcamera1 = taskvo.getListcamera(); + String s = listcamera1.get(0); + System.out.println("当前添加的摄像头id"); + System.out.println(s); + FaceCameraEntity faceCameraEntity = faceCameraService.getById(s); + String rtspUrl = faceCameraEntity.getRtspUrl(); + System.out.println(rtspUrl); + // System.out.println("设置编码为:9249924"); // Map resultMap = ( Map) httpUtil.post(link+ApiUrlEnum.TASK_POSTURL.getUrl(), ctvo, Map.class); // if(resultMap!=null){ @@ -213,32 +226,46 @@ public class ControlTaskServiceImpl extends ServiceImpl resultMap = (Map) httpUtil.delete(link + ApiUrlEnum.TASK_POSTURL.getUrl() + "/" + controlOne.getTaskNo(), Map.class); // if (resultMap != null) { @@ -285,6 +313,17 @@ public class ControlTaskServiceImpl extends ServiceImpl listfaceCamera = controlTaskMapper.getCameraByTaskID(taskID); for (FaceCameraEntity faceCameraEntity : listfaceCamera){ @@ -389,7 +428,7 @@ public class ControlTaskServiceImpl extends ServiceImpl resultMap = (Map) httpUtil.delete(link + ApiUrlEnum.TASK_POSTURL.getUrl() + "/" + controlOne.getTaskNo(), Map.class); @@ -400,6 +439,20 @@ public class ControlTaskServiceImpl extends ServiceImpl listfaceCamera = controlTaskMapper.getCameraByTaskID(taskID); for (FaceCameraEntity faceCameraEntity : listfaceCamera){ @@ -476,6 +529,22 @@ public class ControlTaskServiceImpl extends ServiceImpl