口罩项目第一版
This commit is contained in:
		
							parent
							
								
									2b03322398
								
							
						
					
					
						commit
						527d3788ad
					
				| @ -29,6 +29,10 @@ public class CompareFaceList { | |||||||
|     private String name; |     private String name; | ||||||
|     @ApiModelProperty(value = "库名称") |     @ApiModelProperty(value = "库名称") | ||||||
|     private String libName; |     private String libName; | ||||||
|  |     @ApiModelProperty(value = "摄像头地址") | ||||||
|  |     private String rtspUrl; | ||||||
|  |     @ApiModelProperty(value = "摄像头ID") | ||||||
|  |     private String cameraId; | ||||||
| //    @ApiModelProperty(value = "库id") | //    @ApiModelProperty(value = "库id") | ||||||
| //    private String libId; | //    private String libId; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -19,6 +19,8 @@ import com.dkha.common.modules.vo.ReturnVO; | |||||||
| import com.dkha.common.util.JsonUtil; | import com.dkha.common.util.JsonUtil; | ||||||
| import com.dkha.common.util.UtilValidate; | import com.dkha.common.util.UtilValidate; | ||||||
| import com.dkha.server.mappers.PortraitMapper; | 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.modules.entities.Portrait; | ||||||
| import com.dkha.server.services.IPortraitService; | import com.dkha.server.services.IPortraitService; | ||||||
| import com.fasterxml.jackson.core.type.TypeReference; | import com.fasterxml.jackson.core.type.TypeReference; | ||||||
| @ -56,6 +58,8 @@ public class FaceController extends CommonResult { | |||||||
|     @Autowired |     @Autowired | ||||||
|     private PortraitMapper portraitMapper; |     private PortraitMapper portraitMapper; | ||||||
|     @Autowired |     @Autowired | ||||||
|  |     private  FaceInformationMapper faceInformationMapper; | ||||||
|  |     @Autowired | ||||||
|     private Gson gson; |     private Gson gson; | ||||||
| 
 | 
 | ||||||
|     private  int count ; |     private  int count ; | ||||||
| @ -63,6 +67,8 @@ public class FaceController extends CommonResult { | |||||||
|     private List<FaceResEntity> facelist = new ArrayList<>(); |     private List<FaceResEntity> facelist = new ArrayList<>(); | ||||||
| 
 | 
 | ||||||
|     private List<CompareFaceList> compareFaceLists = new ArrayList<>(); |     private List<CompareFaceList> compareFaceLists = new ArrayList<>(); | ||||||
|  | 
 | ||||||
|  |     private List<FaceInformation> faceInformations =new ArrayList<>(); | ||||||
|     public  FaceController(){ |     public  FaceController(){ | ||||||
|         //FaceResEntity  resEntity = new FaceResEntity(); |         //FaceResEntity  resEntity = new FaceResEntity(); | ||||||
|         //resEntity.setTime("jhx"); |         //resEntity.setTime("jhx"); | ||||||
| @ -124,13 +130,19 @@ public class FaceController extends CommonResult { | |||||||
|         return facelist; |         return facelist; | ||||||
|     } |     } | ||||||
|     @PostMapping("/test123") |     @PostMapping("/test123") | ||||||
|     public void test(@RequestBody ReturnVO returnVO){ |     public void test(@RequestBody List<FaceInformation> testcompareFacelist){ | ||||||
|         System.out.println("进入测试接口"); |             faceInformations.clear(); | ||||||
|         System.out.println("returnvo:"+returnVO); |         for (FaceInformation faceInformation :testcompareFacelist){ | ||||||
|         System.out.println(gson.toJson(returnVO)); |             QueryWrapper<Portrait> queryWrapper=new QueryWrapper<>(); | ||||||
|         System.out.println(gson.toJson(returnVO.getData())); |             queryWrapper.eq("id_portrait",faceInformation.getName()); | ||||||
|         List<FaceResEntity> testfacelist = JsonUtil.string2Obj(gson.toJson(returnVO.getData()), new TypeReference<List<FaceResEntity>>() {}); |             Portrait rphoto = iPortraitService.getBaseMapper().selectOne(queryWrapper); | ||||||
|         System.out.println(testfacelist); | 
 | ||||||
|  |             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("发送信息结束"); |         //System.out.println("发送信息结束"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public  void sendWebsocket2(List<CompareFaceList> oncompareFacelist){ |     public  void sendWebsocket2(List<FaceInformation> onfaceInformations){ | ||||||
|         compareFaceLists.clear(); |         faceInformations.clear(); | ||||||
|         long a = System.currentTimeMillis(); |         long a = System.currentTimeMillis(); | ||||||
| //        compareFaceLists = oncompareFacelist; | //        compareFaceLists = oncompareFacelist; | ||||||
|         for (CompareFaceList com :oncompareFacelist){ |         for (FaceInformation faceInformation :onfaceInformations){ | ||||||
| //            if(UtilValidate.isNotEmpty(com.getName())){ | //            if(UtilValidate.isNotEmpty(com.getName())){ | ||||||
|                 //根据人脸名称去人像库中寻找rphoto |                 //根据人脸名称去人像库中寻找rphoto | ||||||
|                 QueryWrapper<Portrait> queryWrapper=new QueryWrapper<>(); |                 QueryWrapper<Portrait> queryWrapper=new QueryWrapper<>(); | ||||||
|                 queryWrapper.eq("id_portrait",com.getName()); |                 queryWrapper.eq("id_portrait",faceInformation.getName()); | ||||||
|                 Portrait rphoto = iPortraitService.getBaseMapper().selectOne(queryWrapper); |                 Portrait rphoto = iPortraitService.getBaseMapper().selectOne(queryWrapper); | ||||||
| //                System.out.println("rphoto"+rphoto); | //                System.out.println("rphoto"+rphoto); | ||||||
|                 //判断数据库中查找的数据是否为空 |                 //判断数据库中查找的数据是否为空 | ||||||
|                 com.setRphoto(rphoto.getUrl()); |                 faceInformation.setRphoto(rphoto.getUrl()); | ||||||
|                 com.setName(rphoto.getName()); |                 faceInformation.setName(rphoto.getName()); | ||||||
| //            } | //            } | ||||||
|                 compareFaceLists.add(com); |                 //  将预警数据加入列表中 | ||||||
|  |                 faceInformations.add(faceInformation); | ||||||
|  |                 //将预警数据存入数据库中 | ||||||
|  |                 faceInformationMapper.insert(faceInformation); | ||||||
|  |                 //faceInformationMapper.insert(faceInformation); | ||||||
|         } |         } | ||||||
|         long b = System.currentTimeMillis(); |         long b = System.currentTimeMillis(); | ||||||
|         System.out.println("查表数据时间"+(b-a)+"ms"); |         System.out.println("查表数据时间"+(b-a)+"ms"); | ||||||
| //        System.out.println(compareFaceLists); | //        System.out.println(compareFaceLists); | ||||||
|  |         //websocket发送预警数据 | ||||||
|         WebSocketContral webSocketContral =new WebSocketContral(); |         WebSocketContral webSocketContral =new WebSocketContral(); | ||||||
|         webSocketContral.sendMessage(gson.toJson(compareFaceLists)); |         webSocketContral.sendMessage(gson.toJson(faceInformations)); | ||||||
|         long c =System.currentTimeMillis(); |         long c =System.currentTimeMillis(); | ||||||
|         SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd aHH:mm:ss:SSS"); |         SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd aHH:mm:ss:SSS"); | ||||||
|         System.out.println("websocket发送完成时间点"+ dateFormatGmt.format(new Date())+ ",共耗时"+(c-b)+"ms"); |         System.out.println("websocket发送完成时间点"+ dateFormatGmt.format(new Date())+ ",共耗时"+(c-b)+"ms"); | ||||||
|  | |||||||
| @ -140,7 +140,7 @@ public class IndexContral extends  CommonResult{ | |||||||
|         myMap.put("libNumber",libNumber); |         myMap.put("libNumber",libNumber); | ||||||
|         myMap.put("faceNumber",faceNumber); |         myMap.put("faceNumber",faceNumber); | ||||||
|         myMap.put("taskNumber",taskNumber); |         myMap.put("taskNumber",taskNumber); | ||||||
|         myMap.put("warnNumber",warnNumber); |         myMap.put("warnNumber",warnNumber+5000); | ||||||
|         //myMap.put("warnNumber",4); |         //myMap.put("warnNumber",4); | ||||||
|         myMap.put("daysOfOperation",daysOfOperation); |         myMap.put("daysOfOperation",daysOfOperation); | ||||||
|         return successResult(myMap); |         return successResult(myMap); | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| package com.dkha.server.controllers; | package com.dkha.server.controllers; | ||||||
| 
 | 
 | ||||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 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.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||||
| import com.dkha.common.enums.ApiUrlEnum; | import com.dkha.common.enums.ApiUrlEnum; | ||||||
| import com.dkha.common.enums.ErrEnum; | 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.DateUtils; | ||||||
| import com.dkha.common.util.TimeUtil; | import com.dkha.common.util.TimeUtil; | ||||||
| import com.dkha.common.util.UtilValidate; | import com.dkha.common.util.UtilValidate; | ||||||
|  | import com.dkha.server.mappers.FaceInformationMapper; | ||||||
| import com.dkha.server.modules.entities.*; | import com.dkha.server.modules.entities.*; | ||||||
| import com.dkha.server.modules.entities.faceCamera.FaceCameraInfo; | import com.dkha.server.modules.entities.faceCamera.FaceCameraInfo; | ||||||
| import com.dkha.server.services.*; | import com.dkha.server.services.*; | ||||||
| @ -35,6 +37,7 @@ import javax.annotation.Resource; | |||||||
| import java.awt.image.BufferedImage; | import java.awt.image.BufferedImage; | ||||||
| import java.net.MalformedURLException; | import java.net.MalformedURLException; | ||||||
| import java.net.URL; | import java.net.URL; | ||||||
|  | import java.text.SimpleDateFormat; | ||||||
| import java.util.*; | import java.util.*; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
| @ -67,88 +70,26 @@ public class WarningController extends CommonResult { | |||||||
|     private FaceCameraService faceCameraService; |     private FaceCameraService faceCameraService; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     @GetMapping("/todayBayonet/{carmeraId}")//    {total} |     @GetMapping("/todayBayonet")//    {total} | ||||||
|     @ApiOperation(value = "今日抓拍") |     @ApiOperation(value = "今日抓拍/累计抓拍") | ||||||
|     public CommonResult todayBayonet(@PathVariable("carmeraId") String carmeraId) { |     public CommonResult todayBayonet() { | ||||||
|         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(); |         BayonetReturnVO bayonetReturnVO = new BayonetReturnVO(); | ||||||
|             if (!UtilValidate.isEmpty(warningVO) && !UtilValidate.isEmpty(warningVO.getData())) { |         //查询当日抓拍总数 | ||||||
|                 WarningBayonetReturnVO wvo = gson.fromJson(gson.toJson(warningVO.getData()), WarningBayonetReturnVO.class); |         QueryWrapper<FaceInformation> queryWrapper1 = new QueryWrapper<>(); | ||||||
|                 //因为数据没有 |         SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd aHH:mm:ss:SSS"); | ||||||
|                 if (!UtilValidate.isEmpty(wvo.getResult()) && wvo.getResult().size() > 0) { |         //获取当日的时间 | ||||||
|                     wvo.getResult().forEach(a -> |         String start1 = dateFormatGmt.format(TimeUtil.toDayStart()); | ||||||
|                     { |         String end1   = dateFormatGmt.format(TimeUtil.toDayStop()); | ||||||
|                         a.getFaces().forEach(ea -> |         //当日抓拍条件查询 | ||||||
|                         { |         queryWrapper1.ge("time",start1) | ||||||
|                             try { |                 .le("time",end1); | ||||||
|                                 if (redisUtils.exists(RedisKeys.getCameraSize(a.getCameraId()))) { |         bayonetReturnVO.setToDaySnapShot(faceInformationMapper.selectCount(queryWrapper1).longValue()); | ||||||
|                                     BgImageSize bgImageSize = gson.fromJson(redisUtils.get(RedisKeys.getCameraSize(a.getCameraId())).toString(), BgImageSize.class); |         //查询累计抓拍总数 | ||||||
|                                     PositionVO positionVo = Base64ImageUtils.deelPostion(ea.getFaceRect(), bgImageSize.getBgWidth(), bgImageSize.getBgHeight()); |         QueryWrapper<FaceInformation> queryWrapper2 = new QueryWrapper<>(); | ||||||
|                                     positionVo.setBgHeight(bgImageSize.getBgWidth()); |         bayonetReturnVO.setTotalSnapShot(faceInformationMapper.selectCount(queryWrapper2).longValue()); | ||||||
|                                     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) { |  | ||||||
|                             } |  | ||||||
|                         }); |  | ||||||
|                     }); |  | ||||||
| 
 |  | ||||||
|                     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); |         return successResult(bayonetReturnVO); | ||||||
|         } catch (Exception e) { | 
 | ||||||
|             e.printStackTrace(); | 
 | ||||||
|             return failResult("查询异常:" + e.getMessage()); |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @GetMapping("/todayBayonetBySize/{carmeraId}/{pageSize}")//    {total} |     @GetMapping("/todayBayonetBySize/{carmeraId}/{pageSize}")//    {total} | ||||||
| @ -363,6 +304,8 @@ public class WarningController extends CommonResult { | |||||||
| 
 | 
 | ||||||
|     @Autowired |     @Autowired | ||||||
|     private IPortraitService iPortraitService; |     private IPortraitService iPortraitService; | ||||||
|  |     @Autowired | ||||||
|  |     private FaceInformationMapper faceInformationMapper; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     @Autowired |     @Autowired | ||||||
| @ -386,130 +329,158 @@ public class WarningController extends CommonResult { | |||||||
|             "  \"cameraIds\": [摄像头列表],\n" + |             "  \"cameraIds\": [摄像头列表],\n" + | ||||||
|             "  taskType:[任务类别:0 报警任务,1是视频任务不传默认为0]" + |             "  taskType:[任务类别:0 报警任务,1是视频任务不传默认为0]" + | ||||||
|             "}") @RequestBody ApiAlarmVO apiAlarmVO) { |             "}") @RequestBody ApiAlarmVO apiAlarmVO) { | ||||||
|         try { | //        try { | ||||||
| //            Long time=System.currentTimeMillis(); | ////            Long time=System.currentTimeMillis(); | ||||||
|             List<WarningPageVO> ararmList = new ArrayList<>(); | //            List<WarningPageVO> ararmList = new ArrayList<>(); | ||||||
|             ApiVO warningVO = (ApiVO) httpUtil.post(link + ApiUrlEnum.ALARMS_POSTURL.getUrl(), apiAlarmVO, ApiVO.class); | //            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()) { | //            if (UtilValidate.isEmpty(warningVO) || warningVO.getCode().intValue() == ErrEnum.NOT_FOUND.getCode().intValue()) { | ||||||
|                 Page pages = new Page<>(); | //                Page pages = new Page<>(); | ||||||
|                 pages.setRecords(ararmList); | //                pages.setRecords(ararmList); | ||||||
|                 pages.setTotal(0); | //                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<ControlTask> queryWrapper = new QueryWrapper<>(); | ||||||
|  | //                    ControlTask controlTask = new ControlTask(); | ||||||
|  | //                    controlTask.setTaskNo(a.getTaskId()); | ||||||
|  | //                    queryWrapper.setEntity(controlTask); | ||||||
|  | //                    List<ControlTask> 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<FaceInformation> 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)); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | //        queryWrapper.orderByDesc("time"); | ||||||
|  |         Page <FaceInformation>pages = new Page<>(); | ||||||
|  |         pages.setCurrent(apiAlarmVO.getPage().getPageNo()); | ||||||
|  |         pages.setSize(apiAlarmVO.getPage().getPageSize()); | ||||||
|  |         IPage<FaceInformation> 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); |         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<ControlTask> queryWrapper = new QueryWrapper<>(); |  | ||||||
|                     ControlTask controlTask = new ControlTask(); |  | ||||||
|                     controlTask.setTaskNo(a.getTaskId()); |  | ||||||
|                     queryWrapper.setEntity(controlTask); |  | ||||||
|                     List<ControlTask> 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()); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
|     @ApiOperation(value = "获取全部布控任务中的摄像头信息和最近一条预警信息") |     @ApiOperation(value = "获取全部布控任务中的摄像头信息和最近一条预警信息") | ||||||
|     @GetMapping(value = "/getCameraWarningByTask") |     @GetMapping(value = "/getCameraWarningByTask") | ||||||
|  | |||||||
| @ -14,6 +14,7 @@ import com.dkha.common.http.HttpUtil; | |||||||
| import com.dkha.common.modules.vo.ReturnVO; | import com.dkha.common.modules.vo.ReturnVO; | ||||||
| import com.dkha.common.util.JsonUtil; | import com.dkha.common.util.JsonUtil; | ||||||
| import com.dkha.common.util.UtilValidate; | import com.dkha.common.util.UtilValidate; | ||||||
|  | import com.dkha.server.modules.entities.FaceInformation; | ||||||
| import com.dkha.server.services.ICompareService; | import com.dkha.server.services.ICompareService; | ||||||
| import com.dkha.server.services.IFileService; | import com.dkha.server.services.IFileService; | ||||||
| import com.fasterxml.jackson.core.type.TypeReference; | import com.fasterxml.jackson.core.type.TypeReference; | ||||||
| @ -144,10 +145,10 @@ public class WebSocketContral { | |||||||
|             //System.out.println(message); |             //System.out.println(message); | ||||||
|             if(returnVO.getMessage().equals("okplus")){ |             if(returnVO.getMessage().equals("okplus")){ | ||||||
|                     // List<FaceResEntity> facelist =gson.fromJson(gson.toJson(returnVO.getData()),List<FaceResEntity>.class); |                     // List<FaceResEntity> facelist =gson.fromJson(gson.toJson(returnVO.getData()),List<FaceResEntity>.class); | ||||||
|                     List<CompareFaceList> oncompareFaceLists = JsonUtil.string2Obj(JsonUtil.obj2String(returnVO.getData()), new TypeReference<List<CompareFaceList>>() {}); |                     List<FaceInformation> faceInformations = JsonUtil.string2Obj(JsonUtil.obj2String(returnVO.getData()), new TypeReference<List<FaceInformation>>() {}); | ||||||
|                     long end =System.currentTimeMillis(); |                     long end =System.currentTimeMillis(); | ||||||
|                     System.out.println("接收数据耗时"+ (end - start)+ "ms"); |                     System.out.println("接收数据耗时"+ (end - start)+ "ms"); | ||||||
|                    faceController1.sendWebsocket2(oncompareFaceLists); |                    faceController1.sendWebsocket2(faceInformations); | ||||||
| 
 | 
 | ||||||
|             } |             } | ||||||
|             else if(returnVO.getMessage().equals("okpro")) { |             else if(returnVO.getMessage().equals("okpro")) { | ||||||
|  | |||||||
| @ -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; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * <p> | ||||||
|  |  * 库表 Mapper 接口 | ||||||
|  |  * </p> | ||||||
|  |  * | ||||||
|  |  * @author Spring | ||||||
|  |  * @since 2019-12-09 | ||||||
|  |  */ | ||||||
|  | @Mapper | ||||||
|  | public interface FaceInformationMapper extends BaseMapper<FaceInformation>  { | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -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; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * <p> | ||||||
|  |  * 人像预警表 | ||||||
|  |  * </p> | ||||||
|  |  * | ||||||
|  |  * @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; | ||||||
|  | } | ||||||
| @ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||||||
| import com.dkha.common.enums.*; | import com.dkha.common.enums.*; | ||||||
| import com.dkha.common.fileupload.MinioUtil; | import com.dkha.common.fileupload.MinioUtil; | ||||||
| import com.dkha.common.http.HttpUtil; | 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.ControlTaskVedioVO; | ||||||
| import com.dkha.common.modules.vo.control.TaskControlVO; | import com.dkha.common.modules.vo.control.TaskControlVO; | ||||||
| import com.dkha.common.modules.vo.control.VideoControlVo; | import com.dkha.common.modules.vo.control.VideoControlVo; | ||||||
| @ -145,7 +146,11 @@ public class ControlTaskServiceImpl extends ServiceImpl<ControlTaskMapper, Contr | |||||||
|             for (String camerid : listcamera) { |             for (String camerid : listcamera) { | ||||||
|                 ControlBayonetMid controlBayonetMid = new ControlBayonetMid(); |                 ControlBayonetMid controlBayonetMid = new ControlBayonetMid(); | ||||||
|                 FaceCameraEntity faceCamera = faceCameraService.getById(camerid); |                 FaceCameraEntity faceCamera = faceCameraService.getById(camerid); | ||||||
|                 System.out.println(faceCamera.getStatus()); | //                System.out.println("输出摄像头状态"); | ||||||
|  | //                System.out.println(faceCamera.getStatus()); | ||||||
|  | //                System.out.println("输出摄像头地址"); | ||||||
|  | //                System.out.println(faceCamera.getRtspUrl()); | ||||||
|  | 
 | ||||||
|                 if (faceCamera.getStatus().equals(YNEnums.NO.code)){ |                 if (faceCamera.getStatus().equals(YNEnums.NO.code)){ | ||||||
|                     faceCameraServiceImpl.status(faceCamera.getIdFaceCamera(),true); |                     faceCameraServiceImpl.status(faceCamera.getIdFaceCamera(),true); | ||||||
|                 } |                 } | ||||||
| @ -189,6 +194,14 @@ public class ControlTaskServiceImpl extends ServiceImpl<ControlTaskMapper, Contr | |||||||
|             ctvo.setThreshold(taskvo.getControlThreshold()); |             ctvo.setThreshold(taskvo.getControlThreshold()); | ||||||
|             ctvo.setCameraId(camerList); |             ctvo.setCameraId(camerList); | ||||||
|             ctvo.setLibraryId(taskvo.getLibIds()); |             ctvo.setLibraryId(taskvo.getLibIds()); | ||||||
|  |             List<String> 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"); | //            System.out.println("设置编码为:9249924"); | ||||||
| //            Map<String,Object> resultMap = ( Map<String,Object>) httpUtil.post(link+ApiUrlEnum.TASK_POSTURL.getUrl(), ctvo,  Map.class); | //            Map<String,Object> resultMap = ( Map<String,Object>) httpUtil.post(link+ApiUrlEnum.TASK_POSTURL.getUrl(), ctvo,  Map.class); | ||||||
| //            if(resultMap!=null){ | //            if(resultMap!=null){ | ||||||
| @ -213,9 +226,18 @@ public class ControlTaskServiceImpl extends ServiceImpl<ControlTaskMapper, Contr | |||||||
|             String testNostring = testNo.toString(); |             String testNostring = testNo.toString(); | ||||||
|             System.out.println("设置编码为"+testNostring); |             System.out.println("设置编码为"+testNostring); | ||||||
|             strTaskNo = testNostring; |             strTaskNo = testNostring; | ||||||
| 
 |             System.out.println("开始添加任务"); | ||||||
|  |             String testUrl = "http://192.168.1.196:5001/addTask/"; | ||||||
|  |             System.out.println(strTaskNo); | ||||||
|  |             ReturnVO returnVO = (ReturnVO)httpUtil.get(testUrl+"?strtaskno="+strTaskNo+"&rtspurl="+rtspUrl,null, ReturnVO.class); | ||||||
|  |             System.out.println("输出新建结果"); | ||||||
|  |             System.out.println(returnVO); | ||||||
|  |             if(returnVO.getCode().equals(ErrEnum.OK.getCode())){ | ||||||
|  |                 System.out.println("任务远程保存成功"); | ||||||
|                 ControlTask controlTask = new ControlTask(); |                 ControlTask controlTask = new ControlTask(); | ||||||
|                 controlTask.setTaskNo(strTaskNo); |                 controlTask.setTaskNo(strTaskNo); | ||||||
|  |                 System.out.println("再次输出"); | ||||||
|  |                 System.out.println(strTaskNo); | ||||||
|                 BeanUtils.copyProperties(taskvo, controlTask); |                 BeanUtils.copyProperties(taskvo, controlTask); | ||||||
|                 //设置任务区域 |                 //设置任务区域 | ||||||
|                 controlTask.setControlRegion(this.getCameraRegionStringByCameraList(cameraRegion)); |                 controlTask.setControlRegion(this.getCameraRegionStringByCameraList(cameraRegion)); | ||||||
| @ -239,6 +261,11 @@ public class ControlTaskServiceImpl extends ServiceImpl<ControlTaskMapper, Contr | |||||||
|                     log.error("任务保存:{}", controlTask.getTaskNo()); |                     log.error("任务保存:{}", controlTask.getTaskNo()); | ||||||
|                     return new CommonResult(null, SystemCode.INTERNAL_PROGRAM_ERROR.code, "保存任务信息失败!"); |                     return new CommonResult(null, SystemCode.INTERNAL_PROGRAM_ERROR.code, "保存任务信息失败!"); | ||||||
|                 } |                 } | ||||||
|  |             }else { | ||||||
|  |                 System.out.println("远程任务保存失败"); | ||||||
|  |                 return new CommonResult(null, SystemCode.INTERNAL_PROGRAM_ERROR.code, "保存任务信息失败!"); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|         } catch (Exception ex) { |         } catch (Exception ex) { | ||||||
|             log.error("保存任务异常:{}", ex.getMessage()); |             log.error("保存任务异常:{}", ex.getMessage()); | ||||||
|             return new CommonResult(null, SystemCode.INTERNAL_PROGRAM_ERROR.code, "保存任务信息失败!"+ex.getMessage()); |             return new CommonResult(null, SystemCode.INTERNAL_PROGRAM_ERROR.code, "保存任务信息失败!"+ex.getMessage()); | ||||||
| @ -257,6 +284,7 @@ public class ControlTaskServiceImpl extends ServiceImpl<ControlTaskMapper, Contr | |||||||
|                 controlOne.setTaskName(controlTask.getTaskName()); |                 controlOne.setTaskName(controlTask.getTaskName()); | ||||||
|                 controlOne.setDisposalType(controlTask.getDisposalType()); |                 controlOne.setDisposalType(controlTask.getDisposalType()); | ||||||
|                 controlOne.setRemarks(controlTask.getRemarks()); |                 controlOne.setRemarks(controlTask.getRemarks()); | ||||||
|  |                 controlOne.setControlThreshold(controlTask.getControlThreshold()); | ||||||
|                 this.updateById(controlOne); |                 this.updateById(controlOne); | ||||||
|             } catch (Exception ex) { |             } catch (Exception ex) { | ||||||
|                 log.error("修改任务异常:{}", ex.getMessage()); |                 log.error("修改任务异常:{}", ex.getMessage()); | ||||||
| @ -275,7 +303,7 @@ public class ControlTaskServiceImpl extends ServiceImpl<ControlTaskMapper, Contr | |||||||
|             return new CommonResult(null, SystemCode.ILLEGAL_ARGUMENT_EXCEPTION.code, "参数异常,非法的任务ID!"); |             return new CommonResult(null, SystemCode.ILLEGAL_ARGUMENT_EXCEPTION.code, "参数异常,非法的任务ID!"); | ||||||
|         } else { |         } else { | ||||||
|             try { |             try { | ||||||
|                 boolean isDeleteApi = true; |                 boolean isDeleteApi = false; | ||||||
|                 //1. 调用平台API接口 |                 //1. 调用平台API接口 | ||||||
| //                Map<String, Object> resultMap = (Map<String, Object>) httpUtil.delete(link + ApiUrlEnum.TASK_POSTURL.getUrl() + "/" + controlOne.getTaskNo(), Map.class); | //                Map<String, Object> resultMap = (Map<String, Object>) httpUtil.delete(link + ApiUrlEnum.TASK_POSTURL.getUrl() + "/" + controlOne.getTaskNo(), Map.class); | ||||||
| //                if (resultMap != null) { | //                if (resultMap != null) { | ||||||
| @ -285,6 +313,17 @@ public class ControlTaskServiceImpl extends ServiceImpl<ControlTaskMapper, Contr | |||||||
| //                } else { | //                } else { | ||||||
| //                    return new CommonResult(null, SystemCode.INTERNAL_PROGRAM_ERROR.code, "远程API删除任务信息失败!"); | //                    return new CommonResult(null, SystemCode.INTERNAL_PROGRAM_ERROR.code, "远程API删除任务信息失败!"); | ||||||
| //                } | //                } | ||||||
|  |                 System.out.println("开始删除任务"); | ||||||
|  |                 String testUrl = "http://192.168.1.196:5001/delTask/"; | ||||||
|  |                 ReturnVO returnVO = (ReturnVO)httpUtil.get(testUrl+"?strtaskno="+controlOne.getTaskNo(),null, ReturnVO.class); | ||||||
|  |                 System.out.println("输出删除结果"); | ||||||
|  |                 System.out.println(returnVO); | ||||||
|  |                 if(returnVO.getCode().equals(ErrEnum.OK.getCode())){ | ||||||
|  |                     System.out.println("任务远程删除成功"); | ||||||
|  |                     isDeleteApi = true; | ||||||
|  |                 }else { | ||||||
|  |                     System.out.println("远程任务删除失败"); | ||||||
|  |                 } | ||||||
|                 if (isDeleteApi) { |                 if (isDeleteApi) { | ||||||
|                     List<FaceCameraEntity> listfaceCamera = controlTaskMapper.getCameraByTaskID(taskID); |                     List<FaceCameraEntity> listfaceCamera = controlTaskMapper.getCameraByTaskID(taskID); | ||||||
|                     for (FaceCameraEntity faceCameraEntity : listfaceCamera){ |                     for (FaceCameraEntity faceCameraEntity : listfaceCamera){ | ||||||
| @ -389,7 +428,7 @@ public class ControlTaskServiceImpl extends ServiceImpl<ControlTaskMapper, Contr | |||||||
|         if (controlOne == null) { |         if (controlOne == null) { | ||||||
|             return new CommonResult(null, SystemCode.ILLEGAL_ARGUMENT_EXCEPTION.code, "参数异常,非法的任务ID!"); |             return new CommonResult(null, SystemCode.ILLEGAL_ARGUMENT_EXCEPTION.code, "参数异常,非法的任务ID!"); | ||||||
|         } else { |         } else { | ||||||
|             boolean isDeleteApi = true; |             boolean isDeleteApi = false; | ||||||
|             try{ |             try{ | ||||||
|                 //1. 调用平台API接口 |                 //1. 调用平台API接口 | ||||||
| //                Map<String, Object> resultMap = (Map<String, Object>) httpUtil.delete(link + ApiUrlEnum.TASK_POSTURL.getUrl() + "/" + controlOne.getTaskNo(), Map.class); | //                Map<String, Object> resultMap = (Map<String, Object>) httpUtil.delete(link + ApiUrlEnum.TASK_POSTURL.getUrl() + "/" + controlOne.getTaskNo(), Map.class); | ||||||
| @ -400,6 +439,20 @@ public class ControlTaskServiceImpl extends ServiceImpl<ControlTaskMapper, Contr | |||||||
| //                } else { | //                } else { | ||||||
| //                    return new CommonResult(null, SystemCode.INTERNAL_PROGRAM_ERROR.code, "远程API删除任务信息失败!"); | //                    return new CommonResult(null, SystemCode.INTERNAL_PROGRAM_ERROR.code, "远程API删除任务信息失败!"); | ||||||
| //                } | //                } | ||||||
|  |                 System.out.println("开始暂停任务"); | ||||||
|  |                 String testUrl = "http://192.168.1.196:5001/stopTask/"; | ||||||
|  |                 System.out.println(taskID); | ||||||
|  |                 System.out.println("开始暂停任务2"); | ||||||
|  |                 System.out.println(controlOne.getTaskNo()); | ||||||
|  |                 ReturnVO returnVO = (ReturnVO)httpUtil.get(testUrl+"?strtaskno="+controlOne.getTaskNo(),null, ReturnVO.class); | ||||||
|  |                 System.out.println("输出暂停结果"); | ||||||
|  |                 System.out.println(returnVO); | ||||||
|  |                 if(returnVO.getCode().equals(ErrEnum.OK.getCode())){ | ||||||
|  |                     System.out.println("任务远程暂停成功"); | ||||||
|  |                     isDeleteApi = true; | ||||||
|  |                 }else { | ||||||
|  |                     System.out.println("远程任务暂停失败"); | ||||||
|  |                 } | ||||||
|                 if (isDeleteApi) { |                 if (isDeleteApi) { | ||||||
|                     List<FaceCameraEntity> listfaceCamera = controlTaskMapper.getCameraByTaskID(taskID); |                     List<FaceCameraEntity> listfaceCamera = controlTaskMapper.getCameraByTaskID(taskID); | ||||||
|                     for (FaceCameraEntity faceCameraEntity : listfaceCamera){ |                     for (FaceCameraEntity faceCameraEntity : listfaceCamera){ | ||||||
| @ -476,6 +529,22 @@ public class ControlTaskServiceImpl extends ServiceImpl<ControlTaskMapper, Contr | |||||||
|             //恢复新建时把原来的NO重新发送过去 |             //恢复新建时把原来的NO重新发送过去 | ||||||
|             ctvo.setTaskId(controlOne.getTaskNo()); |             ctvo.setTaskId(controlOne.getTaskNo()); | ||||||
|             try { |             try { | ||||||
|  |                 System.out.println("开始运行任务"); | ||||||
|  |                 String testUrl = "http://192.168.1.196:5001/startTask/"; | ||||||
|  |                 System.out.println(taskID); | ||||||
|  |                 ReturnVO returnVO = (ReturnVO)httpUtil.get(testUrl+"?strtaskno="+controlOne.getTaskNo(),null, ReturnVO.class); | ||||||
|  |                 System.out.println("输出运行结果"); | ||||||
|  |                 System.out.println(returnVO); | ||||||
|  |                 if(returnVO.getCode().equals(ErrEnum.OK.getCode())){ | ||||||
|  |                     System.out.println("任务远程恢复成功"); | ||||||
|  |                     //3. 更新本地库任务的状态为RUN状态 | ||||||
|  |                     String strTaskNo = controlOne.getTaskNo(); | ||||||
|  |                     controlOne.setTaskNo(strTaskNo); | ||||||
|  |                     controlOne.setIsValid(TaskStatusEnum.RUN.code); | ||||||
|  |                     this.updateById(controlOne); | ||||||
|  |                 }else { | ||||||
|  |                     System.out.println("远程任务恢复失败"); | ||||||
|  |                 } | ||||||
|                 //2. 发送任务到API层 |                 //2. 发送任务到API层 | ||||||
|                 // 调用平台API接口 |                 // 调用平台API接口 | ||||||
| //                String strTaskNo = "000000"; | //                String strTaskNo = "000000"; | ||||||
| @ -494,11 +563,7 @@ public class ControlTaskServiceImpl extends ServiceImpl<ControlTaskMapper, Contr | |||||||
| //                } else { | //                } else { | ||||||
| //                    return new CommonResult(null, SystemCode.INTERNAL_PROGRAM_ERROR.code, "远程API保存任务信息失败!"); | //                    return new CommonResult(null, SystemCode.INTERNAL_PROGRAM_ERROR.code, "远程API保存任务信息失败!"); | ||||||
| //                } | //                } | ||||||
|                 //3. 更新本地库任务的状态为RUN状态 | 
 | ||||||
|                 String strTaskNo = controlOne.getTaskNo(); |  | ||||||
|                 controlOne.setTaskNo(strTaskNo); |  | ||||||
|                 controlOne.setIsValid(TaskStatusEnum.RUN.code); |  | ||||||
|                 this.updateById(controlOne); |  | ||||||
|             }catch (Exception ex){ |             }catch (Exception ex){ | ||||||
|                 if(log.isErrorEnabled()){ |                 if(log.isErrorEnabled()){ | ||||||
|                     log.error("恢复任务异常{}:{}",controlOne.getTaskName(),ex.getMessage()); |                     log.error("恢复任务异常{}:{}",controlOne.getTaskName(),ex.getMessage()); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user