package weaver.interfaces.htsc.payment;

import com.engine.htsc.payment.util.BizUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;
import weaver.workflow.request.RequestManager;

/**
 * k1810012
 * 更新员工慰问流程建模的状态
 * 配置在工会付款流程:
 * 提交节点后: fkzt = 1;
 * 提交节点前: fkzt = 0;
 * 出纳付款完成后: fkzt = 2;
 */
public class StaffCodStatusChange extends BaseBean implements Action {

  //付款状态
  private String fkzt = "";

  @Override
  public String execute(RequestInfo requestInfo) {
    try {
      RequestManager rm = requestInfo.getRequestManager();
      String tableName = rm.getBillTableName();
      String rid = requestInfo.getRequestid();
      writeLog(String.format("更新员工慰问流程建模的状态,requestId: %s", rid));
      RecordSet rs = new RecordSet();
      String sql = String.format("select glygwwsqlc from %s where REQUESTID=?", tableName);
      rs.executeQuery(sql, rid);
      String relWf = "";
      if (rs.next()) {
        relWf = Util.null2String(rs.getString("glygwwsqlc"));
      }
      if ("".equals(relWf)) {
        return SUCCESS;
      }
      BizUtils.updateStaffCodStatus(relWf, fkzt);
      return SUCCESS;
    } catch (Exception e) {
      writeLog("StaffCodStatusChange catch e:" + e.getMessage());
      return FAILURE_AND_CONTINUE;
    }
  }

  public String getFkzt() {
    return fkzt;
  }

  public void setFkzt(String fkzt) {
    this.fkzt = fkzt;
  }
}
