Commit fd1e9e88 authored by 廖旭伟's avatar 廖旭伟

综窗事项同步接口

parent 6d6c51e0
......@@ -54,6 +54,7 @@ public class EventImplementationServiceImpl extends AbstractCRUDServiceImpl<Even
req.setPageSize(pageSize);
req.setCurrentPage(currentPage);
try {
log.info("当前页码:"+currentPage);
req.setNonce(RandomUtil.randomNumbers(6));
cacheService.lpush(KEY_COMPLEX_REQ, JSONObject.toJSONString(req));
String rest = cacheService.blpop(KEY_EVENT_IMPLEMENTATION_RESP + req.getNonce(), HTTP_TIMEOUT, String.class);
......@@ -67,10 +68,16 @@ public class EventImplementationServiceImpl extends AbstractCRUDServiceImpl<Even
this.saveOrUpdate(list);
int total = eventListRest.getData().getTotal();
int pages = total/pageSize + 1;
log.info("总页数:"+ pages);
if(pages > 1){
while (currentPage < pages){
try {
Thread.sleep(10000);
} catch (InterruptedException e2) {
}
currentPage++;
req.setCurrentPage(currentPage);
log.info("当前页码:"+currentPage);
req.setNonce(RandomUtil.randomNumbers(6));
cacheService.lpush(KEY_COMPLEX_REQ, JSONObject.toJSONString(req));
String restTemp = cacheService.blpop(KEY_EVENT_IMPLEMENTATION_RESP + req.getNonce(), HTTP_TIMEOUT, String.class);
......@@ -82,9 +89,13 @@ public class EventImplementationServiceImpl extends AbstractCRUDServiceImpl<Even
if(eventListTemp.getCode()==ApiRespCodeEnum.SUCCESS.getValue()){
List<EventImplementationEntity> listTemp = convertEventImplementation(eventListTemp.getData().getRecords());
this.saveOrUpdate(listTemp);
}else {
log.info("查询综窗事项列表失败");
}
}
}
}else {
log.info("查询综窗事项列表失败");
}
} catch (Exception e) {
log.error("同步数据失败", e);
......@@ -134,18 +145,4 @@ public class EventImplementationServiceImpl extends AbstractCRUDServiceImpl<Even
}
return list;
}
public static void main(String[] args) {
int total = 175;
int pageSize = 50;
int currentPage = 1;
System.out.println("当前页数:"+currentPage);
int pages = total/pageSize + 1;
System.out.println("总页数:"+pages);
while (currentPage < pages){
currentPage++;
System.out.println("当前页数:"+currentPage);
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment