liubing пре 4 година
родитељ
комит
832ea603bc

+ 5 - 5
common/common-entity/src/main/java/com/yihu/jw/entity/care/assistance/EmergencyAssistanceDO.java

@ -18,7 +18,7 @@ public class EmergencyAssistanceDO extends UuidIdentityEntityWithOperator {
    private String patientIdcard; //救助居民身份证
    private String orgCode; //救助居民所在机构code
    private String orgName; //救助居民所在机构名称
    private String patientAddress;
    private String serveAddress;
    private String serveLat; //居民当前定位地址纬度
    private String serveLon; //居民当前定位地址经度
    private String sessionId; //会话id
@ -165,12 +165,12 @@ public class EmergencyAssistanceDO extends UuidIdentityEntityWithOperator {
        this.status = status;
    }
    public String getPatientAddress() {
        return patientAddress;
    public String getServeAddress() {
        return serveAddress;
    }
    public void setPatientAddress(String patientAddress) {
        this.patientAddress = patientAddress;
    public void setServeAddress(String serveAddress) {
        this.serveAddress = serveAddress;
    }
    public String getDoctorAddress() {

+ 23 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/assistance/EmergencyAssistanceEndpoint.java

@ -156,10 +156,10 @@ public class EmergencyAssistanceEndpoint extends EnvelopRestEndpoint {
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }
            return ObjEnvelop.getSuccess("查询成功",result.getJSONObject("resultMsg"));
            return ObjEnvelop.getSuccess("取消成功",result.getJSONObject("resultMsg"));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败"+e.getMessage());
            return ObjEnvelop.getError("取消失败"+e.getMessage());
        }
    }
@ -211,4 +211,25 @@ public class EmergencyAssistanceEndpoint extends EnvelopRestEndpoint {
        }
    }
    @PostMapping(value = "sendQuickMessage")
    @ApiOperation(value = "患者发送快捷消息")
    @ObserverRequired
    public ObjEnvelop sendQuickMessage(@ApiParam(name="orderId",value = "工单id",required =true )
                                       @RequestParam(value = "orderId") String orderId,
                                       @ApiParam(name="patient",value = "patient")
                                       @RequestParam(value = "patient") String patient,
                                       @ApiParam(name="content",value = "content")
                                       @RequestParam(value = "content") String content){
        try {
            JSONObject result =assistanceService.sendQuickMessage(orderId,patient,content);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }
            return ObjEnvelop.getSuccess("发送成功","");
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("发送失败"+e.getMessage());
        }
    }
}

+ 44 - 9
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java

@ -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;
    }
}

+ 2 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/CountDistance.java

@ -11,7 +11,7 @@ public class CountDistance {
    }
    /**
     * 通过经纬度计算两点之间的距离(单位:米)
     * 通过经纬度计算两点之间的距离(单位:千米)
     * @param latone
     * @param lngone
     * @param lattwo
@ -28,7 +28,7 @@ public class CountDistance {
                * Math.pow(Math.sin(b / 2), 2)));
        s = s * EARTH_RADIUS;
        s = Math.round(s * 10000d) / 10000d;
        s = s*1000;
        s = s;
        return s;
    }