|
@ -13,6 +13,7 @@ import com.yihu.jw.care.service.contacts.ContactsService;
|
|
|
import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
|
|
|
import com.yihu.jw.care.service.wechat.WeiXinAccessTokenUtils;
|
|
|
import com.yihu.jw.care.util.ConcealUtil;
|
|
|
import com.yihu.jw.care.util.CountDistance;
|
|
|
import com.yihu.jw.care.util.MyJdbcTemplate;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
@ -25,6 +26,7 @@ import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
|
import com.yihu.jw.util.common.GpsUtil;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.util.common.LatitudeUtils;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.entity.ServiceException;
|
|
|
import com.yihu.jw.util.healthIndex.HealthIndexUtil;
|
|
@ -115,7 +117,8 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
|
|
|
private EmergencyAssistanceService emergencyAssistanceService;
|
|
|
@Autowired
|
|
|
private SecurityMonitoringOrderService securityMonitoringOrderService;
|
|
|
|
|
|
@Autowired
|
|
|
private CountDistance countDistance;
|
|
|
@PostConstruct
|
|
|
public void init() {
|
|
|
relations.put(0, "其他");
|
|
@ -945,11 +948,21 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
|
|
|
dataSql = "SELECT record_date recordDate,value1,value2,value3,value4,value5,value6,value7,type FROM wlyy_patient_health_index WHERE device_sn = '" + deviceSn + "' AND del = 1 ORDER BY sort_date DESC LIMIT 10";
|
|
|
dataList = jdbcTemplate.queryForList(dataSql);
|
|
|
devInfoObj.put("data", dataList);
|
|
|
|
|
|
String ssql = "SELECT record_date recordDate,value1,value2,value3,value4,value5,value6,value7,type FROM wlyy_patient_health_index WHERE device_sn = '" + deviceSn + "' AND del = 1 AND status = 1 ";
|
|
|
String bloodPressureSql = ssql + " AND type = 1 ORDER BY sort_date DESC LIMIT 10";
|
|
|
dataList = jdbcTemplate.queryForList(bloodPressureSql);
|
|
|
devInfoObj.put("bloodPressure",dataList); //血压
|
|
|
break;
|
|
|
case "2"://血糖设备
|
|
|
dataSql = "SELECT record_date recordDate,value1,value2,value3,value4,value5,value6,value7,type FROM wlyy_patient_health_index WHERE device_sn = '" + deviceSn + "' AND del = 1 ORDER BY sort_date DESC LIMIT 10";
|
|
|
dataSql = "SELECT record_date recordDate,value1,value2,value3,value4,value5,value6,value7,type FROM wlyy_patient_health_index WHERE device_sn = '" + deviceSn + "' AND del = 1 ";
|
|
|
dataSql += " ORDER BY sort_date DESC LIMIT 10";
|
|
|
dataList = jdbcTemplate.queryForList(dataSql);
|
|
|
devInfoObj.put("data", dataList);
|
|
|
devInfoObj.put("data", dataList); //血糖数据
|
|
|
|
|
|
recordSql = "SELECT record_date recordDate,value1,value2,value3,value4,value5,value6,value7,type FROM wlyy_patient_health_index WHERE device_sn = '" + deviceSn + "' AND del = 1 AND status = 1 ORDER BY sort_date DESC LIMIT 10";
|
|
|
dataList = jdbcTemplate.queryForList(recordSql);
|
|
|
devInfoObj.put("bloodSugar", dataList); //血糖异常数据
|
|
|
break;
|
|
|
case "4"://手表 围栏与轨迹
|
|
|
if (StringUtils.isBlank(day)) {
|
|
@ -992,6 +1005,47 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
|
|
|
devInfoObj.put("safeAreaGz", securityMonitoringOrderService.getElectronicFence(deviceSn));
|
|
|
// 行动轨迹
|
|
|
devInfoObj.put("actionTrack", securityMonitoringOrderService.getActionTrack(deviceSn));
|
|
|
//当前定位
|
|
|
List<Map<String , Object>> newList = securityMonitoringOrderService.getNewList(deviceSn,day);
|
|
|
String lat = "";
|
|
|
String lon = "";
|
|
|
if (newList.size() > 0) {
|
|
|
lat = (String) newList.get(0).get("lat");
|
|
|
lon = (String) newList.get(0).get("lon");
|
|
|
devInfoObj.put("currentPositioning", LatitudeUtils.getLocationAddress(lat,lon)); //当前定位
|
|
|
} else { //当前地址为null,则获取居民坐标
|
|
|
newList = securityMonitoringOrderService.getPatientLatLon(deviceSn);
|
|
|
String safeArea = (String) newList.get(0).get("lat_lon");
|
|
|
String[] safeAreas = safeArea.split(";");
|
|
|
com.alibaba.fastjson.JSONArray fenceLocation = new com.alibaba.fastjson.JSONArray();
|
|
|
for (String area:safeAreas){
|
|
|
String[] areaPoint = area.split(",");
|
|
|
lat = areaPoint[0];
|
|
|
lon = areaPoint[1];
|
|
|
}
|
|
|
}
|
|
|
devInfoObj.put("currentPositioning",LatitudeUtils.getLocationAddress(lat,lon)); //当前定位
|
|
|
double dulat =Double.parseDouble(lat);
|
|
|
double dulon = Double.parseDouble(lon);
|
|
|
String safeArea = device.getSafeAreaGz();
|
|
|
String[] safeAreas = safeArea.split(";");
|
|
|
com.alibaba.fastjson.JSONArray fenceLocation = new com.alibaba.fastjson.JSONArray();
|
|
|
for (String area:safeAreas){
|
|
|
String[] areaPoint = area.split(",");
|
|
|
com.alibaba.fastjson.JSONObject positionTmp = new com.alibaba.fastjson.JSONObject();
|
|
|
Double areaLon = Double.parseDouble( areaPoint[0]);
|
|
|
Double areaLat = Double.parseDouble( areaPoint[1]);
|
|
|
// com.alibaba.fastjson.JSONObject positionTmp = gpsUtil.gcj02_To_Bd09(lat,lon);
|
|
|
positionTmp.put("lat",areaLat);
|
|
|
positionTmp.put("lon",areaLon);
|
|
|
fenceLocation.add(positionTmp);
|
|
|
}
|
|
|
if (!countDistance.isInPolygon(dulon,dulat,fenceLocation)){
|
|
|
// orderUtil.createSecurityOrder(sn,null,null,8,"1","yslkaqqy",null);
|
|
|
devInfoObj.put("isTrueFalse","已超出围栏范围");
|
|
|
} else {
|
|
|
devInfoObj.put("isTrueFalse","未超出围栏范围");
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
// }
|
|
@ -1012,9 +1066,9 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
|
|
|
List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSn(deviceSn);
|
|
|
if (devices.size()>0){
|
|
|
DevicePatientDevice device = devices.get(0);
|
|
|
if (!patient.equals(device.getUser())){
|
|
|
throw new Exception("居民未绑定该设备");
|
|
|
}else{
|
|
|
// if (!patient.equals(device.getUser())){
|
|
|
// throw new Exception("居民未绑定该设备");
|
|
|
// }else{
|
|
|
switch (device.getCategoryCode()){
|
|
|
case "1"://血压设备
|
|
|
result = getHealthIndex(result,1,deviceSn,patient,page,pageSize);
|
|
@ -1026,10 +1080,12 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
|
|
|
result = getEmeWarn(result,deviceSn,null,page,pageSize);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
// }
|
|
|
}else {
|
|
|
throw new Exception("设备未被绑定");
|
|
|
}
|
|
|
result.put(ResponseContant.resultFlag,ResponseContant.success);
|
|
|
result.put(ResponseContant.resultMsg,JSON.toJSONString(result,SerializerFeature.WriteMapNullValue));
|
|
|
return result;
|
|
|
}
|
|
|
|