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
ed434bba
Commit
ed434bba
authored
Jun 23, 2021
by
wangweidong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hmhj原始记录优化
parent
901aa79b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
141 additions
and
78 deletions
+141
-78
MoreItemMoreOperation.java
...oud/service/lims/hmhj/original/MoreItemMoreOperation.java
+131
-66
OriginalTemplateServiceImpl.java
...e/lims/hmhj/service/impl/OriginalTemplateServiceImpl.java
+10
-12
No files found.
src/main/java/com/patzn/cloud/service/lims/hmhj/original/MoreItemMoreOperation.java
View file @
ed434bba
package
com
.
patzn
.
cloud
.
service
.
lims
.
hmhj
.
original
;
package
com
.
patzn
.
cloud
.
service
.
lims
.
hmhj
.
original
;
import
com.google.common.collect.Lists
;
import
com.patzn.cloud.service.hmhj.entity.Entrust
;
import
com.patzn.cloud.service.hmhj.entity.Entrust
;
import
com.patzn.cloud.service.hmhj.entity.OriginalTemplate
;
import
com.patzn.cloud.service.hmhj.entity.OriginalTemplate
;
import
com.patzn.cloud.service.hmhj.entity.OriginalTemplateConfig
;
import
com.patzn.cloud.service.hmhj.entity.OriginalTemplateConfig
;
import
com.patzn.cloud.service.hmhj.vo.EntrustSampleItemVO
;
import
com.patzn.cloud.service.hmhj.vo.EntrustSampleVO
;
import
com.patzn.cloud.service.hmhj.vo.EntrustSampleVO
;
import
com.patzn.cloud.service.lims.common.StringHandleUtils
;
import
com.patzn.cloud.service.lims.common.StringHandleUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -33,95 +33,160 @@ public class MoreItemMoreOperation implements Operation {
...
@@ -33,95 +33,160 @@ public class MoreItemMoreOperation implements Operation {
OriginalUtil
.
doReplace
(
xssfWorkbook
,
entrust
);
OriginalUtil
.
doReplace
(
xssfWorkbook
,
entrust
);
XSSFSheet
sheetOne
=
xssfWorkbook
.
getSheetAt
(
0
);
XSSFSheet
sheetOne
=
xssfWorkbook
.
getSheetAt
(
0
);
sheetOne
.
setForceFormulaRecalculation
(
true
);
sheetOne
.
setForceFormulaRecalculation
(
true
);
Integer
beginRow
=
template
.
getSampleBeginRow
();
int
sampleMergerNum
=
template
.
getSampleMergerNum
();
int
sampleMergerNum
=
template
.
getSampleMergerNum
();
int
templateSampleNum
=
template
.
getTemplateSampleNum
();
int
templateSampleNum
=
template
.
getTemplateSampleNum
();
int
insertRow
=
beginRow
+
sampleMergerNum
*
templateSampleNum
;
XSSFRow
zeroRow
=
sheetOne
.
getRow
(
beginRow
);
XSSFRow
zeroRow
=
sheetOne
.
getRow
(
template
.
getSampleBeginRow
()
);
XSSFCellStyle
cellStyle
=
zeroRow
.
getCell
(
0
).
getCellStyle
();
XSSFCellStyle
cellStyle
=
zeroRow
.
getCell
(
0
).
getCellStyle
();
int
lastCellNum
=
zeroRow
.
getLastCellNum
();
int
lastCellNum
=
zeroRow
.
getLastCellNum
();
int
insertCount
=
voList
.
size
()-
templateSampleNum
;
if
(
template
.
getMoreSheet
()==
1
){
for
(
int
m
=
0
;
m
<
insertCount
;
m
++)
{
//生成多个sheet的原始记录
for
(
int
i
=
0
;
i
<
sampleMergerNum
;
i
++)
{
//判断要生成几份sheet
sheetOne
.
shiftRows
(
insertRow
,
sheetOne
.
getLastRowNum
(),
1
,
true
,
false
);
int
total
=
voList
.
size
();
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
++;
int
totalSheetSize
=
(
total
+
templateSampleNum
-
1
)/
templateSampleNum
;
List
<
List
<
EntrustSampleVO
>>
listList
=
Lists
.
partition
(
voList
,
templateSampleNum
);
for
(
int
i
=
1
;
i
<
totalSheetSize
;
i
++)
{
xssfWorkbook
.
cloneSheet
(
0
,
sheetOne
.
getSheetName
()+(
i
+
1
));
}
}
}
int
sn
=
1
;
for
(
int
m
=
0
;
m
<
listList
.
size
();
m
++)
{
List
<
EntrustSampleVO
>
sampleVOListIndex
=
listList
.
get
(
m
);
for
(
EntrustSampleVO
vo:
voList
)
{
XSSFSheet
sheetIndex
=
xssfWorkbook
.
getSheetAt
(
m
);
XSSFRow
xssfRow
=
sheetOne
.
getRow
(
beginRow
);
Integer
beginRow
=
template
.
getSampleBeginRow
(
);
for
(
OriginalTemplateConfig
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
(
OriginalTemplateConfig
config:
configList
)
{
for
(
EntrustSampleVO
vo:
sampleVOListIndex
)
{
if
(
null
==
config
.
getMergeRowNum
()){
XSSFRow
xssfRow
=
sheetIndex
.
getRow
(
beginRow
);
config
.
setMergeRowNum
(
1
);
for
(
OriginalTemplateConfig
config:
configList
)
{
}
XSSFCell
cell
=
xssfRow
.
getCell
(
config
.
getColumnPlace
());
if
(
StringUtils
.
isNotBlank
(
config
.
getFormula
())&&
null
!=
config
.
getColumnPlace
()
&&
null
!=
config
.
getMergeRowNum
()){
if
(
"sn"
.
equals
(
config
.
getDataAttribute
())){
continue
;
}
if
(
StringUtils
.
isBlank
(
config
.
getDataAttribute
())){
continue
;
}
cell
.
setCellValue
(
StringHandleUtils
.
getFieldValue
(
config
.
getDataAttribute
(),
vo
));
}
beginRow
+=
sampleMergerNum
;
}
Integer
sampleBgMum
=
template
.
getSampleBeginRow
();
Integer
sampleBgMum
=
template
.
getSampleBeginRow
();
Integer
mergeRowNum
=
config
.
getMergeRowNum
();
for
(
OriginalTemplateConfig
config:
configList
)
{
int
formulaNum
=
template
.
getSampleBeginRow
()+
sampleMergerNum
*
voList
.
size
()-
1
;
if
(
null
==
config
.
getMergeRowNum
()){
for
(
int
i
=
sampleBgMum
;
i
<=
formulaNum
;
i
+=
mergeRowNum
)
{
config
.
setMergeRowNum
(
1
);
XSSFRow
row
=
sheetOne
.
getRow
(
i
);
}
if
(
null
==
row
){
String
formula
=
config
.
getFormula
();
if
(
StringUtils
.
isBlank
(
formula
)){
continue
;
continue
;
}
}
XSSFCell
cell
=
row
.
getCell
(
config
.
getColumnPlace
());
if
(
null
==
cell
){
Integer
columnPlace
=
config
.
getColumnPlace
();
if
(
null
==
config
.
getColumnPlace
()){
continue
;
continue
;
}
}
String
formula
=
config
.
getFormula
();
if
(
null
==
config
.
getMergeRowNum
()){
cell
.
setCellFormula
(
OriginalUtil
.
initFormula
(
formula
,
i
));
continue
;
}
}
}
}
Integer
mergeRowNum
=
config
.
getMergeRowNum
();
int
formulaNum
=
template
.
getSampleBeginRow
()+
sampleMergerNum
*
templateSampleNum
-
1
;
for
(
OriginalTemplateConfig
config:
configList
)
{
for
(
int
i
=
sampleBgMum
;
i
<=
formulaNum
;
i
+=
mergeRowNum
)
{
if
(
null
==
config
.
getMergeRowNum
()){
XSSFRow
row
=
sheetOne
.
getRow
(
i
);
config
.
setMergeRowNum
(
1
);
XSSFCell
cell
=
row
.
getCell
(
columnPlace
);
cell
.
setCellFormula
(
OriginalUtil
.
initFormula
(
formula
,
i
));
}
}
}
}
if
(
null
==
config
.
getMergeBegin
()){
}
else
{
continue
;
Integer
beginRow
=
template
.
getSampleBeginRow
();
int
insertRow
=
beginRow
+
sampleMergerNum
*
templateSampleNum
;
int
insertCount
=
voList
.
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
==
config
.
getMergeEnd
()){
int
sn
=
1
;
continue
;
for
(
EntrustSampleVO
vo:
voList
)
{
XSSFRow
xssfRow
=
sheetOne
.
getRow
(
beginRow
);
for
(
OriginalTemplateConfig
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
++;
}
}
int
step
=
config
.
getMergeRowNum
();
for
(
OriginalTemplateConfig
config:
configList
)
{
if
(
step
==
1
&&
config
.
getMergeEnd
()
==
config
.
getMergeBegin
()){
if
(
null
==
config
.
getMergeRowNum
()){
continue
;
config
.
setMergeRowNum
(
1
);
}
if
(
StringUtils
.
isNotBlank
(
config
.
getFormula
())&&
null
!=
config
.
getColumnPlace
()
&&
null
!=
config
.
getMergeRowNum
()){
Integer
sampleBgMum
=
template
.
getSampleBeginRow
();
Integer
mergeRowNum
=
config
.
getMergeRowNum
();
int
formulaNum
=
template
.
getSampleBeginRow
()+
sampleMergerNum
*
voList
.
size
()-
1
;
for
(
int
i
=
sampleBgMum
;
i
<=
formulaNum
;
i
+=
mergeRowNum
)
{
XSSFRow
row
=
sheetOne
.
getRow
(
i
);
if
(
null
==
row
){
continue
;
}
XSSFCell
cell
=
row
.
getCell
(
config
.
getColumnPlace
());
if
(
null
==
cell
){
continue
;
}
String
formula
=
config
.
getFormula
();
cell
.
setCellFormula
(
OriginalUtil
.
initFormula
(
formula
,
i
));
}
}
}
}
if
(
null
!=
config
.
getColumnPlace
()
&&
null
!=
config
.
getMergeRowNum
()){
Integer
sampleBgMum
=
template
.
getSampleBeginRow
()+
templateSampleNum
*
sampleMergerNum
;
Integer
sampleEnMum
=
template
.
getSampleBeginRow
()+
voList
.
size
()*
sampleMergerNum
-
1
;
for
(
OriginalTemplateConfig
config:
configList
)
{
while
(
sampleBgMum
<=
sampleEnMum
)
{
if
(
null
==
config
.
getMergeRowNum
()){
sheetOne
.
addMergedRegion
(
new
CellRangeAddress
(
sampleBgMum
,
sampleBgMum
+
step
-
1
,
config
.
getMergeBegin
(),
config
.
getMergeEnd
()));
config
.
setMergeRowNum
(
1
);
sampleBgMum
=
sampleBgMum
+
step
;
}
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
=
template
.
getSampleBeginRow
()+
templateSampleNum
*
sampleMergerNum
;
Integer
sampleEnMum
=
template
.
getSampleBeginRow
()+
voList
.
size
()*
sampleMergerNum
-
1
;
while
(
sampleBgMum
<=
sampleEnMum
)
{
sheetOne
.
addMergedRegion
(
new
CellRangeAddress
(
sampleBgMum
,
sampleBgMum
+
step
-
1
,
config
.
getMergeBegin
(),
config
.
getMergeEnd
()));
sampleBgMum
=
sampleBgMum
+
step
;
}
}
}
}
}
}
}
}
}
}
}
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/OriginalTemplateServiceImpl.java
View file @
ed434bba
...
@@ -237,12 +237,6 @@ public class OriginalTemplateServiceImpl extends BaseServiceImpl<OriginalTemplat
...
@@ -237,12 +237,6 @@ public class OriginalTemplateServiceImpl extends BaseServiceImpl<OriginalTemplat
RestAssert
.
fail
(
StringUtils
.
isBlank
(
someParam
)
||
4
!=
someParam
.
split
(
"&"
).
length
,
"参数传递有误"
);
RestAssert
.
fail
(
StringUtils
.
isBlank
(
someParam
)
||
4
!=
someParam
.
split
(
"&"
).
length
,
"参数传递有误"
);
String
[]
arr
=
someParam
.
split
(
"&"
);
String
[]
arr
=
someParam
.
split
(
"&"
);
Long
businessId
=
Long
.
parseLong
(
arr
[
0
]);
Long
businessId
=
Long
.
parseLong
(
arr
[
0
]);
String
userName
=
null
;
try
{
userName
=
java
.
net
.
URLDecoder
.
decode
(
arr
[
2
],
"utf-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
Long
userId
=
Long
.
parseLong
(
arr
[
1
]);
Long
userId
=
Long
.
parseLong
(
arr
[
1
]);
Long
companyId
=
Long
.
parseLong
(
arr
[
3
]);
Long
companyId
=
Long
.
parseLong
(
arr
[
3
]);
OriginalRecord
report
=
originalRecordService
.
getById
(
businessId
);
OriginalRecord
report
=
originalRecordService
.
getById
(
businessId
);
...
@@ -263,8 +257,6 @@ public class OriginalTemplateServiceImpl extends BaseServiceImpl<OriginalTemplat
...
@@ -263,8 +257,6 @@ public class OriginalTemplateServiceImpl extends BaseServiceImpl<OriginalTemplat
return
false
;
return
false
;
}
}
XSSFSheet
sheet
=
xssfWorkbook
.
getSheetAt
(
0
);
if
(
null
==
report
.
getTemplateId
())
{
if
(
null
==
report
.
getTemplateId
())
{
return
true
;
return
true
;
}
}
...
@@ -274,6 +266,13 @@ public class OriginalTemplateServiceImpl extends BaseServiceImpl<OriginalTemplat
...
@@ -274,6 +266,13 @@ public class OriginalTemplateServiceImpl extends BaseServiceImpl<OriginalTemplat
if
(
null
==
template
)
{
if
(
null
==
template
)
{
return
true
;
return
true
;
}
}
int
sheetSize
=
xssfWorkbook
.
getNumberOfSheets
();
Integer
moreSheet
=
template
.
getMoreSheet
();
Integer
moreSheet
=
template
.
getMoreSheet
();
List
<
OriginalTemplateConfig
>
configList
=
originalTemplateConfigService
.
list
(
Condition
.
create
().
eq
(
"template_id"
,
template
.
getId
()));
List
<
OriginalTemplateConfig
>
configList
=
originalTemplateConfigService
.
list
(
Condition
.
create
().
eq
(
"template_id"
,
template
.
getId
()));
...
@@ -308,8 +307,8 @@ public class OriginalTemplateServiceImpl extends BaseServiceImpl<OriginalTemplat
...
@@ -308,8 +307,8 @@ public class OriginalTemplateServiceImpl extends BaseServiceImpl<OriginalTemplat
for
(
EntrustSampleItemIndexVO
soilItemVO
:
indexList
)
{
for
(
EntrustSampleItemIndexVO
soilItemVO
:
indexList
)
{
stringMap
.
put
(
soilItemVO
.
getSampleCode
()
+
soilItemVO
.
getEntrustSampleItemId
()
+
soilItemVO
.
getName
(),
soilItemVO
.
getId
());
stringMap
.
put
(
soilItemVO
.
getSampleCode
()
+
soilItemVO
.
getEntrustSampleItemId
()
+
soilItemVO
.
getName
(),
soilItemVO
.
getId
());
}
}
for
(
int
k
=
0
;
k
<
sheetSize
;
k
++)
{
if
(
null
==
moreSheet
||
0
==
moreSheet
)
{
XSSFSheet
sheet
=
xssfWorkbook
.
getSheetAt
(
k
);
int
sampleBeginRow
=
template
.
getSampleBeginRow
();
int
sampleBeginRow
=
template
.
getSampleBeginRow
();
int
sampleMergerNum
=
template
.
getSampleMergerNum
();
int
sampleMergerNum
=
template
.
getSampleMergerNum
();
int
lastRowNum
=
sheet
.
getLastRowNum
();
int
lastRowNum
=
sheet
.
getLastRowNum
();
...
@@ -533,9 +532,8 @@ public class OriginalTemplateServiceImpl extends BaseServiceImpl<OriginalTemplat
...
@@ -533,9 +532,8 @@ public class OriginalTemplateServiceImpl extends BaseServiceImpl<OriginalTemplat
if
(
CollectionUtils
.
isNotEmpty
(
updateList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
updateList
))
{
entrustSampleItemIndexService
.
updateBatchById
(
updateList
);
entrustSampleItemIndexService
.
updateBatchById
(
updateList
);
}
}
}
}
return
true
;
return
true
;
}
}
...
...
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