Commit b22267d2 authored by lisong's avatar lisong

es时间查询修改

parent da75ca7f
...@@ -26,6 +26,8 @@ import org.springframework.util.ObjectUtils; ...@@ -26,6 +26,8 @@ import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.LinkedList; import java.util.LinkedList;
...@@ -275,12 +277,17 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin ...@@ -275,12 +277,17 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
boolMust.must(query); boolMust.must(query);
} }
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//充装开始时间 //充装开始时间
if (!ObjectUtils.isEmpty(esCylinderFillingRecordDto.getFillingStartTime())) { if (!ObjectUtils.isEmpty(esCylinderFillingRecordDto.getFillingStartTime())) {
flag = false; flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery(); BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("fillingStartTime", esCylinderFillingRecordDto.getFillingStartTime())); // query.must(QueryBuilders.matchQuery("fillingStartTime", esCylinderFillingRecordDto.getFillingStartTime()));
try {
query.must(QueryBuilders.rangeQuery("inspectionDateMs").gte(sdf.parse(esCylinderFillingRecordDto.getFillingStartTime()).getTime()));
} catch (ParseException e) {
e.printStackTrace();
}
boolMust.must(query); boolMust.must(query);
} }
...@@ -288,7 +295,12 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin ...@@ -288,7 +295,12 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
if (!ObjectUtils.isEmpty(esCylinderFillingRecordDto.getFillingEndTime())) { if (!ObjectUtils.isEmpty(esCylinderFillingRecordDto.getFillingEndTime())) {
flag = false; flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery(); BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("fillingEndTime", esCylinderFillingRecordDto.getFillingEndTime())); // query.must(QueryBuilders.matchQuery("fillingEndTime", esCylinderFillingRecordDto.getFillingEndTime()));
try {
query.must(QueryBuilders.rangeQuery("inspectionDateAfterMS").lte(sdf.parse(esCylinderFillingRecordDto.getFillingEndTime()).getTime()));
} catch (ParseException e) {
e.printStackTrace();
}
boolMust.must(query); boolMust.must(query);
} }
......
...@@ -744,7 +744,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -744,7 +744,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
}); });
} }
@Scheduled(cron = "${tzs.cylinder.info.cron}") // @Scheduled(cron = "${tzs.cylinder.info.cron}")
@SchedulerLock(name = "cylinderInfoToESTask", lockAtMostFor = "PT6H") @SchedulerLock(name = "cylinderInfoToESTask", lockAtMostFor = "PT6H")
public void setTimeSaveCylinderInfoToES() { public void setTimeSaveCylinderInfoToES() {
Page<CylinderInfoDto> cylinderInfoPage = new Page<>(); Page<CylinderInfoDto> cylinderInfoPage = new Page<>();
...@@ -924,12 +924,17 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -924,12 +924,17 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
query.must(QueryBuilders.matchQuery("manufacturingUnit", "*" + cylinderInfoDto.getManufacturingUnit() + "*")); query.must(QueryBuilders.matchQuery("manufacturingUnit", "*" + cylinderInfoDto.getManufacturingUnit() + "*"));
boolMust.must(query); boolMust.must(query);
} }
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//检验日期 //检验日期
if (!ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateStart()) && !ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateEnd())) { if (!ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateStart()) && !ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateEnd())) {
flag = false; flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery(); BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.rangeQuery("inspectionDate").from(cylinderInfoDto.getInspectionDateStart()).to(cylinderInfoDto.getInspectionDateEnd())); // query.must(QueryBuilders.rangeQuery("inspectionDate").from(cylinderInfoDto.getInspectionDateStart()).to(cylinderInfoDto.getInspectionDateEnd()));
try {
query.must(QueryBuilders.rangeQuery("inspectionDateMs").gte(sdf.parse(cylinderInfoDto.getInspectionDateStart()).getTime()));
} catch (ParseException e) {
e.printStackTrace();
}
boolMust.must(query); boolMust.must(query);
} }
......
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