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
a7fe5e1d
Commit
a7fe5e1d
authored
Nov 18, 2021
by
lijingjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
霍煤需求修改;
parent
56639177
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
182 additions
and
9 deletions
+182
-9
Operation.java
...com/patzn/cloud/service/lims/hmhj/original/Operation.java
+78
-1
SingleSheetMoreItemOperation.java
...vice/lims/hmhj/original/SingleSheetMoreItemOperation.java
+0
-0
SingleSheetMoreOperation.java
.../service/lims/hmhj/original/SingleSheetMoreOperation.java
+0
-0
EntrustSampleItemServiceImpl.java
.../lims/hmhj/service/impl/EntrustSampleItemServiceImpl.java
+15
-4
Test.java
src/test/java/com/patzn/cloud/service/lims/test/Test.java
+89
-4
No files found.
src/main/java/com/patzn/cloud/service/lims/hmhj/original/Operation.java
View file @
a7fe5e1d
package
com
.
patzn
.
cloud
.
service
.
lims
.
hmhj
.
original
;
package
com
.
patzn
.
cloud
.
service
.
lims
.
hmhj
.
original
;
import
com.patzn.cloud.service.lims.common.StringHandleUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.ss.usermodel.Cell
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
public
interface
Operation
{
public
interface
Operation
{
void
doMakeOriginal
();
void
doMakeOriginal
();
/**
* 对从直读光谱中抓取过来的原铝分析结果,进行修约
* @param cell
* @param value
* @param roundNum
*/
default
void
rounding
(
Cell
cell
,
String
value
,
Integer
roundNum
)
{
if
(
StringUtils
.
isNotBlank
(
value
))
{
if
(!
StringHandleUtils
.
validateNumber
(
value
))
{
if
(
value
.
startsWith
(
"!"
))
{
value
=
value
.
substring
(
1
);
}
else
{
cell
.
setCellValue
(
value
);
return
;
}
}
// IF(ABS(TRUNC(A1,B1+5)*10^B1-TRUNC(A1,B1+5)*10^B1)<0.499999,ROUND(A1,B1),
// IF(ABS(TRUNC(A1,B1+5)*10^B1-TRUNC(A1,B1+5)*10^B1)>0.500001,ROUND(A1,B1),
// CEILING(ABS(TRUNC(A1,B1+1)-0.5*10^(-B1),2*10^(-B1)*SIGN(A1)))
int
beginIndex
=
value
.
lastIndexOf
(
"."
)
+
1
,
valueLength
=
value
.
length
();
int
remindLength
=
valueLength
-
beginIndex
;
String
truncValue
=
""
,
zeroStr
=
"000000000"
;
// bdA = TRUNC(A1,B1+5)*10^B1
if
(
remindLength
>=
roundNum
+
5
)
{
truncValue
=
"0."
+
value
.
substring
(
beginIndex
,
beginIndex
+
roundNum
+
5
);
}
else
{
truncValue
=
"0."
+
value
.
substring
(
beginIndex
)
+
zeroStr
.
substring
(
0
,
roundNum
+
5
-
remindLength
);
}
BigDecimal
bdDiff
=
new
BigDecimal
(
truncValue
).
scaleByPowerOfTen
(
roundNum
);
// bdB = TRUNC(A1,B1+5)*10^B1
if
(
remindLength
>=
roundNum
)
{
truncValue
=
"0."
+
value
.
substring
(
beginIndex
,
beginIndex
+
roundNum
);
}
else
{
truncValue
=
"0."
+
value
.
substring
(
beginIndex
)
+
zeroStr
.
substring
(
0
,
roundNum
-
remindLength
);
}
bdDiff
=
bdDiff
.
subtract
(
new
BigDecimal
(
truncValue
).
scaleByPowerOfTen
(
roundNum
)).
abs
();
// 若 < 0.499999 或 大于 0.500001
if
(
bdDiff
.
compareTo
(
new
BigDecimal
(
"0.499999"
))
<
0
||
bdDiff
.
compareTo
(
new
BigDecimal
(
"0.500001"
))
>
0
)
{
cell
.
setCellValue
(
new
BigDecimal
(
value
).
setScale
(
roundNum
,
RoundingMode
.
HALF_EVEN
).
toPlainString
());
return
;
}
// 处理第三种情况
// CEILING(ABS(TRUNC(A1,B1+1)-0.5*10^(-B1),2*10^(-B1)*SIGN(A1))
if
(
remindLength
>=
roundNum
+
1
)
{
truncValue
=
"0."
+
value
.
substring
(
beginIndex
,
beginIndex
+
roundNum
+
1
);
}
else
{
truncValue
=
"0."
+
value
.
substring
(
beginIndex
)
+
zeroStr
.
substring
(
0
,
roundNum
+
1
-
remindLength
);
}
bdDiff
=
new
BigDecimal
(
truncValue
);
bdDiff
=
bdDiff
.
subtract
(
new
BigDecimal
(
"0.5"
).
scaleByPowerOfTen
(-
roundNum
)).
abs
();
int
signValue
=
Integer
.
valueOf
(
value
).
compareTo
(
0
);
BigDecimal
significance
=
new
BigDecimal
(
"2"
).
scaleByPowerOfTen
(-
roundNum
).
multiply
(
BigDecimal
.
valueOf
(
signValue
)).
abs
();
// ceiling
BigDecimal
[]
result
=
bdDiff
.
divideAndRemainder
(
significance
);
if
(
result
[
1
].
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
cell
.
setCellValue
(
bdDiff
.
toPlainString
());
}
else
{
cell
.
setCellValue
(
result
[
0
].
add
(
BigDecimal
.
ONE
).
multiply
(
significance
).
setScale
(
roundNum
).
toPlainString
());
}
}
}
}
}
src/main/java/com/patzn/cloud/service/lims/hmhj/original/SingleSheetMoreItemOperation.java
View file @
a7fe5e1d
This diff is collapsed.
Click to expand it.
src/main/java/com/patzn/cloud/service/lims/hmhj/original/SingleSheetMoreOperation.java
View file @
a7fe5e1d
This diff is collapsed.
Click to expand it.
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/EntrustSampleItemServiceImpl.java
View file @
a7fe5e1d
...
@@ -1199,9 +1199,20 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
...
@@ -1199,9 +1199,20 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
String
objectKey
=
entry
.
getKey
();
String
objectKey
=
entry
.
getKey
();
Long
reportId
=
entry
.
getValue
();
Long
reportId
=
entry
.
getValue
();
entrustReport
.
setId
(
reportId
);
entrustReport
.
setId
(
reportId
);
Map
<
String
,
String
>
sampleMap
=
reportSampleList
.
stream
().
filter
(
t
->
t
.
getObjectKey
().
equals
(
objectKey
)).
collect
(
Collectors
.
toMap
(
t
->
{
Map
<
String
,
String
>
sampleMap
=
null
;
return
finalIsOther
?
t
.
getFirstCode
()
:
t
.
getSampleCode
();
// 根据是否一级编码确定使用得objectKey
},
ReportSampleVO:
:
getSampleGrading
));
if
(
finalIsOther
)
{
sampleMap
=
reportSampleList
.
stream
().
filter
(
t
->
t
.
getOtherObjectKey
().
equals
(
objectKey
)).
collect
(
Collectors
.
toMap
(
ReportSampleVO:
:
getFirstCode
,
ReportSampleVO:
:
getSampleGrading
));
}
else
{
sampleMap
=
reportSampleList
.
stream
().
filter
(
t
->
t
.
getObjectKey
().
equals
(
objectKey
)).
collect
(
Collectors
.
toMap
(
t
->
{
if
(
StringUtils
.
isNotBlank
(
t
.
getThirdCode
()))
{
return
t
.
getThirdCode
();
}
else
if
(
StringUtils
.
isNotBlank
(
t
.
getSecondCode
()))
{
return
t
.
getSecondCode
();
}
return
t
.
getFirstCode
();
},
ReportSampleVO:
:
getSampleGrading
));
}
if
(
StringUtils
.
isBlank
(
objectKey
))
{
if
(
StringUtils
.
isBlank
(
objectKey
))
{
continue
;
continue
;
...
@@ -1306,7 +1317,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
...
@@ -1306,7 +1317,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
private
void
updateJudgeNoPass
(
EntrustSample
sample
,
Account
account
,
List
<
EntrustSample
>
sampleList
)
{
private
void
updateJudgeNoPass
(
EntrustSample
sample
,
Account
account
,
List
<
EntrustSample
>
sampleList
)
{
sampleList
.
add
(
sample
.
setOkJudge
(
"不合格"
).
setJudger
(
account
.
getUserName
()).
setJudgerId
(
account
.
getUserId
())
sampleList
.
add
(
sample
.
setOkJudge
(
"不合格"
).
setJudger
(
account
.
getUserName
()).
setJudgerId
(
account
.
getUserId
())
.
setJudgeTime
(
new
Date
()).
setJudgeStatus
(
0
).
setJudgeProgress
(
0
)
.
setJudgeTime
(
new
Date
()).
setJudgeStatus
(
0
).
setJudgeProgress
(
0
)
.
setSampleGrading
(
"
-
"
));
.
setSampleGrading
(
"
等外
"
));
}
}
...
...
src/test/java/com/patzn/cloud/service/lims/test/Test.java
View file @
a7fe5e1d
package
com
.
patzn
.
cloud
.
service
.
lims
.
test
;
package
com
.
patzn
.
cloud
.
service
.
lims
.
test
;
import
com.patzn.cloud.service.lims.common.DateKit
;
import
com.patzn.cloud.service.lims.common.StringHandleUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.List
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
public
class
Test
{
public
class
Test
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
List
<
String
>
dateList
=
DateKit
.
dateInMonth
(
"2021-09"
);
System
.
out
.
println
(
getTestValue
(
"0.1841"
,
2
));
dateList
.
stream
().
forEach
(
System
.
out
::
print
);
System
.
out
.
println
(
getTestValue
(
"0.1952"
,
2
));
System
.
out
.
println
(
getTestValue
(
"0.2056"
,
2
));
}
private
static
String
getTestValue
(
String
value
,
int
roundNum
)
{
if
(
StringUtils
.
isNotBlank
(
value
))
{
if
(!
StringHandleUtils
.
validateNumber
(
value
))
{
if
(
value
.
startsWith
(
"!"
))
{
value
=
value
.
substring
(
1
);
}
else
{
return
value
;
}
}
// IF(ABS(TRUNC(A1,B1+5)*10^B1-TRUNC(A1,B1+5)*10^B1)<0.499999,ROUND(A1,B1),
// IF(ABS(TRUNC(A1,B1+5)*10^B1-TRUNC(A1,B1+5)*10^B1)>0.500001,ROUND(A1,B1),
// CEILING(ABS(TRUNC(A1,B1+1)-0.5*10^(-B1),2*10^(-B1)*SIGN(A1)))
int
beginIndex
=
value
.
lastIndexOf
(
"."
)
+
1
,
valueLength
=
value
.
length
();
int
remindLength
=
valueLength
-
beginIndex
;
String
truncValue
=
""
,
zeroStr
=
"000000000"
;
// bdA = TRUNC(A1,B1+5)*10^B1
if
(
remindLength
>=
roundNum
+
5
)
{
truncValue
=
"0."
+
value
.
substring
(
beginIndex
,
beginIndex
+
roundNum
+
5
);
}
else
{
truncValue
=
"0."
+
value
.
substring
(
beginIndex
)
+
zeroStr
.
substring
(
0
,
roundNum
+
5
-
remindLength
);
}
BigDecimal
bdDiff
=
new
BigDecimal
(
truncValue
).
scaleByPowerOfTen
(
roundNum
);
// bdB = TRUNC(A1,B1+5)*10^B1
if
(
remindLength
>=
roundNum
)
{
truncValue
=
"0."
+
value
.
substring
(
beginIndex
,
beginIndex
+
roundNum
);
}
else
{
truncValue
=
"0."
+
value
.
substring
(
beginIndex
)
+
zeroStr
.
substring
(
0
,
roundNum
-
remindLength
);
}
bdDiff
=
bdDiff
.
subtract
(
new
BigDecimal
(
truncValue
).
scaleByPowerOfTen
(
roundNum
)).
abs
();
// 若 < 0.499999 或 大于 0.500001
if
(
bdDiff
.
compareTo
(
new
BigDecimal
(
"0.499999"
))
<
0
||
bdDiff
.
compareTo
(
new
BigDecimal
(
"0.500001"
))
>
0
)
{
return
new
BigDecimal
(
value
).
setScale
(
roundNum
,
RoundingMode
.
HALF_EVEN
).
toPlainString
();
}
// 处理第三种情况
// CEILING(ABS(TRUNC(A1,B1+1)-0.5*10^(-B1),2*10^(-B1)*SIGN(A1))
if
(
remindLength
>=
roundNum
+
1
)
{
truncValue
=
"0."
+
value
.
substring
(
beginIndex
,
beginIndex
+
roundNum
+
1
);
}
else
{
truncValue
=
"0."
+
value
.
substring
(
beginIndex
)
+
zeroStr
.
substring
(
0
,
roundNum
+
1
-
remindLength
);
}
bdDiff
=
new
BigDecimal
(
truncValue
);
bdDiff
=
bdDiff
.
subtract
(
new
BigDecimal
(
"0.5"
).
scaleByPowerOfTen
(-
roundNum
)).
abs
();
int
signValue
=
Double
.
valueOf
(
value
).
compareTo
(
0.0
);
BigDecimal
significance
=
new
BigDecimal
(
"2"
).
scaleByPowerOfTen
(-
roundNum
).
multiply
(
BigDecimal
.
valueOf
(
signValue
)).
abs
();
// ceiling
BigDecimal
[]
result
=
bdDiff
.
divideAndRemainder
(
significance
);
if
(
result
[
1
].
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
return
bdDiff
.
setScale
(
roundNum
).
toPlainString
();
}
else
{
return
result
[
0
].
add
(
BigDecimal
.
ONE
).
multiply
(
significance
).
setScale
(
roundNum
).
toPlainString
();
}
}
return
value
;
}
private
static
String
rounding
(
String
value
,
Integer
roundNum
)
{
if
(
StringUtils
.
isNotBlank
(
value
))
{
if
(!
StringHandleUtils
.
validateNumber
(
value
))
{
if
(
value
.
startsWith
(
"!"
))
{
value
=
value
.
substring
(
1
);
}
else
{
return
value
;
}
}
BigDecimal
bd1
=
new
BigDecimal
(
value
);
BigDecimal
bd2
=
bd1
.
setScale
(
roundNum
,
BigDecimal
.
ROUND_HALF_EVEN
);
return
bd2
.
toPlainString
();
}
return
""
;
}
}
}
}
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