Optimal Charging and Discharging Scheme of Battery Energy Storage System in Active Distribution Network