|
@ -61,6 +61,7 @@ import javax.annotation.PostConstruct;
|
|
import java.text.MessageFormat;
|
|
import java.text.MessageFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Component
|
|
@Component
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@ -247,7 +248,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
|
|
|
|
|
|
//V1.0.0 监控器、报警器、燃气传感器 烟雾传感器支持一个设备绑定多个居民
|
|
//V1.0.0 监控器、报警器、燃气传感器 烟雾传感器支持一个设备绑定多个居民
|
|
//监控器 12 报警器 7 14 15
|
|
//监控器 12 报警器 7 14 15
|
|
if ("12".equals(type) || "14".equals(type) || "15".equals(type) || "7".equals(type) ) {
|
|
|
|
|
|
if ("12".equals(type) || "14".equals(type) || "15".equals(type)) {
|
|
if (devicePatientDevice.getUser().equals(device.getUser())) {
|
|
if (devicePatientDevice.getUser().equals(device.getUser())) {
|
|
System.out.println("居民已经绑定此sn码:"+sn);
|
|
System.out.println("居民已经绑定此sn码:"+sn);
|
|
return -5;
|
|
return -5;
|
|
@ -902,12 +903,11 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
|
|
result.put(ResponseContant.resultFlag,ResponseContant.fail);
|
|
result.put(ResponseContant.resultFlag,ResponseContant.fail);
|
|
result.put(ResponseContant.resultMsg,"居民未绑定该设备");
|
|
result.put(ResponseContant.resultMsg,"居民未绑定该设备");
|
|
}else {
|
|
}else {
|
|
String sql = "select dd.photo,pd.device_sn,dd.brands,dd.category_code,dd.model,pd.device_name,date_format(pd.czrq,'%Y-%m-%d %H:%i:%S' ) deviceTime " +
|
|
|
|
"from dm_device dd INNER JOIN wlyy_patient_device pd on dd.category_code = pd.category_code INNER JOIN wlyy_devices wd on dd.model = wd.device_model and pd.device_sn = wd.device_code \n" +
|
|
|
|
"where 1=1 and pd.del=0 and pd.device_sn ='"+deviceSn+"' group by pd.user";
|
|
|
|
|
|
String sql = "select dd.photo,GROUP_CONCAT( p.name) as patientName,pd.device_sn,dd.brands,dd.category_code,dd.model,pd.device_name,date_format(pd.czrq,'%Y-%m-%d %H:%i:%S' ) deviceTime " +
|
|
|
|
"from dm_device dd INNER JOIN wlyy_patient_device pd on dd.category_code = pd.category_code INNER JOIN base_patient p on p.id = pd.user \n" +
|
|
|
|
"where 1=1 and pd.del=0 and pd.device_sn ='"+deviceSn+"' group by pd.device_sn";
|
|
Map<String,Object> devInfo = jdbcTemplate.queryForMap(sql);
|
|
Map<String,Object> devInfo = jdbcTemplate.queryForMap(sql);
|
|
devInfo.put("patient",patient);
|
|
devInfo.put("patient",patient);
|
|
devInfo.put("patientName",patientDO.getName());
|
|
|
|
devInfo.put("sosContactsDOS",new ArrayList<>());
|
|
devInfo.put("sosContactsDOS",new ArrayList<>());
|
|
if ("4".equals(device.getCategoryCode())||"7".equals(device.getCategoryCode())){
|
|
if ("4".equals(device.getCategoryCode())||"7".equals(device.getCategoryCode())){
|
|
devInfo.put("sosContactsDOS",contactsService.getPatientSosContacts(patient));
|
|
devInfo.put("sosContactsDOS",contactsService.getPatientSosContacts(patient));
|
|
@ -975,13 +975,13 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
|
|
}else{
|
|
}else{
|
|
switch (device.getCategoryCode()){
|
|
switch (device.getCategoryCode()){
|
|
case "1"://血压设备
|
|
case "1"://血压设备
|
|
result = getHealthIndex(result,deviceSn,patient,page,pageSize);
|
|
|
|
|
|
result = getHealthIndex(result,deviceSn,null,page,pageSize);
|
|
break;
|
|
break;
|
|
case "2"://血糖设备
|
|
case "2"://血糖设备
|
|
result = getHealthIndex(result,deviceSn,patient,page,pageSize);
|
|
|
|
|
|
result = getHealthIndex(result,deviceSn,null,page,pageSize);
|
|
break;
|
|
break;
|
|
default://安防设备
|
|
default://安防设备
|
|
result = getEmeWarn(result,deviceSn,patient,page,pageSize);
|
|
|
|
|
|
result = getEmeWarn(result,deviceSn,null,page,pageSize);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@ -1024,15 +1024,23 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
|
|
" and ord.patient='"+patient+"' " +
|
|
" and ord.patient='"+patient+"' " +
|
|
"UNION All " +
|
|
"UNION All " +
|
|
"select count(ord.id) as total from base_security_monitoring_order ord where ord.device_sn='"+deviceSn+"' " +
|
|
"select count(ord.id) as total from base_security_monitoring_order ord where ord.device_sn='"+deviceSn+"' " +
|
|
" and ord.patient='"+patient+"' )A ";
|
|
|
|
long count = jdbcTemplate.queryForObject(sqlCount,long.class);
|
|
|
|
|
|
" {{patient}} )A ";
|
|
String sql = "select '20' as OrderType,ord.id,ord.patient,ord.patient_name,ord.doctor,ord.status,ord.doctor_name," +
|
|
String sql = "select '20' as OrderType,ord.id,ord.patient,ord.patient_name,ord.doctor,ord.status,ord.doctor_name," +
|
|
"'紧急呼叫' as serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time " +
|
|
"'紧急呼叫' as serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time " +
|
|
"from base_emergency_assistance_order ord where ord.device_sn='"+deviceSn+"' and ord.patient='"+patient+"' " +
|
|
"from base_emergency_assistance_order ord where ord.device_sn='"+deviceSn+"' and ord.patient='"+patient+"' " +
|
|
"UNION " +
|
|
"UNION " +
|
|
"select '22' as 'OrderType',ord.id,ord.patient,ord.patient_name,ord.doctor,ord.status,ord.doctor_name," +
|
|
"select '22' as 'OrderType',ord.id,ord.patient,ord.patient_name,ord.doctor,ord.status,ord.doctor_name," +
|
|
"ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_security_monitoring_order ord " +
|
|
"ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_security_monitoring_order ord " +
|
|
" where ord.device_sn='"+deviceSn+"' and ord.patient='"+patient+"' order by create_time desc limit "+page*pageSize+","+pageSize;
|
|
|
|
|
|
" where ord.device_sn='"+deviceSn+"' {{patient}} order by create_time desc limit "+page*pageSize+","+pageSize;
|
|
|
|
if (StringUtils.isNotBlank(patient)){
|
|
|
|
sqlCount = sqlCount.replace("{{patient}}","and ord.patient='"+patient+"' ");
|
|
|
|
sql = sql.replace("{{patient}}","and ord.patient='"+patient+"' ");
|
|
|
|
}else {
|
|
|
|
sqlCount = sqlCount.replace("{{patient}}"," ");
|
|
|
|
sql = sql.replace("{{patient}}"," ");
|
|
|
|
}
|
|
|
|
long count = jdbcTemplate.queryForObject(sqlCount,long.class);
|
|
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
result.put("total",count);
|
|
result.put("total",count);
|
|
result.put("page",page+1);
|
|
result.put("page",page+1);
|
|
@ -1202,7 +1210,9 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
|
|
* @param time_begin YYYYMMDD 日期
|
|
* @param time_begin YYYYMMDD 日期
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public com.alibaba.fastjson.JSONObject getX1Locations(String deviceSn,String time_begin){
|
|
|
|
|
|
public JSONArray getX1Locations(String deviceSn,String time_begin){
|
|
|
|
|
|
|
|
JSONArray result = new JSONArray();
|
|
|
|
|
|
String url = AqgConfig.X1_locations+"?device="+deviceSn+"&depth="+1+"&rows_per_page="+300;
|
|
String url = AqgConfig.X1_locations+"?device="+deviceSn+"&depth="+1+"&rows_per_page="+300;
|
|
if (StringUtils.isNotBlank(time_begin)){
|
|
if (StringUtils.isNotBlank(time_begin)){
|
|
@ -1212,8 +1222,20 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
|
|
headers.put("Accept", MediaType.APPLICATION_JSON.toString());
|
|
headers.put("Accept", MediaType.APPLICATION_JSON.toString());
|
|
headers.put("Cookie", getCookie());
|
|
headers.put("Cookie", getCookie());
|
|
String responseStr = httpClientUtil.get(url,"utf-8",headers);
|
|
String responseStr = httpClientUtil.get(url,"utf-8",headers);
|
|
com.alibaba.fastjson.JSONObject result = JSON.parseObject(responseStr);
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject resObj = JSON.parseObject(responseStr);
|
|
|
|
if (resObj.getBooleanValue("success")){
|
|
|
|
com.alibaba.fastjson.JSONArray arr = resObj.getJSONArray("objs");
|
|
|
|
arr.sort(Comparator.comparing(obj -> ((JSONObject) obj).getLong("created_at")));
|
|
|
|
for (int i=0;i<arr.size();i++){
|
|
|
|
com.alibaba.fastjson.JSONObject obj = arr.getJSONObject(i);
|
|
|
|
com.alibaba.fastjson.JSONArray pointArr = obj.getJSONObject("point").getJSONArray("coordinates");
|
|
|
|
Double lon = pointArr.getDouble(0);
|
|
|
|
Double lat = pointArr.getDouble(1);
|
|
|
|
com.alibaba.fastjson.JSONObject pointJson = gpsUtil.gcj02_To_Bd09(lat,lon);
|
|
|
|
result.put(pointJson);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|