|
@@ -8,7 +8,9 @@ import com.jpsoft.smart.modules.common.dto.MessageResult;
|
|
|
import com.jpsoft.smart.modules.base.entity.DeviceInfo;
|
|
|
import com.jpsoft.smart.modules.base.service.DeviceInfoService;
|
|
|
import com.jpsoft.smart.modules.lapi.service.ILapiService;
|
|
|
+import com.jpsoft.smart.modules.sys.entity.User;
|
|
|
import com.jpsoft.smart.modules.sys.service.DataDictionaryService;
|
|
|
+import com.jpsoft.smart.modules.sys.service.UserService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
@@ -38,6 +40,9 @@ public class DeviceInfoController {
|
|
|
@Autowired
|
|
|
private ILapiService lapiService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
@ApiOperation(value="添加设备")
|
|
|
@PostMapping("add")
|
|
|
public MessageResult<DeviceInfo> add(@RequestBody DeviceInfo deviceInfo,@RequestAttribute String subject){
|
|
@@ -306,7 +311,23 @@ public class DeviceInfoController {
|
|
|
public MessageResult<List<DeviceInfo>> list(@RequestAttribute String subject) {
|
|
|
MessageResult<List<DeviceInfo>> msgResult = new MessageResult<>();
|
|
|
try {
|
|
|
- List<DeviceInfo> list = deviceInfoService.list();
|
|
|
+ List<DeviceInfo> list = new ArrayList<>();
|
|
|
+ //为公司管理员
|
|
|
+ boolean is_admin = userService.hasRole(subject,"ADMIN");
|
|
|
+ if(is_admin){
|
|
|
+ User user = userService.get(subject);
|
|
|
+ String companyId = user.getCompanyId();
|
|
|
+
|
|
|
+ List<DeviceInfo> deviceInfoList = deviceInfoService.findByCompanyId(companyId);
|
|
|
+ List<String> deviceIdList = new ArrayList<String>();
|
|
|
+ for (DeviceInfo deviceInfo:deviceInfoList) {
|
|
|
+ deviceIdList.add(deviceInfo.getId());
|
|
|
+ }
|
|
|
+ list = deviceInfoService.findByDeviceIdList(deviceIdList);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ list = deviceInfoService.list();
|
|
|
+ }
|
|
|
|
|
|
for (DeviceInfo deviceInfo:list) {
|
|
|
String typeN = dataDictionaryService.findParentId("ddf2ecbe-84a6-4f0d-a84f-2fc6917f5856",deviceInfo.getType());
|