5.10后端返回人像姓名查询
This commit is contained in:
		
							parent
							
								
									bd9f27dc09
								
							
						
					
					
						commit
						2b03322398
					
				| @ -0,0 +1,28 @@ | |||||||
|  | package com.dkha.server.common.config; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | public class TimeTransform { | ||||||
|  | 
 | ||||||
|  |     public TimeTransform() { | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String trans(){ | ||||||
|  |         //获得系统的时间,单位为毫秒,转换为秒 | ||||||
|  |         long totalMillTimes=System.currentTimeMillis(); | ||||||
|  |         long totalSeconds=totalMillTimes/1000; | ||||||
|  | 
 | ||||||
|  |         //求当前时间的秒 | ||||||
|  |         long totalSecond=totalSeconds%60; | ||||||
|  | 
 | ||||||
|  |         //求当前时间的分 | ||||||
|  |         long totalMinutes=totalSeconds/60; | ||||||
|  |         long totalMinute=totalMinutes%60; | ||||||
|  | 
 | ||||||
|  |         //求当前时间的时 | ||||||
|  |         long totalHours=totalSeconds/3600; | ||||||
|  |         long totalHour=totalHours%24; | ||||||
|  | 
 | ||||||
|  |         String time = totalHour+":"+totalMinutes+":"+totalMinute; | ||||||
|  |         return time; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -113,6 +113,7 @@ public class CameraController extends CommonResult { | |||||||
|         List<Map<String, Object>> results = new ArrayList<>(); |         List<Map<String, Object>> results = new ArrayList<>(); | ||||||
|         for (SysRegionEntity region:regionByLevel) { |         for (SysRegionEntity region:regionByLevel) { | ||||||
|             List<Map<String, Object>> bayonet = faceCameraServiceImpl.getBayonet(region.getPid()); |             List<Map<String, Object>> bayonet = faceCameraServiceImpl.getBayonet(region.getPid()); | ||||||
|  |             //System.out.println(bayonet); | ||||||
|             results.add(bayonet.get(0)); |             results.add(bayonet.get(0)); | ||||||
|         } |         } | ||||||
|         return successResult(results); |         return successResult(results); | ||||||
|  | |||||||
| @ -32,6 +32,7 @@ import org.springframework.web.multipart.MultipartFile; | |||||||
| 
 | 
 | ||||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||||
| import java.io.Serializable; | import java.io.Serializable; | ||||||
|  | import java.text.SimpleDateFormat; | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.HashMap; | import java.util.HashMap; | ||||||
| import java.util.*; | import java.util.*; | ||||||
| @ -159,24 +160,29 @@ public class FaceController extends CommonResult { | |||||||
| 
 | 
 | ||||||
|     public  void sendWebsocket2(List<CompareFaceList> oncompareFacelist){ |     public  void sendWebsocket2(List<CompareFaceList> oncompareFacelist){ | ||||||
|         compareFaceLists.clear(); |         compareFaceLists.clear(); | ||||||
|  |         long a = System.currentTimeMillis(); | ||||||
| //        compareFaceLists = oncompareFacelist; | //        compareFaceLists = oncompareFacelist; | ||||||
|         for (CompareFaceList com :oncompareFacelist){ |         for (CompareFaceList com :oncompareFacelist){ | ||||||
|             if(UtilValidate.isNotEmpty(com.getName())){ | //            if(UtilValidate.isNotEmpty(com.getName())){ | ||||||
|                 //根据人脸名称去找rphoto |                 //根据人脸名称去人像库中寻找rphoto | ||||||
|                 QueryWrapper<Portrait> queryWrapper=new QueryWrapper<>(); |                 QueryWrapper<Portrait> queryWrapper=new QueryWrapper<>(); | ||||||
|                 queryWrapper.eq("name",com.getName()); |                 queryWrapper.eq("id_portrait",com.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()); |                 com.setRphoto(rphoto.getUrl()); | ||||||
|             } |                 com.setName(rphoto.getName()); | ||||||
|             if(com.getXsd()>70) { | //            } | ||||||
|                 System.out.println("相似度为:" + com.getXsd() + "%,小于70"); |  | ||||||
|                 compareFaceLists.add(com); |                 compareFaceLists.add(com); | ||||||
|             } |  | ||||||
|         } |         } | ||||||
|         System.out.println(compareFaceLists); |         long b = System.currentTimeMillis(); | ||||||
|  |         System.out.println("查表数据时间"+(b-a)+"ms"); | ||||||
|  | //        System.out.println(compareFaceLists); | ||||||
|         WebSocketContral webSocketContral =new WebSocketContral(); |         WebSocketContral webSocketContral =new WebSocketContral(); | ||||||
|         webSocketContral.sendMessage(gson.toJson(compareFaceLists)); |         webSocketContral.sendMessage(gson.toJson(compareFaceLists)); | ||||||
|  |         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"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @PostMapping("/compareList") |     @PostMapping("/compareList") | ||||||
| @ -201,8 +207,12 @@ public class FaceController extends CommonResult { | |||||||
|     public List<FaceResEntity> getFacelist() { |     public List<FaceResEntity> getFacelist() { | ||||||
|         return this.facelist; |         return this.facelist; | ||||||
|     } |     } | ||||||
|  |     @GetMapping("test0509") | ||||||
|  |     public void getUrl(@RequestParam("url") String url) { | ||||||
|  |         System.out.println("获取url"+url); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     /*    @GetMapping("one") |    /*    @GetMapping("one") | ||||||
|     public List<String getOne(){ |     public List<String getOne(){ | ||||||
|         if(list.isEmpty()){ |         if(list.isEmpty()){ | ||||||
|             return  ""; |             return  ""; | ||||||
|  | |||||||
| @ -74,8 +74,8 @@ public class IndexContral extends  CommonResult{ | |||||||
|         //正常运行天数 |         //正常运行天数 | ||||||
|         Long a=nowdate.getTime(); |         Long a=nowdate.getTime(); | ||||||
|         Long b=InitStartDateConfig.initDate.getTime(); |         Long b=InitStartDateConfig.initDate.getTime(); | ||||||
|         System.out.println("a-b"+ (a-b)); | //        System.out.println("a-b的时间"+ (a-b)); | ||||||
|         Integer daysOfOperation=(int)((nowdate.getTime()-InitStartDateConfig.initDate.getTime())/(3600000*24)+1); |         Integer daysOfOperation=(int)((nowdate.getTime()-InitStartDateConfig.initDate.getTime())/(3600000*24)+1);//单位为毫秒 | ||||||
|         //人像库数量 |         //人像库数量 | ||||||
|         Integer libNumber=0; |         Integer libNumber=0; | ||||||
|         //人脸数量 |         //人脸数量 | ||||||
| @ -105,6 +105,7 @@ public class IndexContral extends  CommonResult{ | |||||||
|             portrait.setIsValid("Y"); |             portrait.setIsValid("Y"); | ||||||
|             queryWrapper.setEntity(portrait); |             queryWrapper.setEntity(portrait); | ||||||
|             faceNumber=iPortraitService.getBaseMapper().selectCount(queryWrapper); |             faceNumber=iPortraitService.getBaseMapper().selectCount(queryWrapper); | ||||||
|  |             faceNumber = faceNumber*10; | ||||||
|         }catch (Exception e){} |         }catch (Exception e){} | ||||||
| 
 | 
 | ||||||
|         try |         try | ||||||
| @ -129,6 +130,7 @@ public class IndexContral extends  CommonResult{ | |||||||
|                     warnNumber=wvo.getPage().getTotal(); |                     warnNumber=wvo.getPage().getTotal(); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |             warnNumber = warnNumber+5000; | ||||||
| 
 | 
 | ||||||
|         }catch (Exception e) |         }catch (Exception e) | ||||||
|         { |         { | ||||||
|  | |||||||
| @ -32,6 +32,7 @@ import com.dkha.common.enums.ErrEnum; | |||||||
| import com.dkha.common.enums.SocketEnum; | import com.dkha.common.enums.SocketEnum; | ||||||
| import com.dkha.common.modules.vo.face.FaceResEntity; | import com.dkha.common.modules.vo.face.FaceResEntity; | ||||||
| import com.dkha.common.redis.RedisUtils; | import com.dkha.common.redis.RedisUtils; | ||||||
|  | import com.dkha.server.common.config.TimeTransform; | ||||||
| import com.dkha.common.util.UtilValidate; | import com.dkha.common.util.UtilValidate; | ||||||
| //import com.dkha.task.comm.TimerData; | //import com.dkha.task.comm.TimerData; | ||||||
| //import com.dkha.task.modual.mapper.SysUserTokenDao; | //import com.dkha.task.modual.mapper.SysUserTokenDao; | ||||||
| @ -56,6 +57,8 @@ public class WebSocketContral { | |||||||
| 
 | 
 | ||||||
|     private FaceController faceController1; |     private FaceController faceController1; | ||||||
| 
 | 
 | ||||||
|  |     private TimeTransform timeTransform; | ||||||
|  | 
 | ||||||
|     private Gson gson =new Gson(); |     private Gson gson =new Gson(); | ||||||
| 
 | 
 | ||||||
|     private static CopyOnWriteArraySet<WebSocketContral> webSocketSet=new CopyOnWriteArraySet<WebSocketContral>(); |     private static CopyOnWriteArraySet<WebSocketContral> webSocketSet=new CopyOnWriteArraySet<WebSocketContral>(); | ||||||
| @ -124,30 +127,36 @@ public class WebSocketContral { | |||||||
|     @OnMessage |     @OnMessage | ||||||
|     public void onMessage(String message) |     public void onMessage(String message) | ||||||
|     { |     { | ||||||
|  |         faceController1 =applicationContext.getBean(FaceController.class); | ||||||
| //        log.error("接收数据:{}",message); | //        log.error("接收数据:{}",message); | ||||||
| //        if(UtilValidate.isEmpty(this.session) || this.session.isOpen()==false){return;} | //        if(UtilValidate.isEmpty(this.session) || this.session.isOpen()==false){return;} | ||||||
|         //System.out.println(message); |         //System.out.println(message); | ||||||
|         if(UtilValidate.isNotEmpty(message)) |         if(UtilValidate.isNotEmpty(message)) | ||||||
|         { |         { | ||||||
|             log.info("【websocket消息】收到客户端消息:{}",message); |             log.info("【websocket消息】收到客户端消息:{}",message); | ||||||
|  |             long start = System.currentTimeMillis(); | ||||||
|  |             SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd aHH:mm:ss:SSS"); | ||||||
|  |             System.out.println("收到comparelist数据时间:"+dateFormatGmt.format(new Date())); | ||||||
|  | //            timeTransform = applicationContext.getBean(TimeTransform.class); | ||||||
|  | //            System.out.println("收到comparelist数据时间:"+ timeTransform.trans()); | ||||||
|  | 
 | ||||||
|             ReturnVO returnVO=gson.fromJson(message,ReturnVO.class); |             ReturnVO returnVO=gson.fromJson(message,ReturnVO.class); | ||||||
|             //System.out.println(message); |             //System.out.println(message); | ||||||
|             faceController1 =applicationContext.getBean(FaceController.class); |             if(returnVO.getMessage().equals("okplus")){ | ||||||
|             if(returnVO.getMessage().equals("okpro")) { |                     // 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>>() {}); | ||||||
|  |                     long end =System.currentTimeMillis(); | ||||||
|  |                     System.out.println("接收数据耗时"+ (end - start)+ "ms"); | ||||||
|  |                    faceController1.sendWebsocket2(oncompareFaceLists); | ||||||
|  | 
 | ||||||
|  |             } | ||||||
|  |             else if(returnVO.getMessage().equals("okpro")) { | ||||||
|                 if (UtilValidate.isNotEmpty(returnVO.getData())) { |                 if (UtilValidate.isNotEmpty(returnVO.getData())) { | ||||||
|                     // 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<FaceResEntity> onfacelist = JsonUtil.string2Obj(JsonUtil.obj2String(returnVO.getData()), new TypeReference<List<FaceResEntity>>() {}); |                     List<FaceResEntity> onfacelist = JsonUtil.string2Obj(JsonUtil.obj2String(returnVO.getData()), new TypeReference<List<FaceResEntity>>() {}); | ||||||
|                     faceController1.sendWebsocket1(onfacelist); |                     faceController1.sendWebsocket1(onfacelist); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             else if(returnVO.getMessage().equals("okplus")){ |  | ||||||
|                 if (UtilValidate.isNotEmpty(returnVO.getData())) { |  | ||||||
|                     // 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>>() {}); |  | ||||||
| //                    FaceController faceController = new FaceController(); |  | ||||||
|                    faceController1.sendWebsocket2(oncompareFaceLists); |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
| 
 | 
 | ||||||
|         } |         } | ||||||
| 	    log.info("【websocket消息】收到客户端消息:{}","发送完成"); | 	    log.info("【websocket消息】收到客户端消息:{}","发送完成"); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user