mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 05:12:07 +08:00
新增:ES文档数据手动刷新
This commit is contained in:
+26
-11
@@ -6,6 +6,7 @@ import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
||||
import co.elastic.clients.elasticsearch._types.FieldValue;
|
||||
import co.elastic.clients.elasticsearch.core.*;
|
||||
import co.elastic.clients.elasticsearch.core.search.Hit;
|
||||
import co.elastic.clients.elasticsearch.indices.RefreshRequest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.cf.imes.framework.common.enums.OrderStatusEnum;
|
||||
import com.cf.imes.framework.common.enums.PlanStatusEnum;
|
||||
@@ -230,7 +231,7 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
|
||||
}catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
throw new ServiceException(ES_ERROR_UPDATE);
|
||||
throw new ServiceException(ES_DATA_ERROR);
|
||||
}
|
||||
|
||||
if(cutedBoardNumber > 0){
|
||||
@@ -333,7 +334,7 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage());
|
||||
throw new ServiceException(ES_ERROR_UPDATE);
|
||||
throw new ServiceException(ES_DATA_ERROR);
|
||||
}
|
||||
|
||||
if(cutedBoardInfo.getCutedBoardNumber() == 0){
|
||||
@@ -708,7 +709,8 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
// 保存优化后的大板数据
|
||||
batchSaveBoardModel(req.getOptimizeBoardModelDOS());
|
||||
|
||||
|
||||
// ES文档数据刷新
|
||||
refresh(ORDER_REMAIN_PLATE_MODEL);
|
||||
|
||||
plateMapper.updatePlateOptimized(orderIds,ids,getUserOrganId());
|
||||
|
||||
@@ -774,12 +776,9 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
*/
|
||||
public void batchSaveBoardModel(List<OptimizeBoardModelDO> optimizeBoardModelDOS) {
|
||||
try {
|
||||
BulkResponse bulkResponse = esDocumentService.bulkCreate(ORDER_REMAIN_PLATE_MODEL, optimizeBoardModelDOS);
|
||||
boolean errors = bulkResponse.errors();
|
||||
if (errors) {
|
||||
log.error("优化生产ES文档保存数据异常: "+bulkResponse.items().toString());
|
||||
throw new ServiceException(DATA_DATA_ERROR);
|
||||
}
|
||||
|
||||
esDocumentService.bulkCreate(ORDER_REMAIN_PLATE_MODEL, optimizeBoardModelDOS);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("优化生产ES文档保存数据异常: "+e.getMessage());
|
||||
@@ -905,12 +904,28 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
log.info("Deleted {} documents with planId {}", response.deleted(), planIds);
|
||||
} catch (Exception e) {
|
||||
log.error("Error deleting documents with planId {}: {}", planIds, e.getMessage());
|
||||
throw new ServiceException(ES_ERROR_DELETE);
|
||||
throw new ServiceException(ES_DATA_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void refresh( String index) {
|
||||
|
||||
try {
|
||||
|
||||
// 创建刷新请求
|
||||
RefreshRequest refreshRequest = new RefreshRequest.Builder().index(index).build();
|
||||
|
||||
elasticsearchClient.indices().refresh(refreshRequest);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("ES文档数据刷新失败:"+e.getMessage());
|
||||
throw new ServiceException(ES_DATA_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -992,7 +992,7 @@ public class PlanServiceImpl implements PlanService {
|
||||
log.info("Deleted {} documents with planId {}", response.deleted(), planIds);
|
||||
} catch (Exception e) {
|
||||
log.error("Error deleting documents with planId {}: {}", planIds, e.getMessage());
|
||||
throw new ServiceException(ES_ERROR_DELETE);
|
||||
throw new ServiceException(ES_DATA_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -50,8 +50,7 @@ import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants.ES_ERROR_UPDATE;
|
||||
import static com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR;
|
||||
import static com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants.*;
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.framework.common.util.json.JsonUtils.parseObject;
|
||||
import static com.cf.imes.framework.common.util.json.JsonUtils.toJsonString;
|
||||
@@ -175,7 +174,7 @@ public class PlateServiceImpl implements PlateService {
|
||||
} catch (Exception e) {
|
||||
|
||||
log.error(e.getMessage());
|
||||
throw new ServiceException(ES_ERROR_UPDATE);
|
||||
throw new ServiceException(ES_DATA_ERROR);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user