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

📄 actionent_customer_enterprise.java

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

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.*;

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 GDPE.customer.enterprise.*;
import GDPE.follow.EnEnt_Record_Following;

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");
		String idstr = userInfor.getId();
		String flag = "";
		String chStationCode;
		EnEnt_Customer_Enterprise aEnEnt_Customer_Enterprise[];
		flag = checkFlag(idstr);
		if (flag.equals("isAdmin")) {
			// System.out.println("---21-");
			String where = "chCommitCode like '%" + userInfor.getId()
					+ "%'and chIsAudited like '%0%' ";

			// 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(), where,
							" dtFoundTime desc"));// rownum < 120
			// System.out.println("----1-");
		} 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 + "'";
			// aEnDepartment = (EnDepartment[]) DAOBase.findByCondition(
			// new DbAccess(), EnDepartment.class.getName(), where, "");
			//			
			// System.out.println("----1-"+aEnDepartment.length);
			// 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("'");
			// }
			// sb.append(" or chCommitCode =");
			//
			// sb.append(idstr);
			// String where1 = sb.toString();
			String where1 = "chStationCode ='" + chStationCode + "'"
					+ " and chIsAudited like '%0%' or chareacode = '"
					+ chStationCode + "'"
					+ " and chIsAudited like '%0%' or chCommitCode = '" + idstr
					+ "'" + " and chIsAudited like '%0%'";

			String order = " dtFoundTime,chCommitCode desc";
			aEnEnt_Customer_Enterprise = (EnEnt_Customer_Enterprise[]) (DAOBase
					.findByCondition(new DbAccess(),
							EnEnt_Customer_Enterprise.class.getName(), where1,
							order));
			// System.out.println("----1-"+where1);
		} else {
			String where = "chCommitCode = '" + userInfor.getId() + "'"
					+ " and chIsAudited like '%0%' ";
			String order = " dtFoundTime desc";
			aEnEnt_Customer_Enterprise = (EnEnt_Customer_Enterprise[]) (DAOBase
					.findByCondition(new DbAccess(),
							EnEnt_Customer_Enterprise.class.getName(), where,
							order));
			// System.out.println("----1-");
		}

		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");

		String cId = userInfor.getId();
		EnAuditor cEnAuditor = (EnAuditor) DAOBase.findByPK(new DbAccess(),
				EnAuditor.class.getName(), cId);
		String chStationCode = cEnAuditor.getChDeptCode();
		EnDepartment cEnDepartment = (EnDepartment) DAOBase.findByPK(
				new DbAccess(), EnDepartment.class.getName(), chStationCode);
		String chStation = cEnDepartment.getChDeptName();

		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);

		// dtFoundTime
		cEnEnt_Customer_Enterprise.setDtFoundTime(timestamp);// 录入时间
		cEnEnt_Customer_Enterprise.setChStation(chStation);
		cEnEnt_Customer_Enterprise.setChStationCode(chStationCode);

		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("0");
		cEnEnt_Customer_Enterprise.setChIsFollowed("0");

		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");
		// System.out.println("77777777777----"+cEnEnt_Customer_Enterprise.getChIsFollowed());
		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.latent.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.latent.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);
		// request.setAttribute("aEnEnt_Customer_Enterprise",
		// request.getParameter("aEnEnt_Customer_Enterprise"));
		request.setAttribute("doType", "modify");
		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("企业库",
					"您无权修改其他人员的客户记录.", "closeSelf()");
			msg.save(request);

			return this.getTargetPage("Message");
		}
		// .out.println("----1------");
		// MultiPage cMultiPage = MultiPage.getInstance(request);
		// cMultiPage.updateObject("aEnEnt_Customer_Enterprise", "id",
		// cEnEnt_Customer_Enterprise.getId()+"", cEnEnt_Customer_Enterprise);
		// String strOpen =
		// "openTop(\"GDPE.customer.enterprise.ActionEnt_Customer_Enterprise.do?doType=summary&jspPageId="+cMultiPage.getJspPageId()+"\");";
		// String strOpen =
		// "openTop(\"page.do?targetPage=/GDPE/customer/latent/Ent_Customer_Enterprise_Summary.jsp&jspPageId="+cMultiPage.getJspPageId()+"\",true)";

		String strOpen = "openTop(\"GDPE.customer.latent.ActionEnt_Customer_Enterprise.do?doType=summary\");";
		// String strOpen =
		// "openTop(\"page.do?targetPage=/GDPE/customer/latent/Ent_Customer_Enterprise_Summary.jsp&jspPageId="+cMultiPage.getJspPageId()+"\",true)";
		// System.out.println("---"+request.getParameter("jspPageId"));
		// System.out.println("----2------");
		// //String strOpen="closeWindow()";
		// String strOpen="closeSelf()";
		levin.iMessage msg = levin.iMessage.getNewInstance("客户管理", "修改成功!",
				strOpen);
		// "openTop(\"GDPE.customer.enterprise.ActionEnt_Customer_Enterprise.do?doType=summary\");");
		// System.out.println("----3------");
		msg.save(request);

		// logger.info("修改时使用的帐号:" + operatorId);

		return this.getTargetPage("Message");
	}

	public String view(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);
		request.setAttribute("cEnEnt_Customer_Enterprise",
				cEnEnt_Customer_Enterprise);
		request.setAttribute("doType", "view");
		return this.getTargetPage("detail");
	}

	public String delete(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		HttpSession session = request.getSession(false);

⌨️ 快捷键说明

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