Commit e7836482 authored by tianbo's avatar tianbo

refactor(jg): 优化设备类别保存逻辑并添加立即刷新索引功能

- 新增 EquipmentCategoryService 类,提供 saveWithImmediateRefresh 方法 - 在 IdxBizJgRegisterInfoServiceImpl 中使用新方法保存设备类别信息 - 修复数据源复制逻辑中的潜在 bug
parent 93c6fb44
package com.yeejoin.amos.boot.module.common.biz.service.impl;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import lombok.RequiredArgsConstructor;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class EquipmentCategoryService {
private final ESEquipmentCategory equipmentCategoryDao;
private final ElasticsearchOperations elasticsearchOperations;
public ESEquipmentCategoryDto saveWithImmediateRefresh(ESEquipmentCategoryDto dto) {
ESEquipmentCategoryDto saved = equipmentCategoryDao.save(dto);
// 手动触发索引刷新
elasticsearchOperations.indexOps(ESEquipmentCategoryDto.class).refresh();
return saved;
}
}
\ No newline at end of file
......@@ -24,6 +24,7 @@ import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.*;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.common.biz.service.impl.EquipmentCategoryService;
import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.entity.*;
import com.yeejoin.amos.boot.module.jg.api.enums.*;
......@@ -244,6 +245,8 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
@Autowired
ESEquipmentCategory esEquipmentCategory;
@Autowired
EquipmentCategoryService equipmentCategoryService;
@Autowired
ICommonService commonService;
@Autowired
CommonMapper commonMapper;
......@@ -3280,7 +3283,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
String sourceRecord = equipmentClassForm.get(RECORD).toString();
// bug-21203
if (equipmentInfoForm.containsKey("DATA_SOURCE")) {
String dataSourceCopy = equipmentInfoForm.get("DATA_SOURCE").toString();
String dataSourceCopy = dataSource;
if (dataSourceCopy.startsWith("jg_his_black")) {
dataSource = "jg_his_black_" + sourceRecord;
} else if (dataSourceCopy.startsWith("jg_his")) {
......@@ -3673,7 +3676,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
Date nextInspectDate = (Date) map.get("NEXT_INSPECT_DATE");
dto.setNEXT_INSPECT_DATE(DateUtil.parse(DateUtil.format(nextInspectDate, DatePattern.NORM_DATE_PATTERN)).getTime());
}
esEquipmentCategory.save(dto);
equipmentCategoryService.saveWithImmediateRefresh(dto);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment