package com.zd.airbottle.controller;

import com.zd.airbottle.domain.QpFlowDetail;
import com.zd.airbottle.domain.QpQualificationApply;
import com.zd.airbottle.domain.QpQualificationApplyRecord;
import com.zd.airbottle.domain.vo.*;
import com.zd.airbottle.service.*;
import com.zd.common.core.domain.R;
import com.zd.common.core.exception.ServiceException;
import com.zd.common.core.utils.poi.ExcelUtil;
import com.zd.common.core.web.controller.BaseController;
import com.zd.common.core.web.domain.AjaxResult;
import com.zd.common.core.web.domain.ResultData;
import com.zd.common.core.web.page.TableDataInfo;
import com.zd.common.log.annotation.Log;
import com.zd.common.log.enums.BusinessType;
import com.zd.common.security.service.TokenService;
import com.zd.system.api.domain.SysUser;
import com.zd.system.api.laboratory.RemoteLaboratoryService;
import com.zd.system.api.message.RemoteMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;

/**
 * 用气资格申请Controller
 *
 * @author zd
 * @date 2022-05-10
 */
@RestController
@Api(tags = "【用气资格申请】")
//作者手动加入 ，在接口上加作者@ApiOperationSupport(author = "XXX")
//@ApiSupport(author = Knife4jConfiguration.Author.)
@RequestMapping("/qualificationApply")
public class QpQualificationApplyController extends BaseController
{
    @Autowired
    private IQpQualificationApplyService qpQualificationApplyService;

    @Autowired
    private IQpQualificationApplyDetailService qpQualificationApplyDetailService;

    @Autowired
    private IQpAirBottleService qpAirBottleService;

    @Autowired
    private IQpQualificationApplyRecordService qpQualificationApplyRecordService;

    @Autowired
    private TokenService tokenService;

    @Autowired
    private IQpTaskService qpTaskService;

    @Autowired
    private IQpUsegasApplyService qpUsegasApplyService;

    @Autowired
    private IQpAirGoodsConfigService qpAirGoodsConfigService;

    @Autowired
    private IQpFlowDetailService qpFlowDetailService;

    @Autowired
    private RemoteLaboratoryService remoteLaboratoryService;

    @Autowired
    private RemoteMessageService remoteMessageService;

    /**
     * 查询资格申请列表
     */
    //@PreAuthorize(hasPermi = "airbottle:apply:list")
    //@PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_QUALIFICATIONAPPLY+ PerFun.LIST)
    @GetMapping("/list")
    @ApiOperation(value = "查询资格申请列表")
    public TableDataInfo<QpQualificationApplyVO> list(QpQualificationApplyVO qpQualificationApply)
    {
        //获取当前登录用户信息
        SysUser sysUser = tokenService.getLoginUser().getSysUser();
        qpQualificationApply.setUserId(sysUser.getUserId());//当前登陆人申请数据

        startPage();
        List<QpQualificationApplyVO> list = qpQualificationApplyService.selectQpQualificationApplyList(qpQualificationApply);

        return getDataTable(list);
    }


    /***
     * 资格审核列表
     * @param applyVO
     * @return
     */
    //@PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_QUALIFICATIONAPPLYMANAGE+ "auditList")
    @GetMapping("/auditList")
    @ApiOperation(value = "用气资格管理列表")
    public TableDataInfo<QpQualificationApplyVO> auditList(QpQualificationApplyVO applyVO)
    {
        //获取当前登录用户信息
        SysUser sysUser = tokenService.getLoginUser().getSysUser();

        String type="lead";
        //查询当前用户负责的实验室集合
        /*map.put("userId",sysUser.getUserId());
        R<Object> sub =  remoteLaboratoryService.mySubjectList(map);
        List<Map> listSub = (List<Map>) sub.getData();*/
        List<Map<String, Object>> listSubject = qpQualificationApplyService.selectMySubject(sysUser.getUserId());
        List<Long> subIds = Optional.ofNullable(listSubject).orElseGet(Collections::emptyList).stream()
                .map(a->(Long.parseLong(a.get("id")+""))).collect(Collectors.toList());
        if(subIds.size()>0){
            applyVO.setIds(subIds);
        }

        //登陆人是否有实验中心资格审核权限-用气
        QpFlowDetail zgCheck =  qpFlowDetailService.selectYqCenterByUserIdIs(sysUser.getUserId());
        if(zgCheck!=null){
            applyVO.setZgBoolean(true);
            applyVO.setYqBoolean(true);
            applyVO.setIds(null);
            //applyVO.setDeptId(sysUser.getDeptId());
            type="center";
        }else{
            applyVO.setZgBoolean(false);
            applyVO.setYqBoolean(false);
        }

        startPage();
        List<QpQualificationApplyVO> list = qpQualificationApplyService.selectQpApplyListManageApp(applyVO);
        for (int i=0;i<list.size();i++){
                if("lead".equals(type)){
                    //实验室负责人
                    if(list.get(i).getLeadAuditStatus()==0){
                        list.get(i).setAuditStatus(0);//待审核
                    }else if(list.get(i).getLeadAuditStatus()==1){
                        list.get(i).setAuditStatus(1);//通过
                    }else if(list.get(i).getLeadAuditStatus()==2 ){
                        list.get(i).setAuditStatus(2);//驳回
                    }
                }else if("center".equals(type)){
                    //实验中心
                    if(list.get(i).getCenterAuditStatus()==0){
                        list.get(i).setAuditStatus(0);//待审核
                    }else if(list.get(i).getCenterAuditStatus()==1){
                        list.get(i).setAuditStatus(1);//通过
                    }else if(list.get(i).getCenterAuditStatus()==2 ){
                        list.get(i).setAuditStatus(2);//驳回
                    }
                }

            }
        return getDataTable(list);
    }

    //@PreAuthorize(hasPermi = "airbottle:apply:list")
    //@PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_QUALIFICATIONAPPLY+ PerFun.LIST)
    @GetMapping("/qualificationList")
    @ApiOperation(value = "查询当前用户申请的资格实验室")
    public TableDataInfo<QpQualificationApplyVO> qualificationList()
    {
        //获取当前登录用户信息
        SysUser sysUser = tokenService.getLoginUser().getSysUser();
        QpQualificationApplyVO qpQualificationApply = new QpQualificationApplyVO();
        qpQualificationApply.setUserId(sysUser.getUserId());//当前登陆人申请数据
        qpQualificationApply.setLeadAuditStatus(2);
        qpQualificationApply.setCenterAuditStatus(2);

        List<QpQualificationApplyVO> list = qpQualificationApplyService.selectQpQualificationApplyList(qpQualificationApply);
        return getDataTable(list);
    }

    /**
     * 导出资格申请列表
     */
    @ApiOperation(value = "导出资格申请列表")
    //@PreAuthorize(hasPermi = "airbottle:apply:export")
    //@PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_QUALIFICATIONAPPLY+ PerFun.EXPORT)
    @Log(title = "资格申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QpQualificationApplyVO qpQualificationApply) throws IOException
    {
        //获取当前登录用户信息
        //SysUser sysUser = tokenService.getLoginUser().getSysUser();
        //qpQualificationApply.setApplyUserid(sysUser.getUserId());//当前登陆人申请数据
        qpQualificationApply.setCenterAuditStatus(1);//审核通过的数据
        qpQualificationApply.setRemark("100");
        List<QpQualificationApplyVO> list = qpQualificationApplyService.selectQpQualificationApplyList(qpQualificationApply);

        List<QpQualificationApplyExcelVo> listExcel = new ArrayList<>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        for (QpQualificationApplyVO applyVO:list) {
            QpQualificationApplyExcelVo excelVo = new QpQualificationApplyExcelVo();
            excelVo.setApplyUser(applyVO.getApplyUser());//申请人
            excelVo.setPhone(applyVO.getPhone());//电话
            //excelVo.setLocation(applyVO.getRoom()+"("+applyVO.getLocation()+")");//实验地点
            excelVo.setLocation(applyVO.getLocation());//实验地点
            excelVo.setBottleNumber(applyVO.getBottleNumber());//气瓶数量
            excelVo.setStrTime(sdf.format(applyVO.getStartTime())+"~"+ sdf.format(applyVO.getEndTime()));//使用期限
            listExcel.add(excelVo);
        }
        LocalDate nowDate = LocalDate.now();
        ExcelUtil<QpQualificationApplyExcelVo> util = new ExcelUtil<>(QpQualificationApplyExcelVo.class);
        util.exportExcel(response, listExcel, "资格数据", null, "资格信息导出表"+nowDate);
    }

    /**
     * 获取资格申请详细信息
     */
    @ApiOperation(value = "获取资格申请详细信息")
    // @PreAuthorize(hasPermi = "airbottle:apply:query")
    //@PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_QUALIFICATIONAPPLY+ PerFun.QUERY)
    @GetMapping(value = "/{id}")
    public ResultData<QpQualificationApply> getInfo(@PathVariable("id") Long id)
    {
        return ResultData.success(qpQualificationApplyService.selectQpQualificationApplyById(id));
    }

    /**
     * 获取资格申请详细信息
     */
    @ApiOperation(value = "获取资格申请详细信息")
    //@PreAuthorize(hasPermi = "airbottle:apply:query")
    //@PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_QUALIFICATIONAPPLY+ PerFun.QUERY)
    @GetMapping("/getById")
    public AjaxResult getById( Long id)
    {
        Map<String,Object> map = new HashMap<>();
        //申请单详情
        QpQualificationApply qpQualificationApply =qpQualificationApplyService.selectQpQualificationApplyById(id);
        map.put("apply",qpQualificationApply);

        //申请气瓶详情
        /*QpQualificationApplyDetailVO detailVO = new QpQualificationApplyDetailVO();
        detailVO.setQualificateApplyId(qpQualificationApply.getId());
        List<QpQualificationApplyDetailVO> airBottlelist = qpQualificationApplyDetailService.selectQpQualificationApplyDetailListRelation(detailVO);
        */
        List<QpAirGoodsConfigRelationVo> airBottlelist = qpQualificationApplyDetailService.selectQpQualificationApplyDetailListRelation(qpQualificationApply.getId());
        map.put("airBottlelist",airBottlelist);

        //审核记录
        QpQualificationApplyRecord auditlog = new QpQualificationApplyRecord();
        auditlog.setQualificationApplyId(id);
        List<QpQualificationApplyRecord> auditlist= qpQualificationApplyRecordService.selectQpQualificationApplyRecordList(auditlog);
        map.put("auditlist",auditlist);

        return AjaxResult.success(map);
    }


    /**
     * 获取资格申请详细信息-根据id查询
     */
    @ApiOperation(value = "获取资格申请详细信息-根据id查询")
    //@PreAuthorize(hasPermi = "airbottle:apply:query")
    //@PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_QUALIFICATIONAPPLY+ PerFun.QUERY)
    @GetMapping("/getDetails")
    public AjaxResult getDetails( Long id)
    {
        //获取当前登录用户信息
        SysUser sysUser = tokenService.getLoginUser().getSysUser();
        Map<String,Object> map = new HashMap<>();

        //申请单详情
        QpQualificationApplyVO qpQualificationApply =qpQualificationApplyService.selectQpQualificationApplyById(id);
        map.put("apply",qpQualificationApply);

        boolean isAdmin =false;//是否实验室负责人
        boolean audit = false;//是否有审核资格
        //判断当前的登录用户是否该实验室负责人
        if(sysUser.getUserId().equals(qpQualificationApply.getAdminId()) ) {
            isAdmin=true;
        }

        //待审核或者驳回
        if(0 == qpQualificationApply.getLeadAuditStatus() || 2 == qpQualificationApply.getLeadAuditStatus()){
            //查询是否有审核资格
            /*QpFlowDetailVO qpFlowDetail = new QpFlowDetailVO();
            qpFlowDetail.setUserType(1L);//1实验室 2实验中心
            qpFlowDetail.setUserIds(sysUser.getUserId());//登录人id
            qpFlowDetail.setFlowType(1);//资格申请
            List<QpFlowDetailVO> flowDetailList = qpFlowDetailService.selectQpFlowDetailList(qpFlowDetail);
            if(flowDetailList.size()>0){
                audit=true;
            }*/
            if(sysUser.getUserId().equals(qpQualificationApply.getAdminId()) ) {
                audit=true;
            }
        }else if(1 == qpQualificationApply.getLeadAuditStatus()){
            //查询登录用户是否有实验中心审核资格
            QpFlowDetailVO qpFlowDetail = new QpFlowDetailVO();
            //qpFlowDetail.setUserType(2L);//1实验室 2实验中心
            qpFlowDetail.setUserId(sysUser.getUserId());//登录人id
            //qpFlowDetail.setFlowType(1);//资格申请
            List<QpFlowDetailVO> flowDetailList = qpFlowDetailService.selectQpFlowDetailList(qpFlowDetail);
            if(flowDetailList.size()>0){
                audit=true;
            }
        }
        map.put("isAdmin",isAdmin);
        map.put("audit",audit);

        //申请气瓶详情
        /*QpQualificationApplyDetailVO detailVO = new QpQualificationApplyDetailVO();
        detailVO.setQualificateApplyId(qpQualificationApply.getId());
        List<QpQualificationApplyDetailVO> airBottlelist = qpQualificationApplyDetailService.selectQpQualificationApplyDetailListRelation(detailVO);
        */
        List<QpAirGoodsConfigRelationVo> airBottlelist = qpQualificationApplyDetailService.selectQpQualificationApplyDetailListRelation(qpQualificationApply.getId());
        map.put("airBottlelist",airBottlelist);

        //审核记录
        QpQualificationApplyRecord auditlog = new QpQualificationApplyRecord();
        auditlog.setQualificationApplyId(id);
        List<QpQualificationApplyRecord> auditlist= qpQualificationApplyRecordService.selectQpQualificationApplyRecordList(auditlog);
        map.put("auditlist",auditlist);

        return AjaxResult.success(map);
    }


    /**
     * 新增资格申请
     */
    @ApiOperation(value = "新增资格申请")
    // @PreAuthorize(hasPermi = "airbottle:apply:add")
    @Log(title = "资格申请", businessType = BusinessType.INSERT)
    //@PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_QUALIFICATIONAPPLY+ PerFun.ADD)
    @PostMapping
    public ResultData<Boolean> add(@RequestBody QpQualificationApplyVO qpQualificationApplyVo)
    {
        return ResultData.result(qpQualificationApplyService.insertQpQualificationApply(qpQualificationApplyVo));
    }

    @ApiOperation(value = "新增资格重新申请")
    // @PreAuthorize(hasPermi = "airbottle:apply:add")
    @Log(title = "资格重新申请", businessType = BusinessType.INSERT)
    //@PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_QUALIFICATIONAPPLY+ PerFun.ADD)
    @PostMapping("/reapply")
    public ResultData<Boolean> reapply(@RequestBody QpQualificationApply qpQualificationApply)
    {
        return ResultData.result(qpQualificationApplyService.updateQpQualificationApplyRepeat(qpQualificationApply));
    }

    /**
     * 修改资格申请
     */
    @ApiOperation(value = "修改资格申请")
    // @PreAuthorize(hasPermi = "airbottle:apply:edit")
    //@PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_QUALIFICATIONAPPLY+ PerFun.EDIT)
    @Log(title = "资格申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResultData<Boolean> edit(@RequestBody QpQualificationApply qpQualificationApply)
    {
        return  ResultData.result(qpQualificationApplyService.updateQpQualificationApply(qpQualificationApply));
    }

    /**
     * 实验中心审核
     */
    @ApiOperation(value = "实验中心审核")
    // @PreAuthorize(hasPermi = "airbottle:apply:centerexamine")
    //@PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_QUALIFICATIONAPPLY+ "centerexamine")
    @Log(title = "实验中心审核", businessType = BusinessType.UPDATE)
    @PostMapping("/centerExamine")
    public ResultData<Boolean> centerExamine(@RequestBody QpQualificationApply qpQualificationApply)
    {
        //获取当前登录用户信息
        SysUser sysUser = tokenService.getLoginUser().getSysUser();

        //审核表数据录入
        QpQualificationApplyRecord record = new QpQualificationApplyRecord();
        record.setAuditUser(sysUser.getNickName());
        record.setAuditUserid(sysUser.getUserId());
        record.setAuditTime(new Date());
        record.setAuditStatus(qpQualificationApply.getCenterAuditStatus());
        record.setRemark(qpQualificationApply.getCenterAuditCause());
        record.setQualificationApplyId(qpQualificationApply.getId());
        record.setAuditType(2L);
        qpQualificationApplyRecordService.insertQpQualificationApplyRecord(record);


        qpQualificationApply.setCenterAuditUserid(sysUser.getUserId());
        qpQualificationApply.setCenterAuditUsername(sysUser.getNickName());
        qpQualificationApply.setCenterAuditTime(new Date());

        //消息发送
        QpQualificationApplyVO qualificationApply = qpQualificationApplyService.selectQpQualificationApplyById(qpQualificationApply.getId());
        /*checkType "审核类型 1：资格申请 2：用气申请"),
        checkStatus "审核状态 1：通过 2：已驳回"),
        checkTime "审核时间")*/
        remoteMessageService.check(qualificationApply.getUserId(),1,qpQualificationApply.getCenterAuditStatus(),new Date(),qualificationApply.getId());

        return  ResultData.result(qpQualificationApplyService.updateQpQualificationApply(qpQualificationApply));
    }

    /**
     * 实验室负责人审核
     */
    @ApiOperation(value = "实验室负责人审核")
    // @PreAuthorize(hasPermi = "airbottle:apply:leadexamine")
    //@PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_QUALIFICATIONAPPLY+ "leadexamine")
    @Log(title = "实验室负责人审核", businessType = BusinessType.UPDATE)
    @PostMapping("/leadExamine")
    public ResultData<Boolean> leadExamine(@RequestBody QpQualificationApply qpQualificationApply)
    {
        //获取当前登录用户信息
        SysUser sysUser = tokenService.getLoginUser().getSysUser();

        //审核表数据录入
        QpQualificationApplyRecord record = new QpQualificationApplyRecord();
        record.setAuditUser(sysUser.getNickName());
        record.setAuditUserid(sysUser.getUserId());
        record.setAuditTime(new Date());
        record.setAuditStatus(qpQualificationApply.getLeadAuditStatus());
        record.setRemark(qpQualificationApply.getLeadAuditCause());
        record.setQualificationApplyId(qpQualificationApply.getId());
        record.setAuditType(1L);
        qpQualificationApplyRecordService.insertQpQualificationApplyRecord(record);


        qpQualificationApply.setLeadAuditUserid(sysUser.getUserId());
        qpQualificationApply.setLeadAuditUsername(sysUser.getNickName());
        qpQualificationApply.setLeadAuditTime(new Date());

        if(2==qpQualificationApply.getLeadAuditStatus()){
            //实验室审核驳回时 消息发送
            QpQualificationApplyVO qualificationApply = qpQualificationApplyService.selectQpQualificationApplyById(qpQualificationApply.getId());
            /*checkType "审核类型 1：资格申请 2：用气申请"),
            checkStatus "审核状态 1：通过 2：已驳回"),
            checkTime "审核时间")*/
            remoteMessageService.check(qualificationApply.getUserId(),1,2,new Date(),qualificationApply.getId());
        }
        return  ResultData.result(qpQualificationApplyService.updateQpQualificationApply(qpQualificationApply));
    }

    /**
     * 删除资格申请
     */
    @ApiOperation(value = "删除资格申请")
    // @PreAuthorize(hasPermi = "airbottle:apply:remove")
   // @PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_QUALIFICATIONAPPLY+ PerFun.REMOVE)
    @Log(title = "资格申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public ResultData<Boolean> remove(@PathVariable Long[] ids)
    {
        return ResultData.result(qpQualificationApplyService.deleteQpQualificationApplyByIds(ids));
    }

    /**
     * 获取当前登录用户信息
     */
    @ApiOperation(value = "获取资格申请详细信息")
    @GetMapping("/getLoginUser")
    public ResultData<SysUser> getLoginUser()
    {
        //获取当前登录用户信息
        SysUser sysUser = tokenService.getLoginUser().getSysUser();
        return ResultData.success(sysUser);
    }

    /***
     * 查询所有供应商气瓶信息
     * @param relationVo
     * @return
     */
    @GetMapping("/listAllGoods")
    @ApiOperation(value = "查询资格申请气瓶列表")
    public TableDataInfo<QpAirGoodsConfigRelationVo> listAllGoods(QpAirGoodsConfigRelationVo relationVo)
    {
        startPage();
        List<QpAirGoodsConfigRelationVo> list =  qpAirGoodsConfigService.selectQpAirGoodsConfigRelationList(relationVo);
        return getDataTable(list);
    }

    /***
     * 获取当前登录用户的申请总数
     * @return
     */
    @ApiOperation(value = "获取当前登录用户的申请总数")
    //@PreAuthorize(hasPermi = "airbottle:apply:query")
    //@PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_QUALIFICATIONAPPLY+ PerFun.QUERY)
    @GetMapping("/getUserApplyCount")
    public AjaxResult getUserApplyCount( )
    {
        Map<String,Object> map = new HashMap<>();
        //获取当前登录用户信息
        SysUser sysUser = tokenService.getLoginUser().getSysUser();
        map.put("sysUser",sysUser);
        int zgCount=0;//资格申请总数
        int yqCount=0;//用气申请总数
        int userApplyNumberZg=0;//资格申请通过数
        int userApplyNumberYq=0;//用气申请总数


        //查询当前用户资格申请总数
        QpQualificationApplyVO applyVO = new QpQualificationApplyVO();
        applyVO.setUserId(sysUser.getUserId());
        List<QpQualificationApplyVO> list = qpQualificationApplyService.selectApplyListCount(applyVO);

        for (QpQualificationApplyVO applyvo:list) {
            userApplyNumberZg++;
        }
        if(list.size()>0){
            zgCount=list.size();
        }

        //查询是否有用气资格
        QpUsegasApplyVO usegasApply = new QpUsegasApplyVO();
        usegasApply.setUserId(sysUser.getUserId());
        List<QpUsegasApplyVO>  usegasList= qpUsegasApplyService.selectQpUsegasApplyList(usegasApply);
        for (QpUsegasApplyVO useApplyvo:usegasList) {
            userApplyNumberYq++;
        }
        if(usegasList.size()>0){
            yqCount=usegasList.size();
        }
        map.put("userApplyNumberYq",userApplyNumberYq);
        map.put("userApplyNumberZg",userApplyNumberZg);
        map.put("yqCount",yqCount);
        map.put("zgCount",zgCount);
        return AjaxResult.success(map);
    }

    /***
     * 查询申请的实验室是否有准入资格
     * @param subjectId
     * @return
     */
    @ApiOperation(value = "查询申请的实验室是否有准入资格")
    @GetMapping("/applyCheck")
    public AjaxResult applyCheck(Long subjectId)
    {
        Map<String,Object> map = new HashMap<>();
        SysUser sysUser = tokenService.getLoginUser().getSysUser();
        Integer count=0;
        map.put("userId",sysUser.getUserId());
        if("22".equals(sysUser.getUserType())){
            //学生
            map.put("subjectId",subjectId);
            count = Integer.valueOf(qpQualificationApplyService.checkStudentQualification(map)) ;
            map.put("count",count);
        }else if("11".equals(sysUser.getUserType())){
            //老师
            count =  Integer.valueOf(qpQualificationApplyService.checkTeacherQualification(map));
            map.put("count",count);
        }else{
            throw  new ServiceException("非老师和学生，暂无法申请！");
        }
        return AjaxResult.success(map);
    }

}
