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
ee86a608
Commit
ee86a608
authored
Jul 09, 2021
by
Jbb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除多余的代码 config包下的代码没有删除
parent
037b5fc4
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
246 additions
and
6 deletions
+246
-6
common/common_utils/src/main/java/com/founder/commonutils/viewEntity/AccidentPoint.java
+52
-0
service/view/src/main/java/com/founder/view/ViewApplication.java
+3
-0
service/view/src/main/java/com/founder/view/config/MybatisQgDbConfig.java
+1
-1
service/view/src/main/java/com/founder/view/controller/AccidentPointController.java
+164
-0
service/view/src/main/java/com/founder/view/mapper/AccidentPointMapper.java
+2
-1
service/view/src/main/java/com/founder/view/mapper/xml/AccidentPointMapper.xml
+1
-1
service/view/src/main/java/com/founder/view/service/AccidentPointService.java
+7
-0
service/view/src/main/java/com/founder/view/service/impl/AccidentPointServiceImpl.java
+12
-0
service/view/src/main/resources/bootstrap.properties
+4
-3
No files found.
common/common_utils/src/main/java/com/founder/commonutils/viewEntity/AccidentPoint.java
0 → 100644
View file @
ee86a608
package
com
.
founder
.
commonutils
.
viewEntity
;
import
java.io.Serializable
;
import
java.util.Date
;
public
class
AccidentPoint
implements
Serializable
{
private
String
xxzjbh
;
private
double
lat
;
//纬度
private
double
lon
;
//经度
private
String
title
;
//事故提示
private
Date
time
;
//事故时间
public
String
getXxzjbh
()
{
return
xxzjbh
;
}
public
void
setXxzjbh
(
String
xxzjbh
)
{
this
.
xxzjbh
=
xxzjbh
;
}
public
double
getLat
()
{
return
lat
;
}
public
void
setLat
(
double
lat
)
{
this
.
lat
=
lat
;
}
public
double
getLon
()
{
return
lon
;
}
public
void
setLon
(
double
lon
)
{
this
.
lon
=
lon
;
}
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/src/main/java/com/founder/view/ViewApplication.java
View file @
ee86a608
package
com
.
founder
.
view
;
package
com
.
founder
.
view
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
@SpringBootApplication
@SpringBootApplication
@EnableSwagger2
@EnableSwagger2
@MapperScan
(
basePackages
=
"com.founder.view.mapper"
)
public
class
ViewApplication
{
public
class
ViewApplication
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
...
service/view/src/main/java/com/founder/view/config/MybatisQgDbConfig.java
View file @
ee86a608
...
@@ -15,7 +15,7 @@ import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
...
@@ -15,7 +15,7 @@ import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import
org.springframework.core.io.support.ResourcePatternResolver
;
import
org.springframework.core.io.support.ResourcePatternResolver
;
@Configuration
@Configuration
@MapperScan
(
basePackages
=
{
"com.founder.
asj
.qgxzMapper"
},
@MapperScan
(
basePackages
=
{
"com.founder.
view
.qgxzMapper"
},
sqlSessionTemplateRef
=
"qgSqlTemplate"
)
sqlSessionTemplateRef
=
"qgSqlTemplate"
)
public
class
MybatisQgDbConfig
{
public
class
MybatisQgDbConfig
{
...
...
service/view/src/main/java/com/founder/view/controller/AccidentPointController.java
0 → 100644
View file @
ee86a608
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.AccidentPoint
;
import
com.founder.view.service.AccidentPointService
;
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
AccidentPointController
{
@Resource
AccidentPointService
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
<
AccidentPoint
>
pointList
=
new
ArrayList
<>();
for
(
int
i
=
1
;
i
<=
lastRowNum
;
i
++)
{
AccidentPoint
point
=
new
AccidentPoint
();
String
id
=
KeyUtil
.
getUUIDKey
(
"xy"
);
point
.
setXxzjbh
(
id
);
XSSFRow
row
=
sheetAt
.
getRow
(
i
);
//获取excel有多少列
short
lastCellNum
=
row
.
getLastCellNum
();
//判断经纬度是否符合要求
//检车一下数据是否能正常读取.....
/*double x = 0.0;
double y = 0.0;
String title = "";
String dateTime = "";
if(row.getCell(0) != null && row.getCell(1) != null){
x = row.getCell(0).getNumericCellValue();
y = row.getCell(1).getNumericCellValue();
title = row.getCell(2).getStringCellValue();
dateTime = row.getCell(3).getStringCellValue();
System.out.println(x + "==========" + y + "=========" + title + "=========" + dateTime);
}*/
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
.
setLon
(
x
);
}
if
(
j
==
1
){
double
y
=
row
.
getCell
(
1
).
getNumericCellValue
();
point
.
setLat
(
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
);
}
}
}
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
.
setLon
(
x
);
}
if
(
j
==
1
){
//y = row.getCell(1).getNumericCellValue();
point
.
setLat
(
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
++)
{
AccidentPoint
accidentPoint
=
pointList
.
get
(
i
);
double
lon
=
accidentPoint
.
getLon
();
double
lat
=
accidentPoint
.
getLat
();
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
.
ok
();
}
}
service/view/src/main/java/com/founder/view/mapper/
SysUsers
Mapper.java
→
service/view/src/main/java/com/founder/view/mapper/
AccidentPoint
Mapper.java
View file @
ee86a608
...
@@ -3,6 +3,7 @@ package com.founder.view.mapper;
...
@@ -3,6 +3,7 @@ package com.founder.view.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.founder.commonutils.publicEntity.SysUser
;
import
com.founder.commonutils.publicEntity.SysUser
;
import
com.founder.commonutils.viewEntity.AccidentPoint
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
/**
/**
...
@@ -14,6 +15,6 @@ import org.apache.ibatis.annotations.Mapper;
...
@@ -14,6 +15,6 @@ import org.apache.ibatis.annotations.Mapper;
* @since 2021-03-11
* @since 2021-03-11
*/
*/
@Mapper
@Mapper
public
interface
SysUsersMapper
extends
BaseMapper
<
SysUser
>
{
public
interface
AccidentPointMapper
extends
BaseMapper
<
AccidentPoint
>
{
}
}
service/view/src/main/java/com/founder/view/mapper/xml/
SysUsers
Mapper.xml
→
service/view/src/main/java/com/founder/view/mapper/xml/
AccidentPoint
Mapper.xml
View file @
ee86a608
<?xml version="1.0" encoding="UTF-8"?>
<?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">
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.founder.view.mapper.
SysUsers
Mapper"
>
<mapper
namespace=
"com.founder.view.mapper.
AccidentPoint
Mapper"
>
</mapper>
</mapper>
service/view/src/main/java/com/founder/view/service/AccidentPointService.java
0 → 100644
View file @
ee86a608
package
com
.
founder
.
view
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.founder.commonutils.viewEntity.AccidentPoint
;
public
interface
AccidentPointService
extends
IService
<
AccidentPoint
>
{
}
service/view/src/main/java/com/founder/view/service/impl/AccidentPointServiceImpl.java
0 → 100644
View file @
ee86a608
package
com
.
founder
.
view
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.founder.commonutils.viewEntity.AccidentPoint
;
import
com.founder.view.mapper.AccidentPointMapper
;
import
com.founder.view.service.AccidentPointService
;
import
org.springframework.stereotype.Service
;
@Service
public
class
AccidentPointServiceImpl
extends
ServiceImpl
<
AccidentPointMapper
,
AccidentPoint
>
implements
AccidentPointService
{
}
service/view/src/main/resources/bootstrap.properties
View file @
ee86a608
...
@@ -9,12 +9,12 @@ spring.profiles.active=dev
...
@@ -9,12 +9,12 @@ spring.profiles.active=dev
# 该配置影响统一配置中心中的dataId
# 该配置影响统一配置中心中的dataId
spring.application.name
=
view
spring.application.name
=
view
spring.cloud.nacos.config.namespace
=
dev
spring.cloud.nacos.config.namespace
=
f1160b5f-cef5-4e86-bddc-c55e28c2d8b0
#spring.cloud.nacos.config.ext-config[0].data-id=image.properties
#spring.cloud.nacos.config.ext-config[0].data-id=image.properties
# 开启动态刷新配置,否则配置文件修改,工程无法感知
# 开启动态刷新配置,否则配置文件修改,工程无法感知
#spring.cloud.nacos.config.ext-config[0].refresh=true
#spring.cloud.nacos.config.ext-config[0].refresh=true
spring.cloud.nacos.config.shared-dataids
=
view-dev.
yml
spring.cloud.nacos.config.shared-dataids
=
view-dev.
properties
spring.cloud.nacos.config.refreshable-dataids
=
view-dev.
yml
spring.cloud.nacos.config.refreshable-dataids
=
view-dev.
properties
management.health.elasticsearch.enabled
:
false
management.health.elasticsearch.enabled
:
false
\ No newline at end of file
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