|
|
@@ -1,27 +1,55 @@
|
|
|
package com.ydtech.modules.task.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ydtech.core.page.HttpResult;
|
|
|
+import com.ydtech.exception.SystemException;
|
|
|
+import com.ydtech.modules.admin.model.SysUser;
|
|
|
+import com.ydtech.modules.admin.model.po.SysDeptInternalAgent;
|
|
|
+import com.ydtech.modules.admin.model.po.SysUserLinkDeptInternalAgent;
|
|
|
+import com.ydtech.modules.admin.service.SysDeptInternalAgentService;
|
|
|
+import com.ydtech.modules.admin.service.SysUserLinkDeptInternalAgentService;
|
|
|
+import com.ydtech.modules.admin.service.SysUserService;
|
|
|
import com.ydtech.modules.base.controller.BaseController;
|
|
|
-import com.ydtech.modules.ser.model.SerAnnualAuditOrder;
|
|
|
+import com.ydtech.modules.task.entity.po.TaskPersonCharge;
|
|
|
import com.ydtech.modules.task.entity.po.TaskProject;
|
|
|
+import com.ydtech.modules.task.entity.po.TaskTask;
|
|
|
+import com.ydtech.modules.task.entity.vo.AddTaskVo;
|
|
|
+import com.ydtech.modules.task.entity.vo.AssignTaskVo;
|
|
|
+import com.ydtech.modules.task.entity.vo.BackLineUserVo;
|
|
|
import com.ydtech.modules.task.entity.vo.TaskProjectVo;
|
|
|
+import com.ydtech.modules.task.service.TaskPersonChargeService;
|
|
|
import com.ydtech.modules.task.service.TaskProjectService;
|
|
|
+import com.ydtech.modules.task.service.TaskTaskService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
@Api(tags = "任务controller")
|
|
|
@RestController
|
|
|
@RequestMapping("/task/task")
|
|
|
public class TaskController extends BaseController {
|
|
|
|
|
|
- @Resource
|
|
|
- private TaskProjectService taskProjectService;
|
|
|
+ @Autowired
|
|
|
+ TaskTaskService taskTaskService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ TaskPersonChargeService taskPersonChargeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ TaskProjectService taskProjectService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SysUserService sysUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SysDeptInternalAgentService sysDeptInternalAgentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SysUserLinkDeptInternalAgentService sysUserLinkDeptInternalAgentService;
|
|
|
|
|
|
@ApiOperation("新增任务项目")
|
|
|
@PostMapping("/addProject")
|
|
|
@@ -46,4 +74,70 @@ public class TaskController extends BaseController {
|
|
|
public HttpResult selectProject(@RequestBody TaskProjectVo taskProjectVo){
|
|
|
return HttpResult.ok("",taskProjectService.selectProject(taskProjectVo));
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/getBackLineUser")
|
|
|
+ @ApiOperation("获取后线用户")
|
|
|
+ public HttpResult<Object> getBackLineUser(){
|
|
|
+ //获取用户信息
|
|
|
+ SysUserLinkDeptInternalAgent sysUserLinkDeptInternalAgent = sysUserLinkDeptInternalAgentService.getByUserId(getUserId());
|
|
|
+ //获取部门
|
|
|
+ SysDeptInternalAgent sysDeptInternalAgent = sysDeptInternalAgentService.getById(sysUserLinkDeptInternalAgent.getSysDeptInternalAgentId());
|
|
|
+ List<BackLineUserVo> backLineUser = taskTaskService.getBackLineUser(sysDeptInternalAgent.getId());
|
|
|
+// List<SysDeptInternalAgent> tree = sysDeptInternalAgentService.findTree(null, null);
|
|
|
+ return HttpResult.ok(backLineUser);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/getTaskInfo")
|
|
|
+ @ApiOperation("获取任务详情")
|
|
|
+ public HttpResult<Object> getTaskInfo(){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/getTaskTree")
|
|
|
+ @ApiOperation("获取任务树结构")
|
|
|
+ public HttpResult<Object> getTaskTree(String projectId,String userId){
|
|
|
+ List<TaskTask> taskTree = taskTaskService.getTaskTree(projectId,userId);
|
|
|
+ return HttpResult.ok(taskTree);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/addTask")
|
|
|
+ @ApiOperation("添加任务")
|
|
|
+ public HttpResult<Object> addTask(@RequestBody AddTaskVo addTaskVo){
|
|
|
+ if(taskProjectService.getById(addTaskVo.getProjectId()) == null){
|
|
|
+ throw new SystemException("项目id填写错误");
|
|
|
+ }
|
|
|
+ TaskTask task = taskTaskService.getById(addTaskVo.getTaskId());
|
|
|
+ if(!addTaskVo.getTaskId().equals("0") && task == null){
|
|
|
+ throw new SystemException("任务id填写错误");
|
|
|
+ }
|
|
|
+ return taskTaskService.addTask(addTaskVo,getUserName()) ? HttpResult.ok("添加任务成功") : HttpResult.error("添加任务失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/assignTask")
|
|
|
+ @ApiOperation("分配任务")
|
|
|
+ public HttpResult<Object> assignTask(@RequestBody AssignTaskVo assignTaskVo){
|
|
|
+ List<TaskPersonCharge> taskPersonChargeList = taskPersonChargeService.getTaskPersonChargeList(assignTaskVo.getTaskId());
|
|
|
+ JSONObject diffTaskPersonCharge = taskPersonChargeService.getDiffTaskPersonCharge(assignTaskVo, taskPersonChargeList);
|
|
|
+ List<String> addUserArr = (List<String>) diffTaskPersonCharge.get("userIdsToAdd");
|
|
|
+ List<String> delUserArr = (List<String>) diffTaskPersonCharge.get("userIdsToDelete");
|
|
|
+ List<SysUser> addUsers = new ArrayList<>();
|
|
|
+ List<SysUser> delUsers = new ArrayList<>();
|
|
|
+ if(!addUserArr.isEmpty()) {
|
|
|
+ addUsers = sysUserService.getByIds(addUserArr);
|
|
|
+ }
|
|
|
+ if(!delUserArr.isEmpty()) {
|
|
|
+ delUsers = sysUserService.getByIds(delUserArr);
|
|
|
+ }
|
|
|
+ return taskPersonChargeService.dealPersonCharge(assignTaskVo.getTaskId(), addUsers, delUsers) ?
|
|
|
+ HttpResult.ok("分配任务成功") :
|
|
|
+ HttpResult.error("分配任务失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/changeTaskStatus")
|
|
|
+ @ApiOperation("更改任务状态")
|
|
|
+ public HttpResult<Object> changeTaskStatus(){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|