package com.lantone.report.facade;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.google.common.collect.Maps;
import com.lantone.common.enums.IsDeleteEnum;
import com.lantone.common.exception.Asserts;
import com.lantone.common.util.DateUtil;
import com.lantone.common.util.ListUtil;
import com.lantone.common.util.StringUtil;
import com.lantone.report.dto.GetAppealDeptDTO;
import com.lantone.report.dto.GetAppealInfoDTO;
import com.lantone.report.dto.GetAppealModeDTO;
import com.lantone.report.dto.GetReviewerDTO;
import com.lantone.report.entity.AppealExamineInfo;
import com.lantone.report.entity.AppealInfo;
import com.lantone.report.entity.QcresultDetail;
import com.lantone.report.enums.AppealOperationTypeEnum;
import com.lantone.report.enums.ExampleStatusEnum;
import com.lantone.report.enums.WorkFlowNodeEnum;
import com.lantone.report.facade.base.AppealExamineInfoFacade;
import com.lantone.report.facade.base.AppealInfoFacade;
import com.lantone.report.facade.base.QcresultDetailFacade2;
import com.lantone.report.facade.base.SysUserRoleFacade2;
import com.lantone.report.facade.base.WorkFlowNodeFacade;
import com.lantone.report.vo.AddAppealInfoVO;
import com.lantone.report.vo.CancelAppealInfoVO;
import com.lantone.report.vo.GetAppealDeptVo;
import com.lantone.report.vo.GetAppealInfoVO;
import com.lantone.report.vo.GetAppealModeVo;
import com.lantone.report.vo.GetAppealOperationTypeVO;
import com.lantone.report.vo.GetReviewerVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Description:申诉审核管理
 * @Author: songxl
 * @Date 2022/1/5
 */
@Component
public class MedAppealInfoManagementFacade {

    @Autowired
    private AppealInfoFacade appealInfoFacade;
    @Autowired
    private SysUserRoleFacade2 sysUserRoleFacade;
    @Autowired
    private QcresultDetailFacade2 qcresultDetailFacade;
    @Autowired
    private AppealExamineInfoFacade appealExamineInfoFacade;


