Commit 5424fb97 by 阳浪

题库添加类别

parent ee97215e
......@@ -38,6 +38,15 @@ public class ListLibraryVO {
@ApiModelProperty(value = "是否使用 1已使用 2未使用")
private Integer des;
@ApiModelProperty(value = "操作人ID")
Long accountId;
@ApiModelProperty(value = "操作人姓名")
String accountName;
@ApiModelProperty("题库类型:1-测试,2-问卷,3-投票")
private Integer libraryType;
@ApiModelProperty(value = "该题库对应的题目的类型和个数")
private List<TypeAndCountVo> typeAndCountVoList;
......
......@@ -42,6 +42,9 @@ public class QuestionLibraryVO {
@ApiModelProperty(value = "题库标签,多个用逗号分割")
private String libraryLabel;
@ApiModelProperty("题库类型:1-测试,2-问卷,3-投票")
private Integer libraryType;
@ApiModelProperty(value = "备注")
private String comments;
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
......@@ -38,6 +39,11 @@ public class QuestionLibrary extends Model<QuestionLibrary> {
@TableField("library_label")
private String libraryLabel;
@TableField("library_type")
@ApiModelProperty("题库类型:1-测试,2-问卷,3-投票")
private Integer libraryType;
private Integer state;
......
package com.yizhi.application.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.domain.QuestionLibrary;
......@@ -17,16 +18,20 @@ import com.yizhi.application.mapper.TrQuestionLibrarySubjectMapper;
import com.yizhi.application.mapper.TrQuestionSubjectOptionMapper;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.service.IQuestionLibraryService;
import com.yizhi.util.application.date.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -55,8 +60,10 @@ public class QuestionLibraryServiceImpl extends ServiceImpl<QuestionLibraryMappe
TrQuestionLibrarySubjectMapper trQuestionLibrarySubjectMapper;
@Autowired
TrQuestionSubjectOptionMapper trQuestionSubjectOptionMapper;
@Autowired
private RedisTemplate redisTemplate;
@Override
public Boolean importQuestionLibrary(MultipartFile file, Long id) {
/*ExcelImporter excelImporter = (ExcelImporter) ExcelImporter.build(file.getOriginalFilename(),"C:\\file\\dir", file.getName(), properties, this);
excelImporter.handle();*/
......@@ -64,6 +71,7 @@ public class QuestionLibraryServiceImpl extends ServiceImpl<QuestionLibraryMappe
}
@Override
public Boolean importQuestionLibrary(String file, String fileName, Long id) {
/*ExcelImporter excelImporter = (ExcelImporter) ExcelImporter.build(file, "C:\\file\\dir", fileName, properties, this);
......@@ -110,7 +118,7 @@ public class QuestionLibraryServiceImpl extends ServiceImpl<QuestionLibraryMappe
} else {
questionLibrary = new QuestionLibrary();
BeanUtils.copyProperties(que, questionLibrary);
questionLibrary.setLibraryNo("KK00001");
questionLibrary.setLibraryNo(getNumber());
questionLibrary.setOrgId(0L);
questionLibrary.setSiteId(0L);
questionLibrary.setCompanyId(0L);
......@@ -231,12 +239,14 @@ public class QuestionLibraryServiceImpl extends ServiceImpl<QuestionLibraryMappe
}
@Override
public Integer sumNum() {
// TODO Auto-generated method stub
Long siteId = 0L; //先根据siteid=0
return questionLibraryMapper.sumNum(siteId);
}
@Override
public boolean insertQuestionLibraryAndTrQuestionLibrarySubjectService(QuestionLibraryVO questionLibraryVO) {
int questionLibraryCount = 0;
int questionLibraryLibrarySubjectCount = 0;
......@@ -258,7 +268,7 @@ public class QuestionLibraryServiceImpl extends ServiceImpl<QuestionLibraryMappe
questionLibrary.setOrgId(questionLibraryVO.getOrgId());
questionLibrary.setSiteId(questionLibraryVO.getSiteId());
questionLibrary.setCompanyId(questionLibraryVO.getCompanyId());
questionLibrary.setLibraryNo("TK");
questionLibrary.setLibraryNo(getNumber());
// 新增题库
int result = questionLibraryCount = questionLibraryMapper.insert(questionLibrary);
if (result > 0) {
......@@ -324,6 +334,7 @@ public class QuestionLibraryServiceImpl extends ServiceImpl<QuestionLibraryMappe
}
}
@Override
public boolean updateQuestionLibraryAmdTrQuestionLibrarySubjectService(QuestionLibraryVO questionLibraryVO) {
int questionLibraryCount = 0;
int questionLibraryLibrarySubjectCount = 0;
......@@ -337,7 +348,7 @@ public class QuestionLibraryServiceImpl extends ServiceImpl<QuestionLibraryMappe
questionLibrary.setUpdateById(questionLibraryVO.getAccountId());
questionLibrary.setUpdateByName(questionLibraryVO.getAccountName());
questionLibrary.setUpdateTime(createTime);
questionLibrary.setLibraryNo("");
questionLibrary.setLibraryNo(getNumber());
// 修改题库
questionLibraryCount = questionLibraryMapper.updateById(questionLibrary);
......@@ -542,7 +553,29 @@ public class QuestionLibraryServiceImpl extends ServiceImpl<QuestionLibraryMappe
return questionLibraryMapper.examCountBySubjectId(subjectId);
}
@Override
public List<TypeAndCountVo> getTypeAndCount(Long examId, Long libraryId) {
return questionLibraryMapper.getTypeAndCount(examId, libraryId);
}
public String getNumber(){
Long numVal = getIncrement("question:number");
NumberFormat formatter = NumberFormat.getNumberInstance();
formatter.setMinimumIntegerDigits(4);
formatter.setGroupingUsed(false);
String idStr = formatter.format(numVal);
return String.join(DateUtil.format(new Date(),"yyyy"), "TK", idStr);
}
/**
* 获取自增数据
*
* @param key
* @return
*/
public Long getIncrement(String key) {
ValueOperations<String, Long> valueOperations = redisTemplate.opsForValue();
Long t = redisTemplate.getExpire(key);
return ObjectUtil.isEmpty(t) ? valueOperations.increment(key) : valueOperations.increment(key,t);
}
}
......@@ -60,7 +60,8 @@
(case
when ((exists(select library_id from tr_exam_question where state =1 and library_id = a.id)
or
exists(SELECT library_id from tr_exam_answer_question where library_id = a.id ))) then 1 else 2 end) des
exists(SELECT library_id from tr_exam_answer_question where library_id = a.id ))) then 1 else 2 end) des,
a.library_label AS libraryType,a.create_by_name AS accountName,a.library_no AS libraryNo
FROM question_library a
WHERE a.state = 1
<if test="name!=null">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment