|
@ -1,5 +1,7 @@
|
|
|
package com.yihu.jw.service.channel;
|
|
|
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.im.ConsultDo;
|
|
|
import com.yihu.jw.entity.base.im.ConsultTeamDo;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
@ -30,6 +32,8 @@ import com.yihu.jw.order.dao.BusinessOrderDao;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.utils.YkyySMSService;
|
|
|
import oracle.sql.DATE;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@ -42,6 +46,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Component
|
|
|
@Transactional
|
|
@ -97,6 +102,10 @@ public class TimeoutOverDueService {
|
|
|
private YkyyEntranceService ykyyEntranceService;
|
|
|
@Autowired
|
|
|
private WlyyHospitalSysDictDao hospitalSysDictDao;
|
|
|
@Autowired
|
|
|
private YkyySMSService ykyySMSService;
|
|
|
@Autowired
|
|
|
private BaseDoctorDao doctorDao;
|
|
|
/**
|
|
|
* 取消未结束门诊
|
|
|
*/
|
|
@ -285,5 +294,75 @@ public class TimeoutOverDueService {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
|
public void sendMessageNoReply(){
|
|
|
List<WlyyHospitalSysDictDO> sysDictDOList = hospitalSysDictDao.findByDictName("noReplyTime");
|
|
|
String sql = "SELECT\n" ;
|
|
|
if ("xm_ykyy_wx".equals(wechatId)) {
|
|
|
sql = sql + "to_char(s.last_message_time,'YYYY-MM-DD hh24:mi:ss') AS \"lastMessageTime\",";
|
|
|
} else {
|
|
|
sql = sql + "date_format(s.last_message_time,'%Y-%m-%d %H:%i:%S' ) AS \"lastMessageTime\",";
|
|
|
}
|
|
|
sql = sql+ "\ts.last_sender_id as \"lastSenderId\",\n" +
|
|
|
"\ts.last_sender_name as \"lastSenderName\",\n" +
|
|
|
"\to.id as \"id\"\n" +
|
|
|
"FROM\n" +
|
|
|
"\twlyy_outpatient o\n" +
|
|
|
"LEFT JOIN wlyy_consult c ON o.id = c.relation_code\n" +
|
|
|
"LEFT JOIN topics t ON t.id = c.id\n" +
|
|
|
"LEFT JOIN sessions s ON s.id = t.session_id\n" +
|
|
|
"where o.status>0 and o.status<3 ";
|
|
|
logger.info("sql语句"+sql);
|
|
|
List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
|
|
|
logger.info("mapList"+mapList);
|
|
|
if(mapList!=null&&mapList.size()>0){
|
|
|
Long currentTime = DateUtil.getNowDate().getTime();
|
|
|
for (Map<String,Object> map:mapList){
|
|
|
String lastMessageTime = map.get("lastMessageTime").toString();
|
|
|
String lastSenderId = map.get("lastSenderId").toString();
|
|
|
Long lastTime = DateUtil.strToDate(lastMessageTime).getTime();
|
|
|
Long time = currentTime-lastTime;
|
|
|
logger.info("time"+time);
|
|
|
for (int i =0;i<sysDictDOList.size();i++){
|
|
|
boolean flag = false;
|
|
|
int j = i+1;
|
|
|
WlyyHospitalSysDictDO wlyyHospitalSysDictDO = sysDictDOList.get(i);
|
|
|
Long noReplyTime = Long.parseLong(wlyyHospitalSysDictDO.getDictValue());
|
|
|
if (j>=sysDictDOList.size()){
|
|
|
flag=false;
|
|
|
}else {
|
|
|
WlyyHospitalSysDictDO wlyyHospitalSysDictDO1 = sysDictDOList.get(j);
|
|
|
Long noReplyTime1 = Long.parseLong(wlyyHospitalSysDictDO1.getDictValue());
|
|
|
logger.info("noReplyTime1"+noReplyTime1+"==="+noReplyTime);
|
|
|
if (time>noReplyTime*60*1000&&time<=noReplyTime1*60*1000){
|
|
|
flag = true;
|
|
|
}
|
|
|
}
|
|
|
if (flag){
|
|
|
BasePatientDO patientDO = basePatientDao.findById(lastSenderId);
|
|
|
BaseDoctorDO doctorDO = doctorDao.findById(lastSenderId);
|
|
|
String mobile = "";
|
|
|
if (patientDO!=null){
|
|
|
mobile = patientDO.getMobile();
|
|
|
}else if (doctorDO!=null){
|
|
|
mobile = doctorDO.getMobile();
|
|
|
}
|
|
|
logger.info("mobile"+mobile+flag+noReplyTime);
|
|
|
if (wechatId.equalsIgnoreCase("xm_ykyy_wx")){
|
|
|
ykyySMSService.ykyySendSMS(mobile,"您有新的咨询消息,请及时回复。");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|