Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
patzn-cloud-service-hmhj
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangweidong
patzn-cloud-service-hmhj
Commits
8752777f
Commit
8752777f
authored
Jun 23, 2021
by
wangweidong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hmhj优化报告生成
parent
ed434bba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
53 deletions
+98
-53
EntrustSampleServiceImpl.java
...vice/lims/hmhj/service/impl/EntrustSampleServiceImpl.java
+92
-53
20210623新增报告模板字段.sql
...test/java/resources/db_sql/hmhj/v113/20210623新增报告模板字段.sql
+6
-0
No files found.
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/EntrustSampleServiceImpl.java
View file @
8752777f
...
...
@@ -418,10 +418,11 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
String
sheetName
=
sheetOne
.
getSheetName
();
System
.
out
.
println
(
sheetName
);
sheetOne
.
setForceFormulaRecalculation
(
true
);
Integer
beginRow
=
sysFileTemplate
.
getSampleBeginRow
();
int
sampleMergerNum
=
sysFileTemplate
.
getSampleMergerNum
();
int
templateSampleNum
=
sysFileTemplate
.
getTemplateSampleNum
();
if
(
templateSampleNum
>=
sampleVOList
.
size
())
{
Integer
beginRow
=
sysFileTemplate
.
getSampleBeginRow
();
for
(
EntrustSampleVO
vo
:
sampleVOList
)
{
List
<
EntrustSampleItemIndex
>
indexList
=
entrustSampleItemIndexService
.
listBySampleId
(
vo
.
getId
());
vo
.
setIndexList
(
indexList
);
...
...
@@ -470,69 +471,107 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
}
}
else
{
int
insertRow
=
beginRow
+
sampleMergerNum
*
templateSampleNum
;
XSSFRow
zeroRow
=
sheetOne
.
getRow
(
beginRow
);
XSSFCellStyle
cellStyle
=
zeroRow
.
getCell
(
0
).
getCellStyle
();
int
lastCellNum
=
zeroRow
.
getLastCellNum
();
int
insertCount
=
sampleVOList
.
size
()
-
templateSampleNum
;
for
(
int
m
=
0
;
m
<
insertCount
;
m
++)
{
for
(
int
i
=
0
;
i
<
sampleMergerNum
;
i
++)
{
sheetOne
.
shiftRows
(
insertRow
,
sheetOne
.
getLastRowNum
(),
1
,
true
,
false
);
XSSFRow
row
=
sheetOne
.
createRow
(
insertRow
);
row
.
setHeight
(
zeroRow
.
getHeight
());
for
(
int
j
=
0
;
j
<
lastCellNum
;
j
++)
{
XSSFCell
xssfCell
=
row
.
createCell
(
j
);
xssfCell
.
setCellStyle
(
cellStyle
);
}
insertRow
++;
if
(
null
!=
sysFileTemplate
.
getMoreSheet
()&&
sysFileTemplate
.
getMoreSheet
()==
1
){
int
total
=
sampleVOList
.
size
();
int
totalSheetSize
=
(
total
+
templateSampleNum
-
1
)/
templateSampleNum
;
List
<
List
<
EntrustSampleVO
>>
listList
=
Lists
.
partition
(
sampleVOList
,
templateSampleNum
);
for
(
int
i
=
1
;
i
<
totalSheetSize
;
i
++)
{
xssfWorkbook
.
cloneSheet
(
0
,
sheetOne
.
getSheetName
()+(
i
+
1
));
}
for
(
int
k
=
0
;
k
<
listList
.
size
();
k
++)
{
Integer
beginRow
=
sysFileTemplate
.
getSampleBeginRow
();
List
<
EntrustSampleVO
>
sampleVOListIndex
=
listList
.
get
(
k
);
for
(
EntrustSampleVO
vo
:
sampleVOListIndex
)
{
List
<
EntrustSampleItemIndex
>
indexList
=
entrustSampleItemIndexService
.
listBySampleId
(
vo
.
getId
());
vo
.
setIndexList
(
indexList
);
XSSFSheet
sheetOneIndex
=
xssfWorkbook
.
getSheetAt
(
k
);
XSSFRow
xssfRow
=
sheetOneIndex
.
getRow
(
beginRow
);
for
(
EntrustReportTemplateConfig
config
:
configList
)
{
XSSFCell
cell
=
xssfRow
.
getCell
(
config
.
getColumnPlace
());
if
(
"sn"
.
equals
(
config
.
getDataAttribute
()))
{
continue
;
}
if
(
StringUtils
.
isBlank
(
config
.
getDataAttribute
()))
{
continue
;
}
String
value
=
StringHandleUtils
.
getFieldValue
(
config
.
getDataAttribute
(),
vo
);
cell
.
setCellValue
(
value
);
}
beginRow
+=
sampleMergerNum
;
}
}
}
int
sn
=
1
;
for
(
EntrustSampleVO
vo
:
sampleVOList
)
{
XSSFRow
xssfRow
=
sheetOne
.
getRow
(
beginRow
);
List
<
EntrustSampleItemIndex
>
indexList
=
entrustSampleItemIndexService
.
listBySampleId
(
vo
.
getId
());
vo
.
setIndexList
(
indexList
);
for
(
EntrustReportTemplateConfig
config
:
configList
)
{
if
(
null
==
config
.
getColumnPlace
())
{
continue
;
}
XSSFCell
cell
=
xssfRow
.
getCell
(
config
.
getColumnPlace
());
if
(
"sn"
.
equals
(
config
.
getDataAttribute
()))
{
cell
.
setCellValue
(
sn
);
}
else
{
cell
.
setCellValue
(
StringHandleUtils
.
getFieldValue
(
config
.
getDataAttribute
(),
vo
));
}
else
{
Integer
beginRow
=
sysFileTemplate
.
getSampleBeginRow
();
int
insertRow
=
beginRow
+
sampleMergerNum
*
templateSampleNum
;
XSSFRow
zeroRow
=
sheetOne
.
getRow
(
beginRow
);
XSSFCellStyle
cellStyle
=
zeroRow
.
getCell
(
0
).
getCellStyle
();
int
lastCellNum
=
zeroRow
.
getLastCellNum
();
int
insertCount
=
sampleVOList
.
size
()
-
templateSampleNum
;
for
(
int
m
=
0
;
m
<
insertCount
;
m
++)
{
for
(
int
i
=
0
;
i
<
sampleMergerNum
;
i
++)
{
sheetOne
.
shiftRows
(
insertRow
,
sheetOne
.
getLastRowNum
(),
1
,
true
,
false
);
XSSFRow
row
=
sheetOne
.
createRow
(
insertRow
);
row
.
setHeight
(
zeroRow
.
getHeight
());
for
(
int
j
=
0
;
j
<
lastCellNum
;
j
++)
{
XSSFCell
xssfCell
=
row
.
createCell
(
j
);
xssfCell
.
setCellStyle
(
cellStyle
);
}
insertRow
++;
}
}
beginRow
+=
sampleMergerNum
;
sn
++;
int
sn
=
1
;
for
(
EntrustSampleVO
vo
:
sampleVOList
)
{
XSSFRow
xssfRow
=
sheetOne
.
getRow
(
beginRow
);
List
<
EntrustSampleItemIndex
>
indexList
=
entrustSampleItemIndexService
.
listBySampleId
(
vo
.
getId
());
vo
.
setIndexList
(
indexList
);
for
(
EntrustReportTemplateConfig
config
:
configList
)
{
if
(
null
==
config
.
getColumnPlace
())
{
continue
;
}
XSSFCell
cell
=
xssfRow
.
getCell
(
config
.
getColumnPlace
());
if
(
"sn"
.
equals
(
config
.
getDataAttribute
()))
{
cell
.
setCellValue
(
sn
);
}
else
{
cell
.
setCellValue
(
StringHandleUtils
.
getFieldValue
(
config
.
getDataAttribute
(),
vo
));
}
}
beginRow
+=
sampleMergerNum
;
sn
++;
}
for
(
EntrustReportTemplateConfig
config
:
configList
)
{
if
(
null
==
config
.
getMergeRowNum
())
{
config
.
setMergeRowNum
(
1
);
}
if
(
null
==
config
.
getMergeBegin
())
{
continue
;
}
if
(
null
==
config
.
getMergeEnd
())
{
continue
;
}
int
step
=
config
.
getMergeRowNum
();
if
(
step
==
1
&&
config
.
getMergeEnd
()
==
config
.
getMergeBegin
())
{
continue
;
}
if
(
null
!=
config
.
getColumnPlace
()
&&
null
!=
config
.
getMergeRowNum
())
{
Integer
sampleBgMum
=
sysFileTemplate
.
getSampleBeginRow
()
+
templateSampleNum
*
sampleMergerNum
;
Integer
sampleEnMum
=
sysFileTemplate
.
getSampleBeginRow
()
+
sampleVOList
.
size
()
*
sampleMergerNum
-
1
;
while
(
sampleBgMum
<=
sampleEnMum
)
{
sheetOne
.
addMergedRegion
(
new
CellRangeAddress
(
sampleBgMum
,
sampleBgMum
+
step
-
1
,
config
.
getMergeBegin
(),
config
.
getMergeEnd
()));
sampleBgMum
=
sampleBgMum
+
step
;
for
(
EntrustReportTemplateConfig
config
:
configList
)
{
if
(
null
==
config
.
getMergeRowNum
())
{
config
.
setMergeRowNum
(
1
);
}
if
(
null
==
config
.
getMergeBegin
())
{
continue
;
}
if
(
null
==
config
.
getMergeEnd
())
{
continue
;
}
int
step
=
config
.
getMergeRowNum
();
if
(
step
==
1
&&
config
.
getMergeEnd
()
==
config
.
getMergeBegin
())
{
continue
;
}
if
(
null
!=
config
.
getColumnPlace
()
&&
null
!=
config
.
getMergeRowNum
())
{
Integer
sampleBgMum
=
sysFileTemplate
.
getSampleBeginRow
()
+
templateSampleNum
*
sampleMergerNum
;
Integer
sampleEnMum
=
sysFileTemplate
.
getSampleBeginRow
()
+
sampleVOList
.
size
()
*
sampleMergerNum
-
1
;
while
(
sampleBgMum
<=
sampleEnMum
)
{
sheetOne
.
addMergedRegion
(
new
CellRangeAddress
(
sampleBgMum
,
sampleBgMum
+
step
-
1
,
config
.
getMergeBegin
(),
config
.
getMergeEnd
()));
sampleBgMum
=
sampleBgMum
+
step
;
}
}
}
}
}
String
generated
=
entrust
.
getCode
();
FileOutputStream
os
=
null
;
...
...
src/test/java/resources/db_sql/hmhj/v113/20210623新增报告模板字段.sql
0 → 100644
View file @
8752777f
ALTER
TABLE
"public"
.
"entrust_report_template"
ALTER
TABLE
"public"
.
"entrust_report_template"
ADD
COLUMN
"more_sheet"
int2
DEFAULT
0
;
COMMENT
ON
COLUMN
"public"
.
"entrust_report_template"
.
"more_sheet"
IS
'多Sheet模板(0否1是)'
;
\ No newline at end of file
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