1
|
package com.yoho.unions.server.task;
|
1
|
package com.yoho.unions.server.task;
|
2
|
|
2
|
|
|
|
3
|
+import com.google.common.base.Function;
|
|
|
4
|
+import com.google.common.collect.Lists;
|
3
|
import com.google.common.collect.Maps;
|
5
|
import com.google.common.collect.Maps;
|
4
|
import com.yoho.core.rest.client.ServiceCaller;
|
6
|
import com.yoho.core.rest.client.ServiceCaller;
|
5
|
import com.yoho.unions.common.redis.RedisValueCache;
|
7
|
import com.yoho.unions.common.redis.RedisValueCache;
|
6
|
import com.yoho.unions.dal.IUserOrdersDAO;
|
8
|
import com.yoho.unions.dal.IUserOrdersDAO;
|
7
|
import com.yoho.unions.server.service.IOrderPushService;
|
9
|
import com.yoho.unions.server.service.IOrderPushService;
|
8
|
import com.yoho.unions.vo.OrderInfo;
|
10
|
import com.yoho.unions.vo.OrderInfo;
|
|
|
11
|
+import org.apache.commons.collections.CollectionUtils;
|
9
|
import org.springframework.beans.factory.annotation.Autowired;
|
12
|
import org.springframework.beans.factory.annotation.Autowired;
|
10
|
import org.springframework.scheduling.annotation.Scheduled;
|
13
|
import org.springframework.scheduling.annotation.Scheduled;
|
11
|
import org.springframework.stereotype.Component;
|
14
|
import org.springframework.stereotype.Component;
|
|
@@ -29,8 +32,40 @@ public class BigDataOrderInfoTask { |
|
@@ -29,8 +32,40 @@ public class BigDataOrderInfoTask { |
29
|
|
32
|
|
30
|
@Scheduled(cron = "0 0/10 * * * ?")
|
33
|
@Scheduled(cron = "0 0/10 * * * ?")
|
31
|
public void run() {
|
34
|
public void run() {
|
32
|
- Map<String, List<OrderInfo>> orderInfoMap = serviceCaller.call("bigdata.get", null, Map.class, 3);
|
|
|
33
|
- for (String clientId : orderInfoMap.keySet()) {
|
35
|
+ Map<String, Object> param = Maps.newHashMap();
|
|
|
36
|
+ param.put("limit", 100);
|
|
|
37
|
+ //调bigdata获去订单集合
|
|
|
38
|
+ List<OrderInfo> orderInfoList = serviceCaller.call("bigdata.get", param, List.class, 3);
|
|
|
39
|
+ if (CollectionUtils.isEmpty(orderInfoList)) {
|
|
|
40
|
+ return;
|
|
|
41
|
+ }
|
|
|
42
|
+ //订单列表转map key:orderCode value:OrderInfo
|
|
|
43
|
+ Map<Integer,OrderInfo> orderMap = Maps.uniqueIndex(orderInfoList, new Function<OrderInfo, Integer>() {
|
|
|
44
|
+ @Override
|
|
|
45
|
+ public Integer apply(OrderInfo input) {
|
|
|
46
|
+ return input.getOrderCode();
|
|
|
47
|
+ }
|
|
|
48
|
+ });
|
|
|
49
|
+ //获取校验后的订单code
|
|
|
50
|
+ List<Integer> orderCodeList = null;
|
|
|
51
|
+ //按source分类
|
|
|
52
|
+ Map<Integer,List<OrderInfo>> orderInfoMap = Maps.newHashMap();
|
|
|
53
|
+ for(Integer orderCode : orderCodeList){
|
|
|
54
|
+ OrderInfo orderInfo = orderMap.get(orderCode);
|
|
|
55
|
+ //为空直接return
|
|
|
56
|
+ if(null == orderInfo){
|
|
|
57
|
+ continue;
|
|
|
58
|
+ }
|
|
|
59
|
+ //组装分类
|
|
|
60
|
+ if(!orderInfoMap.containsKey(orderInfo.getClientId())){
|
|
|
61
|
+ orderInfoMap.put(orderInfo.getClientId(),Lists.newArrayList(orderInfo));
|
|
|
62
|
+ continue;
|
|
|
63
|
+ }
|
|
|
64
|
+ orderInfoMap.get(orderInfo.getClientId()).add(orderInfo);
|
|
|
65
|
+ }
|
|
|
66
|
+
|
|
|
67
|
+ //按source分类推送
|
|
|
68
|
+ for (Integer clientId : orderInfoMap.keySet()) {
|
34
|
IOrderPushService orderPushService = orderPushServiceMap.get(clientId);
|
69
|
IOrderPushService orderPushService = orderPushServiceMap.get(clientId);
|
35
|
orderPushService.pushOrder(orderInfoMap.get(clientId));
|
70
|
orderPushService.pushOrder(orderInfoMap.get(clientId));
|
36
|
}
|
71
|
}
|