Administrator
2023-08-05 8bafb39c563225acb1068a3b83462c33f4b3bab7
ard-work/src/main/java/com/ruoyi/app/patrolplan/controller/ArdAppPatrolplanController.java
@@ -1,7 +1,28 @@
package com.ruoyi.app.patrolplan.controller;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell;
import com.ruoyi.alarmpoints.well.service.IArdAlarmpointsWellService;
import com.ruoyi.app.patrolplan.domain.ArdAppPatrolpoint;
import com.ruoyi.app.patrolplan.service.IArdAppPatrolpointService;
import com.ruoyi.app.patrolplan.service.IArdAppPatroluserService;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.utils.result.Results;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jdk.nashorn.internal.ir.annotations.Reference;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@@ -29,21 +50,44 @@
 */
@RestController
@RequestMapping("/app/appPatrolplan")
@Api(tags = "app巡检计划")
public class ArdAppPatrolplanController extends BaseController
{
    @Autowired
    private IArdAppPatrolplanService ardAppPatrolplanService;
    @Resource
    IArdAppPatrolpointService ardAppPatrolpointService;
    @Resource
    IArdAppPatroluserService ardAppPatroluserService;
    @Resource
    ISysUserService sysUserService;
    @Resource
    ISysDeptService sysDeptService;
    @Resource
    IArdAlarmpointsWellService wellService;
    /**
     * 查询app巡检计划列表
     */
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArdAppPatrolplan ardAppPatrolplan)
    @ApiOperation("查询全部巡检列表及搜索筛选")
    public Results list(ArdAppPatrolplan ardAppPatrolplan)
    {
        startPage();
        if(ardAppPatrolplan.getPageNum()==null || ardAppPatrolplan.getPageNum() == 0){
            ardAppPatrolplan.setPageNum(1);
        }
        if(ardAppPatrolplan.getPageSize()==null || ardAppPatrolplan.getPageSize() == 0){
            ardAppPatrolplan.setPageSize(10);
        }
        PageHelper.startPage(ardAppPatrolplan.getPageNum(),ardAppPatrolplan.getPageSize());
        List<ArdAppPatrolplan> list = ardAppPatrolplanService.selectArdAppPatrolplanList(ardAppPatrolplan);
        return getDataTable(list);
        return Results.succeed(new PageInfo<>(list));
    }
    /**
@@ -52,6 +96,7 @@
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:export')")
    @Log(title = "app巡检计划", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出全部巡检列表")
    public void export(HttpServletResponse response, ArdAppPatrolplan ardAppPatrolplan)
    {
        List<ArdAppPatrolplan> list = ardAppPatrolplanService.selectArdAppPatrolplanList(ardAppPatrolplan);
@@ -60,24 +105,82 @@
    }
    /**
     * 获取app巡检计划详细信息
     * 根据巡检ID查询兴趣点
     */
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:query')")
    @GetMapping(value = "/{patroEndTime}")
    public AjaxResult getInfo(@PathVariable("patroEndTime") String patroEndTime)
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:wellByPlanId')")
    @GetMapping(value = "wellByPlanId/{id}")
    @ApiOperation("根据巡检ID查询兴趣点")
    public Results wellByPlanId(@PathVariable String id)
    {
        return success(ardAppPatrolplanService.selectArdAppPatrolplanByPatroEndTime(patroEndTime));
        return ardAppPatrolpointService.wellByPlanId(id);
    }
    /**
     * 新增app巡检计划
     * 根据巡检ID查询巡检人
     */
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:add')")
    @Log(title = "app巡检计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArdAppPatrolplan ardAppPatrolplan)
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:userByPlanId')")
    @GetMapping(value = "userByPlanId/{id}")
    @ApiOperation("根据巡检ID查询巡检人员")
    public Results userByPlanId(@PathVariable String id)
    {
        return toAjax(ardAppPatrolplanService.insertArdAppPatrolplan(ardAppPatrolplan));
        return ardAppPatroluserService.userByPlanId(id);
    }
    /**
     * 删除app巡检计划
     */
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:remove')")
    @Log(title = "app巡检计划", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    @ApiOperation("删除app巡检计划")
    //public Results remove(@PathVariable String id)
    public AjaxResult remove(@PathVariable String id)
    {
        //return ardAppPatrolplanService.deleteArdApp(id);
        return toAjax(ardAppPatrolplanService.deleteArdApp(id));
    }
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:allPlanUser')")
    @PostMapping("allPlanUser")
    @ApiOperation("查询权限下全部人员和兴趣点")
    public Results allPlanUser()
    {
        JSONObject jsonObject = new JSONObject();
        String userId = SecurityUtils.getUserId();
        //根据userId查询部门Id
        SysUser sysUser = sysUserService.selectUserById(userId);
        //根据当前deptId或者当前及所属下级的所有deptId
        List<Long> deptList = sysDeptService.deptIdBySub(sysUser.getDeptId());
        //根据deptId列表获取到所有用户
        List<SysUser> sysUserList = sysUserService.userByDeptList(deptList);
        jsonObject.put("user",sysUserList);
        //根据deptId列表获取到所有兴趣点
        List<ArdAlarmpointsWell> wellList = wellService.wellByDeptList(deptList);
        jsonObject.put("well",wellList);
        return Results.succeed(jsonObject);
    }
    /**
     * 新增app巡检计划及人员点位
     */
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:insertArdAppPatrolplan')")
    @Log(title = "app巡检计划", businessType = BusinessType.INSERT)
    @PostMapping("/insertArdAppPatrolplan")
    @ApiOperation("新增app巡检计划及人员点位")
    public AjaxResult addArdAppPatrolplan(@RequestBody Map<String,Object> para)
    {
        return toAjax(ardAppPatrolplanService.insertArdAppPatrolplan(para));
    }
    /**
     * 查询单条数据
     */
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:oneById')")
    @PostMapping("/oneById/{id}")
    @ApiOperation("查询单条数据")
    public Results oneById(@PathVariable String id)
    {
        return ardAppPatrolplanService.oneById(id);
    }
    /**
@@ -91,14 +194,5 @@
        return toAjax(ardAppPatrolplanService.updateArdAppPatrolplan(ardAppPatrolplan));
    }
    /**
     * 删除app巡检计划
     */
    @PreAuthorize("@ss.hasPermi('app:appPatrolplan:remove')")
    @Log(title = "app巡检计划", businessType = BusinessType.DELETE)
   @DeleteMapping("/{patroEndTimes}")
    public AjaxResult remove(@PathVariable String[] patroEndTimes)
    {
        return toAjax(ardAppPatrolplanService.deleteArdAppPatrolplanByPatroEndTimes(patroEndTimes));
    }
}