From b1f85cd3ab917767c503315c05e4cfa307ff817b Mon Sep 17 00:00:00 2001 From: Lenovo Date: Thu, 1 Aug 2024 08:16:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=8B=89=E5=8F=96=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E5=A2=9E=E5=8A=A0redis=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/MeituanServiceImpl.java | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/business/service/impl/MeituanServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/business/service/impl/MeituanServiceImpl.java index 32353db..79cb2b9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/business/service/impl/MeituanServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/business/service/impl/MeituanServiceImpl.java @@ -383,6 +383,13 @@ public class MeituanServiceImpl implements IMeituanService { @Transactional(rollbackFor = Exception.class) public R orderInfo(String wmPoiId, String date, String cookie) { try { + LocalDate localDate = LocalDate.parse(date); + LocalDate prevDay = localDate.minusDays(1); + String oldKey = wmPoiId + prevDay.toString(); + if (redisTemplate.opsForValue().get(oldKey) != null){ + redisTemplate.delete(oldKey); + } + int pageNum = 1; String getUrl = proxyProperties.gettpsUrl(); JSONObject jsonObject = merchantOrders(getUrl,pageNum, date, cookie); @@ -442,9 +449,9 @@ public class MeituanServiceImpl implements IMeituanService { if (redisDaySeq == null) { redisTemplate.opsForValue().set(key, daySeq); } else { -// if (Integer.valueOf(daySeq) > Integer.valueOf(redisDaySeq)) { -// redisTemplate.opsForValue().set(key, daySeq); -// } + if (Integer.valueOf(daySeq) > Integer.valueOf(redisDaySeq)) { + redisTemplate.opsForValue().set(key, daySeq); + } if (daySeq.equals(lastDayseq)) { flag = true; break; @@ -517,7 +524,7 @@ public class MeituanServiceImpl implements IMeituanService { }catch (Exception e){ System.out.println("================拉取订单出错:==============="+e.getMessage()); // return orderInfo(wmPoiId, date, cookie); - return R.fail("=====================拉取订单出错=================="); + return R.fail("拉取订单出错"); } } @@ -600,6 +607,9 @@ public class MeituanServiceImpl implements IMeituanService { orderInfo.setPrivcyPhone(privacyPhone); orderInfo.setRecipientPhone(recipientPhone); orderInfo.setRecipientBindedPhone(recipientBindedPhone); + + System.out.println("****************订单解析成功:****************"+JSON.toJSONString(orderInfo)); + lsList.add(orderInfo); BusReturnVisitInfo returnVisitInfo = new BusReturnVisitInfo(); @@ -614,16 +624,16 @@ public class MeituanServiceImpl implements IMeituanService { e.printStackTrace(); continue; } + lss.add(returnVisitInfo); } } - System.out.println("********************************"+JSON.toJSONString(lsList)); -// if (lsList.size() > 0) { -// busOrderInfoMapper.batchInsertOrder(lsList); -// } -// if (lss.size() > 0) { -// busReturnVisitInfoMapper.batchInsertVisit(lss); -// } + if (lsList.size() > 0) { + busOrderInfoMapper.batchInsertOrder(lsList); + } + if (lss.size() > 0) { + busReturnVisitInfoMapper.batchInsertVisit(lss); + } } private String getOrderCountByType(String getUrl, String wmOrderViewId,String cookie){