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

import com.yem.wm.im.clientdemand.validator.ClientDemandValidator;
import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.operate.result.OperationResult;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.AddValidatorsEventArgs;
import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.plugin.args.EndOperationTransactionArgs;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;

//import static com.yem.wm.es.salesorder.utils.SalesOrderUtils.genTradeTerms;

/**
 * @author 张立攀
 * @version 1.0
 * @description  客户需求单保存服务插件
 * @date 2023-07-22 14:56
 */
public class DetailedinforSavePlugin extends AbstractOperationServicePlugIn{

    @Override
    public void onPreparePropertys(PreparePropertysEventArgs e) {
        e.getFieldKeys().add(ClientDemandValidator.billtypes);
        e.getFieldKeys().add(ClientDemandValidator.materialclass);
        e.getFieldKeys().add("yem_im_detailedinfor");

    }
    @Override
    public void onAddValidators(AddValidatorsEventArgs e) {
        e.addValidator(new ClientDemandValidator());
    }

    @Override
    public void endOperationTransaction(EndOperationTransactionArgs e) {
        super.endOperationTransaction(e);
        if ("save".equals(e.getOperationKey())) {
            DynamicObject[] bills = e.getDataEntities();
            for (DynamicObject bill : bills) {
//                genTradeTerms(bill);
                SaveServiceHelper.update(bill);

            }
        }
    }
}
