gbs_replyfromeditaction.java

来自「对日软件外包 为东芝做的一个全球商业管理系统」· Java 代码 · 共 377 行

JAVA
377
字号
/*
 * Created on 2004/08/13
 *
 */
package ACTION;

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

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

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

import COMMON.BaseCommonCheck;
import COMMON.BaseDispatchAction;
import COMMON.MessageList;
import COMMON.ReturnValue;
import COMMON.SystemConstants;
import DataBean.GBS_ReplyList_stBean;
import LOGIC.GBS_ReplyFromEditActionLogic;
/**
 * <p>Description: process page action<br>
 * </p>
 * <p> Copyright (c) 2004</p>
 * @author qfk
 * @version  1.0
 */
public class GBS_ReplyFromEditAction extends BaseDispatchAction implements SystemConstants {

	/**
	 * init page 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
		throws Exception {
		GBS_ReplyFromEditForm thisform = (GBS_ReplyFromEditForm) form;
		// get login user info from session
		this.setUserInfoFromSession(request, thisform);

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

		//get combox value and label
		ReturnValue returnValue = logic.getSubsidiaryList();
		HashMap map = (HashMap) returnValue.getDataValue();
		thisform.setSubsidiaryValueList((ArrayList) map.get(SUBSIDIARY_CODE));
		thisform.setSubsidiaryLabelList((ArrayList) map.get(SUBSIDIARY_NAME));

		String lineNo = thisform.getLineNo();
		String seqNo = thisform.getSeqNo();
		String customerID = thisform.getCustomerID();
		String rfpNo = thisform.getRfpNo();
		String replyKbn = thisform.getReplyKbn();
		String subCode = thisform.getSubCodeHidden();
		thisform.setMethod("insert");
		if ((lineNo != null && !lineNo.equals("")) || (seqNo != null && !seqNo.equals(""))) {
			//read data from session;
			ArrayList replyAttachList = (ArrayList) this.getFromSession(request, REPLYATTACHLIST);
			for (int i = 0; replyAttachList != null && i < replyAttachList.size(); i++) {
				GBS_ReplyList_stBean replyListBean = (GBS_ReplyList_stBean) replyAttachList.get(i);
				if (lineNo.equals(replyListBean.getLineNo())
					&& customerID.equals(replyListBean.getCustomerID())
					&& rfpNo.equals(replyListBean.getRfpNo())
					&& replyKbn.equals(replyListBean.getReplyKbn())
					&& subCode.equals(replyListBean.getSubCode())
					&& seqNo.equals(replyListBean.getSeqNo())) {
					thisform.setCustomerID(replyListBean.getCustomerID());
					thisform.setSeqNo(replyListBean.getSeqNo());
					thisform.setRfpNo(replyListBean.getRfpNo());
					thisform.setReplyKbn(replyListBean.getReplyKbn());
					thisform.setLineNo(replyListBean.getLineNo());
					thisform.setSubCode(replyListBean.getSubCode());
					thisform.setTitle(replyListBean.getTitle());
					thisform.setComment(replyListBean.getComment());
					thisform.setSubCodeHidden(subCode);
					thisform.setAttachmentfilename(replyListBean.getAttachmentfilename());
					thisform.setMethod("update");
					break;
				}
			}

		}

		return (mapping.findForward(nextview));
	}

	/**
	 * update: edit
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward insert(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
		throws Exception {

		GBS_ReplyFromEditForm thisform = (GBS_ReplyFromEditForm) form;
		HttpSession session = request.getSession();

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

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

		//get combox value and label
		ReturnValue returnValue = logic.getSubsidiaryList();
		HashMap map = (HashMap) returnValue.getDataValue();
		thisform.setSubsidiaryValueList((ArrayList) map.get(SUBSIDIARY_CODE));
		thisform.setSubsidiaryLabelList((ArrayList) map.get(SUBSIDIARY_NAME));

		//String lineNo     = thisform.getLineNo();
		//String seqNo      = thisform.getSeqNo();
		MessageList errorMsg = new MessageList();
		errorMsg = inputCheck(thisform, request);
		if (errorMsg.size() > 0) {
			//save error to request
			this.setMessage(errorMsg);
			return (mapping.findForward(nextview));
		}
		//save uploaded file to t_temp
		if (thisform.getAttachmentFile() != null && !thisform.getAttachmentFile().getFileName().equals("")) {
			//insert a new record into Temp info
			int iSeqNo = logic.insertTemp(session.getId(), thisform.getLoginUserId(), thisform.getAttachmentFile());
			if (iSeqNo > 0) {
				thisform.setSeqNo(String.valueOf(iSeqNo));
				thisform.setAttachmentfilename(thisform.getAttachmentFile().getFileName());
			}
		}
		returnValue = logic.getSubsidiaryName(thisform.getSubCode());
		String subName = returnValue.getDataValue() == null ? "" : returnValue.getDataValue().toString();
		//update thisform info to session
		ArrayList replyAttachList = (ArrayList) this.getFromSession(request, REPLYATTACHLIST);
		GBS_ReplyList_stBean replyListBean = new GBS_ReplyList_stBean();
		replyListBean.setCustomerID(thisform.getCustomerID());
		replyListBean.setRfpNo(thisform.getRfpNo());
		replyListBean.setLineNo("ADD" + replyAttachList.size());
		replyListBean.setSeqNo(thisform.getSeqNo());
		replyListBean.setSubCode(thisform.getSubCode());
		replyListBean.setComment(thisform.getComment());
		replyListBean.setReplyKbn(thisform.getReplyKbn());
		replyListBean.setTitle(thisform.getTitle());
		replyListBean.setSubName(subName);
		replyListBean.setAttachmentfilename(thisform.getAttachmentfilename());
		//		replyListBean.setFdelflag(thisform.getFdelflag());
		replyListBean.setRowUpdateFlg(true);
		replyListBean.setCreateuser(thisform.getLoginUserId());
		replyListBean.setCreateuserName(thisform.getLoginMemberNameFirst() + " " + thisform.getLoginMemberNameLast());
		replyListBean.setCreatedate(BaseCommonCheck.convertDateToYYYYMonDD());
		//Edit by Gxk 2004/08/27 start
		replyListBean.setUpdateuser(thisform.getLoginUserId());
		replyListBean.setUpdateuserName(thisform.getLoginMemberNameFirst() + " " + thisform.getLoginMemberNameLast());
		replyListBean.setUpdatedate(BaseCommonCheck.convertDateToYYYYMonDD());
		//Edit by Gxk 2004/08/27 end
		replyListBean.setRecordDeleteFlg(false);
		//session.setAttribute(REPLYATTACHLIST,replyAttachList);
		//forward to sucess 
		replyListBean.setFiletype(BaseCommonCheck.getFileType(thisform.getAttachmentfilename()));
		//String filetype = "";	
		//String filename	=thisform.getAttachmentfilename();		
		//if(!(filename == null) && !filename.equals("")){
		//	filetype = filename.substring(filename.lastIndexOf(".")+1);
		//	if(!(filetype.equals("doc") || filetype.equals("xls") || filetype.equals("pdf")) )	
		//		filetype = "other";				
		//}	
		//replyListBean.setFiletype(filetype);
		replyAttachList.add(replyListBean);
		thisform.setMethod("close");
		return (mapping.findForward(nextview));
	}

	/**
	 * update: edit
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
		throws Exception {

		GBS_ReplyFromEditForm thisform = (GBS_ReplyFromEditForm) form;
		HttpSession session = request.getSession();

		GBS_ReplyFromEditActionLogic logic = new GBS_ReplyFromEditActionLogic(this.getDataSource(request));
		//get combox value and label
		ReturnValue returnValue = logic.getSubsidiaryList();
		HashMap map = (HashMap) returnValue.getDataValue();
		thisform.setSubsidiaryValueList((ArrayList) map.get(SUBSIDIARY_CODE));
		thisform.setSubsidiaryLabelList((ArrayList) map.get(SUBSIDIARY_NAME));

		//get login user info from session
		this.setUserInfoFromSession(request, thisform);
		MessageList errorMsg = new MessageList();
		errorMsg = inputCheck(thisform, request);
		if (errorMsg.size() > 0) {
			//save error to request
			this.setMessage(errorMsg);
			return (mapping.findForward(nextview));
		}
		String lineNo = thisform.getLineNo();
		String seqNo = thisform.getSeqNo();
		String customerID = thisform.getCustomerID();
		String rfpNo = thisform.getRfpNo();
		String replyKbn = thisform.getReplyKbn();
		String subCode = thisform.getSubCodeHidden();
		thisform.setSubCodeHidden(subCode);
		thisform.getFdelflag();

		//save uploaded file to t_temp
		if (thisform.getAttachmentFile() != null && !thisform.getAttachmentFile().getFileName().equals("")) {
			//insert a new record into Temp info
			int iSeqNo = logic.insertTemp(session.getId(), thisform.getLoginUserId(), thisform.getAttachmentFile());
			if (iSeqNo > 0) {
				thisform.setSeqNo(String.valueOf(iSeqNo));
				thisform.setAttachmentfilename(thisform.getAttachmentFile().getFileName());
			}
		}
		returnValue = logic.getSubsidiaryName(thisform.getSubCode());
		String subName = returnValue.getDataValue() == null ? "" : returnValue.getDataValue().toString();
		//update thisform info to session
		ArrayList replyAttachList = (ArrayList) this.getFromSession(request, REPLYATTACHLIST);
		for (int i = 0; replyAttachList != null && i < replyAttachList.size(); i++) {
			GBS_ReplyList_stBean replyListBean = (GBS_ReplyList_stBean) replyAttachList.get(i);
			if (lineNo.equals(replyListBean.getLineNo())
				&& customerID.equals(replyListBean.getCustomerID())
				&& rfpNo.equals(replyListBean.getRfpNo())
				&& replyKbn.equals(replyListBean.getReplyKbn())
				&& subCode.equals(replyListBean.getSubCode())
				&& seqNo.equals(replyListBean.getSeqNo())) {

				replyListBean.setLineNo(thisform.getLineNo());
				replyListBean.setSeqNo(thisform.getSeqNo());
				replyListBean.setSubCode(thisform.getSubCode());
				replyListBean.setComment(thisform.getComment());
				replyListBean.setReplyKbn(thisform.getReplyKbn());
				replyListBean.setTitle(thisform.getTitle());
				replyListBean.setSubName(subName);
				replyListBean.setAttachmentfilename(thisform.getAttachmentfilename());
				//			replyListBean.setFdelflag(thisform.getFdelflag());
				replyListBean.setRowUpdateFlg(true);
				//			if (!replyListBean.getLineNo().startsWith("A")) {
				replyListBean.setUpdateuser(thisform.getLoginUserId());
				replyListBean.setUpdateuserName(thisform.getLoginMemberNameFirst() + " " + thisform.getLoginMemberNameLast());
				replyListBean.setUpdatedate(BaseCommonCheck.convertDateToYYYYMonDD());
				//			}
				replyListBean.setRecordDeleteFlg(false);
				replyListBean.setFiletype(BaseCommonCheck.getFileType(thisform.getAttachmentfilename()));
				//Page Delete combox is checked
				if (thisform.getFdelflag().equals("on")) {
					replyListBean.setFiletype("");
					replyListBean.setAttachmentfilename("");
					replyListBean.setFdelflag(true);
				}
				//String filetype = "";	
				//String filename	=thisform.getAttachmentfilename();		
				//if(!(filename == null) && !filename.equals("")){
				//	filetype = filename.substring(filename.lastIndexOf(".")+1);
				//	if(!(filetype.equals("doc") || filetype.equals("xls") || filetype.equals("pdf")) )	
				//		filetype = "other";				
				//}	
				//replyListBean.setFiletype(filetype);						
				break;
			}
		}
		// forward to sucess 
		thisform.setMethod("close");
		return (mapping.findForward(nextview));
	}
	/**
	 * delete
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
		throws Exception {
		GBS_ReplyFromEditForm thisform = (GBS_ReplyFromEditForm) form;
		HttpSession session = request.getSession();

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

		String lineNo = thisform.getLineNo();
		String seqNo = thisform.getSeqNo();
		String customerID = thisform.getCustomerID();
		String rfpNo = thisform.getRfpNo();
		String replyKbn = thisform.getReplyKbn();
		String subCode = thisform.getSubCodeHidden();
		GBS_ReplyFromEditActionLogic logic = new GBS_ReplyFromEditActionLogic(this.getDataSource(request));

		//update thisform info to session
		ArrayList replyAttachList = (ArrayList) this.getFromSession(request, REPLYATTACHLIST);
		for (int i = 0; replyAttachList != null && i < replyAttachList.size(); i++) {
			GBS_ReplyList_stBean replyListBean = (GBS_ReplyList_stBean) replyAttachList.get(i);
			if (lineNo.equals(replyListBean.getLineNo())
				&& customerID.equals(replyListBean.getCustomerID())
				&& rfpNo.equals(replyListBean.getRfpNo())
				&& replyKbn.equals(replyListBean.getReplyKbn())
				&& subCode.equals(replyListBean.getSubCode())
				&& seqNo.equals(replyListBean.getSeqNo())) {
				replyListBean.setRowUpdateFlg(true);
				replyListBean.setCreateuser(thisform.getLoginUserId());
				replyListBean.setRecordDeleteFlg(true);
				break;
			}
		}
		// forward to sucess 
		thisform.setMethod("close");
		return (mapping.findForward(nextview));
	}

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

	private MessageList inputCheck(GBS_ReplyFromEditForm thisForm, HttpServletRequest request) throws Exception {
		//create ErrorMessages to display
		MessageList messages = new MessageList();
		FormFile attachmentFile = thisForm.getAttachmentFile();
		if (BaseCommonCheck.isEmpty(thisForm.getSubCode()) || thisForm.getSubCode().equals("-1")) {
			messages.setMessage(
				"subCode",
				thisForm.getSubCode(),
				"10000009",
				Integer.MIN_VALUE,
				new Object[] { "Participating Subsidiary" },
				"Participating Subsidiary");
		}
		//Comment check
		if (thisForm.getComment().length() > 200) {
			messages.setMessage("comment", thisForm.getSubCode(), "90000002", Integer.MIN_VALUE);
		}
		//Title check
		if (thisForm.getTitle().length() > 100) {
			messages.setMessage("title", thisForm.getSubCode(), "90000002", Integer.MIN_VALUE);
		}
		//AttachmentFile check
		//if(thisForm.getFdelflag().equals("off")){
		if ((attachmentFile != null && !attachmentFile.getFileName().equals("")) && attachmentFile.getFileSize() == 0) {
			messages.setMessage(
				"attachmentFile",
				null,
				"10000012",
				Integer.MIN_VALUE,
				new Object[] { "AttachmentFile" },
				"AttachmentFile");
		}
		//}
		//AttachmentFile's name check
		if (attachmentFile != null && attachmentFile.getFileName().length() > 100) {
			messages.setMessage("", "", "10000018", Integer.MIN_VALUE);
		}
		return messages;
	}

}

⌨️ 快捷键说明

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