|
@@ -129,64 +129,163 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
@Override
|
|
@Override
|
|
public CommonPage<DmpDeviceInfo> page(DmpDeviceInfoRequest diRequest) {
|
|
public CommonPage<DmpDeviceInfo> page(DmpDeviceInfoRequest diRequest) {
|
|
List<DmpDeviceInfo> list = new ArrayList<>();
|
|
List<DmpDeviceInfo> list = new ArrayList<>();
|
|
- LambdaQueryWrapper<DmpDeviceInfo> queryWrapper = Wrappers.lambdaQuery();
|
|
|
|
- queryWrapper.like(StringUtils.isNotBlank(diRequest.getDeviceName()),DmpDeviceInfo::getDeviceName,diRequest.getDeviceName())
|
|
|
|
- .eq(diRequest.getProductId() != null,DmpDeviceInfo::getProductId,diRequest.getProductId())
|
|
|
|
- .eq(diRequest.getServiceStatus() != null,DmpDeviceInfo::getServiceStatus,diRequest.getServiceStatus())
|
|
|
|
- .eq(DmpDeviceInfo::getDeleteFlag,0)
|
|
|
|
- .eq(DmpDeviceInfo::getTenantId,SecurityUtils.getTenantId())
|
|
|
|
- .orderByDesc(DmpDeviceInfo::getId);
|
|
|
|
- List<DmpDeviceInfo> list1 = this.list(queryWrapper);
|
|
|
|
-
|
|
|
|
- if(CollectionUtils.isNotEmpty(list1)){
|
|
|
|
- List<String> devList = new ArrayList<>();
|
|
|
|
- for(int i=0;i<list1.size();i++){
|
|
|
|
- devList.add(list1.get(i).getDeviceId());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if(devList.size() > 0){
|
|
|
|
- LambdaQueryWrapper<DmpDeviceStatus> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
|
- queryWrapper1.in(DmpDeviceStatus::getDeviceId,devList);
|
|
|
|
- List<DmpDeviceStatus> statusList = dmpDeviceStatusService.list(queryWrapper1);
|
|
|
|
- if(statusList.size() > 0){
|
|
|
|
|
|
+ Integer total = 0;
|
|
|
|
+ Integer pageCurrent = diRequest.getCurrent();
|
|
|
|
+ Integer pageSize = diRequest.getSize();
|
|
|
|
+ IPage<DmpDeviceInfo> page = new Page<>(pageCurrent,pageSize);
|
|
|
|
+
|
|
|
|
+ if(diRequest.getDeviceStatus() != null){
|
|
|
|
+ if(StringUtils.isNotBlank(diRequest.getDeviceName()) || diRequest.getProductId() != null || diRequest.getServiceStatus() != null){
|
|
|
|
+ LambdaQueryWrapper<DmpDeviceInfo> queryWrapper = Wrappers.lambdaQuery();
|
|
|
|
+ queryWrapper.like(StringUtils.isNotBlank(diRequest.getDeviceName()),DmpDeviceInfo::getDeviceName,diRequest.getDeviceName())
|
|
|
|
+ .eq(diRequest.getProductId() != null,DmpDeviceInfo::getProductId,diRequest.getProductId())
|
|
|
|
+ .eq(diRequest.getServiceStatus() != null,DmpDeviceInfo::getServiceStatus,diRequest.getServiceStatus())
|
|
|
|
+ .eq(DmpDeviceInfo::getDeleteFlag,0)
|
|
|
|
+ .eq(DmpDeviceInfo::getTenantId,SecurityUtils.getTenantId())
|
|
|
|
+ .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++){
|
|
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());
|
|
|
|
- continue;
|
|
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
|
|
- if(diRequest.getDeviceStatus() != null){
|
|
|
|
- list = list1.stream().filter(m-> m.getDeviceStatus().equals(diRequest.getDeviceStatus())).collect(Collectors.toList());
|
|
|
|
|
|
+ page.setRecords(list.stream().skip(current).limit(pageSize).collect(Collectors.toList()));
|
|
}else{
|
|
}else{
|
|
- for(int j=0;j<list1.size();j++){
|
|
|
|
- list.add(list1.get(j));
|
|
|
|
|
|
+ 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,SecurityUtils.getTenantId())
|
|
|
|
+ .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()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- Integer total = 0;
|
|
|
|
- if(list.size() > 0){
|
|
|
|
- total = list.size();
|
|
|
|
- }
|
|
|
|
|
|
+ }else{
|
|
|
|
+ LambdaQueryWrapper<DmpDeviceInfo> queryWrapper = Wrappers.lambdaQuery();
|
|
|
|
+ queryWrapper.like(StringUtils.isNotBlank(diRequest.getDeviceName()),DmpDeviceInfo::getDeviceName,diRequest.getDeviceName())
|
|
|
|
+ .eq(diRequest.getProductId() != null,DmpDeviceInfo::getProductId,diRequest.getProductId())
|
|
|
|
+ .eq(diRequest.getServiceStatus() != null,DmpDeviceInfo::getServiceStatus,diRequest.getServiceStatus())
|
|
|
|
+ .eq(DmpDeviceInfo::getDeleteFlag,0)
|
|
|
|
+ .eq(DmpDeviceInfo::getTenantId,SecurityUtils.getTenantId())
|
|
|
|
+ .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());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- Integer current = 0;
|
|
|
|
- Integer pageCurrent = diRequest.getCurrent();
|
|
|
|
- Integer pageSize = diRequest.getSize();
|
|
|
|
- if(pageCurrent != null && pageSize > 0){
|
|
|
|
- current = (pageCurrent-1)*pageSize;
|
|
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- List<DmpDeviceInfo> records = list.stream().skip(current).limit(pageSize).collect(Collectors.toList());
|
|
|
|
|
|
|
|
- return new CommonPage<>(records,total,pageSize,pageCurrent);
|
|
|
|
|
|
+ return new CommonPage<>(page.getRecords(),page.getTotal(),pageSize,pageCurrent);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|