|
|
@@ -30,6 +30,7 @@ import com.uas.platform.core.model.PageParams;
|
|
|
import com.uas.search.console.LuceneProperties;
|
|
|
import com.uas.search.console.dao.BrandSimpleInfoDao;
|
|
|
import com.uas.search.console.dao.ComponentSimpleInfoDao;
|
|
|
+import com.uas.search.console.dao.GoodsSimpleInfoDao;
|
|
|
import com.uas.search.console.dao.KindSimpleInfoDao;
|
|
|
import com.uas.search.console.dao.LuceneQueueMessageDao;
|
|
|
import com.uas.search.console.dao.OrderInvoiceSimpleInfoDao;
|
|
|
@@ -81,6 +82,9 @@ public class IndexServiceImpl implements IndexService {
|
|
|
@Autowired
|
|
|
private ComponentSimpleInfoDao componentDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private GoodsSimpleInfoDao goodsDao;
|
|
|
+
|
|
|
@Autowired
|
|
|
private OrderSimpleInfoDao orderDao;
|
|
|
|
|
|
@@ -570,6 +574,8 @@ public class IndexServiceImpl implements IndexService {
|
|
|
} else if (obj instanceof ComponentSimpleInfo) {
|
|
|
indexWriter.deleteDocuments(new Term(SearchConstants.COMPONENT_ID_FIELD,
|
|
|
String.valueOf(((ComponentSimpleInfo) obj).getId())));
|
|
|
+ } else if (obj instanceof GoodsSimpleInfo) {
|
|
|
+ indexWriter.deleteDocuments(toTerm((GoodsSimpleInfo) obj));
|
|
|
} else if (obj instanceof OrderSimpleInfo) {
|
|
|
indexWriter.deleteDocuments(
|
|
|
new Term(SearchConstants.ORDER_ID_FIELD, String.valueOf(((OrderSimpleInfo) obj).getId())));
|
|
|
@@ -598,6 +604,21 @@ public class IndexServiceImpl implements IndexService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据goods构造Term
|
|
|
+ *
|
|
|
+ * @param goods
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Term toTerm(GoodsSimpleInfo goods) {
|
|
|
+ if (goods.getGoId() != null) {
|
|
|
+ return new Term(SearchConstants.GOODS_GO_ID_FIELD, String.valueOf(goods.getGoId()));
|
|
|
+ } else if (goods.getCmpId() != null) {
|
|
|
+ return new Term(SearchConstants.GOODS_CMP_ID_FIELD, String.valueOf(goods.getCmpId()));
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<Object> maintainIndexes(ParsedQueueMessage parsedQueueMessage) {
|
|
|
if (parsedQueueMessage == null) {
|
|
|
@@ -613,9 +634,20 @@ public class IndexServiceImpl implements IndexService {
|
|
|
// 新增、更新索引
|
|
|
if (parsedQueueMessage.isInsert() || parsedQueueMessage.isUpdate()) {
|
|
|
for (Object object : objects) {
|
|
|
- Object maintainedObject = update(object);
|
|
|
- if (maintainedObject != null) {
|
|
|
- maintainedObjects.add(maintainedObject);
|
|
|
+ if (object instanceof GoodsSimpleInfo) {
|
|
|
+ List<GoodsSimpleInfo> goodsesList = goodsDao.find((GoodsSimpleInfo) object);
|
|
|
+ delete(object);
|
|
|
+ for (GoodsSimpleInfo goods : goodsesList) {
|
|
|
+ Object maintainedObject = save(goods);
|
|
|
+ if (maintainedObject != null) {
|
|
|
+ maintainedObjects.add(maintainedObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Object maintainedObject = update(object);
|
|
|
+ if (maintainedObject != null) {
|
|
|
+ maintainedObjects.add(maintainedObject);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|