package com.yem.wm.bc.bill.op;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.AddValidatorsEventArgs;
import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.plugin.args.AfterOperationArgs;
import kd.bos.entity.plugin.args.BeginOperationTransactionArgs;
import kd.bos.entity.plugin.args.EndOperationTransactionArgs;
import kd.bos.servicehelper.operation.SaveServiceHelper;

import java.util.List;

/**
 * @author 夜子
 * @ClassName YemBillAuditOp
 * @description: 外贸基类反审核操作插件
 * @date 2023年08月10日
 * @version: 1.0
 */
public class YemBillUnAuditOp extends AbstractOperationServicePlugIn {

    @Override
    public void onPreparePropertys(PreparePropertysEventArgs e) {
        List<String> fieldKeys = e.getFieldKeys();
        fieldKeys.add("yem_forminstid");
        fieldKeys.add("yem_flowinstid");
        super.onPreparePropertys(e);
    }

    @Override
    public void onAddValidators(AddValidatorsEventArgs e) {
        super.onAddValidators(e);
    }

    @Override
    public void beginOperationTransaction(BeginOperationTransactionArgs e) {
        super.beginOperationTransaction(e);
    }

    @Override
    public void endOperationTransaction(EndOperationTransactionArgs e) {
        super.endOperationTransaction(e);
    }

    @Override
    public void afterExecuteOperationTransaction(AfterOperationArgs e) {
        for (DynamicObject object : e.getDataEntities()) {
            object.set("yem_forminstid",null);
            object.set("yem_flowinstid",null);
            SaveServiceHelper.update(object);
        }
        super.afterExecuteOperationTransaction(e);

    }
}
