更改获取证书编号

This commit is contained in:
wuchunlei
2025-04-29 10:45:06 +08:00
parent f861171fb5
commit d02026567a
3 changed files with 18 additions and 27 deletions

View File

@@ -414,6 +414,7 @@ public class ClassController {
type = "A";
}
userCertificate.setType(type);
userCertificate.setLabelId(5);
MyUserEntity user = (MyUserEntity)userScoreMap.get("user");
userCertificate.setUserId(user.getId());
userCertificate.setClassId(classEntity.getId());

View File

@@ -204,6 +204,7 @@ public class ClassExamController {
if ("2".equals(classExamUser.getType())&&classExamUser.getScore()>=60){
UserCertificate userCertificate = new UserCertificate();
userCertificate.setType("ZK");
userCertificate.setLabelId(8);
userCertificate.setUserId(ShiroUtils.getUId());
CourseEntity courseEntity = courseService.getById(classExamUser.getRelationId());
String courseTitle = courseEntity.getTitle();

View File

@@ -15,6 +15,7 @@ import com.peanut.modules.common.service.ClassEntityService;
import com.peanut.modules.common.service.UserVipService;
import com.peanut.modules.sys.dao.SysUserDao;
import com.peanut.modules.sys.entity.SysUserEntity;
import com.peanut.modules.sys.service.SysDictDataService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.amqp.core.MessagePostProcessor;
@@ -65,6 +66,8 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
private StringRedisTemplate redisTemplate;
@Autowired
private UserVipService userVipService;
@Autowired
private SysDictDataService sysDictDataService;
@Override
public Page getClassModelList(Map<String, Object> params) {
@@ -349,35 +352,21 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
Boolean lock = redisTemplate.opsForValue().setIfAbsent("certificateNoLock", "getNextCertificateNo");
if(lock) {
try {
List<UserCertificate> userCertificateList = userCertificateDao.selectList(new LambdaQueryWrapper<UserCertificate>()
.orderByDesc(UserCertificate::getCreateTime));
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);
}
com.peanut.modules.book.entity.SysDictDataEntity sysDictDataEntity =
sysDictDataService.getOne(new LambdaQueryWrapper<com.peanut.modules.book.entity.SysDictDataEntity>()
.eq(com.peanut.modules.book.entity.SysDictDataEntity::getDictLabel,"userCertificateNo"));
int oldNo = Integer.parseInt(sysDictDataEntity.getDictValue());
sysDictDataEntity.setDictValue(oldNo+1+"");
sysDictDataService.updateById(sysDictDataEntity);
if ("A".equals(type)){
return "NO."+String.format("%06d", oldNo)+courseNamePinyin+"-A";
}else if ("B".equals(type)){
return "NO."+String.format("%06d", oldNo)+courseNamePinyin+"-B";
}else if ("ZK".equals(type)){
return "NO.ZK"+String.format("%06d", oldNo)+courseNamePinyin;
}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 "NO."+String.format("%06d", oldNo)+courseNamePinyin;
}
return res+courseNamePinyin;
}finally {
//解锁
redisTemplate.delete("certificateNoLock");