|
|
@@ -674,11 +674,11 @@ public class IndexServiceImpl implements IndexService {
|
|
|
* @return
|
|
|
*/
|
|
|
private Term toTerm(Goods goods) {
|
|
|
- if (goods.getTradeGoods() != null) {
|
|
|
- return new Term(SearchConstants.GOODS_GO_ID_FIELD, String.valueOf(goods.getTradeGoods().getId()));
|
|
|
- } else if (goods.getComponent() != null) {
|
|
|
- return new Term(SearchConstants.GOODS_CMP_ID_FIELD, String.valueOf(goods.getComponent().getId()));
|
|
|
- }
|
|
|
+ if (goods.getComponent() != null) {
|
|
|
+ return new Term(SearchConstants.GOODS_CMP_ID_FIELD, String.valueOf(goods.getComponent().getId()));
|
|
|
+ } else if (goods.getTradeGoods() != null) {
|
|
|
+ return new Term(SearchConstants.GOODS_GO_ID_FIELD, String.valueOf(goods.getTradeGoods().getId()));
|
|
|
+ }
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@@ -710,9 +710,25 @@ public class IndexServiceImpl implements IndexService {
|
|
|
}
|
|
|
// 删除索引
|
|
|
else if (parsedQueueMessage.isDelete()) {
|
|
|
- Object maintainedObject = delete(object);
|
|
|
- if (maintainedObject != null) {
|
|
|
- maintainedObjects.add(maintainedObject);
|
|
|
+ if (object instanceof Goods) {
|
|
|
+ // 先删除相关批次和器件,再重新写入
|
|
|
+ delete(object);
|
|
|
+ Goods goodsObject = (Goods) object;
|
|
|
+ if (goodsObject.getComponent() != null && goodsObject.getComponent().getId() != null) {
|
|
|
+ // 如果是器件,再重新写入
|
|
|
+ List<Goods> goodsesList = goodsDao.find((Goods) object);
|
|
|
+ for (Goods goods : goodsesList) {
|
|
|
+ Object maintainedObject = save(goods);
|
|
|
+ if (maintainedObject != null) {
|
|
|
+ maintainedObjects.add(maintainedObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Object maintainedObject = delete(object);
|
|
|
+ if (maintainedObject != null) {
|
|
|
+ maintainedObjects.add(maintainedObject);
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
throw new IllegalStateException("message parsing failed!");
|