In the dynamic yet uncertain environment of Industry 4.0, industrial companies are utilizing the benefits of contemporary technologies in manufacturing by striving to implement optimization models in each stage of the decision-making process. Many organizations are focusing particularly on the optimization of two key aspects of the manufacturing process - production schedules and maintenance plans. This article presents a mathematical model with the main advantage of finding a valid production schedule (if such exists) for the distribution of individual production orders on the available production lines over a specified period. The model further considers the scheduled preventive maintenance activities on the production lines, as well as the preferences of the production planners regarding the start of the production orders and non-use of certain machines. When necessary, it also offers the possibility to make timely changes in the production schedule, and thus to handle the uncertainty as precisely as possible. For the verification of the model, two experiments were conducted (quasi-real and real-life), with data from a discrete automotive manufacturer of locking systems. The results from the sensitivity analysis demonstrated that the model further optimizes the execution times of all orders, and specifically the production lines usage - their optimal load and non-use of unnecessary machines (valid plan with 4 out of 12 lines not used). This allows for cost savings and raises the overall efficiency of the production process. Thus, the model adds value for the organization by presenting a production plan with optimal machine usage and product allocation. If incorporated into an ERP system, it could distinctly save time and streamline the production scheduling process.