package nckd.jxccl.hr.ijp.plugin.form.recgen;

import com.google.common.collect.Lists;
import kd.bos.common.enums.EnableEnum;
import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.EntityMetadataCache;
import kd.bos.entity.QueryEntityType;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.entity.operate.result.OperationResult;
import kd.bos.form.ConfirmCallBackListener;
import kd.bos.form.ConfirmTypes;
import kd.bos.form.MessageBoxOptions;
import kd.bos.form.MessageBoxResult;
import kd.bos.form.events.AfterDoOperationEventArgs;
import kd.bos.form.events.MessageBoxClosedEvent;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.hr.hbp.business.servicehelper.HRQueryEntityHelper;
import kd.sdk.plugin.Plugin;
import nckd.jxccl.base.common.constant.FormConstant;
import nckd.jxccl.base.common.enums.AppraisalResultEnum;
import nckd.jxccl.base.common.utils.ConvertUtil;
import nckd.jxccl.base.common.utils.DateUtil;
import nckd.jxccl.base.common.utils.QueryFieldBuilder;
import nckd.jxccl.base.entity.helper.EntityHelper;
import nckd.jxccl.base.hrpi.helper.EmpPosOrgRelHelper;
import nckd.jxccl.base.orm.helper.QFilterCommonHelper;
import nckd.jxccl.hr.ijp.common.IntJobPostConstant;
import nckd.jxccl.hr.psms.common.PerfRankMgmtConstant;
import org.apache.commons.lang3.StringUtils;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

/**
* 三类人员记录生成
* 实体标识：nckd_intjobpost
* @author W.Y.C
* @date 2026/1/7 11:41
* @version 1.0
*/
public class IntJobPostFormPlugin extends AbstractFormPlugin implements Plugin {

    // 常量定义
    private static final int FIVE_YEARS = 5;
    private static final String[] POST_TYPES = {"JTCC_1002", "1010_S"};
    private static final String PERF_MANAGER_ENTRY = "nckd_perfmanagerentry";
    private static final String PERF_MANAGER = "nckd_perfmanager";
    private static final String APPRAISAL_RESULT = "nckd_appraisalresult";
    private static final String APPRAISAL_YEAR = "nckd_appraisalyear";
    private static final String PERSON_FIELD = FormConstant.NCKD_PERSON;
    private static final String[] PERFORMANCE_EVALUATION_TYPES = {"JTCC_1002", "1010_S"}; // 任职类型：上挂/全职任职
    
