|  |  |  | 
|---|
|  |  |  | package com.zy.acs.manager.manager.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.zy.acs.framework.common.Cools; | 
|---|
|  |  |  | import com.zy.acs.framework.common.R; | 
|---|
|  |  |  | import com.zy.acs.manager.common.utils.ExcelUtil; | 
|---|
|  |  |  | import com.zy.acs.manager.common.annotation.OperationLog; | 
|---|
|  |  |  | import com.zy.acs.manager.common.domain.BaseParam; | 
|---|
|  |  |  | import com.zy.acs.manager.common.domain.KeyValVo; | 
|---|
|  |  |  | import com.zy.acs.manager.common.domain.PageParam; | 
|---|
|  |  |  | import com.zy.acs.manager.common.utils.BusinessSortService; | 
|---|
|  |  |  | import com.zy.acs.manager.common.utils.ExcelUtil; | 
|---|
|  |  |  | import com.zy.acs.manager.manager.entity.Task; | 
|---|
|  |  |  | import com.zy.acs.manager.manager.service.TaskService; | 
|---|
|  |  |  | import com.zy.acs.manager.system.controller.BaseController; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private TaskService taskService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private BusinessSortService businessSortService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:task:list')") | 
|---|
|  |  |  | @PostMapping("/task/page") | 
|---|
|  |  |  | public R page(@RequestBody Map<String, Object> map) { | 
|---|
|  |  |  | BaseParam baseParam = buildParam(map, BaseParam.class); | 
|---|
|  |  |  | PageParam<Task, BaseParam> pageParam = new PageParam<>(baseParam, Task.class); | 
|---|
|  |  |  | return R.ok().add(taskService.page(pageParam, pageParam.buildWrapper(true))); | 
|---|
|  |  |  | QueryWrapper<Task> wrapper = pageParam.buildWrapper(false, "io_time"); | 
|---|
|  |  |  | if (hasCreateTimeDesc(pageParam.getOrders())) { | 
|---|
|  |  |  | //            wrapper.last(businessSortService.getOrderBySql(TaskStsType.class, "task_sts")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(taskService.page(pageParam, wrapper)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:task:list')") | 
|---|
|  |  |  | 
|---|
|  |  |  | ExcelUtil.build(ExcelUtil.create(taskService.list(), Task.class), response); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:task:update')") | 
|---|
|  |  |  | @OperationLog("Complete Task") | 
|---|
|  |  |  | @GetMapping("/task/complete/{id}") | 
|---|
|  |  |  | public R complete(@PathVariable Long id) { | 
|---|
|  |  |  | return taskService.complete(id, getLoginUserId()) ? R.ok("Complete Success") : R.error("Complete Fail"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:task:update')") | 
|---|
|  |  |  | @OperationLog("Cancel Task") | 
|---|
|  |  |  | @GetMapping("/task/cancel/{id}") | 
|---|
|  |  |  | public R cancel(@PathVariable Long id) { | 
|---|
|  |  |  | return taskService.cancel(id, getLoginUserId()) ? R.ok("Cancel Success") : R.error("Cancel Fail"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|