|
@ -1,13 +1,18 @@
|
|
|
package com.yihu.jw.entrance.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.device.dao.DevicePatientHealthIndexDao;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
|
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
|
import com.yihu.jw.entity.iot.gateway.GcToken;
|
|
|
import com.yihu.jw.entrance.util.zysoft.SDKRunnerService;
|
|
|
import com.yihu.jw.entrance.util.zysoft.ZysoftBaseService;
|
|
|
import com.yihu.jw.gateway.dao.GcTokenDao;
|
|
|
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
@ -38,6 +43,10 @@ public class IotDeviceService {
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private GcTokenDao gcTokenDao;
|
|
|
@Autowired
|
|
|
private DevicePatientHealthIndexDao patientHealthIndexDao;
|
|
|
@Autowired
|
|
|
private BasePatientDao patientDao;
|
|
|
|
|
|
/**
|
|
|
* 获取accesstoken,i健康写法暂时不能用
|
|
@ -72,11 +81,46 @@ public class IotDeviceService {
|
|
|
}
|
|
|
//设备业务数据信息上传
|
|
|
@Transactional
|
|
|
public String uploadDeviceData(){
|
|
|
public String uploadDeviceData(Long id){
|
|
|
if(id == null){
|
|
|
return " id is null";
|
|
|
}
|
|
|
DevicePatientHealthIndex healthIndex = patientHealthIndexDao.findById(id).orElse(null);
|
|
|
if(healthIndex==null){
|
|
|
return " data is null";
|
|
|
}
|
|
|
JSONObject jsonData = new JSONObject();
|
|
|
jsonData.put("deviceSn",healthIndex.getDeviceSn());
|
|
|
jsonData.put("hospital","350211A1004");
|
|
|
BasePatientDO patientDO = patientDao.findById(healthIndex.getUser()).orElse(null);
|
|
|
if(patientDO!=null){
|
|
|
jsonData.put("name",patientDO.getName());
|
|
|
jsonData.put("idcard",patientDO.getIdcard());
|
|
|
}
|
|
|
JSONArray data = new JSONArray();
|
|
|
if(healthIndex.getType()==1){
|
|
|
jsonData.put("categoryCode","2");
|
|
|
JSONObject blood = new JSONObject();
|
|
|
blood.put("blood_sugar",healthIndex.getValue1());
|
|
|
blood.put("measure_time",DateUtil.dateToStrLong(healthIndex.getRecordDate()));
|
|
|
data.add(blood);
|
|
|
}else if(healthIndex.getType()==2){
|
|
|
jsonData.put("categoryCode","1");
|
|
|
// 血压:data={ "systolic ": "110", "diastolic ": "78", "pulse ": "66", "heart_rate ": "66", "measure_time ": "2023-02-02 14:07:25"
|
|
|
JSONObject blood = new JSONObject();
|
|
|
blood.put("systolic",healthIndex.getValue1());
|
|
|
blood.put("diastolic",healthIndex.getValue2());
|
|
|
blood.put("heart_rate",healthIndex.getValue3());
|
|
|
blood.put("measure_time",DateUtil.dateToStrLong(healthIndex.getRecordDate()));
|
|
|
data.add(blood);
|
|
|
}else {
|
|
|
return " only type 1 or 2";
|
|
|
}
|
|
|
jsonData.put("data",data);
|
|
|
|
|
|
Map<String,String> header = new HashMap<>();
|
|
|
String jsonData = "{\"deviceSn\":\"xty_test\",\"deviceModel\":\"测试\",\"name\":\"血糖仪TEST\",\"hospital\":\"350211A1004\",\"hospitalName\":\"厦门市第三医院\",\"categoryCode\":\"2\",\"categoryName\":\" 血糖仪\",\"commonName\":\" 血糖仪\",\"combinationMethod\":\"1\",\"networkTransmission\":\" 11\",\"deviceUse\":\"2\",\"dropLocation\":\"2\",\"dataAcquisition\":\"IoT_equipment_blood_glucose_mete\",\"companyName\":\"血糖仪厂商名称\",\"companyType\":\"3\"}";
|
|
|
Map<String,String> params = new HashMap<>();
|
|
|
params.put("jsonData",jsonData);
|
|
|
params.put("jsonData",jsonData.toJSONString());
|
|
|
header.put("accesstoken",getAccessToken());
|
|
|
String response = sdkRunnerService.post("wlw/uploadDeviceData","设备业务数据信息上传",params,header,true,true);
|
|
|
return response;
|