Files
sso-newjar/src/main/java/com/example/sso/dao/J9052Dao.java
2025-09-26 14:16:20 +08:00

98 lines
3.3 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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<Map<String, Object>> condList = new ArrayList<Map<String, Object>>();
//因为想查询大于50的数据所以创建一个数组
JSONArray jsonArray = new JSONArray();
//在这个数组里面放一个数值类型的数字,用来判断查询范围
jsonArray.add("");
condList.add(new HashMap<String, Object>() {
{
put("field", "shfzhh");//查新字段的名称/别名
put("method", "nq");//判断的方法
put("value", jsonArray);//查询的条件
}
});
Map<String, Object> filter = new HashMap<String, Object>() {
{
put("rel", "and");
put("cond", condList);
}
};
//字段别名
List<Map<String, Object>> 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<Map<String, Object>> 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<Map<String, Object>> findData(APIUtils api, Map<String, Object> filter, String id) {
List<Map<String, Object>> 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;
}
}