package weaver.interfaces.htsc.seal;

import com.engine.common.util.ServiceUtil;
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 SealChangeLaunchAction extends BaseBean implements Action {

    @Override
    public String execute(RequestInfo requestInfo) {
        RecordSet rs = new RecordSet();
        RecordSet rs2 = new RecordSet();
        String requestid = requestInfo.getRequestid();
        String tablename = requestInfo.getRequestManager().getBillTableName();//主表
        writeLog("----SealChangeLaunchAction-------" + requestid);
        try{
            String mainid = "";
            String gllc = "";
            String sql = "select id,gllc from "+tablename+" where requestid = '"+requestid+"'";
            writeLog(sql);
            rs.executeQuery(sql);
            if(rs.next()){
                mainid = Util.null2String(rs.getString("id"));
                gllc = Util.null2String(rs.getString("gllc"));
            }

            sql = "select wjmc from "+tablename+"_dt1 where mainid = '"+mainid+"'";
            writeLog(sql);
            rs.executeQuery(sql);
            while(rs.next()){
                String wjmc = Util.null2String(rs.getString("wjmc"));
                String update_sql = "update uf_yyxx set wjzt = '1' where gllc in ("+gllc+") and (yywj = '"+wjmc+"' or ywj = '"+wjmc+"')";
                writeLog(update_sql);
                rs2.executeUpdate(update_sql);
            }
            return Action.SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            writeLog( "异常参考:" + e );
            requestInfo.getRequestManager().setMessageid( "111111" );
            requestInfo.getRequestManager().setMessagecontent( "流程提交失败" );
            return Action.FAILURE_AND_CONTINUE;
        }
    }
}
