Commit 66cb916f by 王祖波

Merge branch 'bugfix-20241021' into 'master'

Bugfix 20241021

See merge request !2232
parents 8e508e7f ec742df9
...@@ -9,6 +9,7 @@ import java.util.stream.Collectors; ...@@ -9,6 +9,7 @@ import java.util.stream.Collectors;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.HttpClient; import com.gic.commons.util.HttpClient;
import com.gic.haoban.manage.service.util.ApolloUtils;
import com.gic.redis.data.util.RedisUtil; import com.gic.redis.data.util.RedisUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
...@@ -243,10 +244,12 @@ public class MaterialServiceImpl implements MaterialService { ...@@ -243,10 +244,12 @@ public class MaterialServiceImpl implements MaterialService {
Integer width = jsonObject.getInteger("width"); Integer width = jsonObject.getInteger("width");
Integer height = jsonObject.getInteger("height"); Integer height = jsonObject.getInteger("height");
Integer size = jsonObject.getInteger("size"); Integer size = jsonObject.getInteger("size");
String extensions = url.substring(url.lastIndexOf(".") + 1);
//朋友圈类型图片,长边不超过10800像素,短边不超过1080像素 //朋友圈类型图片,长边不超过10800像素,短边不超过1080像素
//图片宽高超过限制 或 大小大于2m 处理图片 //图片宽高超过限制 或 大小大于2m 处理图片
if (size / 1000 > 2000 || width > 1080 || height > 10800) { if (size / 1000 > 2000 || width > 1080 || height > 10800 ||
url+= "?imageView2/2/w/1080/h/10800" ; (Objects.equals(extensions, "png") && size / 1000 > 1000 && ApolloUtils.compressShareEid(wxEnterpriseId))) {
url += "?imageView2/2/w/1080/h/10800/format/jpg";
} }
logger.info("url={}",url); logger.info("url={}",url);
} }
...@@ -272,21 +275,22 @@ public class MaterialServiceImpl implements MaterialService { ...@@ -272,21 +275,22 @@ public class MaterialServiceImpl implements MaterialService {
public static void main(String[] args) { public static void main(String[] args) {
String url = "https://platform-1251519181.cos.ap-shanghai.myqcloud.com/image/jhdm/common-fbcae3533d414bf8baac917df600b20e.png"; String url = "https://platform-1251519181.cos.ap-shanghai.myqcloud.com/image/jhdm/common-fbcae3533d414bf8baac917df600b20e.png";
Map<String, Object> map = HttpClient.getHttpByGet(url + "?imageInfo"); // Map<String, Object> map = HttpClient.getHttpByGet(url + "?imageInfo");
String response = (String) map.get("response"); // String response = (String) map.get("response");
if (StringUtils.isBlank(response)) { // if (StringUtils.isBlank(response)) {
throw new RuntimeException(); // throw new RuntimeException();
} // }
JSONObject jsonObject = null; // JSONObject jsonObject = null;
jsonObject = JSONObject.parseObject(response); // jsonObject = JSONObject.parseObject(response);
Integer width = jsonObject.getInteger("width"); // Integer width = jsonObject.getInteger("width");
Integer height = jsonObject.getInteger("height"); // Integer height = jsonObject.getInteger("height");
Integer size = jsonObject.getInteger("size"); // Integer size = jsonObject.getInteger("size");
//图片宽高超过限制 或 大小大于2m 处理图片 // //图片宽高超过限制 或 大小大于2m 处理图片
if (size / 1000 > 2000 || width > 1440 || height > 1080) { // if (size / 1000 > 2000 || width > 1440 || height > 1080) {
url+= "?imageView2/2/w/1440/h/1080" ; // url+= "?imageView2/2/w/1440/h/1080" ;
} // }
logger.info("url={}",url); String substring = url.substring(url.lastIndexOf(".") + 1);
logger.info("url={}",substring);
} }
public List<String> getImageMediaId(String wxEnterpriseId, List<ContentMaterialDTO> imageList, int mediaType) { public List<String> getImageMediaId(String wxEnterpriseId, List<ContentMaterialDTO> imageList, int mediaType) {
......
...@@ -44,6 +44,20 @@ public class NoticeMessageHandler { ...@@ -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) { private int sendDelayValue(boolean delay) {
if (!delay) { if (!delay) {
return 0; return 0;
......
...@@ -331,8 +331,11 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -331,8 +331,11 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
return ServiceResponse.failure("-1", "模版枚举不存在"); return ServiceResponse.failure("-1", "模版枚举不存在");
} }
List<String> userIdList = relationList.stream().map(StaffClerkRelationDTO::getClerkId).distinct().collect(Collectors.toList()); List<String> userIdList = relationList.stream().map(StaffClerkRelationDTO::getClerkId).distinct().collect(Collectors.toList());
Integer batchInterval = ApolloUtils.notifyBatchInterval();
List<List<String>> listList = ListUtil.split(userIdList, 1000); 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() noticeMessageHandler.sendMessage(NoticeMessageForm.builder()
.messageCode(noticeMessageTypeEnum.getMessageCode()) .messageCode(noticeMessageTypeEnum.getMessageCode())
.mqRouterCode(noticeMessageTypeEnum.getRouterCode()) .mqRouterCode(noticeMessageTypeEnum.getRouterCode())
...@@ -340,8 +343,8 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -340,8 +343,8 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
.createTime(new Date()) .createTime(new Date())
.enterpriseId(notifyMessageBatchQDTO.getEnterpriseId()) .enterpriseId(notifyMessageBatchQDTO.getEnterpriseId())
.uniqueKey(UniqueIdUtils.uniqueLongHex()) .uniqueKey(UniqueIdUtils.uniqueLongHex())
.userIdList(list) .userIdList(listList.get(i))
.variableMap(variableMap).build()); .variableMap(variableMap).build(),delay);
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("发送消息通知失败", e); logger.error("发送消息通知失败", e);
......
...@@ -2,9 +2,14 @@ package com.gic.haoban.manage.service.util; ...@@ -2,9 +2,14 @@ package com.gic.haoban.manage.service.util;
import com.ctrip.framework.apollo.Config; import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService; import com.ctrip.framework.apollo.ConfigService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ApolloUtils { public class ApolloUtils {
private static final Logger log = LoggerFactory.getLogger(ApolloUtils.class);
/** /**
* 旧的调用发送,是否采用新的消息中心开关1:是 0:否 * 旧的调用发送,是否采用新的消息中心开关1:是 0:否
* @return * @return
...@@ -14,4 +19,30 @@ public class ApolloUtils { ...@@ -14,4 +19,30 @@ public class ApolloUtils {
String messageCenterSwitch = config.getProperty("messageCenterSwitch", "0"); String messageCenterSwitch = config.getProperty("messageCenterSwitch", "0");
return "1".equals(messageCenterSwitch); 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);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment