|
|
@@ -1,19 +1,18 @@
|
|
|
-package com.example.services;
|
|
|
+package cn.seecoder.ai.service;
|
|
|
|
|
|
-import com.example.analysis.FileAnalysis;
|
|
|
-import com.example.dao.*;
|
|
|
-import com.example.data.CsvAdapter;
|
|
|
-import com.example.data.CsvLoader;
|
|
|
-import com.example.data.SasLoader;
|
|
|
-import com.example.entity.Config;
|
|
|
-import com.example.entity.FileInfo;
|
|
|
-import com.example.entity.HeaderInfo;
|
|
|
-import com.example.entity.Model;
|
|
|
-import com.example.services.pojo.*;
|
|
|
-import com.example.util.FileHelper;
|
|
|
-import com.example.util.Json2Object;
|
|
|
+import cn.seecoder.ai.analysis.FileAnalysis;
|
|
|
+import cn.seecoder.ai.dao.*;
|
|
|
+import cn.seecoder.ai.data.CsvAdapter;
|
|
|
+import cn.seecoder.ai.util.CsvLoader;
|
|
|
+import cn.seecoder.ai.util.SasLoader;
|
|
|
+import cn.seecoder.ai.dao.entity.Config;
|
|
|
+import cn.seecoder.ai.dao.entity.FileInfo;
|
|
|
+import cn.seecoder.ai.dao.entity.HeaderInfo;
|
|
|
+import cn.seecoder.ai.dao.entity.Model;
|
|
|
+import cn.seecoder.ai.model.bo.*;
|
|
|
+import cn.seecoder.ai.util.FileHelper;
|
|
|
+import cn.seecoder.ai.util.Json2Object;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import lombok.val;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
@@ -38,19 +37,19 @@ public class FileService {
|
|
|
@Autowired
|
|
|
private CsvAdapter csvAdapter;
|
|
|
@Autowired
|
|
|
- private HdfsDao hdfsDao;
|
|
|
+ private HdfsDAO hdfsDao;
|
|
|
@Autowired
|
|
|
- private FileInfoDao fileInfoDao;
|
|
|
+ private FileInfoDAO fileInfoDao;
|
|
|
@Autowired
|
|
|
- private ConfigDao configDao;
|
|
|
+ private ConfigDAO configDao;
|
|
|
@Autowired
|
|
|
- private HeaderInfoDao headerInfoDao;
|
|
|
+ private HeaderInfoDAO headerInfoDao;
|
|
|
@Autowired
|
|
|
private FileAnalysis fileAnalysis;
|
|
|
@Autowired
|
|
|
- private ModelDao modelDao;
|
|
|
+ private ModelDAO modelDao;
|
|
|
@Autowired
|
|
|
- private FuncInfoDao funcInfoDao;
|
|
|
+ private FuncInfoDAO funcInfoDao;
|
|
|
|
|
|
/**
|
|
|
* @param userId
|
|
|
@@ -85,13 +84,13 @@ public class FileService {
|
|
|
hdfsDao.deleteFileInHdfs(fileLoc, true);
|
|
|
}
|
|
|
|
|
|
- public TestFileValuePojo uploadTestFile(int userId, MultipartFile inFile, String filename) throws Exception {
|
|
|
+ public TestFileValueBO uploadTestFile(int userId, MultipartFile inFile, String filename) throws Exception {
|
|
|
int fileId = uploadFile(userId, inFile, filename);
|
|
|
String fileLoc = fileInfoDao.findById(fileId).getLocation();
|
|
|
List<Map<String, String>> values = csvAdapter.parquetFileReader(fileLoc);
|
|
|
log.error("Test File values: ", values);
|
|
|
//deleteFile(fileId);
|
|
|
- return new TestFileValuePojo(String.valueOf(fileId), values);
|
|
|
+ return new TestFileValueBO(String.valueOf(fileId), values);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -99,9 +98,9 @@ public class FileService {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public List<FileNamePojo> getAllFiles(int userId) throws Exception {
|
|
|
+ public List<FileNameBO> getAllFiles(int userId) throws Exception {
|
|
|
List<FileInfo> files = fileInfoDao.findByUserId(userId);
|
|
|
- List<FileNamePojo> rsl = files.stream().map((file) -> new FileNamePojo(String.valueOf(file.getId()), file.getFilename()))
|
|
|
+ List<FileNameBO> rsl = files.stream().map((file) -> new FileNameBO(String.valueOf(file.getId()), file.getFilename()))
|
|
|
.collect(Collectors.toList());
|
|
|
return rsl;
|
|
|
}
|
|
|
@@ -111,8 +110,8 @@ public class FileService {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public FileAndFuncInfoPojo getAllFilesAndFunc(int userId) throws Exception {
|
|
|
- return new FileAndFuncInfoPojo(getAllFiles(userId), funcInfoDao.findAll());
|
|
|
+ public FileAndFuncInfoBO getAllFilesAndFunc(int userId) throws Exception {
|
|
|
+ return new FileAndFuncInfoBO(getAllFiles(userId), funcInfoDao.findAll());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -120,10 +119,10 @@ public class FileService {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public FileDetailPojo getFileDetailInfo(int fileId) throws Exception {
|
|
|
+ public FileDetailBO getFileDetailInfo(int fileId) throws Exception {
|
|
|
FileInfo fileInfo = fileInfoDao.findById(fileId);
|
|
|
List<HeaderInfo> headerInfos = headerInfoDao.findByFileInfoId(fileId);
|
|
|
- return new FileDetailPojo(fileInfo.getFilename(), fileInfo.getUploadTime(), new Json2Object().Json2HashMap(fileInfo.getFileStrucInfo()), headerInfos);
|
|
|
+ return new FileDetailBO(fileInfo.getFilename(), fileInfo.getUploadTime(), new Json2Object().Json2HashMap(fileInfo.getFileStrucInfo()), headerInfos);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -206,21 +205,21 @@ public class FileService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param innerHeaderInfos
|
|
|
+ * @param innerHeaderInfoBOS
|
|
|
* @param headerToUpdate
|
|
|
* @return
|
|
|
*/
|
|
|
- public boolean updateAllHeaders(List<InnerHeaderInfo> innerHeaderInfos, List<Integer> headerToUpdate) {
|
|
|
- if (innerHeaderInfos == null || headerToUpdate == null) {
|
|
|
+ public boolean updateAllHeaders(List<InnerHeaderInfoBO> innerHeaderInfoBOS, List<Integer> headerToUpdate) {
|
|
|
+ if (innerHeaderInfoBOS == null || headerToUpdate == null) {
|
|
|
return false;
|
|
|
}
|
|
|
int currLen = headerToUpdate.size();
|
|
|
- System.out.println("headerInfos = [" + innerHeaderInfos + "], headerToUpdate = [" + headerToUpdate + "]");
|
|
|
+ System.out.println("headerInfos = [" + innerHeaderInfoBOS + "], headerToUpdate = [" + headerToUpdate + "]");
|
|
|
System.out.println(currLen);
|
|
|
for (int index : headerToUpdate) {
|
|
|
- InnerHeaderInfo innerheaderInfo = innerHeaderInfos.get(index);
|
|
|
- if (!updateHeaderInfo(Integer.parseInt(innerheaderInfo.getId()), innerheaderInfo.getAliasName(),
|
|
|
- innerheaderInfo.getFieldDes())) {
|
|
|
+ InnerHeaderInfoBO innerheaderInfoBO = innerHeaderInfoBOS.get(index);
|
|
|
+ if (!updateHeaderInfo(Integer.parseInt(innerheaderInfoBO.getId()), innerheaderInfoBO.getAliasName(),
|
|
|
+ innerheaderInfoBO.getFieldDes())) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|