package weaver.interfaces.htxc.zbhb;

import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans;
import weaver.general.BaseBean;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

/**
 * 这个接口是用来拟稿提交后，将主表的会签部门存入dt2，跨公司会签存入dt3
 */
public class InsertDt2Dt3 extends BaseBean implements Action {
    public String p1; //自定义参数1
    public String p2; //自定义参数2
    @Override
    public String execute(RequestInfo requestinfo) {
        try{
            String requestid = requestinfo.getRequestid();//请求ID
            String tablename = requestinfo.getRequestManager().getBillTableName();//表单名称
            RecordSet rs = new RecordSet();
            RecordSetTrans rst = new RecordSetTrans();
            String mainSql = "select bmhq,kgsldsp from " + tablename+" where requestid = "+requestid;
            rs.execute(mainSql);
            if(rs.next()){
                String id = rs.getString("id");
                String bmhq = rs.getString("bmhq");
                String kgsldsp = rs.getString("kgsldsp");
                String dt2Sql = "insert into "+tablename+"_dt2 (mainid,hqbm,yhq)values('"+id+"','"+bmhq+"')";
                rst.execute(dt2Sql);
                String dt3Sql = "insert into "+tablename+"_dt3 (mainid,bmfzr)values('"+id+"','"+kgsldsp+"')";
                rst.execute(dt3Sql);
            }
        }catch (Exception e){
            return Action.FAILURE_AND_CONTINUE;
        }
        return Action.SUCCESS;
    }
}
