he2802 2 anos atrás
pai
commit
de311f8f02

+ 10 - 1
zhongzheng-admin/src/main/java/com/zhongzheng/controller/bank/QuestionController.java

@@ -270,7 +270,7 @@ public class QuestionController extends BaseController {
         return AjaxResult.success(errorLog);
     }
 
-    @Log(title = "" +"", businessType = BusinessType.IMPORT)
+    @Log(title = "导入题目Word模板列表", businessType = BusinessType.IMPORT)
     @ApiOperation("导入题目Word模板列表")
     @PreAuthorize("@ss.hasPermi('system:question:import')")
     @PostMapping("/importWordQuestionList")
@@ -289,4 +289,13 @@ public class QuestionController extends BaseController {
         Map<String,Object> result = iQuestionService.importJJWordQuestionList(file,  eduId,  projectId,  businessId, subjectId);
         return AjaxResult.success(result);
     }
+
+    @ApiOperation("导入学监题目Word模板列表")
+    @PreAuthorize("@ss.hasPermi('system:question:import')")
+    @PostMapping("/importXueJianWordQuestionList")
+    public AjaxResult<Map<String,Object>> importXueJianWordQuestionList(MultipartFile file, Long eduId, Long projectId, Long businessId, Long subjectId) throws Exception
+    {
+        Map<String,Object> result = iQuestionService.importXueJianWordQuestionList(file,  eduId,  projectId,  businessId, subjectId);
+        return AjaxResult.success(result);
+    }
 }

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

@@ -87,6 +87,8 @@ public interface IQuestionService extends IService<Question> {
 
 	Map<String,Object> importJJWordQuestionList(MultipartFile file, Long eduId, Long projectId, Long businessId, Long subjectId);
 
+	Map<String,Object> importXueJianWordQuestionList(MultipartFile file, Long eduId, Long projectId, Long businessId, Long subjectId);
+
     boolean batchDelQuestion(QuestionBatchDelBo bo);
 
     List<BankGoodsExamVo> getBankGoodsExamList(Long goodsId);

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

@@ -1887,6 +1887,407 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
         return result;
     }
 
