|
@@ -0,0 +1,82 @@
|
|
|
+package com.jjt.out.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.jjt.common.constant.Constants;
|
|
|
+import com.jjt.common.domain.FileDesc;
|
|
|
+import com.jjt.common.domain.IndexDO;
|
|
|
+import com.jjt.common.enums.SyncType;
|
|
|
+import com.jjt.common.utils.CompressZip;
|
|
|
+import com.jjt.common.utils.DateUtils;
|
|
|
+import com.jjt.common.utils.LinuxCommand;
|
|
|
+import com.jjt.out.service.IOutMysqlService;
|
|
|
+import com.jjt.system.service.ISysConfigService;
|
|
|
+import org.apache.commons.codec.digest.DigestUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 数据同步Service业务层处理
|
|
|
+ *
|
|
|
+ * @author wukai
|
|
|
+ * @date 2023-06-06
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class OutBaseService {
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(OutBaseService.class);
|
|
|
+ @Resource
|
|
|
+ private ISysConfigService sysConfigService;
|
|
|
+
|
|
|
+ private String getDir(String key) {
|
|
|
+ String dir = sysConfigService.selectConfigByKey(key);
|
|
|
+
|
|
|
+ if (!dir.endsWith(Constants.DIR_END)) {
|
|
|
+ dir += "/";
|
|
|
+ }
|
|
|
+
|
|
|
+ //如果没有目录,则创建目录
|
|
|
+ File file = new File(dir);
|
|
|
+ if (!file.exists()) {
|
|
|
+ boolean b = file.mkdirs();
|
|
|
+ log.info("创建目录", dir, b);
|
|
|
+ }
|
|
|
+ return dir;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取外网临时目录
|
|
|
+ *
|
|
|
+ * @return 临时目录
|
|
|
+ */
|
|
|
+ public String tmpDIr() {
|
|
|
+ return getDir("out.dir.tmp");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取外网同步目录
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String syncDIr(){
|
|
|
+ return getDir("out.dir.sync");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取外网备份目录
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String bakDir(){
|
|
|
+ return getDir("out.dir.bak");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|