|
|
|
@ -30,6 +30,8 @@ import org.jeecg.modules.system.entity.SysUser; |
|
|
|
|
import org.jeecg.modules.system.service.ISysUserService; |
|
|
|
|
import org.jeecg.modules.task.entity.Task; |
|
|
|
|
import org.jeecg.modules.task.service.ITaskService; |
|
|
|
|
import org.jeecg.modules.taskType.entity.TaskType; |
|
|
|
|
import org.jeecg.modules.taskType.service.ITaskTypeService; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
import org.springframework.web.servlet.ModelAndView; |
|
|
|
@ -89,39 +91,16 @@ public class TaskController extends JeecgController<Task, ITaskService> { |
|
|
|
|
@ApiOperation(value = "任务管理-分页列表查询", notes = "任务管理-分页列表查询") |
|
|
|
|
@GetMapping(value = "/list") |
|
|
|
|
public Result<?> queryPageList(Task task, |
|
|
|
|
@RequestParam(name = "userName",defaultValue = "") String userName, |
|
|
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
|
|
|
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
|
|
|
|
HttpServletRequest req) { |
|
|
|
|
QueryWrapper<Task> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
QueryWrapper<Task> queryWrapper = QueryGenerator.initQueryWrapper(task, req.getParameterMap()); |
|
|
|
|
Page<Task> page = new Page<Task>(pageNo, pageSize); |
|
|
|
|
|
|
|
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
|
if (!StringUtils.equals(ADMIN, user.getUsername())) { |
|
|
|
|
queryWrapper.like("manager_users", user.getId()); |
|
|
|
|
} |
|
|
|
|
List<SysUser> sysUsers = taskService.UserIdByUserName(userName); |
|
|
|
|
if(sysUsers!=null&& sysUsers.size() > 0) |
|
|
|
|
for (int i = 0; i < sysUsers.size(); i++) { |
|
|
|
|
queryWrapper.like("manager_users", sysUsers.get(i).getId()); |
|
|
|
|
if (i != sysUsers.size() - 1) |
|
|
|
|
queryWrapper.or(); |
|
|
|
|
} |
|
|
|
|
if (task != null && StringUtils.isNotBlank(task.getTypeId())) { |
|
|
|
|
queryWrapper.eq("type_id", task.getTypeId()); |
|
|
|
|
} |
|
|
|
|
if (task != null && StringUtils.isNotBlank(task.getTaskName())) { |
|
|
|
|
String tas = task.getTaskName(); |
|
|
|
|
if(tas.startsWith("*")&&tas.endsWith("*")) |
|
|
|
|
tas = tas.substring(1, tas.length() - 1); |
|
|
|
|
queryWrapper.like("task_name", tas); |
|
|
|
|
} |
|
|
|
|
if (task != null && task.getWorkStatus() != null && (task.getWorkStatus() == 0 || task.getWorkStatus() == 1)) { |
|
|
|
|
queryWrapper.in("work_status", 0, 1); |
|
|
|
|
} |
|
|
|
|
if (task != null && task.getWorkStatus() != null && (task.getWorkStatus() == 2 || task.getWorkStatus() == 9)) { |
|
|
|
|
queryWrapper.in("work_status", 2, 9); |
|
|
|
|
} |
|
|
|
|
queryWrapper.orderByDesc("create_time"); |
|
|
|
|
IPage<Task> pageList = taskService.page(page, queryWrapper); |
|
|
|
|
pageList.getRecords().stream().forEach(e -> { |
|
|
|
@ -178,7 +157,7 @@ public class TaskController extends JeecgController<Task, ITaskService> { |
|
|
|
|
@ApiOperation(value = "任务管理-分页列表查询", notes = "任务管理-分页列表查询") |
|
|
|
|
@GetMapping(value = "/list1") |
|
|
|
|
public Result<?> queryPageList1(Task task, |
|
|
|
|
@RequestParam(name = "userId") String userId, |
|
|
|
|
@RequestParam(name = "userId", defaultValue = "1") String userId, |
|
|
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
|
|
|
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
|
|
|
|
HttpServletRequest req) { |
|
|
|
@ -290,17 +269,6 @@ public class TaskController extends JeecgController<Task, ITaskService> { |
|
|
|
|
public Result<?> delete(@RequestParam(name = "id", required = true) String id) { |
|
|
|
|
Task task = taskService.getById(id); |
|
|
|
|
Optional.ofNullable(task).orElseThrow(() -> new JeecgBootException(id + ":任务不存在")); |
|
|
|
|
if (task.getWorkStatus() == 2 || task.getWorkStatus() == 3 || task.getWorkStatus() == 4) { |
|
|
|
|
throw new JeecgBootException("该状态下不可删除"); |
|
|
|
|
} |
|
|
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
|
if (!StringUtils.equals(ADMIN, user.getUsername())) { |
|
|
|
|
if (StringUtils.equals(ADMIN, task.getCreateBy())) { |
|
|
|
|
throw new JeecgBootException("非管理员不可删除"); |
|
|
|
|
} else if (!StringUtils.equals(user.getUsername(), task.getCreateBy())) { |
|
|
|
|
throw new JeecgBootException("不可删除他人的任务"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
int count = taskService.count(new LambdaQueryWrapper<Task>().eq(Task::getUpperId, task.getId())); |
|
|
|
|
if (count > 0) { |
|
|
|
|
throw new JeecgBootException("存在子任务暂不可删除"); |
|
|
|
|