|
@ -15,6 +15,10 @@ import net.sf.json.JSONObject;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.commons.lang3.math.NumberUtils;
|
|
|
import org.apache.http.NameValuePair;
|
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
@ -82,6 +86,7 @@ public class DeviceService extends BaseService{
|
|
|
@Autowired
|
|
|
private IotDeviceService iotDeviceService;
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(DeviceService.class);
|
|
|
private ObjectMapper objectMapper = new ObjectMapper();
|
|
|
private Integer aStart;
|
|
|
|
|
@ -468,6 +473,19 @@ public class DeviceService extends BaseService{
|
|
|
String sql = "select count(*) num from wlyy.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\":\"MEASURE\",\"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()+"\"}";
|
|
@ -475,18 +493,12 @@ public class DeviceService extends BaseService{
|
|
|
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)){
|
|
|
List<Map<String,Object>> list = (List<Map<String,Object>>)jsonObject.get("detailModelList");
|
|
|
if (list!=null && list.size()>0){
|
|
|
String integrate = String.valueOf(list.get(0).get("integrate"));
|
|
|
//@TODO 调用发送微信模板接口
|
|
|
//这里调整到新增积分的接口中发送微信模板
|
|
|
}
|
|
|
if (!"200".equals(status)){
|
|
|
logger.error(jsonObject.getString("msg"));
|
|
|
}
|
|
|
}*/
|
|
|
}
|
|
|
|
|
|
|
|
|
//血糖、血压数据需校验,如果超标,需要发送消息给医生
|
|
|
//血糖、血压数据需校验,如果超标,需要发送消息给医生
|
|
|
if (1 == deviceType || 2 == deviceType) {
|
|
|
verifyHealthIndex(result);
|
|
|
//发送华三demo推送
|
|
@ -505,6 +517,7 @@ public class DeviceService extends BaseService{
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
logger.error(e.getMessage());
|
|
|
}
|
|
|
|
|
|
return Result.success("Device data incoming success");
|