|
|
@@ -169,37 +169,38 @@ public class ObjectToDocumentUtils {
|
|
|
* @return
|
|
|
*/
|
|
|
public static Document toDocument(Goods goods) {
|
|
|
- if (goods == null || StringUtils.isEmpty(goods.getCmpId()) || StringUtils.isEmpty(goods.getCmpCode())
|
|
|
- || goods.getKind() == null || goods.getBrand() == null) {
|
|
|
+ if (goods == null || goods.getComponent() == null || StringUtils.isEmpty(goods.getComponent().getId()) ||
|
|
|
+ StringUtils.isEmpty(goods.getComponent().getCode()) || goods.getComponent().getKind() == null ||
|
|
|
+ goods.getComponent().getBrand() == null) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
Document document = new Document();
|
|
|
- if (goods.getId() != null) {
|
|
|
- document.add(new StringField(SearchConstants.GOODS_ID_FIELD, goods.getId(), Store.YES));
|
|
|
- }
|
|
|
- if (goods.getGoId() != null) {
|
|
|
- document.add(
|
|
|
- new StringField(SearchConstants.GOODS_GO_ID_FIELD, String.valueOf(goods.getGoId()), Store.YES));
|
|
|
- }
|
|
|
- if (goods.getGoReserve() != null) {
|
|
|
- document.add(new DoubleDocValuesField(SearchConstants.GOODS_GO_RESERVE_FIELD, goods.getGoReserve()));
|
|
|
- document.add(new DoubleField(SearchConstants.GOODS_GO_RESERVE_FIELD, goods.getGoReserve(), Store.YES));
|
|
|
- }
|
|
|
- if (goods.getGoMinPriceRMB() != null) {
|
|
|
- document.add(
|
|
|
- new DoubleDocValuesField(SearchConstants.GOODS_GO_MINPRICERMB_FIELD, goods.getGoMinPriceRMB()));
|
|
|
- document.add(
|
|
|
- new DoubleField(SearchConstants.GOODS_GO_MINPRICERMB_FIELD, goods.getGoMinPriceRMB(), Store.YES));
|
|
|
- }
|
|
|
- if (goods.getGoMinPriceUSD() != null) {
|
|
|
- document.add(
|
|
|
- new DoubleDocValuesField(SearchConstants.GOODS_GO_MINPRICEUSD_FIELD, goods.getGoMinPriceUSD()));
|
|
|
- document.add(
|
|
|
- new DoubleField(SearchConstants.GOODS_GO_MINPRICEUSD_FIELD, goods.getGoMinPriceUSD(), Store.YES));
|
|
|
- }
|
|
|
- if (goods.getCrName() != null) {
|
|
|
- document.add(new TextField(SearchConstants.GOODS_CRNAME_FIELD, goods.getCrName(), Store.YES));
|
|
|
+ if(goods.getTradeGoods() != null){
|
|
|
+ TradeGoods tradeGoods = goods.getTradeGoods();
|
|
|
+ if (tradeGoods.getId() != null) {
|
|
|
+ document.add(
|
|
|
+ new StringField(SearchConstants.GOODS_GO_ID_FIELD, String.valueOf(tradeGoods.getId()), Store.YES));
|
|
|
+ }
|
|
|
+ if (tradeGoods.getReserve() != null) {
|
|
|
+ document.add(new DoubleDocValuesField(SearchConstants.GOODS_GO_RESERVE_FIELD, tradeGoods.getReserve()));
|
|
|
+ document.add(new DoubleField(SearchConstants.GOODS_GO_RESERVE_FIELD, tradeGoods.getReserve(), Store.YES));
|
|
|
+ }
|
|
|
+ if (tradeGoods.getMinPriceRMB() != null) {
|
|
|
+ document.add(
|
|
|
+ new DoubleDocValuesField(SearchConstants.GOODS_GO_MINPRICERMB_FIELD, tradeGoods.getMinPriceRMB()));
|
|
|
+ document.add(
|
|
|
+ new DoubleField(SearchConstants.GOODS_GO_MINPRICERMB_FIELD, tradeGoods.getMinPriceRMB(), Store.YES));
|
|
|
+ }
|
|
|
+ if (tradeGoods.getMinPriceUSD() != null) {
|
|
|
+ document.add(
|
|
|
+ new DoubleDocValuesField(SearchConstants.GOODS_GO_MINPRICEUSD_FIELD, tradeGoods.getMinPriceUSD()));
|
|
|
+ document.add(
|
|
|
+ new DoubleField(SearchConstants.GOODS_GO_MINPRICEUSD_FIELD, tradeGoods.getMinPriceUSD(), Store.YES));
|
|
|
+ }
|
|
|
+ if (tradeGoods.getCrName() != null) {
|
|
|
+ document.add(new TextField(SearchConstants.GOODS_CRNAME_FIELD, tradeGoods.getCrName(), Store.YES));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (goods.getStore() != null) {
|
|
|
@@ -212,10 +213,11 @@ public class ObjectToDocumentUtils {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- document.add(new StringField(SearchConstants.GOODS_CMP_ID_FIELD, String.valueOf(goods.getCmpId()), Store.YES));
|
|
|
- document.add(new TextField(SearchConstants.GOODS_CMP_CODE_FIELD, goods.getCmpCode(), Store.YES));
|
|
|
+ Component component = goods.getComponent();
|
|
|
+ document.add(new StringField(SearchConstants.GOODS_CMP_ID_FIELD, String.valueOf(component.getId()), Store.YES));
|
|
|
+ document.add(new TextField(SearchConstants.GOODS_CMP_CODE_FIELD, component.getCode(), Store.YES));
|
|
|
|
|
|
- Kind kind = goods.getKind();
|
|
|
+ Kind kind = component.getKind();
|
|
|
if (kind.getId() != null) {
|
|
|
document.add(new StringField(SearchConstants.GOODS_KI_ID_FIELD, String.valueOf(kind.getId()), Store.YES));
|
|
|
}
|
|
|
@@ -231,7 +233,7 @@ public class ObjectToDocumentUtils {
|
|
|
new StringField(SearchConstants.GOODS_KI_ISLEAF_FIELD, String.valueOf(kind.getLevel()), Store.YES));
|
|
|
}
|
|
|
|
|
|
- Brand brand = goods.getBrand();
|
|
|
+ Brand brand = component.getBrand();
|
|
|
if (brand.getId() != null) {
|
|
|
document.add(new StringField(SearchConstants.GOODS_BR_ID_FIELD, String.valueOf(brand.getId()), Store.YES));
|
|
|
}
|
|
|
@@ -249,8 +251,8 @@ public class ObjectToDocumentUtils {
|
|
|
document.add(new StringField(SearchConstants.GOODS_BR_UUID_FIELD, brand.getUuid(), Store.YES));
|
|
|
}
|
|
|
|
|
|
- if (goods.getDescription() != null) {
|
|
|
- document.add(new TextField(SearchConstants.GOODS_CMP_DESCRIPTION_FIELD, goods.getDescription(), Store.YES));
|
|
|
+ if (component.getDescription() != null) {
|
|
|
+ document.add(new TextField(SearchConstants.GOODS_CMP_DESCRIPTION_FIELD, component.getDescription(), Store.YES));
|
|
|
}
|
|
|
return document;
|
|
|
}
|