package org.springblade.common.utils; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import java.util.function.BiConsumer; import java.util.function.Consumer; /** * @author zhongrj * @date 2021-08-12 */ public class InvestigateUtil { /** * 人员审查 * * @param idCardNo 人员身份证号 * @return */ public static String httpGet(String idCardNo, Integer pageNum, Integer pageSize) { OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder() .url("http://47.49.27.44:8000/dbapi/dmc_bjhc?page_num=" + pageNum + "&page_size=" + pageSize + "&sfzh=" + idCardNo) .get() .addHeader("Authorization", "Bearer eyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiIsInVjIjoiMzYwNjAyMTk4OTA3MDgxMDE4IiwidG9rZW5fdHlwZSI6MX0.eyJpc3MiOiJITGdGVGYwZWwwNTRDYlNWNUptMUY1eXA3UjRWNnpuMyIsImlhdCI6MTYyOTc5NDk4MH0.KOyEdkXDc5FP98KFLYOBnDgthJZF6VDOxJvlYFrXmrA") .build(); try { Response response = client.newCall(request).execute(); return response.body().string(); } catch (Exception e) { } return null; } /** * 人员审查 * * @param idCardNo 人员身份证号 * @return */ public static String httpGetOne(String idCardNo) { OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder() .url("http://47.49.27.44:8000/dbapi/dmc_bjhc?page_num=1&page_size=1000&sfzh=" + idCardNo) .get() .addHeader("Authorization", "Bearer eyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiIsInVjIjoiMzYwNjAyMTk4OTA3MDgxMDE4IiwidG9rZW5fdHlwZSI6MX0.eyJpc3MiOiJITGdGVGYwZWwwNTRDYlNWNUptMUY1eXA3UjRWNnpuMyIsImlhdCI6MTYyOTc5NDk4MH0.KOyEdkXDc5FP98KFLYOBnDgthJZF6VDOxJvlYFrXmrA") .build(); try { Response response = client.newCall(request).execute(); return response.body().string(); } catch (Exception e) { } return null; } /** * 枪支定位 * * @param idCardNo 护卫员身份证号 * @param deptName 所在单位名称 * @param startTime 定位开始时间 * @param endTime 定位结束时间 */ public static String httpGetGunPosition(String idCardNo, String deptName, String startTime, String endTime, Integer pageNum, Integer pageSize) { OkHttpClient client = new OkHttpClient(); String hwysfzh = ""; String szdw = ""; String kssj = ""; String jssj = ""; String page_size = "&page_size=" + pageSize; String page_num = "&page_num=" + pageNum; if (idCardNo != null && !idCardNo.equals("")) { hwysfzh = "&hwysfzh=" + idCardNo; } if (deptName != null && !deptName.equals("")) { szdw = "&szdw=" + deptName; } if (startTime != null && !startTime.equals("")) { kssj = "&kssj=" + startTime; } if (endTime != null && !endTime.equals("")) { jssj = "&jssj=" + endTime; } Request request = new Request.Builder() .url("http://47.49.27.44:8000/dbapi/dmc_qzdw?" + hwysfzh + szdw + kssj + jssj) .get() .addHeader("Authorization", "Bearer eyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiIsInVjIjoiMzYwNjAyMTk4OTA3MDgxMDE4IiwidG9rZW5fdHlwZSI6MX0.eyJpc3MiOiI3aWN5MXplc3N2eVBPVlJKUVk2aHpPRTJhc0JMdkw1MyIsImlhdCI6MTYyOTI1MTMzOX0.DLasFawQHexpRBFORQU64tbSR_n76bpway42GfIwPf4") .build(); try { Response response = client.newCall(request).execute(); return response.body().string(); } catch (Exception e) { } return null; } // 工具方法 public static Consumer consumerWithIndex(BiConsumer consumer) { class Obj { int i; } Obj obj = new Obj(); return t -> { int index = obj.i++; consumer.accept(t, index); }; } }