| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | |
| | |
| | | public class NettyServerHandler extends ChannelInboundHandlerAdapter { |
| | | @Resource |
| | | private ComPropertyAlarmDao comPropertyAlarmDao; |
| | | |
| | | private static NettyServerHandler nettyServerHandler; |
| | | /** |
| | | * 客户端连接会触发 |
| | | */ |
| | |
| | | myTools.writeToClient("404A01"+ DateUtils.getDateFormatString(new Date(),"HHmmss")+"23",ctx,"心跳包"); |
| | | } |
| | | if(msg.toString().startsWith("4A1803")){ |
| | | String serial=msg.toString().substring(12,22); |
| | | String serial=msg.toString().substring(14,24); |
| | | myTools.writeToClient("404A03"+msg.toString().substring(msg.toString().length()-2)+"23",ctx,"事件包"); |
| | | ComPropertyAlarm comPropertyAlarm=new ComPropertyAlarm(); |
| | | comPropertyAlarm.setCreateTime(DateUtil.date()); |
| | | comPropertyAlarm.setSerialNo(serial); |
| | | comPropertyAlarm.setType(ComPropertyAlarm.type.one); |
| | | comPropertyAlarmDao.insert(comPropertyAlarm); |
| | | nettyServerHandler.comPropertyAlarmDao.insert(comPropertyAlarm); |
| | | } |
| | | ctx.flush(); |
| | | } |
| | |
| | | cause.printStackTrace(); |
| | | ctx.close(); |
| | | } |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | | nettyServerHandler=this; |
| | | nettyServerHandler.comPropertyAlarmDao=this.comPropertyAlarmDao; |
| | | } |
| | | } |