Browse Source

fix 按区域权限查询数据

459242451@qq.com 2 years ago
parent
commit
837972ed7a

+ 9 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlIncidentController.java

@@ -47,7 +47,6 @@ public class TlIncidentController extends BaseController {
      */
     @GetMapping("/list")
     public TableDataInfo list(TlIncident tlIncident) {
-        startPage();
         // 根据当前用户角色,如果是巡检员的话,则只查询自己的
         // 如果是巡检员管理员的话,查询接收人是自己的
         Set<String> roleSet = sysRoleService.selectRolePermissionByUserId(getUserId());
@@ -56,6 +55,7 @@ public class TlIncidentController extends BaseController {
         } else if (roleSet.contains("xun_manage")) {
             tlIncident.setAcceptUser(getUsername());
         }
+        startPage();
         List<TlIncident> list = tlIncidentService.selectTlIncidentList(tlIncident);
         return getDataTable(list);
     }
@@ -86,6 +86,14 @@ public class TlIncidentController extends BaseController {
     @Log(title = "巡检事件管理", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, TlIncident tlIncident) {
+        // 根据当前用户角色,如果是巡检员的话,则只查询自己的
+        // 如果是巡检员管理员的话,查询接收人是自己的
+        Set<String> roleSet = sysRoleService.selectRolePermissionByUserId(getUserId());
+        if (roleSet.contains("xun")) {
+            tlIncident.setCreateBy(getUsername());
+        } else if (roleSet.contains("xun_manage")) {
+            tlIncident.setAcceptUser(getUsername());
+        }
         List<TlIncident> list = tlIncidentService.selectTlIncidentList(tlIncident);
         ExcelUtil<TlIncident> util = new ExcelUtil<TlIncident>(TlIncident.class);
         util.exportExcel(response, list, "巡检事件管理数据");

+ 6 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlInspectionDeviceController.java

@@ -8,6 +8,7 @@ import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.qdtl.domain.TlInspectionDevice;
 import com.ruoyi.qdtl.service.ITlInspectionDeviceService;
+import com.ruoyi.system.service.ISysRoleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -20,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
+import java.util.Set;
 
 /**
  * 巡检设备管理Controller
@@ -32,12 +34,16 @@ import java.util.List;
 public class TlInspectionDeviceController extends BaseController {
     @Autowired
     private ITlInspectionDeviceService tlInspectionDeviceService;
+    @Autowired
+    private ISysRoleService sysRoleService;
 
     /**
      * 查询巡检设备管理列表
      */
     @GetMapping("/list")
     public TableDataInfo list(TlInspectionDevice tlInspectionDevice) {
+        Set<String> roleSet = sysRoleService.selectRolePermissionByUserId(getUserId());
+        tlInspectionDevice.setAreaIds(roleSet);
         startPage();
         List<TlInspectionDevice> list = tlInspectionDeviceService.selectTlInspectionDeviceList(tlInspectionDevice);
         return getDataTable(list);

+ 6 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlInspectionLocationController.java

@@ -14,6 +14,7 @@ import com.ruoyi.qdtl.domain.TlInspectionLocation;
 import com.ruoyi.qdtl.service.ITlAreaService;
 import com.ruoyi.qdtl.service.ITlInspectionDeviceService;
 import com.ruoyi.qdtl.service.ITlInspectionLocationService;
+import com.ruoyi.system.service.ISysRoleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -28,6 +29,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -45,12 +47,16 @@ public class TlInspectionLocationController extends BaseController {
     private ITlInspectionDeviceService tlInspectionDeviceService;
     @Autowired
     private ITlAreaService tlAreaService;
+    @Autowired
+    private ISysRoleService sysRoleService;
 
     /**
      * 查询巡检点管理列表
      */
     @GetMapping("/list")
     public TableDataInfo list(TlInspectionLocation tlInspectionLocation) {
+        Set<String> roleSet = sysRoleService.selectRolePermissionByUserId(getUserId());
+        tlInspectionLocation.setAreaIds(roleSet);
         startPage();
         List<TlInspectionLocation> list = tlInspectionLocationService.selectTlInspectionLocationList(tlInspectionLocation);
         // 查询区域数据

+ 12 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/domain/TlInspectionDevice.java

@@ -5,6 +5,8 @@ import com.ruoyi.common.core.domain.BaseEntity;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 
+import java.util.Set;
+
 /**
  * 巡检设备管理对象 tl_inspection_device
  *
@@ -49,6 +51,8 @@ public class TlInspectionDevice extends BaseEntity {
     @Excel(name = "所属区域")
     private Long areaId;
 
+    private Set<String> areaIds;
+
     /**
      * 删除标志(0代表存在 2代表删除)
      */
@@ -147,4 +151,12 @@ public class TlInspectionDevice extends BaseEntity {
     public void setVersion(Integer version) {
         this.version = version;
     }
+
+    public Set<String> getAreaIds() {
+        return areaIds;
+    }
+
+    public void setAreaIds(Set<String> areaIds) {
+        this.areaIds = areaIds;
+    }
 }

+ 11 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/domain/TlInspectionLocation.java

@@ -6,6 +6,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 
 import java.util.List;
+import java.util.Set;
 
 /**
  * 巡检点管理对象 tl_inspection_location
@@ -57,6 +58,8 @@ public class TlInspectionLocation extends BaseEntity {
     @Excel(name = "所属区域")
     private Long areaId;
 
+    private Set<String> areaIds;
+
     private String areaName;
 
     /**
@@ -233,4 +236,12 @@ public class TlInspectionLocation extends BaseEntity {
     public void setPic(String pic) {
         this.pic = pic;
     }
+
+    public Set<String> getAreaIds() {
+        return areaIds;
+    }
+
+    public void setAreaIds(Set<String> areaIds) {
+        this.areaIds = areaIds;
+    }
 }

+ 1 - 0
ruoyi-system/src/main/resources/mapper/qdtl/TlIncidentMapper.xml

@@ -66,6 +66,7 @@
             <if test="dealUserName != null  and dealUserName != ''">and deal_user_name like concat('%', #{dealUserName}, '%')</if>
             <if test="dealTime != null ">and deal_time = #{dealTime}</if>
         </where>
+        order by happen_time desc
     </select>
 
     <select id="selectTlIncidentById" parameterType="Long" resultMap="TlIncidentResult">

+ 6 - 0
ruoyi-system/src/main/resources/mapper/qdtl/TlInspectionDeviceMapper.xml

@@ -46,6 +46,12 @@
             <if test="deviceName != null  and deviceName != ''">and device_name like concat('%', #{deviceName}, '%')</if>
             <if test="deviceType != null  and deviceType != ''">and device_type = #{deviceType}</if>
             <if test="areaId != null ">and area_id = #{areaId}</if>
+            <if test="areaIds != null and areaIds.size()>0">
+                and area_id in
+                <foreach item="item" index="index" collection="areaIds" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
             and del_flag = '0'
         </where>
         order by create_time desc

+ 6 - 0
ruoyi-system/src/main/resources/mapper/qdtl/TlInspectionLocationMapper.xml

@@ -49,6 +49,12 @@
             <if test="locationCode != null  and locationCode != ''">and location_code like concat('%', #{locationCode}, '%')</if>
             <if test="locationName != null  and locationName != ''">and location_name like concat('%', #{locationName}, '%')</if>
             <if test="areaId != null ">and area_id = #{areaId}</if>
+            <if test="areaIds != null and areaIds.size()>0">
+                and area_id in
+                <foreach item="item" index="index" collection="areaIds" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
         </where>
         order by create_time desc
     </select>