|
@ -0,0 +1,157 @@
|
|
|
|
package com.yihu.jw.care.endpoint.device;
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import com.yihu.jw.care.dao.device.PatientDeviceDao;
|
|
|
|
import com.yihu.jw.care.endpoint.BaseController;
|
|
|
|
import com.yihu.jw.care.service.device.DeviceDetailService;
|
|
|
|
import com.yihu.jw.care.service.device.PatientDeviceService;
|
|
|
|
import com.yihu.jw.care.service.device.PatientHealthIndexService;
|
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
|
import com.yihu.jw.entity.base.sync.BaseSyncDataDO;
|
|
|
|
import com.yihu.jw.entity.care.device.DevicePatientDevice;
|
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
|
import com.yihu.jw.rm.base.BaseRequestMapping;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/***
|
|
|
|
* @ClassName: PadDeviceController
|
|
|
|
* @Description:
|
|
|
|
* @Auther: shi kejing
|
|
|
|
* @Date: 2021/5/7 13:39
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
@RequestMapping(value = "pad/device")
|
|
|
|
@Api(value = "患者设备管理(平板端)", description = "患者设备管理")
|
|
|
|
public class PadDeviceController extends BaseController {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private PatientDeviceService patientDeviceService;
|
|
|
|
@Autowired
|
|
|
|
private DeviceDetailService deviceDetailService;
|
|
|
|
@Autowired
|
|
|
|
private BasePatientDao patientDao;
|
|
|
|
private ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
@Autowired
|
|
|
|
private BaseDoctorDao baseDoctorDao;
|
|
|
|
/**
|
|
|
|
* 设备列表获取
|
|
|
|
*
|
|
|
|
* @return 操作结果
|
|
|
|
*/
|
|
|
|
@ApiOperation("管理员获取设备列表")
|
|
|
|
@RequestMapping(value = "PatientDeviceList", method = RequestMethod.GET)
|
|
|
|
public String getDeviceByPatient(@ApiParam(name = "patientName", value = "居民姓名", defaultValue = "张")
|
|
|
|
@RequestParam(value = "patientName", required = false) String patientName,
|
|
|
|
@ApiParam(name = "idcard", value = "身份证号", defaultValue = "")
|
|
|
|
@RequestParam(value = "idcard", required = false) String idcard,
|
|
|
|
@ApiParam(name = "page", value = "分页起始id", defaultValue = "1")
|
|
|
|
@RequestParam(value = "page", required = true) int page,
|
|
|
|
@ApiParam(name = "pagesize", value = "每页条数", defaultValue = "10")
|
|
|
|
@RequestParam(value = "pagesize", required = true) int pagesize) {
|
|
|
|
try {
|
|
|
|
List<Map<String , Object>> list = patientDeviceService.findDeviceFromAdmin(patientName, idcard, page, pagesize);
|
|
|
|
|
|
|
|
return write(200, "查询成功", "data", list);
|
|
|
|
} catch (Exception ex) {
|
|
|
|
error(ex);
|
|
|
|
return invalidUserException(ex, -1, ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation("平板端,添加设备时获取设备类型(大类)")
|
|
|
|
@RequestMapping(value = "getDeviceTypeBig", method = RequestMethod.GET)
|
|
|
|
public String getDeviceTypeBig(@ApiParam(name = "pyCode", value = "获取设备类型(默认为null,获取大类)", defaultValue = "")
|
|
|
|
@RequestParam(value = "pyCode", required = false) String pyCode) {
|
|
|
|
try {
|
|
|
|
List<Map<String , Object>> list = patientDeviceService.getDeviceType(1,pyCode);
|
|
|
|
return write(200, "查询成功", "data", list);
|
|
|
|
} catch (Exception ex) {
|
|
|
|
error(ex);
|
|
|
|
return invalidUserException(ex, -1, ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation("平板端,添加设备时获取设备类型(小类)")
|
|
|
|
@RequestMapping(value = "getDeviceTypeSmall", method = RequestMethod.GET)
|
|
|
|
public String getDeviceTypeSmall(@ApiParam(name = "pyCode", value = "获取设备类型(默认为 watch,获取小类(智能手表多类型))", defaultValue = "watch")
|
|
|
|
@RequestParam(value = "pyCode", required = false) String pyCode) {
|
|
|
|
try {
|
|
|
|
List<Map<String , Object>> list = patientDeviceService.getDeviceType(0,pyCode);
|
|
|
|
return write(200, "查询成功", "data", list);
|
|
|
|
} catch (Exception ex) {
|
|
|
|
error(ex);
|
|
|
|
return invalidUserException(ex, -1, ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation("设备保存接口(平板端绑定设备 设备为报警器时需要填写投放地址)")
|
|
|
|
@RequestMapping(value = "SavePatientDevice", method = RequestMethod.POST)
|
|
|
|
public String saveDevice(@ApiParam(name = "json", value = "设备数据json", defaultValue = "{ \"deviceId\":\"3\", \"deviceName\":\"血压计-优瑞恩\", \"deviceSn\":\"7052169111\", \"categoryCode\":\"7\", \"userType\":\"-1\", \"sosAddress\":\"福建省厦门市思明区望海路55号之1\" }")
|
|
|
|
@RequestParam(value = "json", required = true) String json,
|
|
|
|
@ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = false) String patientCode
|
|
|
|
) {
|
|
|
|
try {
|
|
|
|
DevicePatientDevice device = objectMapper.readValue(json, DevicePatientDevice.class);
|
|
|
|
// 设置患者标识
|
|
|
|
device.setUser(patientCode);
|
|
|
|
//患者和设备是否首绑
|
|
|
|
Map<String,Object> checkMap = patientDeviceService.checkBindingFirstAndType(device);
|
|
|
|
boolean flag = (Boolean)checkMap.get("flag");
|
|
|
|
int code = (Integer)checkMap.get("code");
|
|
|
|
if (code==-30000){
|
|
|
|
return write(-1,"设备不存在或者数据存在错误!");
|
|
|
|
}
|
|
|
|
|
|
|
|
BaseDoctorDO doctor = baseDoctorDao.findById(getUID());
|
|
|
|
device.setAgent(getUID());
|
|
|
|
device.setAgentName(doctor.getName());
|
|
|
|
String sn = device.getDeviceSn();
|
|
|
|
synchronized (sn.intern()){
|
|
|
|
Boolean flagDevice = patientDeviceService.saveDevice(device);
|
|
|
|
if (flagDevice == false){
|
|
|
|
return write(-1,"请填写投放地址");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//修改设备表中{"1":"0", "2":"0"}的绑定次数 和其他绑定信息
|
|
|
|
deviceDetailService.updateAfterBinding(device,new Date(),flag);
|
|
|
|
|
|
|
|
return success("设备保存成功!");
|
|
|
|
} catch (Exception ex) {
|
|
|
|
error(ex);
|
|
|
|
return invalidUserException(ex, -1, ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation("设备解绑接口(平板端解绑设备 )")
|
|
|
|
@RequestMapping(value = "delDeviceByDeviceSn", method = RequestMethod.POST)
|
|
|
|
public String delDeviceByDeviceSn(
|
|
|
|
@ApiParam(name = "deviceSn", value = "设备sn码") @RequestParam(value = "deviceSn", required = false) String deviceSn
|
|
|
|
) {
|
|
|
|
try {
|
|
|
|
int flagDevice = patientDeviceService.delDeviceByDeviceSn(deviceSn);
|
|
|
|
if (flagDevice == 1){
|
|
|
|
return success("设备解绑成功!");
|
|
|
|
}else {
|
|
|
|
return write(-1,"解绑失败,请确认设备sn码");
|
|
|
|
}
|
|
|
|
} catch (Exception ex) {
|
|
|
|
error(ex);
|
|
|
|
return invalidUserException(ex, -1, ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|