|
@ -41,7 +41,6 @@ import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
|
import com.yihu.jw.restmodel.emergency.EmergencyOrderVO;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
import com.yihu.jw.rm.base.BaseRequestMapping;
|
|
|
import com.yihu.jw.util.common.GpsUtil;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.util.common.LatitudeUtils;
|
|
@ -456,7 +455,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
}else {
|
|
|
monitorInfo.put("sleepPlan",false);
|
|
|
}
|
|
|
monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall",null);
|
|
|
monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall",null,true);
|
|
|
emergencyOrderVO.setInformation(monitorInfo);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
@ -465,7 +464,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
if (6==orderDO.getOrderSource()){//气感工单
|
|
|
try {
|
|
|
JSONObject monitorInfo = JSONObject.parseObject(orderDO.getWarnInfo());
|
|
|
monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall",null);
|
|
|
monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall",null,true);
|
|
|
emergencyOrderVO.setInformation(monitorInfo);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
@ -474,7 +473,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
if (7==orderDO.getOrderSource()){//烟感工单
|
|
|
try {
|
|
|
JSONObject monitorInfo = JSONObject.parseObject(orderDO.getWarnInfo());
|
|
|
monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall",null);
|
|
|
monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall",null,true);
|
|
|
emergencyOrderVO.setInformation(monitorInfo);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
@ -1398,7 +1397,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject patientMonitoringInfo(String patient,String topicItem){
|
|
|
public JSONObject patientMonitoringInfo(String patient,String topicItem,boolean video){
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("location",null);
|
|
|
result.put("fences",null);
|
|
@ -1406,7 +1405,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
result.put("fire",null);
|
|
|
result.put("fall",null);
|
|
|
result.put("sleep",null);
|
|
|
result.put("sleepInfo",null);//最近工单
|
|
|
result.put("sleepOrderInfo",null);//最近工单
|
|
|
result.put("deviceSn",null);
|
|
|
result.put("emeAssistance",false);
|
|
|
result.put("monitorInfo",null);
|
|
@ -1448,7 +1447,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
"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("sleepInfo",serveDesces.get(0));
|
|
|
result.put("sleepOrderInfo",serveDesces.get(0));
|
|
|
}
|
|
|
}else {
|
|
|
result.put("sleep",false);
|
|
@ -1461,7 +1460,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
if (counnt>0){
|
|
|
result.put("emeAssistance",true);
|
|
|
}
|
|
|
result = patientSignTopicInfo(result,patient,topicItem,null);
|
|
|
result = patientSignTopicInfo(result,patient,topicItem,null,true);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@ -1479,7 +1478,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
result.put("fire",null);
|
|
|
result.put("fall",null);
|
|
|
result.put("sleep",null);
|
|
|
result.put("sleepInfo",null);//最近工单
|
|
|
result.put("sleepOrderInfo",null);//最近工单
|
|
|
result.put("deviceSn",null);
|
|
|
result.put("emeAssistance",false);
|
|
|
result.put("monitorInfo",null);
|
|
@ -1521,7 +1520,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
"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("sleepInfo",serveDesces.get(0));
|
|
|
result.put("sleepOrderInfo",serveDesces.get(0));
|
|
|
}
|
|
|
}else {
|
|
|
result.put("sleep",false);
|
|
@ -1536,9 +1535,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
}
|
|
|
List<DevicePatientDevice> devices4 = patientDeviceDao.findByUserAndCategoryCode(patient,"4");//手表
|
|
|
if (devices4.size()>0){
|
|
|
result = patientSignTopicInfo(result,patient,"preventLost",devices4.get(0).getDeviceSn());
|
|
|
result = patientSignTopicInfo(result,patient,"preventLost",devices4.get(0).getDeviceSn(),true);
|
|
|
}
|
|
|
patientSignTopicInfo(result,patient,"preventFall",null);
|
|
|
patientSignTopicInfo(result,patient,"preventFall",null,true);
|
|
|
|
|
|
return result;
|
|
|
}
|
|
@ -1575,6 +1574,11 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
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);
|
|
|
}
|
|
|
JSONObject tmp = gpsUtil.gcj02_To_Bd09(lat,lon);
|
|
|
tmp.put("city",response.getString("last_city"));
|
|
|
tmp.put("province",response.getString("last_province"));
|
|
@ -1865,7 +1869,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
|
|
|
}
|
|
|
|
|
|
public JSONObject patientSignTopicInfo(JSONObject result,String patient,String topicItem,String deviceSn){
|
|
|
public JSONObject patientSignTopicInfo(JSONObject result,String patient,String topicItem,String deviceSn,boolean video){
|
|
|
if (null==result){
|
|
|
result = new JSONObject();
|
|
|
}
|
|
@ -1879,14 +1883,15 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
preventOutOfBed(result, patient,true,null);
|
|
|
}
|
|
|
if ("preventFire".equals(topicItem)||StringUtils.isBlank(topicItem)){
|
|
|
preventFire(result, patient,null,true);
|
|
|
preventFire(result, patient,null,video);
|
|
|
}
|
|
|
if ("preventGasLeakage".equals(topicItem)||StringUtils.isBlank(topicItem)){
|
|
|
preventGasLeakage(result, patient,true);
|
|
|
preventGasLeakage(result, patient,video);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
public JSONObject updateDoctorLocation(String doctor,String orderId,String doctorAddress,String doctorLat,String doctorLon){
|
|
|
JSONObject result = new JSONObject();
|
|
|
BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
|
|
@ -2058,20 +2063,126 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> findMonitorPatientsByDoctor(String doctor,String topicItem){
|
|
|
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' ";
|
|
|
|
|
|
String filter =" 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 FIND_IN_SET('"+topicItem+"',dd.service_topic)) ";
|
|
|
String filter = "";
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
filter =" 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)){//有绑定围栏的居民
|
|
|
filter += " and EXISTS (select 1 from wlyy_patient_safe_area sf where sf.patient = p.id and sf.del=1 and sf.manage_status=1) ";
|
|
|
}
|
|
|
return jdbcTemplate.queryForList(sql+filter);
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filter);
|
|
|
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 ="";
|
|
|
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){
|
|
|
deviceSn = deviceSns.get(0);
|
|
|
}
|
|
|
if (deviceSns.size()>0){
|
|
|
deviceSn = deviceSns.get(0);
|
|
|
}
|
|
|
object.put("deviceCode",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,false);
|
|
|
break;
|
|
|
}
|
|
|
object.put("patientInfo",patientTmp);
|
|
|
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);
|
|
|
}
|
|
|
JSONObject object = patientMonitoringInfo(patientTmp.get("id").toString(),"null",false);
|
|
|
object.put("deviceSn",deviceSn);
|
|
|
object.put("patientInfo",patientTmp);
|
|
|
monitorInfos.add(object);
|
|
|
}
|
|
|
result.put("topicInfo",monitorInfos);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
}
|