pathinfopcoessoldimpl.java

来自「公司自己开发的工作流引擎」· Java 代码 · 共 242 行

JAVA
242
字号
package cn.com.iaspec.workflow.helper.pathinfo;

import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import cn.com.iaspec.workflow.vo.workflow.NextActivityInfo;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspWriter;
import cn.com.iaspec.workflow.vo.workflow.UserInfo;
import java.util.List;
import cn.com.iaspec.workflow.helper.WorkflowHelper;
import cn.com.iaspec.workflow.vo.workflow.ActivityParameterValue;
import cn.com.iaspec.workflow.util.FlowWebKeys;
import org.apache.log4j.Logger;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.Tag;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: iASPEC Technologies</p>
 *
 * @author xiesonglin
 * @version 1.5
 */
public class PathInfoPcoessOldImpl
    implements PathInfoPcoessInterface{
  private static Logger logger=Logger.getLogger(PathInfoPcoessOldImpl.class);
  public PathInfoPcoessOldImpl(){
  }

  public int process(PageContext pageContext)
      throws JspException{
    logger.info("begin doEndTag...");
    JspWriter out=pageContext.getOut();
    HttpServletRequest request=(HttpServletRequest)pageContext.getRequest();
    //取得工作项id
    String workItemId="";
    if(request.getAttribute("wf_workitem_id")!=null){
      workItemId=(String)request.getAttribute("wf_workitem_id");
    }
    else{
      workItemId=(String)request.getParameter("wf_workitem_id");
    }
    //取得项目id
    String projectId="";
    if(request.getAttribute("wf_project_id")!=null){
      projectId=(String)request.getAttribute("wf_project_id");
    }
    else{
      projectId=(String)request.getParameter("wf_project_id");
    }

    //取得申诉登记号
    String businessId="";
    if(request.getAttribute("wf_business_id")!=null){
      businessId=(String)request.getAttribute("wf_business_id");
    }
    else{
      businessId=request.getParameter("wf_business_id")==null?"":
          request.getParameter("wf_business_id");
    }
    //是否是启动工作流
    String startWorkflowTag=request.getParameter("wf_start_workflow_tag")==null?
        "0":request.getParameter("wf_start_workflow_tag");
    //取得用户信息
    HttpSession session=request.getSession(false);
    UserInfo userInfo=(UserInfo)session.getAttribute(FlowWebKeys.USER_SESSION);
    if(workItemId==null||workItemId.equals("")){
      throw new JspException("工作项id为空");
    }
    //取得父流程实例id
    String parentProInstId="";
    if(request.getAttribute("wf_parent_process_instance_id")!=null){
      parentProInstId=(String)request.getAttribute(
          "wf_parent_process_instance_id");
    }
    else{
      parentProInstId=(String)request.getParameter(
          "wf_parent_process_instance_id");
    }

    //取得辅助子流程标识
    String aidSubflowTag="";
    if(request.getAttribute("wf_aid_subflow_tag")!=null){
      aidSubflowTag=(String)request.getAttribute("wf_aid_subflow_tag");
    }
    else{
      aidSubflowTag=(String)request.getParameter("wf_aid_subflow_tag");
    }
    //取得所属行政区
    String caseAreaId="02";
    NextActivityInfo nextInfo=null;
    WorkflowHelper helper=new WorkflowHelper();
    try{
      //检出工作项
      helper.checkOutWorkItem(userInfo,Long.parseLong(workItemId));

      //取得当前及下一活动信息
      //返回活动节点的对象NextActivityInfod对象(根据userinfo和工作项的ID:workItemID查询)
      nextInfo=helper.getNextActivityInfo(userInfo,Long.parseLong(workItemId));
    }
    catch(Exception ex){
      throw new JspException(ex.getMessage());
    }
    try{
      if(nextInfo==null){
        out.println("没有取到流向信息。");
        return Tag.EVAL_PAGE;
      }
      //取得当前结点的流程实例ID
      long pro_instance_id=0;
      //取得活动实例ID
      long activity_instance_id=0;
      if(nextInfo!=null){
        pro_instance_id=nextInfo.getProcInstID();
        activity_instance_id=nextInfo.getActivityInstanceID();
      }

      out.println("<input type=\"hidden\" name=\"wf_project_id\" value=\""+
          projectId+"\">");
      out.println(
          "<input type=\"hidden\" name=\"wf_curr_activity_name\" value=\""+
          nextInfo.getActivityName().trim()+"\">");
      out.println("<input type=\"hidden\" name=\"wf_workitem_id\" value=\""+
          workItemId+"\">");
      out.println("<input type=\"hidden\" name=\"wf_business_id\" value=\""+
          businessId+"\">");
      out.println(
          "<input type=\"hidden\" name=\"wf_start_workflow_tag\" value=\""+
          startWorkflowTag+"\">");
      out.println(
          "<input type=\"hidden\" name=\"wf_process_instance_id\" value=\""+
          pro_instance_id+"\">");
      out.println(
          "<input type=\"hidden\" name=\"wf_activity_instance_id\" value=\""+
          activity_instance_id+"\">");
      out.println(
          "<input type=\"hidden\" name=\"wf_parent_process_instance_id\" value=\""+
          parentProInstId+"\">");
      out.println("<input type=\"hidden\" name=\"wf_aid_subflow_tag\" value=\""+
          aidSubflowTag+"\">");
      out.println("<input type=\"hidden\" name=\"case_area_id\" value=\""+
          caseAreaId+"\">");
      String fromRecord=request.getParameter("wf_from_workitem_record")==null?
          "0":request.getParameter("wf_from_workitem_record");
      if(fromRecord!=null&&fromRecord.equals("1")){
        return Tag.EVAL_PAGE;
      }
      out.println("<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">");
      out.println("<tr class=\"text\">");
      out.println("<td width=\"9%\" height=\"25\" align=\"right\" nowrap class=\"text\">&nbsp;&nbsp;请选择流向: </td>");

      //取的流向选择方式(多选,单选)
      String selectType="radio";
      if(nextInfo.getAtd_split()==2){
        selectType="checkbox";
      }
      request.setAttribute("selectType",Integer.toString(nextInfo.getAtd_split()));
      List nextList=nextInfo.getNextActivity();
      if(nextList!=null){
        for(int i=0;i<nextList.size();i++){
          String selectTag="";
          if(i==0){
            selectTag=" checked ";
          }
          NextActivityInfo nextSubInfo=(NextActivityInfo)nextList.get(i);
          logger.info("ActivityName is:"+nextSubInfo.getActivityName()+
              " actType is:"+nextSubInfo.getActType());
          //取得orgRel,actorSelMode
          List paramList=nextSubInfo.getActivityParametervalue();
          String org=this.getParamValue(paramList,"orgRel");
          String actorSelMode=this.getParamValue(paramList,"actorSelMode");
          String senderMode=this.getParamValue(paramList,"senderMode");
          String noSelActorPromptType=nextSubInfo.getNoSelActorPromptType();
          long subActId=0;
          int tranType=nextSubInfo.getTranType();

          //如果是嵌套子流程,则取得子流程的首节点信息
          NextActivityInfo subflowInfo=nextSubInfo.getFirstNestingActivity();
          if(nextSubInfo.getActType()==2&&subflowInfo!=null){
            List subParamList=subflowInfo.getActivityParametervalue();
            org=this.getParamValue(subParamList,"orgRel");
            actorSelMode=this.getParamValue(subParamList,"actorSelMode");
            tranType=subflowInfo.getTranType();
            senderMode=this.getParamValue(subParamList,"senderMode");
            subActId=subflowInfo.getActivityID();
            logger.info("subflow first act info org is:"+org+
                " actorSelMode is:"+actorSelMode+" tranType is:"+tranType+
                " senderMode is:"+senderMode+" subActId is:"+subActId);
          }
          logger.info("org is:"+org+" actorSelMode is:"+actorSelMode+
              " tranType is:"+tranType);
          out.println("<td width=\"9%\" nowrap><span class=\"style2\">"+
              "<input name=\"flow_activity_selected\" actName='"+
              nextSubInfo.getATP_APRTINAME()+"' tranType='"+tranType+
              "' actId='"+nextSubInfo.getActivityID()+"' subActId='"+subActId+
              "' selectType='"+selectType+"' orgRel='"+org+"' actorSelMode='"+
              actorSelMode+"' senderMode='"+senderMode+
              "' noSelActorPromptType='"+noSelActorPromptType+"' actType='"+
              nextSubInfo.getActType()+"' type=\""+selectType+"\" "+selectTag+
              " onClick=\"seleActor(this)\" value=\""+nextSubInfo.getActivityID()+
              "\"><span class=\"style7\">"+nextSubInfo.getATP_APRTINAME()+
              "<span class=\"style2\"></span></td>");
          out.println("<input type=\"hidden\" id=\"participator_"+
              nextSubInfo.getActivityID()+"\" name=\"participator_"+
              nextSubInfo.getActivityID()+"\">");
          out.println("<input type=\"hidden\" id=\"variable_"+
              nextSubInfo.getActivityID()+"\" name=\"variable_"+
              nextSubInfo.getActivityID()+"\">");
        }
        out.println("<td>&nbsp;&nbsp;</td>");
        out.println("</tr>");
        out.println("</table>");
      }
    }
    catch(Exception ex){
      throw new JspException(ex);
    }

    return Tag.EVAL_PAGE;
  }

  private String getParamValue(List paramList,String paramName){
    String returnValue="";
    if(paramList!=null){
      for(int j=0;j<paramList.size();j++){
        ActivityParameterValue param=(ActivityParameterValue)paramList.get(j);
        if(param.getAtr_variablename().equals(paramName)){
          returnValue=param.getAtr_stringvalue();
          break;
        }
      }
    }
    return returnValue;
  }

}

⌨️ 快捷键说明

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