|
@@ -74,31 +74,69 @@ public class DmpProductInfoServiceImpl extends AbstractCrudService<DmpProductInf
|
|
.eq(StringUtils.isNotBlank(piRequest.getDeviceModel()),DmpProductInfo::getDeviceModel,piRequest.getDeviceModel())
|
|
.eq(StringUtils.isNotBlank(piRequest.getDeviceModel()),DmpProductInfo::getDeviceModel,piRequest.getDeviceModel())
|
|
.eq(null != piRequest.getId(),DmpProductInfo::getId,piRequest.getId())
|
|
.eq(null != piRequest.getId(),DmpProductInfo::getId,piRequest.getId())
|
|
.eq(DmpProductInfo::getDeleteFlag,0);
|
|
.eq(DmpProductInfo::getDeleteFlag,0);
|
|
- List<DmpProductInfo> records = page.getRecords();
|
|
|
|
|
|
+ List<DmpProductInfo> records = this.list(lambdaQuery);
|
|
List<Integer> productIds = records.stream().map(DmpProductInfo::getId).collect(Collectors.toList());
|
|
List<Integer> productIds = records.stream().map(DmpProductInfo::getId).collect(Collectors.toList());
|
|
List<Map<String, Object>> maps = dmpDeviceInfoService.deviceCollect(productIds);
|
|
List<Map<String, Object>> maps = dmpDeviceInfoService.deviceCollect(productIds);
|
|
List<Map<String, Object>> collectByProduct = dmpDeviceStatusService.getCollectByProduct(productIds);
|
|
List<Map<String, Object>> collectByProduct = dmpDeviceStatusService.getCollectByProduct(productIds);
|
|
- records.forEach(s -> {enhanceByDevice(s,maps);
|
|
|
|
- enhanceByDeviceStatus(s,collectByProduct);
|
|
|
|
- });
|
|
|
|
- page = this.page(page,lambdaQuery);
|
|
|
|
- return new CommonPage<>(page.getRecords(),page.getTotal(),page.getCurrent(),page.getSize());
|
|
|
|
|
|
+
|
|
|
|
+// maps.forEach(s -> {enhanceByDevice(records,s);});
|
|
|
|
+// collectByProduct.forEach(s -> {enhanceByDeviceStatus(records,s);});
|
|
|
|
+ if(records.size()>0){
|
|
|
|
+ for(int i=0;i<records.size();i++){
|
|
|
|
+ if(maps.size()>0){
|
|
|
|
+ for(int j=0;j<maps.size();j++){
|
|
|
|
+ if(maps.get(j).get("productId")==(records.get(i).getId())){
|
|
|
|
+ String coun = maps.get(j).get("count").toString();
|
|
|
|
+ Integer it = Integer.parseInt(maps.get(j).get("count").toString());
|
|
|
|
+ records.get(i).setDeviceCount(Integer.parseInt(maps.get(j).get("count").toString()));
|
|
|
|
+ records.get(i).setServiceStatusCount(Integer.parseInt(maps.get(j).get("serviceCount").toString()));
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(collectByProduct.size()>0){
|
|
|
|
+ for(int j=0;j<collectByProduct.size();j++){
|
|
|
|
+ if(collectByProduct.get(j).get("productId")==(records.get(i).getId())){
|
|
|
|
+ records.get(i).setDeviceStatusCount(Integer.parseInt(collectByProduct.get(j).get("deviceCount").toString()));
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ int total = 0;
|
|
|
|
+ if(records.size()>0){
|
|
|
|
+ total = records.size();
|
|
|
|
+ }
|
|
|
|
+ int current = 0;
|
|
|
|
+ Integer pageNum = piRequest.getCurrent();
|
|
|
|
+ Integer pageSize = piRequest.getSize();
|
|
|
|
+ if(pageNum != null && pageSize > 0){
|
|
|
|
+ current = (pageNum - 1)*pageSize;
|
|
|
|
+ }
|
|
|
|
+ List<DmpProductInfo> list = records.stream().skip(current).limit(pageSize).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ return new CommonPage<>(list,total,page.getCurrent(),page.getSize());
|
|
}
|
|
}
|
|
|
|
|
|
- public void enhanceByDevice(DmpProductInfo dmpProductInfo, List<Map<String,Object>> list){
|
|
|
|
- list.stream()
|
|
|
|
- .filter(s -> dmpProductInfo.getId().toString().equals(s.get("productId")))
|
|
|
|
|
|
+ public void enhanceByDevice(List<DmpProductInfo> dmpProductInfo, Map<String,Object> map){
|
|
|
|
+ dmpProductInfo.stream()
|
|
|
|
+ .filter(s -> map.get("productId").equals(s.getId().toString()))
|
|
.findAny()
|
|
.findAny()
|
|
- .ifPresent(s -> dmpProductInfo.setDeviceCount(Integer.getInteger(s.get("count").toString())));
|
|
|
|
|
|
+ .ifPresent(s -> {
|
|
|
|
+ s.setDeviceCount(Integer.parseInt(map.get("count").toString()));
|
|
|
|
+ s.setServiceStatusCount(Integer.parseInt(map.get("serviceCount").toString()));
|
|
|
|
+ });
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
- public void enhanceByDeviceStatus(DmpProductInfo dmpProductInfo, List<Map<String,Object>> list){
|
|
|
|
- list.stream()
|
|
|
|
- .filter(s -> dmpProductInfo.getId().toString().equals(s.get("productId")))
|
|
|
|
|
|
+ public void enhanceByDeviceStatus(List<DmpProductInfo> dmpProductInfo, Map<String,Object> map){
|
|
|
|
+ dmpProductInfo.stream()
|
|
|
|
+ .filter(s -> map.get("productId").equals(s.getId().toString()))
|
|
.findAny()
|
|
.findAny()
|
|
.ifPresent(s -> {
|
|
.ifPresent(s -> {
|
|
- dmpProductInfo.setDeviceStatusCount(Integer.getInteger(s.get("deviceCount").toString()));
|
|
|
|
- dmpProductInfo.setServiceStatusCount(Integer.getInteger(s.get("serviceCount").toString()));
|
|
|
|
|
|
+ s.setDeviceStatusCount(Integer.parseInt(map.get("deviceCount").toString()));
|
|
}
|
|
}
|
|
);
|
|
);
|
|
}
|
|
}
|