+    @Override
+    public Map<String, Object> importXueJianWordQuestionList(MultipartFile file, Long eduId, Long projectId, Long businessId, Long subjectId) {
+        Map<String,Object> result = new HashMap<>();
+        List<QuestionAddBo> list = new ArrayList<>();
+        String errorLog = ""; //错误提示
+        String buffer = "";
+        String importNo = ServletUtils.getEncoded("IMPORT");
+        Long sort = 1L;
+        if(Validator.isEmpty(file)){
+            throw new CustomException("请选择文件");
+        }
+        try {
+            Long nowTime = DateUtils.getNowTime();
+            String path = file.getOriginalFilename();
+            if (path.endsWith(".doc")) {
+                throw new CustomException("不支持doc格式");
+            } else if (path.endsWith("docx")) {
+                InputStream is = file.getInputStream();
+                XWPFDocument doc = new XWPFDocument(is);
+                List<XWPFParagraph> paragraphList = doc.getParagraphs();
+                int type = -1;  //题目类型
+                boolean isOption = false; //是否判断题
+                List<QuestionChildAddBo> optionsList = new ArrayList<>(); //题目选项
+                String content = ""; //每行正文
+                String qContent = ""; //题目正文
+                String answerQuestion = null; //答案
+                String analysisContent = ""; //解析文本
+                int index = 1; //题目序列号
+                List<QuestionBusinessAddBo> businessList = new ArrayList<>();
+                QuestionBusinessAddBo questionBusinessAddBo = new QuestionBusinessAddBo();
+                questionBusinessAddBo.setEducationTypeId(eduId);
+                questionBusinessAddBo.setProjectId(projectId);
+                questionBusinessAddBo.setBusinessId(businessId);
+                questionBusinessAddBo.setSubjectId(subjectId);
+                businessList.add(questionBusinessAddBo);
+
+                List<QuestionAddBo> list1 = new ArrayList<>(); //单选列表
+                List<QuestionAddBo> list2 = new ArrayList<>(); //多选列表
+                List<QuestionAddBo> list3 = new ArrayList<>(); //简答列表
+                List<QuestionAddBo> list4 = new ArrayList<>(); //判断列表
+
+                Integer nowPart = -1;//0正文 1选项A 2选项B 3选项C 4选项D 5选项E 6选项F
+                String strContent = "";
+                String imgUrl = "";
+                boolean hasQuestion = false;
+                boolean hasRightTag = false;
+                boolean hasError = false;
+                for (XWPFParagraph paragraph : paragraphList) {
+                    content = paragraph.getText();
+                    List<XWPFRun> runs = paragraph.getRuns();
+                    imgUrl = null;
+                    for (XWPFRun run : runs) {
+                        Node node = run.getCTR().getDomNode();
+
+                        // drawing 一个绘画的图片
+                        Node drawingNode = getChildNode(node, "w:drawing");
+                        if (drawingNode == null && content == null) {
+                            imgUrl = null;
+                            continue;
+                        }
+                        //上传图片
+                        if (Validator.isNotEmpty(drawingNode)) {
+                            // 绘画图片的宽和高
+                            Node extentNode = getChildNode(drawingNode, "wp:extent");
+                            NamedNodeMap extentAttrs = extentNode.getAttributes();
+                            int wPx = ToolsUtils.emuToPx(Double.valueOf(extentAttrs.getNamedItem("cx").getNodeValue()));
+                            //            System.out.println("宽:".concat(extentAttrs.getNamedItem("cx").getNodeValue()).concat("emu"));
+                            //            System.out.println("高:".concat(extentAttrs.getNamedItem("cy").getNodeValue()).concat("emu"));
+                            int HPx = ToolsUtils.emuToPx(Double.valueOf(extentAttrs.getNamedItem("cy").getNodeValue()));
+
+                            // 绘画图片具体引用
+                            Node blipNode = getChildNode(drawingNode, "a:blip");
+                            NamedNodeMap blipAttrs = blipNode.getAttributes();
+                            String rid = blipAttrs.getNamedItem("r:embed").getNodeValue();
+                            //            System.out.println("word中图片ID:".concat(rid));
+
+                            // 获取图片信息
+                            PackagePart part = doc.getPartById(rid);
+                            String ossPath = null;
+                            try {
+                                ossPath = ossService.uploadInputStream(part.getInputStream(), 8);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
+                            imgUrl =  ossPath + "?x-oss-process=image/resize,w_" + wPx + ",h_" + HPx;
+                            if(isOptionStart(content)||(nowPart>0&&nowPart<7&&!isNotOptionStart(content))){
+                                //选项图片路径不用处理
+
+                            }else{
+                                //正文图片
+                                content =  content +"<br />" +"<p><img src=\"" + ossHost + "/" + imgUrl + "\"></p>";
+                            }
+                        }
+                    }
+                    content = dealTxt(content);
+                    if (content.startsWith("#")||isQuestionStart(content)) {
+                        if(hasQuestion){
+                            index++;
+                            hasQuestion = false;
+                            //插入上一条
+                            QuestionAddBo addBo = new QuestionAddBo();
+                            qContent = removeNo(qContent);
+                            if (Validator.isEmpty(qContent)) {
+                                hasError = true;
+                                errorLog += "第" + index + "条题目内容错误\n";
+                                continue;
+
+                            }
+                            QuestionAddBo bo = new QuestionAddBo();
+                            if (type == -1) {
+                                hasError = true;
+                                errorLog += "第" + index + "条题目选项错误\n";
+                                continue;
+
+                            }
+                            if(!hasError){
+                                if (Validator.isEmpty(answerQuestion)) {
+                                    errorLog += "第" + index + "正确答案错误\n";
+                                    continue;
+
+                                }
+                                if(type==5){
+                                    answerQuestion = null;
+                                }
+                                bo.setType(type);
+                                bo.setStatus(1);
+                                bo.setContent(qContent);
+                                bo.setAnswerQuestion(answerQuestion);
+                                bo.setAnalysisContent(analysisContent);
+                                bo.setOptionsList(copyList(optionsList));
+                                bo.setCreateBy(SecurityUtils.getUsername());
+                                bo.setImportNo(importNo);
+                                bo.setPublishStatus(1);
+                                bo.setBusinessList(businessList);
+                                bo.setCreateTime(nowTime);
+                                if(type==1){
+                                    list1.add(bo);
+                                }
+                                if(type==2){
+                                    list2.add(bo);
+                                }
+                                if(type==3){
+                                    list4.add(bo);
+                                }
+                                if(type==5){
+                                    list3.add(bo);
+                                }
+                            }
+
+                            sort++;
+                            hasError = false;
+                            //清空数据
+                            isOption = false;
+                            type = -1;
+                            qContent = "";
+                            answerQuestion = null;
+                            analysisContent = "";
+                            optionsList.clear();
+                            nowPart = -1;
+                            hasRightTag= false;
+                        }
+                    }
+                    if (content.startsWith("正确答案:")){
+                        if(!hasRightTag){
+                            hasRightTag = true;
+                        }else{
+                            errorLog += "第" + index + "题目序号可能错误\n";
+                            hasRightTag =false;
+                            continue;
+                        }
+                    }
+                    if (content.startsWith("#")) { //导入结束
+                        break;
+                    }
+                    if(Validator.isEmpty(content)||content.equals("")){
+                        continue;
+                    }
+                    if (isQuestionStart(content)||(nowPart==0&&!isLineStart(content))) {
+                        hasQuestion = true;
+                        if(nowPart!=0){
+                            qContent = "";
+                        }
+                        nowPart = 0;
+                        //新题开头
+                        qContent = qContent +   content +"<br />";
+                    }
+                    //第一个选项
+                    if(content.startsWith("А.")||content.startsWith("A.")||(nowPart==1&&!isLineStart(content))) {
+                        hasQuestion = true;
+                        if(nowPart!=1){
+                            strContent = "";
+                        }
+                        isOption = true; //是选择题
+                        nowPart = 1;
+                        strContent = strContent +   content ;
+                        QuestionChildAddBo bo1;
+                        if(optionsList.size()<1){
+                            bo1 = new QuestionChildAddBo();
+                            bo1.setOptionsId(1L);
+                            bo1.setImgUrl(imgUrl);
+                            bo1.setContent(strContent.replace("A.", "").replace("А.", ""));
+                            optionsList.add(bo1);
+                        }else{
+                            bo1 = optionsList.get(0);
+                            bo1.setImgUrl(imgUrl);
+                            bo1.setContent(strContent.replace("A.", "").replace("А.", ""));
+                        }
+                    }
+                    //第二个选项
+                    if (content.startsWith("B.")||(nowPart==2&&!isLineStart(content))) {
+                        if (optionsList.size()<1) {
+                            errorLog += "第" + index + "条题目选项A错误\n";
+                            continue;
+                        }
+                        if(nowPart!=2){
+                            strContent = "";
+                        }
+                        nowPart = 2;
+                        strContent = strContent +  content ;
+                        QuestionChildAddBo bo1;
+                        if(optionsList.size()<2){
+                            bo1 = new QuestionChildAddBo();
+                            bo1.setOptionsId(2L);
+                            bo1.setImgUrl(imgUrl);
+                            bo1.setContent(strContent.replace("B.", ""));
+                            optionsList.add(bo1);
+                        }else{
+                            bo1 = optionsList.get(1);
+                            bo1.setImgUrl(imgUrl);
+                            bo1.setContent(strContent.replace("B.", ""));
+                        }
+                    }
+                    //第三个选项
+                    if (content.startsWith("C.")||(nowPart==3&&!isLineStart(content))) {
+                        if(nowPart!=3){
+                            strContent = "";
+                        }
+                        nowPart = 3;
+                        strContent = strContent +   content;
+                        QuestionChildAddBo bo1;
+                        if(optionsList.size()<3){
+                            bo1 = new QuestionChildAddBo();
+                            bo1.setOptionsId(3L);
+                            bo1.setImgUrl(imgUrl);
+                            bo1.setContent(strContent.replace("C.", ""));
+                            optionsList.add(bo1);
+                        }else{
+                            bo1 = optionsList.get(2);
+                            bo1.setImgUrl(imgUrl);
+                            bo1.setContent(strContent.replace("C.", ""));
+                        }
+                    }
+                    //第四个选项
+                    if (content.startsWith("D.")||(nowPart==4&&!isLineStart(content))) {
+                        if(nowPart!=4){
+                            strContent = "";
+                        }
+                        nowPart = 4;
+                        strContent = strContent +   content ;
+                        QuestionChildAddBo bo1;
+                        if(optionsList.size()<4){
+                            bo1 = new QuestionChildAddBo();
+                            bo1.setOptionsId(4L);
+                            bo1.setImgUrl(imgUrl);
+                            bo1.setContent(strContent.replace("D.", ""));
+                            optionsList.add(bo1);
+                        }else{
+                            bo1 = optionsList.get(3);
+                            bo1.setImgUrl(imgUrl);
+                            bo1.setContent(strContent.replace("D.", ""));
+                        }
+                    }
+                    //第五个选项
+                    if (content.startsWith("E.")||(nowPart==5&&!isLineStart(content))) {
+                        if(nowPart!=5){
+                            strContent = "";
+                        }
+                        nowPart = 5;
+                        strContent = strContent +   content ;
+                        QuestionChildAddBo bo1;
+                        if(optionsList.size()<5){
+                            bo1 = new QuestionChildAddBo();
+                            bo1.setOptionsId(5L);
+                            bo1.setImgUrl(imgUrl);
+                            bo1.setContent(strContent.replace("E.", ""));
+                            optionsList.add(bo1);
+                        }else{
+                            bo1 = optionsList.get(4);
+                            bo1.setImgUrl(imgUrl);
+                            bo1.setContent(strContent.replace("E.", ""));
+                        }
+                    }
+                    //第六个选项
+                    if (content.startsWith("F.")||(nowPart==6&&!isLineStart(content))) {
+                        if(nowPart!=6){
+                            strContent = "";
+                        }
+                        nowPart = 6;
+                        strContent = strContent +   content ;
+                        QuestionChildAddBo bo1;
+                        if(optionsList.size()<6){
+                            bo1 = new QuestionChildAddBo();
+                            bo1.setOptionsId(6L);
+                            bo1.setImgUrl(imgUrl);
+                            bo1.setContent(strContent.replace("F.", ""));
+                            optionsList.add(bo1);
+                        }else{
+                            bo1 = optionsList.get(5);
+                            bo1.setImgUrl(imgUrl);
+                            bo1.setContent(strContent.replace("F.", ""));
+                        }
+                    }
+                    //答案和题型
+                    if (content.startsWith("正确答案:")||(nowPart==7&&!isLineStart(content))) {
+                        if(nowPart!=7){
+                            strContent = "";
+                        }
+
+                        nowPart = 7;
+
+                        if(Validator.isNotEmpty(answerQuestion)){
+                            answerQuestion = answerQuestion +  "<br />" + content ;
+                        }else{
+                            answerQuestion = content.replace("正确答案:", "");
+                        }
+                        if (isOption) {
+                            //选择题
+                            answerQuestion = dealImportAnswer(answerQuestion);
+                            if (answerQuestion.length() > 1) {
+                                type = 2; //多选
+                            } else {
+                                type = 1; //单选
+                            }
+                        } else {
+                            if ("正确".equals(answerQuestion)) {
+                                answerQuestion = "1";
+                                type = 3; //判断
+                            } else if ("错误".equals(answerQuestion)) {
+                                answerQuestion = "0";
+                                type = 3;
+                            } else {
+                                analysisContent = answerQuestion; //简答题把正确答案填充到解析文本
+                                type = 5; //简答题
+                            }
+                        }
+
+                    }
+                    else if (content.startsWith("解题思路")||(nowPart==8&&!isLineStart(content))) {
+                        nowPart = 8;
+                        analysisContent = analysisContent +   content +"<br />";
+                    }
+                    else if (content.startsWith("考查考点")||(nowPart==9&&!isLineStart(content))) {
+                        nowPart = 9;
+                        analysisContent = analysisContent +   content +"<br />";
+                    }
+                    else if (content.startsWith("老师解答")||(nowPart==10&&!isLineStart(content))) {
+                        nowPart = 10;
+                        analysisContent = analysisContent +   content +"<br />";
+                    }
+                }
+                //遍历正文
+                int importSort = 1;
+                Collections.reverse(list4);
+                Collections.reverse(list3);
+                Collections.reverse(list2);
+                Collections.reverse(list1);
+                for(QuestionAddBo addBo : list3){
+                    addBo.setImportSort(importSort + addBo.getCreateTime());
+                    list.add(addBo);
+                    importSort++;
+                }
+                for(QuestionAddBo addBo : list4){
+                    addBo.setImportSort(importSort + addBo.getCreateTime());
+                    list.add(addBo);
+                    importSort++;
+                }
+                for(QuestionAddBo addBo : list2){
+                    addBo.setImportSort(importSort + addBo.getCreateTime());
+                    list.add(addBo);
+                    importSort++;
+                }
+                for(QuestionAddBo addBo : list1){
+                    addBo.setImportSort(importSort + addBo.getCreateTime());
+                    list.add(addBo);
+                    importSort++;
+                }
+                //    buffer = extractor.getText();
+                //extractor.close();
+
+            } else {
+                throw new CustomException("请导入word文件!");
+            }
+        } catch (IOException e) {
+            System.out.println("此文件不是word文件!" + e.getMessage() + e.toString() + e.getLocalizedMessage());
+        }
+        Collections.reverse(list);
+        result.put("list",list);
+        result.put("errorLog",errorLog);
+        return result;
+    }
+
     @Override
     public Map<String, Object> importJJWordQuestionList(MultipartFile file, Long eduId, Long projectId, Long businessId, Long subjectId) {
         Map<String,Object> result = new HashMap<>();
@@ -2247,6 +2648,8 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
         return result;
     }
 
+
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean batchDelQuestion(QuestionBatchDelBo bo) {

+ 7 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderGoodsServiceImpl.java

@@ -552,6 +552,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
 
             Long secLong = 0L;
             Long studyLong = 0L;
+            Integer studyStatus = 0;
             SubjectStudyRecordQueryBo subjectStudyRecordQueryBo = new SubjectStudyRecordQueryBo();
             subjectStudyRecordQueryBo.setGoodsId(goodsVo.getGoodsId());
             subjectStudyRecordQueryBo.setUserId(bo.getUserId());
@@ -561,9 +562,15 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
             for (SubjectStudyRecordVo subjectStudyRecordVo : subjectStudyRecordVos) {
                 secLong = new BigDecimal(secLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getSectionNum().toString())).longValue();
                 studyLong = new BigDecimal(studyLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getRecordNum().toString())).longValue();
+                studyStatus = studyStatus + subjectStudyRecordVo.getStudyStatus();
             }
             goodsVo.setSecAllNum(secLong);
             goodsVo.setStuAllNum(studyLong);
