public ResultaddPlatformProject(String areaId) {
List<PlatformProject> arrayList =new ArrayList<>();
int received=0;
Integer page=0;
Integer size=100;
Integer total=0;
try {
do {
JSONObject requestJson =new JSONObject();
requestJson.put("pageNo", page);
requestJson.put("pageSize", size);
requestJson.put("StartTime", "2000-01-01 00:00:00");
String requestStr = requestJson.toJSONString();
JSONObject resultJson = requestDeviceData(true, "url", requestStr);
JSONObject data = resultJson.getJSONObject("data");
JSONArray jsonArray = data.getJSONArray("list");
total = data.getInteger("totalSize");
received+=jsonArray.size();
if (jsonArray.size()==0){
break;
}
JSONArray jsonArray1 = data.getJSONArray("list");
for (int j =0; j < jsonArray1.size(); j++) {
JSONObject itemJson = jsonArray.getJSONObject(j);
PlatformProject platformDate =new PlatformProject();
platformDate.setProjectId(itemJson.getString("id"));
platformDate.setName(itemJson.getString("name"));
platformDate.setAreaId(itemJson.getString("areaId"));
platformDate.setCode(itemJson.getString("code"));
platformDate.setLocationStr(itemJson.getString("locationStr"));
arrayList.add(platformDate);
}
page++;
}while (received<=total);
//去重
List<PlatformProject> unique = arrayList.stream().collect(collectingAndThen(toCollection(() ->new TreeSet<>(Comparator.comparing(PlatformProject::getCode))), ArrayList::new));
platformProjectMapper.delPlatformProjectByAll();
insertBatch(unique);
return Response.response(unique);
} catch (Exception e) {
log.error("工程设备大屏-获取集成平台区域数据失败", e);
return Response.response(arrayList);
}
}
网友评论