Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zhny
Project
Project
Details
Activity
Releases
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
王夏晖
zhny
Commits
6fab7ef5
Commit
6fab7ef5
authored
May 16, 2018
by
jichao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上传参数模板,当没有参数code时,不保存
parent
c72c009d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
32 deletions
+37
-32
ParamLibraryServiceImpl.java
...te/paramlibrary/service/impl/ParamLibraryServiceImpl.java
+37
-32
No files found.
src/main/java/org/rcisoft/business/mainte/paramlibrary/service/impl/ParamLibraryServiceImpl.java
View file @
6fab7ef5
...
...
@@ -132,42 +132,47 @@ public class ParamLibraryServiceImpl implements ParamLibraryService {
String
code1
=
this
.
getCode
(
sheet
,
3
),
code2
=
this
.
getCode
(
sheet
,
4
),
code3
=
this
.
getCode
(
sheet
,
5
);
//读取需要保存的数据
for
(
int
i
=
8
;
i
<
sheet
.
getLastRowNum
()
+
1
;
i
++)
{
BusParamLibrary
b
=
new
BusParamLibrary
();
HSSFRow
row
=
sheet
.
getRow
(
i
);
if
(
row
!=
null
)
{
String
power
=
this
.
getValue
(
row
.
getCell
(
1
));
//功率
String
speed
=
this
.
getValue
(
row
.
getCell
(
2
));
//用气速率
String
code1Value
=
this
.
getValue
(
row
.
getCell
(
3
));
//参数1
String
code2Value
=
this
.
getValue
(
row
.
getCell
(
4
));
//参数2
String
code3Value
=
this
.
getValue
(
row
.
getCell
(
5
));
//参数3
//如果都为null,表明已经没有数据,跳出循环
if
(
power
==
null
&&
speed
==
null
&&
code1Value
==
null
&&
code2Value
==
null
&&
code3Value
==
null
)
break
;
//赋值
//如果code1、2、3都没有值,表示没有添加参数模板
if
(
code1
==
null
&&
code2
==
null
&&
code3
==
null
)
{
}
else
{
//读取需要保存的数据
for
(
int
i
=
8
;
i
<
sheet
.
getLastRowNum
()
+
1
;
i
++)
{
BusParamLibrary
b
=
new
BusParamLibrary
();
HSSFRow
row
=
sheet
.
getRow
(
i
);
if
(
row
!=
null
)
{
String
power
=
this
.
getValue
(
row
.
getCell
(
1
));
//功率
String
speed
=
this
.
getValue
(
row
.
getCell
(
2
));
//用气速率
String
code1Value
=
this
.
getValue
(
row
.
getCell
(
3
));
//参数1
String
code2Value
=
this
.
getValue
(
row
.
getCell
(
4
));
//参数2
String
code3Value
=
this
.
getValue
(
row
.
getCell
(
5
));
//参数3
//如果都为null,表明已经没有数据,跳出循环
if
(
power
==
null
&&
speed
==
null
&&
code1Value
==
null
&&
code2Value
==
null
&&
code3Value
==
null
)
break
;
//赋值
b
.
setDevNum
(
devNum
);
b
.
setPower
(
power
==
null
?
null
:
new
BigDecimal
(
power
));
b
.
setGasSpeed
(
speed
==
null
?
null
:
new
BigDecimal
(
speed
));
b
.
setYear
(
year
);
b
.
setP1
(
code1
);
b
.
setP1V
(
code1Value
==
null
?
null
:
new
BigDecimal
(
code1Value
));
b
.
setP2
(
code2
);
b
.
setP2V
(
code2Value
==
null
?
null
:
new
BigDecimal
(
code2Value
));
b
.
setP3
(
code3
);
b
.
setP3V
(
code3Value
==
null
?
null
:
new
BigDecimal
(
code3Value
));
resultList
.
add
(
b
);
}
}
//先删除数据库的数据,再保存
if
(
resultList
.
size
()
>
0
)
{
BusParamLibrary
b
=
new
BusParamLibrary
();
b
.
setDevNum
(
devNum
);
b
.
setPower
(
power
==
null
?
null
:
new
BigDecimal
(
power
));
b
.
setGasSpeed
(
speed
==
null
?
null
:
new
BigDecimal
(
speed
));
b
.
setYear
(
year
);
b
.
setP1
(
code1
);
b
.
setP1V
(
code1Value
==
null
?
null
:
new
BigDecimal
(
code1Value
));
b
.
setP2
(
code2
);
b
.
setP2V
(
code2Value
==
null
?
null
:
new
BigDecimal
(
code2Value
));
b
.
setP3
(
code3
);
b
.
setP3V
(
code3Value
==
null
?
null
:
new
BigDecimal
(
code3Value
));
resultList
.
add
(
b
);
//先删除
paramLibraryRepository
.
delete
(
b
);
//添加
result
=
paramLibraryRepository
.
saveBusParamLibraryList
(
resultList
);
}
}
//先删除数据库的数据,再保存
if
(
resultList
.
size
()
>
0
)
{
BusParamLibrary
b
=
new
BusParamLibrary
();
b
.
setDevNum
(
devNum
);
b
.
setYear
(
year
);
//先删除
paramLibraryRepository
.
delete
(
b
);
//添加
result
=
paramLibraryRepository
.
saveBusParamLibraryList
(
resultList
);
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
...
...
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