فهرست منبع

fix 模拟随机做题

he2802 2 سال پیش
والد
کامیت
5fd7ddd15c
31فایلهای تغییر یافته به همراه440 افزوده شده و 22 حذف شده
  1. 1 1
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/common/CommonController.java
  2. 2 0
      zhongzheng-admin/src/main/resources/application-dev.yml
  3. 2 0
      zhongzheng-admin/src/main/resources/application-pre.yml
  4. 2 0
      zhongzheng-admin/src/main/resources/application-prod.yml
  5. 2 0
      zhongzheng-admin/src/main/resources/application-trial.yml
  6. 94 0
      zhongzheng-api/src/main/java/com/zhongzheng/controller/bank/ExamSimulateController.java
  7. 2 0
      zhongzheng-api/src/main/resources/application-dev.yml
  8. 2 0
      zhongzheng-api/src/main/resources/application-pre.yml
  9. 2 0
      zhongzheng-api/src/main/resources/application-prod.yml
  10. 2 0
      zhongzheng-api/src/main/resources/application-trial.yml
  11. 17 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/ExamSimulateQueryBo.java
  12. 1 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/ExamSimulateQuestionAddBo.java
  13. 1 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/ExamSimulateQuestionEditBo.java
  14. 1 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/ExamSimulateQuestionQueryBo.java
  15. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/QuestionQueryBo.java
  16. 1 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/domain/ExamSimulateQuestion.java
  17. 10 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/mapper/ExamSimulateMapper.java
  18. 1 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/mapper/QuestionMapper.java
  19. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IExamSimulateQuestionService.java
  20. 8 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IExamSimulateService.java
  21. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IQuestionService.java
  22. 1 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/ExamSimulateQuestionServiceImpl.java
  23. 161 9
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/ExamSimulateServiceImpl.java
  24. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java
  25. 1 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/ExamSimulateQuestionVo.java
  26. 7 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/ExamSimulateVo.java
  27. 33 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/ClassGradeServiceImpl.java
  28. 1 2
      zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/UserPeriodServiceImpl.java
  29. 74 0
      zhongzheng-system/src/main/resources/mapper/modules/bank/ExamSimulateMapper.xml
  30. 1 1
      zhongzheng-system/src/main/resources/mapper/modules/bank/ExamSimulateQuestionMapper.xml
  31. 2 0
      zhongzheng-system/src/main/resources/mapper/modules/bank/QuestionMapper.xml

+ 1 - 1
zhongzheng-admin/src/main/java/com/zhongzheng/controller/common/CommonController.java

@@ -235,7 +235,7 @@ public class CommonController
     @GetMapping("common/jzs/grade")
     public AjaxResult<Void> testGrade()
     {
-        iOrderService.arrangeGrade("安管继续教育网络班B类",890L,3097L,null,114L,"",174L);
+        iClassGradeService.checkEjjjPeopleNumLimit(195L,984L);
         return AjaxResult.success();
     }
 

+ 2 - 0
zhongzheng-admin/src/main/resources/application-dev.yml

@@ -136,6 +136,8 @@ oldStudySys:
     syncPath: http://gdxypx.xy.com/System/BussinessApi/PostUserStudyRecords
     sharePath: http://192.168.1.210:8086/witsystem/dataapi/SaleOrder
     shareCanclePath: http://192.168.1.210:8086/witsystem/dataapi/ordercance
+    searchGradeCount: http://gdxypx.xy.com/System/BussinessApi/OfficialGradeCount
+    pushGradeCount: http://gdxypx.xy.com/System/BussinessApi/OfficialGradeCountAuto
 
 officialPush:
     infoPath: http://jypt-dev.gdcic.net/organjxjy/ShangBaoMingdan

+ 2 - 0
zhongzheng-admin/src/main/resources/application-pre.yml

@@ -136,6 +136,8 @@ oldStudySys:
     syncPath: http://test.jqbao.net/System/BussinessApi/PostUserStudyRecords
     sharePath: http://test.jqbao.net/witsystem/dataapi/SaleOrder
     shareCanclePath: http://test.jqbao.net/witsystem/dataapi/ordercance
+    searchGradeCount: http://test.jqbao.net/System/BussinessApi/OfficialGradeCount
+    pushGradeCount: http://test.jqbao.net/System/BussinessApi/OfficialGradeCountAuto
 
 officialPush:
     infoPath: http://jypt-dev.gdcic.net/organjxjy/ShangBaoMingdan

+ 2 - 0
zhongzheng-admin/src/main/resources/application-prod.yml

@@ -136,6 +136,8 @@ oldStudySys:
     syncPath: https://www.xyyxt.net/System/BussinessApi/PostUserStudyRecords
     sharePath: https://www.xyyxt.net/witsystem/dataapi/SaleOrder
     shareCanclePath: https://www.xyyxt.net/witsystem/dataapi/ordercance
