package weaver.interfaces.htsc.glpt;

import com.customization.htsc.cus.ITManagementPlatformCmd;
import com.weaver.general.BaseBean;
import com.weaver.general.Util;
import weaver.conn.RecordSet;
import weaver.interfaces.htsc.comInfo.PropBean;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

/**
 * @Title: ecology-9
 * @Company: 泛微软件
 * @author: K1810039
 * @version: 1.0
 * @CreateDate: 2022-06-13
 * @Description: 联合IT需求管理平台流程/联合IT测试和上线申请流程，调用上游接口同步流程状态
 * @ModifyLog:
 **/
public class SyncStateAction extends BaseBean implements Action {

    @Override
    public String execute(RequestInfo requestInfo) {
        writeLog("--------SyncStateAction--------");
        try {
            String requestid = requestInfo.getRequestid();
            String workflowid = String.valueOf(requestInfo.getRequestManager().getWorkflowid());
            String tablename = requestInfo.getRequestManager().getBillTableName();
            writeLog("requestid -->" + requestid + ", workflowid -->" + workflowid + ", tablename -->" + tablename);
            //RecordSet rs = new RecordSet();
            //String sql = "";
            //String nodeStatus = "";
            String oaStatus = "3";
            String dt = "";

            PropBean pb = new PropBean();
            String itxqglpt_workflowid = pb.getPropName("itxqglpt_workflowid");
            String itcshsxsqglpt_workflowid = pb.getPropName("itcshsxsqglpt_workflowid");
            writeLog("IT需求管理平台流程---itxqglpt_workflowid"+itxqglpt_workflowid);
            writeLog("IT测试和上线申请流程---itcshsxsqglpt_workflowid"+itcshsxsqglpt_workflowid);

            if(workflowid.equals(itxqglpt_workflowid)){
                dt = tablename + "_dt7";
            }else if (workflowid.equals(itcshsxsqglpt_workflowid)){
                dt = tablename + "_dt4";
            }

            // 获取节点类型  (因为只需要在传办结的状态，配置在办结节点前，所以不需要这段代码获取节点类型了)
            //sql = "select CURRENTNODETYPE from WORKFLOW_REQUESTBASE where REQUESTID = " + requestid;
            //writeLog(sql);
            //rs.execute(sql);
            //if (rs.next()){
            //    nodeStatus = Util.null2String(rs.getString("CURRENTNODETYPE"));
            //}
            //
            //if ("1".equals(nodeStatus) || "2".equals(nodeStatus)){
            //    // 1-审批中，2-终止，3-办结
            //    oaStatus = "1";
            //}else if ("3".equals(nodeStatus) ){
            //    oaStatus = "3";
            //}else{
            //    return Action.SUCCESS;
            //}

            String result = "";
            ITManagementPlatformCmd itManagementPlatformCmd = new ITManagementPlatformCmd();
            result = itManagementPlatformCmd.getUnnumberAndXqhb(workflowid,tablename,dt,requestid,oaStatus);
            writeLog("--------SyncStateAction----workflowid:" + workflowid + "----" + result);

            return Action.SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return Action.FAILURE_AND_CONTINUE;
        }
    }
}
