|
@ -5,11 +5,15 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.care.dao.assistance.EmergencyAssistanceDao;
|
|
|
import com.yihu.jw.care.dao.sign.ServicePackageSignRecordDao;
|
|
|
import com.yihu.jw.care.dao.team.BaseTeamMemberDao;
|
|
|
import com.yihu.jw.care.service.consult.ConsultTeamService;
|
|
|
import com.yihu.jw.care.util.CountDistance;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.im.ConsultTeamDo;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.care.assistance.EmergencyAssistanceDO;
|
|
|
import com.yihu.jw.im.dao.ConsultTeamDao;
|
|
|
import com.yihu.jw.im.util.ImUtil;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
@ -20,7 +24,6 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.print.DocFlavor;
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
@ -43,6 +46,12 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
private CountDistance countDistance;
|
|
|
@Autowired
|
|
|
private BaseDoctorDao doctorDao;
|
|
|
@Autowired
|
|
|
private ConsultTeamService consultTeamService;
|
|
|
@Autowired
|
|
|
private ImUtil imUtill;
|
|
|
@Autowired
|
|
|
private ConsultTeamDao consultTeamDao;
|
|
|
|
|
|
/**
|
|
|
* 新建居民紧急救助
|
|
@ -50,7 +59,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
* @param jsonData
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject newOrder(String patient,String jsonData){
|
|
|
public JSONObject newOrder(String patient,String jsonData) throws Exception{
|
|
|
JSONObject result = new JSONObject();
|
|
|
EmergencyAssistanceDO assistanceDO = JSON.parseObject(jsonData,EmergencyAssistanceDO.class);
|
|
|
BasePatientDO patientDO = patientDao.findById(patient);
|
|
@ -93,22 +102,30 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
//获取距离患者最近的一个医生
|
|
|
double distance = 0.0;
|
|
|
for (BaseDoctorDO doctorDO:doctorDOS){
|
|
|
if (StringUtils.isBlank(doctorDO.getDoctorLat())||StringUtils.isBlank(doctorDO.getDoctorLon())){
|
|
|
continue;
|
|
|
}
|
|
|
double distanceTmp = countDistance.getDistance(Double.parseDouble(assistanceDO.getServeLat()),Double.parseDouble(assistanceDO.getServeLon()),Double.parseDouble(doctorDO.getDoctorLat()),Double.parseDouble(doctorDO.getDoctorLon()));
|
|
|
if (distanceTmp>distance){
|
|
|
distance = distanceTmp;
|
|
|
assistanceDO.setDoctor(doctorDO.getId());
|
|
|
assistanceDO.setDoctorName(doctorDO.getName());
|
|
|
assistanceDO.setDoctorAddress("");
|
|
|
assistanceDO.setDoctorLon(118.0388772928781+"");
|
|
|
assistanceDO.setDoctorLat(24.472242502394266+"");
|
|
|
assistanceDO.setDoctorLon(doctorDO.getDoctorLon());
|
|
|
assistanceDO.setDoctorLat(doctorDO.getDoctorLat());
|
|
|
}
|
|
|
}
|
|
|
//创建im会话
|
|
|
|
|
|
// assistanceDO.setSessionId();
|
|
|
assistanceDO = emergencyAssistanceDao.save(assistanceDO);
|
|
|
//创建im会话 紧急救助咨询的sessionid 为居民code+(wlyy_consult_team表consult)+20
|
|
|
JSONObject IMObj = consultTeamService.addServiceConsult(assistanceDO.getId(),patient,null);
|
|
|
String sessionId=patient+"_"+ IMObj.getJSONObject("resultMsg").getString("consult") + "_20";
|
|
|
assistanceDO.setSessionId(sessionId);
|
|
|
//向会话中发送一条 陈XX发起紧急救助
|
|
|
if (StringUtils.isNotBlank(assistanceDO.getSendMessage())){
|
|
|
//新建工单message不为空时 ,发送对应的消息
|
|
|
ConsultTeamDo consultTeam = consultTeamDao.queryByRelationCode(assistanceDO.getId());
|
|
|
if (consultTeam!=null){
|
|
|
if (StringUtils.isNotBlank(assistanceDO.getSendMessage())){
|
|
|
imUtill.sendTopicIM(patient,patientDO.getName(),consultTeam.getId(),"1",assistanceDO.getSendMessage(),null);
|
|
|
}
|
|
|
}
|
|
|
emergencyAssistanceDao.save(assistanceDO);
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
@ -317,4 +334,22 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject sendQuickMessage(String orderId,String patient,String content){
|
|
|
JSONObject result = new JSONObject();
|
|
|
ConsultTeamDo consultTeam = consultTeamDao.queryByRelationCode(orderId);
|
|
|
BasePatientDO patientDO = patientDao.findById(patient);
|
|
|
if (patientDO==null){
|
|
|
String failMsg = "患者不存在";
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
|
}
|
|
|
if (consultTeam!=null){
|
|
|
imUtill.sendTopicIM(patient,patientDO.getName(),consultTeam.getId(),"1",content,null);
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
result.put(ResponseContant.resultMsg,"发送成功");
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|