|
@ -475,23 +475,27 @@ public class DeviceService extends BaseService{
|
|
userType = "-1";
|
|
userType = "-1";
|
|
}
|
|
}
|
|
|
|
|
|
PatientDevice patientDevice = patientDeviceDao.findByDeviceSnAndCategoryCodeAndUserType(deviceSn,type,userType);
|
|
|
|
int dataUoloadCount = 0;
|
|
int dataUoloadCount = 0;
|
|
if (patientDevice!=null){
|
|
|
|
String today = DateUtil.getStringDateShort();
|
|
|
|
String startTime = today+" 00:00:00";
|
|
|
|
String endTime = today+" 23:59:59";
|
|
|
|
int dateType =1;
|
|
|
|
if (deviceType==1){
|
|
|
|
dateType=2;
|
|
|
|
}else if (deviceType==2){
|
|
|
|
dateType=1;
|
|
|
|
|
|
try {
|
|
|
|
PatientDevice patientDevice = patientDeviceDao.findByDeviceSnAndCategoryCodeAndUserType(deviceSn,type,userType);
|
|
|
|
if (patientDevice!=null){
|
|
|
|
String today = DateUtil.getStringDateShort();
|
|
|
|
String startTime = today+" 00:00:00";
|
|
|
|
String endTime = today+" 23:59:59";
|
|
|
|
int dateType =1;
|
|
|
|
if (deviceType==1){
|
|
|
|
dateType=2;
|
|
|
|
}else if (deviceType==2){
|
|
|
|
dateType=1;
|
|
|
|
}
|
|
|
|
String countSql = "SELECT count(*) num FROM device.wlyy_patient_health_index where `user`='"+patientDevice.getUser()+"' and type = "+dateType+" AND record_date >'"+startTime+"' and record_date <= '"+endTime+"'";
|
|
|
|
Map<String,Object> countMap = jdbcTemplate.queryForMap(countSql);
|
|
|
|
dataUoloadCount = Integer.valueOf(String.valueOf(countMap.get("num")));
|
|
|
|
}else {
|
|
|
|
throw new Exception("This device is not relate patient!");
|
|
}
|
|
}
|
|
String countSql = "SELECT count(*) num FROM device.wlyy_patient_health_index where `user`='"+patientDevice.getUser()+"' and type = "+dateType+" AND record_date >'"+startTime+"' and record_date <= '"+endTime+"'";
|
|
|
|
Map<String,Object> countMap = jdbcTemplate.queryForMap(countSql);
|
|
|
|
dataUoloadCount = Integer.valueOf(String.valueOf(countMap.get("num")));
|
|
|
|
}else {
|
|
|
|
throw new Exception("This device is not relate patient!");
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
logger.error(e.getMessage());
|
|
}
|
|
}
|
|
PatientHealthIndex result = savePatientDeviceData(deviceSn, type, data, uploadTime, userType, json);
|
|
PatientHealthIndex result = savePatientDeviceData(deviceSn, type, data, uploadTime, userType, json);
|
|
if (result == null) {
|
|
if (result == null) {
|
|
@ -508,51 +512,43 @@ public class DeviceService extends BaseService{
|
|
flagStr="GLU_MEASURE";
|
|
flagStr="GLU_MEASURE";
|
|
}
|
|
}
|
|
|
|
|
|
//增加积分
|
|
|
|
if (dataUoloadCount == 0 && "350205".equals(patient.getTown())){
|
|
|
|
String sql = "select count(*) num from device.wlyy_devices where device_code = '"+deviceSn+"'";
|
|
|
|
Map<String,Object> deviceCountMap = jdbcTemplate.queryForMap(sql);
|
|
|
|
if (Integer.valueOf(String.valueOf(deviceCountMap.get("num")))>0){
|
|
|
|
|
|
|
|
String url = wlyyService + "healthBank/insertCredits";
|
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
|
params.add(new BasicNameValuePair("creditsDetail", "{\"tradeType\":\"HEALTH_TASK\",\"flag\":\""+flagStr+"\",\"tradeDirection\":1,\"status\":1,\"patientId\":\""+result.getUser()+"\",\"hospital\":\"350205\"}"));
|
|
|
|
String response = HttpClientUtil.post(url, params, "UTF-8");
|
|
|
|
|
|
|
|
System.out.println(response);
|
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(response);
|
|
|
|
String status = jsonObject.getString("status");
|
|
|
|
if (!"200".equals(status)){
|
|
|
|
logger.error(jsonObject.getString("msg"));
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
//增加积分
|
|
|
|
if (dataUoloadCount == 0 && "350205".equals(patient.getTown())){
|
|
|
|
String sql = "select count(*) num from device.wlyy_devices where device_code = '"+deviceSn+"'";
|
|
|
|
Map<String,Object> deviceCountMap = jdbcTemplate.queryForMap(sql);
|
|
|
|
if (Integer.valueOf(String.valueOf(deviceCountMap.get("num")))>0){
|
|
|
|
|
|
|
|
String url = wlyyService + "healthBank/insertCredits";
|
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
|
params.add(new BasicNameValuePair("creditsDetail", "{\"tradeType\":\"ACTIVITY_TASK\",\"flag\":\""+flagStr+"\",\"tradeDirection\":1,\"status\":1,\"patientId\":\""+result.getUser()+"\",\"hospital\":\"350205\"}"));
|
|
|
|
String response = HttpClientUtil.post(url, params, "UTF-8");
|
|
|
|
|
|
|
|
System.out.println(response);
|
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(response);
|
|
|
|
String status = jsonObject.getString("status");
|
|
|
|
if (!"200".equals(status)){
|
|
|
|
logger.error(jsonObject.getString("msg"));
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
/*if (Integer.valueOf(String.valueOf(deviceCountMap.get("num")))>0){
|
|
|
|
String url = wlyyService + "/healthBank/insertCredits";
|
|
|
|
org.json.JSONObject params = new org.json.JSONObject();
|
|
|
|
String creditDetail = "{\"tradeType\":\"HEALTH_TASK\",\"flag\":\"MEASURE\",\"tradeDirection\":1,\"status\":1,\"patientId\":\""+result.getUser()+"\",\"hospital\":\""+patient.getTown()+"\"}";
|
|
|
|
params.put("creditsDetail", creditDetail);
|
|
|
|
String response = HttpClientUtil.postBody(url, params);
|
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(response);
|
|
|
|
String status = jsonObject.getString("status");
|
|
|
|
if (!"200".equals(status)){
|
|
|
|
logger.error(jsonObject.getString("msg"));
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//增加活跃度
|
|
|
|
if (dataUoloadCount == 0){
|
|
|
|
String url = wlyyService + "healthBank/createActiveRecord";
|
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
|
params.add(new BasicNameValuePair("activeRecord", "{\"taskCode\":\""+flagStr+"\",\"patientId\":\""+result.getUser()+"\"}"));
|
|
|
|
String response = HttpClientUtil.post(url, params, "UTF-8");
|
|
|
|
if (StringUtils.isNotEmpty(response)){
|
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(response);
|
|
|
|
if (!"200".equals(jsonObject.getString("status"))){
|
|
|
|
logger.info("添加活跃度失败!");
|
|
|
|
|
|
//增加活跃度
|
|
|
|
if (dataUoloadCount == 0){
|
|
|
|
String url = wlyyService + "healthBank/createActiveRecord";
|
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
|
params.add(new BasicNameValuePair("activeRecord", "{\"taskCode\":\""+flagStr+"\",\"patientId\":\""+result.getUser()+"\"}"));
|
|
|
|
String response = HttpClientUtil.post(url, params, "UTF-8");
|
|
|
|
if (StringUtils.isNotEmpty(response)){
|
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(response);
|
|
|
|
if (!"200".equals(jsonObject.getString("status"))){
|
|
|
|
logger.info("添加活跃度失败!");
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}catch (Exception e){
|
|
|
|
logger.error(e.getMessage());
|
|
}
|
|
}
|
|
|
|
|
|
//血糖、血压数据需校验,如果超标,需要发送消息给医生
|
|
//血糖、血压数据需校验,如果超标,需要发送消息给医生
|