|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.yihu.jw.care.dao.assistance.EmergencyAssistanceDao;
|
|
|
import com.yihu.jw.care.dao.sign.ServicePackageItemDao;
|
|
|
import com.yihu.jw.care.dao.sign.ServicePackageSignRecordDao;
|
|
|
import com.yihu.jw.care.dao.team.BaseTeamMemberDao;
|
|
|
import com.yihu.jw.care.service.consult.ConsultTeamService;
|
|
@ -19,9 +20,13 @@ 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;
|
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.http.NameValuePair;
|
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
@ -54,6 +59,12 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
private ImUtil imUtill;
|
|
|
@Autowired
|
|
|
private ConsultTeamDao consultTeamDao;
|
|
|
@Autowired
|
|
|
private HttpClientUtil httpClientUtil;
|
|
|
@Value("${baiduApi.AK}")
|
|
|
private String baiduAk;
|
|
|
@Value("${baiduApi.url}")
|
|
|
private String baiduUrl;
|
|
|
|
|
|
/**
|
|
|
* 新建居民紧急救助
|
|
@ -61,7 +72,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
* @param jsonData
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject newOrder(String patient,String jsonData) throws Exception{
|
|
|
public JSONObject newOrder(String patient,String jsonData,String proxyPatient) throws Exception{
|
|
|
JSONObject result = new JSONObject();
|
|
|
EmergencyAssistanceDO assistanceDO = JSON.parseObject(jsonData,EmergencyAssistanceDO.class);
|
|
|
BasePatientDO patientDO = patientDao.findById(patient);
|
|
@ -76,6 +87,18 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
assistanceDO.setPatientIdcard(patientDO.getIdcard());
|
|
|
assistanceDO.setPatientName(patientDO.getName());
|
|
|
assistanceDO.setPatientPhone(patientDO.getMobile());
|
|
|
if(patient.equals(proxyPatient)) {//本人发起
|
|
|
assistanceDO.setProxyPatient(patient);
|
|
|
assistanceDO.setProxyPatientName(patientDO.getName());
|
|
|
assistanceDO.setProxyPatientPhone(patientDO.getMobile());
|
|
|
assistanceDO.setType(1);
|
|
|
}else {//家人
|
|
|
BasePatientDO proxyPatientDO = patientDao.findById(proxyPatient);
|
|
|
assistanceDO.setProxyPatient(proxyPatient);
|
|
|
assistanceDO.setProxyPatientName(proxyPatientDO.getName());
|
|
|
assistanceDO.setProxyPatientPhone(proxyPatientDO.getMobile());
|
|
|
assistanceDO.setType(2);
|
|
|
}
|
|
|
|
|
|
if (emergencyAssistanceDao.findByPatientAndStatus(patient,1)!=null){
|
|
|
String failMsg = "当前居民存在申请中的救助,请完成后再申请";
|
|
@ -84,7 +107,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
return result;
|
|
|
}
|
|
|
//签约防走失服务包
|
|
|
String sql ="SELECT i.code,team_code,org_code from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i \n" +
|
|
|
String sql ="SELECT i.code,i.team_code,i.org_code,i.org_name from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i \n" +
|
|
|
"where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and i.del = 1 and sr.`status`=1 \n" +
|
|
|
"and sr.patient = '"+assistanceDO.getPatient()+"' and i.code='emergencyAssistance' ";
|
|
|
List<Map<String,Object>> items = jdbcTemplate.queryForList(sql);
|
|
@ -96,6 +119,12 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
}
|
|
|
Map<String,Object> mapTmp = items.get(0);
|
|
|
List<BaseDoctorDO> doctorDOS = baseTeamMemberDao.findAllMembers(mapTmp.get("team_code").toString());
|
|
|
if (StringUtils.isNotBlank((mapTmp.get("org_code").toString()))){
|
|
|
assistanceDO.setOrgCode(mapTmp.get("org_code").toString());
|
|
|
}
|
|
|
if (StringUtils.isNotBlank((mapTmp.get("org_name").toString()))){
|
|
|
assistanceDO.setOrgName((mapTmp.get("org_name").toString()));
|
|
|
}
|
|
|
assistanceDO.setTeamCode(mapTmp.get("team_code").toString());
|
|
|
if (doctorDOS.size()==0){
|
|
|
String failMsg = "紧急救助服务项服务医生为空,不可发起救助";
|
|
@ -103,25 +132,25 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
//获取距离患者最近的一个医生
|
|
|
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(doctorDO.getDoctorLocateAddress());
|
|
|
assistanceDO.setDoctorLon(doctorDO.getDoctorLon());
|
|
|
assistanceDO.setDoctorLat(doctorDO.getDoctorLat());
|
|
|
}
|
|
|
}
|
|
|
//获取距离患者最近的一个医生(默认直线距离最近的医生)
|
|
|
// 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(doctorDO.getDoctorLocateAddress());
|
|
|
// assistanceDO.setDoctorLon(doctorDO.getDoctorLon());
|
|
|
// assistanceDO.setDoctorLat(doctorDO.getDoctorLat());
|
|
|
// }
|
|
|
// }
|
|
|
assistanceDO = emergencyAssistanceDao.save(assistanceDO);
|
|
|
//创建im会话 紧急救助咨询的sessionid 为居民code+(wlyy_consult_team表consult)+20
|
|
|
JSONObject IMObj = consultTeamService.addServiceConsult(assistanceDO.getId(),patient,null);
|
|
|
JSONObject IMObj = consultTeamService.addServiceConsult(assistanceDO.getId(),patient,proxyPatient,null);
|
|
|
String sessionId=patient+"_"+ IMObj.getJSONObject("resultMsg").getString("consult") + "_20";
|
|
|
assistanceDO.setSessionId(sessionId);
|
|
|
//向会话中发送一条 陈XX发起紧急救助
|
|
@ -131,6 +160,20 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
imUtill.sendTopicIM(patient,patientDO.getName(),consultTeam.getConsult(),"1",assistanceDO.getSendMessage(),null);
|
|
|
}
|
|
|
}
|
|
|
//推送socket给医生
|
|
|
for (BaseDoctorDO doctorDO:doctorDOS){
|
|
|
JSONObject message = new JSONObject();
|
|
|
message.put("session_id",assistanceDO.getSessionId());
|
|
|
message.put("sender_name",assistanceDO.getPatientName());
|
|
|
message.put("sender_code",assistanceDO.getPatient());
|
|
|
message.put("order_id",assistanceDO.getId());
|
|
|
message.put("content_type",40);
|
|
|
try {
|
|
|
imUtill.sendMDTSocketMessageToDoctor(doctorDO.getId(),message.toString());
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
emergencyAssistanceDao.save(assistanceDO);
|
|
|
return getOrderDetail(assistanceDO.getId());
|
|
|
}
|
|
@ -148,23 +191,49 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
double distance = 0.0;
|
|
|
JSONArray otherDoctorDistance = new JSONArray();
|
|
|
JSONObject otherDoctorDistanceObj = new JSONObject();
|
|
|
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 (doctorDO.getId().equals(assistanceDO.getDoctor())){//服务医生
|
|
|
assistanceDO.setDistance(distance);
|
|
|
}
|
|
|
else {
|
|
|
if (assistanceDO.getStatus()==1){
|
|
|
StringBuilder origins = new StringBuilder("");
|
|
|
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()));
|
|
|
otherDoctorDistanceObj = new JSONObject();
|
|
|
otherDoctorDistanceObj.put("doctor",doctorDO.getId());
|
|
|
otherDoctorDistanceObj.put("doctorName",doctorDO.getName());
|
|
|
otherDoctorDistanceObj.put("doctorAddress",doctorDO.getDoctorLocateAddress());
|
|
|
otherDoctorDistanceObj.put("doctorLon",doctorDO.getDoctorLon());
|
|
|
otherDoctorDistanceObj.put("doctorLat",doctorDO.getDoctorLat());
|
|
|
otherDoctorDistanceObj.put("distance",distanceTmp);
|
|
|
otherDoctorDistanceObj.put("distance",distanceTmp);//两点距离
|
|
|
otherDoctorDistance.add(otherDoctorDistanceObj);
|
|
|
origins.append(doctorDO.getDoctorLat()+","+doctorDO.getDoctorLon()+"|");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(origins.toString())){
|
|
|
origins.deleteCharAt(origins.length()-1);
|
|
|
}
|
|
|
String destinations = assistanceDO.getServeLat()+","+assistanceDO.getServeLon();
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
params.add(new BasicNameValuePair("origins", origins.toString()));
|
|
|
params.add(new BasicNameValuePair("destinations", destinations));
|
|
|
params.add(new BasicNameValuePair("output", "json"));
|
|
|
params.add(new BasicNameValuePair("ak", baiduAk));
|
|
|
|
|
|
//前端做距离计算
|
|
|
// String url = baiduUrl+"routematrix/v2/driving";
|
|
|
// String response = httpClientUtil.get(url,params,"UTF-8");
|
|
|
// JSONObject responseObj = JSONObject.parseObject(response);
|
|
|
// if (responseObj.getInteger("status")==0){
|
|
|
// JSONArray resultArr = responseObj.getJSONArray("result");
|
|
|
// int length = resultArr.size()>otherDoctorDistance.size()?resultArr.size():otherDoctorDistance.size();
|
|
|
// for (int i=0;i<length;i++){
|
|
|
// JSONObject disTmp = resultArr.getJSONObject(i);
|
|
|
// JSONObject docTmp = otherDoctorDistance.getJSONObject(i);
|
|
|
// docTmp.put("time",disTmp.getJSONObject("duration").getString("text"));
|
|
|
// docTmp.put("distance",disTmp.getJSONObject("distance").getInteger("value")/1000.0);//实际路线距离
|
|
|
// docTmp.put("distanceMeter",disTmp.getJSONObject("distance").getInteger("value"));
|
|
|
// }
|
|
|
// otherDoctorDistance.sort(Comparator.comparing(obj -> ((JSONObject) obj).getInteger("distance")));
|
|
|
// }
|
|
|
}
|
|
|
assistanceDO.setOtherDoctorDistance(otherDoctorDistance.toJSONString());
|
|
|
BasePatientDO patientDO = patientDao.findById(assistanceDO.getPatient());
|
|
@ -227,12 +296,12 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
if (assistanceDO.getStatus()!=0){
|
|
|
String failMsg = "当前工单未完成 无法查看";
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
// if (assistanceDO.getStatus()!=0){
|
|
|
// String failMsg = "当前工单未完成 无法查看";
|
|
|
// result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
// result.put(ResponseContant.resultMsg,failMsg);
|
|
|
// return result;
|
|
|
// }
|
|
|
return getOrderDetail(orderID);
|
|
|
}
|
|
|
|
|
@ -249,7 +318,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
tmpObj.put("status_1",0);//申请中
|
|
|
StringBuilder sql = new StringBuilder(" select ord.status,count(ord.id) count from base_emergency_assistance_order ord where 1=1") ;
|
|
|
if (StringUtils.isNotBlank(patient)){
|
|
|
sql.append( " and ord.patient='"+patient+"' group by ord.status ");
|
|
|
sql.append( " and (ord.patient='"+patient+"' or ord.proxy_patient='"+patient+"' ) group by ord.status ");
|
|
|
}
|
|
|
else if (StringUtils.isNotBlank(doctor)) {
|
|
|
sql.append(" AND EXISTS (" +
|
|
@ -276,21 +345,17 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
public JSONObject existApplyStatus(String patient){
|
|
|
JSONObject result = new JSONObject();
|
|
|
JSONObject tmpObj = new JSONObject();
|
|
|
EmergencyAssistanceDO assistanceDO = emergencyAssistanceDao.findByPatientAndStatus(patient,1);
|
|
|
EmergencyAssistanceDO assistanceDO = emergencyAssistanceDao.findByProxyPatientAndStatus(patient,1);
|
|
|
if (assistanceDO==null){
|
|
|
tmpObj.put("exist","false");
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
result.put(ResponseContant.resultMsg,tmpObj);
|
|
|
return result;
|
|
|
}
|
|
|
else {
|
|
|
BasePatientDO patientDO = patientDao.findById(assistanceDO.getPatient());
|
|
|
assistanceDO.setPatientPhoto(patientDO.getPhoto());
|
|
|
assistanceDO.setPatientSex(patientDO.getSex());
|
|
|
assistanceDO.setPatientAge(IdCardUtil.getAgeForIdcard(patientDO.getIdcard()));
|
|
|
double distance=countDistance.getDistance(Double.parseDouble(assistanceDO.getServeLat()),Double.parseDouble(assistanceDO.getServeLon()),Double.parseDouble(assistanceDO.getDoctorLat()),Double.parseDouble(assistanceDO.getDoctorLon()));
|
|
|
assistanceDO.setDistance(distance);
|
|
|
JSONObject detail = getOrderDetail(assistanceDO.getId());
|
|
|
tmpObj.put("exist","true");
|
|
|
tmpObj.put("assistanceDO",JSONObject.parseObject(JSON.toJSONStringWithDateFormat(assistanceDO,"yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue)));
|
|
|
tmpObj.put("assistanceDO",detail.getJSONObject("resultMsg"));
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
result.put(ResponseContant.resultMsg,tmpObj);
|
|
|
}
|
|
@ -304,6 +369,31 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
* @return
|
|
|
*/
|
|
|
public List<EmergencyAssistanceDO> getOrderList(String patient,String doctor,String status,Integer page,Integer pageSize,String sort){
|
|
|
StringBuilder sql = new StringBuilder(" select ord.* from base_emergency_assistance_order ord where 1=1 ");
|
|
|
if (StringUtils.isNotBlank(doctor)){
|
|
|
sql.append(" AND EXISTS (" +
|
|
|
"SELECT sr.patient from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
|
|
|
"base_team_member m " +
|
|
|
"where ord.patient = CONVERT(sr.patient USING utf8) and sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and m.team_code = i.team_code " +
|
|
|
" and i.del = 1 and sr.`status`=1 and i.code='emergencyAssistance' and m.doctor_code = '"+doctor+"' and m.del = '1') ");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(patient)){
|
|
|
sql.append(" and ( ord.patient = '"+patient+"' or ord.proxy_patient='"+patient+"' )");
|
|
|
}
|
|
|
sql.append(" and ord.status in ( '").append(status.replace(",","','")).append("') ");
|
|
|
sql.append(" order by ord.create_time "+sort+" limit "+page*pageSize+","+pageSize);
|
|
|
|
|
|
List<EmergencyAssistanceDO> resultList = jdbcTemplate.query(sql.toString(),new BeanPropertyRowMapper(EmergencyAssistanceDO.class));
|
|
|
for (EmergencyAssistanceDO obj:resultList){
|
|
|
BasePatientDO patientDO = patientDao.findById(obj.getPatient());
|
|
|
obj.setPatientPhoto(patientDO.getPhoto());
|
|
|
obj.setPatientSex(patientDO.getSex());
|
|
|
obj.setPatientAge(IdCardUtil.getAgeForIdcard(patientDO.getIdcard()));
|
|
|
}
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
public List<EmergencyAssistanceDO> doctorGetOrderList(String patient,String doctor,String status,Integer page,Integer pageSize,String sort){
|
|
|
StringBuilder sql = new StringBuilder(" select ord.* from base_emergency_assistance_order ord where 1=1 ");
|
|
|
if (StringUtils.isNotBlank(doctor)){
|
|
|
sql.append(" AND EXISTS (" +
|
|
@ -330,6 +420,13 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
|
|
|
public JSONObject cancelOrder(String patient,String orderId){
|
|
|
JSONObject result = new JSONObject();
|
|
|
BasePatientDO patientDO = patientDao.findById(patient);
|
|
|
if (patientDO==null){
|
|
|
String failMsg = "当前居民信息获取失败";
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
EmergencyAssistanceDO assistanceDO = emergencyAssistanceDao.findOne(orderId);
|
|
|
if (assistanceDO==null){
|
|
|
String failMsg = "当前救助工单不存在";
|
|
@ -337,7 +434,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
if (!assistanceDO.getPatient().equals(patient)){
|
|
|
if (!(assistanceDO.getPatient().equals(patient)||assistanceDO.getProxyPatient().equals(patient))){
|
|
|
String failMsg = "当前救助工单不是您的工单,无法取消";
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
@ -351,9 +448,15 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
}
|
|
|
assistanceDO.setStatus(-1);
|
|
|
assistanceDO.setUpdateUser(patient);
|
|
|
assistanceDO.setUpdateUserName(assistanceDO.getPatientName());
|
|
|
assistanceDO.setUpdateUserName(patientDO.getName());
|
|
|
assistanceDO.setUpdateTime(new Date());
|
|
|
//im是否结束会话?
|
|
|
//结束救助咨询
|
|
|
if (!consultTeamService.finishEmergencyConsult(assistanceDO,patient,1)){
|
|
|
String failMsg = "咨询结束失败 无法完成工单";
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
emergencyAssistanceDao.save(assistanceDO);
|
|
|
String failMsg = "当前救助工单已取消";
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
@ -382,12 +485,23 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
if (StringUtils.isNotBlank(conclusionImg)){
|
|
|
assistanceDO.setConclusionImg(conclusionImg);
|
|
|
}
|
|
|
//完成医生
|
|
|
BaseDoctorDO doctorDO = doctorDao.findById(doctor);
|
|
|
assistanceDO.setDoctor(doctor);
|
|
|
assistanceDO.setDoctorName(doctorDO.getName());
|
|
|
assistanceDO.setCompleteTime(new Date());
|
|
|
assistanceDO.setStatus(0);
|
|
|
assistanceDO.setUpdateUser(doctor);
|
|
|
assistanceDO.setUpdateUserName(assistanceDO.getDoctorName());
|
|
|
assistanceDO.setUpdateTime(new Date());
|
|
|
//im会话是否结束?
|
|
|
//结束会话
|
|
|
if (!consultTeamService.finishEmergencyConsult(assistanceDO,doctor,2)){
|
|
|
String failMsg = "咨询结束失败 无法完成工单";
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
emergencyAssistanceDao.save(assistanceDO);
|
|
|
return getOrderDetail(orderId);
|
|
|
}
|
|
|
|
|
@ -424,6 +538,30 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject updatePatientLocation(String patient,String patientAddress,String patientLat,String patientLon){
|
|
|
JSONObject result = new JSONObject();
|
|
|
BasePatientDO patientDO = patientDao.findById(patient);
|
|
|
if (patientDO==null){
|
|
|
String failMsg = "患者不存在";
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
EmergencyAssistanceDO assistanceDO = emergencyAssistanceDao.findByPatientAndStatus(patient,1);
|
|
|
if (assistanceDO!=null){
|
|
|
assistanceDO.setServeAddress(patientAddress);
|
|
|
assistanceDO.setServeLat(patientLat);
|
|
|
assistanceDO.setServeLon(patientLon);
|
|
|
emergencyAssistanceDao.save(assistanceDO);
|
|
|
return getOrderDetail(assistanceDO.getId());
|
|
|
}
|
|
|
else {
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
result.put(ResponseContant.resultMsg,null);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject sendQuickMessage(String orderId,String patient,String content){
|
|
|
JSONObject result = new JSONObject();
|
|
|
ConsultTeamDo consultTeam = consultTeamDao.queryByRelationCode(orderId);
|
|
@ -448,4 +586,28 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public String test(String doctor,String orderID){
|
|
|
// JSONObject message = new JSONObject();
|
|
|
// message.put("session_id","808080eb78b5d8e90178b5fcfa330001_4028030c78f1df510178f217a6c50001_20");
|
|
|
// message.put("sender_name","一一");
|
|
|
// message.put("sender_code","808080eb78b5d8e90178b5fcfa330001");
|
|
|
// message.put("order_id","4028030c78f1df510178f217a6a70000");
|
|
|
// message.put("content_type",40);
|
|
|
// imUtill.sendMDTSocketMessageToDoctor(doctor,message.toString());
|
|
|
|
|
|
//结束救助咨询
|
|
|
// String sql = "select id from base_emergency_assistance_order where status!=1";
|
|
|
// List<String> ids = jdbcTemplate.queryForList(sql,String.class);
|
|
|
// for (String id:ids){
|
|
|
// EmergencyAssistanceDO assistanceDO = emergencyAssistanceDao.findOne(orderID);
|
|
|
// if (!consultTeamService.finishEmergencyConsult(assistanceDO,doctor,2)){
|
|
|
// String failMsg = "咨询结束失败 无法完成工单";
|
|
|
//
|
|
|
// return failMsg;
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
}
|