瀏覽代碼

Merge branch 'master' of http://192.168.1.220:10080/esb/esb

zhenglingfeng 8 年之前
父節點
當前提交
0838738c49

+ 23 - 0
src/main/java/com/yihu/hos/listeners/ApplicationStart.java

@ -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();

+ 1 - 2
src/main/java/com/yihu/hos/system/dao/FlowDao.java

@ -31,8 +31,7 @@ public class FlowDao extends SQLGeneralDAO {
    }
    public List<SystemServiceFlow> getFlowList(String type) throws Exception {
        String sql = "select * from system_service_flow where valid = 1 and file_type= '" + type + "' order by create_date";
        List<SystemServiceFlow> list = super.queryListBySql(sql, SystemServiceFlow.class);
        List<SystemServiceFlow> list = (List<SystemServiceFlow>) super.hibernateTemplate.find("from SystemServiceFlow s where s.valid=1 and fileType=? ",  type);
        return list;
    }