完成工程导入部分的代码

This commit is contained in:
chenxudong 2025-06-18 12:01:46 +08:00
parent 049ebd0d6f
commit effa0d9f4d
32 changed files with 926 additions and 1004 deletions

View File

@ -43,6 +43,15 @@ public class ElePropertyConfig {
@Value("${data.repo.download.path}") @Value("${data.repo.download.path}")
private String repoDownloadPath; private String repoDownloadPath;
@Value("${data.import.prj.path}")
private String importPrjPath;
@Value("${data.import.upload.path}")
private String importUploadPath;
@Value("${data.import.download.path}")
private String importDownloadPath;
@Getter @Getter
@Value("${backup.mysql.script.path}") @Value("${backup.mysql.script.path}")
private String backupMysqlScriptPath; private String backupMysqlScriptPath;
@ -164,6 +173,27 @@ public class ElePropertyConfig {
return prjRootPath + repoDownloadPath; return prjRootPath + repoDownloadPath;
} }
public String getImportPrjPath() {
if (EleCommonUtil.isWinOs()) {
return winPrefix + prjRootPath + importPrjPath;
}
return prjRootPath + importPrjPath;
}
public String getImportUploadPath() {
if (EleCommonUtil.isWinOs()) {
return winPrefix + prjRootPath + importUploadPath;
}
return prjRootPath + importUploadPath;
}
public String getImportDownloadPath() {
if (EleCommonUtil.isWinOs()) {
return winPrefix + prjRootPath + importDownloadPath;
}
return prjRootPath + importDownloadPath;
}
public String getUploadDataDir(int dataOwnCode) { public String getUploadDataDir(int dataOwnCode) {
if (DataOwnEnum.isSysCode(dataOwnCode)) { if (DataOwnEnum.isSysCode(dataOwnCode)) {
return getSysUploadPath(); return getSysUploadPath();
@ -182,4 +212,5 @@ public class ElePropertyConfig {
return getRepoDownloadPath(); return getRepoDownloadPath();
} }
} }

View File

@ -0,0 +1,28 @@
package com.electromagnetic.industry.software.manage.controller;
import com.electromagnetic.industry.software.common.annotations.UserOperation;
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@RestController
public class ImportPrjController {
/**
* 导入本地工程
*
* @param
* @return
*/
@RequestMapping("/importPrj")
@UserOperation(value = "导入本地工程", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
public ElectromagneticResult<?> importPrj(@RequestParam("file") MultipartFile file) {
return null;
}
}

View File

@ -202,16 +202,5 @@ public class SysEdFileInfoController {
return ElectromagneticResultUtil.success(edFileInfoService.findFavorite(userId, fileInfoQueryDTO)); return ElectromagneticResultUtil.success(edFileInfoService.findFavorite(userId, fileInfoQueryDTO));
} }
/**
* 导入本地工程
*
* @param
* @return
*/
@RequestMapping("/importPrj")
@UserOperation(value = "导入本地工程", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
public ElectromagneticResult<?> importPrj(@RequestParam("file") MultipartFile file, @RequestParam(name = "templateCode", defaultValue = "bhdcfzrjzt", required = false) String templateCode) {
return edFileInfoService.importPrj(file, templateCode);
}
} }

View File

@ -0,0 +1,9 @@
package com.electromagnetic.industry.software.manage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.electromagnetic.industry.software.manage.pojo.models.ImportFileInfo;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ImportPrjInfoMapper extends BaseMapper<ImportFileInfo> {
}

View File

@ -0,0 +1,69 @@
package com.electromagnetic.industry.software.manage.pojo.models;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.experimental.FieldNameConstants;
@EqualsAndHashCode(callSuper = true)
@TableName("import_ed_file_info")
@Accessors(chain = true)
@Data
@FieldNameConstants
public class ImportFileInfo extends BaseModel {
/**
* 主键ID
*/
@TableField(value = "id")
private String id;
/**
* 父目录id
*/
@TableField(value = "parent_id")
private String parentId;
/**
* 文件类型
*/
@TableField(value = "file_type")
private String fileType;
/**
* 文件名
*/
@TableField(value = "file_name")
private String fileName;
/**
* 文件内容保留暂时里面为空
*/
@TableField(value = "file_content")
private String fileContent;
/**
* 文件路径指到文件的父目录有各个父目录的id加下划线组成
*/
@TableField(value = "file_path")
private String filePath;
/**
* 数据类型0-文件夹 1-文件
*/
@TableField(value = "data_type")
private Integer dataType;
/**
* 文件大小
*/
@TableField(value = "file_size")
private Long fileSize;
/**
* 文件夹顺序
*/
@TableField(value = "sort")
private Integer sort;
/**
* 当文件被管理员永久物理删除此时为true
*/
@TableField(value = "permanent_deleted")
private Boolean permanentDeleted;
}

View File

