Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
map-parent
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
常超
map-parent
Commits
0b663726
Commit
0b663726
authored
Jul 14, 2021
by
Jbb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码健壮性的考虑
parent
e4a43ce2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
16 deletions
+21
-16
common/common_utils/src/main/java/com/founder/commonutils/viewEntity/TbStLayer.java
+2
-2
service/view/src/main/java/com/founder/view/controller/TbStLayerDataController.java
+19
-14
No files found.
common/common_utils/src/main/java/com/founder/commonutils/viewEntity/TbStLayer.java
View file @
0b663726
...
...
@@ -22,11 +22,11 @@ public class TbStLayer extends PageInfo {
private
Double
threshold
;
private
String
lrr
;
private
String
lrdwdm
;
private
String
lrdw
d
c
;
private
String
lrdw
m
c
;
private
Date
lrsj
;
private
String
gxr
;
private
String
gxdwdm
;
private
String
gxdw
d
c
;
private
String
gxdw
m
c
;
private
Date
gxsj
;
private
List
<
TbStLayerData
>
stLayerDataList
;
private
String
startTime
;
...
...
service/view/src/main/java/com/founder/view/controller/TbStLayerDataController.java
View file @
0b663726
...
...
@@ -48,14 +48,14 @@ public class TbStLayerDataController {
* @param threshold
* @param lrr
* @param lrdwdm
* @param lrdw
d
c
* @param lrdw
m
c
* @return
*/
@RequestMapping
(
"/uploadExcel"
)
public
MapRestResult
uploadDown
(
@RequestParam
(
"excelFile"
)
MultipartFile
excelFile
,
@RequestParam
(
required
=
false
)
String
xxzjbh
,
@RequestParam
(
required
=
false
)
String
name
,
@RequestParam
(
required
=
false
)
Double
threshold
,
@RequestParam
(
required
=
false
)
String
lrr
,
@RequestParam
(
required
=
false
)
String
lrdwdm
,
@RequestParam
(
required
=
false
)
String
lrdw
d
c
)
{
@RequestParam
(
required
=
false
)
String
lrdw
m
c
)
{
TbStLayer
tbStLayer
=
new
TbStLayer
();
List
<
TbStLayerData
>
pointLists
=
null
;
String
layerId
=
xxzjbh
;
...
...
@@ -71,7 +71,7 @@ public class TbStLayerDataController {
tbStLayer
.
setThreshold
(
threshold
);
tbStLayer
.
setLrr
(
lrr
);
tbStLayer
.
setLrdwdm
(
lrdwdm
);
tbStLayer
.
setLrdw
dc
(
lrdwd
c
);
tbStLayer
.
setLrdw
mc
(
lrdwm
c
);
tbStLayer
.
setLrsj
(
new
Date
());
tbStLayerService
.
save
(
tbStLayer
);
is
=
excelFile
.
getInputStream
();
...
...
@@ -84,7 +84,7 @@ public class TbStLayerDataController {
}
return
MapRestResult
.
build
(
200
,
"数据上传成功!"
,
pointLists
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
//
e.printStackTrace();
//如果保存数据、poi生成excel失败了就将之前的数据删除....
tbStLayerService
.
removeById
(
layerId
);
accidentPointService
.
deleteByGlId
(
layerId
);
...
...
@@ -123,29 +123,32 @@ public class TbStLayerDataController {
dateStr = row.getCell(3).getStringCellValue();
System.out.println(jd + "====" + wd + "====" + titleStr + "====" + dateStr);
}*/
//经纬度不能为空 否则报错 每一行都判断单元格是否为空 设置单元格格式 是因为不知道哪一个会为空
if
(
row
.
getCell
(
0
)
!=
null
&&
row
.
getCell
(
1
)
!=
null
)
{
row
.
getCell
(
0
).
setCellType
(
Cell
.
CELL_TYPE_STRING
);
row
.
getCell
(
1
).
setCellType
(
Cell
.
CELL_TYPE_STRING
);
row
.
getCell
(
2
).
setCellType
(
Cell
.
CELL_TYPE_STRING
);
row
.
getCell
(
3
).
setCellType
(
Cell
.
CELL_TYPE_STRING
);
try
{
//验证经纬度是否是八位小数以内
boolean
isTrue
=
LngLonUtil
.
verifyLongAndLat
(
Double
.
parseDouble
(
row
.
getCell
(
0
).
getStringCellValue
()),
Double
.
parseDouble
(
row
.
getCell
(
1
).
getStringCellValue
()));
if
(
isTrue
)
{
//这里可以不用for循环 因为excel列数比较少
for
(
int
j
=
0
;
j
<
lastCellNum
;
j
++)
{
if
(
j
==
0
)
{
if
(
j
==
0
&&
row
.
getCell
(
0
)
!=
null
)
{
row
.
getCell
(
0
).
setCellType
(
Cell
.
CELL_TYPE_STRING
);
double
x
=
Double
.
parseDouble
(
row
.
getCell
(
0
).
getStringCellValue
());
point
.
setX
(
x
);
}
if
(
j
==
1
)
{
if
(
j
==
1
&&
row
.
getCell
(
1
)
!=
null
)
{
row
.
getCell
(
1
).
setCellType
(
Cell
.
CELL_TYPE_STRING
);
double
y
=
Double
.
parseDouble
(
row
.
getCell
(
1
).
getStringCellValue
());
point
.
setY
(
y
);
}
if
(
j
==
2
)
{
if
(
j
==
2
&&
row
.
getCell
(
2
)
!=
null
)
{
row
.
getCell
(
2
).
setCellType
(
Cell
.
CELL_TYPE_STRING
);
String
title
=
row
.
getCell
(
2
).
getStringCellValue
();
point
.
setTitle
(
title
);
}
if
(
j
==
3
)
{
if
(
j
==
3
&&
row
.
getCell
(
3
)
!=
null
)
{
row
.
getCell
(
3
).
setCellType
(
Cell
.
CELL_TYPE_STRING
);
String
dateTimeStr
=
row
.
getCell
(
3
).
getStringCellValue
();
if
(
dateTimeStr
!=
""
){
Date
dateTime
=
df
.
parse
(
dateTimeStr
);
...
...
@@ -172,19 +175,21 @@ public class TbStLayerDataController {
y
=
Double
.
parseDouble
(
row
.
getCell
(
1
).
getStringCellValue
());
}
for
(
int
j
=
0
;
j
<
lastCellNum
;
j
++)
{
if
(
j
==
0
)
{
if
(
j
==
0
&&
row
.
getCell
(
0
)
!=
null
)
{
//x = row.getCell(0).getNumericCellValue();
point
.
setX
(
x
);
}
if
(
j
==
1
)
{
if
(
j
==
1
&&
row
.
getCell
(
1
)
!=
null
)
{
//y = row.getCell(1).getNumericCellValue();
point
.
setY
(
y
);
}
if
(
j
==
2
)
{
if
(
j
==
2
&&
row
.
getCell
(
2
)
!=
null
)
{
row
.
getCell
(
2
).
setCellType
(
Cell
.
CELL_TYPE_STRING
);
String
title
=
row
.
getCell
(
2
).
getStringCellValue
();
point
.
setTitle
(
title
);
}
if
(
j
==
3
)
{
if
(
j
==
3
&&
row
.
getCell
(
3
)
!=
null
)
{
row
.
getCell
(
3
).
setCellType
(
Cell
.
CELL_TYPE_STRING
);
String
dateTimeStr
=
row
.
getCell
(
3
).
getStringCellValue
();
if
(
dateTimeStr
!=
""
){
Date
dateTime
=
df
.
parse
(
dateTimeStr
);
...
...
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