package weaver.interfaces.workflow.action.javacode;

import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans;
import weaver.general.StringUtil;
import weaver.interfaces.workflow.action.Action;
import weaver.general.BaseBean;
import weaver.soa.workflow.request.RequestInfo;
/**
 * Online custom action interface
 * 修改流程紧急程度(测试环境)
 */
public class Action20231027060156 extends BaseBean implements Action{
    /**
     * After selecting aciton after the process path node, this method will be executed after the node is submitted.
     */

    public static final String updateReqLevel = "update workflow_requestbase  set requestlevel = 2 where requestid= ?";
    public String execute(RequestInfo request) {


        //1:Log
        writeLog("in my online edited action");

        //2：Exception
        // boolean error=true;
        // if(error) {
        // 	request.getRequestManager().setMessageid("90001");
        // 	request.getRequestManager().setMessagecontent("System Abnormal Termination Process Submission！");
        // }
        //3：Get requestid
        String requestId = request.getRequestid();
        if(StringUtil.isEmpty(requestId)){
            return Action.SUCCESS;
        }
        RecordSetTrans rs = request.getRequestManager() .getRsTrans();
        // RecordSet rs = new RecordSet();
        try {
            // rs.setAutoCommit(false);
            rs.executeUpdate(updateReqLevel,requestId);
            int updateCount = rs.getUpdateCount();
            writeLog("更新条数==>",updateCount);
            // if(updateCount > 1){
            //     // rs.rollback();
            // }else{
            //     // rs.commit();
            // }
        } catch (Exception e) {
            // rs.rollback();
            e.printStackTrace();
        }

        return Action.SUCCESS;
    }
}
