|
|
@@ -1,9 +1,9 @@
|
|
|
package com.uas.search.dao;
|
|
|
|
|
|
import com.uas.search.model.*;
|
|
|
+import com.uas.search.util.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Repository;
|
|
|
-import com.uas.search.util.CollectionUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
@@ -106,10 +106,15 @@ public class GoodsDao {
|
|
|
if (component == null || component.getUuid() == null) {
|
|
|
return null;
|
|
|
}
|
|
|
- List<TradeGoods> tradeGoodsesList = tradeGoodsDao.findByCmpUuid(component.getUuid());
|
|
|
List<Goods> goodsesList = new ArrayList<>();
|
|
|
+ List<TradeGoods> tradeGoodsesList = tradeGoodsDao.findByCmpUuid(component.getUuid());
|
|
|
+ boolean hasValidGoods = false;
|
|
|
if (!CollectionUtils.isEmpty(tradeGoodsesList)) {
|
|
|
for (TradeGoods tradeGoods : tradeGoodsesList) {
|
|
|
+ // 判断器件下是否有状态有效的批次
|
|
|
+ if (!hasValidGoods && isValidStatus(tradeGoods.getStatus())) {
|
|
|
+ hasValidGoods = true;
|
|
|
+ }
|
|
|
Store store = null;
|
|
|
Products products = null;
|
|
|
if (tradeGoods.getStoreId() != null) {
|
|
|
@@ -120,9 +125,30 @@ public class GoodsDao {
|
|
|
}
|
|
|
goodsesList.add(new Goods(tradeGoods, store, component, products));
|
|
|
}
|
|
|
- } else {
|
|
|
+ }
|
|
|
+
|
|
|
+ // 器件下没有状态有效的批次(可能没有批次,或者批次状态全都无效)时,另外保存一份不含批次信息的器件数据
|
|
|
+ if (!hasValidGoods) {
|
|
|
goodsesList.add(new Goods(null, null, component, null));
|
|
|
}
|
|
|
return goodsesList;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 是否为有效状态
|
|
|
+ *
|
|
|
+ * @param status 状态
|
|
|
+ * @return true 有效;false 无效
|
|
|
+ */
|
|
|
+ private boolean isValidStatus(Long status) {
|
|
|
+ if (status == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ for (Long validStatus : TradeGoods.VALID_STATUS) {
|
|
|
+ if (validStatus.longValue() == status.longValue()) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|