You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.5 KiB
Java
50 lines
1.5 KiB
Java
2 years ago
|
package com.glxp.api.task;
|
||
|
|
||
|
import com.glxp.api.constant.AsyncDiDlHelper;
|
||
|
import com.glxp.api.entity.basic.UdiCompanyEntity;
|
||
|
import com.glxp.api.service.basic.UdiCompanyService;
|
||
|
import org.slf4j.Logger;
|
||
|
import org.slf4j.LoggerFactory;
|
||
|
import org.springframework.beans.factory.annotation.Value;
|
||
|
import org.springframework.scheduling.annotation.Async;
|
||
|
import org.springframework.stereotype.Service;
|
||
|
|
||
|
import javax.annotation.Resource;
|
||
|
import java.util.List;
|
||
|
|
||
|
@Service
|
||
|
public class AsyncCompanyDlHelper {
|
||
|
@Resource
|
||
|
UdiCompanyService udiCompanyService;
|
||
|
@Resource
|
||
|
AsyncDiDlHelper asyncDiDlHelper;
|
||
|
@Value("${UDI_SERVER_URL}")
|
||
|
private String udiUrl;
|
||
|
|
||
|
private static final Logger logger = LoggerFactory.getLogger(AsyncCompanyDlHelper.class);
|
||
|
|
||
|
|
||
|
@Async
|
||
|
public void asyncDiByTime(String updateTime) {
|
||
|
int page = 1;
|
||
|
int limit = 300;
|
||
|
while (true) {
|
||
|
logger.info("更新时间:" + updateTime + "----" + page + "----" + limit);
|
||
|
List<UdiCompanyEntity> udiCompanyEntities = asyncDiDlHelper.dlCompanyByTime(udiUrl, page, limit, updateTime);
|
||
|
if (udiCompanyEntities != null && udiCompanyEntities.size() > 0) {
|
||
|
udiCompanyService.insertUdiCompanys(udiCompanyEntities);
|
||
|
if (udiCompanyEntities.size() < limit) {
|
||
|
break;
|
||
|
} else {
|
||
|
page++;
|
||
|
}
|
||
|
} else {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
logger.info("更新时间:" + updateTime + "----" + "下载结束");
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|