package com.yem.wm.im.orderproreqbill.op;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.args.AfterOperationArgs;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;

/**
 * @author ljw
 * @date 2024/8/29 10:26
 * @description orderproreqbillcancelstatusOp
 */
public class orderproreqbillcancelstatusOp extends AbstractOperationServicePlugIn {
    @Override
    public void afterExecuteOperationTransaction(AfterOperationArgs e) {
        super.afterExecuteOperationTransaction(e);
        DynamicObject[] dataEntities = e.getDataEntities();
        for (DynamicObject dataEntity : dataEntities) {
            long aLong = dataEntity.getLong("id");
            DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle("yem_orderproreqbill", "id,number,yem_cancelstatus,yem_flowinstid,yem_forminstid,yem_contremark"
                    , new QFilter[]{new QFilter("id", QCP.equals, aLong)});
            String yemCancelstatus = dynamicObject.getString("yem_cancelstatus");
            if (yemCancelstatus.equals("B")){
                dynamicObject.set("yem_flowinstid",null);
                dynamicObject.set("yem_forminstid",null);
            }
            SaveServiceHelper.save(new DynamicObject[]{dynamicObject});
            SaveServiceHelper.update(dynamicObject);
        }
    }
}
