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

📄 gbs_replyfromaction.java

📁 对日软件外包 为东芝做的一个全球商业管理系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/** 
 * method GBS_ReplyFromAction.java
 * created on 07-30-2004
 * 
 * @author   GXK
 * @version  1.0
 */

package ACTION;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import COMMON.BaseCommonCheck;
import COMMON.BaseDispatchAction;
import COMMON.MessageList;
import COMMON.ReturnValue;
import COMMON.SendMail;
import COMMON.SystemConstants;
import DataBean.GBS_Customer_stBean;
import DataBean.GBS_MWideUse_stBean;
import DataBean.GBS_RFP_stBean;
import DataBean.GBS_ReplyList_stBean;
import DataBean.GBS_RfpCountry_stBean;
import LOGIC.GBS_ReplyFromActionLogic;
//import DataBean.*;
//END UOC
/////////////////////////////////////////////////////////////////

public class GBS_ReplyFromAction extends BaseDispatchAction implements SystemConstants {

	/**
	 * init pagelike SUBSIDIARY data
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
		throws Exception {

		log.info("[location info]GBS_ReplyFromAction.init method!");
		GBS_ReplyFromForm requestForm = (GBS_ReplyFromForm) form;
		//get login user info from session
		this.setUserInfoFromSession(request, requestForm);

		GBS_ReplyFromActionLogic logic = new GBS_ReplyFromActionLogic(this.getDataSource(request));
		ReturnValue returnValue = new ReturnValue();

		requestForm.setMethod("update");
		//1-1屭媞柤徧傪庢摼
		returnValue = logic.getCustomer(requestForm.getCustomerID());
		if (returnValue.isError()) {
			if (returnValue.isBussinessError()) {
				this.setMessage(returnValue.getMessageList());
			}
			//getErrorCode,getErrorMessage proc
		} else {
			GBS_Customer_stBean Customer_stBean = (GBS_Customer_stBean) returnValue.getDataValue();
			if (Customer_stBean != null) {
				requestForm.setCustomerID(Customer_stBean.getCustomerID());
				requestForm.setCustomerName(Customer_stBean.getCustomerName());
			}
		}

		//1-2 RFP忣曬傪庢摼
		returnValue = (ReturnValue) logic.getRfpInfo(requestForm.getCustomerID(), requestForm.getRfpNo());
		String OriginatingSubsidiaryCode = "";
		if (returnValue.isError()) {
			if (returnValue.isBussinessError()) {
				this.setMessage(returnValue.getMessageList());
			}
			//getErrorCode,getErrorMessage proc
		} else {
			GBS_RFP_stBean RFP_stBean = (GBS_RFP_stBean) returnValue.getDataValue();
			if (RFP_stBean != null) {
				requestForm.setCustomerID(RFP_stBean.getCustomerID());
				requestForm.setRfpNo(RFP_stBean.getRfpNo());
				requestForm.setInfoCountry(RFP_stBean.getInfoCountry());
				requestForm.setInfoDelivery(RFP_stBean.getInfoDelivery());
				requestForm.setInfoHardCategory(RFP_stBean.getInfoHardCategory());
				requestForm.setQuantity(RFP_stBean.getQuantity());
				requestForm.setRemarks(RFP_stBean.getRemarks());
				requestForm.setComment(RFP_stBean.getComment());
				//Originating Subsidiary Name 傪庢摼
				returnValue = logic.getSubsidiaryName(RFP_stBean.getRfpSubsidiaryCode());
				OriginatingSubsidiaryCode = RFP_stBean.getRfpSubsidiaryCode();
				if (!returnValue.isError()) {
					requestForm.setOriginatingSubsidiary(
						returnValue.getDataValue() == null ? "" : returnValue.getDataValue().toString());
				}
				requestForm.setReply("1");
			}
		}

		//1-3 RFP偺娭楢崙忣曬傪庢摼
		ArrayList subsidiaryCodeList = new ArrayList();
		returnValue = (ReturnValue) logic.getRfpCountryInfo(requestForm.getCustomerID(), requestForm.getRfpNo());
		if (returnValue.isError()) {
			if (returnValue.isBussinessError()) {
				this.setMessage(returnValue.getMessageList());
			}
			//getErrorCode,getErrorMessage proc
		} else {
			ArrayList RfpCountryList = (ArrayList) returnValue.getDataValue();
			//get ParticipatingSubsidiaries
			for (int i = 0; RfpCountryList != null && i < RfpCountryList.size(); i++) {
				GBS_RfpCountry_stBean RfpCountry_stBean = (GBS_RfpCountry_stBean) RfpCountryList.get(i);
				subsidiaryCodeList.add(RfpCountry_stBean.getSubsidiaryCode());
				for (int j = i + 1; j < RfpCountryList.size(); j++) {
					GBS_RfpCountry_stBean RfpCountry_stBean1 = (GBS_RfpCountry_stBean) RfpCountryList.get(j);
					if (RfpCountry_stBean.getSubsidiaryCode().equals(RfpCountry_stBean1.getSubsidiaryCode())) {
						RfpCountryList.remove(j);
						j--;
					}
				}
			}
			for (int i = 0; RfpCountryList != null && i < RfpCountryList.size(); i++) {
				GBS_RfpCountry_stBean RfpCountry_stBean = (GBS_RfpCountry_stBean) RfpCountryList.get(i);
				if (RfpCountry_stBean.getSubsidiaryName() == null || RfpCountry_stBean.getSubsidiaryName().equals("")) {
					RfpCountryList.remove(i);
					i--;
				}
			}

			String subsidiary = "";
			for (int i = 0; RfpCountryList != null && i < RfpCountryList.size(); i++) {
				GBS_RfpCountry_stBean RfpCountry_stBean = (GBS_RfpCountry_stBean) RfpCountryList.get(i);
				if (i == RfpCountryList.size() - 1) {
					subsidiary = subsidiary + RfpCountry_stBean.getSubsidiaryName();
				} else {
					subsidiary = subsidiary + RfpCountry_stBean.getSubsidiaryName() + ",";
				}
			}
			requestForm.setParticipatingSubsidiaries(subsidiary);
		}

		//1-4 Reply忣曬傪庢摼
		returnValue = logic.getReplyInfo(requestForm.getCustomerID(), requestForm.getRfpNo(), requestForm.getLoginPlusHour());
		ArrayList searchList = new ArrayList();
		if (returnValue.isError()) {
			//僄儔乕偑敪惗
			if (returnValue.isBussinessError()) {
				this.setMessage(returnValue.getMessageList());
			}
			// getErrorCode, getErrorMessage() proc
		} else {
			//専嶕寢壥傪FormAction偵曐懚偡傞
			searchList = (ArrayList) returnValue.getDataValue();

			this.saveToSession(request, REPLYATTACHLIST, searchList);
		}
		ArrayList replyList = new ArrayList();
		for (int i = 0; searchList != null && i < searchList.size(); i++) {
			GBS_ReplyList_stBean replyListBean = (GBS_ReplyList_stBean) searchList.get(i);
			if (replyListBean.getReplyKbn().equals("1")) {
				replyList.add(replyListBean);
			}
		}
		requestForm.setReplyList(replyList);
		//whether Edit Button can show or not 
		for (int i = 0; i < subsidiaryCodeList.size(); i++) {
			if (requestForm.getLoginSubsidiaryCode2().equals(subsidiaryCodeList.get(i))) {
				requestForm.setEditflag(true);
				break;
			}else{
				requestForm.setEditflag(false);
			}
		}
		return (mapping.findForward(nextview));
	}

	/**
	 * input error check
	 * @param thisForm GBS_ReplyFromForm
	 * @param request HttpServletRequest
	 * @throws Exception
	 * @return ActionErrors
	 */

