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

📄 actionent_customer_enterprise.java

📁 公司CRM部分原代码,采用的是java技术.
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
package GDPE.customer.enterprise;

import portal.*;
import levin.base.*;
import levin.util.*;
import levin.UserInfo;
import levin.iMessage;
import portal.User;
import portal.sa.auditorrole.EnAuditorRole;
import portal.sa.auditor.*;
import portal.sa.department.EnDepartment;
import javax.servlet.http.*;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.StringTokenizer;
import java.util.Properties;
import java.util.Vector;

import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.mail.Multipart;
import javax.mail.Transport;
import javax.mail.Session;
import javax.mail.Message;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeUtility;
import javax.mail.MessagingException;
import GDPE.customer.linkman.EnENT_CUSTOMER_LINKMAN;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import first.*;

public class ActionEnt_Customer_Enterprise extends Action {
	Logger logger=Logger.getLogger("ActionEnt_Customer_Enterprise.class");
	public ActionEnt_Customer_Enterprise() {
	}	
	public String execute(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		throw new Exception("Error on doType=" + request.getParameter("doType")
				+ ".");
	}
	public String summary(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		//HttpSession session = request.getSession(false);
		//UserInfo userInfor = (UserInfo) session.getAttribute("UserInfo_Object");
		User user = (User)UserInfo.getInstance(request);
		String idstr = user.getId();
		String flag = "";
		String chStationCode;
		EnEnt_Customer_Enterprise aEnEnt_Customer_Enterprise[];

		flag = checkFlag(idstr);
		if (flag.equals("isAdmin")) {

			//aEnEnt_Customer_Enterprise = (EnEnt_Customer_Enterprise[]) (DAOBase
				//	.findAll(new DbAccess(), EnEnt_Customer_Enterprise.class
				//			.getName()));
			
			aEnEnt_Customer_Enterprise = (EnEnt_Customer_Enterprise [])(DAOBase.findByCondition(new DbAccess(),
					EnEnt_Customer_Enterprise.class.getName(), " chIsAudited like '%1%' and chSwapState like'%0%' ", ""));//rownum < 120
            //System.out.println("--");
			  //logger.info("查询时使用的帐号:"+idstr);

		} else if (flag.equals("isStation")) {

			EnAuditor cEnAuditor = (EnAuditor) DAOBase.findByPK(new DbAccess(),
					EnAuditor.class.getName(), idstr);
			chStationCode = cEnAuditor.getChDeptCode();

//			EnDepartment aEnDepartment [] =null;
//			String where = "chparentdept = '" + chStationCode +"'" + " and chIsAudited = '1'";
//			aEnDepartment = (EnDepartment []) DAOBase.findByCondition(new DbAccess(), EnDepartment.class.getName(), where, "");	
//			StringBuffer sb = new StringBuffer("chStationCode= '");
//			sb.append(chStationCode);
//			sb.append(" '");
//			for(int i=0;i<aEnDepartment.length;i++) {
//				sb.append(" or ");
//				sb.append(" chAreacode = '");
//				sb.append(aEnDepartment[i].getChDeptCode());
//				
//				sb.append("'");
//			}
			
			//String where1 = sb.toString();
			String where1 = "chStationCode ='"+chStationCode+"'"+" and chIsAudited like '%1%' or chareacode = '"+chStationCode+"'"+" and chIsAudited like '%1%' or chCommitCode = '" + idstr + "'"+" and chIsAudited like '%1%'";
			String order = " chCommitCode";  
			//logger.info("查询时使用的帐号:"+idstr);
			aEnEnt_Customer_Enterprise = (EnEnt_Customer_Enterprise[]) (DAOBase
					.findByCondition(new DbAccess(),
							EnEnt_Customer_Enterprise.class.getName(), where1,
							order));

		} else {
			String where = "chCommitCode = '" + idstr + "'" +" and chIsAudited like '%1%'";
			//logger.info("查询时使用的帐号:"+idstr);
			String order = " chCommitCode";
			aEnEnt_Customer_Enterprise = (EnEnt_Customer_Enterprise[]) (DAOBase
					.findByCondition(new DbAccess(),
							EnEnt_Customer_Enterprise.class.getName(), where,
							 order));
		}
		
//		for(int i=0; i<aEnEnt_Customer_Enterprise.length;i++) {
//			aEnEnt_Customer_Enterprise[i] = GDPE.customer.enterprise.ActionEnt_Customer_Enterprise.viewInfo(aEnEnt_Customer_Enterprise[i]);
//	    } //这里可以查出联系人里面的资料
		request.setAttribute("aEnEnt_Customer_Enterprise",
				aEnEnt_Customer_Enterprise);
		request.setAttribute("chooseType", "checkbox");
		return this.getTargetPage("summary");

	}

