mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 21:32:07 +08:00
优化生产保存接口-获得生产单数据源接口逻辑修改-新增排单接口逻辑修改
This commit is contained in:
+9
@@ -59,6 +59,15 @@ public interface ESDocumentService {
|
||||
<T> BulkResponse bulkCreate(String idxName, List<?extends ESDocument> documents) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 批量更新文档
|
||||
* @param idxName 索引名
|
||||
* @param documents 要更新的对象集合
|
||||
* @return 批量更新的结果
|
||||
*/
|
||||
<T> BulkResponse bulkUpdate(String idxName, List<?extends ESDocument> documents) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 根据文档id查找文档
|
||||
* @param idxName 索引名
|
||||
|
||||
+34
@@ -156,6 +156,40 @@ public class ESDocumentServiceImpl implements ESDocumentService {
|
||||
return elasticsearchClient.bulk(br.build());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 批量方式更新文档
|
||||
*
|
||||
* @param idxName 索引名
|
||||
* @param documents 要更新的对象集合
|
||||
*/
|
||||
@Override
|
||||
public <T> BulkResponse bulkUpdate(String idxName, List<? extends ESDocument> documents) throws Exception {
|
||||
BulkRequest.Builder br = new BulkRequest.Builder();
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
Date date = new Date();
|
||||
documents.forEach(esDocument -> {
|
||||
// 假设esDocument有一个ID集。如果没有,则应该抛出异常或进行相应的处理。
|
||||
if (StrUtil.isBlank(esDocument.getId())) {
|
||||
throw new IllegalArgumentException("更新操作的文档ID不能为空");
|
||||
}
|
||||
esDocument.setUpdater(loginUser.getNickname());
|
||||
esDocument.setUpdateTime(simpleDateFormat.format(date));
|
||||
|
||||
br.operations(op -> op.update(u -> u
|
||||
.index(idxName)
|
||||
.id(esDocument.getId())
|
||||
.action(a -> a
|
||||
.doc(esDocument))));
|
||||
});
|
||||
return elasticsearchClient.bulk(br.build());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param idxName 索引名称
|
||||
* @param docId 文档id
|
||||
|
||||
Reference in New Issue
Block a user