|
@@ -6,20 +6,20 @@ 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.entity.dto.TaskDto;
|
|
|
import com.management.platform.mapper.*;
|
|
|
-import com.management.platform.service.CompanyDingdingService;
|
|
|
-import com.management.platform.service.TaskExecutorService;
|
|
|
-import com.management.platform.service.TaskService;
|
|
|
-import com.management.platform.service.WxCorpInfoService;
|
|
|
+import com.management.platform.service.*;
|
|
|
import com.management.platform.util.ExcelUtil;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
import com.management.platform.util.MessageUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
|
import org.apache.poi.ss.usermodel.CellType;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -30,6 +30,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.*;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -46,5 +47,58 @@ import java.util.stream.Collectors;
|
|
|
@Transactional
|
|
|
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService {
|
|
|
|
|
|
+ @Resource
|
|
|
+ private UserMapper userMapper;
|
|
|
+ @Resource
|
|
|
+ private TaskMapper taskMapper;
|
|
|
+ @Resource
|
|
|
+ private TaskLogMapper taskLogMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private TaskRepeatDesignMapper taskRepeatDesignMapper;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public HttpRespMsg addTask(TaskDto taskDto, HttpServletRequest request) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+
|
|
|
+ String userId = String.valueOf(request.getHeader("Token"));
|
|
|
+ User user = userMapper.selectById(userId);
|
|
|
+ if (user==null){
|
|
|
+ httpRespMsg.setError("无法获取创建人信息!");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(taskDto.getName())||taskDto.getPriority()==null){
|
|
|
+ httpRespMsg.setError("缺少任务名称或任务优先级!");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ Task task = new Task();
|
|
|
+ BeanUtils.copyProperties(taskDto,task);
|
|
|
+ task.setCreateDate(LocalDate.now());//任务的创建时间
|
|
|
+ task.setCreaterName(user.getName());
|
|
|
+ task.setCompanyId(user.getCompanyId());
|
|
|
+
|
|
|
+ taskMapper.insert(task);
|
|
|
+
|
|
|
+ //重复状态为 自定义日期:4
|
|
|
+ if (taskDto.getRepeatType()==4){
|
|
|
+ TaskRepeatDesign taskRepeatDesign = new TaskRepeatDesign();
|
|
|
+ taskRepeatDesign.setTaskId(task.getId());
|
|
|
+ taskRepeatDesign.setDayCount(taskDto.getTaskRepeatDesign().getDayCount());
|
|
|
+ taskRepeatDesign.setCreateTime(LocalDateTime.now());
|
|
|
+ taskRepeatDesignMapper.insert(taskRepeatDesign);
|
|
|
+ }
|
|
|
+ //添加任务编译记录
|
|
|
+ TaskLog taskLog = new TaskLog();
|
|
|
+ taskLog.setTaskId(task.getId());
|
|
|
+ taskLog.setContent("创建了任务");
|
|
|
+ taskLog.setUserId(userId);
|
|
|
+ taskLog.setUserName(user.getName());
|
|
|
+ taskLog.setModTime(LocalDateTime.now());
|
|
|
+ taskLogMapper.insert(taskLog);
|
|
|
+
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
}
|