宠物笼设备相关接口
This commit is contained in:
parent
9dde87a661
commit
3174cc6998
|
|
@ -280,6 +280,18 @@ public class UserAction {
|
||||||
return baseService.bindCamera(userId, cameraId);
|
return baseService.bindCamera(userId, cameraId);
|
||||||
} /**
|
} /**
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分享摄像头
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @param cameraId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/shareCameraByQrCode.do")
|
||||||
|
public Object shareCameraByQrCode(Integer userId, String cameraId) {
|
||||||
|
return baseService.shareCameraByQrCode(userId, cameraId);
|
||||||
|
} /**
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关联设备和摄像头
|
* 关联设备和摄像头
|
||||||
*
|
*
|
||||||
|
|
@ -306,9 +318,9 @@ public class UserAction {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/deviceBindCamera1.do")
|
@RequestMapping("/deviceBindCamera1.do")
|
||||||
public Object deviceBindCamera1(Integer userId, Integer deviceId, String cameraId) {
|
public Object deviceBindCamera1(Integer userId, Integer deviceId, String cameraId, String type) {
|
||||||
try {
|
try {
|
||||||
return baseService.deviceBindCamera1(userId, deviceId, cameraId);
|
return baseService.deviceBindCamera1(userId, deviceId, cameraId, type);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("DeviceBindCamera1:userId:{},cameraId:{},error message:{}", userId, deviceId, cameraId, e.toString());
|
log.error("DeviceBindCamera1:userId:{},cameraId:{},error message:{}", userId, deviceId, cameraId, e.toString());
|
||||||
}
|
}
|
||||||
|
|
@ -431,6 +443,21 @@ public class UserAction {
|
||||||
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除绑定设备
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/deletePetDeviceUser.do")
|
||||||
|
public Object deletePetDeviceUser(String userId, String deviceId) {
|
||||||
|
try {
|
||||||
|
return baseService.deletePetDeviceUser(userId, deviceId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("delete the binding device:userId:{},deviceId:{},error message:{}", userId, deviceId);
|
||||||
|
}
|
||||||
|
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除绑定的摄像头
|
* 删除绑定的摄像头
|
||||||
*
|
*
|
||||||
|
|
@ -481,6 +508,24 @@ public class UserAction {
|
||||||
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 扫一扫分享设备
|
||||||
|
*
|
||||||
|
* @param user
|
||||||
|
* @param device
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@RequestMapping("/sharePetDeviceByQrCode.do")
|
||||||
|
public Object sharePetDeviceByQrCode(Integer userId, Integer deviceId) {
|
||||||
|
try {
|
||||||
|
return baseService.sharePetDeviceByQrCode(userId, deviceId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("share device by qrCode:userId:{},deviceId:{},error message:{}", userId, deviceId, e.toString());
|
||||||
|
}
|
||||||
|
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取最新版本信息
|
* 获取最新版本信息
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,12 @@ public interface DevicePetUserDao extends BaseDao<DevicePetUser, DeviceUserId>{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据deviceId查询设备和用户对应数据
|
* 根据deviceId查询设备和用户对应数据
|
||||||
* @param deviceId
|
* @param userId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<DevicePetUser> getUserIdByDeviceId(Integer deviceId);
|
List<DevicePetUser> getUserIdByDeviceId(Integer userId);
|
||||||
|
|
||||||
|
List<DevicePetUser> findByDeviceId(Integer deviceId);
|
||||||
|
|
||||||
|
DevicePetUser getDevicePetUserByUseridAndDeviceId(String userId, String deviceId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,4 +84,22 @@ public class DevicePeiUserDaoImpl extends HibernateBaseDao<DevicePetUser, Device
|
||||||
List<DevicePetUser> devicePetUsers = this.findByProperty(criterion);
|
List<DevicePetUser> devicePetUsers = this.findByProperty(criterion);
|
||||||
return devicePetUsers;
|
return devicePetUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param deviceId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<DevicePetUser> findByDeviceId(Integer deviceId) {
|
||||||
|
Criterion criterion = Restrictions.eq("priId.deviceId",deviceId);
|
||||||
|
List<DevicePetUser> devicePetUsers = this.findByProperty(criterion);
|
||||||
|
return devicePetUsers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DevicePetUser getDevicePetUserByUseridAndDeviceId(String userId, String deviceId) {
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@ public class DevicePetUser implements Serializable{
|
||||||
//显示名称
|
//显示名称
|
||||||
private String showName;
|
private String showName;
|
||||||
private String storeName;
|
private String storeName;
|
||||||
|
private Integer isMaster;
|
||||||
|
//创建时间
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
public DevicePetUser() {}
|
public DevicePetUser() {}
|
||||||
|
|
||||||
|
|
@ -45,4 +48,20 @@ public class DevicePetUser implements Serializable{
|
||||||
public void setStoreName(String storeName) {
|
public void setStoreName(String storeName) {
|
||||||
this.storeName = storeName;
|
this.storeName = storeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getIsMaster() {
|
||||||
|
return isMaster;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsMaster(Integer isMaster) {
|
||||||
|
this.isMaster = isMaster;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,8 @@
|
||||||
<key-property name="userId" column="user_id" type="java.lang.Integer" />
|
<key-property name="userId" column="user_id" type="java.lang.Integer" />
|
||||||
<key-property name="deviceId" column="device_id" type="java.lang.Integer" />
|
<key-property name="deviceId" column="device_id" type="java.lang.Integer" />
|
||||||
</composite-id>
|
</composite-id>
|
||||||
<property name="showName" column="device_name" type="string" length="255" />
|
<property name="showName" column="device_name" type="string" length="255" />
|
||||||
<property name="storeName" column="store_name" type="string" length="255" />
|
<property name="storeName" column="store_name" type="string" length="255" />
|
||||||
|
<property name="isMaster" column="is_master" type="java.lang.Integer" length="10" />
|
||||||
</class>
|
</class>
|
||||||
</hibernate-mapping>
|
</hibernate-mapping>
|
||||||
|
|
@ -472,7 +472,7 @@ public class UserHelper implements UserHelperI {
|
||||||
DeviceUserBean deviceUser = new DeviceUserBean();
|
DeviceUserBean deviceUser = new DeviceUserBean();
|
||||||
deviceUser.setDeviceId(devicePetUser.getPriId().getDeviceId());
|
deviceUser.setDeviceId(devicePetUser.getPriId().getDeviceId());
|
||||||
deviceUser.setUserId(devicePetUser.getPriId().getUserId());
|
deviceUser.setUserId(devicePetUser.getPriId().getUserId());
|
||||||
deviceUser.setIsMaster("0");
|
deviceUser.setIsMaster("1");
|
||||||
deviceUser.setShowName(devicePetUser.getShowName());
|
deviceUser.setShowName(devicePetUser.getShowName());
|
||||||
|
|
||||||
if (storeNamesList.containsKey(devicePetUser.getStoreName())) {
|
if (storeNamesList.containsKey(devicePetUser.getStoreName())) {
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public interface BaseService {
|
||||||
public Object activeCamera(String activeCode,String cameraId);
|
public Object activeCamera(String activeCode,String cameraId);
|
||||||
|
|
||||||
//设备和摄像头关联
|
//设备和摄像头关联
|
||||||
public Object deviceBindCamera1(Integer userId,Integer deviceId,String cameraId);
|
public Object deviceBindCamera1(Integer userId,Integer deviceId,String cameraId, String type);
|
||||||
|
|
||||||
//设备和摄像头关联
|
//设备和摄像头关联
|
||||||
public Object deviceBindCamera(Integer deviceId,String cameraId);
|
public Object deviceBindCamera(Integer deviceId,String cameraId);
|
||||||
|
|
@ -86,7 +86,15 @@ public interface BaseService {
|
||||||
|
|
||||||
//删除绑定的设备
|
//删除绑定的设备
|
||||||
public Object deleteDeviceUser(DeviceUser deviceUser);
|
public Object deleteDeviceUser(DeviceUser deviceUser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除宠物笼设备
|
||||||
|
* @param userId
|
||||||
|
* @param deviceId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Object deletePetDeviceUser(String userId, String deviceId);
|
||||||
|
|
||||||
//删除绑定的摄像头
|
//删除绑定的摄像头
|
||||||
public Object deleteCameraUser(Integer userId,String cameraId);
|
public Object deleteCameraUser(Integer userId,String cameraId);
|
||||||
|
|
||||||
|
|
@ -94,9 +102,12 @@ public interface BaseService {
|
||||||
public Object deleteDeviceCamera(Integer deviceId,String cameraId);
|
public Object deleteDeviceCamera(Integer deviceId,String cameraId);
|
||||||
|
|
||||||
//扫一扫分享设备
|
//扫一扫分享设备
|
||||||
@Deprecated
|
|
||||||
public Object shareDeviceByQrCode(Integer userId,Integer deviceId);
|
public Object shareDeviceByQrCode(Integer userId,Integer deviceId);
|
||||||
|
|
||||||
|
public Object shareCameraByQrCode(Integer userId,String cameraId);
|
||||||
|
|
||||||
|
public Object sharePetDeviceByQrCode(Integer userId,Integer deviceId);
|
||||||
|
|
||||||
//获取最新版本信息
|
//获取最新版本信息
|
||||||
public Object getNewestVersionInf(String phoneType);
|
public Object getNewestVersionInf(String phoneType);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -453,6 +453,9 @@ public class BaseServiceImpl implements BaseService {
|
||||||
//新增用户拥有设备
|
//新增用户拥有设备
|
||||||
DeviceUser deviceUser = new DeviceUser();
|
DeviceUser deviceUser = new DeviceUser();
|
||||||
Device device = this.deviceDao.findUniqueByProperty(Restrictions.eq("macAddress", madAddress));
|
Device device = this.deviceDao.findUniqueByProperty(Restrictions.eq("macAddress", madAddress));
|
||||||
|
if (device != null && device.getHardwareType().equals("3f")) {
|
||||||
|
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "设备类型不匹配,请重新选择入口绑定");
|
||||||
|
}
|
||||||
boolean bln = false;
|
boolean bln = false;
|
||||||
//设备存在
|
//设备存在
|
||||||
if (device != null) {
|
if (device != null) {
|
||||||
|
|
@ -573,7 +576,7 @@ public class BaseServiceImpl implements BaseService {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
deviceUser.setUpdateTime(date);
|
deviceUser.setUpdateTime(date);
|
||||||
deviceUser.setCreateTime(date);
|
deviceUser.setCreateTime(date);
|
||||||
this.deviceUserDao.save(deviceUser);
|
deviceUserDao.save(deviceUser);
|
||||||
}
|
}
|
||||||
//封装设备返回信息
|
//封装设备返回信息
|
||||||
return IfishUtil.returnJson(ResultEnum.success.getKey(), getDeviceInfo(device, deviceUser));
|
return IfishUtil.returnJson(ResultEnum.success.getKey(), getDeviceInfo(device, deviceUser));
|
||||||
|
|
@ -587,25 +590,31 @@ public class BaseServiceImpl implements BaseService {
|
||||||
* 绑定宠物笼设备
|
* 绑定宠物笼设备
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object bindPetDevice(User user, String madAddress, String storeName) {
|
public Object bindPetDevice(User user, String macAddress, String storeName) {
|
||||||
User tmpUser = userDao.get(user.getUserId());
|
User tmpUser = userDao.get(user.getUserId());
|
||||||
//新增用户拥有设备
|
//新增用户拥有设备
|
||||||
DevicePetUser devicePetUser = new DevicePetUser();
|
DevicePetUser devicePetUser = new DevicePetUser();
|
||||||
//新增设备信息
|
Device device = this.deviceDao.findUniqueByProperty(Restrictions.eq("macAddress", macAddress));
|
||||||
Device device = new Device();
|
if (device == null) {
|
||||||
device.setLoginCount(0);
|
//新增设备信息
|
||||||
device.setIsBlacklist(BooleanEnum.YES.getKey());
|
device = new Device();
|
||||||
device.setMacAddress(madAddress);
|
device.setLoginCount(0);
|
||||||
Date date = new Date();
|
device.setIsBlacklist(BooleanEnum.YES.getKey());
|
||||||
device.setFirstActivate(date);
|
device.setMacAddress(macAddress);
|
||||||
device.setCreateDate(date);
|
Date date = new Date();
|
||||||
device.setCreateTime(date);
|
device.setFirstActivate(date);
|
||||||
device = this.deviceDao.save(device);
|
device.setCreateDate(date);
|
||||||
|
device.setCreateTime(date);
|
||||||
|
device = this.deviceDao.save(device);
|
||||||
|
} else if (!device.getHardwareType().equals("3f")) {
|
||||||
|
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "设备类型不匹配,请重新选择入口绑定");
|
||||||
|
}
|
||||||
|
|
||||||
devicePetUser.getPriId().setUserId(tmpUser.getUserId());
|
devicePetUser.getPriId().setUserId(tmpUser.getUserId());
|
||||||
devicePetUser.getPriId().setDeviceId(device.getDeviceId());
|
devicePetUser.getPriId().setDeviceId(device.getDeviceId());
|
||||||
devicePetUser.setShowName("宠物笼" + (int) (Math.random() * 9000 + 1000));
|
devicePetUser.setShowName("宠物笼" + (int) (Math.random() * 9000 + 1000));
|
||||||
devicePetUser.setStoreName(storeName);
|
devicePetUser.setStoreName(storeName);
|
||||||
|
devicePetUser.setIsMaster(0);
|
||||||
|
|
||||||
this.devicePetUserDao.save(devicePetUser);
|
this.devicePetUserDao.save(devicePetUser);
|
||||||
|
|
||||||
|
|
@ -687,6 +696,34 @@ public class BaseServiceImpl implements BaseService {
|
||||||
return IfishUtil.returnJson(ResultEnum.success.getKey(),"");
|
return IfishUtil.returnJson(ResultEnum.success.getKey(),"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object shareCameraByQrCode(Integer userId, String cameraId) {
|
||||||
|
User user = userDao.get(userId);
|
||||||
|
Camera camera = this.cameraDao.get(cameraId);
|
||||||
|
//返回数据
|
||||||
|
Map<String, Object> dataMap = new HashMap();
|
||||||
|
if (user != null && camera != null) {
|
||||||
|
//建立关系
|
||||||
|
CameraUser cameraUser = new CameraUser();
|
||||||
|
CameraUserId cameraUserId = new CameraUserId(userId, String.valueOf(cameraId));
|
||||||
|
cameraUser.setCameraUserId(cameraUserId);
|
||||||
|
cameraUser.setIsMaster(BooleanEnum.NO.getKey());
|
||||||
|
cameraUser.setIsLook(BooleanEnum.NO.getKey());
|
||||||
|
cameraUser.setIsLive(BooleanEnum.NO.getKey());
|
||||||
|
cameraUser.setShowName("摄像头" + (int) (Math.random() * 900 + 100));
|
||||||
|
cameraUser.setCreateTime(new Date());
|
||||||
|
this.cameraUserDao.save(cameraUser);
|
||||||
|
//返回数据
|
||||||
|
dataMap.put("cameraId", cameraId);
|
||||||
|
dataMap.put("showName", cameraUser.getShowName());
|
||||||
|
dataMap.put("isMaster", cameraUser.getIsMaster());
|
||||||
|
dataMap.put("isLook", cameraUser.getIsLook());
|
||||||
|
dataMap.put("isLive", cameraUser.getIsLive());
|
||||||
|
dataMap.put("isActive", camera.getActiveCode() != null && !camera.getActiveCode().equals("") ? "1" : "0");
|
||||||
|
return IfishUtil.returnJson(ResultEnum.success.getKey(), dataMap);
|
||||||
|
}
|
||||||
|
return IfishUtil.returnJson(ResultEnum.warn202.getKey(), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -879,7 +916,7 @@ public class BaseServiceImpl implements BaseService {
|
||||||
Map<String, Object> deviceMap = new HashMap<String, Object>();
|
Map<String, Object> deviceMap = new HashMap<String, Object>();
|
||||||
deviceMap.put("userId", devicePetUser.getPriId().getUserId());
|
deviceMap.put("userId", devicePetUser.getPriId().getUserId());
|
||||||
deviceMap.put("deviceId", devicePetUser.getPriId().getDeviceId());
|
deviceMap.put("deviceId", devicePetUser.getPriId().getDeviceId());
|
||||||
deviceMap.put("isMaster", "");
|
deviceMap.put("isMaster", devicePetUser.getIsMaster() == 0 ? "1" : "0");
|
||||||
deviceMap.put("showName", devicePetUser.getShowName());
|
deviceMap.put("showName", devicePetUser.getShowName());
|
||||||
deviceMap.put("macAddress", device.getMacAddress());
|
deviceMap.put("macAddress", device.getMacAddress());
|
||||||
deviceMap.put("isBlacklist", device.getIsBlacklist());
|
deviceMap.put("isBlacklist", device.getIsBlacklist());
|
||||||
|
|
@ -1071,6 +1108,67 @@ public class BaseServiceImpl implements BaseService {
|
||||||
return IfishUtil.returnJson(ResultEnum.success.getKey(), "");
|
return IfishUtil.returnJson(ResultEnum.success.getKey(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object deletePetDeviceUser(String userId, String deviceId) {
|
||||||
|
DevicePetUser devicePetUser = devicePetUserDao.findUniqueByProperty(Restrictions.eq("priId.userId", Integer.parseInt(userId)), Restrictions.eq("priId.deviceId", Integer.parseInt(deviceId)));
|
||||||
|
if (devicePetUser != null && devicePetUser.getIsMaster().intValue() == 0) {
|
||||||
|
List<DevicePetUser> userIdByDeviceId = devicePetUserDao.findByDeviceId(Integer.parseInt(deviceId));
|
||||||
|
for (DevicePetUser petUser : userIdByDeviceId) {
|
||||||
|
Integer userId1 = petUser.getPriId().getUserId();
|
||||||
|
Integer deviceId1 = petUser.getPriId().getDeviceId();
|
||||||
|
//获取设备
|
||||||
|
Device device = this.deviceDao.get(deviceId1);
|
||||||
|
//关闭换水提醒开关
|
||||||
|
device.setWaterRemind("0");
|
||||||
|
this.deviceDao.update(device);
|
||||||
|
//查询推送表中当前设备的所有数据
|
||||||
|
List<PushRemind> pushReminds = this.pushRemindDao.getPushRemindByDeviceId(deviceId1);
|
||||||
|
for (PushRemind pushRemind : pushReminds) {
|
||||||
|
this.pushRemindDao.delete(pushRemind);
|
||||||
|
}
|
||||||
|
User tu = this.userDao.get(userId1);
|
||||||
|
if (tu != null) {
|
||||||
|
String timestamp = IfishUtil.format(new Date());
|
||||||
|
//基本参数
|
||||||
|
Map<String, String> baseMap = new HashMap<String, String>();
|
||||||
|
baseMap.put("title", PushTypeEnum.remove_device.getValue());
|
||||||
|
baseMap.put("content", "你已于" + timestamp + "失去对“" + petUser.getShowName() + "”设备的控制权");
|
||||||
|
baseMap.put("user_id", userId1.toString());
|
||||||
|
baseMap.put("loginType", tu.getLoginType());
|
||||||
|
//推送参数
|
||||||
|
Map<String, String> pushMap = new HashMap<String, String>();
|
||||||
|
pushMap.put("device_id", deviceId1.toString());
|
||||||
|
pushMap.put("device_name", petUser.getShowName());
|
||||||
|
pushMap.put("timestamp", timestamp);
|
||||||
|
pushMap.put("msg_type", PushTypeEnum.remove_device.getKey());
|
||||||
|
//推送消息
|
||||||
|
jPushNotifcation(baseMap, pushMap);
|
||||||
|
}
|
||||||
|
devicePetUserDao.delete(petUser);
|
||||||
|
}
|
||||||
|
//删除设备和摄像头关系
|
||||||
|
DeviceCamera deviceCamera = this.deviceCameraDao.findUniqueByProperty(Restrictions.eq("deviceCameraId.deviceId", devicePetUser.getPriId().getDeviceId()));
|
||||||
|
if (deviceCamera != null) {
|
||||||
|
this.deviceCameraDao.delete(deviceCamera);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//获取设备
|
||||||
|
Device device = this.deviceDao.get(devicePetUser.getPriId().getDeviceId());
|
||||||
|
//关闭换水提醒开关
|
||||||
|
device.setWaterRemind("0");
|
||||||
|
this.deviceDao.update(device);
|
||||||
|
//查询用户和设备的绑定关系 之后删除
|
||||||
|
List<PushRemind> pushReminds = this.pushRemindDao.findByProperty(Restrictions.eq("id.deviceId", devicePetUser.getPriId().getDeviceId()), Restrictions.eq("id.userId", devicePetUser.getPriId().getUserId()));
|
||||||
|
for (PushRemind pushRemind : pushReminds) {
|
||||||
|
this.pushRemindDao.delete(pushRemind);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (devicePetUser != null) {
|
||||||
|
devicePetUserDao.delete(devicePetUser);
|
||||||
|
}
|
||||||
|
return IfishUtil.returnJson(ResultEnum.success.getKey(), "");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除绑定的摄像头
|
* 删除绑定的摄像头
|
||||||
*/
|
*/
|
||||||
|
|
@ -1201,6 +1299,33 @@ public class BaseServiceImpl implements BaseService {
|
||||||
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object sharePetDeviceByQrCode(Integer userId, Integer deviceId) {
|
||||||
|
User user = userDao.get(userId);
|
||||||
|
Device device = deviceDao.get(deviceId);
|
||||||
|
if (user != null && device != null) {
|
||||||
|
DevicePetUser devicePetUser = new DevicePetUser();
|
||||||
|
devicePetUser.getPriId().setUserId(user.getUserId());
|
||||||
|
devicePetUser.getPriId().setDeviceId(device.getDeviceId());
|
||||||
|
DevicePetUser devicePetUser1 = devicePetUserDao.get(devicePetUser.getPriId());
|
||||||
|
if (devicePetUser1 != null) {
|
||||||
|
//封装设备返回信息
|
||||||
|
return IfishUtil.returnJson(ResultEnum.success.getKey(), getDeviceInfo(device, devicePetUser1));
|
||||||
|
} else {
|
||||||
|
List<DevicePetUser> byDeviceId = devicePetUserDao.findByDeviceId(device.getDeviceId());
|
||||||
|
if (byDeviceId != null && byDeviceId.size() > 0) {
|
||||||
|
devicePetUser.setStoreName(byDeviceId.get(0).getStoreName());
|
||||||
|
}
|
||||||
|
devicePetUser.setIsMaster(1);
|
||||||
|
devicePetUser.setShowName("宠物笼" + (int) (Math.random() * 9000 + 1000));
|
||||||
|
this.devicePetUserDao.save(devicePetUser);
|
||||||
|
//封装设备返回信息
|
||||||
|
return IfishUtil.returnJson(ResultEnum.success.getKey(), getDeviceInfo(device, devicePetUser));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 极光推送
|
* 极光推送
|
||||||
*
|
*
|
||||||
|
|
@ -1433,15 +1558,24 @@ public class BaseServiceImpl implements BaseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object deviceBindCamera1(Integer userId, Integer deviceId, String cameraId) {
|
public Object deviceBindCamera1(Integer userId, Integer deviceId, String cameraId, String type) {
|
||||||
//设备和用户关系
|
//设备和用户关系
|
||||||
DeviceUserId priId = new DeviceUserId();
|
DeviceUserId priId = new DeviceUserId();
|
||||||
priId.setDeviceId(deviceId);
|
priId.setDeviceId(deviceId);
|
||||||
priId.setUserId(userId);
|
priId.setUserId(userId);
|
||||||
DeviceUser deviceUser = this.deviceUserDao.get(priId);
|
if (null == type || "".equals(type) || "null".equals(type)) {
|
||||||
if (deviceUser == null) {
|
DeviceUser deviceUser = this.deviceUserDao.get(priId);
|
||||||
return IfishUtil.returnJson(ResultEnum.warn207.getKey(), "");
|
if (deviceUser == null) {
|
||||||
|
return IfishUtil.returnJson(ResultEnum.warn207.getKey(), "");
|
||||||
|
}
|
||||||
|
} else if ("1".equals(type)) {
|
||||||
|
//宠物笼设备
|
||||||
|
DevicePetUser devicePetUser = this.devicePetUserDao.get(priId);
|
||||||
|
if (devicePetUser == null) {
|
||||||
|
return IfishUtil.returnJson(ResultEnum.warn207.getKey(), "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//摄像头和用户关系
|
//摄像头和用户关系
|
||||||
CameraUserId cuId = new CameraUserId(userId, cameraId);
|
CameraUserId cuId = new CameraUserId(userId, cameraId);
|
||||||
CameraUser cameraUser = this.cameraUserDao.get(cuId);
|
CameraUser cameraUser = this.cameraUserDao.get(cuId);
|
||||||
|
|
|
||||||
|
|
@ -1040,7 +1040,7 @@ public class UserServiceImpl implements UserService {
|
||||||
//json存储设备信息
|
//json存储设备信息
|
||||||
json.put("userId", userId);
|
json.put("userId", userId);
|
||||||
json.put("deviceId", deviceId);
|
json.put("deviceId", deviceId);
|
||||||
json.put("isMaster", "0");
|
json.put("isMaster", "1");
|
||||||
//宠物店名称
|
//宠物店名称
|
||||||
json.put("storeName", devicePetUser.getStoreName());
|
json.put("storeName", devicePetUser.getStoreName());
|
||||||
json.put("showName", devicePetUser.getShowName());
|
json.put("showName", devicePetUser.getShowName());
|
||||||
|
|
@ -1199,7 +1199,7 @@ public class UserServiceImpl implements UserService {
|
||||||
public DeviceDto getDeviceDto(DevicePetUser deviceUser,Device device){
|
public DeviceDto getDeviceDto(DevicePetUser deviceUser,Device device){
|
||||||
String type = device.getHardwareType();
|
String type = device.getHardwareType();
|
||||||
//设备信息DTO
|
//设备信息DTO
|
||||||
DeviceDto dto = new DeviceDto(device.getDeviceId(), device.getMacAddress(), deviceUser.getShowName(), "0", type, device.getIsBlacklist());
|
DeviceDto dto = new DeviceDto(device.getDeviceId(), device.getMacAddress(), deviceUser.getShowName(), deviceUser.getIsMaster().intValue() == 0 ? "1" : "0", type, device.getIsBlacklist());
|
||||||
dto.setStoreName(deviceUser.getStoreName());
|
dto.setStoreName(deviceUser.getStoreName());
|
||||||
//用户ID
|
//用户ID
|
||||||
dto.setUserId(deviceUser.getPriId().getUserId());
|
dto.setUserId(deviceUser.getPriId().getUserId());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue