|
@ -47,6 +47,7 @@ import com.yihu.jw.util.common.LatitudeUtils;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.entity.EntityUtils;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
import jdk.nashorn.internal.runtime.FindProperty;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@ -141,7 +142,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(SecurityMonitoringOrderService.class);
|
|
|
|
|
|
public JSONObject createOrder(String jsonData,Integer orderSource,String warnStr) throws Exception {
|
|
|
public JSONObject createOrder(String jsonData, Integer orderSource, String warnStr) throws Exception {
|
|
|
logger.info("创建安防工单jsonData参数:" + jsonData);
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
@ -168,9 +169,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
//V1.4 同一类型的安防工单 距离上次发起小于6小时不可重复发起
|
|
|
String sql = " select count(id) from base_security_monitoring_order where `status`=1 " +
|
|
|
" and TIMESTAMPDIFF(HOUR,create_time,NOW())<=6 " +
|
|
|
" and patient='"+orderDO.getPatient()+"' and serve_desc ='"+orderDO.getServeDesc()+"' ";
|
|
|
Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
if (count>0){
|
|
|
" and patient='" + orderDO.getPatient() + "' and serve_desc ='" + orderDO.getServeDesc() + "' ";
|
|
|
Integer count = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
if (count > 0) {
|
|
|
result.put("resultFlag", 0);
|
|
|
String failMsg = "居民六小时内已存在该预警类型工单,无法重复发起";
|
|
|
result.put("resultMsg", failMsg);
|
|
@ -186,7 +187,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
orderDO.setOrderInfo("0");
|
|
|
orderDO.setOrderSource(orderSource);
|
|
|
|
|
|
if(StringUtils.isEmpty(orderDO.getPatient())){
|
|
|
if (StringUtils.isEmpty(orderDO.getPatient())) {
|
|
|
result.put("resultFlag", 0);
|
|
|
String failMsg = "当前服务对象code为空,请联系管理员检查参数!patient = " + orderDO.getPatient();
|
|
|
result.put("resultMsg", failMsg);
|
|
@ -195,7 +196,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
}
|
|
|
|
|
|
BasePatientDO patientDO = basePatientDao.findById(orderDO.getPatient());
|
|
|
if (patientDO==null){
|
|
|
if (patientDO == null) {
|
|
|
result.put("resultFlag", 0);
|
|
|
String failMsg = "当前服务对象未建档";
|
|
|
result.put("resultMsg", failMsg);
|
|
@ -204,11 +205,11 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
}
|
|
|
|
|
|
//签约防走失服务包
|
|
|
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" +
|
|
|
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 = '"+orderDO.getPatient()+"' and i.code='preventLost' ";
|
|
|
List<Map<String,Object>> items = jdbcTemplate.queryForList(sql);
|
|
|
if (items.size()==0) {
|
|
|
"and sr.patient = '" + orderDO.getPatient() + "' and i.code='preventLost' ";
|
|
|
List<Map<String, Object>> items = jdbcTemplate.queryForList(sql);
|
|
|
if (items.size() == 0) {
|
|
|
result.put("resultFlag", 0);
|
|
|
String failMsg = "当前服务对象未签约防走失服务,请签约后再发起预警!";
|
|
|
result.put("resultMsg", failMsg);
|
|
@ -228,12 +229,12 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
// logger.error(failMsg);
|
|
|
// return result;
|
|
|
// }
|
|
|
Map<String,Object> mapTmp = items.get(0);
|
|
|
List<BaseDoctorDO> doctorDOS = baseTeamMemberDao.findAllMembersByLevel(mapTmp.get("team_code").toString(),2);
|
|
|
if (doctorDOS.size()==0){
|
|
|
Map<String, Object> mapTmp = items.get(0);
|
|
|
List<BaseDoctorDO> doctorDOS = baseTeamMemberDao.findAllMembersByLevel(mapTmp.get("team_code").toString(), 2);
|
|
|
if (doctorDOS.size() == 0) {
|
|
|
String failMsg = "安防警报服务项服务医生为空,不可发起救助";
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@ -243,94 +244,98 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
orderDO.setServiceStatus("2");
|
|
|
this.save(orderDO);
|
|
|
//创建im会话 安防警报咨询的sessionid 为居民code+(wlyy_consult_team表consult)+20
|
|
|
JSONObject IMObj = consultTeamService.addSecurityMoConsult(orderDO.getId(),orderDO.getPatient(),null,null,orderDO.getServeDesc());
|
|
|
String sessionId=orderDO.getPatient()+"_"+ IMObj.getJSONObject("resultMsg").getString("consult") + "_22";
|
|
|
JSONObject IMObj = consultTeamService.addSecurityMoConsult(orderDO.getId(), orderDO.getPatient(), null, null, orderDO.getServeDesc());
|
|
|
String sessionId = orderDO.getPatient() + "_" + IMObj.getJSONObject("resultMsg").getString("consult") + "_22";
|
|
|
orderDO.setSessionId(sessionId);
|
|
|
if (StringUtils.isNotBlank(orderDO.getServeDesc())){
|
|
|
if (StringUtils.isNotBlank(orderDO.getServeDesc())) {
|
|
|
ConsultTeamDo consultTeam = consultTeamDao.queryByRelationCode(orderDO.getId());
|
|
|
if (consultTeam!=null){
|
|
|
imUtil.sendTopicIM(orderDO.getPatient(),patientDO.getName(),consultTeam.getConsult(),"1",orderDO.getServeDesc(),null);
|
|
|
if (consultTeam != null) {
|
|
|
imUtil.sendTopicIM(orderDO.getPatient(), patientDO.getName(), consultTeam.getConsult(), "1", orderDO.getServeDesc(), null);
|
|
|
}
|
|
|
}
|
|
|
//推送socket给医生 推送紧急预警
|
|
|
JSONObject message = new JSONObject();
|
|
|
String latLon = orderDO.getServeLat()+","+orderDO.getServeLon();
|
|
|
message.put("latLon",latLon);
|
|
|
message.put("session_id",sessionId);
|
|
|
message.put("sender_name",orderDO.getPatientName());
|
|
|
message.put("content_notice",orderDO.getPatientName()+" "+warnStr+"!");
|
|
|
message.put("sender_code",orderDO.getPatient());
|
|
|
message.put("OrderType",22);
|
|
|
message.put("OrderStatus","new");
|
|
|
message.put("order_id",orderDO.getId());
|
|
|
message.put("content_type",40);
|
|
|
|
|
|
message.put("serverDesc",orderDO.getServeDesc());
|
|
|
message.put("categoryCode","");
|
|
|
message.put("orgType","");
|
|
|
message.put("contactStatus","");
|
|
|
message.put("residentialArea",patientDO.getResidentialArea());
|
|
|
|
|
|
if (null!=orderDO.getDeviceSn()){
|
|
|
String latLon = orderDO.getServeLat() + "," + orderDO.getServeLon();
|
|
|
message.put("latLon", latLon);
|
|
|
message.put("session_id", sessionId);
|
|
|
message.put("sender_name", orderDO.getPatientName());
|
|
|
message.put("content_notice", orderDO.getPatientName() + " " + warnStr + "!");
|
|
|
message.put("sender_code", orderDO.getPatient());
|
|
|
message.put("OrderType", 22);
|
|
|
message.put("OrderStatus", "new");
|
|
|
message.put("order_id", orderDO.getId());
|
|
|
message.put("content_type", 40);
|
|
|
|
|
|
message.put("serverDesc", orderDO.getServeDesc());
|
|
|
message.put("categoryCode", "");
|
|
|
message.put("orgType", "");
|
|
|
message.put("contactStatus", "");
|
|
|
message.put("residentialArea", patientDO.getResidentialArea());
|
|
|
|
|
|
if (null != orderDO.getDeviceSn()) {
|
|
|
String device_sn = orderDO.getDeviceSn();
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(device_sn)){
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(device_sn)) {
|
|
|
DeviceDetail deviceDetail = deviceDetailDao.findBySn(device_sn);
|
|
|
if (null!=deviceDetail){
|
|
|
message.put("contactStatus",deviceDetail.getContactStatus());
|
|
|
message.put("categoryCode",deviceDetail.getCategoryCode());
|
|
|
if (null != deviceDetail) {
|
|
|
message.put("contactStatus", deviceDetail.getContactStatus());
|
|
|
message.put("categoryCode", deviceDetail.getCategoryCode());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
String orgCode = orderDO.getHospital();
|
|
|
BaseOrgDO orgDO = orgDao.findByCode(orgCode);
|
|
|
if (null!=orgDO){
|
|
|
message.put("orgType",orgDO.getType());
|
|
|
if (null != orgDO) {
|
|
|
message.put("orgType", orgDO.getType());
|
|
|
}
|
|
|
|
|
|
for (BaseDoctorDO doctorDO:doctorDOS){
|
|
|
for (BaseDoctorDO doctorDO : doctorDOS) {
|
|
|
try {
|
|
|
if (StringUtils.isNotBlank(doctorDO.getMobile())){
|
|
|
messageUtil.sendTXYSJson("1141719",doctorDO.getMobile(),orderDO.getPatientName(),orderDO.getServeDesc());
|
|
|
if (StringUtils.isNotBlank(doctorDO.getMobile())) {
|
|
|
messageUtil.sendTXYSJson("1141719", doctorDO.getMobile(), orderDO.getPatientName(), orderDO.getServeDesc());
|
|
|
}
|
|
|
}catch (Exception e){}
|
|
|
imUtil.sendMDTSocketMessageToDoctor(doctorDO.getId(),message.toString());
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
}
|
|
|
String body = "您好," + orderDO.getPatientName() + "居民" + orderDO.getServeDesc() + ",请关注并及时处理。";
|
|
|
messageUtil.sendDoctorGetuiMessage(doctorDO.getId(), "1", "/securityMonitoring/index", "安防紧急预警", body);
|
|
|
imUtil.sendMDTSocketMessageToDoctor(doctorDO.getId(), message.toString());
|
|
|
}
|
|
|
//pc管理端端推送消息
|
|
|
imUtil.sendPcManageMessageToPc("cloudCare_pcManage",message.toString());
|
|
|
imUtil.sendPcManageMessageToPc("cloudCare_pcManage", message.toString());
|
|
|
result.put("resultFlag", 1);
|
|
|
result.put("resultMsg",orderDO);
|
|
|
result.put("resultMsg", orderDO);
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public List<Map<String , Object>> getElectronicFence(String patient){
|
|
|
String sql = " select safe_area_gz safeAreaGz from wlyy_patient_safe_area where patient = '"+patient+"' ";
|
|
|
public List<Map<String, Object>> getElectronicFence(String patient) {
|
|
|
String sql = " select safe_area_gz safeAreaGz from wlyy_patient_safe_area where patient = '" + patient + "' ";
|
|
|
return jdbcTemplate.queryForList(sql);
|
|
|
}
|
|
|
|
|
|
public List<Map<String , Object>> getActionTrack(String deviceSn,String day){
|
|
|
String sql = "SELECT * FROM base_yxdevice_index WHERE sn = '"+deviceSn+"' AND lon != 0 AND lat != 0 and create_time like '"+day+"%' ORDER BY create_time DESC LIMIT 0,20";
|
|
|
public List<Map<String, Object>> getActionTrack(String deviceSn, String day) {
|
|
|
String sql = "SELECT * FROM base_yxdevice_index WHERE sn = '" + deviceSn + "' AND lon != 0 AND lat != 0 and create_time like '" + day + "%' ORDER BY create_time DESC LIMIT 0,20";
|
|
|
return jdbcTemplate.queryForList(sql);
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>>getNewList(String deviceSn,String day){
|
|
|
if (StringUtils.isBlank(day)){
|
|
|
public List<Map<String, Object>> getNewList(String deviceSn, String day) {
|
|
|
if (StringUtils.isBlank(day)) {
|
|
|
day = DateUtil.getStringDateShort();
|
|
|
}
|
|
|
String sql = "SELECT * FROM base_yxdevice_index WHERE sn = '"+deviceSn+"' AND create_time LIKE '"+day+"%' AND lon != 0 AND lat != 0 ORDER BY create_time DESC limit 1";
|
|
|
String sql = "SELECT * FROM base_yxdevice_index WHERE sn = '" + deviceSn + "' AND create_time LIKE '" + day + "%' AND lon != 0 AND lat != 0 ORDER BY create_time DESC limit 1";
|
|
|
return jdbcTemplate.queryForList(sql);
|
|
|
}
|
|
|
|
|
|
public List<Map<String , Object>> getPatientLatLon(String deviceSn){
|
|
|
String sql = "SELECT p.lat_lon FROM base_patient p,wlyy_patient_device pd WHERE pd.del = 0 AND pd.device_sn = '"+deviceSn+"' AND pd.`user` = p.id AND p.del = 1 limit 1";
|
|
|
public List<Map<String, Object>> getPatientLatLon(String deviceSn) {
|
|
|
String sql = "SELECT p.lat_lon FROM base_patient p,wlyy_patient_device pd WHERE pd.del = 0 AND pd.device_sn = '" + deviceSn + "' AND pd.`user` = p.id AND p.del = 1 limit 1";
|
|
|
return jdbcTemplate.queryForList(sql);
|
|
|
}
|
|
|
|
|
|
public JSONObject getSecurityOrderDetail(String orderID,String doctor){
|
|
|
public JSONObject getSecurityOrderDetail(String orderID, String doctor) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
EmergencyOrderVO emergencyOrderVO = new EmergencyOrderVO();
|
|
|
SecurityMonitoringOrderDO orderDO = securityMonitoringOrderDao.findOne(orderID);
|
|
|
if (orderDO==null){
|
|
|
if (orderDO == null) {
|
|
|
String failMsg = "工单不存在!";
|
|
|
result.put("resultFlag", 0);
|
|
|
result.put("resultMsg", failMsg);
|
|
@ -339,13 +344,21 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
}
|
|
|
emergencyOrderVO.setId(orderDO.getId());
|
|
|
BasePatientDO patientDO = basePatientDao.findById(orderDO.getPatient());
|
|
|
Integer statustemp = Integer.valueOf(orderDO.getStatus()+"");
|
|
|
Integer statustemp = Integer.valueOf(orderDO.getStatus() + "");
|
|
|
String statusName = "";
|
|
|
switch (statustemp){
|
|
|
case -2:statusName="误警报";break;
|
|
|
case -1:statusName="已取消";break;
|
|
|
case 0:statusName="已完成";break;
|
|
|
case 1:statusName="预警中";break;
|
|
|
switch (statustemp) {
|
|
|
case -2:
|
|
|
statusName = "误警报";
|
|
|
break;
|
|
|
case -1:
|
|
|
statusName = "已取消";
|
|
|
break;
|
|
|
case 0:
|
|
|
statusName = "已完成";
|
|
|
break;
|
|
|
case 1:
|
|
|
statusName = "预警中";
|
|
|
break;
|
|
|
}
|
|
|
emergencyOrderVO.setStatusName(statusName);
|
|
|
emergencyOrderVO.setOrderId(orderID);
|
|
@ -359,247 +372,244 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
emergencyOrderVO.setSex(patientDO.getSex());
|
|
|
emergencyOrderVO.setTopicItem(orderDO.getTopicItem());
|
|
|
emergencyOrderVO.setOrderType(22);
|
|
|
if (StringUtils.isNotBlank(orderDO.getSceneImg())){
|
|
|
if (StringUtils.isNotBlank(orderDO.getSceneImg())) {
|
|
|
emergencyOrderVO.setSceneImg(orderDO.getSceneImg());
|
|
|
}
|
|
|
|
|
|
List<BaseEmergencyWarnLogDO> logDOS = logDao.findByOrderIdOrderByCreateTimeDesc(orderDO.getId());
|
|
|
for (BaseEmergencyWarnLogDO tmp:logDOS){
|
|
|
tmp.setTimeInfo(DateUtil.getDifferentTimeInfo(new Date(),tmp.getCreateTime(),0));
|
|
|
for (BaseEmergencyWarnLogDO tmp : logDOS) {
|
|
|
tmp.setTimeInfo(DateUtil.getDifferentTimeInfo(new Date(), tmp.getCreateTime(), 0));
|
|
|
}
|
|
|
if (logDOS.size()==0&&1==emergencyOrderVO.getStatus()){//未响应
|
|
|
emergencyOrderVO.setOverTimeNotResponse(DateUtil.getDifferentTimeInfo1(new Date(),orderDO.getCreateTime()));
|
|
|
if (logDOS.size() == 0 && 1 == emergencyOrderVO.getStatus()) {//未响应
|
|
|
emergencyOrderVO.setOverTimeNotResponse(DateUtil.getDifferentTimeInfo1(new Date(), orderDO.getCreateTime()));
|
|
|
}
|
|
|
|
|
|
emergencyOrderVO.setOrderLogInfo(logDOS);
|
|
|
List<PatientSosContactsDO> contactsDOS = contactsService.getPatientSosContacts(orderDO.getPatient());
|
|
|
emergencyOrderVO.setSosContacts(contactsDOS);
|
|
|
List<Map<String,Object>> securityDevices = patientDeviceService.patientEmeDeviceList(orderDO.getPatient());
|
|
|
List<Map<String, Object>> securityDevices = patientDeviceService.patientEmeDeviceList(orderDO.getPatient());
|
|
|
emergencyOrderVO.setSecurityDevices(securityDevices);
|
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(patientDO.getIdcard())){
|
|
|
emergencyOrderVO.setAge((IdCardUtil.getAgeForIdcard(patientDO.getIdcard()))+"");
|
|
|
if (StringUtils.isNotBlank(patientDO.getIdcard())) {
|
|
|
emergencyOrderVO.setAge((IdCardUtil.getAgeForIdcard(patientDO.getIdcard())) + "");
|
|
|
}
|
|
|
emergencyOrderVO.setLiveAddress(patientDO.getAddress());
|
|
|
emergencyOrderVO.setOrderSource(orderDO.getOrderSource());
|
|
|
if(orderDO.getStatus()==-2){//误报警
|
|
|
if (orderDO.getStatus() == -2) {//误报警
|
|
|
emergencyOrderVO.setUpdateUserName(orderDO.getUpdateUserName());
|
|
|
emergencyOrderVO.setUpdateUser(orderDO.getUpdateUser());
|
|
|
emergencyOrderVO.setUpdateTime(orderDO.getUpdateTime());
|
|
|
emergencyOrderVO.setEmergencyCancel(orderDO.getEmergencyCancel());
|
|
|
}
|
|
|
emergencyOrderVO.setUpdateTime(orderDO.getUpdateTime());
|
|
|
if (orderDO.getStatus()==-1){//已取消
|
|
|
if (orderDO.getCancelTime()!=null){
|
|
|
if (orderDO.getStatus() == -1) {//已取消
|
|
|
if (orderDO.getCancelTime() != null) {
|
|
|
emergencyOrderVO.setUpdateTime(orderDO.getCancelTime());
|
|
|
}
|
|
|
else {
|
|
|
} else {
|
|
|
emergencyOrderVO.setUpdateTime(orderDO.getUpdateTime());
|
|
|
}
|
|
|
}
|
|
|
//小结
|
|
|
Integer conclusionStatus = Integer.valueOf(orderDO.getConclusionStatus()==null?"0":(orderDO.getConclusionStatus()+""));
|
|
|
if (conclusionStatus==2){
|
|
|
Integer conclusionStatus = Integer.valueOf(orderDO.getConclusionStatus() == null ? "0" : (orderDO.getConclusionStatus() + ""));
|
|
|
if (conclusionStatus == 2) {
|
|
|
EmergencyWarnConclusionDO conclusionDO = emergencyWarnConclusionDao.findByOrderId(orderDO.getId());
|
|
|
if (conclusionDO!=null){
|
|
|
conclusionDO.setReasonName(dictService.fingByNameAndCode(ConstantUtil.DICT_EMERGENCY_REASON,String.valueOf(conclusionDO.getEmergencyReason())));
|
|
|
conclusionDO.setTreatmentStatusName(dictService.fingByNameAndCode(ConstantUtil.DICT_EMERGENCY_TREATMENT_STATUS,String.valueOf(conclusionDO.getEmergencyTreatmentStatus())));
|
|
|
if (conclusionDO != null) {
|
|
|
conclusionDO.setReasonName(dictService.fingByNameAndCode(ConstantUtil.DICT_EMERGENCY_REASON, String.valueOf(conclusionDO.getEmergencyReason())));
|
|
|
conclusionDO.setTreatmentStatusName(dictService.fingByNameAndCode(ConstantUtil.DICT_EMERGENCY_TREATMENT_STATUS, String.valueOf(conclusionDO.getEmergencyTreatmentStatus())));
|
|
|
emergencyOrderVO.setEmergencyWarnConclusionDO(conclusionDO);
|
|
|
}
|
|
|
}
|
|
|
//附加信息 电子围栏状态
|
|
|
if (2==orderDO.getOrderSource()||8==orderDO.getOrderSource()){//手表/拐杖
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
map.put("inFenceStatus",false);
|
|
|
map.put("inFenceName","疑似超出安全区域");
|
|
|
if (2 == orderDO.getOrderSource() || 8 == orderDO.getOrderSource()) {//手表/拐杖
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("inFenceStatus", false);
|
|
|
map.put("inFenceName", "疑似超出安全区域");
|
|
|
emergencyOrderVO.setInformation(map);
|
|
|
}
|
|
|
if(4==orderDO.getOrderSource()){//监控器
|
|
|
List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(orderDO.getPatient(),"12");
|
|
|
if (devicePatientDeviceDos.size()==0){
|
|
|
}else {
|
|
|
if (4 == orderDO.getOrderSource()) {//监控器
|
|
|
List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(orderDO.getPatient(), "12");
|
|
|
if (devicePatientDeviceDos.size() == 0) {
|
|
|
} else {
|
|
|
try {
|
|
|
JSONObject monitorUrl = ysDeviceServicel.getDeviceLiveAddress(orderDO.getPatient(),devicePatientDeviceDos.get(0).getDeviceSn(),1,null);
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
map.put("monitorInfoStatus",monitorUrl.getIntValue(ResponseContant.resultFlag));
|
|
|
map.put("patientAddress",devicePatientDeviceDos.get(0).getSosAddress());
|
|
|
if (monitorUrl.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail){
|
|
|
map.put("monitorInfo",monitorUrl.getString(ResponseContant.resultMsg));
|
|
|
}
|
|
|
else {
|
|
|
map.put("monitorInfo",monitorUrl.getJSONObject(ResponseContant.resultMsg));
|
|
|
JSONObject monitorUrl = ysDeviceServicel.getDeviceLiveAddress(orderDO.getPatient(), devicePatientDeviceDos.get(0).getDeviceSn(), 1, null);
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("monitorInfoStatus", monitorUrl.getIntValue(ResponseContant.resultFlag));
|
|
|
map.put("patientAddress", devicePatientDeviceDos.get(0).getSosAddress());
|
|
|
if (monitorUrl.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
|
|
|
map.put("monitorInfo", monitorUrl.getString(ResponseContant.resultMsg));
|
|
|
} else {
|
|
|
map.put("monitorInfo", monitorUrl.getJSONObject(ResponseContant.resultMsg));
|
|
|
}
|
|
|
emergencyOrderVO.setInformation(map);
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (5==orderDO.getOrderSource()){//睡眠带工单
|
|
|
if (5 == orderDO.getOrderSource()) {//睡眠带工单
|
|
|
try {
|
|
|
JSONObject monitorInfo = JSONObject.parseObject(orderDO.getWarnInfo());
|
|
|
List<BaseSleepPlan> sleepPlans = sleepPlanDao.findByPatient(patientDO.getId());
|
|
|
if(null==monitorInfo){
|
|
|
if (null == monitorInfo) {
|
|
|
monitorInfo = new JSONObject();
|
|
|
}
|
|
|
if (sleepPlans.size()>0){
|
|
|
if (sleepPlans.size() > 0) {
|
|
|
BaseSleepPlan sleepPlan = sleepPlans.get(0);
|
|
|
String endTime = DateUtil.getNextMin(sleepPlan.getGetUpTime(),-1);
|
|
|
monitorInfo.put("sleepPlan",true);
|
|
|
monitorInfo.put("getUpTime",sleepPlan.getGetUpTime());
|
|
|
monitorInfo.put("siestaTime",sleepPlan.getNapTime());
|
|
|
monitorInfo.put("nightRestTime",sleepPlan.getNightRestTime());
|
|
|
monitorInfo.put("nightRecordTime",sleepPlan.getNightRestTime()+"-隔日"+endTime);
|
|
|
|
|
|
}else {
|
|
|
monitorInfo.put("sleepPlan",false);
|
|
|
String endTime = DateUtil.getNextMin(sleepPlan.getGetUpTime(), -1);
|
|
|
monitorInfo.put("sleepPlan", true);
|
|
|
monitorInfo.put("getUpTime", sleepPlan.getGetUpTime());
|
|
|
monitorInfo.put("siestaTime", sleepPlan.getNapTime());
|
|
|
monitorInfo.put("nightRestTime", sleepPlan.getNightRestTime());
|
|
|
monitorInfo.put("nightRecordTime", sleepPlan.getNightRestTime() + "-隔日" + endTime);
|
|
|
|
|
|
} else {
|
|
|
monitorInfo.put("sleepPlan", false);
|
|
|
}
|
|
|
monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall",null,true);
|
|
|
monitorInfo = patientSignTopicInfo(monitorInfo, orderDO.getPatient(), "preventFall", null, true);
|
|
|
emergencyOrderVO.setInformation(monitorInfo);
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
if (6==orderDO.getOrderSource()){//气感工单
|
|
|
if (6 == orderDO.getOrderSource()) {//气感工单
|
|
|
try {
|
|
|
JSONObject monitorInfo = JSONObject.parseObject(orderDO.getWarnInfo());
|
|
|
monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall",null,true);
|
|
|
monitorInfo = patientSignTopicInfo(monitorInfo, orderDO.getPatient(), "preventFall", null, true);
|
|
|
emergencyOrderVO.setInformation(monitorInfo);
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
if (7==orderDO.getOrderSource()){//烟感工单
|
|
|
if (7 == orderDO.getOrderSource()) {//烟感工单
|
|
|
try {
|
|
|
JSONObject monitorInfo = JSONObject.parseObject(orderDO.getWarnInfo());
|
|
|
monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall",null,true);
|
|
|
monitorInfo = patientSignTopicInfo(monitorInfo, orderDO.getPatient(), "preventFall", null, true);
|
|
|
emergencyOrderVO.setInformation(monitorInfo);
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//通知对象
|
|
|
List<Map<String,Object>> noticePersons = new ArrayList<>();
|
|
|
JSONArray familyArr = familyMemberService.getPatientMembers(orderDO.getPatient(),null,null,null,"3");
|
|
|
for (int i=0;i<familyArr.size();i++){
|
|
|
List<Map<String, Object>> noticePersons = new ArrayList<>();
|
|
|
JSONArray familyArr = familyMemberService.getPatientMembers(orderDO.getPatient(), null, null, null, "3");
|
|
|
for (int i = 0; i < familyArr.size(); i++) {
|
|
|
String patientId = familyArr.getJSONObject(i).getString("id");
|
|
|
BasePatientDO patientDO1 = basePatientDao.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(orderDO.getId(),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","已读");
|
|
|
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(orderDO.getId(), 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);
|
|
|
noticeObj.put("response", arr);
|
|
|
noticePersons.add(noticeObj);
|
|
|
}
|
|
|
//医生信息
|
|
|
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" +
|
|
|
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 = '"+orderDO.getPatient()+"' and i.code='preventLost' ";
|
|
|
List<Map<String,Object>> items = jdbcTemplate.queryForList(sql);
|
|
|
if (items.size()>0){
|
|
|
Map<String,Object> mapTmp = items.get(0);
|
|
|
List<BaseDoctorDO> doctorDOS = baseTeamMemberDao.findAllMembersByLevel(mapTmp.get("team_code").toString(),2);
|
|
|
"and sr.patient = '" + orderDO.getPatient() + "' and i.code='preventLost' ";
|
|
|
List<Map<String, Object>> items = jdbcTemplate.queryForList(sql);
|
|
|
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","已响应");
|
|
|
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);
|
|
|
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){
|
|
|
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 {
|
|
|
} 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);//两点距离
|
|
|
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());
|
|
|
}
|
|
|
emergencyOrderVO.setNoticePersons(noticePersons);
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(JSON.toJSONStringWithDateFormat(emergencyOrderVO,"yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue));
|
|
|
JSONObject jsonObject = JSON.parseObject(JSON.toJSONStringWithDateFormat(emergencyOrderVO, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue));
|
|
|
//获取咨询
|
|
|
ConsultDo consult = consultDao.queryByRelationCode(orderID);
|
|
|
if (null != consult) {
|
|
|
String sessionId = orderDO.getPatient() + "_" + consult.getId() + "_" + consult.getType();
|
|
|
jsonObject.put("sessionId",sessionId);
|
|
|
if (1==orderDO.getStatus()&&StringUtils.isNotBlank(doctor)){//查询未读数量
|
|
|
jsonObject.put("sessionId", sessionId);
|
|
|
if (1 == orderDO.getStatus() && StringUtils.isNotBlank(doctor)) {//查询未读数量
|
|
|
try {
|
|
|
Integer count = imUtil.UserSessionsUnreadMessageCount(sessionId,doctor);
|
|
|
jsonObject.put("UnRead",count);
|
|
|
}catch (Exception e){
|
|
|
jsonObject.put("sessionId",sessionId);
|
|
|
jsonObject.put("UnRead",0);
|
|
|
Integer count = imUtil.UserSessionsUnreadMessageCount(sessionId, doctor);
|
|
|
jsonObject.put("UnRead", count);
|
|
|
} catch (Exception e) {
|
|
|
jsonObject.put("sessionId", sessionId);
|
|
|
jsonObject.put("UnRead", 0);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
jsonObject.put("sessionId",null);
|
|
|
jsonObject.put("UnRead",0);
|
|
|
} else {
|
|
|
jsonObject.put("sessionId", null);
|
|
|
jsonObject.put("UnRead", 0);
|
|
|
}
|
|
|
|
|
|
result.put("resultFlag", 1);
|
|
|
result.put("resultMsg",jsonObject);
|
|
|
result.put("resultMsg", jsonObject);
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
public JSONObject errorWarning(String orderId,Integer emergencyCancel,String doctor){
|
|
|
public JSONObject errorWarning(String orderId, Integer emergencyCancel, String doctor) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
SecurityMonitoringOrderDO orderDO = securityMonitoringOrderDao.findOne(orderId);
|
|
|
if (orderDO==null){
|
|
|
if (orderDO == null) {
|
|
|
String failMsg = "工单不存在!";
|
|
|
result.put("resultFlag", 0);
|
|
|
result.put("resultMsg", failMsg);
|
|
@ -613,60 +623,60 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
orderDO.setUpdateUserName(doctorDO.getName());
|
|
|
orderDO.setUpdateUser(doctorDO.getId());
|
|
|
orderDO.setEmergencyCancel(emergencyCancel);
|
|
|
if (!consultTeamService.finishConsult(orderDO.getId(),orderDO.getPatient(),doctor,2)){
|
|
|
if (!consultTeamService.finishConsult(orderDO.getId(), orderDO.getPatient(), doctor, 2)) {
|
|
|
String failMsg = "修改失败:咨询未能结束";
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
securityMonitoringOrderDao.save(orderDO);
|
|
|
|
|
|
//完成工单向pc管理端发送消息
|
|
|
JSONObject message = new JSONObject();
|
|
|
String latLon = orderDO.getServeLat()+","+orderDO.getServeLon();
|
|
|
message.put("latLon",latLon);
|
|
|
message.put("session_id",orderDO.getSessionId());
|
|
|
message.put("sender_name",orderDO.getPatientName());
|
|
|
message.put("content_notice","完成安防服务工单");
|
|
|
message.put("sender_code",orderDO.getPatient());
|
|
|
message.put("OrderType",22);
|
|
|
message.put("OrderStatus","finish");
|
|
|
message.put("order_id",orderDO.getId());
|
|
|
message.put("content_type",40);
|
|
|
|
|
|
message.put("serverDesc",orderDO.getServeDesc());
|
|
|
message.put("categoryCode","");
|
|
|
message.put("orgType","");
|
|
|
message.put("contactStatus","");
|
|
|
message.put("residentialArea","");//结束时该字段无意义
|
|
|
|
|
|
if (null!=orderDO.getDeviceSn()){
|
|
|
String latLon = orderDO.getServeLat() + "," + orderDO.getServeLon();
|
|
|
message.put("latLon", latLon);
|
|
|
message.put("session_id", orderDO.getSessionId());
|
|
|
message.put("sender_name", orderDO.getPatientName());
|
|
|
message.put("content_notice", "完成安防服务工单");
|
|
|
message.put("sender_code", orderDO.getPatient());
|
|
|
message.put("OrderType", 22);
|
|
|
message.put("OrderStatus", "finish");
|
|
|
message.put("order_id", orderDO.getId());
|
|
|
message.put("content_type", 40);
|
|
|
|
|
|
message.put("serverDesc", orderDO.getServeDesc());
|
|
|
message.put("categoryCode", "");
|
|
|
message.put("orgType", "");
|
|
|
message.put("contactStatus", "");
|
|
|
message.put("residentialArea", "");//结束时该字段无意义
|
|
|
|
|
|
if (null != orderDO.getDeviceSn()) {
|
|
|
String device_sn = orderDO.getDeviceSn();
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(device_sn)){
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(device_sn)) {
|
|
|
DeviceDetail deviceDetail = deviceDetailDao.findBySn(device_sn);
|
|
|
if (null!=deviceDetail){
|
|
|
message.put("contactStatus",deviceDetail.getContactStatus());
|
|
|
message.put("categoryCode",deviceDetail.getCategoryCode());
|
|
|
if (null != deviceDetail) {
|
|
|
message.put("contactStatus", deviceDetail.getContactStatus());
|
|
|
message.put("categoryCode", deviceDetail.getCategoryCode());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
String orgCode = orderDO.getHospital();
|
|
|
BaseOrgDO orgDO = orgDao.findByCode(orgCode);
|
|
|
if (null!=orgDO){
|
|
|
message.put("orgType",orgDO.getType());
|
|
|
if (null != orgDO) {
|
|
|
message.put("orgType", orgDO.getType());
|
|
|
}
|
|
|
|
|
|
imUtil.sendPcManageMessageToPc("cloudCare_pcManage",message.toString());
|
|
|
result = getSecurityOrderDetail(orderId,null);
|
|
|
imUtil.sendPcManageMessageToPc("cloudCare_pcManage", message.toString());
|
|
|
result = getSecurityOrderDetail(orderId, null);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public PageEnvelop getSecurityOrderList(String doctor, String serverDoctor, String patientName, String patient, String status,
|
|
|
String svrDesc,String topicItem, Integer page, Integer pageSize,Integer dailyMonitor){
|
|
|
String svrDesc, String topicItem, Integer page, Integer pageSize, Integer dailyMonitor) {
|
|
|
JSONArray result = new JSONArray();
|
|
|
//服务权限
|
|
|
if(doctorServicePermissionsService.isPermission(doctor,10)==0){
|
|
|
return PageEnvelop.getSuccessListWithPage("success",result,page,pageSize,0L);
|
|
|
if (doctorServicePermissionsService.isPermission(doctor, 10) == 0) {
|
|
|
return PageEnvelop.getSuccessListWithPage("success", result, page, pageSize, 0L);
|
|
|
}
|
|
|
|
|
|
String sqlCount = "select count(ord.id) from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " +
|
|
@ -676,167 +686,178 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
"ord.doctor_name,ord.update_user,ord.update_user_name,ord.patient_phone,ord.conclusion_status from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " +
|
|
|
"where 1=1 ";
|
|
|
|
|
|
if (1==dailyMonitor){//医生日常监护居民安防工单列表查询
|
|
|
if (StringUtils.isBlank(topicItem)||StringUtils.isBlank(doctor)){
|
|
|
if (1 == dailyMonitor) {//医生日常监护居民安防工单列表查询
|
|
|
if (StringUtils.isBlank(topicItem) || StringUtils.isBlank(doctor)) {
|
|
|
return new PageEnvelop();
|
|
|
}
|
|
|
String categoryCode ="";
|
|
|
switch (topicItem){
|
|
|
String categoryCode = "";
|
|
|
switch (topicItem) {
|
|
|
case "preventLost":
|
|
|
categoryCode="'4'";
|
|
|
categoryCode = "'4'";
|
|
|
break;
|
|
|
case "preventFall":
|
|
|
categoryCode="'12'";
|
|
|
categoryCode = "'12'";
|
|
|
break;
|
|
|
case "preventFire":
|
|
|
categoryCode="'15'";
|
|
|
categoryCode = "'15'";
|
|
|
break;
|
|
|
case "preventGasLeakage":
|
|
|
categoryCode="'14'";
|
|
|
categoryCode = "'14'";
|
|
|
break;
|
|
|
case "preventOutOfBed":
|
|
|
categoryCode="'13'";
|
|
|
categoryCode = "'13'";
|
|
|
break;
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(doctor)){//日常监护医生必传
|
|
|
if (StringUtils.isNotBlank(doctor)) {//日常监护医生必传
|
|
|
fliter += " and EXISTS( SELECT DISTINCT p.id,p.name,p.residential_area residentialArea,p.photo,p.idcard,p.mobile, " +
|
|
|
" p.openid,p.sex,p.pad_imei padImei " +
|
|
|
" from base_patient p , base_service_package_sign_record sr,base_service_package_record r,base_team_member m " +
|
|
|
" WHERE p.id = sr.patient and sr.status=1 and m.team_code = r.team_code and sr.id=r.sign_id " +
|
|
|
" and m.doctor_code = '"+doctor+"' and m.del = '1' ) ";
|
|
|
" and m.doctor_code = '" + doctor + "' and m.del = '1' ) ";
|
|
|
|
|
|
fliter +=" and EXISTS (select 1 from wlyy_patient_device pd INNER JOIN dm_device dd on pd.device_id = dd.id " +
|
|
|
" where pd.user = p.id and pd.del=0 and pd.category_code in ("+categoryCode+") and FIND_IN_SET('"+topicItem+"',dd.service_topic)) ";
|
|
|
fliter += " and EXISTS (select 1 from wlyy_patient_device pd INNER JOIN dm_device dd on pd.device_id = dd.id " +
|
|
|
" where pd.user = p.id and pd.del=0 and pd.category_code in (" + categoryCode + ") and FIND_IN_SET('" + topicItem + "',dd.service_topic)) ";
|
|
|
|
|
|
if ("preventLost".equals(topicItem)){//有绑定围栏的居民
|
|
|
if ("preventLost".equals(topicItem)) {//有绑定围栏的居民
|
|
|
fliter += " and EXISTS (select 1 from wlyy_patient_safe_area sf where sf.patient = p.id and sf.del=1 and sf.manage_status=1) ";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}else {
|
|
|
if (StringUtils.isNotBlank(doctor)){
|
|
|
fliter+=" and EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
|
|
|
} else {
|
|
|
if (StringUtils.isNotBlank(doctor)) {
|
|
|
fliter += " and EXISTS ( SELECT 1 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 = r.team_code and i.del = 1 and sr.`status`=1 and m.doctor_code = '"+doctor+"' and m.del = '1') ";
|
|
|
" r.service_package_id = i.service_package_id and m.team_code = r.team_code and i.del = 1 and sr.`status`=1 and m.doctor_code = '" + doctor + "' and m.del = '1') ";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotBlank(serverDoctor)){
|
|
|
fliter +=" and ord.doctor = '"+serverDoctor+"' ";
|
|
|
if (StringUtils.isNotBlank(serverDoctor)) {
|
|
|
fliter += " and ord.doctor = '" + serverDoctor + "' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(patientName)){
|
|
|
fliter+=" and (ord.patient_name like '%"+patientName+"%' or p.idcard='"+patientName+"') ";
|
|
|
if (StringUtils.isNotBlank(patientName)) {
|
|
|
fliter += " and (ord.patient_name like '%" + patientName + "%' or p.idcard='" + patientName + "') ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(patient)){
|
|
|
fliter+=" and ord.patient='"+patient+"' ";
|
|
|
if (StringUtils.isNotBlank(patient)) {
|
|
|
fliter += " and ord.patient='" + patient + "' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(status)){
|
|
|
fliter+=" and ord.status='"+Integer.parseInt(status)+"' ";
|
|
|
if (StringUtils.isNotBlank(status)) {
|
|
|
fliter += " and ord.status='" + Integer.parseInt(status) + "' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(svrDesc)){
|
|
|
fliter+=" and ord.serve_desc='"+svrDesc+"' ";
|
|
|
if (StringUtils.isNotBlank(svrDesc)) {
|
|
|
fliter += " and ord.serve_desc='" + svrDesc + "' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(topicItem)){
|
|
|
fliter+=" and ord.topic_item='"+topicItem+"' ";
|
|
|
if (StringUtils.isNotBlank(topicItem)) {
|
|
|
fliter += " and ord.topic_item='" + topicItem + "' ";
|
|
|
}
|
|
|
Long count = jdbcTemplate.queryForObject(sqlCount+fliter,Long.class);
|
|
|
fliter+=" order by ord.create_time desc limit " + (page*pageSize) + "," + pageSize;
|
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql+fliter);
|
|
|
Long count = jdbcTemplate.queryForObject(sqlCount + fliter, Long.class);
|
|
|
fliter += " order by ord.create_time desc limit " + (page * pageSize) + "," + pageSize;
|
|
|
List<Map<String, Object>> sqlResult = jdbcTemplate.queryForList(sql + fliter);
|
|
|
|
|
|
for (Map<String,Object>one:sqlResult){
|
|
|
for (Map<String, Object> one : sqlResult) {
|
|
|
JSONObject tmp = new JSONObject();
|
|
|
tmp.put("patientCode",one.get("patientCode"));
|
|
|
tmp.put("patientName",one.get("name"));
|
|
|
tmp.put("sex",one.get("sex"));
|
|
|
tmp.put("photo",one.get("photo"));
|
|
|
tmp.put("idcard",one.get("idcard"));
|
|
|
tmp.put("number",one.get("number"));
|
|
|
tmp.put("id",one.get("orderId"));
|
|
|
tmp.put("serveDesc",one.get("serve_desc"));
|
|
|
Date date = (Date)one.get("create_time");
|
|
|
tmp.put("patientCode", one.get("patientCode"));
|
|
|
tmp.put("patientName", one.get("name"));
|
|
|
tmp.put("sex", one.get("sex"));
|
|
|
tmp.put("photo", one.get("photo"));
|
|
|
tmp.put("idcard", one.get("idcard"));
|
|
|
tmp.put("number", one.get("number"));
|
|
|
tmp.put("id", one.get("orderId"));
|
|
|
tmp.put("serveDesc", one.get("serve_desc"));
|
|
|
Date date = (Date) one.get("create_time");
|
|
|
tmp.put("createTime", DateUtil.dateToStrLong(date));
|
|
|
tmp.put("status",one.get("status"));
|
|
|
tmp.put("doctor",one.get("doctor"));
|
|
|
tmp.put("doctorName",one.get("doctor_name"));
|
|
|
tmp.put("patientPhone",one.get("patient_phone"));
|
|
|
tmp.put("conclusionStatus",one.get("conclusion_status"));
|
|
|
Integer conclusionStatus = Integer.valueOf(one.get("conclusion_status")==null?"0":(one.get("conclusion_status")+""));
|
|
|
tmp.put("status", one.get("status"));
|
|
|
tmp.put("doctor", one.get("doctor"));
|
|
|
tmp.put("doctorName", one.get("doctor_name"));
|
|
|
tmp.put("patientPhone", one.get("patient_phone"));
|
|
|
tmp.put("conclusionStatus", one.get("conclusion_status"));
|
|
|
Integer conclusionStatus = Integer.valueOf(one.get("conclusion_status") == null ? "0" : (one.get("conclusion_status") + ""));
|
|
|
String conclusionStatusName = "";
|
|
|
switch (conclusionStatus){
|
|
|
case 1:conclusionStatusName="待补录";break;
|
|
|
case 2:conclusionStatusName="已登记";break;
|
|
|
switch (conclusionStatus) {
|
|
|
case 1:
|
|
|
conclusionStatusName = "待补录";
|
|
|
break;
|
|
|
case 2:
|
|
|
conclusionStatusName = "已登记";
|
|
|
break;
|
|
|
}
|
|
|
tmp.put("conclusionStatusName",conclusionStatusName);
|
|
|
Integer statustemp = Integer.valueOf(one.get("status")+"");
|
|
|
if (-2==statustemp||-1==statustemp){
|
|
|
tmp.put("doctor",one.get("update_user"));
|
|
|
tmp.put("doctorName",one.get("update_user_name"));
|
|
|
tmp.put("conclusionStatusName", conclusionStatusName);
|
|
|
Integer statustemp = Integer.valueOf(one.get("status") + "");
|
|
|
if (-2 == statustemp || -1 == statustemp) {
|
|
|
tmp.put("doctor", one.get("update_user"));
|
|
|
tmp.put("doctorName", one.get("update_user_name"));
|
|
|
}
|
|
|
String statusName = "";
|
|
|
switch (statustemp){
|
|
|
case -2:statusName="误警报";break;
|
|
|
case -1:statusName="已取消";break;
|
|
|
case 0:statusName="已完成";break;
|
|
|
case 1:statusName="预警中";break;
|
|
|
switch (statustemp) {
|
|
|
case -2:
|
|
|
statusName = "误警报";
|
|
|
break;
|
|
|
case -1:
|
|
|
statusName = "已取消";
|
|
|
break;
|
|
|
case 0:
|
|
|
statusName = "已完成";
|
|
|
break;
|
|
|
case 1:
|
|
|
statusName = "预警中";
|
|
|
break;
|
|
|
}
|
|
|
tmp.put("statusName",statusName);
|
|
|
Integer age = IdCardUtil.getAgeForIdcard(tmp.getString("idcard"));
|
|
|
tmp.put("age",age);
|
|
|
tmp.put("statusName", statusName);
|
|
|
Integer age = IdCardUtil.getAgeForIdcard(tmp.getString("idcard"));
|
|
|
tmp.put("age", age);
|
|
|
//患者设备
|
|
|
List<DevicePatientDevice> devices = patientDeviceDao.findAllByUser(tmp.get("patientCode").toString());
|
|
|
if (devices.size()>0){
|
|
|
tmp.put("deviceFlag","1");
|
|
|
}
|
|
|
else {
|
|
|
tmp.put("deviceFlag","0");
|
|
|
if (devices.size() > 0) {
|
|
|
tmp.put("deviceFlag", "1");
|
|
|
} else {
|
|
|
tmp.put("deviceFlag", "0");
|
|
|
}
|
|
|
result.add(tmp);
|
|
|
}
|
|
|
return PageEnvelop.getSuccessListWithPage("success",result,page,pageSize,count);
|
|
|
return PageEnvelop.getSuccessListWithPage("success", result, page, pageSize, count);
|
|
|
}
|
|
|
|
|
|
public JSONObject getSecurityTab(String patient,String doctor,String status,String svrDesc,String topicItem,Integer dailyMonitor){
|
|
|
public JSONObject getSecurityTab(String patient, String doctor, String status, String svrDesc, String topicItem, Integer dailyMonitor) {
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("status_-2",0);//误报警
|
|
|
result.put("status_-1",0);//已取消
|
|
|
result.put("status_0",0);//已完成
|
|
|
result.put("status_1",0);//预警中
|
|
|
result.put("status_all",0);//
|
|
|
result.put("svr_all",0);//
|
|
|
result.put("status_-2", 0);//误报警
|
|
|
result.put("status_-1", 0);//已取消
|
|
|
result.put("status_0", 0);//已完成
|
|
|
result.put("status_1", 0);//预警中
|
|
|
result.put("status_all", 0);//
|
|
|
result.put("svr_all", 0);//
|
|
|
|
|
|
Map<String,String> serverTmp = new HashMap<>();
|
|
|
Map<String, String> serverTmp = new HashMap<>();
|
|
|
|
|
|
String sql = " select py_code,dict_value from wlyy_hospital_sys_dict where dict_name='security_server_dict' ";
|
|
|
List<Map<String,Object>> servers = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> server:servers){
|
|
|
result.put("svr_"+server.get("py_code").toString(),0);
|
|
|
serverTmp.put(server.get("dict_value").toString(),server.get("py_code").toString());
|
|
|
List<Map<String, Object>> servers = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String, Object> server : servers) {
|
|
|
result.put("svr_" + server.get("py_code").toString(), 0);
|
|
|
serverTmp.put(server.get("dict_value").toString(), server.get("py_code").toString());
|
|
|
}
|
|
|
sql = "select ord.status,ord.serve_desc,count(ord.id) count from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " +
|
|
|
"where 1=1 ";
|
|
|
String fliter = " ";
|
|
|
if (1==dailyMonitor){//医生日常监护居民安防工单列表查询
|
|
|
if (StringUtils.isBlank(topicItem)||StringUtils.isBlank(doctor)){
|
|
|
if (1 == dailyMonitor) {//医生日常监护居民安防工单列表查询
|
|
|
if (StringUtils.isBlank(topicItem) || StringUtils.isBlank(doctor)) {
|
|
|
return result;
|
|
|
}
|
|
|
String categoryCode ="";
|
|
|
switch (topicItem){
|
|
|
String categoryCode = "";
|
|
|
switch (topicItem) {
|
|
|
case "preventLost":
|
|
|
categoryCode="'4'";
|
|
|
categoryCode = "'4'";
|
|
|
break;
|
|
|
case "preventFall":
|
|
|
categoryCode="'12'";
|
|
|
categoryCode = "'12'";
|
|
|
break;
|
|
|
case "preventFire":
|
|
|
categoryCode="'15'";
|
|
|
categoryCode = "'15'";
|
|
|
break;
|
|
|
case "preventGasLeakage":
|
|
|
categoryCode="'14'";
|
|
|
categoryCode = "'14'";
|
|
|
break;
|
|
|
case "preventOutOfBed":
|
|
|
categoryCode="'13'";
|
|
|
categoryCode = "'13'";
|
|
|
break;
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(doctor)) {//日常监护医生必传
|
|
@ -853,59 +874,58 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
fliter += " and EXISTS (select 1 from wlyy_patient_safe_area sf where sf.patient = p.id and sf.del=1 and sf.manage_status=1) ";
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
if (StringUtils.isNotBlank(doctor)){
|
|
|
fliter+=" and EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
|
|
|
} else {
|
|
|
if (StringUtils.isNotBlank(doctor)) {
|
|
|
fliter += " and EXISTS ( SELECT 1 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 = r.team_code and i.del = 1 and sr.`status`=1 and m.doctor_code = '"+doctor+"' and m.del = '1') ";
|
|
|
" r.service_package_id = i.service_package_id and m.team_code = r.team_code and i.del = 1 and sr.`status`=1 and m.doctor_code = '" + doctor + "' and m.del = '1') ";
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(patient)){
|
|
|
fliter+=" and ord.patient='"+patient+"' ";
|
|
|
if (StringUtils.isNotBlank(patient)) {
|
|
|
fliter += " and ord.patient='" + patient + "' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(status)){
|
|
|
fliter+=" and ord.status='"+Integer.parseInt(status)+"' ";
|
|
|
if (StringUtils.isNotBlank(status)) {
|
|
|
fliter += " and ord.status='" + Integer.parseInt(status) + "' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(svrDesc)){
|
|
|
fliter+=" and ord.serve_desc='"+svrDesc+"' ";
|
|
|
if (StringUtils.isNotBlank(svrDesc)) {
|
|
|
fliter += " and ord.serve_desc='" + svrDesc + "' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(topicItem)){
|
|
|
fliter+=" and ord.topic_item='"+topicItem+"' ";
|
|
|
if (StringUtils.isNotBlank(topicItem)) {
|
|
|
fliter += " and ord.topic_item='" + topicItem + "' ";
|
|
|
}
|
|
|
fliter+=" group by ord.status,ord.serve_desc ";
|
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql+fliter);
|
|
|
fliter += " group by ord.status,ord.serve_desc ";
|
|
|
List<Map<String, Object>> sqlResult = jdbcTemplate.queryForList(sql + fliter);
|
|
|
String pyCode = "";
|
|
|
for (Map<String,Object> map:sqlResult){
|
|
|
result.put("status_"+map.get("status"),result.getInteger("status_"+map.get("status"))+Integer.parseInt(map.get("count").toString()));
|
|
|
pyCode = serverTmp.get(map.get("serve_desc"))==null?null:serverTmp.get(map.get("serve_desc")).toString();
|
|
|
if (StringUtils.isNotBlank(pyCode)){
|
|
|
result.put("svr_"+pyCode,result.getInteger("svr_"+pyCode)+Integer.parseInt(map.get("count").toString()));
|
|
|
result.put("status_all",result.getInteger("status_all")+Integer.parseInt(map.get("count").toString()));
|
|
|
result.put("svr_all",result.getInteger("svr_all")+Integer.parseInt(map.get("count").toString()));
|
|
|
for (Map<String, Object> map : sqlResult) {
|
|
|
result.put("status_" + map.get("status"), result.getInteger("status_" + map.get("status")) + Integer.parseInt(map.get("count").toString()));
|
|
|
pyCode = serverTmp.get(map.get("serve_desc")) == null ? null : serverTmp.get(map.get("serve_desc")).toString();
|
|
|
if (StringUtils.isNotBlank(pyCode)) {
|
|
|
result.put("svr_" + pyCode, result.getInteger("svr_" + pyCode) + Integer.parseInt(map.get("count").toString()));
|
|
|
result.put("status_all", result.getInteger("status_all") + Integer.parseInt(map.get("count").toString()));
|
|
|
result.put("svr_all", result.getInteger("svr_all") + Integer.parseInt(map.get("count").toString()));
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> getSecurityOrderUnCompleteList(String doctor){
|
|
|
List<Map<String,Object>> result = new ArrayList<>();
|
|
|
public List<Map<String, Object>> getSecurityOrderUnCompleteList(String doctor) {
|
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
|
String sql = " select p.id patientCode,p.name,p.sex,p.idcard,p.photo,ord.id orderId,ord.number,ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time,ord.`status`,ord.doctor," +
|
|
|
"ord.doctor_name,ord.patient_phone,ord.conclusion_status from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " +
|
|
|
"where ord.status <>-1 and ord.status<>0 ";
|
|
|
sql+= "and EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
|
|
|
sql += "and EXISTS ( SELECT 1 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 = r.team_code and i.del = 1 and sr.`status`=1 and i.code='preventLost' and m.doctor_code = '"+doctor+"' and m.del = '1') ";
|
|
|
sql +=" order by ord.create_time asc ";
|
|
|
result= jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map:result){
|
|
|
if (map.get("idcard")==null){
|
|
|
map.put("age",null);
|
|
|
}
|
|
|
else{
|
|
|
Integer age = IdCardUtil.getAgeForIdcard(map.get("idcard").toString());
|
|
|
map.put("age",age);
|
|
|
" r.service_package_id = i.service_package_id and m.team_code = r.team_code and i.del = 1 and sr.`status`=1 and i.code='preventLost' and m.doctor_code = '" + doctor + "' and m.del = '1') ";
|
|
|
sql += " order by ord.create_time asc ";
|
|
|
result = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String, Object> map : result) {
|
|
|
if (map.get("idcard") == null) {
|
|
|
map.put("age", null);
|
|
|
} else {
|
|
|
Integer age = IdCardUtil.getAgeForIdcard(map.get("idcard").toString());
|
|
|
map.put("age", age);
|
|
|
}
|
|
|
|
|
|
}
|
|
@ -913,9 +933,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 系统更新医生工单状态
|
|
|
*
|
|
|
* @param doctor
|
|
|
* @param dispatchOrderStatus
|
|
|
*/
|
|
@ -937,7 +957,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
doctorStatusDao.save(doctorSwitch);
|
|
|
}
|
|
|
|
|
|
public SecurityMonitoringOrderDO acceptOrder1(String orderId,String doctor) throws Exception{
|
|
|
public SecurityMonitoringOrderDO acceptOrder1(String orderId, String doctor) throws Exception {
|
|
|
SecurityMonitoringOrderDO doorServiceOrder = securityMonitoringOrderDao.findOne(orderId);
|
|
|
if (null == doorServiceOrder) {
|
|
|
throw new Exception("该工单不存在");
|
|
@ -948,9 +968,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
|
|
|
securityMonitoringOrderDao.save(doorServiceOrder);
|
|
|
|
|
|
systemMessageDao.orderMessageDelByType(doorServiceOrder.getDoctor(),orderId,"607");
|
|
|
systemMessageDao.orderMessageDelByType(doorServiceOrder.getDoctor(), orderId, "607");
|
|
|
|
|
|
if(doorServiceOrder.getType() == null|| doorServiceOrder.getType() != 3) {
|
|
|
if (doorServiceOrder.getType() == null || doorServiceOrder.getType() != 3) {
|
|
|
|
|
|
// //获取咨询
|
|
|
// ConsultTeam consultTeam = consultTeamDao.queryByRelationCode(orderId);
|
|
@ -976,10 +996,11 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
|
|
|
/**
|
|
|
* 接单
|
|
|
*
|
|
|
* @param orderId
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public JSONObject acceptOrder(String orderId,String doctor) throws Exception {
|
|
|
public JSONObject acceptOrder(String orderId, String doctor) throws Exception {
|
|
|
// JSONObject result = new JSONObject();
|
|
|
// SecurityMonitoringOrderDO doorServiceOrderDO = securityMonitoringOrderDao.findOne(orderId);
|
|
|
// if(null == doorServiceOrderDO){
|
|
@ -1062,21 +1083,22 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
// 待接单消息设为已操作, 434 医生接单-- 王五接受了服务工单12345678
|
|
|
// messageUtil.createMessage("医生接单","634",doorServiceOrder.getPatient(),doorServiceOrder.getPatientName(),
|
|
|
// doorServiceOrder.getId(), doorServiceOrder.getDoctor(),doorServiceOrder.getDoctorName() ,null, doorServiceOrder.getDoctorName() + "接受了服务工单"+ doorServiceOrder.getNumber());
|
|
|
return getSecurityOrderDetail(orderId,null);
|
|
|
return getSecurityOrderDetail(orderId, null);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 取消工单
|
|
|
*
|
|
|
* @param orderId
|
|
|
* @param reason
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject cancelOrder(String orderId,int type,String reason,String doctor){
|
|
|
public JSONObject cancelOrder(String orderId, int type, String reason, String doctor) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
SecurityMonitoringOrderDO orderDO = securityMonitoringOrderDao.findOne(orderId);
|
|
|
if(null == orderDO){
|
|
|
String failMsg = "【取消工单】该工单不存在" ;
|
|
|
if (null == orderDO) {
|
|
|
String failMsg = "【取消工单】该工单不存在";
|
|
|
result.put("resultFlag", 0);
|
|
|
result.put("resultMsg", failMsg);
|
|
|
logger.error(failMsg);
|
|
@ -1084,24 +1106,24 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
}
|
|
|
//接单前可取消工单
|
|
|
BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
|
|
|
if (doctorDO==null){
|
|
|
if (doctorDO == null) {
|
|
|
String failMsg = "【取消工单】操作医生不存在";
|
|
|
result.put("resultFlag", 0);
|
|
|
result.put("resultMsg", failMsg);
|
|
|
logger.error(failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
if(orderDO.getStatus() == SecurityMonitoringOrderDO.Status.complete.getType()){
|
|
|
if (orderDO.getStatus() == SecurityMonitoringOrderDO.Status.complete.getType()) {
|
|
|
String failMsg = "当前工单已结束";
|
|
|
result.put("resultFlag", 0);
|
|
|
result.put("resultMsg", failMsg);
|
|
|
logger.error(failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
if (!consultTeamService.finishConsult(orderDO.getId(),orderDO.getPatient(),orderDO.getPatient(),1)){
|
|
|
if (!consultTeamService.finishConsult(orderDO.getId(), orderDO.getPatient(), orderDO.getPatient(), 1)) {
|
|
|
String failMsg = "咨询结束失败 无法取消工单";
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@ -1113,8 +1135,8 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
orderDO.setStatus(SecurityMonitoringOrderDO.Status.cancel.getType());
|
|
|
this.save(orderDO);
|
|
|
|
|
|
if(type == SecurityMonitoringOrderDO.CancelType.patient.getType()){ //居民取消,消息列表也应该不显示
|
|
|
messageUtil.updateSecurityMonitoringOrderMessage(orderDO,new String[]{"602","603"},"patientCancel");
|
|
|
if (type == SecurityMonitoringOrderDO.CancelType.patient.getType()) { //居民取消,消息列表也应该不显示
|
|
|
messageUtil.updateSecurityMonitoringOrderMessage(orderDO, new String[]{"602", "603"}, "patientCancel");
|
|
|
}
|
|
|
|
|
|
//保存取消记录
|
|
@ -1128,40 +1150,40 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
|
|
|
//完成工单向pc管理端发送消息
|
|
|
JSONObject message = new JSONObject();
|
|
|
String latLon = orderDO.getServeLat()+","+orderDO.getServeLon();
|
|
|
message.put("latLon",latLon);
|
|
|
message.put("session_id",orderDO.getSessionId());
|
|
|
message.put("sender_name",orderDO.getPatientName());
|
|
|
message.put("content_notice","完成安防服务工单");
|
|
|
message.put("sender_code",orderDO.getPatient());
|
|
|
message.put("OrderType",22);
|
|
|
message.put("OrderStatus","finish");
|
|
|
message.put("order_id",orderDO.getId());
|
|
|
message.put("content_type",40);
|
|
|
|
|
|
message.put("serverDesc",orderDO.getServeDesc());
|
|
|
message.put("categoryCode","");
|
|
|
message.put("orgType","");
|
|
|
message.put("contactStatus","");
|
|
|
message.put("residentialArea","");
|
|
|
|
|
|
if (null!=orderDO.getDeviceSn()){
|
|
|
String latLon = orderDO.getServeLat() + "," + orderDO.getServeLon();
|
|
|
message.put("latLon", latLon);
|
|
|
message.put("session_id", orderDO.getSessionId());
|
|
|
message.put("sender_name", orderDO.getPatientName());
|
|
|
message.put("content_notice", "完成安防服务工单");
|
|
|
message.put("sender_code", orderDO.getPatient());
|
|
|
message.put("OrderType", 22);
|
|
|
message.put("OrderStatus", "finish");
|
|
|
message.put("order_id", orderDO.getId());
|
|
|
message.put("content_type", 40);
|
|
|
|
|
|
message.put("serverDesc", orderDO.getServeDesc());
|
|
|
message.put("categoryCode", "");
|
|
|
message.put("orgType", "");
|
|
|
message.put("contactStatus", "");
|
|
|
message.put("residentialArea", "");
|
|
|
|
|
|
if (null != orderDO.getDeviceSn()) {
|
|
|
String device_sn = orderDO.getDeviceSn();
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(device_sn)){
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(device_sn)) {
|
|
|
DeviceDetail deviceDetail = deviceDetailDao.findBySn(device_sn);
|
|
|
if (null!=deviceDetail){
|
|
|
message.put("contactStatus",deviceDetail.getContactStatus());
|
|
|
message.put("categoryCode",deviceDetail.getCategoryCode());
|
|
|
if (null != deviceDetail) {
|
|
|
message.put("contactStatus", deviceDetail.getContactStatus());
|
|
|
message.put("categoryCode", deviceDetail.getCategoryCode());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
String orgCode = orderDO.getHospital();
|
|
|
BaseOrgDO orgDO = orgDao.findByCode(orgCode);
|
|
|
if (null!=orgDO){
|
|
|
message.put("orgType",orgDO.getType());
|
|
|
if (null != orgDO) {
|
|
|
message.put("orgType", orgDO.getType());
|
|
|
}
|
|
|
|
|
|
imUtil.sendPcManageMessageToPc("cloudCare_pcManage",message.toString());
|
|
|
imUtil.sendPcManageMessageToPc("cloudCare_pcManage", message.toString());
|
|
|
// Consult consult = consultDao.queryByRelationCode(orderId);
|
|
|
// // 发送微信模板消息,通知居民工单已取消(smyyyqx-上门预约已取消)
|
|
|
//
|
|
@ -1181,12 +1203,13 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
// }
|
|
|
// pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 30, patient.getOpenid(), patient.getName(), json);
|
|
|
|
|
|
result = getSecurityOrderDetail(orderId,null);
|
|
|
result = getSecurityOrderDetail(orderId, null);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 签到保存
|
|
|
*
|
|
|
* @param orderId
|
|
|
* @param signTime
|
|
|
* @param signWay
|
|
@ -1195,7 +1218,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject signIn(String orderId, String signTime, Integer signWay, String signLocation,
|
|
|
String signImg, String twoDimensionalCode,String doctorId) throws Exception {
|
|
|
String signImg, String twoDimensionalCode, String doctorId) throws Exception {
|
|
|
/* SecurityMonitoringOrderDO doorServiceOrder = securityMonitoringOrderDao.findOne(orderId);
|
|
|
doorServiceOrder.setDoctorSignTime(DateUtil.strToDate(signTime));
|
|
|
doorServiceOrder.setDoctorSignWay(signWay);
|
|
@ -1223,11 +1246,12 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
|
|
|
return getSecurityOrderDetail(orderId);
|
|
|
}*/
|
|
|
return getSecurityOrderDetail(orderId,null);
|
|
|
return getSecurityOrderDetail(orderId, null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据接单医生code获取最近一次服务orderId
|
|
|
*
|
|
|
* @param doctor
|
|
|
* @return
|
|
|
*/
|
|
@ -1239,31 +1263,32 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
|
|
|
/**
|
|
|
* 编辑保存服务工单小结
|
|
|
*
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject updateDoorConclusion(Integer emergency_reason,Integer treatment_status,String orderId,String conclusion,String conclusion_img,String doctor) throws Exception {
|
|
|
public JSONObject updateDoorConclusion(Integer emergency_reason, Integer treatment_status, String orderId, String conclusion, String conclusion_img, String doctor) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd"));
|
|
|
SecurityMonitoringOrderDO one = securityMonitoringOrderDao.findOne(orderId);
|
|
|
if (StringUtils.isNotBlank(doctor)){
|
|
|
if (StringUtils.isNotBlank(doctor)) {
|
|
|
BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
|
|
|
if (doctorDO!=null){
|
|
|
if (doctorDO != null) {
|
|
|
one.setDoctor(doctor);
|
|
|
one.setDoctorName(doctorDO.getName());
|
|
|
one.setUpdateUser(doctor);
|
|
|
one.setUpdateUserName(doctorDO.getName());
|
|
|
}
|
|
|
}
|
|
|
if (one==null){
|
|
|
String failMsg = "工单不存在" ;
|
|
|
if (one == null) {
|
|
|
String failMsg = "工单不存在";
|
|
|
result.put("resultFlag", 0);
|
|
|
result.put("resultMsg", failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
EmergencyWarnConclusionDO doorConclusion = emergencyWarnConclusionDao.findByOrderId(orderId);
|
|
|
if (doorConclusion==null){
|
|
|
EmergencyWarnConclusionDO doorConclusion = emergencyWarnConclusionDao.findByOrderId(orderId);
|
|
|
if (doorConclusion == null) {
|
|
|
doorConclusion = new EmergencyWarnConclusionDO();
|
|
|
doorConclusion.setOrderId(orderId);
|
|
|
doorConclusion.setPatient(one.getPatient());
|
|
@ -1286,7 +1311,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
doorConclusion.setCreateUser(one.getDoctor());
|
|
|
doorConclusion.setCreateUserName(null != doctorVO ? doctorVO.getName() : null);
|
|
|
}
|
|
|
if (!consultTeamService.finishConsult(one.getId(),one.getPatient(),one.getPatient(),1)){
|
|
|
if (!consultTeamService.finishConsult(one.getId(), one.getPatient(), one.getPatient(), 1)) {
|
|
|
String failMsg = "咨询结束失败 无法结束工单";
|
|
|
throw new Exception(failMsg);
|
|
|
}
|
|
@ -1297,66 +1322,67 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
|
|
|
//完成工单向pc管理端发送消息
|
|
|
JSONObject message = new JSONObject();
|
|
|
String latLon = one.getServeLat()+","+one.getServeLon();
|
|
|
message.put("latLon",latLon);
|
|
|
message.put("session_id",one.getSessionId());
|
|
|
message.put("sender_name",one.getPatientName());
|
|
|
message.put("content_notice","完成安防服务工单");
|
|
|
message.put("sender_code",one.getPatient());
|
|
|
message.put("OrderType",22);
|
|
|
message.put("OrderStatus","finish");
|
|
|
message.put("order_id",one.getId());
|
|
|
message.put("content_type",40);
|
|
|
|
|
|
message.put("serverDesc",one.getServeDesc());
|
|
|
message.put("categoryCode","");
|
|
|
message.put("orgType","");
|
|
|
message.put("contactStatus","");
|
|
|
message.put("residentialArea","");
|
|
|
|
|
|
if (null!=one.getDeviceSn()){
|
|
|
String latLon = one.getServeLat() + "," + one.getServeLon();
|
|
|
message.put("latLon", latLon);
|
|
|
message.put("session_id", one.getSessionId());
|
|
|
message.put("sender_name", one.getPatientName());
|
|
|
message.put("content_notice", "完成安防服务工单");
|
|
|
message.put("sender_code", one.getPatient());
|
|
|
message.put("OrderType", 22);
|
|
|
message.put("OrderStatus", "finish");
|
|
|
message.put("order_id", one.getId());
|
|
|
message.put("content_type", 40);
|
|
|
|
|
|
message.put("serverDesc", one.getServeDesc());
|
|
|
message.put("categoryCode", "");
|
|
|
message.put("orgType", "");
|
|
|
message.put("contactStatus", "");
|
|
|
message.put("residentialArea", "");
|
|
|
|
|
|
if (null != one.getDeviceSn()) {
|
|
|
String device_sn = one.getDeviceSn();
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(device_sn)){
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(device_sn)) {
|
|
|
DeviceDetail deviceDetail = deviceDetailDao.findBySn(device_sn);
|
|
|
if (null!=deviceDetail){
|
|
|
message.put("contactStatus",deviceDetail.getContactStatus());
|
|
|
message.put("categoryCode",deviceDetail.getCategoryCode());
|
|
|
if (null != deviceDetail) {
|
|
|
message.put("contactStatus", deviceDetail.getContactStatus());
|
|
|
message.put("categoryCode", deviceDetail.getCategoryCode());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
String orgCode = one.getHospital();
|
|
|
BaseOrgDO orgDO = orgDao.findByCode(orgCode);
|
|
|
if (null!=orgDO){
|
|
|
message.put("orgType",orgDO.getType());
|
|
|
if (null != orgDO) {
|
|
|
message.put("orgType", orgDO.getType());
|
|
|
}
|
|
|
|
|
|
imUtil.sendPcManageMessageToPc("cloudCare_pcManage",message.toString());
|
|
|
return getSecurityOrderDetail(orderId,null);
|
|
|
imUtil.sendPcManageMessageToPc("cloudCare_pcManage", message.toString());
|
|
|
return getSecurityOrderDetail(orderId, null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 跳过登记服务小结
|
|
|
*
|
|
|
* @param orderId
|
|
|
*/
|
|
|
public JSONObject cancelConclusion(String orderId,String doctor) throws Exception {
|
|
|
public JSONObject cancelConclusion(String orderId, String doctor) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
SecurityMonitoringOrderDO one = securityMonitoringOrderDao.findOne(orderId);
|
|
|
if (StringUtils.isNotBlank(doctor)){
|
|
|
if (StringUtils.isNotBlank(doctor)) {
|
|
|
BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
|
|
|
if (doctorDO!=null){
|
|
|
if (doctorDO != null) {
|
|
|
one.setDoctor(doctor);
|
|
|
one.setDoctorName(doctorDO.getName());
|
|
|
one.setUpdateUser(doctor);
|
|
|
one.setUpdateUserName(doctorDO.getName());
|
|
|
}
|
|
|
}
|
|
|
if (one==null){
|
|
|
String failMsg = "工单不存在" ;
|
|
|
if (one == null) {
|
|
|
String failMsg = "工单不存在";
|
|
|
result.put("resultFlag", 0);
|
|
|
result.put("resultMsg", failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
if (!consultTeamService.finishConsult(one.getId(),one.getPatient(),one.getPatient(),1)){
|
|
|
if (!consultTeamService.finishConsult(one.getId(), one.getPatient(), one.getPatient(), 1)) {
|
|
|
String failMsg = "咨询结束失败 无法结束工单";
|
|
|
throw new Exception(failMsg);
|
|
|
}
|
|
@ -1364,44 +1390,46 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
one.setUpdateTime(new Date());
|
|
|
securityMonitoringOrderDao.save(one);
|
|
|
|
|
|
return getSecurityOrderDetail(orderId,null);
|
|
|
return getSecurityOrderDetail(orderId, null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 统计居民已经服务的次数
|
|
|
*
|
|
|
* @param patient
|
|
|
* @return
|
|
|
*/
|
|
|
public Integer countPatientDoorTimes(String patient){
|
|
|
public Integer countPatientDoorTimes(String patient) {
|
|
|
Integer count = 0;
|
|
|
String sql = "SELECT count(o.id) as count FROM base_security_monitoring_order o where o.patient = '" + patient + "' and status>3 ";
|
|
|
count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
count = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
return count;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据orderId获取工单服务小结
|
|
|
*
|
|
|
* @param orderId
|
|
|
* @return
|
|
|
*/
|
|
|
public EmergencyWarnConclusionDO getDoorConclusion(String orderId){
|
|
|
public EmergencyWarnConclusionDO getDoorConclusion(String orderId) {
|
|
|
EmergencyWarnConclusionDO doorConclusion = emergencyWarnConclusionDao.findByOrderId(orderId);
|
|
|
SecurityMonitoringOrderDO one = securityMonitoringOrderDao.findOne(orderId);
|
|
|
if (doorConclusion==null&&one!=null) {
|
|
|
if (doorConclusion == null && one != null) {
|
|
|
doorConclusion = new EmergencyWarnConclusionDO();
|
|
|
doorConclusion.setOrderId(one.getId());
|
|
|
doorConclusion.setPatient(one.getPatient());
|
|
|
doorConclusion.setPatientName(one.getPatientName());
|
|
|
doorConclusion.setDoctor(one.getDoctor());
|
|
|
doorConclusion.setDoctorName(one.getDoctorName());
|
|
|
}else {
|
|
|
doorConclusion.setReasonName(dictService.fingByNameAndCode(ConstantUtil.DICT_EMERGENCY_REASON,String.valueOf(doorConclusion.getEmergencyReason())));
|
|
|
doorConclusion.setTreatmentStatusName(dictService.fingByNameAndCode(ConstantUtil.DICT_EMERGENCY_TREATMENT_STATUS,String.valueOf(doorConclusion.getEmergencyTreatmentStatus())));
|
|
|
} else {
|
|
|
doorConclusion.setReasonName(dictService.fingByNameAndCode(ConstantUtil.DICT_EMERGENCY_REASON, String.valueOf(doorConclusion.getEmergencyReason())));
|
|
|
doorConclusion.setTreatmentStatusName(dictService.fingByNameAndCode(ConstantUtil.DICT_EMERGENCY_TREATMENT_STATUS, String.valueOf(doorConclusion.getEmergencyTreatmentStatus())));
|
|
|
}
|
|
|
return doorConclusion;
|
|
|
}
|
|
|
|
|
|
public JSONObject saveOrderFinishBydoctor(String orderId ,String finishImg) throws Exception {
|
|
|
public JSONObject saveOrderFinishBydoctor(String orderId, String finishImg) throws Exception {
|
|
|
// SecurityMonitoringOrderDO one = securityMonitoringOrderDao.findOne(orderId);
|
|
|
// one.setDoctorConfirmFinishImg(finishImg);
|
|
|
// one.setStatus(SecurityMonitoringOrderDO.Status.complete.getType());
|
|
@ -1419,11 +1447,12 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
// // 发送微信通知 待付款
|
|
|
// BasePatientDO patient = basePatientDao.findById(one.getPatient());
|
|
|
|
|
|
return getSecurityOrderDetail(orderId,null);
|
|
|
return getSecurityOrderDetail(orderId, null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据id获取服务工单信息
|
|
|
*
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
@ -1435,7 +1464,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
BasePatientDO patient = basePatientDao.findById(doorServiceOrder.getPatient());
|
|
|
if (patient != null) {
|
|
|
String sex = IdCardUtil.getSexForIdcard_new(patient.getIdcard());
|
|
|
int age = IdCardUtil.getAgeByIdcardOrBirthday(patient.getIdcard(),patient.getBirthday());
|
|
|
int age = IdCardUtil.getAgeByIdcardOrBirthday(patient.getIdcard(), patient.getBirthday());
|
|
|
doorServiceOrder.setSex("1".equals(sex) ? "男" : "2".equals(sex) ? "女" : "未知");
|
|
|
doorServiceOrder.setAge(age);
|
|
|
doorServiceOrder.setPhoto(patient.getPhoto());
|
|
@ -1455,261 +1484,261 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
return doorServiceOrder;
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> getSecurityServerDoctor(String patient,String topicItem){
|
|
|
public List<Map<String, Object>> getSecurityServerDoctor(String patient, String topicItem) {
|
|
|
//获取患者签约防走失服务的团队
|
|
|
String sql="SELECT DISTINCT r.team_code from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i \n" +
|
|
|
String sql = "SELECT DISTINCT r.team_code 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 = '"+patient+"' and i.code='"+topicItem+"'";
|
|
|
List<String> teams = jdbcTemplate.queryForList(sql,String.class);
|
|
|
List<Map<String,Object>> result = new ArrayList<>();
|
|
|
if (teams.size()==0){
|
|
|
"and sr.patient = '" + patient + "' and i.code='" + topicItem + "'";
|
|
|
List<String> teams = jdbcTemplate.queryForList(sql, String.class);
|
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
|
if (teams.size() == 0) {
|
|
|
return new ArrayList<>();
|
|
|
}else {
|
|
|
for (String team:teams){
|
|
|
} else {
|
|
|
for (String team : teams) {
|
|
|
sql = "select DISTINCT doc.id doctor,doc.name as doctorName,CONCAT(doc.`name`,\n" +
|
|
|
"CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(社工)' END) as name,doc.photo,doc.mobile from base_team_member mem " +
|
|
|
"INNER JOIN base_doctor doc on mem.doctor_code = doc.id and mem.del=1 and mem.team_code='"+team+"'";
|
|
|
List<Map<String,Object>>tmp = jdbcTemplate.queryForList(sql);
|
|
|
"INNER JOIN base_doctor doc on mem.doctor_code = doc.id and mem.del=1 and mem.team_code='" + team + "'";
|
|
|
List<Map<String, Object>> tmp = jdbcTemplate.queryForList(sql);
|
|
|
result.addAll(tmp);
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject patientMonitoringInfo(String patient,String topicItem,boolean video){
|
|
|
public JSONObject patientMonitoringInfo(String patient, String topicItem,String deviceSn,boolean video) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("location",null);
|
|
|
result.put("fences",null);
|
|
|
result.put("gasLeakage",null);
|
|
|
result.put("fire",null);
|
|
|
result.put("fall",null);
|
|
|
result.put("sleep",null);
|
|
|
result.put("sleepOrderInfo",null);//最近工单
|
|
|
result.put("deviceSn",null);
|
|
|
result.put("emeAssistance",false);
|
|
|
result.put("monitorInfo",null);
|
|
|
result.put("location", null);
|
|
|
result.put("fences", null);
|
|
|
result.put("gasLeakage", null);
|
|
|
result.put("fire", null);
|
|
|
result.put("fall", null);
|
|
|
result.put("sleep", null);
|
|
|
result.put("sleepOrderInfo", null);//最近工单
|
|
|
result.put("deviceSn", deviceSn);
|
|
|
result.put("emeAssistance", false);
|
|
|
result.put("monitorInfo", null);
|
|
|
String sql = " select dict.code,count(ord.id) total from base_system_dict_entry dict LEFT JOIN base_security_monitoring_order ord " +
|
|
|
" on dict.code = ord.topic_item COLLATE utf8_unicode_ci and ord.status="+SecurityMonitoringOrderDO.Status.apply.getType()+" where dict.dict_code='service_item' " +
|
|
|
"and dict.remark='security' and ord.patient='"+patient+"' GROUP BY dict.code ";
|
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object>tmp:sqlResult){
|
|
|
switch (tmp.get("code").toString()){
|
|
|
" on dict.code = ord.topic_item COLLATE utf8_unicode_ci and ord.status=" + SecurityMonitoringOrderDO.Status.apply.getType() + " where dict.dict_code='service_item' " +
|
|
|
"and dict.remark='security' and ord.patient='" + patient + "' GROUP BY dict.code ";
|
|
|
List<Map<String, Object>> sqlResult = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String, Object> tmp : sqlResult) {
|
|
|
switch (tmp.get("code").toString()) {
|
|
|
case "preventGasLeakage":
|
|
|
Integer count = Integer.parseInt(tmp.get("total").toString());
|
|
|
if (count>0){
|
|
|
result.put("gasLeakage",true);
|
|
|
}else {
|
|
|
result.put("gasLeakage",false);
|
|
|
Integer count = Integer.parseInt(tmp.get("total").toString());
|
|
|
if (count > 0) {
|
|
|
result.put("gasLeakage", true);
|
|
|
} else {
|
|
|
result.put("gasLeakage", false);
|
|
|
}
|
|
|
break;
|
|
|
case "preventFire":
|
|
|
count = Integer.parseInt(tmp.get("total").toString());
|
|
|
if (count>0){
|
|
|
result.put("fire",true);
|
|
|
}else {
|
|
|
result.put("fire",false);
|
|
|
if (count > 0) {
|
|
|
result.put("fire", true);
|
|
|
} else {
|
|
|
result.put("fire", false);
|
|
|
}
|
|
|
break;
|
|
|
case "preventFall":
|
|
|
count = Integer.parseInt(tmp.get("total").toString());
|
|
|
if (count>0){
|
|
|
result.put("fall",true);
|
|
|
}else {
|
|
|
result.put("fall",false);
|
|
|
if (count > 0) {
|
|
|
result.put("fall", true);
|
|
|
} else {
|
|
|
result.put("fall", false);
|
|
|
}
|
|
|
break;
|
|
|
case "preventOutOfBed":
|
|
|
count = Integer.parseInt(tmp.get("total").toString());
|
|
|
if (count>0){
|
|
|
result.put("sleep",true);
|
|
|
if (count > 0) {
|
|
|
result.put("sleep", true);
|
|
|
sql = " select serve_desc from base_security_monitoring_order where topic_item='preventOutOfBed' " +
|
|
|
"and patient='"+patient+"' and `status`=1 order by create_time desc limit 1 ";
|
|
|
List<String> serveDesces = jdbcTemplate.queryForList(sql,String.class);
|
|
|
if (serveDesces.size()>0){
|
|
|
result.put("sleepOrderInfo",serveDesces.get(0));
|
|
|
"and patient='" + patient + "' and `status`=1 order by create_time desc limit 1 ";
|
|
|
List<String> serveDesces = jdbcTemplate.queryForList(sql, String.class);
|
|
|
if (serveDesces.size() > 0) {
|
|
|
result.put("sleepOrderInfo", serveDesces.get(0));
|
|
|
}
|
|
|
}else {
|
|
|
result.put("sleep",false);
|
|
|
} else {
|
|
|
result.put("sleep", false);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
sql = " select count(id) from base_emergency_assistance_order where patient='"+patient+"' and status="+ EmergencyAssistanceDO.Status.apply.getType();
|
|
|
Integer counnt = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
if (counnt>0){
|
|
|
result.put("emeAssistance",true);
|
|
|
sql = " select count(id) from base_emergency_assistance_order where patient='" + patient + "' and status=" + EmergencyAssistanceDO.Status.apply.getType();
|
|
|
Integer counnt = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
if (counnt > 0) {
|
|
|
result.put("emeAssistance", true);
|
|
|
}
|
|
|
result = patientSignTopicInfo(result,patient,topicItem,null,true);
|
|
|
result = patientSignTopicInfo(result, patient, topicItem, deviceSn, true);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*老人家属首页实时监护信息
|
|
|
* 老人家属首页实时监护信息
|
|
|
* 居家状态取手表 无手表缺省
|
|
|
* 监控
|
|
|
*/
|
|
|
public JSONObject patientMonitoringInfo2(String patient){
|
|
|
public JSONObject patientMonitoringInfo2(String patient) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("atHome",null);// 居家状态
|
|
|
result.put("location",null);
|
|
|
result.put("fences",null);
|
|
|
result.put("gasLeakage",null);
|
|
|
result.put("fire",null);
|
|
|
result.put("fall",null);
|
|
|
result.put("sleep",null);
|
|
|
result.put("sleepOrderInfo",null);//最近工单
|
|
|
result.put("deviceSn",null);
|
|
|
result.put("emeAssistance",false);
|
|
|
result.put("monitorInfo",null);
|
|
|
result.put("atHome", null);// 居家状态
|
|
|
result.put("location", null);
|
|
|
result.put("fences", null);
|
|
|
result.put("gasLeakage", null);
|
|
|
result.put("fire", null);
|
|
|
result.put("fall", null);
|
|
|
result.put("sleep", null);
|
|
|
result.put("sleepOrderInfo", null);//最近工单
|
|
|
result.put("deviceSn", null);
|
|
|
result.put("emeAssistance", false);
|
|
|
result.put("monitorInfo", null);
|
|
|
String sql = " select dict.code,count(ord.id) total from base_system_dict_entry dict LEFT JOIN base_security_monitoring_order ord " +
|
|
|
" on dict.code = ord.topic_item COLLATE utf8_unicode_ci and ord.status="+SecurityMonitoringOrderDO.Status.apply.getType()+" where dict.dict_code='service_item' " +
|
|
|
"and dict.remark='security' and ord.patient='"+patient+"' GROUP BY dict.code ";
|
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object>tmp:sqlResult){
|
|
|
switch (tmp.get("code").toString()){
|
|
|
" on dict.code = ord.topic_item COLLATE utf8_unicode_ci and ord.status=" + SecurityMonitoringOrderDO.Status.apply.getType() + " where dict.dict_code='service_item' " +
|
|
|
"and dict.remark='security' and ord.patient='" + patient + "' GROUP BY dict.code ";
|
|
|
List<Map<String, Object>> sqlResult = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String, Object> tmp : sqlResult) {
|
|
|
switch (tmp.get("code").toString()) {
|
|
|
case "preventGasLeakage":
|
|
|
Integer count = Integer.parseInt(tmp.get("total").toString());
|
|
|
if (count>0){
|
|
|
result.put("gasLeakage",true);
|
|
|
}else {
|
|
|
result.put("gasLeakage",false);
|
|
|
if (count > 0) {
|
|
|
result.put("gasLeakage", true);
|
|
|
} else {
|
|
|
result.put("gasLeakage", false);
|
|
|
}
|
|
|
break;
|
|
|
case "preventFire":
|
|
|
count = Integer.parseInt(tmp.get("total").toString());
|
|
|
if (count>0){
|
|
|
result.put("fire",true);
|
|
|
}else {
|
|
|
result.put("fire",false);
|
|
|
if (count > 0) {
|
|
|
result.put("fire", true);
|
|
|
} else {
|
|
|
result.put("fire", false);
|
|
|
}
|
|
|
break;
|
|
|
case "preventFall":
|
|
|
count = Integer.parseInt(tmp.get("total").toString());
|
|
|
if (count>0){
|
|
|
result.put("fall",true);
|
|
|
}else {
|
|
|
result.put("fall",false);
|
|
|
if (count > 0) {
|
|
|
result.put("fall", true);
|
|
|
} else {
|
|
|
result.put("fall", false);
|
|
|
}
|
|
|
break;
|
|
|
case "preventOutOfBed":
|
|
|
count = Integer.parseInt(tmp.get("total").toString());
|
|
|
if (count>0){
|
|
|
result.put("sleep",true);
|
|
|
if (count > 0) {
|
|
|
result.put("sleep", true);
|
|
|
sql = " select serve_desc from base_security_monitoring_order where topic_item='preventOutOfBed' " +
|
|
|
"and patient='"+patient+"' and `status`=1 order by create_time desc limit 1 ";
|
|
|
List<String> serveDesces = jdbcTemplate.queryForList(sql,String.class);
|
|
|
if (serveDesces.size()>0){
|
|
|
result.put("sleepOrderInfo",serveDesces.get(0));
|
|
|
"and patient='" + patient + "' and `status`=1 order by create_time desc limit 1 ";
|
|
|
List<String> serveDesces = jdbcTemplate.queryForList(sql, String.class);
|
|
|
if (serveDesces.size() > 0) {
|
|
|
result.put("sleepOrderInfo", serveDesces.get(0));
|
|
|
}
|
|
|
}else {
|
|
|
result.put("sleep",false);
|
|
|
} else {
|
|
|
result.put("sleep", false);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
sql = " select count(id) from base_emergency_assistance_order where patient='"+patient+"' and status="+ EmergencyAssistanceDO.Status.apply.getType();
|
|
|
Integer counnt = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
if (counnt>0){
|
|
|
result.put("emeAssistance",true);
|
|
|
sql = " select count(id) from base_emergency_assistance_order where patient='" + patient + "' and status=" + EmergencyAssistanceDO.Status.apply.getType();
|
|
|
Integer counnt = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
if (counnt > 0) {
|
|
|
result.put("emeAssistance", true);
|
|
|
}
|
|
|
List<DevicePatientDevice> devices4 = patientDeviceDao.findByUserAndCategoryCode(patient,"4");//手表
|
|
|
if (devices4.size()>0){
|
|
|
result = patientSignTopicInfo(result,patient,"preventLost",devices4.get(0).getDeviceSn(),true);
|
|
|
List<DevicePatientDevice> devices4 = patientDeviceDao.findByUserAndCategoryCode(patient, "4");//手表
|
|
|
if (devices4.size() > 0) {
|
|
|
result = patientSignTopicInfo(result, patient, "preventLost", devices4.get(0).getDeviceSn(), true);
|
|
|
}
|
|
|
patientSignTopicInfo(result,patient,"preventFall",null,true);
|
|
|
patientSignTopicInfo(result, patient, "preventFall", null, true);
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public void preventLost(JSONObject result,String patient,String deviceSn){
|
|
|
public void preventLost(JSONObject result, String patient, String deviceSn) {
|
|
|
//手表与拐杖同时绑定时优先手表,围栏状态其中一个超出围栏即为超出围栏
|
|
|
try {
|
|
|
Integer categoryCode=0;//未指定设备
|
|
|
Integer categoryCode = 0;//未指定设备
|
|
|
List<DevicePatientDevice> devicePatientDeviceDos = new ArrayList<>();
|
|
|
List<DevicePatientDevice> devicePatientDeviceDos2 = new ArrayList<>();
|
|
|
if (StringUtils.isNotBlank(deviceSn)){//查看指定设备详情
|
|
|
if (StringUtils.isNotBlank(deviceSn)) {//查看指定设备详情
|
|
|
List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSn(deviceSn);
|
|
|
if (devices.size()>0){
|
|
|
String categoryCodeTmp = devices.get(0).getCategoryCode();
|
|
|
categoryCode = StringUtils.isBlank(categoryCodeTmp)?-1:Integer.parseInt(categoryCodeTmp);
|
|
|
if (4==categoryCode){
|
|
|
if (devices.size() > 0) {
|
|
|
String categoryCodeTmp = devices.get(0).getCategoryCode();
|
|
|
categoryCode = StringUtils.isBlank(categoryCodeTmp) ? -1 : Integer.parseInt(categoryCodeTmp);
|
|
|
if (4 == categoryCode) {
|
|
|
devicePatientDeviceDos = devices;
|
|
|
}
|
|
|
if (16==categoryCode){
|
|
|
if (16 == categoryCode) {
|
|
|
devicePatientDeviceDos2 = devices;
|
|
|
}
|
|
|
}
|
|
|
}else {//未指定设备
|
|
|
devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"4");//手表
|
|
|
devicePatientDeviceDos2 = patientDeviceDao.findByUserAndCategoryCode(patient,"16");//拐杖
|
|
|
} else {//未指定设备
|
|
|
devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient, "4");//手表
|
|
|
devicePatientDeviceDos2 = patientDeviceDao.findByUserAndCategoryCode(patient, "16");//拐杖
|
|
|
}
|
|
|
if (devicePatientDeviceDos.size()>0&&(4==categoryCode||0==categoryCode)){//手表
|
|
|
if (devicePatientDeviceDos.size() > 0 && (4 == categoryCode || 0 == categoryCode)) {//手表
|
|
|
DevicePatientDevice device = devicePatientDeviceDos.get(0);
|
|
|
result.put("deviceSn",device.getDeviceSn());
|
|
|
JSONObject response= patientDeviceService.getAqgDeviceInfo2(device.getDeviceSn());
|
|
|
if (response!=null){
|
|
|
result.put("deviceSn", device.getDeviceSn());
|
|
|
JSONObject response = patientDeviceService.getAqgDeviceInfo2(device.getDeviceSn());
|
|
|
if (response != null) {
|
|
|
//定位信息
|
|
|
if (response.containsKey("last_location")&&response.get("last_location")!=null){
|
|
|
if (response.containsKey("last_location") && response.get("last_location") != null) {
|
|
|
JSONObject locationTmp = response.getJSONObject("last_location");
|
|
|
Double lon = locationTmp.getJSONArray("coordinates").getDouble(0);
|
|
|
Double lat = locationTmp.getJSONArray("coordinates").getDouble(1);
|
|
|
if (!response.getBoolean("online")){//设备离线 取居民表定位
|
|
|
result.put("X1online",false);
|
|
|
}else {
|
|
|
result.put("X1online",true);
|
|
|
if (!response.getBoolean("online")) {//设备离线 取居民表定位
|
|
|
result.put("X1online", false);
|
|
|
} else {
|
|
|
result.put("X1online", true);
|
|
|
}
|
|
|
JSONObject tmp = gpsUtil.gcj02_To_Bd09(lat,lon);
|
|
|
tmp.put("city",response.getString("last_city"));
|
|
|
tmp.put("province",response.getString("last_province"));
|
|
|
tmp.put("address",response.getString("last_address"));
|
|
|
result.put("location",tmp);
|
|
|
JSONObject tmp = gpsUtil.gcj02_To_Bd09(lat, lon);
|
|
|
tmp.put("city", response.getString("last_city"));
|
|
|
tmp.put("province", response.getString("last_province"));
|
|
|
tmp.put("address", response.getString("last_address"));
|
|
|
result.put("location", tmp);
|
|
|
BasePatientDO patientDO = basePatientDao.findById(patient);
|
|
|
if (null != patientDO){
|
|
|
if (StringUtils.isNotBlank(patientDO.getHomeLatLon())){
|
|
|
if (null != patientDO) {
|
|
|
if (StringUtils.isNotBlank(patientDO.getHomeLatLon())) {
|
|
|
String homeLatLon = patientDO.getHomeLatLon();
|
|
|
double homeLat = Double.parseDouble( homeLatLon.split(",")[0]);
|
|
|
double homeLon = Double.parseDouble( homeLatLon.split(",")[1]);
|
|
|
double homeDistance = countDistance.getDistance(result.getJSONObject("location").getDouble("lat"),result.getJSONObject("location").getDouble("lon"),
|
|
|
homeLat,homeLon);
|
|
|
if (homeDistance>50*1000){
|
|
|
result.put("atHome",false);
|
|
|
}else {
|
|
|
result.put("atHome",true);
|
|
|
double homeLat = Double.parseDouble(homeLatLon.split(",")[0]);
|
|
|
double homeLon = Double.parseDouble(homeLatLon.split(",")[1]);
|
|
|
double homeDistance = countDistance.getDistance(result.getJSONObject("location").getDouble("lat"), result.getJSONObject("location").getDouble("lon"),
|
|
|
homeLat, homeLon);
|
|
|
if (homeDistance > 50 * 1000) {
|
|
|
result.put("atHome", false);
|
|
|
} else {
|
|
|
result.put("atHome", true);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//围栏信息
|
|
|
if (response.containsKey("fences")&&response.get("fences")!=null){
|
|
|
if (response.containsKey("fences") && response.get("fences") != null) {
|
|
|
JSONArray fencesArr = response.getJSONArray("fences");
|
|
|
JSONArray fencesEnables = new JSONArray();
|
|
|
for (int i=0;i<fencesArr.size();i++){
|
|
|
for (int i = 0; i < fencesArr.size(); i++) {
|
|
|
JSONObject tmp = fencesArr.getJSONObject(i);
|
|
|
if (tmp.getBooleanValue("enable")){//围栏生效
|
|
|
if (tmp.getBooleanValue("enable")) {//围栏生效
|
|
|
JSONObject fenceTmp = new JSONObject();
|
|
|
fenceTmp.put("fenceNO",tmp.getInteger("seqid").toString());
|
|
|
fenceTmp.put("name",tmp.getString("name"));
|
|
|
fenceTmp.put("fenceNO", tmp.getInteger("seqid").toString());
|
|
|
fenceTmp.put("name", tmp.getString("name"));
|
|
|
JSONArray fenceLocationTmp = tmp.getJSONObject("safe_area").getJSONArray("coordinates").getJSONArray(0);
|
|
|
JSONArray fenceLocation = new JSONArray();
|
|
|
for (int j=0;j<fenceLocationTmp.size();j++){
|
|
|
for (int j = 0; j < fenceLocationTmp.size(); j++) {
|
|
|
Double lon = fenceLocationTmp.getJSONArray(j).getDouble(0);
|
|
|
Double lat = fenceLocationTmp.getJSONArray(j).getDouble(1);
|
|
|
JSONObject positionTmp = gpsUtil.gcj02_To_Bd09(lat,lon);
|
|
|
JSONObject positionTmp = gpsUtil.gcj02_To_Bd09(lat, lon);
|
|
|
fenceLocation.add(positionTmp);
|
|
|
}
|
|
|
fenceTmp.put("location",fenceLocation);
|
|
|
fenceTmp.put("inFenceStatus",countDistance.isInPolygon(result.getJSONObject("location").getDouble("lon"),result.getJSONObject("location").getDouble("lat"),fenceLocation));
|
|
|
fenceTmp.put("location", fenceLocation);
|
|
|
fenceTmp.put("inFenceStatus", countDistance.isInPolygon(result.getJSONObject("location").getDouble("lon"), result.getJSONObject("location").getDouble("lat"), fenceLocation));
|
|
|
fencesEnables.add(fenceTmp);
|
|
|
}
|
|
|
}
|
|
|
if (fencesEnables.size()>0){
|
|
|
result.put("fences",fencesEnables);
|
|
|
if (fencesEnables.size() > 0) {
|
|
|
result.put("fences", fencesEnables);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (devicePatientDeviceDos2.size()>0&&(16==categoryCode||0==categoryCode)) {//拐杖
|
|
|
if (devicePatientDeviceDos2.size() > 0 && (16 == categoryCode || 0 == categoryCode)) {//拐杖
|
|
|
DevicePatientDevice deviceDO = devicePatientDeviceDos2.get(0);
|
|
|
double dulat = 0l;
|
|
|
double dulon = 0l;
|
|
@ -1738,8 +1767,8 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
}
|
|
|
if (!(dulat == 0.0 && dulon == 0.0)) {
|
|
|
List<PatientSafeAreaDO> safeAreaDOS = safeAreaDao.findByPatient(deviceDO.getUser());
|
|
|
String safeArea=null;
|
|
|
if (safeAreaDOS.size()>0){
|
|
|
String safeArea = null;
|
|
|
if (safeAreaDOS.size() > 0) {
|
|
|
safeArea = safeAreaDOS.get(0).getSafeAreaGz();
|
|
|
}
|
|
|
JSONArray fenceLocation = new JSONArray();
|
|
@ -1755,7 +1784,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
positionTmp.put("lon", areaLon);
|
|
|
fenceLocation.add(positionTmp);
|
|
|
}
|
|
|
if (devicePatientDeviceDos2.size() > 0 && 0 == categoryCode && devicePatientDeviceDos2.size()>0) {
|
|
|
if (devicePatientDeviceDos2.size() > 0 && 0 == categoryCode && devicePatientDeviceDos2.size() > 0) {
|
|
|
JSONObject obj = result.getJSONArray("fences").getJSONObject(0);
|
|
|
if (obj.getBooleanValue("inFenceStatus")) {
|
|
|
if (!countDistance.isInPolygon(dulon, dulat, fenceLocation)) {
|
|
@ -1766,87 +1795,86 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
obj.put("lat", dulat);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if(devicePatientDeviceDos2.size() > 0) {//指定拐杖设备
|
|
|
} else if (devicePatientDeviceDos2.size() > 0) {//指定拐杖设备
|
|
|
if (StringUtils.isNotBlank(safeArea)) {
|
|
|
result.put("deviceSn", deviceDO.getDeviceSn());
|
|
|
JSONObject location = new JSONObject();
|
|
|
location.put("address",address);
|
|
|
location.put("province","");
|
|
|
location.put("city","");
|
|
|
location.put("lon",dulon);
|
|
|
location.put("lat",dulat);
|
|
|
result.put("location",location);
|
|
|
location.put("address", address);
|
|
|
location.put("province", "");
|
|
|
location.put("city", "");
|
|
|
location.put("lon", dulon);
|
|
|
location.put("lat", dulat);
|
|
|
result.put("location", location);
|
|
|
JSONArray fences = new JSONArray();
|
|
|
JSONObject fence = new JSONObject();
|
|
|
fence.put("fenceNO","1");
|
|
|
fence.put("name","安全区域1");
|
|
|
fence.put("fenceNO", "1");
|
|
|
fence.put("name", "安全区域1");
|
|
|
fence.put("inFenceStatus", countDistance.isInPolygon(dulon, dulat, fenceLocation));
|
|
|
fence.put("location", fenceLocation);
|
|
|
fences.add(fence);
|
|
|
result.put("fences",fences);
|
|
|
result.put("fences", fences);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
result.put("location",null);
|
|
|
result.put("location", null);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void preventOutOfBed(JSONObject result,String patient,boolean video,String dayTime){
|
|
|
List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"13");
|
|
|
if (devicePatientDeviceDos.size()==0){}
|
|
|
else {
|
|
|
public void preventOutOfBed(JSONObject result, String patient, boolean video, String dayTime) {
|
|
|
List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient, "13");
|
|
|
if (devicePatientDeviceDos.size() == 0) {
|
|
|
} else {
|
|
|
DevicePatientDevice deviceDo = devicePatientDeviceDos.get(0);
|
|
|
JSONObject deviceInfo = patientDeviceService.getSleepDeviceInfo(deviceDo.getDeviceSn());
|
|
|
if(deviceInfo.getBooleanValue("success")){
|
|
|
result.put("patientAddress",deviceDo.getSosAddress());
|
|
|
JSONObject deviceInfo = patientDeviceService.getSleepDeviceInfo(deviceDo.getDeviceSn());
|
|
|
if (deviceInfo.getBooleanValue("success")) {
|
|
|
result.put("patientAddress", deviceDo.getSosAddress());
|
|
|
JSONArray objInfo = deviceInfo.getJSONArray("objs");
|
|
|
if (objInfo.size()>0){
|
|
|
result.put("sleepStatus",true);
|
|
|
if (objInfo.size() > 0) {
|
|
|
result.put("sleepStatus", true);
|
|
|
JSONObject tmp = objInfo.getJSONObject(0);
|
|
|
JSONObject sleepInfo = new JSONObject();
|
|
|
if (StringUtils.isBlank(dayTime)){
|
|
|
dayTime = getSleepMonitoringDay(new Date(),patient);
|
|
|
if (StringUtils.isBlank(dayTime)) {
|
|
|
dayTime = getSleepMonitoringDay(new Date(), patient);
|
|
|
}
|
|
|
List<BaseSleepPlanDetail> planDetails = sleepPlanDetailDao.findByPatientAndDay(patient,dayTime);
|
|
|
List<BaseSleepPlanDetail> planDetails = sleepPlanDetailDao.findByPatientAndDay(patient, dayTime);
|
|
|
BaseSleepPlanDetail planDetail = new BaseSleepPlanDetail();
|
|
|
if (planDetails.size()>0){
|
|
|
planDetail = planDetails.get(0);
|
|
|
List<BaseSleepNightRecord> sleepNightRecordList = nightRecordDao.findByPatientAndDayOrderByCreateTimeDesc(patient,dayTime);
|
|
|
if (planDetails.size() > 0) {
|
|
|
planDetail = planDetails.get(0);
|
|
|
List<BaseSleepNightRecord> sleepNightRecordList = nightRecordDao.findByPatientAndDayOrderByCreateTimeDesc(patient, dayTime);
|
|
|
planDetail.setSleepNightRecordList(sleepNightRecordList);
|
|
|
}
|
|
|
String jsonStr = JSON.toJSONStringWithDateFormat(planDetail, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue);
|
|
|
sleepInfo = JSONObject.parseObject(jsonStr);
|
|
|
sleepInfo.put("day",dayTime);
|
|
|
sleepInfo.put("day", dayTime);
|
|
|
List<BaseSleepPlan> sleepPlans = sleepPlanDao.findByPatient(patient);
|
|
|
if (sleepPlans.size()>0){
|
|
|
if (sleepPlans.size() > 0) {
|
|
|
BaseSleepPlan sleepPlan = sleepPlans.get(0);
|
|
|
String endTime = DateUtil.getNextMin(sleepPlan.getGetUpTime(),-1);
|
|
|
sleepInfo.put("sleepPlan",true);
|
|
|
sleepInfo.put("getUpTime",sleepPlan.getGetUpTime());
|
|
|
sleepInfo.put("siestaTime",sleepPlan.getNapTime());
|
|
|
sleepInfo.put("nightRestTime",sleepPlan.getNightRestTime());
|
|
|
sleepInfo.put("nightRecordTime",sleepPlan.getNightRestTime()+"-隔日"+endTime);
|
|
|
}else {
|
|
|
sleepInfo.put("sleepPlan",false);
|
|
|
String endTime = DateUtil.getNextMin(sleepPlan.getGetUpTime(), -1);
|
|
|
sleepInfo.put("sleepPlan", true);
|
|
|
sleepInfo.put("getUpTime", sleepPlan.getGetUpTime());
|
|
|
sleepInfo.put("siestaTime", sleepPlan.getNapTime());
|
|
|
sleepInfo.put("nightRestTime", sleepPlan.getNightRestTime());
|
|
|
sleepInfo.put("nightRecordTime", sleepPlan.getNightRestTime() + "-隔日" + endTime);
|
|
|
} else {
|
|
|
sleepInfo.put("sleepPlan", false);
|
|
|
}
|
|
|
sleepInfo.put("online",tmp.getBooleanValue("online"));
|
|
|
if(tmp.getBooleanValue("onbed")){
|
|
|
sleepInfo.put("bedStatus",1);
|
|
|
sleepInfo.put("heartRate",tmp.getString("heartrate"));
|
|
|
sleepInfo.put("breath",tmp.getString("breathrate"));
|
|
|
}else {
|
|
|
sleepInfo.put("bedStatus",0);
|
|
|
sleepInfo.put("heartRate",null);
|
|
|
sleepInfo.put("breath",null);
|
|
|
sleepInfo.put("online", tmp.getBooleanValue("online"));
|
|
|
if (tmp.getBooleanValue("onbed")) {
|
|
|
sleepInfo.put("bedStatus", 1);
|
|
|
sleepInfo.put("heartRate", tmp.getString("heartrate"));
|
|
|
sleepInfo.put("breath", tmp.getString("breathrate"));
|
|
|
} else {
|
|
|
sleepInfo.put("bedStatus", 0);
|
|
|
sleepInfo.put("heartRate", null);
|
|
|
sleepInfo.put("breath", null);
|
|
|
}
|
|
|
BasePatientOutBed outBed = outBedDao.findByPatientAndDeviceSnAndStatus(patient,deviceDo.getDeviceSn(),0);
|
|
|
if (null!=outBed){
|
|
|
BasePatientOutBed outBed = outBedDao.findByPatientAndDeviceSnAndStatus(patient, deviceDo.getDeviceSn(), 0);
|
|
|
if (null != outBed) {
|
|
|
String outBedTime = "";
|
|
|
Date date = new Date();
|
|
|
long millisecondsDiff = date.getTime() - outBed.getCreateTime().getTime();
|
|
@ -1856,131 +1884,129 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
if (hoursDiff > 0L) {
|
|
|
outBedTime += String.format("%d小时", hoursDiff);
|
|
|
}
|
|
|
if (minuteFieldDiff>0){
|
|
|
outBedTime +=String.format("%d分钟", minuteFieldDiff);
|
|
|
if (minuteFieldDiff > 0) {
|
|
|
outBedTime += String.format("%d分钟", minuteFieldDiff);
|
|
|
}
|
|
|
sleepInfo.put("outBedTimeCrzq",outBed.getCreateTime());
|
|
|
sleepInfo.put("outBedTime",outBedTime);
|
|
|
}else {
|
|
|
sleepInfo.put("outBedTime","无");
|
|
|
sleepInfo.put("outBedTimeCrzq", outBed.getCreateTime());
|
|
|
sleepInfo.put("outBedTime", outBedTime);
|
|
|
} else {
|
|
|
sleepInfo.put("outBedTime", "无");
|
|
|
}
|
|
|
result.put("sleepInfo",sleepInfo);
|
|
|
result.put("sleepInfo", sleepInfo);
|
|
|
}
|
|
|
}else {
|
|
|
result.put("sleepStatus",false);
|
|
|
result.put("sleepInfo","获取睡眠带数据失败");
|
|
|
} else {
|
|
|
result.put("sleepStatus", false);
|
|
|
result.put("sleepInfo", "获取睡眠带数据失败");
|
|
|
}
|
|
|
}
|
|
|
if (video){
|
|
|
if (video) {
|
|
|
monitorInfo(result, patient);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void preventFire(JSONObject result,String patient,String deviceSn,boolean video){
|
|
|
public void preventFire(JSONObject result, String patient, String deviceSn, boolean video) {
|
|
|
String sql = "SELECT r.value from wlyy_patient_device pd,base_device_health_index r " +
|
|
|
"WHERE pd.device_sn = r.device_sn ";
|
|
|
if (StringUtils.isNotBlank(patient)){
|
|
|
sql+=" and pd.`user` = '"+patient+"' ";
|
|
|
if (StringUtils.isNotBlank(patient)) {
|
|
|
sql += " and pd.`user` = '" + patient + "' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(deviceSn)){
|
|
|
sql+=" and r.device_sn = '"+deviceSn+"' ";
|
|
|
if (StringUtils.isNotBlank(deviceSn)) {
|
|
|
sql += " and r.device_sn = '" + deviceSn + "' ";
|
|
|
}
|
|
|
|
|
|
sql += " and pd.category_code='15' ORDER BY r.create_time desc LIMIT 1";
|
|
|
|
|
|
List<Map<String,Object>> list1 = jdbcTemplate.queryForList(sql);
|
|
|
if(list1.size()==0){
|
|
|
result.put("smoke","-1");
|
|
|
}else{
|
|
|
result.put("smoke",list1.get(0).get("value"));
|
|
|
List<Map<String, Object>> list1 = jdbcTemplate.queryForList(sql);
|
|
|
if (list1.size() == 0) {
|
|
|
result.put("smoke", "-1");
|
|
|
} else {
|
|
|
result.put("smoke", list1.get(0).get("value"));
|
|
|
}
|
|
|
result.put("smokeOrderNum",getOrder(patient,"preventFire"));
|
|
|
if (video){
|
|
|
result.put("smokeOrderNum", getOrder(patient, "preventFire"));
|
|
|
if (video) {
|
|
|
monitorInfo(result, patient);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public Integer getOrder(String patient,String topicItem){
|
|
|
public Integer getOrder(String patient, String topicItem) {
|
|
|
String sql = "select count(1) from base_security_monitoring_order " +
|
|
|
"WHERE patient = '"+patient+"' and `status` = 1 and topic_item = '"+topicItem+"'";
|
|
|
Integer num = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
"WHERE patient = '" + patient + "' and `status` = 1 and topic_item = '" + topicItem + "'";
|
|
|
Integer num = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
return num;
|
|
|
}
|
|
|
|
|
|
public void preventGasLeakage(JSONObject result,String patient,boolean video){
|
|
|
public void preventGasLeakage(JSONObject result, String patient, boolean video) {
|
|
|
String sql = "SELECT r.value from wlyy_patient_device pd,base_device_health_index r " +
|
|
|
"WHERE pd.device_sn = r.device_sn and pd.`user` = '"+patient+"' ";
|
|
|
"WHERE pd.device_sn = r.device_sn and pd.`user` = '" + patient + "' ";
|
|
|
sql += " and pd.category_code='14' ORDER BY r.create_time desc LIMIT 1";
|
|
|
|
|
|
List<Map<String,Object>> list1 = jdbcTemplate.queryForList(sql);
|
|
|
if(list1.size()==0){
|
|
|
result.put("methane","-1");
|
|
|
}else{
|
|
|
result.put("methane",list1.get(0).get("value"));
|
|
|
List<Map<String, Object>> list1 = jdbcTemplate.queryForList(sql);
|
|
|
if (list1.size() == 0) {
|
|
|
result.put("methane", "-1");
|
|
|
} else {
|
|
|
result.put("methane", list1.get(0).get("value"));
|
|
|
}
|
|
|
result.put("methaneOrderNum",getOrder(patient,"preventGasLeakage"));
|
|
|
if (video){
|
|
|
result.put("methaneOrderNum", getOrder(patient, "preventGasLeakage"));
|
|
|
if (video) {
|
|
|
monitorInfo(result, patient);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void monitorInfo(JSONObject result,String patient){
|
|
|
public void monitorInfo(JSONObject result, String patient) {
|
|
|
//监控
|
|
|
List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"12");
|
|
|
if (devicePatientDeviceDos.size()==0){
|
|
|
List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient, "12");
|
|
|
if (devicePatientDeviceDos.size() == 0) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
DevicePatientDevice deviceDo = devicePatientDeviceDos.get(0);
|
|
|
JSONObject monitorUrl = ysDeviceServicel.getDeviceLiveAddress(patient,deviceDo.getDeviceSn(),1,null);
|
|
|
result.put("monitorInfoStatus",monitorUrl.getIntValue(ResponseContant.resultFlag));
|
|
|
result.put("patientAddress",deviceDo.getSosAddress());
|
|
|
if (monitorUrl.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail){
|
|
|
result.put("monitorInfo",monitorUrl.getString(ResponseContant.resultMsg));
|
|
|
}
|
|
|
else {
|
|
|
result.put("monitorInfo",monitorUrl.getJSONObject(ResponseContant.resultMsg));
|
|
|
JSONObject monitorUrl = ysDeviceServicel.getDeviceLiveAddress(patient, deviceDo.getDeviceSn(), 1, null);
|
|
|
result.put("monitorInfoStatus", monitorUrl.getIntValue(ResponseContant.resultFlag));
|
|
|
result.put("patientAddress", deviceDo.getSosAddress());
|
|
|
if (monitorUrl.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
|
|
|
result.put("monitorInfo", monitorUrl.getString(ResponseContant.resultMsg));
|
|
|
} else {
|
|
|
result.put("monitorInfo", monitorUrl.getJSONObject(ResponseContant.resultMsg));
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public JSONObject patientSignTopicInfo(JSONObject result,String patient,String topicItem,String deviceSn,boolean video){
|
|
|
if (null==result){
|
|
|
public JSONObject patientSignTopicInfo(JSONObject result, String patient, String topicItem, String deviceSn, boolean video) {
|
|
|
if (null == result) {
|
|
|
result = new JSONObject();
|
|
|
}
|
|
|
if ("preventLost".equals(topicItem)||StringUtils.isBlank(topicItem)){
|
|
|
preventLost(result, patient,deviceSn);
|
|
|
if ("preventLost".equals(topicItem) || StringUtils.isBlank(topicItem)) {
|
|
|
preventLost(result, patient, deviceSn);
|
|
|
}
|
|
|
if ("preventFall".equals(topicItem)||StringUtils.isBlank(topicItem)){
|
|
|
if ("preventFall".equals(topicItem) || StringUtils.isBlank(topicItem)) {
|
|
|
monitorInfo(result, patient);
|
|
|
}
|
|
|
if ("preventOutOfBed".equals(topicItem)||StringUtils.isBlank(topicItem)){
|
|
|
preventOutOfBed(result, patient,true,null);
|
|
|
if ("preventOutOfBed".equals(topicItem) || StringUtils.isBlank(topicItem)) {
|
|
|
preventOutOfBed(result, patient, true, null);
|
|
|
}
|
|
|
if ("preventFire".equals(topicItem)||StringUtils.isBlank(topicItem)){
|
|
|
preventFire(result, patient,null,video);
|
|
|
if ("preventFire".equals(topicItem) || StringUtils.isBlank(topicItem)) {
|
|
|
preventFire(result, patient, null, video);
|
|
|
}
|
|
|
if ("preventGasLeakage".equals(topicItem)||StringUtils.isBlank(topicItem)){
|
|
|
preventGasLeakage(result, patient,video);
|
|
|
if ("preventGasLeakage".equals(topicItem) || StringUtils.isBlank(topicItem)) {
|
|
|
preventGasLeakage(result, patient, video);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
public JSONObject updateDoctorLocation(String doctor,String orderId,String doctorAddress,String doctorLat,String doctorLon){
|
|
|
public JSONObject updateDoctorLocation(String doctor, String orderId, String doctorAddress, String doctorLat, String doctorLon) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
|
|
|
if (doctorDO==null){
|
|
|
if (doctorDO == null) {
|
|
|
String failMsg = "当前医生不存在";
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
else {
|
|
|
} else {
|
|
|
doctorDO.setDoctorLocateAddress(doctorAddress);
|
|
|
doctorDO.setDoctorLat(doctorLat);
|
|
|
doctorDO.setDoctorLon(doctorLon);
|
|
@ -1990,44 +2016,43 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject updatePatientLocation(String patient,String patientAddress,String patientLat,String patientLon){
|
|
|
public JSONObject updatePatientLocation(String patient, String patientAddress, String patientLat, String patientLon) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
BasePatientDO patientDO = basePatientDao.findById(patient);
|
|
|
if (patientDO==null){
|
|
|
if (patientDO == null) {
|
|
|
String failMsg = "患者不存在";
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
patientDO.setLatLon(patientLat+","+patientLon);
|
|
|
patientDO.setLatLon(patientLat + "," + patientLon);
|
|
|
basePatientDao.save(patientDO);
|
|
|
List<SecurityMonitoringOrderDO> monitoringOrderDO = securityMonitoringOrderDao.findByPatientAndStatus(patient,1);
|
|
|
if (monitoringOrderDO.size()>0){
|
|
|
for (SecurityMonitoringOrderDO tmp:monitoringOrderDO){
|
|
|
List<SecurityMonitoringOrderDO> monitoringOrderDO = securityMonitoringOrderDao.findByPatientAndStatus(patient, 1);
|
|
|
if (monitoringOrderDO.size() > 0) {
|
|
|
for (SecurityMonitoringOrderDO tmp : monitoringOrderDO) {
|
|
|
tmp.setServeAddress(patientAddress);
|
|
|
tmp.setServeLat(patientLat);
|
|
|
tmp.setServeLon(patientLon);
|
|
|
securityMonitoringOrderDao.save(monitoringOrderDO);
|
|
|
}
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
}
|
|
|
else {
|
|
|
} else {
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
result.put(ResponseContant.resultMsg,null);
|
|
|
result.put(ResponseContant.resultMsg, null);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject responseOrder(String orderId,String doctor){
|
|
|
public JSONObject responseOrder(String orderId, String doctor) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
SecurityMonitoringOrderDO one = securityMonitoringOrderDao.findOne(orderId);
|
|
|
if (one==null){
|
|
|
String failMsg = "工单不存在" ;
|
|
|
if (one == null) {
|
|
|
String failMsg = "工单不存在";
|
|
|
result.put("resultFlag", 0);
|
|
|
result.put("resultMsg", failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
if (emergencyWarnDoctorResponseDao.findByDoctorAndOrderId(doctor,orderId)==null){
|
|
|
if (emergencyWarnDoctorResponseDao.findByDoctorAndOrderId(doctor, orderId) == null) {
|
|
|
EmergencyWarnDoctorResponseDO responseDO = new EmergencyWarnDoctorResponseDO();
|
|
|
responseDO.setOrderId(orderId);
|
|
|
responseDO.setDoctor(doctor);
|
|
@ -2035,14 +2060,14 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
emergencyWarnDoctorResponseDao.save(responseDO);
|
|
|
|
|
|
BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
|
|
|
if (null!=doctorDO){
|
|
|
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("社工"+doctorDO.getName()+"前往定位");
|
|
|
logDO.setContent("社工" + doctorDO.getName() + "前往定位");
|
|
|
logDao.save(logDO);
|
|
|
}
|
|
|
}
|
|
@ -2053,70 +2078,70 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*获取居民睡眠计划
|
|
|
* 获取居民睡眠计划
|
|
|
*/
|
|
|
public BaseSleepPlan getPatientSleepPlan(String patient){
|
|
|
public BaseSleepPlan getPatientSleepPlan(String patient) {
|
|
|
List<BaseSleepPlan> list = sleepPlanDao.findByPatient(patient);
|
|
|
if (list.size()>0){
|
|
|
if (list.size() > 0) {
|
|
|
return list.get(0);
|
|
|
}else {
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*获取居民睡眠监护列表
|
|
|
* 获取居民睡眠监护列表
|
|
|
*/
|
|
|
public JSONObject getPatientSleepDetainList(String patient,String begin,String end,Integer page,Integer pageSize){
|
|
|
page=page>0?page-1:0;
|
|
|
public JSONObject getPatientSleepDetainList(String patient, String begin, String end, Integer page, Integer pageSize) {
|
|
|
page = page > 0 ? page - 1 : 0;
|
|
|
PageRequest pageRequest = new PageRequest(page, pageSize);
|
|
|
if (StringUtils.isBlank(end)){
|
|
|
if (StringUtils.isBlank(end)) {
|
|
|
end = begin;
|
|
|
}
|
|
|
JSONArray array = new JSONArray();
|
|
|
Page<BaseSleepPlanDetail> list = sleepPlanDetailDao.findByListByPage(patient,begin,end,pageRequest);
|
|
|
Page<BaseSleepPlanDetail> list = sleepPlanDetailDao.findByListByPage(patient, begin, end, pageRequest);
|
|
|
List<BaseSleepPlan> sleepPlans = sleepPlanDao.findByPatient(patient);
|
|
|
BaseSleepPlan sleepPlan=null;
|
|
|
if (sleepPlans.size()>0){
|
|
|
BaseSleepPlan sleepPlan = null;
|
|
|
if (sleepPlans.size() > 0) {
|
|
|
sleepPlan = sleepPlans.get(0);
|
|
|
}
|
|
|
for (BaseSleepPlanDetail tmp:list){
|
|
|
List<BaseSleepNightRecord> records = nightRecordDao.findByPatientAndDayOrderByCreateTimeDesc(patient,tmp.getDay());
|
|
|
for (BaseSleepPlanDetail tmp : list) {
|
|
|
List<BaseSleepNightRecord> records = nightRecordDao.findByPatientAndDayOrderByCreateTimeDesc(patient, tmp.getDay());
|
|
|
tmp.setSleepNightRecordList(records);
|
|
|
String str = JSON.toJSONStringWithDateFormat(tmp, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(str);
|
|
|
if (null==sleepPlan){
|
|
|
jsonObject.put("sleepPlan",false);
|
|
|
}else {
|
|
|
jsonObject.put("sleepPlan",true);
|
|
|
String endTime = DateUtil.getNextMin(sleepPlan.getGetUpTime(),-1);
|
|
|
jsonObject.put("getUpTime",sleepPlan.getGetUpTime());
|
|
|
jsonObject.put("siestaTime",sleepPlan.getNapTime());
|
|
|
jsonObject.put("nightRestTime",sleepPlan.getNightRestTime());
|
|
|
jsonObject.put("nightRecordTime",sleepPlan.getNightRestTime()+"-隔日"+endTime);
|
|
|
if (null == sleepPlan) {
|
|
|
jsonObject.put("sleepPlan", false);
|
|
|
} else {
|
|
|
jsonObject.put("sleepPlan", true);
|
|
|
String endTime = DateUtil.getNextMin(sleepPlan.getGetUpTime(), -1);
|
|
|
jsonObject.put("getUpTime", sleepPlan.getGetUpTime());
|
|
|
jsonObject.put("siestaTime", sleepPlan.getNapTime());
|
|
|
jsonObject.put("nightRestTime", sleepPlan.getNightRestTime());
|
|
|
jsonObject.put("nightRecordTime", sleepPlan.getNightRestTime() + "-隔日" + endTime);
|
|
|
array.add(jsonObject);
|
|
|
}
|
|
|
}
|
|
|
JSONObject result = (JSONObject) JSONObject.toJSON(list);
|
|
|
result.put("content",array);
|
|
|
result.put("content", array);
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*获取居民起夜记录
|
|
|
* 获取居民起夜记录
|
|
|
*/
|
|
|
public List<BaseSleepNightRecord> getPatientSleepNightRecord(String patient, String day){
|
|
|
public List<BaseSleepNightRecord> getPatientSleepNightRecord(String patient, String day) {
|
|
|
|
|
|
List<BaseSleepNightRecord> records = nightRecordDao.findByPatientAndDayOrderByCreateTimeDesc(patient,day);
|
|
|
List<BaseSleepNightRecord> records = nightRecordDao.findByPatientAndDayOrderByCreateTimeDesc(patient, day);
|
|
|
return records;
|
|
|
}
|
|
|
|
|
|
private String getRandomIntStr(){
|
|
|
private String getRandomIntStr() {
|
|
|
Random rand = new Random();
|
|
|
int i = rand.nextInt(); //int范围类的随机数
|
|
|
i = rand.nextInt(100); //生成0-100以内的随机数
|
|
|
i = (int)(Math.random() * 100000000); //0-100以内的随机数,用Matn.random()方式
|
|
|
i = (int) (Math.random() * 100000000); //0-100以内的随机数,用Matn.random()方式
|
|
|
return String.valueOf(i);
|
|
|
}
|
|
|
|
|
@ -2126,98 +2151,242 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
one.setUpdateUserName(one.getDoctorName());
|
|
|
}
|
|
|
|
|
|
private String getSleepMonitoringDay(Date date,String patient){
|
|
|
private String getSleepMonitoringDay(Date date, String patient) {
|
|
|
List<BaseSleepPlan> sleepPlans = sleepPlanDao.findByPatient(patient);
|
|
|
if (sleepPlans.size()>0){
|
|
|
if (sleepPlans.size() > 0) {
|
|
|
BaseSleepPlan sleepPlan = sleepPlans.get(0);
|
|
|
String bedUpStr = sleepPlans.get(0).getGetUpTime();
|
|
|
Date bedUp = DateUtil.strToDate(DateUtil.getStringDateShort()+" "+bedUpStr+":00");// 起床时间 起床前一小时内算为起床
|
|
|
if (date.before(bedUp)&&bedUp.getTime()-date.getTime()>1000*1*3600){
|
|
|
bedUp = DateUtil.getNextDay1(bedUp,-1);
|
|
|
Date bedUp = DateUtil.strToDate(DateUtil.getStringDateShort() + " " + bedUpStr + ":00");// 起床时间 起床前一小时内算为起床
|
|
|
if (date.before(bedUp) && bedUp.getTime() - date.getTime() > 1000 * 1 * 3600) {
|
|
|
bedUp = DateUtil.getNextDay1(bedUp, -1);
|
|
|
}
|
|
|
String dayTime = DateUtil.dateToStr(bedUp,DateUtil.YYYY_MM_DD);//监测日期
|
|
|
String dayTime = DateUtil.dateToStr(bedUp, DateUtil.YYYY_MM_DD);//监测日期
|
|
|
return dayTime;
|
|
|
}else {
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public JSONObject findMonitorPatientsByDoctor(String doctor,String topicItem,String day,Integer page,Integer pageSize,Integer detail){
|
|
|
public JSONObject findMonitorPatientsByDoctor(String doctor, String topicItem, String day, Integer page, Integer pageSize, Integer detail) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
String sql = " SELECT DISTINCT p.id,p.name,p.residential_area residentialArea,p.photo,p.idcard,p.mobile, " +
|
|
|
" p.openid,p.sex,p.pad_imei padImei " +
|
|
|
" from base_patient p , base_service_package_sign_record sr,base_service_package_record r,base_team_member m " +
|
|
|
" WHERE p.id = sr.patient and sr.status=1 and m.team_code = r.team_code and sr.id=r.sign_id " +
|
|
|
" and m.doctor_code = '"+doctor+"' and m.del = '1' ";
|
|
|
" and m.doctor_code = '" + doctor + "' and m.del = '1' ";
|
|
|
String fliter = "";
|
|
|
String categoryCode ="";
|
|
|
String categoryCode = "";
|
|
|
String topicItemTmp = topicItem;
|
|
|
switch (topicItem){
|
|
|
switch (topicItem) {
|
|
|
case "actionTrack":
|
|
|
categoryCode="'4'";
|
|
|
topicItemTmp="preventLost";
|
|
|
categoryCode = "'4'";
|
|
|
topicItemTmp = "preventLost";
|
|
|
break;
|
|
|
case "preventLost":
|
|
|
categoryCode="'4'";
|
|
|
categoryCode = "'4'";
|
|
|
break;
|
|
|
case "preventFall":
|
|
|
categoryCode="'12'";
|
|
|
categoryCode = "'12'";
|
|
|
break;
|
|
|
case "preventFire":
|
|
|
categoryCode="'15'";
|
|
|
categoryCode = "'15'";
|
|
|
break;
|
|
|
case "preventGasLeakage":
|
|
|
categoryCode="'14'";
|
|
|
categoryCode = "'14'";
|
|
|
break;
|
|
|
case "preventOutOfBed":
|
|
|
categoryCode="'13'";
|
|
|
categoryCode = "'13'";
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
fliter =" and EXISTS (select 1 from wlyy_patient_device pd INNER JOIN dm_device dd on pd.device_id = dd.id " +
|
|
|
" where pd.user = sr.patient and pd.del=0 and pd.category_code in ("+categoryCode+") and FIND_IN_SET('"+topicItemTmp+"',dd.service_topic)) ";
|
|
|
fliter = " and EXISTS (select 1 from wlyy_patient_device pd INNER JOIN dm_device dd on pd.device_id = dd.id " +
|
|
|
" where pd.user = sr.patient and pd.del=0 and pd.category_code in (" + categoryCode + ") and FIND_IN_SET('" + topicItemTmp + "',dd.service_topic)) ";
|
|
|
|
|
|
if ("preventLost".equals(topicItem)){//有绑定围栏的居民
|
|
|
if ("preventLost".equals(topicItem)) {//有绑定围栏的居民
|
|
|
fliter += " and EXISTS (select 1 from wlyy_patient_safe_area sf where sf.patient = p.id and sf.del=1 and sf.manage_status=1) ";
|
|
|
}
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+fliter);
|
|
|
result.put("total",list.size());
|
|
|
if (1 == detail){//获取详情
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql + fliter);
|
|
|
result.put("total", list.size());
|
|
|
if (1 == detail) {//获取详情
|
|
|
JSONArray monitorInfos = new JSONArray();
|
|
|
page = page>0?page-1:0;
|
|
|
page = page > 0 ? page - 1 : 0;
|
|
|
Integer totalPage = 0;
|
|
|
if(list.size()%pageSize==0){
|
|
|
totalPage =list.size()/pageSize;
|
|
|
}else{
|
|
|
totalPage = list.size()/pageSize+1;
|
|
|
if (list.size() % pageSize == 0) {
|
|
|
totalPage = list.size() / pageSize;
|
|
|
} else {
|
|
|
totalPage = list.size() / pageSize + 1;
|
|
|
}
|
|
|
Integer currentIndexFrom = page*pageSize;
|
|
|
Integer currentIndexEnd = page*pageSize+pageSize;
|
|
|
result.put("totalPage",totalPage);
|
|
|
result.put("currentPage",page+1);
|
|
|
for (int i=currentIndexFrom;i<list.size()&&i<currentIndexEnd;i++){
|
|
|
Map<String,Object> patientTmp = list.get(i);
|
|
|
Integer currentIndexFrom = page * pageSize;
|
|
|
Integer currentIndexEnd = page * pageSize + pageSize;
|
|
|
result.put("totalPage", totalPage);
|
|
|
result.put("currentPage", page + 1);
|
|
|
for (int i = currentIndexFrom; i < list.size() && i < currentIndexEnd; i++) {
|
|
|
Map<String, Object> patientTmp = list.get(i);
|
|
|
com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
|
|
|
|
|
|
String deviceSn ="";
|
|
|
String deviceSn = "";
|
|
|
List<String> deviceSns = jdbcTemplate.queryForList("select pd.device_sn from wlyy_patient_device pd INNER JOIN dm_device dd " +
|
|
|
" on pd.device_id = dd.id where pd.user = '"+patientTmp.get("id").toString()+"' and pd.del=0 and pd.category_code in ("+categoryCode+") and FIND_IN_SET('"+topicItemTmp+"',dd.service_topic)",String.class);
|
|
|
if (deviceSns.size()>0){
|
|
|
" on pd.device_id = dd.id where pd.user = '" + patientTmp.get("id").toString() + "' and pd.del=0 and pd.category_code in (" + categoryCode + ") and FIND_IN_SET('" + topicItemTmp + "',dd.service_topic)", String.class);
|
|
|
if (deviceSns.size() > 0) {
|
|
|
deviceSn = deviceSns.get(0);
|
|
|
}
|
|
|
if (deviceSns.size()>0){
|
|
|
object.put("deviceSn", deviceSn);
|
|
|
|
|
|
switch (topicItem) {
|
|
|
case "actionTrack":
|
|
|
JSONArray locations = JSON.parseArray(JSON.toJSONString(patientDeviceService.getX1Locations(deviceSn, day), SerializerFeature.WriteMapNullValue));
|
|
|
object.put("routes", locations);
|
|
|
//获取手表定位
|
|
|
JSONObject response = patientDeviceService.getAqgDeviceInfo2(deviceSn);
|
|
|
if (response != null) {
|
|
|
//定位信息
|
|
|
if (response.containsKey("last_location") && response.get("last_location") != null) {
|
|
|
JSONObject locationTmp = response.getJSONObject("last_location");
|
|
|
Double lon = locationTmp.getJSONArray("coordinates").getDouble(0);
|
|
|
Double lat = locationTmp.getJSONArray("coordinates").getDouble(1);
|
|
|
if (!response.getBoolean("online")) {//设备离线 取居民表定位
|
|
|
object.put("X1online", false);
|
|
|
} else {
|
|
|
object.put("X1online", true);
|
|
|
}
|
|
|
JSONObject tmp = gpsUtil.gcj02_To_Bd09(lat, lon);
|
|
|
tmp.put("city", response.getString("last_city"));
|
|
|
tmp.put("province", response.getString("last_province"));
|
|
|
tmp.put("address", response.getString("last_address"));
|
|
|
object.put("location", tmp);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
object = patientMonitoringInfo(patientTmp.get("id").toString(), topicItem,deviceSn, false);
|
|
|
break;
|
|
|
}
|
|
|
object.put("patientInfo", patientTmp);
|
|
|
object.put("deviceSn", deviceSn);
|
|
|
monitorInfos.add(object);
|
|
|
}
|
|
|
result.put("topicInfo", monitorInfos);
|
|
|
} else {
|
|
|
JSONArray monitorInfos = new JSONArray();
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
Map<String, Object> patientTmp = list.get(i);
|
|
|
String deviceSn = "";
|
|
|
List<String> deviceSns = jdbcTemplate.queryForList("select pd.device_sn from wlyy_patient_device pd INNER JOIN dm_device dd " +
|
|
|
" on pd.device_id = dd.id where pd.user = '" + patientTmp.get("id").toString() + "' and pd.del=0 and pd.category_code in (" + categoryCode + ") and FIND_IN_SET('" + topicItem + "',dd.service_topic)", String.class);
|
|
|
if (deviceSns.size() > 0) {
|
|
|
deviceSn = deviceSns.get(0);
|
|
|
}
|
|
|
object.put("deviceCode",deviceSn);
|
|
|
JSONObject object = patientMonitoringInfo(patientTmp.get("id").toString(), "null", null,false);
|
|
|
object.put("deviceSn", deviceSn);
|
|
|
object.put("patientInfo", patientTmp);
|
|
|
monitorInfos.add(object);
|
|
|
}
|
|
|
result.put("topicInfo", monitorInfos);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
public JSONObject findMonitorPatientsByDoctors(String topicItem, String day, Integer page, Integer pageSize, Integer detail) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
switch (topicItem){
|
|
|
String sql = " SELECT DISTINCT p.id,p.name,p.residential_area residentialArea,p.photo,p.idcard,p.mobile, " +
|
|
|
" p.openid,p.sex,p.pad_imei padImei,p.home_lat_lon homeLatLon,p.lat_lon latLon " +
|
|
|
" from base_patient p , base_service_package_sign_record sr,base_service_package_record r,base_team_member m " +
|
|
|
" WHERE p.id = sr.patient and sr.status=1 and m.team_code = r.team_code and sr.id=r.sign_id " +
|
|
|
" and m.del = '1' ";
|
|
|
String fliter = "";
|
|
|
String categoryCode = "";
|
|
|
String topicItemTmp = topicItem;
|
|
|
switch (topicItem) {
|
|
|
case "actionTrack":
|
|
|
categoryCode = "'4'";
|
|
|
topicItemTmp = "preventLost";
|
|
|
break;
|
|
|
case "preventLost":
|
|
|
categoryCode = "'4'";
|
|
|
break;
|
|
|
case "preventFall":
|
|
|
categoryCode = "'12'";
|
|
|
break;
|
|
|
case "preventFire":
|
|
|
categoryCode = "'15'";
|
|
|
break;
|
|
|
case "preventGasLeakage":
|
|
|
categoryCode = "'14'";
|
|
|
break;
|
|
|
case "preventOutOfBed":
|
|
|
categoryCode = "'13'";
|
|
|
break;
|
|
|
case "emergencyAssistance":
|
|
|
categoryCode = "'7','4'";
|
|
|
break;
|
|
|
}
|
|
|
if ("emergencyAssistance".equals(topicItem)) {
|
|
|
fliter = "";
|
|
|
} else {
|
|
|
fliter = " and EXISTS (select 1 from wlyy_patient_device pd INNER JOIN dm_device dd on pd.device_id = dd.id " +
|
|
|
" where pd.user = sr.patient and pd.del=0 and pd.category_code in (" + categoryCode + ") and FIND_IN_SET('" + topicItemTmp + "',dd.service_topic)) ";
|
|
|
}
|
|
|
|
|
|
if ("preventLost".equals(topicItem)) {//有绑定围栏的居民
|
|
|
fliter += " and EXISTS (select 1 from wlyy_patient_safe_area sf where sf.patient = p.id and sf.del=1 and sf.manage_status=1) ";
|
|
|
}
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql + fliter);
|
|
|
result.put("total", list.size());
|
|
|
if (1 == detail) {//获取详情
|
|
|
JSONArray monitorInfos = new JSONArray();
|
|
|
page = page > 0 ? page - 1 : 0;
|
|
|
Integer totalPage = 0;
|
|
|
if (list.size() % pageSize == 0) {
|
|
|
totalPage = list.size() / pageSize;
|
|
|
} else {
|
|
|
totalPage = list.size() / pageSize + 1;
|
|
|
}
|
|
|
Integer currentIndexFrom = page * pageSize;
|
|
|
Integer currentIndexEnd = page * pageSize + pageSize;
|
|
|
result.put("totalPage", totalPage);
|
|
|
result.put("currentPage", page + 1);
|
|
|
for (int i = currentIndexFrom; i < list.size() && i < currentIndexEnd; i++) {
|
|
|
Map<String, Object> patientTmp = list.get(i);
|
|
|
com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
|
|
|
|
|
|
String deviceSn = "";
|
|
|
if ("emergencyAssistance".equals(topicItem)){
|
|
|
sql = "select pd.device_sn,dd.category_code from wlyy_patient_device pd INNER JOIN dm_device dd " +
|
|
|
" on pd.device_id = dd.id where pd.user = '" + patientTmp.get("id").toString() + "' and pd.del=0 and pd.category_code in (" + categoryCode + ")";
|
|
|
List<Map<String,Object>> deviceSns = jdbcTemplate.queryForList(sql);
|
|
|
if (deviceSns.size() > 0) {
|
|
|
boolean findFlag = false;
|
|
|
for (Map<String,Object> tmp:deviceSns){
|
|
|
if("4".equals(tmp.get("category_code").toString())){
|
|
|
deviceSn = tmp.get("device_sn").toString();
|
|
|
findFlag=true;
|
|
|
}
|
|
|
}
|
|
|
if (!findFlag){
|
|
|
deviceSn = deviceSns.get(0).get("device_sn").toString();
|
|
|
}
|
|
|
}
|
|
|
object.put("deviceSn", deviceSn);
|
|
|
}else {
|
|
|
sql = "select pd.device_sn from wlyy_patient_device pd INNER JOIN dm_device dd " +
|
|
|
" on pd.device_id = dd.id where pd.user = '" + patientTmp.get("id").toString() + "' and pd.del=0 and pd.category_code in (" + categoryCode + ") and FIND_IN_SET('" + topicItemTmp + "',dd.service_topic)";
|
|
|
List<String> deviceSns = jdbcTemplate.queryForList(sql, String.class);
|
|
|
if (deviceSns.size() > 0) {
|
|
|
deviceSn = deviceSns.get(0);
|
|
|
}
|
|
|
object.put("deviceSn", deviceSn);
|
|
|
}
|
|
|
|
|
|
switch (topicItem) {
|
|
|
case "actionTrack":
|
|
|
JSONArray locations = JSON.parseArray(JSON.toJSONString(patientDeviceService.getX1Locations(deviceSn, day), SerializerFeature.WriteMapNullValue));
|
|
|
object.put("routes", locations);
|
|
|
//获取手表定位
|
|
|
JSONObject response= patientDeviceService.getAqgDeviceInfo2(deviceSn);
|
|
|
if (response!=null) {
|
|
|
JSONObject response = patientDeviceService.getAqgDeviceInfo2(deviceSn);
|
|
|
if (response != null) {
|
|
|
//定位信息
|
|
|
if (response.containsKey("last_location") && response.get("last_location") != null) {
|
|
|
JSONObject locationTmp = response.getJSONObject("last_location");
|
|
@ -2236,32 +2405,75 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case "emergencyAssistance":
|
|
|
String id = (String) list.get(i).get("id");
|
|
|
String residentialArea = (String) list.get(i).get("residentialArea");
|
|
|
String SoSDeviceSql = "SELECT id FROM base_emergency_assistance_order WHERE `status` = '1' AND patient = '" + id + "'";
|
|
|
List<Map<String, Object>> listMapsOrder = jdbcTemplate.queryForList(SoSDeviceSql);
|
|
|
JSONObject tmp = new JSONObject();
|
|
|
if (listMapsOrder.size() > 0) {
|
|
|
for (Map<String, Object> stringObjectMap : listMapsOrder) {
|
|
|
tmp.put("orderId", stringObjectMap.get("id"));
|
|
|
}
|
|
|
tmp.put("eCall", 1);
|
|
|
} else {
|
|
|
tmp.put("eCall", 0);
|
|
|
tmp.put("orderId", "");
|
|
|
}
|
|
|
BasePatientDO patientDO = basePatientDao.findById(id);
|
|
|
if (null != patientDO) {
|
|
|
if (StringUtils.isNotBlank(patientDO.getLatLon())) {
|
|
|
String[] latLon = patientDO.getLatLon().toString().split(",");
|
|
|
if (StringUtils.isNotBlank(patientDO.getHomeLatLon())) {
|
|
|
String homeLatLon = patientDO.getHomeLatLon();
|
|
|
double homeLat = Double.parseDouble(homeLatLon.split(",")[0]);
|
|
|
double homeLon = Double.parseDouble(homeLatLon.split(",")[1]);
|
|
|
double homeDistance = countDistance.getDistance(Double.parseDouble(latLon[0]), Double.parseDouble(latLon[1]),
|
|
|
homeLat, homeLon);
|
|
|
if (homeDistance > 50 * 1000) {
|
|
|
tmp.put("atHome", false);
|
|
|
} else {
|
|
|
tmp.put("atHome", true);
|
|
|
}
|
|
|
} else {
|
|
|
tmp.put("atHome", null);
|
|
|
}
|
|
|
String locationAddress = LatitudeUtils.getLocationAddress(latLon[0], latLon[1]);
|
|
|
tmp.put("address", locationAddress);
|
|
|
} else {
|
|
|
tmp.put("atHome", null);
|
|
|
tmp.put("address", "");
|
|
|
}
|
|
|
}
|
|
|
object.put("info", tmp);
|
|
|
break;
|
|
|
default:
|
|
|
object = patientMonitoringInfo(patientTmp.get("id").toString(),topicItem,false);
|
|
|
object = patientMonitoringInfo(patientTmp.get("id").toString(), topicItem, deviceSn,false);
|
|
|
break;
|
|
|
}
|
|
|
object.put("patientInfo",patientTmp);
|
|
|
object.put("patientInfo", patientTmp);
|
|
|
object.put("deviceSn", deviceSn);
|
|
|
monitorInfos.add(object);
|
|
|
}
|
|
|
result.put("topicInfo",monitorInfos);
|
|
|
}else {
|
|
|
result.put("topicInfo", monitorInfos);
|
|
|
} else {
|
|
|
JSONArray monitorInfos = new JSONArray();
|
|
|
for (int i=0;i<list.size();i++){
|
|
|
Map<String,Object> patientTmp = list.get(i);
|
|
|
String deviceSn ="";
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
Map<String, Object> patientTmp = list.get(i);
|
|
|
String deviceSn = "";
|
|
|
List<String> deviceSns = jdbcTemplate.queryForList("select pd.device_sn from wlyy_patient_device pd INNER JOIN dm_device dd " +
|
|
|
" on pd.device_id = dd.id where pd.user = '"+patientTmp.get("id").toString()+"' and pd.del=0 and pd.category_code in ("+categoryCode+") and FIND_IN_SET('"+topicItem+"',dd.service_topic)",String.class);
|
|
|
if (deviceSns.size()>0){
|
|
|
" on pd.device_id = dd.id where pd.user = '" + patientTmp.get("id").toString() + "' and pd.del=0 and pd.category_code in (" + categoryCode + ") and FIND_IN_SET('" + topicItem + "',dd.service_topic)", String.class);
|
|
|
if (deviceSns.size() > 0) {
|
|
|
deviceSn = deviceSns.get(0);
|
|
|
}
|
|
|
JSONObject object = patientMonitoringInfo(patientTmp.get("id").toString(),"null",false);
|
|
|
object.put("deviceSn",deviceSn);
|
|
|
object.put("patientInfo",patientTmp);
|
|
|
JSONObject object = patientMonitoringInfo(patientTmp.get("id").toString(), "null", null,false);
|
|
|
object.put("deviceSn", deviceSn);
|
|
|
object.put("patientInfo", patientTmp);
|
|
|
monitorInfos.add(object);
|
|
|
}
|
|
|
result.put("topicInfo",monitorInfos);
|
|
|
result.put("topicInfo", monitorInfos);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|