|
|
@@ -19,6 +19,9 @@ import com.usky.meeting.repository.MeetingRoomRepository;
|
|
|
import com.usky.meeting.service.MeetingDeviceService;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
import com.usky.meeting.service.MeetingRoomService;
|
|
|
+import com.usky.meeting.service.vo.MeetingDeviceBindFacePersonQueryVO;
|
|
|
+import com.usky.meeting.service.vo.MeetingDeviceBindFacePersonVO;
|
|
|
+import com.usky.meeting.service.vo.MeetingDeviceBindPersonRequest;
|
|
|
import com.usky.meeting.service.vo.MeetingDeviceRequestVO;
|
|
|
import net.bytebuddy.implementation.bytecode.Throw;
|
|
|
import org.aspectj.weaver.patterns.ThisOrTargetAnnotationPointcut;
|
|
|
@@ -56,6 +59,10 @@ public class MeetingDeviceServiceImpl extends AbstractCrudService<MeetingDeviceM
|
|
|
private MeetingDeviceHeartbeatMapper heartbeatMapper;
|
|
|
@Autowired
|
|
|
private MeetingTemplateMapper meetingTemplateMapper;
|
|
|
+ @Autowired
|
|
|
+ private MeetingDevicePersonBindMapper meetingDevicePersonBindMapper;
|
|
|
+ @Autowired
|
|
|
+ private SysPersonMapper sysPersonMapper;
|
|
|
|
|
|
@Override
|
|
|
public CommonPage<MeetingDevice> meetingDeviceList(MeetingDeviceRequestVO requestVO) {
|
|
|
@@ -174,11 +181,54 @@ public class MeetingDeviceServiceImpl extends AbstractCrudService<MeetingDeviceM
|
|
|
MeetingDevice::getTemplateId,
|
|
|
buildIdMap(meetingTemplateList, MeetingTemplate::getId),
|
|
|
MeetingDevice::setMeetingTemplate);
|
|
|
+
|
|
|
+ // 5. 填充绑定人员
|
|
|
+ fillBindPerson(page.getRecords());
|
|
|
}
|
|
|
|
|
|
return new CommonPage<>(page.getRecords(), page.getTotal(), size, current);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据设备UUID集合查询 meeting_device_person_bind,将 person_id 按逗号拼接后写入 bindPerson
|
|
|
+ */
|
|
|
+ private void fillBindPerson(List<MeetingDevice> devices) {
|
|
|
+ if (CollectionUtils.isEmpty(devices)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Long> deviceUuids = devices.stream()
|
|
|
+ .map(MeetingDevice::getDeviceUuid)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (deviceUuids.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<MeetingDevicePersonBind> bindList = meetingDevicePersonBindMapper.selectByDeviceUuids(deviceUuids);
|
|
|
+ Map<Long, List<String>> devicePersonMap = new HashMap<>();
|
|
|
+ if (!CollectionUtils.isEmpty(bindList)) {
|
|
|
+ for (MeetingDevicePersonBind bind : bindList) {
|
|
|
+ if (bind.getDeviceUuid() == null || bind.getPersonId() == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ devicePersonMap
|
|
|
+ .computeIfAbsent(bind.getDeviceUuid(), k -> new ArrayList<>())
|
|
|
+ .add(String.valueOf(bind.getPersonId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (MeetingDevice device : devices) {
|
|
|
+ if (device == null || device.getDeviceUuid() == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<String> personIds = devicePersonMap.get(device.getDeviceUuid());
|
|
|
+ if (personIds != null && !personIds.isEmpty()) {
|
|
|
+ device.setBindPerson(String.join(",", personIds));
|
|
|
+ } else {
|
|
|
+ device.setBindPerson("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 构建ID到对象的Map,用于快速查找
|
|
|
* @param dataList 待处理的列表
|
|
|
@@ -286,6 +336,148 @@ public class MeetingDeviceServiceImpl extends AbstractCrudService<MeetingDeviceM
|
|
|
// remoteIotTaskService.deleteDeviceInfo(deviceId.toString());
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void bindPerson(MeetingDeviceBindPersonRequest request) {
|
|
|
+ if (request == null || request.getDeviceUuid() == null) {
|
|
|
+ throw new BusinessException("设备UUID不能为空");
|
|
|
+ }
|
|
|
+ Long deviceUuid = request.getDeviceUuid();
|
|
|
+ MeetingDevice device = this.getById(deviceUuid);
|
|
|
+ Optional.ofNullable(device).orElseThrow(() -> new BusinessException("会议设备信息不存在"));
|
|
|
+
|
|
|
+ // 覆盖式:先清空原有绑定
|
|
|
+ meetingDevicePersonBindMapper.deleteByDeviceUuid(deviceUuid);
|
|
|
+
|
|
|
+ String personIds = request.getPersonIds();
|
|
|
+ // 空字符串视为解除全部授权
|
|
|
+ if (!StringUtils.isNotBlank(personIds)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String[] personIdArr = personIds.split(",");
|
|
|
+ for (String personIdStr : personIdArr) {
|
|
|
+ if (!StringUtils.isNotBlank(personIdStr)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ MeetingDevicePersonBind bind = new MeetingDevicePersonBind();
|
|
|
+ bind.setDeviceUuid(deviceUuid);
|
|
|
+ bind.setPersonId(Integer.parseInt(personIdStr.trim()));
|
|
|
+ bind.setIsLoginNotify(0);
|
|
|
+ meetingDevicePersonBindMapper.insert(bind);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonPage<MeetingDeviceBindFacePersonVO> pageBindFacePersons(MeetingDeviceBindFacePersonQueryVO queryVO) {
|
|
|
+ Integer cur = queryVO.getCurrent();
|
|
|
+ Integer sz = queryVO.getSize();
|
|
|
+ IPage<SysPerson> page = new Page<>(cur, sz);
|
|
|
+
|
|
|
+ List<Long> deviceUuids = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotBlank(queryVO.getDeviceCode())) {
|
|
|
+ MeetingDevice tempDevice = deviceMapper.selectOne(Wrappers.<MeetingDevice>lambdaQuery()
|
|
|
+ .eq(MeetingDevice::getDeviceCode, queryVO.getDeviceCode()));
|
|
|
+ if (tempDevice == null) {
|
|
|
+ return new CommonPage<>(new ArrayList<>(), 0L, sz, cur);
|
|
|
+ }
|
|
|
+ MeetingDevice device = deviceMapper.selectOne(Wrappers.<MeetingDevice>lambdaQuery()
|
|
|
+ .eq(MeetingDevice::getDeviceCode, queryVO.getDeviceCode())
|
|
|
+ .eq(MeetingDevice::getTenantId, tempDevice.getTenantId()));
|
|
|
+ if (device == null || device.getDeviceUuid() == null) {
|
|
|
+ return new CommonPage<>(new ArrayList<>(), 0L, sz, cur);
|
|
|
+ }
|
|
|
+ deviceUuids.add(device.getDeviceUuid());
|
|
|
+ } else {
|
|
|
+ List<MeetingDevice> devices = deviceMapper.selectList(Wrappers.<MeetingDevice>lambdaQuery()
|
|
|
+ .eq(MeetingDevice::getTenantId, SecurityUtils.getTenantId()));
|
|
|
+ if (!CollectionUtils.isEmpty(devices)) {
|
|
|
+ for (MeetingDevice d : devices) {
|
|
|
+ if (d != null && d.getDeviceUuid() != null) {
|
|
|
+ deviceUuids.add(d.getDeviceUuid());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (deviceUuids.isEmpty()) {
|
|
|
+ return new CommonPage<>(new ArrayList<>(), 0L, sz, cur);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<MeetingDevicePersonBind> bindList = meetingDevicePersonBindMapper.selectByDeviceUuids(deviceUuids);
|
|
|
+ LinkedHashSet<Integer> personIdSet = new LinkedHashSet<>();
|
|
|
+ if (!CollectionUtils.isEmpty(bindList)) {
|
|
|
+ for (MeetingDevicePersonBind b : bindList) {
|
|
|
+ if (b.getPersonId() != null) {
|
|
|
+ personIdSet.add(b.getPersonId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (personIdSet.isEmpty()) {
|
|
|
+ return new CommonPage<>(new ArrayList<>(), 0L, sz, cur);
|
|
|
+ }
|
|
|
+ List<Integer> personIds = new ArrayList<>(personIdSet);
|
|
|
+
|
|
|
+ LambdaQueryWrapper<SysPerson> personWrapper = Wrappers.lambdaQuery();
|
|
|
+ personWrapper.in(SysPerson::getId, personIds);
|
|
|
+ if (StringUtils.isNotBlank(queryVO.getFullName())) {
|
|
|
+ personWrapper.like(SysPerson::getFullName, queryVO.getFullName());
|
|
|
+ }
|
|
|
+ Integer faceStatusFilter = queryVO.getFaceStatus();
|
|
|
+ if (faceStatusFilter != null) {
|
|
|
+ personWrapper.eq(SysPerson::getFaceStatus, faceStatusFilter.byteValue());
|
|
|
+ }
|
|
|
+ personWrapper.orderByAsc(SysPerson::getId);
|
|
|
+ page = sysPersonMapper.selectPage(page, personWrapper);
|
|
|
+
|
|
|
+ List<SysPerson> records = page.getRecords();
|
|
|
+ List<Integer> pagePersonIds = new ArrayList<>();
|
|
|
+ for (SysPerson p : records) {
|
|
|
+ if (p != null && p.getId() != null) {
|
|
|
+ pagePersonIds.add(p.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<Integer, Long> personUserIdMap = buildPersonUserIdMap(pagePersonIds);
|
|
|
+ List<MeetingDeviceBindFacePersonVO> rows = new ArrayList<>(records.size());
|
|
|
+ for (SysPerson p : records) {
|
|
|
+ MeetingDeviceBindFacePersonVO vo = new MeetingDeviceBindFacePersonVO();
|
|
|
+ vo.setId(p.getId());
|
|
|
+ vo.setUserId(personUserIdMap.get(p.getId()));
|
|
|
+ vo.setFullName(p.getFullName());
|
|
|
+ vo.setAge(p.getAge());
|
|
|
+ vo.setGender(p.getGender());
|
|
|
+ vo.setLinkPhone(p.getLinkPhone());
|
|
|
+ vo.setFaceBase(p.getFaceBase());
|
|
|
+ vo.setVefNum(p.getVefNum());
|
|
|
+ vo.setFaceStatus(p.getFaceStatus());
|
|
|
+ vo.setCardNum(p.getCardNum());
|
|
|
+ rows.add(vo);
|
|
|
+ }
|
|
|
+ return new CommonPage<>(rows, page.getTotal(), sz, cur);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<Integer, Long> buildPersonUserIdMap(List<Integer> personIds) {
|
|
|
+ Map<Integer, Long> map = new HashMap<>();
|
|
|
+ if (CollectionUtils.isEmpty(personIds)) {
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> rows = sysPersonMapper.selectUserIdsByPersonIds(personIds);
|
|
|
+ if (CollectionUtils.isEmpty(rows)) {
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ for (Map<String, Object> row : rows) {
|
|
|
+ if (row == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Object personIdObj = row.get("personId");
|
|
|
+ Object userIdObj = row.get("userId");
|
|
|
+ if (personIdObj == null || userIdObj == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ map.put(Integer.valueOf(personIdObj.toString()), Long.valueOf(userIdObj.toString()));
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
public boolean checkNameUnique(MeetingDevice meetingDevice) {
|
|
|
Long deviceId = null == meetingDevice.getDeviceUuid() ? -1 : meetingDevice.getDeviceUuid();
|
|
|
LambdaQueryWrapper<MeetingDevice> queryWrapper = Wrappers.lambdaQuery();
|