| | |
| | | package com.genersoft.iot.vmp.netty.handle; |
| | | |
| | | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| | | import com.genersoft.iot.vmp.netty.business.entity.TalkBackEquipment; |
| | | import com.genersoft.iot.vmp.netty.business.service.TalkBackEquipmentService; |
| | | import com.genersoft.iot.vmp.netty.config.MyDecoder; |
| | | import com.genersoft.iot.vmp.policeBodyCamera.entity.DeviceChannelPoliceCamera; |
| | | import com.genersoft.iot.vmp.policeBodyCamera.service.DeviceChannelPoliceCameraService; |
| | | import io.netty.buffer.ByteBuf; |
| | | import io.netty.channel.ChannelHandlerContext; |
| | | import io.netty.channel.SimpleChannelInboundHandler; |
| | |
| | | private TalkBackEquipmentService talkBackEquipmentService; |
| | | |
| | | |
| | | @Autowired |
| | | private DeviceChannelPoliceCameraService deviceChannelPoliceCameraService; |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | | udpServerHandler = this; |
| | | udpServerHandler.talkBackEquipmentService = this.talkBackEquipmentService; |
| | | udpServerHandler.deviceChannelPoliceCameraService = this.deviceChannelPoliceCameraService; |
| | | } |
| | | |
| | | @Override |
| | |
| | | byte[] req = new byte[buf.readableBytes()]; |
| | | buf.readBytes(req); |
| | | String body = new String(req, CharsetUtil.UTF_8); |
| | | |
| | | // System.out.println("【UDP】>>>>>> 收到客户端的数据:"+body); |
| | | // 字节转16进制字符串 |
| | | String s = bytesToHexString(req); |
| | | // System.out.println("s111111 = " + s); |
| | | //获取字符串的长度 |
| | | int length = s.length(); |
| | | // System.out.println("数据长度>>>>>> = " + length); |
| | |
| | | if (Integer.parseInt(second)<10){ |
| | | second = "0" + second; |
| | | } |
| | | String time = year + "-" + month + "-" + day +" " + hour+ ":"+minute + ":" + second; |
| | | String time = year + "-" + month + "-" + day +" " + hour + ":" + minute + ":" + second; |
| | | //时间拼接 |
| | | try { |
| | | backEquipment.setReceiveTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(time)); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 保存设备数据 |
| | | * 保存设备数据--测试 |
| | | * @param body |
| | | */ |
| | | @Async |
| | | public void saveTalkBackEquipmentInfo(String body) { |
| | | TalkBackEquipment equipmentRecord = new TalkBackEquipment(); |
| | | DeviceChannel deviceChannelPoliceCamera = new DeviceChannel(); |
| | | deviceChannelPoliceCamera.setAddress(""); |
| | | deviceChannelPoliceCamera.setDeviceId("123"); |
| | | deviceChannelPoliceCamera.setName("CS"); |
| | | deviceChannelPoliceCamera.setLongitude(128.125412); |
| | | deviceChannelPoliceCamera.setLatitude(29.1254124); |
| | | deviceChannelPoliceCamera.setPTZTypeText("111"); |
| | | deviceChannelPoliceCamera.setCertNum("10"); |
| | | deviceChannelPoliceCamera.setPTZType(1); |
| | | deviceChannelPoliceCamera.setStatus(1); |
| | | deviceChannelPoliceCamera.setChannelId("123456"); |
| | | |
| | | |
| | | udpServerHandler.deviceChannelPoliceCameraService.insertDeviceChannelPoliceCamera(deviceChannelPoliceCamera); |
| | | } |
| | | |
| | | /** |