| 
					
				 | 
			
			
				@@ -34,10 +34,12 @@ import com.fs.fastgptApi.service.Impl.AudioServiceImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.fastgptApi.util.AiImgUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.fastgptApi.util.EventLogUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.fastgptApi.vo.AudioVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.his.domain.FsFirstDiagnosis; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.his.domain.FsStoreOrder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.his.dto.ExpressInfoDTO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.his.dto.TracesDTO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.his.enums.ShipperCodeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.his.mapper.FsFirstDiagnosisMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.his.mapper.FsStoreMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.his.mapper.FsStoreOrderMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.his.service.IFsExpressService; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -56,7 +58,9 @@ import com.fs.qwHookApi.param.QwHookSendMsgParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.qwHookApi.vo.QwHookMsgVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.qwHookApi.vo.QwHookVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.sop.domain.QwSopLogs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.sop.domain.QwSopTempVoice; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.sop.mapper.QwSopLogsMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.sop.service.impl.QwSopTempVoiceServiceImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.utils.SensitiveDataUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.voice.utils.StringUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.wxwork.dto.*; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -166,6 +170,12 @@ public class AiHookServiceImpl implements AiHookService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private ICrmMsgService crmMsgService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private FsFirstDiagnosisMapper fsFirstDiagnosisMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private QwSopTempVoiceServiceImpl qwSopTempVoiceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private static final String AI_REPLY = "AI_REPLY:"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private static final String AI_REPLY_TAG = "AI_REPLY_TAG:"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -588,7 +598,7 @@ public class AiHookServiceImpl implements AiHookService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             sendAiMsg(msg,sender,uid,serverId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            Thread.sleep(10000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            Thread.sleep(2000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } catch (InterruptedException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -601,6 +611,9 @@ public class AiHookServiceImpl implements AiHookService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //创建初诊单 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            aiCreateFirstForm(sender, uid,contentKh, user, fastGptChatSession,qwExternalContacts); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             aiEventProcess(sender, uid, role, contentKh, user, fastGptChatSession, serverId,qwExternalContacts); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -613,6 +626,87 @@ public class AiHookServiceImpl implements AiHookService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return R.ok(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 创建初诊单 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void aiCreateFirstForm(Long sender, String uid,String contentKh, QwUser qwUser,FastGptChatSession fastGptChatSession,QwExternalContact qwExternalContacts) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            fsFirstDiagnosisMapper.insertFsFirstDiagnosis(fsFirstDiagnosis); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //发送欢迎宣语 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 根据发送者id设置用户是否为首次回复 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param sender 发送者id 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1403,7 +1497,7 @@ public class AiHookServiceImpl implements AiHookService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private R  sendAiMsg(Integer i,FastGptChatSession fastGptChatSession, FastGptRole role,QwUser user,Long qwExternalContactsId,String appKey,QwExternalContact qwExternalContacts,Long sender){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //等待5秒 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Thread.sleep(10000); // 5000 毫秒 = 5 秒 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Thread.sleep(2000); // 5000 毫秒 = 5 秒 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } catch (InterruptedException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 |