Commit d2b16664 authored by 郭武斌's avatar 郭武斌

*)修改相似警情过滤参数

parent a98a89be
package com.yeejoin.amos.boot.module.jcs.api.dto;
import com.yeejoin.amos.boot.module.jcs.api.vo.AlertCalledVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ESAlertCalledRequestDto extends AlertCalledVo
{
@ApiModelProperty(value = "警情状态")
private String[] alertStatus;
}
...@@ -31,9 +31,14 @@ public class ESAlertCalled { ...@@ -31,9 +31,14 @@ public class ESAlertCalled {
/** /**
* 警情状态 * 警情状态
*/ */
@Field(type = FieldType.Text) @Field(type = FieldType.Boolean, index = false)
private Boolean alertStatus; private Boolean alertStatus;
/** /**
* 警情状态
*/
@Field(type = FieldType.Text)
private String alertStatusStr;
/**
* 响应级别字典code 为了过滤用(只有航空器故障有) * 响应级别字典code 为了过滤用(只有航空器故障有)
*/ */
@Field(type = FieldType.Text, index = false) @Field(type = FieldType.Text, index = false)
......
package com.yeejoin.amos.boot.module.jcs.api.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
*
* <pre>
* 警情状态枚举
* </pre>
*
* @author gwb
* @version $Id: AlertStatusEnum.java, v 0.1 2021年6月23日 下午5:11:18 gwb Exp $
*/
@Getter
@AllArgsConstructor
public enum AlertStatusEnum {
UNCLOSED("unclosed", "未结案"),
CLOSED("closed", "已结案");
private String code;
private String name;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public static AlertStatusEnum getEnum(String code)
{
for (AlertStatusEnum status : AlertStatusEnum.values())
{
if (status.getCode().equals(code))
{
return status;
}
}
return null;
}
}
...@@ -35,6 +35,7 @@ import com.yeejoin.amos.boot.biz.common.utils.NameUtils; ...@@ -35,6 +35,7 @@ import com.yeejoin.amos.boot.biz.common.utils.NameUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey; import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledDto; import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledRequestDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled; import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertFormValue; import com.yeejoin.amos.boot.module.jcs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.jcs.api.vo.AlertCalledFormVo; import com.yeejoin.amos.boot.module.jcs.api.vo.AlertCalledFormVo;
...@@ -203,17 +204,32 @@ public class AlertCalledController extends BaseController { ...@@ -203,17 +204,32 @@ public class AlertCalledController extends BaseController {
* @return * @return
* @throws Exception * @throws Exception
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "相似警情分页查询") @ApiOperation(value = "相似警情分页查询")
@RequestMapping(value = "/page/similar", method = RequestMethod.POST) @RequestMapping(value = "/page/similar", method = RequestMethod.POST)
public ResponseModel<Page<ESAlertCalledDto>> pageBySimilar( public ResponseModel<Page<ESAlertCalledDto>> pageBySimilar(
@RequestBody AlertCalledVo alertCalledVo, @RequestBody ESAlertCalledRequestDto alertCalledVo,
@RequestParam(value = "current") int current, @RequestParam(value = "current") int current,
@RequestParam(value = "size") int size) throws Exception { @RequestParam(value = "size") int size) throws Exception {
return ResponseHelper.buildResponse(eSAlertCalledService.queryByKeys(alertCalledVo, current, size)); return ResponseHelper.buildResponse(eSAlertCalledService.queryByKeys(alertCalledVo, current, size));
} }
/** /**
*
* <pre>
* 初始化ES
* </pre>
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "初始化ES")
@RequestMapping(value = "/es/init", method = RequestMethod.PUT)
public ResponseModel<Boolean> initEs() {
return ResponseHelper.buildResponse(eSAlertCalledService.initEs());
}
/**
* 列表无分页查询 * 列表无分页查询
* *
* @return * @return
......
...@@ -22,9 +22,10 @@ import com.alibaba.fastjson.JSONObject; ...@@ -22,9 +22,10 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledDto; import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledRequestDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled; import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.jcs.api.entity.ESAlertCalled; import com.yeejoin.amos.boot.module.jcs.api.entity.ESAlertCalled;
import com.yeejoin.amos.boot.module.jcs.api.vo.AlertCalledVo; import com.yeejoin.amos.boot.module.jcs.api.enums.AlertStatusEnum;
import com.yeejoin.amos.boot.module.jcs.biz.dao.ESAlertCalledRepository; import com.yeejoin.amos.boot.module.jcs.biz.dao.ESAlertCalledRepository;
/** /**
...@@ -46,7 +47,8 @@ public class ESAlertCalledService { ...@@ -46,7 +47,8 @@ public class ESAlertCalledService {
private ESAlertCalledRepository esAlertCalledRepository; private ESAlertCalledRepository esAlertCalledRepository;
@Autowired @Autowired
private AlertCalledServiceImpl iAlertCalledService; private AlertCalledServiceImpl alertCalledService;
@PostConstruct @PostConstruct
...@@ -100,10 +102,16 @@ public class ESAlertCalledService { ...@@ -100,10 +102,16 @@ public class ESAlertCalledService {
* @return * @return
*/ */
@SuppressWarnings({ "rawtypes" }) @SuppressWarnings({ "rawtypes" })
public Page<ESAlertCalledDto> queryByKeys(AlertCalledVo alertCalledVo, int current, int size) public Page<ESAlertCalledDto> queryByKeys(ESAlertCalledRequestDto alertCalledVo, int current, int size)
{ {
Page<ESAlertCalledDto> result = new Page<ESAlertCalledDto>(current, size); Page<ESAlertCalledDto> result = new Page<ESAlertCalledDto>(current, size);
String[] alertStatus = alertCalledVo.getAlertStatus();
if (ValidationUtil.isEmpty(alertStatus))
{
return result;
}
AlertCalled alertCalled = alertCalledVo.getAlertCalled(); AlertCalled alertCalled = alertCalledVo.getAlertCalled();
if (ValidationUtil.isEmpty(alertCalled)) if (ValidationUtil.isEmpty(alertCalled))
{ {
...@@ -113,6 +121,17 @@ public class ESAlertCalledService { ...@@ -113,6 +121,17 @@ public class ESAlertCalledService {
* 通用匹配规则,条件构建 * 通用匹配规则,条件构建
*/ */
BoolQueryBuilder boolMust = QueryBuilders.boolQuery(); BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//警情状态
BoolQueryBuilder qb0 = QueryBuilders.boolQuery();
for (String status : alertStatus)
{
AlertStatusEnum alertStatusEnum = AlertStatusEnum.getEnum(status);
if (!ValidationUtil.isEmpty(alertStatusEnum))
{
qb0.should(QueryBuilders.termQuery("alertStatusStr.keyword", alertStatusEnum.getName()));
}
}
boolMust.must(qb0);
//接警时间,距离当前时间不超过半小时的 //接警时间,距离当前时间不超过半小时的
long currentTime = System.currentTimeMillis() ; long currentTime = System.currentTimeMillis() ;
currentTime = currentTime - 30*60*1000; currentTime = currentTime - 30*60*1000;
...@@ -243,6 +262,13 @@ public class ESAlertCalledService { ...@@ -243,6 +262,13 @@ public class ESAlertCalledService {
esAlertCalled.setAddress(alertCalled.getAddress()); esAlertCalled.setAddress(alertCalled.getAddress());
esAlertCalled.setAlertStage(alertCalled.getAlertStage()); esAlertCalled.setAlertStage(alertCalled.getAlertStage());
esAlertCalled.setAlertStatus(alertCalled.getAlertStatus()); esAlertCalled.setAlertStatus(alertCalled.getAlertStatus());
if (alertCalled.getAlertStatus())
{
esAlertCalled.setAlertStatusStr(AlertStatusEnum.CLOSED.getCode());
}else
{
esAlertCalled.setAlertStatusStr(AlertStatusEnum.UNCLOSED.getCode());
}
esAlertCalled.setResponseLevelCode(alertCalled.getResponseLevelCode()); esAlertCalled.setResponseLevelCode(alertCalled.getResponseLevelCode());
esAlertCalled.setUnitInvolved(alertCalled.getUnitInvolved()); esAlertCalled.setUnitInvolved(alertCalled.getUnitInvolved());
esAlertCalled.setCoordinateX(alertCalled.getCoordinateX()); esAlertCalled.setCoordinateX(alertCalled.getCoordinateX());
...@@ -376,7 +402,7 @@ public class ESAlertCalledService { ...@@ -376,7 +402,7 @@ public class ESAlertCalledService {
wrapper.ge("call_time", date); wrapper.ge("call_time", date);
List<AlertCalled> alertCalleds = iAlertCalledService.list(wrapper); List<AlertCalled> alertCalleds = alertCalledService.list(wrapper);
if (!ValidationUtil.isEmpty(alertCalleds)) if (!ValidationUtil.isEmpty(alertCalleds))
{ {
saveAlertCalledToES(alertCalleds); saveAlertCalledToES(alertCalleds);
......
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