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
a1c09428
Commit
a1c09428
authored
Jul 14, 2021
by
xixinzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
交接班pdf下載
parent
f4288ce4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
182 additions
and
18 deletions
+182
-18
PdfUtils.java
...java/com/yeejoin/amos/boot/biz/common/utils/PdfUtils.java
+37
-2
ShiftChangeDutyDto.java
...join/amos/boot/module/jcs/api/dto/ShiftChangeDutyDto.java
+35
-0
ShiftChangePowerDto.java
...oin/amos/boot/module/jcs/api/dto/ShiftChangePowerDto.java
+34
-0
ShiftChangeServiceImpl.java
...t/module/jcs/biz/service/impl/ShiftChangeServiceImpl.java
+76
-16
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/utils/PdfUtils.java
View file @
a1c09428
...
...
@@ -37,18 +37,53 @@ public class PdfUtils {
* @param size 高度
* @return
*/
public
static
PdfPCell
createCell
(
String
value
,
Font
font
,
int
align
,
int
colspan
,
int
row
,
int
size
){
public
static
PdfPCell
createCell
(
Object
value
,
Font
font
,
int
align
,
int
colspan
,
int
row
,
int
size
){
String
cellValue
;
if
(
value
==
null
)
{
cellValue
=
""
;
}
else
{
cellValue
=
value
.
toString
();
}
PdfPCell
cell
=
new
PdfPCell
();
cell
.
setVerticalAlignment
(
Element
.
ALIGN_MIDDLE
);
cell
.
setHorizontalAlignment
(
align
);
cell
.
setColspan
(
colspan
);
cell
.
setPhrase
(
new
Phrase
(
v
alue
,
font
));
cell
.
setPhrase
(
new
Phrase
(
cellV
alue
,
font
));
cell
.
setFixedHeight
(
size
);
if
(
row
!=
1
)
{
cell
.
setRowspan
(
row
);
}
return
cell
;
}
public
static
PdfPCell
createCell
(
Object
value
,
Font
font
,
int
align
,
int
colspan
,
int
row
,
int
size
,
boolean
flag
){
String
cellValue
;
if
(
value
==
null
)
{
cellValue
=
""
;
}
else
{
cellValue
=
value
.
toString
();
}
PdfPCell
cell
=
new
PdfPCell
();
cell
.
setVerticalAlignment
(
Element
.
ALIGN_MIDDLE
);
cell
.
setHorizontalAlignment
(
align
);
cell
.
setColspan
(
colspan
);
cell
.
setPhrase
(
new
Phrase
(
cellValue
,
font
));
cell
.
setFixedHeight
(
size
);
if
(
row
!=
1
)
{
cell
.
setRowspan
(
row
);
}
if
(
flag
)
{
cell
.
setBorderWidthLeft
(
0
);
cell
.
setBorderWidthTop
(
0
);
cell
.
setBorderWidthBottom
(
0
);
}
else
{
cell
.
setBorderWidthLeft
(
0
);
cell
.
setBorderWidthRight
(
0
);
cell
.
setBorderWidthTop
(
0
);
cell
.
setBorderWidthBottom
(
0
);
}
return
cell
;
}
public
static
PdfPCell
createCell
(
Image
image
,
int
align
,
int
colspan
){
PdfPCell
cell
=
new
PdfPCell
();
cell
.
setVerticalAlignment
(
Element
.
ALIGN_MIDDLE
);
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-jcs-api/src/main/java/com/yeejoin/amos/boot/module/jcs/api/dto/ShiftChangeDutyDto.java
0 → 100644
View file @
a1c09428
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jcs
.
api
.
dto
;
import
com.yeejoin.amos.boot.biz.common.dto.BaseDto
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
java.util.List
;
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
"接警情况详情"
)
public
class
ShiftChangeDutyDto
extends
BaseDto
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"重大警情"
)
private
String
majorAlertCount
=
"0"
;
@ApiModelProperty
(
value
=
"已结案"
)
private
String
finishedCount
=
"0"
;
@ApiModelProperty
(
value
=
"接警"
)
private
String
calledCount
=
"0"
;
@ApiModelProperty
(
value
=
"未结案"
)
private
String
unFinishedCount
=
"0"
;
@ApiModelProperty
(
value
=
"接警情况列表"
)
private
List
<
String
>
alertInfoList
;
@ApiModelProperty
(
value
=
"备注"
)
private
String
alarmRemark
;
}
amos-boot-module/amos-boot-module-api/amos-boot-module-jcs-api/src/main/java/com/yeejoin/amos/boot/module/jcs/api/dto/ShiftChangePowerDto.java
0 → 100644
View file @
a1c09428
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jcs
.
api
.
dto
;
import
com.yeejoin.amos.boot.biz.common.dto.BaseDto
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
java.util.List
;
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
"力量出动详情"
)
public
class
ShiftChangePowerDto
extends
BaseDto
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"未归队车辆数"
)
private
String
no_return_car_count
=
"0"
;
@ApiModelProperty
(
value
=
"调派任务数"
)
private
String
transfer_count
=
"0"
;
@ApiModelProperty
(
value
=
"调派车辆数"
)
private
String
car_count
=
"0"
;
@ApiModelProperty
(
value
=
"已完成任务数"
)
private
String
end_count
=
"0"
;
@ApiModelProperty
(
value
=
"力量出动详情"
)
private
List
<
String
>
transferContent
;
@ApiModelProperty
(
value
=
"备注"
)
private
String
powerRemark
;
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-jcs-biz/src/main/java/com/yeejoin/amos/boot/module/jcs/biz/service/impl/ShiftChangeServiceImpl.java
View file @
a1c09428
...
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.Sequence
;
import
com.google.common.base.Joiner
;
import
com.itextpdf.text.*
;
import
com.itextpdf.text.pdf.BaseFont
;
import
com.itextpdf.text.pdf.PdfPTable
;
...
...
@@ -11,19 +12,26 @@ import com.yeejoin.amos.boot.biz.common.utils.PdfUtils;
import
com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance
;
import
com.yeejoin.amos.boot.module.common.biz.service.impl.DynamicFormInstanceServiceImpl
;
import
com.yeejoin.amos.boot.module.jcs.api.dto.ShiftChangeDto
;
import
com.yeejoin.amos.boot.module.jcs.api.dto.ShiftChangeDutyDto
;
import
com.yeejoin.amos.boot.module.jcs.api.dto.ShiftChangeInfoDto
;
import
com.yeejoin.amos.boot.module.jcs.api.dto.ShiftChangePowerDto
;
import
com.yeejoin.amos.boot.module.jcs.api.entity.ShiftChange
;
import
com.yeejoin.amos.boot.module.jcs.api.mapper.ShiftChangeMapper
;
import
com.yeejoin.amos.boot.module.jcs.api.service.IShiftChangeService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.core.foundation.utils.Bean
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
springfox.documentation.spring.web.json.Json
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.text.SimpleDateFormat
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -121,20 +129,29 @@ public class ShiftChangeServiceImpl extends BaseService<ShiftChangeDto, ShiftCha
@Override
public
void
exportPdfById
(
HttpServletResponse
response
,
Long
shiftChangeId
)
throws
IOException
,
DocumentException
{
// 告诉浏览器用什么软件可以打开此文件
response
.
setHeader
(
"content-Type"
,
"application/pdf"
);
response
.
setContentType
(
"application/pdf;charset=UTF-8"
);
response
.
setHeader
(
"content-Type"
,
"application/pdf;charset=UTF-8"
);
// 下载文件的默认名称
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename=交接班记录表.pdf"
);
String
fileName
=
"交接班记录表.pdf"
;
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename="
+
URLEncoder
.
encode
(
fileName
,
StandardCharsets
.
UTF_8
.
name
()));
// 创建document对象
Document
document
=
PdfUtils
.
createFile
(
response
);
// 获取pdf文件数据
ShiftChangeDto
shiftChange
=
this
.
queryBySeq
(
shiftChangeId
);
ShiftChangeInfoDto
ShiftChangeInfoDto
=
new
ShiftChangeInfoDto
();
if
(
shiftChange
!=
null
)
{
Map
<
String
,
Object
>
baseInfo
=
dynamicFormInstanceService
.
getOneMap
(
shiftChange
.
getInstanceId
(),
GROUP_CODE
);
ShiftChangeInfoDto
ShiftChangeInfoDto
=
(
ShiftChangeInfoDto
)
Bean
.
mapToBean
(
baseInfo
,
ShiftChangeInfoDto
.
class
);
ShiftChangeInfoDto
=
(
ShiftChangeInfoDto
)
Bean
.
mapToBean
(
baseInfo
,
ShiftChangeInfoDto
.
class
);
}
else
{
shiftChange
=
new
ShiftChangeDto
();
}
// 创建pdf格式
createPDFReport
(
document
,
ShiftChangeInfoDto
,
shiftChange
);
}
/**
* 创建pdf文件样式数据
*/
public
void
createPDFReport
(
Document
document
,
ShiftChangeInfoDto
shiftChangeInfoDto
,
ShiftChangeDto
shiftChange
)
throws
IOException
,
DocumentException
{
document
.
open
();
// 基本样式参数
...
...
@@ -142,25 +159,31 @@ public class ShiftChangeServiceImpl extends BaseService<ShiftChangeDto, ShiftCha
Font
cellContent
=
new
Font
(
bfChinese
,
11
,
Font
.
NORMAL
);
Font
cellTitle
=
new
Font
(
bfChinese
,
11
,
Font
.
BOLD
);
Font
title
=
new
Font
(
bfChinese
,
20
,
Font
.
BOLD
);
int
size
=
35
;
int
size
=
30
;
int
smallSize
=
0
;
// 表头
Paragraph
docTitle
=
new
Paragraph
(
"119接警坐席交接班记录\n"
,
title
);
docTitle
.
setAlignment
(
Element
.
ALIGN_CENTER
);
// docTitle.setSpacingBefore(20);
// 表格内容
PdfPTable
table1
=
PdfUtils
.
createTable
(
8
);
int
[]
widths
=
{
12
,
25
,
25
,
25
,
25
,
20
,
25
,
25
};
table1
.
setWidthPercentage
(
100
);
table1
.
setSpacingBefore
(
10
);
table1
.
setWidths
(
widths
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
recDare
=
shiftChange
.
getRecDate
()
!=
null
?
sdf
.
format
(
shiftChange
.
getRecDate
())
:
""
;
// 第一行
table1
.
addCell
(
PdfUtils
.
createCell
(
"时间
:
"
,
cellTitle
,
Element
.
ALIGN_CENTER
,
1
,
1
,
size
));
table1
.
addCell
(
PdfUtils
.
createCell
(
shiftChange
.
getRecDate
().
toString
()
,
cellContent
,
Element
.
ALIGN_CENTER
,
3
,
1
,
size
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"值班领导
:
"
,
cellTitle
,
Element
.
ALIGN_CENTER
,
1
,
1
,
size
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"时间"
,
cellTitle
,
Element
.
ALIGN_CENTER
,
1
,
1
,
size
));
table1
.
addCell
(
PdfUtils
.
createCell
(
recDare
,
cellContent
,
Element
.
ALIGN_CENTER
,
3
,
1
,
size
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"值班领导"
,
cellTitle
,
Element
.
ALIGN_CENTER
,
1
,
1
,
size
));
table1
.
addCell
(
PdfUtils
.
createCell
(
shiftChangeInfoDto
.
getJsDutyLeader
(),
cellContent
,
Element
.
ALIGN_CENTER
,
3
,
1
,
size
));
// 第二行
table1
.
addCell
(
PdfUtils
.
createCell
(
"值
班
员"
,
cellTitle
,
Element
.
ALIGN_CENTER
,
1
,
3
,
size
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"值
\n班\n
员"
,
cellTitle
,
Element
.
ALIGN_CENTER
,
1
,
3
,
size
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"正班"
,
cellTitle
,
Element
.
ALIGN_CENTER
,
1
,
1
,
size
));
table1
.
addCell
(
PdfUtils
.
createCell
(
shiftChangeInfoDto
.
getDutyPersonOne
(),
cellContent
,
Element
.
ALIGN_CENTER
,
1
,
1
,
size
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"值班开始时间"
,
cellContent
,
Element
.
ALIGN_CENTER
,
1
,
1
,
size
));
...
...
@@ -183,15 +206,52 @@ public class ShiftChangeServiceImpl extends BaseService<ShiftChangeDto, ShiftCha
table1
.
addCell
(
PdfUtils
.
createCell
(
"经理"
,
cellTitle
,
Element
.
ALIGN_CENTER
,
1
,
1
,
size
));
table1
.
addCell
(
PdfUtils
.
createCell
(
shiftChangeInfoDto
.
getSucceedPersonLeader
(),
cellContent
,
Element
.
ALIGN_CENTER
,
1
,
1
,
size
));
JSONObject
dutyJson
=
shiftChange
.
getDutyJson
();
JSONObject
powerJson
=
shiftChange
.
getPowerJson
();
ShiftChangeDutyDto
dutyDto
=
new
ShiftChangeDutyDto
();
ShiftChangePowerDto
powerDto
=
new
ShiftChangePowerDto
();
if
(
dutyJson
!=
null
)
{
dutyDto
=
JSONObject
.
toJavaObject
(
dutyJson
,
ShiftChangeDutyDto
.
class
);
}
if
(
powerJson
!=
null
)
{
powerDto
=
JSONObject
.
toJavaObject
(
powerJson
,
ShiftChangePowerDto
.
class
);
}
List
<
String
>
infoList
=
dutyDto
.
getAlertInfoList
();
List
<
String
>
powerList
=
powerDto
.
getTransferContent
();
int
infoSize
=
infoList
!=
null
?
infoList
.
size
()
:
0
;
int
powerSize
=
powerList
!=
null
?
powerList
.
size
()
:
0
;
String
alarmRemark
=
dutyDto
.
getAlarmRemark
()
==
null
?
"无"
:
dutyDto
.
getAlarmRemark
();
String
powerRemark
=
powerDto
.
getPowerRemark
()
==
null
?
"无"
:
powerDto
.
getPowerRemark
();
// 值班情况
table1
.
addCell
(
PdfUtils
.
createCell
(
"值班情况"
,
cellTitle
,
Element
.
ALIGN_LEFT
,
1
,
4
,
size
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"接警情况:"
,
cellContent
,
Element
.
ALIGN_LEFT
,
7
,
1
,
size
));
table1
.
addCell
(
PdfUtils
.
createCell
(
shiftChange
.
getDutyJson
().
toString
(),
cellContent
,
Element
.
ALIGN_LEFT
,
7
,
1
,
120
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"力量出动:"
,
cellContent
,
Element
.
ALIGN_LEFT
,
7
,
1
,
size
));
table1
.
addCell
(
PdfUtils
.
createCell
(
shiftChange
.
getPowerJson
().
toString
(),
cellContent
,
Element
.
ALIGN_LEFT
,
7
,
1
,
120
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"值\n班\n情\n况"
,
cellTitle
,
Element
.
ALIGN_CENTER
,
1
,
6
+
powerSize
+
infoSize
,
size
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"接警情况:"
,
cellContent
,
Element
.
ALIGN_LEFT
,
7
,
1
,
size
,
true
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"接警"
+
dutyDto
.
getCalledCount
()
+
"起"
,
cellContent
,
Element
.
ALIGN_CENTER
,
1
,
1
,
smallSize
,
false
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"未结案"
+
dutyDto
.
getUnFinishedCount
()
+
"起"
,
cellContent
,
Element
.
ALIGN_CENTER
,
2
,
1
,
smallSize
,
false
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"已结案"
+
dutyDto
.
getFinishedCount
()
+
"起"
,
cellContent
,
Element
.
ALIGN_CENTER
,
2
,
1
,
smallSize
,
false
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"重大警情"
+
dutyDto
.
getMajorAlertCount
()
+
"起"
,
cellContent
,
Element
.
ALIGN_CENTER
,
2
,
1
,
smallSize
,
true
));
if
(!
ObjectUtils
.
isEmpty
(
infoList
))
{
for
(
String
info
:
infoList
)
{
table1
.
addCell
(
PdfUtils
.
createCell
(
info
,
cellContent
,
Element
.
ALIGN_LEFT
,
7
,
1
,
smallSize
,
true
));
}
}
table1
.
addCell
(
PdfUtils
.
createCell
(
"备注:"
+
alarmRemark
,
cellContent
,
Element
.
ALIGN_LEFT
,
7
,
1
,
smallSize
,
true
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"力量出动:"
,
cellContent
,
Element
.
ALIGN_LEFT
,
7
,
1
,
size
,
true
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"调派任务"
+
powerDto
.
getTransfer_count
()
+
"起"
,
cellContent
,
Element
.
ALIGN_CENTER
,
1
,
1
,
smallSize
,
false
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"调派车辆"
+
powerDto
.
getCar_count
()
+
"起"
,
cellContent
,
Element
.
ALIGN_CENTER
,
2
,
1
,
smallSize
,
false
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"已完成任务"
+
powerDto
.
getEnd_count
()
+
"起"
,
cellContent
,
Element
.
ALIGN_CENTER
,
2
,
1
,
smallSize
,
false
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"未归队车辆"
+
powerDto
.
getNo_return_car_count
()
+
"起"
,
cellContent
,
Element
.
ALIGN_CENTER
,
2
,
1
,
smallSize
,
true
));
if
(!
ObjectUtils
.
isEmpty
(
powerList
))
{
for
(
String
powerInfo
:
powerList
)
{
table1
.
addCell
(
PdfUtils
.
createCell
(
powerInfo
,
cellContent
,
Element
.
ALIGN_LEFT
,
7
,
1
,
smallSize
,
true
));
}
}
table1
.
addCell
(
PdfUtils
.
createCell
(
"备注:"
+
powerRemark
,
cellContent
,
Element
.
ALIGN_LEFT
,
7
,
1
,
smallSize
,
true
));
// 移交事宜
table1
.
addCell
(
PdfUtils
.
createCell
(
"移
交事宜"
,
cellTitle
,
Element
.
ALIGN_LEFT
,
1
,
1
,
size
));
table1
.
addCell
(
PdfUtils
.
createCell
(
"移
\n交\n事\n宜"
,
cellTitle
,
Element
.
ALIGN_CENTER
,
1
,
1
,
size
));
table1
.
addCell
(
PdfUtils
.
createCell
(
shiftChange
.
getRemark
(),
cellContent
,
Element
.
ALIGN_LEFT
,
7
,
1
,
120
));
try
{
...
...
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