宠物笼设备相关接口
This commit is contained in:
parent
5c7d684c84
commit
9dde87a661
|
|
@ -166,6 +166,53 @@ public class UserAction {
|
|||
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定设备
|
||||
*
|
||||
* @param user
|
||||
* @param macAddress
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/bindPetDevice.do")
|
||||
public Object bindPetDevice(User user, String macAddress, String storeName) {
|
||||
try {
|
||||
return baseService.bindPetDevice(user, macAddress.toLowerCase(), storeName);
|
||||
} catch (Exception e) {
|
||||
log.error("bind device:userId:{},macAddress:{},error message:{}", user.getUserId(), macAddress.toLowerCase(), e.toString());
|
||||
}
|
||||
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询宠物店名称
|
||||
*
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/queryPetStore.do")
|
||||
public Object queryPetStore(User user) {
|
||||
try {
|
||||
return baseService.queryPetStore(user);
|
||||
} catch (Exception e) {
|
||||
log.error("queryPetStore:userId:{},error message:{}", user.getUserId(), e.toString());
|
||||
}
|
||||
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改宠物店名称
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/updatePetStore.do")
|
||||
public Object updatePetStore(int userId, String oldName, String newName, String storeName) {
|
||||
try {
|
||||
baseService.updatePetStore(userId, oldName, newName, storeName);
|
||||
} catch (Exception e) {
|
||||
log.error("updatePetStore:oldName:{},newName:{},error message:{}",oldName, newName, e.toString());
|
||||
}
|
||||
return IfishUtil.returnJson(ResultEnum.success.getKey(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增智能加热棒信息
|
||||
* @return
|
||||
|
|
@ -309,9 +356,10 @@ public class UserAction {
|
|||
* @return
|
||||
*/
|
||||
@RequestMapping("/getSingleDeviceInf.do")
|
||||
public Object getSingleDeviceInf(DeviceUser deviceUser) {
|
||||
public Object getSingleDeviceInf(DeviceUser deviceUser, Integer type) {
|
||||
try {
|
||||
return baseService.getSingleDeviceInf(deviceUser);
|
||||
type = type == null ? 0 : type;
|
||||
return baseService.getSingleDeviceInf(deviceUser, type);
|
||||
} catch (Exception e) {
|
||||
log.error("get getDeviceInfByMacAddress Information:userId:{},deviceId:{},error message:{}", deviceUser.getPriId().getUserId(), deviceUser.getPriId().getDeviceId(), e.toString());
|
||||
}
|
||||
|
|
@ -334,6 +382,22 @@ public class UserAction {
|
|||
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备信息
|
||||
*
|
||||
* @param deviceUser
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/updatePetDeviceUser.do")
|
||||
public Object updatePetDeviceUser(DeviceUser deviceUser) {
|
||||
try {
|
||||
return baseService.updatePetDeviceUser(deviceUser);
|
||||
} catch (Exception e) {
|
||||
log.error("update device Information:userId:{},deviceId:{},error message:{}", deviceUser.getPriId().getUserId(), deviceUser.getPriId().getDeviceId(), e.toString());
|
||||
}
|
||||
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改摄像头信息
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
package com.ifish.dao;
|
||||
|
||||
import com.ifish.entity.DevicePetUser;
|
||||
import com.ifish.entity.DeviceUser;
|
||||
import com.ifish.entity.DeviceUserId;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: DeviceUserDao
|
||||
* @Description: TODO
|
||||
* @author ggw
|
||||
*
|
||||
*/
|
||||
public interface DevicePetUserDao extends BaseDao<DevicePetUser, DeviceUserId>{
|
||||
|
||||
public void removeAll(List<DevicePetUser> list);
|
||||
|
||||
/**
|
||||
* 查询用户的设备数量
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
public int getDeviceNumById(Integer userId);
|
||||
|
||||
/**
|
||||
* 查询宠物店
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
public List<String> getDeviceStoreName(Integer userId);
|
||||
|
||||
List getDeviceIdByStoreNameAndUserId(Integer userId, String storeName);
|
||||
|
||||
void updateStoreName(int userId, String oldName, String newName, String storeName);
|
||||
|
||||
/**
|
||||
* 根据deviceId查询设备和用户对应数据
|
||||
* @param deviceId
|
||||
* @return
|
||||
*/
|
||||
List<DevicePetUser> getUserIdByDeviceId(Integer deviceId);
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
package com.ifish.daoImpl;
|
||||
|
||||
import com.ifish.dao.DevicePetUserDao;
|
||||
import com.ifish.dao.DeviceUserDao;
|
||||
import com.ifish.entity.DevicePetUser;
|
||||
import com.ifish.entity.DeviceUser;
|
||||
import com.ifish.entity.DeviceUserId;
|
||||
import com.ifish.hibernate.HibernateBaseDao;
|
||||
import org.hibernate.criterion.Criterion;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: DeviceUserDaoImpl
|
||||
* @Description: TODO
|
||||
* @author ggw
|
||||
*
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public class DevicePeiUserDaoImpl extends HibernateBaseDao<DevicePetUser, DeviceUserId> implements DevicePetUserDao {
|
||||
|
||||
@Override
|
||||
protected Class<DevicePetUser> getEntityClass() {
|
||||
return DevicePetUser.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAll(List<DevicePetUser> list) {
|
||||
for (DevicePetUser devicePetUser:list) {
|
||||
delete(devicePetUser);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户的设备数量
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int getDeviceNumById(Integer userId) {
|
||||
String sql = "select count(*) from tbl_pet_list where user_id=?";
|
||||
int deviceNum = ((BigInteger)this.getSession().createSQLQuery(sql).setInteger(0, userId).uniqueResult()).intValue();
|
||||
return deviceNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询宠物店
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<String> getDeviceStoreName(Integer userId) {
|
||||
String sql = "select store_name from tbl_pet_list where user_id=? group by store_name";
|
||||
List<String> list = this.getSession().createSQLQuery(sql).setInteger(0, userId).list();
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getDeviceIdByStoreNameAndUserId(Integer userId, String storeName) {
|
||||
String sql = "select device_id, device_name from tbl_pet_list where user_id=? and store_name = ?";
|
||||
List list = this.getSession().createSQLQuery(sql).setInteger(0, userId).setString(1, storeName).list();
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStoreName(int userId, String oldName, String newName, String storeName) {
|
||||
String sql = "update tbl_pet_list set device_name = ?,store_name=? where user_id = ? and device_name = ?";
|
||||
int i = this.getSession().createSQLQuery(sql).setString(0, newName).setString(1, storeName).setInteger(2, userId).setString(3, oldName).executeUpdate();
|
||||
System.out.println("updateStoreName : " + i);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据设备ID查询设备用户对应关系表
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<DevicePetUser> getUserIdByDeviceId(Integer userId) {
|
||||
Criterion criterion = Restrictions.eq("priId.userId",userId);
|
||||
List<DevicePetUser> devicePetUsers = this.findByProperty(criterion);
|
||||
return devicePetUsers;
|
||||
}
|
||||
}
|
||||
|
|
@ -27,6 +27,11 @@ public class DeviceDto {
|
|||
* 显示名称
|
||||
*/
|
||||
private String showName;
|
||||
|
||||
/**
|
||||
* 宠物店名字
|
||||
*/
|
||||
private String storeName;
|
||||
/**
|
||||
* 是否主控
|
||||
*/
|
||||
|
|
@ -201,5 +206,12 @@ public class DeviceDto {
|
|||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
|
||||
public String getStoreName() {
|
||||
return storeName;
|
||||
}
|
||||
|
||||
public void setStoreName(String storeName) {
|
||||
this.storeName = storeName;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
package com.ifish.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName: tbl_device_user
|
||||
* @date 2015年7月2日 下午16:40:00
|
||||
*
|
||||
*/
|
||||
public class DevicePetUser implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -6056043883433438749L;
|
||||
//ID
|
||||
private DeviceUserId priId = new DeviceUserId();
|
||||
//显示名称
|
||||
private String showName;
|
||||
private String storeName;
|
||||
|
||||
public DevicePetUser() {}
|
||||
|
||||
public DevicePetUser(DeviceUserId priId, String showName, String storeName) {
|
||||
this.priId = priId;
|
||||
this.showName = showName;
|
||||
this.storeName = storeName;
|
||||
}
|
||||
|
||||
public DeviceUserId getPriId() {
|
||||
return priId;
|
||||
}
|
||||
public void setPriId(DeviceUserId priId) {
|
||||
this.priId = priId;
|
||||
}
|
||||
public String getShowName() {
|
||||
return showName;
|
||||
}
|
||||
public void setShowName(String showName) {
|
||||
this.showName = showName;
|
||||
}
|
||||
|
||||
public String getStoreName() {
|
||||
return storeName;
|
||||
}
|
||||
|
||||
public void setStoreName(String storeName) {
|
||||
this.storeName = storeName;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping package="com.ifish.entity">
|
||||
<class name="DevicePetUser" table="tbl_pet_list" dynamic-insert="true" dynamic-update="true">
|
||||
<meta attribute="sync-DAO">false</meta>
|
||||
<composite-id name="priId" class="com.ifish.entity.DeviceUserId">
|
||||
<key-property name="userId" column="user_id" type="java.lang.Integer" />
|
||||
<key-property name="deviceId" column="device_id" type="java.lang.Integer" />
|
||||
</composite-id>
|
||||
<property name="showName" column="device_name" type="string" length="255" />
|
||||
<property name="storeName" column="store_name" type="string" length="255" />
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
|
|
@ -8,6 +8,7 @@ package com.ifish.helper;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ifish.bean.DeviceUserBean;
|
||||
import com.ifish.dao.DevicePetUserDao;
|
||||
import com.ifish.dao.DeviceUserDao;
|
||||
import com.ifish.dao.PushListDao;
|
||||
import com.ifish.entity.*;
|
||||
|
|
@ -78,6 +79,8 @@ public class UserHelper implements UserHelperI {
|
|||
|
||||
@Autowired
|
||||
private DeviceUserDao deviceUserDao;
|
||||
@Autowired
|
||||
private DevicePetUserDao devicePetUserDao;
|
||||
|
||||
@Autowired
|
||||
private PushListDao pushListDao;
|
||||
|
|
@ -153,6 +156,8 @@ public class UserHelper implements UserHelperI {
|
|||
dataMap.put("shopsInfo", shopsInfoMap);
|
||||
dataMap.put("shopsInfo2", kanhuShopsInfoMap);
|
||||
dataMap.put("device", deviceMap.get("list"));
|
||||
Map devicePetList = getDevicePetList(tmpUser);
|
||||
dataMap.put("pets", devicePetList.get("list"));
|
||||
dataMap.put("camera", list2);
|
||||
dataMap.put("deviceCamera", deviceMap.get("list3"));
|
||||
return IfishUtil.returnJson(ResultEnum.success.getKey(), dataMap);
|
||||
|
|
@ -448,6 +453,57 @@ public class UserHelper implements UserHelperI {
|
|||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户绑定设备信息
|
||||
*
|
||||
* @param tmpUser
|
||||
* @return
|
||||
*/
|
||||
private Map getDevicePetList(User tmpUser) throws Exception {
|
||||
//获取用户拥有设备
|
||||
List<DevicePetUser> deviceUserList = devicePetUserDao.getUserIdByDeviceId(tmpUser.getUserId());
|
||||
List<Integer> deviceIds = new ArrayList<Integer>();
|
||||
Map<String, List> storeNamesList = new HashMap<>();
|
||||
|
||||
for (DevicePetUser devicePetUser : deviceUserList) {
|
||||
|
||||
Device device = deviceUserHelperI.getDeviceById(devicePetUser.getPriId().getDeviceId());
|
||||
deviceIds.add(device.getDeviceId());
|
||||
DeviceUserBean deviceUser = new DeviceUserBean();
|
||||
deviceUser.setDeviceId(devicePetUser.getPriId().getDeviceId());
|
||||
deviceUser.setUserId(devicePetUser.getPriId().getUserId());
|
||||
deviceUser.setIsMaster("0");
|
||||
deviceUser.setShowName(devicePetUser.getShowName());
|
||||
|
||||
if (storeNamesList.containsKey(devicePetUser.getStoreName())) {
|
||||
storeNamesList.get(devicePetUser.getStoreName()).add(device);
|
||||
} else {
|
||||
List<Object> devices = new ArrayList<>();
|
||||
devices.add(device);
|
||||
storeNamesList.put(devicePetUser.getStoreName(), devices);
|
||||
}
|
||||
}
|
||||
|
||||
//设备-摄像头
|
||||
List<Object> list3 = new ArrayList<Object>();
|
||||
//设备已关联摄像头
|
||||
if (deviceIds.size() > 0) {
|
||||
for (Integer deviceId : deviceIds) {
|
||||
List<DeviceCamera> deviceCameraList = deviceUserHelperI.getDeviceCameraListByDeviceId(deviceId);
|
||||
for (DeviceCamera deviceCamera : deviceCameraList) {
|
||||
Map<String, Object> deviceCameraMap = new HashMap<String, Object>();
|
||||
deviceCameraMap.put("cameraId", deviceCamera.getDeviceCameraId().getCameraId());
|
||||
deviceCameraMap.put("deviceId", deviceCamera.getDeviceCameraId().getDeviceId());
|
||||
list3.add(deviceCameraMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map map = new HashMap();
|
||||
map.put("list", storeNamesList);
|
||||
map.put("list3", list3);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装设备返回信息
|
||||
*
|
||||
|
|
|
|||
|
|
@ -44,6 +44,12 @@ public interface BaseService {
|
|||
@Deprecated
|
||||
public Object bindDevice(User user,String madAddress);
|
||||
|
||||
public Object bindPetDevice(User user,String madAddress, String storeName);
|
||||
|
||||
public Object queryPetStore(User user);
|
||||
|
||||
public void updatePetStore(int userId, String oldName, String newName, String storeName);
|
||||
|
||||
public Object getDeviceHeaterInfo(String madAddress);
|
||||
|
||||
public Object getDeviceHeaterPhsByDate(String macAddress,String date);
|
||||
|
|
@ -66,11 +72,12 @@ public interface BaseService {
|
|||
public Object deviceBindCamera(Integer deviceId,String cameraId);
|
||||
|
||||
//获取单个设备信息
|
||||
public Object getSingleDeviceInf(DeviceUser deviceUser);
|
||||
public Object getSingleDeviceInf(DeviceUser deviceUser, int type);
|
||||
|
||||
//修改设备信息
|
||||
public Object update(DeviceUser deviceUser);
|
||||
|
||||
public Object updatePetDeviceUser(DeviceUser deviceUser);
|
||||
|
||||
//修改摄像头信息
|
||||
public Object update(CameraUserId id,String showName);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import com.ifish.service.BaseService;
|
|||
import com.ifish.util.IfishFilePath;
|
||||
import com.ifish.util.IfishUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hibernate.criterion.Criterion;
|
||||
import org.hibernate.criterion.Order;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -57,6 +56,8 @@ public class BaseServiceImpl implements BaseService {
|
|||
@Autowired
|
||||
private DeviceUserDao deviceUserDao;
|
||||
@Autowired
|
||||
private DevicePetUserDao devicePetUserDao;
|
||||
@Autowired
|
||||
private CameraActiveDao cameraActiveDao;
|
||||
@Autowired
|
||||
private VenderListDao venderListDao;
|
||||
|
|
@ -581,6 +582,48 @@ public class BaseServiceImpl implements BaseService {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 绑定宠物笼设备
|
||||
*/
|
||||
@Override
|
||||
public Object bindPetDevice(User user, String madAddress, String storeName) {
|
||||
User tmpUser = userDao.get(user.getUserId());
|
||||
//新增用户拥有设备
|
||||
DevicePetUser devicePetUser = new DevicePetUser();
|
||||
//新增设备信息
|
||||
Device device = new Device();
|
||||
device.setLoginCount(0);
|
||||
device.setIsBlacklist(BooleanEnum.YES.getKey());
|
||||
device.setMacAddress(madAddress);
|
||||
Date date = new Date();
|
||||
device.setFirstActivate(date);
|
||||
device.setCreateDate(date);
|
||||
device.setCreateTime(date);
|
||||
device = this.deviceDao.save(device);
|
||||
|
||||
devicePetUser.getPriId().setUserId(tmpUser.getUserId());
|
||||
devicePetUser.getPriId().setDeviceId(device.getDeviceId());
|
||||
devicePetUser.setShowName("宠物笼" + (int) (Math.random() * 9000 + 1000));
|
||||
devicePetUser.setStoreName(storeName);
|
||||
|
||||
this.devicePetUserDao.save(devicePetUser);
|
||||
|
||||
//封装设备返回信息
|
||||
return IfishUtil.returnJson(ResultEnum.success.getKey(), getDeviceInfo(device, devicePetUser));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object queryPetStore(User user) {
|
||||
List<String> deviceStoreName = this.devicePetUserDao.getDeviceStoreName(user.getUserId());
|
||||
return IfishUtil.returnJson(ResultEnum.success.getKey(), deviceStoreName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePetStore(int userId, String oldName, String newName, String storeName) {
|
||||
this.devicePetUserDao.updateStoreName(userId, oldName, newName, storeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object saveOrUpdateDeviceHeaterInfo(DeviceHeaterDetail heaterDetail) {
|
||||
log.info("加热器保存或修改 : " + heaterDetail.toString());
|
||||
|
|
@ -825,6 +868,76 @@ public class BaseServiceImpl implements BaseService {
|
|||
return deviceMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装设备返回信息
|
||||
*
|
||||
* @param device
|
||||
* @param devicePetUser
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getDeviceInfo(Device device, DevicePetUser devicePetUser) {
|
||||
Map<String, Object> deviceMap = new HashMap<String, Object>();
|
||||
deviceMap.put("userId", devicePetUser.getPriId().getUserId());
|
||||
deviceMap.put("deviceId", devicePetUser.getPriId().getDeviceId());
|
||||
deviceMap.put("isMaster", "");
|
||||
deviceMap.put("showName", devicePetUser.getShowName());
|
||||
deviceMap.put("macAddress", device.getMacAddress());
|
||||
deviceMap.put("isBlacklist", device.getIsBlacklist());
|
||||
deviceMap.put("storeName", devicePetUser.getStoreName());
|
||||
deviceMap.put("customIconName", "");
|
||||
deviceMap.put("customShowName", "");
|
||||
deviceMap.put("deviceIp", device.getDeviceIP());
|
||||
deviceMap.put("loginTime", device.getLoginTime());
|
||||
if (device.getBrandCode() != null && device.getBrandCode().equals("YUEM") && device.getCreateTime().before(IfishUtil.StrToDate("2016-04-26"))) {
|
||||
//是否显示预警推送
|
||||
deviceMap.put("isPushWendu", BooleanEnum.NO.getKey());
|
||||
} else {
|
||||
//是否显示预警推送
|
||||
deviceMap.put("isPushWendu", BooleanEnum.YES.getKey());
|
||||
}
|
||||
//控制方案
|
||||
String type = device.getHardwareType();
|
||||
if (type != null) {
|
||||
HardwareType hardwareType = this.hardwareTypeDao.get(type);
|
||||
if (hardwareType != null) {
|
||||
//设备类型
|
||||
deviceMap.put("type", type);
|
||||
//有无工作模式
|
||||
deviceMap.put("isWorkModel", hardwareType.getIsWorkModel());
|
||||
//控制信息
|
||||
deviceMap.put("controlAmount", hardwareType.getControlAmount());
|
||||
deviceMap.put("timerAmount", hardwareType.getTimerAmount());
|
||||
//背光/柜灯
|
||||
deviceMap.put("isLightness", hardwareType.getIsLightness());
|
||||
deviceMap.put("isSarkLamp", hardwareType.getIsSarkLamp());
|
||||
//自定义图标
|
||||
deviceMap.put("isCustomIcon", hardwareType.getIsCustomIcon());
|
||||
deviceMap.put("iconLink", hardwareType.getIconLink());
|
||||
deviceMap.put("allIconName", hardwareType.getAllIconName());
|
||||
deviceMap.put("allShowName", hardwareType.getAllShowName());
|
||||
deviceMap.put("defaultIconName", hardwareType.getDefaultIconName());
|
||||
deviceMap.put("defaultShowName", hardwareType.getDefaultShowName());
|
||||
deviceMap.put("updateTime", hardwareType.getUpdateTime());
|
||||
//换水提醒
|
||||
deviceMap.put("todayRemind", device.getTodayRemind());
|
||||
deviceMap.put("waterRemind", device.getWaterRemind());
|
||||
deviceMap.put("remindDate", device.getRemindDate() != null ? IfishUtil.format1(device.getRemindDate()) : "");
|
||||
deviceMap.put("remindCycle", device.getRemindCycle() != null ? device.getRemindCycle() : "");
|
||||
}
|
||||
}
|
||||
//厂家
|
||||
if (device.getBrandCode() != null) {
|
||||
//厂家
|
||||
VenderList venderList = venderListDao.get(device.getBrandCode());
|
||||
deviceMap.put("venderList", venderList);
|
||||
} else {
|
||||
//默认爱鱼奇
|
||||
VenderList defaultVenderList = venderListDao.getDefaultVenderList();
|
||||
deviceMap.put("venderList", defaultVenderList);
|
||||
}
|
||||
return deviceMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新设备信息
|
||||
*/
|
||||
|
|
@ -840,6 +953,20 @@ public class BaseServiceImpl implements BaseService {
|
|||
return IfishUtil.returnJson(ResultEnum.warn207.getKey(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新设备信息
|
||||
*/
|
||||
@Override
|
||||
public Object updatePetDeviceUser(DeviceUser deviceUser) {
|
||||
DevicePetUser tmpDeviceUser = this.devicePetUserDao.get(deviceUser.getPriId());
|
||||
if (tmpDeviceUser != null) {
|
||||
tmpDeviceUser.setShowName(deviceUser.getShowName());
|
||||
this.devicePetUserDao.update(tmpDeviceUser);
|
||||
return IfishUtil.returnJson(ResultEnum.success.getKey(), "");
|
||||
}
|
||||
return IfishUtil.returnJson(ResultEnum.warn207.getKey(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新摄像头信息
|
||||
*/
|
||||
|
|
@ -1130,15 +1257,24 @@ public class BaseServiceImpl implements BaseService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object getSingleDeviceInf(DeviceUser deviceUser) {
|
||||
public Object getSingleDeviceInf(DeviceUser deviceUser, int type) {
|
||||
Integer deviceId = deviceUser.getPriId().getDeviceId();
|
||||
Integer userId = deviceUser.getPriId().getUserId();
|
||||
if (deviceId != null && userId != null) {
|
||||
Device tmpDevice = this.deviceDao.get(deviceId);
|
||||
DeviceUser tmpDeviceUser = this.deviceUserDao.get(deviceUser.getPriId());
|
||||
if (tmpDevice != null && tmpDeviceUser != null) {
|
||||
//封装设备返回信息
|
||||
return IfishUtil.returnJson(ResultEnum.success.getKey(), getDeviceInfo(tmpDevice, tmpDeviceUser));
|
||||
if (type == 0) {
|
||||
Device tmpDevice = this.deviceDao.get(deviceId);
|
||||
DeviceUser tmpDeviceUser = this.deviceUserDao.get(deviceUser.getPriId());
|
||||
if (tmpDevice != null && tmpDeviceUser != null) {
|
||||
//封装设备返回信息
|
||||
return IfishUtil.returnJson(ResultEnum.success.getKey(), getDeviceInfo(tmpDevice, tmpDeviceUser));
|
||||
}
|
||||
} else {
|
||||
Device tmpDevice = this.deviceDao.get(deviceId);
|
||||
DevicePetUser petUser = this.devicePetUserDao.get(deviceUser.getPriId());
|
||||
if (tmpDevice != null && petUser != null) {
|
||||
//封装设备返回信息
|
||||
return IfishUtil.returnJson(ResultEnum.success.getKey(), getDeviceInfo(tmpDevice, petUser));
|
||||
}
|
||||
}
|
||||
}
|
||||
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||
|
|
@ -1196,37 +1332,71 @@ public class BaseServiceImpl implements BaseService {
|
|||
this.pushRemindDao.update(pushRemind);
|
||||
}
|
||||
} else {
|
||||
|
||||
//添加设备所绑定的用户
|
||||
for (DeviceUser deviceUser : users) {
|
||||
//根据userID获取已存在的推送对象
|
||||
PushRemind pr = pushRemindMap.get(deviceUser.getPriId().getUserId());
|
||||
//如果对象存在 作修改操作
|
||||
if (pr != null) {
|
||||
pr.setRemindCycle(tmpDevice.getRemindCycle());
|
||||
pr.setRemindDate(tmpDevice.getRemindDate());
|
||||
pr.setNotifyType(type);
|
||||
this.pushRemindDao.update(pr);
|
||||
} else {
|
||||
//推送表ID
|
||||
PushRemindId id = new PushRemindId();
|
||||
//新增对象
|
||||
PushRemind pushRemind = new PushRemind();
|
||||
pushRemind.setRemindCycle(tmpDevice.getRemindCycle());
|
||||
pushRemind.setRemindDate(tmpDevice.getRemindDate());
|
||||
id.setDeviceId(tmpDevice.getDeviceId());
|
||||
pushRemind.setMacAddress(tmpDevice.getMacAddress());
|
||||
//新增操作
|
||||
//查询用户信息
|
||||
User user = this.userDao.get(deviceUser.getPriId().getUserId());
|
||||
id.setUserId(deviceUser.getPriId().getUserId());
|
||||
pushRemind.setId(id);
|
||||
pushRemind.setPhoneNumber(user.getPhoneNumber());
|
||||
pushRemind.setShowName(deviceUser.getShowName());
|
||||
pushRemind.setLoginType(user.getLoginType());
|
||||
pushRemind.setIsPush("0");
|
||||
pushRemind.setNotifyType(type);
|
||||
this.pushRemindDao.save(pushRemind);
|
||||
if (type == 0) {
|
||||
//添加设备所绑定的用户
|
||||
for (DeviceUser deviceUser : users) {
|
||||
//根据userID获取已存在的推送对象
|
||||
PushRemind pr = pushRemindMap.get(deviceUser.getPriId().getUserId());
|
||||
//如果对象存在 作修改操作
|
||||
if (pr != null) {
|
||||
pr.setRemindCycle(tmpDevice.getRemindCycle());
|
||||
pr.setRemindDate(tmpDevice.getRemindDate());
|
||||
pr.setNotifyType(type);
|
||||
this.pushRemindDao.update(pr);
|
||||
} else {
|
||||
//推送表ID
|
||||
PushRemindId id = new PushRemindId();
|
||||
//新增对象
|
||||
PushRemind pushRemind = new PushRemind();
|
||||
pushRemind.setRemindCycle(tmpDevice.getRemindCycle());
|
||||
pushRemind.setRemindDate(tmpDevice.getRemindDate());
|
||||
id.setDeviceId(tmpDevice.getDeviceId());
|
||||
pushRemind.setMacAddress(tmpDevice.getMacAddress());
|
||||
//新增操作
|
||||
//查询用户信息
|
||||
User user = this.userDao.get(deviceUser.getPriId().getUserId());
|
||||
id.setUserId(deviceUser.getPriId().getUserId());
|
||||
pushRemind.setId(id);
|
||||
pushRemind.setPhoneNumber(user.getPhoneNumber());
|
||||
pushRemind.setShowName(deviceUser.getShowName());
|
||||
pushRemind.setLoginType(user.getLoginType());
|
||||
pushRemind.setIsPush("0");
|
||||
pushRemind.setNotifyType(type);
|
||||
this.pushRemindDao.save(pushRemind);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<DevicePetUser> userIdByDeviceId = this.devicePetUserDao.getUserIdByDeviceId(device.getDeviceId());
|
||||
for (DevicePetUser petUser:userIdByDeviceId) {
|
||||
//根据userID获取已存在的推送对象
|
||||
PushRemind pr = pushRemindMap.get(petUser.getPriId().getUserId());
|
||||
//如果对象存在 作修改操作
|
||||
if (pr != null) {
|
||||
pr.setRemindCycle(tmpDevice.getRemindCycle());
|
||||
pr.setRemindDate(tmpDevice.getRemindDate());
|
||||
pr.setNotifyType(type);
|
||||
this.pushRemindDao.update(pr);
|
||||
} else {
|
||||
//推送表ID
|
||||
PushRemindId id = new PushRemindId();
|
||||
//新增对象
|
||||
PushRemind pushRemind = new PushRemind();
|
||||
pushRemind.setRemindCycle(tmpDevice.getRemindCycle());
|
||||
pushRemind.setRemindDate(tmpDevice.getRemindDate());
|
||||
id.setDeviceId(tmpDevice.getDeviceId());
|
||||
pushRemind.setMacAddress(tmpDevice.getMacAddress());
|
||||
//新增操作
|
||||
//查询用户信息
|
||||
User user = this.userDao.get(petUser.getPriId().getUserId());
|
||||
id.setUserId(petUser.getPriId().getUserId());
|
||||
pushRemind.setId(id);
|
||||
pushRemind.setPhoneNumber(user.getPhoneNumber());
|
||||
pushRemind.setShowName(petUser.getShowName());
|
||||
pushRemind.setLoginType(user.getLoginType());
|
||||
pushRemind.setIsPush("0");
|
||||
pushRemind.setNotifyType(type);
|
||||
this.pushRemindDao.save(pushRemind);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import java.sql.SQLException;
|
|||
import java.util.*;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ifish.dao.*;
|
||||
import com.ifish.entity.*;
|
||||
import com.ifish.entity.event.QueueEventBody;
|
||||
import com.ifish.entity.event.QueueEventEntity;
|
||||
|
|
@ -25,18 +26,6 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ifish.apiVersion.ApiVersion;
|
||||
import com.ifish.dao.CameraDao;
|
||||
import com.ifish.dao.CameraUserDao;
|
||||
import com.ifish.dao.DeviceCameraDao;
|
||||
import com.ifish.dao.DeviceDao;
|
||||
import com.ifish.dao.DeviceUserDao;
|
||||
import com.ifish.dao.GoldControlDao;
|
||||
import com.ifish.dao.GoldGetRecordDao;
|
||||
import com.ifish.dao.InformationDao;
|
||||
import com.ifish.dao.PushListDao;
|
||||
import com.ifish.dao.ShopsInfoDao;
|
||||
import com.ifish.dao.UserAssetDao;
|
||||
import com.ifish.dao.UserDao;
|
||||
import com.ifish.dto.DeviceDto;
|
||||
import com.ifish.dto.DeviceInfoDto;
|
||||
import com.ifish.dto.GoldTaskDto;
|
||||
|
|
@ -951,6 +940,10 @@ public class UserServiceImpl implements UserService {
|
|||
neteaseIM.sendMsg(from, to, "感谢您使用爱鱼奇,连接智能设备请查看下方说明书,内含操作视频:http://u.eqxiu.com/s/KmmVl87l \n摄像头售后:18667812003\n睿芯插排售后:15757401229\n绚多插排售后:17301857903\n松诺插排售后:13392205468","");
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private DevicePetUserDao devicePetUserDao;
|
||||
|
||||
/**
|
||||
* 封装设备信息
|
||||
* @param userId
|
||||
|
|
@ -1034,6 +1027,79 @@ public class UserServiceImpl implements UserService {
|
|||
json.put("venderList", cacheService.findVenderListById("AYQ"));
|
||||
}
|
||||
}
|
||||
List<DevicePetUser> devicePetUsers = devicePetUserDao.findByProperty(Restrictions.eq("priId.userId", userId));
|
||||
for (DevicePetUser devicePetUser : devicePetUsers) {
|
||||
//查询设备信息
|
||||
Integer deviceId = devicePetUser.getPriId().getDeviceId();
|
||||
Device device = deviceDao.get(deviceId);
|
||||
//json
|
||||
JSONObject json = new JSONObject();
|
||||
//封装设备返回信息
|
||||
deviceIds.add(deviceId);
|
||||
deviceList.add(json);
|
||||
//json存储设备信息
|
||||
json.put("userId", userId);
|
||||
json.put("deviceId", deviceId);
|
||||
json.put("isMaster", "0");
|
||||
//宠物店名称
|
||||
json.put("storeName", devicePetUser.getStoreName());
|
||||
json.put("showName", devicePetUser.getShowName());
|
||||
json.put("macAddress", device.getMacAddress());
|
||||
json.put("isBlacklist", device.getIsBlacklist());
|
||||
//控制方案
|
||||
String type = device.getHardwareType();
|
||||
//鱼缸厂code
|
||||
String brandCode = device.getBrandCode();
|
||||
if(type!=null){
|
||||
HardwareType hardwareType = cacheService.findHardwareTypeById(type);
|
||||
if(hardwareType!=null){
|
||||
//设备类型
|
||||
json.put("type", type);
|
||||
//有无工作模式
|
||||
json.put("isWorkModel", hardwareType.getIsWorkModel());
|
||||
//控制信息
|
||||
json.put("controlAmount", hardwareType.getControlAmount());
|
||||
json.put("timerAmount", hardwareType.getTimerAmount());
|
||||
//背光/柜灯
|
||||
json.put("isLightness", hardwareType.getIsLightness());
|
||||
json.put("isSarkLamp", hardwareType.getIsSarkLamp());
|
||||
//是否显示预警推送
|
||||
if(brandCode!=null && brandCode.equals("YUEM") && device.getCreateTime().before(IfishUtil.StrToDate("2016-04-26"))){
|
||||
json.put("isPushWendu", BooleanEnum.NO.getKey());
|
||||
}
|
||||
else{
|
||||
json.put("isPushWendu", BooleanEnum.YES.getKey());
|
||||
}
|
||||
//换水提醒
|
||||
json.put("todayRemind", device.getTodayRemind());
|
||||
json.put("waterRemind", device.getWaterRemind());
|
||||
json.put("remindDate", device.getRemindDate()!=null?IfishUtil.format1(device.getRemindDate()):"");
|
||||
json.put("remindCycle", device.getRemindCycle()!=null?device.getRemindCycle():"");
|
||||
//自定义图标信息
|
||||
String isCustomIcon = hardwareType.getIsCustomIcon();
|
||||
json.put("isCustomIcon", isCustomIcon);
|
||||
if(isCustomIcon.equals(BooleanEnum.YES.getKey())){
|
||||
json.put("customIconName", "");
|
||||
json.put("customShowName", "");
|
||||
json.put("isCustomIcon", hardwareType.getIsCustomIcon());
|
||||
json.put("iconLink", hardwareType.getIconLink());
|
||||
json.put("allIconName", hardwareType.getAllIconName());
|
||||
json.put("allShowName", hardwareType.getAllShowName());
|
||||
json.put("defaultIconName", hardwareType.getDefaultIconName());
|
||||
json.put("defaultShowName", hardwareType.getDefaultShowName());
|
||||
}
|
||||
}
|
||||
}
|
||||
//厂家
|
||||
VenderList venderList = cacheService.findVenderListById(brandCode);
|
||||
if(venderList!=null){
|
||||
json.put("venderList", venderList);
|
||||
}
|
||||
else{
|
||||
//默认爱鱼奇
|
||||
json.put("venderList", cacheService.findVenderListById("AYQ"));
|
||||
}
|
||||
}
|
||||
return new DeviceInfoDto(deviceIds, deviceList);
|
||||
}
|
||||
|
||||
|
|
@ -1123,6 +1189,59 @@ public class UserServiceImpl implements UserService {
|
|||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备DTO
|
||||
* @param deviceUser
|
||||
* @param device
|
||||
* @return
|
||||
*/
|
||||
public DeviceDto getDeviceDto(DevicePetUser deviceUser,Device device){
|
||||
String type = device.getHardwareType();
|
||||
//设备信息DTO
|
||||
DeviceDto dto = new DeviceDto(device.getDeviceId(), device.getMacAddress(), deviceUser.getShowName(), "0", type, device.getIsBlacklist());
|
||||
dto.setStoreName(deviceUser.getStoreName());
|
||||
//用户ID
|
||||
dto.setUserId(deviceUser.getPriId().getUserId());
|
||||
//硬件类型
|
||||
HardwareType hardwareType = cacheService.findHardwareTypeById(type);
|
||||
if(hardwareType!=null){
|
||||
//控制数和定时器数
|
||||
dto.setControlAmount(hardwareType.getControlAmount());
|
||||
dto.setTimerAmount(hardwareType.getTimerAmount());
|
||||
//有无工作模式
|
||||
dto.setIsWorkModel(hardwareType.getIsWorkModel());
|
||||
//背光/柜灯
|
||||
dto.setIsLightness(hardwareType.getIsLightness());
|
||||
dto.setIsSarkLamp(hardwareType.getIsSarkLamp());
|
||||
}
|
||||
//鱼缸厂
|
||||
String brandCode = device.getBrandCode();
|
||||
//是否显示预警推送,2016-04-26号之前越美水族的不显示温度预警开关
|
||||
if("YUEM".equals(brandCode) && device.getCreateTime().before(IfishUtil.StrToDate("2016-04-26"))){
|
||||
dto.setIsPushWendu(BooleanEnum.NO.getKey());
|
||||
}
|
||||
else{
|
||||
dto.setIsPushWendu(BooleanEnum.YES.getKey());
|
||||
}
|
||||
//换水提醒
|
||||
dto.setTodayRemind(device.getTodayRemind());
|
||||
dto.setWaterRemind(device.getWaterRemind());
|
||||
dto.setRemindDate(device.getRemindDate()!=null?IfishUtil.format1(device.getRemindDate()):"");
|
||||
dto.setRemindCycle(device.getRemindCycle()!=null?device.getRemindCycle().toString():"");
|
||||
//鱼缸厂信息
|
||||
VenderList venderList = cacheService.findVenderListById(brandCode);
|
||||
if(venderList==null){
|
||||
//默认爱鱼奇
|
||||
venderList = cacheService.findVenderListById("AYQ");
|
||||
}
|
||||
if(venderList!=null){
|
||||
//鱼缸厂信息DTO
|
||||
VenderDto venderDto = new VenderDto(venderList.getBrandName(), venderList.getBrandIntroduce(), venderList.getLogo());
|
||||
dto.setVenderDto(venderDto);
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 优化后设备信息
|
||||
|
|
@ -1145,6 +1264,17 @@ public class UserServiceImpl implements UserService {
|
|||
deviceDtoList.add(getDeviceDto(deviceUser, device));
|
||||
}
|
||||
}
|
||||
List<DevicePetUser> devicePetUsers = devicePetUserDao.findByProperty(Restrictions.eq("priId.userId", userId));
|
||||
for (DevicePetUser devicePetUser : devicePetUsers) {
|
||||
//设备Id
|
||||
Integer deviceId = devicePetUser.getPriId().getDeviceId();
|
||||
//设备信息
|
||||
Device device = deviceDao.get(deviceId);
|
||||
if(device!=null){
|
||||
deviceIds.add(deviceId);
|
||||
deviceDtoList.add(getDeviceDto(devicePetUser, device));
|
||||
}
|
||||
}
|
||||
return new DeviceInfoDto(deviceIds, deviceDtoList);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue