package com.yem.ia.intebilllogon.form;

import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.exception.KDBizException;
import kd.bos.form.events.AfterDoOperationEventArgs;
import kd.bos.servicehelper.BusinessDataServiceHelper;


import java.math.BigDecimal;

/**
 * @author zhouc
 * @date 2023/8/21 17:02
 * @className demoFromPlugin
 * @description 测试分录2000行复制效果
 */
public class demoFromPlugin extends AbstractBillPlugIn {
    public void afterDoOperation(AfterDoOperationEventArgs e) throws KDBizException {
        super.afterDoOperation(e);
        String key = e.getOperateKey();
        IDataModel model = this.getModel();
        DynamicObject dataEntity = this.getModel().getDataEntity(true);
        if (key.equals("getdata")) {
            DynamicObjectCollection yem_es_materialinfo = dataEntity.getDynamicObjectCollection("yem_es_materialinfo");
            for(int i = 0; i<2000;i++){
            DynamicObject materialinfo = yem_es_materialinfo.addNew();
            DynamicObject yem_materiel = BusinessDataServiceHelper.loadSingle("1743600105086258176", "bd_material");
            materialinfo.set("yem_materiel", yem_materiel);
            materialinfo.set("yem_materialname", "弯板");
            materialinfo.set("yem_materialenname", "弯板");
            DynamicObject yem_unit = BusinessDataServiceHelper.loadSingle("1735648786161600512", "bd_measureunits");
            materialinfo.set("yem_unit", yem_unit);
            materialinfo.set("yem_qty", new BigDecimal(1));
            materialinfo.set("yem_baseunit", yem_unit);
            materialinfo.set("yem_price", new BigDecimal(2));
            materialinfo.set("yem_amt", new BigDecimal(2));
            }
            this.getView().updateView("yem_es_materialinfo");
        }
    }
}
