Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
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
haoban3.0
haoban-manage3.0
Commits
66cb916f
Commit
66cb916f
authored
Oct 21, 2024
by
王祖波
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bugfix-20241021' into 'master'
Bugfix 20241021 See merge request
!2232
parents
8e508e7f
ec742df9
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
20 deletions
+72
-20
MaterialServiceImpl.java
...oban/manage/service/service/impl/MaterialServiceImpl.java
+21
-17
NoticeMessageHandler.java
.../manage/service/service/message/NoticeMessageHandler.java
+14
-0
NoticeMessageApiServiceImpl.java
...rvice/service/notify/out/NoticeMessageApiServiceImpl.java
+6
-3
ApolloUtils.java
.../java/com/gic/haoban/manage/service/util/ApolloUtils.java
+31
-0
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/MaterialServiceImpl.java
View file @
66cb916f
...
...
@@ -9,6 +9,7 @@ import java.util.stream.Collectors;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.commons.util.HttpClient
;
import
com.gic.haoban.manage.service.util.ApolloUtils
;
import
com.gic.redis.data.util.RedisUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.time.DateUtils
;
...
...
@@ -243,10 +244,12 @@ public class MaterialServiceImpl implements MaterialService {
Integer
width
=
jsonObject
.
getInteger
(
"width"
);
Integer
height
=
jsonObject
.
getInteger
(
"height"
);
Integer
size
=
jsonObject
.
getInteger
(
"size"
);
String
extensions
=
url
.
substring
(
url
.
lastIndexOf
(
"."
)
+
1
);
//朋友圈类型图片,长边不超过10800像素,短边不超过1080像素
//图片宽高超过限制 或 大小大于2m 处理图片
if
(
size
/
1000
>
2000
||
width
>
1080
||
height
>
10800
)
{
url
+=
"?imageView2/2/w/1080/h/10800"
;
if
(
size
/
1000
>
2000
||
width
>
1080
||
height
>
10800
||
(
Objects
.
equals
(
extensions
,
"png"
)
&&
size
/
1000
>
1000
&&
ApolloUtils
.
compressShareEid
(
wxEnterpriseId
)))
{
url
+=
"?imageView2/2/w/1080/h/10800/format/jpg"
;
}
logger
.
info
(
"url={}"
,
url
);
}
...
...
@@ -272,21 +275,22 @@ public class MaterialServiceImpl implements MaterialService {
public
static
void
main
(
String
[]
args
)
{
String
url
=
"https://platform-1251519181.cos.ap-shanghai.myqcloud.com/image/jhdm/common-fbcae3533d414bf8baac917df600b20e.png"
;
Map
<
String
,
Object
>
map
=
HttpClient
.
getHttpByGet
(
url
+
"?imageInfo"
);
String
response
=
(
String
)
map
.
get
(
"response"
);
if
(
StringUtils
.
isBlank
(
response
))
{
throw
new
RuntimeException
();
}
JSONObject
jsonObject
=
null
;
jsonObject
=
JSONObject
.
parseObject
(
response
);
Integer
width
=
jsonObject
.
getInteger
(
"width"
);
Integer
height
=
jsonObject
.
getInteger
(
"height"
);
Integer
size
=
jsonObject
.
getInteger
(
"size"
);
//图片宽高超过限制 或 大小大于2m 处理图片
if
(
size
/
1000
>
2000
||
width
>
1440
||
height
>
1080
)
{
url
+=
"?imageView2/2/w/1440/h/1080"
;
}
logger
.
info
(
"url={}"
,
url
);
// Map<String, Object> map = HttpClient.getHttpByGet(url + "?imageInfo");
// String response = (String) map.get("response");
// if (StringUtils.isBlank(response)) {
// throw new RuntimeException();
// }
// JSONObject jsonObject = null;
// jsonObject = JSONObject.parseObject(response);
// Integer width = jsonObject.getInteger("width");
// Integer height = jsonObject.getInteger("height");
// Integer size = jsonObject.getInteger("size");
// //图片宽高超过限制 或 大小大于2m 处理图片
// if (size / 1000 > 2000 || width > 1440 || height > 1080) {
// url+= "?imageView2/2/w/1440/h/1080" ;
// }
String
substring
=
url
.
substring
(
url
.
lastIndexOf
(
"."
)
+
1
);
logger
.
info
(
"url={}"
,
substring
);
}
public
List
<
String
>
getImageMediaId
(
String
wxEnterpriseId
,
List
<
ContentMaterialDTO
>
imageList
,
int
mediaType
)
{
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/message/NoticeMessageHandler.java
View file @
66cb916f
...
...
@@ -44,6 +44,20 @@ public class NoticeMessageHandler {
}
}
public
void
sendMessage
(
NoticeMessageForm
noticeMessageForm
,
int
delay
){
logger
.
info
(
"消息中心发送消息实体:{}"
,
JSONObject
.
toJSONString
(
noticeMessageForm
));
if
(
ObjectUtil
.
isEmpty
(
noticeMessageForm
.
getMessageCode
())
||
ObjectUtil
.
isEmpty
(
noticeMessageForm
.
getMqRouterCode
()))
{
logger
.
info
(
"消息中心发送消息实体 messageCode 或 mqRouterCode 不存在"
);
}
GicMQClient
client
=
GICMQClientUtil
.
getClientInstance
();
try
{
client
.
sendMessage
(
noticeMessageForm
.
getMqRouterCode
(),
JSONObject
.
toJSONString
(
noticeMessageForm
),
delay
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"消息中心发送消息实体发送异常 "
,
e
);
}
}
private
int
sendDelayValue
(
boolean
delay
)
{
if
(!
delay
)
{
return
0
;
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/notify/out/NoticeMessageApiServiceImpl.java
View file @
66cb916f
...
...
@@ -331,8 +331,11 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
return
ServiceResponse
.
failure
(
"-1"
,
"模版枚举不存在"
);
}
List
<
String
>
userIdList
=
relationList
.
stream
().
map
(
StaffClerkRelationDTO:
:
getClerkId
).
distinct
().
collect
(
Collectors
.
toList
());
Integer
batchInterval
=
ApolloUtils
.
notifyBatchInterval
();
List
<
List
<
String
>>
listList
=
ListUtil
.
split
(
userIdList
,
1000
);
for
(
List
<
String
>
list
:
listList
)
{
// 优化通知导购 集中下发的问题
for
(
int
i
=
0
;
i
<
listList
.
size
();
i
++)
{
int
delay
=
batchInterval
*
i
;
noticeMessageHandler
.
sendMessage
(
NoticeMessageForm
.
builder
()
.
messageCode
(
noticeMessageTypeEnum
.
getMessageCode
())
.
mqRouterCode
(
noticeMessageTypeEnum
.
getRouterCode
())
...
...
@@ -340,8 +343,8 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
.
createTime
(
new
Date
())
.
enterpriseId
(
notifyMessageBatchQDTO
.
getEnterpriseId
())
.
uniqueKey
(
UniqueIdUtils
.
uniqueLongHex
())
.
userIdList
(
list
)
.
variableMap
(
variableMap
).
build
());
.
userIdList
(
list
List
.
get
(
i
)
)
.
variableMap
(
variableMap
).
build
()
,
delay
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"发送消息通知失败"
,
e
);
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/util/ApolloUtils.java
View file @
66cb916f
...
...
@@ -2,9 +2,14 @@ package com.gic.haoban.manage.service.util;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
ApolloUtils
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ApolloUtils
.
class
);
/**
* 旧的调用发送,是否采用新的消息中心开关1:是 0:否
* @return
...
...
@@ -14,4 +19,30 @@ public class ApolloUtils {
String
messageCenterSwitch
=
config
.
getProperty
(
"messageCenterSwitch"
,
"0"
);
return
"1"
.
equals
(
messageCenterSwitch
);
}
/**
* 分享朋友圈压缩开关
* @return
*/
public
static
boolean
compressShareEid
(
String
wxEnterpriseId
)
{
Config
config
=
ConfigService
.
getAppConfig
();
String
compressShareEid
=
config
.
getProperty
(
"compressShareEid"
,
""
);
if
(
StringUtils
.
isBlank
(
compressShareEid
))
{
return
true
;
}
boolean
contains
=
compressShareEid
.
contains
(
wxEnterpriseId
);
log
.
info
(
"分享朋友圈压缩开关:{}"
,
contains
);
return
contains
;
}
/**
* 导购通知一批次间隔时间
* @return
*/
public
static
Integer
notifyBatchInterval
()
{
Config
config
=
ConfigService
.
getAppConfig
();
String
notifyBatchInterval
=
config
.
getProperty
(
"notifyBatchInterval"
,
"60"
);
log
.
info
(
"导购通知一批次间隔时间:{}"
,
notifyBatchInterval
);
return
Integer
.
parseInt
(
notifyBatchInterval
);
}
}
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