Commit c22db50e authored by tianbo's avatar tianbo

充装检查合格率es查询修改(fillingResult,checkResult使用keyword)

parent 50ccbc8e
......@@ -27,6 +27,7 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -118,7 +119,7 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
long totalResult = searchEsCount(false, true, regionCode, appId);
result5.put("name", "充装检查率(%)");
if (totalAll != 0) {
result5.put("value", (totalCheck / totalAll) * 100);
result5.put("value", new DecimalFormat("#.00").format (((double) totalCheck / totalAll) * 100));
} else {
result5.put("value", 0);
}
......@@ -126,7 +127,7 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
Map<String, Object> result6 = Maps.newHashMap();
result6.put("name", "充装检查合格率(%)");
if (totalAll != 0) {
result6.put("value", (totalResult / totalAll) * 100);
result6.put("value", new DecimalFormat("#.00").format (((double) totalResult / totalAll) * 100));
} else {
result6.put("value", 0);
}
......@@ -183,9 +184,8 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
}
private long searchEsCount(Boolean checkOk, Boolean resultOk, String regionCode, String appId) {
CountRequest countRequest = new CountRequest();
countRequest.indices("cylinder_filling");
// countRequest.indices("tb_test_index");
CountRequest countRequest = new CountRequest("cylinder_filling_tb3");
// countRequest.indices("cylinder_filling");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
if (checkOk) {
//匹配充装前检查和充装后检查都有数据
......@@ -196,27 +196,9 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
}
if (resultOk) {
//匹配充装前检查和充装后检查都有数据
// 定义脚本查询参数
// Map<String, Object> params = new HashMap<>();
// // 脚本内容,检查多个字段的值
// String scriptBody = " boolean allMatch = true;\n" +
// " for (String field : ['fillingResult', 'checkResult']) {\n" +
// " if (doc[field].value != params['matchValue']) {\n" +
// " allMatch = false;\n" +
// " break;\n" +
// " }\n" +
// " }\n" +
// " return allMatch;\n";
// String resultOkMatchValue = "合格";
// params.put("matchValue", resultOkMatchValue);
// // 构建脚本查询
// Script script = new Script(ScriptType.INLINE,"painless", scriptBody, params);
// // 使用ScriptQueryBuilder构造查询条件
// ScriptQueryBuilder scriptQuery = QueryBuilders.scriptQuery(script);
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("fillingResult", "合格"));
meBuilder.must(QueryBuilders.matchQuery("checkResult", "合格"));
// meBuilder.must(scriptQuery);
meBuilder.must(QueryBuilders.termQuery("fillingResult.keyword", "合格"));
meBuilder.must(QueryBuilders.termQuery("checkResult.keyword", "合格"));
boolMust.must(meBuilder);
}
......
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