|
@@ -3,17 +3,15 @@ package com.management.platform.service.impl;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.util.StringUtil;
|
|
|
import com.management.platform.entity.*;
|
|
|
import com.management.platform.mapper.*;
|
|
|
import com.management.platform.service.CompanyDingdingService;
|
|
|
-import com.management.platform.service.MilestoneTaskRefService;
|
|
|
import com.management.platform.service.TaskExecutorService;
|
|
|
import com.management.platform.service.TaskService;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.management.platform.util.*;
|
|
|
+import com.management.platform.util.HttpRespMsg;
|
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
|
-import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.apache.poi.ss.usermodel.CellType;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
@@ -27,10 +25,6 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.*;
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.math.RoundingMode;
|
|
|
-import java.sql.Timestamp;
|
|
|
-import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
@@ -299,7 +293,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg importTask(Integer projectId, Integer groupId, Integer stagesId, MultipartFile multipartFile, HttpServletRequest request) {
|
|
|
+ public HttpRespMsg importTask(Integer projectId, Integer groupId, MultipartFile multipartFile, HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
|
|
|
//首先先搞到公司id
|
|
@@ -307,13 +301,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
User creator = userMapper.selectById(userId);
|
|
|
Integer companyId = creator.getCompanyId();
|
|
|
List<User> allUserList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
|
- //获取当前导入的任务列表
|
|
|
- Stages stages = stagesMapper.selectById(stagesId);
|
|
|
- List<Task> maxList = taskMapper.selectList(new QueryWrapper<Task>().eq("stages_id", stagesId).orderByDesc("seq").last("limit 1"));
|
|
|
- int seq = 1;
|
|
|
- if (maxList.size() > 0) {
|
|
|
- seq = maxList.get(0).getSeq() + 1;
|
|
|
- }
|
|
|
HashMap<String, Integer> taskTypeMap = new HashMap<>();
|
|
|
taskTypeMap.put("任务", 0);
|
|
|
taskTypeMap.put("里程碑", 1);
|
|
@@ -357,12 +344,14 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
break;
|
|
|
}
|
|
|
XSSFCell typeCell = row.getCell(1);
|
|
|
- XSSFCell executorCell = row.getCell(2);
|
|
|
- XSSFCell levelCell = row.getCell(3);
|
|
|
- XSSFCell endDateCell = row.getCell(4);
|
|
|
- XSSFCell planHoursCell = row.getCell(5);
|
|
|
+ XSSFCell stagesCell = row.getCell(2);
|
|
|
+ XSSFCell executorCell = row.getCell(3);
|
|
|
+ XSSFCell levelCell = row.getCell(4);
|
|
|
+ XSSFCell endDateCell = row.getCell(5);
|
|
|
+ XSSFCell planHoursCell = row.getCell(6);
|
|
|
nameCell.setCellType(CellType.STRING);
|
|
|
typeCell.setCellType(CellType.STRING);
|
|
|
+ stagesCell.setCellType(CellType.STRING);
|
|
|
endDateCell.setCellType(CellType.NUMERIC);
|
|
|
planHoursCell.setCellType(CellType.STRING);
|
|
|
String name = nameCell.getStringCellValue();
|
|
@@ -375,20 +364,51 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
task.setCompanyId(companyId);
|
|
|
task.setProjectId(projectId);
|
|
|
task.setGroupId(groupId);
|
|
|
- String executorName = executorCell.getStringCellValue();
|
|
|
- System.out.println("姓名=="+executorCell.getStringCellValue());
|
|
|
- Optional<User> first = allUserList.stream().filter(u -> u.getName().equals(executorName)).findFirst();
|
|
|
- if (first.isPresent()) {
|
|
|
- User find = first.get();
|
|
|
- task.setExecutorId(find.getId());
|
|
|
- task.setExecutorName(find.getName());
|
|
|
- task.setExecutorColor(find.getColor());
|
|
|
+ String[] executorNameArray = executorCell.getStringCellValue().split(",");
|
|
|
+ List<String> executorNameList = Arrays.asList(executorNameArray);
|
|
|
+ String executorIdString="";
|
|
|
+ String executorNameString="";
|
|
|
+ String executorColorString="";
|
|
|
+ for (int i=0;i<executorNameList.size();i++) {
|
|
|
+ String executorName = executorNameList.get(i);
|
|
|
+ Optional<User> first = allUserList.stream().filter(u -> u.getName().equals(executorName)).findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ User find = first.get();
|
|
|
+ if(i==executorNameList.size()-1){
|
|
|
+ executorIdString+=find.getId();
|
|
|
+ executorNameString+=find.getName();
|
|
|
+ executorColorString+=find.getColor();
|
|
|
+ }else{
|
|
|
+ executorIdString+=find.getId()+",";
|
|
|
+ executorNameString+=find.getName()+",";
|
|
|
+ executorColorString+=find.getColor()+",";
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ httpRespMsg.setError("执行人["+executorName+"]不存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ task.setExecutorId(executorIdString);
|
|
|
+ task.setExecutorName(executorNameString);
|
|
|
+ task.setExecutorColor(executorColorString);
|
|
|
+ //获取当前导入的任务列表
|
|
|
+ List<Stages> stagesList = stagesMapper.selectList(new QueryWrapper<Stages>().eq("project_id",projectId).eq("group_id",groupId));
|
|
|
+ if(!stagesList.stream().anyMatch(sg->sg.getStagesName().equals(stagesCell.getStringCellValue()))){
|
|
|
+ httpRespMsg.setError("任务列表["+stagesCell.getStringCellValue()+"]不存在");
|
|
|
+ return httpRespMsg;
|
|
|
}
|
|
|
- task.setStagesId(stagesId);
|
|
|
- task.setStagesName(stages.getStagesName());
|
|
|
- task.setSeq(seq++);
|
|
|
+ Optional<Stages> theFirst = stagesList.stream().filter(sg -> sg.getStagesName().equals(stagesCell.getStringCellValue())).findFirst();
|
|
|
task.setName(name);
|
|
|
task.setTaskType(taskTypeMap.get(typeCell.getStringCellValue()));
|
|
|
+ if(theFirst.isPresent()){
|
|
|
+ List<Task> maxList = taskMapper.selectList(new QueryWrapper<Task>().eq("stages_id", theFirst.get().getId()).orderByDesc("seq").last("limit 1"));
|
|
|
+ int seq = 1;
|
|
|
+ if (maxList.size() > 0) {
|
|
|
+ seq = maxList.get(0).getSeq() + 1;
|
|
|
+ }
|
|
|
+ task.setStagesId(theFirst.get().getId());
|
|
|
+ task.setStagesName(theFirst.get().getStagesName());
|
|
|
+ task.setSeq(seq++);
|
|
|
+ }
|
|
|
task.setTaskLevel(taskLevelMap.get(levelCell.getStringCellValue()));
|
|
|
Date dateCellValue = endDateCell.getDateCellValue();
|
|
|
System.out.println("日期=="+dateCellValue.toString());
|
|
@@ -404,15 +424,18 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
}
|
|
|
saveBatch(taskList);
|
|
|
//保存到执行人表
|
|
|
- List<TaskExecutor> executorList = new ArrayList<>();
|
|
|
+ List<List<TaskExecutor>> executorListAll=new ArrayList<>();
|
|
|
for (Task t : taskList) {
|
|
|
if (!StringUtil.isEmpty(t.getExecutorId())) {
|
|
|
- TaskExecutor executor = TaskExecutor.fromTask(t);
|
|
|
- executorList.add(executor);
|
|
|
+ List<TaskExecutor> executorList = TaskExecutor.fromTask(t);
|
|
|
+ executorListAll.add(executorList);
|
|
|
}
|
|
|
}
|
|
|
- if (executorList.size() > 0) {
|
|
|
- taskExecutorService.saveBatch(executorList);
|
|
|
+ if (executorListAll.size() > 0) {
|
|
|
+ for (List<TaskExecutor> executorList : executorListAll) {
|
|
|
+ taskExecutorService.saveBatch(executorList);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
//最后删掉这个文件
|
|
|
// if (!file.delete()) {
|