+    searchGradeCount: https://www.xyyxt.net/System/BussinessApi/OfficialGradeCount
+    pushGradeCount: https://www.xyyxt.net/System/BussinessApi/OfficialGradeCountAuto
 
 officialPush:
     infoPath: http://jypt.gdcic.net/organjxjy/ShangBaoMingdan

+ 2 - 0
zhongzheng-admin/src/main/resources/application-trial.yml

@@ -136,6 +136,8 @@ oldStudySys:
     syncPath: https://www.xyyxt.net/System/BussinessApi/PostUserStudyRecords
     sharePath: https://www.xyyxt.net/witsystem/dataapi/SaleOrder
     shareCanclePath: https://www.xyyxt.net/witsystem/dataapi/ordercance
+    searchGradeCount: https://www.xyyxt.net/System/BussinessApi/OfficialGradeCount
+    pushGradeCount: https://www.xyyxt.net/System/BussinessApi/OfficialGradeCountAuto
 
 officialPush:
     infoPath: http://jypt.gdcic.net/organjxjy/ShangBaoMingdan

+ 94 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/bank/ExamSimulateController.java

@@ -0,0 +1,94 @@
+package com.zhongzheng.controller.bank;
+
+import java.util.List;
+import java.util.Arrays;
+
+import com.zhongzheng.common.core.page.TableDataInfo;
+import com.zhongzheng.common.utils.ServletUtils;
+import com.zhongzheng.framework.web.service.WxTokenService;
+import com.zhongzheng.modules.bank.bo.ExamSimulateAddBo;
+import com.zhongzheng.modules.bank.bo.ExamSimulateEditBo;
+import com.zhongzheng.modules.bank.bo.ExamSimulateQueryBo;
+import com.zhongzheng.modules.bank.service.IExamSimulateService;
+import com.zhongzheng.modules.bank.vo.ExamSimulateVo;
+import com.zhongzheng.modules.user.entity.ClientLoginUser;
+import lombok.RequiredArgsConstructor;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.zhongzheng.common.annotation.Log;
+import com.zhongzheng.common.core.controller.BaseController;
+import com.zhongzheng.common.core.domain.AjaxResult;
+import com.zhongzheng.common.enums.BusinessType;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * 模拟考生成试卷Controller
+ *
+ * @author hjl
+ * @date 2022-12-09
+ */
+@Api(value = "模拟考生成试卷控制器", tags = {"模拟考生成试卷管理"})
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
+@RestController
+@RequestMapping("/bank/exam/simulate")
+public class ExamSimulateController extends BaseController {
+
+    private final IExamSimulateService iExamSimulateService;
+
+    private final WxTokenService wxTokenService;
+
+    /**
+     * 查询模拟考生成试卷列表
+     */
+    @ApiOperation("查询模拟考生成试卷列表")
+    @PreAuthorize("@ss.hasPermi('system:simulate:list')")
+    @GetMapping("/list")
+    public TableDataInfo<ExamSimulateVo> list(ExamSimulateQueryBo bo) {
+        startPage();
+        List<ExamSimulateVo> list = iExamSimulateService.queryList(bo);
+        return getDataTable(list);
+    }
+
+    @ApiOperation("查询模拟考生成试卷列表1")
+    @PreAuthorize("@ss.hasPermi('system:simulate:list')")
+    @GetMapping("/getlist")
+    public AjaxResult<List<Long>> getlist(ExamSimulateQueryBo bo) {
+        return AjaxResult.success(iExamSimulateService.getQuestionList(bo));
+    }
+
+
+
+    /**
+     * 获取模拟考生成试卷详细信息
+     */
+    @ApiOperation("获取模拟考生成试卷详细信息")
+    @PreAuthorize("@ss.hasPermi('system:simulate:query')")
+    @GetMapping("/{examId}")
+    public AjaxResult<ExamSimulateVo> getInfo(@PathVariable("examId" ) Long examId) {
+        return AjaxResult.success(iExamSimulateService.queryById(examId));
+    }
+
+    /**
+     * 新增模拟考生成试卷
+     */
+    @ApiOperation("新增模拟考生成试卷")
+    @PreAuthorize("@ss.hasPermi('system:simulate:add')")
+    @Log(title = "模拟考生成试卷", businessType = BusinessType.INSERT)
+    @PostMapping()
+    public AjaxResult<ExamSimulateVo> add(@RequestBody ExamSimulateAddBo bo) {
+        ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
+        bo.setUserId(loginUser.getUser().getUserId());
+        return AjaxResult.success(iExamSimulateService.insertByAddBo(bo));
+    }
+
+
+}

+ 2 - 0
zhongzheng-api/src/main/resources/application-dev.yml

