|
@@ -10,18 +10,20 @@ import com.jiayue.biz.domain.ProjectMenusTow;
|
|
import com.jiayue.biz.domain.ProjectProgress;
|
|
import com.jiayue.biz.domain.ProjectProgress;
|
|
import com.jiayue.biz.service.ProjectProgressService;
|
|
import com.jiayue.biz.service.ProjectProgressService;
|
|
import com.jiayue.biz.util.CalculationUtil;
|
|
import com.jiayue.biz.util.CalculationUtil;
|
|
|
|
+import com.jiayue.common.utils.DateUtil;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
|
+import lombok.SneakyThrows;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
import org.springframework.data.mongodb.core.query.Query;
|
|
import org.springframework.data.mongodb.core.query.Query;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import java.io.File;
|
|
|
|
-import java.io.InputStream;
|
|
|
|
|
|
+import java.io.*;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
@@ -32,6 +34,9 @@ public class ProjectProgressServiceImpl implements ProjectProgressService {
|
|
|
|
|
|
private final String projectProgressDir = "D:\\\\projectProgressDir\\\\";
|
|
private final String projectProgressDir = "D:\\\\projectProgressDir\\\\";
|
|
|
|
|
|
|
|
+ private final String projectProgressAttachment = "attachment\\\\";
|
|
|
|
+ private final String projectProgressBackNew = "new\\\\";
|
|
|
|
+
|
|
private MongoTemplate mongoTemplate;
|
|
private MongoTemplate mongoTemplate;
|
|
|
|
|
|
//查询项目进展
|
|
//查询项目进展
|
|
@@ -39,28 +44,80 @@ public class ProjectProgressServiceImpl implements ProjectProgressService {
|
|
return mongoTemplate.find(new Query(), ProjectProgress.class, "project_progress");
|
|
return mongoTemplate.find(new Query(), ProjectProgress.class, "project_progress");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 保存附件
|
|
|
|
+ * @param multipartFile 文件
|
|
|
|
+ * @param name 文件夹名
|
|
|
|
+ */
|
|
|
|
+ @SneakyThrows
|
|
|
|
+ public void saveAttachment(MultipartFile multipartFile, String name){
|
|
|
|
+ File projectProgressDirFileNew = new File(projectProgressDir + name + File.separator + projectProgressAttachment);
|
|
|
|
+ if (!projectProgressDirFileNew.exists()) {
|
|
|
|
+ projectProgressDirFileNew.mkdirs();
|
|
|
|
+ }
|
|
|
|
+ multipartFile.transferTo(new File(projectProgressDirFileNew.getPath() + File.separator + multipartFile.getOriginalFilename()));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
//项目进展解析
|
|
//项目进展解析
|
|
- public void projectProgressParse(MultipartFile multipartFile, String eqId) {
|
|
|
|
- File projectProgressDirFile = new File(projectProgressDir + eqId);
|
|
|
|
- File[] files = projectProgressDirFile.listFiles();
|
|
|
|
- //删除旧文件
|
|
|
|
- if (files.length > 0) {
|
|
|
|
- for (File file : files) {
|
|
|
|
- FileUtil.del(file);
|
|
|
|
|
|
+ public void projectProgressParse(MultipartFile multipartFile, String id, String name) {
|
|
|
|
+
|
|
|
|
+ String fileName = multipartFile.getOriginalFilename();
|
|
|
|
+ File filed = new File(fileName);
|
|
|
|
+ OutputStream out = null;
|
|
|
|
+ try {
|
|
|
|
+ //获取文件流,以文件流的方式输出到新文件
|
|
|
|
+// InputStream in = multipartFile.getInputStream();
|
|
|
|
+ out = new FileOutputStream(filed);
|
|
|
|
+ byte[] ss = multipartFile.getBytes();
|
|
|
|
+ for (int i = 0; i < ss.length; i++) {
|
|
|
|
+ out.write(ss[i]);
|
|
|
|
+ }
|
|
|
|
+ ExcelReader reader = ExcelUtil.getReader(filed);
|
|
|
|
+ List<List<Object>> read = reader.read();
|
|
|
|
+ //解析文件入库
|
|
|
|
+ saveProjectProgress(read,id);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ File projectProgressDirFileNew = new File(projectProgressDir + name + File.separator + projectProgressBackNew);
|
|
|
|
+ if (!projectProgressDirFileNew.exists()) {
|
|
|
|
+ projectProgressDirFileNew.mkdirs();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ File[] files = projectProgressDirFileNew.listFiles();
|
|
|
|
+ //删除旧文件
|
|
|
|
+ if (files != null && files.length > 0) {
|
|
|
|
+ for (File file1 : files) {
|
|
|
|
+ FileUtil.del(file1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //项目进展文件移动
|
|
|
|
+ multipartFile.transferTo(new File(projectProgressDirFileNew.getPath() + File.separator + fileName));
|
|
|
|
+
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } finally {
|
|
|
|
+ if (out != null) {
|
|
|
|
+ try {
|
|
|
|
+ out.close();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (!projectProgressDirFile.exists()) {
|
|
|
|
- projectProgressDirFile.mkdirs();
|
|
|
|
- }
|
|
|
|
- String filename = multipartFile.getOriginalFilename();
|
|
|
|
- File file = new File(filename);
|
|
|
|
- //项目进展文件移动
|
|
|
|
- FileUtil.move(file, new File(projectProgressDirFile.getPath() + File.separator), true);
|
|
|
|
|
|
|
|
- ExcelReader reader = ExcelUtil.getReader(file);
|
|
|
|
- List<List<Object>> read = reader.read();
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //项目进展解析文件入库
|
|
|
|
+ public void saveProjectProgress(List<List<Object>> read,String id){
|
|
ArrayList<ProjectMenusOne> projectMenusOneList = new ArrayList<>();
|
|
ArrayList<ProjectMenusOne> projectMenusOneList = new ArrayList<>();
|
|
|
|
|
|
String s1 = "";
|
|
String s1 = "";
|
|
@@ -112,10 +169,15 @@ public class ProjectProgressServiceImpl implements ProjectProgressService {
|
|
}
|
|
}
|
|
//最终List
|
|
//最终List
|
|
ProjectProgress projectProgress = new ProjectProgress();
|
|
ProjectProgress projectProgress = new ProjectProgress();
|
|
- projectProgress.setId(UUID.randomUUID().toString());
|
|
|
|
|
|
+ projectProgress.setId(id);
|
|
projectProgress.setProjectMenusOneList(projectMenusOneList);
|
|
projectProgress.setProjectMenusOneList(projectMenusOneList);
|
|
|
|
+
|
|
|
|
+// mongoTemplate.save(projectProgress,"project_progress");
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
//设置二级
|
|
//设置二级
|
|
public ProjectMenusTow hTow(List<Object> objects) {
|
|
public ProjectMenusTow hTow(List<Object> objects) {
|
|
ProjectMenusTow projectMenusTow = new ProjectMenusTow();
|
|
ProjectMenusTow projectMenusTow = new ProjectMenusTow();
|