    public Boolean addAppealInfo(AddAppealInfoVO addAppealInfoVO) {

        //判断是否只单人操作
        if (addAppealInfoVO.getSingleAppealFalg()) {
            checkSingleAppeal(addAppealInfoVO);
        }

        if (addAppealInfoVO.getModeId() != null) {
            //获取模块名称
            String modeName = appealInfoFacade.getBaseMapper().getModeName(addAppealInfoVO.getModeId());
            addAppealInfoVO.setModeName(modeName);
        }
        switch (addAppealInfoVO.getAppealOperationType()) {
            //删改
            case "0":
                //通过医院id+病历id+条目ID+未删除  获取该缺陷记录
                QcresultDetail qcresultDetail = getQcresultDetailById(addAppealInfoVO);
                //获取该病历缺陷申诉记录(医院id+病历id+质控缺陷id+未删除)
                AppealInfo appealInfo = getAppealInfo(addAppealInfoVO.getHospitalId()
                        , addAppealInfoVO.getBehospitalCode()
                        , addAppealInfoVO.getCasesEntryId());
                //缺陷状态-删除
                if (IsDeleteEnum.Y.getKey().equals(qcresultDetail.getIsDeleted())) {
                    Asserts.fail("该缺陷已被删除，请走恢复流程");
                }
                //申诉记录不存在
                if (appealInfo == null) {
                    //新增申诉记录+审核记录
                    return addAppealInfoAndExamineInfo(addAppealInfoVO);
                }
                //获取申诉记录当前节点状态(1:申诉|2：撤销|3：科室审核)
                if (WorkFlowNodeEnum.APPEAL.getKey().equals(appealInfo.getWorkFlowNodeId() + "")) {
                    Asserts.fail("请勿重复提交申诉，如需修改，请在申诉列表撤回后重新发起。");
                } else {
                    //删除申诉记录
                    appealInfoFacade.update(new UpdateWrapper<AppealInfo>().set("is_deleted", IsDeleteEnum.Y.getKey())
                            .eq("id", appealInfo.getId()));
                    //逻辑删除申诉审批记录
                    appealExamineInfoFacade.update(new UpdateWrapper<AppealExamineInfo>()
                            .set("is_deleted", IsDeleteEnum.Y.getKey())
                            .eq("appeal_info_id", appealInfo.getId()));
                }
                //新增申诉记录+审核记录
                return addAppealInfoAndExamineInfo(addAppealInfoVO);
            //新增已有
            case "1":
                //通过病历id+条目ID获取缺陷
                List<QcresultDetail> qcresultDetails = qcresultDetailFacade.list(new QueryWrapper<QcresultDetail>()
                        .eq("hospital_id", addAppealInfoVO.getHospitalId())
                        .eq("behospital_code", addAppealInfoVO.getBehospitalCode())
                        .eq("cases_entry_id", addAppealInfoVO.getCasesEntryId()));
                if (StringUtil.isNotBlank(addAppealInfoVO.getCasesEntryMsg())) {
                    addAppealInfoVO.setQcresultDetailMsg(addAppealInfoVO.getCasesEntryMsg());
                }
                if (ListUtil.isNotEmpty(qcresultDetails)) {
                    Asserts.fail("该缺陷已存在无需申诉新增");
                }
                //获取申诉新增已有待审核的申诉记录
                AppealInfo oldAppealInfo = getAppealInfo(addAppealInfoVO);
                if (oldAppealInfo != null) {
                    //如果最新的一条是已审核
                    if (WorkFlowNodeEnum.DEPT_CHECK.getKey().equals(oldAppealInfo.getWorkFlowNodeId() + "")) {
                        //删除改新增已有（已审核）申诉记录
                        appealInfoFacade.update(new UpdateWrapper<AppealInfo>().set("is_deleted", IsDeleteEnum.Y.getKey())
                                .eq("id", oldAppealInfo.getId()));
                        //逻辑删除申诉审批记录
                        appealExamineInfoFacade.update(new UpdateWrapper<AppealExamineInfo>()
                                .set("is_deleted", IsDeleteEnum.Y.getKey())
                                .eq("appeal_info_id", oldAppealInfo.getId()));
                    } else if (WorkFlowNodeEnum.APPEAL.getKey().equals(oldAppealInfo.getWorkFlowNodeId() + "")) {
                        Asserts.fail("该缺陷已被申诉无需再次申诉");
                    }

                }
                //新增申诉记录+审核记录
                return addAppealInfoAndExamineInfo(addAppealInfoVO);
            //新增缺失
            case "2":
                //补全缺失模块信息
                if (StringUtil.isNotBlank(addAppealInfoVO.getModeName())) {
                    //获取模块名称
                    Long modeId = appealInfoFacade.getBaseMapper().getModeIdByName(addAppealInfoVO.getModeName());
                    if (modeId != null) {
                        addAppealInfoVO.setModeId(modeId);
                    }
                }
                //1.判断新增缺失是否存在（医院id+病历id+申诉说明+状态【申诉】）
                AppealInfo notAppealInfo = getAppealInfo(addAppealInfoVO.getHospitalId(), addAppealInfoVO.getBehospitalCode(),
                        addAppealInfoVO.getModeId(), addAppealInfoVO.getAppealExplain());
                //申诉记录不存在
                if (notAppealInfo != null) {
                    if (WorkFlowNodeEnum.APPEAL.getKey().equals(notAppealInfo.getWorkFlowNodeId() + "")) {
                        Asserts.fail("该缺陷已被申诉");
                    } else {
                        //删除申诉记录
                        appealInfoFacade.update(new UpdateWrapper<AppealInfo>().set("is_deleted", IsDeleteEnum.Y.getKey())
                                .eq("id", notAppealInfo.getId()));
                        //逻辑删除申诉审批记录
                        appealExamineInfoFacade.update(new UpdateWrapper<AppealExamineInfo>()
                                .set("is_deleted", IsDeleteEnum.Y.getKey())
                                .eq("appeal_info_id", notAppealInfo.getId()));
                    }
                }

                //新增申诉记录+审核记录
                return addAppealInfoAndExamineInfo(addAppealInfoVO);
            //恢复
            case "3":
                //通过缺陷id获取该缺陷记录
                QcresultDetail qcresultDetail1 = getQcresultDetailById(addAppealInfoVO);
                //获取该病历缺陷申诉记录(医院id+病历id+质控缺陷id+未删除)
                AppealInfo appealInfo1 = getAppealInfo(addAppealInfoVO.getHospitalId()
                        , addAppealInfoVO.getBehospitalCode()
                        , addAppealInfoVO.getCasesEntryId());
                //缺陷状态-删除
                if (qcresultDetail1.getIsDeleted().equals(IsDeleteEnum.N.getKey())) {
                    Asserts.fail("缺陷已被恢复无需再次恢复");
                }
                //申诉记录不存在
                if (appealInfo1 == null) {
                    //新增申诉记录+审核记录
                    return addAppealInfoAndExamineInfo(addAppealInfoVO);
                }
                //获取申诉记录当前节点状态(1:申诉|2：撤销|3：科室审核)
                if (WorkFlowNodeEnum.APPEAL.getKey().equals(appealInfo1.getWorkFlowNodeId() + "")) {
                    Asserts.fail("该缺陷已被申诉");
                } else {
                    //删除申诉记录
                    appealInfoFacade.update(new UpdateWrapper<AppealInfo>().set("is_deleted", IsDeleteEnum.Y.getKey())
                            .eq("id", appealInfo1.getId()));
                    appealExamineInfoFacade.update(new UpdateWrapper<AppealExamineInfo>()
                            .set("is_deleted", IsDeleteEnum.Y.getKey())
                            .eq("appeal_info_id", appealInfo1.getId()));
                }
                //新增申诉记录+审核记录
                return addAppealInfoAndExamineInfo(addAppealInfoVO);
            default:
                Asserts.fail("申诉操作类型不存在！");
        }
        return false;
    }

