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

📄 newarealist.java

📁 java阿里巴巴代码
💻 JAVA
字号:
package com.saas.biz.areaMgr;

import java.util.ArrayList;
import java.util.HashMap;
import net.sf.json.JSONArray;
import com.saas.biz.JavaScriptObject.TreeNode;
import com.saas.biz.JavaScriptObject.TreeObject;
import com.saas.biz.commen.commMethodMgr;
import com.saas.biz.dao.newareaDAO.NewAareaExt;
import com.saas.biz.dao.newareaDAO.NewareaDAO;
import com.saas.biz.dao.relationccDAO.RelationCcExt;
import com.saas.sys.buffer.Buffers;
import com.saas.sys.dbm.Dbtable;
import com.saas.sys.exp.SaasApplicationException;
import com.saas.sys.log.Logger;

/**
 * @author:LiuYang
 * @desc:一级点点的[up_channels_id]=[000000000000000]
 * @2008-4-29
 */
public class NewAreaList {
	
	Logger log;
	Buffers inBuffer;
	Buffers outBuffer;
	Dbtable tradeQuery;
	commMethodMgr commen;
	
	ArrayList queryResult = new ArrayList();
	
	public NewAreaList() {

		log = new Logger(this);
		tradeQuery = new Dbtable();
		commen = new commMethodMgr();
	}
	
	
	public void setOutBuffer(Buffers outBuffer) {

		this.outBuffer = outBuffer;
	}
	
	
	public Buffers getOutBuffer() {

		return this.outBuffer;
	}
	
	
	public void setTradeQuery(Dbtable tradeQuery) {

		this.tradeQuery = tradeQuery;
	}
	
	
	public Dbtable getTradeQuery() {

		return this.tradeQuery;
	}
	
	
	public ArrayList getQueryResult() {

		return this.queryResult;
	}
	
	
	public void setQueryResult(ArrayList queryResult) {

		this.queryResult = queryResult;
	}
	
	
	
	// 新增片区
	public void addNewAreaInfo(Buffers inbuffer) {

		this.outBuffer = inbuffer;
		this.inBuffer = inbuffer;
		log.LOG_INFO("进入addNewAreaInfo方法...");
		int iResult = -1;
		String cust_id = inbuffer.getString("SESSION_CUST_ID");
		String channels_type = inbuffer.getString("CHANNELS_TYPE");
		String channels_id = inbuffer.getString("CHANNELS_ID");
		String channels_name = inbuffer.getString("CHANNELS_NAME");
		String up_channels_id = inbuffer.getString("UP_CHANNELS_ID");
		String channels_level = inbuffer.getString("CHANNELS_LEVEL");
		String channels_desc = inbuffer.getString("CHANNELS_DESC");
		String enable_tag = inbuffer.getString("ENABLE_TAG");
		String remark = inbuffer.getString("REMARK");
		try {
			NewareaDAO areaDao = new NewareaDAO();
			areaDao.setCust_id(cust_id);
			areaDao.setChannels_type(channels_type);
			areaDao.setChannels_id(channels_id);
			areaDao.setChannels_name(channels_name);
			areaDao.setUp_channels_id(up_channels_id);
			areaDao.setChannels_level(channels_level);
			areaDao.setChannels_desc(channels_desc);
			areaDao.setEnable_tag(enable_tag);
			areaDao.setRemark(remark);
			// log.LOG_INFO("111111111111111111111");
			iResult = addNewAreaInfo(areaDao);
		}
		catch (Exception e) {
			log.LOG_INFO(e.getMessage());
		}
		if (iResult != 0) {
			this.outBuffer.setInt("RESULT_CODE", -1);
			this.outBuffer.setString("RESULT_INFO", "新增片区业务处理失败!");
		}
		else {
			this.outBuffer.setInt("RESULT_CODE", 0);
			this.outBuffer.setString("RESULT_INFO", "新增片区业务处理成功!");
		}
		log.LOG_INFO("退出addNewAreaInfo方法...");
	}
	
	
	public int addNewAreaInfo(NewareaDAO areaDao) throws SaasApplicationException {

		NewAareaExt areaExt = new NewAareaExt();
		// log.LOG_INFO("开始执行SQL:===:");
		areaExt.setParam(":VCUST_ID", areaDao.getCust_id());
		areaExt.setParam(":VCHANNELS_TYPE", areaDao.getChannels_type());
		areaExt.setParam(":VCHANNELS_ID", areaDao.getChannels_id());
		areaExt.setParam(":VCHANNELS_NAME", areaDao.getChannels_name());
		areaExt.setParam(":VUP_CHANNELS_ID", areaDao.getUp_channels_id());
		areaExt.setParam(":VCHANNELS_LEVEL", areaDao.getChannels_level());
		areaExt.setParam(":VCHANNELS_DESC", areaDao.getChannels_desc());
		areaExt.setParam(":VENABLE_TAG", areaDao.getEnable_tag());
		areaExt.setParam(":VREMARK", areaDao.getRemark());
		// log.LOG_INFO("开始执行SQL:===:" + areaExt.insBy("INS_BY_ALL"));
		tradeQuery.executeBy(areaExt.insBy("INS_BY_ALL"));
		return 0;
	}
	
	
	
	// 新增片区
	public void addAreaInfo(Buffers inbuffer) {

		this.outBuffer = inbuffer;
		this.inBuffer = inbuffer;
		log.LOG_INFO("进入addAreaInfo方法...");
		int iResult = -1;
		String cust_id = inbuffer.getString("SESSION_CUST_ID");
		String channels_type = inbuffer.getString("CHANNELS_TYPE");
		String channels_id = commen.GenTradeId();
		String channels_name = inbuffer.getString("AREA_NAME");
		String up_channels_id = inbuffer.getString("CHANNELS_ID");
		String channels_level = "1";
		String channels_desc = "";
		String enable_tag = "0";
		String remark = "片区设置";
		try {
			NewareaDAO areaDao = new NewareaDAO();
			areaDao.setCust_id(cust_id);
			areaDao.setChannels_type(channels_type);
			areaDao.setChannels_id(channels_id);
			areaDao.setChannels_name(channels_name);
			areaDao.setUp_channels_id(up_channels_id);
			areaDao.setChannels_level(channels_level);
			areaDao.setChannels_desc(channels_desc);
			areaDao.setEnable_tag(enable_tag);
			areaDao.setRemark(remark);
			iResult = addNewAreaInfo(areaDao);
		}
		catch (Exception e) {
			log.LOG_INFO(e.getMessage());
		}
		if (iResult != 0) {
			this.outBuffer.setInt("RESULT_CODE", -1);
			this.outBuffer.setString("RESULT_INFO", "新增片区业务处理失败!");
		}
		else {
			this.outBuffer.setInt("RESULT_CODE", 0);
			this.outBuffer.setString("RESULT_INFO", "新增片区业务处理成功!");
		}
		log.LOG_INFO("退出addNewAreaInfo方法...");
	}
	
	
	
	// 修改片区资料
	public void modifyAreaInfo(Buffers inbuffer) {

		this.outBuffer = inbuffer;
		this.inBuffer = inbuffer;
		log.LOG_INFO("进入modifyAreaInfo方法...");
		int iResult = -1;
		String cust_id = inbuffer.getString("SESSION_CUST_ID");
		String channels_type = inbuffer.getString("CHANNELS_TYPE");
		String channels_id = inbuffer.getString("CHANNELS_ID");
		String channels_name = inbuffer.getString("CHANNELS_NAME");
		String channels_desc = inbuffer.getString("CHANNELS_DESC");
		String enable_tag = inbuffer.getString("ENABLE_TAG");
		String remark = inbuffer.getString("REMARK");
		try {
			NewareaDAO areaDao = new NewareaDAO();
			areaDao.setCust_id(cust_id);
			areaDao.setChannels_id(channels_id);
			areaDao.setChannels_name(channels_name);
			areaDao.setChannels_desc(channels_desc);
			areaDao.setEnable_tag(enable_tag);
			areaDao.setChannels_type(channels_type);
			areaDao.setRemark(remark);
			iResult = modifyAreaInfo(areaDao);
		}
		catch (Exception e) {
			log.LOG_INFO(e.getMessage());
		}
		if (iResult != 0) {
			this.outBuffer.setInt("RESULT_CODE", -1);
			this.outBuffer.setString("RESULT_INFO", "新增片区业务处理失败!");
		}
		else {
			this.outBuffer.setInt("RESULT_CODE", 0);
			this.outBuffer.setString("RESULT_INFO", "新增片区业务处理成功!");
		}
		log.LOG_INFO("退出modifyAreaInfo方法...");
	}
	
	
	public int modifyAreaInfo(NewareaDAO areaDao) throws SaasApplicationException {

		NewAareaExt areaExt = new NewAareaExt();
		areaExt.setParam(":VCUST_ID", areaDao.getCust_id());
		areaExt.setParam(":VCHANNELS_ID", areaDao.getChannels_id());
		areaExt.setParam(":VCHANNELS_NAME", areaDao.getChannels_name());
		areaExt.setParam(":VCHANNELS_DESC", areaDao.getChannels_desc());
		areaExt.setParam(":VENABLE_TAG", areaDao.getEnable_tag());
		areaExt.setParam(":VCHANNELS_TYPE", areaDao.getChannels_type());
		areaExt.setParam(":VREMARK", areaDao.getRemark());
		tradeQuery.executeBy(areaExt.insBy("UP_BY_ALL"));
		return 0;
	}
	
	
	
	// 删除片区资料
	public void deleteAreaInfo(Buffers inbuffer) {

		this.outBuffer = inbuffer;
		this.inBuffer = inbuffer;
		log.LOG_INFO("进入deleteAreaInfo方法...");
		int iResult = -1;
		String cust_id = inbuffer.getString("SESSION_CUST_ID");
		String channels_id = inbuffer.getString("CHANNELS_ID");
		try {
			NewareaDAO areaDao = new NewareaDAO();
			areaDao.setCust_id(cust_id);
			areaDao.setChannels_id(channels_id);
			iResult = deleteAreaInfo(areaDao);
		}
		catch (Exception e) {
			log.LOG_INFO(e.getMessage());
		}
		if (iResult != 0) {
			this.outBuffer.setInt("RESULT_CODE", -1);
			this.outBuffer.setString("RESULT_INFO", "删除片区业务处理失败!");
		}
		else {
			this.outBuffer.setInt("RESULT_CODE", 0);
			this.outBuffer.setString("RESULT_INFO", "删除片区业务处理成功!");
		}
		log.LOG_INFO("退出deleteAreaInfo方法...");
	}
	
	
	public int deleteAreaInfo(NewareaDAO areaDao) throws SaasApplicationException {

		NewAareaExt areaExt = new NewAareaExt();
		areaExt.setParam(":VCUST_ID", areaDao.getCust_id());
		areaExt.setParam(":VCHANNELS_ID", areaDao.getChannels_id());
		tradeQuery.executeBy(areaExt.insBy("DEL_BY_ALL"));
		return 0;
	}
	
	
	
	// 取出下一级
	public ArrayList getInfoByUpId(String cust_id, String up_channels_id) throws SaasApplicationException {

		ArrayList relationList = new ArrayList();
		NewAareaExt relaExt = new NewAareaExt();
		relaExt.setParam(":VCUST_ID", cust_id);
		relaExt.setParam(":VUP_CHANNELS_ID", up_channels_id);
		relationList = relaExt.selByList("SEL_BY_UP_ID");
		return relationList;
	}
	
	
	
	// 取出自己
	public ArrayList getInfoById(String cust_id, String channels_id) throws SaasApplicationException {

		ArrayList relationList = new ArrayList();
		NewAareaExt relaExt = new NewAareaExt();
		relaExt.setParam(":VCUST_ID", cust_id);
		relaExt.setParam(":VCHANNELS_ID", channels_id);
		relationList = relaExt.selByList("SEL_BY_ID");
		return relationList;
	}
	
