package weaver.interfaces.workflow.action.javacode;

import weaver.conn.BatchRecordSet;
import weaver.conn.RecordSet;
import weaver.general.StringUtil;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.interfaces.workflow.action.Action;
import weaver.general.BaseBean;
import weaver.soa.workflow.request.RequestInfo;

import java.util.ArrayList;

/**
 * Online custom action interface
 */
class Action20240719092807 extends BaseBean implements Action{
    @Override
    public String execute(RequestInfo request) {
        String requestId = request.getRequestid();
        String tablename = request.getRequestManager().getBillTableName();
        RecordSet rs = new RecordSet();
        rs.execute("select * from " + tablename + " where requestid =  " + requestId);
        rs.next();
        String hrmids = rs.getString("hrmids");
        ArrayList<String> hrms = new ArrayList<>();
        // ArrayList<String> deleteParams = new ArrayList<>();
        String[] split = hrmids.split(",");
        for (String s : split) {
            if (!StringUtil.isEmpty(s)){
                hrms.add(s);
            }
        }
        // deleteParams.addAll(hrms);
        String deletesql = "delete uf_yddbmd where ryid = ?";
        BatchRecordSet brs = new BatchRecordSet();
        brs.executeSqlBatchNew(deletesql,hrms);
        return Action.SUCCESS;
    }
}
