|
@ -353,6 +353,77 @@ public class DeviceService {
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
else if (type==1){
|
|
|
|
Double lat= null;
|
|
|
|
Double lon= null;
|
|
|
|
String address=null;
|
|
|
|
List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(deviceid);
|
|
|
|
if (devicePatientDeviceDos.size()>0){
|
|
|
|
DevicePatientDevice deviceDO = devicePatientDeviceDos.get(0);
|
|
|
|
BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());
|
|
|
|
DeviceSosLogDO logDO = new DeviceSosLogDO();
|
|
|
|
logDO.setPatient(patientDO.getId());
|
|
|
|
logDO.setPatientName(patientDO.getName());
|
|
|
|
logDO.setIdcard(patientDO.getIdcard());
|
|
|
|
logDO.setCategoryCode(deviceDO.getCategoryCode());
|
|
|
|
logDO.setDeviceSn(deviceDO.getDeviceSn());
|
|
|
|
logDO.setCreateTime(new Date());
|
|
|
|
if (deviceDO.getCategoryCode().equals("4")) {
|
|
|
|
//获取最新定位
|
|
|
|
String url = cloudCareUrl+"cloudCare/noLogin/device/getDeviceLastLocation";
|
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
|
params.add(new BasicNameValuePair("deviceSn", deviceid));
|
|
|
|
String response = httpClientUtil.get(url, params,"UTF-8");
|
|
|
|
JSONObject resObj = JSONObject.parseObject(response);
|
|
|
|
if (resObj.getInteger("status")==200){
|
|
|
|
lat = resObj.getJSONObject("data").getJSONObject("obj").getJSONObject("locationdata").getJSONObject("point").getDouble("lat");
|
|
|
|
lon = resObj.getJSONObject("data").getJSONObject("obj").getJSONObject("locationdata").getJSONObject("point").getDouble("lon");
|
|
|
|
address = resObj.getJSONObject("data").getJSONObject("obj").getJSONObject("locationdata").getString("address").replace(" ","");
|
|
|
|
logDO.setSosAddress(address);
|
|
|
|
logDO.setSosLat(lat+"");
|
|
|
|
logDO.setSosLon(lon+"");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else if (deviceDO.getCategoryCode().equals("7")) {
|
|
|
|
logDO.setSosAddress(deviceDO.getSosAddress());
|
|
|
|
Map<String, String> json = null;
|
|
|
|
if (StringUtils.isNotBlank(deviceDO.getSosAddress())) {
|
|
|
|
json = LatitudeUtils.getGeocoderLatitude(deviceDO.getSosAddress().replace("G.", "").replace("(糖友网)", "").replace("(高友网)", ""));
|
|
|
|
}
|
|
|
|
if (json != null) {
|
|
|
|
logDO.setSosLat(json.get("lat").toString());
|
|
|
|
logDO.setSosLon(json.get("lng").toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//发送紧急救助
|
|
|
|
String sql =" select Distinct pack.org_code,pack.org_name\n" +
|
|
|
|
"from base_service_package_sign_record sr INNER JOIN base_service_package_record pr\n" +
|
|
|
|
"on sr.id = pr.sign_id and sr.status=1 INNER JOIN base_service_package_item item on pr.service_package_id = item.service_package_id and item.del=1 \n" +
|
|
|
|
"INNER JOIN base_service_package pack on pr.service_package_id = pack.id where item.code='emergencyAssistance' and sr.patient='"+patientDO.getId()+"'";
|
|
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
|
|
|
|
if (sqlResult.size()>0){
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
jsonObject.put("serveAddress",logDO.getSosAddress());
|
|
|
|
jsonObject.put("serveLon",logDO.getSosLon());
|
|
|
|
jsonObject.put("serveLat",logDO.getSosLat());
|
|
|
|
jsonObject.put("orgCode",sqlResult.get(0).get("org_code").toString());
|
|
|
|
jsonObject.put("orgName",sqlResult.get(0).get("org_name").toString());
|
|
|
|
jsonObject.put("patient",logDO.getPatient());
|
|
|
|
jsonObject.put("patientName",logDO.getPatientName());
|
|
|
|
jsonObject.put("deviceSn",logDO.getDeviceSn());
|
|
|
|
String orderSource=null;
|
|
|
|
if (deviceDO.getCategoryCode().equals("4")) {
|
|
|
|
orderSource="2";
|
|
|
|
}
|
|
|
|
if (deviceDO.getCategoryCode().equals("7")) {
|
|
|
|
orderSource="3";
|
|
|
|
}
|
|
|
|
orderUtil.createEmeOrder(logDO,orderSource);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|