package nckd.jimin.jyyy.hr.wtc.wtte.formplugin.web.attcalculate;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.utils.ObjectUtils;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.hr.hbp.formplugin.web.HRDataBaseEdit;

import java.util.EventObject;
/**
 * Tyx
 * 2025-09-05 新增核算时默认弹性方案
 */
public class CalculateTaskPluginEx extends HRDataBaseEdit {
    private static String ACCOUNTPLAN = "wtp_accountplan";

    @Override
    public void afterCreateNewData(EventObject e) {
        super.afterCreateNewData(e);
        //查询一下弹性方案的ID
        QFilter filter = new QFilter("number", QCP.equals, "1040_S");
        filter.and("iscurrentversion", QCP.equals, "1");
        DynamicObject dyn = QueryServiceHelper.queryOne(ACCOUNTPLAN, "id", new QFilter[]{filter});
        if(!ObjectUtils.isEmpty(dyn)) {
            this.getView().getModel().setValue("planid", dyn.getLong("id"));
        }
    }
}
