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.
udi-cpt-java/src/main/java/com/glxp/api/task/AsyncDiDlService.java

51 lines
1.5 KiB
Java

package com.glxp.api.task;
import com.glxp.api.constant.AsyncDiDlHelper;
import com.glxp.api.entity.basic.ProductInfoEntity;
import com.glxp.api.service.basic.ProductInfoService;
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 AsyncDiDlService {
@Value("${UDI_SERVER_URL}")
private String udiUrl;
@Resource
ProductInfoService productInfoService;
@Resource
AsyncDiDlHelper asyncDiDlHelper;
private static final Logger logger = LoggerFactory.getLogger(AsyncDiDlService.class);
@Async
public void asyncDiByTime(String updateTime) {
int page = 1;
int limit = 200;
while (true) {
logger.info("更新时间:" + updateTime + "----" + page + "----" + limit);
List<ProductInfoEntity> productInfoEntityList = asyncDiDlHelper.dlByTime(udiUrl, page, limit, updateTime);
if (productInfoEntityList != null && productInfoEntityList.size() > 0) {
productInfoService.insertProductInfos(productInfoEntityList);
if (productInfoEntityList.size() < limit) {
break;
} else {
page++;
}
} else {
break;
}
}
logger.info("更新时间:" + updateTime + "----" + "下载结束");
}
}