package weaver.formmode.recruit.modeexpand.demandmanage;

import com.engine.recruit.enums.RecruitStatusEnum;
import weaver.conn.RecordSet;
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.soa.workflow.request.RequestInfo;
import weaver.workflow.workflow.WorkflowBillComInfo;

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

/**
 * <p>聚才林招聘</p>
 * 开启需求
 * <p>开启需求——状态为进行中，置空完成日期和结束日期</p>
 *
 * @author:dxfeng
 * @createTime: 2023/09/13
 * @version: 1.0
 */
public class RecruitStartModeExpand extends AbstractModeExpandJavaCodeNew {
    @Override
    public Map<String, String> doModeExpand(Map<String, Object> param) {
        Map<String, String> result = new HashMap<>();
        try {
            int billId;
            int modeId;
            RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo");
            if (requestInfo != null) {
                billId = Util.getIntValue(requestInfo.getRequestid());
                modeId = Util.getIntValue(requestInfo.getWorkflowid());
                if (billId > 0 && modeId > 0) {
                    // 获取表单名称
                    String formId = Util.null2String(param.get("formid"));
                    String tableName = new WorkflowBillComInfo().getTablename(formId);
                    String sql = "update " + tableName + " set xqzt = ? ,jssj = ?,wcsj = ? where id = ?";
                    RecordSet rs = new RecordSet();
                    // 状态为进行中，置空完成日期和结束日期
                    rs.executeUpdate(sql, RecruitStatusEnum.RECRUITMENT_PROGRESS.getValue(), null, null, billId);
                    new BaseBean().writeLog("开启需求操作：billId=[" + billId + "]操作完成");
                }
            }
        } catch (Exception e) {
            new BaseBean().writeLog(e);
            result.put("errmsg", "开启需求操作失败");
            result.put("flag", "false");
        }
        return result;
    }
}
