|
@@ -5,6 +5,8 @@ import com.aliyun.dingtalkcontact_1_0.models.SearchUserResponse;
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.injector.methods.Update;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.github.pagehelper.util.StringUtil;
|
|
import com.github.pagehelper.util.StringUtil;
|
|
import com.management.platform.controller.TaskController;
|
|
import com.management.platform.controller.TaskController;
|
|
@@ -37,8 +39,10 @@ import javax.servlet.http.HttpServletRequest;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
|
+import java.time.Duration;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
+import java.time.LocalTime;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -108,6 +112,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
private TaskTypeMapper taskTypeMapper;
|
|
private TaskTypeMapper taskTypeMapper;
|
|
@Resource
|
|
@Resource
|
|
CustomerInfoMapper customerInfoMapper;
|
|
CustomerInfoMapper customerInfoMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private TaskDailyAllocateService taskDailyAllocateService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private InformationService informationService;
|
|
private InformationService informationService;
|
|
@@ -642,6 +648,15 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
//由于第一行需要指明列对应的标题
|
|
//由于第一行需要指明列对应的标题
|
|
int lastRowNum = sheet.getLastRowNum();
|
|
int lastRowNum = sheet.getLastRowNum();
|
|
System.out.println("lastRowNum==>"+lastRowNum);
|
|
System.out.println("lastRowNum==>"+lastRowNum);
|
|
|
|
+ Integer initTaskId=null;
|
|
|
|
+ Integer initProjectId=null;
|
|
|
|
+ LocalDateTime initStartDate=null;
|
|
|
|
+ LocalDateTime initEndDate=null;
|
|
|
|
+ String initUserStr="";
|
|
|
|
+ String initExectorColors="";
|
|
|
|
+ String initExectorIds="";
|
|
|
|
+ String initExectorNames="";
|
|
|
|
+ Double initworkHourExector= (double) 0;
|
|
for (int rowIndex = 1; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
|
|
for (int rowIndex = 1; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
|
|
ArrayList<TaskExecutor> taskExecutors = new ArrayList<>();
|
|
ArrayList<TaskExecutor> taskExecutors = new ArrayList<>();
|
|
XSSFRow row = sheet.getRow(rowIndex);
|
|
XSSFRow row = sheet.getRow(rowIndex);
|
|
@@ -649,235 +664,439 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
if (row == null) {
|
|
if (row == null) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- for (int i = 0; i < 5; i++) {
|
|
|
|
|
|
+ for (int i = 0; i < 8; i++) {
|
|
XSSFCell cell = row.getCell(0);
|
|
XSSFCell cell = row.getCell(0);
|
|
if (cell!=null) {
|
|
if (cell!=null) {
|
|
cell.setCellType(CellType.STRING);
|
|
cell.setCellType(CellType.STRING);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- XSSFCell typeCell = row.getCell(0);
|
|
|
|
- if (typeCell == null||StringUtils.isEmpty(typeCell.getStringCellValue())) {
|
|
|
|
- throw new Exception("第"+(rowIndex+1)+"行,类型为空");
|
|
|
|
- }else {
|
|
|
|
- Optional<TaskType> first = taskTypeList.stream().filter(t -> t.getName().equals(typeCell.getStringCellValue())).findFirst();
|
|
|
|
- if (first.isPresent()){
|
|
|
|
- task.setTaskPlanType(first.get().getId());
|
|
|
|
- }else {
|
|
|
|
- throw new Exception("第"+(rowIndex+1)+"行,类型填写有误");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //类型不为请假
|
|
|
|
- if (task.getTaskPlanType()!=3){
|
|
|
|
- XSSFCell projectCell = row.getCell(1);
|
|
|
|
- if (projectCell == null||StringUtils.isEmpty(projectCell.getStringCellValue())) {
|
|
|
|
- throw new Exception("第"+(rowIndex+1)+"行,项目为空");
|
|
|
|
- }else {
|
|
|
|
- Optional<Project> first = allProjectList.stream().filter(t -> t.getProjectName().equals(projectCell.getStringCellValue())).findFirst();
|
|
|
|
- if (first.isPresent()){
|
|
|
|
- task.setProjectId(first.get().getId());
|
|
|
|
- }else {
|
|
|
|
- throw new Exception("第"+(rowIndex+1)+"行,项目名称填写有误");
|
|
|
|
|
|
+ if (row.getCell(0)!=null &&row.getCell(10)!=null) {
|
|
|
|
+ initTaskId = null;
|
|
|
|
+ initProjectId=null;
|
|
|
|
+ initStartDate=null;
|
|
|
|
+ initEndDate=null;
|
|
|
|
+ initUserStr="";
|
|
|
|
+ initExectorColors="";
|
|
|
|
+ initExectorIds="";
|
|
|
|
+ initExectorNames="";
|
|
|
|
+ initworkHourExector= (double) 0;
|
|
|
|
+
|
|
|
|
+ XSSFCell typeCell = row.getCell(0);
|
|
|
|
+ if (typeCell == null || StringUtils.isEmpty(typeCell.getStringCellValue())) {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,类型为空");
|
|
|
|
+ } else {
|
|
|
|
+ Optional<TaskType> first = taskTypeList.stream().filter(t -> t.getName().equals(typeCell.getStringCellValue())).findFirst();
|
|
|
|
+ if (first.isPresent()) {
|
|
|
|
+ task.setTaskPlanType(first.get().getId());
|
|
|
|
+ } else {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,类型填写有误");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //类型不为请假
|
|
|
|
+ if (task.getTaskPlanType() != 3) {
|
|
|
|
+ XSSFCell projectCell = row.getCell(1);
|
|
|
|
+ if (projectCell == null || StringUtils.isEmpty(projectCell.getStringCellValue())) {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,项目为空");
|
|
|
|
+ } else {
|
|
|
|
+ Optional<Project> first = allProjectList.stream().filter(t -> t.getProjectName().equals(projectCell.getStringCellValue())).findFirst();
|
|
|
|
+ if (first.isPresent()) {
|
|
|
|
+ task.setProjectId(first.get().getId());
|
|
|
|
+ } else {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,项目名称填写有误");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- XSSFCell researchCell = row.getCell(2);//研究中心
|
|
|
|
- if (researchCell != null||StringUtils.isNotEmpty(researchCell.getStringCellValue())) {
|
|
|
|
- Optional<ReportExtraDegree> first = customerInfoList.stream().filter(c -> c.getName().equals(researchCell.getStringCellValue().trim())).findFirst();
|
|
|
|
- if (first.isPresent()){
|
|
|
|
- task.setCenterId(first.get().getId());
|
|
|
|
- task.setCenterName(first.get().getName());
|
|
|
|
- }else {
|
|
|
|
- throw new Exception("第"+(rowIndex+1)+"行,研究中心填写有误");
|
|
|
|
|
|
+ XSSFCell researchCell = row.getCell(2);//研究中心
|
|
|
|
+ if (researchCell != null || StringUtils.isNotEmpty(researchCell.getStringCellValue())) {
|
|
|
|
+ Optional<ReportExtraDegree> first = customerInfoList.stream().filter(c -> c.getName().equals(researchCell.getStringCellValue().trim())).findFirst();
|
|
|
|
+ if (first.isPresent()) {
|
|
|
|
+ task.setCenterId(first.get().getId());
|
|
|
|
+ task.setCenterName(first.get().getName());
|
|
|
|
+ } else {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,研究中心填写有误");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- XSSFCell taskGroupCell = row.getCell(3);//所属任务分组
|
|
|
|
- if (taskGroupCell == null||StringUtils.isEmpty(taskGroupCell.getStringCellValue())) {
|
|
|
|
- throw new Exception("第"+(rowIndex+1)+"行,任务分组为空");
|
|
|
|
- }else {
|
|
|
|
- Optional<TaskGroup> first = allGroupList.stream().filter(t -> t.getProjectId().equals(task.getProjectId())&&t.getName().equals(taskGroupCell.getStringCellValue())).findFirst();
|
|
|
|
- if (first.isPresent()){
|
|
|
|
- task.setGroupId(first.get().getId());
|
|
|
|
- }else {
|
|
|
|
- throw new Exception("第"+(rowIndex+1)+"行,任务分组填写有误");
|
|
|
|
|
|
+ XSSFCell taskGroupCell = row.getCell(3);//所属任务分组
|
|
|
|
+ if (taskGroupCell == null || StringUtils.isEmpty(taskGroupCell.getStringCellValue())) {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,任务分组为空");
|
|
|
|
+ } else {
|
|
|
|
+ Optional<TaskGroup> first = allGroupList.stream().filter(t -> t.getProjectId().equals(task.getProjectId()) && t.getName().equals(taskGroupCell.getStringCellValue())).findFirst();
|
|
|
|
+ if (first.isPresent()) {
|
|
|
|
+ task.setGroupId(first.get().getId());
|
|
|
|
+ } else {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,任务分组填写有误");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- XSSFCell taskStageCell = row.getCell(4);//所属任务列表
|
|
|
|
- if (taskStageCell == null||StringUtils.isEmpty(taskStageCell.getStringCellValue())) {
|
|
|
|
- throw new Exception("第"+(rowIndex+1)+"行,任务列表为空");
|
|
|
|
- }else {
|
|
|
|
- Optional<Stages> first = stagesList.stream().filter(t -> t.getGroupId().equals(task.getGroupId())&&t.getStagesName().equals(taskStageCell.getStringCellValue())).findFirst();
|
|
|
|
- if (first.isPresent()){
|
|
|
|
- task.setStagesId(first.get().getId());
|
|
|
|
- }else {
|
|
|
|
- throw new Exception("第"+(rowIndex+1)+"行,任务列表填写有误");
|
|
|
|
|
|
+ XSSFCell taskStageCell = row.getCell(4);//所属任务列表
|
|
|
|
+ if (taskStageCell == null || StringUtils.isEmpty(taskStageCell.getStringCellValue())) {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,任务列表为空");
|
|
|
|
+ } else {
|
|
|
|
+ Optional<Stages> first = stagesList.stream().filter(t -> t.getGroupId().equals(task.getGroupId()) && t.getStagesName().equals(taskStageCell.getStringCellValue())).findFirst();
|
|
|
|
+ if (first.isPresent()) {
|
|
|
|
+ task.setStagesId(first.get().getId());
|
|
|
|
+ } else {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,任务列表填写有误");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- XSSFCell taskContentCell = row.getCell(5);//任务内容
|
|
|
|
- if (taskContentCell == null||StringUtils.isEmpty(taskContentCell.getStringCellValue())) {
|
|
|
|
- throw new Exception("第"+(rowIndex+1)+"行,任务内容为空");
|
|
|
|
- }else {
|
|
|
|
- task.setName(taskContentCell.getStringCellValue());
|
|
|
|
- }
|
|
|
|
|
|
+ XSSFCell taskContentCell = row.getCell(5);//任务内容
|
|
|
|
+ if (taskContentCell == null || StringUtils.isEmpty(taskContentCell.getStringCellValue())) {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,任务内容为空");
|
|
|
|
+ } else {
|
|
|
|
+ task.setName(taskContentCell.getStringCellValue());
|
|
|
|
+ }
|
|
|
|
|
|
- XSSFCell planHoursCell = row.getCell(9);//计划工时
|
|
|
|
- if(planHoursCell!=null){
|
|
|
|
- planHoursCell.setCellType(CellType.STRING);
|
|
|
|
- task.setPlanHours(Double.parseDouble(planHoursCell.getStringCellValue()));
|
|
|
|
- }
|
|
|
|
|
|
+// XSSFCell planHoursCell = row.getCell(9);//计划工时
|
|
|
|
+// if(planHoursCell!=null){
|
|
|
|
+// planHoursCell.setCellType(CellType.STRING);
|
|
|
|
+// task.setPlanHours(Double.parseDouble(planHoursCell.getStringCellValue()));
|
|
|
|
+// }
|
|
|
|
|
|
- XSSFCell priorityCell = row.getCell(10);//优先级
|
|
|
|
- if(priorityCell!=null){
|
|
|
|
- priorityCell.setCellType(CellType.STRING);
|
|
|
|
- String stringCellValue = priorityCell.getStringCellValue();
|
|
|
|
- if(StringUtils.isNotEmpty(stringCellValue)){
|
|
|
|
- switch (stringCellValue){
|
|
|
|
- case "一般":
|
|
|
|
- task.setTaskLevel(0);
|
|
|
|
- break;
|
|
|
|
- case "重要":
|
|
|
|
- task.setTaskLevel(1);
|
|
|
|
- break;
|
|
|
|
- case "紧急":
|
|
|
|
- task.setTaskLevel(2);
|
|
|
|
- break;
|
|
|
|
|
|
+ XSSFCell priorityCell = row.getCell(6);//优先级
|
|
|
|
+ if (priorityCell != null) {
|
|
|
|
+ priorityCell.setCellType(CellType.STRING);
|
|
|
|
+ String stringCellValue = priorityCell.getStringCellValue();
|
|
|
|
+ if (StringUtils.isNotEmpty(stringCellValue)) {
|
|
|
|
+ switch (stringCellValue) {
|
|
|
|
+ case "一般":
|
|
|
|
+ task.setTaskLevel(0);
|
|
|
|
+ break;
|
|
|
|
+ case "重要":
|
|
|
|
+ task.setTaskLevel(1);
|
|
|
|
+ break;
|
|
|
|
+ case "紧急":
|
|
|
|
+ task.setTaskLevel(2);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ task.setTaskLevel(0);
|
|
}
|
|
}
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
task.setTaskLevel(0);
|
|
task.setTaskLevel(0);
|
|
}
|
|
}
|
|
- }else {
|
|
|
|
- task.setTaskLevel(0);
|
|
|
|
|
|
+
|
|
|
|
+ XSSFCell descCell = row.getCell(7);//详细描述
|
|
|
|
+ if (descCell != null) {
|
|
|
|
+ descCell.setCellType(CellType.STRING);
|
|
|
|
+ String stringCellValue = descCell.getStringCellValue();
|
|
|
|
+ task.setTaskDesc(stringCellValue);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- XSSFCell descCell = row.getCell(11);//详细描述
|
|
|
|
- if(descCell!=null){
|
|
|
|
- descCell.setCellType(CellType.STRING);
|
|
|
|
- String stringCellValue = descCell.getStringCellValue();
|
|
|
|
- task.setTaskDesc(stringCellValue);
|
|
|
|
|
|
+
|
|
|
|
+ XSSFCell startDateCell = row.getCell(8);//开始时间
|
|
|
|
+ if (startDateCell != null) {
|
|
|
|
+ startDateCell.setCellType(CellType.NUMERIC);
|
|
|
|
+ } else {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,开始时间为空");
|
|
|
|
+ }
|
|
|
|
+ if (startDateCell.getDateCellValue() != null) {
|
|
|
|
+ Date dateCellValue = startDateCell.getDateCellValue();
|
|
|
|
+ System.out.println("开始日期==" + dateCellValue.toString());
|
|
|
|
+ String formatValue = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dateCellValue);
|
|
|
|
+ LocalDateTime startDate = LocalDateTime.parse(formatValue, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
+ task.setStartDate(startDate);
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
|
|
+ XSSFCell endDateCell = row.getCell(9);//结束时间
|
|
|
|
+ if (endDateCell != null) {
|
|
|
|
+ endDateCell.setCellType(CellType.NUMERIC);
|
|
|
|
+ } else {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,截止时间为空");
|
|
|
|
+ }
|
|
|
|
+ if (endDateCell.getDateCellValue() != null) {
|
|
|
|
+ Date dateCellValue = endDateCell.getDateCellValue();
|
|
|
|
+ System.out.println("开始日期==" + dateCellValue.toString());
|
|
|
|
+ String formatValue = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dateCellValue);
|
|
|
|
+ LocalDateTime endDate = LocalDateTime.parse(formatValue, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
+ task.setEndDate(endDate);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ XSSFCell executorCell = row.getCell(10);//执行人
|
|
|
|
+ if (executorCell != null) {
|
|
|
|
+ executorCell.setCellType(CellType.STRING);
|
|
|
|
+ if (executorCell.getStringCellValue().isEmpty()) {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,执行人为空");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,执行人为空");
|
|
|
|
+ }
|
|
|
|
|
|
- XSSFCell startDateCell = row.getCell(6);//开始时间
|
|
|
|
- if (startDateCell != null) {
|
|
|
|
- startDateCell.setCellType(CellType.NUMERIC);
|
|
|
|
- }else {
|
|
|
|
- throw new Exception("第"+(rowIndex+1)+"行,开始时间为空");
|
|
|
|
- }
|
|
|
|
- if(startDateCell.getDateCellValue() != null){
|
|
|
|
- Date dateCellValue = startDateCell.getDateCellValue();
|
|
|
|
- System.out.println("开始日期=="+dateCellValue.toString());
|
|
|
|
- String formatValue = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dateCellValue);
|
|
|
|
- LocalDateTime startDate = LocalDateTime.parse(formatValue, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
- task.setStartDate(startDate);
|
|
|
|
- }
|
|
|
|
|
|
+ TaskDailyAllocate taskDailyAllocate = new TaskDailyAllocate();
|
|
|
|
+ LocalDate date1=null;
|
|
|
|
+ LocalDate date2=null;
|
|
|
|
+ LocalTime time1=null;
|
|
|
|
+ LocalTime time2=null;
|
|
|
|
+ XSSFCell startTimeCell = row.getCell(11);//每日开始时间
|
|
|
|
+ if (startTimeCell != null) {
|
|
|
|
+ startTimeCell.setCellType(CellType.NUMERIC);
|
|
|
|
+ } else {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,每日开始时间为空");
|
|
|
|
+ }
|
|
|
|
+ if (startTimeCell.getDateCellValue() != null) {
|
|
|
|
+ Date dateCellValue = startTimeCell.getDateCellValue();
|
|
|
|
+ System.out.println("每日开始日期==" + dateCellValue.toString());
|
|
|
|
+ String formatValue = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dateCellValue);
|
|
|
|
+ LocalDateTime startDate = LocalDateTime.parse(formatValue, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
+ date1 = startDate.toLocalDate();
|
|
|
|
+ time1=startDate.toLocalTime();
|
|
|
|
+ taskDailyAllocate.setStartTime(time1);
|
|
|
|
+ }
|
|
|
|
|
|
- XSSFCell endDateCell = row.getCell(7);//结束时间
|
|
|
|
- if (endDateCell != null) {
|
|
|
|
- endDateCell.setCellType(CellType.NUMERIC);
|
|
|
|
- }else {
|
|
|
|
- throw new Exception("第"+(rowIndex+1)+"行,截止时间为空");
|
|
|
|
- }
|
|
|
|
- if(endDateCell.getDateCellValue() != null){
|
|
|
|
- Date dateCellValue = endDateCell.getDateCellValue();
|
|
|
|
- System.out.println("开始日期=="+dateCellValue.toString());
|
|
|
|
- String formatValue = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dateCellValue);
|
|
|
|
- LocalDateTime endDate = LocalDateTime.parse(formatValue, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
- task.setEndDate(endDate);
|
|
|
|
- }
|
|
|
|
|
|
+ XSSFCell endTimeCell = row.getCell(12);//每日截止时间
|
|
|
|
+ if (endTimeCell != null) {
|
|
|
|
+ endTimeCell.setCellType(CellType.NUMERIC);
|
|
|
|
+ } else {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,每日截止时间为空");
|
|
|
|
+ }
|
|
|
|
+ if (endTimeCell.getDateCellValue() != null) {
|
|
|
|
+ Date dateCellValue = endTimeCell.getDateCellValue();
|
|
|
|
+ System.out.println("每日截止日期==" + dateCellValue.toString());
|
|
|
|
+ String formatValue = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dateCellValue);
|
|
|
|
+ LocalDateTime endDate = LocalDateTime.parse(formatValue, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
+ date2 = endDate.toLocalDate();
|
|
|
|
+ time2 = endDate.toLocalTime();
|
|
|
|
+ taskDailyAllocate.setEndTime(time2);
|
|
|
|
+ }
|
|
|
|
|
|
- XSSFCell executorCell = row.getCell(8);//执行人
|
|
|
|
- if (executorCell!=null){
|
|
|
|
- executorCell.setCellType(CellType.STRING);
|
|
|
|
- if (executorCell.getStringCellValue().isEmpty()){
|
|
|
|
- throw new Exception("第"+(rowIndex+1)+"行,执行人为空");
|
|
|
|
|
|
+ if (date1==null||date2==null|| !date1.isEqual(date2)){
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,每日开始时间和每日截止时间日期不一致");
|
|
|
|
+ }else {
|
|
|
|
+ taskDailyAllocate.setAllocateDate(date1);
|
|
}
|
|
}
|
|
- }else {
|
|
|
|
- throw new Exception("第"+(rowIndex+1)+"行,执行人为空");
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
+ double hoursDifference = Duration.between(time1, time2).getSeconds() / 3600.0;
|
|
|
|
+ taskDailyAllocate.setWorkHour(hoursDifference);
|
|
|
|
+ taskDailyAllocate.setOverWorkHour(hoursDifference-7.5);
|
|
|
|
|
|
- task.setCompanyId(companyId);
|
|
|
|
- task.setCreaterId(userId);
|
|
|
|
- task.setCreaterName(creator.getName());
|
|
|
|
- task.setCreatorColor(creator.getColor());
|
|
|
|
- task.setCreateDate(LocalDate.now());
|
|
|
|
- task.setIndate(LocalDateTime.now());
|
|
|
|
- task.setTaskStatus(TaskController.STATUS_FIRST_CHECK);
|
|
|
|
- taskMapper.insert(task);
|
|
|
|
|
|
+ task.setCompanyId(companyId);
|
|
|
|
+ task.setCreaterId(userId);
|
|
|
|
+ task.setCreaterName(creator.getName());
|
|
|
|
+ task.setCreatorColor(creator.getColor());
|
|
|
|
+ task.setCreateDate(LocalDate.now());
|
|
|
|
+ task.setIndate(LocalDateTime.now());
|
|
|
|
+ task.setTaskStatus(TaskController.STATUS_FIRST_CHECK);
|
|
|
|
+ taskMapper.insert(task);
|
|
|
|
+ initTaskId = task.getId();
|
|
|
|
+ initProjectId=task.getProjectId();
|
|
|
|
+ initStartDate=task.getStartDate();
|
|
|
|
+ initEndDate=task.getEndDate();
|
|
|
|
|
|
|
|
|
|
- executorCell.setCellType(CellType.STRING);
|
|
|
|
- String executorStr = executorCell.getStringCellValue();
|
|
|
|
|
|
|
|
- String[] strings = executorStr.split(",");
|
|
|
|
|
|
+ executorCell.setCellType(CellType.STRING);
|
|
|
|
+ String executorStr = executorCell.getStringCellValue();
|
|
|
|
+ initUserStr=executorStr;
|
|
|
|
|
|
- StringJoiner exectorIds = new StringJoiner(",");
|
|
|
|
- StringJoiner exectorColors = new StringJoiner(",");
|
|
|
|
- for (int i = 0; i < strings.length; i++) {
|
|
|
|
- TaskExecutor taskExecutor = new TaskExecutor();
|
|
|
|
- String string = strings[i];
|
|
|
|
- Optional<User> first = allUserList.stream().filter(u -> u.getName().equals(string)).findFirst();
|
|
|
|
- if (!first.isPresent()) {
|
|
|
|
- throw new Exception("第"+(rowIndex+1)+"行,执行人填写有误");
|
|
|
|
- }
|
|
|
|
- taskExecutor.setTaskId(task.getId());
|
|
|
|
- User user = first.get();
|
|
|
|
- taskExecutor.setExecutorId(user.getId());
|
|
|
|
- taskExecutor.setExecutorName(user.getName());
|
|
|
|
- taskExecutor.setExecutorColor(user.getColor());
|
|
|
|
- taskExecutor.setPlanHours(task.getPlanHours());
|
|
|
|
- taskExecutor.setProjectId(task.getProjectId());
|
|
|
|
-
|
|
|
|
- Integer count = taskMapper.getUserConflitTaskCount(user.getId(), task.getId(), task.getStartDate(), task.getEndDate());
|
|
|
|
- if (count > 0) {
|
|
|
|
- throw new Exception("第"+(rowIndex+1)+"行,执行人"+user.getName()+"在其他任务上有时间冲突");
|
|
|
|
|
|
+
|
|
|
|
+ String[] strings = executorStr.split(",");
|
|
|
|
+
|
|
|
|
+ StringJoiner exectorIds = new StringJoiner(",");
|
|
|
|
+ StringJoiner exectorColors = new StringJoiner(",");
|
|
|
|
+ for (int i = 0; i < strings.length; i++) {
|
|
|
|
+ TaskExecutor taskExecutor = new TaskExecutor();
|
|
|
|
+ String string = strings[i];
|
|
|
|
+ Optional<User> first = allUserList.stream().filter(u -> u.getName().equals(string)).findFirst();
|
|
|
|
+ if (!first.isPresent()) {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,执行人填写有误");
|
|
|
|
+ }
|
|
|
|
+ taskExecutor.setTaskId(task.getId());
|
|
|
|
+ User user = first.get();
|
|
|
|
+ taskExecutor.setExecutorId(user.getId());
|
|
|
|
+ taskExecutor.setExecutorName(user.getName());
|
|
|
|
+ taskExecutor.setExecutorColor(user.getColor());
|
|
|
|
+ taskExecutor.setPlanHours(task.getPlanHours());
|
|
|
|
+ taskExecutor.setProjectId(task.getProjectId());
|
|
|
|
+
|
|
|
|
+ Integer count = taskMapper.getUserConflitTaskCount(user.getId(), task.getId(), task.getStartDate(), task.getEndDate());
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,执行人" + user.getName() + "在其他任务上有时间冲突");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Optional<Project> projectFirst = allProjectList.stream().filter(t -> t.getId().equals(task.getProjectId())).findFirst();
|
|
|
|
+ projectFirst.ifPresent(project -> taskExecutor.setFirstAuditorId(project.getInchargerId()));
|
|
|
|
+ Optional<Department> departmentOptional = departmentList.stream().filter(t -> t.getDepartmentId().equals(user.getDepartmentId())).findFirst();
|
|
|
|
+ departmentOptional.ifPresent(department -> taskExecutor.setSecondAuditorId(department.getManagerId()));
|
|
|
|
+ taskExecutor.setAuditStatus(TaskController.STATUS_FIRST_CHECK);
|
|
|
|
+ taskExecutors.add(taskExecutor);
|
|
|
|
+
|
|
|
|
+ exectorIds.add(user.getId());
|
|
|
|
+ exectorColors.add(user.getColor());
|
|
}
|
|
}
|
|
|
|
+ task.setExecutorName(executorStr);
|
|
|
|
+ initExectorIds=exectorIds.toString();
|
|
|
|
+ initExectorColors=exectorColors.toString();
|
|
|
|
+ taskDailyAllocate.setUserId(exectorIds.toString());
|
|
|
|
+ task.setExecutorId(exectorIds.toString());
|
|
|
|
+ task.setExecutorColor(exectorColors.toString());
|
|
|
|
|
|
|
|
+ taskMapper.updateById(task);
|
|
|
|
+ taskExecutorService.saveBatch(taskExecutors);
|
|
|
|
+
|
|
|
|
+ taskDailyAllocate.setTaskId(task.getId());
|
|
|
|
+ taskDailyAllocateService.save(taskDailyAllocate);
|
|
|
|
+
|
|
|
|
+ //给第一审核人发送信息提醒
|
|
|
|
+ log.info("添加工作计划,给第一审核人发送信息提醒");
|
|
Optional<Project> projectFirst = allProjectList.stream().filter(t -> t.getId().equals(task.getProjectId())).findFirst();
|
|
Optional<Project> projectFirst = allProjectList.stream().filter(t -> t.getId().equals(task.getProjectId())).findFirst();
|
|
- projectFirst.ifPresent(project -> taskExecutor.setFirstAuditorId(project.getInchargerId()));
|
|
|
|
- Optional<Department> departmentOptional = departmentList.stream().filter(t -> t.getDepartmentId().equals(user.getDepartmentId())).findFirst();
|
|
|
|
- departmentOptional.ifPresent(department -> taskExecutor.setSecondAuditorId(department.getManagerId()));
|
|
|
|
- taskExecutor.setAuditStatus(TaskController.STATUS_FIRST_CHECK);
|
|
|
|
- taskExecutors.add(taskExecutor);
|
|
|
|
-
|
|
|
|
- exectorIds.add(user.getId());
|
|
|
|
- exectorColors.add(user.getColor());
|
|
|
|
|
|
+ if (projectFirst.isPresent()) {
|
|
|
|
+ Project project = projectFirst.get();
|
|
|
|
+ Information information = new Information();
|
|
|
|
+ String executorNames = task.getExecutorList().stream()
|
|
|
|
+ .map(TaskExecutor::getExecutorName)
|
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
|
+
|
|
|
|
+ String infoMsg = project.getProjectName() + "项目有新的预计FTE计划审批任务" +
|
|
|
|
+ (executorNames.isEmpty() ? "" : ",执行人有:" + executorNames) +
|
|
|
|
+ ",请您查收.";
|
|
|
|
+ information.setMsg(infoMsg);
|
|
|
|
+ information.setTaskId(task.getId());
|
|
|
|
+ information.setType(11);
|
|
|
|
+ information.setJumpType(3);
|
|
|
|
+ information.setTime(LocalDateTime.now());
|
|
|
|
+ Optional<User> first = allUserList.stream().filter(u -> u.getId().equals(project.getInchargerId())).findFirst();
|
|
|
|
+ if (first.isPresent()) {
|
|
|
|
+ User owner = first.get();
|
|
|
|
+ information.setUserId(owner.getId());
|
|
|
|
+ }
|
|
|
|
+ informationService.save(information);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- task.setExecutorName(executorStr);
|
|
|
|
- task.setExecutorId(exectorIds.toString());
|
|
|
|
- task.setExecutorColor(exectorColors.toString());
|
|
|
|
|
|
+ else if (row.getCell(0)==null &&row.getCell(10)!=null) {
|
|
|
|
+// initTaskId 不用处理
|
|
|
|
+// initUserStr要赋值
|
|
|
|
+ TaskDailyAllocate taskDailyAllocate = new TaskDailyAllocate();
|
|
|
|
+
|
|
|
|
+ XSSFCell executorCell = row.getCell(10);//执行人
|
|
|
|
+ if (executorCell != null) {
|
|
|
|
+ executorCell.setCellType(CellType.STRING);
|
|
|
|
+ if (executorCell.getStringCellValue().isEmpty()) {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,执行人为空");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,执行人为空");
|
|
|
|
+ }
|
|
|
|
+ executorCell.setCellType(CellType.STRING);
|
|
|
|
+ String executorStr = executorCell.getStringCellValue();
|
|
|
|
+
|
|
|
|
+ LocalDate date1=null;
|
|
|
|
+ LocalDate date2=null;
|
|
|
|
+ LocalTime time1=null;
|
|
|
|
+ LocalTime time2=null;
|
|
|
|
+ XSSFCell startDateCell = row.getCell(11);//每日开始时间
|
|
|
|
+ if (startDateCell != null) {
|
|
|
|
+ startDateCell.setCellType(CellType.NUMERIC);
|
|
|
|
+ } else {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,每日开始时间为空");
|
|
|
|
+ }
|
|
|
|
+ if (startDateCell.getDateCellValue() != null) {
|
|
|
|
+ Date dateCellValue = startDateCell.getDateCellValue();
|
|
|
|
+ System.out.println("每日开始日期==" + dateCellValue.toString());
|
|
|
|
+ String formatValue = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dateCellValue);
|
|
|
|
+ LocalDateTime startDate = LocalDateTime.parse(formatValue, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
+ date1 = startDate.toLocalDate();
|
|
|
|
+ time1=startDate.toLocalTime();
|
|
|
|
+ taskDailyAllocate.setStartTime(time1);
|
|
|
|
+ }
|
|
|
|
|
|
- taskMapper.updateById(task);
|
|
|
|
- taskExecutorService.saveBatch(taskExecutors);
|
|
|
|
|
|
+ XSSFCell endDateCell = row.getCell(12);//每日截止时间
|
|
|
|
+ if (endDateCell != null) {
|
|
|
|
+ endDateCell.setCellType(CellType.NUMERIC);
|
|
|
|
+ } else {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,每日截止时间为空");
|
|
|
|
+ }
|
|
|
|
+ if (endDateCell.getDateCellValue() != null) {
|
|
|
|
+ Date dateCellValue = endDateCell.getDateCellValue();
|
|
|
|
+ System.out.println("每日截止日期==" + dateCellValue.toString());
|
|
|
|
+ String formatValue = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dateCellValue);
|
|
|
|
+ LocalDateTime endDate = LocalDateTime.parse(formatValue, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
+ date2 = endDate.toLocalDate();
|
|
|
|
+ time2 = endDate.toLocalTime();
|
|
|
|
+ taskDailyAllocate.setEndTime(time2);
|
|
|
|
+ }
|
|
|
|
|
|
- //给第一审核人发送信息提醒
|
|
|
|
- log.info("添加工作计划,给第一审核人发送信息提醒");
|
|
|
|
- Optional<Project> projectFirst = allProjectList.stream().filter(t -> t.getId().equals(task.getProjectId())).findFirst();
|
|
|
|
- if (projectFirst.isPresent()) {
|
|
|
|
- Project project = projectFirst.get();
|
|
|
|
- Information information = new Information();
|
|
|
|
- String executorNames = task.getExecutorList().stream()
|
|
|
|
- .map(TaskExecutor::getExecutorName)
|
|
|
|
- .collect(Collectors.joining(","));
|
|
|
|
|
|
+ if (date1==null||date2==null|| !date1.isEqual(date2)){
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,每日开始时间和每日截止时间日期不一致");
|
|
|
|
+ }else {
|
|
|
|
+ taskDailyAllocate.setAllocateDate(date1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ double hoursDifference = Duration.between(time1, time2).getSeconds() / 3600.0;
|
|
|
|
+ taskDailyAllocate.setWorkHour(hoursDifference);
|
|
|
|
+ taskDailyAllocate.setOverWorkHour(hoursDifference-7.5);
|
|
|
|
+
|
|
|
|
+ //如果executorStr==initUserStr,taskExcutor执行人就不用保存
|
|
|
|
+ if(executorStr.equals(initUserStr)){
|
|
|
|
+ String[] strings = executorStr.split(",");
|
|
|
|
+ Optional<User> first = allUserList.stream().filter(u -> u.getName().equals(strings[0])).findFirst();
|
|
|
|
+ if (!first.isPresent()) {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,执行人填写有误");
|
|
|
|
+ }
|
|
|
|
+ taskDailyAllocate.setTaskId(initTaskId);
|
|
|
|
+ taskDailyAllocate.setUserId(first.get().getId());
|
|
|
|
+ taskDailyAllocateService.save(taskDailyAllocate);
|
|
|
|
+ initUserStr=executorStr;
|
|
|
|
+ initExectorIds+=first.get().getId();
|
|
|
|
+ initExectorColors+=first.get().getColor();
|
|
|
|
+ initExectorNames+=first.get().getName();
|
|
|
|
+ initworkHourExector+=hoursDifference;
|
|
|
|
+ taskMapper.update(null,new UpdateWrapper<Task>().set("executor_id",initExectorIds)
|
|
|
|
+ .set("executor_color",initExectorColors).set("executor_name",initExectorNames)
|
|
|
|
+ .eq("id",initTaskId));
|
|
|
|
+ taskExecutorService.update(null,new UpdateWrapper<TaskExecutor>().eq("task_id",initTaskId).eq("executor_id",first.get().getId()).set("plan_hours",initworkHourExector));
|
|
|
|
+
|
|
|
|
+ }else {
|
|
|
|
+
|
|
|
|
+ initworkHourExector=hoursDifference;
|
|
|
|
+ String[] strings = executorStr.split(",");
|
|
|
|
+
|
|
|
|
+ TaskExecutor taskExecutor = new TaskExecutor();
|
|
|
|
+
|
|
|
|
+ Optional<User> first = allUserList.stream().filter(u -> u.getName().equals(strings[0])).findFirst();
|
|
|
|
+ if (!first.isPresent()) {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,执行人填写有误");
|
|
|
|
+ }
|
|
|
|
+ taskExecutor.setTaskId(initTaskId);
|
|
|
|
+ User user = first.get();
|
|
|
|
+ taskExecutor.setExecutorId(user.getId());
|
|
|
|
+ taskExecutor.setExecutorName(user.getName());
|
|
|
|
+ taskExecutor.setExecutorColor(user.getColor());
|
|
|
|
+ taskExecutor.setPlanHours(initworkHourExector);//todo 每个执行人的计划工时,要累加
|
|
|
|
+ taskExecutor.setProjectId(initProjectId);
|
|
|
|
+
|
|
|
|
+ Integer count = taskMapper.getUserConflitTaskCount(user.getId(), initTaskId, initStartDate, initEndDate);
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,执行人" + user.getName() + "在其他任务上有时间冲突");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Integer finalInitProjectId = initProjectId;
|
|
|
|
+ Optional<Project> projectFirst = allProjectList.stream().filter(t -> t.getId().equals(finalInitProjectId)).findFirst();
|
|
|
|
+ projectFirst.ifPresent(project -> taskExecutor.setFirstAuditorId(project.getInchargerId()));
|
|
|
|
+ Optional<Department> departmentOptional = departmentList.stream().filter(t -> t.getDepartmentId().equals(user.getDepartmentId())).findFirst();
|
|
|
|
+ departmentOptional.ifPresent(department -> taskExecutor.setSecondAuditorId(department.getManagerId()));
|
|
|
|
+ taskExecutor.setAuditStatus(TaskController.STATUS_FIRST_CHECK);
|
|
|
|
+
|
|
|
|
+ if (!first.isPresent()) {
|
|
|
|
+ throw new Exception("第" + (rowIndex + 1) + "行,执行人填写有误");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ taskDailyAllocate.setTaskId(initTaskId);
|
|
|
|
+ taskDailyAllocate.setUserId(first.get().getId());
|
|
|
|
+
|
|
|
|
+ initUserStr=executorStr;
|
|
|
|
+ initExectorIds+=first.get().getId();
|
|
|
|
+ initExectorColors+=first.get().getColor();
|
|
|
|
+ initExectorNames+=first.get().getName();
|
|
|
|
+
|
|
|
|
+ taskExecutorService.save(taskExecutor);
|
|
|
|
+ taskDailyAllocateService.save(taskDailyAllocate);
|
|
|
|
+ taskMapper.update(null,new UpdateWrapper<Task>().set("executor_id",initExectorIds)
|
|
|
|
+ .set("executor_color",initExectorColors).set("executor_name",initExectorNames)
|
|
|
|
+ .eq("id",initTaskId));
|
|
|
|
|
|
- String infoMsg = project.getProjectName() + "项目有新的预计FTE计划审批任务" +
|
|
|
|
- (executorNames.isEmpty() ? "" : ",执行人有:" + executorNames) +
|
|
|
|
- ",请您查收.";
|
|
|
|
- information.setMsg(infoMsg);
|
|
|
|
- information.setTaskId(task.getId());
|
|
|
|
- information.setType(11);
|
|
|
|
- information.setJumpType(3);
|
|
|
|
- information.setTime(LocalDateTime.now());
|
|
|
|
- Optional<User> first = allUserList.stream().filter(u -> u.getId().equals(project.getInchargerId())).findFirst();
|
|
|
|
- if (first.isPresent()) {
|
|
|
|
- User owner = first.get();
|
|
|
|
- information.setUserId(owner.getId());
|
|
|
|
}
|
|
}
|
|
- informationService.save(information);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|