package com.toyor.hpqcloud.provider.util;
    import com.toyor.hpqcloud.model.baseinfo.EasyEpcSearchDetail;
    import com.toyor.hpqcloud.provider.mapper.baseinfo.BaseInfoMapper;
    import org.apache.commons.lang.StringUtils;
    import org.springframework.web.context.WebApplicationContext;
    import org.springframework.web.context.request.RequestContextHolder;
    import org.springframework.web.context.request.ServletRequestAttributes;
    import org.springframework.web.servlet.DispatcherServlet;
    import javax.servlet.http.HttpServletRequest;
    public class EasyEpcLogRunnable implements Runnable {
    private BaseInfoMapper baseInfoMapper;
    private EasyEpcSearchDetail easyEpcSearchDetail;
    public EasyEpcLogRunnable(EasyEpcSearchDetail easyEpcSearchDetail) {
    this.easyEpcSearchDetail = easyEpcSearchDetail;
    //获取子容器sevlet, 不能获取父容器root,父容器中不存在service和dao实体bean
    ServletRequestAttributes sevletRequestAttributes =
    (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    HttpServletRequest request = sevletRequestAttributes.getRequest();
    WebApplicationContext servletContext = (WebApplicationContext)
    request.getAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE);
    //从容器中获取Dao层Bean
    baseInfoMapper = servletContext.getBean(“baseInfoMapper”,BaseInfoMapper.class);
    }
    @Override
    public void run() {
    if(StringUtils.isEmpty(easyEpcSearchDetail.getOpenid())){
    easyEpcSearchDetail.setOpenid(“”);
    }
    baseInfoMapper.insertEasyEpcSearchDetail(easyEpcSearchDetail);
    }
    public BaseInfoMapper getBaseInfoMapper() {
    return baseInfoMapper;
    }
    public void setBaseInfoMapper(BaseInfoMapper baseInfoMapper) {
    this.baseInfoMapper = baseInfoMapper;
    }
    public EasyEpcSearchDetail getEasyEpcSearchDetail() {
    return easyEpcSearchDetail;
    }
    public void setEasyEpcSearchDetail(EasyEpcSearchDetail easyEpcSearchDetail) {
    this.easyEpcSearchDetail = easyEpcSearchDetail;
    }
    }