|  | @ -2,10 +2,15 @@ package com.yihu.hos.system.controller;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.yihu.hos.common.Services;
 | 
	
		
			
				|  |  | import com.yihu.hos.system.model.SystemDatasource;
 | 
	
		
			
				|  |  | import com.yihu.hos.system.model.SystemOrganization;
 | 
	
		
			
				|  |  | import com.yihu.hos.system.service.DatasourceManager;
 | 
	
		
			
				|  |  | import com.yihu.hos.system.service.OrganizationManager;
 | 
	
		
			
				|  |  | import com.yihu.hos.web.framework.model.DataGridResult;
 | 
	
		
			
				|  |  | import com.yihu.hos.web.framework.model.Result;
 | 
	
		
			
				|  |  | import com.yihu.hos.web.framework.util.controller.BaseController;
 | 
	
		
			
				|  |  | import net.sf.json.JSONObject;
 | 
	
		
			
				|  |  | import org.apache.commons.beanutils.BeanUtils;
 | 
	
		
			
				|  |  | import org.apache.commons.collections4.CollectionUtils;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Controller;
 | 
	
		
			
				|  |  | import org.springframework.ui.Model;
 | 
	
		
			
				|  |  | import org.springframework.web.bind.annotation.RequestMapping;
 | 
	
	
		
			
				|  | @ -25,13 +30,15 @@ public class DatasourceController extends BaseController {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Resource(name = Services.Datasource)
 | 
	
		
			
				|  |  |     DatasourceManager datasource;
 | 
	
		
			
				|  |  |     @Resource(name = Services.Organization)
 | 
	
		
			
				|  |  |     OrganizationManager organization;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /*
 | 
	
		
			
				|  |  |         数据源配置
 | 
	
		
			
				|  |  |          */
 | 
	
		
			
				|  |  |     @RequestMapping("configSources")
 | 
	
		
			
				|  |  |     public String configSources(Model model) {
 | 
	
		
			
				|  |  |         model.addAttribute("contentPage","system/datasource/configSources");
 | 
	
		
			
				|  |  |         model.addAttribute("contentPage", "system/datasource/configSources");
 | 
	
		
			
				|  |  |         return "partView";
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -39,7 +46,7 @@ public class DatasourceController extends BaseController {
 | 
	
		
			
				|  |  |     数据源新增/编辑
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @RequestMapping("editorSource")
 | 
	
		
			
				|  |  |     public String editorSource(Model model,String sourceId) {
 | 
	
		
			
				|  |  |     public String editorSource(Model model, String sourceId) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             if (sourceId != null) {
 | 
	
		
			
				|  |  |                 SystemDatasource obj = datasource.getDatasourcegById(sourceId);
 | 
	
	
		
			
				|  | @ -47,30 +54,38 @@ public class DatasourceController extends BaseController {
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             model.addAttribute("contentPage", "system/datasource/editorSource");
 | 
	
		
			
				|  |  |             return "pageView";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         catch (Exception ex)
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |         } catch (Exception ex) {
 | 
	
		
			
				|  |  |             model.addAttribute("contentPage", "system/datasource/editorSource");
 | 
	
		
			
				|  |  |             return "pageView";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /******************************* 数据源配置 ******************************************************/
 | 
	
		
			
				|  |  |     /*******************************
 | 
	
		
			
				|  |  |      * 数据源配置
 | 
	
		
			
				|  |  |      ******************************************************/
 | 
	
		
			
				|  |  |     /*
 | 
	
		
			
				|  |  |        获取数据源列表
 | 
	
		
			
				|  |  |     */
 | 
	
		
			
				|  |  |     @RequestMapping("getDatasource")
 | 
	
		
			
				|  |  |     @ResponseBody
 | 
	
		
			
				|  |  |     public Result getDatasource(String orgId,String name,String type,int page, int rows){
 | 
	
		
			
				|  |  |     public Result getDatasource(String orgId, String name, String type, int page, int rows) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             Map<String, Object> map = new HashMap<>();
 | 
	
		
			
				|  |  |             map.put("orgId", orgId);
 | 
	
		
			
				|  |  |             map.put("name", name);
 | 
	
		
			
				|  |  |             map.put("type", type);
 | 
	
		
			
				|  |  |             return datasource.getDatasource(map,page, rows);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         catch (Exception ex)
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |             DataGridResult dataGridResult = datasource.getDatasource(map, page, rows);
 | 
	
		
			
				|  |  |             if (CollectionUtils.isNotEmpty(dataGridResult.getDetailModelList())) {
 | 
	
		
			
				|  |  |                 for (Object obj : dataGridResult.getDetailModelList()) {
 | 
	
		
			
				|  |  |                     SystemDatasource datasource = (SystemDatasource) obj;
 | 
	
		
			
				|  |  |                     SystemOrganization _tempOrg = organization.getOrgById(datasource.getOrgId());
 | 
	
		
			
				|  |  |                     if (null != _tempOrg) {
 | 
	
		
			
				|  |  |                         datasource.setOrgName(_tempOrg.getFullName());
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             return dataGridResult;
 | 
	
		
			
				|  |  |         } catch (Exception ex) {
 | 
	
		
			
				|  |  |             return Result.error(ex.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -80,13 +95,10 @@ public class DatasourceController extends BaseController {
 | 
	
		
			
				|  |  |    */
 | 
	
		
			
				|  |  |     @RequestMapping("getDatasourceByOrg")
 | 
	
		
			
				|  |  |     @ResponseBody
 | 
	
		
			
				|  |  |     public Result getDatasourceByOrg(String orgId)
 | 
	
		
			
				|  |  |     {
 | 
	
		
			
				|  |  |     public Result getDatasourceByOrg(String orgId) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             return datasource.getDatasourceByOrg(orgId);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         catch (Exception ex)
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |         } catch (Exception ex) {
 | 
	
		
			
				|  |  |             return Result.error(ex.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -96,16 +108,13 @@ public class DatasourceController extends BaseController {
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @RequestMapping("addDatasource")
 | 
	
		
			
				|  |  |     @ResponseBody
 | 
	
		
			
				|  |  |     public Result addDatasource(HttpServletRequest request)
 | 
	
		
			
				|  |  |     {
 | 
	
		
			
				|  |  |     public Result addDatasource(HttpServletRequest request) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             SystemDatasource obj = new SystemDatasource();
 | 
	
		
			
				|  |  |             BeanUtils.populate(obj, request.getParameterMap());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             return datasource.addDatasource(obj);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         catch (Exception ex)
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |         } catch (Exception ex) {
 | 
	
		
			
				|  |  |             return Result.error(ex.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -115,15 +124,13 @@ public class DatasourceController extends BaseController {
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @RequestMapping("updateDatasource")
 | 
	
		
			
				|  |  |     @ResponseBody
 | 
	
		
			
				|  |  |     public Result updateDatasource(HttpServletRequest request)
 | 
	
		
			
				|  |  |     {
 | 
	
		
			
				|  |  |     public Result updateDatasource(HttpServletRequest request) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             SystemDatasource obj = new SystemDatasource();
 | 
	
		
			
				|  |  |             BeanUtils.populate(obj, request.getParameterMap());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             return datasource.updateDatasource(obj);
 | 
	
		
			
				|  |  |         } catch (Exception ex)
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |         } catch (Exception ex) {
 | 
	
		
			
				|  |  |             return Result.error(ex.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -133,13 +140,10 @@ public class DatasourceController extends BaseController {
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @RequestMapping("testDatasource")
 | 
	
		
			
				|  |  |     @ResponseBody
 | 
	
		
			
				|  |  |     public Result testDatasource(String dataSource, String config)
 | 
	
		
			
				|  |  |     {
 | 
	
		
			
				|  |  |     public Result testDatasource(String dataSource, String config) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             return datasource.testDatasource(dataSource, config);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         catch (Exception ex)
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |         } catch (Exception ex) {
 | 
	
		
			
				|  |  |             return Result.error(ex.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -149,12 +153,10 @@ public class DatasourceController extends BaseController {
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @RequestMapping("deleteDatasource")
 | 
	
		
			
				|  |  |     @ResponseBody
 | 
	
		
			
				|  |  |     public Result DeleteDatasource(String id)
 | 
	
		
			
				|  |  |     {
 | 
	
		
			
				|  |  |     public Result DeleteDatasource(String id) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             return datasource.deleteDatasource(id);
 | 
	
		
			
				|  |  |         } catch (Exception ex)
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |         } catch (Exception ex) {
 | 
	
		
			
				|  |  |             return Result.error(ex.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 |