| | |
| | | import io.netty.util.CharsetUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springblade.modules.netty.business.entity.PoliceCarEquipment; |
| | | import org.springblade.modules.netty.business.service.PoliceCarEquipmentService; |
| | | import org.springblade.modules.netty.business.entity.TalkBackEquipment; |
| | | import org.springblade.modules.netty.business.service.TalkBackEquipmentService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import javax.annotation.PostConstruct; |
| | |
| | | private static UdpServerHandler udpServerHandler; |
| | | |
| | | @Autowired |
| | | private PoliceCarEquipmentService policeCarEquipmentService; |
| | | private TalkBackEquipmentService talkBackEquipmentService; |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | | udpServerHandler = this; |
| | | udpServerHandler.policeCarEquipmentService = this.policeCarEquipmentService; |
| | | udpServerHandler.talkBackEquipmentService = this.talkBackEquipmentService; |
| | | } |
| | | |
| | | @Override |
| | |
| | | * @param s 16位字符串 |
| | | */ |
| | | private void dataHandler(String s) { |
| | | s = "AAAACCCC220000000033373933343732393100000000000000000000000052D50451F77D5D406C04E275FD723C400000015F0000000507E70306103B0A"; |
| | | // s = "AAAACCCC220000000033373933343732393100000000000000000000000052D50451F77D5D406C04E275FD723C400000015F0000000507E70306103B0A"; |
| | | //创建设备对象 |
| | | PoliceCarEquipment backEquipment = new PoliceCarEquipment(); |
| | | TalkBackEquipment backEquipment = new TalkBackEquipment(); |
| | | if (s.substring(4,8).equals("CCCC")) { |
| | | backEquipment.setStatus(1); |
| | | } |
| | |
| | | } |
| | | backEquipment.setUpdateTime(new Date()); |
| | | // 新增 |
| | | udpServerHandler.policeCarEquipmentService.save(backEquipment); |
| | | udpServerHandler.talkBackEquipmentService.save(backEquipment); |
| | | } |
| | | |
| | | /** |
| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 捕获异常 |
| | | * @param ctx |