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
e1d15369
Commit
e1d15369
authored
Jul 10, 2021
by
Jbb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pom中缺少mybatis中xml的配置
parent
ee86a608
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
283 additions
and
0 deletions
+283
-0
common/common_utils/src/main/java/com/founder/commonutils/viewEntity/TbStLayerData.java
+71
-0
service/view/pom.xml
+3
-0
service/view/src/main/java/com/founder/view/controller/TbStLayerDataController.java
+166
-0
service/view/src/main/java/com/founder/view/mapper/TbStLayerDataMapper.java
+19
-0
service/view/src/main/java/com/founder/view/mapper/xml/TbStLayerDataMapper.xml
+5
-0
service/view/src/main/java/com/founder/view/service/TbStLayerDataService.java
+7
-0
service/view/src/main/java/com/founder/view/service/impl/TbStLayerDataServiceImpl.java
+12
-0
No files found.
common/common_utils/src/main/java/com/founder/commonutils/viewEntity/TbStLayerData.java
0 → 100644
View file @
e1d15369
package
com
.
founder
.
commonutils
.
viewEntity
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
io.swagger.annotations.ApiModel
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
import
java.util.Date
;
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
@TableName
(
"TB_ST_LAYER_DATA"
)
@ApiModel
(
value
=
"图层数据对象"
,
description
=
"图层数据"
)
public
class
TbStLayerData
implements
Serializable
{
private
String
xxzjbh
;
private
String
gl_xxzjbh
;
private
double
x
;
//经度
private
double
y
;
//纬度
private
String
title
;
//事故提示
private
Date
time
;
//事故时间
public
String
getXxzjbh
()
{
return
xxzjbh
;
}
public
void
setXxzjbh
(
String
xxzjbh
)
{
this
.
xxzjbh
=
xxzjbh
;
}
public
String
getGl_xxzjbh
()
{
return
gl_xxzjbh
;
}
public
void
setGl_xxzjbh
(
String
gl_xxzjbh
)
{
this
.
gl_xxzjbh
=
gl_xxzjbh
;
}
public
double
getX
()
{
return
x
;
}
public
void
setX
(
double
x
)
{
this
.
x
=
x
;
}
public
double
getY
()
{
return
y
;
}
public
void
setY
(
double
y
)
{
this
.
y
=
y
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
Date
getTime
()
{
return
time
;
}
public
void
setTime
(
Date
time
)
{
this
.
time
=
time
;
}
}
service/view/pom.xml
View file @
e1d15369
...
...
@@ -14,4 +14,6 @@
<finalName>
view
</finalName>
</build>
</project>
\ No newline at end of file
service/view/src/main/java/com/founder/view/controller/TbStLayerDataController.java
0 → 100644
View file @
e1d15369
package
com
.
founder
.
view
.
controller
;
import
com.founder.commonutils.publicEntity.MapRestResult
;
import
com.founder.commonutils.util.KeyUtil
;
import
com.founder.commonutils.util.LngLonUtil
;
import
com.founder.commonutils.viewEntity.TbStLayerData
;
import
com.founder.view.service.TbStLayerDataService
;
import
io.swagger.annotations.Api
;
import
org.apache.poi.hssf.usermodel.HSSFRow
;
import
org.apache.poi.hssf.usermodel.HSSFSheet
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.xssf.usermodel.XSSFRow
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.InputStream
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
@Api
(
description
=
"经纬度上传"
)
@RestController
@RequestMapping
(
"/xy"
)
public
class
TbStLayerDataController
{
@Resource
TbStLayerDataService
accidentPointService
;
@RequestMapping
(
"/uploadExcel"
)
public
MapRestResult
uploadDown
(
@RequestParam
(
"excelFile"
)
MultipartFile
excelFile
,
HttpServletResponse
response
)
{
try
{
InputStream
is
=
excelFile
.
getInputStream
();
XSSFWorkbook
sheets
=
new
XSSFWorkbook
(
is
);
XSSFSheet
sheetAt
=
sheets
.
getSheetAt
(
0
);
//获取excel有多少行
int
lastRowNum
=
sheetAt
.
getLastRowNum
();
List
<
TbStLayerData
>
pointList
=
new
ArrayList
<>();
for
(
int
i
=
1
;
i
<=
lastRowNum
;
i
++)
{
TbStLayerData
point
=
new
TbStLayerData
();
String
id
=
KeyUtil
.
getUUIDKey
(
"xy"
);
point
.
setXxzjbh
(
id
);
point
.
setGl_xxzjbh
(
id
);
XSSFRow
row
=
sheetAt
.
getRow
(
i
);
//获取excel有多少列
short
lastCellNum
=
row
.
getLastCellNum
();
//判断经纬度是否符合要求
//检车一下数据是否能正常读取.....
double
jd
=
0.0
;
double
wd
=
0.0
;
String
titleStr
=
""
;
String
dateStr
=
""
;
if
(
row
.
getCell
(
0
)
!=
null
&&
row
.
getCell
(
1
)
!=
null
){
jd
=
row
.
getCell
(
0
).
getNumericCellValue
();
wd
=
row
.
getCell
(
1
).
getNumericCellValue
();
titleStr
=
row
.
getCell
(
2
).
getStringCellValue
();
dateStr
=
row
.
getCell
(
3
).
getStringCellValue
();
System
.
out
.
println
(
jd
+
"=========="
+
wd
+
"========="
+
titleStr
+
"========="
+
dateStr
);
}
DateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
try
{
//验证经纬度是否是八位小数以内
boolean
isTrue
=
LngLonUtil
.
verifyLongAndLat
(
row
.
getCell
(
0
).
getNumericCellValue
(),
row
.
getCell
(
1
).
getNumericCellValue
());
if
(
isTrue
){
//这里可以不用for循环 因为excel列数比较少
for
(
int
j
=
0
;
j
<
lastCellNum
;
j
++)
{
if
(
j
==
0
){
double
x
=
row
.
getCell
(
0
).
getNumericCellValue
();
point
.
setX
(
x
);
}
if
(
j
==
1
){
double
y
=
row
.
getCell
(
1
).
getNumericCellValue
();
point
.
setY
(
y
);
}
if
(
j
==
2
){
String
title
=
row
.
getCell
(
2
).
getStringCellValue
();
point
.
setTitle
(
title
);
}
if
(
j
==
3
){
String
dateTimeStr
=
row
.
getCell
(
3
).
getStringCellValue
();
Date
dateTime
=
df
.
parse
(
dateTimeStr
);
point
.
setTime
(
dateTime
);
}
}
accidentPointService
.
save
(
point
);
}
else
{
//经度小数点后超过了八位
double
x
=
0
;
double
y
=
0
;
if
(
row
.
getCell
(
0
).
getNumericCellValue
()
+
""
.
length
()
>
12
){
String
xStr
=
row
.
getCell
(
0
).
getNumericCellValue
()
+
""
.
substring
(
0
,
12
);
x
=
Double
.
parseDouble
(
xStr
);
}
if
(
row
.
getCell
(
1
).
getNumericCellValue
()
+
""
.
length
()
>
11
){
String
yStr
=
row
.
getCell
(
0
).
getNumericCellValue
()
+
""
.
substring
(
0
,
11
);
y
=
Double
.
parseDouble
(
yStr
);
}
for
(
int
j
=
0
;
j
<
lastCellNum
;
j
++)
{
if
(
j
==
0
){
//x = row.getCell(0).getNumericCellValue();
point
.
setX
(
x
);
}
if
(
j
==
1
){
//y = row.getCell(1).getNumericCellValue();
point
.
setY
(
y
);
}
if
(
j
==
2
){
String
title
=
row
.
getCell
(
2
).
getStringCellValue
();
point
.
setTitle
(
title
);
}
if
(
j
==
3
){
String
dateTimeStr
=
row
.
getCell
(
3
).
getStringCellValue
();
Date
dateTime
=
df
.
parse
(
dateTimeStr
);
point
.
setTime
(
dateTime
);
}
}
accidentPointService
.
save
(
point
);
}
}
catch
(
Exception
e
)
{
//具体的错误数据保存到这里
//e.printStackTrace();
pointList
.
add
(
point
);
}
}
//输出流写入到excel中
HSSFWorkbook
wb
=
new
HSSFWorkbook
();
HSSFSheet
sheet
=
wb
.
createSheet
();
//给个标题头
HSSFRow
rowTitle
=
sheet
.
createRow
(
0
);
rowTitle
.
createCell
(
0
).
setCellValue
(
"经度"
);
rowTitle
.
createCell
(
1
).
setCellValue
(
"纬度"
);
rowTitle
.
createCell
(
2
).
setCellValue
(
"标题"
);
rowTitle
.
createCell
(
3
).
setCellValue
(
"时间"
);
for
(
int
i
=
0
;
i
<
pointList
.
size
();
i
++)
{
TbStLayerData
accidentPoint
=
pointList
.
get
(
i
);
double
lon
=
accidentPoint
.
getX
();
double
lat
=
accidentPoint
.
getY
();
String
title
=
accidentPoint
.
getTitle
();
Date
time
=
accidentPoint
.
getTime
();
HSSFRow
rowData
=
sheet
.
createRow
(
i
+
1
);
rowData
.
createCell
(
0
).
setCellValue
(
lon
);
rowData
.
createCell
(
1
).
setCellValue
(
lat
);
rowData
.
createCell
(
2
).
setCellValue
(
title
);
rowData
.
createCell
(
3
).
setCellValue
(
time
);
}
//通过输出流下载
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
//设置文件响应输出格式
response
.
setContentType
(
"application/vnd.ms-excel"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename=error.xls"
);
wb
.
write
(
outputStream
);
outputStream
.
flush
();
outputStream
.
close
();
wb
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
MapRestResult
.
build
(
200
,
"数据上传成功!"
,
null
);
}
}
service/view/src/main/java/com/founder/view/mapper/TbStLayerDataMapper.java
0 → 100644
View file @
e1d15369
package
com
.
founder
.
view
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.founder.commonutils.viewEntity.TbStLayerData
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* <p>
* 用户登录 Mapper 接口
* </p>
*
* @author yy
* @since 2021-03-11
*/
@Mapper
public
interface
TbStLayerDataMapper
extends
BaseMapper
<
TbStLayerData
>
{
}
service/view/src/main/java/com/founder/view/mapper/xml/TbStLayerDataMapper.xml
0 → 100644
View file @
e1d15369
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.founder.view.mapper.TbStLayerDataMapper"
>
</mapper>
service/view/src/main/java/com/founder/view/service/TbStLayerDataService.java
0 → 100644
View file @
e1d15369
package
com
.
founder
.
view
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.founder.commonutils.viewEntity.TbStLayerData
;
public
interface
TbStLayerDataService
extends
IService
<
TbStLayerData
>
{
}
service/view/src/main/java/com/founder/view/service/impl/TbStLayerDataServiceImpl.java
0 → 100644
View file @
e1d15369
package
com
.
founder
.
view
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.founder.commonutils.viewEntity.TbStLayerData
;
import
com.founder.view.mapper.TbStLayerDataMapper
;
import
com.founder.view.service.TbStLayerDataService
;
import
org.springframework.stereotype.Service
;
@Service
public
class
TbStLayerDataServiceImpl
extends
ServiceImpl
<
TbStLayerDataMapper
,
TbStLayerData
>
implements
TbStLayerDataService
{
}
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