卡a证通过率

This commit is contained in:
wuchunlei
2025-05-28 09:07:00 +08:00
parent ef6ae58ff7
commit e5fd9a64ff
3 changed files with 91 additions and 62 deletions

View File

@@ -43,6 +43,8 @@ public class ClassController {
@Autowired @Autowired
private ClassEntityService classEntityService; private ClassEntityService classEntityService;
@Autowired @Autowired
private ClassModelService classModelService;
@Autowired
private UserCertificateService userCertificateService; private UserCertificateService userCertificateService;
@Autowired @Autowired
private CourseService courseService; private CourseService courseService;
@@ -473,76 +475,83 @@ public class ClassController {
//结班后给合格学员发放证书 //结班后给合格学员发放证书
if ("0".equals(r.get("code").toString())){ if ("0".equals(r.get("code").toString())){
ClassEntity classEntity = classEntityService.getById(params.get("classId").toString()); ClassEntity classEntity = classEntityService.getById(params.get("classId").toString());
ClassModel classModel = classModelService.getById(classEntity.getModelId());
List<Map<String,Object>> userScoreList = classEntityService.userScoreList(params); List<Map<String,Object>> userScoreList = classEntityService.userScoreList(params);
for (Map<String, Object> userScoreMap : userScoreList) { if (userScoreList.size() > 0){
MyUserEntity user = (MyUserEntity)userScoreMap.get("user"); for (int i=0;i<userScoreList.size(); i++) {
if (new BigDecimal(userScoreMap.get("userScore").toString()).compareTo(new BigDecimal(60))>=0){ Map<String, Object> userScoreMap = userScoreList.get(i);
UserCertificate userCertificate = new UserCertificate(); MyUserEntity user = (MyUserEntity)userScoreMap.get("user");
userCertificate.setTitle(classEntity.getTitle()); if (new BigDecimal(userScoreMap.get("userScore").toString()).compareTo(new BigDecimal(60))>=0){
String type = "B"; UserCertificate userCertificate = new UserCertificate();
if (new BigDecimal(userScoreMap.get("userScore").toString()).compareTo(new BigDecimal(70))>=0){ userCertificate.setTitle(classEntity.getTitle());
type = "A"; String type = "B";
} //卡一下A证率普通小班A证率为的10%精英班A证率为20%
userCertificate.setType(type); if (new BigDecimal(userScoreMap.get("userScore").toString()).compareTo(new BigDecimal(70))>=0&&
userCertificate.setLabelId(5); "2".equals(classModel.getType())?i<=(Math.floor(userScoreList.size()*0.20)):i<=(Math.floor(userScoreList.size()*0.10))){
userCertificate.setUserId(user.getId()); type = "A";
userCertificate.setClassId(classEntity.getId());
//查询小班下得课程信息
String noticeContent = "";
List<Map<String,Object>> classCourseInfoLlist = classEntityService.classCourseInfoClassId(classEntity.getId(),0);
for (Map<String,Object> classCourseInfo:classCourseInfoLlist){
if (StringUtils.isEmpty(noticeContent)){
noticeContent = classCourseInfo.get("courseTitle").toString();
}else {
noticeContent += ""+classCourseInfo.get("courseTitle").toString();
} }
if (StringUtils.isNotEmpty(classCourseInfo.get("titleAbbr").toString()) userCertificate.setType(type);
&&StringUtils.isNotEmpty(classCourseInfo.get("courseETitle").toString())){ userCertificate.setLabelId(5);
String certificateNo = classEntityService.getNextCertificateNo(type,classCourseInfo.get("titleAbbr").toString()); userCertificate.setUserId(user.getId());
userCertificate.setCertificateNo(certificateNo); userCertificate.setClassId(classEntity.getId());
userCertificate.setCourseId((Integer) classCourseInfo.get("courseId")); //查询小班下得课程信息
if (StringUtils.isNotEmpty(user.getPhoto())&&StringUtils.isNotEmpty(user.getName())){ String noticeContent = "";
String startYear = DateUtil.year(classEntity.getStartTime())+""; List<Map<String,Object>> classCourseInfoLlist = classEntityService.classCourseInfoClassId(classEntity.getId(),0);
String startMonth = DateUtil.month(classEntity.getStartTime())+1+""; for (Map<String,Object> classCourseInfo:classCourseInfoLlist){
String startDay = DateUtil.dayOfMonth(classEntity.getStartTime())+""; if (StringUtils.isEmpty(noticeContent)){
String endYear = DateUtil.year(classEntity.getEndTime())+""; noticeContent = classCourseInfo.get("courseTitle").toString();
String endMonth = DateUtil.month(classEntity.getEndTime())+1+""; }else {
String endDay = DateUtil.dayOfMonth(classEntity.getEndTime())+""; noticeContent += ""+classCourseInfo.get("courseTitle").toString();
double keshiTotal = (double)classCourseInfo.get("keshi"); }
String keshi = (keshiTotal+"").replace(".0",""); if (StringUtils.isNotEmpty(classCourseInfo.get("titleAbbr").toString())
String courseTitle = classCourseInfo.get("courseTitle").toString(); &&StringUtils.isNotEmpty(classCourseInfo.get("courseETitle").toString())){
if (courseTitle.contains("")){ String certificateNo = classEntityService.getNextCertificateNo(type,classCourseInfo.get("titleAbbr").toString());
courseTitle = courseTitle.substring(0,courseTitle.indexOf("")); userCertificate.setCertificateNo(certificateNo);
} userCertificate.setCourseId((Integer) classCourseInfo.get("courseId"));
String[] des = {startYear,startMonth,startDay,endYear,endMonth,endDay, if (StringUtils.isNotEmpty(user.getPhoto())&&StringUtils.isNotEmpty(user.getName())){
classEntity.getTitle(),courseTitle,keshi}; String startYear = DateUtil.year(classEntity.getStartTime())+"";
String[] edes = {classCourseInfo.get("courseETitle").toString(),keshi}; String startMonth = DateUtil.month(classEntity.getStartTime())+1+"";
String url = userCertificateService.generateCertificate(type,certificateNo,user.getPhoto(),user.getName(), String startDay = DateUtil.dayOfMonth(classEntity.getStartTime())+"";
des, edes, endYear,endMonth,endDay); String endYear = DateUtil.year(classEntity.getEndTime())+"";
userCertificate.setCertificateUrl(url); String endMonth = DateUtil.month(classEntity.getEndTime())+1+"";
String endDay = DateUtil.dayOfMonth(classEntity.getEndTime())+"";
double keshiTotal = (double)classCourseInfo.get("keshi");
String keshi = (keshiTotal+"").replace(".0","");
String courseTitle = classCourseInfo.get("courseTitle").toString();
if (courseTitle.contains("")){
courseTitle = courseTitle.substring(0,courseTitle.indexOf(""));
}
String[] des = {startYear,startMonth,startDay,endYear,endMonth,endDay,
classEntity.getTitle(),courseTitle,keshi};
String[] edes = {classCourseInfo.get("courseETitle").toString(),keshi};
String url = userCertificateService.generateCertificate(type,certificateNo,user.getPhoto(),user.getName(),
des, edes, endYear,endMonth,endDay);
userCertificate.setCertificateUrl(url);
}
userCertificateService.save(userCertificate);
}else {
R.error("课程未设置英文名或缩写");
} }
userCertificateService.save(userCertificate);
}else {
R.error("课程未设置英文名或缩写");
} }
} SysNotice notice = new SysNotice();
SysNotice notice = new SysNotice(); notice.setUserId(user.getId());
notice.setUserId(user.getId()); if ("A".equals(type)){
if ("A".equals(type)){ notice.setContent("您参与的"+classEntity.getTitle()+"小班,已顺利结课,恭喜您," +
notice.setContent("您参与的"+classEntity.getTitle()+"小班,已顺利结课,恭喜您," + "获得"+noticeContent+"课程的A证书在证书管理填写您的相关信息即可出证啦");
"获得"+noticeContent+"课程的A证书在证书管理填写您的相关信息即可出证啦"); }else {
notice.setContent("您参与的"+classEntity.getTitle()+"小班,已顺利结课,恭喜您," +
"获得"+noticeContent+"课程的B证书在证书管理填写您的相关信息即可出证啦");
}
sysNoticeService.save(notice);
}else { }else {
notice.setContent("您参与的"+classEntity.getTitle()+"小班,已顺利结课,恭喜您," + SysNotice notice = new SysNotice();
"获得"+noticeContent+"课程的B证书在证书管理填写您的相关信息即可出证啦"); notice.setUserId(user.getId());
notice.setContent("您参与的"+classEntity.getTitle()+"小班已经结束,很遗憾,您未获得课程证书。期待您下次能考出好的成绩!");
sysNoticeService.save(notice);
} }
sysNoticeService.save(notice);
}else {
SysNotice notice = new SysNotice();
notice.setUserId(user.getId());
notice.setContent("您参与的"+classEntity.getTitle()+"小班已经结束,很遗憾,您未获得课程证书。期待您下次能考出好的成绩!");
sysNoticeService.save(notice);
} }
} }
return R.ok(); return R.ok();
}else { }else {
return r; return r;

View File

@@ -0,0 +1,7 @@
package com.peanut.modules.common.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.ClassModel;
public interface ClassModelService extends IService<ClassModel> {
}

View File

@@ -0,0 +1,13 @@
package com.peanut.modules.common.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.ClassModelDao;
import com.peanut.modules.common.entity.ClassModel;
import com.peanut.modules.common.service.ClassModelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service("commonClassModelService")
public class ClassModelServiceImpl extends ServiceImpl<ClassModelDao, ClassModel> implements ClassModelService {
}