|
@@ -0,0 +1,99 @@
|
|
|
+package com.management.platform.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.management.platform.entity.*;
|
|
|
+import com.management.platform.mapper.*;
|
|
|
+import com.management.platform.service.TaskProgressService;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.management.platform.service.TprogressPaticipatorsService;
|
|
|
+import com.management.platform.util.HttpRespMsg;
|
|
|
+import com.management.platform.util.ListUtil;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author Seyason
|
|
|
+ * @since 2021-05-17
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@Transactional
|
|
|
+public class TaskProgressServiceImpl extends ServiceImpl<TaskProgressMapper, TaskProgress> implements TaskProgressService {
|
|
|
+ @Resource
|
|
|
+ private TaskProgressMapper taskProgressMapper;
|
|
|
+ @Resource
|
|
|
+ private TprogressPaticipatorsMapper tprogressPaticipatorsMapper;
|
|
|
+ @Resource
|
|
|
+ private UserMapper userMapper;
|
|
|
+ @Resource
|
|
|
+ private InformationMapper informationMapper;
|
|
|
+ @Resource
|
|
|
+ private TaskMapper taskMapper;
|
|
|
+ @Resource
|
|
|
+ private ProjectMapper projectMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg addProgress(TaskProgress progress, String participatorIds, HttpServletRequest request) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ User creator = userMapper.selectById(request.getHeader("Token"));
|
|
|
+ progress.setCreatorId(request.getHeader("Token"));
|
|
|
+ taskProgressMapper.insert(progress);
|
|
|
+ if (!StringUtils.isEmpty(participatorIds)) {
|
|
|
+ List<String> ids = ListUtil.convertLongIdsArrayToList(participatorIds);
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().in("id", ids));
|
|
|
+ for (User user : userList) {
|
|
|
+ TprogressPaticipators item = new TprogressPaticipators();
|
|
|
+ item.setProgressId(progress.getId());
|
|
|
+ item.setUserId(user.getId());
|
|
|
+ item.setUserName(user.getName());
|
|
|
+ tprogressPaticipatorsMapper.insert(item);
|
|
|
+
|
|
|
+ //发消息通知进展
|
|
|
+ Information information = new Information();
|
|
|
+ information.setContent(""+progress.getTaskId());
|
|
|
+ information.setMsg("任务有新进展");
|
|
|
+ information.setUserId(user.getId());
|
|
|
+ information.setType(2);
|
|
|
+ informationMapper.insert(information);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg deleteProgress(Integer id, HttpServletRequest request) {
|
|
|
+ String userId = request.getHeader("Token");
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ TaskProgress taskProgress = taskProgressMapper.selectById(id);
|
|
|
+ Task task = taskMapper.selectById(taskProgress.getTaskId());
|
|
|
+ Project project = projectMapper.selectById(task.getProjectId());
|
|
|
+ if (taskProgress.getCreatorId().equals(userId)
|
|
|
+ ||userId.equals(project.getInchargerId())) {
|
|
|
+ taskProgressMapper.deleteById(id);
|
|
|
+ tprogressPaticipatorsMapper.delete(new QueryWrapper<TprogressPaticipators>().eq("progress_id", id));
|
|
|
+ } else {
|
|
|
+ msg.setError("只有创建人和项目经理可以删除");
|
|
|
+ }
|
|
|
+
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getList(Integer taskId) {
|
|
|
+ //倒序,最新的在最上面
|
|
|
+ List<TaskProgress> taskProgressList
|
|
|
+ = taskProgressMapper.selectList(new QueryWrapper<TaskProgress>().eq("task_id", taskId).orderByDesc("id"));
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ msg.data = taskProgressList;
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+}
|