Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
5e1a899f
Commit
5e1a899f
authored
Jul 30, 2019
by
季圣华
Browse files
解决商品导出excel失败的bug
parent
0e46a9f2
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/jsh/erp/controller/MaterialController.java
View file @
5e1a899f
...
...
@@ -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
;
}
/**
...
...
src/main/java/com/jsh/erp/utils/StringUtil.java
View file @
5e1a899f
...
...
@@ -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
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment