|
|
@ -6,14 +6,18 @@ import android.os.Handler; |
|
|
|
import android.os.Looper; |
|
|
|
import android.widget.Toast; |
|
|
|
|
|
|
|
import com.iflytop.profilometer.common.constant.SystemConfigType; |
|
|
|
import com.iflytop.profilometer.common.enums.DownloadFileType; |
|
|
|
import com.iflytop.profilometer.common.result.Result; |
|
|
|
import com.iflytop.profilometer.common.utils.FileUtil; |
|
|
|
import com.iflytop.profilometer.core.migration.algo.type.XYPoint; |
|
|
|
import com.iflytop.profilometer.dao.ProfileRecordDao; |
|
|
|
import com.iflytop.profilometer.dao.ProfileRecordPointSetDao; |
|
|
|
import com.iflytop.profilometer.dao.SyncTaskDao; |
|
|
|
import com.iflytop.profilometer.dao.SystemConfigDao; |
|
|
|
import com.iflytop.profilometer.model.entity.ProfileRecordDescription; |
|
|
|
import com.iflytop.profilometer.model.entity.ProfileRecordPointSet; |
|
|
|
import com.iflytop.profilometer.model.entity.SystemConfig; |
|
|
|
|
|
|
|
import java.io.BufferedOutputStream; |
|
|
|
import java.io.File; |
|
|
@ -127,21 +131,26 @@ public class RecordApi { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
SystemConfigDao systemConfigDao = new SystemConfigDao(context); |
|
|
|
ProfileRecordDao recordDao = new ProfileRecordDao(context); |
|
|
|
ProfileRecordPointSetDao pointSetDao = new ProfileRecordPointSetDao(context); |
|
|
|
SystemConfig downloadFileTypeConfig = systemConfigDao.getSystemConfigByKey(SystemConfigType.DOWNLOAD_FILE_TYPE); |
|
|
|
String downloadFileType = DownloadFileType.ban.toString(); |
|
|
|
if (downloadFileTypeConfig != null) { |
|
|
|
downloadFileType = downloadFileTypeConfig.getConfigValue(); |
|
|
|
} |
|
|
|
if (ids.size() > 1) { |
|
|
|
String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); |
|
|
|
String zipName = "export-" + timestamp + ".zip"; |
|
|
|
|
|
|
|
File zipFile = new File(exportDir, zipName); |
|
|
|
try (ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)))) { |
|
|
|
ProfileRecordDao recordDao = new ProfileRecordDao(context); |
|
|
|
ProfileRecordPointSetDao pointSetDao = new ProfileRecordPointSetDao(context); |
|
|
|
for (int i = 0; i < ids.size(); i++) { |
|
|
|
Long id = ids.getLong(i); |
|
|
|
ProfileRecordDescription desc = recordDao.getProfileRecordById(id); |
|
|
|
ProfileRecordPointSet ps = pointSetDao.getProfileRecordPointSetByUuid(desc.getUuid()); |
|
|
|
List<XYPoint> pts = JSONUtil.toList(ps.getAlignPoints(), XYPoint.class); |
|
|
|
|
|
|
|
String entryName = "export-" + desc.getName() + ".txt"; |
|
|
|
String entryName = "export-" + desc.getName() + "." + downloadFileType; |
|
|
|
zos.putNextEntry(new ZipEntry(entryName)); |
|
|
|
|
|
|
|
for (XYPoint pt : pts) { |
|
|
@ -158,10 +167,8 @@ public class RecordApi { |
|
|
|
} catch (Exception e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
Long id = ids.getLong(0); |
|
|
|
ProfileRecordDao recordDao = new ProfileRecordDao(context); |
|
|
|
ProfileRecordPointSetDao pointSetDao = new ProfileRecordPointSetDao(context); |
|
|
|
ProfileRecordDescription desc = recordDao.getProfileRecordById(id); |
|
|
|
ProfileRecordPointSet ps = pointSetDao.getProfileRecordPointSetByUuid(desc.getUuid()); |
|
|
|
List<XYPoint> pts = JSONUtil.toList(ps.getAlignPoints(), XYPoint.class); |
|
|
@ -169,9 +176,9 @@ public class RecordApi { |
|
|
|
for (XYPoint pt : pts) { |
|
|
|
sb.append(String.format(Locale.US, "%1$.6f %2$.6f%n", pt.getX(), -pt.getY())); |
|
|
|
} |
|
|
|
String fileName = "export-" + desc.getName() + ".txt"; |
|
|
|
String fileName = "export-" + desc.getName() + "." + downloadFileType; |
|
|
|
try { |
|
|
|
FileUtil.writeTextToDownloadSubDir("廓形导出",fileName,sb.toString()); |
|
|
|
FileUtil.writeTextToDownloadSubDir("廓形导出", fileName, sb.toString()); |
|
|
|
new Handler(Looper.getMainLooper()).post(() -> { |
|
|
|
Toast.makeText(context, "导出成功\n" + "/Download/廓形导出/\n" + fileName, Toast.LENGTH_LONG).show(); |
|
|
|
}); |
|
|
|