1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| List<YTickets> ticketsList = new ArrayList<>(); int i = 1; while (true){ String str = "{\n" + " \"list_info\": {\n" + " \"row_count\": 100,\n" + " \"start_index\": "+i+",\n" + " \"sort_field\": \"id\",\n" + " \"sort_order\": \"asc\",\n" + " \"get_total_count\": true,\n" + " },\n" + " \"fields_required\": [\n" + " \"id\",\n" + " \"requester\",\n" + " \"technician\",\n" + " \"created_time\",\n" + " \"subject\",\n" + " \"udf_fields.udf_sline_1502\",\n" + " \"priority\",\n" + " \"status\",\n" + " \"category\"\n" + " ]\n" + " }\n" + " }\n" + "}"; String getDate = ""; try{ getDate = (String)ticketsController.selectItemApisByParamsAndToken("test_app_leal",str,"authtoken").getData(); }catch (Exception e){ e.printStackTrace(); } JSONObject jobj = JSON.parseObject(getDate); JSONArray requests = jobj.getJSONArray("requests"); if (requests.size() == 0) { break; } for (Object r:requests) { YTickets tickets = new YTickets();
String ids = ((JSONObject) r).getJSONObject("requester").getString("id"); int id = Integer.parseInt(ids); tickets.setRequesterId(id); tickets.setRequesterName(((JSONObject) r).getJSONObject("requester").getString("name")); if (((JSONObject) r).getJSONObject("udf_fields").getString("udf_sline_1502")==null){ tickets.setTechnicianName(((JSONObject) r).getJSONObject("technician").getString("name")); }else { tickets.setTechnicianName(((JSONObject) r).getJSONObject("udf_fields").getString("udf_sline_1502")); } tickets.setCategoryName(((JSONObject) r).getJSONObject("category").getString("name")); String times = ((JSONObject) r).getJSONObject("created_time").getString("display_value"); DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm"); LocalDateTime time = LocalDateTime.parse(times, fmt); tickets.setCreatedTime(time); tickets.setStatusName(((JSONObject) r).getJSONObject("status").getString("name")); tickets.setPriorityName(((JSONObject) r).getJSONObject("priority").getString("name")); tickets.setDepartmentName(((JSONObject) r).getJSONObject("technician").getJSONObject("department").getString("name")); ticketsList.add(tickets); } i = i + 100; } yTicketsService.deleteAllInformationScreen(); System.err.println("---准备开始写入---"); yTicketsService.saveBatch(ticketsList); System.err.println("---所有信息已写入完成---");
|