Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
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
项目统一框架
amos-boot-biz
Commits
9b50a4da
Commit
9b50a4da
authored
Apr 28, 2022
by
wujiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加文档导出接口
parent
47d198cb
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
149 additions
and
2 deletions
+149
-2
pom.xml
...e/amos-boot-module-api/amos-boot-module-equip-api/pom.xml
+5
-0
FilePatrolReportServiceImpl.java
...equipmanage/service/impl/FilePatrolReportServiceImpl.java
+144
-2
FirePatrolReport.ftl
...-system-equip/src/main/resources/ftl/FirePatrolReport.ftl
+0
-0
No files found.
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/pom.xml
View file @
9b50a4da
...
...
@@ -12,6 +12,11 @@
<dependencies>
<dependency>
<groupId>
org.jfree
</groupId>
<artifactId>
jfreechart
</artifactId>
<version>
1.0.19
</version>
</dependency>
<dependency>
<groupId>
org.apache.tika
</groupId>
<artifactId>
tika-core
</artifactId>
<version>
1.17
</version>
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/FilePatrolReportServiceImpl.java
View file @
9b50a4da
package
com
.
yeejoin
.
equipmanage
.
service
.
impl
;
import
java.awt.Font
;
import
java.awt.image.BufferedImage
;
import
java.io.IOException
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.ArrayList
;
import
java.util.Base64
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.jfree.chart.ChartFactory
;
import
org.jfree.chart.ChartUtilities
;
import
org.jfree.chart.JFreeChart
;
import
org.jfree.chart.labels.StandardPieSectionLabelGenerator
;
import
org.jfree.chart.plot.PiePlot
;
import
org.jfree.data.general.DefaultPieDataset
;
import
org.springframework.stereotype.Service
;
import
com.yeejoin.equipmanage.common.enums.WordTemplateTypeEum
;
...
...
@@ -22,13 +36,141 @@ public class FilePatrolReportServiceImpl implements IFirePatrolReportService {
public
void
download
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
code
,
Date
startDate
,
Date
endDate
)
{
WordTemplateUtils
instance
=
WordTemplateUtils
.
getInstance
();
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
// 文档编号
String
timeStr1
=
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ofPattern
(
"yyyyMMddHHmmss"
));
String
documentNumber
=
"ZD-XFSBXC"
+
timeStr1
;
map
.
put
(
"document_number"
,
documentNumber
);
// 换流站名称
map
.
put
(
"station_name"
,
"测试"
);
// 统计时间
SimpleDateFormat
dateStat
=
new
SimpleDateFormat
(
"yyyy年MM月dd日"
);
String
statisticalTime
=
dateStat
.
format
(
startDate
)
+
"-"
+
dateStat
.
format
(
endDate
);
if
(
statisticalTime
.
contains
(
"年0"
))
{
statisticalTime
=
statisticalTime
.
replaceAll
(
"年0"
,
"年"
);
}
map
.
put
(
"statistical_time"
,
statisticalTime
);
// 生成日期
String
timeStr2
=
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy年MM月dd日"
));
if
(
timeStr2
.
contains
(
"年0"
))
{
timeStr2
=
timeStr2
.
replaceAll
(
"年0"
,
"年"
);
}
SimpleDateFormat
dateFm
=
new
SimpleDateFormat
(
"EEEE"
);
String
currSun
=
dateFm
.
format
(
new
Date
());
map
.
put
(
"create_date"
,
timeStr2
+
currSun
);
// 统计时间2
map
.
put
(
"statistical_time2"
,
statisticalTime
.
replaceAll
(
"-"
,
"至"
));
// 巡查任务数
map
.
put
(
"task_count"
,
"10"
);
// 完成任务数
map
.
put
(
"complete_task_count"
,
"5"
);
// 未完成任务数
map
.
put
(
"uncomplete_task_count"
,
"2"
);
// 任务完成率
map
.
put
(
"complete_task_percent"
,
"40%"
);
// 巡查人员数
map
.
put
(
"person_count"
,
"5"
);
// 持证人员数
map
.
put
(
"certified_person_count"
,
"3"
);
// 持证率
map
.
put
(
"certified_percent"
,
"60%"
);
// 应巡查设备总数
map
.
put
(
"equipment_count"
,
"12"
);
int
checked_equipment_count
=
7
;
// 实际巡查设备总数
map
.
put
(
"checked_equipment_count"
,
checked_equipment_count
);
int
unchecked_equipment_count
=
5
;
// 漏查设备总数
map
.
put
(
"unchecked_equipment_count"
,
unchecked_equipment_count
);
// 发现问题总数
map
.
put
(
"problem_count"
,
"5"
);
// 发现问题总数
map
.
put
(
"fixed_problem_count"
,
"3"
);
// 发现问题总数
map
.
put
(
"unfixed_problem_count"
,
"2"
);
// 巡查点位数
map
.
put
(
"checked_location_count"
,
"2"
);
// 缺陷总数
map
.
put
(
"defect_count"
,
"2"
);
// 合格数
int
qualified
=
3
;
// 未合格数
int
no_qualified
=
3
;
// 合格饼图
DefaultPieDataset
pds
=
new
DefaultPieDataset
();
pds
.
setValue
(
"合格"
,
qualified
);
pds
.
setValue
(
"不合格"
,
no_qualified
);
String
qualified_pie_chart
=
getChartString
(
pds
);
map
.
put
(
"qualified_pie_chart"
,
qualified_pie_chart
);
// 设备巡查饼图
DefaultPieDataset
pds2
=
new
DefaultPieDataset
();
pds
.
setValue
(
"已查询设备"
,
checked_equipment_count
);
pds
.
setValue
(
"漏查设备"
,
unchecked_equipment_count
);
String
equip_pie_chart
=
getChartString
(
pds2
);
map
.
put
(
"equip_pie_chart"
,
equip_pie_chart
);
// 业务主题
map
.
put
(
"business_title"
,
"消防巡查"
);
// 缺陷清单
List
<
Map
<
String
,
Object
>>
defect_list
=
new
ArrayList
<>();
Map
<
String
,
Object
>
defectMap
=
new
HashMap
<>();
defectMap
.
put
(
"defect_location"
,
"主控楼一层"
);
defectMap
.
put
(
"defect_description"
,
"仅有一条疏散通道,存在重大火灾隐患,不满足规范要求。"
);
defectMap
.
put
(
"rectified_progress"
,
"待评审"
);
defectMap
.
put
(
"remark"
,
"无法整改"
);
defect_list
.
add
(
defectMap
);
Map
<
String
,
Object
>
defectMap2
=
new
HashMap
<>();
defectMap2
.
put
(
"defect_location"
,
"主控楼一层"
);
defectMap2
.
put
(
"defect_description"
,
"防火卷帘门故障;11个水泵接合器存在问题;"
);
defectMap2
.
put
(
"rectified_progress"
,
"待治理"
);
defectMap2
.
put
(
"remark"
,
"防火卷帘已完成维修,水泵接合器未整改"
);
defect_list
.
add
(
defectMap2
);
Map
<
String
,
Object
>
defectMap3
=
new
HashMap
<>();
defectMap3
.
put
(
"defect_location"
,
"主控楼一层库房区域"
);
defectMap3
.
put
(
"defect_description"
,
"将办公用房作为库房使用,使用性质与原设计不符,耐火等级和相应消防设施不满足规范要求。"
);
defectMap3
.
put
(
"rectified_progress"
,
"治理完毕"
);
defectMap3
.
put
(
"remark"
,
""
);
defect_list
.
add
(
defectMap3
);
map
.
put
(
"defect_list"
,
defect_list
);
try
{
instance
.
exportMillCertificateWord
(
request
,
response
,
map
,
null
,
instance
.
exportMillCertificateWord
(
request
,
response
,
map
,
documentNumber
,
WordTemplateTypeEum
.
firePatrolReport
.
getTemplateFile
());
}
catch
(
IOException
e
)
{
throw
new
CommonException
(
0
,
"下载装备巡查报表失败"
);
}
}
/**
* 获取饼图base64字符串
* @param pds
* @return
*/
private
String
getChartString
(
DefaultPieDataset
pds
)
{
JFreeChart
chart
=
ChartFactory
.
createPieChart
(
"测试"
,
pds
,
false
,
false
,
true
);
// 如果不使用Font,中文将显示不出来
Font
font
=
new
Font
(
"宋体"
,
Font
.
BOLD
,
12
);
// 设置图片标题的字体
chart
.
getTitle
().
setFont
(
font
);
// 得到图块,准备设置标签的字体
PiePlot
plot
=
(
PiePlot
)
chart
.
getPlot
();
// 设置标签字体
plot
.
setLabelFont
(
font
);
plot
.
setStartAngle
(
new
Float
(
3.14f
/
2
f
));
//plot.setSectionPaint((Comparable) Color.BLUE,Color.RED); // 考虑自定义设置颜色——我不会
// 设置plot的前景色透明度
plot
.
setForegroundAlpha
(
0.7f
);
// 设置plot的背景色透明度
plot
.
setBackgroundAlpha
(
0.0f
);
// 设置标签生成器(默认{0})
// {0}:key {1}:value {2}:百分比 {3}:sum
plot
.
setLabelGenerator
(
new
StandardPieSectionLabelGenerator
(
"{0}\n{2}"
));
BufferedImage
image
=
chart
.
createBufferedImage
(
800
,
600
);
byte
[]
bytes
=
null
;
try
{
bytes
=
ChartUtilities
.
encodeAsPNG
(
image
);
}
catch
(
IOException
e1
)
{
throw
new
CommonException
(
0
,
"生成饼图失败"
);
}
String
base64
=
Base64
.
getEncoder
().
encodeToString
(
bytes
);
return
base64
;
}
}
amos-boot-system-equip/src/main/resources/ftl/FirePatrolReport.ftl
View file @
9b50a4da
This diff is collapsed.
Click to expand it.
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