| | |
| | | package com.yeshi.fanli.job.order.jd; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.dao.jd.JDOrderBackUpDao; |
| | | import com.yeshi.fanli.dto.jd.JDOrderForBackUpResult; |
| | | import com.yeshi.fanli.entity.jd.JDBackUpOrder; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.annotation.JobMonitor; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.xxl.job.core.biz.model.ReturnT; |
| | |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private JDOrderBackUpDao jdOrderBackUpDao; |
| | | |
| | | |
| | | /** |
| | | * 保存订单 |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | @JobMonitor(key = "", maxSpaceTime = 60 * 60 * 25) |
| | | @XxlJob("order-jd-backup") |
| | | public ReturnT<String> backUpOrder(String param) throws Exception { |
| | | //更新90天以前的近3天的数据 |
| | | long startTime = System.currentTimeMillis() - 1000 * 60 * 60 * 24L * 90; |
| | | |
| | | for (int i = 0; i < 24 * 3; i++) { |
| | | List<JDBackUpOrder> orderList = getBackUpOrders(new Date(startTime + i * 1000 * 60 * 60L)); |
| | | if (orderList != null && orderList.size() > 0) { |
| | | for (JDBackUpOrder order : orderList) { |
| | | order.setUpdateTime(new Date()); |
| | | jdOrderBackUpDao.save(order); |
| | | } |
| | | } |
| | | } |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | |
| | | private List<JDBackUpOrder> getBackUpOrders(Date hourDate) { |
| | | List<JDBackUpOrder> jdOrderList = new ArrayList<>(); |
| | | int pageSize = 200; |
| | | int page = 1; |
| | | JDOrderForBackUpResult result = JDApiUtil.getOrderListForBackUp(page++, pageSize, hourDate, JDApiUtil.ORDER_TYPE_UPDATETIME); |
| | | if (result != null) { |
| | | jdOrderList.addAll(result.getOrderList()); |
| | | while (result != null && result.isHasMore()) { |
| | | result = JDApiUtil.getOrderListForBackUp(page++, pageSize, hourDate, JDApiUtil.ORDER_TYPE_UPDATETIME); |
| | | if (result != null) |
| | | jdOrderList.addAll(result.getOrderList()); |
| | | } |
| | | } |
| | | return jdOrderList; |
| | | } |
| | | |
| | | |
| | | } |