|
@@ -1,24 +1,166 @@
|
|
package com.jiayue.biz.service.impl;
|
|
package com.jiayue.biz.service.impl;
|
|
|
|
|
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
|
+import cn.hutool.db.handler.StringHandler;
|
|
|
|
+import cn.hutool.poi.excel.ExcelReader;
|
|
|
|
+import cn.hutool.poi.excel.ExcelUtil;
|
|
|
|
+import com.jiayue.biz.domain.ProjectMenusOne;
|
|
|
|
+import com.jiayue.biz.domain.ProjectMenusThree;
|
|
|
|
+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 lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
|
+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 java.io.File;
|
|
|
|
+import java.io.InputStream;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.UUID;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
public class ProjectProgressServiceImpl implements ProjectProgressService {
|
|
public class ProjectProgressServiceImpl implements ProjectProgressService {
|
|
|
|
|
|
|
|
+ private final String indexStr = "一二三四五六七";
|
|
|
|
+ private final String indexStrs = "12345678910";
|
|
|
|
+
|
|
|
|
+ private final String projectProgressDir = "D:\\\\projectProgressDir\\\\";
|
|
|
|
+
|
|
private MongoTemplate mongoTemplate;
|
|
private MongoTemplate mongoTemplate;
|
|
|
|
|
|
//查询项目进展
|
|
//查询项目进展
|
|
- public List<ProjectProgress> selectProProjectInfo(){
|
|
|
|
|
|
+ public List<ProjectProgress> selectProProjectInfo() {
|
|
return mongoTemplate.find(new Query(), ProjectProgress.class, "project_progress");
|
|
return mongoTemplate.find(new Query(), ProjectProgress.class, "project_progress");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ //项目进展解析
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ 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();
|
|
|
|
+
|
|
|
|
+ ArrayList<ProjectMenusOne> projectMenusOneList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ String s1 = "";
|
|
|
|
+ //创建一级菜单
|
|
|
|
+ ProjectMenusOne projectMenusOne = new ProjectMenusOne();
|
|
|
|
+ ProjectMenusTow projectMenusTow = new ProjectMenusTow();
|
|
|
|
+ //循环每行数据
|
|
|
|
+ for (List<Object> objects : read) {
|
|
|
|
+ if (indexStr.contains(objects.get(0).toString())) {
|
|
|
|
+ //每次进入新的一级菜单都需要新的对象
|
|
|
|
+ projectMenusOne = new ProjectMenusOne();
|
|
|
|
+ projectMenusOne.setId(UUID.randomUUID().toString());
|
|
|
|
+ projectMenusOne.setIndex(objects.get(0).toString());
|
|
|
|
+ projectMenusOne.setWorkContent(objects.get(1).toString());
|
|
|
|
+ projectMenusOne.setPlanTime(objects.get(2).toString());
|
|
|
|
+ projectMenusOne.setProjectMenusTows(new ArrayList<ProjectMenusTow>());
|
|
|
|
+ projectMenusOneList.add(projectMenusOne);
|
|
|
|
+ if ((objects.get(0).toString().equals("一") && objects.get(4) != null && !objects.get(4).toString().equals("")) ||
|
|
|
|
+ (objects.get(0).toString().equals("一") && objects.get(5) != null && !objects.get(5).toString().equals(""))) {
|
|
|
|
+ ProjectMenusTow projectMenusTow1 = new ProjectMenusTow();
|
|
|
|
+ projectMenusTow1.setId(UUID.randomUUID().toString());
|
|
|
|
+ projectMenusTow1.setIndex("");
|
|
|
|
+ projectMenusTow1.setPlanTime("");
|
|
|
|
+ projectMenusTow1.setWorkContent("");
|
|
|
|
+ projectMenusTow1.setProjectMenusThreeList(new ArrayList<>());
|
|
|
|
+
|
|
|
|
+ ProjectMenusThree projectMenusThree = new ProjectMenusThree();
|
|
|
|
+ projectMenusThree.setIndex("");
|
|
|
|
+ projectMenusThree.setRealTime(objects.get(4) == null ? "" : objects.get(4).toString());
|
|
|
|
+ projectMenusThree.setWorkContent("");
|
|
|
|
+ projectMenusThree.setRemark(objects.get(5) == null ? "" : objects.get(5).toString());
|
|
|
|
+
|
|
|
|
+ projectMenusTow1.getProjectMenusThreeList().add(projectMenusThree);
|
|
|
|
+ projectMenusOne.getProjectMenusTows().add(projectMenusTow1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else if (indexStrs.contains(objects.get(0).toString())) {
|
|
|
|
+ //如果 二级菜单 有变化再创建新的
|
|
|
|
+ if (!s1.equals(objects.get(1).toString())) {
|
|
|
|
+ projectMenusTow = hTow(objects);
|
|
|
|
+ projectMenusTow.setProjectMenusThreeList(new ArrayList<ProjectMenusThree>());
|
|
|
|
+ projectMenusOne.getProjectMenusTows().add(projectMenusTow);
|
|
|
|
+ }
|
|
|
|
+ //三级菜单每次都需要新对象
|
|
|
|
+ projectMenusTow.getProjectMenusThreeList().add(hThree(objects));
|
|
|
|
+ s1 = objects.get(1).toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ //最终List
|
|
|
|
+ ProjectProgress projectProgress = new ProjectProgress();
|
|
|
|
+ projectProgress.setId(UUID.randomUUID().toString());
|
|
|
|
+ projectProgress.setProjectMenusOneList(projectMenusOneList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //设置二级
|
|
|
|
+ public ProjectMenusTow hTow(List<Object> objects) {
|
|
|
|
+ ProjectMenusTow projectMenusTow = new ProjectMenusTow();
|
|
|
|
+ projectMenusTow.setId(UUID.randomUUID().toString());
|
|
|
|
+ projectMenusTow.setIndex(objects.get(0) == null ? "" : objects.get(0).toString());
|
|
|
|
+ projectMenusTow.setWorkContent(objects.get(1) == null ? "" : objects.get(1).toString());
|
|
|
|
+ projectMenusTow.setPlanTime(objects.get(2) == null ? "" : objects.get(2).toString());
|
|
|
|
+ return projectMenusTow;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //设置三级信息
|
|
|
|
+ public ProjectMenusThree hThree(List<Object> objects) {
|
|
|
|
+ ProjectMenusThree projectMenusThree = new ProjectMenusThree();
|
|
|
|
+ projectMenusThree.setId(UUID.randomUUID().toString());
|
|
|
|
+ if (objects.get(3) != null) {
|
|
|
|
+ projectMenusThree.setIndex(splitStr(objects.get(3).toString()));
|
|
|
|
+ projectMenusThree.setWorkContent(splitStr22(objects.get(3).toString()));
|
|
|
|
+ }
|
|
|
|
+ projectMenusThree.setRealTime(objects.get(4) == null ? "" : objects.get(4).toString());
|
|
|
|
+ projectMenusThree.setRemark(objects.get(5) == null ? "" : objects.get(5).toString());
|
|
|
|
+ return projectMenusThree;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public String splitStr(String strs) {
|
|
|
|
+ if (strs.contains(".")) {
|
|
|
|
+ int index = strs.indexOf(".");
|
|
|
|
+ String substring = strs.substring(0, index + 2);
|
|
|
|
+ return CalculationUtil.getNumberFromStringForDian(substring);
|
|
|
|
+ } else {
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String splitStr22(String strs) {
|
|
|
|
+ if (strs.contains(".")) {
|
|
|
|
+ int index = strs.indexOf(".");
|
|
|
|
+ String substring = strs.substring(index);
|
|
|
|
+ return substring;
|
|
|
|
+ } else {
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|