@@ -137,6 +137,8 @@ oldStudySys:
     syncPath: http://gdxypx.xy.com/System/PostUserStudyRecords
     sharePath: http://192.168.1.210:8086/witsystem/dataapi/SaleOrder
     shareCanclePath: http://192.168.1.210:8086/witsystem/dataapi/ordercance
+    searchGradeCount: http://gdxypx.xy.com/System/BussinessApi/OfficialGradeCount
+    pushGradeCount: http://gdxypx.xy.com/System/BussinessApi/OfficialGradeCountAuto
 
 officialPush:
     infoPath: http://jypt-dev.gdcic.net/organjxjy/ShangBaoMingdan

+ 2 - 0
zhongzheng-api/src/main/resources/application-pre.yml

@@ -136,6 +136,8 @@ oldStudySys:
     syncPath: http://test.jqbao.net/System/PostUserStudyRecords
     sharePath: http://test.jqbao.net/witsystem/dataapi/SaleOrder
     shareCanclePath: http://test.jqbao.net/witsystem/dataapi/ordercance
+    searchGradeCount: http://test.jqbao.net/System/BussinessApi/OfficialGradeCount
+    pushGradeCount: http://test.jqbao.net/System/BussinessApi/OfficialGradeCountAuto
 
 officialPush:
     infoPath: http://jypt-dev.gdcic.net/organjxjy/ShangBaoMingdan

+ 2 - 0
zhongzheng-api/src/main/resources/application-prod.yml

@@ -148,6 +148,8 @@ oldStudySys:
     syncPath: https://www.xyyxt.net/System/PostUserStudyRecords
     sharePath: https://www.xyyxt.net/witsystem/dataapi/SaleOrder
     shareCanclePath: https://www.xyyxt.net/witsystem/dataapi/ordercance
+    searchGradeCount: https://www.xyyxt.net/System/BussinessApi/OfficialGradeCount
+    pushGradeCount: https://www.xyyxt.net/System/BussinessApi/OfficialGradeCountAuto
 
 officialPush:
     infoPath: http://jypt.gdcic.net/organjxjy/ShangBaoMingdan

+ 2 - 0
zhongzheng-api/src/main/resources/application-trial.yml

@@ -148,6 +148,8 @@ oldStudySys:
     syncPath: https://www.xyyxt.net/System/PostUserStudyRecords
     sharePath: https://www.xyyxt.net/witsystem/dataapi/SaleOrder
     shareCanclePath: https://www.xyyxt.net/witsystem/dataapi/ordercance
+    searchGradeCount: https://www.xyyxt.net/System/BussinessApi/OfficialGradeCount
+    pushGradeCount: https://www.xyyxt.net/System/BussinessApi/OfficialGradeCountAuto
 
 officialPush:
     infoPath: http://jypt.gdcic.net/organjxjy/ShangBaoMingdan

+ 17 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/ExamSimulateQueryBo.java

@@ -6,6 +6,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 import java.util.HashMap;
 
