Browse Source

Merge branch 'dev'

yangdamao 2 days ago
parent
commit
2e270aec8f

+ 13 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/goods/GoodsController.java

@@ -12,12 +12,14 @@ import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.poi.EasyPoiUtil;
 import com.zhongzheng.common.utils.poi.ExcelUtil;
 import com.zhongzheng.modules.bank.service.IQuestionService;
+import com.zhongzheng.modules.bank.vo.QuestionAnswerVo;
 import com.zhongzheng.modules.exam.bo.ExamNumberGoodsQueryBo;
 import com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo;
 import com.zhongzheng.modules.goods.bo.*;
 import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.*;
+import com.zhongzheng.modules.top.distribution.vo.DistributionActivityTemplateVo;
 import com.zhongzheng.modules.top.order.bo.TopOrderQuestionImportBo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -444,4 +446,15 @@ public class GoodsController extends BaseController {
     public AjaxResult<Void> disposeQuestion(@PathVariable("goodsId") Long goodsId) {
         return toAjax(iGoodsService.disposeQuestion(goodsId) ? 1 : 0);
     }
+
+    /**
+     * 获取题库答案
+     */
+    @ApiOperation("导出获取题库答案")
+    @GetMapping("/question/answer")
+    public AjaxResult<QuestionAnswerVo> getQuestionAnswer(@RequestParam("goodsId") Long goodsId,@RequestParam("major") String major) {
+        List<QuestionAnswerVo> list = iGoodsService.getQuestionAnswer(goodsId);
+        ExcelUtil<QuestionAnswerVo> util = new ExcelUtil<QuestionAnswerVo>(QuestionAnswerVo.class);
+        return util.exportExcel(list, major);
+    }
 }

+ 16 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/QuestionAnswerVo.java

@@ -0,0 +1,16 @@
+package com.zhongzheng.modules.bank.vo;
+
+import com.zhongzheng.common.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class QuestionAnswerVo implements Serializable {
+
+    @Excel(name = "题库名称")
+    private String questionName;
+
+    @Excel(name = "答案")
+    private String answer;
+}

+ 3 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/mapper/GoodsMapper.java

@@ -2,10 +2,7 @@ package com.zhongzheng.modules.goods.mapper;
 
 import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.zhongzheng.modules.bank.domain.Exam;
-import com.zhongzheng.modules.bank.domain.QuestionBusiness;
-import com.zhongzheng.modules.bank.domain.QuestionChapter;
-import com.zhongzheng.modules.bank.domain.QuestionModule;
+import com.zhongzheng.modules.bank.domain.*;
 import com.zhongzheng.modules.course.bo.CourseQueryBo;
 import com.zhongzheng.modules.course.bo.ExternalQuestionBo;
 import com.zhongzheng.modules.course.bo.ReplenishExamBo;
