Authored by linlong

publish event

... ... @@ -90,6 +90,11 @@
<version>1.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yoho.common</groupId>
<artifactId>error-code</artifactId>
<version>1.2.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yoho.service.model</groupId>
<artifactId>users-service-model</artifactId>
</dependency>
... ...
... ... @@ -12,6 +12,7 @@ import com.yoho.core.common.utils.MD5;
import com.yoho.core.redis.YHRedisTemplate;
import com.yoho.core.redis.YHValueOperations;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.error.event.DeviceActiveEvent;
import com.yoho.error.exception.ServiceException;
import com.yoho.service.model.union.UnionTypeModel;
import com.yoho.service.model.union.request.ActivateUnionRequestBO;
... ... @@ -30,6 +31,8 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.net.URLDecoder;
... ... @@ -46,7 +49,7 @@ import java.util.concurrent.TimeUnit;
* 2016年5月10日
*/
@Service
public class UnionServiceImpl implements IUnionService {
public class UnionServiceImpl implements IUnionService,ApplicationEventPublisherAware {
static Logger activeDingdang = LoggerFactory.getLogger("activeDingdang");
... ... @@ -60,6 +63,7 @@ public class UnionServiceImpl implements IUnionService {
static Logger log = LoggerFactory.getLogger(UnionServiceImpl.class);
private ApplicationEventPublisher publisher;
@Resource(name="yhRedisTemplate")
YHRedisTemplate<String, String> yHRedisTemplate;
... ... @@ -462,6 +466,22 @@ public class UnionServiceImpl implements IUnionService {
//打印15天的大数据日志
activeDingdang.info(j.toString());
String source = u == null ? "" : u.getName();
String source_id = click.getUnion_type();
String muid = "" ;
if(StringUtils.isNotEmpty(request.getIdfa())){
muid = request.getIdfa();
}else if(StringUtils.isNotEmpty(request.getImei())){
muid = request.getImei();
}
DeviceActiveEvent activeEvent = new DeviceActiveEvent("deviceActive",source,source_id,muid);
//上报激活事件
try{
publisher.publishEvent(activeEvent);
}catch(Exception e){
log.warn("publish activate event fail! e {}", e);
}
// UnionTypeModel type =
// UnionConstant.unionTypeMap.get(Integer.parseInt(click.getUnion_type()));
... ... @@ -569,4 +589,8 @@ public class UnionServiceImpl implements IUnionService {
});
}
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
}
}
... ...