package weaver.formmode.recruit.modeexpand.process;

import weaver.conn.RecordSet;
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
import weaver.general.BaseBean;
import weaver.soa.workflow.request.RequestInfo;

import java.util.HashMap;
import java.util.Map;

/**
 * @author:dxfeng
 * @createTime: 2024/07/15
 * @version: 1.0
 */
public class UpdateFlowStageModeExpand extends AbstractModeExpandJavaCodeNew {
    @Override
    public Map<String, String> doModeExpand(Map<String, Object> param) {
        Map<String, String> result = new HashMap<>();
        try {
            String billId;
            RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo");
            if (requestInfo != null) {
                billId = requestInfo.getRequestid();
                int flowId = -1;
                RecordSet rs = new RecordSet();
                rs.executeQuery("select zplc from uf_jcl_zpjdsz where id = ? ", billId);
                if(rs.next()) {
                    flowId = rs.getInt("zplc");
                }
                // 开始阶段
                if (-1 != flowId) {
                    // 更新流程表单的阶段ID
                    StageDataInsert.updateFlowStageId(flowId);
                }
            }
        } catch (Exception e) {
            new BaseBean().writeLog(e);
            result.put("errmsg", e.getMessage());
            result.put("flag", "false");
        }
        return result;
    }
}
