⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 treeservice.java

📁 请认真阅读您的文件包然后写出其具体功能(至少要20个字)。尽量不要让站长把时间都花费在为您修正说明上。压缩包解压
💻 JAVA
字号:
package net.jcreate.e3.samples.tree;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import net.jcreate.e3.core.BusinessException;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementSetter;
import org.springframework.jdbc.core.RowMapper;

public class TreeService  {
	
	private JdbcTemplate jdbcTemplate;

	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}

	/**
	 * 修改机构
	 * @param pChangedOrgs
	 * @throws BusinessException
	 */
	public void updateOrgs(final Map pChangedOrgs)throws BusinessException{
		Iterator orgIds = pChangedOrgs.keySet().iterator();
		/**
		 * TODO: 如果数据量大的话,使用batch 更新
		 */
		while( orgIds.hasNext() ){
			final String orgId = (String)orgIds.next();
			final String parentOrgId = (String)pChangedOrgs.get(orgId);

			String sql =
				"update Date_Organization " +
				"  set fchrParentCode = ? " +
				"where fchrBiCode = ? ";
			jdbcTemplate.update(sql, new PreparedStatementSetter(){
				public void setValues(PreparedStatement pPS) throws SQLException {
					int index = 1;
					pPS.setString(index++, parentOrgId);
					pPS.setString(index++, orgId);
				}
			});
			
		}
	}
	public List getSubOrgs(final String pParentID) throws BusinessException{
		final String SQL = "select * from Date_Organization where fchrParentCode = ?";
		return jdbcTemplate.query(SQL,new PreparedStatementSetter(){
			public void setValues(PreparedStatement pPS) throws SQLException {
				int index = 1;
				pPS.setString(index, pParentID);
			}
		},
		new RowMapper(){
			public Object mapRow(ResultSet pRS, int arg1) throws SQLException {
				Org org = new Org();
				org.setId(pRS.getString("fchrBiCode"));
				org.setParentId(pRS.getString("fchrParentCode"));
				org.setName(pRS.getString("fchrOrgName"));				
				org.setViewOrder(pRS.getInt("IntViewPoint"));
				org.setApp(pRS.getString("fchrAppName"));
				return org;
			}
		});
	}
	public List getRootOrg() throws BusinessException {
		final String SQL = "select * from Date_Organization where fchrParentCode is null";
		return jdbcTemplate.query(SQL, new RowMapper(){
			public Object mapRow(ResultSet pRS, int arg1) throws SQLException {
				Org org = new Org();
				org.setId(pRS.getString("fchrBiCode"));
				org.setParentId(pRS.getString("fchrParentCode"));
				org.setName(pRS.getString("fchrOrgName"));				
				org.setViewOrder(pRS.getInt("IntViewPoint"));
				org.setApp(pRS.getString("fchrAppName"));
				return org;
			}
		});
	}
	
	public List getOrgs() throws BusinessException {
		final String SQL = "select * from Date_Organization";
		return jdbcTemplate.query(SQL, new RowMapper(){
			public Object mapRow(ResultSet pRS, int arg1) throws SQLException {				
				Org org = new Org();
				org.setId(pRS.getString("fchrBiCode"));
				org.setParentId(pRS.getString("fchrParentCode"));
				org.setName(pRS.getString("fchrOrgName"));				
				org.setViewOrder(pRS.getInt("IntViewPoint"));
				org.setApp(pRS.getString("fchrAppName"));
				return org;
			}
		});
	}
	
}
   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -