Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
qianhe-ydsj
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jiangyun
qianhe-ydsj
Commits
5777aeb4
Commit
5777aeb4
authored
Mar 26, 2026
by
MMF
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MMF 2026-03-26 评分填报导出修改
parent
4f094081
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
35 deletions
+63
-35
qianhe-common/src/main/java/com/qianhe/common/utils/MtTimeUtil.java
+9
-3
qianhe-ydsj/src/main/java/com/qianhe/zqcz/pftb/service/impl/ZqczPftbServiceImpl.java
+54
-32
No files found.
qianhe-common/src/main/java/com/qianhe/common/utils/MtTimeUtil.java
View file @
5777aeb4
...
...
@@ -5,13 +5,19 @@ import java.time.format.DateTimeFormatter;
public
class
MtTimeUtil
{
private
static
final
DateTimeFormatter
DATA_TIME_FORMATTER
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
private
static
final
DateTimeFormatter
DATA_TIME_FORMATTER_NYR
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
);
/**
* LocalDateTime -> String
* @param localDateTime
* @return
* LocalDateTime -> String yyyy-MM-dd HH:mm:ss
*/
public
static
String
dateTimeFormat
(
LocalDateTime
localDateTime
){
return
DATA_TIME_FORMATTER
.
format
(
localDateTime
);
}
/**
* LocalDateTime -> String yyyy-MM-dd
*/
public
static
String
dateTimeFormatNyr
(
LocalDateTime
localDateTime
){
return
DATA_TIME_FORMATTER_NYR
.
format
(
localDateTime
);
}
}
qianhe-ydsj/src/main/java/com/qianhe/zqcz/pftb/service/impl/ZqczPftbServiceImpl.java
View file @
5777aeb4
...
...
@@ -5,7 +5,6 @@ import com.qianhe.common.exception.BusinessException;
import
com.qianhe.common.utils.MtTimeUtil
;
import
com.qianhe.zqcz.jcdw.mapper.ZqczJcdwMapper
;
import
com.qianhe.zqcz.jcrw.domain.ZqczJcrwVo
;
import
com.qianhe.zqcz.jcrw.mapper.ZqczJcrwMapper
;
import
com.qianhe.zqcz.pftb.domain.ZqczPftb
;
import
com.qianhe.zqcz.pftb.domain.ZqczPftbQuery
;
import
com.qianhe.zqcz.pftb.mapper.ZqczPftbMapper
;
...
...
@@ -13,6 +12,8 @@ import com.qianhe.zqcz.pftb.service.ZqczPftbService;
import
com.qianhe.zqcz.pwxx.domain.ZqczPwxxQuery
;
import
com.qianhe.zqcz.pwxx.domain.ZqczPwxxVo
;
import
com.qianhe.zqcz.pwxx.mapper.ZqczPwxxMapper
;
import
com.qianhe.zqcz.zsrw.domain.ZqczZsrwVo
;
import
com.qianhe.zqcz.zsrw.mapper.ZqczZsrwMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.ss.util.CellRangeAddress
;
...
...
@@ -36,13 +37,16 @@ public class ZqczPftbServiceImpl implements ZqczPftbService {
@Autowired
private
ZqczPwxxMapper
zqczPwxxMapper
;
@Autowired
private
Zqcz
JcrwMapper
zqczJc
rwMapper
;
private
Zqcz
ZsrwMapper
zqczZs
rwMapper
;
/**
* 条件查询
*/
@Override
public
Map
<
String
,
Object
>
list
(
ZqczPftbQuery
zqczPftbQuery
)
{
if
(
zqczPftbQuery
.
getZsrwid
()
==
null
)
{
throw
new
BusinessException
(
"直属任务ID不能为空"
);
}
if
(
zqczPftbQuery
.
getJcrwid
()
==
null
)
{
throw
new
BusinessException
(
"基层任务ID不能为空"
);
}
...
...
@@ -92,7 +96,7 @@ public class ZqczPftbServiceImpl implements ZqczPftbService {
// 表格标题
List
<
String
>
tableTitle
=
new
ArrayList
<>();
// 拼接完成的标题列表
List
<
String
>
tableTitlePreFixList
=
Arrays
.
asList
(
"时间"
,
"基层单位名称"
,
"班站名称"
,
"项目类别"
,
"盲抽人员姓名"
,
"盲抽项目名称"
);
// 前缀
List
<
String
>
tableTitlePreFixList
=
Arrays
.
asList
(
"
固定字段(别删)"
,
"
时间"
,
"基层单位名称"
,
"班站名称"
,
"项目类别"
,
"盲抽人员姓名"
,
"盲抽项目名称"
);
// 前缀
List
<
String
>
tableTitleSuffixList
=
Arrays
.
asList
(
"得分(平均)"
,
"存在问题"
);
// 后缀
List
<
String
>
tableTitleDynamicList
=
fields
.
stream
().
map
(
ZqczPwxxVo:
:
getPwmc
).
collect
(
Collectors
.
toList
());
// 动态
tableTitle
.
addAll
(
tableTitlePreFixList
);
...
...
@@ -109,6 +113,7 @@ public class ZqczPftbServiceImpl implements ZqczPftbService {
List
<
Object
>
rowList
=
new
ArrayList
<>();
// 固定字段(直接添加,无需多余对象接收)
rowList
.
add
(
rowMap
.
get
(
"xmryid"
));
// 项目人员ID(用于导入修改时用到)
rowList
.
add
(
rowMap
.
get
(
"update_time"
));
// 更新时间
rowList
.
add
(
rowMap
.
get
(
"jcdwmc"
));
// 基层单位名称
rowList
.
add
(
rowMap
.
get
(
"dwmc"
));
// 班站名称
...
...
@@ -135,17 +140,20 @@ public class ZqczPftbServiceImpl implements ZqczPftbService {
// 最终二维数组
Object
[][]
finalArray
=
finalList
.
toArray
(
new
Object
[
0
][]);
// 查询基层单位名称
ZqczJcrwVo
zqczJcrwVo
=
zqczJcrwMapper
.
info
(
zqczPftbQuery
.
getJcrwid
());
// 查询直属任务
ZqczZsrwVo
zqczZsrwVo
=
zqczZsrwMapper
.
info
(
zqczPftbQuery
.
getZsrwid
());
if
(
zqczZsrwVo
==
null
)
{
throw
new
BusinessException
(
"暂无查询到关联的直属任务"
);
}
Workbook
workbook
=
new
XSSFWorkbook
();
try
{
Sheet
sheet
=
workbook
.
createSheet
();
// 创建标签页
createMainTitle
(
workbook
,
sheet
,
tableTitle
.
size
()
-
1
);
createSubTitle
(
workbook
,
sheet
,
zqcz
JcrwVo
.
getJcdwmc
());
createSubTitle
(
workbook
,
sheet
,
zqcz
ZsrwVo
.
getDeptName
());
createTableTitle
(
workbook
,
sheet
,
tableTitle
);
writeTableData
(
workbook
,
sheet
,
finalArray
,
3
);
setExportResponseHeader
(
response
,
"附表1“最强操作”抽取人员及项目评分统计表.xlsx"
);
setExportResponseHeader
(
response
,
String
.
format
(
"附表1“最强操作”抽取人员及项目评分统计表_%s.xlsx"
,
new
Date
().
getTime
())
);
workbook
.
write
(
response
.
getOutputStream
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -214,20 +222,26 @@ public class ZqczPftbServiceImpl implements ZqczPftbService {
tableHeaderStyle
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
// 左对齐
tableHeaderStyle
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
// 垂直居中
tableHeaderStyle
.
setBorderTop
(
BorderStyle
.
THIN
);
// 上边框
tableHeaderStyle
.
setBorderBottom
(
BorderStyle
.
THIN
);
// 下边框
tableHeaderStyle
.
setBorderLeft
(
BorderStyle
.
THIN
);
// 左边框
tableHeaderStyle
.
setBorderRight
(
BorderStyle
.
THIN
);
// 右边框
Font
tableHeaderFont
=
workbook
.
createFont
();
// 设置字体
tableHeaderFont
.
setBold
(
true
);
// 加粗
tableHeaderFont
.
setFontHeightInPoints
((
short
)
11
);
// 字体大小
tableHeaderFont
.
setFontName
(
"宋体"
);
// 字体名称
tableHeaderStyle
.
setFont
(
tableHeaderFont
);
tableHeaderStyle
.
setBorderTop
(
BorderStyle
.
THIN
);
// 上边框
tableHeaderStyle
.
setBorderBottom
(
BorderStyle
.
THIN
);
// 下边框
tableHeaderStyle
.
setBorderLeft
(
BorderStyle
.
THIN
);
// 左边框
tableHeaderStyle
.
setBorderRight
(
BorderStyle
.
THIN
);
// 右边框
Row
tableHeaderRow
=
sheet
.
createRow
(
2
);
// 创建第三行
tableHeaderRow
.
setHeightInPoints
(
43
);
// 设置行高
CellStyle
redStyle
=
workbook
.
createCellStyle
();
redStyle
.
cloneStyleFrom
(
tableHeaderStyle
);
redStyle
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
redStyle
.
setFillPattern
(
FillPatternType
.
SOLID_FOREGROUND
);
redStyle
.
setFillForegroundColor
(
IndexedColors
.
RED1
.
getIndex
());
// 循环创建每一列表头
for
(
int
i
=
0
;
i
<
tableTitle
.
size
();
i
++)
{
// 在当前行创建第 i 列(i 从 0 开始)
...
...
@@ -237,7 +251,7 @@ public class ZqczPftbServiceImpl implements ZqczPftbService {
cell
.
setCellValue
(
tableTitle
.
get
(
i
));
// 将表头样式应用到该单元格
cell
.
setCellStyle
(
tableHeaderStyle
);
cell
.
setCellStyle
(
i
==
0
?
redStyle
:
tableHeaderStyle
);
}
}
...
...
@@ -249,29 +263,31 @@ public class ZqczPftbServiceImpl implements ZqczPftbService {
return
;
}
// 1. 创建通用基础样式(边框+垂直居中)
CellStyle
baseStyle
=
workbook
.
createCellStyle
();
baseStyle
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
baseStyle
.
setBorderTop
(
BorderStyle
.
THIN
);
baseStyle
.
setBorderBottom
(
BorderStyle
.
THIN
);
baseStyle
.
setBorderLeft
(
BorderStyle
.
THIN
);
baseStyle
.
setBorderRight
(
BorderStyle
.
THIN
);
// 2. 普通文本样式(左对齐,继承基础样式)
CellStyle
dataStyle
=
workbook
.
createCellStyle
();
dataStyle
.
cloneStyleFrom
(
baseStyle
);
// 继承边框+垂直居中
dataStyle
.
setAlignment
(
HorizontalAlignment
.
LEFT
);
dataStyle
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
dataStyle
.
setBorderTop
(
BorderStyle
.
THIN
);
dataStyle
.
setBorderBottom
(
BorderStyle
.
THIN
);
dataStyle
.
setBorderLeft
(
BorderStyle
.
THIN
);
dataStyle
.
setBorderRight
(
BorderStyle
.
THIN
);
//
创建数字样式(千分位格
式)
//
3. 数字千分位样式(右对齐,继承基础样
式)
CellStyle
numberStyle
=
workbook
.
createCellStyle
();
numberStyle
.
cloneStyleFrom
(
baseStyle
);
numberStyle
.
setAlignment
(
HorizontalAlignment
.
RIGHT
);
numberStyle
.
set
VerticalAlignment
(
VerticalAlignment
.
CENTER
);
numberStyle
.
set
DataFormat
(
workbook
.
createDataFormat
().
getFormat
(
"#,##0"
)
);
// 设置千分位格式,带2位小数
// "#,##0.00" 表示带千分位和两位小数
DataFormat
dataFormat
=
workbook
.
createDataFormat
();
numberStyle
.
setDataFormat
(
dataFormat
.
getFormat
(
"#,##0"
));
// 复制边框样式
numberStyle
.
setBorderTop
(
BorderStyle
.
THIN
);
numberStyle
.
setBorderBottom
(
BorderStyle
.
THIN
);
numberStyle
.
setBorderLeft
(
BorderStyle
.
THIN
);
numberStyle
.
setBorderRight
(
BorderStyle
.
THIN
);
// 4. 红色背景样式(居中+红底,继承基础样式)
CellStyle
redStyle
=
workbook
.
createCellStyle
();
redStyle
.
cloneStyleFrom
(
baseStyle
);
redStyle
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
redStyle
.
setFillPattern
(
FillPatternType
.
SOLID_FOREGROUND
);
redStyle
.
setFillForegroundColor
(
IndexedColors
.
RED1
.
getIndex
());
for
(
int
i
=
0
;
i
<
finalArray
.
length
;
i
++)
{
Row
row
=
sheet
.
createRow
(
i
+
firstRow
);
...
...
@@ -288,12 +304,15 @@ public class ZqczPftbServiceImpl implements ZqczPftbService {
int
intValue
=
(
Integer
)
value
;
cell
.
setCellValue
(
intValue
);
// 设置为数值
}
else
if
(
value
instanceof
LocalDateTime
)
{
String
timeValue
=
MtTimeUtil
.
dateTimeFormat
((
LocalDateTime
)
value
);
String
timeValue
=
MtTimeUtil
.
dateTimeFormat
Nyr
((
LocalDateTime
)
value
);
cell
.
setCellValue
(
timeValue
);
// 将日期类型转化为字符串类型
}
// 设置单元格样式
if
(
j
==
0
)
{
cell
.
setCellStyle
(
redStyle
);
}
else
{
cell
.
setCellStyle
(
dataStyle
);
}
}
}
...
...
@@ -314,6 +333,9 @@ public class ZqczPftbServiceImpl implements ZqczPftbService {
sheet
.
setColumnWidth
(
j
,
width
);
}
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
firstRow
,
firstRow
+
finalArray
.
length
-
1
,
1
,
1
));
// 单元格合并(时间)
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
firstRow
,
firstRow
+
finalArray
.
length
-
1
,
2
,
2
));
// 单元格合并(基层单位名称)
}
/**
...
...
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