|
@@ -3,13 +3,10 @@ package com.jpsoft.smart.modules.base.controller;
|
|
|
import com.github.pagehelper.Page;
|
|
|
import com.jpsoft.smart.modules.base.dto.CompanyInfoDTO;
|
|
|
import com.jpsoft.smart.modules.base.entity.*;
|
|
|
-import com.jpsoft.smart.modules.base.service.CompanyDeviceRelationService;
|
|
|
-import com.jpsoft.smart.modules.base.service.CompanyPositionService;
|
|
|
-import com.jpsoft.smart.modules.base.service.PersonInfoService;
|
|
|
+import com.jpsoft.smart.modules.base.service.*;
|
|
|
import com.jpsoft.smart.modules.common.utils.PojoUtils;
|
|
|
import com.jpsoft.smart.modules.common.dto.Sort;
|
|
|
import com.jpsoft.smart.modules.common.dto.MessageResult;
|
|
|
-import com.jpsoft.smart.modules.base.service.CompanyInfoService;
|
|
|
import com.jpsoft.smart.modules.sys.entity.User;
|
|
|
import com.jpsoft.smart.modules.sys.service.UserService;
|
|
|
import com.rabbitmq.client.AMQP;
|
|
@@ -52,6 +49,9 @@ public class CompanyInfoController {
|
|
|
@Autowired
|
|
|
private CompanyDeviceRelationService companyDeviceRelationService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DeviceInfoService deviceInfoService;
|
|
|
+
|
|
|
@ApiOperation(value="创建空记录")
|
|
|
@GetMapping("create")
|
|
|
public MessageResult<CompanyInfoDTO> create(){
|
|
@@ -376,13 +376,54 @@ public class CompanyInfoController {
|
|
|
}
|
|
|
|
|
|
@GetMapping("queryBindDeviceList")
|
|
|
- public MessageResult<List> queryBindDeviceList(String companyId){
|
|
|
- MessageResult<List> messageResult = new MessageResult<>();
|
|
|
+ public MessageResult<Map> queryBindDeviceList(String companyId,
|
|
|
+ @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
+ @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
+ @RequestAttribute String subject){
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
- List<DeviceInfo> deviceList = companyDeviceRelationService.findDeviceByCompanyId(companyId);
|
|
|
+ User user = userService.get(subject);
|
|
|
+
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
+
|
|
|
+ if(!userService.hasRole(user.getId(),"SYSADMIN")) {
|
|
|
+ searchParams.put("bindCompanyId",user.getCompanyId());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Sort> sorts = new ArrayList<>();
|
|
|
+ sorts.add(new Sort("create_time","asc"));
|
|
|
+
|
|
|
+ //设备列表
|
|
|
+ Page<DeviceInfo> deviceInfoPage = deviceInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sorts);
|
|
|
+
|
|
|
+ //查询已绑定设备
|
|
|
+ List<DeviceInfo> bindDeviceList = companyDeviceRelationService.findDeviceByCompanyId(companyId);
|
|
|
+
|
|
|
+ List<Map> mapList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (DeviceInfo deviceInfo : deviceInfoPage) {
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+
|
|
|
+ map.put("device",deviceInfo);
|
|
|
+
|
|
|
+ long count = bindDeviceList.stream().filter((d)->d.getId().equals(deviceInfo.getId())).count();
|
|
|
+
|
|
|
+ if (count>0){
|
|
|
+ map.put("bound",true);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ map.put("bound",false);
|
|
|
+ }
|
|
|
+
|
|
|
+ mapList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String,Object> dataMap = PojoUtils.pageWrapper(deviceInfoPage);
|
|
|
+
|
|
|
+ dataMap.put("data",mapList);
|
|
|
|
|
|
- messageResult.setData(deviceList);
|
|
|
+ messageResult.setData(dataMap);
|
|
|
messageResult.setResult(true);
|
|
|
}
|
|
|
catch (Exception ex){
|