Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rs-cloud-platform
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
周健威
rs-cloud-platform
Commits
cbdb8a97
Commit
cbdb8a97
authored
Dec 27, 2021
by
周健威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改代码
parent
07802411
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
126 additions
and
2 deletions
+126
-2
CoverScheduleTask.java
.../upyuns/platform/rs/datacenter/job/CoverScheduleTask.java
+70
-0
SaticScheduleTask.java
.../upyuns/platform/rs/datacenter/job/SaticScheduleTask.java
+6
-1
UploadService.java
...m/upyuns/platform/rs/universal/service/UploadService.java
+2
-1
ShpToGeojson.java
.../com/upyuns/platform/rs/universal/utils/ShpToGeojson.java
+48
-0
No files found.
rs-datacenter/rs-datacenter-server/src/main/java/com/upyuns/platform/rs/datacenter/job/CoverScheduleTask.java
0 → 100644
View file @
cbdb8a97
package
com
.
upyuns
.
platform
.
rs
.
datacenter
.
job
;
import
cn.hutool.core.date.DateField
;
import
cn.hutool.core.date.DateUtil
;
import
com.upyuns.platform.rs.datacenter.biz.RscpImageDataTotalBiz
;
import
com.upyuns.platform.rs.datacenter.biz.RscpImagePriceBiz
;
import
com.upyuns.platform.rs.datacenter.biz.RscpImageStatisticsBiz
;
import
com.upyuns.platform.rs.datacenter.entity.RscpImageDataTotal
;
import
com.upyuns.platform.rs.datacenter.entity.RscpImagePrice
;
import
com.upyuns.platform.rs.datacenter.entity.RscpImageStatistics
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
static
com
.
github
.
wxiaoqi
.
security
.
common
.
constant
.
CommonConstants
.
SYS_FALSE
;
import
static
com
.
github
.
wxiaoqi
.
security
.
common
.
constant
.
CommonConstants
.
SYS_TRUE
;
@Configuration
//1.主要用于标记配置类,兼备Component的效果。
@EnableScheduling
// 2.开启定时任务
@Slf4j
public
class
CoverScheduleTask
{
@Autowired
RscpImagePriceBiz
rscpImagePriceBiz
;
@Autowired
RscpImageDataTotalBiz
rscpImageDataTotalBiz
;
@Autowired
RscpImageStatisticsBiz
rscpImageStatisticsBiz
;
//定时按月份统计覆盖率
@Scheduled
(
cron
=
"0 0 2 * * ?"
)
//或直接指定时间间隔,例如:5秒
//@Scheduled(fixedRate=5000)
public
void
configureTasks
()
{
}
private
void
insertPart
(
int
sort
,
String
satelliteType
,
Integer
countAll
,
int
type
)
{
insertPart
(
sort
,
satelliteType
,
countAll
,
type
,
null
);
}
private
void
insertPart
(
int
sort
,
String
satelliteType
,
Integer
countAll
,
int
type
,
String
year
)
{
RscpImageStatistics
rscpImageStatisticsAll
=
new
RscpImageStatistics
();
rscpImageStatisticsAll
.
setName
(
satelliteType
);
rscpImageStatisticsAll
.
setNum
(
countAll
);
rscpImageStatisticsAll
.
setSort
(
sort
);
rscpImageStatisticsAll
.
setType
(
type
);
rscpImageStatisticsAll
.
setDateyear
(
Integer
.
valueOf
(
year
));
rscpImageStatisticsBiz
.
insertSelective
(
rscpImageStatisticsAll
);
}
private
void
yearInsert
(
String
year
,
String
satelliteType
,
Integer
sort
)
{
Integer
countYear
=
rscpImageDataTotalBiz
.
selectCountByWeekend
(
w
->
{
w
.
andEqualTo
(
RscpImageDataTotal:
:
getImageSatelliteType
,
satelliteType
);
w
.
andEqualTo
(
RscpImageDataTotal:
:
getImageYear
,
year
);
return
w
;
});
//添加
insertPart
(
sort
,
satelliteType
,
countYear
,
RscpImageStatistics
.
TYPE_YEAR
,
year
);
}
}
\ No newline at end of file
rs-datacenter/rs-datacenter-server/src/main/java/com/upyuns/platform/rs/datacenter/job/SaticScheduleTask.java
View file @
cbdb8a97
...
@@ -98,11 +98,16 @@ public class SaticScheduleTask {
...
@@ -98,11 +98,16 @@ public class SaticScheduleTask {
}
}
private
void
insertPart
(
int
sort
,
String
satelliteType
,
Integer
countAll
,
int
type
)
{
private
void
insertPart
(
int
sort
,
String
satelliteType
,
Integer
countAll
,
int
type
)
{
insertPart
(
sort
,
satelliteType
,
countAll
,
type
,
null
);
}
private
void
insertPart
(
int
sort
,
String
satelliteType
,
Integer
countAll
,
int
type
,
String
year
)
{
RscpImageStatistics
rscpImageStatisticsAll
=
new
RscpImageStatistics
();
RscpImageStatistics
rscpImageStatisticsAll
=
new
RscpImageStatistics
();
rscpImageStatisticsAll
.
setName
(
satelliteType
);
rscpImageStatisticsAll
.
setName
(
satelliteType
);
rscpImageStatisticsAll
.
setNum
(
countAll
);
rscpImageStatisticsAll
.
setNum
(
countAll
);
rscpImageStatisticsAll
.
setSort
(
sort
);
rscpImageStatisticsAll
.
setSort
(
sort
);
rscpImageStatisticsAll
.
setType
(
type
);
rscpImageStatisticsAll
.
setType
(
type
);
rscpImageStatisticsAll
.
setDateyear
(
Integer
.
valueOf
(
year
));
rscpImageStatisticsBiz
.
insertSelective
(
rscpImageStatisticsAll
);
rscpImageStatisticsBiz
.
insertSelective
(
rscpImageStatisticsAll
);
}
}
...
@@ -114,6 +119,6 @@ public class SaticScheduleTask {
...
@@ -114,6 +119,6 @@ public class SaticScheduleTask {
});
});
//添加
//添加
insertPart
(
sort
,
satelliteType
,
countYear
,
RscpImageStatistics
.
TYPE_YEAR
);
insertPart
(
sort
,
satelliteType
,
countYear
,
RscpImageStatistics
.
TYPE_YEAR
,
year
);
}
}
}
}
\ No newline at end of file
rs-universal/rs-universal-server/src/main/java/com/upyuns/platform/rs/universal/service/UploadService.java
View file @
cbdb8a97
...
@@ -67,7 +67,8 @@ public class UploadService {
...
@@ -67,7 +67,8 @@ public class UploadService {
//将文件写入指定位置
//将文件写入指定位置
FileUtils
.
copyInputStreamToFile
(
file
.
getInputStream
(),
new
File
(
filePath
));
FileUtils
.
copyInputStreamToFile
(
file
.
getInputStream
(),
new
File
(
filePath
));
String
key
=
"shp:"
+
UUIDUtils
.
generateShortUuid
();
String
key
=
"shp:"
+
UUIDUtils
.
generateShortUuid
();
String
geomJson
=
ShpToGeojson
.
shp2geojson
(
filePath
);
// String geomJson = ShpToGeojson.shp2geojson(filePath);
String
geomJson
=
ShpToGeojson
.
shp2OneGeojson
(
filePath
);
redisTemplate
.
opsForValue
().
setIfAbsent
(
key
,
geomJson
);
redisTemplate
.
opsForValue
().
setIfAbsent
(
key
,
geomJson
);
// realFileRelPath=xx_url+SystemConfig.XXMP_URL+realFileRelPath;
// realFileRelPath=xx_url+SystemConfig.XXMP_URL+realFileRelPath;
...
...
rs-universal/rs-universal-server/src/main/java/com/upyuns/platform/rs/universal/utils/ShpToGeojson.java
View file @
cbdb8a97
...
@@ -147,6 +147,54 @@ public class ShpToGeojson {
...
@@ -147,6 +147,54 @@ public class ShpToGeojson {
// return map;
// return map;
// }
// }
/**
* shp文件转换geojson数据
* @param shpPath
* @return
*/
public
static
String
shp2OneGeojson
(
String
shpPath
){
Map
map
=
new
HashMap
();
//新建json对象
FeatureJSON
fjson
=
new
FeatureJSON
();
JSONObject
geojsonObject
=
new
JSONObject
();
geojsonObject
.
put
(
"type"
,
"FeatureCollection"
);
Object
geometry
=
new
JSONObject
();
try
{
//获取featurecollection
File
file
=
new
File
(
shpPath
);
ShapefileDataStore
shpDataStore
=
null
;
shpDataStore
=
new
ShapefileDataStore
(
file
.
toURL
());
//设置编码
/* Charset charset = Charset.forName("GBK");
shpDataStore.setCharset(charset);*/
String
typeName
=
shpDataStore
.
getTypeNames
()[
0
];
SimpleFeatureSource
featureSource
=
null
;
featureSource
=
shpDataStore
.
getFeatureSource
(
typeName
);
SimpleFeatureCollection
result
=
featureSource
.
getFeatures
();
SimpleFeatureIterator
itertor
=
result
.
features
();
//遍历feature转为json对象
while
(
itertor
.
hasNext
())
{
SimpleFeature
feature
=
itertor
.
next
();
StringWriter
writer
=
new
StringWriter
();
fjson
.
writeFeature
(
feature
,
writer
);
String
temp
=
writer
.
toString
();
geometry
=
JSONObject
.
parseObject
(
temp
).
getString
(
"geometry"
);
byte
[]
b
=
temp
.
getBytes
(
"iso8859-1"
);
temp
=
new
String
(
b
,
"gbk"
);
JSONObject
json
=
JSON
.
parseObject
(
temp
);
break
;
}
itertor
.
close
();
}
catch
(
Exception
e
){
map
.
put
(
"status"
,
"failure"
);
map
.
put
(
"message"
,
e
.
getMessage
());
e
.
printStackTrace
();
}
return
geometry
.
toString
();
}
/**
/**
* shp文件转换geojson数据
* shp文件转换geojson数据
* @param shpPath
* @param shpPath
...
...
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