Due to the outbreak of the new crown epidemic, the production plans of most factories have been affected to a certain extent, and there may be some changes in the production machinery and manpower arrangements of the factories. In this paper, we study how to arrange the dispatch strategy of generators under the condition of power demand in a specified time. Based on the minimum cost, a mixed integer model was established, which provided a solution for some factories to control the scheduling of machines on time during the outbreak of the epidemic. According to the established model, a factory is programmed to solve the problem, and the minimum power generation cost in a week is given 1589130 CNY. In special cases, the working generator set must set aside 20% of the power generation capacity margin to cope with the unexpected situation. At this time, the generator’s daily production cost is as small as 239870 CNY while giving the corresponding generator scheduling scheme. Finally, this paper does a sensitivity analysis of the total daily power generation cost when the power generation margin changes, and finds that the total daily cost of the generator is sensitive to the power generation margin.