Browse Source

人员是否绑定设备列表
设备分页列表
添加管理员所属单位条件筛选

yanliming 5 năm trước cách đây
mục cha
commit
a147477758

+ 6 - 0
common/src/main/resources/mapper/base/DeviceInfo.xml

@@ -151,6 +151,12 @@ id_, header_,device_no,alias_name,address_,is_online,company_id,unlock_password,
 		]]>
 		<where>
 				and a.del_flag=false
+			<if test="searchParams.deviceIdList != null">
+				and a.id_ in
+				<foreach item="item" collection="searchParams.deviceIdList"  open="(" separator="," close=")">
+					#{item}
+				</foreach>
+			</if>
 			<if test="searchParams.aliasName != null">
 				and a.alias_name like #{searchParams.aliasName}
 			</if>

+ 16 - 0
web/src/main/java/com/jpsoft/smart/modules/base/controller/DeviceInfoController.java

@@ -256,6 +256,22 @@ public class DeviceInfoController {
         List<Sort> sortList = new ArrayList<>();
         sortList.add(new Sort("a.create_time","desc"));
 
+        //为公司管理员
+        boolean is_admin = userService.hasRole(subject,"ADMIN");
+        if(is_admin){
+            User user = userService.get(subject);
+            String userCompanyId = user.getCompanyId();
+
+            List<DeviceInfo> deviceInfoList = deviceInfoService.findByCompanyId(userCompanyId);
+            List<String> deviceIdList = new ArrayList<String>();
+            for (DeviceInfo deviceInfo:deviceInfoList) {
+                deviceIdList.add(deviceInfo.getId());
+            }
+
+            searchParams.put("deviceIdList",deviceIdList);
+        }
+
+
         if (StringUtils.isNotEmpty(aliasName)) {
             searchParams.put("aliasName","%" + aliasName + "%");
         }

+ 14 - 0
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonDeviceRelationController.java

@@ -444,6 +444,20 @@ public class PersonDeviceRelationController {
         List<Sort> sortList = new ArrayList<>();
         sortList.add(new Sort("create_time","desc"));
 
+        //为公司管理员
+        boolean is_admin = userService.hasRole(subject,"ADMIN");
+        if(is_admin){
+            String userCompanyId = user.getCompanyId();
+
+            List<DeviceInfo> deviceInfoList = deviceInfoService.findByCompanyId(userCompanyId);
+            List<String> deviceIdList = new ArrayList<String>();
+            for (DeviceInfo deviceInfo:deviceInfoList) {
+                deviceIdList.add(deviceInfo.getId());
+            }
+
+            searchParams.put("deviceIdList",deviceIdList);
+        }
+
         //searchParams.put("companyId",user.getCompanyId());
 
         Page<DeviceInfo> page = deviceInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);