|
@ -1,6 +1,8 @@
|
|
|
package com.yihu.jw.service.im;
|
|
|
|
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
|
import com.yihu.jw.entity.knowledge.BaseSystemDialogSetting;
|
|
|
import com.yihu.jw.im.service.RobotService;
|
|
|
import com.yihu.jw.im.util.ImUtil;
|
|
|
import com.yihu.jw.knowledge.dao.BaseSystemDialogSettingDao;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
@ -12,7 +14,6 @@ import org.springframework.stereotype.Service;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* Created by yeshijie on 2023/4/26.
|
|
@ -28,31 +29,70 @@ public class ImJobService {
|
|
|
private ImUtil imUtil;
|
|
|
@Value("${im.data_base_name}")
|
|
|
private String imDbName;
|
|
|
@Autowired
|
|
|
private RobotService robotService;
|
|
|
|
|
|
public void ss(){
|
|
|
List<BaseSystemDialogSetting> settingList = dialogSettingDao.findAll();
|
|
|
Map<String,List<BaseSystemDialogSetting>> systemTypeMap = settingList.stream().
|
|
|
collect(Collectors.groupingBy(BaseSystemDialogSetting::getSystemType));
|
|
|
|
|
|
List<BaseSystemDialogSetting> systemTypeList1 = systemTypeMap.get("1");
|
|
|
List<BaseSystemDialogSetting> systemTypeList2 = systemTypeMap.get("2");
|
|
|
List<BaseSystemDialogSetting> systemTypeList3 = systemTypeMap.get("3");
|
|
|
List<BaseSystemDialogSetting> systemTypeList4 = systemTypeMap.get("4");
|
|
|
}
|
|
|
|
|
|
//在线导诊无响应
|
|
|
public void onlineGuidanceNoResponse(){
|
|
|
/**
|
|
|
*
|
|
|
* @param type 18在线导诊 26专属服务导诊
|
|
|
*/
|
|
|
public void onlineGuidance(String type){
|
|
|
//查找配置
|
|
|
WlyyHospitalSysDictDO dictDO = robotService.getSender();
|
|
|
BaseSystemDialogSetting customerSetting = dialogSettingDao.findBySystemTypeAndFunctionType("1","3",1);
|
|
|
BaseSystemDialogSetting userSetting = dialogSettingDao.findBySystemTypeAndFunctionType("1","3",1);
|
|
|
if(customerSetting==null&&userSetting==null){
|
|
|
return;
|
|
|
if(customerSetting!=null){
|
|
|
String content = customerSetting.getContent();
|
|
|
String time = timeTransfor(customerSetting.getTime(),customerSetting.getTimeUnit());
|
|
|
//查找未结束的在线导诊
|
|
|
String sql = "SELECT s.id from "+imDbName+".sessions s,"+imDbName+".patients p WHERE " +
|
|
|
"s.type='"+type+"' and s.`status`='0' and s.last_message_time<='"+time+"' and s.last_sender_id=p.id ";
|
|
|
List<Map<String,Object>> sessionList = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map:sessionList){
|
|
|
String sessionId = map.get("id")+"";
|
|
|
try {
|
|
|
imUtil.sendImMsg(dictDO.getDictCode(), dictDO.getDictValue(), sessionId, "1", content, "1", null);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
BaseSystemDialogSetting userSetting = dialogSettingDao.findBySystemTypeAndFunctionType("1","4",1);
|
|
|
if(userSetting!=null){
|
|
|
String content = userSetting.getContent();
|
|
|
String time = timeTransfor(customerSetting.getTime(),customerSetting.getTimeUnit());
|
|
|
//查找未结束的在线导诊
|
|
|
String sql = "SELECT s.id from "+imDbName+".sessions s,"+imDbName+".doctors d WHERE " +
|
|
|
"s.type='"+type+"' and s.`status`='0' and s.last_message_time<='"+time+"' and s.last_sender_id=d.id ";
|
|
|
List<Map<String,Object>> sessionList = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map:sessionList){
|
|
|
String sessionId = map.get("id")+"";
|
|
|
try {
|
|
|
imUtil.sendImMsg(dictDO.getDictCode(), dictDO.getDictValue(), sessionId, "1", content, "1", null);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
timeTransfor(customerSetting.getTime(),customerSetting.getTimeUnit());
|
|
|
//查找未结束的在线导诊
|
|
|
String sql = "select * from ";
|
|
|
List<Map<String,Object>> sessionList = jdbcTemplate.queryForList(sql);
|
|
|
|
|
|
BaseSystemDialogSetting endSetting = dialogSettingDao.findBySystemTypeAndFunctionType("1","6",1);
|
|
|
if(userSetting!=null){
|
|
|
String content = endSetting.getContent();
|
|
|
String time = timeTransfor(customerSetting.getTime(),customerSetting.getTimeUnit());
|
|
|
//查找未结束的在线导诊
|
|
|
String sql = "SELECT s.id from im.sessions s WHERE " +
|
|
|
"s.type='"+type+"' and s.`status`='0' and s.last_message_time<='"+time+"' ";
|
|
|
List<Map<String,Object>> sessionList = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map:sessionList){
|
|
|
String sessionId = map.get("id")+"";
|
|
|
try {
|
|
|
imUtil.sendImMsg(dictDO.getDictCode(), dictDO.getDictValue(), sessionId, "1", content, "1", null);
|
|
|
imUtil.updateSessionStatus(sessionId,"1");
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|