|
|
|
@ -15,6 +15,7 @@ import com.ruoyi.web.controller.manager.QuManager;
|
|
|
|
|
import com.ruoyi.web.controller.manager.RepoManager;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.apache.commons.compress.utils.IOUtils;
|
|
|
|
|
import org.apache.commons.compress.utils.Lists;
|
|
|
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
|
@ -27,6 +28,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
@ -192,8 +194,10 @@ public class QuController extends BaseController {
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@PostMapping( "/import")
|
|
|
|
|
public AjaxResult importFile(@RequestParam("file") MultipartFile file) {
|
|
|
|
|
InputStream inputStream = null;
|
|
|
|
|
try {
|
|
|
|
|
ImportExcel ei = new ImportExcel(file, 1, 0);
|
|
|
|
|
inputStream = file.getInputStream();
|
|
|
|
|
ImportExcel ei = new ImportExcel(file,inputStream, 1, 0);
|
|
|
|
|
List<QuExportDTO> list = ei.getDataList(QuExportDTO.class);
|
|
|
|
|
// 导入数据条数
|
|
|
|
|
quManager.importExcel(list);
|
|
|
|
@ -201,6 +205,8 @@ public class QuController extends BaseController {
|
|
|
|
|
return success("导入成功");
|
|
|
|
|
} catch (IOException | InvalidFormatException | IllegalAccessException | InstantiationException e) {
|
|
|
|
|
logger.info(e.getMessage());
|
|
|
|
|
}finally {
|
|
|
|
|
IOUtils.closeQuietly(inputStream);
|
|
|
|
|
}
|
|
|
|
|
return error("导入失败");
|
|
|
|
|
}
|
|
|
|
|