mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 21:32:07 +08:00
处理ES字段的mapping映射
This commit is contained in:
-2
@@ -6,8 +6,6 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
import static com.cf.imes.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT;
|
||||
|
||||
|
||||
+10
-10
@@ -37,8 +37,7 @@ public class ESDocumentServiceImpl implements ESDocumentService {
|
||||
|
||||
private Snowflake snowflake = IdUtil.getSnowflake();
|
||||
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ISO_DATE_TIME;
|
||||
ZoneId utc = ZoneId.of("UTC");
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
public ESDocumentServiceImpl(ElasticsearchClient elasticsearchClient, ElasticsearchAsyncClient elasticsearchAsyncClient) {
|
||||
this.elasticsearchClient = elasticsearchClient;
|
||||
@@ -47,13 +46,13 @@ public class ESDocumentServiceImpl implements ESDocumentService {
|
||||
|
||||
@Override
|
||||
public <T> IndexResponse createByFluentDSL(String idxName, String idxId, ESDocument document) throws Exception {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
Date date = new Date();
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
document.setCreator(loginUser.getId());
|
||||
document.setUpdater(loginUser.getId());
|
||||
document.setOrganId(loginUser.getOrganId());
|
||||
document.setCreateTime((now.atZone(utc).format(dateTimeFormatter)));
|
||||
document.setUpdateTime((now.atZone(utc).format(dateTimeFormatter)));
|
||||
document.setCreateTime(simpleDateFormat.format(date));
|
||||
document.setUpdateTime(simpleDateFormat.format(date));
|
||||
if (StrUtil.isBlank(document.getId())) {
|
||||
document.setId(snowflake.nextIdStr());
|
||||
}
|
||||
@@ -73,12 +72,12 @@ public class ESDocumentServiceImpl implements ESDocumentService {
|
||||
@Override
|
||||
public <T> IndexResponse createByBuilderPattern(String idxName, String idxId, ESDocument document) throws Exception {
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
Date date = new Date();
|
||||
document.setCreator(loginUser.getId());
|
||||
document.setUpdater(loginUser.getId());
|
||||
document.setOrganId(loginUser.getOrganId());
|
||||
document.setCreateTime((now.atZone(utc).format(dateTimeFormatter)));
|
||||
document.setUpdateTime((now.atZone(utc).format(dateTimeFormatter)));
|
||||
document.setCreateTime(simpleDateFormat.format(date));
|
||||
document.setUpdateTime(simpleDateFormat.format(date));
|
||||
IndexRequest.Builder<Object> indexReqBuilder = new IndexRequest.Builder<>();
|
||||
indexReqBuilder.index(idxName);
|
||||
if (StrUtil.isBlank(idxId)) {
|
||||
@@ -144,9 +143,10 @@ public class ESDocumentServiceImpl implements ESDocumentService {
|
||||
esDocument.setId(snowflake.nextIdStr());
|
||||
}
|
||||
esDocument.setCreator(loginUser.getId());
|
||||
esDocument.setCreateTime(now.atZone(utc).format(dateTimeFormatter));
|
||||
esDocument.setCreateTime(simpleDateFormat.format(date));
|
||||
esDocument.setUpdater(loginUser.getId());
|
||||
esDocument.setUpdateTime(now.atZone(utc).format(dateTimeFormatter));
|
||||
|
||||
esDocument.setUpdateTime(simpleDateFormat.format(date));
|
||||
br.operations(op -> op.index(idx -> idx
|
||||
.index(idxName)
|
||||
.id(esDocument.getId().toString())
|
||||
|
||||
Reference in New Issue
Block a user