|
@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ArrayUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -95,6 +96,32 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
commandUserName = SecurityUtils.getUsername();
|
|
|
}
|
|
|
|
|
|
+ //人员设备权限校验,校验通过,可以下发命令控制设备
|
|
|
+ Integer fid = baseMapper.getMeetingFaceData(commandUserId);
|
|
|
+ if(fid == null){
|
|
|
+ throw new BusinessException("人脸卡号信息未注册");
|
|
|
+ }
|
|
|
+ Integer[] deviceFid = baseMapper.getMeetingFaceDeviceList(fid);
|
|
|
+ if(deviceFid.length == 0){
|
|
|
+ throw new BusinessException("人员未绑定设备,请检查");
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaQueryWrapper<DmpDeviceInfo> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.select(DmpDeviceInfo::getId)
|
|
|
+ .eq(DmpDeviceInfo::getProductCode,productCode)
|
|
|
+ .eq(DmpDeviceInfo::getDeviceId,deviceId)
|
|
|
+ .eq(DmpDeviceInfo::getDeleteFlag,0);
|
|
|
+ DmpDeviceInfo one = this.getOne(queryWrapper);
|
|
|
+ if(one != null){
|
|
|
+ boolean exist = Arrays.asList(deviceFid).contains(one.getId());
|
|
|
+ if(!exist){
|
|
|
+ throw new BusinessException("暂无权限");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ throw new BusinessException("设备未注册,请先注册");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
map.put("method","control");
|
|
|
Map<String,Object> map1 = new HashMap<>();
|
|
@@ -180,11 +207,12 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
IPage<DmpDeviceInfo> page = new Page<>(pageCurrent,pageSize);
|
|
|
|
|
|
if(diRequest.getDeviceStatus() != null){
|
|
|
- if(StringUtils.isNotBlank(diRequest.getDeviceId()) || StringUtils.isNotBlank(diRequest.getDeviceName()) || diRequest.getProductId() != null || diRequest.getServiceStatus() != null){
|
|
|
+ if(StringUtils.isNotBlank(diRequest.getDeviceId()) || StringUtils.isNotBlank(diRequest.getDeviceName()) || diRequest.getProductId() != null || StringUtils.isNotBlank(diRequest.getProductCode()) || diRequest.getServiceStatus() != null){
|
|
|
LambdaQueryWrapper<DmpDeviceInfo> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.eq(StringUtils.isNotBlank(diRequest.getDeviceId()),DmpDeviceInfo::getDeviceId,diRequest.getDeviceId())
|
|
|
.like(StringUtils.isNotBlank(diRequest.getDeviceName()),DmpDeviceInfo::getDeviceName,diRequest.getDeviceName())
|
|
|
.eq(diRequest.getProductId() != null,DmpDeviceInfo::getProductId,diRequest.getProductId())
|
|
|
+ .like(StringUtils.isNotBlank(diRequest.getProductCode()),DmpDeviceInfo::getProductCode,diRequest.getProductCode())
|
|
|
.eq(diRequest.getServiceStatus() != null,DmpDeviceInfo::getServiceStatus,diRequest.getServiceStatus())
|
|
|
.eq(DmpDeviceInfo::getDeleteFlag,0)
|
|
|
.eq(DmpDeviceInfo::getTenantId,SecurityUtils.getTenantId())
|
|
@@ -293,6 +321,7 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
queryWrapper.eq(StringUtils.isNotBlank(diRequest.getDeviceId()),DmpDeviceInfo::getDeviceId,diRequest.getDeviceId())
|
|
|
.like(StringUtils.isNotBlank(diRequest.getDeviceName()),DmpDeviceInfo::getDeviceName,diRequest.getDeviceName())
|
|
|
.eq(diRequest.getProductId() != null,DmpDeviceInfo::getProductId,diRequest.getProductId())
|
|
|
+ .like(StringUtils.isNotBlank(diRequest.getProductCode()),DmpDeviceInfo::getProductCode,diRequest.getProductCode())
|
|
|
.eq(diRequest.getServiceStatus() != null,DmpDeviceInfo::getServiceStatus,diRequest.getServiceStatus())
|
|
|
.eq(DmpDeviceInfo::getDeleteFlag,0)
|
|
|
.eq(DmpDeviceInfo::getTenantId,SecurityUtils.getTenantId())
|
|
@@ -335,6 +364,177 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
return new CommonPage<>(page.getRecords(),page.getTotal(),pageSize,pageCurrent);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public CommonPage<DmpDeviceInfo> pageWhite(DmpDeviceInfoRequest diRequest) {
|
|
|
+ List<DmpDeviceInfo> list = new ArrayList<>();
|
|
|
+ Integer total = 0;
|
|
|
+ Integer pageCurrent = diRequest.getCurrent();
|
|
|
+ Integer pageSize = diRequest.getSize();
|
|
|
+ IPage<DmpDeviceInfo> page = new Page<>(pageCurrent,pageSize);
|
|
|
+ Integer tenantId = 0;
|
|
|
+ String domain = diRequest.getDomain();
|
|
|
+ if(StringUtils.isNotBlank(domain)){
|
|
|
+ tenantId = baseMapper.sysTenantId(domain);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(diRequest.getDeviceStatus() != null){
|
|
|
+ if(StringUtils.isNotBlank(diRequest.getDeviceId()) || StringUtils.isNotBlank(diRequest.getDeviceName()) || diRequest.getProductId() != null || StringUtils.isNotBlank(diRequest.getProductCode()) || diRequest.getServiceStatus() != null){
|
|
|
+ LambdaQueryWrapper<DmpDeviceInfo> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(StringUtils.isNotBlank(diRequest.getDeviceId()),DmpDeviceInfo::getDeviceId,diRequest.getDeviceId())
|
|
|
+ .like(StringUtils.isNotBlank(diRequest.getDeviceName()),DmpDeviceInfo::getDeviceName,diRequest.getDeviceName())
|
|
|
+ .eq(diRequest.getProductId() != null,DmpDeviceInfo::getProductId,diRequest.getProductId())
|
|
|
+ .like(StringUtils.isNotBlank(diRequest.getProductCode()),DmpDeviceInfo::getProductCode,diRequest.getProductCode())
|
|
|
+ .eq(diRequest.getServiceStatus() != null,DmpDeviceInfo::getServiceStatus,diRequest.getServiceStatus())
|
|
|
+ .eq(DmpDeviceInfo::getDeleteFlag,0)
|
|
|
+ .eq(DmpDeviceInfo::getTenantId,tenantId)
|
|
|
+ .orderByDesc(DmpDeviceInfo::getId);
|
|
|
+ List<DmpDeviceInfo> list1 = this.list(queryWrapper);
|
|
|
+
|
|
|
+ if(CollectionUtils.isNotEmpty(list1)){
|
|
|
+ List<String> devList = new ArrayList<>();
|
|
|
+ List<Integer> productIdList = new ArrayList<>();
|
|
|
+ for(int i=0;i<list1.size();i++){
|
|
|
+ if(!devList.contains(list1.get(i).getDeviceId())){
|
|
|
+ devList.add(list1.get(i).getDeviceId());
|
|
|
+ }
|
|
|
+ if(!productIdList.contains(list1.get(i).getProductId())){
|
|
|
+ productIdList.add(list1.get(i).getProductId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(devList.size() > 0){
|
|
|
+ LambdaQueryWrapper<DmpDeviceStatus> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper1.in(DmpDeviceStatus::getDeviceId,devList)
|
|
|
+ .in(DmpDeviceStatus::getProductId,productIdList)
|
|
|
+ .eq(DmpDeviceStatus::getDeviceStatus,diRequest.getDeviceStatus());
|
|
|
+ List<DmpDeviceStatus> statusList = dmpDeviceStatusService.list(queryWrapper1);
|
|
|
+ if(statusList.size() > 0){
|
|
|
+ for(int i=0;i<list1.size();i++){
|
|
|
+ for(int j=0;j<statusList.size();j++){
|
|
|
+ if(list1.get(i).getProductId().equals(statusList.get(j).getProductId()) && list1.get(i).getDeviceId().equals(statusList.get(j).getDeviceId())){
|
|
|
+ list1.get(i).setDeviceStatus(statusList.get(j).getDeviceStatus());
|
|
|
+ list1.get(i).setLastOnlineTime(statusList.get(j).getLastOnlineTime());
|
|
|
+ list1.get(i).setLastOfflineTime(statusList.get(j).getLastOfflineTime());
|
|
|
+ list.add(list1.get(i));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if(list.size() > 0){
|
|
|
+ total = list.size();
|
|
|
+ page.setTotal(total);
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer current = 0;
|
|
|
+ if(pageCurrent != null && pageSize > 0){
|
|
|
+ current = (pageCurrent-1)*pageSize;
|
|
|
+ }
|
|
|
+
|
|
|
+ page.setRecords(list.stream().skip(current).limit(pageSize).collect(Collectors.toList()));
|
|
|
+ }else{
|
|
|
+ LambdaQueryWrapper<DmpDeviceStatus> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(DmpDeviceStatus::getDeviceStatus,diRequest.getDeviceStatus());
|
|
|
+ List<DmpDeviceStatus> statusList = dmpDeviceStatusService.list(queryWrapper);
|
|
|
+ if(statusList.size() > 0){
|
|
|
+ List<String> devList = new ArrayList<>();
|
|
|
+ List<Integer> productIdList = new ArrayList<>();
|
|
|
+ for(int i=0;i<statusList.size();i++){
|
|
|
+ if(!devList.contains(statusList.get(i).getDeviceId())){
|
|
|
+ devList.add(statusList.get(i).getDeviceId());
|
|
|
+ }
|
|
|
+ if(!productIdList.contains(statusList.get(i).getProductId())){
|
|
|
+ productIdList.add(statusList.get(i).getProductId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(devList.size() > 0){
|
|
|
+ LambdaQueryWrapper<DmpDeviceInfo> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper1.in(DmpDeviceInfo::getDeviceId,devList)
|
|
|
+ .in(DmpDeviceInfo::getProductId,productIdList)
|
|
|
+ .eq(DmpDeviceInfo::getDeleteFlag,0)
|
|
|
+ .eq(DmpDeviceInfo::getTenantId,tenantId)
|
|
|
+ .orderByDesc(DmpDeviceInfo::getId);
|
|
|
+ List<DmpDeviceInfo> list1 = this.list(queryWrapper1);
|
|
|
+ if(list1.size() > 0){
|
|
|
+ for(int i=0;i<list1.size();i++){
|
|
|
+ for(int j=0;j<statusList.size();j++){
|
|
|
+ if(list1.get(i).getProductId().equals(statusList.get(j).getProductId()) && list1.get(i).getDeviceId().equals(statusList.get(j).getDeviceId())){
|
|
|
+ list1.get(i).setDeviceStatus(statusList.get(j).getDeviceStatus());
|
|
|
+ list1.get(i).setLastOnlineTime(statusList.get(j).getLastOnlineTime());
|
|
|
+ list1.get(i).setLastOfflineTime(statusList.get(j).getLastOfflineTime());
|
|
|
+ list.add(list1.get(i));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(list.size() > 0){
|
|
|
+ total = list.size();
|
|
|
+ page.setTotal(total);
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer current = 0;
|
|
|
+ if(pageCurrent != null && pageSize > 0){
|
|
|
+ current = (pageCurrent-1)*pageSize;
|
|
|
+ }
|
|
|
+
|
|
|
+ page.setRecords(list.stream().skip(current).limit(pageSize).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ LambdaQueryWrapper<DmpDeviceInfo> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(StringUtils.isNotBlank(diRequest.getDeviceId()),DmpDeviceInfo::getDeviceId,diRequest.getDeviceId())
|
|
|
+ .like(StringUtils.isNotBlank(diRequest.getDeviceName()),DmpDeviceInfo::getDeviceName,diRequest.getDeviceName())
|
|
|
+ .eq(diRequest.getProductId() != null,DmpDeviceInfo::getProductId,diRequest.getProductId())
|
|
|
+ .like(StringUtils.isNotBlank(diRequest.getProductCode()),DmpDeviceInfo::getProductCode,diRequest.getProductCode())
|
|
|
+ .eq(diRequest.getServiceStatus() != null,DmpDeviceInfo::getServiceStatus,diRequest.getServiceStatus())
|
|
|
+ .eq(DmpDeviceInfo::getDeleteFlag,0)
|
|
|
+ .eq(DmpDeviceInfo::getTenantId,tenantId)
|
|
|
+ .orderByDesc(DmpDeviceInfo::getId);
|
|
|
+ page = this.page(page,queryWrapper);
|
|
|
+ if(page.getTotal() > 0){
|
|
|
+ List<String> devList = new ArrayList<>();
|
|
|
+ List<Integer> productIdList = new ArrayList<>();
|
|
|
+ for(int i=0;i<page.getRecords().size();i++){
|
|
|
+ if(!devList.contains(page.getRecords().get(i).getDeviceId())){
|
|
|
+ devList.add(page.getRecords().get(i).getDeviceId());
|
|
|
+ }
|
|
|
+ if(!productIdList.contains(page.getRecords().get(i).getProductId())){
|
|
|
+ productIdList.add(page.getRecords().get(i).getProductId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(devList.size() > 0){
|
|
|
+ LambdaQueryWrapper<DmpDeviceStatus> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper1.in(DmpDeviceStatus::getDeviceId,devList)
|
|
|
+ .in(DmpDeviceStatus::getProductId,productIdList);
|
|
|
+ List<DmpDeviceStatus> statusList = dmpDeviceStatusService.list(queryWrapper1);
|
|
|
+ if(statusList.size() > 0){
|
|
|
+ for(int i=0;i<page.getRecords().size();i++){
|
|
|
+ for(int j=0;j<statusList.size();j++){
|
|
|
+ if(page.getRecords().get(i).getProductId().equals(statusList.get(j).getProductId()) && page.getRecords().get(i).getDeviceId().equals(statusList.get(j).getDeviceId())){
|
|
|
+ page.getRecords().get(i).setDeviceStatus(statusList.get(j).getDeviceStatus());
|
|
|
+ page.getRecords().get(i).setLastOnlineTime(statusList.get(j).getLastOnlineTime());
|
|
|
+ page.getRecords().get(i).setLastOfflineTime(statusList.get(j).getLastOfflineTime());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return new CommonPage<>(page.getRecords(),page.getTotal(),pageSize,pageCurrent);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public boolean remove(Integer id) {
|
|
|
DmpDeviceInfo dmpDeviceInfo = this.getById(id);
|