mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
新增:ES文档数据手动刷新
This commit is contained in:
+2
-2
@@ -32,9 +32,9 @@ public class GlobalErrorCodeConstants {
|
||||
public static final ErrorCode NOT_IMPLEMENTED = new ErrorCode(501, "功能未实现/未开启");
|
||||
|
||||
// ES文档更新失败
|
||||
public static final ErrorCode ES_ERROR_UPDATE = new ErrorCode(503, "数据异常,请勿点击过快,请稍等再试");
|
||||
// ES文档删除失败
|
||||
public static final ErrorCode ES_ERROR_DELETE = new ErrorCode(504, "数据异常,请勿点击过快,请稍等再试");
|
||||
// ES文档刷新失败
|
||||
public static final ErrorCode ES_DATA_ERROR = new ErrorCode(503, "数据异常,请勿点击过快,请稍等再试");
|
||||
public static final ErrorCode DATA_EXCEPTION_ERROR = new ErrorCode(505, "数据异常,请联系客服处理");
|
||||
public static final ErrorCode DATA_DATA_ERROR = new ErrorCode(506, "文档数据异常,请稍后重试或联系客服处理");
|
||||
|
||||
|
||||
+6
@@ -17,6 +17,12 @@ import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.e
|
||||
*/
|
||||
public class AssertUtils {
|
||||
|
||||
|
||||
private AssertUtils() {
|
||||
throw new IllegalStateException("AssertUtils class");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 判断是否为空,可以不用if语句,简化代码
|
||||
* */
|
||||
|
||||
+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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -27,8 +27,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_DELETE;
|
||||
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.object.BeanUtils.toBean;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.DATA_SOURCE_NOT_EXISTS;
|
||||
@@ -788,7 +787,7 @@ public class DataSourceServiceImpl implements DataSourceService {
|
||||
log.info("Deleted {} documents with planId {}", response.deleted(), machineId);
|
||||
} catch (IOException e) {
|
||||
log.error("Error deleting documents with planId {}: {}", machineId, e.getMessage());
|
||||
throw new ServiceException(ES_ERROR_DELETE);
|
||||
throw new ServiceException(ES_DATA_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user