搜索数据包含测试流程里的测试参数

This commit is contained in:
dengchun
2025-05-03 15:02:10 +08:00
parent 8bddd2c4c1
commit b68074bee5
4 changed files with 56 additions and 3 deletions

View File

@@ -10,9 +10,12 @@ public enum ComponentSearchType {
MODEL_NUMBER(1, "样品型号"), MODEL_NUMBER(1, "样品型号"),
MODEL_NAME(2, "样品名称"), MODEL_NAME(2, "样品名称"),
MODEL_TYPE(3, "样品类型"), MODEL_TYPE(3, "样品类型"),
MODEL_BATCH_NO(4, "样品批次"); MODEL_BATCH_NO(4, "样品批次"),
TEST_PARAMS(5, "测试参数")
;
int code; final int code;
String name; final String name;
} }

View File

@@ -14,4 +14,12 @@ public interface IComponentSearchService extends IService<SearchResult> {
void saveDataAfterSaveExperiment(Experiment experiment); void saveDataAfterSaveExperiment(Experiment experiment);
boolean saveComponentSearch(SearchResult searchResult); boolean saveComponentSearch(SearchResult searchResult);
/**
* 根据类型保存搜索记录
* @param type 数据类型
* @param content 数据内容
* @return 保存结果 是否保存成功
*/
boolean saveComponentSearchByType(int type, String content);
} }

View File

@@ -112,4 +112,24 @@ public class ComponentSearchServiceImpl extends ServiceImpl<ComponentSearchMappe
return this.saveOrUpdate(searchResult); return this.saveOrUpdate(searchResult);
} }
@Override
public boolean saveComponentSearchByType(int type, String content) {
boolean result = false;
LambdaQueryWrapper<SearchResult> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SearchResult::getDataType, type);
queryWrapper.likeRight(SearchResult::getContent, content);
if (0L == this.count(queryWrapper)){
SearchResult modelBatchNoRecord = new SearchResult();
modelBatchNoRecord.setDataType(type);
modelBatchNoRecord.setContent(content);
try {
result = saveOrUpdate(modelBatchNoRecord);
}catch (Exception e) {
logger.warn("搜索数据更新失败type: " + type + ", 内容:" + content);
result = false;
}
}
return result;
}
} }

View File

@@ -2,9 +2,13 @@ package org.jeecg.modules.database.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.database.constant.ComponentSearchType;
import org.jeecg.modules.database.entity.*; import org.jeecg.modules.database.entity.*;
import org.jeecg.modules.database.mapper.ExperimentTestProcessMapper; import org.jeecg.modules.database.mapper.ExperimentTestProcessMapper;
import org.jeecg.modules.database.service.*; import org.jeecg.modules.database.service.*;
@@ -29,6 +33,10 @@ public class ExperimentTestProcessServiceImpl extends ServiceImpl<ExperimentTest
@Autowired @Autowired
private IExperimentSampleInfoService experimentSampleInfoService; private IExperimentSampleInfoService experimentSampleInfoService;
@Autowired
private IComponentSearchService componentSearchService;
@Override @Override
public List<ExperimentTestProcess> getByExperimentId(String experimentId) { public List<ExperimentTestProcess> getByExperimentId(String experimentId) {
List<ExperimentTestProcess> list = list( List<ExperimentTestProcess> list = list(
@@ -75,6 +83,19 @@ public class ExperimentTestProcessServiceImpl extends ServiceImpl<ExperimentTest
} }
experimentTestProcess.setSampleInfo(StringUtils.join(sampleInfoIds, ",")); experimentTestProcess.setSampleInfo(StringUtils.join(sampleInfoIds, ","));
saveOrUpdate(experimentTestProcess); saveOrUpdate(experimentTestProcess);
//保存测试参数到搜索数据
String testParameters = experimentTestProcess.getTestParameters();
if (StringUtils.isNotBlank(testParameters)) {
JSONArray jsonObject = JSON.parseArray(testParameters);
if (jsonObject != null && !jsonObject.isEmpty()) {
List<String> nameList = jsonObject.stream().map(v -> ((JSONObject) v).getString("name")).collect(Collectors.toList());
nameList.forEach(name -> {
componentSearchService.saveComponentSearchByType(ComponentSearchType.TEST_PARAMS.getCode(), name);
});
}
}
} }
@Override @Override
@@ -94,4 +115,5 @@ public class ExperimentTestProcessServiceImpl extends ServiceImpl<ExperimentTest
} }
save(experiment); save(experiment);
} }
} }