Commit 3e6b8c55 by wutong

同步SKU改为降序查

parent 9fe13f32
...@@ -97,7 +97,14 @@ public class SkuJsonHandle { ...@@ -97,7 +97,14 @@ public class SkuJsonHandle {
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
throw new RuntimeException("同步SKU信息JSON解URL编码失败", e); throw new RuntimeException("同步SKU信息JSON解URL编码失败", e);
} }
totalPage = jsonObject1.getIntValue("TotalPages"); //如果是0, 则保存总页数, 降序查
if (jobPointLog.getPageIndex().equals(0)) {
jobPointLog.setPageIndex(jsonObject1.getIntValue("TotalPages"));
}
/*
* 转化JSON,
* 去处理SKU信息
*/
List<CommonSkuProductInfo> allSkuProductInfoList = jsonObject1.getObject("Items", new TypeReference<List<CommonSkuProductInfo>>() { List<CommonSkuProductInfo> allSkuProductInfoList = jsonObject1.getObject("Items", new TypeReference<List<CommonSkuProductInfo>>() {
}); });
if (allSkuProductInfoList != null && allSkuProductInfoList.size() > 0) { if (allSkuProductInfoList != null && allSkuProductInfoList.size() > 0) {
...@@ -109,8 +116,8 @@ public class SkuJsonHandle { ...@@ -109,8 +116,8 @@ public class SkuJsonHandle {
} else { } else {
throw new RuntimeException("调用同步SKU信息接口失败"); throw new RuntimeException("调用同步SKU信息接口失败");
} }
jobPointLog.setPageIndex(jobPointLog.getPageIndex() + 1); jobPointLog.setPageIndex(jobPointLog.getPageIndex() - 1);
if (jobPointLog.getPageIndex() % 5 == 0) { if (jobPointLog.getPageIndex() % 10 == 0) {
try { try {
JobPointLogMapper jobPointLogMapper = SessionUtil.getSession().getMapper(JobPointLogMapper.class); JobPointLogMapper jobPointLogMapper = SessionUtil.getSession().getMapper(JobPointLogMapper.class);
jobPointLogMapper.upsertSelective(jobPointLog); jobPointLogMapper.upsertSelective(jobPointLog);
...@@ -122,12 +129,10 @@ public class SkuJsonHandle { ...@@ -122,12 +129,10 @@ public class SkuJsonHandle {
SessionUtil.closeSession(); SessionUtil.closeSession();
} }
} }
} while (jobPointLog.getPageIndex() <= totalPage); } while (jobPointLog.getPageIndex() > 0);
if (jobPointLog.getPageIndex() > totalPage) { jobPointLog.setPageIndex(0);
jobPointLog.setPageIndex(1); jobPointLog.setStartTime(jobPointLog.getEndTime());
jobPointLog.setStartTime(jobPointLog.getEndTime()); jobPointLog.setEndTime(jobPointLog.getEndTime().plusDays(jobPointLog.getIntervalTime()).isAfter(LocalDateTime.now()) ? LocalDateTime.now() : jobPointLog.getEndTime().plusDays(jobPointLog.getIntervalTime()));
jobPointLog.setEndTime(jobPointLog.getEndTime().plusDays(jobPointLog.getIntervalTime()).isAfter(LocalDateTime.now()) ? LocalDateTime.now() : jobPointLog.getEndTime().plusDays(jobPointLog.getIntervalTime()));
}
} }
static void handleSkuResultJSON(List<CommonSkuProductInfo> allSkuProductInfoList) { static void handleSkuResultJSON(List<CommonSkuProductInfo> allSkuProductInfoList) {
......
...@@ -20,8 +20,6 @@ public class SkuSyncByUpdateTimeJob extends PointJob { ...@@ -20,8 +20,6 @@ public class SkuSyncByUpdateTimeJob extends PointJob {
skuConditionDto.setIsFinish(-1); skuConditionDto.setIsFinish(-1);
//有ResultWare返回发货仓库信息 //有ResultWare返回发货仓库信息
skuConditionDto.setIsResultWare(1); skuConditionDto.setIsResultWare(1);
//有SKU只查提供的SKU
// skuConditionDto.setSkus("438396007");
//有UpdateDate只查当天更新的数据-增量更新 //有UpdateDate只查当天更新的数据-增量更新
skuConditionDto.setUpdateDate(jobPointLog.getStartTime().format(DateTimeFormatter.ofPattern(CommonConstant.DATE_FORMAT))); skuConditionDto.setUpdateDate(jobPointLog.getStartTime().format(DateTimeFormatter.ofPattern(CommonConstant.DATE_FORMAT)));
SkuJsonHandle.skuMSRequest(skuConditionDto, jobPointLog); SkuJsonHandle.skuMSRequest(skuConditionDto, jobPointLog);
......
...@@ -20,7 +20,6 @@ public class SkuSyncJob extends PointJob { ...@@ -20,7 +20,6 @@ public class SkuSyncJob extends PointJob {
//有SKU只查提供的SKU //有SKU只查提供的SKU
// skuConditionDto.setSkus("909117825"); // skuConditionDto.setSkus("909117825");
//有UpdateDate只查当天更新的数据-增量更新 //有UpdateDate只查当天更新的数据-增量更新
// skuConditionDto.setUpdateDate(jobPointLog.getStartTime().format(DateTimeFormatter.ofPattern(CommonConstant.DATE_FORMAT)));
SkuJsonHandle.skuMSRequest(skuConditionDto, jobPointLog); SkuJsonHandle.skuMSRequest(skuConditionDto, jobPointLog);
} }
......
import com.bailuntec.domain.entity.JobPointLog; import com.bailuntec.domain.entity.JobPointLog;
import com.bailuntec.job.SkuSyncByCreateTimeJob; import com.bailuntec.job.SkuSyncByCreateTimeJob;
import com.bailuntec.job.SkuSyncByUpdateTimeJob;
import com.bailuntec.job.SkuSyncJob; import com.bailuntec.job.SkuSyncJob;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
...@@ -9,7 +10,7 @@ public class SyncSkuTest { ...@@ -9,7 +10,7 @@ public class SyncSkuTest {
@Test @Test
public void test() { public void test() {
SkuSyncJob skuSyncJob = new SkuSyncJob(); SkuSyncJob skuSyncJob = new SkuSyncJob();
skuSyncJob.executeJob(null, new JobPointLog("base-sku",1 ,100,1,1, LocalDateTime.now(),LocalDateTime.now())); skuSyncJob.executeJob(null, new JobPointLog("base-sku",0 ,100,1,1, LocalDateTime.now(),LocalDateTime.now()));
} }
@Test @Test
public void tes1() { public void tes1() {
...@@ -18,4 +19,11 @@ public class SyncSkuTest { ...@@ -18,4 +19,11 @@ public class SyncSkuTest {
LocalDateTime.of(2019,03,01,0,0), LocalDateTime.of(2019,03,01,0,0),
LocalDateTime.now())); LocalDateTime.now()));
} }
@Test
public void tes2() {
SkuSyncByUpdateTimeJob skuSyncJob = new SkuSyncByUpdateTimeJob();
skuSyncJob.executeJob(null, new JobPointLog("base-sku",1 ,100,1,1,
LocalDateTime.of(2019,03,21,0,0),
LocalDateTime.now()));
}
} }
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