Ver código fonte

Merge branch 'dev' of yeshijie/patient-co-management into dev

yeshijie 7 anos atrás
pai
commit
e6db125390

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDeviceDao.java

@ -34,7 +34,7 @@ public interface PatientDeviceDao extends PagingAndSortingRepository<PatientDevi
    //更换患者绑定的血糖仪
    @Modifying
    @Query("update PatientDevice t set t.deviceSn = ?3 , t.userType = ?4 where t.user = ?1 and t.deviceSn = ?2 ")
    int updatePatientDevice(String user, String deviceSN, String newDeviceSN,String userType);
    @Query("update PatientDevice t set t.deviceSn = ?3 , t.userType = ?4,t.sim=?5 where t.user = ?1 and t.deviceSn = ?2 ")
    int updatePatientDevice(String user, String deviceSN, String newDeviceSN,String userType,String sim);
}

+ 2 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java

@ -18,7 +18,6 @@ import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -569,8 +568,8 @@ public class PatientDeviceService extends BaseService {
     * @param newDeviceSN
     * @throws Exception
     */
    public int updatePatientDevice(String user, String deviceSN, String newDeviceSN, String userType) throws Exception {
        int rows = patientDeviceDao.updatePatientDevice(user, deviceSN, newDeviceSN, userType);
    public int updatePatientDevice(String user, String deviceSN, String newDeviceSN, String userType,String sim) throws Exception {
        int rows = patientDeviceDao.updatePatientDevice(user, deviceSN, newDeviceSN, userType,sim);
        return rows;
    }

+ 36 - 30
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java

@ -104,6 +104,7 @@ public class PatientDeviceController extends BaseController {
                               @RequestParam(required = false) String afterDinnerEnd,
                               @RequestParam(required = false) String beforeSleepStart,
                               @RequestParam(required = false) String beforeSleepEnd,
                               @RequestParam(required = false) String sim,
                               @RequestParam String deviceSN,
                               @RequestParam String categoryCode,
                               @RequestParam String userType,
@ -115,43 +116,48 @@ public class PatientDeviceController extends BaseController {
            if (StringUtils.isNotEmpty(newDeviceSN)) {
//                校验新的sn码 1.是否被占用 2.是否是真的设备码
                PatientDevice device = patientDeviceDao.findByDeviceSnAndUserType(newDeviceSN, userType);
                if (device != null) {
                    throw new Exception("sn码" + newDeviceSN + "已被使用!");
                }
                if(!newDeviceSN.equals(deviceSN)){
                    //有改sn码
                    PatientDevice device = patientDeviceDao.findByDeviceSnAndUserType(newDeviceSN, userType);
                    if (device != null) {
                        throw new Exception("sn码" + newDeviceSN + "已被使用!");
                    }
                    //注册设备
                    Map<String, String> params = new HashMap<>();
                    params.put("deviceSn", newDeviceSN);
                //注册设备
                Map<String, String> params = new HashMap<>();
                params.put("deviceSn", newDeviceSN);
                    //调用服务
                    String response = HttpClientUtil.httpPost(url + registerDevice, HttpClientUtil.getSecretParams(params, appid, secret));
                    System.out.println("注册设备=" + response);
                    JSONObject json = new JSONObject(response);
                    String code = json.get("Code").toString();
                    //10000注册成功 10001已注册 -10000参数不通过(没传参数) -10001设备不存在 -10002设备未出库
                    if ("10000".equals(code) || "10001".equals(code)) {
                //调用服务
                String response = HttpClientUtil.httpPost(url + registerDevice, HttpClientUtil.getSecretParams(params, appid, secret));
                System.out.println("注册设备=" + response);
                JSONObject json = new JSONObject(response);
                String code = json.get("Code").toString();
                //10000注册成功 10001已注册 -10000参数不通过(没传参数) -10001设备不存在 -10002设备未出库
                if ("10000".equals(code) || "10001".equals(code)) {
                    if ("1".equals(categoryCode)) {
                    } else {
                        String message = json.get("Message").toString();
                        return error(-1,message);
                    }
                }
                if ("1".equals(categoryCode)) {
//                        先修改患者设备绑定表
                        int rows = patientDeviceService.updatePatientDevice(user, deviceSN, newDeviceSN,userType);
                        if (rows != 0) {
                            //                只更换设备编码,不更改时间值
                    int rows = patientDeviceService.updatePatientDevice(user, deviceSN, newDeviceSN,userType,sim);
                    if (rows != 0) {
                        //                只更换设备编码,不更改时间值
//                1.先查询是否自定义时间段,没有则新增,有则修改
                            PatientHealthTime healthTime = patientHealthTimeDao.findByUserAndSN(user, deviceSN);
                            if (healthTime == null) {
                                patientDeviceService.setBloodTime(user, newDeviceSN, "null", "null", "null", "null", "null", "null",
                                        "null", "null", "null", "null", "null", "null", "null", "null");
                            } else {
                                patientDeviceService.updateDeviceSN(user, deviceSN, newDeviceSN);
                            }
                        PatientHealthTime healthTime = patientHealthTimeDao.findByUserAndSN(user, deviceSN);
                        if (healthTime == null) {
                            patientDeviceService.setBloodTime(user, newDeviceSN, "null", "null", "null", "null", "null", "null",
                                    "null", "null", "null", "null", "null", "null", "null", "null");
                        } else {
                            patientDeviceService.updateDeviceSN(user, deviceSN, newDeviceSN);
                        }
                    }else {
                        int rows = patientDeviceService.updatePatientDevice(user, deviceSN, newDeviceSN,userType);
                    }
                } else {
                    String message = json.get("Message").toString();
                    throw new Exception(message);
                }else {
                    int rows = patientDeviceService.updatePatientDevice(user, deviceSN, newDeviceSN,userType,sim);
                }
                return write(200, "更改sv码成功!");
            }
            patientDeviceService.setBloodTime(user, deviceSN, fastingStart, fastingEnd, afterBreakfastStart, afterBreakfastEnd, beforeLunchStart, beforeLunchEnd,