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

📄 rfcaction.java

📁 建立于Eclipse平台的WEB应用系统-物流管理系统变更模块
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package org.mychange.struts.action;


import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

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

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.mychange.obj.Rfc;
import org.mychange.obj.Testreport;
import org.mychange.obj.Users;
import org.mychange.service.IRfcListService;
import org.mychange.service.IRfcService;
import org.mychange.service.impl.CmFactory;
import org.mychange.service.impl.RfcService;
import org.mychange.service.impl.TestreportService;
import org.mychange.service.impl.UsersService;
import org.mychange.struts.form.RfcForm;
import org.mychange.toChinese.ChineseEncoding;



/** 
 * MyEclipse Struts
 * Creation date: 07-03-2008
 * 
 * XDoclet definition:
 * @struts.action scope="request" validate="true"
 */
public class RfcAction extends Action {
	
	private int action;
	private CmFactory facotory;
	/*
	 * Generated Methods
	 */

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	/*Spring相关设置*/
	
//	ChineseEncoding ce=new ChineseEncoding();
	private RfcService rfcService;
	
	
    public void setRfcService(RfcService rfcService) {
    	this.rfcService = rfcService;
	}
    public RfcService getRfcService() {
	    return rfcService;
	}
	
    private TestreportService testreportService;
    
    public TestreportService getTestreportService() {
		return testreportService;
	}
	public void setTestreportService(TestreportService testreportService) {
		this.testreportService = testreportService;
	}
	private UsersService usersService;
	public UsersService getUsersService() {
		return usersService;
	}
	public void setUsersService(UsersService usersService) {
		this.usersService = usersService;
	}
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
    	action = Integer.parseInt(request.getParameter("action"));
    	
//    	return null;
		
