Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zhny
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王夏晖
zhny
Commits
372a228a
Commit
372a228a
authored
Jun 05, 2018
by
王夏晖
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/develop' into develop
parents
f398625d
d2be8d64
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
19 deletions
+70
-19
BusDeviceController.java
...usiness/device/assets/controller/BusDeviceController.java
+5
-2
BusDeviceService.java
...soft/business/device/assets/service/BusDeviceService.java
+1
-1
BusDeviceServiceImpl.java
...ness/device/assets/service/impl/BusDeviceServiceImpl.java
+64
-16
No files found.
src/main/java/org/rcisoft/business/device/assets/controller/BusDeviceController.java
View file @
372a228a
...
@@ -176,9 +176,12 @@ public class BusDeviceController extends PaginationController<BusDevice> {
...
@@ -176,9 +176,12 @@ public class BusDeviceController extends PaginationController<BusDevice> {
}
}
@ApiOperation
(
value
=
"参数库导出"
,
notes
=
"参数库导出功能,需要将页面上的名称、编号以json对象数组的形式传到后台"
)
@ApiOperation
(
value
=
"参数库导出"
,
notes
=
"参数库导出功能,需要将页面上的名称、编号以json对象数组的形式传到后台"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"devNums"
,
value
=
"devNums"
,
required
=
true
,
dataType
=
"逗号分隔的devNum字符串,如:111,222,333"
)
})
@RequestMapping
(
"/downloadExcel"
)
@RequestMapping
(
"/downloadExcel"
)
public
void
downloadExcel
(
HttpServletResponse
response
,
@Request
Body
List
<
DeviceParamsVo
>
list
)
{
public
void
downloadExcel
(
HttpServletResponse
response
,
@Request
Param
String
devNums
)
{
busDeviceServiceImpl
.
downloadExcel
(
response
,
list
);
busDeviceServiceImpl
.
downloadExcel
(
response
,
devNums
);
}
}
@ApiOperation
(
value
=
"生成设备二维码"
,
notes
=
"生成设备二维码"
)
@ApiOperation
(
value
=
"生成设备二维码"
,
notes
=
"生成设备二维码"
)
...
...
src/main/java/org/rcisoft/business/device/assets/service/BusDeviceService.java
View file @
372a228a
...
@@ -89,7 +89,7 @@ public interface BusDeviceService {
...
@@ -89,7 +89,7 @@ public interface BusDeviceService {
* 参数库导出
* 参数库导出
* @param response
* @param response
*/
*/
void
downloadExcel
(
HttpServletResponse
response
,
List
<
DeviceParamsVo
>
list
);
void
downloadExcel
(
HttpServletResponse
response
,
String
devNums
);
/**
/**
* 生成设备二维码
* 生成设备二维码
...
...
src/main/java/org/rcisoft/business/device/assets/service/impl/BusDeviceServiceImpl.java
View file @
372a228a
...
@@ -9,6 +9,8 @@ import org.rcisoft.business.device.assets.dao.BusDeviceRepository;
...
@@ -9,6 +9,8 @@ import org.rcisoft.business.device.assets.dao.BusDeviceRepository;
import
org.rcisoft.business.device.assets.service.BusDeviceService
;
import
org.rcisoft.business.device.assets.service.BusDeviceService
;
import
org.rcisoft.business.device.assets.vo.DeviceAssetStatisticVo
;
import
org.rcisoft.business.device.assets.vo.DeviceAssetStatisticVo
;
import
org.rcisoft.business.device.assets.vo.DeviceParamsVo
;
import
org.rcisoft.business.device.assets.vo.DeviceParamsVo
;
import
org.rcisoft.business.mainte.paramlibrary.dao.ParamLibraryRepository
;
import
org.rcisoft.business.mainte.paramlibrary.entity.BusParamLibrary
;
import
org.rcisoft.business.manage.dao.BusLibraryParamRepository
;
import
org.rcisoft.business.manage.dao.BusLibraryParamRepository
;
import
org.rcisoft.business.manage.entity.BusDevicetpParam
;
import
org.rcisoft.business.manage.entity.BusDevicetpParam
;
import
org.rcisoft.business.manage.entity.BusLibraryParam
;
import
org.rcisoft.business.manage.entity.BusLibraryParam
;
...
@@ -59,6 +61,8 @@ public class BusDeviceServiceImpl implements BusDeviceService {
...
@@ -59,6 +61,8 @@ public class BusDeviceServiceImpl implements BusDeviceService {
private
BusLibraryParamRepository
busLibraryParamRepository
;
private
BusLibraryParamRepository
busLibraryParamRepository
;
@Autowired
@Autowired
private
BusDevicetpParamService
busDevicetpParamService
;
private
BusDevicetpParamService
busDevicetpParamService
;
@Autowired
private
ParamLibraryRepository
paramLibraryRepository
;
/**
/**
* 二维码存放路径
* 二维码存放路径
...
@@ -249,10 +253,10 @@ public class BusDeviceServiceImpl implements BusDeviceService {
...
@@ -249,10 +253,10 @@ public class BusDeviceServiceImpl implements BusDeviceService {
}
}
@Override
@Override
public
void
downloadExcel
(
HttpServletResponse
response
,
List
<
DeviceParamsVo
>
list
)
{
public
void
downloadExcel
(
HttpServletResponse
response
,
String
devNums
)
{
try
(
OutputStream
outputStream
=
response
.
getOutputStream
())
{
try
(
OutputStream
outputStream
=
response
.
getOutputStream
())
{
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename=download.xls"
);
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename=download.xls"
);
outputStream
.
write
(
this
.
createExcel
(
list
));
outputStream
.
write
(
this
.
createExcel
(
devNums
));
outputStream
.
flush
();
outputStream
.
flush
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -289,23 +293,67 @@ public class BusDeviceServiceImpl implements BusDeviceService {
...
@@ -289,23 +293,67 @@ public class BusDeviceServiceImpl implements BusDeviceService {
return
new
PersistModel
(
line
,
message
);
return
new
PersistModel
(
line
,
message
);
}
}
private
byte
[]
createExcel
(
List
<
DeviceParamsVo
>
list
)
throws
IOException
{
private
byte
[]
createExcel
(
String
devNums
)
throws
IOException
{
int
year
=
Calendar
.
getInstance
().
get
(
Calendar
.
YEAR
);
HSSFWorkbook
workbook
=
null
;
HSSFWorkbook
workbook
=
null
;
try
(
ByteArrayOutputStream
os
=
new
ByteArrayOutputStream
())
{
try
(
ByteArrayOutputStream
os
=
new
ByteArrayOutputStream
())
{
workbook
=
new
HSSFWorkbook
();
workbook
=
new
HSSFWorkbook
();
HSSFSheet
sheet
=
workbook
.
createSheet
(
"sheet1"
);
// 拆分devNums
//表头
String
[]
numArray
=
devNums
.
split
(
","
);
String
[]
title
=
new
String
[]{
"名称"
,
"编号"
};
for
(
String
devNum
:
numArray
)
{
HSSFRow
title_row
=
sheet
.
createRow
(
0
);
int
rowNum
=
0
;
for
(
int
i
=
0
;
i
<
title
.
length
;
i
++)
{
//定义sheet
title_row
.
createCell
(
i
,
CellType
.
STRING
).
setCellValue
(
title
[
i
]);
HSSFSheet
sheet
=
workbook
.
createSheet
(
devNum
);
//第一行:设备编号 + 年份
HSSFRow
row_1
=
sheet
.
createRow
(
rowNum
++);
row_1
.
createCell
(
0
,
CellType
.
STRING
).
setCellValue
(
"设备编号"
);
row_1
.
createCell
(
1
,
CellType
.
STRING
).
setCellValue
(
devNum
);
row_1
.
createCell
(
3
,
CellType
.
STRING
).
setCellValue
(
"年份"
);
row_1
.
createCell
(
4
,
CellType
.
STRING
).
setCellValue
(
Calendar
.
getInstance
().
get
(
Calendar
.
YEAR
));
//空一行
rowNum
++;
// 第三行:参数、参数名称、参数编码
String
[]
title_3
=
new
String
[]{
"参数"
,
"名称"
,
"编码"
};
HSSFRow
row_3
=
sheet
.
createRow
(
rowNum
++);
for
(
int
i
=
0
;
i
<
title_3
.
length
;
i
++)
{
row_3
.
createCell
(
i
,
CellType
.
STRING
).
setCellValue
(
title_3
[
i
]);
}
//循环参数列表
List
<
Map
<
String
,
String
>>
paramsList
=
busLibraryParamRepository
.
selectParamsByDevNum
(
devNum
);
int
size
=
paramsList
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
Map
<
String
,
String
>
param
=
paramsList
.
get
(
i
);
HSSFRow
row
=
sheet
.
createRow
(
rowNum
++);
row
.
createCell
(
0
,
CellType
.
STRING
).
setCellValue
(
i
+
1
);
//编号
row
.
createCell
(
1
,
CellType
.
STRING
).
setCellValue
(
param
.
get
(
"paramNm"
));
//参数名称
row
.
createCell
(
2
,
CellType
.
STRING
).
setCellValue
(
param
.
get
(
"param"
));
//参数编码
}
//空一行
rowNum
=
rowNum
+
1
+
3
-
size
;
//添加参数值表头列
HSSFRow
row_next
=
sheet
.
createRow
(
rowNum
);
row_next
.
createCell
(
0
,
CellType
.
STRING
).
setCellValue
(
"参数值列表"
);
row_next
.
createCell
(
1
,
CellType
.
STRING
).
setCellValue
(
"功率(kw)"
);
row_next
.
createCell
(
2
,
CellType
.
STRING
).
setCellValue
(
"用气速率(m3/h)"
);
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
row_next
.
createCell
(
3
+
i
,
CellType
.
STRING
).
setCellValue
(
"参数"
+
(
i
+
1
)
+
"值"
);
}
//查询参数库列表
Example
example
=
new
Example
(
BusParamLibrary
.
class
);
Example
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andEqualTo
(
"devNum"
,
devNum
);
criteria
.
andEqualTo
(
"year"
,
year
);
List
<
BusParamLibrary
>
list
=
paramLibraryRepository
.
selectByExample
(
example
);
//循环放入当前sheet
rowNum
++;
for
(
BusParamLibrary
busParamLibrary
:
list
)
{
HSSFRow
row
=
sheet
.
createRow
(
rowNum
++);
row
.
createCell
(
1
,
CellType
.
STRING
).
setCellValue
(
busParamLibrary
.
getPower
()
==
null
?
""
:
busParamLibrary
.
getPower
().
toString
());
row
.
createCell
(
2
,
CellType
.
STRING
).
setCellValue
(
busParamLibrary
.
getGasSpeed
()
==
null
?
""
:
busParamLibrary
.
getGasSpeed
().
toString
());
row
.
createCell
(
3
,
CellType
.
STRING
).
setCellValue
(
busParamLibrary
.
getP1V
()
==
null
?
""
:
busParamLibrary
.
getP1V
().
toString
());
row
.
createCell
(
4
,
CellType
.
STRING
).
setCellValue
(
busParamLibrary
.
getP2V
()
==
null
?
""
:
busParamLibrary
.
getP2V
().
toString
());
row
.
createCell
(
5
,
CellType
.
STRING
).
setCellValue
(
busParamLibrary
.
getP3V
()
==
null
?
""
:
busParamLibrary
.
getP3V
().
toString
());
}
}
//内容
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
HSSFRow
row
=
sheet
.
createRow
(
i
+
1
);
DeviceParamsVo
deviceParamsVo
=
list
.
get
(
i
);
row
.
createCell
(
0
,
CellType
.
STRING
).
setCellValue
(
deviceParamsVo
.
getName
());
row
.
createCell
(
1
,
CellType
.
STRING
).
setCellValue
(
deviceParamsVo
.
getNum
());
}
}
workbook
.
write
(
os
);
workbook
.
write
(
os
);
return
os
.
toByteArray
();
return
os
.
toByteArray
();
...
...
Write
Preview
Markdown
is supported
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