    @Override
    public void afterDoOperation(AfterDoOperationEventArgs evt) {
        if(evt.getOperationResult() != null && evt.getOperationResult().isSuccess()){
            String operateKey = evt.getOperateKey();
            if(IntJobPostConstant.FETCHEMP_OP.equalsIgnoreCase(operateKey)){
                String talentType = ConvertUtil.toStr(this.getModel().getValue(IntJobPostConstant.NCKD_TALENTTYPE));
                DynamicObject org = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(IntJobPostConstant.NCKD_ORG));
                if(StringUtils.isBlank(talentType)){
                    this.getView().showTipNotification("请先选择人员类别！");
                }else if(org == null){
                    this.getView().showTipNotification("请先选择二级单位！");
                }else{
                    switch (talentType.toUpperCase()) {
                        case "A":
                            getExcellentEmp();
                            break;
                        case "C":
                            getPerformanceEndEmployees();
                            break;
                        default:
                            // 其他类型暂不处理
                            break;
                    }
                }
            }
        }
    }

    @Override
    public void beforePropertyChanged(PropertyChangedArgs e) {
        String name = e.getProperty().getName();
        if (PerfRankMgmtConstant.NCKD_ORG.equalsIgnoreCase(name) || IntJobPostConstant.NCKD_TALENTTYPE.equalsIgnoreCase(name)) {
            ChangeData[] changeSet = e.getChangeSet();
            Object oldValue = changeSet[0].getOldValue();
            Object newValue = changeSet[0].getNewValue();
            if(!Objects.equals(newValue, oldValue)) {
                DynamicObjectCollection entryEntities = getModel().getEntryEntity(PerfRankMgmtConstant.NCKD_ENTRYENTITY);
                boolean hasNonEmptyPerson = entryEntities.stream()
                        .anyMatch(entry -> entry.getDynamicObject(PerfRankMgmtConstant.NCKD_PERSON) != null);
                if(hasNonEmptyPerson) {
                    // 直接弹出确认框，无需回滚
                    // 表单字段修改前交互
                    this.getView().showConfirm(
                            "确认修改【二级组织或员工类别】吗？",
                            "请注意：修改【二级组织或员工类别】会导致员工范围变化会清空现有员工信息。您需要在之后重新生成。确认要修改吗？",
                            MessageBoxOptions.OKCancel,
                            ConfirmTypes.Delete,
                            new ConfirmCallBackListener(PerfRankMgmtConstant.NCKD_ORG, this)
                    );
                }
            }
        }
    }

    @Override
    public void propertyChanged(PropertyChangedArgs e) {
        String name = e.getProperty().getName();
        if (PerfRankMgmtConstant.NCKD_PERSON.equalsIgnoreCase(name)) {
            String talentType = ConvertUtil.toStr(this.getModel().getValue(IntJobPostConstant.NCKD_TALENTTYPE));
            ChangeData[] changeSet = e.getChangeSet();
            int rowIndex = changeSet[0].getRowIndex();
            Object oldValue = changeSet[0].getOldValue();
            Object newValue = changeSet[0].getNewValue();
            if(!Objects.equals(newValue, oldValue) && "B".equalsIgnoreCase(talentType)) {
                // 获取考核结果信息
                LocalDateTime lastYear = DateUtil.minusYears(DateUtil.now(), 1);
                LocalDateTime beforeLastYear = DateUtil.minusYears(DateUtil.now(), 2);
                DynamicObject person = ConvertUtil.toDynamicObject(newValue);
                Map<Long, List<DynamicObject>> perfManagerMap = getPerformanceEvaluationResults(Lists.newArrayList(person.getLong(FormConstant.ID_KEY)));
                if(perfManagerMap != null && perfManagerMap.get(person.getLong(FormConstant.ID_KEY)) != null){
                    List<DynamicObject> perfManagerList = perfManagerMap.get(person.getLong(FormConstant.ID_KEY));
                    for (DynamicObject perfManager : perfManagerList) {
                        Date appraisalYear = perfManager.getDate(APPRAISAL_YEAR);
                        long appraisalResultId = perfManager.getLong(String.join(".", APPRAISAL_RESULT, FormConstant.ID_KEY));
                        String appraisalResultName = perfManager.getString(String.join(".", APPRAISAL_RESULT, FormConstant.NAME_KEY));
                        String appraisalResultNumber = perfManager.getString(String.join(".", APPRAISAL_RESULT, FormConstant.NUMBER_KEY));
                        DynamicObject appraisalResult = EntityHelper.newEntity(FormConstant.NCKD_APPRAISALRESULT, appraisalResultId);
                        appraisalResult.set(FormConstant.NAME_KEY, appraisalResultName);
                        appraisalResult.set(FormConstant.NUMBER_KEY, appraisalResultNumber);
                        if(lastYear.getYear() == DateUtil.getYear(appraisalYear)) {
                            this.getModel().setValue(IntJobPostConstant.NCKD_APPRAISALRESULT, appraisalResult);
                        }
                        if(beforeLastYear.getYear() == DateUtil.getYear(appraisalYear)) {
                            this.getModel().setValue(IntJobPostConstant.NCKD_BEFORELAST, appraisalResult);
                        }
                    }
                }


            }
        }
    }

    @Override
    public void confirmCallBack(MessageBoxClosedEvent evt) {
        super.confirmCallBack(evt);
        if(PerfRankMgmtConstant.NCKD_ORG.equalsIgnoreCase(evt.getCallBackId())){
            // 用户确认：允许修改继续，并清空分录
            if (evt.getResult() == MessageBoxResult.Yes) {
                DynamicObjectCollection entryEntities = getModel().getEntryEntity(PerfRankMgmtConstant.NCKD_ENTRYENTITY);
                entryEntities.clear();
                this.getModel().updateEntryCache(entryEntities);
                this.getView().updateView(PerfRankMgmtConstant.NCKD_ENTRYENTITY);
            }
        }
    }

    /**
     * 获取优秀生员工
     * 本单位工作（工作信息-进本单位时间）满5年，距法定退休年龄（工作信息-新法定退休日期）超过5年且上年度员工绩效考核为优秀的所有员工
     * @return: void
     * @author W.Y.C
     * @date: 2026/01/08 15:46
     */
    private void getExcellentEmp(){
        DynamicObject org = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(IntJobPostConstant.NCKD_ORG));
        
        // 获取满足基本条件的员工
        Map<Long, DynamicObject> personMap = getBasicEmployeeCondition(org, "A");
        
        // 获取考核结果信息
        Map<Long, List<DynamicObject>> perfManagerMap = getPerformanceEvaluationResults(personMap.keySet());
        
        // 处理员工数据，筛选符合条件的优秀员工
        List<PersonData> personDataList = processExcellentEmployeeData(perfManagerMap);
        
        // 更新界面显示
        updateEntryEntity(personDataList);
    }

    /**
     * 获取满足基本条件的员工
     * @param org 组织信息
     * @param talentType 类型
     * @return 员工信息映射
     */
    private Map<Long, DynamicObject> getBasicEmployeeCondition(DynamicObject org, String talentType) {
        //前5年
        LocalDateTime fiveYearsAgo = DateUtil.minusYears(DateUtil.now(), FIVE_YEARS);
        //后5年
        LocalDateTime fiveYearsLater = DateUtil.addYears(DateUtil.now(), FIVE_YEARS);

        QueryFieldBuilder queryFieldBuilder = QueryFieldBuilder.create()
                .add(FormConstant.ID_KEY)
                .add(FormConstant.STARTDATE)
                .addIdNumberName(FormConstant.ADMINORG)
                .addIdNumberName(FormConstant.POSITION_KEY)
                .addGroup(new String[]{FormConstant.EMPLOYEE_KEY}, FormConstant.ID_KEY, FormConstant.NAME_KEY, FormConstant.EMP_NUMBER_KEY)
                .orderDesc(FormConstant.STARTDATE);

        QFilter qFilter = new QFilter(String.join(".", FormConstant.ADMINORG, FormConstant.NCKD_SECONDORG), QCP.equals, org.getLong(FormConstant.ID_KEY))
                .and(QFilterCommonHelper.getValidDateFilter(FormConstant.STARTDATE, FormConstant.ENDDATE))
                //任职类型：上挂/全职任职
                .and(String.join(".", FormConstant.POSTYPE, FormConstant.NUMBER_KEY), QCP.in, PERFORMANCE_EVALUATION_TYPES)
                //在职人员
                .and(String.join(".", FormConstant.HRPI_EMPENTREL, FormConstant.LABOR_REL_STATUS, FormConstant.IS_HIRED), QCP.equals, EnableEnum.YES.getCode());
        if(talentType.equalsIgnoreCase("A")) {
            //进本单位满5年
            qFilter.and(String.join(".", FormConstant.HRPI_EMPENTREL, FormConstant.STARTDATE), QCP.less_equals, DateUtil.toDate(fiveYearsAgo));
        }

        //新法定退休日期超过5年条件，或退休日期为空
        QFilter retirementDateFilter = new QFilter(String.join(".", FormConstant.HRPI_PERSERLEN, FormConstant.NCKD_NEWPLANRETDT), QCP.is_null, null)
                .or(String.join(".", FormConstant.HRPI_PERSERLEN, FormConstant.NCKD_NEWPLANRETDT), QCP.large_equals, DateUtil.toDate(fiveYearsLater));
        qFilter.and(retirementDateFilter);
        
        QueryEntityType queryEntityType = (QueryEntityType) EntityMetadataCache.getDataEntityType("personfilequery");
        DynamicObjectCollection personList = HRQueryEntityHelper.getInstance().getQueryDyoColl(queryEntityType, queryFieldBuilder.buildSelect(), new QFilter[]{qFilter}, queryFieldBuilder.buildOrder());
        
        // 调试信息，仅在开发阶段使用
        // for (DynamicObject dynamicObject : personList) {
        //     String number = dynamicObject.getString(String.join(".", FormConstant.EMPLOYEE_KEY, FormConstant.NUMBER_KEY));
        //     System.out.println(number);
        // }
        
        return personList.stream()
                .collect(Collectors.groupingBy(
                        obj -> obj.getLong(String.join(".", FormConstant.EMPLOYEE_KEY, FormConstant.ID_KEY))
                ))
                .entrySet()
                .stream()
                .collect(Collectors.toMap(
                        Map.Entry::getKey,
                        entry -> entry.getValue().get(0) // 由于已按日期降序排列，取第一条即为最新
                ));
    }

    /**
     * 获取绩效考核结果
     * @param personList 员工ID
     * @return 绩效考核结果映射
     */
    private Map<Long, List<DynamicObject>> getPerformanceEvaluationResults(Collection<Long> personList) {
        QueryFieldBuilder perfManagerQueryFieldBuilder = QueryFieldBuilder.create()
                .addIdNumberName(PERF_MANAGER, FormConstant.NCKD_PERSON)
                .addIdNumberName(APPRAISAL_RESULT)
                .add(APPRAISAL_YEAR);

        Date beginDate = DateUtil.beginOfYear(DateUtil.minusYears(DateUtil.nowDate(), 2));
        Date endDate = DateUtil.endOfYear(DateUtil.minusYears(DateUtil.nowDate(), 1));
        QFilter perfManagerFilter = new QFilter(APPRAISAL_YEAR, QCP.large_equals, beginDate)
                .and(APPRAISAL_YEAR, QCP.less_equals, endDate)
                .and(String.join(".", PERF_MANAGER, FormConstant.NCKD_PERSON), QCP.in, personList);
        
        DynamicObjectCollection perfManagerColl = QueryServiceHelper.query(PERF_MANAGER_ENTRY, perfManagerQueryFieldBuilder.buildSelect(), new QFilter[]{perfManagerFilter});
        
        return perfManagerColl.stream()
                .collect(Collectors.groupingBy(perfManager ->
                        perfManager.getLong(String.join(".", PERF_MANAGER, FormConstant.NCKD_PERSON, FormConstant.ID_KEY))
                ));
    }

    /**
     * 处理优秀员工数据
     * @param perfManagerMap 绩效考核结果映射
     * @return 符合条件的员工数据列表
     */
    private List<PersonData> processExcellentEmployeeData(Map<Long, List<DynamicObject>> perfManagerMap) {
        //取出上年度
        LocalDateTime lastYear = DateUtil.minusYears(DateUtil.now(), 1);
        LocalDateTime beforeLastYear = DateUtil.minusYears(DateUtil.now(), 2);
        List<PersonData> personDataList = new ArrayList<>();
        
        for (Map.Entry<Long, List<DynamicObject>> perfManagerEntry : perfManagerMap.entrySet()) {
            Long key = perfManagerEntry.getKey();
            List<DynamicObject> perfManagerList = perfManagerEntry.getValue();
            
            PersonData personData = new PersonData();
            boolean isExcellent = false;
            
            for (DynamicObject perfManager : perfManagerList) {
                Date appraisalYear = perfManager.getDate(APPRAISAL_YEAR);
                String appraisalResultNumber = perfManager.getString(String.join(".", APPRAISAL_RESULT, FormConstant.NUMBER_KEY));
                Long personId = perfManager.getLong(String.join(".", PERF_MANAGER, FormConstant.NCKD_PERSON, FormConstant.ID_KEY));
                
                personData.personId = personId;
                
                if(lastYear.getYear() == DateUtil.getYear(appraisalYear)) {
                    AppraisalResultEnum appraisalResult = AppraisalResultEnum.getByCode(appraisalResultNumber);
                    if((appraisalResult == AppraisalResultEnum.EXCELLENT || appraisalResult == AppraisalResultEnum.DEEMED_EXCELLENT)) {
                        isExcellent = true;
                        personData.appraisalResultId = perfManager.getLong(String.join(".", APPRAISAL_RESULT, FormConstant.ID_KEY));
                        personData.appraisalResultNumber = perfManager.getString(String.join(".", APPRAISAL_RESULT, FormConstant.NUMBER_KEY));
                        personData.appraisalResultName = perfManager.getString(String.join(".", APPRAISAL_RESULT, FormConstant.NAME_KEY));
                    }
                }
                
                if(beforeLastYear.getYear() == DateUtil.getYear(appraisalYear)) {
                    personData.beforeLastResultId = perfManager.getLong(String.join(".", APPRAISAL_RESULT, FormConstant.ID_KEY));
                    personData.beforeLastResultNumber = perfManager.getString(String.join(".", APPRAISAL_RESULT, FormConstant.NUMBER_KEY));
                    personData.beforeLastResultName = perfManager.getString(String.join(".", APPRAISAL_RESULT, FormConstant.NAME_KEY));
                }
            }
            
            if(isExcellent) {
                personDataList.add(personData);
            }
        }
        
        return personDataList;
    }

    /**
     * 获取绩效末等员工
     * 查询年度绩效考核定格为"不合格"或连续两年定格为"基本合格"的所有员工（距法定退休年龄小于5年（含）的员工除外）
     * @return:
     * @author W.Y.C
     * @date: 2026/01/08 15:47
     */
    public void getPerformanceEndEmployees(){
        DynamicObject org = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(IntJobPostConstant.NCKD_ORG));
        
        // 获取满足基本条件的员工
        Map<Long, DynamicObject> personMap = getBasicEmployeeCondition(org, "C");
        
        // 获取考核结果信息
        Map<Long, List<DynamicObject>> perfManagerMap = getPerformanceEvaluationResults(personMap.keySet());
        
        // 处理员工数据，筛选符合条件的绩效末等员工
        List<PersonData> personDataList = processPerformanceEndEmployeeData(perfManagerMap);
        
        // 更新界面显示
        updateEntryEntity(personDataList);
    }

    /**
     * 处理绩效末等员工数据
     * @param perfManagerMap 绩效考核结果映射
     * @return 符合条件的员工数据列表
     */
    private List<PersonData> processPerformanceEndEmployeeData(Map<Long, List<DynamicObject>> perfManagerMap) {
        //取出上年度
        LocalDateTime lastYear = DateUtil.minusYears(DateUtil.now(), 1);
        LocalDateTime beforeLastYear = DateUtil.minusYears(DateUtil.now(), 2);
        List<PersonData> personDataList = new ArrayList<>();
        
        for (Map.Entry<Long, List<DynamicObject>> perfManagerEntry : perfManagerMap.entrySet()) {
            Long key = perfManagerEntry.getKey();
            List<DynamicObject> perfManagerList = perfManagerEntry.getValue();
            
            PersonData personData = new PersonData();
            boolean isUnQualified = false;
            //连续两年为基本合格
            int basicallyQualifiedCount = 0;
            
            for (DynamicObject perfManager : perfManagerList) {
                Date appraisalYear = perfManager.getDate(APPRAISAL_YEAR);
                Long appraisalResultId = perfManager.getLong(String.join(".", APPRAISAL_RESULT, FormConstant.ID_KEY));
                String appraisalResultNumber = perfManager.getString(String.join(".", APPRAISAL_RESULT, FormConstant.NUMBER_KEY));
                String appraisalResultName = perfManager.getString(String.join(".", APPRAISAL_RESULT, FormConstant.NAME_KEY));
                AppraisalResultEnum appraisalResult = AppraisalResultEnum.getByCode(appraisalResultNumber);
                Long personId = perfManager.getLong(String.join(".", PERF_MANAGER, FormConstant.NCKD_PERSON, FormConstant.ID_KEY));
                
                personData.personId = personId;
                
                if(lastYear.getYear() == DateUtil.getYear(appraisalYear)) {
                    if((appraisalResult == AppraisalResultEnum.UN_QUALIFIED || appraisalResult == AppraisalResultEnum.DEEMED_UNQUALIFIED)
                            || (appraisalResult == AppraisalResultEnum.BASICALLY_QUALIFIED || appraisalResult == AppraisalResultEnum.DEEMED_BASICALLY_QUALIFIED)) {
                        if((appraisalResult == AppraisalResultEnum.UN_QUALIFIED || appraisalResult == AppraisalResultEnum.DEEMED_UNQUALIFIED)) {
                            isUnQualified = true;
                        } else if(appraisalResult == AppraisalResultEnum.BASICALLY_QUALIFIED || appraisalResult == AppraisalResultEnum.DEEMED_BASICALLY_QUALIFIED) {
                            basicallyQualifiedCount++;
                        }
                        personData.appraisalResultId = appraisalResultId;
                        personData.appraisalResultNumber = appraisalResultNumber;
                        personData.appraisalResultName = appraisalResultName;
                    }
                }
                
                if(beforeLastYear.getYear() == DateUtil.getYear(appraisalYear)) {
                    if(appraisalResult == AppraisalResultEnum.BASICALLY_QUALIFIED || appraisalResult == AppraisalResultEnum.DEEMED_BASICALLY_QUALIFIED) {
                        basicallyQualifiedCount++;
                    }
                    personData.beforeLastResultId = appraisalResultId;
                    personData.beforeLastResultNumber = appraisalResultNumber;
                    personData.beforeLastResultName = appraisalResultName;
                }
            }
            
            if(isUnQualified || basicallyQualifiedCount >= 2) { // 至少2次基本合格
                personDataList.add(personData);
            }
        }
        
        return personDataList;
    }

    /**
     * 更新条目实体
     * @param personDataList 员工数据列表
     */
    private void updateEntryEntity(List<PersonData> personDataList) {
        if(!personDataList.isEmpty()) {
            List<Long> personIds = personDataList.stream()
                    .map(personData -> personData.personId)
                    .collect(Collectors.toList());
            Map<Long, DynamicObject> empPosOrgRelMap = EmpPosOrgRelHelper.queryEmpPosOrgRelByEmployeesMap(personIds);
            DynamicObjectCollection entryEntityColl = this.getModel().getDataEntity(true).getDynamicObjectCollection(FormConstant.NCKD_ENTRYENTITY);
            
            for (PersonData personData : personDataList) {
                DynamicObject empPosOrgRel = empPosOrgRelMap.get(personData.personId);
                if(empPosOrgRel != null) {
                    DynamicObject entry = entryEntityColl.addNew();
                    entry.set(IntJobPostConstant.NCKD_ISJOG, EnableEnum.NO.getCode());
                    entry.set(IntJobPostConstant.NCKD_ISENTER, EnableEnum.YES.getCode());
                    entry.set(FormConstant.NCKD_PERSON, empPosOrgRel.getDynamicObject(FormConstant.EMPLOYEE_KEY));
                    entry.set(FormConstant.NCKD_DEP, empPosOrgRel.getDynamicObject(FormConstant.ADMINORG));
                    entry.set(FormConstant.NCKD_POSITION_KEY, empPosOrgRel.getDynamicObject(FormConstant.POSITION_KEY));
                    
                    DynamicObject appraisalResult = EntityHelper.newEntity(FormConstant.NCKD_APPRAISALRESULT, personData.appraisalResultId);
                    appraisalResult.set(FormConstant.NAME_KEY, personData.appraisalResultName);
                    appraisalResult.set(FormConstant.NUMBER_KEY, personData.appraisalResultNumber);
                    entry.set(IntJobPostConstant.NCKD_APPRAISALRESULT, appraisalResult);

                    if (personData.beforeLastResultId != null && personData.beforeLastResultId > 0) {
                        DynamicObject beforeAppraisalResult = EntityHelper.newEntity(FormConstant.NCKD_APPRAISALRESULT, personData.appraisalResultId);
                        beforeAppraisalResult.set(FormConstant.NAME_KEY, personData.beforeLastResultName);
                        beforeAppraisalResult.set(FormConstant.NUMBER_KEY, personData.beforeLastResultNumber);
                        entry.set(IntJobPostConstant.NCKD_BEFORELAST, beforeAppraisalResult);
                    }
                }
            }
            this.getView().showSuccessNotification("获取成功！");
            this.getModel().updateEntryCache(entryEntityColl);
            this.getView().updateView(FormConstant.NCKD_ENTRYENTITY);
        }else{
            this.getView().showTipNotification("无符合条件的员工！");
        }
    }
    
    class PersonData{
        Long personId;
        Long appraisalResultId;
        String appraisalResultNumber;
        String appraisalResultName;
        Long beforeLastResultId;
        String beforeLastResultNumber;
        String beforeLastResultName;
    }
}