From 39ed23e9d4d40371d88ecf7cf2d844e310eb80c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E6=88=90?= <2847920761@qq.com> Date: Tue, 18 Feb 2025 11:56:03 +0800 Subject: [PATCH] =?UTF-8?q?app=E5=AE=89=E5=85=A8=E6=95=99=E8=82=B2?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wgz/controller/WgzAppController.java | 60 +++++----- .../src/main/resources/vm/java/domain.java.vm | 2 +- ...a => WgzAppRealNameAuthenticationReq.java} | 4 +- .../wgz/bo/req/WgzAppSubmitATestPaperReq.java | 26 ++++ .../wgz/bo/res/WgzAppSubmitATestPaperRes.java | 37 ++++++ .../bo/rests/WgzAppSubmitATestPaperTwo.java | 24 ++++ .../com/ruoyi/wgz/domain/WgzQuestionSave.java | 6 +- .../wgz/domain/WgzQuestionsConfiguration.java | 4 +- .../wgz/mapper/WgzQuestionSaveMapper.java | 11 ++ .../wgz/service/IWgzQuestionBankService.java | 6 + .../wgz/service/IWgzQuestionSaveService.java | 16 +++ .../IWgzQuestionsConfigurationService.java | 2 +- .../ruoyi/wgz/service/IWgzUserService.java | 4 +- .../impl/WgzQuestionBankServiceImpl.java | 5 + .../impl/WgzQuestionSaveServiceImpl.java | 113 +++++++++++++++++- .../WgzQuestionsConfigurationServiceImpl.java | 11 +- .../wgz/service/impl/WgzUserServiceImpl.java | 4 +- .../mapper/wgz/WgzQuestionBankMapper.xml | 24 ++++ .../mapper/wgz/WgzQuestionCategoryMapper.xml | 13 ++ .../mapper/wgz/WgzQuestionSaveMapper.xml | 27 +++++ .../wgz/WgzQuestionsConfigurationMapper.xml | 21 ++++ .../main/resources/mapper/wgz/bankMenu.sql | 22 ---- .../resources/mapper/wgz/categoryMenu.sql | 22 ---- .../mapper/wgz/configurationMenu.sql | 22 ---- .../main/resources/mapper/wgz/saveMenu.sql | 22 ---- 25 files changed, 368 insertions(+), 140 deletions(-) rename ruoyi-system/src/main/java/com/ruoyi/wgz/bo/req/{WgzRealNameAuthenticationReq.java => WgzAppRealNameAuthenticationReq.java} (92%) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/wgz/bo/req/WgzAppSubmitATestPaperReq.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/wgz/bo/res/WgzAppSubmitATestPaperRes.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/wgz/bo/rests/WgzAppSubmitATestPaperTwo.java create mode 100644 ruoyi-system/src/main/resources/mapper/wgz/WgzQuestionBankMapper.xml create mode 100644 ruoyi-system/src/main/resources/mapper/wgz/WgzQuestionCategoryMapper.xml create mode 100644 ruoyi-system/src/main/resources/mapper/wgz/WgzQuestionSaveMapper.xml create mode 100644 ruoyi-system/src/main/resources/mapper/wgz/WgzQuestionsConfigurationMapper.xml delete mode 100644 ruoyi-system/src/main/resources/mapper/wgz/bankMenu.sql delete mode 100644 ruoyi-system/src/main/resources/mapper/wgz/categoryMenu.sql delete mode 100644 ruoyi-system/src/main/resources/mapper/wgz/configurationMenu.sql delete mode 100644 ruoyi-system/src/main/resources/mapper/wgz/saveMenu.sql diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wgz/controller/WgzAppController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wgz/controller/WgzAppController.java index 780214e..0f30b8a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wgz/controller/WgzAppController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wgz/controller/WgzAppController.java @@ -8,15 +8,16 @@ import com.ruoyi.common.domain.Annex; import com.ruoyi.common.service.IAnnexService; import com.ruoyi.system.service.ISysDictTypeService; import com.ruoyi.wgz.bo.res.WgzAppGetTestPaperRes; +import com.ruoyi.wgz.bo.res.WgzAppSubmitATestPaperRes; import com.ruoyi.wgz.bo.rests.WgzAppGetTestPaperThree; import com.ruoyi.wgz.bo.rests.WgzAppGetTestPaperTwo; import com.ruoyi.wgz.bo.rests.WgzAutonymAnnex; import com.ruoyi.wgz.bo.req.*; import com.ruoyi.wgz.bo.res.WgzAppAttachmentAcquisitionRes; import com.ruoyi.wgz.bo.res.WgzAppPersonalBasicInformationRes; -import com.ruoyi.wgz.domain.WgzQuestionBank; import com.ruoyi.wgz.domain.WgzQuestionsConfiguration; import com.ruoyi.wgz.service.IWgzQuestionBankService; +import com.ruoyi.wgz.service.IWgzQuestionSaveService; import com.ruoyi.wgz.service.IWgzQuestionsConfigurationService; import com.ruoyi.wgz.service.IWgzUserService; import io.swagger.annotations.Api; @@ -54,6 +55,12 @@ public class WgzAppController { @Autowired private IWgzQuestionBankService iWgzQuestionBankService; + @Autowired + private IWgzQuestionsConfigurationService iWgzQuestionsConfigurationService; + + @Autowired + private IWgzQuestionSaveService iWgzQuestionSaveService; + /** @@ -141,13 +148,19 @@ public class WgzAppController { @ApiOperation("APP务工者-实名认证") @PreAuthorize("@ss.hasPermi('wgzApp:user:userRealNameAuthentication')") @PutMapping("/wgzUserRealNameAuthentication") - public AjaxResult userRealNameAuthentication(@Validated @RequestBody WgzRealNameAuthenticationReq req) { + public AjaxResult userRealNameAuthentication(@Validated @RequestBody WgzAppRealNameAuthenticationReq req) { return AjaxResult.success(iWgzUserService.userRealNameAuthentication(req)); } - - @Autowired - private IWgzQuestionsConfigurationService iWgzQuestionsConfigurationService; + /** + * 【我的】【签协议】协议列表(无任何实际操作目前只是查看) + */ + @ApiOperation("APP务工者-签协议·协议列表") + @PreAuthorize("@ss.hasPermi('wgzApp:user:userSignAnAgreement')") + @GetMapping("/WgzUserSignAnAgreement") + public AjaxResult userSignAnAgreement(@Validated WgzAppSubmitATestPaperReq req) { + return AjaxResult.success(iWgzQuestionSaveService.userSubmitATestPaper(req)); + } /** * 【我的】【岗前培训】获取安全教育考试试卷(随机获取) @@ -157,16 +170,14 @@ public class WgzAppController { @GetMapping("/WgzUserGetTestPaper") public AjaxResult userGetTestPaper() { //1、获取配置信息 - WgzQuestionsConfiguration configuration = iWgzQuestionsConfigurationService.appQueryById(2L); + WgzQuestionsConfiguration configuration = iWgzQuestionsConfigurationService.appQueryLimitOne(); if (configuration == null) { throw new RuntimeException("未查询到配置信息"); } - //2、随机获取数据,返回id和score Integer s = configuration.getSingleChoice(); Integer m = configuration.getMultipleChoice(); Integer e = configuration.getEstimate(); - List sEntity = iWgzQuestionBankService.appQueryList(1, s); List mEntity = iWgzQuestionBankService.appQueryList(2, m); List eEntity = iWgzQuestionBankService.appQueryList(3, e); @@ -175,34 +186,21 @@ public class WgzAppController { res.setSingleList(createQuestionSection("一、单选题", sEntity, configuration.getSingleScore(), s)); res.setMultipleList(createQuestionSection("二、多选题", mEntity, configuration.getMultipleScore(), m)); res.setEstimateList(createQuestionSection("三、判断题", eEntity, configuration.getEstimateScore(), e)); -// WgzAppGetTestPaperTwo one = new WgzAppGetTestPaperTwo(); -// one.setTopic("一、单选题,共" + s + "道题,每小题" + configuration.getSingleScore() + "分,共计" + s * configuration.getSingleScore() + "分"); -// sEntity.forEach(item -> { -// item.setScore(configuration.getSingleScore()); -// }); -// one.setList(sEntity); -// res.setSingleList(one); -// -// WgzAppGetTestPaperTwo two = new WgzAppGetTestPaperTwo(); -// two.setTopic("二、多选题,共" + m + "道题,每小题" + configuration.getMultipleScore() + "分,共计" + m * configuration.getMultipleScore() + "分"); -// mEntity.forEach(item -> { -// item.setScore(configuration.getMultipleScore()); -// }); -// two.setList(mEntity); -// res.setMultipleList(two); -// -// WgzAppGetTestPaperTwo three = new WgzAppGetTestPaperTwo(); -// three.setTopic("三、判断题,共" + e + "道题,每小题" + configuration.getEstimateScore() + "分,共计" + e * configuration.getEstimateScore() + "分"); -// eEntity.forEach(item -> { -// item.setScore(configuration.getEstimateScore()); -// }); -// three.setList(eEntity); -// res.setMultipleList(three); //4、设置最大考试时间 res.setMaximum(configuration.getAnswerTime()); return AjaxResult.success(res); } + /** + * 【我的】【岗前培训】提交用户的试卷(只保存最高分的试卷信息) + */ + @ApiOperation("APP务工者-岗前培训·提交试卷") + @PreAuthorize("@ss.hasPermi('wgzApp:user:userSubmitATestPaper')") + @PostMapping("/WgzUserSubmitATestPaper") + public AjaxResult userSubmitATestPaper(@Validated @RequestBody WgzAppSubmitATestPaperReq req) { + return AjaxResult.success(iWgzQuestionSaveService.userSubmitATestPaper(req)); + } + /** * 控制层业务 * ================================================================================================================= diff --git a/ruoyi-generator/src/main/resources/vm/java/domain.java.vm b/ruoyi-generator/src/main/resources/vm/java/domain.java.vm index 2360d15..0b685db 100644 --- a/ruoyi-generator/src/main/resources/vm/java/domain.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/domain.java.vm @@ -74,7 +74,7 @@ public class ${ClassName} implements Serializable { @TableField($TableField) #end #if($column.javaField=='delFlag') - @TableLogic +## @TableLogic 罗成直接只注释掉,需要使用逻辑删除需自己手动添加 #end #if($column.javaField=='version') @Version diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/req/WgzRealNameAuthenticationReq.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/req/WgzAppRealNameAuthenticationReq.java similarity index 92% rename from ruoyi-system/src/main/java/com/ruoyi/wgz/bo/req/WgzRealNameAuthenticationReq.java rename to ruoyi-system/src/main/java/com/ruoyi/wgz/bo/req/WgzAppRealNameAuthenticationReq.java index 215ffdd..bbe20d7 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/req/WgzRealNameAuthenticationReq.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/req/WgzAppRealNameAuthenticationReq.java @@ -1,6 +1,5 @@ package com.ruoyi.wgz.bo.req; -import com.baomidou.mybatisplus.annotation.TableId; import com.ruoyi.common.domain.Annex; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +9,6 @@ import lombok.experimental.Accessors; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; import java.io.Serializable; import java.util.List; @@ -18,7 +16,7 @@ import java.util.List; @NoArgsConstructor @Accessors(chain = true) @ApiModel("务工者APP-实名认证对象") -public class WgzRealNameAuthenticationReq implements Serializable { +public class WgzAppRealNameAuthenticationReq implements Serializable { @ApiModelProperty("唯一标识") @NotNull(message = "唯一标识不能为空") private Long userId; diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/req/WgzAppSubmitATestPaperReq.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/req/WgzAppSubmitATestPaperReq.java new file mode 100644 index 0000000..2422ad7 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/req/WgzAppSubmitATestPaperReq.java @@ -0,0 +1,26 @@ +package com.ruoyi.wgz.bo.req; + +import com.ruoyi.wgz.bo.rests.WgzAppSubmitATestPaperTwo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +@Data +@NoArgsConstructor +@Accessors(chain = true) +@ApiModel("务工者APP-提交考试信息请求对象") +public class WgzAppSubmitATestPaperReq implements Serializable { + @ApiModelProperty("务工者唯一标识") + private Long userId; + + @ApiModelProperty("用时时间(时间戳/秒)") + private Long takeTime; + + @ApiModelProperty("list") + private List list; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/res/WgzAppSubmitATestPaperRes.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/res/WgzAppSubmitATestPaperRes.java new file mode 100644 index 0000000..d75860d --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/res/WgzAppSubmitATestPaperRes.java @@ -0,0 +1,37 @@ +package com.ruoyi.wgz.bo.res; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +@Data +@NoArgsConstructor +@Accessors(chain = true) +@ApiModel("务工者APP-提交考试信息返回对象") +public class WgzAppSubmitATestPaperRes implements Serializable { + @ApiModelProperty("总考试时间(分钟)") + private Integer answerTime; + + @ApiModelProperty("用时时间(时间戳/秒)") + private Long takeTime; + + @ApiModelProperty("满分") + private Double fullMark; + + @ApiModelProperty("及格分") + private Double passingScore; + + @ApiModelProperty("当前分") + private Double score; + + @ApiModelProperty("答对题数") + private Integer number; + + @ApiModelProperty("试卷") + private String pdfStr; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/rests/WgzAppSubmitATestPaperTwo.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/rests/WgzAppSubmitATestPaperTwo.java new file mode 100644 index 0000000..964d301 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/rests/WgzAppSubmitATestPaperTwo.java @@ -0,0 +1,24 @@ +package com.ruoyi.wgz.bo.rests; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +@Data +@NoArgsConstructor +@Accessors(chain = true) +public class WgzAppSubmitATestPaperTwo implements Serializable { + @ApiModelProperty("题库ID") + private long bankId; + + @ApiModelProperty("答案") + private String answer; + + @ApiModelProperty("当前题分数") + private double score; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/domain/WgzQuestionSave.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/domain/WgzQuestionSave.java index 7fdc995..6ab0345 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wgz/domain/WgzQuestionSave.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/domain/WgzQuestionSave.java @@ -59,7 +59,7 @@ public class WgzQuestionSave implements Serializable { /** 得分(当前题) */ @Excel(name = "得分" , readConverterExp = "当=前题") @ApiModelProperty("得分(当前题)") - private Long score; + private Double score; /** 签名路径 */ @Excel(name = "签名路径") @@ -74,7 +74,7 @@ public class WgzQuestionSave implements Serializable { /** 最大超时时间(单位/分钟) */ @Excel(name = "最大超时时间" , readConverterExp = "单=位/分钟") @ApiModelProperty("最大超时时间(单位/分钟)") - private Long timeOut; + private Integer timeOut; /** 及格线/总分(格式:60,100) */ @Excel(name = "及格线/总分" , readConverterExp = "格=式:60,100") @@ -84,7 +84,7 @@ public class WgzQuestionSave implements Serializable { /** 删除标志(0代表存在 2代表删除) */ @Excel(name = "删除标志" , readConverterExp = "0=代表存在,2=代表删除") @ApiModelProperty("删除标志(0代表存在 2代表删除)") - @TableLogic + // @TableLogic private String delFlag; /** 创建者 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/domain/WgzQuestionsConfiguration.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/domain/WgzQuestionsConfiguration.java index c86cc38..3f7677b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wgz/domain/WgzQuestionsConfiguration.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/domain/WgzQuestionsConfiguration.java @@ -69,12 +69,12 @@ public class WgzQuestionsConfiguration implements Serializable { /** 满分 */ @Excel(name = "满分") @ApiModelProperty("满分") - private Long fullMark; + private Double fullMark; /** 及格线 */ @Excel(name = "及格线") @ApiModelProperty("及格线") - private Long passingScore; + private Double passingScore; /** 答题最大时间(单位/分钟) */ @Excel(name = "答题最大时间" , readConverterExp = "单=位/分钟") diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/mapper/WgzQuestionSaveMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/mapper/WgzQuestionSaveMapper.java index a287ad8..005518e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wgz/mapper/WgzQuestionSaveMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/mapper/WgzQuestionSaveMapper.java @@ -4,6 +4,10 @@ import com.ruoyi.wgz.domain.WgzQuestionSave; import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; import com.ruoyi.common.core.mybatisplus.cache.MybatisPlusRedisCache; import org.apache.ibatis.annotations.CacheNamespace; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.Map; /** * 用户试卷存储Mapper接口 @@ -15,4 +19,11 @@ import org.apache.ibatis.annotations.CacheNamespace; @CacheNamespace(implementation = MybatisPlusRedisCache.class, eviction = MybatisPlusRedisCache.class) public interface WgzQuestionSaveMapper extends BaseMapperPlus { + @Select("SELECT SUM(score) AS sumScore, " + + "(SELECT pass FROM bus_question_save WHERE user_id = #{userId} AND del_flag = '0' ORDER BY id ASC LIMIT 1) AS pass, " + + "(SELECT sign FROM bus_question_save WHERE user_id = #{userId} AND del_flag = '0' ORDER BY id ASC LIMIT 1) AS sign " + + "FROM wgz_question_save " + + "WHERE correct = 1 AND user_id = #{userId}") + Map getSumScoreAndPassAndSign(@Param("userId") Long userId); + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/service/IWgzQuestionBankService.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/service/IWgzQuestionBankService.java index 1cf0f61..bd40cfd 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wgz/service/IWgzQuestionBankService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/service/IWgzQuestionBankService.java @@ -61,6 +61,7 @@ public interface IWgzQuestionBankService extends IServicePlus { * ================================================================================================================= * ================================================================================================================= */ + /** * 随机获取指定个数类型的题 * @param type 类型 @@ -70,4 +71,9 @@ public interface IWgzQuestionBankService extends IServicePlus { * @param num 数量 */ List appQueryList(int type, int num); + + /** + * 根据id查询得到具体题库的信息 + */ + WgzQuestionBank selectById(Long id); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/service/IWgzQuestionSaveService.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/service/IWgzQuestionSaveService.java index 2c0a91c..8de9671 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wgz/service/IWgzQuestionSaveService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/service/IWgzQuestionSaveService.java @@ -1,9 +1,13 @@ package com.ruoyi.wgz.service; +import com.ruoyi.wgz.bo.req.WgzAppSubmitATestPaperReq; +import com.ruoyi.wgz.bo.res.WgzAppSubmitATestPaperRes; import com.ruoyi.wgz.domain.WgzQuestionSave; import com.ruoyi.wgz.bo.WgzQuestionSaveQueryBo; import com.ruoyi.common.core.mybatisplus.core.IServicePlus; import com.ruoyi.common.core.page.TableDataInfo; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; import java.util.Collection; import java.util.List; @@ -52,4 +56,16 @@ public interface IWgzQuestionSaveService extends IServicePlus { * @return */ Boolean deleteWithValidByIds(Collection ids, Boolean isValid); + + /** + * APP相关 + * ================================================================================================================= + * ================================================================================================================= + * ================================================================================================================= + */ + + /** + * 安全教育试卷提交保存 + */ + WgzAppSubmitATestPaperRes userSubmitATestPaper(@Validated @RequestBody WgzAppSubmitATestPaperReq req); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/service/IWgzQuestionsConfigurationService.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/service/IWgzQuestionsConfigurationService.java index 3429241..c4cb206 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wgz/service/IWgzQuestionsConfigurationService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/service/IWgzQuestionsConfigurationService.java @@ -64,5 +64,5 @@ public interface IWgzQuestionsConfigurationService extends IServicePlus { /** * 务工者APP实名认证 */ - Boolean userRealNameAuthentication(@Validated @RequestBody WgzRealNameAuthenticationReq req); + Boolean userRealNameAuthentication(@Validated @RequestBody WgzAppRealNameAuthenticationReq req); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/service/impl/WgzQuestionBankServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/service/impl/WgzQuestionBankServiceImpl.java index 6cb45e5..bb9f38f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wgz/service/impl/WgzQuestionBankServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/service/impl/WgzQuestionBankServiceImpl.java @@ -100,4 +100,9 @@ public class WgzQuestionBankServiceImpl extends ServicePlusImpl implements IWgzQuestionSaveService { + @Autowired + private IWgzQuestionsConfigurationService iWgzQuestionsConfigurationService; + + @Autowired + private IWgzQuestionBankService iWgzQuestionBankService; + @Override public WgzQuestionSave queryById(Long id){ return getById(id); @@ -81,4 +94,94 @@ public class WgzQuestionSaveServiceImpl extends ServicePlusImpl spMap = baseMapper.getSumScoreAndPassAndSign(req.getUserId()); + if (spMap != null) { + String pass = (String) spMap.get("pass"); + if (pass != null && !pass.isEmpty()) { + String[] split = pass.split(","); + double float1 = Double.parseDouble(split[1]); + double sumScore = (double) spMap.get("sumScore"); + scoreOne = 100.00 / float1 * sumScore; + } + } + //2、获取配置信息 + WgzQuestionsConfiguration configuration = iWgzQuestionsConfigurationService.appQueryLimitOne(); + //3、计算这次用户提交的试卷信息所得到的分数 + List bqs = new ArrayList<>(); + AtomicReference fenshu = new AtomicReference<>(0.0); + AtomicInteger number = new AtomicInteger(0); + AtomicInteger index = new AtomicInteger(0); + req.getList().forEach(data -> { + String correct = ""; + String pass = ""; + // 获取题库的正确答案,然后和用户的答案作对比 + WgzQuestionBank bqb = iWgzQuestionBankService.selectById(data.getBankId()); + if (bqb == null) { + throw new RuntimeException("您的试卷被外星人卷走了!"); + } else { + if (StringUtils.isEmpty(data.getAnswer())) { + throw new RuntimeException("您还有题未答完!"); + } + if (bqb.getCorrectAnswer().toLowerCase().contains(data.getAnswer().toLowerCase())) { + correct = "1"; + fenshu.updateAndGet(v -> v + data.getScore()); + number.incrementAndGet(); + } else { + correct = "2"; + } + } + // 记录这次的及格线和总分 + pass = configuration.getPassingScore().toString() + "," + configuration.getFullMark().toString(); + WgzQuestionSave bqsTwo = new WgzQuestionSave(); + bqsTwo.setUserId(req.getUserId()); + bqsTwo.setBankId(data.getBankId()); + bqsTwo.setAnswer(data.getAnswer()); + bqsTwo.setCorrect(correct); + bqsTwo.setScore(data.getScore()); + //这几条数据只在每张试卷的第一条数据中存储(重复的没必要每条都存储) + if (index.get() == 0) { + bqsTwo.setTakeTime(req.getTakeTime()); + bqsTwo.setTimeOut(configuration.getAnswerTime()); + bqsTwo.setPass(pass); + } + bqs.add(bqsTwo); + index.incrementAndGet(); + }); + Double fullMark = configuration.getFullMark(); + scoreTwo = 100.00 / fullMark * fenshu.get(); + WgzAppSubmitATestPaperRes res = new WgzAppSubmitATestPaperRes(); + res.setAnswerTime(configuration.getAnswerTime()); + res.setTakeTime(req.getTakeTime()); + res.setFullMark(fullMark); + res.setPassingScore(configuration.getPassingScore()); + res.setScore(fenshu.get()); + res.setNumber(number.get()); + //4、两次卷子的分数对比,第一次的分数比第二次大那么第二次只返回结果;第二次的分数比第一次大那么删除第一次的数据再重新插入 + if (scoreOne > scoreTwo) { + return res; + } else { + // 先查询当前用户是否有答题,有就把之前的删除(真删) + int deleteResult = baseMapper.delete(new LambdaQueryWrapper().eq(WgzQuestionSave::getUserId, req.getUserId())); + if (deleteResult >0){ + // 插入新数据 + super.saveBatch(bqs); + } + } + return res; + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/service/impl/WgzQuestionsConfigurationServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/service/impl/WgzQuestionsConfigurationServiceImpl.java index 29746f5..c4abd01 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wgz/service/impl/WgzQuestionsConfigurationServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/service/impl/WgzQuestionsConfigurationServiceImpl.java @@ -2,6 +2,7 @@ package com.ruoyi.wgz.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.utils.PageUtils; import com.ruoyi.common.core.page.PagePlus; @@ -89,7 +90,13 @@ public class WgzQuestionsConfigurationServiceImpl extends ServicePlusImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.last("LIMIT 1"); + WgzQuestionsConfiguration wgzQuestionsConfiguration = baseMapper.selectOne(queryWrapper); + if(wgzQuestionsConfiguration==null){ + throw new RuntimeException("题库配置为空"); + } + return wgzQuestionsConfiguration; } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/service/impl/WgzUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/service/impl/WgzUserServiceImpl.java index 0c363f3..0812704 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wgz/service/impl/WgzUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/service/impl/WgzUserServiceImpl.java @@ -16,7 +16,7 @@ import com.ruoyi.wgz.bo.WgzUserQueryBo; import com.ruoyi.wgz.bo.req.WgzAppModifyingUserProfilePictureReq; import com.ruoyi.wgz.bo.req.WgzAppPersonalBasicInformationReq; import com.ruoyi.wgz.bo.req.WgzAppUserRegisterReq; -import com.ruoyi.wgz.bo.req.WgzRealNameAuthenticationReq; +import com.ruoyi.wgz.bo.req.WgzAppRealNameAuthenticationReq; import com.ruoyi.wgz.bo.res.WgzAppPersonalBasicInformationRes; import com.ruoyi.wgz.common.SnowflakeIdUtil; import com.ruoyi.wgz.domain.WgzUser; @@ -168,7 +168,7 @@ public class WgzUserServiceImpl extends ServicePlusImpl //实名认证 @Override @Transactional() - public Boolean userRealNameAuthentication(WgzRealNameAuthenticationReq req) { + public Boolean userRealNameAuthentication(WgzAppRealNameAuthenticationReq req) { //1、对指定用户进行实名认证 WgzUser user = new WgzUser(); BeanUtils.copyProperties(req, user); diff --git a/ruoyi-system/src/main/resources/mapper/wgz/WgzQuestionBankMapper.xml b/ruoyi-system/src/main/resources/mapper/wgz/WgzQuestionBankMapper.xml new file mode 100644 index 0000000..9f5fdd0 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/wgz/WgzQuestionBankMapper.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/wgz/WgzQuestionCategoryMapper.xml b/ruoyi-system/src/main/resources/mapper/wgz/WgzQuestionCategoryMapper.xml new file mode 100644 index 0000000..6f98e30 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/wgz/WgzQuestionCategoryMapper.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/wgz/WgzQuestionSaveMapper.xml b/ruoyi-system/src/main/resources/mapper/wgz/WgzQuestionSaveMapper.xml new file mode 100644 index 0000000..7dd9808 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/wgz/WgzQuestionSaveMapper.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/wgz/WgzQuestionsConfigurationMapper.xml b/ruoyi-system/src/main/resources/mapper/wgz/WgzQuestionsConfigurationMapper.xml new file mode 100644 index 0000000..5018523 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/wgz/WgzQuestionsConfigurationMapper.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/wgz/bankMenu.sql b/ruoyi-system/src/main/resources/mapper/wgz/bankMenu.sql deleted file mode 100644 index 6d72bcb..0000000 --- a/ruoyi-system/src/main/resources/mapper/wgz/bankMenu.sql +++ /dev/null @@ -1,22 +0,0 @@ --- 菜单 SQL -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('题库', '${parentMenuId}', '1', 'bank', 'wgz/bank/index', 1, 0, 'C', '0', '0', 'wgz:bank:list', '#', 'admin', sysdate(), '', null, '题库菜单'); - --- 按钮父菜单ID -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('题库查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', 'wgz:bank:query', '#', 'admin', sysdate(), '', null, ''); - -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('题库新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', 'wgz:bank:add', '#', 'admin', sysdate(), '', null, ''); - -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('题库修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', 'wgz:bank:edit', '#', 'admin', sysdate(), '', null, ''); - -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('题库删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', 'wgz:bank:remove', '#', 'admin', sysdate(), '', null, ''); - -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('题库导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', 'wgz:bank:export', '#', 'admin', sysdate(), '', null, ''); \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/wgz/categoryMenu.sql b/ruoyi-system/src/main/resources/mapper/wgz/categoryMenu.sql deleted file mode 100644 index c9fadc6..0000000 --- a/ruoyi-system/src/main/resources/mapper/wgz/categoryMenu.sql +++ /dev/null @@ -1,22 +0,0 @@ --- 菜单 SQL -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('题库_题库类别', '3', '1', 'category', 'wgz/category/index', 1, 0, 'C', '0', '0', 'wgz:category:list', '#', 'admin', sysdate(), '', null, '题库_题库类别菜单'); - --- 按钮父菜单ID -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('题库_题库类别查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', 'wgz:category:query', '#', 'admin', sysdate(), '', null, ''); - -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('题库_题库类别新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', 'wgz:category:add', '#', 'admin', sysdate(), '', null, ''); - -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('题库_题库类别修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', 'wgz:category:edit', '#', 'admin', sysdate(), '', null, ''); - -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('题库_题库类别删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', 'wgz:category:remove', '#', 'admin', sysdate(), '', null, ''); - -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('题库_题库类别导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', 'wgz:category:export', '#', 'admin', sysdate(), '', null, ''); \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/wgz/configurationMenu.sql b/ruoyi-system/src/main/resources/mapper/wgz/configurationMenu.sql deleted file mode 100644 index 5524725..0000000 --- a/ruoyi-system/src/main/resources/mapper/wgz/configurationMenu.sql +++ /dev/null @@ -1,22 +0,0 @@ --- 菜单 SQL -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('题库配置', '${parentMenuId}', '1', 'configuration', 'wgz/configuration/index', 1, 0, 'C', '0', '0', 'wgz:configuration:list', '#', 'admin', sysdate(), '', null, '题库配置菜单'); - --- 按钮父菜单ID -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('题库配置查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', 'wgz:configuration:query', '#', 'admin', sysdate(), '', null, ''); - -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('题库配置新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', 'wgz:configuration:add', '#', 'admin', sysdate(), '', null, ''); - -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('题库配置修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', 'wgz:configuration:edit', '#', 'admin', sysdate(), '', null, ''); - -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('题库配置删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', 'wgz:configuration:remove', '#', 'admin', sysdate(), '', null, ''); - -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('题库配置导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', 'wgz:configuration:export', '#', 'admin', sysdate(), '', null, ''); \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/wgz/saveMenu.sql b/ruoyi-system/src/main/resources/mapper/wgz/saveMenu.sql deleted file mode 100644 index 6d880f5..0000000 --- a/ruoyi-system/src/main/resources/mapper/wgz/saveMenu.sql +++ /dev/null @@ -1,22 +0,0 @@ --- 菜单 SQL -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('用户试卷存储', '${parentMenuId}', '1', 'save', 'wgz/save/index', 1, 0, 'C', '0', '0', 'wgz:save:list', '#', 'admin', sysdate(), '', null, '用户试卷存储菜单'); - --- 按钮父菜单ID -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('用户试卷存储查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', 'wgz:save:query', '#', 'admin', sysdate(), '', null, ''); - -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('用户试卷存储新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', 'wgz:save:add', '#', 'admin', sysdate(), '', null, ''); - -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('用户试卷存储修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', 'wgz:save:edit', '#', 'admin', sysdate(), '', null, ''); - -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('用户试卷存储删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', 'wgz:save:remove', '#', 'admin', sysdate(), '', null, ''); - -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('用户试卷存储导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', 'wgz:save:export', '#', 'admin', sysdate(), '', null, ''); \ No newline at end of file