package nckd.jxccl.hr.hstu.plugin.operate;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.args.BeginOperationTransactionArgs;
import kd.sdk.plugin.Plugin;
import nckd.jxccl.hr.hstu.business.helper.HonorStudentHelper;

import java.util.ArrayList;
import java.util.List;

/**
* 【优秀生】-综合测评问卷-获取评分结果
* @author W.Y.C
* @date 2025/8/15 17:24
* @version 1.0
*/
public class EvalQuestGetScoreOperationPlugin extends AbstractOperationServicePlugIn implements Plugin {

    @Override
    public void beginOperationTransaction(BeginOperationTransactionArgs e) {
        DynamicObject[] selectedRows = e.getDataEntities();
        if (selectedRows != null && selectedRows.length > 0) {
            List<Long> selectedRowIds = new ArrayList<>(selectedRows.length);
            for (DynamicObject row : selectedRows) {
                // 获取单据ID（主键）
                Long id = (Long) row.getPkValue();
                selectedRowIds.add(id);
            }
            HonorStudentHelper.updateQuestResult(selectedRowIds.toArray(new Long[0]));
        }
    }
}