		switch ( action ){
		/*0--表示新增事件记录*/
		
		    case 0:  return addNewRfc(mapping, form, request, response);
		    /*1--表示查看所有事件记录*/
	        case 1:  return selectAllRfc(mapping, form, request, response);
		  
	        
	        case 2: return updateRfc(mapping, form, request, response);
			
			case 3: return programChange(mapping, form, request, response);
			
			case 4: return testRFC(mapping,form,request,response);
			
			case 5: return broadcastRFC(mapping,form,request,response);
			
			case 6: return updateTestreport(mapping,form,request,response);
			
			case 7: return  removeTestreport(mapping, form,request, response);
			
			case 8: return findNotCheckRfc(mapping,form,request,response);
			
			case 9: return endRfc(mapping,form,request,response);
			
			case 10: return findById(mapping,form,request,response);
			case 11: return findDisplay(mapping, form, request, response);
			    default:
			    	return null;		
		    }
//	
	}
    /**
     * 新增加rfc
     * action=0
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     */
	
	public ActionForward addNewRfc(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {

		
		RfcForm rfcForm = (RfcForm)form;
		
		HttpSession session=request.getSession();
		String userName=(String)session.getAttribute("userName");
		
		String type=rfcForm.getType();
		String des=rfcForm.getDescription();
		String name=rfcForm.getRFCname();
		String risk=rfcForm.getRisk();

		String money = rfcForm.getMoney();
		String people = rfcForm.getPeople();
		String priority = rfcForm.getPriority();
		String effection = rfcForm.getEffection();
		String emergence = rfcForm.getEmergence();
		String technology=rfcForm.getTechnology();
		String upload=rfcForm.getUploadFile();
		String submitDate=rfcForm.getSubmitDate();
		String expectDate=rfcForm.getExpectDate();
		String waitingTime=rfcForm.getWaitingTime();
	  
	    Users users=usersService.getUsersByName(userName);

	    Rfc rfc = new Rfc();
	    rfc.setUsers(users);

		
		rfc.setRfcname(name);
		rfc.setTypes(type);

		rfc.setRiskLevel(risk);
		rfc.setSkillLevel(technology);
		rfc.setDescription(des);
		rfc.setEffectLevel(effection);
		rfc.setInstancyLevel(emergence);

		rfc.setLatencyTime(waitingTime);
		rfc.setCost(money);
		rfc.setManpower(people);
		rfc.setPriority(priority);
		rfc.setEffectLevel(effection);
		rfc.setAttachment(upload);
		rfc.setState("未审批");
		rfc.setEnventId(3);

		rfc.setSubmitDate(submitDate);
		rfc.setExpectDate(expectDate);
		rfcService.addRfc(rfc);
	
		return mapping.findForward("rfc");
	}

	
	/**
	 * 审批RFC
	 * action=2
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */

	
	public ActionForward updateRfc(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		// TODO Auto-generated method stub
		HttpSession session=request.getSession();
		RfcForm rfcForm = (RfcForm)form;
		String rollBack=rfcForm.getRollBack();
		String pass=rfcForm.getPass();
		
		int id=rfcForm.getId();

		String des=rfcForm.getDescription();

		String risk=rfcForm.getRisk();
		String technology=rfcForm.getTechnology();
		String money = rfcForm.getMoney();
		String people = rfcForm.getPeople();
		String priority = rfcForm.getPriority();
		String effection = rfcForm.getEffection();
		String emergence = rfcForm.getEmergence();


		String expectDate=rfcForm.getExpectDate();
		
		Rfc rfc = rfcService.getRfcById(id);
	    if(rollBack!=null&&rollBack.length()>1)
		
	    {
	    	rfc.setState("已回绝");
	    	((RfcForm)form).setRollBack("");
	    }
	    else if(pass!=null&&pass.length()>1)
	    {
		
	    	rfc.setState("已审批");

	    	((RfcForm)form).setPass("");
	    }
		
		rfc.setId(id);

		rfc.setRiskLevel(risk);
		rfc.setSkillLevel(technology);
		rfc.setDescription(des);
		rfc.setEffectLevel(effection);
		rfc.setInstancyLevel(emergence);

		rfc.setCost(money);
		rfc.setManpower(people);
		rfc.setPriority(priority);
		rfc.setEffectLevel(effection);


		

		
		rfc.setEnventId(1);

		rfc.setExpectDate(expectDate);
		rfcService.updateRfc(rfc);
//		Rfc findRfc=new Rfc();
//		findRfc.setState("未审批");
//	    List rfcList = rfcService.findRfc(findRfc);
//	    session.setAttribute("rfcList", rfcList);

		return mapping.findForward("rfcListAction");

	}

	
	/**
	 * 	显示要审批的rfcList
	 *  action=1
	 *  
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	
public ActionForward selectAllRfc(ActionMapping mapping, ActionForm form,
		HttpServletRequest request, HttpServletResponse response) {
	
	HttpSession session = request.getSession();//取得一个session
	String identity=session.getAttribute("identity").toString();
	IRfcListService rfclistService=facotory.getCM(identity);

//	Rfc rfc =new Rfc();
//	rfc.setState("未审批");
    List rfcList = rfclistService.getUCheckedRFC();
    session.setAttribute("rfcList", rfcList);
    return mapping.findForward("rfcList");
   
}

/**
 * 显示要规划的RFC的list
 * action=3
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 */
public ActionForward programChange(ActionMapping mapping, ActionForm form,
		HttpServletRequest request, HttpServletResponse response) {
        
	HttpSession session = request.getSession();//取得一个session
	String identity=session.getAttribute("identity").toString();
	IRfcListService rfclistService=facotory.getCM(identity);
	
//	Rfc rfc=new Rfc();
//	rfc.setState("已审批");
	/**
	 * 获取已审批的变更请求
	 */
    List program =rfclistService.getCheckedRFC();
    session.setAttribute("programList",  program);
    return mapping.findForward("program");
   
}
/**
 * 显示要测试的rfc列表
 * 
 * action=4
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 */
public ActionForward testRFC(ActionMapping mapping, ActionForm form,
		HttpServletRequest request, HttpServletResponse response) {
        
	HttpSession session = request.getSession();//取得一个session
	String identity=session.getAttribute("identity").toString();
	IRfcListService rfclistService=this.facotory.getCM(identity);
	
	/**
	 * 获取已规划的变更请求
	 */
    List testRFC = rfclistService.getPlanRFC();
    session.setAttribute("testRFC",  testRFC);
    return mapping.findForward("test");
   
}
/**
 * 
 * 显示要发布的已测试或者已回绝的列表
 * action=5
 * 
 */
public ActionForward broadcastRFC(ActionMapping mapping, ActionForm form,
		HttpServletRequest request, HttpServletResponse response){
	
	HttpSession session = request.getSession();//取得一个session
	String identity=session.getAttribute("identity").toString();
	IRfcListService rfclistService=this.facotory.getCM(identity);
	

	List<Rfc> rfcState=rfclistService.getTestedRFC();
	List<Rfc> rfcState2=rfclistService.getFailedRFC();
	rfcState.addAll(rfcState2);
	List testReports = new ArrayList();
	List broadcastRFC=new ArrayList();
	for(Rfc r:rfcState)
	{
		testReports=testreportService.getByProperty("rfc", r);
		if(testReports.size()!=0){
			 broadcastRFC.add(testReports.get(0));
		}
	}
    session.setAttribute("broadcastRFC", broadcastRFC);
    return mapping.findForward("broadcast");
	
}

/**
 * 发布测试报告
 * 
 * action=6
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 */

public ActionForward updateTestreport(ActionMapping mapping, ActionForm form,
		HttpServletRequest request, HttpServletResponse response){
	HttpSession session = request.getSession();
	int id = Integer.parseInt(request.getParameter("row"));
	
	Testreport testreport=testreportService.getTestreportById(id);
	Rfc rfc=testreport.getRfc();
	rfc.setState("已发布");
	testreportService.updateTestreport(testreport);
	
	response.setCharacterEncoding("gb2312");
	return mapping.findForward("BroadcastDisplay");
	
	
	
}


/**
 * 显示已撤销的rfc列表
 * 
 * action=7
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 */
public ActionForward removeTestreport(ActionMapping mapping, ActionForm form,
		HttpServletRequest request, HttpServletResponse response){
	int id = Integer.parseInt(request.getParameter("row2"));
	
	Testreport testreport=testreportService.getTestreportById(id);
	Rfc rfc=testreport.getRfc();
	rfc.setState("失败");
	
	testreportService.updateTestreport(testreport);
	
	return mapping.findForward("BroadcastDisplay");
}

/**
 * 显示已撤销、已回绝、已发布的RFC列表
 * 
 * action=8
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 */

public ActionForward findNotCheckRfc(ActionMapping mapping, ActionForm form,
		HttpServletRequest request, HttpServletResponse response){
	
	HttpSession session = request.getSession(); //取得一个session
	String states1="已发布";
	String states2="已回绝";
	String states3="已撤销";
	
	Rfc rfc=new Rfc();
	
	
	rfc.setState(states1);
    List rfcState = rfcService.findRfc(rfc);
    rfc.setState(states2);
    List rfcState2= rfcService.findRfc(rfc);
    rfc.setState(states3);
    List rfcState3 = rfcService.findRfc(rfc);
    
    rfcState.addAll(rfcState2);
    rfcState.addAll(rfcState3);
    	
    session.setAttribute("rfcState", rfcState);

	
	int totalSize = rfcState.size();


	session.setAttribute("notCheckRfcSize", totalSize);
	
	
	
	
	return mapping.findForward("rfcState");
}

/**
 * 用户查看了由变更处理的Rfc后将Rfc的状态为“已完成”
 * 
 * action=9
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 */
 public ActionForward endRfc(ActionMapping mapping, ActionForm form,
		HttpServletRequest request, HttpServletResponse response){
	 HttpSession session = request.getSession(); //取得一个session 
	 
	 
	int  id=Integer.parseInt(request.getSession().getAttribute("selectedRfcID").toString());
	 Rfc rfc = rfcService.getRfcById(id);
	 
	 rfc.setState("已完成");
	 rfcService.updateRfc(rfc);
	 
	 
	 
	 Rfc findRfc=new Rfc();
		String states1="已发布";
		String states2="已回绝";
		String states3="失败";
		
		
		
		
		findRfc.setState(states1);
	    List rfcState = rfcService.findRfc(findRfc);
	    findRfc.setState(states2);
	    List rfcState2= rfcService.findRfc(findRfc);
	    findRfc.setState(states3);
	    List rfcState3 = rfcService.findRfc(findRfc);
	    
	    rfcState.addAll(rfcState2);
	    rfcState.addAll(rfcState3);
	    	
	     session.setAttribute("rfcState", rfcState);
	 
	 return mapping.findForward("rfcState");
 }
 /**
  * 查看Rfc的详细信息
  * action=10
  * @param mapping
  * @param form
  * @param request
  * @param response
  * @return
  */
 public ActionForward findById(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response){
	 
	 HttpSession session = request.getSession();
	 int id = Integer.parseInt(request.getParameter("id"));
	 Rfc rfc=rfcService.getRfcById(id);
	 
	 session.setAttribute("rfc", rfc);
	 
	 return mapping.findForward("rfcDis");
 }
 
	 /**
	  * 
	  * action=11
	  * @param mapping
	  * @param form
	  * @param request
	  * @param response
	  * @return
	  */
	 public ActionForward findDisplay(ActionMapping mapping, ActionForm form,
				HttpServletRequest request, HttpServletResponse response){
		 
		 HttpSession session = request.getSession(); //取得一个session
			String states1="已发布";
			String states2="已回绝";
			String states3="已撤销";
			
			Rfc rfc=new Rfc();
			
			
			rfc.setState(states1);
		    List rfcState = rfcService.findRfc(rfc);
		    rfc.setState(states2);
		    List rfcState2= rfcService.findRfc(rfc);
		    rfc.setState(states3);
		    List rfcState3 = rfcService.findRfc(rfc);
		    
		    rfcState.addAll(rfcState2);
		    rfcState.addAll(rfcState3);
		    	
		    session.setAttribute("rfcState", rfcState);

			
			int totalSize = rfcState.size();


			session.setAttribute("notCheckRfcSize", totalSize);
			
			return mapping.findForward("display");
		 
	 }
 
 
public CmFactory getFacotory() {
	return facotory;
}
public void setFacotory(CmFactory facotory) {
	this.facotory = facotory;
}
	   
   }

⌨️ 快捷键说明

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