| 
					
				 | 
			
			
				@ -1,25 +1,38 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.hos.common; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.fasterxml.jackson.core.type.TypeReference; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.ehr.agModel.app.AppFeatureModel; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.common.constants.ContextAttributes; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.core.http.HTTPResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.core.http.HttpClientKit; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.remoteManage.service.RemoteShellService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.system.model.SystemUser; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.tenant.model.TenantSession; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.tenant.service.AuthenticateService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.web.framework.model.AccessToken; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.web.framework.model.Envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.web.framework.model.EnvelopExt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.hos.web.framework.util.controller.BaseController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.ApiParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.io.IOUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.security.core.Authentication; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.security.core.GrantedAuthority; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.security.core.authority.SimpleGrantedAuthority; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.security.core.context.SecurityContextHolder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Controller; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.ui.Model; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.util.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.PathVariable; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.RequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import javax.servlet.http.HttpServletRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import javax.servlet.http.HttpServletResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import javax.servlet.http.HttpSession; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.io.IOException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.io.PrintWriter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * 数据采集配置页面 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -31,6 +44,12 @@ public class CommonPageController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Value("${spring.administrators}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String saasAdmin; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Value("${spring.clientId}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String clientId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Value("${service-gateway.adminUrl}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String adminUrl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Value("${service-gateway.portalUrl}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String portalUrl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private AuthenticateService authenticateService; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -118,9 +137,61 @@ public class CommonPageController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    首页页面 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				首页页面 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @RequestMapping("indexPage") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String index(HttpServletRequest request, Model model) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HttpSession session = request.getSession(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        SystemUser user = (SystemUser) session.getAttribute("userInfo"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        TenantSession tenantSession = (TenantSession) session.getAttribute(ContextAttributes.TENANT_SESSION); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        model.addAttribute("userName", user.getUserName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        model.addAttribute("tenant", tenantSession.getTenant()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //获取菜单 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String menu = "[{id: 1, text: '任务管理',icon:'${staticRoot}/images/index/menu2_icon.png'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 11, pid: 1, text: '任务跟踪', url: '${contextRoot}/datacollect/trackJob',targetType:'1'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 12, pid: 1, text: '任务补采', url: '${contextRoot}/datacollect/repeatDatacollect'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 13, pid: 1, text: '任务配置', url: '${contextRoot}/datacollect/configJob'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 2, text: '标准管理',icon:'${staticRoot}/images/index/menu3_icon.png'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 21, pid: 2, text: '集成标准', url: '${contextRoot}/integration/initial/standard'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 22, pid: 2, text: '应用标准', url: '${contextRoot}/integration/initial/application'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 23, pid: 2, text: '适配方案', url: '${contextRoot}/adapterPlan/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 3, text: '资源管理',icon:'${staticRoot}/images/index/menu4_icon.png'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 31, pid: 3, text: '资源注册', url: '${contextRoot}/resource/resource/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 32, pid: 3, text: '资源浏览', url: '${contextRoot}/resource/resourcePage'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 34, pid: 3, text: '资源分类', url: '${contextRoot}/resource/rsCategory/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 35, pid: 3, text: '业务资源', url: '${contextRoot}/resourceRest/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 4, text: '维度管理',icon:'${staticRoot}/images/index/menu5_icon.png'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 41, pid: 4, text: '维度配置', url: '${contextRoot}/dimension/dimension'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 42, pid: 4, text: '维度类别配置', url: '${contextRoot}/dimension/dimensioncatetory'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 9, text: '系统配置',icon:'${staticRoot}/images/index/menu6_icon.png'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 91, pid: 9, text: '机构配置', url: '${contextRoot}/org/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 92, pid: 9, text: '数据源配置', url: '${contextRoot}/datasource/configSources'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 93, pid: 9, text: '菜单配置', url: '${contextRoot}/menu/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 100, pid: 9, text: '菜单按钮配置', url: '${contextRoot}/menu/menuAction/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 94, pid: 9, text: '用户管理', url: '${contextRoot}/user/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 95, pid: 9, text: '角色管理', url: '${contextRoot}/role/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 96, pid: 9, text: '权限管理', url: '${contextRoot}/authority/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 97, pid: 9, text: '字典管理', url: '${contextRoot}/dict/initial' },\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 98, pid: 9, text: '系统参数', url: '${contextRoot}/param/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 99, pid: 9, text: '<spring:message code=\"title.app.manage\"/>', url: '${contextRoot}/app/initial'}]"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        model.addAttribute("menu", menu); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        model.addAttribute("contentPage", "/common/index"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return "pageView"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * oauth2 自动登录后首页 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param tenantName 租户名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param request 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param model 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @RequestMapping("{tenantName}/indexPage") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @RequestMapping("{tenantName}/oauth2/index") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String tenantIndex( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @PathVariable(name = "tenantName") String tenantName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            HttpServletRequest request, Model model) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -131,85 +202,23 @@ public class CommonPageController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String token = request.getParameter(ContextAttributes.ACCESSTOKEN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String loginName = request.getParameter(ContextAttributes.LOGIN_NAME); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //通过clientId和 oauth2 code 获取token 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        String token = getToken(clientId, code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (!StringUtils.isEmpty(token)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //验证token 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            boolean succ = validToken(clientId, token); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (succ) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //TODO 根据token和clientId 获取用户信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                SystemUser userInfo = new SystemUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                userInfo.setLoginCode(loginName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                userInfo.setUserName("管理员"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                session.setAttribute("userInfo", userInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    auth = authenticateService.auth(session, tenantName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (!auth) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        model.addAttribute("contentPage", "/common/tokenValidFail"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        return "pageView"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                model.addAttribute("userName", "admin"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                model.addAttribute("tenant", tenantName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //获取菜单 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String menu = "[{id: 1, text: '任务管理',icon:'${staticRoot}/images/index/menu2_icon.png'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 11, pid: 1, text: '任务跟踪', url: '${contextRoot}/datacollect/trackJob',targetType:'1'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 12, pid: 1, text: '任务补采', url: '${contextRoot}/datacollect/repeatDatacollect'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 13, pid: 1, text: '任务配置', url: '${contextRoot}/datacollect/configJob'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 2, text: '标准管理',icon:'${staticRoot}/images/index/menu3_icon.png'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 21, pid: 2, text: '集成标准', url: '${contextRoot}/integration/initial/standard'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 22, pid: 2, text: '应用标准', url: '${contextRoot}/integration/initial/application'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 23, pid: 2, text: '适配方案', url: '${contextRoot}/adapterPlan/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 3, text: '资源管理',icon:'${staticRoot}/images/index/menu4_icon.png'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 31, pid: 3, text: '资源注册', url: '${contextRoot}/resource/resource/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 32, pid: 3, text: '资源浏览', url: '${contextRoot}/resource/resourcePage'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 34, pid: 3, text: '资源分类', url: '${contextRoot}/resource/rsCategory/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 35, pid: 3, text: '业务资源', url: '${contextRoot}/resourceRest/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 4, text: '维度管理',icon:'${staticRoot}/images/index/menu5_icon.png'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 41, pid: 4, text: '维度配置', url: '${contextRoot}/dimension/dimension'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 42, pid: 4, text: '维度类别配置', url: '${contextRoot}/dimension/dimensioncatetory'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 9, text: '系统配置',icon:'${staticRoot}/images/index/menu6_icon.png'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 91, pid: 9, text: '机构配置', url: '${contextRoot}/org/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 92, pid: 9, text: '数据源配置', url: '${contextRoot}/datasource/configSources'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 93, pid: 9, text: '菜单配置', url: '${contextRoot}/menu/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 100, pid: 9, text: '菜单按钮配置', url: '${contextRoot}/menu/menuAction/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 94, pid: 9, text: '用户管理', url: '${contextRoot}/user/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 95, pid: 9, text: '角色管理', url: '${contextRoot}/role/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 96, pid: 9, text: '权限管理', url: '${contextRoot}/authority/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 97, pid: 9, text: '字典管理', url: '${contextRoot}/dict/initial' },\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 98, pid: 9, text: '系统参数', url: '${contextRoot}/param/initial'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "        {id: 99, pid: 9, text: '<spring:message code=\"title.app.manage\"/>', url: '${contextRoot}/app/initial'}]"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                model.addAttribute("menu", menu); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                model.addAttribute("contentPage", "/common/index"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //TODO  返回验证错误页面 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //TODO 根据token和clientId 获取用户信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        SystemUser userInfo = new SystemUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        userInfo.setLoginCode(loginName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        userInfo.setUserName("管理员"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        session.setAttribute("userInfo", userInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            auth = authenticateService.auth(session, tenantName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (!auth) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                model.addAttribute("contentPage", "/common/tokenValidFail"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return "pageView"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //TODO  返回验证错误页面 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            model.addAttribute("contentPage", "/common/tokenValidFail"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return "pageView"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				首页页面 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @RequestMapping("indexPage") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String index(HttpServletRequest request, Model model) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HttpSession session = request.getSession(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        SystemUser user = (SystemUser) session.getAttribute("userInfo"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        TenantSession tenantSession = (TenantSession) session.getAttribute(ContextAttributes.TENANT_SESSION); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        model.addAttribute("userName", user.getUserName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        model.addAttribute("tenant", tenantSession.getTenant()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        model.addAttribute("userName", "admin"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        model.addAttribute("tenant", tenantName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //获取菜单 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String menu = "[{id: 1, text: '任务管理',icon:'${staticRoot}/images/index/menu2_icon.png'},\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        {id: 11, pid: 1, text: '任务跟踪', url: '${contextRoot}/datacollect/trackJob',targetType:'1'},\n" + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -242,9 +251,91 @@ public class CommonPageController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        model.addAttribute("contentPage", "/common/index"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return "pageView"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * oauth2 自动登陆中间页 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param model 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param tenantName 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @RequestMapping(value = "{tenantName}/oauth2/signin") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String signin(Model model, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         @PathVariable(name = "tenantName") String tenantName) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        model.addAttribute("tenantName", tenantName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        model.addAttribute("contentPage", "common/signin"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        model.addAttribute("successFlg", true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return "pageView"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      *  oauth2 自动登录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @RequestMapping(value = "oauth2/autoLogin", method = RequestMethod.POST) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Envelop autoLogin(Model model, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             HttpServletRequest request, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             @ApiParam(name = "token") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             @RequestParam String token) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Envelop result = new Envelop(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String, String> params = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            params.put("clientId", clientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            params.put("accessToken", token); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            HTTPResponse response = HttpClientKit.post(portalUrl + "/oauth/validToken", params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (response.getStatusCode() != 200) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                System.out.println("获取 token 请求失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map map = objectMapper.readValue(response.getBody(), Map.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if ((Boolean) map.get("successFlg")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                AccessToken accessToken = objectMapper.readValue(objectMapper.writeValueAsString(map.get("data")), AccessToken.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String loginName = accessToken.getUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //验证通过。赋值session中的用户信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                HTTPResponse userResponse = HttpClientKit.get(adminUrl + "/users/" + loginName, params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                result = (Envelop) this.objectMapper.readValue(userResponse.getBody(), Envelop.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Collection<GrantedAuthority> gas = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (result.isSuccessFlg()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String ex = this.objectMapper.writeValueAsString(result.getObj()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Map userMap = objectMapper.readValue(ex, Map.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //TODO 设置当前登录用户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String userId = userMap.get("id").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    List<AppFeatureModel> features = getUserFeatures(userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (features != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        for (int i = 0; i < features.size(); i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            String url = features.get(i).getUrl(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if (!StringUtils.isEmpty(url)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                gas.add(new SimpleGrantedAuthority(url)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return failed(result.getErrorMsg()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //生成认证token 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Authentication AuthenticationToken = new UsernamePasswordAuthenticationToken(loginName, "", gas); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //将信息存放到SecurityContext 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                SecurityContextHolder.getContext().setAuthentication(AuthenticationToken); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return success(accessToken); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String msg = String.valueOf(map.get("message")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return failed(msg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return failed(e.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    系统主页 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -255,6 +346,19 @@ public class CommonPageController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return "partView"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private List<AppFeatureModel> getUserFeatures(String userId) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, String> params = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        params.put("user_id", userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HTTPResponse resultStr = HttpClientKit.get(adminUrl + "/roles/user/features", params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        EnvelopExt<AppFeatureModel> envelop = 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                (EnvelopExt<AppFeatureModel>) objectMapper.readValue(resultStr.getBody(), new TypeReference<EnvelopExt<AppFeatureModel>>() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (envelop.isSuccessFlg()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return envelop.getDetailModelList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        throw new Exception(resultStr.getBody()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void setRemoteShellService(RemoteShellService remoteShellService) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        this.remoteShellService = remoteShellService; 
			 |