|
|
@@ -7,13 +7,16 @@ import com.fs.common.utils.PubFun;
|
|
|
import com.fs.course.domain.FsCourseSopAppLink;
|
|
|
import com.fs.course.mapper.FsCourseSopAppLinkMapper;
|
|
|
import com.fs.gtPush.service.uniPush2Service;
|
|
|
+import com.fs.his.domain.FsUser;
|
|
|
import com.fs.his.mapper.FsUserMapper;
|
|
|
import com.fs.im.dto.OpenImMsgDTO;
|
|
|
+import com.fs.im.dto.OpenImResponseDTO;
|
|
|
import com.fs.im.service.OpenIMService;
|
|
|
import com.fs.qw.domain.QwSopUpdateStatus;
|
|
|
import com.fs.qw.domain.QwUser;
|
|
|
import com.fs.qw.mapper.QwExternalContactMapper;
|
|
|
import com.fs.qw.result.QwFilterSopCustomersResult;
|
|
|
+import com.fs.qw.vo.QwSopCourseFinishTempSetting;
|
|
|
import com.fs.qw.vo.QwSopRuleTimeVO;
|
|
|
import com.fs.qw.vo.QwSopTempSetting;
|
|
|
import com.fs.sop.domain.QwSop;
|
|
|
@@ -531,6 +534,50 @@ public class AsyncSopTestService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public boolean asyncSendMsgBySopAppLinkNormalIM(
|
|
|
+ List<QwSopCourseFinishTempSetting.Setting> setting,
|
|
|
+ String cropId,
|
|
|
+ Long companyUserId,
|
|
|
+ Long fsUserId,
|
|
|
+ String logId) {
|
|
|
+
|
|
|
+ boolean success = true;
|
|
|
+
|
|
|
+ for (QwSopCourseFinishTempSetting.Setting item : setting) {
|
|
|
+ try {
|
|
|
+ item.setSendStatus(2);
|
|
|
+ item.setSendRemarks("APP发送失败");
|
|
|
+ OpenImResponseDTO resp =
|
|
|
+ push2Service.pushSopAppLinkMsgByExternalIMV2(
|
|
|
+ cropId,
|
|
|
+ item.getLinkTitle(),
|
|
|
+ item.getLinkDescribe(),
|
|
|
+ item.getLinkImageUrl(),
|
|
|
+ item.getAppLinkUrl(),
|
|
|
+ companyUserId,
|
|
|
+ fsUserId
|
|
|
+ );
|
|
|
+ if (resp != null && resp.getErrCode() != null && resp.getErrCode() == 0) {
|
|
|
+ item.setSendStatus(1);
|
|
|
+ item.setSendRemarks("发送成功");
|
|
|
+ } else {
|
|
|
+ success = false;
|
|
|
+ if (resp != null) {
|
|
|
+ item.setSendRemarks(resp.getErrMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ success = false;
|
|
|
+ item.setSendRemarks("异常:" + e.getMessage());
|
|
|
+ log.error("APP课程发送异常 logId={}", logId, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("APP课程发送完成,logId={}", logId);
|
|
|
+ return success;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 异步录入 发送有app的客户 之 正常sop版
|
|
|
*/
|
|
|
@@ -567,6 +614,51 @@ public class AsyncSopTestService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public boolean asyncSendMsgBySopAppTxtNormalIM(List<QwSopCourseFinishTempSetting.Setting> setting,Long companyUserId,Long fsUserId, String logId){
|
|
|
+ boolean success = true;
|
|
|
+ for (QwSopCourseFinishTempSetting.Setting item : setting) {
|
|
|
+ try {
|
|
|
+ item.setSendStatus(2);
|
|
|
+ item.setSendRemarks("APP发送失败");
|
|
|
+
|
|
|
+ FsUser fsUser = fsUserMapper.selectFsUserByUserId(fsUserId);
|
|
|
+
|
|
|
+ // ===== 用户校验 =====
|
|
|
+ if (fsUser == null || com.fs.common.utils.StringUtils.isEmpty(fsUser.getHistoryApp())) {
|
|
|
+ item.setSendRemarks("未找到对应的用户信息");
|
|
|
+ success = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ OpenImMsgDTO openImMsgDTO = new OpenImMsgDTO();
|
|
|
+ openImMsgDTO.setSendID("C" + companyUserId);
|
|
|
+ openImMsgDTO.setRecvID("U" + fsUserId);
|
|
|
+ openImMsgDTO.setContentType(101);
|
|
|
+ openImMsgDTO.setSessionType(1);
|
|
|
+ OpenImMsgDTO.Content imContent = new OpenImMsgDTO.Content();
|
|
|
+ imContent.setContent(item.getValue());
|
|
|
+ openImMsgDTO.setContent(imContent);
|
|
|
+ OpenImResponseDTO resp = openIMService.openIMSendMsg(openImMsgDTO);
|
|
|
+
|
|
|
+ if (resp != null && resp.getErrCode() != null && resp.getErrCode() == 0) {
|
|
|
+ item.setSendStatus(1);
|
|
|
+ item.setSendRemarks("发送成功");
|
|
|
+ } else {
|
|
|
+ success = false;
|
|
|
+ if (resp != null) {
|
|
|
+ item.setSendRemarks(resp.getErrMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ success = false;
|
|
|
+ item.setSendRemarks("异常:" + e.getMessage());
|
|
|
+ log.error("APP文本发送异常,logId={}", logId, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("APP文本发送完成,logId={}", logId);
|
|
|
+ return success;
|
|
|
+ }
|
|
|
+
|
|
|
@Async("scheduledExecutorService")
|
|
|
public void asyncSendMsgBySopAppMP3NormalIM(List<QwSopTempSetting.Content.Setting> setting,String cropId,Long companyUserId,Long fsUserId){
|
|
|
|
|
|
@@ -602,4 +694,55 @@ public class AsyncSopTestService {
|
|
|
});
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ public boolean asyncSendMsgBySopAppMP3NormalIM(List<QwSopCourseFinishTempSetting.Setting> setting,Long companyUserId,Long fsUserId, String logId){
|
|
|
+ boolean success = true;
|
|
|
+ for (QwSopCourseFinishTempSetting.Setting item : setting) {
|
|
|
+ try {
|
|
|
+ item.setSendStatus(2);
|
|
|
+ item.setSendRemarks("APP发送失败");
|
|
|
+
|
|
|
+ FsUser fsUser = fsUserMapper.selectFsUserByUserId(fsUserId);
|
|
|
+ // ===== 用户校验 =====
|
|
|
+ if (fsUser == null || com.fs.common.utils.StringUtils.isEmpty(fsUser.getHistoryApp())) {
|
|
|
+ success = false;
|
|
|
+ item.setSendRemarks("未找到对应的用户信息");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ boolean isText = StrUtil.isEmpty(item.getVoiceUrl());
|
|
|
+ log.info("执行发送app{}消息:{}", isText ? "文本" : "语音", item);
|
|
|
+
|
|
|
+ OpenImMsgDTO msg = new OpenImMsgDTO();
|
|
|
+ msg.setSendID("C" + companyUserId);
|
|
|
+ msg.setRecvID("U" + fsUserId);
|
|
|
+ msg.setSessionType(1);
|
|
|
+ msg.setContentType(isText ? 101 : 103);
|
|
|
+
|
|
|
+ OpenImMsgDTO.Content content = new OpenImMsgDTO.Content();
|
|
|
+ if (isText) {
|
|
|
+ content.setContent(item.getValue());
|
|
|
+ } else {
|
|
|
+ content.setSourceUrl(item.getVoiceUrl());
|
|
|
+ content.setDuration(Integer.parseInt(item.getVoiceDuration()));
|
|
|
+ }
|
|
|
+ msg.setContent(content);
|
|
|
+
|
|
|
+ OpenImResponseDTO resp = openIMService.openIMSendMsg(msg);
|
|
|
+
|
|
|
+ if (resp != null && resp.getErrCode() == 0) {
|
|
|
+ item.setSendStatus(1);
|
|
|
+ item.setSendRemarks("发送成功");
|
|
|
+ } else {
|
|
|
+ success = false;
|
|
|
+ item.setSendRemarks(resp != null ? resp.getErrMsg() : "未知错误");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ success = false;
|
|
|
+ item.setSendRemarks("异常:" + e.getMessage());
|
|
|
+ log.error("APP语音/文本发送异常,logId={}", logId, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("APP语音发送完成,logId={}", logId);
|
|
|
+ return success;
|
|
|
+ }
|
|
|
}
|