|
|
|
@ -85,6 +85,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
@Resource
|
|
|
|
|
private ScheduledDao scheduledDao;
|
|
|
|
|
|
|
|
|
|
private String imagePath = "register/file/image2/";
|
|
|
|
|
/*获取拉取任务列表*/
|
|
|
|
|
@Override
|
|
|
|
|
public BaseResponse taskList(HttpServletRequest request, Map<String, Object> params) {
|
|
|
|
@ -410,7 +411,8 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
IDCUtils.createDirectory(filePath + filePathSlash + datePath + "/");
|
|
|
|
|
if (!FileUtils.makeDirectory(backFilePath + backFileSlash + datePath))
|
|
|
|
|
IDCUtils.createDirectory(filePath + backFileSlash + datePath + "/");
|
|
|
|
|
|
|
|
|
|
if(!FileUtils.makeDirectory(filePath + filePathSlash + imagePath))
|
|
|
|
|
IDCUtils.createDirectory(filePath + filePathSlash + imagePath);
|
|
|
|
|
FileUtils.SaveFileAs(content, fileName);
|
|
|
|
|
FileUtils.SaveFileAs(content, backFileName);
|
|
|
|
|
ArrayList<String> saveFiles = new ArrayList<>();
|
|
|
|
@ -420,11 +422,11 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
int n = 0;
|
|
|
|
|
try {
|
|
|
|
|
for (MultipartFile file : files) {
|
|
|
|
|
String imageName = filePath + filePathSlash + "register/file/image2/" + file.getOriginalFilename();
|
|
|
|
|
String imageName = filePath + filePathSlash + imagePath + file.getOriginalFilename();
|
|
|
|
|
saveFiles.add(imageName);
|
|
|
|
|
|
|
|
|
|
writeFile(file.getBytes(), filePath + filePathSlash + "register/file/image2/", file.getOriginalFilename());
|
|
|
|
|
writeFile(file.getBytes(), backFilePath + backFileSlash + datePath + "register/file/image2/", file.getOriginalFilename());
|
|
|
|
|
writeFile(file.getBytes(), filePath + filePathSlash + imagePath, file.getOriginalFilename());
|
|
|
|
|
writeFile(file.getBytes(), backFilePath + backFileSlash + datePath + imagePath, file.getOriginalFilename());
|
|
|
|
|
n++;
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
@ -486,14 +488,16 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
public void downloadFile(String fileName, HttpServletResponse response) {
|
|
|
|
|
OutputStream os;
|
|
|
|
|
String filePathSlash = filePath.substring(filePath.length() - 1).equals("/") ? "" : fileName.substring(0, 1).equals("/") ? "" : "/";
|
|
|
|
|
|
|
|
|
|
String sourceFileName = filePath +filePathSlash+imagePath +fileName;
|
|
|
|
|
try {
|
|
|
|
|
if (FileUtils.isFileExist(filePath + filePathSlash + fileName)) {
|
|
|
|
|
byte[] bytes = FileUtils.readFileByBytes(filePath + filePathSlash + fileName);
|
|
|
|
|
if (FileUtils.isFileExist(sourceFileName)) {
|
|
|
|
|
byte[] bytes = FileUtils.readFileByBytes(sourceFileName);
|
|
|
|
|
os = response.getOutputStream();
|
|
|
|
|
os.write(bytes);
|
|
|
|
|
os.flush();
|
|
|
|
|
os.close();
|
|
|
|
|
} else {
|
|
|
|
|
logger.error("file not exists:"+sourceFileName);
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
@ -619,8 +623,8 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
String fileNames = list.get(m).get(filePathColumn).toString();
|
|
|
|
|
String[] str = fileNames.split(",");
|
|
|
|
|
for (int r = 0; r < str.length; r++) {
|
|
|
|
|
if (!StringUtils.isEmpty(str[r]) && FileUtils.isFileExist(filePath + filePathSlash + "register/file/image2/" + str[r]))
|
|
|
|
|
files.add(filePath + filePathSlash + "register/file/image2/" + str[r]);
|
|
|
|
|
if (!StringUtils.isEmpty(str[r]) && FileUtils.isFileExist(filePath + filePathSlash + imagePath + str[r]))
|
|
|
|
|
files.add(filePath + filePathSlash + imagePath + str[r]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
recordSql += !StringUtils.isEmpty(recordSql) ? "," : "";
|
|
|
|
@ -642,8 +646,8 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
if (childList.get(i).get(chidTnames[7]) != null) {
|
|
|
|
|
String[] str = childList.get(i).get(chidTnames[7]).toString().split(",");
|
|
|
|
|
for (int s = 0; s < str.length; s++) {
|
|
|
|
|
if (!StringUtils.isEmpty(str[s]) && FileUtils.isFileExist(filePath + filePathSlash + "register/file/image2/" + str[s]))
|
|
|
|
|
files.add(filePath + filePathSlash + "register/file/image2/" + str[s]);
|
|
|
|
|
if (!StringUtils.isEmpty(str[s]) && FileUtils.isFileExist(filePath + filePathSlash + imagePath + str[s]))
|
|
|
|
|
files.add(filePath + filePathSlash + imagePath + str[s]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1009,6 +1013,9 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private 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);
|
|
|
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
|
|
|
.build();
|
|
|
|
|
;
|
|
|
|
@ -1025,13 +1032,12 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
Response result = client.newCall(request).execute();
|
|
|
|
|
String msg = result!=null ? result.message().length()>200 ? result.message().substring(0,200) : result.message() : "";
|
|
|
|
|
int total = 0;
|
|
|
|
|
|
|
|
|
|
if (result!=null&&result.isSuccessful()&&MediaType.parse("application/force-download").equals(result.body().contentType())) {
|
|
|
|
|
try (InputStream inputStream = result.body().byteStream()) {
|
|
|
|
|
|
|
|
|
|
String filePathSlash = filePath.substring(filePath.length() - 1).equals("/") ? "" : "/";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileOutputStream outputStream = new FileOutputStream(filePath + filePathSlash + fileName);
|
|
|
|
|
FileOutputStream outputStream = new FileOutputStream(filePath + filePathSlash + imagePath+fileName);
|
|
|
|
|
|
|
|
|
|
byte b[] = new byte[1024];
|
|
|
|
|
|
|
|
|
@ -1045,7 +1051,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
outputStream.flush();
|
|
|
|
|
outputStream.close();
|
|
|
|
|
if(!(total>0)) {
|
|
|
|
|
new File(filePath + filePathSlash + fileName).delete();
|
|
|
|
|
new File(filePath + filePathSlash + imagePath+fileName).delete();
|
|
|
|
|
executeSql("delete from idc_file where filePath='"+fileName+"'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1059,7 +1065,6 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
executeSql(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
@ -1247,6 +1252,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void executeSql(String sql) {
|
|
|
|
|
try {
|
|
|
|
|
jdbcTemplate.execute(sql);
|
|
|
|
|