package com.awspaas.user.apps.donenow_ctt.event;

import com.actionsoft.bpms.bo.engine.BO;
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener;
import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.exception.BPMNError;
import com.actionsoft.sdk.local.SDK;

import java.sql.Connection;

public class costProductFormAfterSave extends ExecuteListener {
    public String getDescription() {
        return "合同产品新增后，创建采购审批";
    }

    /**
     *
     * @param processExecutionContext
     * @throws Exception
     */
    @Override
    public void execute(ProcessExecutionContext processExecutionContext) throws Exception {

        Connection conn = null;
        try {
            conn = DBSql.open();
            conn.setAutoCommit(false);

            BO costBO = processExecutionContext.getBO("BO_EU_DNCTT_CONTRACT_COST");// 获取合同产品BO
            costBO.set("STATUS_ID", "1234");//待采购/待拣货
            SDK.getBOAPI().update("BO_EU_DNCTT_CONTRACT_COST", costBO,conn);


            conn.commit();
        } catch (Exception e) {
            conn.rollback();
            throw new BPMNError("550", "库存转移失败");
        } finally {
            DBSql.close(conn);
        }

    }
}
