feat: 图片同步

lh_dev_fifo^2
chenhc 3 months ago
parent 72bd111c70
commit 0a6811ded7

@ -9,5 +9,6 @@ public class FileConstant {
public static String PDF_FILE_PATH = "";
public static String COMMON_FILE_PATH = "register/image2/";
public static String DEV_COMMON_FILE_PATH = "register/device/";
}

@ -87,6 +87,7 @@ public class IdcServiceImpl implements IdcService {
private ScheduledDao scheduledDao;
private String imagePath = FileConstant.COMMON_FILE_PATH;
private String devImagePath = FileConstant.DEV_COMMON_FILE_PATH;
/*获取拉取任务列表*/
@Override
@ -1166,8 +1167,8 @@ public class IdcServiceImpl implements IdcService {
@Override
public boolean signleDownloadFile(String syncIp, String fileName) {
String filePathSlash = filePath.substring(filePath.length() - 1).equals("/") ? "" : "/";
if (!FileUtils.makeDirectory(filePath + filePathSlash + imagePath))
IDCUtils.createDirectory(filePath + filePathSlash + imagePath);
if (!FileUtils.makeDirectory(filePath + filePathSlash + devImagePath))
IDCUtils.createDirectory(filePath + filePathSlash + devImagePath);
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
;
@ -1189,7 +1190,7 @@ public class IdcServiceImpl implements IdcService {
try (InputStream inputStream = result.body().byteStream()) {
FileOutputStream outputStream = new FileOutputStream(filePath + filePathSlash + imagePath + fileName);
FileOutputStream outputStream = new FileOutputStream(filePath + filePathSlash + devImagePath + fileName);
byte b[] = new byte[1024];
@ -1203,7 +1204,7 @@ public class IdcServiceImpl implements IdcService {
outputStream.flush();
outputStream.close();
if (!(total > 0)) {
new File(filePath + filePathSlash + imagePath + fileName).delete();
new File(filePath + filePathSlash + devImagePath + fileName).delete();
executeSql("delete from idc_file where filePath='" + fileName + "'");
}

Loading…
Cancel
Save