Yes, your employer can absolutely do this; it could also have suspended or fired you on the spot if it chose for absenteeism and not following its instructions. The company is under  no obligation to take your second job into account in terms of scheduling.