解决冲突

dev_xd
lijun 2024-10-04 18:49:39 +08:00
commit 4e2e4c831f
17 changed files with 853 additions and 610 deletions

View File

@ -0,0 +1,31 @@
package com.yanzhu.common.core.enums;
/**
*
*/
public enum CraftType {
PTGZ("1", "普通工种"),
TSGZ("2", "特殊工种"),
GLRY("3", "管理人员");
private final String code;
private final String info;
CraftType(String code, String info)
{
this.code = code;
this.info = info;
}
public String getCode()
{
return code;
}
public String getInfo()
{
return info;
}
}

View File

@ -0,0 +1,32 @@
package com.yanzhu.common.core.enums;
/**
*
*
* @author ruoyi
*/
public enum UseStateEnums {
IN("1", "进场"),
OUT("2", "离场");
private final String code;
private final String info;
UseStateEnums(String code, String info)
{
this.code = code;
this.info = info;
}
public String getCode()
{
return code;
}
public String getInfo()
{
return info;
}
}

View File

@ -5,6 +5,8 @@ import com.yanzhu.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.List;
/**
* bus_exam_user
*
@ -39,11 +41,11 @@ public class BusExamUser extends BaseEntity
/** 用户名称 */
@Excel(name = "用户名称")
private Long userNick;
private String userNick;
/** 用户账号 */
@Excel(name = "用户账号")
private Long userName;
private String userName;
/** 试卷名称 */
@Excel(name = "试卷名称")
@ -89,6 +91,9 @@ public class BusExamUser extends BaseEntity
@Excel(name = "删除标识")
private Long isDel;
/** 用户试卷结果信息 */
private List<BusExamUserResult> busExamUserResultList;
public void setId(Long id)
{
this.id = id;
@ -143,19 +148,19 @@ public class BusExamUser extends BaseEntity
return userId;
}
public Long getUserNick() {
public String getUserNick() {
return userNick;
}
public void setUserNick(Long userNick) {
public void setUserNick(String userNick) {
this.userNick = userNick;
}
public Long getUserName() {
public String getUserName() {
return userName;
}
public void setUserName(Long userName) {
public void setUserName(String userName) {
this.userName = userName;
}
@ -259,6 +264,14 @@ public class BusExamUser extends BaseEntity
return isDel;
}
public List<BusExamUserResult> getBusExamUserResultList() {
return busExamUserResultList;
}
public void setBusExamUserResultList(List<BusExamUserResult> busExamUserResultList) {
this.busExamUserResultList = busExamUserResultList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -9,27 +9,41 @@ import org.apache.commons.lang3.builder.ToStringStyle;
* bus_exam_user_result
*
* @author JiangYuQi
* @date 2024-08-25
* @date 2024-10-03
*/
public class BusExamUserResult extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 用户试卷主键 */
@Excel(name = "用户试卷主键")
private Long examUserId;
/** 问题主键 */
@Excel(name = "问题主键")
private Long questionId;
/** 问题描述 */
@Excel(name = "问题描述")
private String questionTitle;
/** 问题类型 */
@Excel(name = "问题类型")
private Long questionType;
/** 问题选项 */
@Excel(name = "问题选项")
private String questionOption;
/** 用户答案 */
@Excel(name = "用户答案")
private String answers;
private String userAnswer;
/** 排序 */
@Excel(name = "排序")
private Long sortBy;
/** 问题答案 */
@Excel(name = "问题答案")
private String answer;
/** 答题结果 */
@Excel(name = "答题结果")
@ -39,6 +53,15 @@ public class BusExamUserResult extends BaseEntity
@Excel(name = "答题得分")
private String useMark;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setExamUserId(Long examUserId)
{
this.examUserId = examUserId;
@ -48,32 +71,58 @@ public class BusExamUserResult extends BaseEntity
{
return examUserId;
}
public void setQuestionId(Long questionId)
public void setQuestionTitle(String questionTitle)
{
this.questionTitle = questionTitle;
}
public String getQuestionTitle()
{
return questionTitle;
}
public Long getQuestionId() {
return questionId;
}
public void setQuestionId(Long questionId) {
this.questionId = questionId;
}
public Long getQuestionId()
{
return questionId;
}
public void setAnswers(String answers)
{
this.answers = answers;
public Long getQuestionType() {
return questionType;
}
public String getAnswers()
{
return answers;
}
public void setSortBy(Long sortBy)
{
this.sortBy = sortBy;
public void setQuestionType(Long questionType) {
this.questionType = questionType;
}
public Long getSortBy()
public void setQuestionOption(String questionOption)
{
return sortBy;
this.questionOption = questionOption;
}
public String getQuestionOption()
{
return questionOption;
}
public void setUserAnswer(String userAnswer)
{
this.userAnswer = userAnswer;
}
public String getUserAnswer()
{
return userAnswer;
}
public void setAnswer(String answer)
{
this.answer = answer;
}
public String getAnswer()
{
return answer;
}
public void setUseRes(String useRes)
{
@ -97,10 +146,12 @@ public class BusExamUserResult extends BaseEntity
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("examUserId", getExamUserId())
.append("questionId", getQuestionId())
.append("answers", getAnswers())
.append("sortBy", getSortBy())
.append("questionTitle", getQuestionTitle())
.append("questionOption", getQuestionOption())
.append("userAnswer", getUserAnswer())
.append("answer", getAnswer())
.append("useRes", getUseRes())
.append("useMark", getUseMark())
.toString();

View File

@ -44,6 +44,14 @@ public interface BusExamInfoMapper
*/
public int updateBusExamInfo(BusExamInfo busExamInfo);
/**
* 使
*
* @param id
* @return
*/
public void updateExamUseNumber(Long id);
/**
*
*

View File

@ -2,6 +2,7 @@ package com.yanzhu.manage.mapper;
import java.util.List;
import com.yanzhu.manage.domain.BusExamUser;
import com.yanzhu.manage.domain.BusExamUserResult;
/**
* Mapper
@ -58,4 +59,30 @@ public interface BusExamUserMapper
* @return
*/
public int deleteBusExamUserByIds(Long[] ids);
/**
*
*
* @param ids
* @return
*/
public int deleteBusExamUserResultByExamUserIds(Long[] ids);
/**
*
*
* @param busExamUserResultList
* @return
*/
public int batchBusExamUserResult(List<BusExamUserResult> busExamUserResultList);
/**
*
*
* @param id ID
* @return
*/
public int deleteBusExamUserResultByExamUserId(Long id);
}

View File

@ -60,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="examType != null and examType != ''"> and bei.exam_type = #{examType}</if>
<if test="craftType != null and craftType != ''"> and bei.craft_type = #{craftType}</if>
<if test="craftPost != null and craftPost != ''"> and bei.craft_post = #{craftPost}</if>
<if test="isDel != null "> and bei.is_del = #{isDel}</if>
</where>
order by bei.id desc
</select>
@ -152,6 +153,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</update>
<update id="updateExamUseNumber" parameterType="Long">
update bus_exam_info set use_number = use_number+1 where id = #{id}
</update>
<delete id="deleteBusExamInfoById" parameterType="Long">
delete from bus_exam_info where id = #{id}
</delete>

View File

@ -62,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="questionType != null "> and beq.question_type = #{questionType} </if>
<if test="questionScope != null and questionScope != ''"> and beq.question_scope = #{questionScope}</if>
<if test="questionDesc != null and questionDesc != ''"> and beq.question_desc = #{questionDesc}</if>
<if test="isDel != null"> and beq.is_del = #{isDel}</if>
</where>
order by beq.id desc
</select>

View File

@ -31,8 +31,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="remark" column="remark" />
</resultMap>
<resultMap id="BusExamUserBusExamUserResultResult" type="BusExamUser" extends="BusExamUserResult">
<collection property="busExamUserResultList" notNullColumn="sub_id" javaType="java.util.List" resultMap="BusExamUserResultResult" />
</resultMap>
<resultMap type="BusExamUserResult" id="BusExamUserResultResult">
<result property="id" column="sub_id" />
<result property="examUserId" column="sub_exam_user_id" />
<result property="questionId" column="sub_question_id" />
<result property="questionTitle" column="sub_question_title" />
<result property="questionType" column="sub_question_type" />
<result property="questionOption" column="sub_question_option" />
<result property="userAnswer" column="sub_user_answer" />
<result property="answer" column="sub_answer" />
<result property="useRes" column="sub_use_res" />
<result property="useMark" column="sub_use_mark" />
</resultMap>
<sql id="selectBusExamUserVo">
select beu.id, beu.com_id, sd.dept_name as com_name, beu.project_id, pi.project_name, beu.user_id, su.user_nick, su.user_name, beu.exam_title, beu.exam_type, beu.craft_type, beu.craft_post, beu.single_num, beu.multiple_num, beu.estimate_num, beu.user_mark, beu.res_status, beu.use_times, beu.is_del, beu.create_by, beu.create_time, beu.update_by, beu.update_time, beu.remark from bus_exam_user beu
select beu.id, beu.com_id, sd.dept_name as com_name, beu.project_id, pi.project_name, beu.user_id, su.nick_name as user_nick, su.user_name, beu.exam_title, beu.exam_type, beu.craft_type, beu.craft_post, beu.single_num, beu.multiple_num, beu.estimate_num, beu.user_mark, beu.res_status, beu.use_times, beu.is_del, beu.create_by, beu.create_time, beu.update_by, beu.update_time, beu.remark from bus_exam_user beu
left join pro_project_info pi on pi.id = beu.project_id
left join sys_dept sd on sd.dept_id = pi.com_id
left join sys_user su on su.user_id = beu.user_id
@ -41,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBusExamUserList" parameterType="BusExamUser" resultMap="BusExamUserResult">
<include refid="selectBusExamUserVo"/>
<where>
beu.is_del = 0
and beu.is_del = 0
<if test="comId != null "> and beu.com_id = #{comId}</if>
<if test="projectId != null "> and beu.project_id = #{projectId}</if>
<if test="activeComId != null "> and beu.com_id = #{activeComId}</if>
@ -58,15 +75,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by beu.id desc
</select>
<select id="selectBusExamUserById" parameterType="Long" resultMap="BusExamUserResult">
<include refid="selectBusExamUserVo"/>
where beu.id = #{id}
<select id="selectBusExamUserById" parameterType="Long" resultMap="BusExamUserBusExamUserResultResult">
select a.id, a.com_id, sd.dept_name as com_name, a.project_id, pi.project_name, a.user_id, su.nick_name as user_nick, su.user_name, a.exam_title, a.exam_type, a.craft_type, a.craft_post, a.single_num, a.multiple_num, a.estimate_num, a.user_mark, a.res_status, a.use_times, a.is_del, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
b.id as sub_id, b.exam_user_id as sub_exam_user_id, b.question_id as sub_question_id, b.question_title as sub_question_title, b.question_type as sub_question_type, b.question_option as sub_question_option, b.user_answer as sub_user_answer, b.answer as sub_answer, b.use_res as sub_use_res, b.use_mark as sub_use_mark
from bus_exam_user a
left join pro_project_info pi on pi.id = a.project_id
left join sys_dept sd on sd.dept_id = a.com_id
left join sys_user su on su.user_id = a.user_id
left join bus_exam_user_result b on b.exam_user_id = a.id
where a.id = #{id}
</select>
<insert id="insertBusExamUser" parameterType="BusExamUser" useGeneratedKeys="true" keyProperty="id">
insert into bus_exam_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deptId != null">dept_id,</if>
<if test="comId != null">com_id,</if>
<if test="projectId != null">project_id,</if>
<if test="userId != null">user_id,</if>
<if test="examTitle != null">exam_title,</if>
@ -87,7 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deptId != null">#{deptId},</if>
<if test="comId != null">#{comId},</if>
<if test="projectId != null">#{projectId},</if>
<if test="userId != null">#{userId},</if>
<if test="examTitle != null">#{examTitle},</if>
@ -112,7 +135,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateBusExamUser" parameterType="BusExamUser">
update bus_exam_user
<trim prefix="SET" suffixOverrides=",">
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="comId != null">com_id = #{comId},</if>
<if test="projectId != null">project_id = #{projectId},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="examTitle != null">exam_title = #{examTitle},</if>
@ -145,4 +168,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<delete id="deleteBusExamUserResultByExamUserIds" parameterType="String">
delete from bus_exam_user_result where exam_user_id in
<foreach item="examUserId" collection="array" open="(" separator="," close=")">
#{examUserId}
</foreach>
</delete>
<delete id="deleteBusExamUserResultByExamUserId" parameterType="Long">
delete from bus_exam_user_result where exam_user_id = #{examUserId}
</delete>
<insert id="batchBusExamUserResult">
insert into bus_exam_user_result( id, exam_user_id, question_id, question_title, question_type, question_option, user_answer, answer, use_res, use_mark) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.id}, #{item.examUserId}, #{item.questionId}, #{item.questionTitle}, #{item.questionType}, #{item.questionOption}, #{item.userAnswer}, #{item.answer}, #{item.useRes}, #{item.useMark})
</foreach>
</insert>
</mapper>

View File

@ -63,17 +63,6 @@ public class BusExamUserController extends BaseController
return success(busExamUserService.selectBusExamUserById(id));
}
/**
*
*/
@RequiresPermissions("manage:busExamUser:add")
@Log(title = "用户试卷", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BusExamUser busExamUser)
{
return success(busExamUserService.insertBusExamUser(busExamUser));
}
/**
*
*/
@ -102,8 +91,8 @@ public class BusExamUserController extends BaseController
*/
@Log(title = "新增试卷考题", businessType = BusinessType.INSERT)
@PostMapping("/push")
public AjaxResult pushBusExamUser(@RequestBody BusExamUser busExamUser)
public AjaxResult pushBusExamUser()
{
return success(busExamUserService.insertBusExamUser(busExamUser));
return success(busExamUserService.insertBusExamUser());
}
}

View File

@ -1,98 +0,0 @@
package com.yanzhu.manage.controller;
import com.yanzhu.common.core.utils.poi.ExcelUtil;
import com.yanzhu.common.core.web.controller.BaseController;
import com.yanzhu.common.core.web.domain.AjaxResult;
import com.yanzhu.common.core.web.page.TableDataInfo;
import com.yanzhu.common.log.annotation.Log;
import com.yanzhu.common.log.enums.BusinessType;
import com.yanzhu.common.security.annotation.RequiresPermissions;
import com.yanzhu.manage.domain.BusExamUserResult;
import com.yanzhu.manage.service.IBusExamUserResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller
*
* @author JiangYuQi
* @date 2024-08-25
*/
@RestController
@RequestMapping("/busExamUserResult")
public class BusExamUserResultController extends BaseController
{
@Autowired
private IBusExamUserResultService busExamUserResultService;
/**
*
*/
@RequiresPermissions("manage:busExamUserResult:list")
@GetMapping("/list")
public TableDataInfo list(BusExamUserResult busExamUserResult)
{
startPage();
List<BusExamUserResult> list = busExamUserResultService.selectBusExamUserResultList(busExamUserResult);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("manage:busExamUserResult:export")
@Log(title = "用户试卷结果", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BusExamUserResult busExamUserResult)
{
List<BusExamUserResult> list = busExamUserResultService.selectBusExamUserResultList(busExamUserResult);
ExcelUtil<BusExamUserResult> util = new ExcelUtil<BusExamUserResult>(BusExamUserResult.class);
util.exportExcel(response, list, "用户试卷结果数据");
}
/**
*
*/
@RequiresPermissions("manage:busExamUserResult:query")
@GetMapping(value = "/{examUserId}")
public AjaxResult getInfo(@PathVariable("examUserId") Long examUserId)
{
return success(busExamUserResultService.selectBusExamUserResultByExamUserId(examUserId));
}
/**
*
*/
@RequiresPermissions("manage:busExamUserResult:add")
@Log(title = "用户试卷结果", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BusExamUserResult busExamUserResult)
{
return toAjax(busExamUserResultService.insertBusExamUserResult(busExamUserResult));
}
/**
*
*/
@RequiresPermissions("manage:busExamUserResult:edit")
@Log(title = "用户试卷结果", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BusExamUserResult busExamUserResult)
{
return toAjax(busExamUserResultService.updateBusExamUserResult(busExamUserResult));
}
/**
*
*/
@RequiresPermissions("manage:busExamUserResult:remove")
@Log(title = "用户试卷结果", businessType = BusinessType.DELETE)
@DeleteMapping("/{examUserIds}")
public AjaxResult remove(@PathVariable Long[] examUserIds)
{
return toAjax(busExamUserResultService.deleteBusExamUserResultByExamUserIds(examUserIds));
}
}

View File

@ -30,10 +30,9 @@ public interface IBusExamUserService
/**
*
*
* @param busExamUser
* @return
*/
public BusExamUser insertBusExamUser(BusExamUser busExamUser);
public BusExamUser insertBusExamUser();
/**
*

View File

@ -1,14 +1,24 @@
package com.yanzhu.manage.service.impl;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson2.JSON;
import com.yanzhu.common.core.enums.CraftType;
import com.yanzhu.common.core.enums.IsDelEnums;
import com.yanzhu.common.core.enums.UseStateEnums;
import com.yanzhu.common.core.exception.ServiceException;
import com.yanzhu.common.core.text.Convert;
import com.yanzhu.common.core.utils.DateUtils;
import com.yanzhu.common.core.utils.StringUtils;
import com.yanzhu.common.security.utils.SecurityUtils;
import com.yanzhu.manage.domain.*;
import com.yanzhu.manage.mapper.*;
import com.yanzhu.system.api.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanzhu.manage.mapper.BusExamUserMapper;
import com.yanzhu.manage.domain.BusExamUser;
import com.yanzhu.manage.service.IBusExamUserService;
import org.springframework.transaction.annotation.Transactional;
/**
* Service
@ -19,9 +29,18 @@ import com.yanzhu.manage.service.IBusExamUserService;
@Service
public class BusExamUserServiceImpl implements IBusExamUserService
{
@Autowired
private BusExamInfoMapper busExamInfoMapper;
@Autowired
private BusExamUserMapper busExamUserMapper;
@Autowired
private BusExamQuestionMapper busExamQuestionMapper;
@Autowired
private ProProjectInfoSubdeptsUsersMapper proProjectInfoSubdeptsUsersMapper;
/**
*
*
@ -43,25 +62,178 @@ public class BusExamUserServiceImpl implements IBusExamUserService
@Override
public List<BusExamUser> selectBusExamUserList(BusExamUser busExamUser)
{
busExamUser.setActiveComId(SecurityUtils.getLoginUser().getProjectDeptId());
busExamUser.setActiveProjectId(SecurityUtils.getLoginUser().getProjectId());
return busExamUserMapper.selectBusExamUserList(busExamUser);
}
/**
*
*
* @param busExamUser
*
* @return
*/
@Override
public BusExamUser insertBusExamUser(BusExamUser busExamUser)
@Transactional
public BusExamUser insertBusExamUser()
{
BusExamUser busExamUser = new BusExamUser();
SysUser cache = SecurityUtils.getLoginUser().getSysUser();
busExamUser.setCreateTime(DateUtils.getNowDate());
busExamUserMapper.insertBusExamUser(busExamUser);
// 查询用户详细
ProProjectInfoSubdeptsUsers userQuery = new ProProjectInfoSubdeptsUsers();
userQuery.setUserId(cache.getUserId());
userQuery.setComId(cache.getActiveComId());
userQuery.setProjectId(cache.getActiveProjectId());
userQuery.setUseStatus(UseStateEnums.IN.getCode());
userQuery.setIsDel(IsDelEnums.NO.getCode());
List<ProProjectInfoSubdeptsUsers> userList = proProjectInfoSubdeptsUsersMapper.selectProProjectInfoSubdeptsUsersList(userQuery);
if(StringUtils.isEmpty(userList)){
throw new ServiceException("用户信息异常...不能抽取试题...");
}
ProProjectInfoSubdeptsUsers userEntity = userList.get(0);
// 查询试卷列表
BusExamInfo query = new BusExamInfo();
query.setComId(cache.getActiveComId());
query.setProjectId(cache.getActiveProjectId());
query.setCraftType(userEntity.getCraftType());
// 管理人员获取所有管理类试卷
if(!Objects.equals(CraftType.GLRY.getCode(),query.getCraftType())){
query.setCraftPost(userEntity.getCraftPost());
}
query.setIsDel(IsDelEnums.NO.getCode());
List<BusExamInfo> examInfoList = busExamInfoMapper.selectBusExamInfoList(query);
if(StringUtils.isNotEmpty(examInfoList)){
// 优先从项目试卷中获取试卷、未找到项目试卷则从所有试卷中筛选
List<BusExamInfo> _projectExamInfolist = examInfoList.stream().filter(examInfo -> examInfo.getProjectId() != null)
.collect(Collectors.toList());
Random random = new Random();
BusExamInfo findExamInfo;
if(StringUtils.isNotEmpty(_projectExamInfolist)){
int randomIntBound = random.nextInt(_projectExamInfolist.size());
findExamInfo = _projectExamInfolist.get(randomIntBound);
}else{
int randomIntBound = random.nextInt(examInfoList.size());
findExamInfo = examInfoList.get(randomIntBound);
}
// 获取试卷试题
List<BusExamQuestion> questions = extractExamQuestion(findExamInfo,userEntity.getCraftPost());
// 试题重新排序
Collections.shuffle(questions);
busExamUser.setComId(userEntity.getComId());
busExamUser.setProjectId(userEntity.getProjectId());
busExamUser.setUserId(cache.getUserId());
busExamUser.setExamTitle(findExamInfo.getExamTitle());
busExamUser.setExamType(findExamInfo.getExamType());
busExamUser.setCraftType(userEntity.getCraftType());
busExamUser.setCraftPost(userEntity.getCraftPost());
busExamUser.setSingleNum(findExamInfo.getSingleNum());
busExamUser.setMultipleNum(findExamInfo.getMultipleNum());
busExamUser.setEstimateNum(findExamInfo.getEstimateNum());
busExamUser.setCreateBy(cache.getUserName());
busExamUser.setCreateTime(DateUtils.getNowDate());
busExamUserMapper.insertBusExamUser(busExamUser);
List<BusExamUserResult> busExamUserResultList = new ArrayList<>();
for(BusExamQuestion examQuestion:questions){
BusExamQuestion question = busExamQuestionMapper.selectBusExamQuestionById(examQuestion.getId());
BusExamUserResult entity = new BusExamUserResult();
entity.setExamUserId(busExamUser.getId());
entity.setQuestionId(examQuestion.getId());
entity.setQuestionTitle(examQuestion.getQuestionDesc());
entity.setQuestionType(examQuestion.getQuestionType());
entity.setQuestionOption(JSON.toJSONString(question.getBusExamQuestionResultList()));
entity.setAnswer(question.getQuestionAnswer());
busExamUserResultList.add(entity);
}
busExamUser.setBusExamUserResultList(busExamUserResultList);
busExamUserMapper.batchBusExamUserResult(busExamUserResultList);
// 修改试卷使用次数
busExamInfoMapper.updateExamUseNumber(findExamInfo.getId());
}else{
throw new ServiceException("当前项目未配置试卷信息,请联系管理员配置...");
}
return busExamUser;
}
/**
*
* @param findExamInfo
* @param craftPost
* @return
*/
private List<BusExamQuestion> extractExamQuestion(BusExamInfo findExamInfo,String craftPost){
BusExamQuestion questionQuery = new BusExamQuestion();
questionQuery.setActiveComId(findExamInfo.getComId());
questionQuery.setActiveProjectId(findExamInfo.getProjectId());
questionQuery.setCraftPost(craftPost);
questionQuery.setIsDel(IsDelEnums.NO.getCode());
List<BusExamQuestion> list = new ArrayList<>();
List<BusExamQuestion> allQuestionList = busExamQuestionMapper.selectBusExamQuestionList(questionQuery);
if(StringUtils.isNotEmpty(allQuestionList)){
/**
*
* oxtQuestionList
* dxtQuestionList
* pdtQuestionList
*/
List<BusExamQuestion> oxtQuestionList = allQuestionList.stream().filter(question -> question.getQuestionType() == 1L).collect(Collectors.toList());
List<BusExamQuestion> dxtQuestionList = allQuestionList.stream().filter(question -> question.getQuestionType() == 2L).collect(Collectors.toList());
List<BusExamQuestion> pdtQuestionList = allQuestionList.stream().filter(question -> question.getQuestionType() == 3L).collect(Collectors.toList());
int singleNum = Convert.toInt(findExamInfo.getSingleNum(),0);
if(singleNum>0){
if(Objects.nonNull(oxtQuestionList) && oxtQuestionList.size()>singleNum){
list.addAll(getRandomQuestions(oxtQuestionList,singleNum));
}else{
if(Objects.nonNull(oxtQuestionList)){
list.addAll(oxtQuestionList);
}
}
}
int multipleNum = Convert.toInt(findExamInfo.getMultipleNum(),0);
if(multipleNum>0){
if(Objects.nonNull(dxtQuestionList) && dxtQuestionList.size()>multipleNum){
list.addAll(getRandomQuestions(dxtQuestionList,multipleNum));
}else{
if(Objects.nonNull(dxtQuestionList)){
list.addAll(dxtQuestionList);
}
}
}
int estimateNum = Convert.toInt(findExamInfo.getEstimateNum(),0);
if(singleNum>0){
if(Objects.nonNull(pdtQuestionList) && pdtQuestionList.size()>estimateNum){
list.addAll(getRandomQuestions(pdtQuestionList,estimateNum));
}else{
if(Objects.nonNull(pdtQuestionList)){
list.addAll(pdtQuestionList);
}
}
}
}else{
throw new ServiceException("请联系管理员配置试题...");
}
return list;
}
/**
*
* @param questionList
* @param numberOfQuestions
* @return
*/
private static List<BusExamQuestion> getRandomQuestions(List<BusExamQuestion> questionList, int numberOfQuestions) {
// 打乱列表
Collections.shuffle(questionList);
// 获取前 numberOfQuestions 个元素
return questionList.stream()
.limit(numberOfQuestions)
.collect(Collectors.toList());
}
/**
*
*
@ -98,4 +270,28 @@ public class BusExamUserServiceImpl implements IBusExamUserService
{
return busExamUserMapper.deleteBusExamUserById(id);
}
/**
*
*
* @param busExamUser
*/
public void insertBusExamUserResult(BusExamUser busExamUser)
{
List<BusExamUserResult> busExamUserResultList = busExamUser.getBusExamUserResultList();
Long id = busExamUser.getId();
if (StringUtils.isNotNull(busExamUserResultList))
{
List<BusExamUserResult> list = new ArrayList<BusExamUserResult>();
for (BusExamUserResult busExamUserResult : busExamUserResultList)
{
busExamUserResult.setExamUserId(id);
list.add(busExamUserResult);
}
if (list.size() > 0)
{
busExamUserMapper.batchBusExamUserResult(list);
}
}
}
}

View File

@ -102,12 +102,12 @@
<dict-tag :options="pro_craft_post" :value="scope.row.craftPost"/>
</template>
</el-table-column>
<el-table-column label="单选题数量" align="center" prop="singleNum" width="88"/>
<el-table-column label="单选题分数" align="center" prop="fullMark" width="88"/>
<el-table-column label="多选题数量" align="center" prop="multipleNum" width="88"/>
<el-table-column label="多选题分数" align="center" prop="fullMark" width="88"/>
<el-table-column label="判断题数量" align="center" prop="estimateNum" width="88"/>
<el-table-column label="判断题分数" align="center" prop="fullMark" width="88"/>
<el-table-column label="单选题数量" align="center" prop="singleNum" width="68"/>
<el-table-column label="单选题分数" align="center" prop="singleMark" width="68"/>
<el-table-column label="多选题数量" align="center" prop="multipleNum" width="68"/>
<el-table-column label="多选题分数" align="center" prop="multipleMark" width="68"/>
<el-table-column label="判断题数量" align="center" prop="estimateNum" width="68"/>
<el-table-column label="判断题分数" align="center" prop="estimateMark" width="68"/>
<el-table-column label="通过分数" align="center" prop="passMark" width="100">
<template #default="scope">
<el-tag type="success" effect="dark">{{ scope.row.passMark }}</el-tag>
@ -130,7 +130,6 @@
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['manage:busExamInfo:edit']"></el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['manage:busExamInfo:remove']"></el-button>
<el-button type="danger" link disabled>-</el-button>
</template>
</el-table-column>
</el-table>
@ -145,7 +144,7 @@
<!-- 添加或修改基础试卷对话框 -->
<el-dialog :title="title" v-model="open" width="680px" append-to-body>
<el-form ref="busExamInfoRef" :model="form" :rules="rules" label-width="88px">
<el-form ref="busExamInfoRef" :model="form" :rules="rules" label-width="100px">
<el-form-item label="项目名称" v-if="form.projectId">
<el-tag effect="plain">{{ form.projectName }}</el-tag>
</el-form-item>
@ -210,8 +209,8 @@
</el-form-item>
</el-col>
</el-row>
<el-form-item label="及格分数" prop="passMark">
<el-input v-model.number="form.passMark" placeholder="请输入及格分数" />
<el-form-item label="及格分数线" prop="passMark">
<el-input v-model.number="form.passMark" placeholder="请输入及格分数线" />
</el-form-item>
</el-form>
<template #footer>
@ -319,8 +318,11 @@ function reset() {
craftType: null,
craftPost: null,
singleNum: null,
singleMark: null,
multipleNum: null,
multipleMark: null,
estimateNum: null,
estimateMark: null,
fullMark: null,
passMark: null,
useNumber: null,

View File

@ -9,15 +9,15 @@
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="题描述" prop="questionDesc">
<el-form-item label="题描述" prop="questionDesc">
<el-input
v-model="queryParams.questionDesc"
placeholder="请输入题描述"
placeholder="请输入题描述"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="工种类型" prop="craftType">
<el-form-item label="工种类型" prop="craftType" v-if="false">
<el-select v-model="queryParams.craftType" placeholder="请选择工种类型" clearable>
<el-option
v-for="dict in pro_craft_type"
@ -27,19 +27,23 @@
/>
</el-select>
</el-form-item>
<el-form-item label="工种岗位" prop="craftPost" v-if="queryParams.craftType">
<el-select v-model="queryParams.craftPost" placeholder="请选择工种岗位" clearable>
<el-form-item label="工种岗位" prop="craftPost">
<el-select v-model="queryParams.craftPost" placeholder="请选择工种岗位" filterable clearable>
<el-option
v-for="dict in pro_craft_post"
v-show="dict.elTagClass == queryParams.craftType"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
>
<span style="float: left">{{ dict.label }}</span>
<span style="float: right;color: var(--el-text-color-secondary);font-size: 13px;">
{{ findCraftPost(dict.elTagClass) }}
</span>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="问题类型" prop="questionType">
<el-select v-model="queryParams.questionType" placeholder="请选择问题类型" clearable>
<el-form-item label="题类型" prop="questionType">
<el-select v-model="queryParams.questionType" placeholder="请选择题类型" clearable>
<el-option
v-for="dict in edu_question_type"
:key="dict.value"
@ -48,8 +52,8 @@
/>
</el-select>
</el-form-item>
<el-form-item label="问题范围" prop="questionScope">
<el-select v-model="queryParams.questionScope" placeholder="请选择题范围" clearable>
<el-form-item label="试题范围" prop="questionScope" v-if="false">
<el-select v-model="queryParams.questionScope" placeholder="请选择题范围" clearable>
<el-option
v-for="dict in edu_question_scope"
:key="dict.value"
@ -71,7 +75,7 @@
icon="Plus"
@click="handleAdd"
v-hasPermi="['manage:busExamQuestion:add']"
>新增通用</el-button>
>新增通用</el-button>
</el-col>
<el-col v-if="FirRoles=='admin' || FirRoles=='gsAdmin'" :span="1.5">
<el-button
@ -80,7 +84,7 @@
icon="Plus"
@click="handleAddCom"
v-hasPermi="['manage:busExamQuestion:add']"
>新增公司</el-button>
>新增公司</el-button>
</el-col>
<el-col :span="1.5">
<el-button
@ -89,7 +93,7 @@
icon="Plus"
@click="handleAddProject"
v-hasPermi="['manage:busExamQuestion:add']"
>新增项目</el-button>
>新增项目</el-button>
</el-col>
<el-col :span="1.5">
<el-button
@ -125,26 +129,26 @@
<el-table v-loading="loading" :data="busExamQuestionList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="题编号" align="center" prop="id" width="80"/>
<el-table-column label="所属公司" align="center" prop="comName" >
<el-table-column label="题编号" align="center" prop="id" width="80"/>
<el-table-column label="所属公司" align="center" prop="comName" width="120" :show-overflow-tooltip="true">
<template #default="scope">
<span v-if="scope.row.comId">{{scope.row.comName}}</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="项目名称" align="center" prop="projectName" >
<el-table-column label="项目名称" align="center" prop="projectName" width="120" :show-overflow-tooltip="true">
<template #default="scope">
<span v-if="scope.row.projectId">{{scope.row.projectName}}</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="题描述" align="center" prop="questionDesc" width="200"/>
<el-table-column label="工种类型" align="center" prop="craftType" width="100">
<el-table-column label="题描述" align="center" prop="questionDesc"/>
<el-table-column label="工种类型" align="center" prop="craftType" width="100" v-if="false">
<template #default="scope">
<dict-tag :options="pro_craft_type" :value="scope.row.craftType"/>
</template>
</el-table-column>
<el-table-column label="工种岗位" align="center" prop="craftPost" width="250">
<el-table-column label="工种岗位" align="center" prop="craftPost" width="450">
<template #default="scope">
<div class="flex gap-2">
<el-tag
@ -157,17 +161,17 @@
</div>
</template>
</el-table-column>
<el-table-column label="题类型" align="center" prop="questionType" width="80">
<el-table-column label="题类型" align="center" prop="questionType" width="80">
<template #default="scope">
<dict-tag :options="edu_question_type" :value="scope.row.questionType"/>
</template>
</el-table-column>
<el-table-column label="题范围" align="center" prop="questionScope" width="100">
<el-table-column label="题范围" align="center" prop="questionScope" width="100" v-if="false">
<template #default="scope">
<dict-tag :options="edu_question_scope" :value="scope.row.questionScope"/>
</template>
</el-table-column>
<el-table-column label="题答案" align="center" prop="questionAnswer" />
<el-table-column label="题答案" align="center" prop="questionAnswer" width="100"/>
<el-table-column label="是否启用" align="center" prop="isDel" width="88">
<template #default="scope">
<el-tooltip :content="scope.row.isDel == 0 ? '启用' : '停用'" placement="top">
@ -212,7 +216,7 @@
<el-form-item label="项目名称" v-if="form.projectId">
<el-tag effect="plain">{{ form.projectName }}</el-tag>
</el-form-item>
<el-form-item label="工种类型" prop="craftType">
<el-form-item label="工种类型" prop="craftType" v-if="false">
<el-select v-model="form.craftType" placeholder="请选择工种类型" style="width:100%" @change="changeCraftType">
<el-option
v-for="dict in pro_craft_type"
@ -222,19 +226,17 @@
></el-option>
</el-select>
</el-form-item>
<el-form-item label="工种岗位" prop="craftPost" v-if="form.craftType">
<el-select v-model="form.craftPost" multiple placeholder="请选择工种岗位" style="width:100%">
<el-option
v-for="dict in pro_craft_post"
v-show="dict.elTagClass == form.craftType"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
<el-form-item label="工种岗位" prop="craftPost">
<el-cascader
v-model="form.craftPost"
:options="craftPostOptions"
:props="casProps"
style="width: 100%"
placeholder="请选择工种岗位"
/>
</el-form-item>
<el-form-item label="题类型" prop="questionType">
<el-select v-model="form.questionType" placeholder="请选择题类型" style="width:100%">
<el-form-item label="试题类型" prop="questionType">
<el-select v-model="form.questionType" placeholder="请选择题类型" style="width:100%">
<el-option
v-for="dict in edu_question_type"
:key="dict.value"
@ -243,15 +245,15 @@
></el-option>
</el-select>
</el-form-item>
<el-form-item label="问题范围" prop="questionScope">
<el-form-item label="试题范围" prop="questionScope" v-if="false">
<el-radio-group v-model="form.questionScope">
<el-radio v-for="dict in edu_question_scope" :label="dict.value" border>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="题描述" prop="questionDesc">
<el-input v-model="form.questionDesc" placeholder="请输入题描述" type="textarea" rows="2" maxlength="64" show-word-limit/>
<el-form-item label="题描述" prop="questionDesc">
<el-input v-model="form.questionDesc" placeholder="请输入题描述" type="textarea" rows="2" maxlength="64" show-word-limit/>
</el-form-item>
<el-divider content-position="center">题答案信息</el-divider>
<el-divider content-position="center">题答案信息</el-divider>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" icon="Plus" @click="handleAddBusExamQuestionResult"></el-button>
@ -316,6 +318,7 @@ const multiple = ref(true);
const total = ref(0);
const title = ref("");
const FirRoles = ref("");
const craftPostOptions = ref([]);
const data = reactive({
form: {},
@ -332,14 +335,20 @@ const data = reactive({
rules: {
craftType: [{ required: true, message: "工种类型不能为空", trigger: "change" }],
craftPost: [{ required: true, message: "工种岗位不能为空", trigger: "change" }],
questionType: [{ required: true, message: "题类型不能为空", trigger: "change" }],
questionScope: [{ required: true, message: "题范围不能为空", trigger: "change" }],
questionDesc: [{ required: true, message: "题描述不能为空", trigger: "blur" }]
questionType: [{ required: true, message: "题类型不能为空", trigger: "change" }],
questionScope: [{ required: true, message: "题范围不能为空", trigger: "change" }],
questionDesc: [{ required: true, message: "题描述不能为空", trigger: "blur" }]
}
});
const { queryParams, form, rules } = toRefs(data);
const casProps = {
value: "value",
label: "label",
multiple: true,
};
/** 查询基础题库列表 */
function getList() {
loading.value = true;
@ -408,8 +417,9 @@ function handleSelectionChange(selection) {
/** 新增按钮操作 */
function handleAdd() {
reset();
initPost();
open.value = true;
title.value = "添加题及答案";
title.value = "添加题及答案";
}
/** 新增按钮操作 */
@ -419,10 +429,11 @@ function handleAddCom() {
return false;
}
reset();
initPost();
form.value.comId = userStore.currentComId;
form.value.comName = userStore.currentComName;
open.value = true;
title.value = "添加题及答案";
title.value = "添加题及答案";
}
/** 新增按钮操作 */
@ -432,24 +443,26 @@ function handleAddProject() {
return false;
}
reset();
initPost();
form.value.comId = userStore.currentComId;
form.value.comName = userStore.currentComName;
form.value.projectId = userStore.currentProId;
form.value.projectName = userStore.currentProName;
open.value = true;
title.value = "添加题及答案";
title.value = "添加题及答案";
}
/** 修改按钮操作 */
function handleUpdate(row) {
reset();
initPost();
const _id = row.id || ids.value
getBusExamQuestion(_id).then(response => {
response.data.craftPost = response.data.craftPost.split(',');
response.data.craftPost = JSON.parse(response.data.remark);
form.value = response.data;
busExamQuestionResultList.value = response.data.busExamQuestionResultList;
open.value = true;
title.value = "修改题及答案";
title.value = "修改题及答案";
});
}
@ -458,18 +471,18 @@ function submitForm() {
proxy.$refs["busExamQuestionRef"].validate(valid => {
if (valid) {
if (busExamQuestionResultList.value.length == 0) {
proxy.$modal.msgError("请添加题答案信息");
proxy.$modal.msgError("请添加题答案信息");
return false;
}
let answer = [];
//
busExamQuestionResultList.value.forEach((item,idx) => {
if(!item.opt){
proxy.$modal.msgError("请输入第"+(idx+1)+"个题的答案选项");
proxy.$modal.msgError("请输入第"+(idx+1)+"个题的答案选项");
return false;
}
if(!item.result){
proxy.$modal.msgError("请输入第"+(idx+1)+"个题的答案描述");
proxy.$modal.msgError("请输入第"+(idx+1)+"个题的答案描述");
return false;
}
if (item.isOk != 0) {
@ -480,7 +493,17 @@ function submitForm() {
proxy.$modal.msgError("请选择正确答案信息");
return false;
}
form.value.craftPost = form.value.craftPost.toString();
form.value.remark = JSON.stringify(form.value.craftPost);
let craftTypeValues = [];
let craftPostValues = [];
form.value.craftPost.forEach((item) => {
if(craftTypeValues.indexOf(item[0])<0){
craftTypeValues.push(item[0])
}
craftPostValues.push(item[1]);
});
form.value.craftType = craftTypeValues.toString();
form.value.craftPost = craftPostValues.toString();
form.value.questionAnswer = answer.toString();
form.value.busExamQuestionResultList = busExamQuestionResultList.value;
if (form.value.id != null) {
@ -533,12 +556,12 @@ function handleDelete(row) {
}).catch(() => {});
}
/** 题库题序号 */
/** 题库题序号 */
function rowBusExamQuestionResultIndex({ row, rowIndex }) {
row.index = rowIndex + 1;
}
/** 题库题添加按钮操作 */
/** 题库题添加按钮操作 */
function handleAddBusExamQuestionResult() {
let obj = {};
obj.opt = "";
@ -547,10 +570,10 @@ function handleAddBusExamQuestionResult() {
busExamQuestionResultList.value.push(obj);
}
/** 题库题删除按钮操作 */
/** 题库题删除按钮操作 */
function handleDeleteBusExamQuestionResult() {
if (checkedBusExamQuestionResult.value.length == 0) {
proxy.$modal.msgError("请先选择要删除的题库题数据");
proxy.$modal.msgError("请先选择要删除的题库题数据");
} else {
const busExamQuestionResults = busExamQuestionResultList.value;
const checkedBusExamQuestionResults = checkedBusExamQuestionResult.value;
@ -603,6 +626,28 @@ function initPage() {
}
}
function initPost() {
//
let craftTypeDatas=pro_craft_type._object.pro_craft_type;
let craftPostDatas=pro_craft_post._object.pro_craft_post;
craftTypeDatas.forEach(item =>{
item.children = craftPostDatas.filter(deatil=>deatil.elTagClass==item.value);
});
console.log("DEFAULT" , craftTypeDatas);
craftPostOptions.value = craftTypeDatas;
}
//
function findCraftPost(value) {
let craftTypeDatas=pro_craft_type._object.pro_craft_type;
for(let i=0;i<craftTypeDatas.length;i++){
if(craftTypeDatas[i].value == value){
return craftTypeDatas[i].label;
}
}
return "-";
}
initPage();
getList();
</script>

View File

@ -26,7 +26,7 @@
/>
</el-form-item>
<el-form-item label="工种类型" prop="craftType">
<el-select v-model="queryParams.craftType" placeholder="请选择工种类型" clearable>
<el-select v-model="queryParams.craftType" placeholder="请选择工种类型" @change="changeCraftType" clearable>
<el-option
v-for="dict in pro_craft_type"
:key="dict.value"
@ -62,8 +62,8 @@
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<!-- <el-col :span="1.5">
<el-row v-if="false" :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
@ -71,7 +71,7 @@
@click="handleAdd"
v-hasPermi="['manage:busExamUser:add']"
>新增</el-button>
</el-col> -->
</el-col>
<el-col :span="1.5">
<el-button
type="success"
@ -109,7 +109,6 @@
<el-table-column label="项目名称" align="center" prop="projectName" />
<el-table-column label="用户账号" align="center" prop="userName" />
<el-table-column label="试卷名称" align="center" prop="examTitle" />
<el-table-column label="试卷类型" align="center" prop="examType" />
<el-table-column label="工种类型" align="center" prop="craftType">
<template #default="scope">
<dict-tag :options="pro_craft_type" :value="scope.row.craftType"/>
@ -120,22 +119,30 @@
<dict-tag :options="pro_craft_post" :value="scope.row.craftPost"/>
</template>
</el-table-column>
<el-table-column label="考试用户" align="center" prop="userName">
<template #default="scope">
<el-button link type="primary" @click="handleDetail(scope.row)">{{
scope.row.userName
}}</el-button>
</template>
</el-table-column>
<el-table-column label="考试结果" align="center" prop="resStatus">
<template #default="scope">
<dict-tag :options="edu_res_status" :value="scope.row.resStatus"/>
</template>
</el-table-column>
<el-table-column label="用户分数" align="center" prop="userMark" />
<el-table-column label="答题耗时" align="center" prop="useTimes" />
<el-table-column label="答题时间" align="center" prop="createTime" width="150">
<template #default="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}') }}</span>
</template>
</el-table-column>
<el-table-column label="结果状态" align="center" prop="resStatus">
<template #default="scope">
<dict-tag :options="edu_res_status" :value="scope.row.resStatus"/>
</template>
</el-table-column>
<el-table-column label="答题耗时" align="center" prop="useTimes" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['manage:busExamUser:edit']"></el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['manage:busExamUser:remove']"></el-button>
<el-button v-if="false" link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['manage:busExamUser:edit']"></el-button>
<el-button v-if="false" link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['manage:busExamUser:remove']"></el-button>
<el-button link type="primary" icon="Management" @click="handleDetail(scope.row)" v-hasPermi="['manage:busExamUser:query']"></el-button>
</template>
</el-table-column>
</el-table>
@ -149,82 +156,121 @@
/>
<!-- 添加或修改用户试卷对话框 -->
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
<el-form ref="busExamUserRef" :model="form" :rules="rules" label-width="80px">
<el-form-item label="部门主键" prop="deptId">
<el-input v-model="form.deptId" placeholder="请输入部门主键" />
</el-form-item>
<el-form-item label="项目主键" prop="projectId">
<el-input v-model="form.projectId" placeholder="请输入项目主键" />
</el-form-item>
<el-form-item label="用户主键" prop="userId">
<el-input v-model="form.userId" placeholder="请输入用户主键" />
</el-form-item>
<el-form-item label="试卷名称" prop="examTitle">
<el-input v-model="form.examTitle" placeholder="请输入试卷名称" />
</el-form-item>
<el-form-item label="工种类型" prop="craftType">
<el-select v-model="form.craftType" placeholder="请选择工种类型">
<el-option
v-for="dict in pro_craft_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="工种岗位" prop="craftPost">
<el-select v-model="form.craftPost" placeholder="请选择工种岗位">
<el-option
v-for="dict in pro_craft_post"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="单选题数量" prop="singleNum">
<el-input v-model="form.singleNum" placeholder="请输入单选题数量" />
</el-form-item>
<el-form-item label="多选题数量" prop="multipleNum">
<el-input v-model="form.multipleNum" placeholder="请输入多选题数量" />
</el-form-item>
<el-form-item label="判断题数量" prop="estimateNum">
<el-input v-model="form.estimateNum" placeholder="请输入判断题数量" />
</el-form-item>
<el-form-item label="用户分数" prop="userMark">
<el-input v-model="form.userMark" placeholder="请输入用户分数" />
</el-form-item>
<el-form-item label="结果状态" prop="resStatus">
<el-radio-group v-model="form.resStatus">
<el-radio
v-for="dict in edu_res_status"
:key="dict.value"
:label="parseInt(dict.value)"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="答题耗时" prop="useTimes">
<el-input v-model="form.useTimes" placeholder="请输入答题耗时" />
</el-form-item>
<el-form-item label="删除标识" prop="isDel">
<el-select v-model="form.isDel" placeholder="请选择删除标识">
<el-option
v-for="dict in sys_is_del"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
</el-form>
<el-dialog :title="title" v-model="open" width="880px" append-to-body modal-class="busExamUserDlg">
<el-row class="task_panel">
<el-col :span="6">
<el-statistic class="statistic_div">
<template #title>
<div style="display: inline-flex; align-items: center">
<el-icon style="margin-right: 4px; color: #409eff" :size="12">
<InfoFilled />
</el-icon>
<strong>考试结果</strong>
</div>
</template>
</el-statistic>
<div v-if="form.resStatus == '0'" class="countdown-footer">
<strong style="font-size: 16px; color: #909399; font-weight: 800;">未提交</strong>
</div>
<div v-if="form.resStatus == '1'" class="countdown-footer">
<strong style="font-size: 16px; color: #67c23a; font-weight: 800;">已通过</strong>
</div>
<div v-if="form.resStatus == '2'" class="countdown-footer">
<strong style="font-size: 16px; color: #f56c6c; font-weight: 800;">不通过</strong>
</div>
</el-col>
<el-col :span="6">
<el-statistic class="statistic_div">
<template #title>
<div style="display: inline-flex; align-items: center">
<el-icon style="margin-right: 4px; color: #67c23a" :size="12">
<TrendCharts />
</el-icon>
<strong>考试分数</strong>
</div>
</template>
</el-statistic>
<div class="countdown-footer">
<strong style="font-size: 16px; color: #909399">{{form.userMark!=null?form.userMark:'-'}}</strong>
</div>
</el-col>
<el-col :span="6">
<el-statistic class="statistic_div">
<template #title>
<div style="display: inline-flex; align-items: center">
<el-icon style="margin-right: 4px; color: #409eff" :size="12">
<InfoFilled />
</el-icon>
<strong>答题耗时</strong>
</div>
</template>
</el-statistic>
<div class="countdown-footer">
<strong style="font-size: 16px; color: #909399">{{form.useTimes?form.useTimes:'-'}}</strong>
</div>
</el-col>
<el-col :span="6">
<el-statistic class="statistic_div">
<template #title>
<div style="display: inline-flex; align-items: center">
<el-icon style="margin-right: 4px" :size="12">
<Calendar />
</el-icon>
答题时间
</div>
</template>
</el-statistic>
<div class="countdown-footer">
<strong>{{ parseTime(form.createTime, "{y}-{m}-{d} {h}:{i}") }}</strong>
</div>
</el-col>
</el-row>
<div class="startExamination">
<ul>
<li v-for="(item,idx) in useQuestionList" :key="item.id">
<div class="topicTilte" style="font-weight: bold" ref="topicTilte">
{{ idx + 1 }}<span class="score">[{{ item.questionType==1?'单选题':(item.questionType==2?'多选题':'判断题')}}]</span>{{ item.questionTitle }}
</div>
<template v-if="item.questionType === 1">
<el-radio-group v-model="item.userAnswer" class="ml-4 Selected_item_radio" style="width: 100%">
<div v-for="(option,ox) in item.questionOption" class="Selected_item">
<el-radio :label="option.opt" disabled> {{ option.result }} </el-radio>
</div>
</el-radio-group>
<div :class="item.answer == item.userAnswer?'answer':'error'">
<div class="correctAnswer">正确答案{{ item.answer }}</div>
<div class="testAnswers">试卷答案{{ item.userAnswer }}</div>
</div>
</template>
<template v-if="item.questionType === 2">
<el-checkbox-group v-model="item.userAnswerValues" class="ml-4 Selected_item_radio" style="width: 100%">
<div v-for="option in item.questionOption" class="Selected_item">
<el-checkbox :label="option.opt" disabled> {{ option.result }} </el-checkbox>
</div>
</el-checkbox-group>
<div :class="item.answer == item.userAnswer?'answer':'error'">
<div class="correctAnswer">正确答案{{ item.answer }}</div>
<div class="testAnswers">试卷答案{{ item.userAnswer }}</div>
</div>
</template>
<template v-if="item.questionType === 3">
<el-checkbox-group v-model="item.userAnswerValues" class="ml-4 Selected_item_radio" style="width: 100%">
<div v-for="option in item.questionOption" class="Selected_item">
<el-checkbox :label="option.opt" disabled> {{ option.result }} </el-checkbox>
</div>
</el-checkbox-group>
<div :class="item.answer == item.userAnswer?'answer':'error'">
<div class="correctAnswer">正确答案{{ item.answer }}</div>
<div class="testAnswers">试卷答案{{ item.userAnswer }}</div>
</div>
</template>
</li>
</ul>
</div>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
@ -248,6 +294,7 @@ const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const useQuestionList = ref([]);
const data = reactive({
form: {},
@ -348,6 +395,28 @@ function handleUpdate(row) {
});
}
/** 试卷详情按钮 */
function handleDetail(row) {
reset();
getBusExamUser(row.id).then(response => {
let list = response.data.busExamUserResultList;
list.forEach(item => {
if(item.questionType===2){
if(item.userAnswer==null){
item.userAnswer = "";
}
item.userAnswerValues = item.userAnswer.split(',');
}
item.questionOption = JSON.parse(item.questionOption);
});
console.log("LIST",list);
useQuestionList.value = list;
form.value = response.data;
open.value = true;
title.value = "查看试卷详情";
});
}
/** 提交按钮 */
function submitForm() {
proxy.$refs["busExamUserRef"].validate(valid => {
@ -387,5 +456,131 @@ function handleExport() {
}, `busExamUser_${new Date().getTime()}.xlsx`)
}
/** 改变工种类型 */
function changeCraftType() {
queryParams.value.craftPost = null;
}
getList();
</script>
<style lang="scss" scope>
.el-divider__text{
color: #409eff;
font-weight: 800;
}
.busExamUserDlg{
.el-dialog__body{
margin-top: -25px;
overflow: auto;
max-height: 680px;
}
}
.task_panel {
text-align: center;
margin-bottom: 20px;
}
.statistic_div {
.el-statistic__content {
display: none;
}
}
.startExamination {
ul {
margin: 30px 0;
li {
list-style: none;
margin-top: 10px;
.Selected_item_radio {
display: block;
flex: none;
}
.topicTilte {
.score {
display: inline-block;
margin-right: 10px;
}
}
.Selected_item_fill {
height: 45px;
display: flex;
align-items: center;
}
.answer {
height: 30px;
display: flex;
align-items: center;
border: 1px solid #e1f3d8;
color: #67c23a;
padding: 0 15px;
//margin: 10px 20px 10px 0;
background-color: #f0f9eb;
.correctAnswer {
margin-right: 40px;
}
}
.error {
height: 30px;
display: flex;
align-items: center;
padding: 0 15px;
//margin: 10px 20px 10px 0;
background: #fdf6ec;
border: 1px solid #faecd8;
color: #f56c6c;
.correctAnswer {
margin-right: 40px;
}
}
.CompletionAnswer {
height: 80px;
display: flex;
align-items: center;
border: 1px solid #e1f3d8;
color: #67c23a;
padding: 0 15px;
margin: 10px 20px 10px 0;
background-color: #f0f9eb;
.CompletionAnswerIndex {
width: 50px;
height: 100%;
display: flex;
align-items: center;
border-right: 1px solid #e1f3d8;
margin-right: 20px;
}
.correctAnswer {
margin-right: 40px;
}
}
.CompletionError {
height: 80px;
display: flex;
align-items: center;
padding: 0 15px;
margin: 10px 20px 10px 0;
background: #fdf6ec;
border: 1px solid #faecd8;
color: #f56c6c;
.CompletionAnswerIndex {
width: 25px;
height: 100%;
display: flex;
align-items: center;
border-right: 1px solid #faecd8;
margin-right: 20px;
}
.correctAnswer {
height: 40px;
margin-right: 40px;
}
}
}
}
}
.el-alert {
margin: 20px 0 0;
}
.el-alert:first-child {
margin: 0;
}
</style>

View File

@ -1,295 +0,0 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="用户试卷主键" prop="examUserId">
<el-input
v-model="queryParams.examUserId"
placeholder="请输入用户试卷主键"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="问题主键" prop="questionId">
<el-input
v-model="queryParams.questionId"
placeholder="请输入问题主键"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="用户答案" prop="answers">
<el-input
v-model="queryParams.answers"
placeholder="请输入用户答案"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="排序" prop="sortBy">
<el-input
v-model="queryParams.sortBy"
placeholder="请输入排序"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="答题结果" prop="useRes">
<el-input
v-model="queryParams.useRes"
placeholder="请输入答题结果"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="答题得分" prop="useMark">
<el-input
v-model="queryParams.useMark"
placeholder="请输入答题得分"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery"></el-button>
<el-button icon="Refresh" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="Plus"
@click="handleAdd"
v-hasPermi="['manage:busExamUserResult:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="Edit"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['manage:busExamUserResult:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="Delete"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['manage:busExamUserResult:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="Download"
@click="handleExport"
v-hasPermi="['manage:busExamUserResult:export']"
>导出</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="busExamUserResultList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="用户试卷主键" align="center" prop="examUserId" />
<el-table-column label="问题主键" align="center" prop="questionId" />
<el-table-column label="用户答案" align="center" prop="answers" />
<el-table-column label="排序" align="center" prop="sortBy" />
<el-table-column label="答题结果" align="center" prop="useRes" />
<el-table-column label="答题得分" align="center" prop="useMark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['manage:busExamUserResult:edit']"></el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['manage:busExamUserResult:remove']"></el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改用户试卷结果对话框 -->
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
<el-form ref="busExamUserResultRef" :model="form" :rules="rules" label-width="80px">
<el-form-item label="用户试卷主键" prop="examUserId">
<el-input v-model="form.examUserId" placeholder="请输入用户试卷主键" />
</el-form-item>
<el-form-item label="问题主键" prop="questionId">
<el-input v-model="form.questionId" placeholder="请输入问题主键" />
</el-form-item>
<el-form-item label="用户答案" prop="answers">
<el-input v-model="form.answers" placeholder="请输入用户答案" />
</el-form-item>
<el-form-item label="排序" prop="sortBy">
<el-input v-model="form.sortBy" placeholder="请输入排序" />
</el-form-item>
<el-form-item label="答题结果" prop="useRes">
<el-input v-model="form.useRes" placeholder="请输入答题结果" />
</el-form-item>
<el-form-item label="答题得分" prop="useMark">
<el-input v-model="form.useMark" placeholder="请输入答题得分" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name="BusExamUserResult">
import { listBusExamUserResult, getBusExamUserResult, delBusExamUserResult, addBusExamUserResult, updateBusExamUserResult } from "@/api/manage/busExamUserResult";
const { proxy } = getCurrentInstance();
const busExamUserResultList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const data = reactive({
form: {},
queryParams: {
pageNum: 1,
pageSize: 10,
examUserId: null,
questionId: null,
answers: null,
sortBy: null,
useRes: null,
useMark: null
},
rules: {
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询用户试卷结果列表 */
function getList() {
loading.value = true;
listBusExamUserResult(queryParams.value).then(response => {
busExamUserResultList.value = response.rows;
total.value = response.total;
loading.value = false;
});
}
//
function cancel() {
open.value = false;
reset();
}
//
function reset() {
form.value = {
examUserId: null,
questionId: null,
answers: null,
sortBy: null,
useRes: null,
useMark: null
};
proxy.resetForm("busExamUserResultRef");
}
/** 搜索按钮操作 */
function handleQuery() {
queryParams.value.pageNum = 1;
getList();
}
/** 重置按钮操作 */
function resetQuery() {
proxy.resetForm("queryRef");
handleQuery();
}
//
function handleSelectionChange(selection) {
ids.value = selection.map(item => item.examUserId);
single.value = selection.length != 1;
multiple.value = !selection.length;
}
/** 新增按钮操作 */
function handleAdd() {
reset();
open.value = true;
title.value = "添加用户试卷结果";
}
/** 修改按钮操作 */
function handleUpdate(row) {
reset();
const _examUserId = row.examUserId || ids.value
getBusExamUserResult(_examUserId).then(response => {
form.value = response.data;
open.value = true;
title.value = "修改用户试卷结果";
});
}
/** 提交按钮 */
function submitForm() {
proxy.$refs["busExamUserResultRef"].validate(valid => {
if (valid) {
if (form.value.examUserId != null) {
updateBusExamUserResult(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功");
open.value = false;
getList();
});
} else {
addBusExamUserResult(form.value).then(response => {
proxy.$modal.msgSuccess("新增成功");
open.value = false;
getList();
});
}
}
});
}
/** 删除按钮操作 */
function handleDelete(row) {
const _examUserIds = row.examUserId || ids.value;
proxy.$modal.confirm('是否确认删除用户试卷结果编号为"' + _examUserIds + '"的数据项?').then(function() {
return delBusExamUserResult(_examUserIds);
}).then(() => {
getList();
proxy.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
/** 导出按钮操作 */
function handleExport() {
proxy.download('manage/busExamUserResult/export', {
...queryParams.value
}, `busExamUserResult_${new Date().getTime()}.xlsx`)
}
getList();
</script>