Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
patzn-cloud-service-soil
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-soil
Commits
b2ee5275
Commit
b2ee5275
authored
Apr 19, 2021
by
wangweidong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
土工问题
parent
5e869911
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
579 additions
and
989 deletions
+579
-989
OriginalOperationFactory.java
...cloud/service/lims/original/OriginalOperationFactory.java
+79
-0
SheetMoreMuchOperation.java
...n/cloud/service/lims/original/SheetMoreMuchOperation.java
+298
-0
SingleLessOperation.java
...atzn/cloud/service/lims/original/SingleLessOperation.java
+150
-0
SoilExperimentServiceImpl.java
...ice/lims/soil/service/impl/SoilExperimentServiceImpl.java
+52
-989
No files found.
src/main/java/com/patzn/cloud/service/lims/original/OriginalOperationFactory.java
0 → 100644
View file @
b2ee5275
package
com
.
patzn
.
cloud
.
service
.
lims
.
original
;
import
com.patzn.cloud.service.soil.entity.SoilEntrust
;
import
com.patzn.cloud.service.soil.entity.SoilOriginalTemplate
;
import
com.patzn.cloud.service.soil.entity.SoilOriginalTemplateConfig
;
import
com.patzn.cloud.service.soil.vo.SoilExperimentVO
;
import
com.patzn.cloud.service.soil.vo.SoilItemVO
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
public
class
OriginalOperationFactory
{
private
XSSFWorkbook
xssfWorkbook
;
private
InputStream
io
;
private
Map
<
String
,
String
>
mapReplace
;
private
List
<
SoilOriginalTemplateConfig
>
configList
;
private
SoilOriginalTemplate
template
;
private
List
<
SoilExperimentVO
>
voList
;
private
Map
<
Long
,
List
<
SoilItemVO
>>
sampleSoilItemVOMap
=
new
ConcurrentHashMap
<>();
private
SoilEntrust
entrust
;
public
OriginalOperationFactory
(
XSSFWorkbook
xssfWorkbook
,
InputStream
io
,
Map
<
String
,
String
>
mapReplace
,
List
<
SoilOriginalTemplateConfig
>
configList
,
SoilOriginalTemplate
template
,
List
<
SoilExperimentVO
>
voList
,
List
<
SoilItemVO
>
soilItemVOList
,
SoilEntrust
entrust
)
{
this
.
xssfWorkbook
=
xssfWorkbook
;
this
.
io
=
io
;
this
.
mapReplace
=
mapReplace
;
this
.
configList
=
configList
;
this
.
template
=
template
;
for
(
SoilExperimentVO
vo:
voList
)
{
if
(
vo
.
getName
().
contains
(
"重塑"
)){
vo
.
setMorphology
(
"重塑"
);
}
else
{
vo
.
setMorphology
(
"原状"
);
}
}
for
(
SoilItemVO
soilItemVO:
soilItemVOList
)
{
if
(
sampleSoilItemVOMap
.
containsKey
(
soilItemVO
.
getSampleId
())){
List
<
SoilItemVO
>
sampleItems
=
sampleSoilItemVOMap
.
get
(
soilItemVO
.
getSampleId
());
sampleItems
.
add
(
soilItemVO
);
sampleSoilItemVOMap
.
put
(
soilItemVO
.
getSampleId
(),
sampleItems
);
}
else
{
List
<
SoilItemVO
>
sampleItems
=
new
ArrayList
<>();
sampleItems
.
add
(
soilItemVO
);
sampleSoilItemVOMap
.
put
(
soilItemVO
.
getSampleId
(),
sampleItems
);
}
}
this
.
voList
=
voList
;
this
.
entrust
=
entrust
;
}
public
Operation
getOperation
(
SoilOriginalTemplate
template
,
Integer
templateSampleNum
,
List
<
SoilExperimentVO
>
voList
){
if
(
null
==
template
.
getMoreSheet
()
||
0
==
template
.
getMoreSheet
()){
//单模板
if
(
voList
.
size
()<
templateSampleNum
){
return
new
SingleLessOperation
(
xssfWorkbook
,
io
,
mapReplace
,
configList
,
template
,
voList
,
sampleSoilItemVOMap
);
}
else
{
return
new
SingleMoreOperation
(
xssfWorkbook
,
io
,
mapReplace
,
configList
,
template
,
voList
,
sampleSoilItemVOMap
);
}
}
else
{
//多sheet模板
if
(
null
==
templateSampleNum
||
1
==
templateSampleNum
){
return
new
SheetMoreSingleOperation
(
xssfWorkbook
,
io
,
mapReplace
,
configList
,
template
,
voList
,
sampleSoilItemVOMap
);
}
else
{
return
new
SheetMoreMuchOperation
(
xssfWorkbook
,
io
,
mapReplace
,
configList
,
template
,
voList
,
sampleSoilItemVOMap
,
entrust
);
}
}
}
}
src/main/java/com/patzn/cloud/service/lims/original/SheetMoreMuchOperation.java
0 → 100644
View file @
b2ee5275
package
com
.
patzn
.
cloud
.
service
.
lims
.
original
;
import
com.baomidou.mybatisplus.toolkit.CollectionUtils
;
import
com.patzn.cloud.service.lims.common.HSSFWorkbookUtil
;
import
com.patzn.cloud.service.lims.common.StringHandleUtils
;
import
com.patzn.cloud.service.lims.gideon.utils.ApachePoiLineChart4
;
import
com.patzn.cloud.service.lims.gideon.utils.DrawXlsxUtil
;
import
com.patzn.cloud.service.soil.entity.SoilEntrust
;
import
com.patzn.cloud.service.soil.entity.SoilOriginalTemplate
;
import
com.patzn.cloud.service.soil.entity.SoilOriginalTemplateConfig
;
import
com.patzn.cloud.service.soil.vo.SoilExperimentVO
;
import
com.patzn.cloud.service.soil.vo.SoilItemVO
;
import
org.apache.commons.collections4.ListUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.ss.usermodel.PrintSetup
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.InputStream
;
import
java.math.BigDecimal
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
SheetMoreMuchOperation
implements
Operation
{
private
XSSFWorkbook
xssfWorkbook
;
private
InputStream
io
;
private
Map
<
String
,
String
>
mapReplace
;
private
List
<
SoilOriginalTemplateConfig
>
configList
;
private
SoilOriginalTemplate
template
;
private
List
<
SoilExperimentVO
>
voList
;
private
Map
<
Long
,
List
<
SoilItemVO
>>
sampleSoilItemVOMap
;
private
SoilEntrust
entrust
;
protected
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SheetMoreMuchOperation
.
class
);
public
SheetMoreMuchOperation
(
XSSFWorkbook
xssfWorkbook
,
InputStream
io
,
Map
<
String
,
String
>
mapReplace
,
List
<
SoilOriginalTemplateConfig
>
configList
,
SoilOriginalTemplate
template
,
List
<
SoilExperimentVO
>
voList
,
Map
<
Long
,
List
<
SoilItemVO
>>
sampleSoilItemVOMap
,
SoilEntrust
entrust
)
{
this
.
xssfWorkbook
=
xssfWorkbook
;
this
.
io
=
io
;
this
.
mapReplace
=
mapReplace
;
this
.
configList
=
configList
;
this
.
template
=
template
;
this
.
voList
=
voList
;
this
.
sampleSoilItemVOMap
=
sampleSoilItemVOMap
;
this
.
entrust
=
entrust
;
}
public
void
doProductOriginal
(){
Integer
templateSampleNum
=
template
.
getTemplateSampleNum
();
List
<
List
<
SoilExperimentVO
>>
relList
=
ListUtils
.
partition
(
voList
,
templateSampleNum
);
int
templateSheetMum
=
xssfWorkbook
.
getNumberOfSheets
();
XSSFSheet
sheetMy
=
xssfWorkbook
.
getSheetAt
(
0
);
PrintSetup
printSetup
=
sheetMy
.
getPrintSetup
();
boolean
printRound
=
printSetup
.
getLandscape
();
boolean
first
=
true
;
List
<
SoilExperimentVO
>
firstList
=
null
;
for
(
List
<
SoilExperimentVO
>
expVOList:
relList
)
{
XSSFSheet
sheet
=
null
;
if
(
first
){
sheet
=
sheetMy
;
firstList
=
expVOList
;
first
=
false
;
continue
;
}
else
{
sheet
=
xssfWorkbook
.
cloneSheet
(
0
,
sheetMy
.
getSheetName
()+(
templateSheetMum
));
sheet
.
getPrintSetup
().
setLandscape
(
printRound
);
}
Map
<
String
,
String
>
mapReplaceMy
=
new
HashMap
<>();
mapReplaceMy
.
put
(
"#{reportCode}"
,
entrust
.
getEntrustCode
());
for
(
int
i
=
0
;
i
<
templateSampleNum
;
i
++)
{
mapReplaceMy
.
put
(
"#{sampleCode"
+
i
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{sampleDepth"
+
i
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{siteNo"
+
i
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{含水率"
+
i
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81"
+
i
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{密度9.81"
+
i
+
"}"
,
""
);
}
mapReplaceMy
.
put
(
"#{projectName}"
,
entrust
.
getProjectName
());
mapReplaceMy
.
put
(
"#{client}"
,
entrust
.
getClient
());
mapReplaceMy
.
put
(
"#{boreholeName}"
,
entrust
.
getBoreholeName
());
mapReplaceMy
.
put
(
"#{projectNo}"
,
entrust
.
getProjectNo
());
int
entitySize
=
expVOList
.
size
();
for
(
int
j
=
0
;
j
<
entitySize
;
j
++)
{
SoilExperimentVO
vo
=
expVOList
.
get
(
j
);
mapReplaceMy
.
put
(
"#{sampleCode"
+
j
+
"}"
,
StringHandleUtils
.
getString
(
vo
.
getSampleCode
()));
mapReplaceMy
.
put
(
"#{sampleDepth"
+
j
+
"}"
,
StringHandleUtils
.
getString
(
vo
.
getSampleDepth
()));
mapReplaceMy
.
put
(
"#{siteNo"
+
j
+
"}"
,
StringHandleUtils
.
getString
(
vo
.
getSiteNo
()));
List
<
SoilItemVO
>
itemVOList
=
sampleSoilItemVOMap
.
get
(
vo
.
getSampleId
());
if
(
CollectionUtils
.
isNotEmpty
(
itemVOList
)){
for
(
SoilItemVO
itemVO:
itemVOList
)
{
mapReplaceMy
.
put
(
"#{"
+
itemVO
.
getName
()+
"}"
,
itemVO
.
getTestValue
());
}
}
if
(!
mapReplaceMy
.
containsKey
(
"#{含水率}"
)){
mapReplaceMy
.
put
(
"#{含水率}"
,
""
);
mapReplaceMy
.
put
(
"#{含水率"
+
j
+
"}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{液限}"
)){
mapReplaceMy
.
put
(
"#{液限}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{塑限}"
)){
mapReplaceMy
.
put
(
"#{塑限}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{比重}"
)){
mapReplaceMy
.
put
(
"#{比重}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{密度}"
)){
mapReplaceMy
.
put
(
"#{密度}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{密度}"
)){
mapReplaceMy
.
put
(
"#{密度}"
,
""
);
mapReplaceMy
.
put
(
"#{密度9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{密度"
+
j
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{密度9.81"
+
j
+
"}"
,
""
);
}
else
{
String
midu
=
mapReplaceMy
.
get
(
"#{密度}"
);
if
(
StringUtils
.
isBlank
(
midu
)){
mapReplaceMy
.
put
(
"#{密度9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{密度9.81"
+
j
+
"}"
,
""
);
}
else
{
if
(
StringHandleUtils
.
validateNumber
(
midu
)){
BigDecimal
mi
=
new
BigDecimal
(
midu
);
BigDecimal
chengshu
=
new
BigDecimal
(
"9.81"
);
BigDecimal
ji
=
mi
.
multiply
(
chengshu
);
mapReplaceMy
.
put
(
"#{密度9.81}"
,
ji
.
toString
());
mapReplaceMy
.
put
(
"#{密度9.81"
+
j
+
"}"
,
ji
.
toString
());
}
else
{
mapReplaceMy
.
put
(
"#{密度9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{密度9.81"
+
j
+
"}"
,
""
);
}
}
}
if
(!
mapReplaceMy
.
containsKey
(
"#{容重}"
)){
mapReplaceMy
.
put
(
"#{容重}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{容重"
+
j
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81"
+
j
+
"}"
,
""
);
}
else
{
String
rongzhong
=
mapReplace
.
get
(
"#{容重}"
);
if
(
StringUtils
.
isBlank
(
rongzhong
)){
mapReplaceMy
.
put
(
"#{容重9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81"
+
j
+
"}"
,
""
);
}
else
{
if
(
StringHandleUtils
.
validateNumber
(
rongzhong
)){
BigDecimal
rong
=
new
BigDecimal
(
rongzhong
);
BigDecimal
chengshu
=
new
BigDecimal
(
"9.81"
);
BigDecimal
ji
=
rong
.
multiply
(
chengshu
);
mapReplaceMy
.
put
(
"#{容重9.81}"
,
ji
.
toString
());
mapReplaceMy
.
put
(
"#{容重9.81"
+
j
+
"}"
,
ji
.
toString
());
}
else
{
mapReplaceMy
.
put
(
"#{容重9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81"
+
j
+
"}"
,
""
);
}
}
}
}
HSSFWorkbookUtil
.
replaceModel
(
mapReplaceMy
,
xssfWorkbook
,
sheet
);
templateSheetMum
++;
}
int
firstSize
=
firstList
.
size
();
Map
<
String
,
String
>
mapReplaceMy
=
new
HashMap
<>();
InitMapReplace
.
initMapReplace
(
mapReplaceMy
,
entrust
);
for
(
int
i
=
0
;
i
<
templateSampleNum
;
i
++)
{
mapReplaceMy
.
put
(
"#{sampleCode"
+
i
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{sampleDepth"
+
i
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{siteNo"
+
i
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{含水率"
+
i
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{密度9.81"
+
i
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81"
+
i
+
"}"
,
""
);
}
mapReplaceMy
.
put
(
"#{projectName}"
,
entrust
.
getProjectName
());
mapReplaceMy
.
put
(
"#{client}"
,
entrust
.
getClient
());
mapReplaceMy
.
put
(
"#{boreholeName}"
,
entrust
.
getBoreholeName
());
mapReplaceMy
.
put
(
"#{projectNo}"
,
entrust
.
getProjectNo
());
for
(
int
j
=
0
;
j
<
firstSize
;
j
++)
{
SoilExperimentVO
vo
=
firstList
.
get
(
j
);
mapReplaceMy
.
put
(
"#{sampleCode"
+
j
+
"}"
,
StringHandleUtils
.
getString
(
vo
.
getSampleCode
()));
mapReplaceMy
.
put
(
"#{sampleDepth"
+
j
+
"}"
,
StringHandleUtils
.
getString
(
vo
.
getSampleDepth
()));
mapReplaceMy
.
put
(
"#{siteNo"
+
j
+
"}"
,
StringHandleUtils
.
getString
(
vo
.
getSiteNo
()));
List
<
SoilItemVO
>
itemVOList
=
sampleSoilItemVOMap
.
get
(
vo
.
getSampleId
());
if
(
CollectionUtils
.
isNotEmpty
(
itemVOList
)){
for
(
SoilItemVO
itemVO:
itemVOList
)
{
mapReplaceMy
.
put
(
"#{"
+
itemVO
.
getName
()+
"}"
,
itemVO
.
getTestValue
());
}
}
else
{
continue
;
}
if
(!
mapReplaceMy
.
containsKey
(
"#{含水率}"
)){
mapReplaceMy
.
put
(
"#{含水率}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{液限}"
)){
mapReplaceMy
.
put
(
"#{液限}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{塑限}"
)){
mapReplaceMy
.
put
(
"#{塑限}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{比重}"
)){
mapReplaceMy
.
put
(
"#{比重}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{密度}"
)){
mapReplaceMy
.
put
(
"#{密度}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{含水率}"
)){
mapReplaceMy
.
put
(
"#{含水率"
+
j
+
"}"
,
""
);
}
else
{
mapReplaceMy
.
put
(
"#{含水率"
+
j
+
"}"
,
mapReplaceMy
.
get
(
"#{含水率}"
));
}
if
(!
mapReplaceMy
.
containsKey
(
"#{密度}"
)){
mapReplaceMy
.
put
(
"#{密度}"
,
""
);
mapReplaceMy
.
put
(
"#{密度9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{密度"
+
j
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{密度9.81"
+
j
+
"}"
,
""
);
}
else
{
String
rongzhong
=
mapReplaceMy
.
get
(
"#{密度}"
);
if
(
StringUtils
.
isBlank
(
rongzhong
)){
mapReplaceMy
.
put
(
"#{密度9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{密度9.81"
+
j
+
"}"
,
""
);
}
else
{
if
(
StringHandleUtils
.
validateNumber
(
rongzhong
)){
BigDecimal
rong
=
new
BigDecimal
(
rongzhong
);
BigDecimal
chengshu
=
new
BigDecimal
(
"9.81"
);
BigDecimal
ji
=
rong
.
multiply
(
chengshu
);
mapReplaceMy
.
put
(
"#{密度9.81}"
,
ji
.
toString
());
mapReplaceMy
.
put
(
"#{密度9.81"
+
j
+
"}"
,
ji
.
toString
());
}
else
{
mapReplaceMy
.
put
(
"#{密度9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{密度9.81"
+
j
+
"}"
,
""
);
}
}
}
if
(!
mapReplaceMy
.
containsKey
(
"#{容重}"
)){
mapReplaceMy
.
put
(
"#{容重}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{容重"
+
j
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81"
+
j
+
"}"
,
""
);
}
else
{
String
rongzhong
=
mapReplace
.
get
(
"#{容重}"
);
if
(
StringUtils
.
isBlank
(
rongzhong
)){
mapReplaceMy
.
put
(
"#{容重9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81"
+
j
+
"}"
,
""
);
}
else
{
if
(
StringHandleUtils
.
validateNumber
(
rongzhong
)){
BigDecimal
rong
=
new
BigDecimal
(
rongzhong
);
BigDecimal
chengshu
=
new
BigDecimal
(
"9.81"
);
BigDecimal
ji
=
rong
.
multiply
(
chengshu
);
mapReplaceMy
.
put
(
"#{容重9.81}"
,
ji
.
toString
());
mapReplaceMy
.
put
(
"#{容重9.81"
+
j
+
"}"
,
ji
.
toString
());
}
else
{
mapReplaceMy
.
put
(
"#{容重9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81"
+
j
+
"}"
,
""
);
}
}
}
}
HSSFWorkbookUtil
.
replaceModel
(
mapReplaceMy
,
xssfWorkbook
,
sheetMy
);
}
}
src/main/java/com/patzn/cloud/service/lims/original/SingleLessOperation.java
0 → 100644
View file @
b2ee5275
package
com
.
patzn
.
cloud
.
service
.
lims
.
original
;
import
com.patzn.cloud.service.lims.common.HSSFWorkbookUtil
;
import
com.patzn.cloud.service.lims.common.StringHandleUtils
;
import
com.patzn.cloud.service.soil.entity.SoilOriginalTemplate
;
import
com.patzn.cloud.service.soil.entity.SoilOriginalTemplateConfig
;
import
com.patzn.cloud.service.soil.vo.SoilExperimentVO
;
import
com.patzn.cloud.service.soil.vo.SoilItemVO
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.xssf.usermodel.*
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.InputStream
;
import
java.util.List
;
import
java.util.Map
;
public
class
SingleLessOperation
implements
Operation
{
private
XSSFWorkbook
xssfWorkbook
;
private
InputStream
io
;
private
Map
<
String
,
String
>
mapReplace
;
private
List
<
SoilOriginalTemplateConfig
>
configList
;
private
SoilOriginalTemplate
template
;
private
List
<
SoilExperimentVO
>
voList
;
private
Map
<
Long
,
List
<
SoilItemVO
>>
sampleSoilItemVOMap
;
protected
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SingleLessOperation
.
class
);
public
SingleLessOperation
(
XSSFWorkbook
xssfWorkbook
,
InputStream
io
,
Map
<
String
,
String
>
mapReplace
,
List
<
SoilOriginalTemplateConfig
>
configList
,
SoilOriginalTemplate
template
,
List
<
SoilExperimentVO
>
voList
,
Map
<
Long
,
List
<
SoilItemVO
>>
sampleSoilItemVOMap
)
{
this
.
xssfWorkbook
=
xssfWorkbook
;
this
.
io
=
io
;
this
.
mapReplace
=
mapReplace
;
this
.
configList
=
configList
;
this
.
template
=
template
;
this
.
voList
=
voList
;
this
.
sampleSoilItemVOMap
=
sampleSoilItemVOMap
;
}
public
void
doProductOriginal
(){
HSSFWorkbookUtil
.
replaceModel
(
mapReplace
,
xssfWorkbook
,
0
);
XSSFSheet
sheetOne
=
xssfWorkbook
.
getSheetAt
(
0
);
sheetOne
.
setForceFormulaRecalculation
(
true
);
Integer
beginRow
=
template
.
getSampleBeginRow
();
if
(
null
==
beginRow
){
return
;
}
if
(
null
==
template
.
getSampleMergerNum
()){
return
;
}
if
(
null
==
template
.
getTemplateSampleNum
()){
return
;
}
int
templateSampleNum
=
template
.
getTemplateSampleNum
();
//样品数量小于模板里面的样品数量
int
sampleMergerNum
=
template
.
getSampleMergerNum
();
for
(
SoilExperimentVO
vo:
voList
)
{
List
<
SoilItemVO
>
soilItemVOS
=
sampleSoilItemVOMap
.
get
(
vo
.
getSampleId
());
XSSFRow
xssfRow
=
sheetOne
.
getRow
(
beginRow
);
for
(
SoilOriginalTemplateConfig
config:
configList
)
{
if
(
null
==
config
.
getColumnPlace
()){
continue
;
}
XSSFCell
cell
=
xssfRow
.
getCell
(
config
.
getColumnPlace
());
if
(
"sn"
.
equals
(
config
.
getDataAttribute
())){
continue
;
}
if
(
StringUtils
.
isNotBlank
(
config
.
getDataAttribute
())&&
config
.
getDataAttribute
().
contains
(
"for"
)){
String
name
=
config
.
getDataAttribute
().
replace
(
"for"
,
""
);
OriginalUtil
.
doForValue
(
sampleMergerNum
,
sheetOne
,
beginRow
,
config
,
name
,
soilItemVOS
);
continue
;
}
cell
.
setCellValue
(
HSSFWorkbookUtil
.
getFieldValue
(
config
.
getDataAttribute
(),
vo
,
soilItemVOS
));
}
beginRow
+=
sampleMergerNum
;
}
for
(
SoilOriginalTemplateConfig
config:
configList
)
{
if
(
null
==
config
.
getMergeRowNum
()){
config
.
setMergeRowNum
(
1
);
}
if
(
OriginalUtil
.
skipDoExcel
(
config
)){
continue
;
}
Integer
sampleBgMum
=
template
.
getSampleBeginRow
();
Integer
mergeRowNum
=
config
.
getMergeRowNum
();
int
formulaNum
=
template
.
getSampleBeginRow
()+
sampleMergerNum
*
templateSampleNum
-
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
();
formula
=
formula
.
replace
(
"#{sn}"
,(
i
+
1
)+
""
);
if
(
formula
.
contains
(
"#{sneven1}"
)){
if
(
StringHandleUtils
.
isEven
(
i
)){
formula
=
formula
.
replace
(
"#{sneven1}"
,(
i
+
1
)+
""
);
}
else
{
formula
=
formula
.
replace
(
"#{sneven1}"
,
i
+
""
);
}
}
if
(
formula
.
contains
(
"#{snodd1}"
)){
if
(!
StringHandleUtils
.
isEven
(
i
)){
formula
=
formula
.
replace
(
"#{snodd1}"
,(
i
+
1
)+
""
);
}
else
{
formula
=
formula
.
replace
(
"#{snodd1}"
,
i
+
""
);
}
}
if
(
formula
.
contains
(
"#{sn+1}"
)){
formula
=
formula
.
replace
(
"#{sn+1}"
,(
i
+
2
)+
""
);
}
if
(
formula
.
contains
(
"#{sn+2}"
)){
formula
=
formula
.
replace
(
"#{sn+2}"
,(
i
+
3
)+
""
);
}
if
(
formula
.
contains
(
"#{sn+3}"
)){
formula
=
formula
.
replace
(
"#{sn+3}"
,(
i
+
4
)+
""
);
}
if
(
formula
.
contains
(
"#{sn+4}"
)){
formula
=
formula
.
replace
(
"#{sn+4}"
,(
i
+
5
)+
""
);
}
if
(
formula
.
contains
(
"#{sn+5}"
)){
formula
=
formula
.
replace
(
"#{sn+5}"
,(
i
+
6
)+
""
);
}
if
(
formula
.
contains
(
"#{sn+6}"
)){
formula
=
formula
.
replace
(
"#{sn+6}"
,(
i
+
7
)+
""
);
}
if
(
formula
.
contains
(
"#{sn+7}"
)){
formula
=
formula
.
replace
(
"#{sn+7}"
,(
i
+
8
)+
""
);
}
cell
.
setCellFormula
(
formula
);
}
}
logger
.
error
(
"----------------------7"
);
}
}
src/main/java/com/patzn/cloud/service/lims/soil/service/impl/SoilExperimentServiceImpl.java
View file @
b2ee5275
...
...
@@ -29,6 +29,9 @@ import com.patzn.cloud.service.lims.common.service.IExportService;
import
com.patzn.cloud.service.lims.common.service.ILmsMsgService
;
import
com.patzn.cloud.service.lims.gideon.utils.ApachePoiLineChart4
;
import
com.patzn.cloud.service.lims.gideon.utils.DrawXlsxUtil
;
import
com.patzn.cloud.service.lims.original.InitMapReplace
;
import
com.patzn.cloud.service.lims.original.Operation
;
import
com.patzn.cloud.service.lims.original.OriginalOperationFactory
;
import
com.patzn.cloud.service.lims.soil.service.*
;
import
com.patzn.cloud.service.soil.dto.SoilExperimentQueryDTO
;
import
com.patzn.cloud.service.soil.entity.*
;
...
...
@@ -303,979 +306,52 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
SoilOriginalRecord
saveExcelOriginalRecord
(
Long
[]
ids
,
Long
templateId
,
Account
account
)
{
logger
.
error
(
"saveExcelOriginalRecord开始生成"
);
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择试验项目!"
);
RestAssert
.
fail
(
null
==
templateId
,
"请选择原始记录模板"
);
logger
.
error
(
"saveExcelOriginalRecord开始生成"
);
RestAssert
.
fail
(
ArrayUtils
.
isEmpty
(
ids
),
"请选择试验项目!"
);
RestAssert
.
fail
(
null
==
templateId
,
"请选择原始记录模板"
);
SoilOriginalTemplate
template
=
soilOriginalTemplateService
.
getById
(
templateId
);
if
(
null
==
template
){
logger
.
error
(
"----------------------0"
);
RestAssert
.
fail
(
"模板不存在"
);
}
logger
.
error
(
"saveExcelOriginalRecord模板存在"
);
List
<
SoilExperimentVO
>
voList
=
soilExperimentService
.
listVOByIds
(
ids
);
for
(
SoilExperimentVO
vo:
voList
)
{
if
(
vo
.
getName
().
contains
(
"重塑"
)){
vo
.
setMorphology
(
"重塑"
);
}
else
{
vo
.
setMorphology
(
"原状"
);
}
}
boolean
teShu
=
"界限含水率 (碟式液限仪多点法)试验记录表"
.
equals
(
template
.
getName
());
if
(
CollectionUtils
.
isEmpty
(
voList
)){
logger
.
error
(
"----------------------1"
);
return
null
;
}
List
<
Long
>
sampleIdList
=
voList
.
stream
().
map
(
s
->{
return
s
.
getSampleId
();
}).
collect
(
Collectors
.
toList
());
List
<
SoilItemVO
>
soilItemVOList
=
soilItemService
.
listVOByExpSampleIds
(
sampleIdList
);
Map
<
Long
,
List
<
SoilItemVO
>>
sampleSoilItemVOMap
=
new
HashMap
<>();
for
(
SoilItemVO
soilItemVO:
soilItemVOList
)
{
if
(
sampleSoilItemVOMap
.
containsKey
(
soilItemVO
.
getSampleId
())){
List
<
SoilItemVO
>
sampleItems
=
sampleSoilItemVOMap
.
get
(
soilItemVO
.
getSampleId
());
sampleItems
.
add
(
soilItemVO
);
sampleSoilItemVOMap
.
put
(
soilItemVO
.
getSampleId
(),
sampleItems
);
}
else
{
List
<
SoilItemVO
>
sampleItems
=
new
ArrayList
<>();
sampleItems
.
add
(
soilItemVO
);
sampleSoilItemVOMap
.
put
(
soilItemVO
.
getSampleId
(),
sampleItems
);
}
}
SoilEntrust
entrust
=
soilEntrustService
.
getById
(
voList
.
get
(
0
).
getEntrustId
());
logger
.
error
(
"saveExcelOriginalRecord entrust"
);
InputStream
io
=
ossClient
.
download
(
template
.
getObjectKey
());
if
(
null
==
io
){
logger
.
error
(
"----------------------2"
);
RestAssert
.
fail
(
"模板不存在"
);
}
logger
.
error
(
" InputStream io 存在"
);
SoilOriginalRecord
objectKey
=
null
;
XSSFWorkbook
xssfWorkbook
=
null
;
try
{
xssfWorkbook
=
new
XSSFWorkbook
(
io
);
}
catch
(
Exception
e
){
logger
.
error
(
"获取证书模板错误"
+
e
.
getMessage
());
e
.
printStackTrace
();
}
Map
<
String
,
String
>
mapReplace
=
new
HashMap
<>();
mapReplace
.
put
(
"#{projectName}"
,
entrust
.
getProjectName
());
mapReplace
.
put
(
"#{client}"
,
entrust
.
getClient
());
mapReplace
.
put
(
"#{boreholeName}"
,
entrust
.
getBoreholeName
());
mapReplace
.
put
(
"#{projectNo}"
,
entrust
.
getProjectNo
());
if
(
null
==
entrust
.
getWaterDepth
()){
mapReplace
.
put
(
"#{waterDepth}"
,
""
);
}
else
{
mapReplace
.
put
(
"#{waterDepth}"
,
entrust
.
getWaterDepth
().
toString
());
}
mapReplace
.
put
(
"#{reportCode}"
,
entrust
.
getEntrustCode
());
List
<
SoilOriginalTemplateConfig
>
configList
=
soilOriginalTemplateConfigService
.
list
(
Condition
.
create
().
eq
(
"template_id"
,
templateId
));
boolean
attachJIeXianWater
=
"界限含水率 (碟式液限仪多点法)试验记录表1212"
.
equals
(
template
.
getName
());
if
(
null
==
template
.
getMoreSheet
()
||
0
==
template
.
getMoreSheet
()){
logger
.
error
(
"----------------------3"
);
HSSFWorkbookUtil
.
replaceModel
(
mapReplace
,
xssfWorkbook
,
0
);
logger
.
error
(
"----------------------4"
);
XSSFSheet
sheetOne
=
xssfWorkbook
.
getSheetAt
(
0
);
sheetOne
.
setForceFormulaRecalculation
(
true
);
logger
.
error
(
"----------------------5"
);
Integer
beginRow
=
template
.
getSampleBeginRow
();
if
(
null
!=
beginRow
&&
null
!=
template
.
getSampleMergerNum
()
&&
null
!=
template
.
getTemplateSampleNum
()){
int
templateSampleNum
=
template
.
getTemplateSampleNum
();
if
(
voList
.
size
()<
templateSampleNum
){
int
sampleMergerNum
=
template
.
getSampleMergerNum
();
int
xBegin1
=
9
;
int
xBegin2
=
10
;
int
xBegin3
=
11
;
int
xStep
=
5
;
for
(
SoilExperimentVO
vo:
voList
)
{
List
<
SoilItemVO
>
soilItemVOS
=
sampleSoilItemVOMap
.
get
(
vo
.
getSampleId
());
XSSFRow
xssfRow
=
sheetOne
.
getRow
(
beginRow
);
for
(
SoilOriginalTemplateConfig
config:
configList
)
{
if
(
null
==
config
.
getColumnPlace
()){
continue
;
}
XSSFCell
cell
=
xssfRow
.
getCell
(
config
.
getColumnPlace
());
if
(
"sn"
.
equals
(
config
.
getDataAttribute
())){
continue
;
}
if
(
null
!=
config
.
getDataAttribute
()&&
config
.
getDataAttribute
().
contains
(
"for"
)){
String
name
=
config
.
getDataAttribute
().
replace
(
"for"
,
""
);
for
(
int
i
=
0
;
i
<
sampleMergerNum
;
i
++)
{
XSSFRow
zhuiRow
=
sheetOne
.
getRow
(
beginRow
+
i
);
if
(
null
!=
zhuiRow
){
XSSFCell
cellZhui
=
zhuiRow
.
getCell
(
config
.
getColumnPlace
());
if
(
null
!=
cellZhui
){
for
(
SoilItemVO
itemVO:
soilItemVOS
)
{
if
((
name
+(
i
+
1
)).
equals
(
itemVO
.
getName
())){
cellZhui
.
setCellValue
(
itemVO
.
getTestValue
());
break
;
}
}
}
}
}
continue
;
}
cell
.
setCellValue
(
getFieldValue
(
config
.
getDataAttribute
(),
vo
,
soilItemVOS
));
}
beginRow
+=
sampleMergerNum
;
if
(
attachJIeXianWater
){
XSSFSheet
sheet
=
xssfWorkbook
.
createSheet
(
"附录"
+
vo
.
getSampleCode
());
XSSFCellStyle
style
=
xssfWorkbook
.
createCellStyle
();
style
.
setBorderBottom
(
BorderStyle
.
THIN
);
style
.
setBorderLeft
(
BorderStyle
.
THIN
);
style
.
setBorderRight
(
BorderStyle
.
THIN
);
style
.
setBorderTop
(
BorderStyle
.
THIN
);
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
XSSFRow
row
=
sheet
.
createRow
(
i
);
for
(
int
j
=
0
;
j
<
2
;
j
++)
{
XSSFCell
cell
=
row
.
createCell
(
j
);
cell
.
setCellStyle
(
style
);
}
}
int
row2Num
=
6
;
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
XSSFRow
row
=
sheet
.
createRow
(
row2Num
+
i
);
for
(
int
j
=
0
;
j
<
2
;
j
++)
{
XSSFCell
cell
=
row
.
createCell
(
j
);
cell
.
setCellStyle
(
style
);
}
}
int
row3Num
=
10
;
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
XSSFRow
row
=
sheet
.
createRow
(
row3Num
+
i
);
for
(
int
j
=
0
;
j
<
2
;
j
++)
{
XSSFCell
cell
=
row
.
createCell
(
j
);
cell
.
setCellStyle
(
style
);
}
}
XSSFCell
cell00
=
sheet
.
getRow
(
0
).
getCell
(
0
);
XSSFFont
font
=
new
XSSFFont
();
font
.
setFontName
(
"黑体"
);
style
.
setFont
(
font
);
cell00
.
setCellStyle
(
style
);
cell00
.
setCellValue
(
"样品编号:"
);
XSSFCell
cell01
=
sheet
.
getRow
(
0
).
getCell
(
1
);
cell01
.
setCellValue
(
vo
.
getSampleCode
());
XSSFCell
cell10
=
sheet
.
getRow
(
1
).
getCell
(
0
);
cell10
.
setCellStyle
(
style
);
cell10
.
setCellValue
(
"对数x轴"
);
XSSFCell
cell11
=
sheet
.
getRow
(
1
).
getCell
(
1
);
cell11
.
setCellStyle
(
style
);
cell11
.
setCellValue
(
"y轴"
);
XSSFCell
cell20
=
sheet
.
getRow
(
2
).
getCell
(
0
);
cell20
.
setCellFormula
(
"'界限含水率 (碟式液限仪多点法)'!D"
+
xBegin1
+
""
);
XSSFCell
cell30
=
sheet
.
getRow
(
3
).
getCell
(
0
);
cell30
.
setCellFormula
(
"'界限含水率 (碟式液限仪多点法)'!D"
+
xBegin2
+
""
);
XSSFCell
cell40
=
sheet
.
getRow
(
4
).
getCell
(
0
);
cell40
.
setCellFormula
(
"'界限含水率 (碟式液限仪多点法)'!D"
+
xBegin3
+
""
);
XSSFCell
cell21
=
sheet
.
getRow
(
2
).
getCell
(
1
);
cell21
.
setCellFormula
(
"'界限含水率 (碟式液限仪多点法)'!J"
+
xBegin1
+
""
);
XSSFCell
cell31
=
sheet
.
getRow
(
3
).
getCell
(
1
);
cell31
.
setCellFormula
(
"'界限含水率 (碟式液限仪多点法)'!J"
+
xBegin2
+
""
);
XSSFCell
cell41
=
sheet
.
getRow
(
4
).
getCell
(
1
);
cell41
.
setCellFormula
(
"'界限含水率 (碟式液限仪多点法)'!J"
+
xBegin3
+
""
);
XSSFCell
cell60
=
sheet
.
getRow
(
6
).
getCell
(
0
);
cell60
.
setCellValue
(
"备注:y=kx+b"
);
XSSFCell
cell70
=
sheet
.
getRow
(
7
).
getCell
(
0
);
cell70
.
setCellValue
(
"k:"
);
XSSFCell
cell80
=
sheet
.
getRow
(
8
).
getCell
(
0
);
cell80
.
setCellValue
(
"b:"
);
XSSFCell
cell71
=
sheet
.
getRow
(
7
).
getCell
(
1
);
cell71
.
setCellFormula
(
"INDEX(LINEST(B3:B5,A3:A5,1,0),1,1)"
);
XSSFCell
cell81
=
sheet
.
getRow
(
8
).
getCell
(
1
);
cell81
.
setCellFormula
(
"INDEX(LINEST(B3:B5,A3:A5,1,0),1,2)"
);
XSSFCell
cell100
=
sheet
.
getRow
(
10
).
getCell
(
0
);
cell100
.
setCellValue
(
"液限(%) Liquid Limit"
);
XSSFCell
cell101
=
sheet
.
getRow
(
10
).
getCell
(
1
);
cell101
.
setCellFormula
(
"(B8*LOG10(25)+B9)"
);
GenerateChart
(
sheet
,
"'界限含水率 (碟式液限仪多点法)'!$D$"
+
xBegin1
+
":"
+
"$D$"
+
xBegin3
,
"'界限含水率 (碟式液限仪多点法)'!$J$"
+
xBegin1
+
":$J$"
+
xBegin3
);
xBegin1
+=
xStep
;
xBegin2
+=
xStep
;
xBegin3
+=
xStep
;
}
}
for
(
SoilOriginalTemplateConfig
config:
configList
)
{
if
(
null
==
config
.
getMergeRowNum
()){
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
*
templateSampleNum
-
1
;
for
(
int
i
=
sampleBgMum
;
i
<=
formulaNum
;
i
+=
mergeRowNum
)
{
XSSFRow
row
=
sheetOne
.
getRow
(
i
);
XSSFCell
cell
=
row
.
getCell
(
config
.
getColumnPlace
());
String
formula
=
config
.
getFormula
();
formula
=
formula
.
replace
(
"#{sn}"
,(
i
+
1
)+
""
);
if
(
formula
.
contains
(
"#{sneven1}"
)){
if
(
StringHandleUtils
.
isEven
(
i
)){
formula
=
formula
.
replace
(
"#{sneven1}"
,(
i
+
1
)+
""
);
}
else
{
formula
=
formula
.
replace
(
"#{sneven1}"
,
i
+
""
);
}
}
if
(
formula
.
contains
(
"#{snodd1}"
)){
if
(!
StringHandleUtils
.
isEven
(
i
)){
formula
=
formula
.
replace
(
"#{snodd1}"
,(
i
+
1
)+
""
);
}
else
{
formula
=
formula
.
replace
(
"#{snodd1}"
,
i
+
""
);
}
}
if
(
formula
.
contains
(
"#{sn+1}"
)){
formula
=
formula
.
replace
(
"#{sn+1}"
,(
i
+
2
)+
""
);
}
if
(
formula
.
contains
(
"#{sn+2}"
)){
formula
=
formula
.
replace
(
"#{sn+2}"
,(
i
+
3
)+
""
);
}
if
(
formula
.
contains
(
"#{sn+3}"
)){
formula
=
formula
.
replace
(
"#{sn+3}"
,(
i
+
4
)+
""
);
}
if
(
formula
.
contains
(
"#{sn+4}"
)){
formula
=
formula
.
replace
(
"#{sn+4}"
,(
i
+
5
)+
""
);
}
if
(
formula
.
contains
(
"#{sn+5}"
)){
formula
=
formula
.
replace
(
"#{sn+5}"
,(
i
+
6
)+
""
);
}
if
(
formula
.
contains
(
"#{sn+6}"
)){
formula
=
formula
.
replace
(
"#{sn+6}"
,(
i
+
7
)+
""
);
}
if
(
formula
.
contains
(
"#{sn+7}"
)){
formula
=
formula
.
replace
(
"#{sn+7}"
,(
i
+
8
)+
""
);
}
cell
.
setCellFormula
(
formula
);
}
}
}
logger
.
error
(
"----------------------7"
);
if
(
attachJIeXianWater
){
int
length
=
voList
.
size
();
int
begin
=
8
;
int
step
=
5
;
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
XSSFCell
xssfCell
=
sheetOne
.
getRow
(
begin
).
getCell
(
10
);
xssfCell
.
setCellFormula
(
"'附录"
+
voList
.
get
(
i
).
getSampleCode
()+
"'!B11"
);
begin
+=
step
;
}
}
}
else
{
logger
.
error
(
"----------------------8"
);
int
sampleMergerNum
=
template
.
getSampleMergerNum
();
int
insertRow
=
beginRow
+
sampleMergerNum
*
templateSampleNum
;
logger
.
error
(
"---------------------9"
);
XSSFRow
zeroRow
=
sheetOne
.
getRow
(
beginRow
);
logger
.
error
(
"----------------------10"
);
int
lastCellNum
=
zeroRow
.
getLastCellNum
();
int
insertCount
=
voList
.
size
()-
templateSampleNum
;
for
(
int
m
=
0
;
m
<
insertCount
;
m
++)
{
for
(
int
i
=
0
;
i
<
sampleMergerNum
;
i
++)
{
XSSFRow
row
=
sheetOne
.
createRow
(
insertRow
);
row
.
setHeight
(
zeroRow
.
getHeight
());
for
(
int
j
=
0
;
j
<
lastCellNum
;
j
++)
{
XSSFCellStyle
cellStyle
=
zeroRow
.
getCell
(
j
).
getCellStyle
();
XSSFCell
xssfCell
=
row
.
createCell
(
j
);
xssfCell
.
setCellStyle
(
cellStyle
);
}
insertRow
++;
}
}
int
sn
=
1
;
Map
<
String
,
String
>
siteNoSampleCodeMap
=
new
HashMap
<>();
for
(
SoilExperimentVO
vo:
voList
){
siteNoSampleCodeMap
.
put
(
vo
.
getSiteNo
(),
vo
.
getSampleCode
());
}
for
(
SoilExperimentVO
vo:
voList
)
{
List
<
SoilItemVO
>
soilItemVOS
=
sampleSoilItemVOMap
.
get
(
vo
.
getSampleId
());
XSSFRow
xssfRow
=
sheetOne
.
getRow
(
beginRow
);
for
(
SoilOriginalTemplateConfig
config:
configList
)
{
if
(
null
==
config
.
getColumnPlace
()){
continue
;
}
XSSFCell
cell
=
xssfRow
.
getCell
(
config
.
getColumnPlace
());
if
(
null
!=
config
.
getDataAttribute
()&&
config
.
getDataAttribute
().
contains
(
"for"
)){
String
name
=
config
.
getDataAttribute
().
replace
(
"for"
,
""
);
for
(
int
i
=
0
;
i
<
sampleMergerNum
;
i
++)
{
XSSFRow
zhuiRow
=
sheetOne
.
getRow
(
beginRow
+
i
);
if
(
null
!=
zhuiRow
){
XSSFCell
cellZhui
=
zhuiRow
.
getCell
(
config
.
getColumnPlace
());
if
(
null
!=
cellZhui
){
for
(
SoilItemVO
itemVO:
soilItemVOS
)
{
if
((
name
+(
i
+
1
)).
equals
(
itemVO
.
getName
())){
cellZhui
.
setCellValue
(
itemVO
.
getTestValue
());
break
;
}
}
}
}
}
continue
;
}
if
(
"sn"
.
equals
(
config
.
getDataAttribute
())){
cell
.
setCellValue
(
sn
);
}
else
{
cell
.
setCellValue
(
getFieldValue
(
config
.
getDataAttribute
(),
vo
,
soilItemVOS
));
}
}
beginRow
+=
sampleMergerNum
;
sn
++;
}
for
(
SoilOriginalTemplateConfig
config:
configList
)
{
if
(
null
==
config
.
getMergeRowNum
()){
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
();
formula
=
formula
.
replace
(
"#{sn}"
,(
i
+
1
)+
""
);
if
(
formula
.
contains
(
"#{sneven1}"
)){
if
(
StringHandleUtils
.
isEven
(
i
)){
formula
=
formula
.
replace
(
"#{sneven1}"
,(
i
+
1
)+
""
);
}
else
{
formula
=
formula
.
replace
(
"#{sneven1}"
,
i
+
""
);
}
}
if
(
formula
.
contains
(
"#{snodd1}"
)){
if
(!
StringHandleUtils
.
isEven
(
i
)){
formula
=
formula
.
replace
(
"#{snodd1}"
,(
i
+
1
)+
""
);
}
else
{
formula
=
formula
.
replace
(
"#{snodd1}"
,
i
+
""
);
}
}
if
(
formula
.
contains
(
"#{sn+1}"
)){
formula
=
formula
.
replace
(
"#{sn+1}"
,(
i
+
2
)+
""
);
}
if
(
formula
.
contains
(
"#{sn+2}"
)){
formula
=
formula
.
replace
(
"#{sn+2}"
,(
i
+
3
)+
""
);
}
if
(
formula
.
contains
(
"#{sn+3}"
)){
formula
=
formula
.
replace
(
"#{sn+3}"
,(
i
+
4
)+
""
);
}
if
(
formula
.
contains
(
"#{sn+4}"
)){
formula
=
formula
.
replace
(
"#{sn+4}"
,(
i
+
5
)+
""
);
}
if
(
formula
.
contains
(
"#{sn+5}"
)){
formula
=
formula
.
replace
(
"#{sn+5}"
,(
i
+
6
)+
""
);
}
if
(
formula
.
contains
(
"#{sn+6}"
)){
formula
=
formula
.
replace
(
"#{sn+6}"
,(
i
+
7
)+
""
);
}
if
(
formula
.
contains
(
"#{sn+7}"
)){
formula
=
formula
.
replace
(
"#{sn+7}"
,(
i
+
8
)+
""
);
}
cell
.
setCellFormula
(
formula
);
}
}
}
for
(
SoilOriginalTemplateConfig
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
()){
if
(!
teShu
){
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
;
}
}
else
{
if
(
config
.
getColumnPlace
()
!=
10
&&
config
.
getColumnPlace
()
!=
12
){
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
;
}
}
else
{
Integer
sampleBgMum
=
template
.
getSampleBeginRow
()+
templateSampleNum
*
sampleMergerNum
;
Integer
sampleEnMum
=
template
.
getSampleBeginRow
()+
voList
.
size
()*
sampleMergerNum
-
1
;
int
indexJishu
=
0
;
while
(
sampleBgMum
<=
sampleEnMum
)
{
if
(
indexJishu
%
2
==
0
){
sheetOne
.
addMergedRegion
(
new
CellRangeAddress
(
sampleBgMum
,
sampleBgMum
+
3
-
1
,
config
.
getMergeBegin
(),
config
.
getMergeEnd
()));
if
(
config
.
getColumnPlace
()==
10
){
XSSFRow
teshuRow
=
sheetOne
.
getRow
(
sampleBgMum
);
if
(
null
!=
teshuRow
){
XSSFCell
teshuCell
=
teshuRow
.
getCell
(
config
.
getColumnPlace
());
XSSFCell
teshuCellSampleCode
=
teshuRow
.
getCell
(
1
);
String
code
=
HSSFWorkbookUtil
.
getJavaValue
(
teshuCellSampleCode
).
toString
();
String
mapCode
=
siteNoSampleCodeMap
.
get
(
code
);
if
(
StringUtils
.
isNotBlank
(
mapCode
)){
teshuCell
.
setCellFormula
(
"'附录"
+
mapCode
+
"'!B11"
);
}
else
{
teshuCell
.
setCellFormula
(
"'附录"
+
code
+
"'!B11"
);
}
}
}
sampleBgMum
=
sampleBgMum
+
3
;
}
else
{
sheetOne
.
addMergedRegion
(
new
CellRangeAddress
(
sampleBgMum
,
sampleBgMum
+
2
-
1
,
config
.
getMergeBegin
(),
config
.
getMergeEnd
()));
if
(
config
.
getColumnPlace
()==
10
){
XSSFRow
teshuRow
=
sheetOne
.
getRow
(
sampleBgMum
);
if
(
null
!=
teshuRow
){
XSSFCell
teshuCell
=
teshuRow
.
getCell
(
config
.
getColumnPlace
());
teshuCell
.
setCellFormula
(
"IF(OR(J"
+(
sampleBgMum
+
1
)+
"=\"\",J"
+(
sampleBgMum
+
2
)+
"=\"\",J"
+(
sampleBgMum
+
1
)+
"=\"/\",J"
+(
sampleBgMum
+
2
)+
"=\"/\"),\"\",(J"
+(
sampleBgMum
+
1
)+
"+J"
+((
sampleBgMum
+
2
))+
")/2)"
);
}
}
sampleBgMum
=
sampleBgMum
+
2
;
}
indexJishu
++;
}
}
}
}
}
}
}
}
else
{
Integer
templateSampleNum
=
template
.
getTemplateSampleNum
();
if
(
null
==
templateSampleNum
||
1
==
templateSampleNum
){
XSSFSheet
xssfSheet
=
xssfWorkbook
.
getSheetAt
(
0
);
xssfSheet
.
setForceFormulaRecalculation
(
true
);
int
index
=
0
;
SoilExperimentVO
firstVO
=
null
;
int
sheetNum
=
xssfWorkbook
.
getNumberOfSheets
();
boolean
keliJIa
=
"颗粒分析实验(甲种)"
.
equals
(
template
.
getName
())
||
"颗粒分析实验(乙种)"
.
equals
(
template
.
getName
());
boolean
keliAstm
=
"颗粒分析实验(ASTM)"
.
equals
(
template
.
getName
())
;
if
(
keliJIa
){
//='颗粒分析试验(密度计法)'!$S$3:$T$22
// GenerateChartKeli(xssfSheet,"'"+xssfSheet.getSheetName()+"'!$S$"+3+":"+"$S$"+22,"'"+xssfSheet.getSheetName()+"'!$T$"+3+":$T$"+22);
DrawXlsxUtil
.
AnchorPosition
position
=
new
DrawXlsxUtil
.
AnchorPosition
(
21
,
2
,
28
,
8
,
"颗粒大小分布曲线"
,
"颗粒大小(mm)"
,
"小于某直径之百分数(%)"
);
ApachePoiLineChart4
.
productZhexian
(
xssfSheet
,
position
);
}
if
(
keliAstm
){
DrawXlsxUtil
.
AnchorPosition
position
=
new
DrawXlsxUtil
.
AnchorPosition
(
21
,
2
,
28
,
8
,
"颗粒大小分布曲线"
,
"颗粒大小(mm)"
,
"小于某直径之百分数(%)"
);
ApachePoiLineChart4
.
productZhexianAstm
(
xssfSheet
,
position
);
}
for
(
SoilExperimentVO
vo:
voList
)
{
if
(
index
==
0
){
index
++;
firstVO
=
vo
;
continue
;
}
XSSFSheet
sheet
=
xssfWorkbook
.
cloneSheet
(
0
);
if
(
keliJIa
){
DrawXlsxUtil
.
AnchorPosition
position
=
new
DrawXlsxUtil
.
AnchorPosition
(
21
,
2
,
28
,
8
,
"颗粒大小分布曲线"
,
"颗粒大小(mm)"
,
"小于某直径之百分数(%)"
);
ApachePoiLineChart4
.
productZhexian
(
sheet
,
position
);
}
if
(
keliAstm
){
DrawXlsxUtil
.
AnchorPosition
position
=
new
DrawXlsxUtil
.
AnchorPosition
(
21
,
2
,
28
,
8
,
"颗粒大小分布曲线"
,
"颗粒大小(mm)"
,
"小于某直径之百分数(%)"
);
ApachePoiLineChart4
.
productZhexianAstm
(
xssfSheet
,
position
);
}
index
++;
}
int
nextSample
=
sheetNum
;
boolean
start
=
true
;
for
(
SoilExperimentVO
vo:
voList
)
{
if
(
start
){
start
=
false
;
continue
;
}
XSSFSheet
sheet
=
xssfWorkbook
.
getSheetAt
(
nextSample
);
xssfWorkbook
.
setSheetName
(
nextSample
,
vo
.
getSampleCode
());
List
<
SoilItemVO
>
itemVOList
=
sampleSoilItemVOMap
.
get
(
vo
.
getSampleId
());
if
(
CollectionUtils
.
isNotEmpty
(
itemVOList
)){
for
(
SoilItemVO
itemVO:
itemVOList
)
{
mapReplace
.
put
(
"#{"
+
itemVO
.
getName
()+
"}"
,
itemVO
.
getTestValue
());
}
}
if
(!
mapReplace
.
containsKey
(
"#{含水率}"
)){
mapReplace
.
put
(
"#{含水率}"
,
""
);
}
if
(!
mapReplace
.
containsKey
(
"#{液限}"
)){
mapReplace
.
put
(
"#{液限}"
,
""
);
}
if
(!
mapReplace
.
containsKey
(
"#{塑限}"
)){
mapReplace
.
put
(
"#{塑限}"
,
""
);
}
if
(!
mapReplace
.
containsKey
(
"#{比重}"
)){
mapReplace
.
put
(
"#{比重}"
,
""
);
}
if
(!
mapReplace
.
containsKey
(
"#{密度}"
)){
mapReplace
.
put
(
"#{密度}"
,
""
);
}
mapReplace
.
put
(
"#{sampleCode}"
,
vo
.
getSampleCode
());
mapReplace
.
put
(
"#{siteNo}"
,
vo
.
getSiteNo
());
mapReplace
.
put
(
"#{sampleDepth}"
,
vo
.
getSampleDepth
());
String
midu
=
mapReplace
.
get
(
"#{密度}"
);
if
(
StringUtils
.
isNotBlank
(
midu
)){
try
{
BigDecimal
bigDecimal
=
new
BigDecimal
(
midu
);
BigDecimal
mul
=
new
BigDecimal
(
"9.81"
);
BigDecimal
rz981
=
bigDecimal
.
multiply
(
mul
);
mapReplace
.
put
(
"#{密度9.81}"
,
rz981
.
toString
());
}
catch
(
Exception
e
){
logger
.
error
(
"密度9.81失败"
+
e
.
getMessage
());
mapReplace
.
put
(
"#{密度9.81}"
,
""
);
}
}
else
{
mapReplace
.
put
(
"#{密度9.81}"
,
""
);
}
nextSample
++;
HSSFWorkbookUtil
.
replaceModel
(
mapReplace
,
xssfWorkbook
,
sheet
);
}
List
<
SoilItemVO
>
itemVOList
=
sampleSoilItemVOMap
.
get
(
firstVO
.
getSampleId
());
if
(
CollectionUtils
.
isNotEmpty
(
itemVOList
)){
for
(
SoilItemVO
itemVO:
itemVOList
)
{
mapReplace
.
put
(
"#{"
+
itemVO
.
getName
()+
"}"
,
itemVO
.
getTestValue
());
}
}
if
(!
mapReplace
.
containsKey
(
"#{含水率}"
)){
mapReplace
.
put
(
"#{含水率}"
,
""
);
}
if
(!
mapReplace
.
containsKey
(
"#{液限}"
)){
mapReplace
.
put
(
"#{液限}"
,
""
);
}
if
(!
mapReplace
.
containsKey
(
"#{塑限}"
)){
mapReplace
.
put
(
"#{塑限}"
,
""
);
}
if
(!
mapReplace
.
containsKey
(
"#{比重}"
)){
mapReplace
.
put
(
"#{比重}"
,
""
);
}
if
(!
mapReplace
.
containsKey
(
"#{密度}"
)){
mapReplace
.
put
(
"#{密度}"
,
""
);
}
mapReplace
.
put
(
"#{sampleCode}"
,
firstVO
.
getSampleCode
());
mapReplace
.
put
(
"#{siteNo}"
,
firstVO
.
getSiteNo
());
mapReplace
.
put
(
"#{sampleDepth}"
,
firstVO
.
getSampleDepth
());
String
midu
=
mapReplace
.
get
(
"#{密度}"
);
if
(
StringUtils
.
isNotBlank
(
midu
)){
try
{
BigDecimal
bigDecimal
=
new
BigDecimal
(
midu
);
BigDecimal
mul
=
new
BigDecimal
(
"9.81"
);
BigDecimal
rz981
=
bigDecimal
.
multiply
(
mul
);
mapReplace
.
put
(
"#{密度9.81}"
,
rz981
.
toString
());
}
catch
(
Exception
e
){
logger
.
error
(
"密度9.81失败"
+
e
.
getMessage
());
mapReplace
.
put
(
"#{密度9.81}"
,
""
);
}
}
else
{
mapReplace
.
put
(
"#{密度9.81}"
,
""
);
}
HSSFWorkbookUtil
.
replaceModel
(
mapReplace
,
xssfWorkbook
,
xssfSheet
);
}
else
{
List
<
List
<
SoilExperimentVO
>>
relList
=
ListUtils
.
partition
(
voList
,
templateSampleNum
);
int
templateSheetMum
=
xssfWorkbook
.
getNumberOfSheets
();
XSSFSheet
sheetMy
=
xssfWorkbook
.
getSheetAt
(
0
);
PrintSetup
printSetup
=
sheetMy
.
getPrintSetup
();
boolean
printRound
=
printSetup
.
getLandscape
();
boolean
first
=
true
;
List
<
SoilExperimentVO
>
firstList
=
null
;
for
(
List
<
SoilExperimentVO
>
expVOList:
relList
)
{
XSSFSheet
sheet
=
null
;
if
(
first
){
sheet
=
sheetMy
;
firstList
=
expVOList
;
first
=
false
;
continue
;
}
else
{
sheet
=
xssfWorkbook
.
cloneSheet
(
0
,
sheetMy
.
getSheetName
()+(
templateSheetMum
));
sheet
.
getPrintSetup
().
setLandscape
(
printRound
);
}
Map
<
String
,
String
>
mapReplaceMy
=
new
HashMap
<>();
mapReplaceMy
.
put
(
"#{reportCode}"
,
entrust
.
getEntrustCode
());
for
(
int
i
=
0
;
i
<
templateSampleNum
;
i
++)
{
mapReplaceMy
.
put
(
"#{sampleCode"
+
i
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{sampleDepth"
+
i
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{含水率"
+
i
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81"
+
i
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{密度9.81"
+
i
+
"}"
,
""
);
}
mapReplaceMy
.
put
(
"#{projectName}"
,
entrust
.
getProjectName
());
mapReplaceMy
.
put
(
"#{client}"
,
entrust
.
getClient
());
mapReplaceMy
.
put
(
"#{boreholeName}"
,
entrust
.
getBoreholeName
());
mapReplaceMy
.
put
(
"#{projectNo}"
,
entrust
.
getProjectNo
());
int
entitySize
=
expVOList
.
size
();
for
(
int
j
=
0
;
j
<
entitySize
;
j
++)
{
SoilExperimentVO
vo
=
expVOList
.
get
(
j
);
mapReplaceMy
.
put
(
"#{sampleCode"
+
j
+
"}"
,
StringHandleUtils
.
getString
(
vo
.
getSampleCode
()));
mapReplaceMy
.
put
(
"#{sampleDepth"
+
j
+
"}"
,
StringHandleUtils
.
getString
(
vo
.
getSampleDepth
()));
mapReplaceMy
.
put
(
"#{siteNo"
+
j
+
"}"
,
StringHandleUtils
.
getString
(
vo
.
getSiteNo
()));
List
<
SoilItemVO
>
itemVOList
=
sampleSoilItemVOMap
.
get
(
vo
.
getSampleId
());
if
(
CollectionUtils
.
isNotEmpty
(
itemVOList
)){
for
(
SoilItemVO
itemVO:
itemVOList
)
{
mapReplaceMy
.
put
(
"#{"
+
itemVO
.
getName
()+
"}"
,
itemVO
.
getTestValue
());
}
}
if
(!
mapReplaceMy
.
containsKey
(
"#{含水率}"
)){
mapReplaceMy
.
put
(
"#{含水率}"
,
""
);
mapReplaceMy
.
put
(
"#{含水率"
+
j
+
"}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{液限}"
)){
mapReplaceMy
.
put
(
"#{液限}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{塑限}"
)){
mapReplaceMy
.
put
(
"#{塑限}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{比重}"
)){
mapReplaceMy
.
put
(
"#{比重}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{密度}"
)){
mapReplaceMy
.
put
(
"#{密度}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{密度}"
)){
mapReplaceMy
.
put
(
"#{密度}"
,
""
);
mapReplaceMy
.
put
(
"#{密度9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{密度"
+
j
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{密度9.81"
+
j
+
"}"
,
""
);
}
else
{
String
midu
=
mapReplaceMy
.
get
(
"#{密度}"
);
if
(
StringUtils
.
isBlank
(
midu
)){
mapReplaceMy
.
put
(
"#{密度9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{密度9.81"
+
j
+
"}"
,
""
);
}
else
{
if
(
StringHandleUtils
.
validateNumber
(
midu
)){
BigDecimal
mi
=
new
BigDecimal
(
midu
);
BigDecimal
chengshu
=
new
BigDecimal
(
"9.81"
);
BigDecimal
ji
=
mi
.
multiply
(
chengshu
);
mapReplaceMy
.
put
(
"#{密度9.81}"
,
ji
.
toString
());
mapReplaceMy
.
put
(
"#{密度9.81"
+
j
+
"}"
,
ji
.
toString
());
}
else
{
mapReplaceMy
.
put
(
"#{密度9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{密度9.81"
+
j
+
"}"
,
""
);
}
}
}
if
(!
mapReplaceMy
.
containsKey
(
"#{容重}"
)){
mapReplaceMy
.
put
(
"#{容重}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{容重"
+
j
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81"
+
j
+
"}"
,
""
);
}
else
{
String
rongzhong
=
mapReplace
.
get
(
"#{容重}"
);
if
(
StringUtils
.
isBlank
(
rongzhong
)){
mapReplaceMy
.
put
(
"#{容重9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81"
+
j
+
"}"
,
""
);
}
else
{
if
(
StringHandleUtils
.
validateNumber
(
rongzhong
)){
BigDecimal
rong
=
new
BigDecimal
(
rongzhong
);
BigDecimal
chengshu
=
new
BigDecimal
(
"9.81"
);
BigDecimal
ji
=
rong
.
multiply
(
chengshu
);
mapReplaceMy
.
put
(
"#{容重9.81}"
,
ji
.
toString
());
mapReplaceMy
.
put
(
"#{容重9.81"
+
j
+
"}"
,
ji
.
toString
());
}
else
{
mapReplaceMy
.
put
(
"#{容重9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81"
+
j
+
"}"
,
""
);
}
}
}
}
HSSFWorkbookUtil
.
replaceModel
(
mapReplaceMy
,
xssfWorkbook
,
sheet
);
templateSheetMum
++;
}
int
firstSize
=
firstList
.
size
();
Map
<
String
,
String
>
mapReplaceMy
=
new
HashMap
<>();
mapReplaceMy
.
put
(
"#{reportCode}"
,
entrust
.
getEntrustCode
());
for
(
int
i
=
0
;
i
<
templateSampleNum
;
i
++)
{
mapReplaceMy
.
put
(
"#{sampleCode"
+
i
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{sampleDepth"
+
i
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{含水率"
+
i
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81"
+
i
+
"}"
,
""
);
}
mapReplaceMy
.
put
(
"#{projectName}"
,
entrust
.
getProjectName
());
mapReplaceMy
.
put
(
"#{client}"
,
entrust
.
getClient
());
mapReplaceMy
.
put
(
"#{boreholeName}"
,
entrust
.
getBoreholeName
());
mapReplaceMy
.
put
(
"#{projectNo}"
,
entrust
.
getProjectNo
());
for
(
int
j
=
0
;
j
<
firstSize
;
j
++)
{
SoilExperimentVO
vo
=
firstList
.
get
(
j
);
mapReplaceMy
.
put
(
"#{sampleCode"
+
j
+
"}"
,
StringHandleUtils
.
getString
(
vo
.
getSampleCode
()));
mapReplaceMy
.
put
(
"#{sampleDepth"
+
j
+
"}"
,
StringHandleUtils
.
getString
(
vo
.
getSampleDepth
()));
List
<
SoilItemVO
>
itemVOList
=
sampleSoilItemVOMap
.
get
(
vo
.
getSampleId
());
if
(
CollectionUtils
.
isNotEmpty
(
itemVOList
)){
for
(
SoilItemVO
itemVO:
itemVOList
)
{
mapReplaceMy
.
put
(
"#{"
+
itemVO
.
getName
()+
"}"
,
itemVO
.
getTestValue
());
}
}
if
(!
mapReplaceMy
.
containsKey
(
"#{含水率}"
)){
mapReplaceMy
.
put
(
"#{含水率}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{液限}"
)){
mapReplaceMy
.
put
(
"#{液限}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{塑限}"
)){
mapReplaceMy
.
put
(
"#{塑限}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{比重}"
)){
mapReplaceMy
.
put
(
"#{比重}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{密度}"
)){
mapReplaceMy
.
put
(
"#{密度}"
,
""
);
}
if
(!
mapReplaceMy
.
containsKey
(
"#{含水率}"
)){
mapReplaceMy
.
put
(
"#{含水率"
+
j
+
"}"
,
""
);
}
else
{
mapReplaceMy
.
put
(
"#{含水率"
+
j
+
"}"
,
mapReplaceMy
.
get
(
"#{含水率}"
));
}
if
(!
mapReplaceMy
.
containsKey
(
"#{密度}"
)){
mapReplaceMy
.
put
(
"#{密度}"
,
""
);
mapReplaceMy
.
put
(
"#{密度9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{密度"
+
j
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{密度9.81"
+
j
+
"}"
,
""
);
}
else
{
String
rongzhong
=
mapReplaceMy
.
get
(
"#{密度}"
);
if
(
StringUtils
.
isBlank
(
rongzhong
)){
mapReplaceMy
.
put
(
"#{密度9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{密度9.81"
+
j
+
"}"
,
""
);
}
else
{
if
(
StringHandleUtils
.
validateNumber
(
rongzhong
)){
BigDecimal
rong
=
new
BigDecimal
(
rongzhong
);
BigDecimal
chengshu
=
new
BigDecimal
(
"9.81"
);
BigDecimal
ji
=
rong
.
multiply
(
chengshu
);
mapReplaceMy
.
put
(
"#{密度9.81}"
,
ji
.
toString
());
mapReplaceMy
.
put
(
"#{密度9.81"
+
j
+
"}"
,
ji
.
toString
());
}
else
{
mapReplaceMy
.
put
(
"#{密度9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{密度9.81"
+
j
+
"}"
,
""
);
}
}
}
SoilOriginalTemplate
template
=
soilOriginalTemplateService
.
getById
(
templateId
);
if
(
null
==
template
){
logger
.
error
(
"----------------------0"
);
RestAssert
.
fail
(
"模板不存在"
);
}
logger
.
error
(
"saveExcelOriginalRecord模板存在"
);
List
<
SoilExperimentVO
>
voList
=
soilExperimentService
.
listVOByIds
(
ids
);
if
(!
mapReplaceMy
.
containsKey
(
"#{容重}"
)){
mapReplaceMy
.
put
(
"#{容重}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81}"
,
""
);
if
(
CollectionUtils
.
isEmpty
(
voList
)){
logger
.
error
(
"----------------------1"
);
return
null
;
}
List
<
Long
>
sampleIdList
=
voList
.
stream
().
map
(
s
->{
return
s
.
getSampleId
();
}).
collect
(
Collectors
.
toList
());
mapReplaceMy
.
put
(
"#{容重"
+
j
+
"}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81"
+
j
+
"}"
,
""
);
}
else
{
String
rongzhong
=
mapReplace
.
get
(
"#{容重}"
);
if
(
StringUtils
.
isBlank
(
rongzhong
)){
mapReplaceMy
.
put
(
"#{容重9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81"
+
j
+
"}"
,
""
);
}
else
{
if
(
StringHandleUtils
.
validateNumber
(
rongzhong
)){
BigDecimal
rong
=
new
BigDecimal
(
rongzhong
);
BigDecimal
chengshu
=
new
BigDecimal
(
"9.81"
);
BigDecimal
ji
=
rong
.
multiply
(
chengshu
);
mapReplaceMy
.
put
(
"#{容重9.81}"
,
ji
.
toString
());
mapReplaceMy
.
put
(
"#{容重9.81"
+
j
+
"}"
,
ji
.
toString
());
}
else
{
mapReplaceMy
.
put
(
"#{容重9.81}"
,
""
);
mapReplaceMy
.
put
(
"#{容重9.81"
+
j
+
"}"
,
""
);
}
}
List
<
SoilItemVO
>
soilItemVOList
=
soilItemService
.
listVOByExpSampleIds
(
sampleIdList
);
SoilEntrust
entrust
=
soilEntrustService
.
getById
(
voList
.
get
(
0
).
getEntrustId
());
logger
.
error
(
"saveExcelOriginalRecord entrust"
);
InputStream
io
=
ossClient
.
download
(
template
.
getObjectKey
());
if
(
null
==
io
){
RestAssert
.
fail
(
"模板不存在"
);
}
}
}
HSSFWorkbookUtil
.
replaceModel
(
mapReplaceMy
,
xssfWorkbook
,
sheetMy
);
logger
.
error
(
" InputStream io 存在"
);
SoilOriginalRecord
objectKey
=
null
;
XSSFWorkbook
xssfWorkbook
=
null
;
try
{
xssfWorkbook
=
new
XSSFWorkbook
(
io
);
}
catch
(
Exception
e
){
logger
.
error
(
"获取证书模板错误"
+
e
.
getMessage
());
e
.
printStackTrace
();
}
Map
<
String
,
String
>
mapReplace
=
new
HashMap
<>();
InitMapReplace
.
initMapReplace
(
mapReplace
,
entrust
);
List
<
SoilOriginalTemplateConfig
>
configList
=
soilOriginalTemplateConfigService
.
list
(
Condition
.
create
().
eq
(
"template_id"
,
templateId
));
}
}
OriginalOperationFactory
operationFactory
=
new
OriginalOperationFactory
(
xssfWorkbook
,
io
,
mapReplace
,
configList
,
template
,
voList
,
soilItemVOList
,
entrust
);
Operation
operation
=
operationFactory
.
getOperation
(
template
,
template
.
getTemplateSampleNum
(),
voList
);
operation
.
doProductOriginal
();
FileOutputStream
os
=
null
;
File
file
=
null
;
String
generated
=
"ORIGINAL"
;
...
...
@@ -1307,24 +383,7 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
return
objectKey
;
}
private
String
getFieldValue
(
String
dataAttribute
,
SoilExperimentVO
vo
,
List
<
SoilItemVO
>
soilItemVOList
)
{
if
(
StringUtils
.
isBlank
(
dataAttribute
)){
return
""
;
}
if
(
StringHandleUtils
.
is_alpha
(
dataAttribute
)){
return
StringHandleUtils
.
getFieldIfNummReturnBlankValueByFieldName
(
dataAttribute
,
vo
);
}
else
{
if
(
CollectionUtils
.
isEmpty
(
soilItemVOList
)){
return
""
;
}
for
(
SoilItemVO
soilItemVO
:
soilItemVOList
)
{
if
(
dataAttribute
.
equals
(
soilItemVO
.
getName
())){
return
soilItemVO
.
getTestValue
();
}
}
}
return
""
;
}
public
void
GenerateChart
(
XSSFSheet
sheet
,
String
xValue
,
String
yValue
)
{
...
...
@@ -1859,7 +918,8 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
int
sheetNum
=
xssfWorkbook
.
getNumberOfSheets
();
PrintSetup
printSetup
=
xssfSheet
.
getPrintSetup
();
boolean
printRound
=
printSetup
.
getLandscape
();
for
(
SoilExperimentVO
vo:
voList
)
{
if
(
index
==
0
){
index
++;
...
...
@@ -1867,7 +927,9 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
firstVO
=
vo
;
continue
;
}
xssfWorkbook
.
cloneSheet
(
0
);
XSSFSheet
sheet
=
xssfWorkbook
.
cloneSheet
(
0
);
sheet
.
getPrintSetup
().
setLandscape
(
printRound
);
index
++;
}
...
...
@@ -1975,7 +1037,8 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
boolean
first
=
true
;
List
<
SoilExperimentVO
>
firstList
=
null
;
PrintSetup
printSetup
=
sheetMy
.
getPrintSetup
();
boolean
printRound
=
printSetup
.
getLandscape
();
for
(
List
<
SoilExperimentVO
>
expVOList:
relList
)
{
XSSFSheet
sheet
=
null
;
if
(
first
){
...
...
@@ -1985,6 +1048,7 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
continue
;
}
else
{
sheet
=
xssfWorkbook
.
cloneSheet
(
0
,
sheetMy
.
getSheetName
()+(
templateSheetMum
));
sheet
.
getPrintSetup
().
setLandscape
(
printRound
);
}
Map
<
String
,
String
>
mapReplaceMy
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
templateSampleNum
;
i
++)
{
...
...
@@ -3016,8 +2080,7 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
}
else
{
testEnglish
=
"FIGURE OF TRIAXIAL COMPRESSION TEST"
;
}
replaceMap
.
put
(
"#{reportCode}"
,
StringHandleUtils
.
getString
(
type
.
getEntrustCode
()));
replaceMap
.
put
(
"#{title}"
,
"附录"
+(
count
)+
" "
+
type
.
getExperiment
()+
"试验成果图\n"
+
"APPENDIX "
+
count
+
" "
+
testEnglish
);
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