|
@@ -121,9 +121,63 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
|
|
|
@Override
|
|
|
public CommonPage<DmpDeviceInfo> page(DmpDeviceInfoRequest diRequest) {
|
|
|
- IPage<DmpDeviceInfo> page = new Page<>(diRequest.getCurrent(), diRequest.getSize());
|
|
|
- page = baseMapper.page(page,diRequest,SecurityUtils.getTenantId());
|
|
|
- return new CommonPage<>(page.getRecords(),page.getTotal(),page.getCurrent(),page.getSize());
|
|
|
+ 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){
|
|
|
+ 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());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(diRequest.getDeviceStatus() != null){
|
|
|
+ list = list1.stream().filter(m-> m.getDeviceStatus().equals(diRequest.getDeviceStatus())).collect(Collectors.toList());
|
|
|
+ }else{
|
|
|
+ for(int j=0;j<list1.size();j++){
|
|
|
+ list.add(list1.get(j));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer total = 0;
|
|
|
+ if(list.size() > 0){
|
|
|
+ total = list.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer current = 0;
|
|
|
+ Integer pageCurrent = diRequest.getCurrent();
|
|
|
+ Integer pageSize = diRequest.getSize();
|
|
|
+ if(pageCurrent != null && pageSize > 0){
|
|
|
+ current = (pageCurrent-1)*pageSize;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<DmpDeviceInfo> records = list.stream().skip(current).limit(pageSize).collect(Collectors.toList());
|
|
|
+
|
|
|
+ return new CommonPage<>(records,total,pageSize,pageCurrent);
|
|
|
}
|
|
|
|
|
|
@Override
|