/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.yuntong.action;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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 com.yuntong.business.vo.G_RoadwayVO;
import com.yuntong.service.G_IRegisterInfoService;
import com.yuntong.service.G_IRoadwayService;

/** 
 * MyEclipse Struts
 * Creation date: 04-13-2007
 * 
 * XDoclet definition:
 * @struts.action validate="true"
 * @struts.action-forward name="scps3" path="/G_scps3.jsp"
 */
public class G_GoSNPS3Action extends Action {
	private G_IRoadwayService roadwayService;
	private G_IRegisterInfoService registerInfoService;
	/*
	 * Generated Methods
	 */

	public G_IRoadwayService getRoadwayService() {
		return roadwayService;
	}

	public void setRoadwayService(G_IRoadwayService roadwayService) {
		this.roadwayService = roadwayService;
	}

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		String driverName=request.getParameter("hdriverName");
		String truckNum=request.getParameter("htruckNum");
		int driverId=Integer.parseInt(request.getParameter("hdriverId"));
		int truckId=Integer.parseInt(request.getParameter("htruckId"));
		int roadType=Integer.parseInt(request.getParameter("hroadType"));
		Date date=Calendar.getInstance().getTime();
		DateFormat df=new SimpleDateFormat("yyyy-MM-dd");
		String dateString=df.format(date);
		G_RoadwayVO vo=new G_RoadwayVO();
		vo.setDriverId(driverId);
		vo.setDriverName(driverName);
		vo.setRoadStartDate(date);
		vo.setRoadType(roadType);
		vo.setTruckId(truckId);
		vo.setTruckNum(truckNum);
		vo.setDateString(dateString);
		roadwayService.addRoadway(vo);
//		String[] registerIds=request.getParameter("hRGID").split("/");
//		for (int i = 0; i < registerIds.length; i++) {
//			if(!registerIds[i].equals("null")){
//				long registerGlideId=Long.parseLong(registerIds[i].trim());
//				registerInfoService.changeRegisterState(registerGlideId);
//			}
//		}
		request.getSession().setAttribute("info", vo);
		return mapping.findForward("scps3");
	}

	public G_IRegisterInfoService getRegisterInfoService() {
		return registerInfoService;
	}

	public void setRegisterInfoService(G_IRegisterInfoService registerInfoService) {
		this.registerInfoService = registerInfoService;
	}
}