@@ -139,4 +136,6 @@ public interface GoodsMapper extends BaseMapper<Goods> {
     List<GoodsCourseTreeVo> getGoodsCourseTree(Long goodsId);
 
     List<CourseSection> getGoodsSectionInfo(Long goodsId);
+
+    List<Question> getQuestionAnswer(Long goodsId);
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/IGoodsService.java

@@ -1,6 +1,7 @@
 package com.zhongzheng.modules.goods.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.zhongzheng.modules.bank.vo.QuestionAnswerVo;
 import com.zhongzheng.modules.course.bo.CourseQueryBo;
 import com.zhongzheng.modules.course.bo.ExternalQuestionBo;
 import com.zhongzheng.modules.course.bo.ReplenishExamBo;
@@ -181,4 +182,6 @@ public interface IGoodsService extends IService<Goods> {
 	boolean sectionExport(List<SectionExportBo> boList,String json);
 
 	boolean disposeQuestion(Long goodsId);
+
+    List<QuestionAnswerVo> getQuestionAnswer(Long goodsId);
 }

+ 89 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -28,6 +28,7 @@ import com.zhongzheng.modules.alioss.service.OssService;
 import com.zhongzheng.modules.bank.domain.*;
 import com.zhongzheng.modules.bank.mapper.QuestionMapper;
 import com.zhongzheng.modules.bank.service.*;
+import com.zhongzheng.modules.bank.vo.QuestionAnswerVo;
 import com.zhongzheng.modules.base.domain.*;
 import com.zhongzheng.modules.base.service.*;
 import com.zhongzheng.modules.course.bo.*;
@@ -376,6 +377,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
 //                    goods.setSpecTemplateId(relation.getSpecTemplateId());
 //                }
 //            }
+            List<Question> questionAnswer = baseMapper.getQuestionAnswer(goods.getGoodsId());
+            goods.setIsQuestionAnswer(CollectionUtils.isNotEmpty(questionAnswer)?1:0);
             //多规格下的价格区间
             if (ObjectUtils.isNotNull(goods.getSpecTemplateId())) {
                 List<GoodsSpecAttributeRelation> specAttributeRelations = goodsSpecAttributeRelationService
@@ -5888,6 +5891,92 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         return true;
     }
 
+    @Override
+    public List<QuestionAnswerVo> getQuestionAnswer(Long goodsId) {
+        Goods goods = getById(goodsId);
+        if (ObjectUtils.isNull(goods)){
+            throw new CustomException("获取商品信息失败");
+        }
+
+        //获取题库
+        List<Question> questions = baseMapper.getQuestionAnswer(goodsId);
+        if (CollectionUtils.isEmpty(questions)){
+            return new ArrayList<>();
+        }
+        List<QuestionAnswerVo> answerVos = questions.stream().map(item -> {
+            QuestionAnswerVo vo = new QuestionAnswerVo();
+            vo.setQuestionName(htmlToTextSimple(item.getContent()));
+            switch (item.getType()) {
+                case 1: //单选
+                    vo.setAnswer(answerTransition(item.getAnswerQuestion()));
+                    break;
+                case 2: //多选
+                    vo.setAnswer(answerTransition(item.getAnswerQuestion()));
+                    break;
+                case 3: //判断
+                    vo.setAnswer(item.getAnswerQuestion().equals("1") ? "正确" : "错误");
+                    break;
+                default:
+                    break;
+            }
+            return vo;
+        }).collect(Collectors.toList());
+
+        return answerVos;
+    }
+
+    private static String htmlToTextSimple(String html) {
+        if (html == null) return "";
+
+        // 去除常见HTML标签
+        String text = html
+                .replaceAll("<p>", "")
+                .replaceAll("</p>", "")
+                .replaceAll("<div>", "")
+                .replaceAll("</div>", "")
+                .replaceAll("<br>", "\n")
+                .replaceAll("<br/>", "\n")
+                .replaceAll("<br />", "\n");
+
+        // 去除HTML实体
+        text = text
+                .replaceAll("&nbsp;", " ")
+                .replaceAll("&amp;", "&")
+                .replaceAll("&lt;", "<")
+                .replaceAll("&gt;", ">")
+                .replaceAll("&quot;", "\"");
+
+        return text.trim();
+    }
+
+    private String answerTransition(String answer){
+        List<String> list = Arrays.asList(answer.split(","));
+        String collect = list.stream().map(x -> {
+            String mm = "";
+            switch (x) {
+                case "1":
+                    mm = "A";
+                    break;
+                case "2":
+                    mm = "B";
+                    break;
+                case "3":
+                    mm = "C";
+                    break;
+                case "4":
+                    mm = "D";
+                    break;
+                case "5":
+                    mm = "E";
+                    break;
+                default:
+                    mm = "";
+                    break;
+            }
+            return mm;
+        }).collect(Collectors.joining(","));
+        return collect;
+    }
 
     private void updateHandoutsId(Long goodsId, Long tenantId, Long handoutsId) {
         baseMapper.updateHandoutsId(goodsId, tenantId, handoutsId);

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/vo/GoodsVo.java

@@ -427,4 +427,7 @@ public class GoodsVo {
 
 	/** 课时标识:1 显示 0不显示 */
 	private Integer hoursSign;
+
+	/** 是否有题库答案:1 有 0没有 */
+	private Integer isQuestionAnswer;
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderServiceImpl.java

@@ -285,7 +285,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                 vo.setOrderGoodsStatus(1);
             }
 
-            if (vo.getOrderType() == 7 && ObjectUtils.isNotNull(vo.getArtisanDataId())){
+            if (ObjectUtils.isNotNull(vo.getArtisanDataId())){
                 //技工订单
                 ArtisanData artisanData = iArtisanDataService.getById(vo.getArtisanDataId());
                 vo.setArtisanData(artisanData.getDataStr());

+ 13 - 0
zhongzheng-system/src/main/resources/mapper/modules/goods/GoodsMapper.xml

@@ -1243,4 +1243,17 @@
             AND cs.`status` = 1
     </select>
 
+    <select id="getQuestionAnswer" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.bank.domain.Question">
+        SELECT
+            q.*
+        FROM
+            goods g
+                LEFT JOIN goods_course gc ON g.goods_id = gc.goods_id
+                LEFT JOIN course_menu_exam cme ON gc.course_id = cme.course_id
+                LEFT JOIN exam_question eq ON cme.exam_id = eq.exam_id
+                INNER JOIN question q ON eq.question_id = q.question_id
+        WHERE
+            g.goods_id = #{goodsId}
+    </select>
+
 </mapper>