结班后证书发放
This commit is contained in:
@@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URL;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -400,54 +401,91 @@ public class ClassController {
|
||||
return R.ok().put("userCertificate",userCertificate);
|
||||
}
|
||||
|
||||
//生成证书
|
||||
@RequestMapping("/generateCertificateClass")
|
||||
//结班后发放证书
|
||||
@RequestMapping("/generateCertificateByClassEnd")
|
||||
@Transactional
|
||||
public R generateCertificateClass(@RequestBody Map<String,Object> params) {
|
||||
//抢锁
|
||||
Boolean lock = redisTemplate.opsForValue().setIfAbsent("lock", "123");
|
||||
if(lock) {
|
||||
try {
|
||||
//证书类型A a证 B b证 ZK自考
|
||||
String type = params.get("type").toString();
|
||||
MyUserEntity user = ShiroUtils.getUser();
|
||||
String photoUrl = user.getPhoto();//证书人照片
|
||||
String realName = user.getName();//真是姓名
|
||||
public R generateCertificateByClassEnd(@RequestBody Map<String,Object> params){
|
||||
ClassEntity classEntity = classEntityService.getById(params.get("classId").toString());
|
||||
//给合格学员发放证书
|
||||
List<Map<String,Object>> userScoreList = classEntityService.userScoreList(params);
|
||||
for (Map<String, Object> userScoreMap : userScoreList) {
|
||||
if (new BigDecimal(userScoreMap.get("userScore").toString()).compareTo(new BigDecimal(60))>=0){
|
||||
UserCertificate userCertificate = new UserCertificate();
|
||||
userCertificate.setType(type);
|
||||
userCertificate.setUserId(ShiroUtils.getUId());
|
||||
if ("ZK".equals(type)){
|
||||
CourseEntity courseEntity = courseService.getById(params.get("relationId").toString());
|
||||
String courseTitle = courseEntity.getTitle();
|
||||
if (courseTitle.contains("【")){
|
||||
courseTitle = courseEntity.getTitle().substring(0,courseEntity.getTitle().indexOf("【"));
|
||||
userCertificate.setTitle(classEntity.getTitle());
|
||||
String type = "B";
|
||||
if (new BigDecimal(userScoreMap.get("userScore").toString()).compareTo(new BigDecimal(70))>=0){
|
||||
type = "A";
|
||||
}
|
||||
userCertificate.setTitle(courseTitle);
|
||||
ClassExamUser classExamUser = classExamUserService.getOne(new LambdaQueryWrapper<ClassExamUser>()
|
||||
.eq(ClassExamUser::getUserId,ShiroUtils.getUId())
|
||||
.eq(ClassExamUser::getRelationId,params.get("relationId").toString()));
|
||||
String endYear = DateUtil.year(classExamUser.getEndTime())+"";
|
||||
String endMonth = DateUtil.month(classExamUser.getEndTime())+1+"";
|
||||
String endDay = DateUtil.dayOfMonth(classExamUser.getEndTime())+"";
|
||||
String[] description= {endYear,endMonth,endDay,courseTitle};
|
||||
String[] edes = {courseEntity.getEtitle()};
|
||||
String certificateNo = getNextCertificateNo(type,courseEntity.getTitleAbbr());//证书编号
|
||||
String url = userCertificateService.generateCertificate(type,certificateNo,photoUrl,realName, description, edes, endYear,endMonth,endDay);
|
||||
userCertificate.setType(type);
|
||||
MyUserEntity user = (MyUserEntity)userScoreMap.get("user");
|
||||
userCertificate.setUserId(user.getId());
|
||||
userCertificate.setClassId(classEntity.getId());
|
||||
//查询小班下得课程信息
|
||||
List<Map<String,Object>> classCourseInfoLlist = classEntityService.classCourseInfoClassId(classEntity.getId(),0);
|
||||
for (Map<String,Object> classCourseInfo:classCourseInfoLlist){
|
||||
String certificateNo = classEntityService.getNextCertificateNo(type,classCourseInfo.get("titleAbbr").toString());
|
||||
userCertificate.setCertificateNo(certificateNo);
|
||||
userCertificate.setCertificateUrl(url);
|
||||
userCertificate.setCourseId(courseEntity.getId());
|
||||
userCertificateService.save(userCertificate);
|
||||
}else {
|
||||
ClassEntity classEntity = classEntityService.getById(params.get("relationId").toString());
|
||||
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())+"";
|
||||
List<Map<String,Object>> list = classEntityService.classCourseInfoClassId(classEntity.getId());
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//生成证书图片
|
||||
@RequestMapping("/generateCertificateClass")
|
||||
public R generateCertificateClass(@RequestBody Map<String,Object> params) {
|
||||
MyUserEntity user = ShiroUtils.getUser();
|
||||
String photoUrl = user.getPhoto();//证书人照片
|
||||
String realName = user.getName();//真实姓名
|
||||
UserCertificate userCertificate = userCertificateService.getById(params.get("id").toString());
|
||||
String type = userCertificate.getType();//证书类型A a证 B b证 ZK自考
|
||||
if ("ZK".equals(type)){
|
||||
CourseEntity courseEntity = courseService.getById(userCertificate.getCourseId());
|
||||
String courseTitle = userCertificate.getTitle();
|
||||
ClassExamUser classExamUser = classExamUserService.getOne(new LambdaQueryWrapper<ClassExamUser>()
|
||||
.eq(ClassExamUser::getUserId,ShiroUtils.getUId())
|
||||
.eq(ClassExamUser::getRelationId,userCertificate.getCourseId()));
|
||||
String endYear = DateUtil.year(classExamUser.getEndTime())+"";
|
||||
String endMonth = DateUtil.month(classExamUser.getEndTime())+1+"";
|
||||
String endDay = DateUtil.dayOfMonth(classExamUser.getEndTime())+"";
|
||||
String[] description= {endYear,endMonth,endDay,courseTitle};
|
||||
String[] edes = {courseEntity.getEtitle()};
|
||||
String certificateNo = userCertificate.getCertificateNo();//证书编号
|
||||
String url = userCertificateService.generateCertificate(type,certificateNo,photoUrl,realName, description, edes, endYear,endMonth,endDay);
|
||||
userCertificate.setCertificateUrl(url);
|
||||
userCertificateService.updateById(userCertificate);
|
||||
}else {
|
||||
ClassEntity classEntity = classEntityService.getById(userCertificate.getClassId());
|
||||
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())+"";
|
||||
List<Map<String,Object>> list = classEntityService.classCourseInfoClassId(classEntity.getId(),userCertificate.getCourseId());
|
||||
for (Map<String,Object> map:list){
|
||||
userCertificate.setCourseId((Integer) map.get("courseId"));
|
||||
double keshiTotal = (double)map.get("keshi");
|
||||
String keshi = (keshiTotal+"").replace(".0","");
|
||||
String courseTitle = map.get("courseTitle").toString();
|
||||
@@ -457,58 +495,15 @@ public class ClassController {
|
||||
String[] des = {startYear,startMonth,startDay,endYear,endMonth,endDay,
|
||||
classEntity.getTitle(),courseTitle,keshi};
|
||||
String[] edes = {map.get("courseETitle").toString(),keshi};
|
||||
String certificateNo = getNextCertificateNo(type,map.get("titleAbbr").toString());
|
||||
String certificateNo = userCertificate.getCertificateNo();
|
||||
String url = userCertificateService.generateCertificate(type,certificateNo,photoUrl,realName,des, edes, endYear,endMonth,endDay);
|
||||
userCertificate.setCertificateUrl(url);
|
||||
userCertificate.setCertificateNo(certificateNo);
|
||||
userCertificate.setTitle(classEntity.getTitle());
|
||||
userCertificate.setClassId(classEntity.getId());
|
||||
userCertificateService.save(userCertificate);
|
||||
userCertificateService.updateById(userCertificate);
|
||||
}
|
||||
}
|
||||
}finally {
|
||||
//解锁
|
||||
redisTemplate.delete("lock");
|
||||
}
|
||||
}else {
|
||||
generateCertificateClass(params);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//获取下一个编号
|
||||
public String getNextCertificateNo(String type,String courseNamePinyin){
|
||||
List<UserCertificate> userCertificateList = userCertificateService.list(new LambdaQueryWrapper<UserCertificate>()
|
||||
.orderByDesc(UserCertificate::getId));
|
||||
String res = "";
|
||||
if (userCertificateList.size() > 0){
|
||||
UserCertificate u0 = userCertificateList.get(0);
|
||||
String certificateNo = u0.getCertificateNo();
|
||||
int no = 0;
|
||||
if (certificateNo.contains("ZK")){
|
||||
no = Integer.parseInt(certificateNo.substring(5,11))+1;
|
||||
}else {
|
||||
no = Integer.parseInt(certificateNo.substring(3,9))+1;
|
||||
}
|
||||
if ("A".equals(type)){
|
||||
res = "NO."+String.format("%06d", no);
|
||||
}else if ("B".equals(type)){
|
||||
res = "NO."+String.format("%06d", no);
|
||||
}else if ("ZK".equals(type)){
|
||||
res = "NO.ZK"+String.format("%06d", no);
|
||||
}
|
||||
}else {
|
||||
if ("A".equals(type)){
|
||||
res = "NO.000001";
|
||||
}else if ("B".equals(type)){
|
||||
res = "NO.000001";
|
||||
}else if ("ZK".equals(type)){
|
||||
res = "NO.ZK000001";
|
||||
}
|
||||
}
|
||||
return res+courseNamePinyin;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.excel.ExcelUtil;
|
||||
import com.peanut.common.utils.DateUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.ClassExamOption;
|
||||
import com.peanut.modules.common.entity.ClassExamSubject;
|
||||
import com.peanut.modules.common.entity.ClassExamUser;
|
||||
import com.peanut.modules.common.entity.ClassModel;
|
||||
import com.peanut.modules.common.service.ClassExamOptionService;
|
||||
import com.peanut.modules.common.service.ClassExamService;
|
||||
import com.peanut.modules.common.service.ClassExamSubjectService;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.*;
|
||||
import com.peanut.modules.master.service.CourseService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -35,6 +33,12 @@ public class ClassExamController {
|
||||
private ClassExamSubjectService classExamSubjectService;
|
||||
@Autowired
|
||||
private ClassExamOptionService classExamOptionService;
|
||||
@Autowired
|
||||
private CourseService courseService;
|
||||
@Autowired
|
||||
private ClassEntityService classEntityService;
|
||||
@Autowired
|
||||
private UserCertificateService userCertificateService;
|
||||
|
||||
//导入考试题
|
||||
@RequestMapping("/importSubject")
|
||||
@@ -191,8 +195,34 @@ public class ClassExamController {
|
||||
//提交试卷
|
||||
@RequestMapping("/submitExamPaper")
|
||||
public R submitExamPaper(@RequestBody Map<String,Object> params){
|
||||
Object examPaper = classExamService.submitExamPaper(params);
|
||||
return R.ok().put("examPaper",examPaper);
|
||||
ClassExamUser classExamUser = classExamService.submitExamPaper(params);
|
||||
//自考的人成绩达标,发放证书
|
||||
if ("2".equals(classExamUser.getType())&&classExamUser.getScore()>=80){
|
||||
UserCertificate userCertificate = new UserCertificate();
|
||||
userCertificate.setType("ZK");
|
||||
userCertificate.setUserId(ShiroUtils.getUId());
|
||||
CourseEntity courseEntity = courseService.getById(classExamUser.getRelationId());
|
||||
String courseTitle = courseEntity.getTitle();
|
||||
if (courseTitle.contains("【")){
|
||||
courseTitle = courseEntity.getTitle().substring(0,courseEntity.getTitle().indexOf("【"));
|
||||
}
|
||||
userCertificate.setTitle(courseTitle);
|
||||
String certificateNo = classEntityService.getNextCertificateNo("ZK",courseEntity.getTitleAbbr());//证书编号
|
||||
userCertificate.setCertificateNo(certificateNo);
|
||||
if (StringUtils.isNotEmpty(ShiroUtils.getUser().getPhoto())&&StringUtils.isNotEmpty(ShiroUtils.getUser().getName())){
|
||||
String endYear = DateUtil.year(classExamUser.getEndTime())+"";
|
||||
String endMonth = DateUtil.month(classExamUser.getEndTime())+1+"";
|
||||
String endDay = DateUtil.dayOfMonth(classExamUser.getEndTime())+"";
|
||||
String[] description= {endYear,endMonth,endDay,courseTitle};
|
||||
String[] edes = {courseEntity.getEtitle()};
|
||||
String url = userCertificateService.generateCertificate("ZK",certificateNo,ShiroUtils.getUser().getPhoto(),
|
||||
ShiroUtils.getUser().getName(), description, edes, endYear,endMonth,endDay);
|
||||
userCertificate.setCertificateUrl(url);
|
||||
}
|
||||
userCertificate.setCourseId(courseEntity.getId());
|
||||
userCertificateService.save(userCertificate);
|
||||
}
|
||||
return R.ok().put("examPaper",classExamUser);
|
||||
}
|
||||
|
||||
//试卷列表
|
||||
|
||||
@@ -14,11 +14,11 @@ public class ClassExamUser {
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
private String type;
|
||||
private String type;//考试类型 1小班 2自考
|
||||
|
||||
private Integer relationId;//考试类型 1小班 2自考
|
||||
private Integer relationId;//班级id或课程id
|
||||
|
||||
private Integer userId;//班级id或课程id
|
||||
private Integer userId;
|
||||
|
||||
private Integer score;//分数
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ public interface ClassEntityService extends IService<ClassEntity> {
|
||||
|
||||
R updateClassState(Map<String,Object> params);
|
||||
|
||||
String getNextCertificateNo(String type,String courseNamePinyin);
|
||||
|
||||
boolean editClass(Map<String ,Object> params);
|
||||
|
||||
R setUserRole(Map<String ,Object> params);
|
||||
@@ -95,6 +97,6 @@ public interface ClassEntityService extends IService<ClassEntity> {
|
||||
|
||||
List userScoreList(Map<String,Object> params);
|
||||
|
||||
List<Map<String,Object>> classCourseInfoClassId(int classId);
|
||||
List<Map<String,Object>> classCourseInfoClassId(int classId,int courseId);
|
||||
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public interface ClassExamService extends IService<ClassExam> {
|
||||
|
||||
void submitOption(Map<String,Object> params);
|
||||
|
||||
Object submitExamPaper(Map<String,Object> params);
|
||||
ClassExamUser submitExamPaper(Map<String,Object> params);
|
||||
|
||||
Object getExamPaperList(Map<String,Object> params);
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.amqp.core.MessagePostProcessor;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import java.math.BigDecimal;
|
||||
@@ -54,6 +55,8 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
@Autowired
|
||||
private UserCertificateDao userCertificateDao;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
@Override
|
||||
public Page getClassModelList(Map<String, Object> params) {
|
||||
@@ -334,6 +337,51 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//获取下一个编号
|
||||
@Override
|
||||
public String getNextCertificateNo(String type,String courseNamePinyin){
|
||||
//抢锁
|
||||
Boolean lock = redisTemplate.opsForValue().setIfAbsent("certificateNoLock", "getNextCertificateNo");
|
||||
if(lock) {
|
||||
try {
|
||||
List<UserCertificate> userCertificateList = userCertificateDao.selectList(new LambdaQueryWrapper<UserCertificate>()
|
||||
.orderByDesc(UserCertificate::getId));
|
||||
String res = "";
|
||||
if (userCertificateList.size() > 0){
|
||||
UserCertificate u0 = userCertificateList.get(0);
|
||||
String certificateNo = u0.getCertificateNo();
|
||||
int no = 0;
|
||||
if (certificateNo.contains("ZK")){
|
||||
no = Integer.parseInt(certificateNo.substring(5,11))+1;
|
||||
}else {
|
||||
no = Integer.parseInt(certificateNo.substring(3,9))+1;
|
||||
}
|
||||
if ("A".equals(type)){
|
||||
res = "NO."+String.format("%06d", no);
|
||||
}else if ("B".equals(type)){
|
||||
res = "NO."+String.format("%06d", no);
|
||||
}else if ("ZK".equals(type)){
|
||||
res = "NO.ZK"+String.format("%06d", no);
|
||||
}
|
||||
}else {
|
||||
if ("A".equals(type)){
|
||||
res = "NO.000001";
|
||||
}else if ("B".equals(type)){
|
||||
res = "NO.000001";
|
||||
}else if ("ZK".equals(type)){
|
||||
res = "NO.ZK000001";
|
||||
}
|
||||
}
|
||||
return res+courseNamePinyin;
|
||||
}finally {
|
||||
//解锁
|
||||
redisTemplate.delete("certificateNoLock");
|
||||
}
|
||||
}else {
|
||||
return getNextCertificateNo(type,courseNamePinyin);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean editClass(Map<String, Object> params) {
|
||||
ClassEntity c = new ClassEntity();
|
||||
@@ -1302,7 +1350,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String,Object>> classCourseInfoClassId(int classId) {
|
||||
public List<Map<String,Object>> classCourseInfoClassId(int classId,int courseId) {
|
||||
List<Map<String,Object>> res = new ArrayList<>();
|
||||
ClassEntity classEntity = this.baseMapper.selectById(classId);
|
||||
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
@@ -1310,6 +1358,9 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
wrapper.leftJoin(ClassCourse.class,ClassCourse::getCourseId,CourseEntity::getId);
|
||||
wrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassCourse::getModelId);
|
||||
wrapper.eq(ClassModel::getId,classEntity.getModelId());
|
||||
if (courseId!=0){
|
||||
wrapper.eq(CourseEntity::getId,courseId);
|
||||
}
|
||||
List<CourseEntity> courseEntityList = courseDao.selectList(wrapper);
|
||||
for (CourseEntity course:courseEntityList){
|
||||
Map<String,Object> candk = new HashMap<>();
|
||||
|
||||
@@ -278,7 +278,7 @@ public class ClassExamServiceImpl extends ServiceImpl<ClassExamDao, ClassExam> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object submitExamPaper(Map<String, Object> params) {
|
||||
public ClassExamUser submitExamPaper(Map<String, Object> params) {
|
||||
ClassExamUser classExamUser = classExamUserDao.selectById(params.get("id").toString());
|
||||
List<Object> subjectList = JSONUtil.parseArray(classExamUser.getSubject());
|
||||
List<Object> answerList = JSONUtil.parseArray(classExamUser.getAnswer());
|
||||
|
||||
Reference in New Issue
Block a user