|
@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSONArray;
|
|
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.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.additional.update.impl.LambdaUpdateChainWrapper;
|
|
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.entity.*;
|
|
import com.management.platform.entity.*;
|
|
@@ -156,5 +158,64 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional
|
|
|
|
+ public HttpRespMsg updateTask(TaskDto taskDto, HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg=new HttpRespMsg();
|
|
|
|
+ String token = String.valueOf(request.getHeader("Token"));
|
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
|
+ if (user==null){
|
|
|
|
+ msg.setError("无法获取创建人信息!");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ taskDto.setCompanyId(user.getCompanyId());
|
|
|
|
+ if (taskDto.getId()==null){
|
|
|
|
+ msg.setError("无任务的关键信息");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(taskDto.getTaskName())||taskDto.getPriority()==null){
|
|
|
|
+ msg.setError("缺少任务名称或任务优先级!");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ Task task = taskMapper.selectById(taskDto.getId());
|
|
|
|
+ updateTaskRepeatConfigure(task);//将任务中之前的关于重复日期相关的置空
|
|
|
|
+ taskMapper.updateRepeatConfig(task);
|
|
|
|
+ BeanUtils.copyProperties(taskDto,task);
|
|
|
|
+ taskMapper.updateById(task);
|
|
|
|
+
|
|
|
|
+ //删除之前的执行人
|
|
|
|
+ LambdaQueryWrapper<TaskExecutor> lwq = new LambdaQueryWrapper<>();
|
|
|
|
+ lwq.eq(TaskExecutor::getTaskId,taskDto.getId());
|
|
|
|
+ taskExecutorMapper.delete(lwq);
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isNotEmpty(taskDto.getExecutorId())){
|
|
|
|
+ String[] executorIds = taskDto.getExecutorId().split(",");
|
|
|
|
+ for (String executorId : executorIds) {
|
|
|
|
+ TaskExecutor taskExecutor = new TaskExecutor();
|
|
|
|
+ User selectedUser = userMapper.selectById(executorId);
|
|
|
|
+ taskExecutor.setExecutorId(executorId)
|
|
|
|
+ .setTaskId(task.getId())
|
|
|
|
+ .setExecutorName(selectedUser.getName());
|
|
|
|
+ taskExecutorMapper.insert(taskExecutor);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //添加任务编译记录
|
|
|
|
+ TaskLog taskLog = new TaskLog();
|
|
|
|
+ taskLog.setTaskId(task.getId());
|
|
|
|
+ taskLog.setContent("修改了任务");
|
|
|
|
+ taskLog.setUserId(user.getId());
|
|
|
|
+ taskLog.setUserName(user.getName());
|
|
|
|
+ taskLog.setModTime(LocalDateTime.now());
|
|
|
|
+ taskLogMapper.insert(taskLog);
|
|
|
|
+
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void updateTaskRepeatConfigure(Task task){
|
|
|
|
+ task.setRepeatType(null).setRepeatEndNever(null).setRepeatEndCount(null)
|
|
|
|
+ .setRepeatEndDate(null).setRepeatDesignDay(null).setRepeatDesignSameday(null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|