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

📄 ruleaction.java

📁 培训考试系统代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.huawei.icd30.agt.synevaluate;

import javax.servlet.http.*;

import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import com.huawei.icd30.agt.util.*;
import com.huawei.icd30.common.db.*;

/**
 * <p> 本类的功能描述信息</p>
 * <p> (这家伙很懒,什么都没有写)</p>
 * <p> </p>
 * <p> </p>
 * @author unascribed
 * @version 1.0
 */

public class RuleAction extends Action
{
     public ActionForward perform(ActionMapping mapping,
       ActionForm form, HttpServletRequest req,
        HttpServletResponse res)
    {
        // 检查session是否超时
  //       ActionForward checkForword = Tools.checkSession(req,res);
 //        得到操作标识operatorflag
        String operatorflag = ((RuleForm) form).getOperatorflag();
        // 根据查询条件查询人员综合考评规则列表
        if (operatorflag.equalsIgnoreCase("RULE_QUERYLIST"))
        {
             return queryRuleList(mapping, form, req, res);
        }
       //根据考评规则ID查询考评规则详细信息
       else if (operatorflag.equalsIgnoreCase("RULE_QUERYDETAIL"))
        {
             return queryRuleDetail(mapping,form,req,res);
        }
        //新增考评规则
         else if (operatorflag.equalsIgnoreCase("RULE_ADD"))
        {
             return newRule(mapping, form, req, res);
        }
        //修改考评规则
      else if (operatorflag.equalsIgnoreCase("RULE_MOD"))
        {
             return modRule(mapping, form, req, res);
        }
       //根据考评规则ID删除考评规则
          else if (operatorflag.equalsIgnoreCase("RULE_DEL"))
        {
             return delRule(mapping, form, req, res);
        }

        //转到错误页面,错误码 ErrorCode.unKnownError;
          else
          {
              req.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
              return(mapping.findForward("error"));
          }

    }
        /****************************************************
         * 根据查询条件查询综合考评规则列表
         ****************************************************/
       private ActionForward queryRuleList (ActionMapping mapping,
       ActionForm form, HttpServletRequest req,
        HttpServletResponse res)
    {
       //得到规则名称、规则说明、转换方法
       String ruletitle = ((RuleForm) form).getRuletitle();
       String rulenote = ((RuleForm) form).getRulenote();
       String methodid = ((RuleForm) form).getMethodid();
       SysDbConn aplcoms = null ;
       try
       {
           //连接数据源
           aplcoms = SysConnPool.getInstance().getAplComs();
           aplcoms.preparedSP();

           //获得输入参数ruletitle、rulenote、methodid
           aplcoms.setString(1,ruletitle);
           aplcoms.setString(2,rulenote);
           aplcoms.setString(3,methodid);

           //调用P_Agt_EvaRuleSearch查询,得到数据集rs1
           SysResultSet rs1 = aplcoms.csCommonSP("P_Agt_RuleSearch").getResultSet();
           rs1.next();
           aplcoms.preparedQuery(rs1.getString(1));
           SysResultSet rs2 = aplcoms.csCommonQuery("SELFSQL","1","-1").getResultSet();
           //if (rs 不为空)
           if (rs2 != null)
           {
            //按业务代表ID排序
            rs2.sort(0,true);
            //将结果集放到session中 RULE-LIST
            req.getSession().setAttribute("RULE-LIST",new ResUtil(rs2));

           //将输入的查询条件传递给页面
            req.setAttribute("ruletitle",ruletitle);
            req.setAttribute("rulenote",rulenote);
            req.setAttribute("methodid",methodid);
            //定向到列表页面rulelist
            return (mapping.findForward("rulelist"));
           }
           else
           {
             req.setAttribute("errorId",ErrorCode.SYNEVA_RULEQUERY);
             return(mapping.findForward("error"));
           }
        }
      catch (SysDbException aple)
      {
        //捕获CommonService系统异常,定向到出错页面,错误码为ErrorCode.COMMONSERVICE_ERROR
          aple.printStackTrace();
          req.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
          return (mapping.findForward("error"));
       }
      catch(java.sql.SQLException sqle)
      {
        //捕获调用aplcoms异常,定向到出错页面,错误码为ErrorCode.DATABASE_ERROR
          sqle.printStackTrace();
          req.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
          return (mapping.findForward("error"));
       }
      catch(Exception e)
      {
        //捕获未知异常,定向到出错页面,错误码为ErrorCode.UNKNOW_ERROR
          e.printStackTrace();
          req.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
          return (mapping.findForward("error"));
       }
      finally
        //关闭连接实例
        {
          if(aplcoms != null)
          {
             aplcoms.close();
          }
        }
    }
        /****************************************************
         *根据考评规则ID查询培训考评规则详细信息
         ****************************************************/
       private ActionForward queryRuleDetail (ActionMapping mapping,
       ActionForm form, HttpServletRequest req,
        HttpServletResponse res)
    {
      String ruleid = ((RuleForm) form).getRuleid();
      SysDbConn aplcoms = null ;
       try
       {
           //连接数据源
           aplcoms = SysConnPool.getInstance().getAplComs();
           aplcoms.preparedQuery("");
           //设置查询参数
           aplcoms.setString(1,ruleid);

          //调用SQL_AGT_QueryRuleDetail查询得到此业务代表的培训档案列表
           SysResultSet rs = new ResUtil(aplcoms.csCommonQuery("SQL_AGT_QueryRuleDetail","1","-1").getResultSet());

          //if (rs 不为空)
           if (rs != null)
           {
            rs.next();
            //将查询结果传递给页面

            req.setAttribute("ruleid",rs.getString(0));
            req.setAttribute("ruletitle",rs.getString(1));
            req.setAttribute("rulenote",rs.getString(2));
            req.setAttribute("dutyratio",rs.getString(3));
            req.setAttribute("workratio",rs.getString(4));
            req.setAttribute("handleratio",rs.getString(5));
            req.setAttribute("qcratio",rs.getString(6));
            req.setAttribute("monitorratio",rs.getString(7));
            req.setAttribute("visitratio",rs.getString(8));
            req.setAttribute("trainratio",rs.getString(9));
            req.setAttribute("methodid",rs.getString(10));
            //定向到列表页面rulemodify
            return (mapping.findForward("rulemodify"));
            }
           else
           {
              req.setAttribute("errorId",ErrorCode.SYNEVA_RULESHOWDETAIL);
              return(mapping.findForward("error"));
           }
        }
      catch (SysDbException aple)
      {
        //捕获CommonService系统异常,定向到出错页面,错误码为ErrorCode.COMMONSERVICE_ERROR
          aple.printStackTrace();
          req.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
          return (mapping.findForward("error"));
       }
      catch(java.sql.SQLException sqle)
      {
        //捕获调用aplcoms异常,定向到出错页面,错误码为ErrorCode.DATABASE_ERROR
          sqle.printStackTrace();
          req.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
          return (mapping.findForward("error"));
       }
      catch(Exception e)
      {
        //捕获未知异常,定向到出错页面,错误码为ErrorCode.UNKNOW_ERROR
          e.printStackTrace();
          req.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
          return (mapping.findForward("error"));
       }
      finally
        //关闭连接实例
        {
          if(aplcoms != null)
          {
             aplcoms.close();
          }
        }
    }

        /****************************************************
         *新增综合考评规则
         ****************************************************/
      private ActionForward newRule (ActionMapping mapping,
       ActionForm form, HttpServletRequest req,
        HttpServletResponse res)
       {
        //得到输入参数
    String operatorflag = ((RuleForm)form).getOperatorflag();
    String ruletitle = ((RuleForm)form).getRuletitle();
    String rulenote = ((RuleForm)form).getRulenote();
    String dutyratio = ((RuleForm)form).getDutyratio();
    String workratio = ((RuleForm)form).getWorkratio();
    String handleratio = ((RuleForm)form).getHandleratio() ;
    String qcratio = ((RuleForm)form).getQcratio();
    String monitorratio = ((RuleForm)form).getMonitorratio();
    String visitratio = ((RuleForm)form).getVisitratio();

⌨️ 快捷键说明

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