|
@@ -106,24 +106,27 @@ public class EgDeviceServiceImpl extends AbstractCrudService<EgDeviceMapper, EgD
|
|
|
long userId = SecurityUtils.getUserId();
|
|
|
//人员设备权限校验,校验通过,可以下发命令控制设备
|
|
|
Integer fid = baseMapper.getMeetingFaceData(userId);
|
|
|
- if(fid == null){
|
|
|
- throw new BusinessException("人脸卡号信息未注册");
|
|
|
- }
|
|
|
+// if(fid == null){
|
|
|
+// throw new BusinessException("人脸卡号信息未注册");
|
|
|
+// }
|
|
|
Integer[] deviceFid = baseMapper.getMeetingFaceDeviceList(fid);
|
|
|
- if(deviceFid.length == 0){
|
|
|
- throw new BusinessException("人员未绑定设备,请检查");
|
|
|
- }
|
|
|
+// if(deviceFid.length == 0){
|
|
|
+// throw new BusinessException("人员未绑定设备,请检查");
|
|
|
+// }
|
|
|
|
|
|
IPage<EgDevice> page = new Page<>(requestVO.getCurrent(),requestVO.getSize());
|
|
|
- LambdaQueryWrapper<EgDevice> queryWrapper = Wrappers.lambdaQuery();
|
|
|
- queryWrapper.like(StringUtils.isNotBlank(requestVO.getDeviceName()),EgDevice::getDeviceName,requestVO.getDeviceName())
|
|
|
- .like(StringUtils.isNotBlank(requestVO.getInstallAddress()),EgDevice::getInstallAddress,requestVO.getInstallAddress())
|
|
|
- .eq(null != requestVO.getServiceStatus(),EgDevice::getServiceStatus,requestVO.getServiceStatus())
|
|
|
- .eq(null != requestVO.getId(),EgDevice::getId,requestVO.getId())
|
|
|
- .in(EgDevice::getId,deviceFid)
|
|
|
- .eq(EgDevice::getTenantId,SecurityUtils.getTenantId())
|
|
|
- .orderByDesc(EgDevice::getId);
|
|
|
- page = this.page(page,queryWrapper);
|
|
|
+ if(deviceFid.length > 0){
|
|
|
+ LambdaQueryWrapper<EgDevice> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.like(StringUtils.isNotBlank(requestVO.getDeviceName()),EgDevice::getDeviceName,requestVO.getDeviceName())
|
|
|
+ .like(StringUtils.isNotBlank(requestVO.getInstallAddress()),EgDevice::getInstallAddress,requestVO.getInstallAddress())
|
|
|
+ .eq(null != requestVO.getServiceStatus(),EgDevice::getServiceStatus,requestVO.getServiceStatus())
|
|
|
+ .eq(null != requestVO.getId(),EgDevice::getId,requestVO.getId())
|
|
|
+ .in(EgDevice::getId,deviceFid)
|
|
|
+ .eq(EgDevice::getTenantId,SecurityUtils.getTenantId())
|
|
|
+ .orderByDesc(EgDevice::getId);
|
|
|
+ page = this.page(page,queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
return new CommonPage<>(page.getRecords(),page.getTotal(),requestVO.getSize(),requestVO.getCurrent());
|
|
|
}
|
|
@@ -133,6 +136,9 @@ public class EgDeviceServiceImpl extends AbstractCrudService<EgDeviceMapper, EgD
|
|
|
if(checkNameUnique(egDevice)){
|
|
|
throw new BusinessException("新增门禁门号设备'"+egDevice.getDeviceId()+","+egDevice.getEgNumber()+"'失败,设备已存在");
|
|
|
}
|
|
|
+ if(checkDeviceNameUnique(egDevice)){
|
|
|
+ throw new BusinessException("新增门禁设备'"+egDevice.getDeviceName()+"'失败,设备已存在");
|
|
|
+ }
|
|
|
|
|
|
egDevice.setDeviceUuid(UUIDUtils.uuid());
|
|
|
egDevice.setCreateBy(SecurityUtils.getUsername());
|
|
@@ -155,10 +161,18 @@ public class EgDeviceServiceImpl extends AbstractCrudService<EgDeviceMapper, EgD
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void update(EgDevice egDevice){
|
|
|
+ public void update(EgDevice egDevice) {
|
|
|
+
|
|
|
+ EgDevice one = this.getById(egDevice.getId());
|
|
|
+ egDevice.setBindFace(one.getBindFace());
|
|
|
+
|
|
|
+
|
|
|
if(checkNameUnique(egDevice)){
|
|
|
throw new BusinessException("修改门禁门号设备'"+egDevice.getDeviceId()+","+egDevice.getEgNumber()+"'失败,设备已存在");
|
|
|
}
|
|
|
+ if(checkDeviceNameUnique(egDevice)){
|
|
|
+ throw new BusinessException("新增门禁设备'"+egDevice.getDeviceName()+"'失败,设备已存在");
|
|
|
+ }
|
|
|
|
|
|
egDevice.setUpdateBy(SecurityUtils.getUsername());
|
|
|
egDevice.setUpdateTime(LocalDateTime.now());
|
|
@@ -166,9 +180,10 @@ public class EgDeviceServiceImpl extends AbstractCrudService<EgDeviceMapper, EgD
|
|
|
this.updateById(egDevice);
|
|
|
|
|
|
String[] fids = new String[0];
|
|
|
- egDeviceMapper.deleteMeetingFaceDevice(egDevice.getId());
|
|
|
if(Objects.nonNull(egDevice.getBindFace()) || StringUtils.isNotBlank(egDevice.getBindFace())){
|
|
|
fids = egDevice.getBindFace().split(",");
|
|
|
+
|
|
|
+ egDeviceMapper.deleteMeetingFaceDevice(egDevice.getId());
|
|
|
}
|
|
|
if(fids.length > 0){
|
|
|
for (int i = 0; i < fids.length; i++) {
|
|
@@ -179,9 +194,16 @@ public class EgDeviceServiceImpl extends AbstractCrudService<EgDeviceMapper, EgD
|
|
|
|
|
|
@Override
|
|
|
public void attachUpdate(EgDevice egDevice){
|
|
|
+
|
|
|
+ EgDevice one = this.getById(egDevice.getId());
|
|
|
+ egDevice.setBindFace(one.getBindFace());
|
|
|
+
|
|
|
if(checkNameUnique(egDevice)){
|
|
|
throw new BusinessException("更新门禁设备附加功能'"+egDevice.getDeviceId()+"'失败,设备已存在");
|
|
|
}
|
|
|
+ if(checkDeviceNameUnique(egDevice)){
|
|
|
+ throw new BusinessException("新增门禁设备'"+egDevice.getDeviceName()+"'失败,设备已存在");
|
|
|
+ }
|
|
|
|
|
|
egDevice.setUpdateBy(SecurityUtils.getUsername());
|
|
|
egDevice.setUpdateTime(LocalDateTime.now());
|
|
@@ -217,6 +239,16 @@ public class EgDeviceServiceImpl extends AbstractCrudService<EgDeviceMapper, EgD
|
|
|
return null != one && !Objects.equals(one.getId(),id);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean checkDeviceNameUnique(EgDevice egDevice){
|
|
|
+ Integer id = null == egDevice.getId() ? -1 : egDevice.getId();
|
|
|
+ LambdaQueryWrapper<EgDevice> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(EgDevice::getDeviceName,egDevice.getDeviceName())
|
|
|
+ .eq(EgDevice::getTenantId, SecurityUtils.getTenantId());
|
|
|
+ EgDevice one = this.getOne(queryWrapper);
|
|
|
+ return null != one && !Objects.equals(one.getId(),id);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Map<String,Object> control(String productCode, String deviceUuid, String commandCode, String commandValue, String domain, Long userId, String userName){
|
|
|
Integer tenantId;
|