    private void checkSingleAppeal(AddAppealInfoVO addAppealInfoVO) {
        //新增缺失
        if (AppealOperationTypeEnum.ADD_NO_EXIST.getKey().equals(addAppealInfoVO.getAppealOperationType())) {

        } else {
            List<AppealInfo> appealInfos = appealInfoFacade.list(new QueryWrapper<AppealInfo>()
                    .eq("hospital_id", addAppealInfoVO.getHospitalId())
                    .eq("behospital_code", addAppealInfoVO.getBehospitalCode())
                    .eq("cases_entry_id", addAppealInfoVO.getCasesEntryId())
                    .notIn("work_flow_node_id", WorkFlowNodeEnum.APPEAL_BACK.getKey())
                    .notIn("claimant_id", addAppealInfoVO.getClaimantId())
                    .orderByDesc("gmt_create"));
            if (ListUtil.isNotEmpty(appealInfos)) {
                Asserts.fail("该缺陷条目已被他人操作,无法操作。");
            }
        }
    }

    private AppealInfo getAppealInfo(AddAppealInfoVO addAppealInfoVO) {
        if (addAppealInfoVO.getCasesEntryId() == null) {
            Asserts.fail("新增已有条目casesEntryId不能为空");
        }
        if (addAppealInfoVO.getIsReject() == null) {
            Asserts.fail("新增已有条目isReject不能为空");
        }
        if (addAppealInfoVO.getCasesScore() == null) {
            Asserts.fail("新增已有条目casesScore不能为空");
        }
        List<AppealInfo> appealInfos = appealInfoFacade.list(new QueryWrapper<AppealInfo>()
                .eq("hospital_id", addAppealInfoVO.getHospitalId())
                .eq("behospital_code", addAppealInfoVO.getBehospitalCode())
                .eq("cases_entry_id", addAppealInfoVO.getCasesEntryId())
                .eq("cases_score", addAppealInfoVO.getCasesScore())
                .eq("is_reject", addAppealInfoVO.getIsReject())
                .eq("is_deleted", IsDeleteEnum.N.getKey())
                .orderByDesc("gmt_create"));
        if (ListUtil.isNotEmpty(appealInfos)) {
            return appealInfos.get(0);
        }
        return null;
    }

    private Boolean addAppealInfoAndExamineInfo(AddAppealInfoVO addAppealInfoVO) {
        AppealInfo appealInfo = new AppealInfo();
        BeanUtils.copyProperties(addAppealInfoVO, appealInfo);
        appealInfo.setGmtCreate(DateUtil.now());
        //申诉记录插入成功
        if (appealInfoFacade.save(appealInfo)) {
            AppealExamineInfo appealExamineInfo = new AppealExamineInfo();
            appealExamineInfo.setAppealInfoId(appealInfo.getId());
            appealExamineInfo.setCheckId(addAppealInfoVO.getCheckId());
            return appealExamineInfoFacade.save(appealExamineInfo);
        }
        Asserts.fail("申诉记录插入失败！");
        return false;
    }

