禅道bug修复
This commit is contained in:
parent
02707d6a6b
commit
735eb37858
|
|
@ -87,6 +87,12 @@ public class AddTrainingTaskVo {
|
|||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String createUserName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
/**课件ID*/
|
||||
private List<Integer> coursewareIdList;
|
||||
|
||||
/**课件List*/
|
||||
List<CoursewareVo> coursewareVos;
|
||||
|
||||
/**
|
||||
* 查询条件限制
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -123,6 +123,17 @@
|
|||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- ZXing 二维码生成库 -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>3.5.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>javase</artifactId>
|
||||
<version>3.5.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Minio -->
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import com.bonus.common.exam.vo.TrainingTasksVo;
|
|||
import com.bonus.common.log.annotation.SysLog;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import com.bonus.exam.service.TrainingTasksService;
|
||||
import com.google.zxing.WriterException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -20,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -47,7 +49,14 @@ public class TrainingTasksController extends BaseController {
|
|||
@SysLog(title = "培训任务", businessType = OperaType.QUERY,logType = 0,module = "培训任务->培训任务列表")
|
||||
public TableDataInfo list(ExamParamDto dto) {
|
||||
startPage();
|
||||
List<TrainingTasksVo> list = service.getTrainingTasksList(dto);
|
||||
List<TrainingTasksVo> list = null;
|
||||
try {
|
||||
list = service.getTrainingTasksList(dto);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (WriterException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.bonus.common.core.web.domain.AjaxResult;
|
|||
import com.bonus.common.entity.SysFileInfo;
|
||||
import com.bonus.common.exam.dto.ExamParamDto;
|
||||
import com.bonus.common.exam.vo.AddTrainingTaskVo;
|
||||
import com.bonus.common.exam.vo.CoursewareVo;
|
||||
import com.bonus.common.exam.vo.PersonVo;
|
||||
import com.bonus.common.exam.vo.TrainingTasksVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
|
@ -120,4 +121,24 @@ public interface TrainingTasksMapper {
|
|||
* @return 数据集合
|
||||
*/
|
||||
double getScore(PersonVo vo);
|
||||
|
||||
/**
|
||||
* 保存课件信息
|
||||
* @param coursewareIdList
|
||||
* @param id
|
||||
*/
|
||||
void addTrainingTaskCourseware(@Param("list") List<Integer> coursewareIdList, @Param("trainTaskId")String id);
|
||||
|
||||
/**
|
||||
* 删除课件
|
||||
* @param trainId
|
||||
*/
|
||||
void delTrainingTaskCourseware(String trainId);
|
||||
|
||||
/**
|
||||
* 获取课件列表
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
List<CoursewareVo> getTrainTaskCourseware(ExamParamDto dto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,11 @@ import com.bonus.common.exam.dto.ExamParamDto;
|
|||
import com.bonus.common.exam.vo.AddTrainingTaskVo;
|
||||
import com.bonus.common.exam.vo.PersonVo;
|
||||
import com.bonus.common.exam.vo.TrainingTasksVo;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.google.zxing.WriterException;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -24,7 +27,7 @@ public interface TrainingTasksService {
|
|||
* @param dto 实体类
|
||||
* @return 数据集合
|
||||
*/
|
||||
List<TrainingTasksVo> getTrainingTasksList(ExamParamDto dto);
|
||||
List<TrainingTasksVo> getTrainingTasksList(ExamParamDto dto) throws IOException, WriterException;
|
||||
/**
|
||||
* 开启签到
|
||||
* @param id id
|
||||
|
|
|
|||
|
|
@ -14,6 +14,13 @@ import com.bonus.exam.mapper.TrainingTasksMapper;
|
|||
import com.bonus.exam.service.TrainingTasksService;
|
||||
import com.bonus.system.api.RemoteFileService;
|
||||
import com.bonus.system.api.domain.SysFile;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.WriterException;
|
||||
import com.google.zxing.client.j2se.MatrixToImageWriter;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.qrcode.QRCodeWriter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -24,6 +31,8 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
|
@ -56,8 +65,33 @@ public class TrainingTasksServiceImpl implements TrainingTasksService {
|
|||
* @return 数据集合
|
||||
*/
|
||||
@Override
|
||||
public List<TrainingTasksVo> getTrainingTasksList(ExamParamDto dto) {
|
||||
return mapper.getTrainingTasksList(dto);
|
||||
public List<TrainingTasksVo> getTrainingTasksList(ExamParamDto dto) throws IOException, WriterException {
|
||||
List<TrainingTasksVo> trainingTasksVoList = mapper.getTrainingTasksList(dto);
|
||||
Map<String,Object> res = new HashMap<>();
|
||||
//每条数据生成一个二维码
|
||||
for (TrainingTasksVo trainingTasks:trainingTasksVoList) {
|
||||
res.put("trainingName",trainingTasks.getTrainingName());
|
||||
res.put("trainId",trainingTasks.getId());
|
||||
// 将对象转换为JSON字符串
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonData = objectMapper.writeValueAsString(res);
|
||||
|
||||
// 生成二维码
|
||||
QRCodeWriter qrCodeWriter = new QRCodeWriter();
|
||||
BitMatrix bitMatrix = qrCodeWriter.encode(
|
||||
jsonData,
|
||||
BarcodeFormat.QR_CODE,
|
||||
300,
|
||||
300
|
||||
);
|
||||
|
||||
// 转换为Base64字符串
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
MatrixToImageWriter.writeToStream(bitMatrix, "PNG", outputStream);
|
||||
byte[] imageBytes = outputStream.toByteArray();
|
||||
trainingTasks.setQrCodeUuid(java.util.Base64.getEncoder().encodeToString(imageBytes));
|
||||
}
|
||||
return trainingTasksVoList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -114,8 +148,10 @@ public class TrainingTasksServiceImpl implements TrainingTasksService {
|
|||
if (code == 0) {
|
||||
return AjaxResult.error("新增培训任务失败");
|
||||
}
|
||||
|
||||
|
||||
//保存培训课件
|
||||
if (CollectionUtils.isNotEmpty(vo.getCoursewareIdList())) {
|
||||
mapper.addTrainingTaskCourseware(vo.getCoursewareIdList(), vo.getId());
|
||||
}
|
||||
// 添加学习任务-相关人员
|
||||
List<EkTaskUserVo> taskUserVos = new ArrayList<>();
|
||||
taskUserVos = getTaskUsers(vo.getUserIdList(), Integer.valueOf(vo.getId()));
|
||||
|
|
@ -239,6 +275,9 @@ public class TrainingTasksServiceImpl implements TrainingTasksService {
|
|||
examPaperVo.setQuestionNum(num);
|
||||
}
|
||||
}
|
||||
// 获取学习任务课件
|
||||
List<CoursewareVo> coursewareVos = mapper.getTrainTaskCourseware(dto);
|
||||
vo.setCoursewareVos(coursewareVos);
|
||||
vo.setExamPaperList(examPaperList);
|
||||
vo.setUserIdList(newUserIdList);
|
||||
} catch (Exception e) {
|
||||
|
|
@ -281,7 +320,11 @@ public class TrainingTasksServiceImpl implements TrainingTasksService {
|
|||
learningTaskMapper.delEkTaskUserData(Integer.valueOf(vo.getId()), "2");
|
||||
taskUserVos = getTaskUsers(vo.getUserIdList(), Integer.valueOf(vo.getId()));
|
||||
learningTaskMapper.addEkTaskUserData(taskUserVos);
|
||||
|
||||
// 存在课件则先删除旧课件并重新添加
|
||||
mapper.delTrainingTaskCourseware(vo.getTrainId());
|
||||
if (CollectionUtils.isNotEmpty(vo.getCoursewareIdList())) {
|
||||
mapper.addTrainingTaskCourseware(vo.getCoursewareIdList(), vo.getId());
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(vo.getDelExamPaperIds())) {
|
||||
// 删除考试/练习的试卷数据
|
||||
learningTaskMapper.delExamPapers(vo.getDelExamPaperIds(), "2");
|
||||
|
|
|
|||
|
|
@ -57,6 +57,17 @@
|
|||
VALUES
|
||||
(#{id}, #{filePath}, #{fileSize},#{fileName})
|
||||
</insert>
|
||||
<insert id="addTrainingTaskCourseware">
|
||||
INSERT INTO edu_train_task_courseware(train_task_id, courseware_id,is_active)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{trainTaskId},
|
||||
#{item},
|
||||
'1'
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
<update id="changeSignStatus">
|
||||
UPDATE edu_train_task
|
||||
SET sign_status = #{status}
|
||||
|
|
@ -88,6 +99,9 @@
|
|||
</foreach>
|
||||
|
||||
</delete>
|
||||
<delete id="delTrainingTaskCourseware">
|
||||
DELETE FROM edu_train_task_courseware WHERE train_task_id = #{trainId} AND is_active = '1'
|
||||
</delete>
|
||||
<select id="getTrainingTasksList" resultType="com.bonus.common.exam.vo.TrainingTasksVo">
|
||||
SELECT
|
||||
ett.train_task_id as id,
|
||||
|
|
@ -165,19 +179,19 @@
|
|||
from(
|
||||
SELECT
|
||||
count(1) AS totalNum,
|
||||
'' AS notSign
|
||||
0 AS notSign
|
||||
FROM
|
||||
ek_task_user
|
||||
WHERE
|
||||
task_id =#{id}
|
||||
AND task_type = '2' UNION ALL
|
||||
SELECT
|
||||
'' AS totalNum,
|
||||
0 AS totalNum,
|
||||
count( 1) AS notSign
|
||||
FROM
|
||||
ek_task_user
|
||||
WHERE
|
||||
task_id = #{id} and (sign_time is not null and sign_time != '' or sign_time != 'null')
|
||||
task_id = #{id} and (sign_time is not null and sign_time != null)
|
||||
AND task_type = '2')r
|
||||
</select>
|
||||
<select id="isExistTrainTaskName" resultType="java.lang.Integer">
|
||||
|
|
@ -244,4 +258,13 @@
|
|||
epr.uuid = #{userId}
|
||||
AND estp.study_task_id = #{id}
|
||||
</select>
|
||||
<select id="getTrainTaskCourseware" resultType="com.bonus.common.exam.vo.CoursewareVo">
|
||||
SELECT ec.courseware_id AS coursewareId,
|
||||
ec.courseware_name AS coursewareName,
|
||||
ec.courseware_size AS coursewareSize,
|
||||
ec.study_time AS studyTime
|
||||
FROM edu_train_task_courseware ettc
|
||||
LEFT JOIN edu_courseware ec ON ec.courseware_id = ettc.courseware_id
|
||||
WHERE ettc.train_task_id = #{studyTaskId} AND ettc.is_active = '1'
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue