|  | @ -1,14 +1,20 @@
 | 
	
		
			
				|  |  | package com.yihu.hos.listeners;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.yihu.hos.common.constants.ContextAttributes;
 | 
	
		
			
				|  |  | import com.yihu.hos.core.log.Logger;
 | 
	
		
			
				|  |  | import com.yihu.hos.core.log.LoggerFactory;
 | 
	
		
			
				|  |  | import com.yihu.hos.interceptor.LocalContext;
 | 
	
		
			
				|  |  | import com.yihu.hos.services.ServiceFlowEventService;
 | 
	
		
			
				|  |  | import com.yihu.hos.system.model.bo.ServiceFlow;
 | 
	
		
			
				|  |  | import com.yihu.hos.system.service.FlowManager;
 | 
	
		
			
				|  |  | import com.yihu.hos.tenant.model.TenantModel;
 | 
	
		
			
				|  |  | import com.yihu.hos.tenant.service.TenatService;
 | 
	
		
			
				|  |  | import com.yihu.hos.web.framework.constrant.DateConvert;
 | 
	
		
			
				|  |  | import org.apache.commons.beanutils.ConvertUtils;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Value;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.annotation.Resource;
 | 
	
		
			
				|  |  | import javax.servlet.ServletContextEvent;
 | 
	
		
			
				|  |  | import javax.servlet.ServletContextListener;
 | 
	
		
			
				|  |  | import java.util.Date;
 | 
	
	
		
			
				|  | @ -21,6 +27,12 @@ import java.util.List;
 | 
	
		
			
				|  |  | public class ApplicationStart implements ServletContextListener {
 | 
	
		
			
				|  |  |     static private final Logger logger = LoggerFactory.getLogger(ApplicationStart.class);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Value("${spring.administrators}")
 | 
	
		
			
				|  |  |     private String saasAdmin;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Resource(name = TenatService.BEAN_ID)
 | 
	
		
			
				|  |  |     private TenatService tenatService;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private ServiceFlowEventService serviceFlowEventService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
	
		
			
				|  | @ -29,6 +41,17 @@ public class ApplicationStart implements ServletContextListener {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Override
 | 
	
		
			
				|  |  |     public void contextInitialized(ServletContextEvent context) {
 | 
	
		
			
				|  |  |         //切换到主库
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             TenantModel tenantModel = tenatService.findTenantByName(saasAdmin);
 | 
	
		
			
				|  |  |             if (tenantModel!=null){
 | 
	
		
			
				|  |  |                 LocalContext.getContext().setAttachment(ContextAttributes.SCHEMA, tenantModel.getSchema());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //使用自定义转化器转化时间格式
 | 
	
		
			
				|  |  |         ConvertUtils.register(new DateConvert(), Date.class);
 | 
	
		
			
				|  |  |         this.flowRefresh();
 |