@@ -57,4 +58,20 @@ public class ExamSimulateQueryBo extends BaseEntity {
 	/** 试卷类型id */
 	@ApiModelProperty("试卷类型id")
 	private Long examPaperId;
+	/** 类型 1单选 2多选 3判断题 4案列题  5简答题 */
+	@ApiModelProperty("类型 1单选 2多选 3判断题 4案列题  5简答题")
+	private Integer type;
+	@ApiModelProperty("知识点ID数组")
+	private List<Long> knowledIds;
+	@ApiModelProperty("知识点取题数")
+	private Integer knum;
+	@ApiModelProperty("取题数")
+	private Integer qnum;
+	@ApiModelProperty("知识点题目ID数组")
+	private List<Long> knowledQuestionIds;
+
+	@ApiModelProperty("抽题顺序 1顺序 0随机")
+	private Integer randomNum;
+	@ApiModelProperty("模拟做题试卷ID")
+	private Long simulateExamId;
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/ExamSimulateQuestionAddBo.java

@@ -20,7 +20,7 @@ public class ExamSimulateQuestionAddBo {
 
     /** 试卷ID */
     @ApiModelProperty("试卷ID")
-    private Long examId;
+    private Long simulateExamId;
     /** 题目ID */
     @ApiModelProperty("题目ID")
     private Long questionId;

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/ExamSimulateQuestionEditBo.java

@@ -23,7 +23,7 @@ public class ExamSimulateQuestionEditBo {
 
     /** 试卷ID */
     @ApiModelProperty("试卷ID")
-    private Long examId;
+    private Long simulateExamId;
 
     /** 题目ID */
     @ApiModelProperty("题目ID")

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/ExamSimulateQuestionQueryBo.java

@@ -38,7 +38,7 @@ public class ExamSimulateQuestionQueryBo extends BaseEntity {
 
 	/** 试卷ID */
 	@ApiModelProperty("试卷ID")
-	private Long examId;
+	private Long simulateExamId;
 	/** 题目ID */
 	@ApiModelProperty("题目ID")
 	private Long questionId;

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/QuestionQueryBo.java

@@ -94,4 +94,6 @@ public class QuestionQueryBo extends BaseEntity {
 	/** 商品服务期校验字段 */
 	@ApiModelProperty("商品服务期校验字段:1,未过期 2,已过期")
 	private Integer serviceCheck;
+	@ApiModelProperty("多题目id")
+	private List<Long> ids;
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/domain/ExamSimulateQuestion.java

@@ -27,7 +27,7 @@ private static final long serialVersionUID=1L;
     @TableId(value = "id")
     private Long id;
     /** 试卷ID */
-    private Long examId;
+    private Long simulateExamId;
     /** 题目ID */
     private Long questionId;
     /** 排序 */

+ 10 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/mapper/ExamSimulateMapper.java

@@ -1,7 +1,12 @@
 package com.zhongzheng.modules.bank.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhongzheng.modules.bank.bo.ExamSimulateQueryBo;
+import com.zhongzheng.modules.bank.bo.ExamTempQueryBo;
 import com.zhongzheng.modules.bank.domain.ExamSimulate;
+import com.zhongzheng.modules.bank.vo.QuestionVo;
+
+import java.util.List;
 
 /**
  * 模拟考生成试卷Mapper接口
@@ -11,4 +16,9 @@ import com.zhongzheng.modules.bank.domain.ExamSimulate;
  */
 public interface ExamSimulateMapper extends BaseMapper<ExamSimulate> {
 
+    List<Long> getKnowledQuestionList(ExamSimulateQueryBo bo);
+
+    List<Long> getQuestionList(ExamSimulateQueryBo bo);
+
+    List<QuestionVo> queryBatchList(ExamSimulateQueryBo bo);
 }

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/mapper/QuestionMapper.java

@@ -33,4 +33,5 @@ public interface QuestionMapper extends BaseMapper<Question> {
     List<GoodsUserQuestionVo> listUserFreeUnionBuyGoodsList(GoodsQueryBo bo);
 
     List<BankGoodsExamVo> getBankGoodsExamList(@Param("goodsId") Long goodsId);
+
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IExamSimulateQuestionService.java

@@ -1,5 +1,6 @@
 package com.zhongzheng.modules.bank.service;
 
+import com.zhongzheng.modules.bank.bo.ExamSimulateQueryBo;
 import com.zhongzheng.modules.bank.bo.ExamSimulateQuestionAddBo;
 import com.zhongzheng.modules.bank.bo.ExamSimulateQuestionEditBo;
 import com.zhongzheng.modules.bank.bo.ExamSimulateQuestionQueryBo;
@@ -49,4 +50,5 @@ public interface IExamSimulateQuestionService extends IService<ExamSimulateQuest
 	 * @return
 	 */
 	Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+
 }

+ 8 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IExamSimulateService.java

@@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.zhongzheng.modules.bank.bo.ExamSimulateAddBo;
 import com.zhongzheng.modules.bank.bo.ExamSimulateEditBo;
 import com.zhongzheng.modules.bank.bo.ExamSimulateQueryBo;
+import com.zhongzheng.modules.bank.bo.QuestionQueryBo;
 import com.zhongzheng.modules.bank.domain.ExamSimulate;
 import com.zhongzheng.modules.bank.vo.ExamSimulateVo;
+import com.zhongzheng.modules.bank.vo.QuestionVo;
 
 import java.util.Collection;
 import java.util.List;
@@ -33,7 +35,7 @@ public interface IExamSimulateService extends IService<ExamSimulate> {
 	 * @param bo 模拟考生成试卷新增业务对象
 	 * @return
 	 */
-	Boolean insertByAddBo(ExamSimulateAddBo bo);
+	ExamSimulateVo insertByAddBo(ExamSimulateAddBo bo);
 
 	/**
 	 * 根据编辑业务对象修改模拟考生成试卷
@@ -49,4 +51,9 @@ public interface IExamSimulateService extends IService<ExamSimulate> {
 	 * @return
 	 */
 	Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+
+
+	List<Long> getQuestionList(ExamSimulateQueryBo bo);
+
+	List<QuestionVo> queryBatchList(ExamSimulateQueryBo bo);
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IQuestionService.java

@@ -97,4 +97,6 @@ public interface IQuestionService extends IService<Question> {
 
 	TodayExamWeekRecordDetailVo getTodayExamWeekRecord(Long goodsId, Long userId);
 
+
+
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/ExamSimulateQuestionServiceImpl.java

@@ -39,7 +39,7 @@ public class ExamSimulateQuestionServiceImpl extends ServiceImpl<ExamSimulateQue
     @Override
     public List<ExamSimulateQuestionVo> queryList(ExamSimulateQuestionQueryBo bo) {
         LambdaQueryWrapper<ExamSimulateQuestion> lqw = Wrappers.lambdaQuery();
-        lqw.eq(bo.getExamId() != null, ExamSimulateQuestion::getExamId, bo.getExamId());
+        lqw.eq(bo.getSimulateExamId() != null, ExamSimulateQuestion::getSimulateExamId, bo.getSimulateExamId());
         lqw.eq(bo.getQuestionId() != null, ExamSimulateQuestion::getQuestionId, bo.getQuestionId());
         lqw.eq(bo.getSort() != null, ExamSimulateQuestion::getSort, bo.getSort());
         return entity2Vo(this.list(lqw));

+ 161 - 9
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/ExamSimulateServiceImpl.java

@@ -1,24 +1,34 @@
 package com.zhongzheng.modules.bank.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
+import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
-import com.zhongzheng.modules.bank.bo.ExamSimulateAddBo;
-import com.zhongzheng.modules.bank.bo.ExamSimulateEditBo;
-import com.zhongzheng.modules.bank.bo.ExamSimulateQueryBo;
+import com.zhongzheng.common.utils.ServletUtils;
+import com.zhongzheng.modules.bank.bo.*;
+import com.zhongzheng.modules.bank.domain.Exam;
 import com.zhongzheng.modules.bank.domain.ExamSimulate;
+import com.zhongzheng.modules.bank.domain.ExamSimulateQuestion;
+import com.zhongzheng.modules.bank.domain.ExamTempQuestion;
 import com.zhongzheng.modules.bank.mapper.ExamSimulateMapper;
-import com.zhongzheng.modules.bank.service.IExamSimulateService;
+import com.zhongzheng.modules.bank.service.*;
 import com.zhongzheng.modules.bank.vo.ExamSimulateVo;
+import com.zhongzheng.modules.bank.vo.ExamTempVo;
+import com.zhongzheng.modules.bank.vo.QuestionVo;
+import com.zhongzheng.modules.exam.service.IExamPaperService;
+import com.zhongzheng.modules.goods.vo.GoodsPlayConfigVo;
+import com.zhongzheng.modules.order.domain.Order;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.pagehelper.Page;
+import org.springframework.transaction.annotation.Transactional;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -30,6 +40,15 @@ import java.util.stream.Collectors;
 @Service
 public class ExamSimulateServiceImpl extends ServiceImpl<ExamSimulateMapper, ExamSimulate> implements IExamSimulateService {
 
+    @Autowired
+    private IExamService iExamService;
+
+    @Autowired
+    private IExamSimulateQuestionService iExamSimulateQuestionService;
+
+    @Autowired
+    private IQuestionService iQuestionService;
+
     @Override
     public ExamSimulateVo queryById(Long examId){
         ExamSimulate db = this.baseMapper.selectById(examId);
@@ -70,12 +89,135 @@ public class ExamSimulateServiceImpl extends ServiceImpl<ExamSimulateMapper, Exa
     }
 
     @Override
-    public Boolean insertByAddBo(ExamSimulateAddBo bo) {
+    @Transactional(rollbackFor = Exception.class)
+    public ExamSimulateVo insertByAddBo(ExamSimulateAddBo bo) {
         ExamSimulate add = BeanUtil.toBean(bo, ExamSimulate.class);
+        Exam exam = iExamService.getOne(new LambdaQueryWrapper<Exam>().eq(Exam::getExamId, bo.getExamId()));
+        if(exam.getDoType()!=2||exam.getSimulateStatus()==0){
+            throw new CustomException("该试卷没开启模拟随机考");
+        }
+        if(Validator.isEmpty(exam.getSimulateConfigJson())){
+            throw new CustomException("该试卷没配置模拟随机考");
+        }
+        ExamSimulateConfigBo simulateConfig = JSON.parseObject(exam.getSimulateConfigJson(), ExamSimulateConfigBo.class);
+
+
+        ExamSimulateQueryBo qk1Bo = new ExamSimulateQueryBo(); //单选知识点
+        qk1Bo.setExamId(exam.getExamId());
+        qk1Bo.setKnowledIds(simulateConfig.getSingleChoice().getKnowledIds());
+        qk1Bo.setKnum(simulateConfig.getSingleChoice().getKnum());
+        qk1Bo.setRandomNum(simulateConfig.getType());
+        qk1Bo.setType(1);
+        List<Long> qk1 = baseMapper.getKnowledQuestionList(qk1Bo);
+
+        ExamSimulateQueryBo qk2Bo = new ExamSimulateQueryBo(); //多选知识点
+        qk2Bo.setExamId(exam.getExamId());
+        qk2Bo.setKnowledIds(simulateConfig.getMultipleChoice().getKnowledIds());
+        qk2Bo.setKnum(simulateConfig.getMultipleChoice().getKnum());
+        qk2Bo.setRandomNum(simulateConfig.getType());
+        qk2Bo.setType(2);
+        List<Long> qk2 = baseMapper.getKnowledQuestionList(qk2Bo);
+
+        ExamSimulateQueryBo qk3Bo = new ExamSimulateQueryBo(); //案例选知识点
+        qk3Bo.setExamId(exam.getExamId());
+        qk3Bo.setKnowledIds(simulateConfig.getCaseQuestion().getKnowledIds());
+        qk3Bo.setKnum(simulateConfig.getCaseQuestion().getKnum());
+        qk3Bo.setRandomNum(simulateConfig.getType());
+        qk3Bo.setType(4);
+        List<Long> qk3 = baseMapper.getKnowledQuestionList(qk3Bo);
+
+        ExamSimulateQueryBo q1Bo = new ExamSimulateQueryBo();  //单选
+        q1Bo.setExamId(exam.getExamId());
+        q1Bo.setKnowledQuestionIds(qk1);
+        q1Bo.setQnum(simulateConfig.getSingleChoice().getQnum()-qk1.size());
+        q1Bo.setRandomNum(simulateConfig.getType());
+        q1Bo.setType(1);
+        List<Long> q1 = baseMapper.getQuestionList(q1Bo);
+
+        ExamSimulateQueryBo q2Bo = new ExamSimulateQueryBo();  //多选
+        q2Bo.setExamId(exam.getExamId());
+        q2Bo.setKnowledQuestionIds(qk2);
+        q2Bo.setQnum(simulateConfig.getMultipleChoice().getQnum()-qk2.size());
+        q2Bo.setRandomNum(simulateConfig.getType());
+        q2Bo.setType(2);
+        List<Long> q2 = baseMapper.getQuestionList(q2Bo);
+
+        ExamSimulateQueryBo q3Bo = new ExamSimulateQueryBo();  //案例选
+        q3Bo.setExamId(exam.getExamId());
+        q3Bo.setKnowledQuestionIds(qk3);
+        q3Bo.setQnum(simulateConfig.getCaseQuestion().getQnum()-qk3.size());
+        q3Bo.setRandomNum(simulateConfig.getType());
+        q3Bo.setType(4);
+        List<Long> q3 = baseMapper.getQuestionList(q3Bo);
+
+        qk1.addAll(q1);
+        qk2.addAll(q2);
+        qk3.addAll(q3);
+
+        List<Long> allQ = new ArrayList<>();
+        if(simulateConfig.getSingleChoice().getRandomNum()==1){ //题型顺序
+            for(int i=1;i<4;i++){
+                if(simulateConfig.getSingleChoice().getOrderNum()==i){
+                    allQ.addAll(qk1);
+                }
+                if(simulateConfig.getMultipleChoice().getOrderNum()==i){
+                    allQ.addAll(qk2);
+                }
+                if(simulateConfig.getCaseQuestion().getOrderNum()==i){
+                    allQ.addAll(qk3);
+                }
+            }
+        }else{//题型随机
+            Map<Integer,Integer> map = new HashMap<>();
+            for(int i=1;i<50;i++){
+                int num = (int)(10.0*Math.random()) + 1;
+                if(num%3==0){
+                    if(!map.containsKey(0)){
+                        map.put(0,0);
+                        allQ.addAll(qk1);
+                    }
+                }
+                if(num%3==1){
+                    if(!map.containsKey(1)){
+                        map.put(1,1);
+                        allQ.addAll(qk2);
+                    }
+                }
+                if(num%3==2){
+                    if(!map.containsKey(2)){
+                        map.put(2,2);
+                        allQ.addAll(qk3);
+                    }
+                }
+                if(allQ.size()>=3){
+                    break;
+                }
+            }
+        }
         validEntityBeforeSave(add);
         add.setCreateTime(DateUtils.getNowTime());
         add.setUpdateTime(DateUtils.getNowTime());
-        return this.save(add);
+        add.setExamPaperId(exam.getExamPaperId());
+        add.setExamName(exam.getExamName()+"-"+ServletUtils.getEncoded(""));
+        boolean result = this.save(add);
+        Collection<ExamSimulateQuestion> coll = new HashSet<>();
+        for(int i=0;i<allQ.size();i++){
+            ExamSimulateQuestion addItem = new ExamSimulateQuestion();
+            addItem.setSimulateExamId(add.getSimulateExamId());
+            addItem.setQuestionId(allQ.get(i));
+            addItem.setSort(new Long(i));
+            coll.add(addItem);
+        }
+        if(!iExamSimulateQuestionService.saveBatch(coll)){
+            throw new CustomException("试卷绑定错误");
+        }
+        ExamSimulateVo examSimulateVo = BeanUtil.toBean(add, ExamSimulateVo.class);
+        ExamSimulateQueryBo questionQueryBo = new ExamSimulateQueryBo();
+        questionQueryBo.setSimulateExamId(examSimulateVo.getSimulateExamId());
+        List<QuestionVo> questionlist = queryBatchList(questionQueryBo);
+        examSimulateVo.setQuestionList(questionlist);
+        examSimulateVo.setDoMode(3);
+        return examSimulateVo;
     }
 
     @Override
@@ -102,4 +244,14 @@ public class ExamSimulateServiceImpl extends ServiceImpl<ExamSimulateMapper, Exa
         }
         return this.removeByIds(ids);
     }
+
+    @Override
+    public List<Long> getQuestionList(ExamSimulateQueryBo bo) {
+        return this.baseMapper.getQuestionList(bo);
+    }
+
+    @Override
+    public List<QuestionVo> queryBatchList(ExamSimulateQueryBo bo) {
+        return this.baseMapper.queryBatchList(bo);
+    }
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java

@@ -1996,6 +1996,8 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
     }
 
 
+
+
     private String getPercent(Integer x,Integer y){
         Double d1 = x * 1.0;
         Double d2 = y * 1.0;

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/ExamSimulateQuestionVo.java

@@ -27,7 +27,7 @@ public class ExamSimulateQuestionVo {
 	/** 试卷ID */
 	@Excel(name = "试卷ID")
 	@ApiModelProperty("试卷ID")
-	private Long examId;
+	private Long simulateExamId;
 	/** 题目ID */
 	@Excel(name = "题目ID")
 	@ApiModelProperty("题目ID")

+ 7 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/ExamSimulateVo.java

@@ -6,7 +6,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import java.util.Date;
-
+import java.util.List;
 
 
 /**
@@ -52,4 +52,10 @@ public class ExamSimulateVo {
 	@Excel(name = "试卷类型id")
 	@ApiModelProperty("试卷类型id")
 	private Long examPaperId;
+	@ApiModelProperty("题目列表")
+	private List<QuestionVo> questionList;
+	/** 做题模式 1章卷 2随机练习 */
+	@Excel(name = "做题模式 1章卷 2随机练习 3模拟随机")
+	@ApiModelProperty("做题模式 1章卷 2随机练习 3模拟随机")
+	private Integer doMode;
 }

+ 33 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/ClassGradeServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.lang.Validator;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
@@ -12,6 +13,7 @@ import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.SecurityUtils;
 import com.zhongzheng.common.utils.ServletUtils;
+import com.zhongzheng.common.utils.ToolsUtils;
 import com.zhongzheng.common.utils.http.HttpUtils;
 import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
 import com.zhongzheng.modules.course.bo.CourseBusinessQueryBo;
@@ -50,6 +52,8 @@ import com.zhongzheng.modules.user.vo.UserVo;
 import org.apache.http.Header;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -78,6 +82,8 @@ import java.util.stream.Collectors;
 @Service
 public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGrade> implements IClassGradeService {
 
+    private static Logger log = LoggerFactory.getLogger(ClassGradeServiceImpl.class);
+
     @Autowired
     private IGoodsService iGoodsService;
 
@@ -132,6 +138,9 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
     @Value("${aliyun.sms.classRemind}")
     private String classRemind;
 
+    @Value("${oldStudySys.searchGradeCount}")
+    private String GRADE_COUNT_PATH;
+
     @Override
     public ClassGradeVo queryById(Long gradeId) {
         ClassGradeQueryBo classGradeQueryBo = new ClassGradeQueryBo();
@@ -740,7 +749,30 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
                 ClassGradeQueryBo queryBo = new ClassGradeQueryBo();
                 queryBo.setOfficialName(gradeVo.getOfficialName());
                 Integer peopleNum = queryOfficialGradeCount(queryBo);
-                if(peopleNum>=300){ //全系统平台二建班级人数不能超300
+                //查询旧系统
+                Map<String, String> params = new HashMap<>();
+                Long nowTime = DateUtils.getNowTime();
+                String sign = ToolsUtils.EncoderByMd5(nowTime.toString()+"pubilc2022");
+                params.put("stamp", nowTime.toString());
+                params.put("sign", sign);
+                params.put("jsonstr", gradeVo.getOfficialName());
+                String respone = "";
+                log.info("查询业务系统班级人数"+params,"");
+                Integer oldGradeNum = 0;
+                try {
+                    respone = HttpUtils.postFormBody(GRADE_COUNT_PATH, params);
+                    log.info("查询业务系统班级人数结果"+respone,"");
+                    if (!respone.contains("\"Status\":true")) {
+                        throw new CustomException("同步请求错误"+respone);
+                    }
+                    JSONObject jsonObject = (JSONObject) JSONObject.parse(respone);
+                    JSONArray dataArray =  jsonObject.getJSONArray("Data");
+                    JSONObject fObject = dataArray.getJSONObject(0);
+                    oldGradeNum = (Integer)fObject.get("num");
+                } catch (IOException e) {
+                    throw new CustomException("同步请求错误"+e.getMessage());
+                }
+                if((peopleNum+oldGradeNum)>=300){ //全系统平台二建班级人数不能超300
                     return false;
                 }
             }

+ 1 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/UserPeriodServiceImpl.java

@@ -761,11 +761,10 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
         try {
             respone = HttpUtils.postFormBody(SYNC_PATH, params);
             log.info("学时推送业务系统结果"+respone,"");
-            if (!respone.contains("{\"Status\":true")) {
+            if (!respone.contains("\"Status\":true")) {
                 throw new CustomException("同步请求错误"+respone);
             }
         } catch (IOException e) {
-            log.info("学时推送业务系统同步请求错误"+e.getMessage(),"");
             throw new CustomException("同步请求错误"+e.getMessage());
         }
         return studyRec;

+ 74 - 0
zhongzheng-system/src/main/resources/mapper/modules/bank/ExamSimulateMapper.xml

@@ -17,5 +17,79 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="examPaperId" column="exam_paper_id"/>
     </resultMap>
 
+    <resultMap type="com.zhongzheng.modules.bank.vo.QuestionVo" id="QuestionResultVo">
+        <result property="questionId" column="question_id"/>
+        <result property="content" column="content"/>
+        <result property="type" column="type"/>
+        <result property="answerQuestion" column="answer_question"/>
+        <result property="status" column="status"/>
+        <result property="analysisContent" column="analysis_content"/>
+        <result property="imgUrl" column="img_url"/>
+        <result property="jsonStr" column="json_str"/>
+        <result property="prefixName" column="prefix_name"/>
+        <result property="knowledgeIds" column="knowledge_ids"/>
+        <result property="publishStatus" column="publish_status"/>
+        <result property="code" column="code"/>
+    </resultMap>
+
+    <select id="getKnowledQuestionList" parameterType="com.zhongzheng.modules.bank.bo.ExamSimulateQueryBo" resultType="Long">
+        SELECT
+            q.question_id
+        FROM
+            exam_question eq
+                LEFT JOIN question q ON eq.question_id = q.question_id
+        WHERE
+            eq.exam_id = #{examId}
+        <if test="type != null and type != ''">
+          AND q.`type` = #{type}
+        </if>
+        <if test="knowledIds != null and knowledIds.size()!=0 ">
+            AND
+            <foreach collection="knowledIds" item="item" index="index" open="(" close=")" separator="or">
+                FIND_IN_SET(#{item},
+                q.knowledge_ids)
+            </foreach>
+        </if>
+        <if test="randomNum == 1">
+        ORDER BY eq.sort,eq.id DESC
+        </if>
+        <if test=" randomNum == 2">
+            ORDER BY RAND()
+        </if>
+        LIMIT  #{knum}
+    </select>
+
+    <select id="getQuestionList" parameterType="com.zhongzheng.modules.bank.bo.ExamSimulateQueryBo" resultType="Long">
+        SELECT
+        q.question_id
+        FROM
+        exam_question eq
+        LEFT JOIN question q ON eq.question_id = q.question_id
+        WHERE
+        eq.exam_id = #{examId}
+        <if test="type != null and type != ''">
+            AND q.`type` = #{type}
+        </if>
+        <if test="knowledQuestionIds != null and knowledQuestionIds.size()!=0 ">
+            AND q.question_id not in
+            <foreach collection="knowledQuestionIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="randomNum == 1">
+            ORDER BY eq.sort,eq.id DESC
+        </if>
+        <if test=" randomNum == 2">
+            ORDER BY RAND()
+        </if>
+        LIMIT  #{qnum}
+    </select>
+
+    <select id="queryBatchList" parameterType="com.zhongzheng.modules.bank.bo.ExamSimulateQueryBo" resultMap="QuestionResultVo">
+        SELECT
+        q.*
+        FROM
+            exam_simulate_question esq on question q esq.question_id = q.question_id where esq.simulate_exam_id = #{simulateExamId} ORDER BY esq.sort
 
+    </select>
 </mapper>

+ 1 - 1
zhongzheng-system/src/main/resources/mapper/modules/bank/ExamSimulateQuestionMapper.xml

@@ -6,7 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <resultMap type="com.zhongzheng.modules.bank.domain.ExamSimulateQuestion" id="ExamSimulateQuestionResult">
         <result property="id" column="id"/>
-        <result property="examId" column="exam_id"/>
+        <result property="simulateExamId" column="simulate_exam_id"/>
         <result property="questionId" column="question_id"/>
         <result property="sort" column="sort"/>
     </resultMap>

+ 2 - 0
zhongzheng-system/src/main/resources/mapper/modules/bank/QuestionMapper.xml

@@ -636,4 +636,6 @@
         WHERE
             ga.goods_id = #{goodsId} AND ga.type = 3
     </select>
+
+
 </mapper>