Commit 4c26173a by wang_jiaxing

全国相关接口

parent efb5848b
......@@ -8,7 +8,6 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* TODO
*
* @author create by lystar
* @date 2022/8/16 09:42
......@@ -16,6 +15,6 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
public @interface CheckAuthorization {
CheckType type();
boolean checkIp();
CheckType type() default CheckType.FW;
boolean checkIp() default true;
}
......@@ -2,8 +2,11 @@ package com.founder.checkAuthorization.mysqldao;
import com.founder.checkAuthorization.entity.CheckEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.Map;
/**
* @author create by lystar
* @date 2022/8/16 10:17
......@@ -14,4 +17,6 @@ public interface AuthorizationMapper {
CheckEntity getAuthorizationByZy(CheckEntity checkEntity);
CheckEntity getAuthorizationByFw(CheckEntity checkEntity);
Map<String, String> getFwidAndXtmc(@Param("appId") String appId, @Param("appSecret") String appSecret);
}
package com.founder.controller;
import com.alibaba.fastjson.JSONObject;
import com.founder.checkAuthorization.annotation.CheckAuthorization;
import com.founder.checkAuthorization.config.AuthorizationInterceptor;
import com.founder.checkAuthorization.mysqldao.AuthorizationMapper;
import com.founder.common.IpADdress;
import com.founder.common.IpADressLock;
import com.founder.common.LogsUtil;
import com.founder.model.*;
import com.founder.service.SysGnsyrzOpenApiService;
import com.founder.service.XxcxService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@RestController
@RequestMapping(value="/ggfw/qg",produces = "application/json; charset=utf-8")
@CheckAuthorization
public class GgfwXxcxController {
@Value("${app_keyes}")
private String app_key;
@Value("${app_secretes}")
private String app_secret;
@Value("${moduleId}")
private String moduleId;
@Value("${moduleName}")
private String moduleName;
@Value("${gabesUrl}")
private String gabesUrl;
@Value("${gabUrl}")
private String gabUrl;
@Autowired
private SysGnsyrzOpenApiService sysGnsyrzOpenApiService;
@Autowired
private XxcxService xxcxService;
@Autowired
private IpADressLock ipADressLock;
@Autowired
private RestTemplate restTemplate;
@Autowired
private AuthorizationMapper authorizationMapper;
@RequestMapping("/AsjApiByAsjbh")
public R AsjApiByAsjbh(HttpServletRequest request, @RequestBody AsjRyRelateVoBzpt asjbl){
if(StringUtils.isEmpty(asjbl.getAsjbh()) ){
return R.error("没有传入案件编号,不能查询!");
}
Map mapResult = new HashMap();
List<Map<String,Object>> listResult = new ArrayList<>();
AsjRyRelateVoBzpt asj=new AsjRyRelateVoBzpt();
asj.setAsjbh(asjbl.getAsjbh());
JSONObject jsonParams = new JSONObject();
jsonParams.put("index","tb_st_asj");// 索引名称
jsonParams.put("request",JSONObject.parse(queryJson(asj)));// 请求json
System.out.println("----"+jsonParams.toJSONString());
HttpEntity<Map<String,Object>> params = new HttpEntity<>(jsonParams,getHeaders(asj));// 请求头
JSONObject resultJson = restTemplate.postForEntity(gabesUrl+"search",params,JSONObject.class).getBody();
LinkedHashMap json = (LinkedHashMap) resultJson.get("result");
LinkedHashMap jsonResponse = (LinkedHashMap) json.get("response");
LinkedHashMap jsonHit = (LinkedHashMap) jsonResponse.get("hits");
int total = (int) jsonHit.get("total");
if(total > 0 ){
List<LinkedHashMap> jsonHitArray = (List<LinkedHashMap>) jsonHit.get("hits");
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddhhmmss");
for(int i=0;i<jsonHitArray.size();i++){
Map map = new HashMap();
LinkedHashMap obj = (LinkedHashMap) jsonHitArray.get(i).get("_source");
String asjbh = (String) obj.get("v_solr6_tb_st_asj_AS_ASJBH");
String ajmc = (String) obj.get("v_solr6_tb_st_asj_AT_AJMC");
String ajlbdmMc = (String) obj.get("v_solr6_tb_st_asj_AS_AJLBDM_value");// 案件类别
String ajlbdm = (String) obj.get("v_solr6_tb_st_asj_AS_AJLBDM");// 案件类别代码
String ajzlbMc = (String) obj.get("v_solr6_tb_st_asj_AS_ZATZ_JYQK_value");// 小案类别
String ajxzlbMc = (String) obj.get("tb_st_asj_asjbz_AJXLB_VALUE");// 细类案类别
String bzrXm = (String) obj.get("tb_st_asj_asjbz_XXCZRY_XM");// 标注人姓名
String bzrDwdmMc = (String) obj.get("tb_st_asj_asjbz_XXCZDW_GAJGJGDM_VALUE");// 标注人单位
String asjfsddDzmc = (String) obj.get("v_solr6_tb_st_asj_AT_ASJFSDD_DZMC");// 案发地详细地址
String asjfsddXzqh = (String) obj.get("v_solr6_tb_st_asj_AS_ASJFSDD_XZQHDM");// 案发地详细地址
String ssjzrmby = (String) obj.get("v_solr6_tb_st_asj_AN_SSJZRMBY");// 损失总价值
String larq = (String) obj.get("v_solr6_tb_st_asj_AS_LARQ");// 立案日期
String ladwdm = (String) obj.get("v_solr6_tb_st_asj_AS_LADW_GAJGJGDM");// 立案单位代码
String ladwMc = (String) obj.get("v_solr6_tb_st_asj_AT_LADW_GAJGMC");// 立案单位名称
String asjfssjAsjfskssj = (String) obj.get("v_solr6_tb_st_asj_AS_ASJFSSJ_ASJFSKSSJ");// 案发开始时间
String asjfssjAsjfsjssj = (String) obj.get("v_solr6_tb_st_asj_AS_ASJFSSJ_ASJFSJSSJ");// 案发结束时间
String jyaq = (String) obj.get("v_solr6_tb_st_asj_AT_JYAQ");// 简要案情
String bzztMs = (String) obj.get("tb_st_asj_asjbz_BZZT_VALUE");// 标注状态描述
String bzzt = (String) obj.get("tb_st_asj_asjbz_BZZT");// 标注状态
map.put("asjbh",asjbh);
map.put("ajmc",ajmc);
map.put("ajlbdmMc",ajlbdmMc);
map.put("ajlbdm",ajlbdm);
map.put("ajzlbMc",ajzlbMc);
map.put("ajxzlbMc",ajxzlbMc);
map.put("bzrDwdmMc",bzrDwdmMc);
map.put("bzrXm",bzrXm);
map.put("asjfsddDzmc",asjfsddDzmc);
map.put("ssjzrmby",ssjzrmby);
map.put("asjfsddXzqh",asjfsddXzqh);
// if(null!=ladwPcs){
// ladwMc = detailervice.getDwMcBydm(ladwPcs);
// }
map.put("ladwdm",ladwdm);
map.put("ladwMc",ladwMc);
// 立案日期和案发日期 过滤
if(null != larq){
try {
map.put("larq",sf.parse(larq));
} catch (ParseException e) {
e.printStackTrace();
}
}else{
map.put("larq","无");
}
if(null != asjfssjAsjfskssj){
try {
map.put("asjfssjAsjfskssj",sf.parse(asjfssjAsjfskssj));
} catch (ParseException e) {
e.printStackTrace();
}
}else{
map.put("asjfssjAsjfskssj","无");
}
if(null != asjfssjAsjfsjssj){
try {
map.put("asjfssjAsjfsjssj",sf.parse(asjfssjAsjfsjssj));
} catch (ParseException e) {
e.printStackTrace();
}
}else{
map.put("asjfssjAsjfsjssj","无");
}
if(StringUtils.isEmpty(bzztMs)){
map.put("bzztMs","未标注");
}else{
map.put("bzztMs",bzztMs);
}
map.put("bzzt",bzzt);
map.put("jyaq",jyaq);
listResult.add(map);
}
}
mapResult.put("total",total);
mapResult.put("rows",listResult);
Map<String, String> map = getFwidAndXtmc(request);
sysGnsyrzOpenApiService.insertGNSYRZOPENAPI("01",map.get("FWMC"), LogsUtil.getNotEmptyFiled(asjbl).toString(),
"","","430000000000",map.get("XTMC"),"", ipADressLock.getAddressIp(request),"1", map.get("FWID"));
return R.ok().data(mapResult).message(map.get("FWMC") + "查询成功");
}
@RequestMapping("/AsjApiByZjhm")
public R AsjApiByZjhm(@RequestBody XyrParam xyr){
HttpServletRequest request = IpADdress.getRequest();
if(StringUtils.isEmpty(xyr.getZjhm()) ){
return R.error("没有传入证件号码,不能查询!");
}
Map mapResult = new HashMap();
List<Map<String,Object>> listResult = new ArrayList<>();
AsjRyRelateVoBzpt asj=new AsjRyRelateVoBzpt();
JSONObject jsonParams = new JSONObject();
jsonParams.put("index","tb_st_asj");// 索引名称
jsonParams.put("request",JSONObject.parse(xxcxService.getEsAsjQryStr(xyr)));// 请求json
System.out.println("----"+jsonParams.toJSONString());
HttpEntity<Map<String,Object>> params = new HttpEntity<>(jsonParams,getHeaders(asj));// 请求头
JSONObject resultJson = restTemplate.postForEntity(gabesUrl+"search",params,JSONObject.class).getBody();
// JSONObject resultJson =getAsjResultJson();
LinkedHashMap json = (LinkedHashMap) resultJson.get("result");
LinkedHashMap jsonResponse = (LinkedHashMap) json.get("response");
LinkedHashMap jsonHit = (LinkedHashMap) jsonResponse.get("hits");
int total = (int) jsonHit.get("total");
if(total > 0 ){
List<LinkedHashMap> jsonHitArray = (List<LinkedHashMap>) jsonHit.get("hits");
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddhhmmss");
for(int i=0;i<jsonHitArray.size();i++){
Map map = new HashMap();
LinkedHashMap obj = (LinkedHashMap) jsonHitArray.get(i).get("_source");
String asjbh = (String) obj.get("v_solr6_tb_st_asj_AS_ASJBH");
String ajmc = (String) obj.get("v_solr6_tb_st_asj_AT_AJMC");
String ajlbdmMc = (String) obj.get("v_solr6_tb_st_asj_AS_AJLBDM_value");// 案件类别名称
String ajlbdm = (String) obj.get("v_solr6_tb_st_asj_AS_AJLBDM");// 案件类别代码
String ajzlbMc = (String) obj.get("v_solr6_tb_st_asj_AS_ZATZ_JYQK_value");// 小案类别
String ajxzlbMc = (String) obj.get("tb_st_asj_asjbz_AJXLB_VALUE");// 细类案类别
String bzrXm = (String) obj.get("tb_st_asj_asjbz_XXCZRY_XM");// 标注人姓名
String bzrDwdmMc = (String) obj.get("tb_st_asj_asjbz_XXCZDW_GAJGJGDM_VALUE");// 标注人单位
String asjfsddDzmc = (String) obj.get("v_solr6_tb_st_asj_AT_ASJFSDD_DZMC");// 案发地详细地址
String asjfsddXzqh = (String) obj.get("v_solr6_tb_st_asj_AS_ASJFSDD_XZQHDM");// 案发地详细地址
String ssjzrmby = (String) obj.get("v_solr6_tb_st_asj_AN_SSJZRMBY");// 损失总价值
String larq = (String) obj.get("v_solr6_tb_st_asj_AS_LARQ");// 立案日期
String ladwdm = (String) obj.get("v_solr6_tb_st_asj_AS_LADW_GAJGJGDM");// 立案单位代码
String ladwMc = (String) obj.get("v_solr6_tb_st_asj_AT_LADW_GAJGMC");// 立案单位名称
String asjfssjAsjfskssj = (String) obj.get("v_solr6_tb_st_asj_AS_ASJFSSJ_ASJFSKSSJ");// 案发开始时间
String asjfssjAsjfsjssj = (String) obj.get("v_solr6_tb_st_asj_AS_ASJFSSJ_ASJFSJSSJ");// 案发结束时间
String jyaq = (String) obj.get("v_solr6_tb_st_asj_AT_JYAQ");// 简要案情
String bzztMs = (String) obj.get("tb_st_asj_asjbz_BZZT_VALUE");// 标注状态描述
String bzzt = (String) obj.get("tb_st_asj_asjbz_BZZT");// 标注状态
String zcjddm=(String) obj.get("v_solr6_tb_st_asj_AS_ZCJDDM");//侦查阶段代码
String zbrxm=(String) obj.get("v_solr6_tb_st_asj_AS_ZUZDW_ZBR_XM");//主办人姓名
String zbrdwmc=(String) obj.get("v_solr6_tb_st_asj_AT_ZUZDW_GAJGMC");//主办人单位名称
map.put("asjbh",asjbh);
map.put("ajmc",ajmc);
map.put("ajlbdmMc",ajlbdmMc);
map.put("zcjddm",zcjddm);
map.put("ajlbdm",ajlbdm);
map.put("ajzlbMc",ajzlbMc);
map.put("ajxzlbMc",ajxzlbMc);
map.put("bzrDwdmMc",bzrDwdmMc);
map.put("bzrXm",bzrXm);
map.put("asjfsddDzmc",asjfsddDzmc);
map.put("ssjzrmby",ssjzrmby);
map.put("zbrxm",zbrxm);
map.put("zbrdwmc",zbrdwmc);
map.put("asjfsddXzqh",asjfsddXzqh);
// if(null!=ladwPcs){
// ladwMc = detailervice.getDwMcBydm(ladwPcs);
// }
map.put("ladwdm",ladwdm);
map.put("ladwMc",ladwMc);
// 立案日期和案发日期 过滤
if(null != larq){
try {
map.put("larq",sf.parse(larq));
} catch (ParseException e) {
e.printStackTrace();
}
}else{
map.put("larq","无");
}
if(null != asjfssjAsjfskssj){
try {
map.put("asjfssjAsjfskssj",sf.parse(asjfssjAsjfskssj));
} catch (ParseException e) {
e.printStackTrace();
}
}else{
map.put("asjfssjAsjfskssj","无");
}
if(null != asjfssjAsjfsjssj){
try {
map.put("asjfssjAsjfsjssj",sf.parse(asjfssjAsjfsjssj));
} catch (ParseException e) {
e.printStackTrace();
}
}else{
map.put("asjfssjAsjfsjssj","无");
}
if(StringUtils.isEmpty(bzztMs)){
map.put("bzztMs","未标注");
}else{
map.put("bzztMs",bzztMs);
}
map.put("bzzt",bzzt);
map.put("jyaq",jyaq);
listResult.add(map);
}
}
mapResult.put("total",total);
mapResult.put("rows",listResult);
Map<String, String> map = getFwidAndXtmc(request);
sysGnsyrzOpenApiService.insertGNSYRZOPENAPI("01",map.get("FWMC"), LogsUtil.getNotEmptyFiled(xyr).toString(),
"","","430000000000",map.get("XTMC"),"", ipADressLock.getAddressIp(request),"1", map.get("FWID"));
return R.ok().data(mapResult).message(map.get("FWMC") + "查询成功");
}
@RequestMapping("/AsjApiIsExist")
public R AsjApiIsExist(@RequestBody AsjRyRelateVoBzpt asjbl){
HttpServletRequest request = IpADdress.getRequest();
if(StringUtils.isEmpty(asjbl.getAsjbh()) ){
return R.error("没有传入案件编号,不能查询!");
}
Map mapResult = new HashMap();
mapResult.put("isExist","false");
List<Map<String,Object>> listResult = new ArrayList<>();
AsjRyRelateVoBzpt asj=new AsjRyRelateVoBzpt();
asj.setAsjbh(asjbl.getAsjbh());
JSONObject jsonParams = new JSONObject();
jsonParams.put("index","tb_st_asj");// 索引名称
jsonParams.put("request",JSONObject.parse(queryJson(asj)));// 请求json
System.out.println("----"+jsonParams.toJSONString());
HttpEntity<Map<String,Object>> params = new HttpEntity<>(jsonParams,getHeaders(asj));// 请求头
JSONObject resultJson = restTemplate.postForEntity(gabesUrl+"search",params,JSONObject.class).getBody();
LinkedHashMap json = (LinkedHashMap) resultJson.get("result");
LinkedHashMap jsonResponse = (LinkedHashMap) json.get("response");
LinkedHashMap jsonHit = (LinkedHashMap) jsonResponse.get("hits");
int total = (int) jsonHit.get("total");
if(total > 0 ){
mapResult.put("isExist","true");
}
Map<String, String> map = getFwidAndXtmc(request);
sysGnsyrzOpenApiService.insertGNSYRZOPENAPI("01",map.get("FWMC"), LogsUtil.getNotEmptyFiled(asjbl).toString(),
"","","430000000000",map.get("XTMC"),"", ipADressLock.getAddressIp(request),"1", map.get("FWID"));
return R.ok().data(mapResult).message(map.get("FWMC") + "查询成功");
}
@RequestMapping("/zbfzxyrxxByAsjbh")
public R zbfzxyrxxByAsjbh(@RequestBody AsjRyRelateVoBzpt asjbl){
HttpServletRequest request = IpADdress.getRequest();
if(StringUtils.isEmpty(asjbl.getAsjbh()) ){
return R.error("没有传入案件编号,不能查询!");
}
Map mapResult = new HashMap();
Map<String, Object> resultMap = new HashMap<String, Object>();
//通过案件编号拿到受害人信息
//如没有案件编号表示没有相关联的受害人信息
//拿到身份证号码调用人员常口---数据库落地数据基本只有身份证号码
Qgckzp getzp = new Qgckzp(); //全国人员常口
List<TbStRy> listTbStRy = new ArrayList<>();
AsjRyRelateVoBzpt asj=new AsjRyRelateVoBzpt();
asj.setAsjbh(asjbl.getAsjbh());
JSONObject jsonParams = new JSONObject();
jsonParams.put("asjbh",asj.getAsjbh());
jsonParams.put("from","0");
jsonParams.put("size","1000");
HttpEntity<Map<String,Object>> params = new HttpEntity<>(jsonParams,getHeaders(asj));// 请求头
JSONObject resultJson = restTemplate.postForEntity(gabUrl+"xyr",params,JSONObject.class).getBody();
List<LinkedHashMap> jsonHitArray = (List<LinkedHashMap>) resultJson.get("result");
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
if(jsonHitArray.size()>0){
for(int i=0;i<jsonHitArray.size();i++){
TbStRy tbStRy = new TbStRy();
LinkedHashMap obj = (LinkedHashMap) jsonHitArray.get(i);
String xm = (String) obj.get("ZHFZXYR_XM");// 姓名
String xzzDzmc = (String) obj.get("ZHFZXYR_XZZ_DZMC");// 现住址
String lxdh = (String) obj.get("ZHFZXYR_LXDH");// 联系电话
String csrq = (String) obj.get("ZHFZXYR_CSRQ_RQGZXX");// 出生日期
String cyzjZjhm = (String) obj.get("ZHFZXYR_CYZJ_ZJHM");// 证件号码
String xbdm = (String) obj.get("ZHFZXYR_XBDM");// 性别
String mzdm = (String) obj.get("ZHFZXYR_MZDM");// 民族
String gjdm = (String) obj.get("ZHFZXYR_GJDM");// 国际
tbStRy.setXm(xm);
tbStRy.setXzzDzmc(xzzDzmc);
tbStRy.setLxdh(lxdh);
if(StringUtils.isNotEmpty(csrq)){
try {
tbStRy.setCsrq(sf.format(sf.parse(csrq)));
} catch (ParseException e) {
e.printStackTrace();
}
}
HashMap<String,String> codeMap = new HashMap<String,String>();
// 性别
if(StringUtils.isNotEmpty(xbdm)){
// 翻译行政区划
codeMap.put("groupid","CODE_XB");
codeMap.put("code",xbdm);
tbStRy.setXbdm(xbdm);
// String name = sysDictitemMapper.getNameByCode(codeMap);
// tbStRy.setXbdmStr(name);
}
// 民族
if(StringUtils.isNotEmpty(mzdm)){
// 翻译行政区划
codeMap.put("groupid","CODE_MZ");
codeMap.put("code",mzdm);
tbStRy.setMzdm(mzdm);
// String name = sysDictitemMapper.getNameByCode(codeMap);
// tbStRy.setMzdmStr(name);
}
// 国籍
if(StringUtils.isNotEmpty(gjdm)){
// 翻译行政区划
codeMap.put("groupid","CODE_GJ");
codeMap.put("code",gjdm);
tbStRy.setGjdm(gjdm);
// String name = sysDictitemMapper.getNameByCode(codeMap);
// tbStRy.setGjdm(name);
}
tbStRy.setCyzjZjhm(cyzjZjhm);
// if (cyzjZjhm != null && !"".equals(cyzjZjhm.trim())) {
// String ryzp = getzp.getQgckZpXml(cyzjZjhm);// 获取人员照片
// tbStRy.setZp(ryzp);
// }
listTbStRy.add(tbStRy);
}
}
String zbfzxyrCount = "0";
if(listTbStRy!=null){
zbfzxyrCount = ""+listTbStRy.size();
}
resultMap.put("total",zbfzxyrCount);
resultMap.put("rows",listTbStRy);
Map<String, String> map = getFwidAndXtmc(request);
sysGnsyrzOpenApiService.insertGNSYRZOPENAPI("01",map.get("FWMC"), LogsUtil.getNotEmptyFiled(asjbl).toString(),
"","","430000000000",map.get("XTMC"),"", ipADressLock.getAddressIp(request),"1", map.get("FWID"));
return R.ok().data(mapResult).message(map.get("FWMC") + "查询成功");
}
public HttpHeaders getHeaders(AsjRyRelateVoBzpt asj) {
HttpHeaders hearders = new HttpHeaders();
// 设置请求头的格式类型
hearders.setContentType(MediaType.APPLICATION_JSON);
hearders.set("app_key",app_key);
hearders.set("app_secret",app_secret);
hearders.set("moduleId",moduleId);
hearders.set("moduleName",moduleName);
hearders.set("userCardId","460000");
hearders.set("userName","admin");
hearders.set("userDept","460000");
hearders.set("userDeptName","海南省公安厅");
hearders.set("zdsbip","74.25.21.65");
return hearders;
}
public String queryJson(AsjRyRelateVoBzpt asj) {
String sortStr1 = "," + "\"sort\": {";//排序
String sortStr2 = "}";
String ascOrdesc = "desc";
if(asj.getPage()==null||"".equals(asj.getPage())){
asj.setPage("1");
}
if(asj.getLimit()==null||"".equals(asj.getLimit())){
asj.setLimit("10");
}
String fenye = ",\"from\":" + (((Integer.parseInt(asj.getPage()) - 1) * Integer.parseInt(asj.getLimit()))) + ",\"size\":" + asj.getLimit();
String unitCode = asj.getUnitcode();
String grade = asj.getGrade();
//编辑查询条件
String qbStr1 = "{\"query\": {\"bool\": {";
String qbStr2 = "}}, \"track_total_hits\": true";
String sortQ = "\"" + "v_solr6_tb_st_asj_AS_LARQ" + "\"" + ": { \"order\": \"" + ascOrdesc + "\"}";
String sortjson = sortStr1 + sortQ + sortStr2 + fenye;
qbStr2 += sortjson + "}";
String shouldStr1 = ",\"should\": [";
String shouldStr2 = "]";
String matchstr1 = "{\"match\": {";
String matchstr2 = "}}";
String must1 = "\"must\": [";
String must2 = "]";
String must_not1 = "\"must_not\": [";
String must_not2 = "]";
String mmsStr1 = "\"must_not\": [{\"match\": {";
String mmsStr2 = "}}]";
String wildcardStr1 = "{\"wildcard\": {";//模糊查询
String wildcardStr2 = "}}";
String rangStr1 = "{\"range\": {";//日期范围
String rangStr2 = "}}}";
String existStr1 = "{\"exists\": {";//非空
String existStr2 = "}}";
String filterStr1 = "\"filter\": [";
String filterStr2 = "]";
// // 根据用户grade判断 B公安部 S省级 D地市 X县级 K派出所
if("B".equals(grade)){
asj.setLadw_gajgjgdm("B");
}else if("S".equals(grade)){
asj.setLadw_gajgjgdm(asj.getUnitcode().substring(0,2));
}else if("D".equals(grade)){
asj.setLadw_gajgjgdm(asj.getUnitcode().substring(0,4));
}else if("X".equals(grade)){
asj.setLadw_gajgjgdm(asj.getUnitcode().substring(0,6));
}else if("K".equals(grade)){
asj.setLadw_gajgjgdm(asj.getUnitcode().substring(0,6));
}
String q = matchstr1 + "\"v_solr6_tb_st_asj_AS_XXSC_PDBZ\" : \"0\"" + matchstr2;// 默认删除标志为0
String q1 = "";//must_not
String q2 = "";//should
// q += ",{\"bool\" : { \"should\" : [{\"terms\" : {\"v_solr6_tb_st_asj_AS_AJLBDM\" : [\"05000200\",\"05000300\",\"05000100\",\"05000400\",\"06010300\",\"05001000\",\"04000900\",\"06012400\",\"05001100\",\"06012300\",\"03080700\",\"04000300\",\"06015400\"]}}]}}";
if (StringUtils.isNotEmpty(asj.getAsjbh())) {// 案件编号
q += "," + matchstr1 + "\"v_solr6_tb_st_asj_AS_ASJBH\" : \"" + asj.getAsjbh() + "\"" + matchstr2;
}
if (StringUtils.isNotEmpty(asj.getAjlbdm())) {// 案件类别
q += "," + matchstr1 + "\"v_solr6_tb_st_asj_AS_AJLBDM\" : \"" + asj.getAjlbdm() + "\"" + matchstr2;
}
if (StringUtils.isNotEmpty(asj.getXszalxdm())) {// 小案类别
q += "," + matchstr1 + "\"v_solr6_tb_st_asj_AS_ZATZ_JYQK\" : \"" + asj.getXszalxdm() + "\"" + matchstr2;
}
if (StringUtils.isNotEmpty(asj.getXslalxdm())) {// 案件细类别
q += "," + matchstr1 + "\"tb_st_asj_asjbz_AJXLB\" : \"" + asj.getXslalxdm() + "\"" + matchstr2;
}
if (StringUtils.isNotEmpty(asj.getLadw_gajgjgdm())&&!"B".equals(asj.getLadw_gajgjgdm())
&&StringUtils.isEmpty(asj.getLadw_gajgjgdms())&& StringUtils.isEmpty(asj.getBzrDwdm())) {// 默认登陆者立案单位代码 当不选择立案单位查询条件时 公安部用户查所有
String unitcode = asj.getLadw_gajgjgdm();
if(unitCode.endsWith("0000000000")){
unitCode=unitcode.substring(0,2) + "*";
}else if(unitCode.endsWith("00000000")){
unitCode=unitcode.substring(0,4)+ "*";
}else if(unitCode.endsWith("000000")){
unitCode=unitcode.substring(0,6)+ "*";
}else if(unitCode.endsWith("0000")){
unitCode=unitcode.substring(0,8)+ "*";
}
q += "," + wildcardStr1 + "\"v_solr6_tb_st_asj_AS_LADW_GAJGJGDM\" : \"" + unitCode + "\"" + wildcardStr2;
}
if (StringUtils.isNotEmpty(asj.getLadw_gajgjgdm())
&&StringUtils.isNotEmpty(asj.getLadw_gajgjgdms())) {// 查询条件立案单位代码当选择立案单位查询条件时情况 立案单位根据规则截取模糊查询
String unitcode = asj.getLadw_gajgjgdms();
if(unitcode.endsWith("0000000000")){
unitcode=unitcode.substring(0,2) + "*";
}else if(unitcode.endsWith("00000000")){
unitcode=unitcode.substring(0,4)+ "*";
}else if(unitcode.endsWith("000000")){
unitcode=unitcode.substring(0,6)+ "*";
}else if(unitcode.endsWith("0000")){
unitcode=unitcode.substring(0,8)+ "*";
}
q += "," + wildcardStr1 + "\"v_solr6_tb_st_asj_AS_LADW_GAJGJGDM\" : \"" + unitcode + "\"" + wildcardStr2;
}
if (StringUtils.isNotEmpty(asj.getLasjRqsjKssj()) && StringUtils.isNotEmpty(asj.getLasjRqsjKssj())
&&!asj.getLasjRqsjKssj().equals(asj.getLasjRqsjJssj())) {// 立案时间
if(null != asj.getLasjRqsjJssj() && !"".equals(asj.getLasjRqsjJssj())){
q += "," + rangStr1 + "\"v_solr6_tb_st_asj_AS_LARQ\" : {\"lte\": \"" + simpleTime(asj.getLasjRqsjJssj()) + "\"" + ",\"gte\": \"" + simpleTime(asj.getLasjRqsjKssj()) + "\"" + rangStr2;
}else{
q += "," + rangStr1 + "\"v_solr6_tb_st_asj_AS_LARQ\" : {\"gte\": \"" + simpleTime(asj.getLasjRqsjKssj()) + "\"" + rangStr2;
}
} else if (StringUtils.isNotEmpty(asj.getLasjRqsjJssj()) && StringUtils.isEmpty(asj.getLasjRqsjKssj())) {
q += "," + rangStr1 + "\"v_solr6_tb_st_asj_AS_LARQ\" : {\"lte\": \"" + simpleTime(asj.getLasjRqsjJssj()) + "\"" + rangStr2;
} else if (StringUtils.isNotEmpty(asj.getLasjRqsjKssj()) && StringUtils.isNotEmpty(asj.getLasjRqsjJssj())
&&asj.getLasjRqsjKssj().equals(asj.getLasjRqsjJssj())) {
q += "," + wildcardStr1 + "\"v_solr6_tb_st_asj_AS_LARQ\" : \"" + simpleTime(asj.getLasjRqsjKssj()) + "*\"" + wildcardStr2;
}
if (StringUtils.isNotEmpty(asj.getAsjfssjKssj()) && StringUtils.isNotEmpty(asj.getAsjfssjKssj())
&&!asj.getAsjfssjKssj().equals(asj.getAsjfssjJssj())) {// 案发时间
if(null != asj.getAsjfssjJssj() && !"".equals(asj.getAsjfssjJssj())){
q += "," + rangStr1 + "\"v_solr6_tb_st_asj_AS_ASJFSSJ_ASJFSKSSJ\" : {\"lte\": \"" + simpleTime(asj.getAsjfssjJssj()) + "\"" + ",\"gte\": \"" + simpleTime(asj.getAsjfssjKssj()) + "\"" + rangStr2;
}else{
q += "," + rangStr1 + "\"v_solr6_tb_st_asj_AS_ASJFSSJ_ASJFSKSSJ\" : {\"gte\": \"" + simpleTime(asj.getAsjfssjKssj()) + "\"" + rangStr2;
}
} else if (StringUtils.isNotEmpty(asj.getAsjfssjJssj()) && StringUtils.isEmpty(asj.getAsjfssjKssj())) {
q += "," + rangStr1 + "\"v_solr6_tb_st_asj_AS_ASJFSSJ_ASJFSKSSJ\" : {\"lte\": \"" + simpleTime(asj.getAsjfssjJssj()) + "\"" + rangStr2;
} else if (StringUtils.isNotEmpty(asj.getAsjfssjKssj()) && StringUtils.isNotEmpty(asj.getAsjfssjJssj())
&&asj.getAsjfssjKssj().equals(asj.getAsjfssjJssj())) {
q += "," + wildcardStr1 + "\"v_solr6_tb_st_asj_AS_ASJFSSJ_ASJFSKSSJ\" : \"" +simpleTime(asj.getAsjfssjJssj()) + "*\"" + wildcardStr2;
}
if (StringUtils.isNotEmpty(asj.getBzzt())) {// 标注状态
// 已标注
if("1".equals(asj.getBzzt())){
q += "," + matchstr1 + "\"tb_st_asj_asjbz_BZZT\" : \"" + asj.getBzzt() + "\"" + matchstr2;
}else{// 未标注
q1 += matchstr1 + "\"tb_st_asj_asjbz_BZZT\" : \"1\"" + matchstr2;
}
}
if (StringUtils.isNotEmpty(asj.getSsjzMin()) && StringUtils.isNotEmpty(asj.getSsjzMin())) {// 损失总值
if(null != asj.getSsjzMax() && !"".equals(asj.getSsjzMax())){
q += "," + rangStr1 + "\"v_solr6_tb_st_asj_AN_SSJZRMBY\" : {\"lte\": \"" + asj.getSsjzMax() + "\"" + ",\"gte\": \"" + asj.getSsjzMin() + "\"" + rangStr2;
}else{
q += "," + rangStr1 + "\"v_solr6_tb_st_asj_AN_SSJZRMBY\" : {\"gte\": \"" + asj.getSsjzMax() + "\"" + rangStr2;
}
} else if (StringUtils.isNotEmpty(asj.getSsjzMax()) && StringUtils.isEmpty(asj.getSsjzMin())) {
q += "," + rangStr1 + "\"v_solr6_tb_st_asj_AN_SSJZRMBY\" : {\"lte\": \"" + asj.getSsjzMax() + "\"" + rangStr2;
}
if (StringUtils.isNotEmpty(asj.getAsjfsdd_xzqhdm())) {// 案发地行政区划模糊查询
String asjfsddXzqh = asj.getAsjfsdd_xzqhdm();
if(asjfsddXzqh.endsWith("0000")){
asjfsddXzqh=asjfsddXzqh.substring(0,2) + "*";
}else if(asjfsddXzqh.endsWith("00")){
asjfsddXzqh=asjfsddXzqh.substring(0,4)+ "*";
}else{
asjfsddXzqh = asjfsddXzqh;
}
q += "," + wildcardStr1 + "\"v_solr6_tb_st_asj_AS_ASJFSDD_XZQHDM\" : \"" + asjfsddXzqh + "\"" + wildcardStr2;
}
if (StringUtils.isNotEmpty(asj.getAsjfsddDzmc())) {// 案发地详细地址模糊查询
String asjfsddMc = "*" + asj.getAsjfsddDzmc() + "*";
q += "," + wildcardStr1 + "\"v_solr6_tb_st_asj_AT_ASJFSDD_DZMC\" : \"" + asjfsddMc + "\"" + wildcardStr2;
}
if (StringUtils.isNotEmpty(asj.getJyaq())) {// 简要案情
String jyaq = "*" + asj.getJyaq() + "*";
q += "," + wildcardStr1 + "\"v_solr6_tb_st_asj_AT_JYAQ\" : \"" + jyaq + "\"" + wildcardStr2;
}
if (StringUtils.isNotEmpty(asj.getBzrXm())) {// 标注人姓名
q += "," + matchstr1 + "\"tb_st_asj_asjbz_XXCZRY_XM\" : \"" + asj.getBzrXm() + "\"" + matchstr2;
}
if (StringUtils.isNotEmpty(asj.getBzrDwdm())) {// 标注人单位模糊查询
String unitcode = asj.getBzrDwdm();
if(unitCode.endsWith("0000000000")){
unitCode=unitcode.substring(0,2) + "*";
}else if(unitCode.endsWith("00000000")){
unitCode=unitcode.substring(0,4)+ "*";
}else if(unitCode.endsWith("000000")){
unitCode=unitcode.substring(0,6)+ "*";
}else if(unitCode.endsWith("0000")){
unitCode=unitcode.substring(0,4)+ "*";
}
q += "," + wildcardStr1 + "\"tb_st_asj_asjbz_XXCZDW_GAJGJGDM\" : \"" + unitCode + "\"" + wildcardStr2;
}
if (StringUtils.isNotEmpty(asj.getBzrSfzh())) {// 标注人身份证号码
q += "," + wildcardStr1 + "\"tb_st_asj_asjbz_XXCZRY_GMSFHM\" : \"" + asj.getBzrSfzh() + "\"" + wildcardStr2;
}
if (StringUtils.isNotEmpty(asj.getCyclzt())) {// 查询退回
q += existStr1 + "\"field\":\"tb_st_asj_asjbz_HTMS\"" + existStr2;
}
q1 = "," + must_not1 + q1 + must_not2;
q2 = shouldStr1 + q2 + shouldStr2;
q = qbStr1 + must1 + q + must2 + q2 + q1 + qbStr2;
System.out.println("调用部查询接口es条件为:"+q);
return q;
}
public static String simpleTime(String time) {
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");
String date = "";
date = sf.format(java.sql.Date.valueOf(time));
return date;
}
private Map<String, String> getFwidAndXtmc(HttpServletRequest request) {
String appId = request.getHeader(AuthorizationInterceptor.appId);
String appSecret = request.getHeader(AuthorizationInterceptor.appSecret);
return authorizationMapper.getFwidAndXtmc(appId, appSecret);
}
}
......@@ -8,6 +8,7 @@ public class SysGnsyrzOpenApi {
private String yymcJyqk;
private String yhGmsfhm;
private String yhIp;
private String fwid;
private String yhdwGajgjgdm;
private String yhdwGajgmc;
private String czlxdm;
......@@ -26,6 +27,15 @@ public class SysGnsyrzOpenApi {
private Date gxsj;
private String xxlyms;
public SysGnsyrzOpenApi(){}
public String getFwid() {
return fwid;
}
public void setFwid(String fwid) {
this.fwid = fwid;
}
public String getRzlsh() {
return rzlsh;
}
......
......@@ -7,5 +7,7 @@ import com.founder.model.Rycj;
public interface SysGnsyrzOpenApiService {
String insertGNSYRZOPENAPI(String var1, String var2, String var3, String var4, String var5, String var6, String var7, String var8, String var9, String var10);
String insertGNSYRZOPENAPI(String var1, String var2, String var3, String var4, String var5, String var6,
String var7, String var8, String var9, String var10, String var11);
}
......@@ -75,7 +75,7 @@ public class SysGnsyrzOpenApiServiceImpl implements SysGnsyrzOpenApiService {
gnsyrz.setFwsj(now);
gnsyrz.setXxdjdwGajgjgdm(unitCode);
gnsyrz.setXxdjdwGajgmc(unitName);
gnsyrz.setXxscPdbz("0");
gnsyrz.setXxscPdbz(sjly);
gnsyrz.setXxdjryXm(userName);
gnsyrz.setXxdjryGmsfhm(userId);
gnsyrz.setXxdjryLxdh(lxdh);
......@@ -90,4 +90,55 @@ public class SysGnsyrzOpenApiServiceImpl implements SysGnsyrzOpenApiService {
sysGnsyrzOpenApiDao.saveSysgnsyrz(gnsyrz);
return rzlsh;
}
public String insertGNSYRZOPENAPI(String type, String yymc, String cxcs, String userId, String userName, String unitCode, String unitName, String lxdh, String ip, String sjly, String fwid) {
String rzlsh = null;
rzlsh = this.getRzlsh(unitCode);
String cznr = "";
if (cxcs != null && !"".equals(cxcs)) {
cxcs = cxcs.replace(" ", ",");
}
if ("01".equals(type)) {
cznr = "执行[查询]动作,参数为:" + cxcs;
} else if ("02".equals(type)) {
cznr = "执行[新建]动作";
} else if ("03".equals(type)) {
cznr = "执行[修改]动作,参数为:" + cxcs;
} else if ("04".equals(type)) {
cznr = "执行[删除]动作,参数为:" + cxcs;
} else if ("05".equals(type)) {
cznr = "执行[点击访问]动作,参数为:" + cxcs;
} else {
cznr = "执行[未知]操作,参数为:" + cxcs + ",类型为:" + type;
}
Date now = new Date();
SysGnsyrzOpenApi gnsyrz = new SysGnsyrzOpenApi();
gnsyrz.setYhGmsfhm(userId);
gnsyrz.setYhIp(ip);
gnsyrz.setYhdwGajgjgdm(unitCode);
gnsyrz.setYhdwGajgmc(unitName);
gnsyrz.setRzlsh(rzlsh);
gnsyrz.setDjsj(now);
gnsyrz.setGxsj(now);
gnsyrz.setFwsj(now);
gnsyrz.setXxdjdwGajgjgdm(unitCode);
gnsyrz.setXxdjdwGajgmc(unitName);
gnsyrz.setXxscPdbz(sjly);
gnsyrz.setXxdjryXm(userName);
gnsyrz.setXxdjryGmsfhm(userId);
gnsyrz.setXxdjryLxdh(lxdh);
gnsyrz.setXxczdwGajgjgdm(unitCode);
gnsyrz.setXxczdwGajgmc(unitName);
gnsyrz.setXxczryGmsfhm(userId);
gnsyrz.setXxczryXm(userName);
gnsyrz.setCzlxdm(type);
gnsyrz.setCzxxJyqk(cznr);
gnsyrz.setYymcJyqk(yymc);
gnsyrz.setXxlyms("服务调用日志");
gnsyrz.setFwid(fwid);
sysGnsyrzOpenApiDao.saveSysgnsyrz(gnsyrz);
return rzlsh;
}
}
......@@ -19,4 +19,13 @@
ORDER BY djsj DESC
LIMIT 1
</select>
<select id="getFwidAndXtmc" resultType="java.util.Map">
SELECT fwid AS FWID,
fwmc AS FWMC,
(SELECT xtmc FROM tb_st_ggfw_zcxt WHERE xxsc_pdbz = '0' AND id = xtid) AS XTMC
FROM tb_st_ggfw_zcfw
WHERE app_id = #{appId,jdbcType=VARCHAR}
AND app_secret = #{appSecret,jdbcType=VARCHAR}
AND xxsc_pdbz = '0'
</select>
</mapper>
\ No newline at end of file
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