ソースを参照

绑定设备,修改提示语

Shi Kejing 3 年 前
コミット
543f5f4eb6

+ 10 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PadDeviceController.java

@ -144,9 +144,17 @@ public class PadDeviceController extends BaseController {
            device.setAgentName(doctor.getName());
            String sn = device.getDeviceSn();
            synchronized (sn.intern()){
                Boolean flagDevice = patientDeviceService.saveDevice(device,sleepPlan,iotDeviceSn,safeAreaGz);
                if (flagDevice == false){
                int flagDevice = patientDeviceService.saveDevice(device,sleepPlan,iotDeviceSn,safeAreaGz);
                if (flagDevice == 0){
                    return write(-1,"请填写投放地址");
                } else if (flagDevice == -1) {
                    return write(-1,"设备不存在");
                } else if (flagDevice == -2) {
                    return write(-1,"请完善睡眠时间规划");
                } else if (flagDevice == -3) {
                    return write(-1,"sn码已被使用");
                } else if (flagDevice == -4) {
                    return write(-1,"不存在该条记录");
                }
                //注册设备地址
                deviceDetailService.registerToWlyy(device);

+ 11 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java

@ -12,6 +12,7 @@ import com.yihu.jw.entity.care.device.BaseSleepPlan;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.util.entity.ServiceException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -130,9 +131,17 @@ public class PatientDeviceController extends BaseController {
            String sn = device.getDeviceSn();
            synchronized (sn.intern()){
//                patientDeviceService.saveDevice(device);
                Boolean flagDevice = patientDeviceService.saveDevice(device,sleepPlan,iotDeviceSn,safeAreaGz);
                if (flagDevice == false){
                int flagDevice = patientDeviceService.saveDevice(device,sleepPlan,iotDeviceSn,safeAreaGz);
                if (flagDevice == 0){
                    return write(-1,"请填写投放地址");
                } else if (flagDevice == -1) {
                    return write(-1,"设备不存在");
                } else if (flagDevice == -2) {
                    return write(-1,"请完善睡眠时间规划");
                } else if (flagDevice == -3) {
                    return write(-1,"sn码已被使用");
                } else if (flagDevice == -4) {
                    return write(-1,"不存在该条记录");
                }
                //注册设备地址
                deviceDetailService.registerToWlyy(device);

+ 12 - 8
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java

@ -26,6 +26,7 @@ import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.util.common.GpsUtil;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.ServiceException;
import com.yihu.jw.util.healthIndex.HealthIndexUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.mysql.query.BaseJpaService;
@ -199,7 +200,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    /**
     * 保存患者设备
     */
    public boolean saveDevice(DevicePatientDevice devicePatientDevice, BaseSleepPlan sleepPlan, String iotDeviceSn, String safeAreaGz) throws Exception {
    public int saveDevice(DevicePatientDevice devicePatientDevice, BaseSleepPlan sleepPlan, String iotDeviceSn, String safeAreaGz) throws Exception {
        //判断sn码是否被使用
        String sn = devicePatientDevice.getDeviceSn();
        String type = devicePatientDevice.getCategoryCode();
@ -214,13 +215,13 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        if (type.equals("7")){
            if (StringUtils.isBlank(devicePatientDevice.getSosAddress())){
                return false;
                return 0;
            }
        }
        if (type.equals("13")){
            if (StringUtils.isBlank(devicePatientDevice.getSosAddress())){
                return false;
                return 0;
            }
        }
@ -233,7 +234,8 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
                    needVerify = false;
                }
            } else {
                throw new Exception("不存在该条记录!");
//                throw new Exception("不存在该条记录!");
                return -4;
            }
        }
@ -246,8 +248,10 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
                //监控器 12   报警器 7  14  15
                if ("12".equals(type) || "14".equals(type) || "15".equals(type) || "7".equals(type) ) {
                    System.out.println("此类设备支持多绑定");
                } else {
                    System.out.println("sn码" + sn + "已被使用!");
                    return -3;
                }
                throw new Exception("sn码" + sn + "已被使用!");
            }
        }
        devicePatientDevice.setCzrq(new Date());
@ -262,7 +266,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
            if ("13".equals(type)){ //睡眠带
                if (StringUtils.isBlank(sleepPlan.getGetUpTime()) || StringUtils.isBlank(sleepPlan.getNightRestTime())) {
                    String message = "请完善睡眠时间规划";
                    throw new Exception(message);
                    return -2;
                }
                sleepPlanDao.save(sleepPlan);
            }
@ -276,10 +280,10 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
            patientDeviceDao.save(devicePatientDevice);
        }else {
            String message = "设备不存在";
            throw new Exception(message);
            return -1;
        }
        return true;
        return 1;
    }
    public int delDeviceByDeviceSn(String deviceSn){