package com.finance.web.controller.tool;
|
|
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSONObject;
|
import com.finance.common.core.domain.R;
|
import lombok.extern.slf4j.Slf4j;
|
|
import java.io.IOException;
|
import java.util.List;
|
|
/**
|
* 导出返回信息
|
*/
|
@Slf4j
|
public class ImportExcelUtil {
|
|
/**
|
* @param errorLines 错误行数
|
* @param successLines 成功行数
|
* @param errorMessage 错误信息
|
* @return
|
* @throws IOException
|
*/
|
public static R<String> importReturnMsg(int errorLines, int successLines, List<String> errorMessage) throws IOException {
|
if (errorLines == 0) {
|
return R.ok("共" + successLines + "行数据全部导入成功!");
|
} else {
|
JSONObject result = new JSONObject(5);
|
int totalCount = successLines + errorLines;
|
result.put("totalCount", totalCount);
|
result.put("errorCount", errorLines);
|
result.put("errorMessage", errorMessage);
|
result.put("successCount", successLines);
|
result.put("msg", "总上传行数:" + totalCount + ",已导入行数:" + successLines + ",错误行数:" + errorLines);
|
return R.ok(JSON.toJSONString(result));
|
}
|
}
|
|
}
|