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
07a6b977
Commit
07a6b977
authored
Jan 13, 2021
by
wangweidong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
土工平台修改
parent
2412152c
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
316 additions
and
60 deletions
+316
-60
HSSFWorkbookUtil.java
...com/patzn/cloud/service/lims/common/HSSFWorkbookUtil.java
+39
-0
StringHandleUtils.java
...om/patzn/cloud/service/lims/common/StringHandleUtils.java
+13
-0
SoilEntrustController.java
...d/service/lims/soil/controller/SoilEntrustController.java
+2
-2
SoilEntrustMapper.java
...tzn/cloud/service/lims/soil/mapper/SoilEntrustMapper.java
+1
-1
ISoilEntrustService.java
.../cloud/service/lims/soil/service/ISoilEntrustService.java
+1
-1
SoilEntrustServiceImpl.java
...ervice/lims/soil/service/impl/SoilEntrustServiceImpl.java
+5
-5
SoilExperimentServiceImpl.java
...ice/lims/soil/service/impl/SoilExperimentServiceImpl.java
+237
-48
Ytest.java
src/test/java/com/patzn/cloud/service/lims/test/Ytest.java
+18
-3
No files found.
src/main/java/com/patzn/cloud/service/lims/common/HSSFWorkbookUtil.java
View file @
07a6b977
...
@@ -515,6 +515,45 @@ public class HSSFWorkbookUtil {
...
@@ -515,6 +515,45 @@ public class HSSFWorkbookUtil {
}
}
return
wb
;
return
wb
;
}
}
public
static
XSSFWorkbook
replaceModel
(
Map
item
,
XSSFWorkbook
wb
,
XSSFSheet
sheet
)
{
try
{
Iterator
rows
=
sheet
.
rowIterator
();
while
(
rows
.
hasNext
()){
XSSFRow
row
=
(
XSSFRow
)
rows
.
next
();
if
(
row
!=
null
)
{
int
num
=
row
.
getLastCellNum
();
for
(
int
i
=
0
;
i
<
num
;
i
++)
{
XSSFCell
cell
=
row
.
getCell
(
i
);
if
(
cell
==
null
||
StringUtils
.
isBlank
(
getJavaValue
(
cell
).
toString
()))
{
continue
;
}
String
value
=
getJavaValue
(
cell
).
toString
();
if
(!
""
.
equals
(
value
))
{
Set
<
String
>
keySet
=
item
.
keySet
();
Iterator
<
String
>
it
=
keySet
.
iterator
();
while
(
it
.
hasNext
())
{
String
text
=
it
.
next
();
if
(
value
.
contains
(
text
))
{
String
txt
=
value
.
replace
(
text
,(
String
)
item
.
get
(
text
));
cell
.
setCellValue
(
txt
);
break
;
}
}
}
else
{
cell
.
setCellValue
(
""
);
}
}
}
}
// 输出文件
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
wb
;
}
public
static
XSSFWorkbook
getWorkbookByIO
(
InputStream
io
)
{
public
static
XSSFWorkbook
getWorkbookByIO
(
InputStream
io
)
{
try
{
try
{
XSSFWorkbook
xssfWorkbook
=
new
XSSFWorkbook
(
io
);
XSSFWorkbook
xssfWorkbook
=
new
XSSFWorkbook
(
io
);
...
...
src/main/java/com/patzn/cloud/service/lims/common/StringHandleUtils.java
View file @
07a6b977
...
@@ -22,6 +22,19 @@ import java.util.regex.Pattern;
...
@@ -22,6 +22,19 @@ import java.util.regex.Pattern;
*/
*/
public
class
StringHandleUtils
{
public
class
StringHandleUtils
{
public
static
boolean
validateNumber
(
String
str
)
{
if
(
StringUtils
.
isBlank
(
str
))
{
return
false
;
}
// 说明一下的是该正则只能识别4位小数;如果不限制小数位数的话,写成[+-]?[0-9]+(\\.[0-9]+)?就可以了
return
str
.
matches
(
"[+-]?[0-9]+(\\.[0-9]+)?"
);
}
public
static
String
getContinuousStringData
(
String
[]
intString
,
String
stringPre
)
{
public
static
String
getContinuousStringData
(
String
[]
intString
,
String
stringPre
)
{
...
...
src/main/java/com/patzn/cloud/service/lims/soil/controller/SoilEntrustController.java
View file @
07a6b977
...
@@ -775,7 +775,7 @@ public class SoilEntrustController extends ServiceController {
...
@@ -775,7 +775,7 @@ public class SoilEntrustController extends ServiceController {
@ApiOperation
(
value
=
"查询列表"
,
notes
=
"查询数据列表"
)
@ApiOperation
(
value
=
"查询列表"
,
notes
=
"查询数据列表"
)
@PostMapping
(
"/list_summary_query"
)
@PostMapping
(
"/list_summary_query"
)
public
RestResult
<
List
<
SoilEntrustSummaryDTO
>>
listSummaryQuery
(
SoilEntrustVO
soilEntrust
)
{
public
RestResult
<
Page
<
SoilEntrustSummaryDTO
>>
listSummaryQuery
(
SoilEntrustVO
soilEntrust
)
{
return
success
(
soilEntrustService
.
listSummaryQuery
(
soilEntrust
));
return
success
(
soilEntrustService
.
listSummaryQuery
(
getPage
(),
soilEntrust
));
}
}
}
}
src/main/java/com/patzn/cloud/service/lims/soil/mapper/SoilEntrustMapper.java
View file @
07a6b977
...
@@ -57,5 +57,5 @@ public interface SoilEntrustMapper extends BaseMapper<SoilEntrust> {
...
@@ -57,5 +57,5 @@ public interface SoilEntrustMapper extends BaseMapper<SoilEntrust> {
List
<
SoilEntrustVO
>
selectReportBySummaryReportList
(
RowBounds
rowBounds
,
@Param
(
"vo"
)
SoilEntrustVO
soilEntrust
);
List
<
SoilEntrustVO
>
selectReportBySummaryReportList
(
RowBounds
rowBounds
,
@Param
(
"vo"
)
SoilEntrustVO
soilEntrust
);
@SqlParser
(
filter
=
true
)
@SqlParser
(
filter
=
true
)
List
<
SoilEntrustVO
>
selectListForSummaryQuery
(
@Param
(
"vo"
)
SoilEntrustVO
soilEntrust
);
List
<
SoilEntrustVO
>
selectListForSummaryQuery
(
RowBounds
rowBounds
,
@Param
(
"vo"
)
SoilEntrustVO
soilEntrust
);
}
}
src/main/java/com/patzn/cloud/service/lims/soil/service/ISoilEntrustService.java
View file @
07a6b977
...
@@ -101,5 +101,5 @@ public interface ISoilEntrustService extends IBaseService<SoilEntrust> {
...
@@ -101,5 +101,5 @@ public interface ISoilEntrustService extends IBaseService<SoilEntrust> {
Page
<
SoilEntrustVO
>
pageReportBySummaryReport
(
Page
<
SoilEntrustVO
>
page
,
SoilEntrustVO
soilEntrust
);
Page
<
SoilEntrustVO
>
pageReportBySummaryReport
(
Page
<
SoilEntrustVO
>
page
,
SoilEntrustVO
soilEntrust
);
List
<
SoilEntrustSummaryDTO
>
listSummaryQuery
(
SoilEntrustVO
soilEntrust
);
Page
<
SoilEntrustSummaryDTO
>
listSummaryQuery
(
Page
<
SoilEntrustSummaryDTO
>
page
,
SoilEntrustVO
soilEntrust
);
}
}
src/main/java/com/patzn/cloud/service/lims/soil/service/impl/SoilEntrustServiceImpl.java
View file @
07a6b977
...
@@ -1172,10 +1172,10 @@ public class SoilEntrustServiceImpl extends BaseServiceImpl<SoilEntrustMapper, S
...
@@ -1172,10 +1172,10 @@ public class SoilEntrustServiceImpl extends BaseServiceImpl<SoilEntrustMapper, S
@Override
@Override
public
List
<
SoilEntrustSummaryDTO
>
listSummaryQuery
(
SoilEntrustVO
soilEntrust
)
{
public
Page
<
SoilEntrustSummaryDTO
>
listSummaryQuery
(
Page
<
SoilEntrustSummaryDTO
>
page
,
SoilEntrustVO
soilEntrust
)
{
List
<
SoilEntrustVO
>
voList
=
baseMapper
.
selectListForSummaryQuery
(
soilEntrust
);
List
<
SoilEntrustVO
>
voList
=
baseMapper
.
selectListForSummaryQuery
(
page
,
soilEntrust
);
if
(
CollectionUtils
.
isEmpty
(
voList
)){
if
(
CollectionUtils
.
isEmpty
(
voList
)){
return
Lists
.
newArrayList
()
;
return
page
;
}
}
List
<
Long
>
entrustIdList
=
new
ArrayList
<>();
List
<
Long
>
entrustIdList
=
new
ArrayList
<>();
...
@@ -1432,8 +1432,8 @@ public class SoilEntrustServiceImpl extends BaseServiceImpl<SoilEntrustMapper, S
...
@@ -1432,8 +1432,8 @@ public class SoilEntrustServiceImpl extends BaseServiceImpl<SoilEntrustMapper, S
continue
;
continue
;
}
}
}
}
page
.
setRecords
(
dtoList
);
return
dtoList
;
return
page
;
}
}
...
...
src/main/java/com/patzn/cloud/service/lims/soil/service/impl/SoilExperimentServiceImpl.java
View file @
07a6b977
...
@@ -3,6 +3,7 @@ package com.patzn.cloud.service.lims.soil.service.impl;
...
@@ -3,6 +3,7 @@ package com.patzn.cloud.service.lims.soil.service.impl;
import
java.awt.image.BufferedImage
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.ColorModel
;
import
java.awt.image.ColorModel
;
import
java.io.*
;
import
java.io.*
;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -30,6 +31,7 @@ import com.patzn.cloud.service.lims.common.*;
...
@@ -30,6 +31,7 @@ import com.patzn.cloud.service.lims.common.*;
import
com.patzn.cloud.service.lims.common.service.IExportService
;
import
com.patzn.cloud.service.lims.common.service.IExportService
;
import
com.patzn.cloud.service.lims.common.service.ILmsMsgService
;
import
com.patzn.cloud.service.lims.common.service.ILmsMsgService
;
import
com.patzn.cloud.service.lims.soil.service.*
;
import
com.patzn.cloud.service.lims.soil.service.*
;
import
com.patzn.cloud.service.llgt.entity.ManufactWarrantiesRelSample
;
import
com.patzn.cloud.service.meter.entity.MeterEntrust
;
import
com.patzn.cloud.service.meter.entity.MeterEntrust
;
import
com.patzn.cloud.service.soil.dto.SoilExperimentQueryDTO
;
import
com.patzn.cloud.service.soil.dto.SoilExperimentQueryDTO
;
import
com.patzn.cloud.service.soil.entity.*
;
import
com.patzn.cloud.service.soil.entity.*
;
...
@@ -44,7 +46,9 @@ import com.patzn.cloud.service.soil.vo.SoilItemVO;
...
@@ -44,7 +46,9 @@ import com.patzn.cloud.service.soil.vo.SoilItemVO;
import
com.patzn.cloud.service.soil.vo.SoilUserVO
;
import
com.patzn.cloud.service.soil.vo.SoilUserVO
;
import
jcifs.smb.SmbFile
;
import
jcifs.smb.SmbFile
;
import
net.coobird.thumbnailator.Thumbnails
;
import
net.coobird.thumbnailator.Thumbnails
;
import
org.apache.commons.collections4.ListUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.math.NumberUtils
;
import
org.apache.poi.ss.usermodel.CellType
;
import
org.apache.poi.ss.usermodel.CellType
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.xssf.usermodel.*
;
import
org.apache.poi.xssf.usermodel.*
;
...
@@ -588,72 +592,59 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
...
@@ -588,72 +592,59 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
}
}
}
else
{
}
else
{
Integer
templateSampleNum
=
template
.
getTemplateSampleNum
();
if
(
null
==
templateSampleNum
||
1
==
templateSampleNum
){
XSSFSheet
xssfSheet
=
xssfWorkbook
.
getSheetAt
(
0
);
XSSFSheet
xssfSheet
=
xssfWorkbook
.
getSheetAt
(
0
);
xssfSheet
.
setForceFormulaRecalculation
(
true
);
xssfSheet
.
setForceFormulaRecalculation
(
true
);
// int rowNum = xssfSheet.getLastRowNum();
int
index
=
0
;
//
// for (int i = 0; i < rowNum ; i++) {
// XSSFRow row = xssfSheet.getRow(i);
//
// int cellNum = row.getLastCellNum();
// for (int j = 0; j < cellNum; j++) {
// XSSFCell cell = row.getCell(j);
// if (cell.getCellType().equals(CellType.FORMULA)){
// String formula = cell.getCellFormula();
// if (StringUtils.isNotBlank(formula)){
// cell.setCellFormula(formula);
// }
// }
// }
// }
//
// xssfSheet.setForceFormulaRecalculation(true);
// for (SoilOriginalTemplateConfig config:configList) {
SoilExperimentVO
firstVO
=
null
;
// if(StringUtils.isBlank(config.getFormula())){
// continue;
// }
// if (null == config.getMergeRowNum()){
// continue;
// }
// if (null == config.getColumnPlace()){
// continue;
// }
//
// XSSFRow xssfRow = xssfSheet.getRow(config.getMergeRowNum());
// if (null == xssfRow){
// continue;
// }
// XSSFCell cell = xssfRow.getCell(config.getColumnPlace());
// if (null == cell){
// continue;
// }
// cell.setCellFormula(config.getFormula());
// }
int
index
=
0
;
for
(
SoilExperimentVO
vo:
voList
)
{
for
(
SoilExperimentVO
vo:
voList
)
{
if
(
index
==
0
){
if
(
index
==
0
){
xssfWorkbook
.
setSheetName
(
0
,
vo
.
getSampleCode
());
xssfWorkbook
.
setSheetName
(
0
,
vo
.
getSampleCode
());
index
++;
index
++;
firstVO
=
vo
;
continue
;
continue
;
}
}
XSSFSheet
sheet
=
xssfWorkbook
.
cloneSheet
(
0
);
XSSFSheet
sheet
=
xssfWorkbook
.
cloneSheet
(
0
);
xssfWorkbook
.
setSheetName
(
index
,
vo
.
getSampleCode
());
xssfWorkbook
.
setSheetName
(
index
,
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
());
HSSFWorkbookUtil
.
replaceModel
(
mapReplace
,
xssfWorkbook
,
sheet
);
index
++;
index
++;
}
}
int
length
=
voList
.
size
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
List
<
SoilItemVO
>
itemVOList
=
sampleSoilItemVOMap
.
get
(
firstVO
.
getSampleId
());
SoilExperimentVO
experimentVO
=
voList
.
get
(
i
);
List
<
SoilItemVO
>
itemVOList
=
sampleSoilItemVOMap
.
get
(
experimentVO
.
getSampleId
());
if
(
CollectionUtils
.
isNotEmpty
(
itemVOList
)){
if
(
CollectionUtils
.
isNotEmpty
(
itemVOList
)){
for
(
SoilItemVO
itemVO:
itemVOList
)
{
for
(
SoilItemVO
itemVO:
itemVOList
)
{
mapReplace
.
put
(
"#{"
+
itemVO
.
getName
()+
"}"
,
itemVO
.
getTestValue
());
mapReplace
.
put
(
"#{"
+
itemVO
.
getName
()+
"}"
,
itemVO
.
getTestValue
());
...
@@ -670,11 +661,209 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
...
@@ -670,11 +661,209 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
mapReplace
.
put
(
"#{塑限}"
,
""
);
mapReplace
.
put
(
"#{塑限}"
,
""
);
}
}
mapReplace
.
put
(
"#{sampleCode}"
,
experimentVO
.
getSampleCode
());
if
(!
mapReplace
.
containsKey
(
"#{比重}"
)){
HSSFWorkbookUtil
.
replaceModel
(
mapReplace
,
xssfWorkbook
,
i
);
mapReplace
.
put
(
"#{比重}"
,
""
);
}
if
(!
mapReplace
.
containsKey
(
"#{密度}"
)){
mapReplace
.
put
(
"#{密度}"
,
""
);
}
mapReplace
.
put
(
"#{sampleCode}"
,
firstVO
.
getSampleCode
());
HSSFWorkbookUtil
.
replaceModel
(
mapReplace
,
xssfWorkbook
,
xssfSheet
);
int
length
=
voList
.
size
();
// for (int i = 0; i < length; i++) {
//
//
// }
}
else
{
List
<
List
<
SoilExperimentVO
>>
relList
=
ListUtils
.
partition
(
voList
,
templateSampleNum
);
int
templateSheetMum
=
xssfWorkbook
.
getNumberOfSheets
();
XSSFSheet
sheetMy
=
xssfWorkbook
.
getSheetAt
(
0
);
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
));
}
Map
<
String
,
String
>
mapReplaceMy
=
new
HashMap
<>();
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
());
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
()));
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
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
<>();
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
=
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
);
}
}
}
FileOutputStream
os
=
null
;
FileOutputStream
os
=
null
;
File
file
=
null
;
File
file
=
null
;
...
...
src/test/java/com/patzn/cloud/service/lims/test/Ytest.java
View file @
07a6b977
package
com
.
patzn
.
cloud
.
service
.
lims
.
test
;
package
com
.
patzn
.
cloud
.
service
.
lims
.
test
;
import
org.apache.commons.lang3.StringUtils
;
public
class
Ytest
{
public
class
Ytest
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
Double
a
=
Double
.
parseDouble
(
"0"
);
boolean
d
=
validateNumber
(
"325.312122"
);
Double
b
=
Double
.
parseDouble
(
"0"
);
System
.
out
.
println
(
d
);
System
.
out
.
println
(
a
/
b
);
}
private
static
boolean
validateNumber
(
String
str
)
{
if
(
StringUtils
.
isBlank
(
str
))
{
return
false
;
}
// 说明一下的是该正则只能识别4位小数;如果不限制小数位数的话,写成[+-]?[0-9]+(\\.[0-9]+)?就可以了
return
str
.
matches
(
"[+-]?[0-9]+(\\.[0-9]+)?"
);
}
}
}
}
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