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
1a1cd083
Commit
1a1cd083
authored
Aug 15, 2024
by
周健威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改代码
parent
4e388281
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
343 additions
and
0 deletions
+343
-0
DataTempcache.java
.../com/upyuns/platform/rs/website/entity/DataTempcache.java
+175
-0
DataTempcacheBiz.java
.../com/upyuns/platform/rs/website/biz/DataTempcacheBiz.java
+18
-0
DataTempcacheController.java
...rm/rs/website/controller/web/DataTempcacheController.java
+129
-0
DataTempcacheMapper.java
...pyuns/platform/rs/website/mapper/DataTempcacheMapper.java
+15
-0
DataTempcacheMapper.xml
...-server/src/main/resources/mapper/DataTempcacheMapper.xml
+6
-0
No files found.
rs-website/rs-website-api/src/main/java/com/upyuns/platform/rs/website/entity/DataTempcache.java
0 → 100755
View file @
1a1cd083
package
com
.
upyuns
.
platform
.
rs
.
website
.
entity
;
import
java.io.Serializable
;
import
java.util.Date
;
import
javax.persistence.*
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* 数据临时缓存库
*
* @author zjw
* @email jiaoruizhen@126.com
* @date 2024-08-14 14:52:35
*/
@Data
@Table
(
name
=
"data_tempcache"
)
public
class
DataTempcache
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
public
static
final
int
HASGTDATA_NOT
=
0
;
public
static
final
int
HASGTDATA_FIN
=
1
;
public
static
final
int
HASGTDATA_UPD
=
2
;
public
static
final
int
UPTYPE_UPLOAD
=
1
;
public
static
final
int
UPTYPE_GTDATA
=
2
;
public
static
final
int
UPTYPE_URL
=
3
;
/**
*
*/
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@ApiModelProperty
(
""
)
private
Integer
id
;
/**
* 数据名称
*/
@Column
(
name
=
"name"
)
@ApiModelProperty
(
value
=
"数据名称"
)
private
String
name
;
/**
* 数据类型 1--图片;2--栅格文件;3--图库
*/
@Column
(
name
=
"type"
)
@ApiModelProperty
(
value
=
"数据类型 1--图片;2--栅格文件;3--图库"
)
private
Integer
type
;
/**
* 数据来源 1--门户;2--生产线;3--AI系统
*/
@Column
(
name
=
"source"
)
@ApiModelProperty
(
value
=
"数据来源 1--门户;2--生产线;3--AI系统"
)
private
Integer
source
;
/**
* 功能模块 0--默认;
*/
@Column
(
name
=
"source_module"
)
@ApiModelProperty
(
value
=
"功能模块 0--默认;"
)
private
String
sourceModule
;
/**
* 文件名称
*/
@Column
(
name
=
"filename"
)
@ApiModelProperty
(
value
=
"文件名称"
)
private
String
filename
;
/**
* 文件类型
*/
@Column
(
name
=
"filetype"
)
@ApiModelProperty
(
value
=
"文件类型"
)
private
String
filetype
;
/**
* 文件地址
*/
@Column
(
name
=
"fileurl"
)
@ApiModelProperty
(
value
=
"文件地址"
)
private
String
fileurl
;
/**
* 文件大小
*/
@Column
(
name
=
"filesize"
)
@ApiModelProperty
(
value
=
"文件大小"
)
private
String
filesize
;
/**
* 是否删除 1--已删除;0--未删除
*/
@Column
(
name
=
"is_del"
)
@ApiModelProperty
(
value
=
"是否删除 1--已删除;0--未删除"
)
private
Integer
isDel
;
/**
* 属性信息
*/
@Column
(
name
=
"detail_json"
)
@ApiModelProperty
(
value
=
"属性信息"
)
private
String
detailJson
;
/**
* gtdata路径
*/
@Column
(
name
=
"gtdata_path"
)
@ApiModelProperty
(
value
=
"gtdata路径"
)
private
String
gtdataPath
;
/**
* 是否已经存储gtdata 0--未处理;1--已处理;2--已更新
*/
@Column
(
name
=
"has_gtdata"
)
@ApiModelProperty
(
value
=
"是否已经存储gtdata 0--未处理;1--已处理;2--已更新"
)
private
Integer
hasGtdata
;
/**
* 创建时间
*/
@Column
(
name
=
"crt_time"
)
@ApiModelProperty
(
value
=
"创建时间"
,
hidden
=
true
)
private
Long
crtTime
;
/**
* 更新时间
*/
@Column
(
name
=
"upd_time"
)
@ApiModelProperty
(
value
=
"更新时间"
,
hidden
=
true
)
private
Long
updTime
;
/**
* 创建人
*/
@Column
(
name
=
"crt_user"
)
@ApiModelProperty
(
value
=
"创建人"
)
private
String
crtUser
;
/**
* 更新人
*/
@Column
(
name
=
"upd_user"
)
@ApiModelProperty
(
value
=
"更新人"
)
private
String
updUser
;
/**
* 定制用户
*/
@Column
(
name
=
"user_id"
)
@ApiModelProperty
(
value
=
"定制用户"
)
private
Integer
userId
;
/**
* 1--已提交;
*/
@Column
(
name
=
"status"
)
@ApiModelProperty
(
value
=
"1--已提交;"
)
private
Integer
status
;
@Column
(
name
=
"remark"
)
@ApiModelProperty
(
value
=
"备注描述"
)
private
String
remark
;
@Column
(
name
=
"uptype"
)
@ApiModelProperty
(
value
=
"上传类型 1--文件上传;2--gtdata路径;3--url"
)
private
Integer
uptype
;
@Column
(
name
=
"upurl"
)
@ApiModelProperty
(
value
=
"上传文件url地址"
)
private
String
upurl
;
}
rs-website/rs-website-server/src/main/java/com/upyuns/platform/rs/website/biz/DataTempcacheBiz.java
0 → 100644
View file @
1a1cd083
package
com
.
upyuns
.
platform
.
rs
.
website
.
biz
;
import
org.springframework.stereotype.Service
;
import
com.upyuns.platform.rs.website.entity.DataTempcache
;
import
com.upyuns.platform.rs.website.mapper.DataTempcacheMapper
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
/**
* 数据临时缓存库
*
* @author zjw
* @email jiaoruizhen@126.com
* @date 2024-08-14 14:52:35
*/
@Service
public
class
DataTempcacheBiz
extends
BaseBiz
<
DataTempcacheMapper
,
DataTempcache
>
{
}
\ No newline at end of file
rs-website/rs-website-server/src/main/java/com/upyuns/platform/rs/website/controller/web/DataTempcacheController.java
0 → 100755
View file @
1a1cd083
package
com
.
upyuns
.
platform
.
rs
.
website
.
controller
.
web
;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.http.HttpUtil
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.rest.BaseController
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
com.github.wxiaoqi.security.common.util.process.SystemConfig
;
import
com.upyuns.platform.rs.gtdata.GtDataRestClient
;
import
com.upyuns.platform.rs.gtdata.GtFileInfo
;
import
com.upyuns.platform.rs.website.biz.DataTempcacheBiz
;
import
com.upyuns.platform.rs.website.entity.DataTempcache
;
import
com.upyuns.platform.rs.website.entity.FileData
;
import
com.upyuns.platform.rs.website.entity.GainData
;
import
io.swagger.annotations.ApiModelProperty
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.Map
;
import
static
com
.
github
.
wxiaoqi
.
security
.
common
.
constant
.
CommonConstants
.
SYS_TRUE
;
@RestController
@RequestMapping
(
"gainData/web"
)
public
class
DataTempcacheController
extends
BaseController
<
DataTempcacheBiz
,
DataTempcache
>
{
@Autowired
GtDataRestClient
gtDataRestClient
;
@Value
(
"${universal.tempcachePath}"
)
private
String
tempcachePath
;
@Value
(
"${universal.baseUploadPath}"
)
private
String
baseUploadPath
;
@Value
(
"${universal.url}"
)
private
String
xx_url
;
@ApiModelProperty
(
"添加修改文件"
)
@RequestMapping
(
value
=
"/saveDataTempcache"
,
method
=
RequestMethod
.
POST
)
public
ObjectRestResponse
<
FileData
>
saveDataTempcache
(
@RequestBody
DataTempcache
dataTempcache
)
{
if
(
null
!=
dataTempcache
.
getUptype
())
{
if
(
DataTempcache
.
UPTYPE_GTDATA
==
dataTempcache
.
getUptype
())
{
// //gtdtat 获取数据
Map
<
String
,
Object
>
responseMap
=
gtDataRestClient
.
list
(
dataTempcache
.
getGtdataPath
());
if
(
null
!=
responseMap
&&
null
!=
responseMap
.
get
(
"HttpStatusCode"
)
&&
null
!=
responseMap
.
get
(
"files"
)
&&
200
==
(
Integer
)
responseMap
.
get
(
"HttpStatusCode"
))
{
List
<
GtFileInfo
>
gtFileInfos
=
Convert
.
toList
(
GtFileInfo
.
class
,
responseMap
.
get
(
"files"
));
GtFileInfo
gtFileInfo
=
gtFileInfos
.
get
(
0
);
String
filename
=
gtFileInfo
.
getFilename
();
String
filesize
=
gtFileInfo
.
getSize
();
String
filetype
=
filename
.
substring
(
filename
.
lastIndexOf
(
"."
));
long
fileSize
=
Long
.
valueOf
(
filesize
);
// double fileSizeInKB = (double) fileSize / 1024; // 转换为 KB
double
fileSizeInMB
=
(
double
)
fileSize
/
(
1024
*
1024
);
// 转换为 MB
double
roundedFileSizeInMB
=
Math
.
round
(
fileSizeInMB
*
100.0
)
/
100.0
;
// 保留两位小数
String
fileSizeString
=
String
.
format
(
"%.2f MB"
,
roundedFileSizeInMB
);
dataTempcache
.
setHasGtdata
(
SYS_TRUE
);
dataTempcache
.
setFilename
(
filename
);
dataTempcache
.
setFiletype
(
filetype
);
dataTempcache
.
setFilesize
(
fileSizeString
);
}
else
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
FAILED_CODE
,
"分布式路径不对"
);
}
}
else
if
(
DataTempcache
.
UPTYPE_URL
==
dataTempcache
.
getUptype
())
{
//提前插入
if
(
null
==
dataTempcache
.
getId
())
{
baseBiz
.
insertSelective
(
dataTempcache
);
}
//创建目录
if
(!
FileUtil
.
exist
(
baseUploadPath
+
tempcachePath
+
"/"
+
dataTempcache
.
getId
()))
{
FileUtil
.
mkdir
(
baseUploadPath
+
tempcachePath
+
"/"
+
dataTempcache
.
getId
());
}
String
fileName
=
StrUtil
.
subAfter
(
dataTempcache
.
getUpurl
(),
"/"
,
true
);
//然后获取这个文件名的后缀
String
suffix
=
StrUtil
.
subAfter
(
fileName
,
"."
,
true
);
if
(
StrUtil
.
isBlank
(
dataTempcache
.
getFilename
()))
{
dataTempcache
.
setFilename
(
fileName
);
}
if
(
StrUtil
.
isBlank
(
dataTempcache
.
getFiletype
()))
{
dataTempcache
.
setFiletype
(
"."
+
suffix
);
}
//下载文件
Long
size
=
HttpUtil
.
downloadFile
(
dataTempcache
.
getUpurl
(),
FileUtil
.
file
(
baseUploadPath
+
tempcachePath
+
"/"
+
dataTempcache
.
getFilename
()));
double
fileSizeInMB
=
(
double
)
size
/
(
1024
*
1024
);
// 转换为 MB
double
roundedFileSizeInMB
=
Math
.
round
(
fileSizeInMB
*
100.0
)
/
100.0
;
// 保留两位小数
String
fileSizeString
=
String
.
format
(
"%.2f MB"
,
roundedFileSizeInMB
);
dataTempcache
.
setFilesize
(
fileSizeString
);
dataTempcache
.
setFileurl
(
xx_url
+
SystemConfig
.
XXMP_URL
+
tempcachePath
+
"/"
+
dataTempcache
.
getFilename
());
}
}
if
(
dataTempcache
.
getId
()!=
null
){
baseBiz
.
updateSelectiveById
(
dataTempcache
);
}
else
{
dataTempcache
.
setIsDel
(
0
);
baseBiz
.
insertSelective
(
dataTempcache
);
}
return
ObjectRestResponse
.
succ
();
}
public
static
void
main
(
String
[]
args
)
{
String
url
=
"http://example.com/path/to/file.jpg"
;
// 假设URL的最后一个部分是文件名,我们可以先获取这个部分
String
fileName
=
StrUtil
.
subAfter
(
url
,
"/"
,
true
);
System
.
out
.
println
(
"URL路径的文件后缀是:"
+
fileName
);
// 然后获取这个文件名的后缀
String
suffix
=
StrUtil
.
subAfter
(
fileName
,
"."
,
true
);
System
.
out
.
println
(
"URL路径的文件后缀是:"
+
suffix
);
}
}
\ No newline at end of file
rs-website/rs-website-server/src/main/java/com/upyuns/platform/rs/website/mapper/DataTempcacheMapper.java
0 → 100755
View file @
1a1cd083
package
com
.
upyuns
.
platform
.
rs
.
website
.
mapper
;
import
com.upyuns.platform.rs.website.entity.DataTempcache
;
import
tk.mybatis.mapper.common.Mapper
;
/**
* 数据临时缓存库
*
* @author zjw
* @email jiaoruizhen@126.com
* @date 2024-08-14 14:52:35
*/
public
interface
DataTempcacheMapper
extends
Mapper
<
DataTempcache
>
{
}
rs-website/rs-website-server/src/main/resources/mapper/DataTempcacheMapper.xml
0 → 100755
View file @
1a1cd083
<?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.upyuns.platform.rs.website.mapper.DataTempcacheMapper"
>
</mapper>
\ 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