feat(sis): 电梯授权增加楼层选择功能
This commit is contained in:
parent
800a2de30f
commit
b95f99532f
@ -35,7 +35,7 @@ public class SisElevatorFloorRef extends TenantEntity {
|
||||
/**
|
||||
* 楼层层数
|
||||
*/
|
||||
private Long floorNum;
|
||||
private Long floorId;
|
||||
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 授权记录业务对象 sis_auth_record
|
||||
@ -38,5 +38,5 @@ public class SisAuthRecordBo extends BaseEntity {
|
||||
* 授权设备idList
|
||||
*/
|
||||
@NotEmpty(message = "授权设备idList不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Collection<Long> deviceIds;
|
||||
private List<List<Long>> deviceIds;
|
||||
}
|
||||
|
@ -38,7 +38,9 @@ public class SisElevatorFloorRefBo extends BaseEntity {
|
||||
* 楼层层数
|
||||
*/
|
||||
@NotEmpty(message = "楼层层数不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Collection<Long> floorNums;
|
||||
private Collection<Long> floorIds;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -38,10 +38,10 @@ public class SisElevatorFloorRefVo implements Serializable {
|
||||
private Long elevatorId;
|
||||
|
||||
/**
|
||||
* 楼层层数
|
||||
* 楼层id
|
||||
*/
|
||||
@ExcelProperty(value = "楼层层数")
|
||||
private Long floorNum;
|
||||
@ExcelProperty(value = "楼层id")
|
||||
private Long floorId;
|
||||
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.dromara.sis.sdk.hik.HCNetSDK.*;
|
||||
|
||||
@ -356,11 +357,11 @@ public class HikAlarmCallBack implements HCNetSDK.FMSGCallBack_V31 {
|
||||
// 获取电梯⇄楼层关联信息
|
||||
List<SisElevatorFloorRefVo> floorRefList = elevatorFloorRefService.queryByElevatorId(deviceId);
|
||||
// 获取楼层数组
|
||||
List<Long> layerArray = floorInfo.stream().map(RemoteFloorVo::getFloorNumber).sorted().toList();
|
||||
List<Long> layerArray = floorInfo.stream().map(RemoteFloorVo::getId).sorted().toList();
|
||||
|
||||
layerArray.forEach(layer -> {
|
||||
SisElevatorFloorRefVo floorRef = floorRefList.stream()
|
||||
.filter(vo -> vo.getFloorNum().intValue() == layer) // 直接使用 layer
|
||||
.filter(vo -> Objects.equals(vo.getFloorId(), layer)) // 直接使用 layer
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (floorRef == null) {
|
||||
|
@ -15,10 +15,12 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.property.api.RemoteFloorService;
|
||||
import org.dromara.property.api.domain.vo.RemoteFloorVo;
|
||||
import org.dromara.sis.domain.bo.SisAccessControlBo;
|
||||
import org.dromara.sis.domain.bo.SisElevatorFloorRefBo;
|
||||
import org.dromara.sis.domain.bo.SisElevatorInfoBo;
|
||||
import org.dromara.sis.domain.vo.SisAccessControlVo;
|
||||
import org.dromara.sis.domain.vo.SisElevatorInfoVo;
|
||||
import org.dromara.sis.service.ISisAccessControlService;
|
||||
import org.dromara.sis.service.ISisElevatorFloorRefService;
|
||||
import org.dromara.sis.service.ISisElevatorInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.sis.domain.bo.SisAuthRecordBo;
|
||||
@ -46,6 +48,7 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
|
||||
private final SisAuthRecordMapper baseMapper;
|
||||
|
||||
private final ISisElevatorFloorRefService elevatorFloorRefService;
|
||||
private final ISisAccessControlService accessControlService;
|
||||
private final ISisElevatorInfoService elevatorInfoService;
|
||||
|
||||
@ -113,11 +116,18 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
// 每次授权先删除上一次授权信息
|
||||
deleteByLibId(bo.getLibId());
|
||||
|
||||
//取出需要授权的门禁id、电梯id、楼层id
|
||||
List<Long> acIds = bo.getDeviceIds().get(0);
|
||||
List<Long> eleIds = bo.getDeviceIds().get(1);
|
||||
List<Long> floorIds = bo.getDeviceIds().get(2);
|
||||
|
||||
// 过滤不是设备的节点数据
|
||||
// 门禁设备
|
||||
List<SisAccessControlVo> acVoList = accessControlService.queryListByIds(bo.getDeviceIds());
|
||||
List<SisAccessControlVo> acVoList = accessControlService.queryListByIds(acIds);
|
||||
// 电梯设备
|
||||
List<SisElevatorInfoVo> eleVoList = elevatorInfoService.queryListByIds(bo.getDeviceIds());
|
||||
List<SisElevatorInfoVo> eleVoList = elevatorInfoService.queryListByIds(eleIds);
|
||||
// 楼层信息
|
||||
|
||||
if (CollUtil.isEmpty(acVoList) || CollUtil.isEmpty(eleVoList)) {
|
||||
return false;
|
||||
}
|
||||
@ -139,12 +149,24 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
log.info("开始写入电梯授权记录,eleIds:{}", eleVoList);
|
||||
for (SisElevatorInfoVo ele : eleVoList) {
|
||||
SisAuthRecord authRecord = new SisAuthRecord();
|
||||
SisElevatorFloorRefBo refBo = new SisElevatorFloorRefBo();
|
||||
|
||||
authRecord.setDeviceType(2);
|
||||
authRecord.setLibId(bo.getLibId());
|
||||
authRecord.setDeviceId(ele.getElevatorId());
|
||||
flag = baseMapper.insert(authRecord) > 0;
|
||||
Assert.isTrue(flag, "写入电梯授权记录失败!");
|
||||
|
||||
log.info("开始写入电梯⇄楼层关联关系");
|
||||
// 获取该电梯所在单元的楼层信息
|
||||
List<RemoteFloorVo> floorVoList = remoteFloorService.queryByUnitId(ele.getUnitId());
|
||||
// 该单元所有楼层id
|
||||
List<Long> allFloors = floorVoList.stream().map(RemoteFloorVo::getId).toList();
|
||||
// 对比找出授权楼层id
|
||||
List<Long> authFloors = floorIds.stream().filter(allFloors::contains).toList();
|
||||
refBo.setElevatorId(ele.getElevatorId());
|
||||
refBo.setFloorIds(authFloors);
|
||||
elevatorFloorRefService.insertByBo(refBo);
|
||||
}
|
||||
log.info("写入电梯授权记录完成");
|
||||
|
||||
@ -224,21 +246,21 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
root.setLevel(0);
|
||||
root.setCode(0L);
|
||||
root.setParentCode(-1L);
|
||||
root.setLabel("授权设备");
|
||||
root.setTitle("授权设备");
|
||||
|
||||
// 创建门禁设备父节点
|
||||
TreeNode<Long> accessNode = new TreeNode<>();
|
||||
accessNode.setLevel(1);
|
||||
accessNode.setCode(1L);
|
||||
accessNode.setParentCode(0L);
|
||||
accessNode.setLabel("门禁设备");
|
||||
accessNode.setTitle("门禁设备");
|
||||
|
||||
// 创建电梯父节点
|
||||
TreeNode<Long> elevatorNode = new TreeNode<>();
|
||||
elevatorNode.setLevel(1);
|
||||
elevatorNode.setCode(2L);
|
||||
elevatorNode.setParentCode(0L);
|
||||
elevatorNode.setLabel("电梯设备");
|
||||
elevatorNode.setTitle("电梯设备");
|
||||
|
||||
|
||||
List<SisAccessControlVo> acVoList = accessControlService.queryList(new SisAccessControlBo());
|
||||
@ -250,7 +272,8 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
node.setLevel(2);
|
||||
node.setCode(item.getId());
|
||||
node.setParentCode(1L);
|
||||
node.setLabel(item.getAccessName());
|
||||
node.setLabel("accessControl");
|
||||
node.setTitle(item.getAccessName());
|
||||
return node;
|
||||
}).toList();
|
||||
|
||||
@ -260,8 +283,9 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
TreeNode<Long> eleNode = new TreeNode<>();
|
||||
eleNode.setLevel(2);
|
||||
eleNode.setParentCode(2L);
|
||||
eleNode.setLabel("elevator");
|
||||
eleNode.setCode(item.getElevatorId());
|
||||
eleNode.setLabel(item.getElevatorName());
|
||||
eleNode.setTitle(item.getElevatorName());
|
||||
|
||||
// 楼层节点
|
||||
List<TreeNode<Long>> floorTree = new ArrayList<>();
|
||||
@ -270,8 +294,9 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
floorInfoList.forEach(floor -> {
|
||||
TreeNode<Long> floorNode = new TreeNode<>();
|
||||
floorNode.setLevel(3);
|
||||
floorNode.setLabel("floor");
|
||||
floorNode.setCode(floor.getId());
|
||||
floorNode.setLabel(floor.getFloorName());
|
||||
floorNode.setTitle(floor.getFloorName());
|
||||
floorNode.setParentCode(item.getElevatorId());
|
||||
floorTree.add(floorNode);
|
||||
});
|
||||
|
@ -94,9 +94,9 @@ public class SisElevatorFloorRefServiceImpl implements ISisElevatorFloorRefServi
|
||||
baseMapper.deleteByIds(ids);
|
||||
|
||||
boolean flag = false;
|
||||
for (Long num : bo.getFloorNums()){
|
||||
for (Long num : bo.getFloorIds()){
|
||||
SisElevatorFloorRef add = new SisElevatorFloorRef();
|
||||
add.setFloorNum(num);
|
||||
add.setFloorId(num);
|
||||
add.setElevatorId(bo.getElevatorId());
|
||||
flag = baseMapper.insert(add) > 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user