|
@@ -376,32 +376,73 @@ public class ProductServiceImpl implements ProductService {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
}, page);*/
|
|
}, page);*/
|
|
|
- List<Long> list = new ArrayList<>();
|
|
|
|
|
List<V_ProductPerson> productList = productPage.getContent();
|
|
List<V_ProductPerson> productList = productPage.getContent();
|
|
|
- for (V_ProductPerson product : productList) {
|
|
|
|
|
- if ("ERP".equals(product.getSourceApp())) {
|
|
|
|
|
- ProductDetail productDetail = productDetailDao.findByProductId(product.getId());
|
|
|
|
|
- if (productDetail != null) {
|
|
|
|
|
- product.setProductDetail(productDetail);
|
|
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(productList)) {
|
|
|
|
|
+ List<Long> list = new ArrayList<>();
|
|
|
|
|
+ for (V_ProductPerson product : productList) {
|
|
|
|
|
+ if ("ERP".equals(product.getSourceApp())) {
|
|
|
|
|
+ ProductDetail productDetail = productDetailDao.findByProductId(product.getId());
|
|
|
|
|
+ if (productDetail != null) {
|
|
|
|
|
+ product.setProductDetail(productDetail);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ list.add(product.getId());
|
|
|
}
|
|
}
|
|
|
- List<ProductReplace> productReplaceList = productReplaceDao.findByProductIdOrderByDetno(product.getId());
|
|
|
|
|
- product.setProductReplaceList(productReplaceList);
|
|
|
|
|
- list.add(product.getId());
|
|
|
|
|
- }
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(list)) {
|
|
|
|
|
- List<ProductAttachSubmit> submits = productAttachService.findByProductidsAndStatus(list, Status.UNAUDIT.value());
|
|
|
|
|
- for (ProductAttachSubmit productAttachSubmit : submits) {
|
|
|
|
|
- for (V_ProductPerson product : productList) {
|
|
|
|
|
- if (product.getId().longValue() == productAttachSubmit.getProductId().longValue()) {
|
|
|
|
|
- product.setProductAttachSubmit(productAttachSubmit);
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
|
|
+ List<ProductAttachSubmit> submits = productAttachService.findByProductidsAndStatus(list, Status.UNAUDIT.value());
|
|
|
|
|
+ for (ProductAttachSubmit productAttachSubmit : submits) {
|
|
|
|
|
+ for (V_ProductPerson product : productList) {
|
|
|
|
|
+ if (product.getId().longValue() == productAttachSubmit.getProductId().longValue()) {
|
|
|
|
|
+ product.setProductAttachSubmit(productAttachSubmit);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ Map<Long, List<ProductReplace>> batchGetProductReplace = batchGetProductReplace(list);
|
|
|
|
|
+ if ((batchGetProductReplace != null) && (batchGetProductReplace.size() != 0)) {
|
|
|
|
|
+ for (V_ProductPerson product : productList) {
|
|
|
|
|
+ List<ProductReplace> productReplaces = batchGetProductReplace.get(product.getId());
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(productReplaces)) {
|
|
|
|
|
+ product.setProductReplaceList(productReplaces);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ return new PageImpl<V_ProductPerson>(productList, page, productPage.getTotalElements());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return productPage;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public Map<Long, List<ProductReplace>> batchGetProductReplace(List<Long> list) {
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
|
|
+ List<ProductReplace> productReplaceList = productReplaceDao.findByProductId(list);
|
|
|
|
|
+ Map<Long, List<ProductReplace>> map = new HashedMap();
|
|
|
|
|
+ for (ProductReplace productReplace : productReplaceList) {
|
|
|
|
|
+ List<ProductReplace> productReplaces = map.get(productReplace.getProductId());
|
|
|
|
|
+ if (productReplaces == null) {
|
|
|
|
|
+ productReplaces = new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
+ productReplaces.add(productReplace);
|
|
|
|
|
+ map.put(productReplace.getProductId(), productReplaces);
|
|
|
|
|
+ }
|
|
|
|
|
+ Set<Long> keySet = map.keySet();
|
|
|
|
|
+ for (Long id : keySet) {
|
|
|
|
|
+ List<ProductReplace> productReplaces = map.get(id);
|
|
|
|
|
+ if ((productReplaces != null) && (productReplaces.size() != 0)) {
|
|
|
|
|
+ Collections.sort(productReplaces, new Comparator<ProductReplace>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int compare(ProductReplace o1, ProductReplace o2) {
|
|
|
|
|
+ return o1.getDetno().shortValue() - o2.getDetno().shortValue();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return map;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return new HashedMap();
|
|
|
}
|
|
}
|
|
|
- return new PageImpl<V_ProductPerson>(productList, page, productPage.getTotalElements());
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|