修改已知问题。
This commit is contained in:
parent
47c4a16fb7
commit
3b721dd3c9
|
|
@ -1,5 +1,6 @@
|
||||||
package com.electromagnetic.industry.software.manage.pojo.resp;
|
package com.electromagnetic.industry.software.manage.pojo.resp;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
@ -15,8 +16,10 @@ public class FileBackLogVO {
|
||||||
|
|
||||||
private String fileName;
|
private String fileName;
|
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date backStartTime;
|
private Date backStartTime;
|
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date backEndTime;
|
private Date backEndTime;
|
||||||
|
|
||||||
private boolean backupSuccess;
|
private boolean backupSuccess;
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,10 @@ public class CommonService {
|
||||||
PATH_MAP.put(DataOwnEnum.REPO_PRJ.code, elePropertyConfig.getRepoPrjPath());
|
PATH_MAP.put(DataOwnEnum.REPO_PRJ.code, elePropertyConfig.getRepoPrjPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPrjPath(int dataOwnCode) {
|
||||||
|
return PATH_MAP.get(dataOwnCode) + File.separator;
|
||||||
|
}
|
||||||
|
|
||||||
public String getEleDataPath(int dataOwnCode) {
|
public String getEleDataPath(int dataOwnCode) {
|
||||||
|
|
||||||
if (DataOwnEnum.isUserCode(dataOwnCode)) {
|
if (DataOwnEnum.isUserCode(dataOwnCode)) {
|
||||||
|
|
@ -147,7 +151,8 @@ public class CommonService {
|
||||||
public String getFileSysPath(String dbPath, int dataOwnCode) {
|
public String getFileSysPath(String dbPath, int dataOwnCode) {
|
||||||
ArrayList<String> paths = CollUtil.newArrayList(dbPath.split(MYSQL_FILE_PATH_SPLIT));
|
ArrayList<String> paths = CollUtil.newArrayList(dbPath.split(MYSQL_FILE_PATH_SPLIT));
|
||||||
String path = getDbPath(paths);
|
String path = getDbPath(paths);
|
||||||
return getEleDataPath(dataOwnCode) + File.separator + path;
|
String destPath = getEleDataPath(dataOwnCode) + File.separator + path;
|
||||||
|
return destPath.replace("//", "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDbPath(String dbPath) {
|
public String getDbPath(String dbPath) {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.electromagnetic.industry.software.common.enums.DataOwnEnum;
|
||||||
import com.electromagnetic.industry.software.common.enums.EleDataTypeEnum;
|
import com.electromagnetic.industry.software.common.enums.EleDataTypeEnum;
|
||||||
import com.electromagnetic.industry.software.common.enums.FileBackupSource;
|
import com.electromagnetic.industry.software.common.enums.FileBackupSource;
|
||||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||||
|
|
@ -21,12 +22,15 @@ import com.electromagnetic.industry.software.manage.pojo.resp.FileBackLogVO;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.resp.RespPageVO;
|
import com.electromagnetic.industry.software.manage.pojo.resp.RespPageVO;
|
||||||
import com.electromagnetic.industry.software.manage.service.FileBackLogService;
|
import com.electromagnetic.industry.software.manage.service.FileBackLogService;
|
||||||
import com.electromagnetic.industry.software.manage.tasks.BackupHandler;
|
import com.electromagnetic.industry.software.manage.tasks.BackupHandler;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class FileBackLogServiceImpl extends ServiceImpl<FileBackupLogMapper, FileBackupLog> implements FileBackLogService {
|
public class FileBackLogServiceImpl extends ServiceImpl<FileBackupLogMapper, FileBackupLog> implements FileBackLogService {
|
||||||
|
|
||||||
|
|
@ -66,7 +70,15 @@ public class FileBackLogServiceImpl extends ServiceImpl<FileBackupLogMapper, Fil
|
||||||
.eq(EdFileInfo::getPermanentDeleted, false)
|
.eq(EdFileInfo::getPermanentDeleted, false)
|
||||||
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FILE.code));
|
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FILE.code));
|
||||||
for (EdFileInfo edFileInfo : edFileInfos) {
|
for (EdFileInfo edFileInfo : edFileInfos) {
|
||||||
String destPath = commonService.getFileSysPath(edFileInfo.getFilePath(), edFileInfo.getDataOwn());
|
|
||||||
|
String destPath = "";
|
||||||
|
if (DataOwnEnum.isUserCode(edFileInfo.getDataOwn())) {
|
||||||
|
destPath = commonService.getPrjPath(edFileInfo.getDataOwn()) + File.separator + edFileInfo.getCreatedBy() + File.separator + commonService.getDbPath(edFileInfo.getFilePath());
|
||||||
|
} else {
|
||||||
|
destPath = commonService.getPrjPath(edFileInfo.getDataOwn()) + File.separator + commonService.getDbPath(edFileInfo.getFilePath());
|
||||||
|
}
|
||||||
|
destPath = destPath.replace("//", "/");
|
||||||
|
log.info("back up file path is {}", destPath);
|
||||||
if (!FileUtil.exist(destPath)) {
|
if (!FileUtil.exist(destPath)) {
|
||||||
byte[] bytes = backupHandler.downloadFile(edFileInfo.getId());
|
byte[] bytes = backupHandler.downloadFile(edFileInfo.getId());
|
||||||
FileUtil.writeBytes(bytes, destPath);
|
FileUtil.writeBytes(bytes, destPath);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue