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

📄 relationccinfo.java

📁 java阿里巴巴代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.saas.biz.relationccMgr;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.saas.biz.dao.relationccDAO.RelationCcDAO;
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;

public class RelationCcInfo {
	
	
	Dbtable tradeQuery;
	
	
	Logger log;
	
	
	Buffers inBuffer;
	
	
	Buffers outBuffer;
	
	
	ArrayList queryResult = new ArrayList();
	
	
	
	public RelationCcInfo() {

		log = new Logger(this);
		tradeQuery = new Dbtable();
	}
	
	
	public void setTradeQuery(Dbtable tradeQuery) {

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

		return this.tradeQuery;
	}
	
	
	public void setOutBuffer(Buffers outBuffer) {

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

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

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

		this.queryResult = queryResult;
	}
	
	
	
	// 新增客户管理信息
	public void addCustomerRelation(Buffers inbuffer) {

		log.LOG_INFO("进入addProductInfo方法...");
		this.outBuffer = inbuffer;
		this.inBuffer = inbuffer;
		int iResult = -1;
		String rela_class = inbuffer.getString("RELA_CLASS");
		try {
			RelationCcDAO relation = new RelationCcDAO();
			relation.setCust_id(inbuffer.getString("SESSION_CUST_ID"));
			relation.setObj_cust_id(inbuffer.getString("CUST_ID"));
			relation.setRelation_type_code(inbuffer.getString("RELATION_TYPE_CODE"));
			relation.setEnd_date("2050-12-30");
			relation.setUpdate_staff_id(inbuffer.getString("SESSION_USER_ID"));
			relation.setRemark(inbuffer.getString("USER_ID"));
			relation.setRela_class(rela_class);
			iResult = addCustomerRelation(relation);
		}
		catch (SaasApplicationException 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("退出addCustomerRelation方法...");
	}
	
	
	public int addCustomerRelation(RelationCcDAO relation) throws SaasApplicationException {

		RelationCcExt relatExt = new RelationCcExt();
		relatExt.setParam(":VCUST_ID", relation.getCust_id());
		relatExt.setParam(":VOBJ_CUST_ID", relation.getObj_cust_id());
		relatExt.setParam(":VRELATION_TYPE_CODE", relation.getRelation_type_code());
		relatExt.setParam(":VEND_DATE", relation.getEnd_date());
		relatExt.setParam(":VUPDATE_STAFF_ID", relation.getUpdate_staff_id());
		relatExt.setParam(":VRELA_CLASS", relation.getRela_class());
		relatExt.setParam(":VREMARK", relation.getRemark());
		tradeQuery.executeBy(relatExt.insBy("INS_BY_CUSTOMER"));
		return 0;
	}
	
	
	
	// 查找客户关系
	public ArrayList getRelationByCustId(int iStart, String strCustId) throws SaasApplicationException {
		iStart = iStart * 20;
		ArrayList relationList = new ArrayList();
		RelationCcExt relaExt = new RelationCcExt();
		relaExt.setParam(":VCUST_ID", strCustId);
		relationList = relaExt.selByList("SEL_BY_CUST", iStart, 20);
		return relationList;
	}
	
	
	
	// 查找客户关系
	public ArrayList getRelationByCustId(String strCustId) throws SaasApplicationException {

		ArrayList relationList = new ArrayList();
		RelationCcExt relaExt = new RelationCcExt();
		relaExt.setParam(":VCUST_ID", strCustId);
		relationList = relaExt.selByList("SEL_BY_CUST");
		return relationList;
	}
	
	
	
	// 统计总数
	public int getRelationNumber(String cust_id) throws SaasApplicationException {

		ArrayList relationList = new ArrayList();
		RelationCcExt relaExt = new RelationCcExt();
		relaExt.setParam(":VCUST_ID", cust_id);
		relationList = relaExt.selByList("SEL_COUNT_CUST");
		if (relationList != null && relationList.size() > 0) {
			HashMap map = (HashMap) relationList.get(0);
			int size = 0;
			if (map.get("ct") != null) {
				size = Integer.parseInt(map.get("ct").toString());
			}
			return size;
		}
		else {
			return 0;
		}
	}
	
	
	
	// 删除客户管理信息
	public void updateCustomerRelation(Buffers inbuffer) {

		log.LOG_INFO("进入updateCustomerRelation方法...");
		this.outBuffer = inbuffer;
		this.inBuffer = inbuffer;
		int iResult = -1;
		try {
			
			String cust_id = inbuffer.getString("SESSION_CUST_ID");
			String obj_cust_id = inbuffer.getString("OBJ_CUST_ID");
			String relation_type_code = inbuffer.getString("RELATION_TYPE_CODE");
			iResult = updateCustomerRelation(cust_id, obj_cust_id, relation_type_code);
		}
		catch (SaasApplicationException 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("退出updateCustomerRelation方法...");
	}
	
	
	public int updateCustomerRelation(String cust_id, String obj_cust_id, String relation_type_code) throws SaasApplicationException {

		RelationCcExt relatExt = new RelationCcExt();
		log.LOG_INFO("========[" + cust_id + "]==========[" + obj_cust_id + "]===========[" + relation_type_code + "]===============");
		relatExt.setParam(":VCUST_ID", cust_id.trim());
		relatExt.setParam(":VOBJ_CUST_ID", obj_cust_id.trim());
		relatExt.setParam(":VRELATION_TYPE_CODE", relation_type_code);
		tradeQuery.executeBy(relatExt.insBy("DEL_BY_OBJID"));
		return 0;
	}
	
	
	
	// 修改客户管理信息
	
	public void updateCustomerRelationByObjId(Buffers inbuffer) {

		log.LOG_INFO("进入updateCustomerRelationByObjId方法...");
		this.outBuffer = inbuffer;
		this.inBuffer = inbuffer;
		int iResult = -1;
		String user_id = inbuffer.getString("SESSION_USER_ID");
		String cust_id = inbuffer.getString("SESSION_CUST_ID");
		String obj_cust_id = inbuffer.getString("OBJ_CUST_ID");
		String relation_type_code = inbuffer.getString("RELATION_TYPE_CODE");
		String rela_class = inbuffer.getString("RELA_CLASS");
		try {
			iResult = updateCustomerRelationByObjId(obj_cust_id, cust_id, user_id, relation_type_code, rela_class);
		}
		catch (SaasApplicationException 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("退出updateCustomerRelationByObjId方法...");
	}
	
	
	public int updateCustomerRelationByObjId(String obj_cust_id, String cust_id, String user_id, String relation_type_code, String rela_class) throws SaasApplicationException {

		RelationCcExt relatExt = new RelationCcExt();
		relatExt.setParam(":VOBJ_CUST_ID", obj_cust_id);
		relatExt.setParam(":VCUST_ID", cust_id);
		relatExt.setParam(":VUPDATE_STAFF_ID", user_id);
		relatExt.setParam(":VRELATION_TYPE_CODE", relation_type_code);
		relatExt.setParam(":VRELA_CLASS", rela_class);
		tradeQuery.executeBy(relatExt.insBy("UPDATE_BY_OBJID"));
		return 0;
	}
	
	
	
	// 查询客户关系及客户信息
	public ArrayList getRelationByObjId(String strCustId) throws SaasApplicationException {

		ArrayList relationList = new ArrayList();
		RelationCcExt relaExt = new RelationCcExt();
		relaExt.setParam(":VOBJ_CUST_ID", strCustId);
		relationList = relaExt.selByList("SEL_BY_OBJ_ID");
		return relationList;
	}
	
	
	
	// 查询关系客户
	public ArrayList getRelationByCustName(String cust_id, String cust_name) throws SaasApplicationException {

		ArrayList relationList = new ArrayList();
		RelationCcExt relaExt = new RelationCcExt();
		relaExt.setParam(":VCUST_ID", cust_id);
		relaExt.setParam(":VCUST_NAME", cust_name);
		relationList = relaExt.selByList("SEL_BY_RELA_NAME");
		return relationList;
	}
	
	
	
	// 查询关系客户
	public ArrayList getRelationByRelaType(String cust_id, String relationType) throws SaasApplicationException {

		ArrayList relationList = new ArrayList();
		RelationCcExt relaExt = new RelationCcExt();
		relaExt.setParam(":VCUST_ID", cust_id);
		relaExt.setParam(":VRELATION_TYPE_CODE", relationType);
		relationList = relaExt.selByList("SEL_BY_RELA_CLASS_TYPE");
		return relationList;
	}
	
	
	
	// 查询关系客户
	public ArrayList getRelationPageByType(int iStart, String cust_id, String rela_class) throws SaasApplicationException {

		
		
			iStart = iStart  * 20;
		
		ArrayList relationList = new ArrayList();
		RelationCcExt relaExt = new RelationCcExt();
		relaExt.setParam(":VCUST_ID", cust_id);
		relaExt.setParam(":VRELA_CLASS", rela_class);
		relationList = relaExt.selByList("SEL_BY_RELA_CLASS_TYPE", iStart, 20);
		return relationList;
	}
	
	// 查询关系经销商
	public ArrayList getDealerByType(int iStart, String cust_id, String rela_class) throws SaasApplicationException {

		
			iStart = iStart  * 20;
		
		ArrayList relationList = new ArrayList();
		RelationCcExt relaExt = new RelationCcExt();
		relaExt.setParam(":VCUST_ID", cust_id);
		relaExt.setParam(":VRELA_CLASS", rela_class);
		relationList = relaExt.selByList("SEL_DEALER_BY_TYPE", iStart, 20);
		return relationList;
	}
	
	public ArrayList getCustByRelationTypeCode(int iStart, String cust_id, String relation_type_code) throws SaasApplicationException {

		
		
			iStart = iStart  * 20;
		
		ArrayList relationList = new ArrayList();
		RelationCcExt relaExt = new RelationCcExt();
		relaExt.setParam(":VCUST_ID", cust_id);
		relaExt.setParam(":VRELATION_TYPE_CODE", relation_type_code);
		relationList = relaExt.selByList("SEL_CUST_BY_RELATION_TYPE_CODE", iStart, 20);
		return relationList;
	}
	
	public int getCustByRelationTypeCode(String cust_id, String relation_type_code) throws SaasApplicationException {
		int count = 0;
		ArrayList relationList = new ArrayList();
		RelationCcExt relaExt = new RelationCcExt();
		relaExt.setParam(":VCUST_ID", cust_id);
		relaExt.setParam(":VRELATION_TYPE_CODE", relation_type_code);
		relationList = relaExt.selByList("SEL_CUST_BY_RELATION_TYPE_CODE");
		if(relationList!=null && relationList.size()>0){
			count = relationList.size();
		}
		return count;
	}
	
	// 统计同一级别的客户
	public int getCustomerLevel(String cust_id, String rela_class, String type_code) throws SaasApplicationException {

		int size = 0;
		ArrayList levelList = new ArrayList();
		RelationCcExt relaExt = new RelationCcExt();
		relaExt.setParam(":VCUST_ID", cust_id);
		relaExt.setParam(":VRELA_CLASS", rela_class);
		relaExt.setParam(":VRELATION_TYPE_CODE", type_code);
		levelList = relaExt.selByList("SEL_BY_RELA_CT");
		log.LOG_INFO(":" + relaExt.insBy("SEL_BY_RELA_CT"));
		if (levelList != null && levelList.size() > 0) {
			HashMap map = (HashMap) levelList.get(0);
			size = Integer.parseInt(map.get("ct").toString());
		}
		return size;
	}
	
	
	public ArrayList getRelationJSONByType(int iStart, int pageSize, String cust_id, String rela_class) throws SaasApplicationException {

		ArrayList relationList = new ArrayList();
		RelationCcExt relaExt = new RelationCcExt();
		relaExt.setParam(":VCUST_ID", cust_id);
		relaExt.setParam(":VRELA_CLASS", rela_class);
		relationList = relaExt.selByList("SEL_ALLOPP_BY_TYPE", iStart, pageSize);
		return relationList;
	}
	
	
	public ArrayList getAllOppPageByType(int iStart, String cust_id, String rela_class) throws SaasApplicationException {

		log.LOG_INFO("进入getAllOppPageByType方法...");
		
			iStart = iStart  * 20;
		
//		log.LOG_INFO("==========" + cust_id + "==============" + rela_class + "=================");
		ArrayList relationList = new ArrayList();
		RelationCcExt relaExt = new RelationCcExt();
		relaExt.setParam(":VCUST_ID", cust_id);
		relaExt.setParam(":VRELA_CLASS", rela_class);
		relationList = relaExt.selByList("SEL_ALLOPP_BY_TYPE", iStart, 20);

⌨️ 快捷键说明

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