|
|
@@ -2,6 +2,7 @@ package com.fs.app.task;
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.fs.app.service.IpadSendServer;
|
|
|
import com.fs.common.core.redis.RedisCacheT;
|
|
|
@@ -90,19 +91,21 @@ public class SendMsg {
|
|
|
if (qwUserList.isEmpty()) {
|
|
|
List<QwIpadServer> serverList = qwIpadServerMapper.selectList(new QueryWrapper<QwIpadServer>().eq("group_no", groupNo));
|
|
|
if (serverList.isEmpty()) {
|
|
|
+ log.info("没找到可用的服务器 {} ",serverList);
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
List<Long> serverIds = PubFun.listToNewList(serverList, QwIpadServer::getId);
|
|
|
List<QwUser> qwUsers = qwUserMapper.selectList(new QueryWrapper<QwUser>().eq("send_msg_type", 1).eq("server_status", 1).eq("ipad_status", 1).in("server_id", serverIds));
|
|
|
qwUserList.addAll(qwUsers);
|
|
|
}
|
|
|
+ log.info("getQwUserList {}",JSON.toJSONString(qwUserList));
|
|
|
return qwUserList;
|
|
|
}
|
|
|
|
|
|
private Map<String, FsCoursePlaySourceConfig> getMiniMap() {
|
|
|
List<FsCoursePlaySourceConfig> list = fsCoursePlaySourceConfigService.list(new QueryWrapper<FsCoursePlaySourceConfig>().ne("type", 2).eq("is_del", 0));
|
|
|
- log.info("获取到的小程序配置:{}", JSON.toJSONString(list));
|
|
|
- log.info("获取到的小程序配置:{}", JSON.toJSONString(list));
|
|
|
+// log.info("获取到的小程序配置:{}", JSON.toJSONString(list));
|
|
|
+// log.info("获取到的小程序配置:{}", JSON.toJSONString(list));
|
|
|
return PubFun.listToMapByGroupObject(list, FsCoursePlaySourceConfig::getAppid);
|
|
|
}
|
|
|
|
|
|
@@ -169,6 +172,7 @@ public class SendMsg {
|
|
|
// 获取当前企微待发送记录
|
|
|
List<QwSopLogs> qwSopLogList = qwSopLogsMapper.selectByQwUserId(qwUser.getId());
|
|
|
if (qwSopLogList.isEmpty()) {
|
|
|
+ log.info("获取当前企微待发送记录为空");
|
|
|
return;
|
|
|
}
|
|
|
// 获取企微用户
|
|
|
@@ -178,6 +182,7 @@ public class SendMsg {
|
|
|
long end1 = System.currentTimeMillis();
|
|
|
// 判断这个企微是否需要发送
|
|
|
if (!sendServer.isSend(user, parentVo)) {
|
|
|
+ log.info("当前这个企微不需要发送 数据{}",user);
|
|
|
return;
|
|
|
}
|
|
|
log.info("销售:{}, 消息:{}, 耗时: {}, 时间:{}", user.getQwUserName(), qwSopLogList.size(), end1 - start1, qwMap.get(qwUser.getId()));
|
|
|
@@ -186,10 +191,20 @@ public class SendMsg {
|
|
|
for (QwSopLogs qwSopLogs : qwSopLogList) {
|
|
|
long start2 = System.currentTimeMillis();
|
|
|
QwSopCourseFinishTempSetting setting = JSON.parseObject(qwSopLogs.getContentJson(), QwSopCourseFinishTempSetting.class);
|
|
|
- // 判断消息状态是否满足发送条件
|
|
|
- if (!sendServer.isSendLogs(qwSopLogs, setting, user)) {
|
|
|
- log.info("销售:{}, 消息发送条件未满足:{}", user.getQwUserName(), qwSopLogs.getId());
|
|
|
- continue;
|
|
|
+ //直播的sendType:20单独走判断 其他的走以前的逻辑
|
|
|
+ boolean isSendLive = Integer.valueOf(20).equals(qwSopLogs.getSendType());
|
|
|
+ if(isSendLive){
|
|
|
+ if (!sendServer.isSendLogsLive(qwSopLogs, setting, user)) {
|
|
|
+ log.info("销售:{}, 直播消息发送条件未满足:{}", user.getQwUserName(), qwSopLogs.getId());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ // 判断消息状态是否满足发送条件
|
|
|
+ if (!sendServer.isSendLogs(qwSopLogs, setting, user)) {
|
|
|
+ log.info("销售:{}, 消息发送条件未满足:{}", user.getQwUserName(), qwSopLogs.getId());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
log.info("进入发送消息状态:{}", qwSopLogs.getId());
|
|
|
String key = "qw:logs:pad:send:id:" + qwSopLogs.getId();
|
|
|
@@ -246,7 +261,7 @@ public class SendMsg {
|
|
|
}
|
|
|
long end4 = System.currentTimeMillis();
|
|
|
log.info("请求pad发送完成:{}, {}, 时长4:{}", user.getQwUserName(), qwSopLogs.getId(), end4 - start4);
|
|
|
- if (content.getSendStatus() == 2 && ("请求失败:消息发送过于频繁,请稍后再试".equals(content.getSendRemarks()) || "请求失败:请求频率异常".equals(content.getSendRemarks()))) {
|
|
|
+ if(content.getSendStatus() == 2 && ("请求失败:消息发送过于频繁,请稍后再试".equals(content.getSendRemarks()) || "请求失败:请求频率异常".equals(content.getSendRemarks()))){
|
|
|
QwUser update = new QwUser();
|
|
|
update.setRemark("请求频率异常,暂停发送,三小时后恢复继续发送");
|
|
|
update.setUpdateTime(new Date());
|
|
|
@@ -264,16 +279,32 @@ public class SendMsg {
|
|
|
}
|
|
|
}
|
|
|
// 推送 APP
|
|
|
-// if (!setting.getSetting().isEmpty()) {
|
|
|
-// new Thread(() -> {
|
|
|
-// try {
|
|
|
-// List<QwSopTempSetting.Content.Setting> settings = JSON.parseArray(JSON.toJSONString(setting.getSetting()), QwSopTempSetting.Content.Setting.class).stream().filter(e -> "9".equals(e.getContentType())).collect(Collectors.toList());
|
|
|
-// asyncSopTestService.asyncSendMsgBySopAppLinkNormalIM(settings, qwSopLogs.getCorpId(), user.getCompanyUserId(), qwSopLogs.getFsUserId());
|
|
|
-// } catch (Exception e) {
|
|
|
-// log.error("推送APP失败", e);
|
|
|
-// }
|
|
|
-// }).start();
|
|
|
-// }
|
|
|
+ if (!setting.getSetting().isEmpty()) {
|
|
|
+ new Thread(() -> {
|
|
|
+ try {
|
|
|
+ List<QwSopTempSetting.Content.Setting> settings = JSON.parseArray(JSON.toJSONString(setting.getSetting()), QwSopTempSetting.Content.Setting.class).stream().filter(e -> "9".equals(e.getContentType())).collect(Collectors.toList());
|
|
|
+ if (!settings.isEmpty()) {
|
|
|
+ asyncSopTestService.asyncSendMsgBySopAppLinkNormalIM(settings, qwSopLogs.getCorpId(), user.getCompanyUserId(), qwSopLogs.getFsUserId());
|
|
|
+ }
|
|
|
+
|
|
|
+ //app文本消息
|
|
|
+ log.info("开始发送app文本消息消息开始,消息{},用户{}", JSONObject.toJSONString(settings), user.getQwUserName());
|
|
|
+ settings = JSON.parseArray(JSON.toJSONString(setting.getSetting()), QwSopTempSetting.Content.Setting.class).stream().filter(e -> "15".equals(e.getContentType())).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (!settings.isEmpty()) {
|
|
|
+ asyncSopTestService.asyncSendMsgBySopAppTxtNormalIM(settings, qwSopLogs.getCorpId(), qwUser.getCompanyUserId(), qwSopLogs.getFsUserId());
|
|
|
+ }
|
|
|
+ //app语音消息
|
|
|
+ log.info("开始发送app语音消息消息开始,消息{},用户{}", JSONObject.toJSONString(settings), user.getQwUserName());
|
|
|
+ settings = JSON.parseArray(JSON.toJSONString(setting.getSetting()), QwSopTempSetting.Content.Setting.class).stream().filter(e -> "16".equals(e.getContentType())).collect(Collectors.toList());
|
|
|
+ if (!settings.isEmpty()) {
|
|
|
+ asyncSopTestService.asyncSendMsgBySopAppMP3NormalIM(settings, qwSopLogs.getCorpId(), qwUser.getCompanyUserId(), qwSopLogs.getFsUserId());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("推送APP失败", e);
|
|
|
+ }
|
|
|
+ }).start();
|
|
|
+ }
|
|
|
qwSopLogs.setSend(true);
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
QwSopLogs updateQwSop = new QwSopLogs();
|