|
@@ -64,10 +64,45 @@ public class InProcessServiceImpl extends InBaseService implements IInProcessSer
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 从FTP接收目录拷入到正式同步目录
|
|
|
+ */
|
|
|
+ private void cpFile() {
|
|
|
+ String ftpDir = sysConfigService.selectConfigByKey("in.ftp.dir");
|
|
|
+ //获取内网同步正式目录
|
|
|
+ String syncDir = syncDIr();
|
|
|
+ // 创建File对象
|
|
|
+ File dirFile = new File(ftpDir);
|
|
|
+ if (dirFile.isDirectory()) {
|
|
|
+ //先获取目录下所有json格式文件
|
|
|
+ File[] files = dirFile.listFiles(((dir, name) -> name.endsWith(".json")));
|
|
|
+ if (files != null && files.length > 0) {
|
|
|
+ Arrays.sort(files, Comparator.comparing(File::getName));
|
|
|
+ }
|
|
|
+
|
|
|
+ for (File file : files) {
|
|
|
+ try {
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
+ FileDesc desc = mapper.readValue(file, FileDesc.class);
|
|
|
+ File zipFile = new File(ftpDir + desc.getName());
|
|
|
+ String md5 = DigestUtils.md5Hex(Files.newInputStream(zipFile.toPath()));
|
|
|
+ if (md5.equals(desc.getMd5())) {
|
|
|
+ Files.move(file.toPath(), Paths.get(syncDir + file.getName()), StandardCopyOption.REPLACE_EXISTING);
|
|
|
+ Files.move(zipFile.toPath(), Paths.get(syncDir + zipFile.getName()), StandardCopyOption.REPLACE_EXISTING);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 解压文件
|
|
|
*/
|
|
|
@Override
|
|
|
public void unzip() {
|
|
|
+ cpFile();
|
|
|
//获取内网同步正式目录
|
|
|
String syncDir = syncDIr();
|
|
|
//获取内网临时目录
|