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
67a296cf
Commit
67a296cf
authored
Dec 19, 2020
by
wangweidong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
土工平台修改
parent
0e3e8b3f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
8 deletions
+81
-8
StringHandleUtils.java
...om/patzn/cloud/service/lims/common/StringHandleUtils.java
+10
-4
SoilExperimentServiceImpl.java
...ice/lims/soil/service/impl/SoilExperimentServiceImpl.java
+66
-2
SoilOriginalTemplateServiceImpl.java
...ms/soil/service/impl/SoilOriginalTemplateServiceImpl.java
+5
-2
No files found.
src/main/java/com/patzn/cloud/service/lims/common/StringHandleUtils.java
View file @
67a296cf
...
...
@@ -21,6 +21,8 @@ import java.util.regex.Pattern;
* @author wwd
*/
public
class
StringHandleUtils
{
public
static
String
getContinuousStringData
(
String
[]
intString
,
String
stringPre
)
{
StringBuffer
result
=
new
StringBuffer
();
...
...
@@ -65,6 +67,14 @@ public class StringHandleUtils {
}
public
static
boolean
is_alpha
(
String
str
)
{
if
(
str
==
null
)
return
false
;
String
regex
=
"[\u4e00-\u9fa5]"
;
//汉字的Unicode取值范围
Pattern
pattern
=
Pattern
.
compile
(
regex
);
Matcher
match
=
pattern
.
matcher
(
str
);
return
!
match
.
find
();
}
public
static
String
getNumFromString
(
String
str
)
{
String
regEx
=
"[^0-9]"
;
...
...
@@ -565,9 +575,5 @@ public class StringHandleUtils {
}
public
boolean
is_alpha
(
String
str
)
{
if
(
str
==
null
)
return
false
;
return
str
.
matches
(
"[a-zA-Z]+"
);
}
}
src/main/java/com/patzn/cloud/service/lims/soil/service/impl/SoilExperimentServiceImpl.java
View file @
67a296cf
...
...
@@ -84,6 +84,10 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
@Autowired
private
ISoilItemService
soilItemService
;
@Autowired
private
ISoilExpReportTemplateConfigService
soilExpReportTemplateConfigService
;
...
...
@@ -530,6 +534,24 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
RestAssert
.
fail
(
"试验项目不存在"
);
}
List
<
Long
>
expIdsList
=
expVOList
.
stream
().
map
(
e
->{
return
e
.
getId
();
}).
collect
(
Collectors
.
toList
());
List
<
SoilItem
>
soilItemList
=
soilItemService
.
list
(
Condition
.
create
().
in
(
"experiment_id"
,
expIdsList
));
if
(
CollectionUtils
.
isNotEmpty
(
soilItemList
)){
for
(
SoilExperimentVO
experimentVO:
expVOList
)
{
List
<
SoilItem
>
itemList
=
new
ArrayList
<>();
Long
expId
=
experimentVO
.
getId
();
for
(
SoilItem
soilItem:
soilItemList
)
{
if
(
expId
.
equals
(
soilItem
.
getExperimentId
())){
itemList
.
add
(
soilItem
);
}
}
experimentVO
.
setItemList
(
itemList
);
}
}
InputStream
io
=
ossClient
.
download
(
template
.
getObjectKey
());
RestAssert
.
fail
(
null
==
io
,
"模板不存在"
);
...
...
@@ -562,11 +584,34 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
int
rowBegin
=
sampleBeginRow
;
for
(
SoilExperimentVO
vo:
expVOList
)
{
XSSFRow
row
=
xssfSheet
.
getRow
(
rowBegin
);
List
<
SoilItem
>
itemList
=
vo
.
getItemList
();
for
(
SoilExpReportTemplateConfig
config:
configList
)
{
XSSFCell
cell
=
row
.
getCell
(
config
.
getColumnPlace
());
cell
.
setCellValue
(
StringHandleUtils
.
getFieldIfNummReturnBlankValueByFieldName
(
config
.
getDataAttribute
(),
vo
));
String
prepory
=
config
.
getDataAttribute
();
if
(
StringUtils
.
isNotBlank
(
prepory
)){
if
(
StringHandleUtils
.
is_alpha
(
prepory
)){
cell
.
setCellValue
(
StringHandleUtils
.
getFieldIfNummReturnBlankValueByFieldName
(
prepory
,
vo
));
}
else
{
if
(
CollectionUtils
.
isNotEmpty
(
itemList
)){
for
(
SoilItem
item:
itemList
)
{
if
(
prepory
.
equals
(
item
.
getName
())){
cell
.
setCellValue
(
item
.
getTestValue
());
break
;
}
}
}
}
}
}
rowBegin
+=
dataTotalRow
;
}
}
else
{
int
insertRowNum
=
expVOList
.
size
()
-
templateSampleNum
;
...
...
@@ -621,9 +666,28 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
int
rowBegin
=
sampleBeginRow
;
for
(
SoilExperimentVO
vo:
expVOList
)
{
XSSFRow
row
=
xssfSheet
.
getRow
(
rowBegin
);
List
<
SoilItem
>
itemList
=
vo
.
getItemList
();
for
(
SoilExpReportTemplateConfig
config:
configList
)
{
XSSFCell
cell
=
row
.
getCell
(
config
.
getColumnPlace
());
cell
.
setCellValue
(
StringHandleUtils
.
getFieldIfNummReturnBlankValueByFieldName
(
config
.
getDataAttribute
(),
vo
));
String
prepory
=
config
.
getDataAttribute
();
if
(
StringUtils
.
isNotBlank
(
prepory
)){
if
(
StringHandleUtils
.
is_alpha
(
prepory
)){
cell
.
setCellValue
(
StringHandleUtils
.
getFieldIfNummReturnBlankValueByFieldName
(
prepory
,
vo
));
}
else
{
if
(
CollectionUtils
.
isNotEmpty
(
itemList
)){
for
(
SoilItem
item:
itemList
)
{
if
(
prepory
.
equals
(
item
.
getName
())){
cell
.
setCellValue
(
item
.
getTestValue
());
break
;
}
}
}
}
}
}
rowBegin
+=
dataTotalRow
;
}
...
...
src/main/java/com/patzn/cloud/service/lims/soil/service/impl/SoilOriginalTemplateServiceImpl.java
View file @
67a296cf
...
...
@@ -15,6 +15,8 @@ import com.patzn.poibox.xwpf.HSSFWorkbookUtil;
import
org.apache.bcel.generic.IF_ACMPEQ
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.ss.usermodel.DataFormatter
;
import
org.apache.poi.ss.usermodel.FormulaEvaluator
;
import
org.apache.poi.xssf.usermodel.XSSFCell
;
import
org.apache.poi.xssf.usermodel.XSSFRow
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
...
...
@@ -307,6 +309,8 @@ public class SoilOriginalTemplateServiceImpl extends BaseServiceImpl<SoilOrigina
List
<
SoilItemCollectData
>
soilItemList
=
new
ArrayList
<>();
DataFormatter
formatter
=
new
DataFormatter
();
FormulaEvaluator
evaluator
=
xssfWorkbook
.
getCreationHelper
().
createFormulaEvaluator
();
for
(
int
i
=
sampleBeginRow
;
i
<
lastRowNum
;
i
+=
sampleMergerNum
)
{
XSSFRow
xssfRow
=
sheet
.
getRow
(
i
);
XSSFCell
sampleCodeCell
=
xssfRow
.
getCell
(
sampleCol
);
...
...
@@ -314,8 +318,7 @@ public class SoilOriginalTemplateServiceImpl extends BaseServiceImpl<SoilOrigina
for
(
ItemCollectEntity
collectEntity:
collectEntitiesList
)
{
XSSFCell
itemCell
=
xssfRow
.
getCell
(
collectEntity
.
getColumnPlace
());
String
value
=
HSSFWorkbookUtil
.
getJavaValue
(
itemCell
).
toString
();
String
value
=
formatter
.
formatCellValue
(
itemCell
,
evaluator
);
String
itemName
=
collectEntity
.
getItemName
();
if
(
StringUtils
.
isBlank
(
value
)){
continue
;
...
...
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