103 lines
3.6 KiB
Java
103 lines
3.6 KiB
Java
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 J9051Dao {
|
||
public static void main(String[] args) {
|
||
getAllJiashiyuans();
|
||
}
|
||
/**
|
||
*
|
||
* @param
|
||
* @return
|
||
*/
|
||
public static JSONArray getAllJiashiyuans() {
|
||
//需要修改 appid entryid apikey
|
||
APIUtils api = new APIUtils("628eeaace7f28c00089a60cc", "5c9d82c72ceed93a0d9ebca4","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", "vcn");//查新字段的名称/别名
|
||
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[]{"jsy_id","xm","xb","shfzhh","whchd","xzhzh","lxdh","shjh","jshzhh","zhjchx","lingzhengriqi","status","jdkh","jjlxr",
|
||
"jg","zp","createTime","tuizuriqi","sfzzm","sfzbm","yhkh","xhhy","gahy","lhh","gsmc","gsdh","jszzy","jszfy"},
|
||
//姓名
|
||
//性别
|
||
//身份号码
|
||
//文化程度
|
||
//居民身份证住址
|
||
//联系电话
|
||
//手机号码
|
||
//驾驶证档案编号
|
||
//准驾车型
|
||
//初次领证日期
|
||
//驾驶员状态
|
||
//监督卡号
|
||
//紧急联系人手机号
|
||
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[]{"jsy_id","xm","xb","shfzhh","whchd","xzhzh","lxdh","shjh","jshzhh","zhjchx","lingzhengriqi","status","jdkh","jjlxr",
|
||
"jg","zp","createTime","tuizuriqi","sfzzm","sfzbm","yhkh","xhhy","gahy","lhh","gsmc","gsdh","jszzy","jszfy"},
|
||
filter, id);
|
||
if (datas == null) {
|
||
return null;
|
||
}
|
||
if (datas.size() == 0) {
|
||
return null;
|
||
}
|
||
return datas;
|
||
}
|
||
|
||
|
||
|
||
}
|