|
@@ -4,14 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.hssx.pcbms.constant.Constant;
|
|
|
-import com.hssx.pcbms.entity.Task;
|
|
|
-import com.hssx.pcbms.entity.TaskDynamic;
|
|
|
-import com.hssx.pcbms.entity.TaskParticipants;
|
|
|
+import com.hssx.pcbms.entity.*;
|
|
|
import com.hssx.pcbms.entity.vo.TaskDTO;
|
|
|
import com.hssx.pcbms.entity.vo.TaskVO;
|
|
|
-import com.hssx.pcbms.mapper.TaskDynamicMapper;
|
|
|
-import com.hssx.pcbms.mapper.TaskMapper;
|
|
|
-import com.hssx.pcbms.mapper.UserMapper;
|
|
|
+import com.hssx.pcbms.mapper.*;
|
|
|
import com.hssx.pcbms.service.TaskParticipantsService;
|
|
|
import com.hssx.pcbms.service.TaskService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -19,8 +15,11 @@ import com.hssx.pcbms.util.HttpRespMsg;
|
|
|
import com.hssx.pcbms.util.ListUtil;
|
|
|
import com.hssx.pcbms.util.PageUtil;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -44,19 +43,44 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
private TaskDynamicMapper taskDynamicMapper;
|
|
|
@Resource
|
|
|
private UserMapper userMapper;
|
|
|
+ @Resource
|
|
|
+ private NewsNoticeMapper newsNoticeMapper;
|
|
|
+ @Resource
|
|
|
+ private NewsNoticeUserMapper newsNoticeUserMapper;
|
|
|
|
|
|
@Override
|
|
|
public HttpRespMsg addOrUpdate(Task task,String participantsIdes) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
List<TaskParticipants> taskParticipants = new ArrayList<>();
|
|
|
if(null == task.getId()){
|
|
|
- taskMapper.insert(task);
|
|
|
TaskDynamic taskDynamic = new TaskDynamic();
|
|
|
+ if(task.getRecipientId() != null){
|
|
|
+ task.setState(1);//已派发
|
|
|
+ taskDynamic.setTaskState(1);//已派发
|
|
|
+ taskDynamic.setStateContent(Constant.ALREADY_DISTRIBUTED);
|
|
|
+ taskDynamic.setContent(userMapper.selectById(task.getPublishId()).getName()+Constant.TASK_DISTRIBUTE+userMapper.selectById(task.getRecipientId()).getName());
|
|
|
+ //给接收人发送消息
|
|
|
+ NewsNotice newsNotice = new NewsNotice();
|
|
|
+ newsNotice.setNoticeType(2);
|
|
|
+ newsNotice.setRefId(Integer.parseInt(task.getId()));
|
|
|
+ newsNotice.setRafName(task.getName());
|
|
|
+ newsNotice.setContent("有新的任务待您接受");
|
|
|
+ newsNoticeMapper.insert(newsNotice);
|
|
|
+ NewsNoticeUser noticeUser = new NewsNoticeUser();
|
|
|
+ noticeUser.setIsRead(0);
|
|
|
+ noticeUser.setUserId(task.getRecipientId());
|
|
|
+ noticeUser.setNewsId(newsNotice.getId());
|
|
|
+ newsNoticeUserMapper.insert(noticeUser);
|
|
|
+ }else{
|
|
|
+ task.setState(0);//待派发
|
|
|
+ taskDynamic.setTaskState(0);//待派发
|
|
|
+ taskDynamic.setStateContent(Constant.TO_BE_DISTRIBUTE);
|
|
|
+ taskDynamic.setContent(userMapper.selectById(task.getPublishId()).getName()+Constant.TASK_PULISH);
|
|
|
+ }
|
|
|
+ taskMapper.insert(task);
|
|
|
taskDynamic.setTaskId(task.getId());
|
|
|
- taskDynamic.setTaskState(0);//待派发
|
|
|
- taskDynamic.setStateContent(userMapper.selectById(task.getPublishId()).getName()+Constant.TASK_PULISH);
|
|
|
taskDynamicMapper.insert(taskDynamic);
|
|
|
- if(participantsIdes.length()>0 && participantsIdes != ""){
|
|
|
+ if(participantsIdes != null && participantsIdes != ""){
|
|
|
List<Integer> ids = ListUtil.convertIntegerIdsArrayToList(participantsIdes);
|
|
|
for (Integer id : ids) {
|
|
|
TaskParticipants participants = new TaskParticipants();
|
|
@@ -67,17 +91,37 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
taskParticipantsService.saveBatch(taskParticipants);
|
|
|
}
|
|
|
}else{
|
|
|
- if(task.getDelayTime()!=null){
|
|
|
+ Task oldTask = taskMapper.selectById(task.getId());
|
|
|
+ TaskDynamic taskDynamic = new TaskDynamic();
|
|
|
+ taskDynamic.setTaskId(task.getId());
|
|
|
+ if(task.getDelayTime()!=null && oldTask.getDelayTime() == null){
|
|
|
//添加动态
|
|
|
- TaskDynamic taskDynamic = new TaskDynamic();
|
|
|
- taskDynamic.setTaskId(task.getId());
|
|
|
taskDynamic.setTaskState(6);//已延期
|
|
|
- taskDynamic.setStateContent(userMapper.selectById(task.getPublishId()).getName()+Constant.TASK_DELAY+task.getDelayTime());
|
|
|
+ taskDynamic.setStateContent(Constant.ALREADY_DELAY);
|
|
|
+ taskDynamic.setContent(userMapper.selectById(task.getPublishId()).getName()+Constant.TASK_DELAY+task.getDelayTime());
|
|
|
+ taskDynamicMapper.insert(taskDynamic);
|
|
|
+ }
|
|
|
+ if(task.getRecipientId() != null && oldTask.getRecipientId() == null){
|
|
|
+ task.setState(1);//已派发
|
|
|
+ taskDynamic.setTaskState(1);//已派发
|
|
|
+ taskDynamic.setStateContent(Constant.ALREADY_DISTRIBUTED);
|
|
|
+ taskDynamic.setContent(userMapper.selectById(task.getPublishId()).getName()+Constant.TASK_DISTRIBUTE+userMapper.selectById(task.getRecipientId()).getName());
|
|
|
taskDynamicMapper.insert(taskDynamic);
|
|
|
+ //给接收人发送消息
|
|
|
+ NewsNotice newsNotice = new NewsNotice();
|
|
|
+ newsNotice.setNoticeType(2);
|
|
|
+ newsNotice.setRefId(Integer.parseInt(task.getId()));
|
|
|
+ newsNotice.setRafName(task.getName());
|
|
|
+ newsNotice.setContent("有新的任务待您接受");
|
|
|
+ newsNoticeMapper.insert(newsNotice);
|
|
|
+ NewsNoticeUser noticeUser = new NewsNoticeUser();
|
|
|
+ noticeUser.setIsRead(0);
|
|
|
+ noticeUser.setUserId(task.getRecipientId());
|
|
|
+ noticeUser.setNewsId(newsNotice.getId());
|
|
|
+ newsNoticeUserMapper.insert(noticeUser);
|
|
|
}
|
|
|
taskMapper.updateById(task);
|
|
|
-
|
|
|
- if(participantsIdes.length()>0 && participantsIdes != ""){
|
|
|
+ if(participantsIdes != null && participantsIdes != ""){
|
|
|
taskParticipantsService.remove(new QueryWrapper<TaskParticipants>().eq("task_id",task.getId()));
|
|
|
List<Integer> ids = ListUtil.convertIntegerIdsArrayToList(participantsIdes);
|
|
|
for (Integer id : ids) {
|
|
@@ -128,4 +172,41 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
msg.data = dto;
|
|
|
return msg;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg acceptTask(Task task) {
|
|
|
+ HttpRespMsg msg= new HttpRespMsg();
|
|
|
+ task.setState(2);//已接受
|
|
|
+ taskMapper.updateById(task);
|
|
|
+ TaskDynamic dynamic = new TaskDynamic();
|
|
|
+ dynamic.setTaskId(task.getId());
|
|
|
+ dynamic.setStateContent(Constant.ALREADY_ACCEPT);
|
|
|
+ dynamic.setContent(userMapper.selectById(task.getRecipientId()).getName()+Constant.TASK_ACCEPTED);
|
|
|
+ taskDynamicMapper.insert(dynamic);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg taskInvalidChecking() {
|
|
|
+ List<Task> taskList = taskMapper.selectList(new QueryWrapper<Task>().ne("state", 7));
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ String format = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(now);
|
|
|
+ for (Task task : taskList) {
|
|
|
+ if(task.getState()==6){
|
|
|
+// if(){
|
|
|
+//
|
|
|
+// }
|
|
|
+ }else{
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ String format = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(now);
|
|
|
+ System.out.println(format);
|
|
|
+ }
|
|
|
}
|