A charge reconstruction algorithm for DAMPE silicon microstrip detectors