解决商品导出excel失败的bug
This commit is contained in:
@@ -198,15 +198,13 @@ public class MaterialController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/exportExcel")
|
||||
public BaseResponseInfo exportExcel(@RequestParam("name") String name,
|
||||
public void exportExcel(@RequestParam("name") String name,
|
||||
@RequestParam("model") String model,
|
||||
@RequestParam("categoryIds") String categoryIds,
|
||||
HttpServletRequest request, HttpServletResponse response)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String message = "成功";
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
List<MaterialVo4Unit> dataList = materialService.findByAll(name, model, categoryIds);
|
||||
List<MaterialVo4Unit> dataList = materialService.findByAll(StringUtil.toNull(name), StringUtil.toNull(model),
|
||||
StringUtil.toNull(categoryIds));
|
||||
String[] names = {"品名", "类型", "型号", "安全存量", "单位", "零售价", "最低售价", "预计采购价", "批发价", "备注", "状态"};
|
||||
String title = "商品信息";
|
||||
List<String[]> objects = new ArrayList<String[]>();
|
||||
@@ -229,16 +227,9 @@ public class MaterialController {
|
||||
}
|
||||
File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects);
|
||||
ExportExecUtil.showExec(file, file.getName(), response);
|
||||
res.code = 200;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
message = "导出失败";
|
||||
res.code = 500;
|
||||
} finally {
|
||||
map.put("message", message);
|
||||
res.data = map;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -215,4 +215,16 @@ public class StringUtil {
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static String toNull(String value) {
|
||||
if(("").equals(value)) {
|
||||
value = null;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
int i = 10/3;
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user