搜索数据包含测试流程里的测试参数
This commit is contained in:
@@ -10,9 +10,12 @@ public enum ComponentSearchType {
|
||||
MODEL_NUMBER(1, "样品型号"),
|
||||
MODEL_NAME(2, "样品名称"),
|
||||
MODEL_TYPE(3, "样品类型"),
|
||||
MODEL_BATCH_NO(4, "样品批次");
|
||||
MODEL_BATCH_NO(4, "样品批次"),
|
||||
TEST_PARAMS(5, "测试参数")
|
||||
|
||||
;
|
||||
|
||||
|
||||
int code;
|
||||
String name;
|
||||
final int code;
|
||||
final String name;
|
||||
}
|
||||
|
||||
@@ -14,4 +14,12 @@ public interface IComponentSearchService extends IService<SearchResult> {
|
||||
void saveDataAfterSaveExperiment(Experiment experiment);
|
||||
|
||||
boolean saveComponentSearch(SearchResult searchResult);
|
||||
|
||||
/**
|
||||
* 根据类型保存搜索记录
|
||||
* @param type 数据类型
|
||||
* @param content 数据内容
|
||||
* @return 保存结果 是否保存成功
|
||||
*/
|
||||
boolean saveComponentSearchByType(int type, String content);
|
||||
}
|
||||
|
||||
@@ -112,4 +112,24 @@ public class ComponentSearchServiceImpl extends ServiceImpl<ComponentSearchMappe
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,13 @@ package org.jeecg.modules.database.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
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.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.modules.database.constant.ComponentSearchType;
|
||||
import org.jeecg.modules.database.entity.*;
|
||||
import org.jeecg.modules.database.mapper.ExperimentTestProcessMapper;
|
||||
import org.jeecg.modules.database.service.*;
|
||||
@@ -29,6 +33,10 @@ public class ExperimentTestProcessServiceImpl extends ServiceImpl<ExperimentTest
|
||||
@Autowired
|
||||
private IExperimentSampleInfoService experimentSampleInfoService;
|
||||
|
||||
@Autowired
|
||||
private IComponentSearchService componentSearchService;
|
||||
|
||||
|
||||
@Override
|
||||
public List<ExperimentTestProcess> getByExperimentId(String experimentId) {
|
||||
List<ExperimentTestProcess> list = list(
|
||||
@@ -75,6 +83,19 @@ public class ExperimentTestProcessServiceImpl extends ServiceImpl<ExperimentTest
|
||||
}
|
||||
experimentTestProcess.setSampleInfo(StringUtils.join(sampleInfoIds, ","));
|
||||
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
|
||||
@@ -94,4 +115,5 @@ public class ExperimentTestProcessServiceImpl extends ServiceImpl<ExperimentTest
|
||||
}
|
||||
save(experiment);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user