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
1c897ad5
Commit
1c897ad5
authored
Jul 25, 2021
by
ghxdhr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修约位数
parent
ce7a8fe9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
28 deletions
+14
-28
SingleSheetMoreItemOperation.java
...vice/lims/hmhj/original/SingleSheetMoreItemOperation.java
+6
-8
SingleSheetMoreOperation.java
.../service/lims/hmhj/original/SingleSheetMoreOperation.java
+8
-20
No files found.
src/main/java/com/patzn/cloud/service/lims/hmhj/original/SingleSheetMoreItemOperation.java
View file @
1c897ad5
...
@@ -6,8 +6,6 @@ import com.patzn.cloud.service.hmhj.entity.OriginalTemplateConfig;
...
@@ -6,8 +6,6 @@ import com.patzn.cloud.service.hmhj.entity.OriginalTemplateConfig;
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
;
import
org.apache.commons.lang3.math.NumberUtils
;
import
org.apache.poi.ss.formula.FormulaParseException
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.FormulaEvaluator
;
import
org.apache.poi.ss.usermodel.FormulaEvaluator
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.ss.util.CellRangeAddress
;
...
@@ -145,18 +143,18 @@ public class SingleSheetMoreItemOperation implements Operation {
...
@@ -145,18 +143,18 @@ public class SingleSheetMoreItemOperation implements Operation {
if
(
sampleIdMap
.
get
(
vo
.
getId
())
!=
null
&&
sampleIdMap
.
get
(
vo
.
getId
()).
size
()
>
0
)
{
if
(
sampleIdMap
.
get
(
vo
.
getId
())
!=
null
&&
sampleIdMap
.
get
(
vo
.
getId
()).
size
()
>
0
)
{
if
(
null
!=
config
.
getRoundNum
())
{
// 需要修约
if
(
null
!=
config
.
getRoundNum
())
{
// 需要修约
String
s
=
sampleIdMap
.
get
(
vo
.
getId
()).
get
(
mapKey
);
String
s
=
sampleIdMap
.
get
(
vo
.
getId
()).
get
(
mapKey
);
rounding
(
cell
,
s
);
rounding
(
cell
,
s
,
config
.
getRoundNum
()
);
if
(
null
!=
cell2
&&
vo
.
getCollectionDataList
().
size
()
>=
2
)
{
if
(
null
!=
cell2
&&
vo
.
getCollectionDataList
().
size
()
>=
2
)
{
String
s1
=
vo
.
getCollectionDataList
().
get
(
1
).
get
(
mapKey
);
String
s1
=
vo
.
getCollectionDataList
().
get
(
1
).
get
(
mapKey
);
rounding
(
cell2
,
s1
);
rounding
(
cell2
,
s1
,
config
.
getRoundNum
()
);
}
}
if
(
null
!=
cell3
&&
vo
.
getCollectionDataList
().
size
()
>=
3
)
{
if
(
null
!=
cell3
&&
vo
.
getCollectionDataList
().
size
()
>=
3
)
{
String
s2
=
vo
.
getCollectionDataList
().
get
(
2
).
get
(
mapKey
);
String
s2
=
vo
.
getCollectionDataList
().
get
(
2
).
get
(
mapKey
);
rounding
(
cell3
,
s2
);
rounding
(
cell3
,
s2
,
config
.
getRoundNum
()
);
}
}
if
(
null
!=
cell4
&&
vo
.
getCollectionDataList
().
size
()
>=
4
)
{
if
(
null
!=
cell4
&&
vo
.
getCollectionDataList
().
size
()
>=
4
)
{
String
s3
=
vo
.
getCollectionDataList
().
get
(
3
).
get
(
mapKey
);
String
s3
=
vo
.
getCollectionDataList
().
get
(
3
).
get
(
mapKey
);
rounding
(
cell4
,
s3
);
rounding
(
cell4
,
s3
,
config
.
getRoundNum
()
);
}
}
continue
;
continue
;
}
}
...
@@ -238,10 +236,10 @@ public class SingleSheetMoreItemOperation implements Operation {
...
@@ -238,10 +236,10 @@ public class SingleSheetMoreItemOperation implements Operation {
}
}
// 四舍六入五成双
// 四舍六入五成双
private
static
void
rounding
(
Cell
cell
,
String
value
)
{
private
static
void
rounding
(
Cell
cell
,
String
value
,
Integer
roundNum
)
{
if
(
StringUtils
.
isNotBlank
(
value
)
&&
StringHandleUtils
.
validateNumber
(
value
))
{
if
(
StringUtils
.
isNotBlank
(
value
)
&&
StringHandleUtils
.
validateNumber
(
value
))
{
BigDecimal
bd1
=
new
BigDecimal
(
value
);
BigDecimal
bd1
=
new
BigDecimal
(
value
);
BigDecimal
bd2
=
bd1
.
setScale
(
2
,
BigDecimal
.
ROUND_HALF_EVEN
);
BigDecimal
bd2
=
bd1
.
setScale
(
roundNum
,
BigDecimal
.
ROUND_HALF_EVEN
);
cell
.
setCellValue
(
bd2
.
toPlainString
());
cell
.
setCellValue
(
bd2
.
toPlainString
());
}
else
{
}
else
{
cell
.
setCellValue
(
""
);
cell
.
setCellValue
(
""
);
...
...
src/main/java/com/patzn/cloud/service/lims/hmhj/original/SingleSheetMoreOperation.java
View file @
1c897ad5
...
@@ -7,13 +7,10 @@ import com.patzn.cloud.service.hmhj.entity.OriginalTemplateConfig;
...
@@ -7,13 +7,10 @@ import com.patzn.cloud.service.hmhj.entity.OriginalTemplateConfig;
import
com.patzn.cloud.service.hmhj.vo.EntrustSampleItemVO
;
import
com.patzn.cloud.service.hmhj.vo.EntrustSampleItemVO
;
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
;
import
org.apache.commons.lang3.math.NumberUtils
;
import
org.apache.poi.ss.formula.FormulaParseException
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.FormulaEvaluator
;
import
org.apache.poi.ss.usermodel.FormulaEvaluator
;
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.*
;
import
org.aspectj.weaver.ast.Var
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -28,7 +25,7 @@ public class SingleSheetMoreOperation implements Operation {
...
@@ -28,7 +25,7 @@ public class SingleSheetMoreOperation implements Operation {
private
XSSFWorkbook
xssfWorkbook
;
private
XSSFWorkbook
xssfWorkbook
;
private
String
collectionDataPrefix
=
"clc."
;
private
String
collectionDataPrefix
=
"clc."
;
private
FormulaEvaluator
formulaEvaluator
;
private
FormulaEvaluator
formulaEvaluator
;
private
Map
<
Integer
,
String
>
valueMap
;
public
SingleSheetMoreOperation
(
OriginalTemplate
template
,
List
<
EntrustSampleItemVO
>
voList
,
Entrust
entrust
,
List
<
OriginalTemplateConfig
>
configList
,
XSSFWorkbook
xssfWorkbook
)
{
public
SingleSheetMoreOperation
(
OriginalTemplate
template
,
List
<
EntrustSampleItemVO
>
voList
,
Entrust
entrust
,
List
<
OriginalTemplateConfig
>
configList
,
XSSFWorkbook
xssfWorkbook
)
{
this
.
template
=
template
;
this
.
template
=
template
;
this
.
voList
=
voList
;
this
.
voList
=
voList
;
...
@@ -36,16 +33,7 @@ public class SingleSheetMoreOperation implements Operation {
...
@@ -36,16 +33,7 @@ public class SingleSheetMoreOperation implements Operation {
this
.
configList
=
configList
;
this
.
configList
=
configList
;
this
.
xssfWorkbook
=
xssfWorkbook
;
this
.
xssfWorkbook
=
xssfWorkbook
;
this
.
formulaEvaluator
=
new
XSSFFormulaEvaluator
(
xssfWorkbook
);
this
.
formulaEvaluator
=
new
XSSFFormulaEvaluator
(
xssfWorkbook
);
valueMap
=
new
HashMap
<>();
valueMap
.
put
(
1
,
"0.1"
);
valueMap
.
put
(
2
,
"0.01"
);
valueMap
.
put
(
3
,
"0.001"
);
valueMap
.
put
(
4
,
"0.0001"
);
valueMap
.
put
(
5
,
"0.00001"
);
valueMap
.
put
(
6
,
"0.000001"
);
valueMap
.
put
(
7
,
"0.0000001"
);
valueMap
.
put
(
8
,
"0.00000001"
);
valueMap
.
put
(
9
,
"0.000000001"
);
}
}
@Override
@Override
...
@@ -124,19 +112,19 @@ public class SingleSheetMoreOperation implements Operation {
...
@@ -124,19 +112,19 @@ public class SingleSheetMoreOperation implements Operation {
if
(
CollectionUtils
.
isNotEmpty
(
vo
.
getCollectionDataList
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
vo
.
getCollectionDataList
()))
{
String
s
=
vo
.
getCollectionDataList
().
get
(
0
).
get
(
mapKey
);
String
s
=
vo
.
getCollectionDataList
().
get
(
0
).
get
(
mapKey
);
if
(
null
!=
config
.
getRoundNum
())
{
// 需要修约
if
(
null
!=
config
.
getRoundNum
())
{
// 需要修约
rounding
(
cell
,
s
);
rounding
(
cell
,
s
,
config
.
getRoundNum
()
);
/* 下面为冗余代码,可能要删掉 */
/* 下面为冗余代码,可能要删掉 */
if
(
null
!=
cell2
&&
vo
.
getCollectionDataList
().
size
()
>=
2
)
{
if
(
null
!=
cell2
&&
vo
.
getCollectionDataList
().
size
()
>=
2
)
{
String
s1
=
vo
.
getCollectionDataList
().
get
(
1
).
get
(
mapKey
);
String
s1
=
vo
.
getCollectionDataList
().
get
(
1
).
get
(
mapKey
);
rounding
(
cell2
,
s1
);
rounding
(
cell2
,
s1
,
config
.
getRoundNum
()
);
}
}
if
(
null
!=
cell3
&&
vo
.
getCollectionDataList
().
size
()
>=
3
)
{
if
(
null
!=
cell3
&&
vo
.
getCollectionDataList
().
size
()
>=
3
)
{
String
s2
=
vo
.
getCollectionDataList
().
get
(
2
).
get
(
mapKey
);
String
s2
=
vo
.
getCollectionDataList
().
get
(
2
).
get
(
mapKey
);
rounding
(
cell3
,
s2
);
rounding
(
cell3
,
s2
,
config
.
getRoundNum
()
);
}
}
if
(
null
!=
cell4
&&
vo
.
getCollectionDataList
().
size
()
>=
4
)
{
if
(
null
!=
cell4
&&
vo
.
getCollectionDataList
().
size
()
>=
4
)
{
String
s3
=
vo
.
getCollectionDataList
().
get
(
3
).
get
(
mapKey
);
String
s3
=
vo
.
getCollectionDataList
().
get
(
3
).
get
(
mapKey
);
rounding
(
cell4
,
s3
);
rounding
(
cell4
,
s3
,
config
.
getRoundNum
()
);
}
}
continue
;
continue
;
}
}
...
@@ -261,10 +249,10 @@ public class SingleSheetMoreOperation implements Operation {
...
@@ -261,10 +249,10 @@ public class SingleSheetMoreOperation implements Operation {
}
}
// 四舍六入五成双
// 四舍六入五成双
private
static
void
rounding
(
Cell
cell
,
String
value
)
{
private
static
void
rounding
(
Cell
cell
,
String
value
,
Integer
roundNum
)
{
if
(
StringUtils
.
isNotBlank
(
value
)
&&
StringHandleUtils
.
validateNumber
(
value
))
{
if
(
StringUtils
.
isNotBlank
(
value
)
&&
StringHandleUtils
.
validateNumber
(
value
))
{
BigDecimal
bd1
=
new
BigDecimal
(
value
);
BigDecimal
bd1
=
new
BigDecimal
(
value
);
BigDecimal
bd2
=
bd1
.
setScale
(
2
,
BigDecimal
.
ROUND_HALF_EVEN
);
BigDecimal
bd2
=
bd1
.
setScale
(
roundNum
,
BigDecimal
.
ROUND_HALF_EVEN
);
cell
.
setCellValue
(
bd2
.
toPlainString
());
cell
.
setCellValue
(
bd2
.
toPlainString
());
}
else
{
}
else
{
cell
.
setCellValue
(
""
);
cell
.
setCellValue
(
""
);
...
...
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