|
|
@@ -633,76 +633,113 @@ public class AiHookServiceImpl implements AiHookService {
|
|
|
if(contentKh.contains("【收集完成】") || contentKh.contains("【报名成功】")){
|
|
|
if(fastGptChatSession.getQwUserId() != null && qwExternalContacts.getFsUserId() != null){
|
|
|
FsFirstDiagnosis firstDiagnosis = fsFirstDiagnosisMapper.selectFsFirstDiagnosisByQwUserIdAndUserId(fastGptChatSession.getQwUserId(),qwExternalContacts.getFsUserId());
|
|
|
- if(firstDiagnosis == null){
|
|
|
- Long id = qwExternalContacts.getId();
|
|
|
- QwExternalContactInfo info = qwExternalContactInfoMapper.selectQwExternalContactInfoByExternalContactId(id);
|
|
|
- if(info != null){
|
|
|
- Field[] fields = info.getClass().getDeclaredFields();
|
|
|
- FsFirstDiagnosis fsFirstDiagnosis = new FsFirstDiagnosis();
|
|
|
- for (Field field : fields) {
|
|
|
- field.setAccessible(true);
|
|
|
- Excel annotation = field.getAnnotation(Excel.class);
|
|
|
- if (annotation != null) {
|
|
|
- String name = field.getName();
|
|
|
- String fieldName = annotation.name();
|
|
|
- String[] split = new String[]{"姓名","性别","年龄","身体状态","手机号","是否线下就诊"};
|
|
|
- for (String zName : split) {
|
|
|
- if (zName.equals(fieldName)) {
|
|
|
- Object value = null;
|
|
|
- try {
|
|
|
- value = field.get(info);
|
|
|
- } catch (IllegalAccessException e) {
|
|
|
- }
|
|
|
- switch (zName){
|
|
|
- case "姓名":
|
|
|
- fsFirstDiagnosis.setPatientName(value.toString());
|
|
|
- break;
|
|
|
- case "性别":
|
|
|
- fsFirstDiagnosis.setGender(Long.valueOf(value.toString()));
|
|
|
- break;
|
|
|
- case "年龄":
|
|
|
- fsFirstDiagnosis.setAge(value.toString());
|
|
|
- break;
|
|
|
- case "身体状态":
|
|
|
- fsFirstDiagnosis.setPhysicalCondition(value.toString());
|
|
|
- break;
|
|
|
- case "手机号":
|
|
|
- fsFirstDiagnosis.setPhone(value.toString());
|
|
|
- break;
|
|
|
- }
|
|
|
+ try {
|
|
|
+ if(firstDiagnosis == null){
|
|
|
+ Long id = qwExternalContacts.getId();
|
|
|
+ QwExternalContactInfo info = qwExternalContactInfoMapper.selectQwExternalContactInfoByExternalContactId(id);
|
|
|
+ if(info != null){
|
|
|
+ Field[] fields = info.getClass().getDeclaredFields();
|
|
|
+ FsFirstDiagnosis fsFirstDiagnosis = new FsFirstDiagnosis();
|
|
|
+ for (Field field : fields) {
|
|
|
+ field.setAccessible(true);
|
|
|
+ Excel annotation = field.getAnnotation(Excel.class);
|
|
|
+ if (annotation != null) {
|
|
|
+ String fieldName = annotation.name();
|
|
|
+ switch (fieldName){
|
|
|
+ case "姓名":
|
|
|
+ try {
|
|
|
+ fsFirstDiagnosis.setPatientName((String) field.get(info));
|
|
|
+ } catch (IllegalAccessException ignored) {}
|
|
|
+ break;
|
|
|
+ case "性别":
|
|
|
+ try {
|
|
|
+ Object value = field.get(info);
|
|
|
+ if (value != null) {
|
|
|
+ fsFirstDiagnosis.setGender(Long.valueOf(value.toString()));
|
|
|
+ }
|
|
|
+ } catch (IllegalAccessException | NumberFormatException ignored) {}
|
|
|
+ break;
|
|
|
+ case "年龄":
|
|
|
+ try {
|
|
|
+ fsFirstDiagnosis.setAge((String) field.get(info));
|
|
|
+ } catch (IllegalAccessException ignored) {}
|
|
|
+ break;
|
|
|
+ case "身体状态":
|
|
|
+ try {
|
|
|
+ fsFirstDiagnosis.setPhysicalCondition((String) field.get(info));
|
|
|
+ } catch (IllegalAccessException ignored) {}
|
|
|
+ break;
|
|
|
+ case "手机号":
|
|
|
+ try {
|
|
|
+ fsFirstDiagnosis.setPhone((String) field.get(info));
|
|
|
+ } catch (IllegalAccessException ignored) {}
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
fsFirstDiagnosisMapper.insertFsFirstDiagnosis(fsFirstDiagnosis);
|
|
|
}
|
|
|
}
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("创建初诊单异常",e);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- //发送欢迎宣语
|
|
|
- Long companyUserId = qwUser.getCompanyUserId();
|
|
|
- QwSopTempVoice qwSopTempVoice = qwSopTempVoiceService.selectQwSopTempVoiceByCompanyUserIdAndVoiceTxt(companyUserId, "欢迎宣导");
|
|
|
- if(qwSopTempVoice != null && qwSopTempVoice.getVoiceUrl() != null ){
|
|
|
- String voiceUrl = qwSopTempVoice.getVoiceUrl();
|
|
|
- WxwUploadCdnLinkFileDTO wxwUploadCdnLinkFileDTO = new WxwUploadCdnLinkFileDTO();
|
|
|
- wxwUploadCdnLinkFileDTO.setUrl(voiceUrl);
|
|
|
- wxwUploadCdnLinkFileDTO.setFilename(voiceUrl);
|
|
|
- wxwUploadCdnLinkFileDTO.setUuid(uid);
|
|
|
- WxWorkResponseDTO<WxwUploadCdnLinkFileRespDTO> dto = wxWorkService.uploadCdnLinkFile(wxwUploadCdnLinkFileDTO, qwUser.getServerId());
|
|
|
- WxwUploadCdnLinkFileRespDTO voice = dto.getData();
|
|
|
- WxwSendCDNVoiceMsgDTO wxwSendCDNVoiceMsgDTO = new WxwSendCDNVoiceMsgDTO();
|
|
|
- wxwSendCDNVoiceMsgDTO.setSend_userid(sender);
|
|
|
- System.out.println("语音size"+voice.getSize());
|
|
|
- wxwSendCDNVoiceMsgDTO.setVoice_time(qwSopTempVoice.getDuration());
|
|
|
- wxwSendCDNVoiceMsgDTO.setIsRoom(false);
|
|
|
- wxwSendCDNVoiceMsgDTO.setCdnkey(voice.getCdn_key());
|
|
|
- wxwSendCDNVoiceMsgDTO.setAeskey(voice.getAes_key());
|
|
|
- wxwSendCDNVoiceMsgDTO.setMd5(voice.getMd5());
|
|
|
- wxwSendCDNVoiceMsgDTO.setFileSize(voice.getSize());
|
|
|
- wxwSendCDNVoiceMsgDTO.setUuid(uid);
|
|
|
- WxWorkResponseDTO<WxwSendCDNVoiceMsgRespDTO> wxwSendCDNVoiceMsgRespDTOWxWorkResponseDTO = wxWorkService.SendCDNVoiceMsg(wxwSendCDNVoiceMsgDTO, qwUser.getServerId());
|
|
|
- log.info("发送语音成功"+qwUser);
|
|
|
- System.out.println(wxwSendCDNVoiceMsgRespDTOWxWorkResponseDTO);
|
|
|
- }
|
|
|
+ //发送欢迎宣语
|
|
|
+ Long companyUserId = qwUser.getCompanyUserId();
|
|
|
+ QwSopTempVoice qwSopTempVoice = qwSopTempVoiceService.selectQwSopTempVoiceByCompanyUserIdAndVoiceTxt(companyUserId, "欢迎宣导");
|
|
|
+ if(qwSopTempVoice != null && qwSopTempVoice.getVoiceUrl() != null ){
|
|
|
+ String voiceUrl = qwSopTempVoice.getVoiceUrl();
|
|
|
+ WxwUploadCdnLinkFileDTO wxwUploadCdnLinkFileDTO = new WxwUploadCdnLinkFileDTO();
|
|
|
+ wxwUploadCdnLinkFileDTO.setUrl(voiceUrl);
|
|
|
+ wxwUploadCdnLinkFileDTO.setFilename(voiceUrl);
|
|
|
+ wxwUploadCdnLinkFileDTO.setUuid(uid);
|
|
|
+ WxWorkResponseDTO<WxwUploadCdnLinkFileRespDTO> dto = wxWorkService.uploadCdnLinkFile(wxwUploadCdnLinkFileDTO, qwUser.getServerId());
|
|
|
+ WxwUploadCdnLinkFileRespDTO voice = dto.getData();
|
|
|
+ WxwSendCDNVoiceMsgDTO wxwSendCDNVoiceMsgDTO = new WxwSendCDNVoiceMsgDTO();
|
|
|
+ wxwSendCDNVoiceMsgDTO.setSend_userid(sender);
|
|
|
+ System.out.println("语音size"+voice.getSize());
|
|
|
+ wxwSendCDNVoiceMsgDTO.setVoice_time(qwSopTempVoice.getDuration());
|
|
|
+ wxwSendCDNVoiceMsgDTO.setIsRoom(false);
|
|
|
+ wxwSendCDNVoiceMsgDTO.setCdnkey(voice.getCdn_key());
|
|
|
+ wxwSendCDNVoiceMsgDTO.setAeskey(voice.getAes_key());
|
|
|
+ wxwSendCDNVoiceMsgDTO.setMd5(voice.getMd5());
|
|
|
+ wxwSendCDNVoiceMsgDTO.setFileSize(voice.getSize());
|
|
|
+ wxwSendCDNVoiceMsgDTO.setUuid(uid);
|
|
|
+ WxWorkResponseDTO<WxwSendCDNVoiceMsgRespDTO> wxwSendCDNVoiceMsgRespDTOWxWorkResponseDTO = wxWorkService.SendCDNVoiceMsg(wxwSendCDNVoiceMsgDTO, qwUser.getServerId());
|
|
|
+ log.info("发送语音成功"+qwUser);
|
|
|
+ System.out.println(wxwSendCDNVoiceMsgRespDTOWxWorkResponseDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ WxWorkResponseDTO<WxCdnUploadVideoResp> videoDto = new WxWorkResponseDTO<>();
|
|
|
+ String videoUrl = "https://ysy-1329817240.cos.ap-guangzhou.myqcloud.com/app/344a6ed8e22f4928d9cbc4fe0bc1cb29.mp4";
|
|
|
+ //1.1上传cdn网络视频
|
|
|
+ WxCdnUploadVideoLinkDTO wxwUploadCdnVideoLinkDTO = new WxCdnUploadVideoLinkDTO();
|
|
|
+ wxwUploadCdnVideoLinkDTO.setUuid(uid);
|
|
|
+ wxwUploadCdnVideoLinkDTO.setUrl(videoUrl);
|
|
|
+ // 找到最后一个斜杠的位置
|
|
|
+ int lastSlashIndex = videoUrl.lastIndexOf('/');
|
|
|
+
|
|
|
+ // 截取文件名(处理没有斜杠的特殊情况)
|
|
|
+ String fileName = lastSlashIndex != -1 ? videoUrl.substring(lastSlashIndex + 1) : videoUrl;
|
|
|
+ wxwUploadCdnVideoLinkDTO.setFilename(fileName);
|
|
|
+ videoDto = wxWorkService.uploadCdnVideoLink(wxwUploadCdnVideoLinkDTO, qwUser.getServerId());
|
|
|
+
|
|
|
+
|
|
|
+ //2.1发送模板中的视频内容
|
|
|
+ if("成功".equals(videoDto.getErrmsg())){
|
|
|
+ WxCdnUploadVideoResp videoDtoData = videoDto.getData();
|
|
|
+ WxwSendCDNVideoMsgDTO sendCDNVideoMsgRespDTO = new WxwSendCDNVideoMsgDTO();
|
|
|
+ sendCDNVideoMsgRespDTO.setSend_userid(sender);
|
|
|
+ sendCDNVideoMsgRespDTO.setUuid(uid);
|
|
|
+ sendCDNVideoMsgRespDTO.setIsRoom(false);
|
|
|
+ sendCDNVideoMsgRespDTO.setCdnkey(videoDtoData.getCdn_key());
|
|
|
+ sendCDNVideoMsgRespDTO.setAeskey(videoDtoData.getAes_key());
|
|
|
+ sendCDNVideoMsgRespDTO.setMd5(videoDtoData.getMd5());
|
|
|
+ sendCDNVideoMsgRespDTO.setFileSize(videoDtoData.getSize());
|
|
|
+ sendCDNVideoMsgRespDTO.setVideo_img_size(videoDtoData.getVideo_img_size());
|
|
|
+ sendCDNVideoMsgRespDTO.setVideo_duration(videoDtoData.getVideoDuration());
|
|
|
+ wxWorkService.SendCDNVideoMsg(sendCDNVideoMsgRespDTO, qwUser.getServerId());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -2030,8 +2067,9 @@ public class AiHookServiceImpl implements AiHookService {
|
|
|
sendAIParam.setKey(user.getAppKey());
|
|
|
redisTemplate.opsForList().leftPush("AiMsg:"+user.getAppKey(), JSON.toJSONString(sendAIParam));
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
- public R qwHookNotifyAddMsg(Long qwUserID, Long sender,String count,String uid) {
|
|
|
+ public R qwHookNotifyAddMsgNew(Long qwUserID, Long sender,String count,String uid,Integer type) {
|
|
|
QwUser sendUser = qwUserMapper.selectQwUserById(qwUserID);
|
|
|
|
|
|
|
|
|
@@ -2045,6 +2083,25 @@ public class AiHookServiceImpl implements AiHookService {
|
|
|
FastGptChatSession fastGptChatSession = fastGptChatSessionMapper.selectFastGptChatSessionByQwExternalContactsAndUserId(qwExternalContacts.getId(), sendUser.getId());
|
|
|
if (fastGptChatSession!=null){
|
|
|
saveQwUserMsg(fastGptChatSession,2,count);
|
|
|
+ // 客服进行回复后就转人工10分钟
|
|
|
+ if(type == 1){
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.add(Calendar.MINUTE, -5);
|
|
|
+ Date lastTime = calendar.getTime();
|
|
|
+ if(lastTime.after(fastGptChatSession.getCreateTime())){
|
|
|
+ Calendar calendar1 = Calendar.getInstance();
|
|
|
+ //定时任务会处理10分钟以内的,所以设置20分钟
|
|
|
+ calendar1.add(Calendar.MINUTE, 10);
|
|
|
+ Date expireTime = calendar1.getTime();
|
|
|
+
|
|
|
+ FastGptChatSession chatSession = new FastGptChatSession();
|
|
|
+ chatSession.setLastTime(expireTime);
|
|
|
+ chatSession.setIsArtificial(1);
|
|
|
+ chatSession.setSessionId(fastGptChatSession.getSessionId());
|
|
|
+
|
|
|
+ fastGptChatSessionMapper.updateFastGptChatSession(chatSession);
|
|
|
+ }
|
|
|
+ }
|
|
|
}else {
|
|
|
|
|
|
if(qwExternalContacts.getType()!=null&&qwExternalContacts.getType()==1){
|
|
|
@@ -2071,19 +2128,49 @@ public class AiHookServiceImpl implements AiHookService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // 客服进行回复后就转人工10分钟
|
|
|
- if(fastGptChatSession != null){
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- //定时任务会处理10分钟以内的,所以设置20分钟
|
|
|
- calendar.add(Calendar.MINUTE, 30);
|
|
|
- Date expireTime = calendar.getTime();
|
|
|
-
|
|
|
- FastGptChatSession chatSession = new FastGptChatSession();
|
|
|
- chatSession.setLastTime(expireTime);
|
|
|
- chatSession.setIsArtificial(1);
|
|
|
- chatSession.setSessionId(fastGptChatSession.getSessionId());
|
|
|
-
|
|
|
- fastGptChatSessionMapper.updateFastGptChatSession(chatSession);
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public R qwHookNotifyAddMsg(Long qwUserID, Long sender,String count,String uid) {
|
|
|
+ QwUser sendUser = qwUserMapper.selectQwUserById(qwUserID);
|
|
|
+
|
|
|
+
|
|
|
+ if (sendUser!=null){
|
|
|
+
|
|
|
+ String extId = getExtId(sender, uid, sendUser.getServerId());
|
|
|
+ QwExternalContact qwExternalContacts = qwExternalContactMapper.selectQwExternalContactByExternalUserIdAndQwUserId(extId, sendUser.getCorpId(),sendUser.getQwUserId());
|
|
|
+ if (qwExternalContacts==null){
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ FastGptChatSession fastGptChatSession = fastGptChatSessionMapper.selectFastGptChatSessionByQwExternalContactsAndUserId(qwExternalContacts.getId(), sendUser.getId());
|
|
|
+ if (fastGptChatSession!=null){
|
|
|
+ saveQwUserMsg(fastGptChatSession,2,count);
|
|
|
+ }else {
|
|
|
+
|
|
|
+ if(qwExternalContacts.getType()!=null&&qwExternalContacts.getType()==1){
|
|
|
+ if(sendUser.getFastGptRoleId()!=null){
|
|
|
+ fastGptChatSession = new FastGptChatSession();
|
|
|
+ String chatId = UUID.randomUUID().toString();
|
|
|
+ fastGptChatSession.setChatId(chatId);
|
|
|
+ fastGptChatSession.setKfId(sendUser.getFastGptRoleId().toString());
|
|
|
+ fastGptChatSession.setStatus(1);
|
|
|
+ fastGptChatSession.setRemindCount(0);
|
|
|
+ fastGptChatSession.setRemindStatus(0);
|
|
|
+ fastGptChatSession.setCreateTime(new Date());
|
|
|
+ fastGptChatSession.setQwExtId(qwExternalContacts.getId());
|
|
|
+ fastGptChatSession.setQwUserId(sendUser.getId());
|
|
|
+ fastGptChatSession.setIsArtificial(0);
|
|
|
+ fastGptChatSession.setAvatar(qwExternalContacts.getAvatar());
|
|
|
+ fastGptChatSession.setNickName(qwExternalContacts.getName());
|
|
|
+ fastGptChatSession.setCompanyId(sendUser.getCompanyId());
|
|
|
+ fastGptChatSession.setLastTime(new Date());
|
|
|
+ fastGptChatSession.setIsReply(0);
|
|
|
+ fastGptChatSessionMapper.insertFastGptChatSession(fastGptChatSession);
|
|
|
+ addUserSex(qwExternalContacts);
|
|
|
+ saveQwUserMsg(fastGptChatSession,2,count);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return R.ok();
|