package weaver.interfaces.htsc.riskReport;

import com.engine.common.util.ServiceUtil;
import com.engine.htsc.riskReport.service.RiskReportService;
import com.weaver.general.BaseBean;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

public class RiskReportDocConvertToPdf extends BaseBean implements Action {

    @Override
    public String execute(RequestInfo requestInfo) {
        RecordSet rs = new RecordSet();
        String requestid = requestInfo.getRequestid();
        String tablename = requestInfo.getRequestManager().getBillTableName();//主表
        writeLog("----RiskReportDocConvertToPdf-------" + requestid);
        try{
            String sfnbsy = "";//是否内部送阅 0-是 1-否
            String sql = "select sfnbsy from "+tablename+" where requestid = '"+requestid+"'";
            writeLog(sql);
            rs.executeQuery(sql);
            if(rs.next()){
                sfnbsy = Util.null2String(rs.getString("sfnbsy"));
            }

            if("1".equals(sfnbsy)){
                RiskReportService riskReportService = ServiceUtil.getService(RiskReportService.class);
                riskReportService.docConvertToPdf(requestid);
            }

            return Action.SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            writeLog( "异常参考:" + e );
            requestInfo.getRequestManager().setMessageid( "111111" );
            requestInfo.getRequestManager().setMessagecontent( "流程提交失败" );
            return Action.FAILURE_AND_CONTINUE;
        }
    }
}
