package weaver.interfaces.ythpt.workflow;

import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

/**
 * 审批复核 归档Action
 *
 * @author:dxfeng
 * @createTime: 2025/04/09
 * @version: 1.0
 */
public class LegalReviewAction implements Action {

    @Override
    public String execute(RequestInfo requestInfo) {
        BaseBean bb = new BaseBean();
        RecordSet rs = new RecordSet();
        try {
            int requestId = Util.getIntValue(requestInfo.getRequestid());
            String formTableName = requestInfo.getRequestManager().getBillTableName();
            User user = requestInfo.getRequestManager().getUser();
            String userId = String.valueOf(user.getUID());

            String bdbh = "";
            String ay = "";
            int zlcid = 0;
            String dsr = "";
            String zfry = "";
            String bsrq = "";
            String jbqk = "";
            String nzcdjdyj = "";
            String shyj = "";
            String shr = "";
            String shrq = "";
            String mainId = "";
            String sql = "select * from " + formTableName + " where requestid=" + requestId;
            rs.executeQuery(sql);
            if (rs.next()) {
                zlcid = Util.getIntValue(Util.null2String(rs.getString("zlcid")));
                bdbh = Util.null2String(rs.getString("bdbh"));
                ay = Util.null2String(rs.getString("ay"));
                dsr = Util.null2String(rs.getString("dsr"));
                zfry = Util.null2String(rs.getString("zfry"));
                bsrq = Util.null2String(rs.getString("bsrq"));
                jbqk = Util.null2String(rs.getString("jbqk"));
                nzcdjdyj = Util.null2String(rs.getString("nzcdjdyj"));
                shyj = Util.null2String(rs.getString("shyj"));
                shr = Util.null2String(rs.getString("shr"));
                shrq = Util.null2String(rs.getString("shrq"));
                mainId = Util.null2String(rs.getString("mainId"));
            }

            if(StringUtils.isNotBlank(mainId)){
                sql = " select * from "+formTableName+"_dt1 where mainid = "+mainId+" order by id";
                rs.executeQuery(sql);
                while (rs.next()){
                    String glscx = Util.null2String(rs.getString("glscx"));
                }
            }

        } catch (Exception e) {
            bb.writeLog(e);
            requestInfo.getRequestManager().setMessageid("1111");
            requestInfo.getRequestManager().setMessagecontent(e.getMessage());
            return FAILURE_AND_CONTINUE;
        }
        return SUCCESS;
    }

}
