The time-sensitive networking (TSN) technique has shown its potential to provide deterministic communication guarantees for industrial applications. Specifically, the recently applied cyclic queuing and forwarding (CQF) mechanism in TSN can further provide bounded latency and stable delay jitter for time-triggered (TT) flows with simplified configuration of gate control list (GCL) for TSN switches. However, previous traffic scheduling approaches with the CQF mechanism have overlooked the influence of routing strategies on scheduling optimization. To account for the interaction between the scheduling and routing problems, we propose a two-layer heuristic optimization algorithm, called the Joint Optimization on Offset and Route Selection (JOORS). In this algorithm, the inner layer is responsible for selecting routing decisions, while the outer layer focuses on selecting the time offset.The algorithm establishes the connection between the inner and outer decisions through simulating the flow scheduling process. The goal of the JOORS algorithm is to maximize the scheduling success rate for TT flows in a TSN network based on the CQF mechanism.Extensive simulations demonstrate that the JOORS algorithm can significantly improve the scheduling success rate compared to other algorithms and benchmark schemes.