Ver Fonte

mongo内网处理恢复增量备份

wukai há 1 ano atrás
pai
commit
f70ddfa43a

+ 127 - 0
sync-in/src/main/java/com/jjt/in/controller/InSyncInfoController.java

@@ -0,0 +1,127 @@
+package com.jjt.in.controller;
+
+import java.util.List;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import com.jjt.common.annotation.Log;
+import com.jjt.common.enums.BusinessType;
+import com.jjt.in.domain.InSyncInfo;
+import com.jjt.in.service.IInSyncInfoService;
+import com.jjt.common.core.controller.BaseController;
+import com.jjt.common.core.domain.AjaxResult;
+import com.jjt.common.utils.poi.ExcelUtil;
+import com.jjt.common.core.page.TableDataInfo;
+
+/**
+ * 内网数据同步Controller
+ * 
+ * @author ruoyi
+ * @date 2023-06-20
+ */
+@Controller
+@RequestMapping("/in/info")
+public class InSyncInfoController extends BaseController
+{
+    private String prefix = "in/info";
+
+    @Autowired
+    private IInSyncInfoService inSyncInfoService;
+
+    @RequiresPermissions("in:info:view")
+    @GetMapping()
+    public String info()
+    {
+        return prefix + "/info";
+    }
+
+    /**
+     * 查询内网数据同步列表
+     */
+    @RequiresPermissions("in:info:list")
+    @PostMapping("/list")
+    @ResponseBody
+    public TableDataInfo list(InSyncInfo inSyncInfo)
+    {
+        startPage();
+        List<InSyncInfo> list = inSyncInfoService.selectInSyncInfoList(inSyncInfo);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出内网数据同步列表
+     */
+    @RequiresPermissions("in:info:export")
+    @Log(title = "内网数据同步", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    @ResponseBody
+    public AjaxResult export(InSyncInfo inSyncInfo)
+    {
+        List<InSyncInfo> list = inSyncInfoService.selectInSyncInfoList(inSyncInfo);
+        ExcelUtil<InSyncInfo> util = new ExcelUtil<InSyncInfo>(InSyncInfo.class);
+        return util.exportExcel(list, "内网数据同步数据");
+    }
+
+    /**
+     * 新增内网数据同步
+     */
+    @GetMapping("/add")
+    public String add()
+    {
+        return prefix + "/add";
+    }
+
+    /**
+     * 新增保存内网数据同步
+     */
+    @RequiresPermissions("in:info:add")
+    @Log(title = "内网数据同步", businessType = BusinessType.INSERT)
+    @PostMapping("/add")
+    @ResponseBody
+    public AjaxResult addSave(InSyncInfo inSyncInfo)
+    {
+        return toAjax(inSyncInfoService.insertInSyncInfo(inSyncInfo));
+    }
+
+    /**
+     * 修改内网数据同步
+     */
+    @RequiresPermissions("in:info:edit")
+    @GetMapping("/edit/{infoId}")
+    public String edit(@PathVariable("infoId") Long infoId, ModelMap mmap)
+    {
+        InSyncInfo inSyncInfo = inSyncInfoService.selectInSyncInfoByInfoId(infoId);
+        mmap.put("inSyncInfo", inSyncInfo);
+        return prefix + "/edit";
+    }
+
+    /**
+     * 修改保存内网数据同步
+     */
+    @RequiresPermissions("in:info:edit")
+    @Log(title = "内网数据同步", businessType = BusinessType.UPDATE)
+    @PostMapping("/edit")
+    @ResponseBody
+    public AjaxResult editSave(InSyncInfo inSyncInfo)
+    {
+        return toAjax(inSyncInfoService.updateInSyncInfo(inSyncInfo));
+    }
+
+    /**
+     * 删除内网数据同步
+     */
+    @RequiresPermissions("in:info:remove")
+    @Log(title = "内网数据同步", businessType = BusinessType.DELETE)
+    @PostMapping( "/remove")
+    @ResponseBody
+    public AjaxResult remove(String ids)
+    {
+        return toAjax(inSyncInfoService.deleteInSyncInfoByInfoIds(ids));
+    }
+}

+ 164 - 0
sync-in/src/main/java/com/jjt/in/domain/InSyncInfo.java

@@ -0,0 +1,164 @@
+package com.jjt.in.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.jjt.common.annotation.Excel;
+import com.jjt.common.core.domain.BaseEntity;
+
+/**
+ * 内网数据同步对象 in_sync_info
+ * 
+ * @author ruoyi
+ * @date 2023-06-20
+ */
+public class InSyncInfo extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 数据ID */
+    private Long infoId;
+
+    /** 同步类型 */
+    @Excel(name = "同步类型")
+    private String syncType;
+
+    /** 同步文件名 */
+    @Excel(name = "同步文件名")
+    private String syncFileName;
+
+    /** 同步文件MD5值 */
+    @Excel(name = "同步文件MD5值")
+    private String syncFileMd5;
+
+    /** 同步文件大小 */
+    @Excel(name = "同步文件大小")
+    private Long syncFileSize;
+
+    /** 同步文件本次序号 */
+    @Excel(name = "同步文件本次序号")
+    private Long syncSort;
+
+    /** 文件MD5值校验 */
+    @Excel(name = "文件MD5值校验")
+    private String syncValid;
+
+    /** 文件处理花费时间 */
+    @Excel(name = "文件处理花费时间")
+    private Long costTime;
+
+    /** 成功状态 */
+    @Excel(name = "成功状态")
+    private String isSucess;
+
+    /** 日志信息 */
+    @Excel(name = "日志信息")
+    private String logMsg;
+
+    public void setInfoId(Long infoId) 
+    {
+        this.infoId = infoId;
+    }
+
+    public Long getInfoId() 
+    {
+        return infoId;
+    }
+    public void setSyncType(String syncType) 
+    {
+        this.syncType = syncType;
+    }
+
+    public String getSyncType() 
+    {
+        return syncType;
+    }
+    public void setSyncFileName(String syncFileName) 
+    {
+        this.syncFileName = syncFileName;
+    }
+
+    public String getSyncFileName() 
+    {
+        return syncFileName;
+    }
+    public void setSyncFileMd5(String syncFileMd5) 
+    {
+        this.syncFileMd5 = syncFileMd5;
+    }
+
+    public String getSyncFileMd5() 
+    {
+        return syncFileMd5;
+    }
+    public void setSyncFileSize(Long syncFileSize) 
+    {
+        this.syncFileSize = syncFileSize;
+    }
+
+    public Long getSyncFileSize() 
+    {
+        return syncFileSize;
+    }
+    public void setSyncSort(Long syncSort) 
+    {
+        this.syncSort = syncSort;
+    }
+
+    public Long getSyncSort() 
+    {
+        return syncSort;
+    }
+    public void setSyncValid(String syncValid) 
+    {
+        this.syncValid = syncValid;
+    }
+
+    public String getSyncValid() 
+    {
+        return syncValid;
+    }
+    public void setCostTime(Long costTime) 
+    {
+        this.costTime = costTime;
+    }
+
+    public Long getCostTime() 
+    {
+        return costTime;
+    }
+    public void setIsSucess(String isSucess) 
+    {
+        this.isSucess = isSucess;
+    }
+
+    public String getIsSucess() 
+    {
+        return isSucess;
+    }
+    public void setLogMsg(String logMsg) 
+    {
+        this.logMsg = logMsg;
+    }
+
+    public String getLogMsg() 
+    {
+        return logMsg;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("infoId", getInfoId())
+            .append("syncType", getSyncType())
+            .append("syncFileName", getSyncFileName())
+            .append("syncFileMd5", getSyncFileMd5())
+            .append("syncFileSize", getSyncFileSize())
+            .append("syncSort", getSyncSort())
+            .append("syncValid", getSyncValid())
+            .append("costTime", getCostTime())
+            .append("isSucess", getIsSucess())
+            .append("createTime", getCreateTime())
+            .append("logMsg", getLogMsg())
+            .toString();
+    }
+}

+ 61 - 0
sync-in/src/main/java/com/jjt/in/mapper/InSyncInfoMapper.java

@@ -0,0 +1,61 @@
+package com.jjt.in.mapper;
+
+import java.util.List;
+import com.jjt.in.domain.InSyncInfo;
+
+/**
+ * 内网数据同步Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2023-06-20
+ */
+public interface InSyncInfoMapper 
+{
+    /**
+     * 查询内网数据同步
+     * 
+     * @param infoId 内网数据同步主键
+     * @return 内网数据同步
+     */
+    public InSyncInfo selectInSyncInfoByInfoId(Long infoId);
+
+    /**
+     * 查询内网数据同步列表
+     * 
+     * @param inSyncInfo 内网数据同步
+     * @return 内网数据同步集合
+     */
+    public List<InSyncInfo> selectInSyncInfoList(InSyncInfo inSyncInfo);
+
+    /**
+     * 新增内网数据同步
+     * 
+     * @param inSyncInfo 内网数据同步
+     * @return 结果
+     */
+    public int insertInSyncInfo(InSyncInfo inSyncInfo);
+
+    /**
+     * 修改内网数据同步
+     * 
+     * @param inSyncInfo 内网数据同步
+     * @return 结果
+     */
+    public int updateInSyncInfo(InSyncInfo inSyncInfo);
+
+    /**
+     * 删除内网数据同步
+     * 
+     * @param infoId 内网数据同步主键
+     * @return 结果
+     */
+    public int deleteInSyncInfoByInfoId(Long infoId);
+
+    /**
+     * 批量删除内网数据同步
+     * 
+     * @param infoIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteInSyncInfoByInfoIds(String[] infoIds);
+}

+ 16 - 0
sync-in/src/main/java/com/jjt/in/service/IInMongoService.java

@@ -0,0 +1,16 @@
+package com.jjt.in.service;
+
+/**
+ * 数据同步Service接口
+ *
+ * @author ruoyi
+ * @date 2023-06-07
+ */
+public interface IInMongoService {
+    /**
+     * 解析同步文件
+     *
+     * @param dir 解析文件目录
+     */
+    public void parseSyncFile(String dir) throws Exception;
+}

+ 61 - 0
sync-in/src/main/java/com/jjt/in/service/IInSyncInfoService.java

@@ -0,0 +1,61 @@
+package com.jjt.in.service;
+
+import java.util.List;
+import com.jjt.in.domain.InSyncInfo;
+
+/**
+ * 内网数据同步Service接口
+ * 
+ * @author ruoyi
+ * @date 2023-06-20
+ */
+public interface IInSyncInfoService 
+{
+    /**
+     * 查询内网数据同步
+     * 
+     * @param infoId 内网数据同步主键
+     * @return 内网数据同步
+     */
+    public InSyncInfo selectInSyncInfoByInfoId(Long infoId);
+
+    /**
+     * 查询内网数据同步列表
+     * 
+     * @param inSyncInfo 内网数据同步
+     * @return 内网数据同步集合
+     */
+    public List<InSyncInfo> selectInSyncInfoList(InSyncInfo inSyncInfo);
+
+    /**
+     * 新增内网数据同步
+     * 
+     * @param inSyncInfo 内网数据同步
+     * @return 结果
+     */
+    public int insertInSyncInfo(InSyncInfo inSyncInfo);
+
+    /**
+     * 修改内网数据同步
+     * 
+     * @param inSyncInfo 内网数据同步
+     * @return 结果
+     */
+    public int updateInSyncInfo(InSyncInfo inSyncInfo);
+
+    /**
+     * 批量删除内网数据同步
+     * 
+     * @param infoIds 需要删除的内网数据同步主键集合
+     * @return 结果
+     */
+    public int deleteInSyncInfoByInfoIds(String infoIds);
+
+    /**
+     * 删除内网数据同步信息
+     * 
+     * @param infoId 内网数据同步主键
+     * @return 结果
+     */
+    public int deleteInSyncInfoByInfoId(Long infoId);
+}

+ 11 - 8
sync-in/src/main/java/com/jjt/in/service/impl/InBaseService.java

@@ -8,6 +8,9 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 
 /**
  * 数据同步Service业务层处理
@@ -27,13 +30,13 @@ public class InBaseService {
         if (!dir.endsWith(Constants.DIR_END)) {
             dir += "/";
         }
-
-        //如果没有目录,则创建目录
-        File file = new File(dir);
-        if (!file.exists()) {
-            boolean b = file.mkdirs();
-            log.info("创建目录", dir, b);
+        try {
+            //创建目录及父目录
+            Files.createDirectories(Paths.get(dir));
+        } catch (IOException e) {
+            throw new RuntimeException(e);
         }
+
         return dir;
     }
 
@@ -51,7 +54,7 @@ public class InBaseService {
      *
      * @return
      */
-    public String syncDIr(){
+    public String syncDIr() {
         return getDir("in.dir.sync");
     }
 
@@ -60,7 +63,7 @@ public class InBaseService {
      *
      * @return
      */
-    public String bakDir(){
+    public String bakDir() {
         return getDir("in.dir.bak");
     }
 

+ 1 - 7
sync-in/src/main/java/com/jjt/in/service/impl/InEsServiceImpl.java

@@ -123,13 +123,7 @@ public class InEsServiceImpl extends InBaseService implements IInEsService {
                 }
             }
         } catch (IOException e) {
-            log.error("处理es出错啦:", e.getMessage());
+            log.error("处理es出错啦:{}", e.getMessage());
         }
     }
-
-//    elasticdump --input http://localhost:9200/test --output /mnt/test_index_mapping.json --type=mapping
-//    elasticdump --input http://localhost:9200/test --output /mnt/test_index_data.json --type=data
-
-//    elasticdump --input ./test_index_mapping.json --output http://localhost:9200/ --type=mapping
-//    elasticdump --input ./test_index_data.json --output http://192.168.188.61:9200/ --type=data
 }

+ 61 - 0
sync-in/src/main/java/com/jjt/in/service/impl/InMongoServiceImpl.java

@@ -0,0 +1,61 @@
+package com.jjt.in.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.jjt.common.constant.Constants;
+import com.jjt.common.domain.IndexDO;
+import com.jjt.common.utils.LinuxCommand;
+import com.jjt.in.service.IInEsService;
+import com.jjt.in.service.IInMongoService;
+import com.jjt.system.service.ISysConfigService;
+import org.apache.http.HttpHost;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestClient;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.client.indices.CreateIndexRequest;
+import org.elasticsearch.client.indices.CreateIndexResponse;
+import org.elasticsearch.common.settings.Settings;
+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;
+
+/**
+ * 数据同步Service业务层处理
+ *
+ * @author wukai
+ * @date 2023-06-06
+ */
+@Service
+public class InMongoServiceImpl extends InBaseService implements IInMongoService {
+    private static final Logger log = LoggerFactory.getLogger(InMongoServiceImpl.class);
+    @Resource
+    private ISysConfigService sysConfigService;
+
+    /**
+     * 解析同步文件
+     */
+    @Override
+    public void parseSyncFile(String dir) throws Exception {
+        String params = sysConfigService.selectConfigByKey("in.mongo.info");
+
+        JSONObject mongoInfo = JSONObject.parseObject(params);
+        String host = mongoInfo.getString("host");
+        String port = mongoInfo.getString("port");
+        if (!dir.endsWith(Constants.DIR_END)) {
+            dir += "/";
+        }
+
+        String filaName = dir + "local/oplog.rs.bson";
+        try {
+            String cmd = String.format("/usr/bin/mongorestore --host %s --port %s --drop --oplogReplay %s", host, port, filaName);
+            LinuxCommand.exec(cmd);
+        } catch (Exception e) {
+            log.error("还原mongo出错啦:{}", e.getMessage());
+            throw new Exception(e.getMessage());
+        }
+    }
+}

+ 59 - 32
sync-in/src/main/java/com/jjt/in/service/impl/InProcessServiceImpl.java

@@ -5,8 +5,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import com.jjt.common.constant.Constants;
 import com.jjt.common.domain.FileDesc;
 import com.jjt.common.utils.*;
+import com.jjt.in.domain.InSyncInfo;
 import com.jjt.in.service.IInEsService;
+import com.jjt.in.service.IInMongoService;
 import com.jjt.in.service.IInProcessService;
+import com.jjt.in.service.IInSyncInfoService;
 import com.jjt.system.service.ISysConfigService;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.slf4j.Logger;
@@ -19,10 +22,7 @@ import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.nio.file.StandardCopyOption;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
+import java.util.*;
 
 /**
  * 数据同步Service业务层处理
@@ -37,6 +37,10 @@ public class InProcessServiceImpl extends InBaseService implements IInProcessSer
     private ISysConfigService sysConfigService;
     @Resource
     private IInEsService esService;
+    @Resource
+    private IInMongoService mongoService;
+    @Resource
+    private IInSyncInfoService syncInfoService;
 
     /**
      * 从光闸FTP下载文件
@@ -82,47 +86,70 @@ public class InProcessServiceImpl extends InBaseService implements IInProcessSer
                 for (File file : files) {
                     ObjectMapper mapper = new ObjectMapper();
                     FileDesc desc = mapper.readValue(file, FileDesc.class);
+                    //写入同步记录表
+                    InSyncInfo syncInfo = new InSyncInfo();
 
+                    syncInfo.setSyncType(desc.getType().toString());
+                    syncInfo.setSyncFileName(desc.getName());
                     File zipFile = new File(syncDir + desc.getName());
                     String md5 = DigestUtils.md5Hex(Files.newInputStream(zipFile.toPath()));
+                    syncInfo.setSyncFileMd5(md5);
+                    syncInfo.setSyncFileSize(zipFile.length());
+                    Date st = new Date();
+                    syncInfo.setCreateTime(st);
                     if (md5.equals(desc.getMd5())) {
-                        System.err.println("这个是正确的" + desc.toString());
-                        switch (desc.getType()) {
-                            case crontab:
-                                handleCrontabType(zipFile);
-                                break;
-                            case es:
-                                File targetDir = new File(tmpDir + "es/");
-                                CompressZip.unzip(zipFile, targetDir);
-                                String esDir = tmpDir + "es/" + desc.getName().split("\\.")[0].split("-")[2];
-                                esService.parseSyncFile(esDir);
-                                break;
-                            case mongo:
-                            case mysql:
-                                handleMysqlType(zipFile);
-                                break;
-                            case other:
-                                handleOtherType(desc.getTarget(), zipFile);
-                                break;
-                            case php:
-                                handlePhpType(desc.getTarget(), zipFile);
-                                break;
-                            case shell:
-                                handleShellType(desc.getTarget(), zipFile);
-                                break;
-                            default:
-                                break;
+                        syncInfo.setSyncValid("Y");
+                        try {
+                            switch (desc.getType()) {
+                                case crontab:
+                                    handleCrontabType(zipFile);
+                                    break;
+                                case es:
+                                    File targetDir = new File(tmpDir + "es/");
+                                    CompressZip.unzip(zipFile, targetDir);
+                                    String esDir = tmpDir + "es/" + desc.getName().split("\\.")[0].split("-")[2];
+                                    esService.parseSyncFile(esDir);
+                                    break;
+                                case mongo:
+                                    File mongoTargetDir = new File(tmpDir + "mongo/");
+                                    CompressZip.unzip(zipFile, mongoTargetDir);
+                                    String mongoDir = tmpDir + "mongo/" + desc.getName().split("\\.")[0].split("-")[2];
+                                    mongoService.parseSyncFile(mongoDir);
+                                    break;
+                                case mysql:
+                                    handleMysqlType(zipFile);
+                                    break;
+                                case other:
+                                    handleOtherType(desc.getTarget(), zipFile);
+                                    break;
+                                case php:
+                                    handlePhpType(desc.getTarget(), zipFile);
+                                    break;
+                                case shell:
+                                    handleShellType(desc.getTarget(), zipFile);
+                                    break;
+                                default:
+                                    break;
+                            }
+                            syncInfo.setIsSucess("Y");
+                        } catch (Exception e) {
+                            syncInfo.setIsSucess("N");
+                            syncInfo.setLogMsg(e.getMessage());
                         }
                         //移动文件到备份目录
                         Files.move(file.toPath(), Paths.get(bakDir + file.getName()), StandardCopyOption.REPLACE_EXISTING);
                         Files.move(zipFile.toPath(), Paths.get(bakDir + zipFile.getName()), StandardCopyOption.REPLACE_EXISTING);
                     } else {
-                        System.err.println("这个是错误滴" + desc.toString());
+                        syncInfo.setSyncValid("N");
+                        syncInfo.setIsSucess("N");
                     }
+                    Date et = new Date();
+                    syncInfo.setCostTime(et.getTime() - st.getTime());
+                    syncInfoService.insertInSyncInfo(syncInfo);
                 }
             }
         } catch (Exception e) {
-            log.error("处理es出错啦:", e.getMessage());
+            log.error("同步处理出错啦:{}", e.getMessage());
             e.printStackTrace();
         }
     }

+ 92 - 0
sync-in/src/main/java/com/jjt/in/service/impl/InSyncInfoServiceImpl.java

@@ -0,0 +1,92 @@
+package com.jjt.in.service.impl;
+
+import java.util.List;
+
+import com.jjt.common.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.jjt.in.mapper.InSyncInfoMapper;
+import com.jjt.in.domain.InSyncInfo;
+import com.jjt.in.service.IInSyncInfoService;
+import com.jjt.common.core.text.Convert;
+
+import javax.annotation.Resource;
+
+/**
+ * 内网数据同步Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2023-06-20
+ */
+@Service
+public class InSyncInfoServiceImpl implements IInSyncInfoService {
+    @Resource
+    private InSyncInfoMapper inSyncInfoMapper;
+
+    /**
+     * 查询内网数据同步
+     *
+     * @param infoId 内网数据同步主键
+     * @return 内网数据同步
+     */
+    @Override
+    public InSyncInfo selectInSyncInfoByInfoId(Long infoId) {
+        return inSyncInfoMapper.selectInSyncInfoByInfoId(infoId);
+    }
+
+    /**
+     * 查询内网数据同步列表
+     *
+     * @param inSyncInfo 内网数据同步
+     * @return 内网数据同步
+     */
+    @Override
+    public List<InSyncInfo> selectInSyncInfoList(InSyncInfo inSyncInfo) {
+        return inSyncInfoMapper.selectInSyncInfoList(inSyncInfo);
+    }
+
+    /**
+     * 新增内网数据同步
+     *
+     * @param inSyncInfo 内网数据同步
+     * @return 结果
+     */
+    @Override
+    public int insertInSyncInfo(InSyncInfo inSyncInfo) {
+        inSyncInfo.setCreateTime(DateUtils.getNowDate());
+        return inSyncInfoMapper.insertInSyncInfo(inSyncInfo);
+    }
+
+    /**
+     * 修改内网数据同步
+     *
+     * @param inSyncInfo 内网数据同步
+     * @return 结果
+     */
+    @Override
+    public int updateInSyncInfo(InSyncInfo inSyncInfo) {
+        return inSyncInfoMapper.updateInSyncInfo(inSyncInfo);
+    }
+
+    /**
+     * 批量删除内网数据同步
+     *
+     * @param infoIds 需要删除的内网数据同步主键
+     * @return 结果
+     */
+    @Override
+    public int deleteInSyncInfoByInfoIds(String infoIds) {
+        return inSyncInfoMapper.deleteInSyncInfoByInfoIds(Convert.toStrArray(infoIds));
+    }
+
+    /**
+     * 删除内网数据同步信息
+     *
+     * @param infoId 内网数据同步主键
+     * @return 结果
+     */
+    @Override
+    public int deleteInSyncInfoByInfoId(Long infoId) {
+        return inSyncInfoMapper.deleteInSyncInfoByInfoId(infoId);
+    }
+}

+ 118 - 0
sync-in/src/main/resources/mapper/in/InSyncInfoMapper.xml

@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.jjt.in.mapper.InSyncInfoMapper">
+
+    <resultMap type="InSyncInfo" id="InSyncInfoResult">
+        <result property="infoId" column="INFO_ID"/>
+        <result property="syncType" column="SYNC_TYPE"/>
+        <result property="syncFileName" column="SYNC_FILE_NAME"/>
+        <result property="syncFileMd5" column="SYNC_FILE_MD5"/>
+        <result property="syncFileSize" column="SYNC_FILE_SIZE"/>
+        <result property="syncSort" column="SYNC_SORT"/>
+        <result property="syncValid" column="SYNC_VALID"/>
+        <result property="costTime" column="COST_TIME"/>
+        <result property="isSucess" column="IS_SUCESS"/>
+        <result property="createTime" column="CREATE_TIME"/>
+        <result property="logMsg" column="LOG_MSG"/>
+    </resultMap>
+
+    <sql id="selectInSyncInfoVo">
+        select INFO_ID,
+               SYNC_TYPE,
+               SYNC_FILE_NAME,
+               SYNC_FILE_MD5,
+               SYNC_FILE_SIZE,
+               SYNC_SORT,
+               SYNC_VALID,
+               COST_TIME,
+               IS_SUCESS,
+               CREATE_TIME,
+               LOG_MSG
+        from in_sync_info
+    </sql>
+
+    <select id="selectInSyncInfoList" parameterType="InSyncInfo" resultMap="InSyncInfoResult">
+        <include refid="selectInSyncInfoVo"/>
+        <where>
+            <if test="syncType != null  and syncType != ''">and SYNC_TYPE = #{syncType}</if>
+            <if test="syncFileName != null  and syncFileName != ''">and SYNC_FILE_NAME like concat('%', #{syncFileName},
+                '%')
+            </if>
+            <if test="syncFileMd5 != null  and syncFileMd5 != ''">and SYNC_FILE_MD5 = #{syncFileMd5}</if>
+            <if test="syncFileSize != null ">and SYNC_FILE_SIZE = #{syncFileSize}</if>
+            <if test="syncSort != null ">and SYNC_SORT = #{syncSort}</if>
+            <if test="syncValid != null  and syncValid != ''">and SYNC_VALID = #{syncValid}</if>
+            <if test="costTime != null ">and COST_TIME = #{costTime}</if>
+            <if test="isSucess != null  and isSucess != ''">and IS_SUCESS = #{isSucess}</if>
+            <if test="createTime != null ">and CREATE_TIME = #{createTime}</if>
+            <if test="logMsg != null  and logMsg != ''">and LOG_MSG = #{logMsg}</if>
+        </where>
+        order by CREATE_TIME desc
+    </select>
+
+    <select id="selectInSyncInfoByInfoId" parameterType="Long" resultMap="InSyncInfoResult">
+        <include refid="selectInSyncInfoVo"/>
+        where INFO_ID = #{infoId}
+    </select>
+
+    <insert id="insertInSyncInfo" parameterType="InSyncInfo" useGeneratedKeys="true" keyProperty="infoId">
+        insert into in_sync_info
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="syncType != null">SYNC_TYPE,</if>
+            <if test="syncFileName != null">SYNC_FILE_NAME,</if>
+            <if test="syncFileMd5 != null">SYNC_FILE_MD5,</if>
+            <if test="syncFileSize != null">SYNC_FILE_SIZE,</if>
+            <if test="syncSort != null">SYNC_SORT,</if>
+            <if test="syncValid != null">SYNC_VALID,</if>
+            <if test="costTime != null">COST_TIME,</if>
+            <if test="isSucess != null">IS_SUCESS,</if>
+            <if test="createTime != null">CREATE_TIME,</if>
+            <if test="logMsg != null">LOG_MSG,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="syncType != null">#{syncType},</if>
+            <if test="syncFileName != null">#{syncFileName},</if>
+            <if test="syncFileMd5 != null">#{syncFileMd5},</if>
+            <if test="syncFileSize != null">#{syncFileSize},</if>
+            <if test="syncSort != null">#{syncSort},</if>
+            <if test="syncValid != null">#{syncValid},</if>
+            <if test="costTime != null">#{costTime},</if>
+            <if test="isSucess != null">#{isSucess},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="logMsg != null">#{logMsg},</if>
+        </trim>
+    </insert>
+
+    <update id="updateInSyncInfo" parameterType="InSyncInfo">
+        update in_sync_info
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="syncType != null">SYNC_TYPE = #{syncType},</if>
+            <if test="syncFileName != null">SYNC_FILE_NAME = #{syncFileName},</if>
+            <if test="syncFileMd5 != null">SYNC_FILE_MD5 = #{syncFileMd5},</if>
+            <if test="syncFileSize != null">SYNC_FILE_SIZE = #{syncFileSize},</if>
+            <if test="syncSort != null">SYNC_SORT = #{syncSort},</if>
+            <if test="syncValid != null">SYNC_VALID = #{syncValid},</if>
+            <if test="costTime != null">COST_TIME = #{costTime},</if>
+            <if test="isSucess != null">IS_SUCESS = #{isSucess},</if>
+            <if test="createTime != null">CREATE_TIME = #{createTime},</if>
+            <if test="logMsg != null">LOG_MSG = #{logMsg},</if>
+        </trim>
+        where INFO_ID = #{infoId}
+    </update>
+
+    <delete id="deleteInSyncInfoByInfoId" parameterType="Long">
+        delete
+        from in_sync_info
+        where INFO_ID = #{infoId}
+    </delete>
+
+    <delete id="deleteInSyncInfoByInfoIds" parameterType="String">
+        delete from in_sync_info where INFO_ID in
+        <foreach item="infoId" collection="array" open="(" separator="," close=")">
+            #{infoId}
+        </foreach>
+    </delete>
+
+</mapper>

+ 73 - 0
sync-in/src/main/resources/templates/in/info/add.html

@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
+<head>
+    <th:block th:include="include :: header('新增内网数据同步')" />
+</head>
+<body class="white-bg">
+    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
+        <form class="form-horizontal m" id="form-info-add">
+            <div class="form-group">    
+                <label class="col-sm-3 control-label">同步文件名:</label>
+                <div class="col-sm-8">
+                    <input name="syncFileName" class="form-control" type="text">
+                </div>
+            </div>
+            <div class="form-group">    
+                <label class="col-sm-3 control-label">同步文件MD5值:</label>
+                <div class="col-sm-8">
+                    <input name="syncFileMd5" class="form-control" type="text">
+                </div>
+            </div>
+            <div class="form-group">    
+                <label class="col-sm-3 control-label">同步文件大小:</label>
+                <div class="col-sm-8">
+                    <input name="syncFileSize" class="form-control" type="text">
+                </div>
+            </div>
+            <div class="form-group">    
+                <label class="col-sm-3 control-label">同步文件本次序号:</label>
+                <div class="col-sm-8">
+                    <input name="syncSort" class="form-control" type="text">
+                </div>
+            </div>
+            <div class="form-group">    
+                <label class="col-sm-3 control-label">文件MD5值校验:</label>
+                <div class="col-sm-8">
+                    <input name="syncValid" class="form-control" type="text">
+                </div>
+            </div>
+            <div class="form-group">    
+                <label class="col-sm-3 control-label">文件处理花费时间:</label>
+                <div class="col-sm-8">
+                    <input name="costTime" class="form-control" type="text">
+                </div>
+            </div>
+            <div class="form-group">    
+                <label class="col-sm-3 control-label">成功状态:</label>
+                <div class="col-sm-8">
+                    <input name="isSucess" class="form-control" type="text">
+                </div>
+            </div>
+            <div class="form-group">
+                <label class="col-sm-3 control-label">日志信息:</label>
+                <div class="col-sm-8">
+                    <textarea name="logMsg" class="form-control"></textarea>
+                </div>
+            </div>
+        </form>
+    </div>
+    <th:block th:include="include :: footer" />
+    <script th:inline="javascript">
+        var prefix = ctx + "in/info"
+        $("#form-info-add").validate({
+            focusCleanup: true
+        });
+
+        function submitHandler() {
+            if ($.validate.form()) {
+                $.operate.save(prefix + "/add", $('#form-info-add').serialize());
+            }
+        }
+    </script>
+</body>
+</html>

+ 74 - 0
sync-in/src/main/resources/templates/in/info/edit.html

@@ -0,0 +1,74 @@
+<!DOCTYPE html>
+<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
+<head>
+    <th:block th:include="include :: header('修改内网数据同步')" />
+</head>
+<body class="white-bg">
+    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
+        <form class="form-horizontal m" id="form-info-edit" th:object="${inSyncInfo}">
+            <input name="infoId" th:field="*{infoId}" type="hidden">
+            <div class="form-group">    
+                <label class="col-sm-3 control-label">同步文件名:</label>
+                <div class="col-sm-8">
+                    <input name="syncFileName" th:field="*{syncFileName}" class="form-control" type="text">
+                </div>
+            </div>
+            <div class="form-group">    
+                <label class="col-sm-3 control-label">同步文件MD5值:</label>
+                <div class="col-sm-8">
+                    <input name="syncFileMd5" th:field="*{syncFileMd5}" class="form-control" type="text">
+                </div>
+            </div>
+            <div class="form-group">    
+                <label class="col-sm-3 control-label">同步文件大小:</label>
+                <div class="col-sm-8">
+                    <input name="syncFileSize" th:field="*{syncFileSize}" class="form-control" type="text">
+                </div>
+            </div>
+            <div class="form-group">    
+                <label class="col-sm-3 control-label">同步文件本次序号:</label>
+                <div class="col-sm-8">
+                    <input name="syncSort" th:field="*{syncSort}" class="form-control" type="text">
+                </div>
+            </div>
+            <div class="form-group">    
+                <label class="col-sm-3 control-label">文件MD5值校验:</label>
+                <div class="col-sm-8">
+                    <input name="syncValid" th:field="*{syncValid}" class="form-control" type="text">
+                </div>
+            </div>
+            <div class="form-group">    
+                <label class="col-sm-3 control-label">文件处理花费时间:</label>
+                <div class="col-sm-8">
+                    <input name="costTime" th:field="*{costTime}" class="form-control" type="text">
+                </div>
+            </div>
+            <div class="form-group">    
+                <label class="col-sm-3 control-label">成功状态:</label>
+                <div class="col-sm-8">
+                    <input name="isSucess" th:field="*{isSucess}" class="form-control" type="text">
+                </div>
+            </div>
+            <div class="form-group">
+                <label class="col-sm-3 control-label">日志信息:</label>
+                <div class="col-sm-8">
+                    <textarea name="logMsg" class="form-control">[[*{logMsg}]]</textarea>
+                </div>
+            </div>
+        </form>
+    </div>
+    <th:block th:include="include :: footer" />
+    <script th:inline="javascript">
+        var prefix = ctx + "in/info";
+        $("#form-info-edit").validate({
+            focusCleanup: true
+        });
+
+        function submitHandler() {
+            if ($.validate.form()) {
+                $.operate.save(prefix + "/edit", $('#form-info-edit').serialize());
+            }
+        }
+    </script>
+</body>
+</html>

+ 150 - 0
sync-in/src/main/resources/templates/in/info/info.html

@@ -0,0 +1,150 @@
+<!DOCTYPE html>
+<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
+<head>
+    <th:block th:include="include :: header('内网数据同步列表')" />
+</head>
+<body class="gray-bg">
+     <div class="container-div">
+        <div class="row">
+            <div class="col-sm-12 search-collapse">
+                <form id="formId">
+                    <div class="select-list">
+                        <ul>
+                            <li>
+                                <label>同步文件名:</label>
+                                <input type="text" name="syncFileName"/>
+                            </li>
+                            <li>
+                                <label>同步文件MD5值:</label>
+                                <input type="text" name="syncFileMd5"/>
+                            </li>
+                            <li>
+                                <label>同步文件大小:</label>
+                                <input type="text" name="syncFileSize"/>
+                            </li>
+                            <li>
+                                <label>同步文件本次序号:</label>
+                                <input type="text" name="syncSort"/>
+                            </li>
+                            <li>
+                                <label>文件MD5值校验:</label>
+                                <input type="text" name="syncValid"/>
+                            </li>
+                            <li>
+                                <label>文件处理花费时间:</label>
+                                <input type="text" name="costTime"/>
+                            </li>
+                            <li>
+                                <label>成功状态:</label>
+                                <input type="text" name="isSucess"/>
+                            </li>
+                            <li>
+                                <label>文件处理时间:</label>
+                                <input type="text" class="time-input" placeholder="请选择文件处理时间" name="createTime"/>
+                            </li>
+                            <li>
+                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
+                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
+                            </li>
+                        </ul>
+                    </div>
+                </form>
+            </div>
+
+            <div class="btn-group-sm" id="toolbar" role="group">
+                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="in:info:add">
+                    <i class="fa fa-plus"></i> 添加
+                </a>
+                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="in:info:edit">
+                    <i class="fa fa-edit"></i> 修改
+                </a>
+                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="in:info:remove">
+                    <i class="fa fa-remove"></i> 删除
+                </a>
+                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="in:info:export">
+                    <i class="fa fa-download"></i> 导出
+                </a>
+            </div>
+            <div class="col-sm-12 select-table table-striped">
+                <table id="bootstrap-table"></table>
+            </div>
+        </div>
+    </div>
+    <th:block th:include="include :: footer" />
+    <script th:inline="javascript">
+        var editFlag = [[${@permission.hasPermi('in:info:edit')}]];
+        var removeFlag = [[${@permission.hasPermi('in:info:remove')}]];
+        var prefix = ctx + "in/info";
+
+        $(function() {
+            var options = {
+                url: prefix + "/list",
+                createUrl: prefix + "/add",
+                updateUrl: prefix + "/edit/{id}",
+                removeUrl: prefix + "/remove",
+                exportUrl: prefix + "/export",
+                modalName: "内网数据同步",
+                columns: [{
+                    checkbox: true
+                },
+                {
+                    field: 'infoId',
+                    title: '数据ID',
+                    visible: false
+                },
+                {
+                    field: 'syncType',
+                    title: '同步类型'
+                },
+                {
+                    field: 'syncFileName',
+                    title: '同步文件名'
+                },
+                {
+                    field: 'syncFileMd5',
+                    title: '同步文件MD5值'
+                },
+                {
+                    field: 'syncFileSize',
+                    title: '同步文件大小'
+                },
+                {
+                    field: 'syncSort',
+                    title: '同步文件本次序号'
+                },
+                {
+                    field: 'syncValid',
+                    title: '文件MD5值校验'
+                },
+                {
+                    field: 'costTime',
+                    title: '文件处理花费时间'
+                },
+                {
+                    field: 'isSucess',
+                    title: '成功状态'
+                },
+                {
+                    field: 'createTime',
+                    title: '文件处理时间'
+                },
+                {
+                    field: 'logMsg',
+                    title: '日志信息'
+                },
+                {
+                    title: '操作',
+                    align: 'center',
+                    formatter: function(value, row, index) {
+                        var actions = [];
+                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.infoId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
+                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.infoId + '\')"><i class="fa fa-remove"></i>删除</a>');
+                        return actions.join('');
+                    }
+                }]
+            };
+            $.table.init(options);
+        });
+    </script>
+</body>
+</html>

