package weaver.interfaces.workflow.action.javacode;

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

public class Action20230914101926 extends BaseBean implements Action   {

    public static final String sql = "update workflow_requestlog set  remark= ? ,OPERATEDATE = ? ,OPERATETIME = ?  where requestid = ? and logid = ? ";

    @Override
    public String execute(RequestInfo request) {
        // RecordSetTrans rs = new RecordSetTrans();
        RecordSetTrans rs = request.getRequestManager() .getRsTrans();
        String requestId = request.getRequestid();
        String tablename = request.getRequestManager().getBillTableName();

        try {
            rs.executeQuery("select * from " + tablename + " where requestid =  " + requestId);
        } catch (Exception e) {
            writeLog("查询异常"+e.getMessage());
            e.printStackTrace();
            request.getRequestManager().setMessageid("90001");
            request.getRequestManager().setMessagecontent("查询异常"+e.getMessage());
        }
        rs.next();
        String logid = rs.getString("logid");
        String requestid = rs.getString("request");
        String remarkNew = rs.getString("remarkNew");
        String newdate = rs.getString("newdate");
        String newtime = rs.getString("newtime");
        try {
            writeLog("修改日志sql"+sql);
            writeLog(logid );
            writeLog(logid == null);
            writeLog(requestid);
            writeLog(requestid== null);
            writeLog(remarkNew);
            writeLog(remarkNew== null);
            rs.executeUpdate(sql,remarkNew,newdate,newtime,requestid,logid);
            writeLog("getCounts"+rs.getCounts());
        } catch (Exception e) {
            writeLog("修改异常"+e.getMessage());
            e.printStackTrace();
            request.getRequestManager().setMessageid("90001");
            request.getRequestManager().setMessagecontent("修改异常"+e.getMessage());
        }
        return Action.SUCCESS;
    }

    public static void main(String[] args) {

    }
}
