package com.ruoyi.app.task.controller; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletResponse; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.ruoyi.app.task.domain.*; import com.ruoyi.common.core.domain.DeptUserTree; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.app.task.service.IArdAppTaskService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; /** * app任务管理Controller * * @author ard * @date 2023-07-22 */ @Api(tags = "app任务管理") @RestController @RequestMapping("/app/task") public class ArdAppTaskController extends BaseController { @Autowired private IArdAppTaskService ardAppTaskService; @Autowired private ISysUserService sysUserService; @Autowired private ISysDeptService sysDeptService; /** * 查询app任务管理列表 */ @ApiOperation("指挥端-历史任务查询") @PreAuthorize("@ss.hasPermi('app:task:list')") @GetMapping("/list") public TableDataInfo list(ArdAppTask ardAppTask) { startPage(); List list = ardAppTaskService.selectArdAppTaskList(ardAppTask); return getDataTable(list); } @ApiOperation("单兵端 - 下发给我的任务列表") @PreAuthorize("@ss.hasPermi('app:task:list')") @GetMapping("/listWithDetail") public TableDataInfo userlist(ArdAppTask ardAppTask) { startPage(); List list = ardAppTaskService.selectArdAppTaskListWithDetail(ardAppTask); return getDataTable(list); } @ApiOperation("单兵端 - 下发给我的任务详情") @PreAuthorize("@ss.hasPermi('app:task:list')") @GetMapping("/userDetailById") public AjaxResult userDetail(ArdAppTask ardAppTask) { List ardAppTasks = ardAppTaskService.selectArdAppTaskListWithDetailById(ardAppTask); return AjaxResult.success(ardAppTasks); } /** * 导出app任务管理列表 */ @PreAuthorize("@ss.hasPermi('app:task:export')") @Log(title = "app任务管理", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, ArdAppTask ardAppTask) { List list = ardAppTaskService.selectArdAppTaskList(ardAppTask); ExcelUtil util = new ExcelUtil(ArdAppTask.class); util.exportExcel(response, list, "app任务管理数据"); } /** * 获取app任务管理详细信息 */ @ApiOperation("指挥端-获取app任务管理详细信息") @PreAuthorize("@ss.hasPermi('app:task:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") String id) { return success(ardAppTaskService.selectArdAppTaskById(id)); } /** * 新增app任务管理 */ @ApiOperation("指挥端-下发任务") @PreAuthorize("@ss.hasPermi('app:task:add')") @Log(title = "app任务管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody ArdAppTask ardAppTask) { return toAjax(ardAppTaskService.insertArdAppTask(ardAppTask)); } /** * 修改app任务管理 */ @PreAuthorize("@ss.hasPermi('app:task:edit')") @Log(title = "app任务管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody ArdAppTask ardAppTask) { return toAjax(ardAppTaskService.updateArdAppTask(ardAppTask)); } /** * 删除app任务管理 */ @PreAuthorize("@ss.hasPermi('app:task:remove')") @Log(title = "app任务管理", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable String[] ids) { return toAjax(ardAppTaskService.deleteArdAppTaskByIds(ids)); } /** * 更新app任务详情 */ @ApiOperation("单兵端-任务打卡") @PreAuthorize("@ss.hasPermi('app:taskdetail:edit')") @Log(title = "更新app任务详情", businessType = BusinessType.UPDATE) @PutMapping("/detail") public AjaxResult editDetail(@RequestBody ArdAppTaskDetail ardAppTaskDetail) { return toAjax(ardAppTaskService.updateArdAppTaskDetail(ardAppTaskDetail)); } @ApiOperation("单兵端-任务查看") @PreAuthorize("@ss.hasPermi('app:taskdetail:edit')") @Log(title = "单兵端-任务查看", businessType = BusinessType.UPDATE) @PutMapping("/detail/view") public AjaxResult editDetailView(@RequestBody ArdAppTaskDetail ardAppTaskDetail) { return toAjax(ardAppTaskService.updateArdAppTaskDetailView(ardAppTaskDetail)); } /** * 获取app任务详情的详细信息 */ @ApiOperation("单兵端-任务点详情") @PreAuthorize("@ss.hasPermi('app:task:query')") @GetMapping(value = "/detail/{id}") public AjaxResult getTaskDetailInfo(@PathVariable("id") String id) { return success(ardAppTaskService.selectArdAppTaskDetailById(id)); } @ApiOperation("单兵端-新任务轮询") @PostMapping(value = "/newTaskPolling") public AjaxResult newTaskPolling(@RequestBody AppParam param) { Map map = new HashMap<>(); String userId = param.getUserId(); if (StringUtils.isNotNull(param.getUserId())) { ArdAppTask ardAppTask = ardAppTaskService.selectNewArdAppTaskByUserId(userId); map.put("task", ardAppTask); int count = ardAppTaskService.selectUnreadArdAppTaskCount(userId); map.put("count", count); } return success(map); } @ApiOperation("指挥端-模糊分页查询所有兴趣点") @PostMapping(value = "/likeWell") public AjaxResult likeWell(@RequestBody WellParam wellParam) { return success(ardAppTaskService.likeWell(wellParam)); } @ApiOperation("指挥端-查询树形组织架构") @PostMapping(value = "/treeDept") public AjaxResult treeDept() { //查询用户ID String usersId = SecurityUtils.getUserId(); //根据userId查询部门Id SysUser sysUser = sysUserService.selectUserById(usersId); //根据当前deptId或者当前及所属下级的所有deptId List deptList = sysDeptService.deptIdBySub(sysUser.getDeptId()); //查询所有部门信息 List sysDeptList = sysDeptService.allByUser(deptList); List deptUserTrees = new ArrayList<>(); for (int i = 0; i < sysDeptList.size(); i++) { SysDept sysDept = sysDeptList.get(i); DeptUserTree deptUserTree = new DeptUserTree(); deptUserTree.setAncestors(sysDept.getAncestors()); deptUserTree.setDeptId(sysDept.getDeptId()); deptUserTree.setDeptName(sysDept.getDeptName()); deptUserTree.setParentId(sysDept.getParentId()); deptUserTrees.add(deptUserTree); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("dept_id",sysDept.getDeptId()); List users = sysUserService.userByDept(sysDept.getDeptId()); for (int j = 0; j < users.size(); j++) { SysUser user = users.get(j); DeptUserTree deptUserTree1 = new DeptUserTree(); deptUserTree1.setDeptId(user.getDeptId()); deptUserTree1.setUserId(user.getUserId()); deptUserTree1.setNickName(user.getNickName()); deptUserTree1.setParentId(user.getDeptId()); deptUserTrees.add(deptUserTree1); } } return success(sysDeptService.deptUserTree(deptUserTrees)); } }