	private MessageList inputCheck(GBS_ReplyFromForm thisForm, HttpServletRequest request) throws Exception {
		//create ErrorMessages to display
		MessageList errorMsg = new MessageList();
		return errorMsg;
	}

	public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
		throws Exception {

		GBS_ReplyFromForm thisform = (GBS_ReplyFromForm) form;
		//get login user info from session
		this.setUserInfoFromSession(request, thisform);

		GBS_ReplyFromActionLogic logic = new GBS_ReplyFromActionLogic(this.getDataSource(request));

		ArrayList replyAttachList = (ArrayList) this.getFromSession(request, REPLYATTACHLIST);
		if (replyAttachList != null) {
			ReturnValue returnValue =
				logic.saveReplyAttachment(
					replyAttachList,
					thisform.getLoginUserId(),
					thisform.getLoginSubsidiaryCode2(),
					thisform.getCustomerID(),
					thisform.getRfpNo());
			if (returnValue.isError()) {
				if (returnValue.isBussinessError()) {
					this.setMessage(returnValue.getMessageList());
				}
				//getErrorCode, getErrorMessage() proc
			} else {
				this.removeFromSession(request, REPLYATTACHLIST);
			}
		} else {
			return (mapping.findForward(nextview));
		}
		//Get the mailList and send mail
		if (!BaseCommonCheck.isEmpty(thisform.getLoginEmail())) {

			ArrayList mailList = new ArrayList();
			ReturnValue returnValue = logic.getMail(thisform.getCustomerID(), String.valueOf(thisform.getRfpNo()));
			if (returnValue.isError()) {
				if (returnValue.isBussinessError()) {
					this.setMessage(returnValue.getMessageList());
				}
				return (mapping.findForward(nextview));
			} else {
				mailList = (ArrayList) returnValue.getDataValue();
			}

			//Get mail server
			String smtpServer = "";
			String mailUser = "";
			String mailPasswd = "";
			returnValue = logic.getWideUse("SMTP");
			if (returnValue.isError()) {
				if (returnValue.isBussinessError()) {
					this.setMessage(returnValue.getMessageList());
				}
				return (mapping.findForward(nextview));
			} else {
				ArrayList tmpList = (ArrayList) returnValue.getDataValue();
				for (int i = 0; tmpList != null && i < tmpList.size(); i++) {
					GBS_MWideUse_stBean stBean = (GBS_MWideUse_stBean) tmpList.get(i);
					if ("SMTP".equals(stBean.getMainKey())) {
						smtpServer = BaseCommonCheck.convertNullToSpace(stBean.getString1());
						mailUser = BaseCommonCheck.convertNullToSpace(stBean.getString2());

⌨️ 快捷键说明

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