Being able to complete the production of the product project on time is the prerequisite to win more tasks, many enterprises have begun to study intelligent scheduling algorithms to achieve dynamic control of the total project duration. However, the production operation time of products is highly volatile, and it is impossible to predict the possible operation time of future products. In the actual production environment, we often encounter extreme situations such as mixed production lines, multiple varieties, variable batches, etc. A dynamic optimization CPM model in the ERP/MES system with the attention mechanism (EMA-DCPM) will collect, extract and predict the operation time through artificial intelligence technology, and it can accurately predict the exact operation time of a batch of products that have not yet been produced. Through experiments, our algorithm can realize the production scheduling and get more than 200% better precision than former algorithms and realize dynamic optimization of complex projects.