We investigate an optimal reinsurance and dividend problem of an insurance company with the presence of reinvestments, or retained earnings. We consider the general situation that the company needs to pay both fixed and proportional costs. The object of the company is to determine reinsurance, dividend and reinvestment strategies so as to maximize the difference between the expected discounted dividends minus the expected discounted reinvestment until the time of ruin. We focus on the excess-of-loss reinsurance strategy, which is shown to be optimal. The mixed classical-impulse control is then used to discuss the problem. Using inventory control theory, the value function and optimal strategy are derived.