package com.yem.wm.es.salescontrac.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/9/23 10:46
 * @description SalesContracAuditOp
 */
public class SalesContracAuditOp extends AbstractOperationServicePlugIn {
    @Override
    public void afterExecuteOperationTransaction(AfterOperationArgs e)
    {
        super.afterExecuteOperationTransaction(e);
        DynamicObject[] entities = e.getDataEntities();
        for (DynamicObject entity : entities) {
            DynamicObject load = BusinessDataServiceHelper.loadSingle(entity.getPkValue(), entity.getDynamicObjectType().getName());
            String billstatus = load.getString("billstatus");
            if ("C".equals(billstatus)) {
                // 衣晓明
                DynamicObject user = BusinessDataServiceHelper.loadSingle("bos_user", new QFilter[]{new QFilter("number", QCP.equals, "10437")});
                if (user != null) {
                    String signature = user.getString("yem_signature");
                    load.set("yem_managersign", signature);
                }
                SaveServiceHelper.save(new DynamicObject[]{load});
            }
        }
    }
}
