|
@ -299,7 +299,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
message.put("orgType",orgDO.getType());
|
|
|
}
|
|
|
|
|
|
|
|
|
String url = "/sos/info?id="+assistanceDO.getId()+"&OrderType=20&patient="+assistanceDO.getPatient()+"&patientName="+assistanceDO.getPatientName();
|
|
|
for (BaseDoctorDO doctorDO:doctorDOS){
|
|
|
try {
|
|
|
if (StringUtils.isNotBlank(doctorDO.getMobile())){
|
|
@ -308,7 +308,8 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
}catch (Exception e){}
|
|
|
String body = "您好,"+assistanceDO.getPatientName()+"居民发起紧急呼叫,请关注并及时处理。";
|
|
|
String dingDingBody = "您好,"+assistanceDO.getPatientName()+"居民发起紧急呼叫,请及时处理。";
|
|
|
messageUtil.sendDoctorGetuiMessage(doctorDO.getId(),"2","/sos/index?tabActive=1","紧急呼叫",body);
|
|
|
|
|
|
messageUtil.sendDoctorGetuiMessage(doctorDO.getId(),"2",url,"紧急呼叫",body);
|
|
|
messageUtil.sendDoctorDingdingMessage(doctorDO,null,"text","2",dingDingBody,null,null);
|
|
|
imUtill.sendMDTSocketMessageToDoctor(doctorDO.getId(),message.toString());
|
|
|
}
|
|
@ -1121,6 +1122,88 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 记录预警核实日志
|
|
|
*/
|
|
|
public void addWarnLog(String sessionId,String doctor,Integer type,String content){
|
|
|
BaseDoctorDO doctorDO = doctorDao.findById(doctor);
|
|
|
if(doctorDO==null){
|
|
|
return;
|
|
|
}
|
|
|
String sql = "SELECT e.id from im_internet_hospital.topics t,wlyy_consult c,base_emergency_assistance_order e " +
|
|
|
"WHERE t.session_id = ? and t.id = c.id " +
|
|
|
"and c.relation_code = e.id and e.`status` = 1 " +
|
|
|
"UNION " +
|
|
|
"SELECT s.id from im_internet_hospital.topics t,wlyy_consult c,base_security_monitoring_order s " +
|
|
|
"WHERE t.session_id = ? and t.id = c.id " +
|
|
|
"and c.relation_code = s.id and s.`status` = 1 ";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql,new Object[]{sessionId,sessionId});
|
|
|
for (Map<String,Object> map:list){
|
|
|
String orderId = map.get("id")+"";
|
|
|
List<BaseEmergencyWarnLogDO> logDOS = logDao.findByOrderIdAndType(orderId,type);
|
|
|
if(logDOS.size()==0){
|
|
|
//新增 type =8 9
|
|
|
BaseEmergencyWarnLogDO logDO = new BaseEmergencyWarnLogDO();
|
|
|
logDO.setUserCode(doctor);
|
|
|
logDO.setUserName(doctorDO.getName());
|
|
|
logDO.setOrderId(orderId);
|
|
|
logDO.setUserType(2);
|
|
|
logDO.setCreateTime(new Date());
|
|
|
if(type==8){
|
|
|
logDO.setContent("发起im会话");
|
|
|
}else {
|
|
|
logDO.setContent(content);
|
|
|
}
|
|
|
logDO.setType(type);
|
|
|
logDao.save(logDO);
|
|
|
}else if(type==9){
|
|
|
//更新9
|
|
|
BaseEmergencyWarnLogDO logDO = logDOS.get(0);
|
|
|
logDO.setContent(content);
|
|
|
logDao.save(logDO);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 预警复核
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject preWarningReview(String orderId,String doctor,String content){
|
|
|
JSONObject result = new JSONObject();
|
|
|
EmergencyAssistanceDO one = emergencyAssistanceDao.findOne(orderId);
|
|
|
if (one==null){
|
|
|
String failMsg = "工单不存在" ;
|
|
|
result.put("resultFlag", 0);
|
|
|
result.put("resultMsg", failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
String orgCode = permissionService.getDoctorOrg(doctor);
|
|
|
if(!orgCode.equals(one.getOrgCode())){
|
|
|
String failMsg = "该操作没权限" ;
|
|
|
result.put("resultFlag", 0);
|
|
|
result.put("resultMsg", failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
BaseDoctorDO doctorDO = doctorDao.findById(doctor);
|
|
|
if (null!=doctorDO){
|
|
|
BaseEmergencyWarnLogDO logDO = new BaseEmergencyWarnLogDO();
|
|
|
logDO.setUserCode(doctor);
|
|
|
logDO.setUserName(doctorDO.getName());
|
|
|
logDO.setOrderId(orderId);
|
|
|
logDO.setUserType(2);
|
|
|
logDO.setCreateTime(new Date());
|
|
|
logDO.setContent(content);
|
|
|
logDO.setType(7);
|
|
|
logDao.save(logDO);
|
|
|
}
|
|
|
result.put("resultFlag", 1);
|
|
|
result.put("resultMsg", "success");
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject responseOrder(String orderId,String doctor){
|
|
|
JSONObject result = new JSONObject();
|
|
|
EmergencyAssistanceDO one = emergencyAssistanceDao.findOne(orderId);
|
|
@ -1147,15 +1230,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
|
|
|
BaseDoctorDO doctorDO = doctorDao.findById(doctor);
|
|
|
if (null!=doctorDO){
|
|
|
BaseEmergencyWarnLogDO logDO = new BaseEmergencyWarnLogDO();
|
|
|
BaseEmergencyWarnLogDO logTypeDO = new BaseEmergencyWarnLogDO();
|
|
|
logDO.setUserCode(doctor);
|
|
|
logDO.setUserName(doctorDO.getName());
|
|
|
logDO.setOrderId(orderId);
|
|
|
logDO.setUserType(2);
|
|
|
logDO.setCreateTime(new Date());
|
|
|
logDO.setContent("前往定位");
|
|
|
logDao.save(logDO);
|
|
|
|
|
|
List<BaseEmergencyWarnLogDO> byOrderIdByType = logDao.findByOrderIdByType(orderId);
|
|
|
if (byOrderIdByType.size()==0){
|
|
@ -1509,22 +1584,90 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
String eaSql = " ";
|
|
|
List<Map<String, Object>> maps = new ArrayList<>();
|
|
|
if ("20".equals(orderType)){
|
|
|
eaSql = "SELECT `status`,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') AS createTime,complete_time AS completeTime " +
|
|
|
"from base_emergency_assistance_order WHERE id = '"+orderId+"'";
|
|
|
eaSql = "SELECT o.`status`,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') AS createTime,o.patient,'紧急呼叫' AS serveDesc,dd.photo " +
|
|
|
"from base_emergency_assistance_order o " +
|
|
|
"LEFT JOIN wlyy_devices wd on wd.device_code=o.device_sn " +
|
|
|
"LEFT JOIN dm_device dd on dd.category_code = wd.category_code " +
|
|
|
" WHERE id = ?";
|
|
|
|
|
|
}
|
|
|
if ("22".equals(orderType)){
|
|
|
eaSql = "SELECT `status`,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') AS createTime,complete_time AS completeTime " +
|
|
|
"from base_security_monitoring_order WHERE id = '"+orderId+"'";
|
|
|
eaSql = "SELECT o.`status`,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') AS createTime,o.patient,o.serve_desc serveDesc,dd.photo " +
|
|
|
"from base_security_monitoring_order o " +
|
|
|
"LEFT JOIN wlyy_devices wd on wd.device_code=o.device_sn " +
|
|
|
"LEFT JOIN dm_device dd on dd.category_code = wd.category_code " +
|
|
|
" WHERE o.id = ?";
|
|
|
}
|
|
|
maps = jdbcTemplate.queryForList(eaSql);
|
|
|
maps = jdbcTemplate.queryForList(eaSql,new Object[]{orderId});
|
|
|
if (maps.size()==0) {
|
|
|
return null;
|
|
|
}
|
|
|
for (Map<String, Object> map : maps) {
|
|
|
jsonObject.put("status",map.get("status"));
|
|
|
jsonObject.put("createTime",map.get("createTime"));
|
|
|
}
|
|
|
//发起预警
|
|
|
jsonObject.put("start",maps.get(0));
|
|
|
String patient = maps.get(0).get("patient")+"";
|
|
|
|
|
|
//预警推送
|
|
|
//通知对象
|
|
|
|
|
|
|
|
|
//医生信息
|
|
|
/* String sql = "SELECT i.code,r.team_code,pack.org_code,pack.org_name from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack \n" +
|
|
|
"where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id and i.del = 1 and sr.`status`=1 \n" +
|
|
|
"and sr.patient = ? and i.code='preventLost' ";
|
|
|
List<Map<String, Object>> items = jdbcTemplate.queryForList(sql,new Object[]{orderId});
|
|
|
if (items.size() > 0) {
|
|
|
Map<String, Object> mapTmp = items.get(0);
|
|
|
List<BaseDoctorDO> doctorDOS = baseTeamMemberDao.findAllMembersByLevel(mapTmp.get("team_code").toString(), 2);
|
|
|
JSONArray otherDoctorDistance = new JSONArray();
|
|
|
JSONObject otherDoctorDistanceObj = new JSONObject();
|
|
|
for (BaseDoctorDO doc : doctorDOS) {
|
|
|
Map<String, Object> noticeObj = new HashMap<>();
|
|
|
noticeObj.put("type", "1");
|
|
|
noticeObj.put("typeName", "社工");
|
|
|
noticeObj.put("id", doc.getId());
|
|
|
noticeObj.put("name", doc.getName());
|
|
|
noticeObj.put("photo", doc.getPhoto());
|
|
|
noticeObj.put("mobile", doc.getMobile());
|
|
|
List<Map<String, Object>> arr = new ArrayList<>();
|
|
|
Map<String, Object> tmp = new HashMap<>();
|
|
|
tmp.put("name", "系统预警");
|
|
|
tmp.put("status", 0);
|
|
|
tmp.put("statusName", "未响应");
|
|
|
if (emergencyWarnDoctorResponseDao.findByDoctorAndOrderId(doc.getId(), orderDO.getId()) != null) {
|
|
|
tmp.put("status", 1);
|
|
|
tmp.put("statusName", "已响应");
|
|
|
}
|
|
|
arr.add(tmp);
|
|
|
noticeObj.put("response", arr);
|
|
|
noticePersons.add(noticeObj);
|
|
|
|
|
|
if (StringUtils.isBlank(doc.getDoctorLat()) || StringUtils.isBlank(doc.getDoctorLon())) {
|
|
|
List<BaseDoctorHospitalDO> doctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(doc.getId());
|
|
|
if (doctorHospitalDOS.size() > 0) {
|
|
|
BaseDoctorHospitalDO hospitalDO = doctorHospitalDOS.get(0);
|
|
|
BaseOrgDO orgDO = orgDao.findByCode(hospitalDO.getOrgCode());
|
|
|
doc.setDoctorLocateAddress(orgDO.getAddress());
|
|
|
doc.setDoctorLat(orgDO.getLatitude());
|
|
|
doc.setDoctorLon(orgDO.getLongitude());
|
|
|
} else {
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
//double distanceTmp = countDistance.getDistance(Double.parseDouble(orderDO.getServeLat()),Double.parseDouble(orderDO.getServeLon()),Double.parseDouble(doc.getDoctorLat()),Double.parseDouble(doc.getDoctorLon()));
|
|
|
otherDoctorDistanceObj = new JSONObject();
|
|
|
otherDoctorDistanceObj.put("doctor", doc.getId());
|
|
|
otherDoctorDistanceObj.put("doctorName", doc.getName());
|
|
|
otherDoctorDistanceObj.put("doctorAddress", doc.getDoctorLocateAddress());
|
|
|
otherDoctorDistanceObj.put("doctorLon", doc.getDoctorLon());
|
|
|
otherDoctorDistanceObj.put("doctorLat", doc.getDoctorLat());
|
|
|
otherDoctorDistanceObj.put("distance", null);//两点距离
|
|
|
otherDoctorDistance.add(otherDoctorDistanceObj);
|
|
|
}
|
|
|
emergencyOrderVO.setOtherDoctorDistance(otherDoctorDistance.toJSONString());
|
|
|
}*/
|
|
|
|
|
|
//其他日志
|
|
|
|
|
|
String sql = "select user_name AS userName,create_time AS createTime,content,type from base_emergency_warn_log where (user_type = 2 and order_id = '"+orderId+"' and type IS NOT NULL) " +
|
|
|
" OR (user_type = 1 AND order_id = '"+orderId+"' and type IS NOT NULL) order by create_time,type ASC ";
|
|
|
List<Map<String, Object>> result = jdbcTemplate.queryForList(sql);
|
|
@ -1541,6 +1684,39 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
public void patientFamily(String patient,String orderId){
|
|
|
List<Map<String, Object>> noticePersons = new ArrayList<>();
|
|
|
JSONArray familyArr = familyMemberService.getPatientMembers(patient, null, null, null, "3");
|
|
|
for (int i = 0; i < familyArr.size(); i++) {
|
|
|
String patientId = familyArr.getJSONObject(i).getString("id");
|
|
|
BasePatientDO patientDO1 = patientDao.findById(patientId);
|
|
|
Map<String, Object> noticeObj = new HashMap<>();
|
|
|
noticeObj.put("type", "0");
|
|
|
noticeObj.put("typeName", "家属");
|
|
|
noticeObj.put("id", patientDO1.getId());
|
|
|
noticeObj.put("name", patientDO1.getName());
|
|
|
noticeObj.put("photo", patientDO1.getPhoto());
|
|
|
noticeObj.put("mobile", patientDO1.getMobile());
|
|
|
List<Map<String, Object>> arr = new ArrayList<>();
|
|
|
Map<String, Object> tmp = new HashMap<>();
|
|
|
tmp.put("name", "系统预警");
|
|
|
tmp.put("status", 0);
|
|
|
tmp.put("statusName", "未读");
|
|
|
SystemMessageDO messageDO = systemMessageDao.findByRelationCodeAndReceiver(orderId, patientId);
|
|
|
if (messageDO != null) {
|
|
|
if (StringUtils.isNotBlank(messageDO.getIsRead())) {
|
|
|
tmp.put("status", Integer.parseInt(messageDO.getIsRead()));
|
|
|
if (Integer.parseInt(messageDO.getIsRead()) == 1) {
|
|
|
tmp.put("statusName", "已读");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
arr.add(tmp);
|
|
|
noticeObj.put("response", arr);
|
|
|
noticePersons.add(noticeObj);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public int phoneLogSave(BaseEmergencyWarnLogDO baseEmergencyWarnLogDO,Integer type){
|
|
|
switch (type) {
|
|
|
case 1:
|