	public ArrayList getInfoByChannelsId(String cust_id, String channels_id) throws SaasApplicationException {
		ArrayList relationList = new ArrayList();
		NewAareaExt relaExt = new NewAareaExt();
		relaExt.setParam(":VCUST_ID", cust_id);
		relaExt.setParam(":VCHANNELS_ID", channels_id);
		relationList = relaExt.selByList("SEL_BY_CHANNELS_ID");
		return relationList;
	}
	
	public HashMap getAreaById(String cust_id, String channels_id) throws SaasApplicationException {

		HashMap map = new HashMap();
		ArrayList relationList = new ArrayList();
		NewAareaExt relaExt = new NewAareaExt();
		relaExt.setParam(":VCUST_ID", cust_id);
		relaExt.setParam(":VCHANNELS_ID", channels_id);
		relationList = relaExt.selByList("SEL_BY_ID");
		map = (HashMap) relationList.get(0);
		return map;
	}
	
	
	
	/**
	 * @param cust_id
	 * @param up_id
	 * @param img
	 * @return json data
	 * @throws SaasApplicationException
	 */
	
	public String getJsonDataForTree(String cust_id, String up_id, String img) throws SaasApplicationException {

		String iconCls = img;
		JSONArray jsonList = new JSONArray();
		ArrayList rootList = getInfoByUpId(cust_id, up_id);
		if (rootList != null && rootList.size() > 0) {
			for (int i = 0; i < rootList.size(); i++) {
				HashMap map = (HashMap) rootList.get(i);
				TreeObject tree = new TreeObject();
				String text = map.get("channels_name").toString();
				String id = map.get("channels_id").toString();
				tree.setIconCls(iconCls);
				tree.setId(id);
				tree.setText(text);
				TreeNode node = isLeaf(cust_id, id);
				tree.setChildren(node.getChildren());
				tree.setLeaf(node.isLeaf());
				jsonList.add(tree);
			}
		}
		return jsonList.toString();
	}
	
	
	
	/**
	 * @param cust_id
	 * @param root_id
	 * @param nextList
	 * @return children
	 * @throws SaasApplicationException
	 */
	public JSONArray getChildrenNodes(String cust_id, String root_id, ArrayList nextList) throws SaasApplicationException {

		JSONArray children = new JSONArray();
		if (nextList != null && nextList.size() > 0) {
			for (int i = 0; i < nextList.size(); i++) {
				HashMap map = (HashMap) nextList.get(i);
				TreeObject tree = new TreeObject();
				String text = map.get("channels_name").toString();
				String id = map.get("channels_id").toString();
				tree.setId(id);
				tree.setText(text);
				TreeNode node = isLeaf(cust_id, id);
				tree.setChildren(node.getChildren());
				tree.setLeaf(node.isLeaf());
				children.add(tree);
			}
		}
		return children;
	}
	
	
	
	/**
	 * @param cust_id
	 * @param up_id
	 * @return TreeNode
	 * @throws SaasApplicationException
	 */
	public TreeNode isLeaf(String cust_id, String up_id) throws SaasApplicationException {

		ArrayList nextList = getInfoByUpId(cust_id, up_id);
		TreeNode node = new TreeNode();
		if (nextList != null && nextList.size() > 0) {
			node.setLeaf(false);
			JSONArray children = getChildrenNodes(cust_id, up_id, nextList);
			node.setChildren(children);
		}
		return node;
	}
	
	
	
	/**
	 * @param cust_id
	 * @param chana_id
	 * @return 判断是否有子节点
	 * @throws SaasApplicationException
	 */
	public int checkChildren(String cust_id, String chana_id) throws SaasApplicationException {

		int child = 0;
		ArrayList list = getInfoByUpId(cust_id, chana_id);
		if (list != null && list.size() > 0) {
			child = list.size();
		}
		return child;
	}
	
}

⌨️ 快捷键说明

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