Authored by wangnan

代码重构

@@ -3,6 +3,7 @@ package com.yoho.search.consumer.service.logic.productIndex; @@ -3,6 +3,7 @@ package com.yoho.search.consumer.service.logic.productIndex;
3 import com.yoho.search.consumer.service.bo.ProductActivitiesBO; 3 import com.yoho.search.consumer.service.bo.ProductActivitiesBO;
4 import com.yoho.search.dal.ProductActivityMapper; 4 import com.yoho.search.dal.ProductActivityMapper;
5 import com.yoho.search.dal.model.ProductActivity; 5 import com.yoho.search.dal.model.ProductActivity;
  6 +import org.apache.commons.collections.CollectionUtils;
6 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.stereotype.Component; 8 import org.springframework.stereotype.Component;
8 9
@@ -20,11 +21,14 @@ public class ProductActivitiesLogicService { @@ -20,11 +21,14 @@ public class ProductActivitiesLogicService {
20 @Autowired 21 @Autowired
21 private ProductActivityMapper productActivityMapper; 22 private ProductActivityMapper productActivityMapper;
22 23
23 - public List<ProductActivitiesBO> getData(List<Integer> skns) {  
24 - //构建ProductActivity 视图  
25 - List<ProductActivity> productActivities = productActivityMapper.getProductActivity(skns);  
26 - //构建ProductActivities视图  
27 - //group by product_skn 24 + /**
  25 + * 根据productSkn查询activity_product表的每一条记录,然后根据productSkn分组把多条记录拼装成一个JSONArray
  26 + */
  27 + public List<ProductActivitiesBO> getData(List<Integer> productSknList) {
  28 + List<ProductActivity> productActivities = productActivityMapper.getProductActivity(productSknList);
  29 + if(CollectionUtils.isEmpty(productActivities)){
  30 + return new ArrayList<>();
  31 + }
28 Map<Integer, String> productActivitiesMap = new HashMap<>(); 32 Map<Integer, String> productActivitiesMap = new HashMap<>();
29 for (ProductActivity p : productActivities) { 33 for (ProductActivity p : productActivities) {
30 if (productActivitiesMap.containsKey(p.getProductSkn())) { 34 if (productActivitiesMap.containsKey(p.getProductSkn())) {
@@ -33,15 +37,14 @@ public class ProductActivitiesLogicService { @@ -33,15 +37,14 @@ public class ProductActivitiesLogicService {
33 productActivitiesMap.put(p.getProductSkn(), p.getActivity()); 37 productActivitiesMap.put(p.getProductSkn(), p.getActivity());
34 } 38 }
35 } 39 }
36 - //塞入ProductActivities,顺便把Activities字段用[]包裹  
37 - List<ProductActivitiesBO> productActivitiesBOs = new ArrayList<>(); 40 + List<ProductActivitiesBO> productActivitiesBOList = new ArrayList<>();
38 for (Map.Entry<Integer, String> entry : productActivitiesMap.entrySet()) { 41 for (Map.Entry<Integer, String> entry : productActivitiesMap.entrySet()) {
39 String activities = "[" + entry.getValue() + "]"; 42 String activities = "[" + entry.getValue() + "]";
40 - ProductActivitiesBO productActivitiesBO1 = new ProductActivitiesBO();  
41 - productActivitiesBO1.setProductSkn(entry.getKey());  
42 - productActivitiesBO1.setActivities(activities);  
43 - productActivitiesBOs.add(productActivitiesBO1); 43 + ProductActivitiesBO productActivitiesBO = new ProductActivitiesBO();
  44 + productActivitiesBO.setProductSkn(entry.getKey());
  45 + productActivitiesBO.setActivities(activities);
  46 + productActivitiesBOList.add(productActivitiesBO);
44 } 47 }
45 - return productActivitiesBOs; 48 + return productActivitiesBOList;
46 } 49 }
47 } 50 }
@@ -38,77 +38,80 @@ public class ProductGoodsLogicService { @@ -38,77 +38,80 @@ public class ProductGoodsLogicService {
38 private StorageService storageService; 38 private StorageService storageService;
39 39
40 /** 40 /**
41 - * @return 41 + *
42 */ 42 */
43 public List<ProductGoodsBO> getData(List<Integer> productIds) { 43 public List<ProductGoodsBO> getData(List<Integer> productIds) {
44 - // 解析product_good视图 44 + //构建productColorsMap
45 List<ProductColor> productColors = productColorMapper.getAll(); 45 List<ProductColor> productColors = productColorMapper.getAll();
  46 + if(CollectionUtils.isEmpty(productColors)){
  47 + return new ArrayList<>();
  48 + }
46 Map<Integer, String> productColorsMap = new HashMap<>(); 49 Map<Integer, String> productColorsMap = new HashMap<>();
47 for (ProductColor p : productColors) { 50 for (ProductColor p : productColors) {
48 productColorsMap.put(p.getId(), p.getColorCode() == null ? "" : p.getColorCode()); 51 productColorsMap.put(p.getId(), p.getColorCode() == null ? "" : p.getColorCode());
49 } 52 }
50 - // 获取Goods数据  
51 - List<Goods> goodss = goodsMapper.selectListByProductIds(productIds);  
52 - // 解析goods_cover_image 视图 53 +
  54 +
  55 + List<Goods> goodsList = goodsMapper.selectListByProductIds(productIds);
53 List<Integer> goodsIds = goodsMapper.getIdByProductIds(productIds); 56 List<Integer> goodsIds = goodsMapper.getIdByProductIds(productIds);
54 - List<GoodsCoverImage> goodsCoverImages = new ArrayList<GoodsCoverImage>();  
55 - List<Storage> storages = new ArrayList<>(); 57 + List<GoodsCoverImage> goodsCoverImageList = new ArrayList<GoodsCoverImage>();
  58 + List<Storage> storageList = new ArrayList<>();
56 if (goodsIds != null && !goodsIds.isEmpty()) { 59 if (goodsIds != null && !goodsIds.isEmpty()) {
57 - goodsCoverImages = goodsCoverImageMapper.selectGoodsCoverImage(goodsIds);  
58 - storages = storageService.getStoragesByGoodsIds(goodsIds); 60 + goodsCoverImageList = goodsCoverImageMapper.selectGoodsCoverImage(goodsIds);
  61 + storageList = storageService.getStoragesByGoodsIds(goodsIds);
59 } 62 }
60 - //获取goods对应的库存  
61 - Map<Integer, Integer> storagesMap = new HashMap<>();  
62 - if (!CollectionUtils.isEmpty(storages)) {  
63 - for (Storage storage : storages) {  
64 - if (storagesMap.containsKey(storage.getGoodsId())) {  
65 - storagesMap.put(storage.getGoodsId(), storage.getStorageNum() + storagesMap.get(storage.getGoodsId())); 63 + //构建storageListMap
  64 + Map<Integer, Integer> storageListMap = new HashMap<>();
  65 + if (!CollectionUtils.isEmpty(storageList)) {
  66 + for (Storage storage : storageList) {
  67 + if (storageListMap.containsKey(storage.getGoodsId())) {
  68 + storageListMap.put(storage.getGoodsId(), storage.getStorageNum() + storageListMap.get(storage.getGoodsId()));
66 } else { 69 } else {
67 - storagesMap.put(storage.getGoodsId(), storage.getStorageNum()); 70 + storageListMap.put(storage.getGoodsId(), storage.getStorageNum());
68 } 71 }
69 } 72 }
70 } 73 }
  74 +
  75 + //构建goodsCoverImagesMap
71 Map<Integer, GoodsCoverImage> goodsCoverImagesMap = new HashMap<>(); 76 Map<Integer, GoodsCoverImage> goodsCoverImagesMap = new HashMap<>();
72 - // 用goodsId作为key  
73 - for (GoodsCoverImage g : goodsCoverImages) {  
74 - if (goodsCoverImagesMap.containsKey(g.getGoodsId())) {  
75 - GoodsCoverImage goodsCoverImage = goodsCoverImagesMap.get(g.getGoodsId());  
76 - if (StringUtils.isBlank(goodsCoverImage.getCover_1()) && !StringUtils.isBlank((g.getCover_1()))) {  
77 - goodsCoverImage.setCover_1(g.getCover_1()); 77 + for (GoodsCoverImage coverImage : goodsCoverImageList) {
  78 + if (goodsCoverImagesMap.containsKey(coverImage.getGoodsId())) {
  79 + GoodsCoverImage goodsCoverImage = goodsCoverImagesMap.get(coverImage.getGoodsId());
  80 + if (StringUtils.isBlank(goodsCoverImage.getCover_1()) && !StringUtils.isBlank((coverImage.getCover_1()))) {
  81 + goodsCoverImage.setCover_1(coverImage.getCover_1());
78 } 82 }
79 - if (StringUtils.isBlank(goodsCoverImage.getCover_2()) && !StringUtils.isBlank((g.getCover_2()))) {  
80 - goodsCoverImage.setCover_2(g.getCover_2()); 83 + if (StringUtils.isBlank(goodsCoverImage.getCover_2()) && !StringUtils.isBlank((coverImage.getCover_2()))) {
  84 + goodsCoverImage.setCover_2(coverImage.getCover_2());
81 } 85 }
82 } else { 86 } else {
83 - goodsCoverImagesMap.put(g.getGoodsId(), g); 87 + goodsCoverImagesMap.put(coverImage.getGoodsId(), coverImage);
84 } 88 }
85 } 89 }
86 - // 构造product_good视图 90 +
  91 + //根据productId分组
87 List<ProductGoodBO> productGoodBOs = new ArrayList<>(); 92 List<ProductGoodBO> productGoodBOs = new ArrayList<>();
88 - for (Goods g : goodss) { 93 + for (Goods goods : goodsList) {
89 ProductGoodBO productGoodBO = new ProductGoodBO(); 94 ProductGoodBO productGoodBO = new ProductGoodBO();
90 - productGoodBO.setProduct_id(g.getProductId());  
91 - productGoodBO.setIsDefault(g.getIsDefault() == null ? "" : g.getIsDefault());  
92 - this.buildGoods(g, productGoodBO, productColorsMap, goodsCoverImagesMap, storagesMap); 95 + productGoodBO.setProduct_id(goods.getProductId());
  96 + productGoodBO.setIsDefault(goods.getIsDefault() == null ? "" : goods.getIsDefault());
  97 + this.buildGoods(goods, productGoodBO, productColorsMap, goodsCoverImagesMap, storageListMap);
93 productGoodBOs.add(productGoodBO); 98 productGoodBOs.add(productGoodBO);
94 } 99 }
95 - // 构建product_goods视图  
96 Map<Integer, JSONArray> productGoodsMap = new HashMap<>(); 100 Map<Integer, JSONArray> productGoodsMap = new HashMap<>();
97 - for (ProductGoodBO p : productGoodBOs) {  
98 - if (productGoodsMap.containsKey(p.getProduct_id())) {  
99 - if (p.getGoodList() != null) {  
100 - JSONArray jsonArray = productGoodsMap.get(p.getProduct_id());  
101 - jsonArray.add(p.getGoodList());  
102 - productGoodsMap.put(p.getProduct_id(), jsonArray); 101 + for (ProductGoodBO productGoodBO : productGoodBOs) {
  102 + if (productGoodsMap.containsKey(productGoodBO.getProduct_id())) {
  103 + if (productGoodBO.getGoodList() != null) {
  104 + JSONArray jsonArray = productGoodsMap.get(productGoodBO.getProduct_id());
  105 + jsonArray.add(productGoodBO.getGoodList());
  106 + productGoodsMap.put(productGoodBO.getProduct_id(), jsonArray);
103 } 107 }
104 } else { 108 } else {
105 JSONArray jsonArray = new JSONArray(); 109 JSONArray jsonArray = new JSONArray();
106 - jsonArray.add(p.getGoodList());  
107 - productGoodsMap.put(p.getProduct_id(), jsonArray); 110 + jsonArray.add(productGoodBO.getGoodList());
  111 + productGoodsMap.put(productGoodBO.getProduct_id(), jsonArray);
108 } 112 }
109 } 113 }
110 List<ProductGoodsBO> productGoodsBOs = new ArrayList<>(); 114 List<ProductGoodsBO> productGoodsBOs = new ArrayList<>();
111 - // 塞入productGoodss 顺便把GoodList加上[]包裹  
112 for (Map.Entry<Integer, JSONArray> entry : productGoodsMap.entrySet()) { 115 for (Map.Entry<Integer, JSONArray> entry : productGoodsMap.entrySet()) {
113 ProductGoodsBO pg = new ProductGoodsBO(); 116 ProductGoodsBO pg = new ProductGoodsBO();
114 pg.setProductId(entry.getKey()); 117 pg.setProductId(entry.getKey());
@@ -119,30 +122,34 @@ public class ProductGoodsLogicService { @@ -119,30 +122,34 @@ public class ProductGoodsLogicService {
119 } 122 }
120 123
121 /** 124 /**
122 - * 拼装goods_list字段 125 + * 拼装goodsList字段
123 */ 126 */
124 - private void buildGoods(Goods g, ProductGoodBO productGoodBO, Map<Integer, String> productColorsMap, Map<Integer, GoodsCoverImage> goodsCoverImagesMap, Map<Integer, Integer> storagesMap) { 127 + private void buildGoods(Goods goods, ProductGoodBO productGoodBO, Map<Integer, String> productColorsMap, Map<Integer, GoodsCoverImage> goodsCoverImagesMap, Map<Integer, Integer> storageMap) {
125 JSONObject jsonObj = new JSONObject(); 128 JSONObject jsonObj = new JSONObject();
126 - jsonObj.put("goods_id", String.valueOf(g.getId()));  
127 - jsonObj.put("color_name", StringUtils.isBlank(g.getColorName())? "" : g.getColorName()); 129 + //来自Goods
  130 + jsonObj.put("goods_id", String.valueOf(goods.getId()));
  131 + jsonObj.put("color_name", StringUtils.isBlank(goods.getColorName())? "" : goods.getColorName());
  132 + jsonObj.put("images_url", StringUtils.isBlank(goods.getColorImage()) ? "" : goods.getColorImage());
  133 + jsonObj.put("is_default", StringUtils.isBlank(goods.getIsDefault())? "" : goods.getIsDefault());
  134 + jsonObj.put("color_id", goods.getColorId() == null ? "" : goods.getColorId().toString());
  135 + jsonObj.put("status", goods.getStatus() == null ? "" : goods.getStatus().toString());
  136 + jsonObj.put("product_skc", goods.getProductSkc() == null ? "" : goods.getProductSkc());
  137 + jsonObj.put("color_value", "");
  138 + //来自productColorsMap
  139 + String colorCode = productColorsMap.get(goods.getColorId());
  140 + jsonObj.put("color_code", StringUtils.isBlank(colorCode) ? "" : colorCode);
  141 + //来自goodsCoverImagesMap
  142 + GoodsCoverImage goodsCoverImage = goodsCoverImagesMap.get(goods.getId());
128 String cover_1 = ""; 143 String cover_1 = "";
129 String cover_2 = ""; 144 String cover_2 = "";
130 - GoodsCoverImage goodsCoverImage = goodsCoverImagesMap.get(g.getId());  
131 if (goodsCoverImage != null) { 145 if (goodsCoverImage != null) {
132 cover_1 = goodsCoverImage.getCover_1(); 146 cover_1 = goodsCoverImage.getCover_1();
133 cover_2 = goodsCoverImage.getCover_2(); 147 cover_2 = goodsCoverImage.getCover_2();
134 } 148 }
135 jsonObj.put("cover_1", StringUtils.isBlank(cover_1) ? "" : cover_1); 149 jsonObj.put("cover_1", StringUtils.isBlank(cover_1) ? "" : cover_1);
136 jsonObj.put("cover_2", StringUtils.isBlank(cover_2) ? "" : cover_2); 150 jsonObj.put("cover_2", StringUtils.isBlank(cover_2) ? "" : cover_2);
137 - jsonObj.put("color_id", g.getColorId() == null ? "" : g.getColorId().toString());  
138 - jsonObj.put("status", g.getStatus() == null ? "" : g.getStatus().toString());  
139 - String colorCode = productColorsMap.get(g.getColorId());  
140 - jsonObj.put("color_code", StringUtils.isBlank(colorCode) ? "" : colorCode);  
141 - jsonObj.put("color_value", "");  
142 - jsonObj.put("images_url", StringUtils.isBlank(g.getColorImage()) ? "" : g.getColorImage());  
143 - jsonObj.put("product_skc", g.getProductSkc() == null ? "" : g.getProductSkc());  
144 - jsonObj.put("is_default", StringUtils.isBlank(g.getIsDefault())? "" : g.getIsDefault());  
145 - jsonObj.put("storage_num", storagesMap.get(g.getId()) == null ? 0 : storagesMap.get(g.getId())); 151 + //来自storageMap
  152 + jsonObj.put("storage_num", storageMap.get(goods.getId()) == null ? 0 : storageMap.get(goods.getId()));
146 productGoodBO.setGoodList(jsonObj); 153 productGoodBO.setGoodList(jsonObj);
147 } 154 }
148 155
@@ -19,22 +19,15 @@ import java.util.stream.Collectors; @@ -19,22 +19,15 @@ import java.util.stream.Collectors;
19 @Component 19 @Component
20 public class ProductSearchBrandWeightLogicService { 20 public class ProductSearchBrandWeightLogicService {
21 21
22 - //数据量17万  
23 @Autowired 22 @Autowired
24 private ProductSearchMapper productSearchMapper; 23 private ProductSearchMapper productSearchMapper;
25 -  
26 @Autowired 24 @Autowired
27 private ProductSearchBrandMapper productSearchBrandMapper; 25 private ProductSearchBrandMapper productSearchBrandMapper;
28 26
29 - public List<ProductSearchBrandWeightBO> getData(List<Integer> skns) {  
30 - //构建ProductSearchBrand 视图  
31 - List<ProductSearchBrand> productSearchBrands = productSearchBrandMapper.getProductSearchBrand(skns);  
32 -  
33 - //构建ProductSearchBrandWeight 视图  
34 - //获取ProductSearch数据  
35 - List<ProductSearch> productSearches = productSearchMapper.getByIds(skns); 27 + public List<ProductSearchBrandWeightBO> getData(List<Integer> productSknList) {
  28 + List<ProductSearchBrand> productSearchBrands = productSearchBrandMapper.getProductSearchBrand(productSknList);
  29 + List<ProductSearch> productSearches = productSearchMapper.getByIds(productSknList);
36 Map<Integer, Long> productSearchesMap = productSearches.stream().collect(Collectors.toMap(ProductSearch::getId, ProductSearch::getIntValue)); 30 Map<Integer, Long> productSearchesMap = productSearches.stream().collect(Collectors.toMap(ProductSearch::getId, ProductSearch::getIntValue));
37 -  
38 List<ProductSearchBrand> productSearchBrandsNew = new ArrayList<>(); 31 List<ProductSearchBrand> productSearchBrandsNew = new ArrayList<>();
39 for (ProductSearchBrand p : productSearchBrands) { 32 for (ProductSearchBrand p : productSearchBrands) {
40 if (productSearchesMap.containsKey(p.getBrandWeightId())) { 33 if (productSearchesMap.containsKey(p.getBrandWeightId())) {
@@ -21,19 +21,13 @@ public class ProductSearchShopWeightLogicService { @@ -21,19 +21,13 @@ public class ProductSearchShopWeightLogicService {
21 21
22 @Autowired 22 @Autowired
23 private ProductSearchMapper productSearchMapper; 23 private ProductSearchMapper productSearchMapper;
24 -  
25 @Autowired 24 @Autowired
26 private ProductSearchShopMapper productSearchShopMapper; 25 private ProductSearchShopMapper productSearchShopMapper;
27 26
28 - public List<ProductSearchShopWeightBO> getData(List<Integer> skns) {  
29 - //构建ProductSearchBrand 视图  
30 - List<ProductSearchShop> productSearchBrands = productSearchShopMapper.getProductSearchShop(skns);  
31 -  
32 - //构建ProductSearchBrandWeight 视图  
33 - //获取ProductSearch数据  
34 - List<ProductSearch> productSearches = productSearchMapper.getByIds(skns); 27 + public List<ProductSearchShopWeightBO> getData(List<Integer> productSknList) {
  28 + List<ProductSearchShop> productSearchBrands = productSearchShopMapper.getProductSearchShop(productSknList);
  29 + List<ProductSearch> productSearches = productSearchMapper.getByIds(productSknList);
35 Map<Integer, Long> productSearchesMap = productSearches.stream().collect(Collectors.toMap(ProductSearch::getId, ProductSearch::getIntValue)); 30 Map<Integer, Long> productSearchesMap = productSearches.stream().collect(Collectors.toMap(ProductSearch::getId, ProductSearch::getIntValue));
36 -  
37 List<ProductSearchShop> productSearchBrandsNew = new ArrayList<>(); 31 List<ProductSearchShop> productSearchBrandsNew = new ArrayList<>();
38 for (ProductSearchShop p : productSearchBrands) { 32 for (ProductSearchShop p : productSearchBrands) {
39 if (productSearchesMap.containsKey(p.getShopWeightId())) { 33 if (productSearchesMap.containsKey(p.getShopWeightId())) {
@@ -21,20 +21,13 @@ public class ProductSearchSortWeightLogicService { @@ -21,20 +21,13 @@ public class ProductSearchSortWeightLogicService {
21 21
22 @Autowired 22 @Autowired
23 private ProductSearchMapper productSearchMapper; 23 private ProductSearchMapper productSearchMapper;
24 -  
25 @Autowired 24 @Autowired
26 private ProductSearchSortMapper productSearchSortMapper; 25 private ProductSearchSortMapper productSearchSortMapper;
27 26
28 - public List<ProductSearchSortWeightBO> getData(List<Integer> skns) {  
29 - // 构建ProductSearchSort 视图  
30 - List<ProductSearchSort> productSearchSorts = productSearchSortMapper.getProductSearchSort(skns);  
31 -  
32 - // 构建ProductSearchSortWeight 视图  
33 - // 获取ProductSearch数据  
34 - List<ProductSearch> productSearches = productSearchMapper.getByIds(skns);  
35 - 27 + public List<ProductSearchSortWeightBO> getData(List<Integer> productSknList) {
  28 + List<ProductSearchSort> productSearchSorts = productSearchSortMapper.getProductSearchSort(productSknList);
  29 + List<ProductSearch> productSearches = productSearchMapper.getByIds(productSknList);
36 Map<Integer, Long> productSearchesMap = productSearches.stream().collect(Collectors.toMap(ProductSearch::getId, ProductSearch::getIntValue)); 30 Map<Integer, Long> productSearchesMap = productSearches.stream().collect(Collectors.toMap(ProductSearch::getId, ProductSearch::getIntValue));
37 -  
38 List<ProductSearchSort> productSearchSortsNew = new ArrayList<>(); 31 List<ProductSearchSort> productSearchSortsNew = new ArrayList<>();
39 for (ProductSearchSort p : productSearchSorts) { 32 for (ProductSearchSort p : productSearchSorts) {
40 if (productSearchesMap.containsKey(p.getSortWeightId())) { 33 if (productSearchesMap.containsKey(p.getSortWeightId())) {
@@ -51,5 +44,4 @@ public class ProductSearchSortWeightLogicService { @@ -51,5 +44,4 @@ public class ProductSearchSortWeightLogicService {
51 } 44 }
52 return productSearchSortWeightBOs; 45 return productSearchSortWeightBOs;
53 } 46 }
54 -  
55 } 47 }
@@ -25,17 +25,14 @@ public class ProductStandardsLogicService { @@ -25,17 +25,14 @@ public class ProductStandardsLogicService {
25 // 数据量300 25 // 数据量300
26 @Autowired 26 @Autowired
27 private StandardMapper standardMapper; 27 private StandardMapper standardMapper;
28 -  
29 // 数据量5000 28 // 数据量5000
30 @Autowired 29 @Autowired
31 private ParameterMakeMapper parameterMakeMapper; 30 private ParameterMakeMapper parameterMakeMapper;
32 -  
33 // 数据量90万,需要多线程 31 // 数据量90万,需要多线程
34 @Autowired 32 @Autowired
35 private ProductStandardRelationMapper productStandardRelationMapper; 33 private ProductStandardRelationMapper productStandardRelationMapper;
36 34
37 /** 35 /**
38 - * @return  
39 */ 36 */
40 public List<ProductStandardsBO> getData(List<Integer> ids) { 37 public List<ProductStandardsBO> getData(List<Integer> ids) {
41 38
@@ -89,7 +86,7 @@ public class ProductStandardsLogicService { @@ -89,7 +86,7 @@ public class ProductStandardsLogicService {
89 } 86 }
90 } 87 }
91 // 构造ProductStandards列表 88 // 构造ProductStandards列表
92 - List<ProductStandardsBO> productStandardseBOs = new ArrayList<>(); 89 + List<ProductStandardsBO> productStandardsBOS = new ArrayList<>();
93 for (Map.Entry<Integer, String[]> entry : productStandardRelationsMap.entrySet()) { 90 for (Map.Entry<Integer, String[]> entry : productStandardRelationsMap.entrySet()) {
94 ProductStandardsBO productStandardsBO = new ProductStandardsBO(); 91 ProductStandardsBO productStandardsBO = new ProductStandardsBO();
95 productStandardsBO.setProductId(entry.getKey()); 92 productStandardsBO.setProductId(entry.getKey());
@@ -97,10 +94,10 @@ public class ProductStandardsLogicService { @@ -97,10 +94,10 @@ public class ProductStandardsLogicService {
97 productStandardsBO.setStandardIds(valueArray[0]); 94 productStandardsBO.setStandardIds(valueArray[0]);
98 productStandardsBO.setStandardNames(valueArray[1]); 95 productStandardsBO.setStandardNames(valueArray[1]);
99 productStandardsBO.setStandardOnlyNames(valueArray[2]); 96 productStandardsBO.setStandardOnlyNames(valueArray[2]);
100 - productStandardseBOs.add(productStandardsBO); 97 + productStandardsBOS.add(productStandardsBO);
101 } 98 }
102 99
103 - return productStandardseBOs; 100 + return productStandardsBOS;
104 101
105 } 102 }
106 103
@@ -34,19 +34,17 @@ public class StorageUpdateTimeLogicService { @@ -34,19 +34,17 @@ public class StorageUpdateTimeLogicService {
34 @Autowired 34 @Autowired
35 private ProductService productService; 35 private ProductService productService;
36 36
37 -  
38 -  
39 - public List<StorageUpdateTime> getData(List<Integer> productIds, List<Integer> productSkns) {  
40 - if (CollectionUtils.isEmpty(productIds) || CollectionUtils.isEmpty(productSkns)) {  
41 - return new ArrayList<StorageUpdateTime>(); 37 + public List<StorageUpdateTime> getData(List<Integer> productIds, List<Integer> productSknList) {
  38 + if (CollectionUtils.isEmpty(productIds) || CollectionUtils.isEmpty(productSknList)) {
  39 + return new ArrayList<>();
42 } 40 }
43 //查询Product对应的StorageUpdateTime 41 //查询Product对应的StorageUpdateTime
44 List<StorageUpdateTime> storageUpdateTimes = storageService.getStorageUpdateTime(productIds); 42 List<StorageUpdateTime> storageUpdateTimes = storageService.getStorageUpdateTime(productIds);
45 if (CollectionUtils.isEmpty(storageUpdateTimes)) { 43 if (CollectionUtils.isEmpty(storageUpdateTimes)) {
46 logger.warn("[class=StorageUpdateTimeLogicService][fun=getData][message={}]", "storageUpdateTimes is empty"); 44 logger.warn("[class=StorageUpdateTimeLogicService][fun=getData][message={}]", "storageUpdateTimes is empty");
47 - return new ArrayList<StorageUpdateTime>(); 45 + return new ArrayList<>();
48 } 46 }
49 - List<ProductTiming> productTimings = productTimingService.selectBySkns(productSkns); 47 + List<ProductTiming> productTimings = productTimingService.selectBySkns(productSknList);
50 Map<Integer, Integer> outSaleTimeMap = new HashMap<>(); 48 Map<Integer, Integer> outSaleTimeMap = new HashMap<>();
51 for (ProductTiming productTiming : productTimings) { 49 for (ProductTiming productTiming : productTimings) {
52 if (outSaleTimeMap.containsKey(productTiming.getProductSkn())) { 50 if (outSaleTimeMap.containsKey(productTiming.getProductSkn())) {