package com.example.sso.dao; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.example.sso.util.APIUtils; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class J9052Dao { public static void main(String[] args) { JSONArray jsonArray= J9052Dao.getAllvGpsHetongs(); for (Object o:jsonArray){ JSONObject jsonObject=(JSONObject)o; String hphm=jsonObject.getString("hphm"); if (hphm.contains("BD98508")){ System.out.println(""); } } } /** * * @param * @return */ public static JSONArray getAllvGpsHetongs() { //需要修改 appid entryid apikey APIUtils api = new APIUtils("628eeaace7f28c00089a60cc", "62b80148c6c1af0007f8a824","BkIyzlh1onqnqu9cQ3ralDQBjECn97ex"); final List> condList = new ArrayList>(); //因为想查询大于50的数据,所以创建一个数组 JSONArray jsonArray = new JSONArray(); //在这个数组里面放一个数值类型的数字,用来判断查询范围 jsonArray.add(""); condList.add(new HashMap() { { put("field", "shfzhh");//查新字段的名称/别名 put("method", "nq");//判断的方法 put("value", jsonArray);//查询的条件 } }); Map filter = new HashMap() { { put("rel", "and"); put("cond", condList); } }; //字段别名 List> datas = api.getFormData(10000, new String[]{"shfzhh","hphm","xgrq","zhzhrq"},//身份证号,车牌号码,承包合同开始日期,承包合同终止日期 //身份号码 //车牌号码 //承包合同开始日期 filter, null); if (datas == null) { return null; } if (datas.size() == 0) { return null; } int i = 1; if (datas != null && datas.size() != 0) { while (i != 0) { if (datas.size() > (i * 10000 - 1)) { String id = (String) (datas.get(i * 10000 - 1).get("_id")); List> data = findData(api, filter, id); if (data == null) { i = 0; } else { datas.addAll(data); i = i + 1; } } else { i = 0; } } } JSONObject jsonObject = new JSONObject(); jsonObject.put("list", datas); return jsonObject.getJSONArray("list"); } private static List> findData(APIUtils api, Map filter, String id) { List> datas = api.getFormData(10000, new String[]{"shfzhh","hphm","xgrq","zhzhrq"}, filter, id); if (datas == null) { return null; } if (datas.size() == 0) { return null; } return datas; } }