From 51c159793a6bf01a75e47ab6e781a0b4d70b1fb1 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 30 一月 2019 18:07:37 +0800 Subject: [PATCH] BUG修改 --- fanli/src/main/java/com/yeshi/fanli/job/UpdateRelationAndSpecialOrderJob.java | 69 +++++++++++++++++++++++++++++++++- 1 files changed, 67 insertions(+), 2 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/job/UpdateRelationAndSpecialOrderJob.java b/fanli/src/main/java/com/yeshi/fanli/job/UpdateRelationAndSpecialOrderJob.java index ffe5d56..55c8e93 100644 --- a/fanli/src/main/java/com/yeshi/fanli/job/UpdateRelationAndSpecialOrderJob.java +++ b/fanli/src/main/java/com/yeshi/fanli/job/UpdateRelationAndSpecialOrderJob.java @@ -35,6 +35,11 @@ @Resource private RedisManager redisManager; + /** + * 鏇存柊娓犻亾璁㈠崟(鏈�澶�20鍒嗛挓) + * + * @param startTime + */ private void updateRelationOrder(long startTime) { String startTimeStr = TimeUtil.getGernalTime(startTime, "yyyy-MM-dd HH:mm:ss"); List<TaoBaoOrder> orderList = TaoKeApiUtil.getTaoBaoRelationOrder(startTimeStr, Constant.TAOBAO_AUTH_APPKEY, @@ -42,11 +47,40 @@ addRelationAndSpecialOrder(orderList); } + /** + * 鎸夊ぉ鏇存柊 + * + * @param day + */ + private void updateRelationOrderByDay(String day) { + long timestamp = TimeUtil.convertToTimeTemp(day, "yyyy-MM-dd"); + for (int i = 0; i < 72; i++) { + updateRelationOrder(timestamp + 1000 * 60 * 20L * i); + } + } + + /** + * 鏇存柊浼氬憳璁㈠崟(鏈�澶�20鍒嗛挓) + * + * @param startTime + */ private void updateSpecialOrder(long startTime) { String startTimeStr = TimeUtil.getGernalTime(startTime, "yyyy-MM-dd HH:mm:ss"); List<TaoBaoOrder> orderList = TaoKeApiUtil.getTaoBaoSpecialOrder(startTimeStr, Constant.TAOBAO_AUTH_APPKEY, Constant.TAOBAO_AUTH_APPSECRET); addRelationAndSpecialOrder(orderList); + } + + /** + * 鎸夊ぉ鏇存柊 + * + * @param day + */ + private void updateSpecialOrderByDay(String day) { + long timestamp = TimeUtil.convertToTimeTemp(day, "yyyy-MM-dd"); + for (int i = 0; i < 72; i++) { + updateSpecialOrder(timestamp + 1000 * 60 * 20L * i); + } } private void addRelationAndSpecialOrder(List<TaoBaoOrder> orderList) { @@ -103,8 +137,39 @@ if (!Constant.IS_TASK) return; long currentTime = System.currentTimeMillis(); - updateRelationOrder(currentTime); - updateSpecialOrder(currentTime); + // 鐖彇21鍒嗛挓涔嬪墠鍒扮幇鍦ㄧ殑 + updateRelationOrder(currentTime - 1000 * 60 * 20L); + updateSpecialOrder(currentTime - 1000 * 60 * 20L); + } + + // 姣�16鍒嗛挓鏇存柊涓�娆′竴澶╃殑锛堟瘡澶╁彲鏇存柊杩�90澶╃殑鏁版嵁锛� + @Scheduled(cron = "0 0/16 * * * ? ") + public void doJob2() { + if (!Constant.IS_TASK) + return; + long currentTime = System.currentTimeMillis(); + long dayStartTime = TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(currentTime, "yyyy-MM-dd"), "yyyy-MM-dd"); + int pos = (int) ((currentTime - dayStartTime) / 1000 * 60 * 16L); + + long time = dayStartTime - (pos + 1) * 1000 * 60 * 60 * 24L; + + // 鍙兘鏇存柊鏈�杩�90澶╃殑 + if (currentTime - time > 1000 * 60 * 60 * 24L * 90) + return; + updateRelationOrderByDay(TimeUtil.getGernalTime(time, "yyyy-MM-dd")); + updateSpecialOrderByDay(TimeUtil.getGernalTime(time, "yyyy-MM-dd")); + } + + // 姣忎釜灏忔椂鏇存柊鏈�杩�1澶╃殑鏁版嵁 + @Scheduled(cron = "0 0 0/1 * * ? ") + public void doJob3() { + if (!Constant.IS_TASK) + return; + long startTime = System.currentTimeMillis() - 1000 * 60 * 60 * 24L; + for (int i = 0; i < 71; i++) { + updateRelationOrder(startTime + 1000 * 60 * 20L * i); + updateSpecialOrder(startTime + 1000 * 60 * 20L * i); + } } } -- Gitblit v1.8.0