Browse Source

fix 导入word提示错误

he2802 3 years ago
parent
commit
a4b1f7110f

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

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

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

@@ -79,5 +79,5 @@ public interface IQuestionService extends IService<Question> {
 
     String importWordQuestion(MultipartFile file, Long eduId, Long projectId, Long businessId, Long subjectId);
 
-	List<QuestionAddBo> 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);
 }

+ 8 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java

@@ -1044,7 +1044,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                             }
                             if(!hasError){
                                 if (Validator.isEmpty(answerQuestion)) {
-                                    throw new CustomException("正确答案错误");
+                                    errorLog += "第" + index + "条正确答案错误\n";
                                 }
                                 if(type==5){
                                     answerQuestion = null;
@@ -1316,7 +1316,8 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
 
 
     @Override
-    public List<QuestionAddBo> importWordQuestionList(MultipartFile file, Long eduId, Long projectId, Long businessId, Long subjectId) {
+    public Map<String,Object> importWordQuestionList(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 = "";
@@ -1428,7 +1429,8 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                             }
                             if(!hasError){
                                 if (Validator.isEmpty(answerQuestion)) {
-                                    throw new CustomException("正确答案错误");
+                                    errorLog += "第" + index + "正确答案错误\n";
+
                                 }
                                 if(type==5){
                                     answerQuestion = null;
@@ -1698,7 +1700,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
             System.out.println("此文件不是word文件!" + e.getMessage() + e.toString() + e.getLocalizedMessage());
         }
         Collections.reverse(list);
-        return list;
+        result.put("list",list);
+        result.put("errorLog",errorLog);
+        return result;
     }
 
 

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

@@ -641,7 +641,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         List<GoodsVo> goodsVoList = queryList(goodsQueryBo);
         List<GoodsJzsVo> jzsVoList = new ArrayList<>();
         for(GoodsVo goodsVo : goodsVoList){
-            if(goodsVo.getGoodsId()!=919L){
+            if(goodsVo.getGoodsId()!=921L){
                 continue;
             }
             GoodsJzsVo jzsVo = new GoodsJzsVo();