|
@@ -8,10 +8,13 @@ import com.fd.constant.MsgCode;
|
|
|
import com.fd.constant.TypeCode;
|
|
|
import com.fd.dto.ConfigJsonDto;
|
|
|
import com.fd.dto.PageDto;
|
|
|
+import com.fd.dto.StyleDto;
|
|
|
import com.fd.entity.FileEntity;
|
|
|
import com.fd.entity.OutputFileEntity;
|
|
|
+import com.fd.entity.StyleEntity;
|
|
|
import com.fd.repository.FileRepository;
|
|
|
import com.fd.repository.OutputFileRepository;
|
|
|
+import com.fd.repository.StyleRepository;
|
|
|
import com.fd.server.CmdServer;
|
|
|
import com.fd.server.VectorServer;
|
|
|
import com.fd.util.FileUtils;
|
|
@@ -19,6 +22,7 @@ import com.fd.util.R;
|
|
|
import com.fd.util.RegexUtils;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.domain.Page;
|
|
@@ -65,6 +69,8 @@ public class VectorServerImpl implements VectorServer {
|
|
|
@Autowired
|
|
|
private CmdServer cmdServer;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private StyleRepository styleRepository;
|
|
|
|
|
|
@Override
|
|
|
public R moveFileToServer(Long fileId, ConfigJsonDto param) {
|
|
@@ -159,48 +165,6 @@ public class VectorServerImpl implements VectorServer {
|
|
|
FileUtils.delFolder(path);
|
|
|
}
|
|
|
|
|
|
-// @Override
|
|
|
-// public R uploadFile(MultipartFile file, String coord) {
|
|
|
-// log.warn("run uploadFile");
|
|
|
-// if (file.isEmpty() || file.getSize() <= 0) {
|
|
|
-// log.info("文件为空");
|
|
|
-// return new R(50001, MsgCode.E50001);
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 文件名全名
|
|
|
-// String fullFileName = file.getOriginalFilename();
|
|
|
-//
|
|
|
-//// // 拼接唯一文件名
|
|
|
-//// String fileName = FileUtils.dateStr() + fullFileName;
|
|
|
-//// String filePath = INPUT_FILE_PATH + fileName;
|
|
|
-//
|
|
|
-// // 文件保存路径
|
|
|
-// String filePath = INPUT_FILE_PATH + fullFileName;
|
|
|
-// log.info("filePath: {}", filePath);
|
|
|
-//
|
|
|
-// // 写文件到本地
|
|
|
-// try {
|
|
|
-// byte[] bytes = file.getBytes();
|
|
|
-// String content = Base64.getEncoder().encodeToString(bytes);
|
|
|
-// FileUtils.base64ToFileWriter(content, filePath);
|
|
|
-// } catch (IOException e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 保存信息到db
|
|
|
-// FileEntity entity = new FileEntity();
|
|
|
-// entity.setFileName(fullFileName);
|
|
|
-// entity.setFileUrl(filePath);
|
|
|
-// entity.setCreateTime(new Date());
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
-// entity.setType(TypeCode.FILE_TYPE_VECTOR);
|
|
|
-// entity.setCoord(coord);
|
|
|
-// entity.setStatus(1);
|
|
|
-// fileRepository.save(entity);
|
|
|
-//
|
|
|
-// log.info("end uploadFile");
|
|
|
-// return new R(200, entity);
|
|
|
-// }
|
|
|
|
|
|
@Override
|
|
|
public R uploadDirectoryFile(MultipartFile file, String directoryName, String coord) {
|
|
@@ -365,6 +329,21 @@ public class VectorServerImpl implements VectorServer {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public R saveStyle(StyleDto entity) {
|
|
|
+ StyleEntity styleEntity = new StyleEntity();
|
|
|
+ BeanUtils.copyProperties(entity, styleEntity);
|
|
|
+ styleEntity.setCreateTime(new Date());
|
|
|
+ styleEntity.setUpdateTime(new Date());
|
|
|
+ StyleEntity save = styleRepository.save(styleEntity);
|
|
|
+ return new R(200, save.getOutputFileId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R getStyle(Long id) {
|
|
|
+ return new R(200, styleRepository.findByOutputFileIdTop(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public OutputFileEntity findById(Long fileId) {
|
|
|
Optional<OutputFileEntity> o = outputFileRepository.findById(fileId);
|
|
|
if (o.isPresent()) {
|