package com.ruoyi.mall.service.impl;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.stream.Collectors;

import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.mall.domain.*;
import com.ruoyi.mall.domain.Bo.UserScoreRuleBO;
import com.ruoyi.mall.domain.Vo.MajorItemVo;
import com.ruoyi.mall.domain.Vo.ReportIntelligenceVo;
import com.ruoyi.mall.mapper.MallAcceptRateSettingMapper;
import com.ruoyi.mall.mapper.MallAcceptRuleMapper;
import com.ruoyi.mall.mapper.ReportIntelligenceMapper;
import com.ruoyi.mall.service.IMallCountMethodService;
import com.ruoyi.mall.service.IReportIntelligenceService;
import net.sf.jsqlparser.expression.LongValue;
import net.sf.jsqlparser.expression.StringValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mall.mapper.MemberReportIntelligenceMapper;
import com.ruoyi.mall.service.IMemberReportIntelligenceService;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * 用户智能志愿报告Service业务层处理
 *
 * @author ruoyi
 * @date 2023-10-28
 */
@Service
public class MemberReportIntelligenceServiceImpl implements IMemberReportIntelligenceService
{
    @Resource
    private MemberReportIntelligenceMapper memberReportIntelligenceMapper;
    @Resource
    private MallAcceptRateSettingMapper mallAcceptRateSettingMapper;
    @Resource
    private IMallCountMethodService mallCountMethodService;
    @Resource
    private IReportIntelligenceService reportIntelligenceService;
    @Resource
    private IMemberReportIntelligenceService memberReportIntelligenceService;
    @Resource
    private ReportIntelligenceMapper reportIntelligenceMapper;
    @Resource
    private MallAcceptRuleMapper acceptRuleMapper;
    /**
     * 查询用户智能志愿报告
     *
     * @param reportId 用户智能志愿报告主键
     * @return 用户智能志愿报告
     */
    @Override
    public MemberReportIntelligence selectMemberReportIntelligenceByReportId(Long reportId)
    {
        return memberReportIntelligenceMapper.selectMemberReportIntelligenceByReportId(reportId);
    }

    /**
     * 查询用户智能志愿报告列表
     *
     * @param memberReportIntelligence 用户智能志愿报告
     * @return 用户智能志愿报告
     */
    @Override
    public List<MemberReportIntelligence> selectMemberReportIntelligenceList(MemberReportIntelligence memberReportIntelligence)
    {
        return memberReportIntelligenceMapper.selectMemberReportIntelligenceList(memberReportIntelligence);
    }

    /**
     * 新增用户智能志愿报告
     *
     * @param memberReportIntelligence 用户智能志愿报告
     * @return 结果
     */
    @Override
    public int insertMemberReportIntelligence(MemberReportIntelligence memberReportIntelligence)
    {
        memberReportIntelligence.setCreateTime(DateUtils.getNowDate());
        int i = memberReportIntelligenceMapper.insertMemberReportIntelligence(memberReportIntelligence);
        return i;
    }

    /**手动
     * 新增用户智能报告 同时新增报告条目
     */
    @Override
    public int insertChoiceReportAndItem(List< ReportIntelligenceVo> collect, MallMemberUser mallMemberUser, Long batchId, Long memberId, String reportType) {
        //查询当前生成的报告单序号
        MemberReportIntelligence reportSort = new MemberReportIntelligence();
        reportSort.setBatchId(batchId);
        reportSort.setUserId(mallMemberUser.getId());
        reportSort.setReportType("1");
        int size = memberReportIntelligenceMapper.selectMemberReportIntelligenceList(reportSort).size();
        //新增报告
        //新增报告 获取返回的报告id
        MemberReportIntelligence memberReportIntelligence = new MemberReportIntelligence();
        memberReportIntelligence.setBatchId(batchId);
        memberReportIntelligence.setUserId(memberId);
        //报告类型 0智能生成 1自主选择
        memberReportIntelligence.setReportType(reportType);
        if(batchId.equals(1L)){//提前批
            memberReportIntelligence.setReportName("提前批-志愿单"+String.valueOf(size+1));
        }else if(batchId.equals(2L)){//本科A段
            memberReportIntelligence.setReportName("本科段-志愿单"+String.valueOf(size+1));
        }else if(batchId.equals(4L)){//艺术专科
            memberReportIntelligence.setReportName("艺术专科-志愿单"+String.valueOf(size+1));
        }
        memberReportIntelligence.setCreateTime(DateUtils.getNowDate());
        int i = memberReportIntelligenceMapper.insertMemberReportIntelligence(memberReportIntelligence);
        //新增到志愿条目表 关联报告id
        Long reportId = memberReportIntelligence.getReportId();
        //新增志愿条目
        //排序
        if(null != collect && collect.size()>0 ){
            int  sort = 1;
            for (ReportIntelligenceVo vo : collect) {
                vo.setSort(sort++);
                vo.setBatchId(batchId);
                vo.setCreateTime(DateUtils.getNowDate());
                vo.setReportId(reportId);
                vo.setUserId(mallMemberUser.getId());
            }
        }
        if (collect != null && collect.size() > 0) {
            //返回展示数据 方便后期 删条目 新增条目 调排序
            int itemI = reportIntelligenceService.insertBatch(collect);
        }
        return i;
    }

    /**智能
     * 新增用户智能报告 同时新增报告条目
     */
    @Override
    public int generateInsertReportAndItem(List<ReportIntelligenceVo> listForIntelligence, MallMemberUser mallMemberUser, Long batchId, Long memberId,String reportType){
        //查询当前生成的报告单序号
        MemberReportIntelligence reportSort = new MemberReportIntelligence();
        reportSort.setBatchId(batchId);
        reportSort.setUserId(mallMemberUser.getId());
        reportSort.setReportType("0");
        int size = memberReportIntelligenceMapper.selectMemberReportIntelligenceList(reportSort).size();
        //新增报告 获取返回的报告id
        MemberReportIntelligence memberReportIntelligence = new MemberReportIntelligence();
        memberReportIntelligence.setBatchId(batchId);
        memberReportIntelligence.setUserId(memberId);
        //报告类型 0智能生成 1自主选择
        memberReportIntelligence.setReportType(reportType);
        if(batchId.equals(1L)){//提前批
            memberReportIntelligence.setReportName("智能志愿-提前批"+String.valueOf(size+1));
        }else if(batchId.equals(2L)){//本科
            memberReportIntelligence.setReportName("智能志愿-本科段"+String.valueOf(size+1));
        }else if(batchId.equals(4L)){//艺术专科
            memberReportIntelligence.setReportName("智能志愿-艺术专科"+String.valueOf(size+1));
        }

        memberReportIntelligence.setCreateTime(DateUtils.getNowDate());
        int id = memberReportIntelligenceMapper.insertMemberReportIntelligence(memberReportIntelligence);
        //新增到志愿条目表 关联报告id
        Long reportId = memberReportIntelligence.getReportId();
        //计算录取率->排序 录取率高到低 ->按批次取前几
        List<ReportIntelligenceVo> appleList = cleanseData2(listForIntelligence, mallMemberUser, batchId,reportId);
        //返回展示数据 方便后期 删条目 新增条目 调排序
        int i = reportIntelligenceService.insertBatch(appleList);
        return id;
    }
    //计算录取率 排序 获得最终列表
    private List<ReportIntelligenceVo> cleanseData(List<ReportIntelligenceVo> listForIntelligence,MallMemberUser mallMemberUser,Long batchId, Long reportId){
        Integer cultureScore = mallMemberUser.getCultureScore();
        Integer majorScore = mallMemberUser.getMajorScore();
        String  subjectType = mallMemberUser.getSubjectType();
        for (ReportIntelligenceVo vo : listForIntelligence) {
            //计算录取率
            //专业录取率
            Map<String, Object> result= new HashMap<>();
            if (vo.getReference() != null){
               result = mallCountMethodService.getAcceptRateForReport(vo.getReference(), vo.getAcceptRuleId(), cultureScore, majorScore);

            }else{
                result.put("acceptRate", 0);
                result.put("rateType", -2);
            }
             if (!result.isEmpty() && new BigDecimal(result.get("acceptRate").toString()).compareTo(BigDecimal.ZERO) > 0 ){
                vo.setAcceptRate(new BigDecimal(result.get("acceptRate").toString()));
                vo.setShowAcceptRate(vo.getAcceptRate() + "%");
                vo.setRateType((Integer)result.get("rateType"));
            }else{//录取率为0
                vo.setAcceptRate(BigDecimal.ZERO);
                vo.setShowAcceptRate(vo.getAcceptRate().toPlainString() + "%");
                vo.setRateType((Integer)result.get("rateType"));
            }
        }
        //专业多样化
        //取大于录取率60
        listForIntelligence = listForIntelligence.stream().filter(s -> s.getAcceptRate().doubleValue() > 0.60).collect(Collectors.toList());
        //打乱
         Collections.shuffle(listForIntelligence);
        //
        //取前几个
        List<ReportIntelligenceVo> collect = new ArrayList<>();
        if(batchId.equals(1L)){//提前批
            collect = listForIntelligence.stream().limit(2).collect(Collectors.toList());
        }else if(batchId.equals(2L)){//本科A段
            collect = listForIntelligence.stream().limit(36).collect(Collectors.toList());
        }else if(batchId.equals(4L)){//艺术专科
            collect = listForIntelligence.stream().limit(30).collect(Collectors.toList());
        }
        //排序
        Collections.sort(collect,new Comparator<ReportIntelligenceVo>() {
            public int compare(ReportIntelligenceVo firstMapEntry, ReportIntelligenceVo secondMapEntry) {
                BigDecimal   tag1=(BigDecimal) firstMapEntry.getAcceptRate();
                BigDecimal   tag2=(BigDecimal) secondMapEntry.getAcceptRate();
                //两者相等 自反性
                if (tag1 == null && tag2 == null) {
                    return 0;
                }
                if (tag1 == null) {
                    return -1;
                }
                if (tag2 == null) {
                    return 1;
                }
                if(tag1.compareTo(tag2)==0){
                    return 0;
                }else{
                    return  (tag1.compareTo(tag2)> -1 ?  -1: 1);
                }
            }
        });


        if(null != collect && collect.size()>0 ){
            int  sort = 1;
            for (ReportIntelligenceVo vo : collect) {
                vo.setSort(sort++);
                vo.setCreateTime(DateUtils.getNowDate());
                vo.setReportId(reportId);
                vo.setUserId(mallMemberUser.getId());
            }
        }
        return collect;
    }

    private List<ReportIntelligenceVo> cleanseData2(List<ReportIntelligenceVo> listForIntelligence,MallMemberUser mallMemberUser,Long batchId, Long reportId){
        Integer cultureScore = mallMemberUser.getCultureScore();
        Integer majorScore = mallMemberUser.getMajorScore();
        String  subjectType = mallMemberUser.getSubjectType();
        List<ReportIntelligenceVo> byb = new ArrayList<>();
        List<ReportIntelligenceVo> kmx = new ArrayList<>();
        List<ReportIntelligenceVo> jwt = new ArrayList<>();
        List<ReportIntelligenceVo> kbd = new ArrayList<>();

        // 计算学生各种录取率下的成绩
        List<MallAcceptRule> rules = acceptRuleMapper.selectNewAcceptRule();
        List<UserScoreRuleBO> scoreList = new ArrayList<>();
        // 计算综合分
        CountDownLatch countDownLatch0 = new CountDownLatch(rules.size());
        try {
            for (MallAcceptRule rule : rules) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        BigDecimal totalScore = mallCountMethodService.getTotalScore(cultureScore, majorScore, rule.getAcceptRuleId());

                        List<ReportIntelligenceVo> collect = listForIntelligence.stream().filter(item -> item.getAcceptRuleId() != null && item.getAcceptRuleId().equals(rule.getAcceptRuleId())).collect(Collectors.toList());

                        if (!collect.isEmpty()){
                            CountDownLatch countDownLatch1 = new CountDownLatch(collect.size());
                            try {
                                for (ReportIntelligenceVo vo : collect) {
                                    new Thread(new Runnable() {
                                        @Override
                                        public void run() {

                                                Map<String, Object> result = new HashMap<>();
                                                if (vo.getBatchId() == 4L){
                                                    // 专科
                                                    if (null != vo.getAcceptLowest()){
                                                        //result = mallCountMethodService.zhuankegetAcceptRateForReport(BigDecimal.valueOf(vo.getAcceptLowest()), vo.getAcceptRuleId(), cultureScore, majorScore);
                                                        result = mallCountMethodService.zhuankegetAcceptRateForReport2(BigDecimal.valueOf(vo.getAcceptLowest()), totalScore, cultureScore, majorScore);

                                                    }else{
                                                        result.put("acceptRate", "0");
                                                        result.put("rateType", -2);
                                                    }
                                                }else{
                                                    // 本科
                                                    if (null != vo.getReference()){
                                                        result = mallCountMethodService.getAcceptRateForReport2(vo.getReference(), totalScore, cultureScore, majorScore);

                                                    }else{
                                                        result.put("acceptRate", "0");
                                                        result.put("rateType", -2);
                                                    }
                                                }

                                                if (!result.isEmpty() && new BigDecimal(result.get("acceptRate").toString()).compareTo(BigDecimal.ZERO) > 0 ){
                                                    vo.setAcceptRate(new BigDecimal(result.get("acceptRate").toString()));
                                                    vo.setShowAcceptRate(vo.getAcceptRate() + "%");
                                                    vo.setRateType((Integer)result.get("rateType"));
                                                    switch (vo.getRateType()){
                                                        case 0:
                                                            //0-可冒险
                                                            kmx.add(vo);
                                                            break;
                                                        case 1:
                                                            //1-搏一搏
                                                            byb.add(vo);
                                                            break;
                                                        case 2:
                                                            //2-较稳妥
                                                            jwt.add(vo);
                                                            break;
                                                        case 3:
                                                            //3-可保底
                                                            kbd.add(vo);
                                                            break;
                                                    }
                                                }
                                                countDownLatch1.countDown();
                                        }
                                    }).start();
                                }
                                countDownLatch1.await();
                            }catch (Exception e){
                                e.printStackTrace();
                            }
                        }
                        countDownLatch0.countDown();
                    }
                }).start();
            }
            countDownLatch0.await();
        }catch (Exception e){
            e.printStackTrace();
        }

        //try {
        //    CountDownLatch countDownLatch = new CountDownLatch(listForIntelligence.size());
        //    for (ReportIntelligenceVo vo : listForIntelligence) {
        //        List<UserScoreRuleBO> collect = scoreList.stream().filter(item -> item.getAcceptRuleId().equals(vo.getAcceptRuleId())).collect(Collectors.toList());
        //        if (!collect.isEmpty()){
        //            BigDecimal totalScore = collect.get(0).getTotalScore();
        //            new Thread(new Runnable() {
        //                @Override
        //                public void run() {
        //                    Map<String, Object> result = new HashMap<>();
        //                    if (vo.getBatchId() == 4L){
        //                        // 专科
        //                        if (null != vo.getAcceptLowest()){
        //                            //result = mallCountMethodService.zhuankegetAcceptRateForReport(BigDecimal.valueOf(vo.getAcceptLowest()), vo.getAcceptRuleId(), cultureScore, majorScore);
        //                            result = mallCountMethodService.zhuankegetAcceptRateForReport2(BigDecimal.valueOf(vo.getAcceptLowest()), totalScore, cultureScore, majorScore);
        //
        //                        }else{
        //                            result.put("acceptRate", "0");
        //                            result.put("rateType", -2);
        //                        }
        //                    }else{
        //                        // 本科
        //                        if (null != vo.getReference()){
        //                            result = mallCountMethodService.getAcceptRateForReport2(vo.getReference(), totalScore, cultureScore, majorScore);
        //
        //                        }else{
        //                            result.put("acceptRate", "0");
        //                            result.put("rateType", -2);
        //                        }
        //                    }
        //
        //                    if (!result.isEmpty() && new BigDecimal(result.get("acceptRate").toString()).compareTo(BigDecimal.ZERO) > 0 ){
        //                        vo.setAcceptRate(new BigDecimal(result.get("acceptRate").toString()));
        //                        vo.setShowAcceptRate(vo.getAcceptRate() + "%");
        //                        vo.setRateType((Integer)result.get("rateType"));
        //                        switch (vo.getRateType()){
        //                            case 0:
        //                                //0-可冒险
        //                                kmx.add(vo);
        //                                break;
        //                            case 1:
        //                                //1-搏一搏
        //                                byb.add(vo);
        //                                break;
        //                            case 2:
        //                                //2-较稳妥
        //                                jwt.add(vo);
        //                                break;
        //                            case 3:
        //                                //3-可保底
        //                                kbd.add(vo);
        //                                break;
        //                        }
        //                    }
        //                    //else{//录取率为0
        //                    //    vo.setAcceptRate(BigDecimal.ZERO);
        //                    //    vo.setShowAcceptRate(vo.getAcceptRate().toPlainString() + "%");
        //                    //    vo.setRateType((Integer)result.get("rateType"));
        //                    //    //byb.add(vo);
        //                    //}
        //                    countDownLatch.countDown();
        //                }
        //            }).start();
        //        }
        //    }
        //    countDownLatch.await();
        //}catch (Exception e){
        //    throw new ServiceException("录取率计算异常",500);
        //}
        List<ReportIntelligenceVo> collect = new ArrayList<>();
        // 打乱随机
        Collections.shuffle(byb);
        Collections.shuffle(kmx);
        Collections.shuffle(jwt);
        Collections.shuffle(kbd);

        if(batchId == 1L){//取两个
            List<ReportIntelligenceVo> items = listForIntelligence.stream().filter(item -> item.getAcceptRate().compareTo(new BigDecimal("70")) >= 0).collect(Collectors.toList());
            Collections.shuffle(items); // 打乱随机
            collect = items.stream().limit(2).collect(Collectors.toList());
        }else if(batchId == 2L){
            //本科35个
            List<ReportIntelligenceVo> finalCollect = collect;
            List<List<ReportIntelligenceVo>> alldata = new ArrayList<>();


            alldata.add(kmx);
            alldata.add(jwt);
            alldata.add(byb);
            //alldata.add(kbd);
            try {
                CountDownLatch countDownLatch = new CountDownLatch(alldata.size());
                for (List<ReportIntelligenceVo> target : alldata) {
                    int index = alldata.indexOf(target);

                        new Thread(new Runnable() {
                            @Override
                            public void run() {
                                if (!target.isEmpty()) {
                                    sublistForResult(finalCollect, target, index);
                                }
                                countDownLatch.countDown();
                            }
                        }).start();
                }
                countDownLatch.await();
            }catch (Exception e){
                throw new ServiceException("录取率计算异常",500);
            }


            int d = kbd.size();
            //Collections.shuffle(jwt);
            int remain = 64-finalCollect.size();
            if(remain >= d){
                finalCollect.addAll(kbd);

            }else{
                finalCollect.addAll(kbd.subList(0,remain));
            }
        }else{
            List<ReportIntelligenceVo> finalCollect = collect;
            List<List<ReportIntelligenceVo>> alldata = new ArrayList<>();
            alldata.add(kmx);
            alldata.add(byb);
            alldata.add(jwt);
            try {
                CountDownLatch countDownLatch = new CountDownLatch(alldata.size());
                for (List<ReportIntelligenceVo> target : alldata) {
                    int index = alldata.indexOf(target);
                    new Thread(new Runnable() {
                        @Override
                        public void run() {
                            sublistForResult(finalCollect,target, index);
                            countDownLatch.countDown();
                        }
                    }).start();
                }
                countDownLatch.await();
            }catch (Exception e){
                throw new ServiceException("录取率计算异常",500);
            }

            int d = kbd.size();
            //Collections.shuffle(jwt);
            int remain = 30-finalCollect.size();
            if(remain >= d){
                finalCollect.addAll(kbd);

            }else{
                finalCollect.addAll(kbd.subList(0,remain));

            }
        }
        //排序
        Collections.sort(collect,new Comparator<ReportIntelligenceVo>() {
            public int compare(ReportIntelligenceVo firstMapEntry, ReportIntelligenceVo secondMapEntry) {
                BigDecimal   tag1=(BigDecimal) firstMapEntry.getAcceptRate();
                BigDecimal   tag2=(BigDecimal) secondMapEntry.getAcceptRate();
                //两者相等 自反性
                if (tag1 == null && tag2 == null) {
                    return 0;
                }
                if (tag1 == null) {
                    return -1;
                }
                if (tag2 == null) {
                    return 1;
                }
                if(tag1.compareTo(tag2)==0){
                    return 0;
                }else{
                    return  (tag1.compareTo(tag2)> -1 ?  1: -1);
                }
            }
        });


        if(!collect.isEmpty() ){
            int  sort = 1;
            for (ReportIntelligenceVo vo : collect) {
                vo.setSort(sort++);
                vo.setCreateTime(DateUtils.getNowDate());
                vo.setReportId(reportId);
                vo.setUserId(mallMemberUser.getId());
            }
        }
        return collect;
    }

    private void sublistForResult(List<ReportIntelligenceVo> finalCollect,List<ReportIntelligenceVo> targetList, Integer index){
        int c = targetList.size();
        if (c > 0){
            Collections.shuffle(targetList);

            if ( targetList.get(0).getBatchId() != 4L){
                // 本科
                if (index == 0){
                    // 可冒险5个
                    if(c>=5){
                        finalCollect.addAll(targetList.subList(0,5));
                    }else{
                        finalCollect.addAll(targetList);
                    }
                }else{
                    if(c>=10){
                        finalCollect.addAll(targetList.subList(0,16));
                    }else{
                        finalCollect.addAll(targetList);
                    }
                }

            }else{
                if (index == 0){
                    if(c>=5){
                        finalCollect.addAll(targetList.subList(0,5));
                    }else{
                        finalCollect.addAll(targetList);
                    }
                }else{
                    if(c>=8){
                        finalCollect.addAll(targetList.subList(0,8));
                    }else{
                        finalCollect.addAll(targetList);
                    }
                }

            }
        }


    }


    /**重新生成*/
    @Transactional
    @Override
    public Long reGenerateInsertReportAndItem(List<ReportIntelligenceVo> listForIntelligence, MallMemberUser mallMemberUser, Long batchId, Long memberId,Long reportId,String reportType){
        //先删原报告
        int a = memberReportIntelligenceService.deleteMemberReportIntelligenceByReportId(reportId);


        //新增报告 获取返回的报告id
        MemberReportIntelligence memberReportIntelligence = new MemberReportIntelligence();
        memberReportIntelligence.setBatchId(batchId);
        memberReportIntelligence.setUserId(memberId);
        //报告类型 0智能生成 1自主选择
        memberReportIntelligence.setReportType(reportType);
        //查询当前生成的报告单序号
        int size = memberReportIntelligenceMapper.selectMemberReportIntelligenceList(memberReportIntelligence).size();
        if(batchId.equals(1L)){//提前批
            memberReportIntelligence.setReportName("智能志愿-提前批"+String.valueOf(size+1));
        }else if(batchId.equals(2L)){//本科A段
            memberReportIntelligence.setReportName("智能志愿-本科段"+String.valueOf(size+1));
        }else if(batchId.equals(4L)){//艺术专科
            memberReportIntelligence.setReportName("智能志愿-艺术专科"+String.valueOf(size+1));
        }

        memberReportIntelligence.setCreateTime(DateUtils.getNowDate());
        int id = memberReportIntelligenceMapper.insertMemberReportIntelligence(memberReportIntelligence);
        //新增到志愿条目表 关联报告id
        Long newreportId = memberReportIntelligence.getReportId();
        //计算录取率->排序 录取率高到低 ->按批次取前几
        List<ReportIntelligenceVo> appleList = cleanseData(listForIntelligence, mallMemberUser, batchId,newreportId);
        //返回展示数据 方便后期 删条目 新增条目 调排序
        int i = reportIntelligenceService.insertBatch(appleList);
        return memberReportIntelligence.getReportId();
    }
    /**
     * 修改用户智能志愿报告
     *
     * @param memberReportIntelligence 用户智能志愿报告
     * @return 结果
     */
    @Override
    public int updateMemberReportIntelligence(MemberReportIntelligence memberReportIntelligence)
    {
        memberReportIntelligence.setUpdateTime(DateUtils.getNowDate());
        return memberReportIntelligenceMapper.updateMemberReportIntelligence(memberReportIntelligence);
    }

    /**
     * 批量删除用户智能志愿报告
     *
     * @param reportIds 需要删除的用户智能志愿报告主键
     * @return 结果
     */
    @Override
    public int deleteMemberReportIntelligenceByReportIds(Long[] reportIds)
    {
        return memberReportIntelligenceMapper.deleteMemberReportIntelligenceByReportIds(reportIds);
    }

    /**
     * 删除用户智能志愿报告信息
     *
     * @param reportId 用户智能志愿报告主键
     * @return 结果
     */
    @Override
    public int deleteMemberReportIntelligenceByReportId(Long reportId)
    {
        //先删除条目 再删除报告
        reportIntelligenceMapper.deleteByReportId(reportId);
        return memberReportIntelligenceMapper.deleteMemberReportIntelligenceByReportId(reportId);
    }
}