    /**
     * @param hospitalId
     * @param behospitalCode
     * @param getCasesEntryId
     * @Description获取该病历缺陷申诉记录
     * @Return com.lantone.report.entity.AppealInfo
     */
    private AppealInfo getAppealInfo(Long hospitalId, String behospitalCode, Long getCasesEntryId) {

        if (getCasesEntryId == null) {
            Asserts.fail("质控缺陷id为空");
        }
        List<AppealInfo> appealInfos = appealInfoFacade.list(new QueryWrapper<AppealInfo>()
                .eq("hospital_id", hospitalId)
                .eq("behospital_code", behospitalCode)
                .eq("cases_entry_id", getCasesEntryId)
                .eq("is_deleted", IsDeleteEnum.N.getKey())
                .orderByDesc("gmt_create"));
        if (ListUtil.isNotEmpty(appealInfos)) {
            return appealInfos.get(0);
        }
        return null;
    }

    /**
     * @param hospitalId
     * @param behospitalCode
     * @Description获取该病历缺陷申诉记录(新增缺失)
     * @Return com.lantone.report.entity.AppealInfo
     */
    private AppealInfo getAppealInfo(Long hospitalId, String behospitalCode, Long modeId, String appealExplain) {

        List<AppealInfo> appealInfos = appealInfoFacade.list(new QueryWrapper<AppealInfo>()
                .eq("hospital_id", hospitalId)
                .eq("behospital_code", behospitalCode)
                .eq("appeal_operation_type", AppealOperationTypeEnum.ADD_NO_EXIST.getKey())
                .eq(modeId != null, "mode_id", modeId)
                .eq("appeal_explain", appealExplain)
                .eq("is_deleted", IsDeleteEnum.N.getKey())
                .orderByDesc("gmt_create"));
        if (ListUtil.isNotEmpty(appealInfos)) {
            return appealInfos.get(0);
        }
        return null;
    }

    /**
     * @param addAppealInfoVO
     * @Description通过医院id+病历id+条目ID+未删除 获取该缺陷记录
     * @Return com.lantone.report.entity.QcresultDetail
     */
    private QcresultDetail getQcresultDetailById(AddAppealInfoVO addAppealInfoVO) {
        if (addAppealInfoVO.getCasesEntryId() == null) {
            Asserts.fail("条目ID为空");
        }
        List<QcresultDetail> qcresultDetails = qcresultDetailFacade.list(new QueryWrapper<QcresultDetail>()
                .eq("hospital_id", addAppealInfoVO.getHospitalId())
                .eq("behospital_code", addAppealInfoVO.getBehospitalCode())
                .eq("cases_entry_id", addAppealInfoVO.getCasesEntryId())
                .orderByDesc("id"));
        if (ListUtil.isEmpty(qcresultDetails)) {
            Asserts.fail("质控缺陷不存在");
        }
        return qcresultDetails.get(0);
    }

    /**
     * @param getReviewerVO
     * @Description获取审核人列表
     * @Return java.util.List<com.lantone.report.dto.GetReviewerDTO>
     */
    public List<GetReviewerDTO> getReviewer(GetReviewerVO getReviewerVO) {
        //获取审核人列表
        List<GetReviewerDTO> reviewers = sysUserRoleFacade.getBaseMapper().getUserByRole(getReviewerVO);
        //获取申诉人申诉记录审核人（时间倒序）
        List<Long> appealInfos = appealInfoFacade.list(new QueryWrapper<AppealInfo>()
                .select("check_id")
                .eq("claimant_id", getReviewerVO.getClaimantId())
                .orderByDesc("gmt_create")).stream().map(AppealInfo::getCheckId).distinct().collect(Collectors.toList());
        //去重
        return sortReviewer(reviewers, appealInfos);
    }

    private List<GetReviewerDTO> sortReviewer(List<GetReviewerDTO> reviewers, List<Long> checkIds) {
        if (ListUtil.isEmpty(checkIds)) {
            return reviewers;
        }
        List<GetReviewerDTO> temp = new ArrayList<>(reviewers);
        if (ListUtil.isNotEmpty(reviewers)) {
            List<GetReviewerDTO> out = new ArrayList<>();
            for (Long checkId : checkIds) {
                for (GetReviewerDTO getReviewerDTO : reviewers) {
                    if (getReviewerDTO.getId().intValue() == checkId.intValue()) {
                        out.add(getReviewerDTO);
                        temp.remove(getReviewerDTO);
                    }
                }
            }
            out.addAll(temp);
            return out;
        }
        return reviewers;
    }

    public Map<String, String> getAppealOperationType(GetAppealOperationTypeVO getAppealOperationTypeVO) {
        Map<String, String> out = Maps.newHashMap();
        //通过缺陷id获取缺陷
        QcresultDetail qcresultDetail = qcresultDetailFacade.getById(getAppealOperationTypeVO.getQcresultDetailId());
        QcresultDetail nowQcresultDetail = null;
        if (qcresultDetail != null) {
            //获取最新的缺陷
            List<QcresultDetail> qcresultDetails = qcresultDetailFacade.list(new QueryWrapper<QcresultDetail>()
                    .eq("hospital_id", qcresultDetail.getHospitalId())
                    .eq("behospital_code", qcresultDetail.getBehospitalCode())
                    .eq("cases_entry_id", qcresultDetail.getCasesEntryId())
                    .orderByDesc("id"));
            if (ListUtil.isNotEmpty(qcresultDetails)) {
                nowQcresultDetail = qcresultDetails.get(0);
            }

        }
        switch (getAppealOperationTypeVO.getAppealOperationType()) {
            case "0":
                if (nowQcresultDetail == null) {
                    Asserts.fail("质控缺陷条目不存在");
                }
                if (IsDeleteEnum.N.getKey().equals(nowQcresultDetail.getIsDeleted())) {
                    out.put("appealOperationType", AppealOperationTypeEnum.UP_OR_DEL.getKey());
                    out.put("appealOperationName", AppealOperationTypeEnum.UP_OR_DEL.getName());
                } else {
                    out.put("appealOperationType", AppealOperationTypeEnum.RECOVER.getKey());
                    out.put("appealOperationName", AppealOperationTypeEnum.RECOVER.getName());
                }
                break;
            case "1":
                if (ExampleStatusEnum.ADOPT_EXAMPLE.getKey().equals(getAppealOperationTypeVO.getExampleStatus())) {
                    out.put("appealOperationType", AppealOperationTypeEnum.UP_OR_DEL.getKey());
                    out.put("appealOperationName", AppealOperationTypeEnum.UP_OR_DEL.getName());
                } else {
                    out.put("appealOperationType", AppealOperationTypeEnum.ADD_EXIST.getKey());
                    out.put("appealOperationName", AppealOperationTypeEnum.ADD_EXIST.getName());
                }
                break;
            case "2":
                out.put("appealOperationType", AppealOperationTypeEnum.ADD_NO_EXIST.getKey());
                out.put("appealOperationName", AppealOperationTypeEnum.ADD_NO_EXIST.getName());
                break;
            case "3":
                if (ExampleStatusEnum.ADOPT_EXAMPLE.getKey().equals(getAppealOperationTypeVO.getExampleStatus())) {
                    out.put("appealOperationType", AppealOperationTypeEnum.UP_OR_DEL.getKey());
                    out.put("appealOperationName", AppealOperationTypeEnum.UP_OR_DEL.getName());
                } else {
                    out.put("appealOperationType", AppealOperationTypeEnum.RECOVER.getKey());
                    out.put("appealOperationName", AppealOperationTypeEnum.RECOVER.getName());
                }
                break;
            default:
                Asserts.fail("申诉操作类型不存在");
        }
        return out;
    }

