|
|
@@ -191,6 +191,7 @@ public class WatchUserServiceImpl implements WatchUserService {
|
|
|
watchUser.setDeviceId(watchFsUser.getDeviceId());
|
|
|
watchUser.setXhsDeviceId(watchFsUser.getXhsDeviceId());
|
|
|
watchUser.setNewXhsDeviceId(watchFsUser.getNewXhsDeviceId());
|
|
|
+ watchUser.setSmartWatchDeviceId(watchFsUser.getSmartWatchDeviceId());
|
|
|
watchUser.setOtherDevice(watchFsUser.getOtherDevice());
|
|
|
watchUser.setMonitorDataTypeOrder(watchFsUser.getMonitorDataTypeOrder());
|
|
|
watchUser.setCreateTime(watchFsUser.getCreateTime());
|
|
|
@@ -343,6 +344,16 @@ public class WatchUserServiceImpl implements WatchUserService {
|
|
|
res.add(vo);
|
|
|
hasDevice = true;
|
|
|
}
|
|
|
+ String smartWatchDeviceId = deviceFamily.getSmartWatchDeviceId();
|
|
|
+ if (StringUtils.isNotBlank(smartWatchDeviceId)) {
|
|
|
+ WatchInfoVo vo = new WatchInfoVo();
|
|
|
+ BeanUtils.copyProperties(deviceFamily, vo);
|
|
|
+ vo.setDeviceId(smartWatchDeviceId);
|
|
|
+ vo.setBle("智能手表:" + deviceFamily.getSmartWatchDeviceId());
|
|
|
+ vo.setStatus(3);
|
|
|
+ res.add(vo);
|
|
|
+ hasDevice = true;
|
|
|
+ }
|
|
|
if (!hasDevice) {
|
|
|
WatchInfoVo vo = new WatchInfoVo();
|
|
|
BeanUtils.copyProperties(deviceFamily, vo);
|
|
|
@@ -406,6 +417,23 @@ public class WatchUserServiceImpl implements WatchUserService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ String smartWatchDeviceId = user.getSmartWatchDeviceId();
|
|
|
+ if (StringUtils.isNotBlank(smartWatchDeviceId)) {
|
|
|
+ List<String> smartWatchDeviceIdList = Arrays.asList(smartWatchDeviceId.split(","));
|
|
|
+ if (!smartWatchDeviceIdList.isEmpty()) {
|
|
|
+ for (String deId : smartWatchDeviceIdList) {
|
|
|
+ WatchInfoVo vo = new WatchInfoVo();
|
|
|
+ vo.setName("自己");
|
|
|
+ vo.setRelationship("自己");
|
|
|
+
|
|
|
+ vo.setDeviceId(deId);
|
|
|
+ vo.setBle("智能手表:" + deId);
|
|
|
+ vo.setStatus(3);
|
|
|
+ res.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if (res.isEmpty()) {
|
|
|
WatchInfoVo vo = new WatchInfoVo();
|
|
|
vo.setName("自己");
|
|
|
@@ -432,6 +460,7 @@ public class WatchUserServiceImpl implements WatchUserService {
|
|
|
String userId = param.get("userId");
|
|
|
String xhsDeviceId = param.get("xhsDeviceId");
|
|
|
String newXhsDeviceId = param.get("newXhsDeviceId");
|
|
|
+ String smartWatchDeviceId = param.get("smartWatchDeviceId");
|
|
|
//查询设备是否已经绑定自己
|
|
|
long userIdL = Long.parseLong(userId);
|
|
|
//1.编辑绑定设备 ,更新用户表
|
|
|
@@ -445,6 +474,9 @@ public class WatchUserServiceImpl implements WatchUserService {
|
|
|
if (StringUtils.isNotBlank(newXhsDeviceId)) {
|
|
|
watchUser.setNewXhsDeviceId(newXhsDeviceId);
|
|
|
}
|
|
|
+ if (StringUtils.isNotBlank(smartWatchDeviceId)) {
|
|
|
+ watchUser.setSmartWatchDeviceId(smartWatchDeviceId);
|
|
|
+ }
|
|
|
insert(watchUser);
|
|
|
} else {
|
|
|
if (StringUtils.isNotBlank(xhsDeviceId)) {
|
|
|
@@ -463,6 +495,14 @@ public class WatchUserServiceImpl implements WatchUserService {
|
|
|
watchFsUser.setNewXhsDeviceId(deviceId + "," + newXhsDeviceId);
|
|
|
}
|
|
|
}
|
|
|
+ if (StringUtils.isNotBlank(smartWatchDeviceId)) {
|
|
|
+ String deviceId = watchFsUser.getSmartWatchDeviceId();
|
|
|
+ if (StringUtils.isBlank(deviceId)) {
|
|
|
+ watchFsUser.setSmartWatchDeviceId(smartWatchDeviceId);
|
|
|
+ } else {
|
|
|
+ watchFsUser.setSmartWatchDeviceId(deviceId + "," + smartWatchDeviceId);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
WatchUser watchUser = setWatchUser(watchFsUser);
|
|
|
//查询是否含有腕表用户信息
|
|
|
@@ -516,13 +556,37 @@ public class WatchUserServiceImpl implements WatchUserService {
|
|
|
deviceSetupService.insertDeviceSetup(deviceSetup);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(smartWatchDeviceId)) {
|
|
|
+ WatchDeviceSetup temp = deviceSetupService.selectDeviceSetupByDeviceId(smartWatchDeviceId);
|
|
|
+ if (temp == null) {
|
|
|
+ WatchDeviceSetup deviceSetup = new WatchDeviceSetup();
|
|
|
+ deviceSetup.setDeviceId(smartWatchDeviceId);
|
|
|
+ deviceSetup.setSmartDoctor(0);
|
|
|
+ deviceSetup.setSedentary(JSONUtil.toJsonStr(new DeviceSedentary()));
|
|
|
+ deviceSetup.setFallcheck(0);
|
|
|
+ deviceSetup.setHeartHealth(0);
|
|
|
+ deviceSetup.setHralarm(JSONUtil.toJsonStr(new DeviceHralarm()));
|
|
|
+ deviceSetup.setSpo2alarm(JSONUtil.toJsonStr(new DeviceSpo2alarm()));
|
|
|
+ deviceSetup.setAlarmClock(JSONUtil.toJsonStr(new DeviceAlarmClock()));
|
|
|
+ deviceSetup.setPower(JSONUtil.toJsonStr(new DevicePower()));
|
|
|
+ deviceSetup.setPhonebook(JSONUtil.toJsonStr(new DevicePhonebooks()));
|
|
|
+ deviceSetup.setTime(JSONUtil.toJsonStr(new DeviceTime()));
|
|
|
+ deviceSetup.setLcdgesture(JSONUtil.toJsonStr(new DeviceLcdgesture()));
|
|
|
+ deviceSetup.setUnit(JSONUtil.toJsonStr(new DeviceUnit()));
|
|
|
+ deviceSetup.setMode(JSONUtil.toJsonStr(new DeviceMode()));
|
|
|
+ deviceSetup.setVersion("1.1.0");
|
|
|
+ deviceSetupService.insertDeviceSetup(deviceSetup);
|
|
|
+ }
|
|
|
+ }
|
|
|
return R.ok("绑定成功!");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public R removeXHSDevice(String userId, String xhsDeviceId,String newXhsDeviceId) {
|
|
|
+ public R removeXHSDevice(String userId, String xhsDeviceId,String newXhsDeviceId,String smartWatchDeviceId) {
|
|
|
//1.编辑绑定设备 ,更新用户表
|
|
|
- if (StringUtils.isNotBlank(xhsDeviceId) || StringUtils.isNotBlank(newXhsDeviceId)) {
|
|
|
+ if (StringUtils.isNotBlank(xhsDeviceId) || StringUtils.isNotBlank(newXhsDeviceId)
|
|
|
+ || StringUtils.isNotBlank(smartWatchDeviceId)) {
|
|
|
Long userIdL = Long.valueOf(userId);
|
|
|
//1.1判断该设备是否已经绑定
|
|
|
WatchFsUser user = null;
|
|
|
@@ -530,6 +594,8 @@ public class WatchUserServiceImpl implements WatchUserService {
|
|
|
user = selectWatchFsUserByDeviceIdAndUserId(xhsDeviceId, userIdL, 2);
|
|
|
} else if (StringUtils.isNotBlank(newXhsDeviceId)) {
|
|
|
user = selectWatchFsUserByDeviceIdAndUserId(newXhsDeviceId, userIdL, 4);
|
|
|
+ } else if (StringUtils.isNotBlank(smartWatchDeviceId)) {
|
|
|
+ user = selectWatchFsUserByDeviceIdAndUserId(smartWatchDeviceId, userIdL, 6);
|
|
|
}
|
|
|
|
|
|
if (user == null) {
|
|
|
@@ -573,6 +639,24 @@ public class WatchUserServiceImpl implements WatchUserService {
|
|
|
user.setNewXhsDeviceId(newDeviceIds.toString());
|
|
|
}
|
|
|
}
|
|
|
+ } else if (StringUtils.isNotBlank(smartWatchDeviceId)) {
|
|
|
+ String deviceIds = user.getSmartWatchDeviceId();
|
|
|
+
|
|
|
+ List<String> list = Arrays.asList(deviceIds.split(","));
|
|
|
+ if (!list.isEmpty()) {
|
|
|
+ if (list.contains(smartWatchDeviceId)) {
|
|
|
+ list = list.stream().filter(s -> !(smartWatchDeviceId.equals(s))).collect(Collectors.toList());
|
|
|
+ StringBuilder newDeviceIds = new StringBuilder();
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ if (i == 0) {
|
|
|
+ newDeviceIds.append(list.get(i));
|
|
|
+ } else {
|
|
|
+ newDeviceIds.append(",").append(list.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ user.setSmartWatchDeviceId(newDeviceIds.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
WatchUser watchUser = new WatchUser();
|
|
|
BeanUtils.copyProperties(user, watchUser);
|
|
|
@@ -588,7 +672,7 @@ public class WatchUserServiceImpl implements WatchUserService {
|
|
|
*
|
|
|
* @param deviceId
|
|
|
* @param userId
|
|
|
- * @param type 0:user 1:familyUser 2:xshUser 3:xhsFamilyUser 4:newXshUser 5:newXhsFamilyUser
|
|
|
+ * @param type 0:user 1:familyUser 2:xshUser 3:xhsFamilyUser 4:newXshUser 5:newXhsFamilyUser 6:smartWatchUser 7:smartWatchFamilyUser
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
@@ -637,6 +721,8 @@ public class WatchUserServiceImpl implements WatchUserService {
|
|
|
user = selectWatchFsUserByDeviceIdAndUserId(deviceId, watchUserId, 2);
|
|
|
} else if (deviceType == 2) {
|
|
|
user = selectWatchFsUserByDeviceIdAndUserId(deviceId, watchUserId, 4);
|
|
|
+ } else if (deviceType == 3) {
|
|
|
+ user = selectWatchFsUserByDeviceIdAndUserId(deviceId, watchUserId, 6);
|
|
|
}
|
|
|
|
|
|
if (user != null) {
|