Commit 864af93b authored by chenzhao's avatar chenzhao

修改bug

parent 89f6c3b6
......@@ -166,4 +166,12 @@ public class AlertCalled extends BaseEntity {
@TableField(exist=false)
@ApiModelProperty(value = "落地时间")
private String landingTime;
@TableField(exist=false)
@ApiModelProperty(value = "任务时间")
private String taskTime;
@TableField(exist=false)
@ApiModelProperty(value = "任务时间")
private String seat;
}
......@@ -115,5 +115,11 @@ public class ESAlertCalled {
@Field(type = FieldType.Text)
private String flightNumber;
/**
* 落地时间
*/
@Field(type = FieldType.Long)
private Long taskTime;
}
......@@ -327,14 +327,14 @@
</where>) b
</select>
<!--bug 8954 历史警情数据缺失 过滤了经纬度导致-->
<select id="alertCalledListByAlertStatusCount" resultType="Integer">
SELECT
COUNT(*)
FROM jc_alert_called a
where a.is_delete=0 and a.alert_type_code <![CDATA[ <> ]]> 1214
AND a.coordinate_x IS NOT NULL
AND a.coordinate_y IS NOT NULL
/* AND a.coordinate_x IS NOT NULL
AND a.coordinate_y IS NOT NULL*/
<if test='par.status==0'>
and a.alert_status =0
</if>
......
......@@ -580,9 +580,17 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
Map<Date, Long> dutyPersonShiftMap = dutyPersonShiftsDb.stream()
.collect(Collectors.toMap(DutyPersonShift::getDutyDate, DutyPersonShift::getSequenceNbr));
// todo: 只更新当天及值班之后数据
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
String format = simpleDateFormat.format(new Date());
Date date = null;
try {
date = simpleDateFormat.parse(format);
} catch (ParseException e) {
e.printStackTrace();
}
Date finalDate = date;
Set<DutyPersonShift> needToDb = shiftDtos.stream()
.filter(s -> DateUtils.dateCompare(s.getDutyDate(), new Date()) >= 0).map(shiftDto -> {
DutyPersonShift dutyPersonShift = new DutyPersonShift();
.filter(s -> DateUtils.dateCompare(s.getDutyDate(), finalDate) >= 0).map(shiftDto -> { DutyPersonShift dutyPersonShift = new DutyPersonShift();
Bean.copyExistPropertis(shiftDto, dutyPersonShift);
dutyPersonShift.setInstanceId(finalInstanceId);
dutyPersonShift.setAppKey(RequestContext.getAppKey());
......
......@@ -128,12 +128,17 @@ public class LinkageUnitServiceImpl extends BaseService<LinkageUnitDto, LinkageU
*/
@Transactional
public LinkageUnitDto saveModel(LinkageUnitDto linkageUnitDto) {
if (linkageUnitDto.getAddress() != null) {
JSONObject address = WaterResourceServiceImpl.getLongLatFromAddress(linkageUnitDto.getAddress());
linkageUnitDto.setAddress(address.getString(BizConstant.ADDRESS));
linkageUnitDto.setLongitude(Double.valueOf(address.getString(BizConstant.LONGITUDE)));
linkageUnitDto.setLatitude(Double.valueOf(address.getString(BizConstant.LATITUDE)));
String[] addressArr = linkageUnitDto.getAddress().split("@address@");
JSONObject jsonObject = JSONObject.parseObject(addressArr[1]);
if (StringUtils.isNotEmpty(jsonObject.getString(BizConstant.LONGITUDE))) {
linkageUnitDto.setLongitude(Double.valueOf(jsonObject.getString(BizConstant.LONGITUDE)));
}
if (StringUtils.isNotEmpty(jsonObject.getString(BizConstant.LATITUDE))) {
linkageUnitDto.setLatitude(Double.valueOf(jsonObject.getString(BizConstant.LATITUDE)));
}
}
// 1.保存行数据
String groupCode = this.getGroupCode();
......
......@@ -104,6 +104,9 @@ public class ShiftChangeController extends BaseController {
public ResponseModel queryForPage(
@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size) {
if (current >= 1){
current = (current-1)*size;
}
return ResponseHelper.buildResponse(iShiftChangeService.queryForShiftChangePage(current, size));
}
......
......@@ -310,7 +310,7 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto, AlertCal
});
Map<String, Integer> statusCountMap = alertCalledMapper.queryAlertStatusCount(beginDate, endDate);
Integer unFinishedCount = this
.count(new LambdaQueryWrapper<AlertCalled>().eq(AlertCalled::getAlertStatus, false));// bug2532
.count(new LambdaQueryWrapper<AlertCalled>().eq(AlertCalled::getAlertStatus, false).eq(AlertCalled::getAlertTypeCode,"1214"));// bug2532
// 未结案警情统计错误
// bykongfm
......@@ -540,6 +540,17 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto, AlertCal
});
}
if (AlertStageEnums.LYXC.getCode().equals(alertCalled.getAlertTypeCode()) ||AlertStageEnums.ZJBZ.getCode().equals(alertCalled.getAlertTypeCode()) ) {
alertFormValuelist.stream().forEach(alertFormValue -> {
if (alertFormValue.getFieldCode().equals("taskTime")) {
alertCalled.setTaskTime(alertFormValue.getFieldValue());
}
if (alertFormValue.getFieldCode().equals("seat")) {
alertCalled.setSeat(alertFormValue.getFieldValue());
}
});
}
// 判断是否归并警情
if (alertCalled.getFatherAlert() != null) {
// 警情归并,设置当前警情状态为结束。
......@@ -752,7 +763,7 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto, AlertCal
});
Map<String, Integer> statusCountMap = alertCalledMapper.queryAlertStatusCount(beginDate, endDate);
Integer unFinishedCount = this
.count(new LambdaQueryWrapper<AlertCalled>().eq(AlertCalled::getAlertStatus, false));// bug2532
.count(new LambdaQueryWrapper<AlertCalled>().eq(AlertCalled::getAlertStatus, false).notIn(AlertCalled::getAlertTypeCode,"1214"));// bug2532
// 未结案警情统计错误
// bykongfm
......
......@@ -302,7 +302,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
definitions.put("$casualtiesNum",ValidationUtil.isEmpty(alertCalled.getCasualtiesNum()) ? "" : String.valueOf(alertCalled.getCasualtiesNum()));
definitions.put("$contactPhone",ValidationUtil.isEmpty(alertCalled.getContactPhone()) ? "" : alertCalled.getContactPhone());
String companyName = JSONObject.parseObject(alertSubmittedExtDto.getSubmissionContent()).getString("$companyName") ;
String companyName = JSONObject.parseObject(alertSubmittedExtDto.getSubmissionContent()).getString("companyName") ;
JSONObject jsonObject = null;
if(!ValidationUtil.isEmpty(alertCalled.getUpdateTime())) {
......
......@@ -9,6 +9,7 @@ import java.util.List;
import javax.annotation.PostConstruct;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.jcs.api.enums.AlertStageEnums;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.sort.SortBuilders;
......@@ -59,8 +60,7 @@ public class ESAlertCalledService {
@PostConstruct
public void init() throws Exception
{
public void init() throws Exception {
//初始化ES,重建索引
initEs();
}
......@@ -75,22 +75,20 @@ public class ESAlertCalledService {
*/
QueryWrapper<AlertCalled> wrapper = new QueryWrapper<>();
long currentTime = System.currentTimeMillis() ;
long currentTime = System.currentTimeMillis();
if (ValidationUtil.isEmpty(time)) //默认为同步48小时
{
currentTime = currentTime - 48*60*60*1000;
}else
{
currentTime = currentTime - time*60*60*1000;
currentTime = currentTime - 48 * 60 * 60 * 1000;
} else {
currentTime = currentTime - time * 60 * 60 * 1000;
}
Date date=new Date(currentTime);
Date date = new Date(currentTime);
wrapper.ge("call_time", date);
wrapper.isNull("father_alert");
List<AlertCalled> alertCalleds = alertCalledService.list(wrapper);
if (!ValidationUtil.isEmpty(alertCalleds))
{
if (!ValidationUtil.isEmpty(alertCalleds)) {
// for (AlertCalled alertCalled : alertCalleds)
// {
// saveAlertCalledToES(alertCalled);
......@@ -103,40 +101,35 @@ public class ESAlertCalledService {
}
/**
*
* <pre>
* 批量保存
* </pre>
*
* @param list 警情信息列表
*/
public void saveAll(List<AlertCalled> alertCalleds) throws Exception{
public void saveAll(List<AlertCalled> alertCalleds) throws Exception {
if (!ValidationUtil.isEmpty(alertCalleds))
{
for (AlertCalled alertCalled : alertCalleds)
{
if (!ValidationUtil.isEmpty(alertCalleds)) {
for (AlertCalled alertCalled : alertCalleds) {
this.saveAlertCalledToES(alertCalled);
}
}
}
/**
*
* <pre>
* 根据警情记录批量保存
* </pre>
*
* @param alertCalleds 警情信息列表
*/
public ESAlertCalled saveAlertCalledToES(AlertCalled alertCalled) throws Exception
{
public ESAlertCalled saveAlertCalledToES(AlertCalled alertCalled) throws Exception {
ESAlertCalled esAlertCalled = new ESAlertCalled();
esAlertCalled.setSequenceNbr(alertCalled.getSequenceNbr());
esAlertCalled.setAlertType(alertCalled.getAlertType());
esAlertCalled.setAlertTypeCode(alertCalled.getAlertTypeCode());
esAlertCalled.setCallTime(alertCalled.getCallTime());
esAlertCalled.setCallTimeLong(alertCalled.getCallTime()!=null?alertCalled.getCallTime().getTime():null);
esAlertCalled.setCallTimeLong(alertCalled.getCallTime() != null ? alertCalled.getCallTime().getTime() : null);
esAlertCalled.setContactUser(alertCalled.getContactUser());
esAlertCalled.setContactPhone(alertCalled.getContactPhone());
esAlertCalled.setAddress(alertCalled.getAddress());
......@@ -144,16 +137,17 @@ public class ESAlertCalledService {
esAlertCalled.setAlertStatus(alertCalled.getAlertStatus());
esAlertCalled.setForcedLandingTrack(alertCalled.getForcedLandingTrack());
esAlertCalled.setFlightNumber(alertCalled.getFlightNumber());
if(alertCalled.getLandingTime() != null ){
Date date = new Date();
date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(alertCalled.getLandingTime());
esAlertCalled.setLandingTime(date.getTime());
if (alertCalled.getLandingTime() != null) {
long time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(alertCalled.getLandingTime()).getTime();
esAlertCalled.setLandingTime(time);
}
if (alertCalled.getAlertStatus())
{
if (alertCalled.getTaskTime() != null) {
long time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(alertCalled.getLandingTime()).getTime();
esAlertCalled.setTaskTime(time);
}
if (alertCalled.getAlertStatus()) {
esAlertCalled.setAlertStatusStr(AlertStatusEnum.CLOSED.getCode());
}else
{
} else {
esAlertCalled.setAlertStatusStr(AlertStatusEnum.UNCLOSED.getCode());
}
esAlertCalled.setResponseLevelCode(alertCalled.getResponseLevelCode());
......@@ -167,27 +161,23 @@ public class ESAlertCalledService {
}
public List<ESAlertCalled> saveAlertCalledToES(List<AlertCalled> alertCalleds) throws Exception
{
List<ESAlertCalled> list1=new ArrayList<>();
for (AlertCalled alertCalled : alertCalleds)
{
public List<ESAlertCalled> saveAlertCalledToES(List<AlertCalled> alertCalleds) throws Exception {
List<ESAlertCalled> list1 = new ArrayList<>();
for (AlertCalled alertCalled : alertCalleds) {
ESAlertCalled esAlertCalled = new ESAlertCalled();
esAlertCalled.setSequenceNbr(alertCalled.getSequenceNbr());
esAlertCalled.setAlertType(alertCalled.getAlertType());
esAlertCalled.setAlertTypeCode(alertCalled.getAlertTypeCode());
esAlertCalled.setCallTime(alertCalled.getCallTime());
esAlertCalled.setCallTimeLong(alertCalled.getCallTime()!=null?alertCalled.getCallTime().getTime():null);
esAlertCalled.setCallTimeLong(alertCalled.getCallTime() != null ? alertCalled.getCallTime().getTime() : null);
esAlertCalled.setContactUser(alertCalled.getContactUser());
esAlertCalled.setContactPhone(alertCalled.getContactPhone());
esAlertCalled.setAddress(alertCalled.getAddress());
esAlertCalled.setAlertStage(alertCalled.getAlertStage());
esAlertCalled.setAlertStatus(alertCalled.getAlertStatus());
if (alertCalled.getAlertStatus())
{
if (alertCalled.getAlertStatus()) {
esAlertCalled.setAlertStatusStr(AlertStatusEnum.CLOSED.getCode());
}else
{
} else {
esAlertCalled.setAlertStatusStr(AlertStatusEnum.UNCLOSED.getCode());
}
esAlertCalled.setResponseLevelCode(alertCalled.getResponseLevelCode());
......@@ -202,10 +192,7 @@ public class ESAlertCalledService {
}
/**
*
* <pre>
* 从ES库批量删除
* </pre>
......@@ -214,7 +201,7 @@ public class ESAlertCalledService {
* @return
* @throws Exception
*/
public Boolean deleteById(List<Long> ids) throws Exception{
public Boolean deleteById(List<Long> ids) throws Exception {
if (!ValidationUtil.isEmpty(ids)) {
for (Long sequenceNbr : ids) {
if (esAlertCalledRepository.existsById(sequenceNbr)) {
......@@ -244,20 +231,17 @@ public class ESAlertCalledService {
* @param size 页面大小
* @return
*/
@SuppressWarnings({ "rawtypes" })
public Page<ESAlertCalledDto> queryByKeys(ESAlertCalledRequestDto alertCalledVo, int current, int size)
{
@SuppressWarnings({"rawtypes"})
public Page<ESAlertCalledDto> queryByKeys(ESAlertCalledRequestDto alertCalledVo, int current, int size) {
Page<ESAlertCalledDto> result = new Page<ESAlertCalledDto>(current, size);
String[] alertStatus = alertCalledVo.getAlertStatus();
if (ValidationUtil.isEmpty(alertStatus))
{
if (ValidationUtil.isEmpty(alertStatus)) {
return result;
}
AlertCalled alertCalled = alertCalledVo.getAlertCalled();
if (ValidationUtil.isEmpty(alertCalled))
{
if (ValidationUtil.isEmpty(alertCalled)) {
return result;
}
/**
......@@ -266,34 +250,33 @@ public class ESAlertCalledService {
BoolQueryBuilder boolMustAll = QueryBuilders.boolQuery();
//警情状态
BoolQueryBuilder qb0 = QueryBuilders.boolQuery();
for (String status : alertStatus)
{
if (alertStatus.length > 1) {
} else {
for (String status : alertStatus) {
AlertStatusEnum alertStatusEnum = AlertStatusEnum.getEnum(status);
if (!ValidationUtil.isEmpty(alertStatusEnum))
{
qb0.should(QueryBuilders.termQuery("alertStatusStr.keyword", alertStatusEnum.getCode()));
if (!ValidationUtil.isEmpty(alertStatusEnum)) {
qb0.must(QueryBuilders.termQuery("alertStatusStr.keyword", alertStatusEnum.getCode()));
}
}
boolMustAll.must(qb0);
}
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//接警时间,距离当前时间不超过半小时的
long currentTime = System.currentTimeMillis() ;
currentTime = currentTime - 30*60*1000;
long currentTime = System.currentTimeMillis();
currentTime = currentTime - 30 * 60 * 1000;
BoolQueryBuilder qb1 = QueryBuilders.boolQuery()
.must(QueryBuilders.rangeQuery("callTimeLong").gte(currentTime));
boolMust.should(qb1);
//报警人及报警电话一致
if (!ValidationUtil.isEmpty(alertCalled.getContactUser()) && !ValidationUtil.isEmpty(alertCalled.getContactPhone()))
{
if (!ValidationUtil.isEmpty(alertCalled.getContactUser()) && !ValidationUtil.isEmpty(alertCalled.getContactPhone())) {
BoolQueryBuilder qb2 = QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("contactUser.keyword", alertCalled.getContactUser()))
.must(QueryBuilders.termQuery("contactPhone.keyword", alertCalled.getContactPhone()));
boolMust.should(qb2);
}
//事发地点一致,或相距不超过200米的
if (!ValidationUtil.isEmpty(alertCalled.getAddress()))
{
if (!ValidationUtil.isEmpty(alertCalled.getAddress())) {
BoolQueryBuilder qb3 = QueryBuilders.boolQuery()
.should(QueryBuilders.matchQuery("address", alertCalled.getAddress()));
boolMust.should(qb3);
......@@ -303,39 +286,55 @@ public class ESAlertCalledService {
.must(QueryBuilders.termQuery("alertTypeCode.keyword", alertCalled.getAlertTypeCode()));
boolMust.should(qb4);
//事发单位名称一致
if (!ValidationUtil.isEmpty(alertCalled.getUnitInvolved()))
{
if (!ValidationUtil.isEmpty(alertCalled.getUnitInvolved())) {
BoolQueryBuilder qb5 = QueryBuilders.boolQuery()
.must(QueryBuilders.matchQuery("unitInvolved", alertCalled.getUnitInvolved()));
.must(QueryBuilders.termQuery("unitInvolved.keyword", alertCalled.getUnitInvolved()));
boolMust.should(qb5);
}
//过滤120警情
BoolQueryBuilder qb6 = QueryBuilders.boolQuery()
.mustNot(QueryBuilders.termQuery("alertTypeCode", "1214"));
if (!ValidationUtil.isEmpty(alertCalledVo.getAlertFormValue())){
//航空器救援规则
if (!ValidationUtil.isEmpty(alertCalledVo.getAlertFormValue()) && AlertStageEnums.HKJY.getCode().equals(alertCalled.getAlertTypeCode())) {
List<AlertFormValue> alertFormValue = alertCalledVo.getAlertFormValue();
for (AlertFormValue formValue : alertFormValue) {
if (formValue.getFieldCode().equals("forcedLandingTrack")&& formValue.getFieldValue() != null){
if (formValue.getFieldCode().equals("forcedLandingTrack") && formValue.getFieldValue() != null) {
BoolQueryBuilder qb7 = QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("forcedLandingTrack.keyword", formValue.getFieldValue()));
boolMust.must(qb7);
}
if (formValue.getFieldCode().equals("flightNumber") && formValue.getFieldValue() != null){
if (formValue.getFieldCode().equals("flightNumber") && formValue.getFieldValue() != null) {
BoolQueryBuilder qb8 = QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("flightNumber.keyword", formValue.getFieldValue()));
boolMust.must(qb8);
}
if (formValue.getFieldCode().equals("landingTime")&& formValue.getFieldValue() != null){
if (formValue.getFieldCode().equals("landingTime") && formValue.getFieldValue() != null) {
BoolQueryBuilder qb9 = QueryBuilders.boolQuery().must(QueryBuilders.rangeQuery("landingTime").gte(currentTime));
boolMust.must(qb9);
}
}
}
//漏油保障规则和专机保障规则
if (!ValidationUtil.isEmpty(alertCalledVo.getAlertFormValue()) &&AlertStageEnums.LYXC.getCode().equals(alertCalled.getAlertTypeCode()) ||AlertStageEnums.ZJBZ.getCode().equals(alertCalled.getAlertTypeCode()) ) {
List<AlertFormValue> alertFormValue = alertCalledVo.getAlertFormValue();
for (AlertFormValue formValue : alertFormValue) {
if (formValue.getFieldCode().equals("taskTime") && formValue.getFieldValue() != null) {
currentTime= currentTime - 30 * 60 * 1000*2;
BoolQueryBuilder qb10 = QueryBuilders.boolQuery()
.must(QueryBuilders.rangeQuery("taskTime").gte(currentTime));
boolMust.must(qb10);
}
if (formValue.getFieldCode().equals("seat") && formValue.getFieldValue() != null) {
BoolQueryBuilder qb11 = QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("seat.keyword", formValue.getFieldValue()));
boolMust.must(qb11);
}
}
}
/**
* 一般火灾,条件构造
......@@ -343,12 +342,11 @@ public class ESAlertCalledService {
boolMust.minimumShouldMatch(1);//至少满足一个
boolMustAll.must(boolMust);
boolMustAll.must(qb6);
// 创建查询构造器
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder()
//过滤条件
......@@ -356,25 +354,21 @@ public class ESAlertCalledService {
// 排序
.withSort(SortBuilders.fieldSort("callTimeLong").order(SortOrder.DESC))
// 分页
.withPageable(PageRequest.of(current, size))
;
.withPageable(PageRequest.of(current, size));
List<ESAlertCalledDto> list = new LinkedList<>();
long totle = 0;
try
{
SearchHits<ESAlertCalled> searchHits =elasticsearchTemplate.search(queryBuilder.build(), ESAlertCalled.class);
try {
SearchHits<ESAlertCalled> searchHits = elasticsearchTemplate.search(queryBuilder.build(), ESAlertCalled.class);
for (SearchHit searchHit : searchHits.getSearchHits())
{
for (SearchHit searchHit : searchHits.getSearchHits()) {
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(searchHit.getContent());
ESAlertCalledDto eSAlertCalled =JSONObject.toJavaObject(jsonObject, ESAlertCalledDto.class);
ESAlertCalledDto eSAlertCalled = JSONObject.toJavaObject(jsonObject, ESAlertCalledDto.class);
list.add(eSAlertCalled);
}
totle =searchHits.getTotalHits();
}
catch (Exception e)
{
totle = searchHits.getTotalHits();
} catch (Exception e) {
// TODO: handle exception
}
result.setRecords(list);
......@@ -382,20 +376,18 @@ public class ESAlertCalledService {
return result;
}
@SuppressWarnings({ "rawtypes" })
public Page<ESAlertCalledDto> queryByKeys(ESAlertCalledRequestDto alertCalledVo, int current, int size,String type)
{
@SuppressWarnings({"rawtypes"})
public Page<ESAlertCalledDto> queryByKeys(ESAlertCalledRequestDto alertCalledVo, int current, int size, String type) {
Page<ESAlertCalledDto> result = new Page<ESAlertCalledDto>(current, size);
String[] alertStatus = alertCalledVo.getAlertStatus();
if (ValidationUtil.isEmpty(alertStatus))
{
if (ValidationUtil.isEmpty(alertStatus)) {
return result;
}
AlertCalled alertCalled = alertCalledVo.getAlertCalled();
if (ValidationUtil.isEmpty(alertCalled))
{
if (ValidationUtil.isEmpty(alertCalled)) {
return result;
}
/**
......@@ -404,11 +396,9 @@ public class ESAlertCalledService {
BoolQueryBuilder boolMustAll = QueryBuilders.boolQuery();
//警情状态
BoolQueryBuilder qb0 = QueryBuilders.boolQuery();
for (String status : alertStatus)
{
for (String status : alertStatus) {
AlertStatusEnum alertStatusEnum = AlertStatusEnum.getEnum(status);
if (!ValidationUtil.isEmpty(alertStatusEnum))
{
if (!ValidationUtil.isEmpty(alertStatusEnum)) {
qb0.should(QueryBuilders.termQuery("alertStatusStr.keyword", alertStatusEnum.getCode()));
}
}
......@@ -416,22 +406,20 @@ public class ESAlertCalledService {
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//接警时间,距离当前时间不超过半小时的
long currentTime = System.currentTimeMillis() ;
currentTime = currentTime - 30*60*1000;
long currentTime = System.currentTimeMillis();
currentTime = currentTime - 30 * 60 * 1000;
BoolQueryBuilder qb1 = QueryBuilders.boolQuery()
.must(QueryBuilders.rangeQuery("callTimeLong").gte(currentTime));
boolMust.should(qb1);
//报警人及报警电话一致
if (!ValidationUtil.isEmpty(alertCalled.getContactUser()) && !ValidationUtil.isEmpty(alertCalled.getContactPhone()))
{
if (!ValidationUtil.isEmpty(alertCalled.getContactUser()) && !ValidationUtil.isEmpty(alertCalled.getContactPhone())) {
BoolQueryBuilder qb2 = QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("contactUser.keyword", alertCalled.getContactUser()))
.must(QueryBuilders.termQuery("contactPhone.keyword", alertCalled.getContactPhone()));
boolMust.should(qb2);
}
//事发地点一致,或相距不超过200米的
if (!ValidationUtil.isEmpty(alertCalled.getAddress()))
{
if (!ValidationUtil.isEmpty(alertCalled.getAddress())) {
BoolQueryBuilder qb3 = QueryBuilders.boolQuery()
.should(QueryBuilders.matchQuery("address", alertCalled.getAddress()));
boolMust.should(qb3);
......@@ -441,8 +429,7 @@ public class ESAlertCalledService {
.must(QueryBuilders.termQuery("alertTypeCode.keyword", alertCalled.getAlertTypeCode()));
//boolMust.should(qb4);
//事发单位名称一致
if (!ValidationUtil.isEmpty(alertCalled.getUnitInvolved()))
{
if (!ValidationUtil.isEmpty(alertCalled.getUnitInvolved())) {
BoolQueryBuilder qb5 = QueryBuilders.boolQuery()
.must(QueryBuilders.matchQuery("unitInvolved", alertCalled.getUnitInvolved()));
boolMust.should(qb5);
......@@ -459,34 +446,28 @@ public class ESAlertCalledService {
boolMustAll.must(qb4);
// 创建查询构造器
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder()
//过滤条件
.withQuery(boolMustAll)
// 分页
.withPageable(PageRequest.of(current, size))
// 排序
.withSort(SortBuilders.fieldSort("callTimeLong").order(SortOrder.DESC))
//过滤条件
.withQuery(boolMustAll)
;
.withSort(SortBuilders.fieldSort("callTimeLong").order(SortOrder.DESC));
List<ESAlertCalledDto> list = new LinkedList<>();
long totle = 0;
try
{
SearchHits<ESAlertCalled> searchHits =elasticsearchTemplate.search(queryBuilder.build(), ESAlertCalled.class);
try {
SearchHits<ESAlertCalled> searchHits = elasticsearchTemplate.search(queryBuilder.build(), ESAlertCalled.class);
for (SearchHit searchHit : searchHits.getSearchHits())
{
for (SearchHit searchHit : searchHits.getSearchHits()) {
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(searchHit.getContent());
ESAlertCalledDto eSAlertCalled =JSONObject.toJavaObject(jsonObject, ESAlertCalledDto.class);
ESAlertCalledDto eSAlertCalled = JSONObject.toJavaObject(jsonObject, ESAlertCalledDto.class);
list.add(eSAlertCalled);
}
totle =searchHits.getTotalHits();
}
catch (Exception e)
{
totle = searchHits.getTotalHits();
} catch (Exception e) {
// TODO: handle exception
}
result.setRecords(list);
......@@ -494,5 +475,4 @@ public class ESAlertCalledService {
return result;
}
}
\ No newline at end of file
......@@ -21,6 +21,8 @@ public interface CheckMapper extends BaseMapper {
List<CheckInfoVo> getCheckInfo(CheckInfoPageParam param);
List<Check> getCheckByTaskId(String taskId);
List<Map> queryUnqualifiedInputItem(@Param(value = "checkId") int checkId);
List<Map> queryCheckPointInputItem(@Param(value = "planTaskId") int planTaskId, @Param(value = "pointId") int pointId);
......
......@@ -25,6 +25,7 @@ import com.yeejoin.amos.supervision.business.feign.DangerFeignClient;
import com.yeejoin.amos.supervision.business.feign.JCSFeignClient;
import com.yeejoin.amos.supervision.business.service.intfc.ICheckReportService;
import com.yeejoin.amos.supervision.business.service.intfc.IPlanService;
import com.yeejoin.amos.supervision.business.service.intfc.IPlanTaskService;
import com.yeejoin.amos.supervision.common.enums.DangerCheckTypeLevelEnum;
import com.yeejoin.amos.supervision.common.enums.PlanCheckLevelEnum;
import com.yeejoin.amos.supervision.common.enums.PlanFrequencyEnum;
......@@ -84,6 +85,9 @@ public class CheckReportServiceImpl extends BaseService<CheckReportDto, CheckRep
HiddenDangerMapper hiddenDangerMapper;
@Autowired
CheckMapper checkMapper;
@Autowired
IPlanDao planDao;
@Autowired
......@@ -142,6 +146,14 @@ public class CheckReportServiceImpl extends BaseService<CheckReportDto, CheckRep
// 获取复查信息
getReviewInfo(checkReport);
List<Check> list = checkMapper.getCheckByTaskId(String.valueOf(planTask.getId()));
//拿去第一条和最后一条检查记录给检查时间赋值
if (list != null){
Check check = list.get(0);
Check check1 = list.get(list.size() - 1);
checkReport.setEndCheckDate(check.getCheckTime());
checkReport.setStartCheckDate(check1.getCheckTime());
}
checkReportMapper.insert(checkReport);
}
}
......
......@@ -149,6 +149,11 @@
</choose>
</select>
<select id="getCheckByTaskId" resultType="com.yeejoin.amos.supervision.dao.entity.Check">
select * from p_check where plan_task_id = #{taskId} order by check_time DESC
</select>
<select id="queryUnqualifiedInputItem" resultType="Map" parameterType="int">
SELECT
ii.name,
......
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