All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.wicp.tams.cas.components.TreeGridOrg Maven / Gradle / Ivy

There is a newer version: 1.3.2
Show newest version
package net.wicp.tams.cas.components;

import java.sql.Connection;
import java.util.List;
import java.util.Map;

import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.annotations.Import;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SetupRender;
import org.apache.tapestry5.http.Link;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.util.TextStreamResponse;

import lombok.extern.slf4j.Slf4j;
import net.wicp.tams.cas.services.IQuery;
import net.wicp.tams.common.apiext.json.EasyUiAssist;
import net.wicp.tams.common.apiext.json.easyuibean.EasyUINode;
import net.wicp.tams.common.apiext.json.easyuibean.EasyUINodeConf;
import net.wicp.tams.common.jdbc.DruidAssit;
import net.wicp.tams.component.tools.TapestryAssist;

/*****
 * 用户下拉列表
 * 
 * TODO pageSize设置会有问题
 * 
 * @author Andy.zhou
 * 
 */
@Import(stack = "easyuistack")
@Slf4j
public class TreeGridOrg {

	@Parameter
	private String userName;

	@Parameter
	private String orgId;
	/**
	 * 是否查询子组织?默认为是
	 */
	@Parameter(value = "true")
	private boolean hasSub;

	@Inject
	protected IQuery query;

	@Inject
	protected ComponentResources resources;

	@Property
	private String url;

	@SetupRender
	void initializeValues() {
		Link link = resources.createEventLink("treeGridOrg");
		this.url = link.getBasePath();// 示例/zh/cas/usermanager.comboboxuser:queryuser
	}

	TextStreamResponse onTreeGridOrg() {
		String retstr = "";
		try {
			// 查询
			Connection connection = DruidAssit.getConnection("default");
			// String sql = String.format("select * from %s.%s %s", getDb(), ColsSysOrg.tb,
			// buff.toString());
			List> orgs = query.queryOrgById(null);

			 EasyUINodeConf conf = new EasyUINodeConf("id", "orgName", "parentId");
			 conf.setFieldCols("orgIdPath","orgCode");
			 List treeRoot = EasyUiAssist.getTreeRoot(orgs, conf);
			 retstr = EasyUiAssist.getTreeFromList(treeRoot);
			/*
			 * IConvertValue parent = new IConvertValue() {
			 * 
			 * @Override public String getStr(String keyObj) { return keyObj; } };
			 */
			//retstr = EasyUiAssist.getJsonForGridAlias2(orgs, new String[] { "parentId,_parentId" },
			//		CollectionUtil.newMap("_parentId", parent), orgs.size());
			connection.close();
		} catch (Exception e) {
			log.error("查询失败", e);
		}
		return TapestryAssist.getTextStreamResponse(retstr);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy