教育训练处考试制证系统后端
heheng
2025-05-19 3a762add44449332d6d379e361698850f6066e16
exam-system/src/main/java/com/gkhy/exam/institutionalaccess/service/serviceImpl/ThBatchManagerServiceImpl.java
@@ -1,19 +1,17 @@
package com.gkhy.exam.institutionalaccess.service.serviceImpl;
import com.gkhy.exam.institutionalaccess.entity.ThBatchCourse;
import com.gkhy.exam.institutionalaccess.entity.ThBatchCourseChapter;
import com.gkhy.exam.institutionalaccess.entity.ThStudentBatch;
import com.gkhy.exam.institutionalaccess.entity.ThStudyDetail;
import com.gkhy.exam.institutionalaccess.entity.*;
import com.gkhy.exam.institutionalaccess.enums.FinishStatus;
import com.gkhy.exam.institutionalaccess.model.query.ThBatchQuery;
import com.gkhy.exam.institutionalaccess.model.resp.ThBatchCourseRespDTO;
import com.gkhy.exam.institutionalaccess.model.resp.ThCourseChapterRespDTO;
import com.gkhy.exam.institutionalaccess.model.resp.ThStudentCourseRespDTO;
import com.gkhy.exam.institutionalaccess.model.resp.ThStudentStudyRespDTO;
import com.gkhy.exam.institutionalaccess.model.vo.*;
import com.gkhy.exam.institutionalaccess.service.*;
import com.gkhy.exam.institutionalaccess.utils.ConvertTimeUtils;
import com.gkhy.exam.institutionalaccess.utils.SendMessageUtil;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -22,8 +20,8 @@
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
@Service("ThBatchManagerService")
@@ -38,6 +36,13 @@
    private ThStudyDetailService thStudyDetailService;
    @Autowired
    private ThBatchCourseChapterService thBatchCourseChapterService;
    @Autowired
    private ThSubjectTypeService subjectTypeService;
    @Autowired
    private ThStudentManagerService thStudentManagerService;
    @Autowired
    private SendMessageUtil sendMessageUtil;
    @Override
    public List<ThBatchVO> listByPage(ThBatchQuery query) {
@@ -51,6 +56,7 @@
            List<ThBatchCourseChapter> chapterList = thBatchCourseChapterService.getListByBatchUuids(batchUuids);
            for (ThBatchVO thBatchVO : thBatchVOS) {
                thBatchVO.setSubjectName(getObtainSuperiors(thBatchVO.getSubjectCode()));
                //课程
                List<ThBatchCourseVO> collect = batchCourseList.stream()
                        .filter(bc -> bc.getBatchUuid().equals(thBatchVO.getUuid()))
@@ -181,4 +187,59 @@
        }
        return respDTOS;
    }
    //短信提醒
    @Override
    public AjaxResult sendMes(String idcard) {
        ThStudent thStudent = thStudentManagerService.findByIdCard(idcard);
        if (StringUtils.isEmpty(thStudent.getPhone()) || thStudent.getPhone().equals("-")){
            return AjaxResult.error("该学员未绑定手机号");
        }
        //调用短信接口
        String[] phone={thStudent.getPhone()};
        HashMap<String, String> map = new HashMap<>();
        map.put("name",thStudent.getName());
        map.put("platform",thStudent.getInstitutionName());
        Boolean b = sendMessageUtil.sendMessageCheck(phone, map);
        if (b){
            return AjaxResult.success();
        }
        return AjaxResult.error();
    }
    public String getObtainSuperiors(String code){
        List<ThSubjectType> subjectTypeList = subjectTypeService.getSubjectTypeList();
        if(StringUtils.isEmpty(code)){
            return "未知";
        }
        StringBuffer stringBuffer = new StringBuffer();
        String subjectName = "未知";
        ThSubjectType currentSubject = getThSubejctInfoByCode(subjectTypeList,code);
        if(currentSubject != null){
            subjectName = currentSubject.getName();
        }
        //一级
        if(code.length() == 1){
            stringBuffer.append(subjectName);
        }
        //二级
        if(code.length() == 3){
            ThSubjectType parentSubject = getThSubejctInfoByCode(subjectTypeList,currentSubject.getParentCode());
            stringBuffer.append(parentSubject.getName()).append("/").append(subjectName);
        }
        //三级
        if(code.length() == 5){
            ThSubjectType parentSubject = getThSubejctInfoByCode(subjectTypeList,currentSubject.getParentCode());
            ThSubjectType grandpaSubject = getThSubejctInfoByCode(subjectTypeList,parentSubject.getParentCode());
            stringBuffer.append(grandpaSubject.getName()).append("/").append(parentSubject.getName()).append("/").append(subjectName);
        }
        return stringBuffer.toString();
    }
   public ThSubjectType getThSubejctInfoByCode(List<ThSubjectType> list, String code){
       List<ThSubjectType> selectList = list.stream().filter(subjectType -> subjectType.getCode().equals(code)).collect(Collectors.toList());
        if(selectList.size() > 0){
            return selectList.get(0);
        }
        return null;
   }
}