aijinhui
2023-08-31 6e54b432ab969eccb47b0aa388b95bf14e398790
ard-work/src/main/java/com/ruoyi/alarmpoints/well/controller/ArdAlarmpointsWellController.java
@@ -3,11 +3,23 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell;
import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWellParam;
import com.ruoyi.alarmpoints.well.service.IArdAlarmpointsWellService;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@@ -23,6 +35,7 @@
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -41,6 +54,12 @@
    @Resource
    private IArdAlarmpointsWellService ardAlarmpointsWellService;
    @Autowired
    private ISysUserService sysUserService;
    @Autowired
    private ISysDeptService sysDeptService;
    /**
     * 查询井管理列表
     */
@@ -53,6 +72,13 @@
        return getDataTable(list);
    }
    @PreAuthorize("@ss.hasPermi('alarmpoints:well:list')")
    @GetMapping("/nonPageList")
    @ApiOperation("查询井列表-不分页")
    public AjaxResult nonPageList(ArdAlarmpointsWell ardAlarmpointsWell) {
        List<ArdAlarmpointsWell> list = ardAlarmpointsWellService.selectArdAlarmpointsWellList(ardAlarmpointsWell);
        return success(list);
    }
    /**
     * 导出井管理列表
     */
@@ -84,7 +110,11 @@
    @PostMapping
    @ApiOperation("新增井")
    public AjaxResult add(@RequestBody ArdAlarmpointsWell ardAlarmpointsWell) {
        return toAjax(ardAlarmpointsWellService.insertArdAlarmpointsWell(ardAlarmpointsWell));
        try {
            return toAjax(ardAlarmpointsWellService.insertArdAlarmpointsWell(ardAlarmpointsWell));
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
    }
    /**
@@ -95,7 +125,11 @@
    @PutMapping
    @ApiOperation("修改井")
    public AjaxResult edit(@RequestBody ArdAlarmpointsWell ardAlarmpointsWell) {
        try {
        return toAjax(ardAlarmpointsWellService.updateArdAlarmpointsWell(ardAlarmpointsWell));
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
    }
    /**
@@ -145,4 +179,38 @@
        }
        return options;
    }
    @GetMapping("/wellById/{id}")
    @ApiOperation("查询单条兴趣点")
    public Results wellById(@PathVariable String id) {
        return Results.succeed(ardAlarmpointsWellService.wellById(id));
    }
    @PostMapping("/wellList")
    @ApiOperation("查询权限下所有兴趣点")
    public Results wellList(){
        String usersId = SecurityUtils.getUserId();
        //根据userId查询部门Id
        SysUser sysUser = sysUserService.selectUserById(usersId);
        //根据当前deptId或者当前及所属下级的所有deptId
        List<Long> deptList = sysDeptService.deptIdBySub(sysUser.getDeptId());
        //根据deptId获取对应兴趣点数据
        List<ArdAlarmpointsWell> list = ardAlarmpointsWellService.wellList(deptList);
        return Results.succeed(list);
    }
    @PostMapping("/conditionList")
    @ApiOperation("查询并筛选权限下所有兴趣点")
    public Results conditionList(ArdAlarmpointsWellParam ardAlarmpointsWellParam){
        String usersId = SecurityUtils.getUserId();
        //根据userId查询部门Id
        SysUser sysUser = sysUserService.selectUserById(usersId);
        //根据当前deptId或者当前及所属下级的所有deptId
        List<Long> deptList = sysDeptService.deptIdBySub(sysUser.getDeptId());
        ardAlarmpointsWellParam.setDeptList(deptList);
        //根据deptId获取对应兴趣点数据
        return Results.succeed(ardAlarmpointsWellService.conditionList(ardAlarmpointsWellParam));
    }
}