+ 9 - 7
sync-out/src/main/java/com/jjt/out/service/impl/OutBaseService.java

@@ -20,6 +20,7 @@ import javax.annotation.Resource;
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -42,12 +43,13 @@ public class OutBaseService {
             dir += "/";
         }
 
-        //如果没有目录,则创建目录
-        File file = new File(dir);
-        if (!file.exists()) {
-            boolean b = file.mkdirs();
-            log.info("创建目录", dir, b);
+        try {
+            //创建目录及父目录
+            Files.createDirectories(Paths.get(dir));
+        } catch (IOException e) {
+            throw new RuntimeException(e);
         }
+        
         return dir;
     }
 
@@ -65,7 +67,7 @@ public class OutBaseService {
      *
      * @return
      */
-    public String syncDIr(){
+    public String syncDIr() {
         return getDir("out.dir.sync");
     }
 
@@ -74,7 +76,7 @@ public class OutBaseService {
      *
      * @return
      */
-    public String bakDir(){
+    public String bakDir() {
         return getDir("out.dir.bak");
     }
 

+ 2 - 2
sync-out/src/main/java/com/jjt/out/service/impl/OutMongoServiceImpl.java

@@ -102,7 +102,7 @@ public class OutMongoServiceImpl extends OutBaseService implements IOutMongoServ
 
             //打包文件--start
             //生成zip文件全路径名
-            String zipName = "sync-mongo-" + time + ".zip";
+            String zipName = "sync-mongo-" + nowTime + ".zip";
 
             //打包目标目录
             File targetDir = new File(tmpDir);
@@ -112,7 +112,7 @@ public class OutMongoServiceImpl extends OutBaseService implements IOutMongoServ
 
             //生成描述json文件--start
             try {
-                String descName = syncDir + "sync-70-" + time + ".json";
+                String descName = syncDir + "sync-70-" + nowTime + ".json";
                 String md5 = DigestUtils.md5Hex(Files.newInputStream(zipFile.toPath()));
                 FileDesc desc = new FileDesc();
                 desc.setName(zipName);