From 227fb1ce0c5e2ed8bdc63537a739af4ebdc32158 Mon Sep 17 00:00:00 2001 From: shijie <648688341@qq.com> Date: Thu, 27 Aug 2020 17:08:28 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=93=8D=E5=BA=94=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/msdw/tms/common/utils/R.java | 10 +++++----- .../tms/service/impl/QuestionsServiceImpl.java | 15 ++++++--------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/msdw/tms/common/utils/R.java b/src/main/java/com/msdw/tms/common/utils/R.java index 4fcc3a4..dc42fcd 100644 --- a/src/main/java/com/msdw/tms/common/utils/R.java +++ b/src/main/java/com/msdw/tms/common/utils/R.java @@ -22,8 +22,8 @@ public class R extends HashMap { private static final long serialVersionUID = 1L; public R() { - put("code", 0); - put("msg", "success"); + put("status", 200); + put("errmessage", "success"); } public static R error() { @@ -36,14 +36,14 @@ public class R extends HashMap { public static R error(int code, String msg) { R r = new R(); - r.put("code", code); - r.put("msg", msg); + r.put("status", code); + r.put("errmessage", msg); return r; } public static R ok(String msg) { R r = new R(); - r.put("msg", msg); + r.put("errmessage", msg); return r; } diff --git a/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java index 74d40a1..78e9dad 100644 --- a/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java +++ b/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java @@ -2,6 +2,7 @@ package com.msdw.tms.service.impl; import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -601,22 +602,18 @@ public class QuestionsServiceImpl extends ServiceImpl parse = (List) JSON.parse(record); + + List parse = JSON.parseObject(record, new TypeReference>() { + }); + parse.sort(Comparator.comparing(QuestionsImportFailureVO::getIndex)); -// Collections.sort(parse, new Comparator() { -// @Override -// public int compare(QuestionsImportFailureVO o1, QuestionsImportFailureVO o2) { -// //升序 -// return o1.getIndex().compareTo(o2.getIndex()); -// } -// }); //2.加载模板流数据 org.springframework.core.io.Resource resource = new ClassPathResource("excel-template/试题导入失败数据导出模板.xlsx"); FileInputStream fis = new FileInputStream(resource.getFile()); //3、通过工具类下载文件 - new ExcelExportUtil(QuestionsImportRequest.class, Constant.ROW_INDEX, Constant.STYLE_INDEX). + new ExcelExportUtil(QuestionsImportFailureVO.class, Constant.ROW_INDEX, Constant.STYLE_INDEX). export(response, fis, parse, "导入失败数据表.xlsx"); }