|
|
@@ -6,6 +6,7 @@ import java.io.FileNotFoundException;
|
|
|
import java.io.FileReader;
|
|
|
import java.io.IOException;
|
|
|
import java.nio.file.Paths;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
|
@@ -55,6 +56,7 @@ import com.uas.search.console.support.IndexWriterManager;
|
|
|
import com.uas.search.console.util.MergeComponentData;
|
|
|
import com.uas.search.console.util.ObjectToDocumentUtils;
|
|
|
import com.uas.search.console.util.SearchConstants;
|
|
|
+import com.uas.search.exception.SearchException;
|
|
|
|
|
|
/**
|
|
|
* 创建索引
|
|
|
@@ -676,4 +678,42 @@ public class IndexServiceImpl implements IndexService {
|
|
|
logger.info("Deleted... " + obj + "\n");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String maintainIndexes(String tableName, String ids) {
|
|
|
+ if (StringUtils.isEmpty(tableName)) {
|
|
|
+ throw new SearchException("需指定要维护的表名:" + SearchConstants.KIND_TABLE_NAME + "、"
|
|
|
+ + SearchConstants.BRAND_TABLE_NAME + "、" + SearchConstants.COMPONENT_TABLE_NAME);
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(ids)) {
|
|
|
+ throw new SearchException("需指定要维护的ids,多个id以英文逗号隔开,如:321,988");
|
|
|
+ }
|
|
|
+
|
|
|
+ String[] strs = ids.split(",");
|
|
|
+ Long[] longIds = new Long[strs.length];
|
|
|
+ for (int i = 0; i < strs.length; i++) {
|
|
|
+ longIds[i] = Long.parseLong(strs[i]);
|
|
|
+ }
|
|
|
+ logger.info(Arrays.toString(longIds));
|
|
|
+ if (tableName.equals(SearchConstants.KIND_TABLE_NAME)) {
|
|
|
+ List<KindSimpleInfo> kinds = kindDao.findByIds(longIds);
|
|
|
+ for (KindSimpleInfo kind : kinds) {
|
|
|
+ update(kind);
|
|
|
+ }
|
|
|
+ } else if (tableName.equals(SearchConstants.BRAND_TABLE_NAME)) {
|
|
|
+ List<BrandSimpleInfo> brands = brandDao.findByIds(longIds);
|
|
|
+ for (BrandSimpleInfo brand : brands) {
|
|
|
+ update(brand);
|
|
|
+ }
|
|
|
+ } else if (tableName.equals(SearchConstants.COMPONENT_TABLE_NAME)) {
|
|
|
+ List<ComponentSimpleInfo> components = componentDao.findByIds(longIds);
|
|
|
+ logger.info(components);
|
|
|
+ for (ComponentSimpleInfo component : components) {
|
|
|
+ update(component);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new SearchException("需指定要维护的ids,多个id以英文逗号隔开,如:321,988");
|
|
|
+ }
|
|
|
+ return "维护成功";
|
|
|
+ }
|
|
|
+
|
|
|
}
|