+            if(studyStatus>0){
+                goodsVo.setStudyStatus(2);
+            }else{
+                goodsVo.setStudyStatus(1);
+            }
             if(goodsVo.getGoodsType()==1){
                 //视频商品
                 //获得当前所在班级

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/vo/OrderGoodsVo.java

@@ -341,4 +341,6 @@ public class OrderGoodsVo {
 	private Long periodWaitTime;
 	@ApiModelProperty("是否是二建二造")
 	private Boolean erJianErZao;
+	@ApiModelProperty("1未开始 2已开始")
+	private Integer studyStatus;
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/SubjectStudyRecordVo.java

@@ -70,4 +70,7 @@ public class SubjectStudyRecordVo {
     @ApiModelProperty("科目節模塊學習返回")
     private List<SectionStudyRecordVo> sectionStudyRecordVo;
 
+    @ApiModelProperty("学习状态")
+    private Integer studyStatus;
+
 }

+ 2 - 0
zhongzheng-system/src/main/resources/mapper/modules/user/UserStudyRecordMapper.xml

@@ -60,6 +60,7 @@
         <result property="sectionNum" column="section_num"/>
         <result property="recordNum" column="record_num"/>
         <result property="recordTime" column="record_time"/>
+        <result property="studyStatus" column="study_status"/>
     </resultMap>
 
     <resultMap type="com.zhongzheng.modules.user.vo.SectionStudyRecordVo" id="SectionStudyRecordVoResult">
@@ -340,6 +341,7 @@
             and c.tenant_id=#{tenantId}
         </if>
         and c.user_id=#{userId} and c.status = 1 and c.goods_id = #{goodsId}) as record_num,
+        (SELECT count(*) from user_study_record usr where usr.user_id = #{userId} and usr.grade_id = #{gradeId} and usr.current_status = 1 and usr.course_id = r.course_id) as study_status,
         (SELECT IFNULL(SUM(cs.duration_time),0) from (select DISTINCT c.section_id,c.course_id FROM user_study_record c where 1=1
         and c.current_status=1
         <if test="gradeId != null and gradeId !=''">