he2802 2 years ago
parent
commit
7e9fa6662f

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

@@ -279,4 +279,14 @@ public class QuestionController extends BaseController {
         Map<String,Object> result = iQuestionService.importWordQuestionList(file,  eduId,  projectId,  businessId, subjectId);
         Map<String,Object> result = iQuestionService.importWordQuestionList(file,  eduId,  projectId,  businessId, subjectId);
         return AjaxResult.success(result);
         return AjaxResult.success(result);
     }
     }
+
+
+    @ApiOperation("导入建匠题目Word模板列表")
+    @PreAuthorize("@ss.hasPermi('system:question:import')")
+    @PostMapping("/importJJWordQuestionList")
+    public AjaxResult<Map<String,Object>> importJJWordQuestionList(MultipartFile file, Long eduId, Long projectId, Long businessId, Long subjectId) throws Exception
+    {
+        Map<String,Object> result = iQuestionService.importJJWordQuestionList(file,  eduId,  projectId,  businessId, subjectId);
+        return AjaxResult.success(result);
+    }
 }
 }

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

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

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

@@ -1887,6 +1887,255 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
         return result;
         return result;
     }
     }
 
 
+    @Override
+    public Map<String, Object> importJJWordQuestionList(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<>(); //判断列表
+                Map<String,QuestionAddBo> allQues = new HashMap<>();
+                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;
+                boolean answerStatus = false;
+                int cIndex = 1;
+                int nIndex = 2;
+                List<String> alKeyList  = new ArrayList<>();
+                alKeyList.add("案例(一)");
+                alKeyList.add("案例(二)");
+                alKeyList.add("案例(三)");
+                alKeyList.add("案例(四)");
+                alKeyList.add("案例(五)");
+                alKeyList.add("案例(六)");
+                alKeyList.add("案例(七)");
+                alKeyList.add("案例(八)");
+                alKeyList.add("案例(九)");
+                alKeyList.add("案例(十)");
+                String indexKey = null;
+                for (XWPFParagraph paragraph : paragraphList) {
+                    content = paragraph.getText();
+                    List<XWPFRun> runs = paragraph.getRuns();
+                    imgUrl = null;
+                //    System.out.println(content);
+                    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)) {
+                            System.out.println("有图片拉");
+                        }
+                    }
+                    content = dealTxt(content);
+            //        System.out.println(content);
+                    if (content.startsWith("#")) { //导入结束
+                        break;
+                    }
+                    if(content.indexOf("单项选择题")>0&&!answerStatus){
+                        System.out.println(content);
+                        type = 1;
+                    }
+                    if(content.indexOf("多项选择题")>0&&!answerStatus){
+                        type = 2;
+                    }
+                    if(content.indexOf("案例分析题")>0&&!answerStatus){
+                        type = 5;
+                    }
+                    //单选,多选
+                    if(type==1||type==2){
+                        if(content.startsWith(cIndex+".")||content.startsWith(nIndex+".")){
+                            if(content.startsWith(nIndex+".")){
+                                indexKey =nIndex+".";
+                                //上一道结束
+                                cIndex++;
+                                nIndex++;
+                            }else{
+                                indexKey =cIndex+".";
+                            }
+                            QuestionAddBo addBo = new QuestionAddBo();
+                            qContent = content.replace(indexKey, "");
+                            addBo.setContent(qContent);
+                            addBo.setType(type);
+                            addBo.setOptionsList(new ArrayList<>());
+                            allQues.put(indexKey,addBo);
+                        }
+                        //第一个选项
+                        if(content.startsWith("A.")) {
+                            QuestionAddBo cAddBo = allQues.get(indexKey);
+                            QuestionChildAddBo bo1;
+                            bo1 = new QuestionChildAddBo();
+                            bo1.setOptionsId(1L);
+                            bo1.setImgUrl(imgUrl);
+                            bo1.setContent(content.replace("A.", ""));
+                            cAddBo.getOptionsList().add(bo1);
+
+                        }
+                        //第二个选项
+                        if (content.startsWith("B.")) {
+                            QuestionChildAddBo bo1;
+                            bo1 = new QuestionChildAddBo();
+                            bo1.setOptionsId(2L);
+                            bo1.setImgUrl(imgUrl);
+                            bo1.setContent(content.replace("B.", ""));
+                            QuestionAddBo cAddBo = allQues.get(indexKey);
+                            cAddBo.getOptionsList().add(bo1);
+                        }
+                        //第三个选项
+                        if (content.startsWith("C.")) {
+                            QuestionChildAddBo bo1;
+                            bo1 = new QuestionChildAddBo();
+                            bo1.setOptionsId(2L);
+                            bo1.setImgUrl(imgUrl);
+                            bo1.setContent(content.replace("C.", ""));
+                            QuestionAddBo cAddBo = allQues.get(indexKey);
+                            cAddBo.getOptionsList().add(bo1);
+                        }
+                        //第四个选项
+                        if (content.startsWith("D.")) {
+                            QuestionChildAddBo bo1;
+                            bo1 = new QuestionChildAddBo();
+                            bo1.setOptionsId(2L);
+                            bo1.setImgUrl(imgUrl);
+                            bo1.setContent(content.replace("D.", ""));
+                            QuestionAddBo cAddBo = allQues.get(indexKey);
+                            cAddBo.getOptionsList().add(bo1);
+                        }
+                        //第五个选项
+                        if (content.startsWith("E.")) {
+                            QuestionChildAddBo bo1;
+                            bo1 = new QuestionChildAddBo();
+                            bo1.setOptionsId(2L);
+                            bo1.setImgUrl(imgUrl);
+                            bo1.setContent(content.replace("E.", ""));
+                            QuestionAddBo cAddBo = allQues.get(indexKey);
+                            cAddBo.getOptionsList().add(bo1);
+                        }
+                        //第六个选项
+                        if (content.startsWith("F.")) {
+                            QuestionChildAddBo bo1;
+                            bo1 = new QuestionChildAddBo();
+                            bo1.setOptionsId(2L);
+                            bo1.setImgUrl(imgUrl);
+                            bo1.setContent(content.replace("F.", ""));
+                            QuestionAddBo cAddBo = allQues.get(indexKey);
+                            cAddBo.getOptionsList().add(bo1);
+                        }
+                    }
+
+                    //问答
+                    if(type==5){
+                        if(alKeyList.contains(content)){
+                            indexKey = content;
+                            QuestionAddBo addBo = new QuestionAddBo();
+                            addBo.setType(type);
+                            addBo.setContent("");
+                            allQues.put(indexKey,addBo);
+                        }else{
+                            QuestionAddBo cAddBo = allQues.get(indexKey);
+                            cAddBo.setContent(cAddBo.getContent()+ content+"<br />");
+                        }
+                    }
+                    if(content.startsWith("参考答案及解析")){
+                        answerStatus = true;
+                    }
+                    if(content.indexOf("单项选择题")>0&&answerStatus){
+
+                    }
+                    if(content.indexOf("多项选择题")>0&&answerStatus){
+
+                    }
+                    if(content.indexOf("案例分析题")>0&&answerStatus){
+
+                    }
+
+                }
+                System.out.println("结束");
+                System.out.println(allQues);
+                //遍历正文
+                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
     @Override
     @Transactional(rollbackFor = Exception.class)
     @Transactional(rollbackFor = Exception.class)
     public boolean batchDelQuestion(QuestionBatchDelBo bo) {
     public boolean batchDelQuestion(QuestionBatchDelBo bo) {

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseQueryBo.java

@@ -114,4 +114,7 @@ public class CourseQueryBo extends BaseEntity {
 
 
 	@ApiModelProperty("手机号码")
 	@ApiModelProperty("手机号码")
 	private List<CourseProgressQueryBo> telphoneList;
 	private List<CourseProgressQueryBo> telphoneList;
+
+	@ApiModelProperty("1未开始 2未完成 3已完成")
+	private Integer studyStatus;
 }
 }

+ 11 - 0
zhongzheng-system/src/main/resources/mapper/modules/course/CourseMapper.xml

@@ -581,6 +581,17 @@
         <if test="goodsId != null and goodsId != ''">
         <if test="goodsId != null and goodsId != ''">
             AND og.goods_id = #{goodsId}
             AND og.goods_id = #{goodsId}
         </if>
         </if>
+        <if test="studyStatus != null and studyStatus == 3">
+            and (SELECT count(*) from class_grade_user cgu where cgu.user_id = o.user_id and cgu.grade_id = og.grade_id and cgu.period_status != -1) >0
+        </if>
+        <if test="studyStatus != null and studyStatus == 2">
+            and (SELECT count(*) from class_grade_user cgu where cgu.user_id = o.user_id and cgu.grade_id = og.grade_id and cgu.period_status == -1) >0
+            and (SELECT count(*) from user_study_record usr where usr.user_id = o.user_id and usr.order_goods_id = og.order_goods_id ) >0
+        </if>
+        <if test="studyStatus != null and studyStatus == 1">
+            and (SELECT count(*) from class_grade_user cgu where cgu.user_id = o.user_id and cgu.grade_id = og.grade_id and cgu.period_status == -1) >0
+            and (SELECT count(*) from user_study_record usr where usr.user_id = o.user_id and usr.order_goods_id = og.order_goods_id ) =0
+        </if>
         order by o.create_time desc
         order by o.create_time desc
     </select>
     </select>
     <select id="courseList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo"  resultMap="CourseUserVo">
     <select id="courseList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo"  resultMap="CourseUserVo">