diff --git a/src/main/java/cn/van/business/util/JDUtils.java b/src/main/java/cn/van/business/util/JDUtils.java index 46220b5..95ce0ca 100644 --- a/src/main/java/cn/van/business/util/JDUtils.java +++ b/src/main/java/cn/van/business/util/JDUtils.java @@ -221,6 +221,12 @@ public class JDUtils { @Scheduled(cron = "0 0 */12 * * ?") public void fetchHistoricalOrders3060() { + fetchHistoricalOrders3060Do(); + } + + private int fetchHistoricalOrders3060Do() { + + int count = 0; LocalDateTime now = LocalDateTime.now(); //logger.info("拉取历史订单---> , {} 点,{} 分", now.getHour(), now.getMinute()); @@ -243,6 +249,7 @@ public class JDUtils { OrderRow orderRow = createOrderRow(orderRowResp); if (orderRow != null) { // Ensure orderRow is not null after creation orderRowRepository.save(orderRow); + count++; } } } @@ -261,6 +268,7 @@ public class JDUtils { } startDate = startDate.plusHours(1); } + return count; } /** @@ -269,6 +277,11 @@ public class JDUtils { @Scheduled(cron = "0 0 */4 * * ?") public void fetchHistoricalOrders1430() { + fetchHistoricalOrders1430Do(); + } + + private int fetchHistoricalOrders1430Do() { + int count = 0; LocalDateTime now = LocalDateTime.now(); //logger.info("拉取历史订单---> , {} 点,{} 分", now.getHour(), now.getMinute()); @@ -291,6 +304,7 @@ public class JDUtils { OrderRow orderRow = createOrderRow(orderRowResp); if (orderRow != null) { // Ensure orderRow is not null after creation orderRowRepository.save(orderRow); + count++; } } } @@ -309,14 +323,19 @@ public class JDUtils { } startDate = startDate.plusMinutes(10); } + return count; } /** * 每10分钟拉取07-14天的订单 */ @Scheduled(cron = "0 */10 * * * ?") - public int fetchHistoricalOrders0714() { + public void fetchHistoricalOrders0714() { + fetchHistoricalOrders0714Do(); + } + + private int fetchHistoricalOrders0714Do() { int count = 0; LocalDateTime now = LocalDateTime.now(); //logger.info("拉取历史订单---> , {} 点,{} 分", now.getHour(), now.getMinute()); @@ -357,13 +376,20 @@ public class JDUtils { if (hasMore) pageIndex++; } startDate = startDate.plusMinutes(10); - } return count; } + @Scheduled(cron = "0 */2 * * * ?") public void fetchHistoricalOrders0007() { + + fetchHistoricalOrders0007Do(); + } + + private int fetchHistoricalOrders0007Do() { + + int count = 0; LocalDateTime now = LocalDateTime.now(); //logger.info("拉取历史订单---> , {} 点,{} 分", now.getHour(), now.getMinute()); LocalDateTime lastHour = now.truncatedTo(ChronoUnit.HOURS); @@ -385,6 +411,7 @@ public class JDUtils { OrderRow orderRow = createOrderRow(orderRowResp); if (orderRow != null) { // Ensure orderRow is not null after creation orderRowRepository.save(orderRow); + count++; } } } @@ -403,6 +430,7 @@ public class JDUtils { } startDate = startDate.plusMinutes(10); } + return count; } /** @@ -442,8 +470,8 @@ public class JDUtils { * 接收京粉指令指令 */ public void sendOrderToWxByOrderJD(String order) throws Exception { - int[] parm = {-1}; - List orderRows = orderRowRepository.findByValidCodeNotInOrderByOrderTimeDesc(parm); + int[] param = {-1}; + List orderRows = orderRowRepository.findByValidCodeNotInOrderByOrderTimeDesc(param); /** * 菜单: * 今日统计 @@ -670,7 +698,7 @@ public class JDUtils { LocalDateTime lastHour = LocalDateTime.now().minusHours(1).withMinute(0).withSecond(0).withNano(0); while (!startDate.isEqual(lastHour)) { startDate = startDate.plusHours(1); - UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(startDate, false, 1,false); + UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(startDate, false, 1, false); if (response != null) { int code = response.getQueryResult().getCode(); @@ -697,24 +725,25 @@ public class JDUtils { } case "刷新3060": { long start = System.currentTimeMillis(); - fetchHistoricalOrders3060(); + int count = fetchHistoricalOrders3060Do(); long time = System.currentTimeMillis() - start; - content.append("刷新3060,耗时: ").append(time).append("ms, ").append((time) / 1000).append(" s\r"); + content.append("订单行:").append(count).append("耗时: ").append(time).append("ms, ").append((time) / 1000).append(" s\r"); break; } case "刷新1430": { long start = System.currentTimeMillis(); - fetchHistoricalOrders1430(); + int count = fetchHistoricalOrders1430Do(); long time = System.currentTimeMillis() - start; - content.append("刷新1430,耗时: ").append(time).append("ms, ").append((time) / 1000).append(" s\r"); + content.append("订单行:").append(count).append("耗时: ").append(time).append("ms, ").append((time) / 1000).append(" s\r"); + break; } case "刷新0714": { long start = System.currentTimeMillis(); - fetchHistoricalOrders0714(); + int count = fetchHistoricalOrders0714Do(); long time = System.currentTimeMillis() - start; - content.append("刷新0014,耗时: ").append(time).append("ms, ").append((time) / 1000).append(" s\r"); + content.append("订单行:").append(count).append("耗时: ").append(time).append("ms, ").append((time) / 1000).append(" s\r"); break; } @@ -879,15 +908,15 @@ public class JDUtils { // // String jsonString = JSON.toJSONString(response); // System.out.println(jsonString); - // - //System.out.println(request.getAppJsonParams()); - //System.out.println(request.getPromotionCodeReq()); - // - //System.out.println("--------"); - //System.out.println(response.getGetResult().getCode()); - //System.out.println(response.getGetResult().getMessage()); - //System.out.println(response.getGetResult().getData().getClickURL()); - //System.out.println(response.getGetResult().getData().getJCommand()); + // + //System.out.println(request.getAppJsonParams()); + //System.out.println(request.getPromotionCodeReq()); + // + //System.out.println("--------"); + //System.out.println(response.getGetResult().getCode()); + //System.out.println(response.getGetResult().getMessage()); + //System.out.println(response.getGetResult().getData().getClickURL()); + //System.out.println(response.getGetResult().getData().getJCommand()); // return response.getGetResult().getData().getClickURL(); //}