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
840134c2
Commit
840134c2
authored
Dec 20, 2020
by
周健威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交代码
parent
752f9bc1
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
132 additions
and
456 deletions
+132
-456
RabbitConstant.java
...wxiaoqi/security/common/config/rabbit/RabbitConstant.java
+10
-17
AppPermissionService.java
...aoqi/security/admin/rpc/service/AppPermissionService.java
+2
-3
pom.xml
rs-common/rs-common-platform-web/pom.xml
+4
-0
RscpImageInputLog.java
...yuns/platform/rs/datacenter/entity/RscpImageInputLog.java
+4
-96
ImageInputVO.java
...va/com/upyuns/platform/rs/datacenter/vo/ImageInputVO.java
+1
-1
RabbitConfig.java
...om/upyuns/platform/rs/datacenter/config/RabbitConfig.java
+33
-0
ImageInputLogMQHandler.java
...tform/rs/datacenter/mqhandler/ImageInputLogMQHandler.java
+78
-0
FileOperateUtil.java
.../upyuns/platform/rs/datacenter/utils/FileOperateUtil.java
+0
-40
ImageStorageParseUtil.java
...s/platform/rs/datacenter/utils/ImageStorageParseUtil.java
+0
-163
TarFileOperateUtil.java
...yuns/platform/rs/datacenter/utils/TarFileOperateUtil.java
+0
-90
XmlFileOperateUtil.java
...yuns/platform/rs/datacenter/utils/XmlFileOperateUtil.java
+0
-46
No files found.
ace-common/src/main/java/com/github/wxiaoqi/security/common/config/rabbit/RabbitConstant.java
View file @
840134c2
...
@@ -9,16 +9,20 @@ public class RabbitConstant {
...
@@ -9,16 +9,20 @@ public class RabbitConstant {
public
static
String
TOPIC_EXC
=
"_topic_exchange"
;
public
static
String
TOPIC_EXC
=
"_topic_exchange"
;
public
static
String
DIRECT_EXC
=
"_direct_exchange"
;
public
static
String
DIRECT_EXC
=
"_direct_exchange"
;
/**************************admin公用主题*********************************/
public
static
final
String
ADMIN
=
"admin"
;
public
static
final
String
ADMIN
=
"admin"
;
public
static
final
String
ADMIN_TOPIC
=
ADMIN
+
TOPIC_EXC
;
public
static
final
String
ADMIN_TOPIC
=
ADMIN
+
TOPIC_EXC
;
public
static
final
String
ORDER
=
"order"
;
public
static
final
String
ORDER_TOPIC
=
ORDER
+
TOPIC_EXC
;
/**************************数据中心公用主题*********************************/
public
static
final
String
INTEGRAL
=
"integral"
;
public
static
final
String
DATACENTER
=
"datacenter"
;
public
static
final
String
INTEGRAL_TOPIC
=
INTEGRAL
+
TOPIC_EXC
;
public
static
final
String
DATACENTER_TOPIC
=
DATACENTER
+
TOPIC_EXC
;
public
static
final
String
ACTIVITY_PRIZE
=
"activity:prize"
;
public
static
final
String
ACTIVITY_PRIZE_TOPIC
=
ACTIVITY_PRIZE
+
TOPIC_EXC
;
/**************************key*********************************/
/**************************key*********************************/
//数据中心
//入库
public
static
final
String
KEY_IMAGE_INPUT_SUCC
=
"image.input.succ"
;
//用户
//用户
public
static
final
String
KEY_APPUSER_REGISTER
=
"appUser.register"
;
public
static
final
String
KEY_APPUSER_REGISTER
=
"appUser.register"
;
public
static
final
String
KEY_APPUSER_AUTH
=
"appUser.auth"
;
public
static
final
String
KEY_APPUSER_AUTH
=
"appUser.auth"
;
...
@@ -32,20 +36,9 @@ public class RabbitConstant {
...
@@ -32,20 +36,9 @@ public class RabbitConstant {
public
static
final
String
KEY_ORDER_CANCEL
=
"order.cancel"
;
public
static
final
String
KEY_ORDER_CANCEL
=
"order.cancel"
;
public
static
final
String
KEY_ORDER_PART_DEPOSIT
=
"order.partDeposit"
;
public
static
final
String
KEY_ORDER_PART_DEPOSIT
=
"order.partDeposit"
;
//钱包
public
static
final
String
KEY_WALLET_ADD
=
"wallet.add"
;
public
static
final
String
KEY_WALLET_WITH_DRAW
=
"wallet.withdraw"
;
//抽奖
public
static
final
String
KEY_ACTIVITY_PRIZE_RECORD
=
"prize:record"
;
static
{
static
{
exchangeTopicSet
=
new
HashSet
<
String
>()
{{
exchangeTopicSet
=
new
HashSet
<
String
>()
{{
add
(
ADMIN_TOPIC
);
add
(
ADMIN_TOPIC
);
add
(
ORDER_TOPIC
);
add
(
INTEGRAL_TOPIC
);
add
(
ACTIVITY_PRIZE_TOPIC
);
}};
}};
}
}
}
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rpc/service/AppPermissionService.java
View file @
840134c2
...
@@ -15,7 +15,6 @@ import com.github.wxiaoqi.security.admin.vo.ImiVo;
...
@@ -15,7 +15,6 @@ import com.github.wxiaoqi.security.admin.vo.ImiVo;
import
com.github.wxiaoqi.security.api.vo.authority.PermissionInfo
;
import
com.github.wxiaoqi.security.api.vo.authority.PermissionInfo
;
import
com.github.wxiaoqi.security.api.vo.user.AppUserInfo
;
import
com.github.wxiaoqi.security.api.vo.user.AppUserInfo
;
import
com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant
;
import
com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant
;
import
com.github.wxiaoqi.security.common.msg.BaseResponse
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.util.EmojiFilter
;
import
com.github.wxiaoqi.security.common.util.EmojiFilter
;
import
com.github.wxiaoqi.security.common.util.ReferralCodeUtil
;
import
com.github.wxiaoqi.security.common.util.ReferralCodeUtil
;
...
@@ -48,7 +47,7 @@ import java.util.*;
...
@@ -48,7 +47,7 @@ import java.util.*;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
static
com
.
github
.
wxiaoqi
.
security
.
common
.
config
.
rabbit
.
RabbitConstant
.
KEY_APPUSER_AUTH
;
import
static
com
.
github
.
wxiaoqi
.
security
.
common
.
config
.
rabbit
.
RabbitConstant
.
KEY_APPUSER_AUTH
;
import
static
com
.
github
.
wxiaoqi
.
security
.
common
.
config
.
rabbit
.
RabbitConstant
.
KEY_
APPUSER_REGISTER
;
import
static
com
.
github
.
wxiaoqi
.
security
.
common
.
config
.
rabbit
.
RabbitConstant
.
KEY_
IMAGE_INPUT_SUCC
;
/**
/**
* @author keliii
* @author keliii
...
@@ -367,7 +366,7 @@ public class AppPermissionService {
...
@@ -367,7 +366,7 @@ public class AppPermissionService {
// 注册成功,发送队列
// 注册成功,发送队列
switch
(
sign
){
switch
(
sign
){
case
1
:
case
1
:
mqSenderFeign
.
sendMessage
(
RabbitConstant
.
ADMIN_TOPIC
,
KEY_
APPUSER_REGISTER
,
JSONUtil
.
toJsonStr
(
registerQueueDTO
));
mqSenderFeign
.
sendMessage
(
RabbitConstant
.
ADMIN_TOPIC
,
KEY_
IMAGE_INPUT_SUCC
,
JSONUtil
.
toJsonStr
(
registerQueueDTO
));
break
;
break
;
case
2
:
case
2
:
mqSenderFeign
.
sendMessage
(
RabbitConstant
.
ADMIN_TOPIC
,
KEY_APPUSER_AUTH
,
JSONUtil
.
toJsonStr
(
registerQueueDTO
));
mqSenderFeign
.
sendMessage
(
RabbitConstant
.
ADMIN_TOPIC
,
KEY_APPUSER_AUTH
,
JSONUtil
.
toJsonStr
(
registerQueueDTO
));
...
...
rs-common/rs-common-platform-web/pom.xml
View file @
840134c2
...
@@ -29,6 +29,10 @@
...
@@ -29,6 +29,10 @@
<dependencies>
<dependencies>
<!-- spring -->
<!-- spring -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-amqp
</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
<artifactId>
spring-boot-starter-web
</artifactId>
...
...
rs-datacenter/rs-datacenter-api/src/main/java/com/upyuns/platform/rs/datacenter/entity/RscpImageInputLog.java
View file @
840134c2
...
@@ -13,6 +13,10 @@ public class RscpImageInputLog implements java.io.Serializable {
...
@@ -13,6 +13,10 @@ public class RscpImageInputLog implements java.io.Serializable {
/** 版本号 */
/** 版本号 */
private
static
final
long
serialVersionUID
=
-
6625661497803837040L
;
private
static
final
long
serialVersionUID
=
-
6625661497803837040L
;
public
static
final
int
STATU_ING
=
1
;
public
static
final
int
STATU_SUCC
=
2
;
public
static
final
int
STATU_FAIL
=
-
1
;
/* This code was generated by TableGo tools, mark 1 begin. */
/* This code was generated by TableGo tools, mark 1 begin. */
/** id */
/** id */
...
@@ -38,100 +42,4 @@ public class RscpImageInputLog implements java.io.Serializable {
...
@@ -38,100 +42,4 @@ public class RscpImageInputLog implements java.io.Serializable {
/* This code was generated by TableGo tools, mark 1 end. */
/* This code was generated by TableGo tools, mark 1 end. */
/* This code was generated by TableGo tools, mark 2 begin. */
/* This code was generated by TableGo tools, mark 2 begin. */
/**
* 获取id
*
* @return id
*/
public
Long
getId
()
{
return
this
.
id
;
}
/**
* 设置id
*
* @param id
*/
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
/**
* 获取创建时间
*
* @return 创建时间
*/
public
Long
getCrtTime
()
{
return
this
.
crtTime
;
}
/**
* 设置创建时间
*
* @param crtTime
* 创建时间
*/
public
void
setCrtTime
(
Long
crtTime
)
{
this
.
crtTime
=
crtTime
;
}
/**
* 获取更新时间
*
* @return 更新时间
*/
public
Long
getUpdTime
()
{
return
this
.
updTime
;
}
/**
* 设置更新时间
*
* @param updTime
* 更新时间
*/
public
void
setUpdTime
(
Long
updTime
)
{
this
.
updTime
=
updTime
;
}
/**
* 获取状态
*
* @return 状态
*/
public
Integer
getStatus
()
{
return
this
.
status
;
}
/**
* 设置状态
*
* @param status
* 状态
*/
public
void
setStatus
(
Integer
status
)
{
this
.
status
=
status
;
}
/**
* 获取json文本
*
* @return json文本
*/
public
String
getContextJson
()
{
return
this
.
contextJson
;
}
/**
* 设置json文本
*
* @param contextJson
* json文本
*/
public
void
setContextJson
(
String
contextJson
)
{
this
.
contextJson
=
contextJson
;
}
/* This code was generated by TableGo tools, mark 2 end. */
}
}
\ No newline at end of file
rs-datacenter/rs-datacenter-api/src/main/java/com/upyuns/platform/rs/datacenter/vo/Image
StorageVo
.java
→
rs-datacenter/rs-datacenter-api/src/main/java/com/upyuns/platform/rs/datacenter/vo/Image
InputVO
.java
View file @
840134c2
...
@@ -6,7 +6,7 @@ import java.math.BigDecimal;
...
@@ -6,7 +6,7 @@ import java.math.BigDecimal;
import
java.util.List
;
import
java.util.List
;
@Data
@Data
public
class
Image
StorageVo
{
public
class
Image
InputVO
{
//左上角经度
//左上角经度
private
BigDecimal
leftTopLon
;
private
BigDecimal
leftTopLon
;
...
...
rs-datacenter/rs-datacenter-server/src/main/java/com/upyuns/platform/rs/datacenter/config/RabbitConfig.java
0 → 100644
View file @
840134c2
package
com
.
upyuns
.
platform
.
rs
.
datacenter
.
config
;
import
com.github.wxiaoqi.security.common.config.rabbit.BindDTO
;
import
com.github.wxiaoqi.security.common.config.rabbit.RabbitCommonConfig
;
import
org.springframework.context.annotation.Configuration
;
import
java.util.ArrayList
;
import
static
com
.
github
.
wxiaoqi
.
security
.
common
.
config
.
rabbit
.
RabbitConstant
.*;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/10/17 17:23
*/
@Configuration
public
class
RabbitConfig
extends
RabbitCommonConfig
{
/**
* 获取成功入库数据。
*/
public
static
final
String
IMAGE_INPUT_LOG_QUEUE
=
"image.input.log.queue"
;
static
{
myQueue
=
new
ArrayList
<
BindDTO
>()
{{
//添加接收
//入库日志队列+数据中心主题+入库完成KEY
add
(
new
BindDTO
(
IMAGE_INPUT_LOG_QUEUE
,
DATACENTER_TOPIC
,
KEY_IMAGE_INPUT_SUCC
));
}};
}
}
rs-datacenter/rs-datacenter-server/src/main/java/com/upyuns/platform/rs/datacenter/mqhandler/ImageInputLogMQHandler.java
0 → 100644
View file @
840134c2
package
com
.
upyuns
.
platform
.
rs
.
datacenter
.
mqhandler
;
import
cn.hutool.json.JSONUtil
;
import
com.rabbitmq.client.Channel
;
import
com.upyuns.platform.rs.datacenter.biz.RscpImageDataTotalBiz
;
import
com.upyuns.platform.rs.datacenter.biz.RscpImageInputLogBiz
;
import
com.upyuns.platform.rs.datacenter.entity.RscpImageDataTotal
;
import
com.upyuns.platform.rs.datacenter.entity.RscpImageInputLog
;
import
com.upyuns.platform.rs.datacenter.vo.ImageInputVO
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.amqp.core.Message
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
import
org.springframework.amqp.support.AmqpHeaders
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.messaging.handler.annotation.Headers
;
import
org.springframework.stereotype.Component
;
import
java.io.IOException
;
import
java.util.Map
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
static
com
.
upyuns
.
platform
.
rs
.
datacenter
.
config
.
RabbitConfig
.
IMAGE_INPUT_LOG_QUEUE
;
@Component
@Slf4j
public
class
ImageInputLogMQHandler
{
@Autowired
RscpImageInputLogBiz
rscpImageInputLogBiz
;
@Autowired
RscpImageDataTotalBiz
rscpImageDataTotalBiz
;
/**
* 同步门店信息
* @param
*/
@RabbitListener
(
queues
=
IMAGE_INPUT_LOG_QUEUE
)
public
void
integralHandler
(
Message
message
,
@Headers
Map
<
String
,
Object
>
headers
,
Channel
channel
)
{
log
.
info
(
"同步门店信息 messageJson:"
+
JSONUtil
.
parse
(
message
));
ExecutorService
executorService
=
Executors
.
newCachedThreadPool
();
executorService
.
execute
(()
->
{
try
{
String
messageId
=
message
.
getMessageProperties
().
getMessageId
();
String
msg
=
new
String
(
message
.
getBody
(),
"UTF-8"
);
ImageInputVO
ii
=
JSONUtil
.
toBean
(
msg
,
ImageInputVO
.
class
);
rscpImageInputLogBiz
.
insertSelective
(
new
RscpImageInputLog
(){{
setContextJson
(
JSONUtil
.
toJsonStr
(
ii
));
setStatus
(
STATU_ING
);
}});
executorService
.
shutdown
();
Long
deliveryTag
=
(
Long
)
headers
.
get
(
AmqpHeaders
.
DELIVERY_TAG
);
// 手动签收
channel
.
basicAck
(
deliveryTag
,
false
);
ExecutorService
executorService2
=
Executors
.
newCachedThreadPool
();
executorService2
.
execute
(()
->
{
try
{
//查询数据是否存在
//rscpImageDataTotalBiz.selectByQuery(new )
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
throw
e
;
}
});
}
catch
(
Exception
e
)
{
log
.
info
(
"接收到的消息失败"
);
try
{
channel
.
basicNack
(
message
.
getMessageProperties
().
getDeliveryTag
(),
false
,
false
);
}
catch
(
IOException
i
)
{
log
.
error
(
e
.
getMessage
(),
i
);
}
log
.
error
(
e
.
getMessage
(),
e
);
}
});
}
}
rs-datacenter/rs-datacenter-server/src/main/java/com/upyuns/platform/rs/datacenter/utils/FileOperateUtil.java
deleted
100644 → 0
View file @
752f9bc1
package
com
.
upyuns
.
platform
.
rs
.
datacenter
.
utils
;
import
java.io.File
;
public
class
FileOperateUtil
{
public
static
String
getFileNameNotFormat
(
String
filePath
)
{
filePath
=
filePath
.
replaceAll
(
"\\\\"
,
"/"
);
Integer
indexOf
=
filePath
.
lastIndexOf
(
"/"
);
String
fileName
=
filePath
.
substring
(
indexOf
);
String
dirName
=
fileName
;
indexOf
=
filePath
.
lastIndexOf
(
"."
);
if
(
indexOf
>
0
)
{
dirName
=
dirName
.
substring
(
0
,
indexOf
);
}
return
dirName
;
}
public
static
String
getFileName
(
String
filePath
)
{
filePath
=
filePath
.
replaceAll
(
"\\\\"
,
"/"
);
Integer
indexOf
=
filePath
.
lastIndexOf
(
"/"
);
String
fileName
=
filePath
.
substring
(
indexOf
);
return
fileName
;
}
public
static
String
getlocalFileParentPath
(
String
filePath
)
{
File
file
=
new
File
(
filePath
);
return
file
.
getParent
();
}
public
static
String
getPathParentPath
(
String
filePath
)
{
filePath
=
filePath
.
replaceAll
(
"\\\\"
,
"/"
);
Integer
indexOf
=
filePath
.
lastIndexOf
(
"/"
);
String
parentPath
=
filePath
;
if
(
indexOf
>
0
)
{
parentPath
=
parentPath
.
substring
(
0
,
indexOf
);
}
return
parentPath
;
}
}
rs-datacenter/rs-datacenter-server/src/main/java/com/upyuns/platform/rs/datacenter/utils/ImageStorageParseUtil.java
deleted
100644 → 0
View file @
752f9bc1
package
com
.
upyuns
.
platform
.
rs
.
datacenter
.
utils
;
import
com.github.wxiaoqi.security.common.constant.RestCode
;
import
com.github.wxiaoqi.security.common.exception.BaseException
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
com.upyuns.platform.rs.datacenter.utils.gdal.ImageOperateTools
;
import
com.upyuns.platform.rs.datacenter.vo.ImageStorageVo
;
import
com.upyuns.platform.rs.gtdata.GtDataRestClient
;
import
org.apache.commons.collections.map.HashedMap
;
import
org.apache.commons.lang.time.DateUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
public
class
ImageStorageParseUtil
{
@Value
(
"${localDirTemp.tarFileTemp}"
)
private
static
String
tarFileTempDir
;
@Autowired
private
static
GtDataRestClient
gtDataRestClient
;
public
static
ImageStorageVo
tarFileParseGtData
(
String
inputGtPath
,
String
ouputGtDir
)
throws
BaseException
{
//将GT上压缩包下载到本地
Integer
indexOf
=
inputGtPath
.
lastIndexOf
(
"/"
);
String
fileName
=
inputGtPath
.
substring
(
indexOf
);
String
dirName
=
fileName
;
indexOf
=
inputGtPath
.
lastIndexOf
(
"."
);
if
(
indexOf
>
0
)
{
dirName
=
dirName
.
substring
(
0
,
indexOf
);
}
File
localDir
=
new
File
(
tarFileTempDir
+
"/"
+
dirName
);
localDir
.
mkdirs
();
String
localInputPath
=
localDir
+
"/"
+
fileName
;
Map
<
String
,
Object
>
result
=
gtDataRestClient
.
open
(
inputGtPath
);
if
((
Integer
)
result
.
get
(
"HttpStatusCode"
)
!=
200
)
{
throw
new
BaseException
(
"文件下载失败"
,
ResultCode
.
FAILED_CODE
);
}
try
{
OutputStream
outputStream
=
new
FileOutputStream
(
new
File
(
localInputPath
));
outputStream
.
write
((
byte
[])
result
.
get
(
"file"
));
outputStream
.
flush
();
outputStream
.
close
();
}
catch
(
Exception
e
)
{
throw
new
BaseException
(
"文件保存失败"
,
ResultCode
.
FAILED_CODE
);
}
return
tarFileParse
(
localInputPath
,
localDir
.
getPath
(),
ouputGtDir
);
}
public
static
ImageStorageVo
tarFileParse
(
String
inputLocalPath
,
String
localOutputDir
,
String
outputGtPath
)
throws
BaseException
{
if
(
inputLocalPath
.
endsWith
(
"zip"
))
{
//Satellogic 压缩包解析
return
satellogicParse
(
inputLocalPath
,
localOutputDir
,
outputGtPath
);
}
else
if
(
inputLocalPath
.
endsWith
(
"tar.gz"
))
{
throw
new
BaseException
(
"tar.gz 压缩包未实现"
,
ResultCode
.
FAILED_CODE
);
}
else
{
throw
new
BaseException
(
"压缩包格式不支持"
,
ResultCode
.
FAILED_CODE
);
}
}
//Satellogic 压缩包解析
public
static
ImageStorageVo
satellogicParse
(
String
inputLocalPath
,
String
localOutputDir
,
String
outputGtPath
)
throws
BaseException
{
//1、提取解析xml文件
List
<
String
>
xmlPathList
=
TarFileOperateUtil
.
zipFileRead
(
inputLocalPath
,
localOutputDir
,
".xml"
);
if
(
xmlPathList
==
null
||
xmlPathList
.
size
()
==
0
)
{
throw
new
BaseException
(
"xml文件提取失败"
,
ResultCode
.
FAILED_CODE
);
}
List
<
String
>
fileNameList
=
new
ArrayList
<>();
ImageStorageVo
imageStorageVo
=
new
ImageStorageVo
();
//初始基础或固定信息
imageStorageVo
.
setName
(
FileOperateUtil
.
getFileNameNotFormat
(
inputLocalPath
));
imageStorageVo
.
setImageProductFormat
(
"TIFF"
);
imageStorageVo
.
setImageSpectrumType
(
"{QS,DGP}"
);
imageStorageVo
.
setImageSpectrumTypeDisplay
(
"{全色,多光谱}"
);
imageStorageVo
.
setImageProjection
(
"WGS-84"
);
Map
<
String
,
String
>
paramsMap
=
new
HashedMap
();
boolean
xmlFlag
=
false
;
for
(
String
xmlPath
:
xmlPathList
)
{
paramsMap
.
clear
();
XmlFileOperateUtil
.
xmlParse
(
xmlPath
,
paramsMap
);
if
(
paramsMap
.
get
(
"camera"
)
!=
null
&&
paramsMap
.
get
(
"bounds"
)
!=
null
)
{
//拍摄时间
String
takeTime
=
paramsMap
.
get
(
"created_at"
);
if
(
StringUtils
.
isNotBlank
(
takeTime
))
{
String
takeTimeFormat
=
takeTime
.
replace
(
"T"
,
" "
);
Integer
indexOf
=
takeTimeFormat
.
lastIndexOf
(
"."
);
if
(
indexOf
>
0
)
{
takeTimeFormat
=
takeTimeFormat
.
substring
(
0
,
indexOf
);
}
if
(
takeTime
.
toLowerCase
().
endsWith
(
"z"
))
{
//UTC格林标准时区
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
try
{
Date
date
=
sdf
.
parse
(
takeTimeFormat
);
DateUtils
.
addHours
(
date
,
8
);
//增加8小时,转为北京时区
takeTimeFormat
=
sdf
.
format
(
date
);
}
catch
(
Exception
e
)
{
throw
new
BaseException
(
"时间解析失败"
,
ResultCode
.
FAILED_CODE
);
}
}
imageStorageVo
.
setImageTakeTime
(
takeTimeFormat
);
imageStorageVo
.
setImageProductTime
(
takeTimeFormat
);
imageStorageVo
.
setImageEndTime
(
takeTimeFormat
);
imageStorageVo
.
setImageStartTime
(
takeTimeFormat
);
imageStorageVo
.
setImageCenterTime
(
takeTimeFormat
);
}
//供应商
imageStorageVo
.
setSupplier
(
paramsMap
.
get
(
"supplier"
));
//卫星名称、类型
imageStorageVo
.
setImageSatelliteType
(
paramsMap
.
get
(
"satellite_name"
));
imageStorageVo
.
setImageSatelliteTypeDisplay
(
paramsMap
.
get
(
"satellite_name"
));
//云量
imageStorageVo
.
setImageCloudage
(
new
BigDecimal
(
paramsMap
.
get
(
"cloud_pctg"
)));
//传感器类型
imageStorageVo
.
setImageSensorType
(
paramsMap
.
get
(
"camera"
));
imageStorageVo
.
setImageSensorId
(
paramsMap
.
get
(
"camera"
));
//景id
imageStorageVo
.
setImageSceneId
(
paramsMap
.
get
(
"scene_id"
));
xmlFlag
=
true
;
break
;
}
}
if
(!
xmlFlag
)
{
throw
new
BaseException
(
"xml 解析失败"
,
ResultCode
.
FAILED_CODE
);
}
//2、提取tiff,生成缩略图
List
<
String
>
tifPathList
=
TarFileOperateUtil
.
zipFileRead
(
inputLocalPath
,
localOutputDir
,
".tif"
);
if
(
tifPathList
==
null
||
tifPathList
.
size
()
==
0
)
{
tifPathList
=
TarFileOperateUtil
.
zipFileRead
(
inputLocalPath
,
localOutputDir
,
".tiff"
);
}
if
(
tifPathList
==
null
||
tifPathList
.
size
()
==
0
)
{
throw
new
BaseException
(
"tif 文件提取失败"
,
ResultCode
.
FAILED_CODE
);
}
//生成缩略图
List
<
String
>
picPathList
=
new
ArrayList
<>();
for
(
String
tifPath
:
tifPathList
)
{
if
(
tifPath
.
toLowerCase
().
contains
(
"_quicklook"
))
{
String
localPicPrefix
=
FileOperateUtil
.
getlocalFileParentPath
(
tifPath
)
+
"/"
+
FileOperateUtil
.
getFileNameNotFormat
(
tifPath
);
String
localPngPic
=
localPicPrefix
+
".png"
;
ImageOperateTools
.
tif2Pic
(
tifPath
,
localPngPic
);
picPathList
.
add
(
localPngPic
);
String
localTargetPngPic
=
localPicPrefix
+
"_800_800.png"
;
ImageOperateTools
.
zipImageFile
(
localPngPic
,
localTargetPngPic
,
800
,
1.0f
);
break
;
}
}
//3、转坐标系
return
imageStorageVo
;
}
}
rs-datacenter/rs-datacenter-server/src/main/java/com/upyuns/platform/rs/datacenter/utils/TarFileOperateUtil.java
deleted
100644 → 0
View file @
752f9bc1
package
com
.
upyuns
.
platform
.
rs
.
datacenter
.
utils
;
import
com.github.wxiaoqi.security.common.exception.BaseException
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.Enumeration
;
import
java.util.List
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipFile
;
public
class
TarFileOperateUtil
{
/**
* 解压zip压缩包中,指定文件类型的文件
* @param file
* @param saveRootDirectory
* @param suffix
* @return 返回解压后的文件路径列表
* @throws Exception
*/
public
static
List
<
String
>
zipFileRead
(
String
file
,
String
saveRootDirectory
,
String
suffix
)
throws
BaseException
{
try
{
List
<
String
>
filePathList
=
new
ArrayList
<>();
String
lowerCaseSuffix
=
suffix
;
if
(
StringUtils
.
isBlank
(
lowerCaseSuffix
))
{
lowerCaseSuffix
=
lowerCaseSuffix
.
toLowerCase
();
}
ZipFile
zipFile
=
new
ZipFile
(
file
);
@SuppressWarnings
(
"unchecked"
)
Enumeration
<
ZipEntry
>
enu
=
(
Enumeration
<
ZipEntry
>)
zipFile
.
entries
();
while
(
enu
.
hasMoreElements
())
{
ZipEntry
zipElement
=
enu
.
nextElement
();
InputStream
read
=
zipFile
.
getInputStream
(
zipElement
);
String
fileName
=
zipElement
.
getName
();
if
(!
zipElement
.
isDirectory
()
&&
fileName
!=
null
)
{
//是否为文件
if
(
StringUtils
.
isBlank
(
lowerCaseSuffix
))
{
if
(
zipExecute
(
zipElement
,
read
,
saveRootDirectory
))
{
filePathList
.
add
(
saveRootDirectory
+
"/"
+
fileName
);
}
}
else
if
(
fileName
.
toLowerCase
().
endsWith
(
lowerCaseSuffix
))
{
//指定文件类型
if
(
zipExecute
(
zipElement
,
read
,
saveRootDirectory
))
{
filePathList
.
add
(
saveRootDirectory
+
"/"
+
fileName
);
}
}
}
}
return
filePathList
;
}
catch
(
Exception
e
)
{
throw
new
BaseException
(
"xml解析失败"
,
ResultCode
.
FAILED_CODE
);
}
}
private
static
boolean
zipExecute
(
ZipEntry
ze
,
InputStream
read
,
String
saveRootDirectory
)
throws
IOException
{
String
fileName
=
ze
.
getName
();
File
file
=
new
File
(
saveRootDirectory
+
"/"
+
fileName
);
if
(!
file
.
exists
())
{
File
rootDirectoryFile
=
new
File
(
file
.
getParent
());
//创建目录
if
(!
rootDirectoryFile
.
exists
())
{
boolean
ifSuccess
=
rootDirectoryFile
.
mkdirs
();
if
(
ifSuccess
)
{
System
.
out
.
println
(
"文件夹创建成功!"
);
}
else
{
return
false
;
}
}
//创建文件
try
{
file
.
createNewFile
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
//写入文件
BufferedOutputStream
write
=
new
BufferedOutputStream
(
new
FileOutputStream
(
file
));
int
cha
=
0
;
while
((
cha
=
read
.
read
())
!=
-
1
)
{
write
.
write
(
cha
);
}
//要注意IO流关闭的先后顺序
write
.
flush
();
write
.
close
();
read
.
close
();
return
true
;
}
}
rs-datacenter/rs-datacenter-server/src/main/java/com/upyuns/platform/rs/datacenter/utils/XmlFileOperateUtil.java
deleted
100644 → 0
View file @
752f9bc1
package
com
.
upyuns
.
platform
.
rs
.
datacenter
.
utils
;
import
com.github.wxiaoqi.security.common.exception.BaseException
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
org.dom4j.Attribute
;
import
org.dom4j.Document
;
import
org.dom4j.Element
;
import
org.dom4j.io.SAXReader
;
import
java.io.File
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
public
class
XmlFileOperateUtil
{
public
static
void
xmlParse
(
String
xmlPath
,
Map
<
String
,
String
>
paramsMap
)
throws
BaseException
{
try
{
//1.创建Reader对象
SAXReader
reader
=
new
SAXReader
();
//2.加载xml
Document
document
=
reader
.
read
(
new
File
(
xmlPath
));
//3.获取根节点
Element
rootElement
=
document
.
getRootElement
();
Iterator
iterator
=
rootElement
.
elementIterator
();
while
(
iterator
.
hasNext
())
{
Element
stu
=
(
Element
)
iterator
.
next
();
List
<
Attribute
>
attributes
=
stu
.
attributes
();
System
.
out
.
println
(
"======获取属性值======"
);
for
(
Attribute
attribute
:
attributes
)
{
System
.
out
.
println
(
attribute
.
getValue
());
}
System
.
out
.
println
(
"======遍历子节点======"
);
Iterator
iterator1
=
stu
.
elementIterator
();
while
(
iterator1
.
hasNext
())
{
Element
stuChild
=
(
Element
)
iterator1
.
next
();
paramsMap
.
put
(
stuChild
.
getName
(),
stuChild
.
getStringValue
());
}
}
}
catch
(
Exception
e
)
{
throw
new
BaseException
(
"xml解析失败"
,
ResultCode
.
FAILED_CODE
);
}
}
}
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