	public String addQuery(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		HttpSession session = request.getSession(false);
		UserInfo userInfor = (UserInfo) session.getAttribute("UserInfo_Object");
		Date now = new Date(System.currentTimeMillis());
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd",
				Locale.SIMPLIFIED_CHINESE);
		String timestamp = sdf.format(now);
		EnEnt_Customer_Enterprise cEnEnt_Customer_Enterprise = new EnEnt_Customer_Enterprise();
		request.setAttribute("cEnEnt_Customer_Enterprise",
				cEnEnt_Customer_Enterprise);

	    cEnEnt_Customer_Enterprise.setChCommitCode(userInfor.getId());
		cEnEnt_Customer_Enterprise.setChCommitName(userInfor.getName());

		cEnEnt_Customer_Enterprise.setChCommitUserId(userInfor.getId());
		cEnEnt_Customer_Enterprise.setChCommitUserName(userInfor.getName());

		cEnEnt_Customer_Enterprise.setDtCommitTime(timestamp);
		cEnEnt_Customer_Enterprise.setChIsAudited("1");
		cEnEnt_Customer_Enterprise.setChIsFollowed("1");

		request.setAttribute("doType", "add");
		return this.getTargetPage("detail");

	}

	public String add(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		String chCollectUserId = (String) request.getParameter("chCommitCode");
		EnEnt_Customer_Enterprise cEnEnt_Customer_Enterprise = (EnEnt_Customer_Enterprise) request
				.getAttribute("cEnEnt_Customer_Enterprise");
		if (chCollectUserId == null || chCollectUserId.equals("")) {
			cEnEnt_Customer_Enterprise.setChCommitCode("########");
			cEnEnt_Customer_Enterprise.setChCommitName("公共仓库");
		}

		String te[] ;
	    
		te=request.getParameterValues("chProduct");
		
		if (te!= null) {
			StringBuffer s = new StringBuffer();
			for (int i = 0; i < te.length; i++) {
				// System.out.println("66666---"+te[i]);
				s.append(te[i]);
				s.append(",");
			}
			cEnEnt_Customer_Enterprise.setChProduct(s.toString());
		}
		// cEnEnt_Customer_Enterprise.setChIsAudited("0");
		// cEnEnt_Customer_Enterprise.setChIsFollowed("0");
		String enterpriseName = cEnEnt_Customer_Enterprise.getChEnterpriseFullName().trim();
		 //System.out.println("777=----"+enterpriseName);
		EnEnt_Customer_Enterprise aEnEnt_Customer_Enterprise[];
		aEnEnt_Customer_Enterprise = (EnEnt_Customer_Enterprise [])(DAOBase.findByCondition(new DbAccess(),
				EnEnt_Customer_Enterprise.class.getName(), " chEnterpriseFullName ='"+enterpriseName+"'", ""));
		
		if(aEnEnt_Customer_Enterprise.length>0) {			
			levin.iMessage msg = levin.iMessage
					.getNewInstance(
							"客户管理",
							"你录入的企业已经被其他客户经理收藏!",
							"openTop(\"GDPE.customer.enterprise.ActionEnt_Customer_Enterprise.do?doType=summary\");");
			msg.save(request);
			return this.getTargetPage("Message");
		}else {
			DbAccess db = new DbAccess();
			try {
				db.beginTransaction();
				DAOBase.insert(db, cEnEnt_Customer_Enterprise);
				db.commit();
			} catch (Exception ex) {
				db.rollback();
				throw ex;
			}
			levin.iMessage msg = levin.iMessage
					.getNewInstance(
							"客户管理",
							"新增成功.",
							"openTop(\"GDPE.customer.enterprise.ActionEnt_Customer_Enterprise.do?doType=summary\");");
			msg.save(request);
			return this.getTargetPage("Message");
		}
		
	}

	public String modifyQuery(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String id = request.getParameter("id");
		EnEnt_Customer_Enterprise cEnEnt_Customer_Enterprise = (EnEnt_Customer_Enterprise) DAOBase
				.findByPK(new DbAccess(), EnEnt_Customer_Enterprise.class
						.getName(), id);

		if (!cEnEnt_Customer_Enterprise.getDtFoundTime().equals("")) {
			if (cEnEnt_Customer_Enterprise.getDtFoundTime().startsWith("1900")) {
				cEnEnt_Customer_Enterprise.setDtFoundTime("");
			} else {
				String year = cEnEnt_Customer_Enterprise.getDtFoundTime()
						.substring(0, 4);
				String month = cEnEnt_Customer_Enterprise.getDtFoundTime()
						.substring(5, 7);
				String day = cEnEnt_Customer_Enterprise.getDtFoundTime()
						.substring(8, 10);
				cEnEnt_Customer_Enterprise.setDtFoundTime(year + month + day);
			}
		}

		if (!cEnEnt_Customer_Enterprise.getDtCommitTime().equals("")) {
			if (cEnEnt_Customer_Enterprise.getDtCommitTime().startsWith("1900")) {
				cEnEnt_Customer_Enterprise.setDtCommitTime("");
			} else {
				String year = cEnEnt_Customer_Enterprise.getDtCommitTime()
						.substring(0, 4);
				String month = cEnEnt_Customer_Enterprise.getDtCommitTime()
						.substring(5, 7);
				String day = cEnEnt_Customer_Enterprise.getDtCommitTime()
						.substring(8, 10);
				cEnEnt_Customer_Enterprise.setDtCommitTime(year + month + day);
			}
			
		}
		if (!cEnEnt_Customer_Enterprise.getDtOpenAccout().equals("")) {
			if (cEnEnt_Customer_Enterprise.getDtOpenAccout().startsWith("1900")) {
				cEnEnt_Customer_Enterprise.setDtOpenAccout("");
			} else {
				String year = cEnEnt_Customer_Enterprise.getDtOpenAccout()
						.substring(0, 4);
				String month = cEnEnt_Customer_Enterprise.getDtOpenAccout()
						.substring(5, 7);
				String day = cEnEnt_Customer_Enterprise.getDtOpenAccout()
						.substring(8, 10);
				cEnEnt_Customer_Enterprise.setDtOpenAccout(year + month + day);
			}
			
		}
		request.setAttribute("cEnEnt_Customer_Enterprise",
				cEnEnt_Customer_Enterprise);
		
		//String jspPageId=request.getParameter("jspPageId");
		//System.out.println(jspPageId);
		//request.setAttribute("aEnEnt_Customer_Enterprise",
		//		request.getParameter("aEnEnt_Customer_Enterprise"));
		request.setAttribute("doType", "modify");
		//request.setAttribute("jspPageId", jspPageId);
		return this.getTargetPage("detail");
	}

	public String modify(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

//		HttpSession session = request.getSession(false);
//		UserInfo userInfor = (UserInfo) session.getAttribute("UserInfo_Object");
		User user = (User)UserInfo.getInstance(request);
		String operatorId = user.getId();// 当前操作员ID
		this.setOperationType(request,"修改");//系统日志 操作类型
		
		String flag = "";
		flag = checkFlag(operatorId);

		EnEnt_Customer_Enterprise cEnEnt_Customer_Enterprise = (EnEnt_Customer_Enterprise) request
				.getAttribute("cEnEnt_Customer_Enterprise");
		String collectUserId = cEnEnt_Customer_Enterprise.getChCommitCode();
		
		String te[] = request.getParameterValues("chProduct");// 处理多选框经营
		if (te!=null) {
			StringBuffer s = new StringBuffer();
			for (int i = 0; i < te.length; i++) {
				// System.out.println("66666---"+te[i]);
				s.append(te[i]);
				int c = te.length;
				if(i<(c-1)) {
				 s.append(",");
				}
			}
			cEnEnt_Customer_Enterprise.setChProduct(s.toString());
		}
		if (flag.equals("isAdmin")||flag.equals("isStation")||collectUserId.equals(operatorId)) {
			DbAccess db = new DbAccess();
			try {
				db.beginTransaction();
				DAOBase.update(db, cEnEnt_Customer_Enterprise);
				db.commit();
			} catch (Exception ex) {
				db.rollback();
				throw ex;
			}	
			
		}  else {
			levin.iMessage msg = levin.iMessage.getNewInstance("企业库",

⌨️ 快捷键说明

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