卡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
private ClassEntityService classEntityService;
@Autowired
private ClassModelService classModelService;
@Autowired
private UserCertificateService userCertificateService;
@Autowired
private CourseService courseService;
@@ -473,76 +475,83 @@ public class ClassController {
//结班后给合格学员发放证书
if ("0".equals(r.get("code").toString())){
ClassEntity classEntity = classEntityService.getById(params.get("classId").toString());
ClassModel classModel = classModelService.getById(classEntity.getModelId());
List<Map<String,Object>> userScoreList = classEntityService.userScoreList(params);
for (Map<String, Object> userScoreMap : userScoreList) {
MyUserEntity user = (MyUserEntity)userScoreMap.get("user");
if (new BigDecimal(userScoreMap.get("userScore").toString()).compareTo(new BigDecimal(60))>=0){
UserCertificate userCertificate = new UserCertificate();
userCertificate.setTitle(classEntity.getTitle());
String type = "B";
if (new BigDecimal(userScoreMap.get("userScore").toString()).compareTo(new BigDecimal(70))>=0){
type = "A";
}
userCertificate.setType(type);
userCertificate.setLabelId(5);
userCertificate.setUserId(user.getId());
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 (userScoreList.size() > 0){
for (int i=0;i<userScoreList.size(); i++) {
Map<String, Object> userScoreMap = userScoreList.get(i);
MyUserEntity user = (MyUserEntity)userScoreMap.get("user");
if (new BigDecimal(userScoreMap.get("userScore").toString()).compareTo(new BigDecimal(60))>=0){
UserCertificate userCertificate = new UserCertificate();
userCertificate.setTitle(classEntity.getTitle());
String type = "B";
//卡一下A证率普通小班A证率为的10%精英班A证率为20%
if (new BigDecimal(userScoreMap.get("userScore").toString()).compareTo(new BigDecimal(70))>=0&&
"2".equals(classModel.getType())?i<=(Math.floor(userScoreList.size()*0.20)):i<=(Math.floor(userScoreList.size()*0.10))){
type = "A";
}
if (StringUtils.isNotEmpty(classCourseInfo.get("titleAbbr").toString())
&&StringUtils.isNotEmpty(classCourseInfo.get("courseETitle").toString())){
String certificateNo = classEntityService.getNextCertificateNo(type,classCourseInfo.get("titleAbbr").toString());
userCertificate.setCertificateNo(certificateNo);
userCertificate.setCourseId((Integer) classCourseInfo.get("courseId"));
if (StringUtils.isNotEmpty(user.getPhoto())&&StringUtils.isNotEmpty(user.getName())){
String startYear = DateUtil.year(classEntity.getStartTime())+"";
String startMonth = DateUtil.month(classEntity.getStartTime())+1+"";
String startDay = DateUtil.dayOfMonth(classEntity.getStartTime())+"";
String endYear = DateUtil.year(classEntity.getEndTime())+"";
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);
userCertificate.setType(type);
userCertificate.setLabelId(5);
userCertificate.setUserId(user.getId());
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())
&&StringUtils.isNotEmpty(classCourseInfo.get("courseETitle").toString())){
String certificateNo = classEntityService.getNextCertificateNo(type,classCourseInfo.get("titleAbbr").toString());
userCertificate.setCertificateNo(certificateNo);
userCertificate.setCourseId((Integer) classCourseInfo.get("courseId"));
if (StringUtils.isNotEmpty(user.getPhoto())&&StringUtils.isNotEmpty(user.getName())){
String startYear = DateUtil.year(classEntity.getStartTime())+"";
String startMonth = DateUtil.month(classEntity.getStartTime())+1+"";
String startDay = DateUtil.dayOfMonth(classEntity.getStartTime())+"";
String endYear = DateUtil.year(classEntity.getEndTime())+"";
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();
notice.setUserId(user.getId());
if ("A".equals(type)){
notice.setContent("您参与的"+classEntity.getTitle()+"小班,已顺利结课,恭喜您," +
"获得"+noticeContent+"课程的A证书在证书管理填写您的相关信息即可出证啦");
SysNotice notice = new SysNotice();
notice.setUserId(user.getId());
if ("A".equals(type)){
notice.setContent("您参与的"+classEntity.getTitle()+"小班,已顺利结课,恭喜您," +
"获得"+noticeContent+"课程的A证书在证书管理填写您的相关信息即可出证啦");
}else {
notice.setContent("您参与的"+classEntity.getTitle()+"小班,已顺利结课,恭喜您," +
"获得"+noticeContent+"课程的B证书在证书管理填写您的相关信息即可出证啦");
}
sysNoticeService.save(notice);
}else {
notice.setContent("您参与的"+classEntity.getTitle()+"小班,已顺利结课,恭喜您," +
"获得"+noticeContent+"课程的B证书在证书管理填写您的相关信息即可出证啦");
SysNotice notice = new SysNotice();
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();
}else {
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 {
}