Commit 27473e3e by wang_jiaxing

修改全国案件相关查询为调用ES接口

parent 6043849c
......@@ -3,6 +3,7 @@ package org.springblade.founder.asj.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.founder.entity.BaseModel;
import org.springblade.founder.utils.Entity.QgEsAsj;
import java.util.Date;
......@@ -28,4 +29,19 @@ public class JbAsjXs extends BaseModel {
private String ajzlb;
private String ajxzlb;
private String xalbdmbcms;
public JbAsjXs() {
}
public JbAsjXs(QgEsAsj qgEsAsj) {
this.asjbh = qgEsAsj.getAsjbh();
this.ajmc = qgEsAsj.getAjmc();
this.fadq = qgEsAsj.getAsjfsddXzqh();
this.afsj = qgEsAsj.getAsjfssjAsjfskssj();
this.ladw = qgEsAsj.getLadwMc();
this.jyaq = qgEsAsj.getJyaq();
this.ajzlb = qgEsAsj.getAjlbdmMc();
this.ajxzlb = qgEsAsj.getAjzlbMc();
this.xalbdmbcms = qgEsAsj.getAjlbdmMc();
}
}
package org.springblade.founder.asj.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import org.springblade.founder.asj.mapper.QgJbAsjXsMapper;
import org.springblade.founder.asj.entity.AsjQueryParam;
import org.springblade.founder.asj.entity.JbAsjXs;
import org.springblade.founder.asj.entity.TbXszCbypQgaj;
import org.springblade.founder.asj.service.QgAsjQueryService;
import org.springblade.founder.asj.service.QgJbAsjXsService;
import org.springblade.founder.utils.Entity.QgEsAsj;
import org.springblade.founder.utils.Entity.QgEsEnum;
import org.springblade.founder.utils.QgEsUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@Service
@DS("xzxt_qg")
public class QgJbAsjXsServiceImpl implements QgJbAsjXsService {
@Autowired
private QgJbAsjXsMapper qgJbAsjXsMapper;
private QgAsjQueryService qgAsjQueryService;
@Override
public List<String> getAsjbhListZjhm(String zjhm, List<String> qsAsjbhList) {
return qgJbAsjXsMapper.getAsjbhListZjhm(zjhm, qsAsjbhList);
List<QgEsAsj> qgAjList = QgEsUtil.getQgEsListByTypeAndParam(QgEsEnum.GET_ASJ_BY_ZJHM, zjhm);
ArrayList<String> qgAsjList = new ArrayList<>();
qgAjList.stream().filter(asj -> !asj.getAsjbh().startsWith("A46"))
.forEach(asj -> qgAsjList.add(asj.getAsjbh()));
return qgAsjList;
}
@Override
public List<String> getAsjbhListBsh(String bsh, List<String> qsAsjbhList) {
return qgJbAsjXsMapper.getAsjbhListBsh(bsh, qsAsjbhList);
//公安网使用
List<String> qgAsjbhList = null;
List<TbXszCbypQgaj> qgajList = qgAsjQueryService.getQgAsjByBsh(bsh);
if (qgajList != null && qgajList.size() > 0) {
qgAsjbhList = new ArrayList<>();
for (TbXszCbypQgaj qgaj : qgajList) {
qgAsjbhList.add(qgaj.getAsjbh());
}
}
return qgAsjbhList;
}
@Override
public List<JbAsjXs> getAsjListByParam(AsjQueryParam asjQueryParam) {
return qgJbAsjXsMapper.getAsjListByParam(asjQueryParam);
List<String> asjbhList = asjQueryParam.getAsjbhList();
List<JbAsjXs> jbAsjXs = Collections.synchronizedList(new ArrayList<>());
asjbhList.stream().parallel().forEach(asjbh -> {
if (QgEsUtil.asjApiIsExist(asjbh)) {
List<QgEsAsj> asjList = QgEsUtil.getQgEsListByTypeAndParam(QgEsEnum.GET_ASJ_BY_ASJBH, asjbh);
asjList.stream().filter(asj -> !asj.getAsjbh().startsWith("A46"))
.forEach(asj -> jbAsjXs.add(new JbAsjXs(asj)));
}
});
return jbAsjXs;
}
}
package org.springblade.founder.utils.Entity;
import lombok.Data;
/**
* 全国案件ES接口案事件实体类
*
* @author create by lystar
* @date 2022/5/6 15:22
*/
@Data
public class QgEsAsj {
//案事件编号
private String asjbh;
//案件名称
private String ajmc;
//案件类别
private String ajlbdmMc;
//小案类别
private String ajzlbMc;
//细案类别
private String ajxzlbMc;
//简要案情
private String jyaq;
//立案日期 yyyy-MM-dd HH:mm:ss
private String larq;
//案件发生开始时间 yyyy-MM-dd HH:mm:ss
private String asjfssjAsjfskssj;
//案件发生结束时间 yyyy-MM-dd HH:mm:ss
private String asjfssjAsjfsjssj;
//立案单位代码
private String ladwdm;
//立案单位名称
private String ladwMc;
//案发地行政区划代码
private String asjfsddXzqh;
//案发地行政区划代码翻译
private String asjfsddXzqhDic;
//案发地址详址
private String asjfsddDzmc;
//损失总价值
private String ssjzrmby;
}
package org.springblade.founder.utils.Entity;
/**
* 全国案件ES接口api枚举
*
* @author create by lystar
* @date 2022/5/6 15:00
*/
public enum QgEsEnum {
IS_EXIST("AsjApiIsExist", null),
GET_ASJ_BY_ASJBH("AsjApiByAsjbh", QgEsAsj.class),
GET_ASJ_BY_ZJHM("AsjApiByZjhm", QgEsAsj.class),
GET_XYR_BY_ASJBH("zbfzxyrxxByAsjbh", QgEsXyr.class);
//全国ES接口url
private final String url;
//返回类型(实体类class对象)
private final Class<?> type;
QgEsEnum(String url, Class<?> type) {
this.url = url;
this.type = type;
}
public String getUrl() {
return url;
}
public Class<?> getType() {
return type;
}
}
package org.springblade.founder.utils.Entity;
import lombok.Data;
/**
* 全国案件ES接口嫌疑人实体类
*
* @author create by lystar
* @date 2022/5/6 16:08
*/
@Data
public class QgEsXyr {
//姓名
private String xm;
//证件号码
private String cyzjZjhm;
//性别代码
private String xbdm;
//民族代码
private String mzdm;
//出生日期
private String csrq;
//联系电话
private String lxdh;
//现住址地址
private String xzzDzmc;
//国籍代码
private String gjdm;
}
......@@ -7,6 +7,7 @@ import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
......@@ -158,9 +159,7 @@ public class HttpUtils {
try{
//设置参数解决中文乱码
if (null != json){
StringEntity entity = new StringEntity(json,"utf-8");
entity.setContentEncoding("UTF-8");
entity.setContentType("application/json");
StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
httpPost.setEntity(entity);
}
//发送请求
......
package org.springblade.founder.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springblade.founder.utils.Entity.QgEsAsj;
import org.springblade.founder.utils.Entity.QgEsEnum;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 全国案件ES接口工具类
*
* @author create by lystar
* @date 2022/5/6 15:10
*/
@Slf4j
@Component
public class QgEsUtil {
private static String url;
private static String authorization;
private static final HashMap<String, String> headers = new HashMap<>();
@Value("${qgEs.url}")
private void setUrl(String url) {
QgEsUtil.url = url;
}
@Value("${qgEs.authorization}")
private void setAuthorization(String authorization) {
QgEsUtil.authorization = authorization;
if (!headers.containsKey("founder.authorization")) {
headers.put("founder.authorization", QgEsUtil.authorization);
}
}
/**
* asjApiIsExist 查询案件是否存在全国ES接口中
*
* @param asjbh: 案事件编号
* @return boolean
* @author lystar
* 2022/5/6 16:25
*/
public static boolean asjApiIsExist(String asjbh) {
try {
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("asjbh", asjbh);
JSONObject json = new JSONObject(jsonMap);
String jsonStr = HttpUtils.doPostJson(url + QgEsEnum.IS_EXIST.getUrl(), headers, json.toString());
JSONObject resultJson = JSON.parseObject(jsonStr);
JSONObject data = resultJson.getJSONObject("data");
return data.getBooleanValue("isExist");
} catch (Exception e) {
log.error("查询全国案件是否存在报错", e);
}
return false;
}
/**
* getQgEsListByTypeAndParam 查询全国ES资源接口数据(数据列表)
*
* @param qgEsEnum: 全国ES接口枚举类型
* @param bh: 号码(案事件编号或证件号码)传身份证号时查询全部
* @return java.util.Map<java.lang.String, java.lang.Object>
* @author lystar
* 2022/5/6 16:26
*/
public static <T> List<T> getQgEsListByTypeAndParam(QgEsEnum qgEsEnum, String bh) {
try {
Map<String, Object> jsonMap = new HashMap<>();
if (QgEsEnum.GET_ASJ_BY_ZJHM == qgEsEnum) {
Map<String, Object> map = getAllAsjMapByZjhm(bh);
List<T> javaList = (List<T>) map.get("rows");
if (javaList == null) {
return new ArrayList<>(0);
}
return javaList;
}
jsonMap.put("asjbh", bh);
JSONObject json = new JSONObject(jsonMap);
String resultJson = HttpUtils.doPostJson(url + qgEsEnum.getUrl(), headers, json.toString());
HashMap<String, Object> map = getResultMapByJsonAndType(qgEsEnum.getType(), resultJson);
List<T> javaList = (List<T>) map.get("rows");
if (javaList == null || javaList.isEmpty()) {
return javaList == null ? new ArrayList<>(0) : javaList;
}
} catch (Exception e) {
log.error("查询全国ES接口报错", e);
}
return new ArrayList<>(0);
}
/**
* getQgEsJsonByTypeAndParam 查询全国ES资源接口数据(map集合,包括total:总数,rows:数据列表)
*
* @param qgEsEnum: 全国ES接口枚举类型
* @param bh: 号码(案事件编号或证件号码)传身份证号时查询全部
* @return java.util.Map<java.lang.String, java.lang.Object>
* @author lystar
* 2022/5/6 16:26
*/
public static Map<String, Object> getQgEsMapByTypeAndParam(QgEsEnum qgEsEnum, String bh) {
try {
Map<String, Object> jsonMap = new HashMap<>();
if (QgEsEnum.GET_XYR_BY_ASJBH == qgEsEnum) {
return getAllAsjMapByZjhm(bh);
}
JSONObject json = new JSONObject(jsonMap);
String json1 = json.toString();
String resultJson = HttpUtils.doPostJson(url + qgEsEnum.getUrl(), headers, json1);
return getResultMapByJsonAndType(qgEsEnum.getType(), resultJson);
} catch (Exception e) {
log.error("查询全国ES接口报错", e);
}
return null;
}
/**
* getQgEsJsonByTypeAndParam 查询全国ES资源接口数据(map集合,包括total:总数,rows:数据列表)
*
* @param qgEsEnum: 全国ES接口枚举类型
* @param bh: 号码(案事件编号或证件号码)
* @param page: 当前页码,只有嫌疑人查案件需要
* @param limit: 每页条数,只有嫌疑人查案件需要
* @return java.util.Map<java.lang.String, java.lang.Object>
* @author lystar
* 2022/5/6 16:26
*/
public static Map<String, Object> getQgEsMapByTypeAndParam(QgEsEnum qgEsEnum, String bh, Integer page, Integer limit) {
try {
Map<String, Object> jsonMap = new HashMap<>();
if (numberIsEmpty(page) || numberIsEmpty(limit)) {
jsonMap.put("asjbh", bh);
} else {
jsonMap.put("zjhm", bh);
jsonMap.put("page", page);
jsonMap.put("limit", limit);
}
JSONObject json = new JSONObject(jsonMap);
String resultJson = HttpUtils.doPostJson(url + qgEsEnum.getUrl(), headers, json.toString());
return getResultMapByJsonAndType(qgEsEnum.getType(), resultJson);
} catch (Exception e) {
log.error("查询全国ES接口报错", e);
}
return null;
}
/**
* getAllAsjMapByZjhm 查询嫌疑人全部案件信息
*
* @param zjhm: 证件号码
* @return java.util.Map<java.lang.String, java.lang.Object>
* @author lystar
* 2022/5/6 17:36
*/
private static Map<String, Object> getAllAsjMapByZjhm(String zjhm) {
int page = 1;
int limit = 100;
HashMap<String, Object> result = new HashMap<>();
Map<String, Object> resultMap = QgEsUtil.getQgEsMapByTypeAndParam(QgEsEnum.GET_ASJ_BY_ZJHM, zjhm, page, limit);
if (resultMap == null) {
result.put("total", 0);
result.put("rows", new ArrayList<>(0));
return result;
}
Integer total = (Integer) resultMap.get("total");
if (total == null) {
total = 0;
}
List<QgEsAsj> javaList = (List<QgEsAsj>) resultMap.get("rows");
if (javaList == null || javaList.isEmpty() || total == 0) {
result.put("total", 0);
result.put("rows", new ArrayList<>(0));
return result;
}
total -= javaList.size();
while (total > 0) {
page++;
limit = limit > total ? total : limit;
Map<String, Object> map = QgEsUtil.getQgEsMapByTypeAndParam(QgEsEnum.GET_ASJ_BY_ZJHM, zjhm, page, limit);
if (map == null) {
break;
}
List<QgEsAsj> list = (List<QgEsAsj>) map.get("rows");
if (list != null && !list.isEmpty()) {
javaList.addAll(list);
}
total -= javaList.size();
}
result.put("total", javaList.size());
result.put("rows", javaList);
return result;
}
/**
* getResultMapByJsonAndType 解析返回的json串,私有,不对外使用
*
* @param type: 返回类型
* @param json: json串
* @return java.util.HashMap<java.lang.String, java.lang.Object>
* @author lystar
* 2022/5/6 16:29
*/
private static HashMap<String, Object> getResultMapByJsonAndType(Class<?> type, String json) throws Exception {
if (type == null) {
throw new Exception("查询案件是否存在请直接使用asjApiIsExist方法");
}
if (json == null || "".equals(json)) {
log.error("全国ES接口返回数据为空");
return new HashMap<>();
}
JSONObject resultJson = JSON.parseObject(json);
JSONObject data = resultJson.getJSONObject("data");
HashMap<String, Object> resultMap = new HashMap<>();
int total = data.getIntValue("total");
resultMap.put("total", total);
JSONArray rows = data.getJSONArray("rows");
List<?> javaList = rows.toJavaList(type);
resultMap.put("rows", javaList);
return resultMap;
}
/**
* numberIsEmpty 判断分页参数是否为空或0
*
* @param number: 分页参数数据
* @return boolean
* @author lystar
* 2022/5/6 16:29
*/
private static boolean numberIsEmpty(Integer number) {
return number == null || (number == 0);
}
}
package org.springblade.founder.ydjwhc.controller;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.springblade.founder.log.LogOper;
import org.springblade.founder.utils.R;
......
......@@ -2,6 +2,7 @@ package org.springblade.founder.ydjwhc.entity;
import lombok.Data;
import org.springblade.founder.asj.entity.TbXszCbypQgaj;
import org.springblade.founder.utils.Entity.QgEsAsj;
import org.springframework.format.annotation.DateTimeFormat;
import java.text.ParseException;
......@@ -40,4 +41,20 @@ public class HcAjJg {
e.printStackTrace();
}
}
public HcAjJg(QgEsAsj qgEsAsj) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
this.asjbh = qgEsAsj.getAsjbh();
this.ajmc = qgEsAsj.getAjmc();
this.ladw = qgEsAsj.getLadwMc();
if (qgEsAsj.getAsjfssjAsjfskssj() != null && !"".equals(qgEsAsj.getAsjfssjAsjfskssj())) {
this.afsj = sdf.parse(qgEsAsj.getAsjfssjAsjfskssj());
}
this.fadq = qgEsAsj.getAsjfsddXzqh();
this.ajlb = qgEsAsj.getAjlbdmMc();
} catch (Exception e) {
e.printStackTrace();
}
}
}
......@@ -19,5 +19,5 @@ public interface QsBjHcMapper {
HcAjJg selectAjByAsjbh(String asjbh);
String getNameByCodeAndGroupid(@Param("ajlb") String ajlb, @Param("code_ajlb") String code_ajlb);
String getNameByCodeAndGroupid(@Param("code") String code, @Param("groupid") String groupid);
}
......@@ -209,10 +209,10 @@ public class BjHcServiceImpl implements BjHcService {
resultMap.put("qsAjCount", qsAjList.size());
List<HcAjJg> qgAjList = qgBjHcService.selectAjBySfzh(hm, qsAjList);
for (HcAjJg hcAjJg : qgAjList) {
if (StringUtils.isNotBlank(hcAjJg.getAjlb())) {
String ajlb = qsBjHcService.getNameByCodeAndGroupid(hcAjJg.getAjlb(), "CODE_AJLB");
hcAjJg.setAjlb(ajlb);
}
// if (StringUtils.isNotBlank(hcAjJg.getAjlb())) {
// String ajlb = qsBjHcService.getNameByCodeAndGroupid(hcAjJg.getAjlb(), "CODE_AJLB");
// hcAjJg.setAjlb(ajlb);
// }
if (StringUtils.isNotBlank(hcAjJg.getFadq())) {
String fadq = qsBjHcService.getNameByCodeAndGroupid(hcAjJg.getFadq(), "CODE_XZQH");
hcAjJg.setFadq(fadq);
......
package org.springblade.founder.ydjwhc.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import org.springblade.founder.utils.Entity.QgEsAsj;
import org.springblade.founder.utils.Entity.QgEsEnum;
import org.springblade.founder.utils.QgEsUtil;
import org.springblade.founder.ydjwhc.entity.HcAjJg;
import org.springblade.founder.ydjwhc.mapper.QgBjHcMapper;
import org.springblade.founder.ydjwhc.service.QgBjHcService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
@DS("xzxt_qg")
......@@ -18,7 +23,11 @@ public class QgBjHcServiceImpl implements QgBjHcService {
@Override
public List<HcAjJg> selectAjBySfzh(String sfzh, List<HcAjJg> qsAjList) {
return qgBjHcMapper.selectAjBySfzh(sfzh, qsAjList);
List<QgEsAsj> qgAjList = QgEsUtil.getQgEsListByTypeAndParam(QgEsEnum.GET_ASJ_BY_ZJHM, sfzh);
ArrayList<HcAjJg> qgAsjList = new ArrayList<>();
qgAjList.stream().filter(asj -> !asj.getAsjbh().startsWith("A46"))
.forEach(asj -> qgAsjList.add(new HcAjJg(asj)));
return qgAsjList;
}
@Override
......
......@@ -118,3 +118,8 @@ socketIoUrl: http://74.6.54.153:9022/sendMassage
bbgxfjPath: /Users/lystar/Software/fileupload/fileupload
rxhczpPath: /Users/lystar/Software/fileupload/rxhczp
qgEs:
url: http://74.6.54.172:9061/xxcx/
# url: http://localhost:9022/bjhc/ktsj/
authorization: Basic 9b6c45cfcf3a4a629e3ed90fa3e5d058
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