|
@@ -35,9 +35,8 @@ import org.springframework.util.CollectionUtils;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.text.ParseException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.List;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -167,17 +166,39 @@ public class EsDenseVectorService {
|
|
|
return pictureNoVos.stream().sorted(Comparator.comparing(EsPictureNoVo::getImageIndex)).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
- public String appendCondition(Integer productId,String keyword) throws Exception {
|
|
|
+ /**
|
|
|
+ * 拼接检索条件
|
|
|
+ *
|
|
|
+ * @param productId
|
|
|
+ * @param keyword
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public String appendCondition(Integer productId, String keyword) {
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
|
|
+ SimpleDateFormat format1 = new SimpleDateFormat("yyyy");
|
|
|
+
|
|
|
+
|
|
|
String condition = "";
|
|
|
String searchCondition = "";
|
|
|
if (productId != null) {
|
|
|
Product product = productMapper.selectById(productId);
|
|
|
searchCondition = product.getSearchCondition();
|
|
|
+
|
|
|
+ Date now = new Date();
|
|
|
+ String nowFormat = format.format(now);
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(now);
|
|
|
+ calendar.add(Calendar.YEAR, -3);
|
|
|
+ Date beforeDate = calendar.getTime();
|
|
|
+ String agoFormat = format1.format(beforeDate) + "0101";
|
|
|
+ String s = agoFormat + "~" + nowFormat;
|
|
|
+ searchCondition = searchCondition + " AND " + "AD = " + "(" + s + ")";
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(searchCondition)) {
|
|
|
if (StringUtils.isNotEmpty(keyword)) {
|
|
|
String key = keyword.replaceAll("[,。、;,./;]", " OR ");
|
|
|
- condition = "TI = " + "(" + key + ")" + " AND " + searchCondition;
|
|
|
+ condition = "TI = " + "(" + key + ")" + " AND " + searchCondition;
|
|
|
} else {
|
|
|
condition = searchCondition;
|
|
|
}
|
|
@@ -185,7 +206,7 @@ public class EsDenseVectorService {
|
|
|
//获取关键词
|
|
|
if (StringUtils.isNotEmpty(keyword)) {
|
|
|
// String key = dto.getKey().replaceAll("[,。、;,./;\\s]"," OR ");
|
|
|
- String key = keyword.replaceAll("[,。、;,./;]"," OR ");
|
|
|
+ String key = keyword.replaceAll("[,。、;,./;]", " OR ");
|
|
|
condition = "TI = " + "(" + key + ")";
|
|
|
}
|
|
|
}
|