|
@@ -26,7 +26,6 @@ import com.zhongshu.card.server.core.domain.org.OrganizationUser;
|
|
|
import com.zhongshu.card.server.core.domain.org.UserAccount;
|
|
import com.zhongshu.card.server.core.domain.org.UserAccount;
|
|
|
import com.zhongshu.card.server.core.domain.projectAbout.OrgUserFace;
|
|
import com.zhongshu.card.server.core.domain.projectAbout.OrgUserFace;
|
|
|
import com.zhongshu.card.server.core.domain.school.CardInfo;
|
|
import com.zhongshu.card.server.core.domain.school.CardInfo;
|
|
|
-import com.zhongshu.card.server.core.event.DevicePermissChangeEvent;
|
|
|
|
|
import com.zhongshu.card.server.core.event.OrgUserBindUpdateSyncEvent;
|
|
import com.zhongshu.card.server.core.event.OrgUserBindUpdateSyncEvent;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
import com.zhongshu.card.server.core.service.projectAbout.CardInfoServiceImpl;
|
|
import com.zhongshu.card.server.core.service.projectAbout.CardInfoServiceImpl;
|
|
@@ -79,9 +78,6 @@ public class DevicePermissService extends SuperService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private OrganizationUserDao organizationUserDao;
|
|
private OrganizationUserDao organizationUserDao;
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
- ApplicationContext applicationContext;
|
|
|
|
|
-
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private OrgUserFaceService orgUserFaceService;
|
|
private OrgUserFaceService orgUserFaceService;
|
|
|
|
|
|
|
@@ -91,6 +87,9 @@ public class DevicePermissService extends SuperService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private DevicePermissEventService devicePermissEventService;
|
|
private DevicePermissEventService devicePermissEventService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DevicePermissIotService devicePermissIotService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 设备绑定用户
|
|
* 设备绑定用户
|
|
|
*
|
|
*
|
|
@@ -119,8 +118,9 @@ public class DevicePermissService extends SuperService {
|
|
|
// 机构用户数据
|
|
// 机构用户数据
|
|
|
List<OrganizationUser> orgUsers = organizationUserDao.findByIdIn(ids);
|
|
List<OrganizationUser> orgUsers = organizationUserDao.findByIdIn(ids);
|
|
|
if (ObjectUtils.isNotEmpty(orgUsers)) {
|
|
if (ObjectUtils.isNotEmpty(orgUsers)) {
|
|
|
|
|
+
|
|
|
|
|
+ List<DevicePermiss> permisses = new ArrayList<DevicePermiss>();
|
|
|
for (DeviceInfo deviceInfo : deviceInfos) {
|
|
for (DeviceInfo deviceInfo : deviceInfos) {
|
|
|
- List<DevicePermiss> permisses = new ArrayList<DevicePermiss>();
|
|
|
|
|
for (OrganizationUser organizationUser : orgUsers) {
|
|
for (OrganizationUser organizationUser : orgUsers) {
|
|
|
String userId = organizationUser.getUserId();
|
|
String userId = organizationUser.getUserId();
|
|
|
// 判断是否是编辑
|
|
// 判断是否是编辑
|
|
@@ -135,14 +135,11 @@ public class DevicePermissService extends SuperService {
|
|
|
buildOrgUserInfo(permiss, organizationUser);
|
|
buildOrgUserInfo(permiss, organizationUser);
|
|
|
permisses.add(permiss);
|
|
permisses.add(permiss);
|
|
|
}
|
|
}
|
|
|
- devicePermissDao.saveAll(permisses);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ devicePermissDao.saveAll(permisses);
|
|
|
|
|
+ // 下发设备权限增加数据
|
|
|
|
|
+ devicePermissIotService.changeDeviceUser(permisses.stream().map(it -> it.getId()).collect(Collectors.toList()), 1);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // 设备权限发生变化
|
|
|
|
|
- DevicePermissChangeEvent event = new DevicePermissChangeEvent(this,
|
|
|
|
|
- param.getDeviceIds(), projectOid);
|
|
|
|
|
- applicationContext.publishEvent(event);
|
|
|
|
|
}
|
|
}
|
|
|
return ResultContent.buildSuccess();
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
}
|
|
@@ -251,10 +248,10 @@ public class DevicePermissService extends SuperService {
|
|
|
devicePermissDao.save(entity);
|
|
devicePermissDao.save(entity);
|
|
|
if (dataState == DataState.Disable) {
|
|
if (dataState == DataState.Disable) {
|
|
|
// 移除权限
|
|
// 移除权限
|
|
|
- changeDeviceUser(List.of(id), 0);
|
|
|
|
|
|
|
+ devicePermissIotService.changeDeviceUser(List.of(id), 0);
|
|
|
} else {
|
|
} else {
|
|
|
// 启用
|
|
// 启用
|
|
|
- changeDeviceUser(List.of(id), 1);
|
|
|
|
|
|
|
+ devicePermissIotService.changeDeviceUser(List.of(id), 1);
|
|
|
}
|
|
}
|
|
|
return ResultContent.buildSuccess();
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
}
|
|
@@ -268,40 +265,13 @@ public class DevicePermissService extends SuperService {
|
|
|
public ResultContent deleteByIds(IDsParam param) {
|
|
public ResultContent deleteByIds(IDsParam param) {
|
|
|
if (ObjectUtils.isNotEmpty(param.getIds())) {
|
|
if (ObjectUtils.isNotEmpty(param.getIds())) {
|
|
|
// 1: 移除权限
|
|
// 1: 移除权限
|
|
|
- changeDeviceUser(param.getIds(), 0);
|
|
|
|
|
|
|
+ devicePermissIotService.changeDeviceUser(param.getIds(), 0);
|
|
|
// 2:删除数据
|
|
// 2:删除数据
|
|
|
devicePermissDao.deleteAllById(param.getIds());
|
|
devicePermissDao.deleteAllById(param.getIds());
|
|
|
}
|
|
}
|
|
|
return ResultContent.buildSuccess();
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 移除权限
|
|
|
|
|
- *
|
|
|
|
|
- * @param ids
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- public ResultContent changeDeviceUser(List<String> ids, int mark) {
|
|
|
|
|
- List<DevicePermiss> list = devicePermissDao.findByIdIn(ids);
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(list)) {
|
|
|
|
|
- Map<String, List<DevicePermiss>> map = list.stream().collect(Collectors.groupingBy(DevicePermiss::getGateWayId));
|
|
|
|
|
- map.forEach((gateWayId, tempList) -> {
|
|
|
|
|
- GateWayPermissModel gateWayPermissModel = new GateWayPermissModel();
|
|
|
|
|
- gateWayPermissModel.setGateWayId(gateWayId);
|
|
|
|
|
-
|
|
|
|
|
- List<DeviceAboutPermiss> devices = tempList.stream().map(it -> {
|
|
|
|
|
- DeviceAboutPermiss permiss = new DeviceAboutPermiss();
|
|
|
|
|
- permiss.setDeviceId(it.getDeviceId());
|
|
|
|
|
- permiss.addUser(it.getUserId());
|
|
|
|
|
- permiss.setMark(mark);
|
|
|
|
|
- return permiss;
|
|
|
|
|
- }).collect(Collectors.toUnmodifiableList());
|
|
|
|
|
- gateWayPermissModel.setDevices(devices);
|
|
|
|
|
- devicePermissEventService.requestDeviceBindData(gateWayPermissModel, tempList.get(0).getProjectOid());
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- return ResultContent.buildSuccess();
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 得到设备关联的用户
|
|
* 得到设备关联的用户
|