Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
H
hzsomms
Project
Project
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
ZTGK
hzsomms
Commits
fb2ad3f6
Commit
fb2ad3f6
authored
Aug 27, 2024
by
史志龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
道岔导入检查--shizhilong
parent
2bc30023
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
9 deletions
+81
-9
RecordsMasterCheckController.java
...es/checkData/controller/RecordsMasterCheckController.java
+34
-6
ExcelAnalysisUtils.java
...main/java/org/jeecg/modules/utils/ExcelAnalysisUtils.java
+47
-3
No files found.
jeecg-module-system/src/main/java/org/jeecg/modules/checkData/controller/RecordsMasterCheckController.java
View file @
fb2ad3f6
...
@@ -70,6 +70,7 @@ public class RecordsMasterCheckController extends JeecgController<RecordsMasterC
...
@@ -70,6 +70,7 @@ public class RecordsMasterCheckController extends JeecgController<RecordsMasterC
private
ICorrugationRecordService
corrugationRecordService
;
private
ICorrugationRecordService
corrugationRecordService
;
//********************************设备检查记录相关接口*************************************************************
//********************************设备检查记录相关接口*************************************************************
/**
/**
* 设备线路检查记录汇总-分页列表查询
* 设备线路检查记录汇总-分页列表查询
*
*
...
@@ -274,7 +275,34 @@ public class RecordsMasterCheckController extends JeecgController<RecordsMasterC
...
@@ -274,7 +275,34 @@ public class RecordsMasterCheckController extends JeecgController<RecordsMasterC
InputStream
in
=
file
.
getInputStream
();
InputStream
in
=
file
.
getInputStream
();
//读取Excel中的数据
//读取Excel中的数据
List
<
List
<
Object
>>
rowRecords
=
ExcelAnalysisUtils
.
getListByExcel
(
in
);
Map
<
String
,
Object
>
map
=
ExcelAnalysisUtils
.
getListByExcel2
(
in
);
List
<
List
<
Object
>>
rowRecords
=
(
List
<
List
<
Object
>>)
map
.
get
(
"result"
);
//校验导入数据的合法性
// List<Object> list1 = rowRecords.get(2);
// String str1 = list1.get(0).toString().trim();
// if (!str1.contains("道岔编号")) {
// return Result.error("导入模板错误,请重新导入!");
// }
// List<Object> list2 = rowRecords.get(3);
// String str2 = list2.get(0).toString().trim();
// if (!str2.contains("道岔号数")) {
// return Result.error("导入模板错误,请重新导入!");
// }
Integer
num
=
0
;
for
(
int
i
=
0
;
i
<
rowRecords
.
size
();
i
++)
{
List
<
Object
>
list
=
rowRecords
.
get
(
i
);
String
str
=
list
.
get
(
0
).
toString
().
trim
();
if
(
str
.
contains
(
"道岔编号"
))
{
num
=
num
+
1
;
}
}
Integer
listByExcelNum
=
(
Integer
)
map
.
get
(
"num"
);
if
(
listByExcelNum
!=
num
){
//释放资源
in
.
close
();
return
Result
.
error
(
"导入模板内容错误,请重新导入"
);
}
//获取当前登录人信息
//获取当前登录人信息
LoginUser
user
=
(
LoginUser
)
SecurityUtils
.
getSubject
().
getPrincipal
();
LoginUser
user
=
(
LoginUser
)
SecurityUtils
.
getSubject
().
getPrincipal
();
String
realname
=
user
.
getRealname
();
String
realname
=
user
.
getRealname
();
...
@@ -327,13 +355,13 @@ public class RecordsMasterCheckController extends JeecgController<RecordsMasterC
...
@@ -327,13 +355,13 @@ public class RecordsMasterCheckController extends JeecgController<RecordsMasterC
List
<
Object
>
flangeList
=
rowRecords
.
get
(
i
+
2
);
List
<
Object
>
flangeList
=
rowRecords
.
get
(
i
+
2
);
this
.
uploadFlange
(
recordsMasterTurnoutInfoList
,
flangeList
,
realname
,
id
,
switchCode
,
switchCodeNum
);
this
.
uploadFlange
(
recordsMasterTurnoutInfoList
,
flangeList
,
realname
,
id
,
switchCode
,
switchCodeNum
);
}
else
if
(
str
.
equals
(
"2.1"
))
{
}
else
if
(
str
.
equals
(
"2.1"
))
{
this
.
uploadSwitchPlate
(
recordsMasterTurnoutInfoList
,
list
,
realname
,
id
,
"5"
,
switchCode
,
switchCodeNum
);
this
.
uploadSwitchPlate
(
recordsMasterTurnoutInfoList
,
list
,
realname
,
id
,
"5"
,
switchCode
,
switchCodeNum
);
}
else
if
(
str
.
equals
(
"2.2"
))
{
}
else
if
(
str
.
equals
(
"2.2"
))
{
this
.
uploadSwitchPlate
(
recordsMasterTurnoutInfoList
,
list
,
realname
,
id
,
"6"
,
switchCode
,
switchCodeNum
);
this
.
uploadSwitchPlate
(
recordsMasterTurnoutInfoList
,
list
,
realname
,
id
,
"6"
,
switchCode
,
switchCodeNum
);
}
else
if
(
str
.
equals
(
"3.1"
))
{
}
else
if
(
str
.
equals
(
"3.1"
))
{
this
.
uploadSwitchPlate
(
recordsMasterTurnoutInfoList
,
list
,
realname
,
id
,
"7"
,
switchCode
,
switchCodeNum
);
this
.
uploadSwitchPlate
(
recordsMasterTurnoutInfoList
,
list
,
realname
,
id
,
"7"
,
switchCode
,
switchCodeNum
);
}
else
if
(
str
.
equals
(
"3.2"
))
{
}
else
if
(
str
.
equals
(
"3.2"
))
{
this
.
uploadSwitchPlate
(
recordsMasterTurnoutInfoList
,
list
,
realname
,
id
,
"8"
,
switchCode
,
switchCodeNum
);
this
.
uploadSwitchPlate
(
recordsMasterTurnoutInfoList
,
list
,
realname
,
id
,
"8"
,
switchCode
,
switchCodeNum
);
}
else
{
}
else
{
if
(
i
!=
rowRecords
.
size
()
-
1
)
{
if
(
i
!=
rowRecords
.
size
()
-
1
)
{
continue
;
continue
;
...
@@ -572,7 +600,7 @@ public class RecordsMasterCheckController extends JeecgController<RecordsMasterC
...
@@ -572,7 +600,7 @@ public class RecordsMasterCheckController extends JeecgController<RecordsMasterC
* @param realname
* @param realname
* @param id
* @param id
*/
*/
public
void
uploadSwitchPlate
(
List
<
RecordsMasterTurnoutInfo
>
recordsMasterTurnoutInfoList
,
List
<
Object
>
list
,
String
realname
,
String
id
,
String
type
,
String
switchCode
,
String
switchCodeNum
)
{
public
void
uploadSwitchPlate
(
List
<
RecordsMasterTurnoutInfo
>
recordsMasterTurnoutInfoList
,
List
<
Object
>
list
,
String
realname
,
String
id
,
String
type
,
String
switchCode
,
String
switchCodeNum
)
{
String
str1
=
list
.
get
(
1
).
toString
().
trim
();
String
str1
=
list
.
get
(
1
).
toString
().
trim
();
String
[]
n
=
str1
.
split
(
"þ"
);
String
[]
n
=
str1
.
split
(
"þ"
);
String
s
=
n
[
0
];
String
s
=
n
[
0
];
...
...
jeecg-module-system/src/main/java/org/jeecg/modules/utils/ExcelAnalysisUtils.java
View file @
fb2ad3f6
...
@@ -3,9 +3,8 @@ package org.jeecg.modules.utils;
...
@@ -3,9 +3,8 @@ package org.jeecg.modules.utils;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.List
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.DateUtil
;
import
org.apache.poi.ss.usermodel.DateUtil
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Row
;
...
@@ -59,6 +58,51 @@ public class ExcelAnalysisUtils {
...
@@ -59,6 +58,51 @@ public class ExcelAnalysisUtils {
return
list
;
return
list
;
}
}
/**
* @Description:获取IO流中的数据,组装成List<List<Object>>对象
*/
public
static
Map
<
String
,
Object
>
getListByExcel2
(
InputStream
in
)
throws
Exception
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
List
<
List
<
Object
>>
list
;
//创建Excel工作薄
Workbook
work
=
new
XSSFWorkbook
(
in
);
Sheet
sheet
;
//页数
Row
row
;
//行数
Cell
cell
;
//列数
list
=
new
ArrayList
<>();
//遍历Excel中所有的sheet
for
(
int
i
=
0
;
i
<
work
.
getNumberOfSheets
();
i
++)
{
sheet
=
work
.
getSheetAt
(
i
);
if
(
sheet
==
null
)
{
continue
;
}
//遍历当前sheet中的所有行
for
(
int
j
=
sheet
.
getFirstRowNum
();
j
<=
sheet
.
getLastRowNum
();
j
++)
{
row
=
sheet
.
getRow
(
j
);
if
(
row
==
null
)
{
continue
;
}
//遍历所有的列
List
<
Object
>
li
=
new
ArrayList
<>();
for
(
int
y
=
row
.
getFirstCellNum
();
y
<
row
.
getLastCellNum
();
y
++)
{
cell
=
row
.
getCell
(
y
);
li
.
add
(
getValue
(
cell
));
}
list
.
add
(
li
);
}
}
map
.
put
(
"result"
,
list
);
map
.
put
(
"num"
,
work
.
getNumberOfSheets
());
return
map
;
}
/**
/**
* 对表格中数值进行格式化 解决excel类型问题,获得数值
* 对表格中数值进行格式化 解决excel类型问题,获得数值
*/
*/
...
...
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