📄 execaction.java
字号:
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 ExecAction extends Action
{
public ActionForward perform(ActionMapping mapping,
ActionForm form, HttpServletRequest req,
HttpServletResponse res)
{
// 检查session是否超时
// ActionForward checkForword = Tools.checkSession(req,res);
// 得到操作标识operatorflag
String operatorflag = ((ExecForm) form).getOperatorflag();
// 计算考评结果
if (operatorflag.equalsIgnoreCase("EVALUATE_DO"))
{
return doEvaluate(mapping, form, req, res);
}
//保存考评结果
else if (operatorflag.equalsIgnoreCase("EVALUATE_SAVE"))
{
return saveEvaluate(mapping,form,req,res);
}
//取消考评结果
else if (operatorflag.equalsIgnoreCase("EVALUATE_CANCELRESULT"))
{
return cancelEvaluate(mapping,form,req,res);
} //查询考评结果
else if (operatorflag.equalsIgnoreCase("EVALUATE_QUERY"))
{
return queryEvaluate(mapping,form,req,res);
}
//转到错误页面,错误码 ErrorCode.unKnownError;
else
{
req.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
return(mapping.findForward("error"));
}
}
/****************************************************
* 进行综合考评结果计算
****************************************************/
private ActionForward doEvaluate (ActionMapping mapping,
ActionForm form, HttpServletRequest req,
HttpServletResponse res)
{
//业务代表ID、业务代表组、考评规则、考评名称、考评种类、开始时间、结束时间、考评说明
String staffno = ((ExecForm) form).getStaffno();
String groupid = ((ExecForm) form).getGroupid();
String ruleid = ((ExecForm) form).getRuleid();
String title = ((ExecForm) form).getTitle();
String evatypeid = ((ExecForm) form).getEvatypeid();
String begintime = ((ExecForm) form).getBegintime();
String endtime = ((ExecForm) form).getEndtime();
String detail = ((ExecForm) form).getEvadetail();
String groupIds = ((ExecForm) form).GetGroupIds();
String staffIds = ((ExecForm) form).GetStaffIds();
if (begintime != null)
{
begintime = begintime.replaceAll("-","");
}
if (endtime != null)
{
endtime = endtime.replaceAll("-","");
}
if (staffIds != null)
{
staffIds = staffIds.replaceAll(",","#");
}
if (groupIds != null)
{
groupIds = groupIds.replaceAll(",","#");
}
SysDbConn aplcoms = null ;
try
{
//连接数据源
aplcoms = SysConnPool.getInstance().getAplComs();
if (groupIds != null && !(groupIds.equals("")))
{
aplcoms.preparedSP();
aplcoms.setString(1,groupIds);
SysDataSet ds1 = aplcoms.csCommonSP("P_agt_GroupToStaff");
SysRecord rc1 = ds1.getParamSet() ;
if (rc1!=null && rc1.getInt(0) == 0 && !(rc1.getString(1).equals("")))
{
if ( staffIds == null || staffIds.equals(""))
{
staffIds = rc1.getString(1);
}
else
{
staffIds = staffIds + "#" + rc1.getString(1);
}
}
else
{
req.setAttribute("errorId",ErrorCode.SYNEVA_EXECGROUPTOSTAFF);
return(mapping.findForward("error"));
}
}
aplcoms.preparedSP();
//获得输入参数staffno、groupid、ruleid、title、evatypeid、begintime、endtime,detail
aplcoms.setString(1,staffIds);
aplcoms.setString(2,ruleid);
aplcoms.setString(3,title);
aplcoms.setString(4,evatypeid);
aplcoms.setString(5,begintime);
aplcoms.setString(6,endtime);
aplcoms.setString(7,detail);
//调用P_Agt_doEvaluate计算考评结果
SysDataSet ds1 = aplcoms.csCommonSP("P_agt_doEvaluate");
SysRecord rc1 = ds1.getParamSet() ;
if (rc1!=null && rc1.getInt(0) == 0)
{
aplcoms.preparedQuery("");
SysResultSet rs2 = aplcoms.csCommonQuery("SQL_AGT_EVATEMPRESULT","1","-1").getResultSet();
//if (rs 不为空)
if (rs2 != null)
{
//按业务代表ID排序
rs2.sort(0,true);
//将结果集放到session中 EVALUATE-TEMPRESULT
req.getSession().setAttribute("EVALUATE-TEMPRESULT",new ResUtil(rs2));
return (mapping.findForward("resultconfirm"));
}
else
{
req.setAttribute("errorId",ErrorCode.SYNEVA_EXECSHOWRESULT);
return(mapping.findForward("error"));
}
}
else
{
req.setAttribute("errorId",ErrorCode.SYNEVA_EXECDOEVA);
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 saveEvaluate (ActionMapping mapping,
ActionForm form, HttpServletRequest req,
HttpServletResponse res)
{ //考评ID
String evaidarray[] = ((ExecForm) form).getEvaidarray();
//将数组中的每个字符串以#分割,赋给idstring
String idstring = "";
for (int i=0; i < evaidarray.length ;i++)
{
if (idstring == "")
{
idstring = evaidarray[i];
}
else
{
idstring = idstring + "#" + evaidarray[i];
}
}
SysDbConn aplcoms = null ;
try
{
//连接数据源
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -