记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
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
董敬伟
liquidnet-bus-v1
Commits
33065d14
Commit
33065d14
authored
Dec 31, 2021
by
jiangxiulong
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'jxl_up_video' into dev_goblin
parents
26ab013e
ad534d28
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
345 additions
and
96 deletions
+345
-96
UploadVo.java
...iquidnet/service/kylin/dto/vo/basicServices/UploadVo.java
+2
-0
AdminUpushServiceImpl.java
...in/zhengzai/admin/service/impl/AdminUpushServiceImpl.java
+3
-3
FilesUtils.java
...main/java/com/liquidnet/commons/lang/util/FilesUtils.java
+65
-17
PlatformOssFiles.java
.../com/liquidnet/service/kylin/entity/PlatformOssFiles.java
+1
-0
FeignPlatformCandyTaskClient.java
...ice/feign/platform/task/FeignPlatformCandyTaskClient.java
+4
-0
PlatformTaskHandler.java
...et/service/executor/main/handler/PlatformTaskHandler.java
+18
-0
db_kylin_structure.sql
.../liquidnet-service-kylin-impl/docu/db_kylin_structure.sql
+0
-21
db_platform_structure.sql
...dnet-service-platform-impl/docu/db_platform_structure.sql
+22
-0
AlOssController.java
...ce/platform/controller/basicServices/AlOssController.java
+129
-55
TaskController.java
...net/service/platform/controller/sweet/TaskController.java
+88
-0
DataUtils.java
.../java/com/liquidnet/service/platform/utils/DataUtils.java
+13
-0
No files found.
liquidnet-bus-api/liquidnet-service-kylin-api/src/main/java/com/liquidnet/service/kylin/dto/vo/basicServices/UploadVo.java
View file @
33065d14
...
...
@@ -25,6 +25,8 @@ public class UploadVo implements Serializable {
private
String
fileName
;
@ApiModelProperty
(
value
=
"上传后的地址"
)
private
String
ossPath
;
@ApiModelProperty
(
value
=
"视频截帧图片文件地址"
)
private
String
videoImg
;
@ApiModelProperty
(
value
=
"文件类型"
)
private
String
contentType
;
@ApiModelProperty
(
value
=
"文件大小"
)
...
...
liquidnet-bus-client/liquidnet-client-admin/liquidnet-client-admin-zhengzai/src/main/java/com/liquidnet/client/admin/zhengzai/admin/service/impl/AdminUpushServiceImpl.java
View file @
33065d14
...
...
@@ -111,20 +111,20 @@ public class AdminUpushServiceImpl extends ServiceImpl<AdminUpushMapper, AdminUp
if
(
upushParam
.
getPushRange
()
==
1
)
{
if
(!
CollectionUtil
.
isEmpty
(
pushList
))
{
if
(
pushList
.
size
()
>=
20
)
{
pushList
.
remove
(
0
);
pushList
.
remove
(
pushList
.
size
()-
1
);
}
}
pushList
.
addFirst
(
adminUpushVo
);
if
(!
CollectionUtil
.
isEmpty
(
pushList2
))
{
if
(
pushList2
.
size
()
>=
20
)
{
pushList2
.
remove
(
0
);
pushList2
.
remove
(
pushList
.
size
()-
1
);
}
}
pushList2
.
addFirst
(
adminUpushVo
);
}
else
{
if
(!
CollectionUtil
.
isEmpty
(
pushList
))
{
if
(
pushList
.
size
()
>=
20
)
{
pushList
.
remove
(
0
);
pushList
.
remove
(
pushList
.
size
()-
1
);
}
}
pushList
.
addFirst
(
adminUpushVo
);
...
...
liquidnet-bus-common/liquidnet-common-base/src/main/java/com/liquidnet/commons/lang/util/FilesUtils.java
View file @
33065d14
...
...
@@ -8,9 +8,12 @@ import java.math.BigInteger;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.security.MessageDigest
;
import
java.time.LocalDateTime
;
import
java.util.UUID
;
/**
* aloss 上传MultipartFile to File
*
* @author jiangxiulong
* @since 2021-06-10
*/
...
...
@@ -22,12 +25,10 @@ public class FilesUtils {
* @param file
* @throws Exception
*/
public
static
File
multipartFileToFile
(
MultipartFile
file
)
throws
Exception
{
public
static
File
multipartFileToFile
(
MultipartFile
file
)
{
try
{
File
toFile
=
null
;
if
(
file
.
equals
(
""
)
||
file
.
getSize
()
<=
0
)
{
file
=
null
;
}
else
{
if
(!
file
.
equals
(
""
)
&&
file
.
getSize
()
>
0
)
{
InputStream
ins
=
null
;
ins
=
file
.
getInputStream
();
toFile
=
new
File
(
file
.
getOriginalFilename
());
...
...
@@ -35,6 +36,10 @@ public class FilesUtils {
ins
.
close
();
}
return
toFile
;
}
catch
(
Exception
e
)
{
log
.
error
(
"multipartFileToFileError"
,
e
);
return
null
;
}
}
//获取流文件
...
...
@@ -55,20 +60,22 @@ public class FilesUtils {
/**
* 删除本地临时文件
*
* @param file
*/
public
static
void
delteTempFile
(
File
file
)
{
public
static
void
del
e
teTempFile
(
File
file
)
{
try
{
if
(
file
!=
null
)
{
file
.
delete
();
}
}
catch
(
Exception
e
)
{
log
.
error
(
"delteTempFileError"
,
e
);
log
.
error
(
"del
e
teTempFileError"
,
e
);
}
}
/**
* 获取文件的md5值
*
* @param file 文件
* @return 返回文件的md5值字符串
*/
...
...
@@ -100,7 +107,14 @@ public class FilesUtils {
}
}
public
static
File
inputStreamToFile
(
String
url
,
String
name
){
/**
* 大美 通过URL上传
*
* @param url
* @param name
* @return
*/
public
static
File
inputStreamToFile
(
String
url
,
String
name
)
{
try
{
HttpURLConnection
httpUrl
=
(
HttpURLConnection
)
new
URL
(
url
).
openConnection
();
httpUrl
.
connect
();
...
...
@@ -119,9 +133,43 @@ public class FilesUtils {
os
.
close
();
ins
.
close
();
return
file
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
}
catch
(
Exception
e
)
{
log
.
error
(
"inputStreamToFileUrlError"
,
e
);
return
null
;
}
}
/**
* 获取上传含文件名的完整路径 这里文件名用了uuid 防止重复,可以根据自己的需要来写
*
* @param pathName banner
* @param filename time.jpeg
* @return
*/
public
static
String
getUploadPath
(
String
pathName
,
String
filename
)
{
// 078a77e0-cf80-481b-824c-5935247cff15.jpeg
String
uploadName
=
UUID
.
randomUUID
()
+
filename
.
substring
(
filename
.
lastIndexOf
(
"."
));
// 078a77e0cf80481b824c5935247cff15.jpeg
uploadName
=
uploadName
.
replace
(
"-"
,
""
);
return
pathName
+
"/"
+
DateUtil
.
format
(
LocalDateTime
.
now
(),
DateUtil
.
Formatter
.
yyyy_MM_dd2
)
+
"/"
+
uploadName
;
}
/**
* 获取 bucketName
*
* @param buckType
* @return
*/
public
static
String
getBucketName
(
int
buckType
)
{
String
bucketName
=
"img-zhengzai-tv"
;
switch
(
buckType
)
{
case
1
:
bucketName
=
"img-zhengzai-tv"
;
break
;
case
2
:
bucketName
=
"app-zhengzai-tv"
;
break
;
}
return
bucketName
;
}
}
liquidnet-bus-do/liquidnet-service-kylin-do/src/main/java/com/liquidnet/service/kylin/entity/PlatformOssFiles.java
View file @
33065d14
...
...
@@ -27,6 +27,7 @@ public class PlatformOssFiles implements Serializable ,Cloneable {
private
String
ossFilesId
;
private
String
fileName
;
private
String
ossPath
;
private
String
videoImg
;
private
String
contentType
;
private
Integer
size
;
private
String
md5str
;
...
...
liquidnet-bus-feign/liquidnet-api-feign-platform/src/main/java/com/liquidnet/service/feign/platform/task/FeignPlatformCandyTaskClient.java
View file @
33065d14
...
...
@@ -4,6 +4,7 @@ import com.liquidnet.service.base.ResponseDto;
import
feign.hystrix.FallbackFactory
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
@Component
...
...
@@ -27,4 +28,7 @@ public interface FeignPlatformCandyTaskClient {
@PutMapping
(
"ccoupon/task/due/user"
)
ResponseDto
<
String
>
dueProcessForUser
();
@GetMapping
(
"followDoTask/doTask"
)
ResponseDto
doTask
();
}
liquidnet-bus-service/liquidnet-service-executor-all/liquidnet-service-executor-main/src/main/java/com/liquidnet/service/executor/main/handler/PlatformTaskHandler.java
View file @
33065d14
...
...
@@ -110,4 +110,22 @@ public class PlatformTaskHandler {
return
fail
;
}
}
// 关注任务加积分脚本
@XxlJob
(
value
=
"sev-platform:followDoTask"
)
public
ReturnT
<
String
>
followDoTask
()
{
try
{
ResponseDto
<
String
>
dto
=
feignPlatformCandyTaskClient
.
doTask
();
String
dtoStr
=
JsonUtils
.
toJson
(
dto
);
log
.
info
(
"result of handler:{}"
,
dtoStr
);
ReturnT
<
String
>
success
=
ReturnT
.
SUCCESS
;
success
.
setMsg
(
dtoStr
);
return
success
;
}
catch
(
Exception
e
)
{
log
.
error
(
"exception of handler:{}"
,
e
.
getMessage
(),
e
);
ReturnT
<
String
>
fail
=
ReturnT
.
FAIL
;
fail
.
setMsg
(
e
.
getLocalizedMessage
());
return
fail
;
}
}
}
liquidnet-bus-service/liquidnet-service-kylin/liquidnet-service-kylin-impl/docu/db_kylin_structure.sql
View file @
33065d14
...
...
@@ -969,27 +969,6 @@ CREATE TABLE `kylin_zhengzai_app_versions`
DEFAULT
CHARSET
utf8mb4
COLLATE
utf8mb4_unicode_ci
COMMENT
'正在现场app版本控制'
;
drop
TABLE
if
exists
`platform_oss_files`
;
create
table
platform_oss_files
(
`mid`
int
(
11
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`oss_files_id`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'oss_files_id'
,
`file_name`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'源文件名称'
,
`content_type`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'文件类型'
,
`size`
int
NOT
NULL
DEFAULT
0
COMMENT
'文件大小'
,
`md5str`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'md5值判断文件是否相同'
,
`oss_path`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'文件地址(阿里oss)'
,
`buck_type`
tinyint
NOT
NULL
DEFAULT
'0'
COMMENT
'buck_type'
,
`uploader_uid`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'上传人id'
,
`uploader_name`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'上传人姓名'
,
`created_at`
timestamp
NULL
DEFAULT
NULL
,
`updated_at`
timestamp
NULL
DEFAULT
NULL
,
KEY
`kylin_oss_files_id_index`
(
`oss_files_id`
),
PRIMARY
KEY
(
`mid`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
utf8mb4
COLLATE
utf8mb4_unicode_ci
COMMENT
'阿里云OSS上传记录'
;
drop
TABLE
if
exists
`admin_upush`
;
CREATE
TABLE
`admin_upush`
(
...
...
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/docu/db_platform_structure.sql
0 → 100755
View file @
33065d14
drop
TABLE
if
exists
`platform_oss_files`
;
create
table
platform_oss_files
(
`mid`
int
(
11
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`oss_files_id`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'oss_files_id'
,
`file_name`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'源文件名称'
,
`content_type`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'文件类型'
,
`size`
int
NOT
NULL
DEFAULT
0
COMMENT
'文件大小'
,
`md5str`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'md5值判断文件是否相同'
,
`oss_path`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'文件地址(阿里oss)'
,
`buck_type`
tinyint
NOT
NULL
DEFAULT
'0'
COMMENT
'buck_type'
,
`uploader_uid`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'上传人id'
,
`uploader_name`
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'上传人姓名'
,
`created_at`
timestamp
NULL
DEFAULT
NULL
,
`updated_at`
timestamp
NULL
DEFAULT
NULL
,
KEY
`kylin_oss_files_id_index`
(
`oss_files_id`
),
PRIMARY
KEY
(
`mid`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
utf8mb4
COLLATE
utf8mb4_unicode_ci
COMMENT
'阿里云OSS上传记录'
;
alter
table
platform_oss_files
add
video_img
varchar
(
255
)
NOT
NULL
DEFAULT
''
COMMENT
'视频截帧图片文件地址(阿里oss)'
after
oss_path
;
\ No newline at end of file
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/src/main/java/com/liquidnet/service/platform/controller/basicServices/AlOssController.java
View file @
33065d14
...
...
@@ -8,7 +8,6 @@ import com.aliyun.oss.model.ProcessObjectRequest;
import
com.aliyun.oss.model.PutObjectRequest
;
import
com.baomidou.mybatisplus.core.toolkit.CollectionUtils
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.liquidnet.commons.lang.util.CollectionUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.FilesUtils
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
...
...
@@ -23,10 +22,15 @@ import io.swagger.annotations.ApiOperation;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.PostMapping
;
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
java.io.File
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.time.LocalDateTime
;
import
java.util.Formatter
;
import
java.util.List
;
...
...
@@ -51,6 +55,8 @@ public class AlOssController {
private
String
accessKeyId
;
@Value
(
"${liquidnet.al-oss.accessKeySecret}"
)
private
String
accessKeySecret
;
@Value
(
"${liquidnet.al-oss.imgUrl}"
)
private
String
imgUrl
;
@Autowired
private
PlatformOssFilesMapper
platformOssFilesMapper
;
...
...
@@ -59,55 +65,98 @@ public class AlOssController {
@ApiOperation
(
"阿里云上传"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
type
=
"form"
,
dataType
=
"File"
,
name
=
"file"
,
value
=
"文件"
,
required
=
true
),
@ApiImplicitParam
(
type
=
"form"
,
dataType
=
"String"
,
name
=
"pathName"
,
value
=
"归类的文件夹名称 比如banner上传就传 banner 返回的地址就会是bnanner/XXX"
,
defaultValue
=
"
other
"
),
@ApiImplicitParam
(
type
=
"form"
,
dataType
=
"String"
,
name
=
"pathName"
,
value
=
"归类的文件夹名称 比如banner上传就传 banner 返回的地址就会是bnanner/XXX"
,
defaultValue
=
"
test
"
),
@ApiImplicitParam
(
type
=
"form"
,
dataType
=
"Integer"
,
name
=
"buckType"
,
value
=
"buckType 1正常的任何文件上传 2apk上传"
,
defaultValue
=
"1"
),
@ApiImplicitParam
(
type
=
"form"
,
dataType
=
"Integer"
,
name
=
"resize"
,
value
=
"resize"
,
defaultValue
=
"0"
),
@ApiImplicitParam
(
type
=
"form"
,
dataType
=
"Integer"
,
name
=
"isCutFrame"
,
value
=
"是否截取帧数 用于视频获取图片 0不需要 1需要"
,
defaultValue
=
"0"
),
})
public
ResponseDto
<
UploadVo
>
upload
(
@RequestParam
MultipartFile
file
,
@RequestParam
(
defaultValue
=
"other"
)
String
pathName
,
@RequestParam
(
defaultValue
=
"1"
,
required
=
false
)
int
buckType
,
@RequestParam
(
defaultValue
=
"0"
,
required
=
false
)
int
resize
@RequestParam
(
defaultValue
=
"0"
,
required
=
false
)
int
resize
,
@RequestParam
(
defaultValue
=
"0"
,
required
=
false
)
int
isCutFrame
)
{
OSS
ossClient
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessKeyId
,
accessKeySecret
);
File
fileNew
=
FilesUtils
.
multipartFileToFile
(
file
);
if
(
null
==
fileNew
)
{
return
ResponseDto
.
failure
(
"上传失败"
);
}
File
fileNew
=
null
;
try
{
fileNew
=
FilesUtils
.
multipartFileToFile
(
file
);
}
catch
(
Exception
e
)
{
return
null
;
// 是否上传过 有直接返回
PlatformOssFiles
ossFile
=
this
.
getOldOssFile
(
fileNew
);
UploadVo
uploadVo
=
new
UploadVo
();
if
(
null
==
ossFile
)
{
// 上传
ossFile
=
this
.
uploadOssFile
(
file
,
pathName
,
buckType
,
resize
,
fileNew
,
isCutFrame
);
}
BeanUtils
.
copyProperties
(
ossFile
,
uploadVo
);
// file md5
String
fileMD5
=
FilesUtils
.
getFileMD5
(
fileNew
);
// 删除临时文件 因为老文件也生成了所以也要删除
FilesUtils
.
deleteTempFile
(
fileNew
);
return
ResponseDto
.
success
(
uploadVo
);
}
/**
* 获取老的上传文件
*
* @param file
* @return
*/
private
PlatformOssFiles
getOldOssFile
(
File
file
)
{
String
fileMD5
=
FilesUtils
.
getFileMD5
(
file
);
List
<
PlatformOssFiles
>
platformOssFiles
=
platformOssFilesMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
PlatformOssFiles
.
class
)
.
eq
(
PlatformOssFiles:
:
getMd5str
,
fileMD5
)
);
UploadVo
uploadVo
=
new
UploadVo
();
if
(
CollectionUtils
.
isEmpty
(
platformOssFiles
))
{
String
filename
=
file
.
getResource
().
getFilename
();
// time.jpeg
//这里文件名用了uuid 防止重复,可以根据自己的需要来写
String
uploadName
=
UUID
.
randomUUID
()
+
filename
.
substring
(
filename
.
lastIndexOf
(
"."
));
// 078a77e0-cf80-481b-824c-5935247cff15.jpeg
uploadName
=
uploadName
.
replace
(
"-"
,
""
);
// 078a77e0cf80481b824c5935247cff15.jpeg
String
uploadpath
=
pathName
+
"/"
+
DateUtil
.
format
(
LocalDateTime
.
now
(),
DateUtil
.
Formatter
.
yyyy_MM_dd2
)
+
"/"
+
uploadName
;
String
buckName
=
"img-zhengzai-tv"
;
if
(
2
==
buckType
)
{
buckName
=
"app-zhengzai-tv"
;
return
null
;
}
else
{
return
platformOssFiles
.
get
(
0
);
}
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
buckName
,
uploadpath
,
fileNew
);
}
/**
* 上传文件
*
* @param file
* @param pathName
* @param buckType
* @param resize
* @param fileNew
* @return
*/
private
PlatformOssFiles
uploadOssFile
(
MultipartFile
file
,
String
pathName
,
int
buckType
,
int
resize
,
File
fileNew
,
int
isCutFrame
)
{
OSS
ossClient
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessKeyId
,
accessKeySecret
);
String
filename
=
""
;
String
contentType
=
""
;
int
size
=
0
;
if
(
null
==
file
)
{
filename
=
fileNew
.
getName
();
Path
fileNewPath
=
new
File
(
fileNew
.
getPath
()).
toPath
();
try
{
contentType
=
Files
.
probeContentType
(
fileNewPath
);
}
catch
(
Exception
e
)
{
}
size
=
(
int
)
fileNew
.
length
();
}
else
{
filename
=
file
.
getResource
().
getFilename
();
contentType
=
file
.
getContentType
();
size
=
(
int
)
file
.
getSize
();
}
String
uploadPath
=
FilesUtils
.
getUploadPath
(
pathName
,
filename
);
String
bucketName
=
FilesUtils
.
getBucketName
(
buckType
);
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
bucketName
,
uploadPath
,
fileNew
);
ossClient
.
putObject
(
putObjectRequest
);
if
(
resize
>
0
)
{
// 将图片缩放
StringBuilder
sbStyle
=
new
StringBuilder
();
Formatter
styleFormatter
=
new
Formatter
(
sbStyle
);
String
styleType
=
"image/resize,w_"
+
resize
;
// String styleType = "image/resize,m_fixed,w_100,h_100";
styleFormatter
.
format
(
"%s|sys/saveas,o_%s,b_%s"
,
styleType
,
BinaryUtil
.
toBase64String
(
uploadpath
.
getBytes
()),
BinaryUtil
.
toBase64String
(
buckName
.
getBytes
()));
ProcessObjectRequest
request
=
new
ProcessObjectRequest
(
buckName
,
uploadpath
,
sbStyle
.
toString
());
GenericResult
processResult
=
ossClient
.
processObject
(
request
);
if
(
resize
>
0
)
{
// 裁切
this
.
ossFileResize
(
resize
,
uploadPath
,
bucketName
,
ossClient
);
}
PlatformOssFiles
ossFileVideoImg
=
null
;
if
(
isCutFrame
>
0
)
{
// 截取帧数
ossFileVideoImg
=
this
.
ossFileCutFrame
(
uploadPath
,
pathName
,
buckType
);
}
ossClient
.
shutdown
();
...
...
@@ -116,24 +165,49 @@ public class AlOssController {
PlatformOssFiles
platformOssFilesDate
=
new
PlatformOssFiles
();
String
ossFilesId
=
IDGenerator
.
nextSnowId
();
platformOssFilesDate
.
setOssFilesId
(
ossFilesId
);
platformOssFilesDate
.
setOssPath
(
uploadpath
);
platformOssFilesDate
.
setOssPath
(
uploadPath
);
if
(
null
!=
ossFileVideoImg
)
{
platformOssFilesDate
.
setVideoImg
(
ossFileVideoImg
.
getOssPath
());
}
platformOssFilesDate
.
setFileName
(
filename
);
platformOssFilesDate
.
setContentType
(
file
.
getContentType
());
platformOssFilesDate
.
setSize
((
int
)
file
.
getSize
());
platformOssFilesDate
.
setContentType
(
contentType
);
platformOssFilesDate
.
setSize
(
size
);
String
fileMD5
=
FilesUtils
.
getFileMD5
(
fileNew
);
platformOssFilesDate
.
setMd5str
(
fileMD5
);
platformOssFilesDate
.
setBuckType
(
buckType
);
platformOssFilesDate
.
setCreatedAt
(
DateUtil
.
getNowTime
());
platformOssFilesMapper
.
insert
(
platformOssFilesDate
);
BeanUtils
.
copyProperties
(
platformOssFilesDate
,
uploadVo
);
}
else
{
PlatformOssFiles
platformOssFilesOne
=
platformOssFiles
.
get
(
0
);
BeanUtils
.
copyProperties
(
platformOssFilesOne
,
uploadVo
);
return
platformOssFilesDate
;
}
FilesUtils
.
delteTempFile
(
fileNew
);
// 删除临时文件
/**
* oss图片裁切
*
* @param resize
* @param uploadPath
* @param bucketName
* @param ossClient
* @return
*/
private
GenericResult
ossFileResize
(
int
resize
,
String
uploadPath
,
String
bucketName
,
OSS
ossClient
)
{
// 将图片缩放
StringBuilder
sbStyle
=
new
StringBuilder
();
Formatter
styleFormatter
=
new
Formatter
(
sbStyle
);
String
styleType
=
"image/resize,w_"
+
resize
;
// String styleType = "image/resize,m_fixed,w_100,h_100";
styleFormatter
.
format
(
"%s|sys/saveas,o_%s,b_%s"
,
styleType
,
BinaryUtil
.
toBase64String
(
uploadPath
.
getBytes
()),
BinaryUtil
.
toBase64String
(
bucketName
.
getBytes
()));
ProcessObjectRequest
request
=
new
ProcessObjectRequest
(
bucketName
,
uploadPath
,
sbStyle
.
toString
());
GenericResult
processResult
=
ossClient
.
processObject
(
request
);
return
processResult
;
}
return
ResponseDto
.
success
(
uploadVo
);
private
PlatformOssFiles
ossFileCutFrame
(
String
ossFileUrl
,
String
pathName
,
int
buckType
)
{
String
style
=
"?x-oss-process=video/snapshot,t_0,f_jpg,w_0,h_0,m_fast,ar_auto"
;
File
fileNew
=
FilesUtils
.
inputStreamToFile
(
imgUrl
.
concat
(
ossFileUrl
).
concat
(
style
),
System
.
currentTimeMillis
()
+
".jpg"
);
return
this
.
uploadOssFile
(
null
,
pathName
,
buckType
,
0
,
fileNew
,
0
);
}
@PostMapping
(
"/uploadUrl"
)
...
...
@@ -184,7 +258,7 @@ public class AlOssController {
BeanUtils
.
copyProperties
(
platformOssFilesOne
,
uploadVo
);
}
FilesUtils
.
delteTempFile
(
fileNew
);
// 删除临时文件
FilesUtils
.
del
e
teTempFile
(
fileNew
);
// 删除临时文件
return
ResponseDto
.
success
(
uploadVo
);
}
...
...
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/src/main/java/com/liquidnet/service/platform/controller/sweet/TaskController.java
0 → 100644
View file @
33065d14
package
com
.
liquidnet
.
service
.
platform
.
controller
.
sweet
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.feign.stone.api.FeignStoneIntegralClient
;
import
com.liquidnet.service.platform.utils.DataUtils
;
import
com.liquidnet.service.sweet.entity.SweetWechatUsers
;
import
com.liquidnet.service.sweet.mapper.SweetWechatUsersMapper
;
import
com.liquidnet.service.sweet.vo.SweetAppletUsersVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.List
;
/**
* <p>
* 关注任务加积分脚本
* </p>
*
* @author jiangxiulong
* @since 2021-12-28
*/
@Api
(
tags
=
"关注任务加积分脚本"
)
@Slf4j
@RestController
@RequestMapping
(
"followDoTask"
)
public
class
TaskController
{
@Autowired
private
SweetWechatUsersMapper
usersMapper
;
@Autowired
private
FeignStoneIntegralClient
feignStoneIntegralClient
;
@Autowired
private
DataUtils
dataUtils
;
@GetMapping
(
"doTask"
)
@ApiOperation
(
"退款回调"
)
public
ResponseDto
doTask
()
{
int
size
=
1000
;
LocalDateTime
localDateTime
=
LocalDateTime
.
now
();
LocalDateTime
newTime
=
localDateTime
.
minusMinutes
(
10
);
// String timeStr = "2021-12-28 00:00:00";
// DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// LocalDateTime dateTime = LocalDateTime.parse(timeStr, df);
// 获取总记录数
Integer
count
=
usersMapper
.
selectCount
(
Wrappers
.
lambdaQuery
(
SweetWechatUsers
.
class
)
.
gt
(
SweetWechatUsers:
:
getCreatedAt
,
newTime
)
.
eq
(
SweetWechatUsers:
:
getType
,
2
)
);
// 总page
int
countPage
=
(
int
)
Math
.
ceil
(
count
/
size
);
countPage
=
countPage
+
1
;
for
(
int
page
=
0
;
page
<
countPage
;
page
++)
{
List
<
SweetWechatUsers
>
sweetWechatUsers
=
usersMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
SweetWechatUsers
.
class
)
.
gt
(
SweetWechatUsers:
:
getCreatedAt
,
newTime
)
.
last
(
"limit "
+
(
page
*
size
)
+
","
+
((
page
+
1
)
*
size
))
);
for
(
SweetWechatUsers
info
:
sweetWechatUsers
)
{
try
{
SweetAppletUsersVo
sweetAppletUsers
=
dataUtils
.
getSweetAppletUsersOfUnionId
(
info
.
getUnionId
());
if
(
sweetAppletUsers
!=
null
)
{
if
(
sweetAppletUsers
.
getUserId
()
!=
null
&&
!
sweetAppletUsers
.
getUserId
().
isEmpty
())
{
log
.
info
(
"followDoTask userId:{}"
,
sweetAppletUsers
.
getUserId
());
ResponseDto
<
HashMap
<
String
,
Object
>>
hashMapResponseDto
=
feignStoneIntegralClient
.
doTask
(
4
,
sweetAppletUsers
.
getUserId
());
//log.info("followDoTask res:{}", hashMapResponseDto);
}
}
}
catch
(
Exception
e
)
{
}
}
}
return
ResponseDto
.
success
();
}
}
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/src/main/java/com/liquidnet/service/platform/utils/DataUtils.java
View file @
33065d14
...
...
@@ -13,6 +13,8 @@ import com.liquidnet.service.kylin.dto.vo.returns.KylinOrderListVo;
import
com.liquidnet.service.kylin.entity.KylinBuyNotice
;
import
com.liquidnet.service.kylin.entity.KylinOrderCoupons
;
import
com.liquidnet.service.kylin.mapper.KylinBuyNoticeMapper
;
import
com.liquidnet.service.sweet.constant.SweetConstant
;
import
com.liquidnet.service.sweet.vo.SweetAppletUsersVo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
...
...
@@ -400,4 +402,15 @@ public class DataUtils {
return
(
ArrayList
<
KylinOrderCoupons
>)
obj
;
}
}
public
SweetAppletUsersVo
getSweetAppletUsersOfUnionId
(
String
unionId
)
{
String
redisKey
=
SweetConstant
.
REDIS_KEY_SWEET_APPLET_USERS_UNIONID
.
concat
(
unionId
);
Object
obj
=
redisDataSourceUtil
.
getRedisSweetUtil
().
get
(
redisKey
);
if
(
null
==
obj
)
{
return
null
;
}
else
{
SweetAppletUsersVo
sweetAppletUsersVo
=
(
SweetAppletUsersVo
)
obj
;
return
sweetAppletUsersVo
;
}
}
}
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