    /**
     * @param cancelAppealInfoVO
     * @Description撤销申诉
     * @Return java.lang.Boolean
     */
    public Boolean cancelAppealInfo(CancelAppealInfoVO cancelAppealInfoVO) {
        Boolean out = false;
        //获取申诉记录
        AppealInfo appealInfo = appealInfoFacade.getById(cancelAppealInfoVO.getId());
        if (!cancelAppealInfoVO.getClaimantId().equals(appealInfo.getClaimantId())) {
            Asserts.fail("该申诉并非由你发起，无法撤回。");
        }
        if (appealInfo == null) {
            Asserts.fail("撤回申诉条目不存在");
        }
        if (WorkFlowNodeEnum.APPEAL.getKey().equals(appealInfo.getWorkFlowNodeId() + "")) {
            List<AppealInfo> appealInfoHistory = null;
            //非新增缺失
            if (!AppealOperationTypeEnum.ADD_NO_EXIST.getKey().equals(appealInfo.getAppealOperationType())) {
                //获取该条目申诉历史记录（非新增缺失）
                appealInfoHistory = appealInfoFacade.list(new QueryWrapper<AppealInfo>()
                        .eq("hospital_id", appealInfo.getHospitalId())
                        .eq("behospital_code", appealInfo.getBehospitalCode())
                        .notIn("work_flow_node_id", WorkFlowNodeEnum.APPEAL_BACK.getKey())
                        .eq(appealInfo.getCasesEntryId() != null, "cases_entry_id", appealInfo.getCasesEntryId())
                        .eq("is_deleted", IsDeleteEnum.Y.getKey())
                        .orderByDesc("gmt_create"));
            } else {
                appealInfoHistory = appealInfoFacade.list(new QueryWrapper<AppealInfo>()
                        .eq("hospital_id", appealInfo.getHospitalId())
                        .eq("behospital_code", appealInfo.getBehospitalCode())
                        .notIn("work_flow_node_id", WorkFlowNodeEnum.APPEAL_BACK.getKey())
                        .eq("appeal_operation_type", AppealOperationTypeEnum.ADD_NO_EXIST.getKey())
                        .eq(appealInfo.getAppealExplain() != null, "appeal_explain", appealInfo.getAppealExplain())
                        .eq("is_deleted", IsDeleteEnum.Y.getKey())
                        .orderByDesc("gmt_create"));
            }


            //存在历史记录还原最后一条
            if (ListUtil.isNotEmpty(appealInfoHistory)) {
                AppealInfo appealInfoOld = appealInfoHistory.get(0);
                appealInfoOld.setIsDeleted(IsDeleteEnum.N.getKey());
                out = appealInfoFacade.saveOrUpdate(appealInfoOld);
                //还原审批记录
                if (out) {
                    out = appealExamineInfoFacade.update(new UpdateWrapper<AppealExamineInfo>()
                            .set("is_deleted", IsDeleteEnum.N.getKey())
                            .eq("appeal_info_id", appealInfoOld.getId()));
                }
            }
            //逻辑删除该申诉（撤回）
            appealInfo.setIsDeleted(IsDeleteEnum.Y.getKey());
            appealInfo.setWorkFlowNodeId(cancelAppealInfoVO.getWorkFlowNodeId());
            appealInfo.setGmtModified(DateUtil.now());
            out = appealInfoFacade.updateById(appealInfo);
            if (out) {
                //逻辑删除申诉申请审批记录
                return appealExamineInfoFacade.update(new UpdateWrapper<AppealExamineInfo>()
                        .set("is_deleted", IsDeleteEnum.Y.getKey())
                        .eq("appeal_info_id", appealInfo.getId()));
            }
            Asserts.fail("撤回失败");
        } else {
            Asserts.fail("该申诉已被审核，无法撤回。");
        }
        return false;
    }

    public GetAppealInfoDTO getAppealInfo(GetAppealInfoVO getAppealInfoVO) {
        //1.获取病历基本信息和病历内容
        GetAppealInfoDTO getAppealInfoDTO = appealInfoFacade.getBaseMapper().getAppealInfo(getAppealInfoVO);
        //2.获取该条申诉记录详情
        AppealInfo appealInfo = appealInfoFacade.getById(getAppealInfoVO.getId());
        if (appealInfo != null) {
            //如果是新增缺失，获取申诉说明（通过申诉说明区别该病历新增的新增缺失）
            if (AppealOperationTypeEnum.ADD_NO_EXIST.getKey().equals(appealInfo.getAppealOperationType())) {
                getAppealInfoVO.setAppealExplain(appealInfo.getAppealExplain());
            }
            getAppealInfoVO.setModeId(appealInfo.getModeId());
        }
        //3.获取申诉审核记录
        getAppealInfoDTO.setAppealExamineRecordDTOList(appealInfoFacade.getBaseMapper().getAppealExamineRecords(getAppealInfoVO));
        return getAppealInfoDTO;
    }

    public List<GetAppealDeptDTO> getAppealDept(GetAppealDeptVo getAppealDeptVo) {
        return appealInfoFacade.getBaseMapper().getAppealDept(getAppealDeptVo);
    }

    public List<GetAppealModeDTO> getAppealMode(GetAppealModeVo getAppealModeVo) {
        return appealInfoFacade.getBaseMapper().getAppealMode(getAppealModeVo);
    }
}