@ -2,8 +2,6 @@ package com.electromagnetic.industry.software.manage.pojo.req;
import lombok.Data; import lombok.Data;
import java.util.Map;
@Data @Data
public class AddImportTableDataDTO { public class AddImportTableDataDTO {

View File

@ -2,8 +2,6 @@ package com.electromagnetic.industry.software.manage.pojo.req;
import lombok.Data; import lombok.Data;
import java.util.Map;
@Data @Data
public class UpdateImportTableDataDTO { public class UpdateImportTableDataDTO {
private String id; private String id;

View File

@ -243,9 +243,4 @@ public interface EdFileInfoService {
* @return * @return
*/ */
ElectromagneticResult<?> uploadFileAndRelation(String parentId, String id, MultipartFile file, String desc, int dataOwnCode); ElectromagneticResult<?> uploadFileAndRelation(String parentId, String id, MultipartFile file, String desc, int dataOwnCode);
/**
* 导入工程
*/
ElectromagneticResult<?> importPrj(MultipartFile file, String templateCode);
} }

View File

@ -0,0 +1,9 @@
package com.electromagnetic.industry.software.manage.service;
import org.springframework.web.multipart.MultipartFile;
public interface ImportPrjService {
boolean importPrj(MultipartFile file);
}

View File

@ -124,6 +124,8 @@ public class CommonService {
PATH_MAP.put(DataOwnEnum.USER_FILE.code, elePropertyConfig.getUserPrjPath()); PATH_MAP.put(DataOwnEnum.USER_FILE.code, elePropertyConfig.getUserPrjPath());
PATH_MAP.put(DataOwnEnum.REPO_FILE.code, elePropertyConfig.getRepoPrjPath()); PATH_MAP.put(DataOwnEnum.REPO_FILE.code, elePropertyConfig.getRepoPrjPath());
PATH_MAP.put(DataOwnEnum.REPO_PRJ.code, elePropertyConfig.getRepoPrjPath()); PATH_MAP.put(DataOwnEnum.REPO_PRJ.code, elePropertyConfig.getRepoPrjPath());
PATH_MAP.put(DataOwnEnum.IMPORT_FILE.code, elePropertyConfig.getImportPrjPath());
PATH_MAP.put(DataOwnEnum.IMPORT_PRJ.code, elePropertyConfig.getImportPrjPath());
} }
public String getPrjRootPath1(int dataOwnCode) { public String getPrjRootPath1(int dataOwnCode) {

View File

@ -17,7 +17,6 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
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.FilePermission;
import com.electromagnetic.industry.software.common.enums.*; import com.electromagnetic.industry.software.common.enums.*;
import com.electromagnetic.industry.software.common.exception.BizException; import com.electromagnetic.industry.software.common.exception.BizException;
import com.electromagnetic.industry.software.common.exception.PermissionDeniedException; import com.electromagnetic.industry.software.common.exception.PermissionDeniedException;
@ -53,7 +52,6 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.*; import java.io.*;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.*; import java.util.*;
@ -1526,211 +1524,6 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
} }
@Override
@Transactional(rollbackFor = Exception.class)
public ElectromagneticResult<?> importPrj(MultipartFile file, String templateCode) {
return null;
}
/**
* 导入工程
*
* @param file
*/
// @Override
@Transactional(rollbackFor = Exception.class)
public ElectromagneticResult<?> importPrj1(MultipartFile file, String templateCode) {
try {
// 创建工程
String prjId = updateImportPrj2Db(file);
// 层级沿用先这样写后续根据需求扩展
EdFileInfo prj = this.baseMapper.selectOne(Wrappers.lambdaQuery(EdFileInfo.class)
.eq(EdFileInfo::getTemplateCode, templateCode)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
commonService.follow(prj.getId(), prjId, DataOwnEnum.SYS_PRJ.code);
// 工程发布
commonService.publish(prjId, DataOwnEnum.SYS_PRJ.code);
// 将文件存入到数据库和文件系统
updateImportPrj2FileSystem(file, prjId);
// 添加所有权限
addRoleAndPermission(prjId);
} catch (Exception e) {
String info = "导入失败,原因 " + e.getMessage();
log.error(info, e);
throw new BizException(info, e);
}
return ElectromagneticResultUtil.success(true);
}
private void addRoleAndPermission(String prjId) {
// 首先添加角色这里先假设只有北航角色名称为936c586c88e44df7a262f0ebb4dbe3ab
Role role = roleMapper.selectOne(Wrappers.lambdaQuery(Role.class)
.eq(Role::getEffectFlag, EffectFlagEnum.EFFECT.code)
.eq(Role::getRoleName, "936c586c88e44df7a262f0ebb4dbe3ab"));
if (Objects.isNull(role)) {
role = new Role();
role.newInit();
role.setRoleName("936c586c88e44df7a262f0ebb4dbe3ab");
role.setRoleDesc("针对北航内定的角色");
roleMapper.insert(role);
}
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code)
.likeRight(EdFileInfo::getFilePath, prjId + MYSQL_FILE_PATH_SPLIT));
Set<String> ids = edFileInfos.stream().map(EdFileInfo::getId).collect(Collectors.toSet());
ids.add(prjId);
for (String id : ids) {
for (FilePermission permission : FilePermission.values()) {
RolePermission rolePermission = new RolePermission();
rolePermission.newInit();
rolePermission.setRoleId(role.getId());
rolePermission.setFileId(id);
rolePermission.setPermissionCode(permission.getCode());
rolePermissionService.saveOrUpdate(rolePermission);
}
}
}
private void updateImportPrj2FileSystem(MultipartFile file, String prjId) {
String tmpZipFile = null;
String destDir = null;
try {
String orgName = file.getOriginalFilename();
tmpZipFile = elePropertyConfig.getEleTmpPath() + File.separator + orgName;
String mainName = FileUtil.mainName(orgName);
FileUtil.del(tmpZipFile);
FileUtil.writeFromStream(file.getInputStream(), tmpZipFile);
destDir = elePropertyConfig.getEleTmpPath() + File.separator + IdUtil.fastSimpleUUID();
try {
ZipUtil.unzip(tmpZipFile, destDir, StandardCharsets.UTF_8);
} catch (Exception e) {
ZipUtil.unzip(tmpZipFile, destDir, Charset.forName("GBK"));
}
File file1 = Objects.requireNonNull(new File(destDir).listFiles())[0];
FileUtil.rename(file1, mainName, true);
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
.likeRight(EdFileInfo::getFilePath, prjId + MYSQL_FILE_PATH_SPLIT)
.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code));
Map<String, String> idNameMap = edFileInfos.stream().collect(Collectors.toMap(EdFileInfo::getId, EdFileInfo::getFileName));
idNameMap.put(prjId, mainName);
Map<String, EdFileInfo> filePathMap = new HashMap<>();
for (EdFileInfo edFileInfo : edFileInfos) {
StringBuilder names = new StringBuilder();
for (String id : edFileInfo.getFilePath().split(MYSQL_FILE_PATH_SPLIT)) {
String name = idNameMap.get(id);
names.append(MYSQL_FILE_PATH_SPLIT).append(name);
}
filePathMap.put(names.substring(1), edFileInfo);
}
List<File> files = FileUtil.loopFiles(destDir);
String tmpPath = FileUtil.normalize(destDir);
for (File importFile : files) {
Assert.isTrue(EleCommonUtil.isFileNameValid(importFile.getName()), "文件名称不符合规范");
String parentDir = FileUtil.normalize(importFile.getParent());
String relativeFilePath = parentDir.replace(tmpPath, "");
String fileType = FileUtil.getSuffix(importFile.getName());
relativeFilePath = relativeFilePath.startsWith("/") ? relativeFilePath.substring(1) : relativeFilePath;
relativeFilePath = relativeFilePath.replace("/", MYSQL_FILE_PATH_SPLIT);
EdFileInfo edFileInfo = filePathMap.get(relativeFilePath);
Assert.notNull(edFileInfo, "导入的工程与定义的层级结构不一致");
String id = edFileInfo.getId();
EdFileInfo newEdFileInfo = new EdFileInfo();
newEdFileInfo.newInit();
String fileCode = commonService.createFileCode(id, fileType, FILE_START_VERSION, newEdFileInfo.getFileTime());
newEdFileInfo.setParentId(id)
.setFileCode(fileCode)
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
.setDataOwn(DataOwnEnum.SYS_FILE.code)
.setFileName(FileUtil.mainName(importFile))
.setFileContent(EleCommonUtil.parse(FileUtil.getInputStream(importFile), fileType))
.setFileType(fileType)
.setFileVersion(FILE_START_VERSION)
.setFileSize(importFile.length())
.setFilePath(edFileInfo.getFilePath() + MYSQL_FILE_PATH_SPLIT + newEdFileInfo.getId())
.setDataType(EleDataTypeEnum.FILE.code)
.setDataStatus(PublishEnum.PUBLISHED.getCode())
.setEffectFlag(EffectFlagEnum.EFFECT.code);
this.baseMapper.insert(newEdFileInfo);
String destPath = commonService.getPrjRootPath1(DataOwnEnum.SYS_FILE.code) + File.separator + newEdFileInfo.getId();
FileUtil.move(importFile, new File(destPath), false);
EleCommonUtil.encryptFile(destPath, SecureUtil.aes(FILE_SEC_PASSWD.getBytes()));
UserThreadLocal.setSuccessInfo(newEdFileInfo.getParentId(), newEdFileInfo.getId(), "解析导入的工程文件成功,导入的工程名为 {},文件名为 {}", orgName, importFile.getName());
}
} catch (Exception e) {
String info = "上传失败,原因 " + e.getMessage();
throw new BizException(info, e);
} finally {
FileUtil.del(destDir);
FileUtil.del(tmpZipFile);
}
}
private String updateImportPrj2Db(MultipartFile file) {
String originalFilename = file.getOriginalFilename();
String suffix = FileUtil.getSuffix(originalFilename);
String mainName = FileUtil.mainName(originalFilename);
Assert.isTrue(StrUtil.equals(suffix, "zip"), "不支持 {} 格式的工程文件", suffix);
Assert.isTrue(EleCommonUtil.isFileNameValid(originalFilename), "项目名称不符合规范");
// 检查工程是否存在
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class).eq(EdFileInfo::getFileName, mainName)
.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID));
if (!edFileInfos.isEmpty()) {
// 废除工程及其下面的所有文件
Set<String> ids = edFileInfos.stream().map(EdFileInfo::getId).collect(Collectors.toSet());
for (EdFileInfo edFileInfo : edFileInfos) {
String id = edFileInfo.getId();
List<EdFileInfo> edFileInfos1 = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
.select(EdFileInfo::getId)
.eq(EdFileInfo::getFileId, id)
.likeRight(EdFileInfo::getFilePath, id + MYSQL_FILE_PATH_SPLIT));
ids.addAll(edFileInfos1.stream().map(EdFileInfo::getId).collect(Collectors.toSet()));
}
this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
.in(EdFileInfo::getId, ids));
UserThreadLocal.setSuccessInfo("", "", "导入工程时,发现了同名工程 {}删除了同名工程ids是 {}", mainName, ids);
}
// 保存信息到MySQL
String maxPrjId = this.baseMapper.maxPrjId();
LambdaQueryWrapper<EdFileInfo> qw = Wrappers.lambdaQuery(EdFileInfo.class).eq(EdFileInfo::getParentId, PRJ_PARENT_ID);
Long prjCount = this.baseMapper.selectCount(qw.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code));
int id = Integer.parseInt(StrUtil.isEmpty(maxPrjId) ? "100000" : maxPrjId);
String newPrjId = String.valueOf(id + 1);
EdFileInfo fileInfo = new EdFileInfo();
fileInfo.newInit();
String nowTimeStr = EleCommonUtil.getNowTimeStr();
fileInfo.setId(newPrjId)
.setFileType("文件夹")
.setFileId(newPrjId)
.setFileName(mainName)
.setFileVersion(FILE_START_VERSION)
.setParentId(PRJ_PARENT_ID)
.setFileTime(nowTimeStr)
.setDataType(EleDataTypeEnum.FOLDER.code)
.setDataStatus(EleDataStatusEnum.PUBLISHED.code)
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
.setFilePath(newPrjId)
.setSort(prjCount.intValue() + 1)
.setFileCode(commonService.createFileCode(newPrjId, EleDataTypeEnum.FOLDER.desc, FILE_START_VERSION, nowTimeStr))
.setDataOwn(DataOwnEnum.SYS_PRJ.code)
.setEffectFlag(EffectFlagEnum.EFFECT.code);
this.baseMapper.insert(fileInfo);
UserThreadLocal.setSuccessInfo("", newPrjId, "创建 {} 项目成功。", mainName);
return newPrjId;
}
/** /**
* 统一废除文件相关数据 * 统一废除文件相关数据
* *

View File

@ -0,0 +1,152 @@
package com.electromagnetic.industry.software.manage.service.serviceimpl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.electromagnetic.industry.software.common.cons.ElectromagneticConstants;
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
import com.electromagnetic.industry.software.common.enums.EleDataTypeEnum;
import com.electromagnetic.industry.software.common.exception.BizException;
import com.electromagnetic.industry.software.common.util.EleCommonUtil;
import com.electromagnetic.industry.software.common.util.IdWorker;
import com.electromagnetic.industry.software.manage.config.ElePropertyConfig;
import com.electromagnetic.industry.software.manage.mapper.ImportPrjInfoMapper;
import com.electromagnetic.industry.software.manage.pojo.models.ImportFileInfo;
import com.electromagnetic.industry.software.manage.service.ImportPrjService;
import jakarta.annotation.Resource;
import org.mockito.internal.util.io.IOUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.InputStream;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import static com.electromagnetic.industry.software.common.cons.ElectromagneticConstants.APPEND_NEW_FILE_NAME;
import static com.electromagnetic.industry.software.common.cons.ElectromagneticConstants.FILE_SEC_PASSWD;
@Service
public class ImportPrjServiceImpl extends ServiceImpl<ImportPrjInfoMapper, ImportFileInfo> implements ImportPrjService {
@Resource
private ElePropertyConfig elePropertyConfig;
@Override
@Transactional(rollbackFor = Exception.class)
public boolean importPrj(MultipartFile file) {
String zipTmpPath = elePropertyConfig.getEleTmpPath() + File.pathSeparator + UUID.randomUUID() + ".zip";
ZipFile zipFile = null;
// zipTmpPath = "D:\\tmp\\szsd\\data\\ele.zip";
try {
FileUtil.writeFromStream(file.getInputStream(), zipTmpPath);
Map<String, String> pathIdMap = new HashMap<>();
List<ImportFileInfo> items = new ArrayList<>();
zipFile = EleCommonUtil.getZipFile(zipTmpPath);
Map<String, ImportFileInfo> itemIdMap = new HashMap<>();
Map<String, ZipEntry> entryMap = new HashMap<>();
Enumeration<? extends ZipEntry> entries = zipFile.entries();
// 预处理建立路径映射
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
String entryName = entry.getName();
// 跳过根目录如果存在
if (entryName.isEmpty()) continue;
// 解析路径结构
String[] pathParts = entryName.split("/");
String currentPath = "";
String parentId = ElectromagneticConstants.PRJ_PARENT_ID; // 根目录的parentId为0
for (int i = 0; i < pathParts.length; i++) {
String name = pathParts[i];
if (name.isEmpty()) continue;
currentPath += (i == 0 ? "" : "/") + name;
// 如果是目录且不是最后一个元素
boolean isDirectory = i < pathParts.length - 1 || entry.isDirectory();
if (!pathIdMap.containsKey(currentPath)) {
String newId = IdWorker.getSnowFlakeIdString();
pathIdMap.put(currentPath, newId);
String findIdPath = findIdPath(parentId, itemIdMap);
String filePath = StrUtil.isEmpty(findIdPath) ? newId : findIdPath + ElectromagneticConstants.MYSQL_FILE_PATH_SPLIT + newId;
ImportFileInfo importFileInfo = new ImportFileInfo()
.setId(newId)
.setParentId(parentId)
.setFileType(FileUtil.getSuffix(entryName))
.setFileName(FileUtil.mainName(entryName))
.setFilePath(filePath)
.setFileContent("")
.setDataType(isDirectory ? EleDataTypeEnum.FOLDER.code : EleDataTypeEnum.FILE.code)
.setFileSize(entry.getSize())
.setPermanentDeleted(false);
resetPrjName(importFileInfo);
if (isDirectory) {
importFileInfo.setSort(createFolderSort(parentId, itemIdMap));
} else {
entryMap.put(newId, entry);
}
items.add(importFileInfo);
itemIdMap.put(newId, importFileInfo);
parentId = newId;
} else {
parentId = pathIdMap.get(currentPath);
}
}
}
this.saveBatch(items);
for (Map.Entry<String, ZipEntry> entry : entryMap.entrySet()) {
String newId = entry.getKey();
ZipEntry tmp = entry.getValue();
InputStream inputStream = zipFile.getInputStream(tmp);
String destPath = elePropertyConfig.getEleTmpPath() + File.pathSeparator + newId;
FileUtil.writeFromStream(inputStream, destPath);
EleCommonUtil.decryptFile(destPath, SecureUtil.aes(FILE_SEC_PASSWD.getBytes()));
}
} catch (Exception e) {
throw new BizException("导入工程失败,原因 " + e.getMessage(), e);
} finally {
IOUtil.close(zipFile);
FileUtil.del(zipTmpPath);
}
return true;
}
public void resetPrjName(ImportFileInfo importFileInfo) {
if (!StrUtil.equals(importFileInfo.getParentId(), ElectromagneticConstants.PRJ_PARENT_ID)) {
return;
}
String fileName = importFileInfo.getFileName();
for (int i = 0; i < 1000; ++i) {
long count = this.baseMapper.selectCount(Wrappers.lambdaQuery(ImportFileInfo.class)
.eq(ImportFileInfo::getParentId, ElectromagneticConstants.PRJ_PARENT_ID)
.eq(ImportFileInfo::getFileName, fileName)
.eq(ImportFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
if (count > 0) {
fileName = fileName + APPEND_NEW_FILE_NAME;
} else {
importFileInfo.setFileName(fileName);
return;
}
}
}
private String findIdPath(String parentId, Map<String, ImportFileInfo> itemIdMap) {
List<String> ids = new ArrayList<>();
while (itemIdMap.containsKey(parentId)) {
ImportFileInfo zipItem = itemIdMap.get(parentId);
ids.add(zipItem.getId());
parentId = zipItem.getParentId();
}
CollUtil.reverse(ids);
return CollUtil.join(ids, "_");
}
private Integer createFolderSort(String parentId, Map<String, ImportFileInfo> itemIdMap) {
long count = itemIdMap.values().stream().filter(e -> e.getParentId().equals(parentId) && e.getDataType().equals(EleDataTypeEnum.FOLDER.code)).count();
return Math.toIntExact(++count);
}
}

View File

@ -1 +1,5 @@
function r(o){throw new Error('Could not dynamically require "'+o+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}export{r as c}; function r(o) {
throw new Error('Could not dynamically require "' + o + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')
}
export {r as c};

View File

@ -1 +1,6 @@
const s=(t,r)=>{const o=t.__vccOpts||t;for(const[c,e]of r)o[c]=e;return o};export{s as _}; const s = (t, r) => {
const o = t.__vccOpts || t;
for (const [c, e] of r) o[c] = e;
return o
};
export {s as _};

View File

@ -1 +1,7 @@
.backup-setting-management[data-v-592b576d]{background-color:#fff;padding:16px 24px;display:flex;flex-direction:column;height:100%} .backup-setting-management[data-v-592b576d] {
background-color: #fff;
padding: 16px 24px;
display: flex;
flex-direction: column;
height: 100%
}

View File

@ -1 +1,7 @@
.file-type-management[data-v-4e509c99]{background-color:#fff;padding:16px 24px;display:flex;flex-direction:column;height:100%} .file-type-management[data-v-4e509c99] {
background-color: #fff;
padding: 16px 24px;
display: flex;
flex-direction: column;
height: 100%
}

View File

@ -1 +1,7 @@
.icon[data-v-0273bbfb]{width:1em;height:1em;vertical-align:-.15em;fill:currentColor;overflow:hidden} .icon[data-v-0273bbfb] {
width: 1em;
height: 1em;
vertical-align: -.15em;
fill: currentColor;
overflow: hidden
}

View File

@ -1 +1,3 @@
.round[data-v-52b10b31]{border-radius:18px} .round[data-v-52b10b31] {
border-radius: 18px
}

View File

@ -1 +1,2 @@
const t=""+new URL("not-data-Byd7gMOX.png",import.meta.url).href;export{t as n}; const t = "" + new URL("not-data-Byd7gMOX.png", import.meta.url).href;
export {t as n};

View File

@ -1 +1,8 @@
System.register([],(function(e,t){"use strict";return{execute:function(){e("n",""+new URL("not-data-Byd7gMOX.png",t.meta.url).href)}}})); System.register([], (function (e, t) {
"use strict";
return {
execute: function () {
e("n", "" + new URL("not-data-Byd7gMOX.png", t.meta.url).href)
}
}
}));

View File

@ -1 +1,12 @@
import{t as e,aY as a,cA as r}from"./index-larX9JiI.js";function u(){const t=e(!0);return a(()=>{t.value=!0}),r(()=>{t.value=!1}),t}export{u}; import {aY as a, cA as r, t as e} from "./index-larX9JiI.js";
function u() {
const t = e(!0);
return a(() => {
t.value = !0
}), r(() => {
t.value = !1
}), t
}
export {u};

View File

@ -1 +1,9 @@
import{aC as a,v as o,eH as t}from"./index-larX9JiI.js";const l=()=>{const e=a(!1);return o(()=>{e.value=t()}),e};export{l as u}; import {aC as a, eH as t, v as o} from "./index-larX9JiI.js";
const l = () => {
const e = a(!1);
return o(() => {
e.value = t()
}), e
};
export {l as u};

View File

@ -95,7 +95,7 @@ self.addEventListener('message', async function (event) {
}) })
self.addEventListener('fetch', function (event) { self.addEventListener('fetch', function (event) {
const { request } = event const {request} = event
// Bypass navigation requests. // Bypass navigation requests.
if (request.mode === 'navigate') { if (request.mode === 'navigate') {
@ -185,7 +185,7 @@ async function resolveMainClient(event) {
} }
async function getResponse(event, client, requestId) { async function getResponse(event, client, requestId) {
const { request } = event const {request} = event
// Clone the request because it might've been already used // Clone the request because it might've been already used
// (i.e. its body has been read and sent to the client). // (i.e. its body has been read and sent to the client).
@ -199,7 +199,7 @@ async function getResponse(event, client, requestId) {
// Some servers forbid unknown request headers. // Some servers forbid unknown request headers.
delete headers['x-msw-intention'] delete headers['x-msw-intention']
return fetch(requestClone, { headers }) return fetch(requestClone, {headers})
} }
// Bypass mocking when the client is not active. // Bypass mocking when the client is not active.

View File

@ -1,10 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Created with Vectornator (http://vectornator.io/) --> <!-- Created with Vectornator (http://vectornator.io/) -->
<svg height="100%" stroke-miterlimit="10" style="fill-rule:nonzero;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;" version="1.1" viewBox="31 31 450 450" width="100%" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <svg height="100%" stroke-miterlimit="10"
style="fill-rule:nonzero;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;" version="1.1"
viewBox="31 31 450 450" width="100%" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
>
<defs/> <defs/>
<g id="图层-1"> <g id="图层-1">
<path d="M71.7162 480.951C245.442 476.178 386.182 360.591 424.806 237.032C433.072 210.6 428.265 188.187 407.178 174.42C397.044 167.804 393.006 171.672 385.839 175.233C380.422 177.925 373.922 182.241 379.097 187.137C382.615 190.465 380.668 194.9 379.363 197.573C375.125 206.224 355.105 205.326 334.648 195.56C314.192 185.793 301.05 170.855 305.297 162.204C308.269 156.139 318.139 154.402 332.173 157.868C339.807 159.753 341.653 156.992 343.845 153.691C347.933 147.536 345.196 145.675 341.891 144.204C333.356 140.404 321.576 138.261 309.985 137.735C145.144 133.229 267.528 285.847 51.8973 427.303C33.8726 436.816 7.71038 482.711 71.7162 480.951Z" fill="#f0322d" fill-rule="nonzero" opacity="1" stroke="none"/> <path d="M71.7162 480.951C245.442 476.178 386.182 360.591 424.806 237.032C433.072 210.6 428.265 188.187 407.178 174.42C397.044 167.804 393.006 171.672 385.839 175.233C380.422 177.925 373.922 182.241 379.097 187.137C382.615 190.465 380.668 194.9 379.363 197.573C375.125 206.224 355.105 205.326 334.648 195.56C314.192 185.793 301.05 170.855 305.297 162.204C308.269 156.139 318.139 154.402 332.173 157.868C339.807 159.753 341.653 156.992 343.845 153.691C347.933 147.536 345.196 145.675 341.891 144.204C333.356 140.404 321.576 138.261 309.985 137.735C145.144 133.229 267.528 285.847 51.8973 427.303C33.8726 436.816 7.71038 482.711 71.7162 480.951Z"
<path d="M356.231 185.86C360.69 183.864 365.088 181.629 369.434 179.183C376.947 174.899 384.181 170.153 391.092 164.973C433.422 133.468 465.071 92.5206 477.548 73.7696C481.013 68.5621 482.62 57.4866 478.761 52.105C469.108 38.6429 449.136 31.9566 431.287 31.081C423.477 30.6979 415.771 31.6629 408.83 34.2076C405.923 35.2737 400.017 38.9675 398.218 50.6922C391.564 94.0823 368.434 127.479 353.408 149.769C349.45 155.652 345.898 160.541 342.996 164.35C341.599 166.185 338.313 170.011 335.256 172.935C332.41 175.658 332.712 180.687 336.496 183.727C341.343 187.62 351.538 187.958 356.231 185.86Z" fill="#6ec83c" fill-rule="nonzero" opacity="1" stroke="none"/> fill="#f0322d" fill-rule="nonzero" opacity="1" stroke="none"/>
<path d="M356.231 185.86C360.69 183.864 365.088 181.629 369.434 179.183C376.947 174.899 384.181 170.153 391.092 164.973C433.422 133.468 465.071 92.5206 477.548 73.7696C481.013 68.5621 482.62 57.4866 478.761 52.105C469.108 38.6429 449.136 31.9566 431.287 31.081C423.477 30.6979 415.771 31.6629 408.83 34.2076C405.923 35.2737 400.017 38.9675 398.218 50.6922C391.564 94.0823 368.434 127.479 353.408 149.769C349.45 155.652 345.898 160.541 342.996 164.35C341.599 166.185 338.313 170.011 335.256 172.935C332.41 175.658 332.712 180.687 336.496 183.727C341.343 187.62 351.538 187.958 356.231 185.86Z"
fill="#6ec83c" fill-rule="nonzero" opacity="1" stroke="none"/>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -1,18 +1,18 @@
<!doctype html> <!doctype html>
<html lang="zh-cn"> <html lang="zh-cn">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1" /> <meta content="width=device-width,initial-scale=1" name="viewport"/>
<title>chili3d</title> <title>chili3d</title>
<link rel="icon" href="favicon.svg" /> <link href="favicon.svg" rel="icon"/>
<link rel="stylesheet" href="index.css" /> <link href="index.css" rel="stylesheet"/>
</head> </head>
<body> <body>
<noscript>You need to enable JavaScript to run this app.</noscript> <noscript>You need to enable JavaScript to run this app.</noscript>
<script src="./iconfont.js"></script> <script src="./iconfont.js"></script>
<script defer src="main.js"></script> <script defer src="main.js"></script>
<script> <script>
function jsonToBlob(json) { function jsonToBlob(json) {
var textEncoder = new TextEncoder() var textEncoder = new TextEncoder()
var seen = new WeakSet() var seen = new WeakSet()
@ -92,6 +92,7 @@
return new Blob([buffer.subarray(0, position)]) return new Blob([buffer.subarray(0, position)])
} }
function getFileFromUrl(url, fileName) { function getFileFromUrl(url, fileName) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var blob = null var blob = null
@ -102,7 +103,7 @@
xhr.onload = () => { xhr.onload = () => {
// 获取返回结果 // 获取返回结果
blob = xhr.response blob = xhr.response
var file = new File([blob], fileName, { type: blob.type }) var file = new File([blob], fileName, {type: blob.type})
// 返回结果 // 返回结果
resolve(file) resolve(file)
} }
@ -146,23 +147,26 @@
} }
function createURLFromString(text) { function createURLFromString(text) {
var blob = new Blob([text], { type: 'text/plain' }) var blob = new Blob([text], {type: 'text/plain'})
return URL.createObjectURL(blob) return URL.createObjectURL(blob)
} }
function createURLFromJson(json) { function createURLFromJson(json) {
var blob var blob
try { try {
var text = JSON.stringify(json) var text = JSON.stringify(json)
var blob = new Blob([text], { type: 'text/plain' }) var blob = new Blob([text], {type: 'text/plain'})
} catch (e) { } catch (e) {
blob = jsonToBlob(json) blob = jsonToBlob(json)
} }
return URL.createObjectURL(blob) return URL.createObjectURL(blob)
} }
function createURLFromArrayBuffer(arrayBuffer) { function createURLFromArrayBuffer(arrayBuffer) {
var blob = new Blob([arrayBuffer], { type: 'text/plain' }) var blob = new Blob([arrayBuffer], {type: 'text/plain'})
return URL.createObjectURL(blob) return URL.createObjectURL(blob)
} }
function lineSegments2ToLine(line) { function lineSegments2ToLine(line) {
// 创建一个常规的 LineSegments 对象 // 创建一个常规的 LineSegments 对象
var tempLine = new window.THREE.LineSegments( var tempLine = new window.THREE.LineSegments(
@ -182,6 +186,7 @@
return tempLine return tempLine
} }
Promise.all([ Promise.all([
new Promise(resolve => { new Promise(resolve => {
window.onload = function () { window.onload = function () {
@ -199,14 +204,14 @@
new Promise(resolve => { new Promise(resolve => {
window.addEventListener( window.addEventListener(
'message', 'message',
({ data }) => { ({data}) => {
resolve(data) resolve(data)
}, },
false, false,
) )
}), }),
]) ])
.then(([myDocument, { url: modelURL, filename }]) => { .then(([myDocument, {url: modelURL, filename}]) => {
return getFileFromUrl( return getFileFromUrl(
modelURL, modelURL,
filename || modelURL.split('/').pop(), filename || modelURL.split('/').pop(),
@ -244,7 +249,7 @@
var json = group.toJSON() var json = group.toJSON()
// var url = createURLFromString(JSON.stringify(json, null, 2)) // var url = createURLFromString(JSON.stringify(json, null, 2))
var url = createURLFromJson(json) var url = createURLFromJson(json)
window.parent.postMessage({ gltf: url }) window.parent.postMessage({gltf: url})
// return exportGLTF( // return exportGLTF(
// myDocument.visual.scene.children.filter( // myDocument.visual.scene.children.filter(
// object => !object.isLight && object.type !== 'AxesHelper', // object => !object.isLight && object.type !== 'AxesHelper',
@ -271,8 +276,8 @@
}) })
.catch(e => { .catch(e => {
console.log(e) console.log(e)
window.parent.postMessage({ error: e.message || e }) window.parent.postMessage({error: e.message || e})
}) })
</script> </script>
</body> </body>
</html> </html>

View File

@ -1,5 +1,24 @@
<!doctype html><html lang="zh-cn"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="description" content="chili3d"><meta name="author" content="仙阁"><title>chili3d</title><link rel="icon" href="favicon.svg"><link rel="stylesheet" href="index.css"><script>!function(t,e,n,c,r,a,i){t[n]=t[n]||function(){(t[n].q=t[n].q||[]).push(arguments)},(a=e.createElement(c)).async=1,a.src="https://www.clarity.ms/tag/"+r,(i=e.getElementsByTagName(c)[0]).parentNode.insertBefore(a,i)}(window,document,"clarity","script","k1qrtibhcl")</script></head><body><noscript>You need to enable JavaScript to run this app.</noscript> <!doctype html>
<script src="./iconfont.js"></script> <html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta content="width=device-width,initial-scale=1" name="viewport">
<meta content="chili3d" name="description">
<meta content="仙阁" name="author">
<title>chili3d</title>
<link href="favicon.svg" rel="icon">
<link href="index.css" rel="stylesheet">
<script>!function (t, e, n, c, r, a, i) {
t[n] = t[n] || function () {
(t[n].q = t[n].q || []).push(arguments)
}, (a = e.createElement(c)).async = 1, a.src = "https://www.clarity.ms/tag/" + r, (i = e.getElementsByTagName(c)[0]).parentNode.insertBefore(a, i)
}(window, document, "clarity", "script", "k1qrtibhcl")</script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<script src="./iconfont.js"></script>
<script defer src="main.js"></script></body></html> <script defer src="main.js"></script>
</body>
</html>

View File

@ -1,19 +1,42 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8"/>
<link rel="icon" href="./favicon.ico" /> <link href="./favicon.ico" rel="icon"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title>商飞数据库后台管理系统</title> <title>商飞数据库后台管理系统</title>
<script type="module" crossorigin src="./assets/index-larX9JiI.js"></script> <script crossorigin src="./assets/index-larX9JiI.js" type="module"></script>
<link rel="stylesheet" crossorigin href="./assets/index-DVJlCBDm.css"> <link crossorigin href="./assets/index-DVJlCBDm.css" rel="stylesheet">
<script type="module">import.meta.url;import("_").catch(()=>1);(async function*(){})().next();if(location.protocol!="file:"){window.__vite_is_modern_browser=true}</script> <script type="module">import.meta.url;
<script type="module">!function(){if(window.__vite_is_modern_browser)return;console.warn("vite: loading legacy chunks, syntax error above and the same error below should be ignored");var e=document.getElementById("vite-legacy-polyfill"),n=document.createElement("script");n.src=e.src,n.onload=function(){System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))},document.body.appendChild(n)}();</script> import("_").catch(() => 1);
</head> (async function* () {
<body> })().next();
<div id="app"></div> if (location.protocol != "file:") {
<script nomodule>!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",(function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()}),!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script> window.__vite_is_modern_browser = true
<script nomodule crossorigin id="vite-legacy-polyfill" src="./assets/polyfills-legacy-vTdn31Iz.js"></script> }</script>
<script nomodule crossorigin id="vite-legacy-entry" data-src="./assets/index-legacy-D6gbX9g9.js">System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))</script> <script type="module">!function () {
</body> if (window.__vite_is_modern_browser) return;
console.warn("vite: loading legacy chunks, syntax error above and the same error below should be ignored");
var e = document.getElementById("vite-legacy-polyfill"), n = document.createElement("script");
n.src = e.src, n.onload = function () {
System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))
}, document.body.appendChild(n)
}();</script>
</head>
<body>
<div id="app"></div>
<script nomodule>!function () {
var e = document, t = e.createElement("script");
if (!("noModule" in t) && "onbeforeload" in t) {
var n = !1;
e.addEventListener("beforeload", (function (e) {
if (e.target === t) n = !0; else if (!e.target.hasAttribute("nomodule") || !n) return;
e.preventDefault()
}), !0), t.type = "module", t.src = ".", e.head.appendChild(t), t.remove()
}
}();</script>
<script crossorigin id="vite-legacy-polyfill" nomodule src="./assets/polyfills-legacy-vTdn31Iz.js"></script>
<script crossorigin data-src="./assets/index-legacy-D6gbX9g9.js" id="vite-legacy-entry"
nomodule>System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))</script>
</body>
</html> </html>

View File

@ -1,311 +0,0 @@
//import cn.hutool.json.JSONUtil;
//import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
//import com.electromagnetic.industry.software.manage.Application;
//import com.electromagnetic.industry.software.manage.service.ImportTableService;
//import jakarta.annotation.Resource;
//import org.junit.jupiter.api.Test;
//import org.springframework.boot.test.context.SpringBootTest;
//
//import java.util.LinkedHashMap;
//import java.util.Map;
//
//@SpringBootTest(classes = Application.class)
//public class ImportTableTest {
//
// @Resource
// private ImportTableService importTableService;
//
// @Test
// public void test1() {
//
//// int[] ids1 = {100423, 100431, 100432, 100433, 100434, 100435};
//// int[] ids2 = {100424, 100436, 100437, 100438, 100439, 100440};
//// int[] ids3 = {100425, 100441, 100442, 100443, 100444, 100445};
////
//// Map<Integer, Object> map1 = new LinkedHashMap<>();
//// map1.put(1, "起始频率");
//// map1.put(2, "终止频率");
//// map1.put(3, "M等级");
//// map1.put(4, "O等级");
//// map1.put(5, "R等级");
//// map1.put(6, "S等级");
//// map1.put(7, "T等级");
//// map1.put(8, "W等级");
//// map1.put(9, "Y等级");
//// map1.put(10, "版本号");
////
//// Map<Integer, Object> map2 = new LinkedHashMap<>();
//// map2.put(1, "起始频率");
//// map2.put(2, "终止频率");
//// map2.put(3, "B等级");
//// map2.put(4, "D等级");
//// map2.put(5, "F等级");
//// map2.put(6, "G等级");
//// map2.put(7, "L等级");
//// map2.put(8, "R等级");
//// map2.put(9, "S等级");
//// map2.put(10, "T等级");
//// map2.put(11, "W等级");
//// map2.put(12, "Y等级");
//// map2.put(13, "版本号");
////
//// Map<Integer, Object> map3 = new LinkedHashMap<>();
//// map3.put(1, "起始频率");
//// map3.put(2, "终止频率");
//// map3.put(3, "B等级");
//// map3.put(4, "F等级");
//// map3.put(5, "S等级");
//// map3.put(6, "G等级");
//// map3.put(7, "L等级");
//// map3.put(8, "R等级");
//// map3.put(9, "版本号");
////
//// for (Integer id : ids1) {
//// importTableService.addTableInfo(id + "", map1);
//// }
////
//// for (Integer id : ids2) {
//// importTableService.addTableInfo(id + "", map2);
//// }
////
//// for (Integer id : ids3) {
//// importTableService.addTableInfo(id + "", map3);
//// }
//
// }
//
// @Test
// public void test2() {
// String[] arr1 = {"1932333966414524416", "1932333966867509248","1932333966922035200","1932333966993338368","1932333967026892800","1932333967060447232"};
// Map<Integer, Object> map1 = new LinkedHashMap<>();
// map1.put(1, 0.01);
// map1.put(2, 0.5);
// map1.put(3, 0.6);
// map1.put(4, 3);
// map1.put(5, 0.6);
// map1.put(6, 0.03);
// map1.put(7, 0.15);
// map1.put(8, 3);
// map1.put(9, 6);
// map1.put(10, 1);
//
// Map<Integer, Object> map2 = new LinkedHashMap<>();
// map2.put(1, 0.5);
// map2.put(2, 1);
// map2.put(3, 30);
// map2.put(4, 150);
// map2.put(5, 30);
// map2.put(6, 1.5);
// map2.put(7, 7.5);
// map2.put(8, 150);
// map2.put(9, 300);
// map2.put(10, 1);
//
// Map<Integer, Object> map3 = new LinkedHashMap<>();
// map3.put(1, 1);
// map3.put(2, 30);
// map3.put(3, 70);
// map3.put(4, 250);
// map3.put(5, 30);
// map3.put(6, 1.5);
// map3.put(7, 7.5);
// map3.put(8, 150);
// map3.put(9, 300);
// map3.put(10, 1);
//
// Map<Integer, Object> map4 = new LinkedHashMap<>();
// map4.put(1, 30);
// map4.put(2, 40);
// map4.put(3, 70);
// map4.put(4, 250);
// map4.put(5, 30);
// map4.put(6, 1.5);
// map4.put(7, 7.5);
// map4.put(8, 150);
// map4.put(9, 300);
// map4.put(10, 1);
//
// Map<Integer, Object> map5 = new LinkedHashMap<>();
// map5.put(1, 40);
// map5.put(2, 100);
// map5.put(3, 32);
// map5.put(4, 50);
// map5.put(5, 30);
// map5.put(6, 1.5);
// map5.put(7, 7.55);
// map5.put(8, 150);
// map5.put(9, 300);
// map5.put(10, 1);
//
// for (String id : arr1) {
// importTableService.addTableData(id, map1);
// importTableService.addTableData(id, map2);
// importTableService.addTableData(id, map3);
// importTableService.addTableData(id, map4);
// importTableService.addTableData(id, map5);
// }
//
// }
//
// @Test
// public void test3() {
// String[] arr1 = {"1932333967098195968", "1932333967177887744", "1932333967236608000", "1932333967274356736", "1932333967307911168", "1932333967341465600"};
//
// Map<Integer, Object> map1 = new LinkedHashMap<>();
// map1.put(1, 100);
// map1.put(2, 200);
// map1.put(3, 20);
// map1.put(4, 25);
// map1.put(5, 50);
// map1.put(6, 100);
// map1.put(7, 200);
// map1.put(8, 20);
// map1.put(9, 1);
// map1.put(10, 5);
// map1.put(11, 100);
// map1.put(12, 200);
// map1.put(13, 1);
//
// Map<Integer, Object> map2 = new LinkedHashMap<>();
// map2.put(1, 200);
// map2.put(2, 400);
// map2.put(3, 20);
// map2.put(4, 25);
// map2.put(5, 50);
// map2.put(6, 100);
// map2.put(7, 200);
// map2.put(8, 20);
// map2.put(9, 1);
// map2.put(10, 5);
// map2.put(11, 100);
// map2.put(12, 200);
// map2.put(13, 1);
//
// Map<Integer, Object> map3 = new LinkedHashMap<>();
// map3.put(1, 400);
// map3.put(2, 700);
// map3.put(3, 20);
// map3.put(4, 20);
// map3.put(5, 25);
// map3.put(6, 50);
// map3.put(7, 200);
// map3.put(8, 20);
// map3.put(9, 1);
// map3.put(10, 5);
// map3.put(11, 100);
// map3.put(12, 200);
// map3.put(13, 1);
//
// Map<Integer, Object> map4 = new LinkedHashMap<>();
// map4.put(1, 700);
// map4.put(2, 1000);
// map4.put(3, 20);
// map4.put(4, 25);
// map4.put(5, 50);
// map4.put(6, 100);
// map4.put(7, 240);
// map4.put(8, 20);
// map4.put(9, 1);
// map4.put(10, 5);
// map4.put(11, 100);
// map4.put(12, 200);
// map4.put(13, 1);
//
// Map<Integer, Object> map5 = new LinkedHashMap<>();
// map5.put(1, 100);
// map5.put(2, 2000);
// map5.put(3, 25);
// map5.put(4, 50);
// map5.put(5, 100);
// map5.put(6, 200);
// map5.put(7, 250);
// map5.put(8, 20);
// map5.put(9, 1);
// map5.put(10, 5);
// map5.put(11, 100);
// map5.put(12, 200);
// map5.put(13, 1);
//
// for (String id : arr1) {
// importTableService.addTableData(id, map1);
// importTableService.addTableData(id, map2);
// importTableService.addTableData(id, map3);
// importTableService.addTableData(id, map4);
// importTableService.addTableData(id, map5);
// }
// }
//
// @Test
// public void test4() {
// String[] arr1 = {"1932333967379214336", "1932333967412768768", "1932333967492460544", "1932333967555375104", "1932333967593123840", "1932333967626678272"};
//
// Map<Integer, Object> map1 = new LinkedHashMap<>();
// map1.put(1, 400);
// map1.put(2, 700);
// map1.put(3, 150);
// map1.put(4, 175);
// map1.put(5, 350);
// map1.put(6, 700);
// map1.put(7, 730);
// map1.put(8, 150);
// map1.put(9, 1);
//
// Map<Integer, Object> map2 = new LinkedHashMap<>();
// map2.put(1, 700);
// map2.put(2, 1000);
// map2.put(3, 150);
// map2.put(4, 175);
// map2.put(5, 350);
// map2.put(6, 700);
// map2.put(7, 1400);
// map2.put(8, 150);
// map2.put(9, 1);
//
// Map<Integer, Object> map3 = new LinkedHashMap<>();
// map3.put(1, 1000);
// map3.put(2, 2000);
// map3.put(3, 250);
// map3.put(4, 500);
// map3.put(5, 1000);
// map3.put(6, 2000);
// map3.put(7, 5000);
// map3.put(8, 150);
// map3.put(9, 1);
//
// Map<Integer, Object> map4 = new LinkedHashMap<>();
// map4.put(1, 2000);
// map4.put(2, 4000);
// map4.put(3, 375);
// map4.put(4, 750);
// map4.put(5, 1500);
// map4.put(6, 3000);
// map4.put(7, 6000);
// map4.put(8, 150);
// map4.put(9, 1);
//
// Map<Integer, Object> map5 = new LinkedHashMap<>();
// map5.put(1, 4000);
// map5.put(2, 6000);
// map5.put(3, 375);
// map5.put(4, 750);
// map5.put(5, 1500);
// map5.put(6, 3000);
// map5.put(7, 7200);
// map5.put(8, 150);
// map5.put(9, 1);
//
// for (String id : arr1) {
// importTableService.addTableData(id, map1);
// importTableService.addTableData(id, map2);
// importTableService.addTableData(id, map3);
// importTableService.addTableData(id, map4);
// importTableService.addTableData(id, map5);
// }
// }
//
// @Test
// public void test5() {
// ElectromagneticResult<?> electromagneticResult = importTableService.selectTableDataByTableInfoId(1, 10, "1932333966867509248");
// System.out.println(JSONUtil.toJsonStr(electromagneticResult));
// }
//}

View File

@ -0,0 +1,35 @@
import com.electromagnetic.industry.software.common.cons.UserConstants;
import com.electromagnetic.industry.software.common.pojo.UserLoginInfo;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
import com.electromagnetic.industry.software.manage.Application;
import com.electromagnetic.industry.software.manage.config.ElePropertyConfig;
import com.electromagnetic.industry.software.manage.service.ImportPrjService;
import com.electromagnetic.industry.software.manage.service.ImportTableService;
import jakarta.annotation.Resource;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest(classes = Application.class)
public class ImportTableTest {
@Resource
private ImportTableService importTableService;
@Resource
private ImportPrjService importPrjService;
@Resource
private ElePropertyConfig elePropertyConfig;
public void testImportPrj() {
UserLoginInfo userLoginInfo = new UserLoginInfo();
userLoginInfo.setUserId("1916756770835075072");
userLoginInfo.setUsername("北航电磁仿真用户1");
userLoginInfo.setWorkNumber("");
userLoginInfo.setAdminType("");
userLoginInfo.setPrjTmpDir(elePropertyConfig.getEleTmpPath());
UserThreadLocal.set(userLoginInfo);
importPrjService.importPrj(null);
}
}

View File

@ -11,10 +11,12 @@ public enum DataOwnEnum {
SYS_PRJ(1, "项目数据层级", "项目数据"), SYS_PRJ(1, "项目数据层级", "项目数据"),
USER_PRJ(2, "个人数据层级", "个人数据"), USER_PRJ(2, "个人数据层级", "个人数据"),
REPO_PRJ(5, "库数据层级", "库数据"), REPO_PRJ(5, "库数据层级", "库数据"),
IMPORT_PRJ(6, "用户导入层级", "导入工程数据"),
SYS_FILE(0, "项目数据文件(文件夹)", "项目数据"), SYS_FILE(0, "项目数据文件(文件夹)", "项目数据"),
USER_FILE(4, "个人数据文件(文件夹)", "个人数据"), USER_FILE(4, "个人数据文件(文件夹)", "个人数据"),
REPO_FILE(3, "库数据文件(文件夹)", "库数据"); REPO_FILE(3, "库数据文件(文件夹)", "库数据"),
IMPORT_FILE(7, "用户导入工程", "导入工程数据");
private static final Map<Integer, Integer> FILE_PRJ_MAP = new HashMap<>(); private static final Map<Integer, Integer> FILE_PRJ_MAP = new HashMap<>();
private static final Map<Integer, DataOwnEnum> CODE_ENUM = new HashMap<>(); private static final Map<Integer, DataOwnEnum> CODE_ENUM = new HashMap<>();

View File

@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.charset.Charset;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -17,6 +18,7 @@ import java.time.format.DateTimeFormatter;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.zip.ZipFile;
@Slf4j @Slf4j
public final class EleCommonUtil { public final class EleCommonUtil {
@ -138,4 +140,17 @@ public final class EleCommonUtil {
return match ? t1 : t2; return match ? t1 : t2;
} }
public static ZipFile getZipFile(String zipFilePath) {
try {
return new ZipFile(zipFilePath);
} catch (Exception e) {
try {
return new ZipFile(zipFilePath, Charset.forName("GBK"));
} catch (Exception e1) {
return null;
}
}
}
} }