package com.ssj.taskasync;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import com.ssj.bean.weixin.push.domain.TbWxTemplate;
import com.ssj.framework.core.util.SystemResourceLocator;
import com.ssj.service.weixin.push.service.WxTemplateService;

@Component	
public class SyncTemplateSaveTask {

	protected Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Async("taskExecutor")
	public void run(TbWxTemplate tbWxTemplate) {
		synchronized(this){
		    try {
		    	if(tbWxTemplate!=null){
		    		WxTemplateService wxTemplateService = (WxTemplateService)SystemResourceLocator.getBean(WxTemplateService.class);
		    		wxTemplateService.save(tbWxTemplate);
		    	}
	        } catch (Exception e) {
	        	logger.error(" 微信模板运行数据保存，异常---------------");
	        }
		}
		
	}

	
	
}
