用户列表用户详情页,新增设备,摄像头,解绑设备,厂家管理,电子厂信息页,电子厂信息修改页,修改电子厂数据

This commit is contained in:
谢洪龙 2017-08-04 13:33:33 +08:00
parent 58f923f8b4
commit f79b7df185
21 changed files with 2122 additions and 907 deletions

View File

@ -23,7 +23,7 @@ public class Tbl_Device implements java.io.Serializable {
/**
* 版本号
*/
private static final long serialVersionUID = 3405700970095511149L;
private static final long serialVersionUID = -7095234476683939631L;
/**
* 设备Id
@ -63,7 +63,7 @@ public class Tbl_Device implements java.io.Serializable {
private Date loginTime;
/**
* 是否在黑名单1不在0
* 是否在黑名单(是否授权)1未授权0已授权
*/
@Column(name = "is_blacklist", nullable = true, length = 1)
private String isBlacklist;
@ -75,11 +75,17 @@ public class Tbl_Device implements java.io.Serializable {
private String hardwareType;
/**
* 是否推送
* 是否温度报警
*/
@Column(name = "on_off", nullable = true, length = 1)
private String onOff;
/**
* 是否接收离线通知1接收0不接受
*/
@Column(name = "off_line", nullable = true, length = 1)
private String offLine;
/**
* 今天是否提醒1提醒0不提醒
*/
@ -119,7 +125,7 @@ public class Tbl_Device implements java.io.Serializable {
/**
* 摄像头ID
*/
@Column(name = "camera_id", nullable = true, length = 20)
@Column(name = "camera_id", unique = true, nullable = true, length = 20)
private String cameraId;
/**
@ -255,18 +261,18 @@ public class Tbl_Device implements java.io.Serializable {
}
/**
* 获取是否在黑名单1不在0
* 获取是否在黑名单(是否授权)1未授权0已授权
*
* @return 是否在黑名单
* @return 是否在黑名单(是否授权)1未授权
*/
public String getIsBlacklist() {
return this.isBlacklist;
}
/**
* 设置是否在黑名单1不在0
* 设置是否在黑名单(是否授权)1未授权0已授权
*
* @param isBlacklist 是否在黑名单1不在0
* @param isBlacklist 是否在黑名单(是否授权)1未授权0已授权
*/
public void setIsBlacklist(String isBlacklist) {
this.isBlacklist = isBlacklist;
@ -291,23 +297,41 @@ public class Tbl_Device implements java.io.Serializable {
}
/**
* 获取是否推送
* 获取是否温度报警
*
* @return 是否推送
* @return 是否温度报警
*/
public String getOnOff() {
return this.onOff;
}
/**
* 设置是否推送
* 设置是否温度报警
*
* @param onOff 是否推送
* @param onOff 是否温度报警
*/
public void setOnOff(String onOff) {
this.onOff = onOff;
}
/**
* 获取是否接收离线通知1接收0不接受
*
* @return 是否接收离线通知1接收
*/
public String getOffLine() {
return this.offLine;
}
/**
* 设置是否接收离线通知1接收0不接受
*
* @param offLine 是否接收离线通知1接收0不接受
*/
public void setOffLine(String offLine) {
this.offLine = offLine;
}
/**
* 获取今天是否提醒1提醒0不提醒
*

View File

@ -24,7 +24,7 @@ public class Tbl_Factory_List implements java.io.Serializable {
/**
* 版本号
*/
private static final long serialVersionUID = -8290320819344778436L;
private static final long serialVersionUID = 348357024725341557L;
/**
* 电子厂代码

View File

@ -0,0 +1,97 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ifish.controller;
import com.ifish.helper.FactoryHelperI;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
/**
*
* @author Administrator
*/
@Controller
public class Factory {
@Autowired
private FactoryHelperI factoryHelperI;
/**
* 电子厂列表页面
*
* @return
*/
@RequestMapping(value = {"/factorylist"}, method = RequestMethod.GET)
public ModelAndView getFactoryListView() {
return factoryHelperI.getFactoryListView();
}
/**
* 电子厂列表数据
*
* @param draw
* @param start
* @param length
* @return
*/
@RequestMapping(value = {"/factorylistData"}, method = RequestMethod.POST)
@ResponseBody
public Object getFactoryListData(String draw, Integer start, Integer length) {
return factoryHelperI.getFactoryListData(draw, start, length);
}
/**
* 修改电子厂信息是否收税
*
* @param code
* @param isTax
* @return
*/
@RequestMapping(value = {"/updateFactoryIsTax"}, method = RequestMethod.POST, produces = " text/html;charset=utf-8")
@ResponseBody
public Object updateFactoryIsTax(String code, String isTax) {
return factoryHelperI.changeFactoryIsTax(code, isTax);
}
/**
* 修改电子厂信息页面
*
* @return
*/
@RequestMapping(value = {"/updateFactoryDetail"}, method = RequestMethod.GET)
public ModelAndView updateFactoryDetail(String code) {
return factoryHelperI.updateFactoryDetail(code);
}
/**
* 修改电子厂
*
* @return
*/
@RequestMapping(value = {"/updateFactory"}, method = RequestMethod.POST, produces = " text/html;charset=utf-8")
@ResponseBody
public Object updateFactory(String[] brandCodes, String[] hardwareTypes, String factoryName, String factoryCode) {
return factoryHelperI.updateFactory(brandCodes, hardwareTypes, factoryName, factoryCode);
}
/**
* 删除电子厂
*
* @param code
* @return
*/
@RequestMapping(value = {"/deleteFactory"}, method = RequestMethod.POST, produces = " text/html;charset=utf-8")
@ResponseBody
public Object deleteFactory(String code) {
return factoryHelperI.deleteFactory(code);
}
}

View File

@ -5,41 +5,71 @@
*/
package com.ifish.helper;
import com.ifish.API.JiGuangPush;
import com.ifish.bean.Tbl_Activa_Code;
import com.ifish.bean.Tbl_Device;
import com.ifish.bean.Tbl_Device_Statistics;
import com.ifish.bean.Tbl_Device_User;
import com.ifish.bean.Tbl_Push_List;
import com.ifish.bean.Tbl_User;
import com.ifish.enums.PushTypeEnum;
import com.ifish.enums.ResultEnum;
import com.ifish.mapper.Tbl_Device_Mapper;
import com.ifish.util.IfishUtil;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
* @author Administrator
*/
public interface DeviceHelper {
@Component
public class DeviceHelper implements DeviceHelperI {
@Autowired
private RedisHelperI redisHelperI;
@Autowired
private RedisKeyHelperI redisKeyHelperI;
@Autowired
private Tbl_Device_Mapper tbl_Device_Mapper;
@Autowired
private UserHelperI userHelperI;
@Autowired
private JiGuangPush jiGuangPush;
@Autowired
private PushMessageHelperI pushMessageHelperI;
/**
* 根据用户Id获取绑定设备集合
*
* @param userId
* @return
* @throws java.lang.Exception
*/
List<Tbl_Device_User> getDeviceUsersByUserId(Integer userId) throws Exception;
/**
* 根据用户ID和摄像头信息获取用户关联数据
*
* @return
*/
Tbl_Device_User getDeviceUserByUserId_CameraId(Integer userId, String cameraId) throws Exception;
/**
* 根据设备Id获取设备详情
*
* @param deviceId
* @return
* @throws Exception
*/
Tbl_Device getDeviceById(Integer deviceId) throws Exception;
@Override
public List<Tbl_Device_User> getDeviceUsersByUserId(Integer userId) throws Exception {
List<Tbl_Device_User> deviceUserList = null;
String key = redisKeyHelperI.getListTbl_Device_UserKeyByUserId(userId);
String redisString = redisHelperI.getRedis(key);
if (StringUtils.isNotBlank(redisString)) {
deviceUserList = (List<Tbl_Device_User>) IfishUtil.JsonToList(redisString, Tbl_Device_User.class);
} else {
deviceUserList = tbl_Device_Mapper.getDeviceUsersByUserId(userId);
if (deviceUserList != null && deviceUserList.size() > 0) {
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(deviceUserList));
}
}
return deviceUserList;
}
/**
* 根据用户ID和设备ID获取此设备和此用户的关系
@ -49,17 +79,107 @@ public interface DeviceHelper {
* @return
* @throws Exception
*/
Tbl_Device_User getDeviceUserByUserId_DeviceId(Integer userId, Integer deviceId) throws Exception;
@Override
public Tbl_Device_User getDeviceUserByUserId_DeviceId(Integer userId, Integer deviceId) throws Exception {
Tbl_Device_User device = null;
String key = redisKeyHelperI.getTbl_Device_UserRedisKeyByDeviceIdAndUserId(userId, deviceId);
String redisString = redisHelperI.getRedis(key);
if (StringUtils.isNotBlank(redisString)) {
device = (Tbl_Device_User) IfishUtil.JsonToBean(redisString, Tbl_Device_User.class);
} else {
device = tbl_Device_Mapper.getDeviceUsersByUserIdAndDeviceId(userId, deviceId);
if (device != null && device.getDeviceId() > 0) {
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(device));
}
}
return device;
}
/**
* 根据设备MacAddress获取设备详情
* 根据用户ID和摄像头ID获取此摄像头和用户的关系
*
* @param macAddress
* @param userId
* @param deviceId
* @return
* @throws Exception
*/
Tbl_Device getDeviceByMacAddress(String macAddress) throws Exception;
@Override
public Tbl_Device_User getDeviceUserByUserId_CameraId(Integer userId, String cameraId) throws Exception {
Tbl_Device device = getDeviceByCameraId(cameraId);
if (device == null) {
return null;
}
return getDeviceUserByUserId_DeviceId(userId, device.getDeviceId());
}
/**
* 根据设备Id获取设备详情
*
* @param deviceId
* @return
* @throws Exception
*/
@Override
public Tbl_Device getDeviceById(Integer deviceId) throws Exception {
Tbl_Device device = null;
String key = redisKeyHelperI.getTbl_DeviceRedisKeyByDeviceId(deviceId);
String redisString = redisHelperI.getRedis(key);
if (StringUtils.isNotBlank(redisString)) {
device = (Tbl_Device) IfishUtil.JsonToBean(redisString, Tbl_Device.class);
} else {
device = tbl_Device_Mapper.getDeviceById(deviceId);
if (device != null && device.getDeviceId() > 0) {
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(device));
}
}
return device;
}
/**
* 根据摄像头ID从缓存中取得设备信息
*
* @param cameraId
* @return
* @throws Exception
*/
@Override
public Tbl_Device getDeviceByCameraId(String cameraId) throws Exception {
Tbl_Device device = null;
String key = redisKeyHelperI.getTbl_CameraRedisKeyByCameraId(cameraId);
String redisString = redisHelperI.getRedis(key);
if (StringUtils.isNotBlank(redisString)) {
device = (Tbl_Device) IfishUtil.JsonToBean(redisString, Tbl_Device.class);
} else {
device = tbl_Device_Mapper.getDeviceByCameraId(cameraId);
if (device != null && device.getDeviceId() > 0) {
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(device));
}
}
return device;
}
/**
* 根据设备mac地址获取设备详情
*
* @param macAddress
* @return
* @throws Exception
*/
@Override
public Tbl_Device getDeviceByMacAddress(String macAddress) throws Exception {
Tbl_Device device = null;
String key = redisKeyHelperI.getTbl_DeviceRedisKeyByMacAddress(macAddress);
String redisString = redisHelperI.getRedis(key);
if (StringUtils.isNotBlank(redisString)) {
device = (Tbl_Device) IfishUtil.JsonToBean(redisString, Tbl_Device.class);
} else {
device = tbl_Device_Mapper.getDeviceByMacAddress(macAddress);
if (device != null && device.getDeviceId() > 0) {
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(device));
}
}
return device;
}
/**
* 根据设备ID获取设备统计信息
@ -68,25 +188,210 @@ public interface DeviceHelper {
* @return
* @throws Exception
*/
public Tbl_Device_Statistics getDeviceStatisticsByDeviceId(Integer deviceId) throws Exception;
@Override
public Tbl_Device_Statistics getDeviceStatisticsByDeviceId(Integer deviceId) throws Exception {
Tbl_Device_Statistics device = null;
String key = redisKeyHelperI.getTbl_Device_StatisticsRedisKeyByDeviceId(deviceId);
String redisString = redisHelperI.getRedis(key);
if (StringUtils.isNotBlank(redisString)) {
device = (Tbl_Device_Statistics) IfishUtil.JsonToBean(redisString, Tbl_Device_Statistics.class);
} else {
device = tbl_Device_Mapper.getDevStatisticsByDeviceId(deviceId);
if (device != null && device.getDeviceId() > 0) {
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(device));
}
}
return device;
}
/**
* 根据设备ID获取设备统计信息
*
* @param deviceId
* @return
* @throws Exception
*/
@Override
public Tbl_Device_Statistics getDeviceStatisticsByMacAddress(String mackAddress) throws Exception {
Tbl_Device_Statistics device = null;
String key = redisKeyHelperI.getTbl_Device_StatisticsRedisKeyByMacAddress(mackAddress);
String redisString = redisHelperI.getRedis(key);
if (StringUtils.isNotBlank(redisString)) {
device = (Tbl_Device_Statistics) IfishUtil.JsonToBean(redisString, Tbl_Device_Statistics.class);
} else {
device = tbl_Device_Mapper.getDevStatisticsByMacAddress(mackAddress);
if (device != null && device.getDeviceId() > 0) {
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(device));
}
}
return device;
}
/**
* 绑定设备
*
* @param userId
* @param user
* @param mackAddress
* @return
*/
Object bindDevice(Integer userId, String mackAddress);
@Override
public Object bindDevice(Integer userId, String mackAddress) {
/**
* 激活摄像头
*
* @param activeCode
* @param cameraId
* @return
*/
Object activeCamera(String activeCode, String cameraId);
try {
Tbl_User tmpUser = userHelperI.getUserById(userId);
//用户存在
if (tmpUser != null) {
//新增用户拥有设备
Tbl_Device_User deviceUser = new Tbl_Device_User();
Tbl_Device device = getDeviceByMacAddress(mackAddress);
boolean bln = false;
//设备存在
if (device != null) {
//关联用户-设备
deviceUser.setUserId(tmpUser.getUserId());
deviceUser.setDeviceId(device.getDeviceId());
//已关联设备的其他用户,这里的用户ID查询条件是不等于<>
List<Tbl_Device_User> deviceUserList = tbl_Device_Mapper.getOtherDeviceUsersByOtherUserIdAndDeviceId(tmpUser.getUserId(), device.getDeviceId());
//是否已关联这里的用户ID查询是等于=
Tbl_Device_User tmpDdeviceUser = tbl_Device_Mapper.getDeviceUsersByUserIdAndDeviceId(tmpUser.getUserId(), device.getDeviceId());
//已关联
if (tmpDdeviceUser != null) {
//原先不是主控制则删除其他用户关联关系
if (!tmpDdeviceUser.getIsMaster().equals("1")) {
for (Tbl_Device_User du : deviceUserList) {
Integer userid = du.getUserId();
Integer deviceId = du.getDeviceId();
Tbl_User tu = userHelperI.getUserById(userid);
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 + "失去对“" + du.getShowName() + "”设备的控制权");
baseMap.put("user_id", tu.getUserId().toString());
baseMap.put("loginType", tu.getLoginType());
//推送参数
Map<String, String> pushMap = new HashMap<String, String>();
pushMap.put("device_id", deviceId.toString());
pushMap.put("device_name", du.getShowName());
pushMap.put("timestamp", timestamp);
pushMap.put("msg_type", PushTypeEnum.remove_device.getKey());
//推送消息
jPushNotifcation(baseMap, pushMap);
}
tbl_Device_Mapper.deleteDeviceUserById(du.getId());
redisKeyHelperI.deleteRedisByTbl_Device_User(tmpDdeviceUser);
}
}
//变更为主控
tmpDdeviceUser.setIsMaster("1");
Date date = new Date();
tmpDdeviceUser.setUpdateTime(date);
tmpDdeviceUser.setCreateTime(date);
tbl_Device_Mapper.updateTblDeviceUser(tmpDdeviceUser);
redisKeyHelperI.deleteRedisByTbl_Device_User(tmpDdeviceUser);
deviceUser.setShowName(tmpDdeviceUser.getShowName());
deviceUser.setIsMaster(tmpDdeviceUser.getIsMaster());
} //未绑定过
else {
//删除其他用户控制权
for (Tbl_Device_User du : deviceUserList) {
Integer userid = du.getUserId();
Integer deviceId = du.getDeviceId();
Tbl_User tu = userHelperI.getUserById(userid);
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 + "失去对“" + du.getShowName() + "”设备的控制权");
baseMap.put("user_id", tu.getUserId().toString());
baseMap.put("loginType", tu.getLoginType());
//推送参数
Map<String, String> pushMap = new HashMap<String, String>();
pushMap.put("device_id", deviceId.toString());
pushMap.put("device_name", du.getShowName());
pushMap.put("timestamp", timestamp);
pushMap.put("msg_type", PushTypeEnum.remove_device.getKey());
//推送消息
jPushNotifcation(baseMap, pushMap);
}
tbl_Device_Mapper.deleteDeviceUserById(du.getId());
redisKeyHelperI.deleteRedisByTbl_Device_User(du);
}
//需要新增
bln = true;
//查询设备统计信息
Tbl_Device_Statistics ds = getDeviceStatisticsByDeviceId(device.getDeviceId());
//如果设备统计信息为空新增
if (ds == null || ds.getId() <= 0) {
ds = new Tbl_Device_Statistics();
ds.setDeviceId(device.getDeviceId());
ds.setMacAddress(StringUtils.isBlank(device.getMacAddress()) ? null : device.getMacAddress());
ds.setLoginCount(1);
ds.setLoginTime(new Date());
ds.setFirstActivate(new Date());
ds.setCreateTime(new Date());
ds.setIsCharge("0");
ds.setHardwareType(StringUtils.isBlank(device.getHardwareType()) ? null : device.getHardwareType());
ds.setFactoryCode(StringUtils.isBlank(device.getFactoryCode()) ? null : device.getFactoryCode());
ds.setBrandCode(StringUtils.isBlank(device.getBrandCode()) ? null : device.getBrandCode());
tbl_Device_Mapper.insertDeviceStatistics(ds);
} else {
//修改设备统计信息
if (ds.getFirstActivate() == null) {
ds.setFirstActivate(new Date());
tbl_Device_Mapper.updateDeviceStatistics(ds);
redisKeyHelperI.deleteRedisByTbl_Device_Statistics(ds);
}
}
}
} //设备不存在
else {
//新增设备信息
device = new Tbl_Device();
device.setIsBlacklist("1");
device.setMacAddress(mackAddress);
Date date = new Date();
device.setCreateTime(date);
int i = tbl_Device_Mapper.insertDevice(device);
if (i > 0) {
Tbl_Device_Statistics tds = new Tbl_Device_Statistics();
tds.setLoginCount(0);
tds.setMacAddress(mackAddress);
tds.setDeviceId(device.getDeviceId());
tds.setFirstActivate(date);
tds.setCreateDate(date);
tds.setCreateTime(date);
tbl_Device_Mapper.insertDeviceStatistics(tds);
bln = true;
deviceUser.setUserId(tmpUser.getUserId());
deviceUser.setDeviceId(device.getDeviceId());
}
}
//需要新增
if (bln) {
//新增关联关系
deviceUser.setShowName("鱼缸" + (int) (Math.random() * 9000 + 1000));
deviceUser.setIsMaster("1");
Date date = new Date();
deviceUser.setUpdateTime(date);
deviceUser.setCreateTime(date);
tbl_Device_Mapper.insertDeviceUser(deviceUser);
redisKeyHelperI.deleteRedisByTbl_Device(device);
redisKeyHelperI.deleteRedisByTbl_Device_User(deviceUser);
}
//封装设备返回信息
return IfishUtil.returnJson(ResultEnum.success.getKey(), "绑定成功");
} else {
return IfishUtil.returnJson(ResultEnum.warn202.getKey(), "绑定出错");
}
} catch (Exception e) {
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "绑定失败");
}
}
/**
* 绑定摄像头
@ -95,24 +400,127 @@ public interface DeviceHelper {
* @param cameraId
* @return
*/
Object bindCamera(Integer userId, String cameraId);
@Override
public Object bindCamera(Integer userId, String cameraId) {
try {
Tbl_User user = userHelperI.getUserById(userId);
Tbl_Device camera = getDeviceByCameraId(cameraId);
//返回数据
Map<String, Object> dataMap = new HashMap<String, Object>();
//用户存在
if (user != null) {
//摄像头存在
if (camera != null) {
//已关联摄像头的用户
List<Tbl_Device_User> CameraUserList = tbl_Device_Mapper.getDeviceUsersByDeviceId(camera.getDeviceId());
//删除摄像头与用户关系
for (Tbl_Device_User cu : CameraUserList) {
//删除摄像头和用户的关系
tbl_Device_Mapper.deleteDeviceUserById(cu.getId());
}
} else {
//摄像头不存在
camera = new Tbl_Device();
camera.setCameraId(cameraId);
camera.setCreateTime(new Date());
camera.setIsCamera("1");
tbl_Device_Mapper.insertDevice(camera);
}
//建立关系
Tbl_Device_User device_User = new Tbl_Device_User();
device_User.setUserId(userId);
device_User.setIsMaster("1");
device_User.setIsLook("0");
device_User.setIsLive("0");
device_User.setDeviceId(camera.getDeviceId());
device_User.setShowName("摄像头" + (int) (Math.random() * 900 + 100));
device_User.setCreateTime(new Date());
tbl_Device_Mapper.insertDeviceUser(device_User);
//返回数据
dataMap.put("cameraId", cameraId);
dataMap.put("showName", device_User.getShowName());
dataMap.put("isMaster", device_User.getIsMaster());
dataMap.put("isLook", device_User.getIsLook());
dataMap.put("isLive", device_User.getIsLive());
dataMap.put("isActive", camera.getActiveCode() != null && !camera.getActiveCode().equals("") ? "1" : "0");
return IfishUtil.returnJson(ResultEnum.success.getKey(), "绑定成功");
} else {
return IfishUtil.returnJson(ResultEnum.warn202.getKey(), "绑定出错");
}
} catch (Exception e) {
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "绑定失败");
}
}
/**
* 根据摄像头ID获取设备信息
*
* @param cameraId
* @return
* 激活摄像头
*/
Tbl_Device getDeviceByCameraId(String cameraId) throws Exception;
@Override
public Object activeCamera(String activeCode, String cameraId) {
try {
Tbl_Activa_Code activa_Code = tbl_Device_Mapper.getActiva_CodeByCode(activeCode);
if (activa_Code != null) {
if (activa_Code.getIsUsed().equals("1")) {
return IfishUtil.returnJson(ResultEnum.warn208.getKey(), "");
} else {
Tbl_Device camera = tbl_Device_Mapper.getDeviceByCameraId(cameraId);
if (camera != null) {
if (StringUtils.isNotBlank(camera.getActiveCode())) {
return IfishUtil.returnJson(ResultEnum.success.getKey(), "");
} else {
Date date = new Date();
camera.setActiveCode(activeCode);
camera.setActiveTime(date);
camera.setUpdateTime(date);
int i = tbl_Device_Mapper.updateTbl_Device(camera);
activa_Code.setIsUsed("1");
tbl_Device_Mapper.updateTblActivaCodeIsUse(activeCode);
return IfishUtil.returnJson(ResultEnum.success.getKey(), "");
}
} else {
return IfishUtil.returnJson(ResultEnum.warn210.getKey(), "");
}
}
} else {
return IfishUtil.returnJson(ResultEnum.warn209.getKey(), "");
}
} catch (Exception e) {
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
}
}
/**
* 修改设备信息
* 修改设备和用户的关系数据
*
* @param device
* @param userId
* @return
*/
Object updateDeviceUser(Tbl_Device_User device);
@Override
public Object updateDeviceUser(Tbl_Device_User device) {
try {
Tbl_Device_User olDevice_User = getDeviceUserByUserId_DeviceId(device.getUserId(), device.getDeviceId());
if (device != null) {
if (olDevice_User != null) {
device.setId(olDevice_User.getId());
int i = tbl_Device_Mapper.updateTblDeviceUser(device);
if (i > 0) {
redisKeyHelperI.deleteRedisByTbl_Device_User(device);
Tbl_Device device1 = getDeviceById(device.getDeviceId());
return IfishUtil.returnJson(ResultEnum.success.getKey(), "");
}
}
return IfishUtil.returnJson(ResultEnum.warn207.getKey(), "");
} else {
return IfishUtil.returnJson(ResultEnum.warn207.getKey(), "");
}
} catch (Exception e) {
}
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
}
/**
* 修改摄像头信息
@ -121,7 +529,58 @@ public interface DeviceHelper {
* @param device_User
* @return
*/
Object updateCameraUser(Integer cameraId, Tbl_Device_User device_User);
@Override
public Object updateCameraUser(Integer cameraId, Tbl_Device_User device_User) {
try {
Tbl_Device_User olDevice_User = getDeviceUserByUserId_CameraId(device_User.getUserId(), cameraId.toString());
if (olDevice_User != null) {
if (olDevice_User != null) {
device_User.setId(olDevice_User.getId());
int i = tbl_Device_Mapper.updateTblDeviceUser(device_User);
if (i > 0) {
redisKeyHelperI.deleteRedisByTbl_Device_User(device_User);
Map dataMap = new HashMap();
dataMap.put("cameraId", cameraId);
dataMap.put("showName", device_User.getShowName());
dataMap.put("isMaster", device_User.getIsMaster());
dataMap.put("isLook", device_User.getIsLook());
dataMap.put("isLive", device_User.getIsLive());
Tbl_Device camera = getDeviceById(olDevice_User.getDeviceId());
dataMap.put("isActive", camera.getActiveCode() != null && !camera.getActiveCode().equals("") ? "1" : "0");
return IfishUtil.returnJson(ResultEnum.success.getKey(), dataMap);
}
}
return IfishUtil.returnJson(ResultEnum.warn207.getKey(), "");
} else {
return IfishUtil.returnJson(ResultEnum.warn207.getKey(), "");
}
} catch (Exception e) {
}
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
}
/**
* 解除绑定设备
*
* @param deviceUser
* @return
*/
@Override
public Object deleteDeviceUser(Tbl_Device_User deviceUser) {
try {
Tbl_Device_User device_User = getDeviceUserByUserId_DeviceId(deviceUser.getUserId(), deviceUser.getDeviceId());
if (device_User != null) {
int i = tbl_Device_Mapper.deleteDeviceUserById(device_User.getId());
if (i > 0) {
redisKeyHelperI.deleteRedisByTbl_Device_User(device_User);
return IfishUtil.returnJson(ResultEnum.success.getKey(), "");
}
}
} catch (Exception e) {
}
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
}
/**
* 删除绑定摄像头
@ -130,13 +589,80 @@ public interface DeviceHelper {
* @param cameraId
* @return
*/
Object deleteCameraUser(Integer userId, String cameraId);
@Override
public Object deleteCameraUser(Integer userId, String cameraId) {
try {
Tbl_Device_User device_User = getDeviceUserByUserId_CameraId(userId, cameraId);
if (device_User != null) {
int i = tbl_Device_Mapper.deleteDeviceUserById(device_User.getId());
if (i > 0) {
Tbl_Device device = getDeviceByCameraId(cameraId);
redisKeyHelperI.deleteRedisByTbl_Device(device);
redisKeyHelperI.deleteRedisByTbl_Device_User(device_User);
return IfishUtil.returnJson(ResultEnum.success.getKey(), "");
}
}
} catch (Exception e) {
}
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
}
/**
* 删除绑定的设备
* 极光推送
*
* @param deviceUser
* @return
* @param userId
*/
Object deleteDeviceUser(Tbl_Device_User deviceUser);
public boolean jPushNotifcation(Map<String, String> baseMap, Map<String, String> pushMap) {
try {
//登录类型
String loginType = baseMap.get("loginType");
if (loginType != null) {
//推送消息类型
String msgType = pushMap.get("msg_type");
String userId = baseMap.get("user_id");
String title = baseMap.get("title");
String content = baseMap.get("content");
boolean result = false;
if (loginType.equals("ios")) {
result = jiGuangPush.pushMessageByIOS(title, content, userId, pushMap);
} else if (loginType.equals("android")) {
result = jiGuangPush.pushMessageByAndroid(title, content, userId, pushMap);
}
//推送记录
Tbl_Push_List pushList = new Tbl_Push_List();
if (msgType.equals(PushTypeEnum.remove_device.getKey())) {
pushList.setUserId(Integer.valueOf(userId));
pushList.setDeviceId(Integer.valueOf(pushMap.get("device_id")));
pushList.setPhoneType(loginType);
pushList.setShowName(pushMap.get("showName"));
pushList.setPushType(msgType);
pushList.setPushTitle(title);
pushList.setPushContext(content);
pushList.setJpushStatus(result ? "1" : "0");
pushList.setCreateTime(new Date());
pushMessageHelperI.save(pushList);
return true;
} //发送看护报告推送
else if (msgType.equals(PushTypeEnum.send_report.getKey())) {
String reportId = baseMap.get("reportId");
if (reportId != null) {
pushList.setReportId(Integer.valueOf(reportId));
}
pushList.setUserId(Integer.valueOf(userId));
pushList.setPhoneType(loginType);
pushList.setPushType(msgType);
pushList.setPushTitle(title);
pushList.setPushContext(content);
pushList.setPushLink(pushMap.get("push_link"));
pushList.setJpushStatus(result ? "1" : "0");
pushList.setCreateTime(new Date());
pushMessageHelperI.save(pushList);
return true;
}
}
} catch (Exception e) {
throw new RuntimeException();
}
return false;
}
}

View File

@ -5,71 +5,41 @@
*/
package com.ifish.helper;
import com.ifish.API.JiGuangPush;
import com.ifish.bean.Tbl_Activa_Code;
import com.ifish.bean.Tbl_Device;
import com.ifish.bean.Tbl_Device_Statistics;
import com.ifish.bean.Tbl_Device_User;
import com.ifish.bean.Tbl_Push_List;
import com.ifish.bean.Tbl_User;
import com.ifish.enums.PushTypeEnum;
import com.ifish.enums.ResultEnum;
import com.ifish.mapper.Tbl_Device_Mapper;
import com.ifish.util.IfishUtil;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
* @author Administrator
*/
@Component
public class DeviceHelperI implements DeviceHelper {
@Autowired
private RedisHelperI redisHelperI;
@Autowired
private RedisKeyHelperI redisKeyHelperI;
@Autowired
private Tbl_Device_Mapper tbl_Device_Mapper;
@Autowired
private UserHelperI userHelperI;
@Autowired
private JiGuangPush jiGuangPush;
@Autowired
private PushMessageHelperI pushMessageHelperI;
public interface DeviceHelperI {
/**
* 根据用户Id获取绑定设备集合
*
* @param userId
* @return
* @throws java.lang.Exception
*/
@Override
public List<Tbl_Device_User> getDeviceUsersByUserId(Integer userId) throws Exception {
List<Tbl_Device_User> deviceUserList = null;
String key = redisKeyHelperI.getListTbl_Device_UserKeyByUserId(userId);
String redisString = redisHelperI.getRedis(key);
if (StringUtils.isNotBlank(redisString)) {
deviceUserList = (List<Tbl_Device_User>) IfishUtil.JsonToList(redisString, Tbl_Device_User.class);
} else {
deviceUserList = tbl_Device_Mapper.getDeviceUsersByUserId(userId);
if (deviceUserList != null && deviceUserList.size() > 0) {
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(deviceUserList));
}
}
return deviceUserList;
}
List<Tbl_Device_User> getDeviceUsersByUserId(Integer userId) throws Exception;
/**
* 根据用户ID和摄像头信息获取用户关联数据
*
* @return
*/
Tbl_Device_User getDeviceUserByUserId_CameraId(Integer userId, String cameraId) throws Exception;
/**
* 根据设备Id获取设备详情
*
* @param deviceId
* @return
* @throws Exception
*/
Tbl_Device getDeviceById(Integer deviceId) throws Exception;
/**
* 根据用户ID和设备ID获取此设备和此用户的关系
@ -79,107 +49,17 @@ public class DeviceHelperI implements DeviceHelper {
* @return
* @throws Exception
*/
@Override
public Tbl_Device_User getDeviceUserByUserId_DeviceId(Integer userId, Integer deviceId) throws Exception {
Tbl_Device_User device = null;
String key = redisKeyHelperI.getTbl_Device_UserRedisKeyByDeviceIdAndUserId(userId, deviceId);
String redisString = redisHelperI.getRedis(key);
if (StringUtils.isNotBlank(redisString)) {
device = (Tbl_Device_User) IfishUtil.JsonToBean(redisString, Tbl_Device_User.class);
} else {
device = tbl_Device_Mapper.getDeviceUsersByUserIdAndDeviceId(userId, deviceId);
if (device != null && device.getDeviceId() > 0) {
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(device));
}
}
return device;
}
Tbl_Device_User getDeviceUserByUserId_DeviceId(Integer userId, Integer deviceId) throws Exception;
/**
* 根据用户ID和摄像头ID获取此摄像头和用户的关系
*
* @param userId
* @param deviceId
* @return
* @throws Exception
*/
@Override
public Tbl_Device_User getDeviceUserByUserId_CameraId(Integer userId, String cameraId) throws Exception {
Tbl_Device device = getDeviceByCameraId(cameraId);
if (device == null) {
return null;
}
return getDeviceUserByUserId_DeviceId(userId, device.getDeviceId());
}
/**
* 根据设备Id获取设备详情
*
* @param deviceId
* @return
* @throws Exception
*/
@Override
public Tbl_Device getDeviceById(Integer deviceId) throws Exception {
Tbl_Device device = null;
String key = redisKeyHelperI.getTbl_DeviceRedisKeyByDeviceId(deviceId);
String redisString = redisHelperI.getRedis(key);
if (StringUtils.isNotBlank(redisString)) {
device = (Tbl_Device) IfishUtil.JsonToBean(redisString, Tbl_Device.class);
} else {
device = tbl_Device_Mapper.getDeviceById(deviceId);
if (device != null && device.getDeviceId() > 0) {
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(device));
}
}
return device;
}
/**
* 根据摄像头ID从缓存中取得设备信息
*
* @param cameraId
* @return
* @throws Exception
*/
@Override
public Tbl_Device getDeviceByCameraId(String cameraId) throws Exception {
Tbl_Device device = null;
String key = redisKeyHelperI.getTbl_CameraRedisKeyByCameraId(cameraId);
String redisString = redisHelperI.getRedis(key);
if (StringUtils.isNotBlank(redisString)) {
device = (Tbl_Device) IfishUtil.JsonToBean(redisString, Tbl_Device.class);
} else {
device = tbl_Device_Mapper.getDeviceByCameraId(cameraId);
if (device != null && device.getDeviceId() > 0) {
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(device));
}
}
return device;
}
/**
* 根据设备mac地址获取设备详情
* 根据设备MacAddress获取设备详情
*
* @param macAddress
* @param deviceId
* @return
* @throws Exception
*/
@Override
public Tbl_Device getDeviceByMacAddress(String macAddress) throws Exception {
Tbl_Device device = null;
String key = redisKeyHelperI.getTbl_DeviceRedisKeyByMacAddress(macAddress);
String redisString = redisHelperI.getRedis(key);
if (StringUtils.isNotBlank(redisString)) {
device = (Tbl_Device) IfishUtil.JsonToBean(redisString, Tbl_Device.class);
} else {
device = tbl_Device_Mapper.getDeviceByMacAddress(macAddress);
if (device != null && device.getDeviceId() > 0) {
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(device));
}
}
return device;
}
Tbl_Device getDeviceByMacAddress(String macAddress) throws Exception;
/**
* 根据设备ID获取设备统计信息
@ -188,187 +68,34 @@ public class DeviceHelperI implements DeviceHelper {
* @return
* @throws Exception
*/
@Override
public Tbl_Device_Statistics getDeviceStatisticsByDeviceId(Integer deviceId) throws Exception {
Tbl_Device_Statistics device = null;
String key = redisKeyHelperI.getTbl_Device_StatisticsRedisKeyByDeviceId(deviceId);
String redisString = redisHelperI.getRedis(key);
if (StringUtils.isNotBlank(redisString)) {
device = (Tbl_Device_Statistics) IfishUtil.JsonToBean(redisString, Tbl_Device_Statistics.class);
} else {
device = tbl_Device_Mapper.getDevStatisticsByDeviceId(deviceId);
if (device != null && device.getDeviceId() > 0) {
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(device));
}
}
return device;
}
public Tbl_Device_Statistics getDeviceStatisticsByDeviceId(Integer deviceId) throws Exception;
/**
* 根据设备ID获取设备统计信息
*
* @param deviceId
* @return
* @throws Exception
*/
public Tbl_Device_Statistics getDeviceStatisticsByMacAddress(String macAddress) throws Exception;
/**
* 绑定设备
*
* @param userId
* @param user
* @param mackAddress
* @return
*/
@Override
public Object bindDevice(Integer userId, String mackAddress) {
Object bindDevice(Integer userId, String mackAddress);
try {
Tbl_User tmpUser = userHelperI.getUserById(userId);
//用户存在
if (tmpUser != null) {
//新增用户拥有设备
Tbl_Device_User deviceUser = new Tbl_Device_User();
Tbl_Device device = getDeviceByMacAddress(mackAddress);
boolean bln = false;
//设备存在
if (device != null) {
//关联用户-设备
deviceUser.setUserId(tmpUser.getUserId());
deviceUser.setDeviceId(device.getDeviceId());
//已关联设备的其他用户,这里的用户ID查询条件是不等于<>
List<Tbl_Device_User> deviceUserList = tbl_Device_Mapper.getOtherDeviceUsersByOtherUserIdAndDeviceId(tmpUser.getUserId(), device.getDeviceId());
//是否已关联这里的用户ID查询是等于=
Tbl_Device_User tmpDdeviceUser = tbl_Device_Mapper.getDeviceUsersByUserIdAndDeviceId(tmpUser.getUserId(), device.getDeviceId());
//已关联
if (tmpDdeviceUser != null) {
//原先不是主控制则删除其他用户关联关系
if (!tmpDdeviceUser.getIsMaster().equals("1")) {
for (Tbl_Device_User du : deviceUserList) {
Integer userid = du.getUserId();
Integer deviceId = du.getDeviceId();
Tbl_User tu = userHelperI.getUserById(userid);
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 + "失去对“" + du.getShowName() + "”设备的控制权");
baseMap.put("user_id", tu.getUserId().toString());
baseMap.put("loginType", tu.getLoginType());
//推送参数
Map<String, String> pushMap = new HashMap<String, String>();
pushMap.put("device_id", deviceId.toString());
pushMap.put("device_name", du.getShowName());
pushMap.put("timestamp", timestamp);
pushMap.put("msg_type", PushTypeEnum.remove_device.getKey());
//推送消息
jPushNotifcation(baseMap, pushMap);
}
tbl_Device_Mapper.deleteDeviceUserById(du.getId());
redisKeyHelperI.deleteRedisByTbl_Device_User(tmpDdeviceUser);
}
}
//变更为主控
tmpDdeviceUser.setIsMaster("1");
Date date = new Date();
tmpDdeviceUser.setUpdateTime(date);
tmpDdeviceUser.setCreateTime(date);
tbl_Device_Mapper.updateTblDeviceUser(tmpDdeviceUser);
redisKeyHelperI.deleteRedisByTbl_Device_User(tmpDdeviceUser);
deviceUser.setShowName(tmpDdeviceUser.getShowName());
deviceUser.setIsMaster(tmpDdeviceUser.getIsMaster());
} //未绑定过
else {
//删除其他用户控制权
for (Tbl_Device_User du : deviceUserList) {
Integer userid = du.getUserId();
Integer deviceId = du.getDeviceId();
Tbl_User tu = userHelperI.getUserById(userid);
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 + "失去对“" + du.getShowName() + "”设备的控制权");
baseMap.put("user_id", tu.getUserId().toString());
baseMap.put("loginType", tu.getLoginType());
//推送参数
Map<String, String> pushMap = new HashMap<String, String>();
pushMap.put("device_id", deviceId.toString());
pushMap.put("device_name", du.getShowName());
pushMap.put("timestamp", timestamp);
pushMap.put("msg_type", PushTypeEnum.remove_device.getKey());
//推送消息
jPushNotifcation(baseMap, pushMap);
}
tbl_Device_Mapper.deleteDeviceUserById(du.getId());
redisKeyHelperI.deleteRedisByTbl_Device_User(du);
}
//需要新增
bln = true;
//查询设备统计信息
Tbl_Device_Statistics ds = getDeviceStatisticsByDeviceId(device.getDeviceId());
//如果设备统计信息为空新增
if (ds == null || ds.getId() <= 0) {
ds = new Tbl_Device_Statistics();
ds.setDeviceId(device.getDeviceId());
ds.setMacAddress(StringUtils.isBlank(device.getMacAddress()) ? null : device.getMacAddress());
ds.setLoginCount(1);
ds.setLoginTime(new Date());
ds.setFirstActivate(new Date());
ds.setCreateTime(new Date());
ds.setIsCharge("0");
ds.setHardwareType(StringUtils.isBlank(device.getHardwareType()) ? null : device.getHardwareType());
ds.setFactoryCode(StringUtils.isBlank(device.getFactoryCode()) ? null : device.getFactoryCode());
ds.setBrandCode(StringUtils.isBlank(device.getBrandCode()) ? null : device.getBrandCode());
tbl_Device_Mapper.insertDeviceStatistics(ds);
} else {
//修改设备统计信息
if (ds.getFirstActivate() == null) {
ds.setFirstActivate(new Date());
tbl_Device_Mapper.updateDeviceStatistics(ds);
redisKeyHelperI.deleteRedisByTbl_Device_Statistics(ds);
}
}
}
} //设备不存在
else {
//新增设备信息
device = new Tbl_Device();
device.setIsBlacklist("1");
device.setMacAddress(mackAddress);
Date date = new Date();
device.setCreateTime(date);
int i = tbl_Device_Mapper.insertDevice(device);
if (i > 0) {
Tbl_Device_Statistics tds = new Tbl_Device_Statistics();
tds.setLoginCount(0);
tds.setMacAddress(mackAddress);
tds.setDeviceId(device.getDeviceId());
tds.setFirstActivate(date);
tds.setCreateDate(date);
tds.setCreateTime(date);
tbl_Device_Mapper.insertDeviceStatistics(tds);
bln = true;
deviceUser.setUserId(tmpUser.getUserId());
deviceUser.setDeviceId(device.getDeviceId());
}
}
//需要新增
if (bln) {
//新增关联关系
deviceUser.setShowName("鱼缸" + (int) (Math.random() * 9000 + 1000));
deviceUser.setIsMaster("1");
Date date = new Date();
deviceUser.setUpdateTime(date);
deviceUser.setCreateTime(date);
tbl_Device_Mapper.insertDeviceUser(deviceUser);
redisKeyHelperI.deleteRedisByTbl_Device(device);
redisKeyHelperI.deleteRedisByTbl_Device_User(deviceUser);
}
//封装设备返回信息
return IfishUtil.returnJson(ResultEnum.success.getKey(), "绑定成功");
} else {
return IfishUtil.returnJson(ResultEnum.warn202.getKey(), "绑定出错");
}
} catch (Exception e) {
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "绑定失败");
}
}
/**
* 激活摄像头
*
* @param activeCode
* @param cameraId
* @return
*/
Object activeCamera(String activeCode, String cameraId);
/**
* 绑定摄像头
@ -377,127 +104,24 @@ public class DeviceHelperI implements DeviceHelper {
* @param cameraId
* @return
*/
@Override
public Object bindCamera(Integer userId, String cameraId) {
try {
Tbl_User user = userHelperI.getUserById(userId);
Tbl_Device camera = getDeviceByCameraId(cameraId);
//返回数据
Map<String, Object> dataMap = new HashMap<String, Object>();
//用户存在
if (user != null) {
//摄像头存在
if (camera != null) {
//已关联摄像头的用户
List<Tbl_Device_User> CameraUserList = tbl_Device_Mapper.getDeviceUsersByDeviceId(camera.getDeviceId());
//删除摄像头与用户关系
for (Tbl_Device_User cu : CameraUserList) {
//删除摄像头和用户的关系
tbl_Device_Mapper.deleteDeviceUserById(cu.getId());
}
} else {
//摄像头不存在
camera = new Tbl_Device();
camera.setCameraId(cameraId);
camera.setCreateTime(new Date());
camera.setIsCamera("1");
tbl_Device_Mapper.insertDevice(camera);
}
//建立关系
Tbl_Device_User device_User = new Tbl_Device_User();
device_User.setUserId(userId);
device_User.setIsMaster("1");
device_User.setIsLook("0");
device_User.setIsLive("0");
device_User.setDeviceId(camera.getDeviceId());
device_User.setShowName("摄像头" + (int) (Math.random() * 900 + 100));
device_User.setCreateTime(new Date());
tbl_Device_Mapper.insertDeviceUser(device_User);
//返回数据
dataMap.put("cameraId", cameraId);
dataMap.put("showName", device_User.getShowName());
dataMap.put("isMaster", device_User.getIsMaster());
dataMap.put("isLook", device_User.getIsLook());
dataMap.put("isLive", device_User.getIsLive());
dataMap.put("isActive", camera.getActiveCode() != null && !camera.getActiveCode().equals("") ? "1" : "0");
return IfishUtil.returnJson(ResultEnum.success.getKey(), "绑定成功");
} else {
return IfishUtil.returnJson(ResultEnum.warn202.getKey(), "绑定出错");
}
} catch (Exception e) {
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "绑定失败");
}
}
Object bindCamera(Integer userId, String cameraId);
/**
* 激活摄像头
* 根据摄像头ID获取设备信息
*
* @param cameraId
* @return
*/
@Override
public Object activeCamera(String activeCode, String cameraId) {
try {
Tbl_Activa_Code activa_Code = tbl_Device_Mapper.getActiva_CodeByCode(activeCode);
if (activa_Code != null) {
if (activa_Code.getIsUsed().equals("1")) {
return IfishUtil.returnJson(ResultEnum.warn208.getKey(), "");
} else {
Tbl_Device camera = tbl_Device_Mapper.getDeviceByCameraId(cameraId);
if (camera != null) {
if (StringUtils.isNotBlank(camera.getActiveCode())) {
return IfishUtil.returnJson(ResultEnum.success.getKey(), "");
} else {
Date date = new Date();
camera.setActiveCode(activeCode);
camera.setActiveTime(date);
camera.setUpdateTime(date);
int i = tbl_Device_Mapper.updateTbl_Device(camera);
activa_Code.setIsUsed("1");
tbl_Device_Mapper.updateTblActivaCodeIsUse(activeCode);
return IfishUtil.returnJson(ResultEnum.success.getKey(), "");
}
} else {
return IfishUtil.returnJson(ResultEnum.warn210.getKey(), "");
}
}
} else {
return IfishUtil.returnJson(ResultEnum.warn209.getKey(), "");
}
} catch (Exception e) {
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
}
}
Tbl_Device getDeviceByCameraId(String cameraId) throws Exception;
/**
* 修改设备和用户的关系数据
* 修改设备信息
*
* @param device
* @param userId
* @return
*/
@Override
public Object updateDeviceUser(Tbl_Device_User device) {
try {
Tbl_Device_User olDevice_User = getDeviceUserByUserId_DeviceId(device.getUserId(), device.getDeviceId());
if (device != null) {
if (olDevice_User != null) {
device.setId(olDevice_User.getId());
int i = tbl_Device_Mapper.updateTblDeviceUser(device);
if (i > 0) {
redisKeyHelperI.deleteRedisByTbl_Device_User(device);
Tbl_Device device1 = getDeviceById(device.getDeviceId());
return IfishUtil.returnJson(ResultEnum.success.getKey(), "");
}
}
return IfishUtil.returnJson(ResultEnum.warn207.getKey(), "");
} else {
return IfishUtil.returnJson(ResultEnum.warn207.getKey(), "");
}
} catch (Exception e) {
}
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
}
Object updateDeviceUser(Tbl_Device_User device);
/**
* 修改摄像头信息
@ -506,58 +130,7 @@ public class DeviceHelperI implements DeviceHelper {
* @param device_User
* @return
*/
@Override
public Object updateCameraUser(Integer cameraId, Tbl_Device_User device_User) {
try {
Tbl_Device_User olDevice_User = getDeviceUserByUserId_CameraId(device_User.getUserId(), cameraId.toString());
if (olDevice_User != null) {
if (olDevice_User != null) {
device_User.setId(olDevice_User.getId());
int i = tbl_Device_Mapper.updateTblDeviceUser(device_User);
if (i > 0) {
redisKeyHelperI.deleteRedisByTbl_Device_User(device_User);
Map dataMap = new HashMap();
dataMap.put("cameraId", cameraId);
dataMap.put("showName", device_User.getShowName());
dataMap.put("isMaster", device_User.getIsMaster());
dataMap.put("isLook", device_User.getIsLook());
dataMap.put("isLive", device_User.getIsLive());
Tbl_Device camera = getDeviceById(olDevice_User.getDeviceId());
dataMap.put("isActive", camera.getActiveCode() != null && !camera.getActiveCode().equals("") ? "1" : "0");
return IfishUtil.returnJson(ResultEnum.success.getKey(), dataMap);
}
}
return IfishUtil.returnJson(ResultEnum.warn207.getKey(), "");
} else {
return IfishUtil.returnJson(ResultEnum.warn207.getKey(), "");
}
} catch (Exception e) {
}
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
}
/**
* 解除绑定设备
*
* @param deviceUser
* @return
*/
@Override
public Object deleteDeviceUser(Tbl_Device_User deviceUser) {
try {
Tbl_Device_User device_User = getDeviceUserByUserId_DeviceId(deviceUser.getUserId(), deviceUser.getDeviceId());
if (device_User != null) {
int i = tbl_Device_Mapper.deleteDeviceUserById(device_User.getId());
if (i > 0) {
redisKeyHelperI.deleteRedisByTbl_Device_User(device_User);
return IfishUtil.returnJson(ResultEnum.success.getKey(), "");
}
}
} catch (Exception e) {
}
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
}
Object updateCameraUser(Integer cameraId, Tbl_Device_User device_User);
/**
* 删除绑定摄像头
@ -566,81 +139,14 @@ public class DeviceHelperI implements DeviceHelper {
* @param cameraId
* @return
*/
@Override
public Object deleteCameraUser(Integer userId, String cameraId) {
try {
Tbl_Device_User device_User = getDeviceUserByUserId_CameraId(userId, cameraId);
if (device_User != null) {
int i = tbl_Device_Mapper.deleteDeviceUserById(device_User.getId());
if (i > 0) {
Tbl_Device device = getDeviceByCameraId(cameraId);
redisKeyHelperI.deleteRedisByTbl_Device(device);
redisKeyHelperI.deleteRedisByTbl_Device_User(device_User);
return IfishUtil.returnJson(ResultEnum.success.getKey(), "");
}
}
} catch (Exception e) {
}
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
}
Object deleteCameraUser(Integer userId, String cameraId);
/**
* 极光推送
* 删除绑定的设备
*
* @param userId
* @param deviceUser
* @return
*/
public boolean jPushNotifcation(Map<String, String> baseMap, Map<String, String> pushMap) {
try {
//登录类型
String loginType = baseMap.get("loginType");
if (loginType != null) {
//推送消息类型
String msgType = pushMap.get("msg_type");
String userId = baseMap.get("user_id");
String title = baseMap.get("title");
String content = baseMap.get("content");
boolean result = false;
if (loginType.equals("ios")) {
result = jiGuangPush.pushMessageByIOS(title, content, userId, pushMap);
} else if (loginType.equals("android")) {
result = jiGuangPush.pushMessageByAndroid(title, content, userId, pushMap);
}
//推送记录
Tbl_Push_List pushList = new Tbl_Push_List();
if (msgType.equals(PushTypeEnum.remove_device.getKey())) {
pushList.setUserId(Integer.valueOf(userId));
pushList.setDeviceId(Integer.valueOf(pushMap.get("device_id")));
pushList.setPhoneType(loginType);
pushList.setShowName(pushMap.get("showName"));
pushList.setPushType(msgType);
pushList.setPushTitle(title);
pushList.setPushContext(content);
pushList.setJpushStatus(result ? "1" : "0");
pushList.setCreateTime(new Date());
pushMessageHelperI.save(pushList);
return true;
} //发送看护报告推送
else if (msgType.equals(PushTypeEnum.send_report.getKey())) {
String reportId = baseMap.get("reportId");
if (reportId != null) {
pushList.setReportId(Integer.valueOf(reportId));
}
pushList.setUserId(Integer.valueOf(userId));
pushList.setPhoneType(loginType);
pushList.setPushType(msgType);
pushList.setPushTitle(title);
pushList.setPushContext(content);
pushList.setPushLink(pushMap.get("push_link"));
pushList.setJpushStatus(result ? "1" : "0");
pushList.setCreateTime(new Date());
pushMessageHelperI.save(pushList);
return true;
}
}
} catch (Exception e) {
throw new RuntimeException();
}
return false;
}
Object deleteDeviceUser(Tbl_Device_User deviceUser);
}

View File

@ -0,0 +1,231 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ifish.helper;
import com.ifish.bean.Tbl_Factory_List;
import com.ifish.bean.Tbl_HardWare_Type;
import com.ifish.mapper.Tbl_Factory_List_Mapper;
import com.ifish.util.IfishUtil;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;
/**
*
* @author Administrator
*/
@Component
public class FactoryHelper implements FactoryHelperI {
@Autowired
private Tbl_Factory_List_Mapper tbl_Factory_List_Mapper;
/**
* 电子厂列表
*
* @return
*/
@Override
public ModelAndView getFactoryListView() {
ModelAndView mv = new ModelAndView();
mv.setViewName("factorylist");
mv.addObject("title", "电子厂列表");
mv.addObject("myjs", "<!-- Other plugins ( load only nessesary plugins for every page) -->\n"
+ " <script src=\"static/assets/plugins/core/moment/moment.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/charts/sparklines/jquery.sparkline.js\"></script>\n"
+ " <script src=\"static/assets/plugins/charts/pie-chart/jquery.easy-pie-chart.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/icheck/jquery.icheck.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/tags/jquery.tagsinput.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/tinymce/tinymce.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/tables/jquery.dataTables.js\"></script>\n"
+ "<link href=\"static/assets/plugins/tables/jquery.dataTables.css\" rel=\"stylesheet\">"
+ "<link href=\"static/assets/plugins/tables/dataTables.bootstrap.css\" rel=\"stylesheet\">"
+ " <script src=\"static/assets/plugins/tables/dataTables.bootstrap.js\"></script>\n"
+ " <script src=\"static/assets/plugins/misc/highlight/highlight.pack.js\"></script>\n"
+ " <script src=\"static/assets/plugins/misc/countTo/jquery.countTo.js\"></script>\n"
+ " <script src=\"static/assets/js/jquery.sprFlat.js\"></script>\n"
+ " <script src=\"static/switchery/switchery.min.js\"></script>\n"
+ "<link href=\"static/switchery/switchery.min.css\" rel=\"stylesheet\">"
+ " <script src=\"static/assets/js/app.js\"></script>");
return mv;
}
/**
* 电子厂列表数据
*
* @param draw
* @param start
* @param length
* @return
*/
public Object getFactoryListData(String draw, Integer start, Integer length) {
//电子厂列表
List<Map> list = tbl_Factory_List_Mapper.getFactoryListData(start, length);
//总数
Integer count = tbl_Factory_List_Mapper.getFactoryListCount();
//循环获取鱼缸厂信息和设备信息
for (Map map : list) {
//鱼缸厂信息
List<Map> vendList = tbl_Factory_List_Mapper.getFactoryVenderListData(map.get("factoryCode").toString());
String vendString = "";
for (Map map1 : vendList) {
vendString = vendString + map1.get("brandName") + "";
}
map.put("vendString", vendString);
//设备信息
List<Tbl_HardWare_Type> hardWare_TypeList = tbl_Factory_List_Mapper.getFactoryHardware_TypeListData(map.get("factoryCode").toString());
String hardWareString = "";
for (Tbl_HardWare_Type tbl_HardWare_Type : hardWare_TypeList) {
hardWareString = hardWareString + tbl_HardWare_Type.getHardwareName();
}
map.put("hardWareString", hardWareString);
if (map.get("createTime") != null && StringUtils.isNotBlank(map.get("createTime").toString())) {
map.put("createTime", IfishUtil.format((Date) map.get("createTime")));
}
}
Map map = new HashMap();
map.put("data", list);
map.put("draw", draw);
map.put("recordsTotal", count);
map.put("recordsFiltered", count);
return map;
}
/**
* 修改电子厂是否收税
*
* @param factoryCode
* @param isTax
* @return
*/
@Override
public Object changeFactoryIsTax(String factoryCode, String isTax) {
try {
Tbl_Factory_List factory_List = tbl_Factory_List_Mapper.getFactory_ListByCode(factoryCode);
if (factory_List != null) {
factory_List.setIsTax(isTax);
int i = tbl_Factory_List_Mapper.updateFactoryIsTax(isTax, factoryCode);
if (i >= 0) {
return "成功";
}
}
return "失败";
} catch (Exception e) {
}
return "失败";
}
/**
* 修改电子厂信息
*
* @return
*/
@Override
public ModelAndView updateFactoryDetail(String code) {
ModelAndView mv = new ModelAndView();
//电子厂信息
Tbl_Factory_List factory_List = tbl_Factory_List_Mapper.getFactory_ListByCode(code);
mv.addObject("factory", factory_List);
//已建立关系鱼缸厂信息
List<Map> vendString = tbl_Factory_List_Mapper.getFactoryVenderListData(code);
//所有鱼缸厂关系
List<Map> vendList = tbl_Factory_List_Mapper.getAllVenderList();
for (Map tbl_Vender : vendList) {
for (Map map : vendString) {
if (map.get("brandName").equals(tbl_Vender.get("brandName"))) {
tbl_Vender.put("check", true);
}
}
}
mv.addObject("vendlist", vendList);
//设备信息
List<Tbl_HardWare_Type> allHardWare_Types = tbl_Factory_List_Mapper.getAllHardWare_TypeList();
mv.addObject("hardlist", allHardWare_Types);
mv.setViewName("factorydetail");
mv.addObject("title", "电子厂详情");
mv.addObject("pagetitle", "电子厂详情");
mv.addObject("myjs", "<!-- Other plugins ( load only nessesary plugins for every page) -->\n"
+ " <script src=\"static/assets/plugins/core/moment/moment.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/charts/sparklines/jquery.sparkline.js\"></script>\n"
+ " <script src=\"static/assets/plugins/charts/pie-chart/jquery.easy-pie-chart.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/icheck/jquery.icheck.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/tags/jquery.tagsinput.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/tinymce/tinymce.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/tables/jquery.dataTables.js\"></script>\n"
+ "<link href=\"static/assets/plugins/tables/jquery.dataTables.css\" rel=\"stylesheet\">"
+ "<link href=\"static/assets/plugins/tables/dataTables.bootstrap.css\" rel=\"stylesheet\">"
+ " <script src=\"static/assets/plugins/tables/dataTables.bootstrap.js\"></script>\n"
+ " <script src=\"static/assets/plugins/misc/highlight/highlight.pack.js\"></script>\n"
+ " <script src=\"static/assets/plugins/misc/countTo/jquery.countTo.js\"></script>\n"
+ " <script src=\"static/assets/js/jquery.sprFlat.js\"></script>\n"
+ " <script src=\"static/switchery/switchery.min.js\"></script>\n"
+ "<link href=\"static/switchery/switchery.min.css\" rel=\"stylesheet\">"
+ " <script src=\"static/assets/js/app.js\"></script>");
return mv;
}
/**
* 删除电子厂
*
* @param code
* @return
*/
@Override
public Object deleteFactory(String code) {
try {
int i = tbl_Factory_List_Mapper.deleteFactory(code);
if (i >= 0) {
return "成功";
}
} catch (Exception e) {
}
return "失败";
}
/**
* 修改电子厂信息
*
* @param brandCodes
* @param hardwareTypes
* @param factoryName
* @return
*/
@Override
public Object updateFactory(String[] brandCodes, String[] hardwareTypes, String factoryName, String factoryCode) {
int i = tbl_Factory_List_Mapper.updateFactory(factoryName, factoryCode);
if (i > 0) {
List<Tbl_HardWare_Type> allHardWare_Types = tbl_Factory_List_Mapper.getAllHardWare_TypeList();
List<String> hardwareTypeslist = Arrays.asList(hardwareTypes);
for (Tbl_HardWare_Type HardWare_Type : allHardWare_Types) {
if (hardwareTypeslist.contains(HardWare_Type.getHardwareType()) && (StringUtils.isBlank(HardWare_Type.getFactoryCode()) || !HardWare_Type.getFactoryCode().equals(factoryCode))) {
tbl_Factory_List_Mapper.updateHardWareType(factoryCode, HardWare_Type.getHardwareType());
} else if (!hardwareTypeslist.contains(HardWare_Type.getHardwareType()) && (StringUtils.isNotBlank(HardWare_Type.getFactoryCode()) && HardWare_Type.getFactoryCode().equals(factoryCode))) {
tbl_Factory_List_Mapper.updateHardWareType(null, HardWare_Type.getHardwareType());
}
}
tbl_Factory_List_Mapper.deleteFactoryVender(factoryCode);
for (String brandCode : brandCodes) {
tbl_Factory_List_Mapper.insertFactoryVender(factoryCode, brandCode);
}
return "修改成功!";
}
return "修改失败!";
}
}

View File

@ -0,0 +1,66 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ifish.helper;
import org.springframework.web.servlet.ModelAndView;
/**
*
* @author Administrator
*/
public interface FactoryHelperI {
/**
* 电子厂列表页面
*
* @return
*/
ModelAndView getFactoryListView();
/**
* 电子厂列表数据
*
* @param draw
* @param start
* @param length
* @return
*/
Object getFactoryListData(String draw, Integer start, Integer length);
/**
* 修改电子厂是否收税
*
* @param factoryCode
* @param isTax
* @return
*/
Object changeFactoryIsTax(String factoryCode, String isTax);
/**
* 修改电子厂信息
*
* @return
*/
ModelAndView updateFactoryDetail(String code);
/**
* 删除电子厂
*
* @param code
* @return
*/
Object deleteFactory(String code);
/**
* 修改电子厂信息
*
* @param brandCodes
* @param hardwareTypes
* @param factoryName
* @return
*/
Object updateFactory(String[] brandCodes, String[] hardwareTypes, String factoryName, String factoryCode);
}

View File

@ -26,9 +26,10 @@ public class RedisKeyHelper implements RedisKeyHelperI {
@Autowired
private RedisHelperI redisHelperI;
@Autowired
private DeviceHelper deviceHelper;
private DeviceHelperI deviceHelper;
@Autowired
private UserHelperI userHelperI;
/**
* 根据phoneNumber获取Tbl_User用户信息的Redis缓存key键值
@ -310,7 +311,6 @@ public class RedisKeyHelper implements RedisKeyHelperI {
* @return
*/
@Override
public String getTbl_Live_Room_CountRedisKey() {
return RedisKey.LIVEROOM_COUNT;
}
@ -377,8 +377,18 @@ public class RedisKeyHelper implements RedisKeyHelperI {
*/
@Override
public void deleteRedisByTbl_Device(Tbl_Device device) {
deleteTbl_DeviceInfo(device);
try {
if (device.getDeviceId() != null && device.getDeviceId() != 0 && StringUtils.isBlank(device.getMacAddress())) {
device = deviceHelper.getDeviceById(device.getDeviceId());
}
if (StringUtils.isNotBlank(device.getMacAddress()) && (device.getDeviceId() == null || device.getDeviceId() == 0)) {
device = deviceHelper.getDeviceByMacAddress(device.getMacAddress());
}
if (StringUtils.isNotBlank(device.getCameraId()) && (device.getDeviceId() == null || device.getDeviceId() == 0)) {
device = deviceHelper.getDeviceByCameraId(device.getCameraId());
}
deleteTbl_DeviceInfo(device);
Tbl_Device_Statistics device_Statistics = deviceHelper.getDeviceStatisticsByDeviceId(device.getDeviceId());
deleteTbl_Device_StatisticsInfo(device_Statistics);
} catch (Exception e) {
@ -405,8 +415,15 @@ public class RedisKeyHelper implements RedisKeyHelperI {
*/
@Override
public void deleteRedisByTbl_Device_Statistics(Tbl_Device_Statistics device) {
deleteTbl_Device_StatisticsInfo(device);
try {
if (device.getDeviceId() != null && device.getDeviceId() != 0 && StringUtils.isBlank(device.getMacAddress())) {
device = deviceHelper.getDeviceStatisticsByDeviceId(device.getDeviceId());
}
if (StringUtils.isNotBlank(device.getMacAddress()) && (device.getDeviceId() == null || device.getDeviceId() == 0)) {
device = deviceHelper.getDeviceStatisticsByMacAddress(device.getMacAddress());
}
deleteTbl_Device_StatisticsInfo(device);
Tbl_Device device1 = deviceHelper.getDeviceById(device.getDeviceId());
deleteTbl_DeviceInfo(device1);
} catch (Exception e) {
@ -415,10 +432,10 @@ public class RedisKeyHelper implements RedisKeyHelperI {
public void deleteTbl_Device_StatisticsInfo(Tbl_Device_Statistics device) {
if (device.getDeviceId() != null && device.getDeviceId() > 0) {
redisHelperI.deleteRedis(getTbl_DeviceRedisKeyByDeviceId(device.getDeviceId()));
redisHelperI.deleteRedis(getTbl_Device_StatisticsRedisKeyByDeviceId(device.getDeviceId()));
}
if (StringUtils.isNotBlank(device.getMacAddress())) {
redisHelperI.deleteRedis(getTbl_DeviceRedisKeyByMacAddress(device.getMacAddress()));
redisHelperI.deleteRedis(getTbl_Device_StatisticsRedisKeyByMacAddress(device.getMacAddress()));
}
}
@ -438,6 +455,7 @@ public class RedisKeyHelper implements RedisKeyHelperI {
deleteTbl_Device_StatisticsInfo(device_Statistics);
} catch (Exception e) {
}
}
public void deleteTbl_Device_UserInfo(Tbl_Device_User tbl_Device_User) {
@ -459,6 +477,12 @@ public class RedisKeyHelper implements RedisKeyHelperI {
*/
@Override
public void deleteRedisByTbl_User(Tbl_User tbl_User) {
try {
if (tbl_User.getUserId() != null && tbl_User.getUserId() > 0) {
tbl_User = userHelperI.getUserById(tbl_User.getUserId());
}
} catch (Exception e) {
}
if (tbl_User.getUserId() != null && tbl_User.getUserId() > 0) {
redisHelperI.deleteRedis(getTbl_UserRedisKeyByUserId(tbl_User.getUserId()));
}
@ -483,11 +507,12 @@ public class RedisKeyHelper implements RedisKeyHelperI {
*/
@Override
public void deleteRedisByTbl_Live_Room(Tbl_Live_Room live_Room) {
if (live_Room.getRoomId() != null && live_Room.getRoomId() > 0) {
redisHelperI.deleteRedis(getTbl_Live_RoomRedisKeyByRoomId(live_Room.getRoomId()));
}
if (StringUtils.isNotBlank(live_Room.getCameraId())) {
redisHelperI.deleteRedis(live_Room.getCameraId());
redisHelperI.deleteRedis(getTbl_Live_RoomRedisKeyByCameraId(live_Room.getCameraId()));
}
if (live_Room.getUserId() != null && live_Room.getUserId() > 0) {
redisHelperI.deleteRedis(getTbl_Live_RoomRedisKeyByUserId(live_Room.getUserId()));
@ -590,4 +615,5 @@ public class RedisKeyHelper implements RedisKeyHelperI {
public void deleteRedisByTbl_Push_ListToAllRedisList() {
redisHelperI.delRedisByTagKey(RedisKey.PUSHLIST_SELECT);
}
}

View File

@ -5,28 +5,155 @@
*/
package com.ifish.helper;
import com.ifish.bean.Tbl_Device;
import com.ifish.bean.Tbl_Device_Statistics;
import com.ifish.bean.Tbl_Device_User;
import com.ifish.bean.Tbl_HardWare_Type;
import com.ifish.bean.Tbl_Security_User;
import com.ifish.bean.Tbl_User;
import com.ifish.bean.Tbl_Vender;
import com.ifish.mapper.Tbl_User_Mapper;
import com.ifish.util.IfishUtil;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;
/**
*
* @author Administrator
*/
public interface UserHelper {
@Component
public class UserHelper implements UserHelperI {
@Autowired
private RedisHelperI redisHelperI;
@Autowired
private RedisKeyHelperI redisKeyHelperI;
@Autowired
private Tbl_User_Mapper tbl_User_Mapper;
@Autowired
private DeviceHelper deviceHelper;
@Autowired
private HardWareTypeHelperI hardWareTypeHelperI;
@Override
public Tbl_Security_User getTbl_Security_User(String usernameSring) {
Tbl_Security_User tbl_Security_User = null;
try {
String key = redisKeyHelperI.getTbl_Security_UserRedisKeyByUserName(usernameSring);
String redisString = redisHelperI.getRedis(key);
if (StringUtils.isNotBlank(redisString)) {
tbl_Security_User = (Tbl_Security_User) IfishUtil.JsonToBean(redisString, Tbl_Security_User.class);
} else {
tbl_Security_User = tbl_User_Mapper.getSecurity_UserByUserName(usernameSring);
if (tbl_Security_User != null && tbl_Security_User.getId() > 0) {
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(tbl_Security_User));
}
}
} catch (Exception e) {
}
return tbl_Security_User;
}
/**
* 根据用户名获取后台管理账户
* 根据用户ID从缓存中获取用户对象
*
* @param usernameSring
* @param userId
* @return
* @throws Exception
*/
public Tbl_Security_User getTbl_Security_User(String usernameSring);
@Override
public Tbl_User getUserById(Integer userId) throws Exception {
Tbl_User tmpUser = null;
String userKey = redisKeyHelperI.getTbl_UserRedisKeyByUserId(userId);
String userString = redisHelperI.getRedis(userKey);
//1.从数据库或缓存中读取用户对象
if (StringUtils.isNotBlank(userString)) {
tmpUser = (Tbl_User) IfishUtil.JsonToBean(userString, Tbl_User.class);
} else {
tmpUser = tbl_User_Mapper.getUserByUserId(userId + "");
if (tmpUser != null && tmpUser.getUserId() > 0) {
redisHelperI.setRedis(userKey, IfishUtil.ObjectToJson(tmpUser));
}
}
return tmpUser;
}
/**
* 根据条件获取用户列表
*
* @return
*/
public Object getlist(String draw, Integer start, Integer length, String userId, String phoneNumber, String userEmail, String phoneType, String isRegisterGwell, String isRegisterJiguang, String sortField, String sortMode, String nickName, String remarks, String loginTime1, String loginTime2, String createTime1, String createTime2);
@Override
public Object getlist(String draw, Integer start, Integer length, String userId, String phoneNumber, String userEmail, String phoneType, String isRegisterGwell, String isRegisterJiguang, String sortField, String sortMode, String nickName, String remarks, String loginTime1, String loginTime2, String createTime1, String createTime2) {
List<Map> list = null;
String key = redisKeyHelperI.getUserListRedisKey(start, length, userId, phoneNumber, userEmail, phoneType, isRegisterGwell, isRegisterJiguang, sortField, sortMode, nickName, remarks, loginTime1, loginTime2, createTime1, createTime2);
String redisString = redisHelperI.getRedis(key);
try {
if (StringUtils.isNotBlank(redisString)) {
list = (List<Map>) IfishUtil.JsonToList(redisString, Map.class);
} else {
list = tbl_User_Mapper.getUserList(start, length, userId, phoneNumber, userEmail, phoneType, isRegisterGwell, isRegisterJiguang, sortField, sortMode, nickName, remarks, loginTime1, loginTime2, createTime1, createTime2);
if (list != null && list.size() > 0) {
for (Map map : list) {
if (map.get("createTime") != null) {
String createTime = IfishUtil.format((Date) map.get("createTime"));
map.put("createTime", createTime);
}
if (map.get("loginTime") != null) {
String loginTime = IfishUtil.format((Date) map.get("loginTime"));
map.put("loginTime", loginTime);
}
}
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(list));
}
}
} catch (Exception e) {
}
Integer count = 0;
key = redisKeyHelperI.getUserListCountRedisKey(userId, phoneNumber, userEmail, phoneType, isRegisterGwell, isRegisterJiguang, sortField, sortMode, nickName, remarks, loginTime1, loginTime2, createTime1, createTime2);
redisString = redisHelperI.getRedis(key);
try {
if (StringUtils.isNotBlank(redisString)) {
count = Integer.parseInt(redisString);
} else {
count = tbl_User_Mapper.getUsersCount(userId, phoneNumber, userEmail, phoneType, isRegisterGwell, isRegisterJiguang, sortField, sortMode, nickName, remarks, loginTime1, loginTime2, createTime1, createTime2);
if (count != null && count > 0) {
redisHelperI.setRedis(key, count.toString());
}
}
} catch (Exception e) {
}
Integer allCount = 0;
key = redisKeyHelperI.getAllUserListCountRedisKey();
redisString = redisHelperI.getRedis(key);
try {
if (StringUtils.isNotBlank(redisString)) {
allCount = Integer.parseInt(redisString);
} else {
allCount = tbl_User_Mapper.getAllUsersCount();
if (allCount != null && allCount > 0) {
redisHelperI.setRedis(key, allCount.toString());
}
}
} catch (Exception e) {
}
Map map = new HashMap();
map.put("data", list);
map.put("draw", draw);
map.put("recordsTotal", allCount);
map.put("recordsFiltered", count);
return map;
}
/**
* 修改备注
@ -35,7 +162,18 @@ public interface UserHelper {
* @param remarks
* @return
*/
public Object updateRemarks(String userId, String remarks);
@Override
public Object updateRemarks(String userId, String remarks) {
Tbl_User user = new Tbl_User();
user.setUserId(Integer.parseInt(userId));
user.setRemarks(remarks);
int i = tbl_User_Mapper.updateUser(user);
if (i > 0) {
return "true";
} else {
return "false";
}
}
/**
* 根据用户ID获取用户详情页
@ -43,7 +181,136 @@ public interface UserHelper {
* @param userId
* @return
*/
public Object getUserDetail(String userId);
public Object getUserDetail(String userId) {
ModelAndView mv = new ModelAndView();
if (StringUtils.isBlank(userId)) {
mv.setViewName("redirect:/userlist");
return mv;
}
try {
//用户信息
Tbl_User user = getUserById(Integer.parseInt(userId));
if (user != null) {
mv.addObject("user", user);
//用户性别
if (StringUtils.isNotBlank(user.getUserSex())) {
String userSex = user.getUserSex().equals("1") ? "" : "";
mv.addObject("userSex", userSex);
} else {
mv.addObject("userSex", "未填写");
}
//注册时间
if (user.getCreateTime() != null) {
mv.addObject("createTime", IfishUtil.format(user.getCreateTime()));
}
//极光推送
if (StringUtils.isNotBlank(user.getJiguangUserid())) {
mv.addObject("jiguang", user.getUserId());
} else {
mv.addObject("jiguang", "未注册别名");
}
List<Tbl_Device_User> list = deviceHelper.getDeviceUsersByUserId(user.getUserId());
List<Map> deviceMaps = new ArrayList<Map>();
List<Map> cameraMaps = new ArrayList<Map>();
for (Tbl_Device_User tbl_Device_User : list) {
Tbl_Device device = deviceHelper.getDeviceById(tbl_Device_User.getDeviceId());
if (StringUtils.isNotBlank(device.getCameraId())) {
//摄像头信息
Map map = new HashMap();
//摄像头ID
map.put("cameraId", device.getCameraId());
//显示名称
map.put("cameraName", tbl_Device_User.getShowName());
//是否主控
map.put("isMaster", tbl_Device_User.getIsMaster().equals("1") ? "<span class='btn btn-xs btn-success'>是</span>" : "<span class='btn btn-xs btn-danger'>否</span>");
//是否直播
map.put("isLive", tbl_Device_User.getIsLive().equals("1") ? "<span class='btn btn-xs btn-success'>是</span>" : "<span class='btn btn-xs btn-danger'>否</span>");
//绑定时间
map.put("bindTime", IfishUtil.format(tbl_Device_User.getCreateTime()));
//激活时间
if (device.getActiveTime() != null) {
map.put("firsttime", IfishUtil.format(device.getActiveTime()));
} else {
map.put("firsttime", " ");
}
cameraMaps.add(map);
} else {
//设备信息
Tbl_HardWare_Type hardWare_Type = hardWareTypeHelperI.getHardwareTypeByTypeCode(device.getHardwareType());
Tbl_Vender vender = hardWareTypeHelperI.getVenderListByHardwareTypeCode(hardWare_Type.getHardwareType());
Tbl_Device_Statistics device_Statistics = deviceHelper.getDeviceStatisticsByDeviceId(device.getDeviceId());
Map map = new HashMap();
//设备ID
map.put("deviceId", tbl_Device_User.getDeviceId());
//设备MAC
map.put("deviceMac", device.getMacAddress());
//设备类型方案
map.put("hardwareName", hardWare_Type.getHardwareName());
//厂家名称
if (vender != null) {
map.put("brandName", vender.getBrandName());
} else {
map.put("brandName", " ");
}
//连接次数
map.put("logincount", device_Statistics.getLoginCount());
//最后登录时间
if (device_Statistics.getLoginTime() != null) {
map.put("lastlogintime", IfishUtil.format(device_Statistics.getLoginTime()));
} else {
map.put("lastlogintime", " ");
}
//设备展示名称
map.put("deviceName", tbl_Device_User.getShowName());
//是否主控
map.put("isMaster", tbl_Device_User.getIsMaster().equals("1") ? "<span class='btn btn-xs btn-success'>是</span>" : "<span class='btn btn-xs btn-danger'>否</span>");
//绑定时间
map.put("bindTime", IfishUtil.format(tbl_Device_User.getCreateTime()));
//首次激活时间
if (device_Statistics.getFirstActivate() != null) {
map.put("firsttime", IfishUtil.format(device_Statistics.getFirstActivate()));
} else {
map.put("firsttime", " ");
}
//出厂时间
if (device_Statistics.getCreateTime() != null) {
map.put("createTime", IfishUtil.format(device_Statistics.getCreateTime()));
} else {
map.put("createTime", " ");
}
//是否授权
map.put("isBlacklist", device.getIsBlacklist().equals("1") ? "<span class='btn btn-xs btn-success'>是</span>" : "<span class='btn btn-xs btn-danger'>否</span>");
deviceMaps.add(map);
}
}
mv.addObject("listmap", deviceMaps);
mv.addObject("cameraMaps", cameraMaps);
}
} catch (Exception e) {
}
mv.addObject("myjs", "<!-- Other plugins ( load only nessesary plugins for every page) -->\n"
+ " <script src=\"static/assets/plugins/core/moment/moment.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/charts/sparklines/jquery.sparkline.js\"></script>\n"
+ " <script src=\"static/assets/plugins/charts/pie-chart/jquery.easy-pie-chart.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/icheck/jquery.icheck.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/tags/jquery.tagsinput.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/tinymce/tinymce.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/tables/jquery.dataTables.js\"></script>\n"
+ "<link href=\"static/assets/plugins/tables/jquery.dataTables.css\" rel=\"stylesheet\">"
+ "<link href=\"static/assets/plugins/tables/dataTables.bootstrap.css\" rel=\"stylesheet\">"
+ " <script src=\"static/assets/plugins/tables/dataTables.bootstrap.js\"></script>\n"
+ " <script src=\"static/assets/plugins/misc/highlight/highlight.pack.js\"></script>\n"
+ " <script src=\"static/assets/plugins/misc/countTo/jquery.countTo.js\"></script>\n"
+ " <script src=\"static/assets/js/jquery.sprFlat.js\"></script>\n"
+ " <script src=\"static/assets/js/app.js\"></script>");
mv.setViewName("userdetail");
mv.addObject("title", "用户详情");
return mv;
}
}

View File

@ -5,131 +5,29 @@
*/
package com.ifish.helper;
import com.ifish.bean.Tbl_Device;
import com.ifish.bean.Tbl_Device_Statistics;
import com.ifish.bean.Tbl_Device_User;
import com.ifish.bean.Tbl_HardWare_Type;
import com.ifish.bean.Tbl_Security_User;
import com.ifish.bean.Tbl_User;
import com.ifish.bean.Tbl_Vender;
import com.ifish.mapper.Tbl_User_Mapper;
import com.ifish.util.IfishUtil;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;
/**
*
* @author Administrator
*/
@Component
public class UserHelperI implements UserHelper {
public interface UserHelperI {
@Autowired
private RedisHelperI redisHelperI;
@Autowired
private RedisKeyHelperI redisKeyHelperI;
@Autowired
private Tbl_User_Mapper tbl_User_Mapper;
@Autowired
private DeviceHelper deviceHelper;
@Autowired
private HardWareTypeHelperI hardWareTypeHelperI;
@Override
public Tbl_Security_User getTbl_Security_User(String usernameSring) {
Tbl_Security_User tbl_Security_User = null;
try {
String key = redisKeyHelperI.getTbl_Security_UserRedisKeyByUserName(usernameSring);
String redisString = redisHelperI.getRedis(key);
if (StringUtils.isNotBlank(redisString)) {
tbl_Security_User = (Tbl_Security_User) IfishUtil.JsonToBean(redisString, Tbl_Security_User.class);
} else {
tbl_Security_User = tbl_User_Mapper.getSecurity_UserByUserName(usernameSring);
if (tbl_Security_User != null && tbl_Security_User.getId() > 0) {
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(tbl_Security_User));
}
}
} catch (Exception e) {
}
return tbl_Security_User;
}
/**
* 根据用户名获取后台管理账户
*
* @param usernameSring
* @return
*/
public Tbl_Security_User getTbl_Security_User(String usernameSring);
/**
* 根据条件获取用户列表
*
* @return
*/
@Override
public Object getlist(String draw, Integer start, Integer length, String userId, String phoneNumber, String userEmail, String phoneType, String isRegisterGwell, String isRegisterJiguang, String sortField, String sortMode, String nickName, String remarks, String loginTime1, String loginTime2, String createTime1, String createTime2) {
List<Map> list = null;
String key = redisKeyHelperI.getUserListRedisKey(start, length, userId, phoneNumber, userEmail, phoneType, isRegisterGwell, isRegisterJiguang, sortField, sortMode, nickName, remarks, loginTime1, loginTime2, createTime1, createTime2);
String redisString = redisHelperI.getRedis(key);
try {
if (StringUtils.isNotBlank(redisString)) {
list = (List<Map>) IfishUtil.JsonToList(redisString, Map.class);
} else {
list = tbl_User_Mapper.getUserList(start, length, userId, phoneNumber, userEmail, phoneType, isRegisterGwell, isRegisterJiguang, sortField, sortMode, nickName, remarks, loginTime1, loginTime2, createTime1, createTime2);
if (list != null && list.size() > 0) {
for (Map map : list) {
if (map.get("createTime") != null) {
String createTime = IfishUtil.format((Date) map.get("createTime"));
map.put("createTime", createTime);
}
if (map.get("loginTime") != null) {
String loginTime = IfishUtil.format((Date) map.get("loginTime"));
map.put("loginTime", loginTime);
}
}
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(list));
}
}
} catch (Exception e) {
}
Integer count = 0;
key = redisKeyHelperI.getUserListCountRedisKey(userId, phoneNumber, userEmail, phoneType, isRegisterGwell, isRegisterJiguang, sortField, sortMode, nickName, remarks, loginTime1, loginTime2, createTime1, createTime2);
redisString = redisHelperI.getRedis(key);
try {
if (StringUtils.isNotBlank(redisString)) {
count = Integer.parseInt(redisString);
} else {
count = tbl_User_Mapper.getUsersCount(userId, phoneNumber, userEmail, phoneType, isRegisterGwell, isRegisterJiguang, sortField, sortMode, nickName, remarks, loginTime1, loginTime2, createTime1, createTime2);
if (count != null && count > 0) {
redisHelperI.setRedis(key, count.toString());
}
}
} catch (Exception e) {
}
Integer allCount = 0;
key = redisKeyHelperI.getAllUserListCountRedisKey();
redisString = redisHelperI.getRedis(key);
try {
if (StringUtils.isNotBlank(redisString)) {
allCount = Integer.parseInt(redisString);
} else {
allCount = tbl_User_Mapper.getAllUsersCount();
if (allCount != null && allCount > 0) {
redisHelperI.setRedis(key, allCount.toString());
}
}
} catch (Exception e) {
}
Map map = new HashMap();
map.put("data", list);
map.put("draw", draw);
map.put("recordsTotal", allCount);
map.put("recordsFiltered", count);
return map;
}
public Object getlist(String draw, Integer start, Integer length, String userId, String phoneNumber, String userEmail, String phoneType, String isRegisterGwell, String isRegisterJiguang, String sortField, String sortMode, String nickName, String remarks, String loginTime1, String loginTime2, String createTime1, String createTime2);
/**
* 修改备注
@ -138,18 +36,7 @@ public class UserHelperI implements UserHelper {
* @param remarks
* @return
*/
@Override
public Object updateRemarks(String userId, String remarks) {
Tbl_User user = new Tbl_User();
user.setUserId(Integer.parseInt(userId));
user.setRemarks(remarks);
int i = tbl_User_Mapper.updateUser(user);
if (i > 0) {
return "true";
} else {
return "false";
}
}
public Object updateRemarks(String userId, String remarks);
/**
* 根据用户ID获取用户详情页
@ -157,158 +44,15 @@ public class UserHelperI implements UserHelper {
* @param userId
* @return
*/
public Object getUserDetail(String userId) {
ModelAndView mv = new ModelAndView();
if (StringUtils.isBlank(userId)) {
mv.setViewName("redirect:/userlist");
return mv;
}
try {
//用户信息
Tbl_User user = getUserById(Integer.parseInt(userId));
if (user != null) {
mv.addObject("user", user);
//用户性别
if (StringUtils.isNotBlank(user.getUserSex())) {
String userSex = user.getUserSex().equals("1") ? "" : "";
mv.addObject("userSex", userSex);
} else {
mv.addObject("userSex", "未填写");
}
//注册时间
if (user.getCreateTime() != null) {
mv.addObject("createTime", IfishUtil.format(user.getCreateTime()));
}
//极光推送
if (StringUtils.isNotBlank(user.getJiguangUserid())) {
mv.addObject("jiguang", user.getUserId());
} else {
mv.addObject("jiguang", "未注册别名");
}
List<Tbl_Device_User> list = deviceHelper.getDeviceUsersByUserId(user.getUserId());
List<Map> deviceMaps = new ArrayList<Map>();
List<Map> cameraMaps = new ArrayList<Map>();
for (Tbl_Device_User tbl_Device_User : list) {
Tbl_Device device = deviceHelper.getDeviceById(tbl_Device_User.getDeviceId());
if (StringUtils.isNotBlank(device.getCameraId())) {
//摄像头信息
Map map = new HashMap();
//摄像头ID
map.put("cameraId", device.getCameraId());
//显示名称
map.put("cameraName", tbl_Device_User.getShowName());
//是否主控
map.put("isMaster", tbl_Device_User.getIsMaster().equals("1") ? "<span class='btn btn-xs btn-success'>是</span>" : "<span class='btn btn-xs btn-danger'>否</span>");
//是否直播
map.put("isLive", tbl_Device_User.getIsLive().equals("1") ? "<span class='btn btn-xs btn-success'>是</span>" : "<span class='btn btn-xs btn-danger'>否</span>");
//绑定时间
map.put("bindTime", IfishUtil.format(tbl_Device_User.getCreateTime()));
//激活时间
if (device.getActiveTime() != null) {
map.put("firsttime", IfishUtil.format(device.getActiveTime()));
} else {
map.put("firsttime", " ");
}
cameraMaps.add(map);
} else {
//设备信息
Tbl_HardWare_Type hardWare_Type = hardWareTypeHelperI.getHardwareTypeByTypeCode(device.getHardwareType());
Tbl_Vender vender = hardWareTypeHelperI.getVenderListByHardwareTypeCode(hardWare_Type.getHardwareType());
Tbl_Device_Statistics device_Statistics = deviceHelper.getDeviceStatisticsByDeviceId(device.getDeviceId());
Map map = new HashMap();
//设备ID
map.put("deviceId", tbl_Device_User.getDeviceId());
//设备MAC
map.put("deviceMac", device.getMacAddress());
//设备类型方案
map.put("hardwareName", hardWare_Type.getHardwareName());
//厂家名称
if (vender != null) {
map.put("brandName", vender.getBrandName());
} else {
map.put("brandName", " ");
}
//连接次数
map.put("logincount", device_Statistics.getLoginCount());
//最后登录时间
if (device_Statistics.getLoginTime() != null) {
map.put("lastlogintime", IfishUtil.format(device_Statistics.getLoginTime()));
} else {
map.put("lastlogintime", " ");
}
//设备展示名称
map.put("deviceName", tbl_Device_User.getShowName());
//是否主控
map.put("isMaster", tbl_Device_User.getIsMaster().equals("1") ? "<span class='btn btn-xs btn-success'>是</span>" : "<span class='btn btn-xs btn-danger'>否</span>");
//绑定时间
map.put("bindTime", IfishUtil.format(tbl_Device_User.getCreateTime()));
//首次激活时间
if (device_Statistics.getFirstActivate() != null) {
map.put("firsttime", IfishUtil.format(device_Statistics.getFirstActivate()));
} else {
map.put("firsttime", " ");
}
//出厂时间
if (device_Statistics.getCreateTime() != null) {
map.put("createTime", IfishUtil.format(device_Statistics.getCreateTime()));
} else {
map.put("createTime", " ");
}
//是否授权
map.put("isBlacklist", device.getIsBlacklist().equals("1") ? "<span class='btn btn-xs btn-success'>是</span>" : "<span class='btn btn-xs btn-danger'>否</span>");
deviceMaps.add(map);
}
}
mv.addObject("listmap", deviceMaps);
mv.addObject("cameraMaps", cameraMaps);
}
} catch (Exception e) {
}
mv.addObject("myjs", "<!-- Other plugins ( load only nessesary plugins for every page) -->\n"
+ " <script src=\"static/assets/plugins/core/moment/moment.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/charts/sparklines/jquery.sparkline.js\"></script>\n"
+ " <script src=\"static/assets/plugins/charts/pie-chart/jquery.easy-pie-chart.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/icheck/jquery.icheck.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/tags/jquery.tagsinput.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/tinymce/tinymce.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/tables/jquery.dataTables.js\"></script>\n"
+ "<link href=\"static/assets/plugins/tables/jquery.dataTables.css\" rel=\"stylesheet\">"
+ "<link href=\"static/assets/plugins/tables/dataTables.bootstrap.css\" rel=\"stylesheet\">"
+ " <script src=\"static/assets/plugins/tables/dataTables.bootstrap.js\"></script>\n"
+ " <script src=\"static/assets/plugins/misc/highlight/highlight.pack.js\"></script>\n"
+ " <script src=\"static/assets/plugins/misc/countTo/jquery.countTo.js\"></script>\n"
+ " <script src=\"static/assets/js/jquery.sprFlat.js\"></script>\n"
+ " <script src=\"static/assets/js/app.js\"></script>");
mv.setViewName("userdetail");
mv.addObject("title", "用户详情");
return mv;
}
public Object getUserDetail(String userId);
/**
* 根据用户ID从缓存中获取用户对象
* 根据用户Id获取用户信息
*
* @param userId
* @return
* @throws Exception
* @throws java.lang.Exception
*/
public Tbl_User getUserById(Integer userId) throws Exception {
Tbl_User tmpUser = null;
String userKey = redisKeyHelperI.getTbl_UserRedisKeyByUserId(userId);
String userString = redisHelperI.getRedis(userKey);
//1.从数据库或缓存中读取用户对象
if (StringUtils.isNotBlank(userString)) {
tmpUser = (Tbl_User) IfishUtil.JsonToBean(userString, Tbl_User.class);
} else {
tmpUser = tbl_User_Mapper.getUserByUserId(userId + "");
if (tmpUser != null && tmpUser.getUserId() > 0) {
redisHelperI.setRedis(userKey, IfishUtil.ObjectToJson(tmpUser));
}
}
return tmpUser;
}
public Tbl_User getUserById(Integer userId) throws Exception;
}

View File

@ -30,7 +30,7 @@ public interface Tbl_Device_Mapper {
* @param deviceid
* @return
*/
@Select("SELECT device_id,server_ip,device_ip,is_camera,mac_address,login_time,is_blacklist,hardware_type,on_off,"
@Select("SELECT device_id,server_ip,device_ip,is_camera,mac_address,login_time,is_blacklist,hardware_type,on_off,off_line,"
+ "today_remind,water_remind,remind_cycle,remind_date,factory_code,brand_code,create_time,active_code,active_time,update_time,camera_id from tbl_device WHERE device_id= #{deviceid}")
Tbl_Device getDeviceById(@Param("deviceid") Integer deviceid);
@ -40,7 +40,7 @@ public interface Tbl_Device_Mapper {
* @param deviceid
* @return
*/
@Select("SELECT device_id,server_ip,device_ip,is_camera,mac_address,login_time,is_blacklist,hardware_type,on_off,"
@Select("SELECT device_id,server_ip,device_ip,is_camera,mac_address,login_time,is_blacklist,hardware_type,on_off,off_line,"
+ "today_remind,water_remind,remind_cycle,remind_date,factory_code,brand_code,create_time,active_code,active_time,update_time,camera_id from tbl_device WHERE camera_id= #{cameraID}")
Tbl_Device getDeviceByCameraId(@Param("cameraID") String cameraID);
@ -50,7 +50,7 @@ public interface Tbl_Device_Mapper {
* @param deviceid
* @return
*/
@Select("SELECT device_id,server_ip,device_ip,is_camera,mac_address,login_time,is_blacklist,hardware_type,on_off,"
@Select("SELECT device_id,server_ip,device_ip,is_camera,mac_address,login_time,is_blacklist,hardware_type,on_off,off_line,"
+ "today_remind,water_remind,remind_cycle,remind_date,factory_code,brand_code,create_time,active_code,active_time,update_time,camera_id from tbl_device WHERE mac_address= #{mac_address}")
Tbl_Device getDeviceByMacAddress(@Param("mac_address") String macAddress);

View File

@ -234,6 +234,9 @@ public class Tbl_Device_MapperSql {
if (StringUtils.isNotBlank(device.getOnOff())) {
sb.append("on_off = #{device.onOff}, ");
}
if (StringUtils.isNotBlank(device.getOffLine())) {
sb.append("off_line = #{device.offLine} ");
}
if (StringUtils.isNotBlank(device.getTodayRemind())) {
sb.append("today_remind = #{device.todayRemind}, ");
}

View File

@ -0,0 +1,147 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ifish.mapper;
import com.ifish.bean.Tbl_Factory_List;
import com.ifish.bean.Tbl_HardWare_Type;
import com.ifish.bean.Tbl_Vender;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
/**
*
* @author Administrator
*/
public interface Tbl_Factory_List_Mapper {
/**
* 分页获取电子厂列表
*
* @param start
* @param length
* @return
*/
@Select("SELECT a.factory_code factoryCode,a.factory_name factoryName,a.create_time createTime,a.is_tax isTax from tbl_factory_list a LIMIT ${start},${length}")
List<Map> getFactoryListData(@Param("start") Integer start, @Param("length") Integer length);
/**
* 分页获取电子厂列表总数
*
* @param start
* @param length
* @return
*/
@Select("SELECT count(1) from tbl_factory_list a ")
Integer getFactoryListCount();
/**
* 根据电子厂代码获取鱼缸厂列表
*
* @param code
* @return
*/
@Select("select a.brand_code brandCode,a.brand_name brandName,a.brand_logo brandLogo,a.brand_introduce brandIntroduce,a.app_show appShow,a.contact_phone contactPhone,a.contact_address contactAddress,a.update_time updateTime,a.create_time createTime,b.factory_code factoryCode from tbl_vender_list a "
+ "LEFT JOIN tbl_factory_vender b ON a.brand_code=b.brand_code "
+ "WHERE b.factory_code=#{factoryCode}")
List<Map> getFactoryVenderListData(@Param("factoryCode") String code);
/**
* 获取所有鱼缸厂数据
*/
@Select("select a.brand_code brandCode,a.brand_name brandName,a.brand_logo brandLogo,a.brand_introduce brandIntroduce,a.app_show appShow,a.contact_phone contactPhone,a.contact_address contactAddress,a.update_time updateTime,a.create_time createTime from tbl_vender_list a")
List<Map> getAllVenderList();
/**
* 根据电子厂代码获取设备类型列表
*
* @param code
* @return
*/
@Select("SELECT * from tbl_hardware_type a WHERE a.factory_code=#{factoryCode}")
List<Tbl_HardWare_Type> getFactoryHardware_TypeListData(@Param("factoryCode") String code);
/**
* 获取所有硬件类型
*
* @param code
* @return
*/
@Select("SELECT * from tbl_hardware_type a ")
List<Tbl_HardWare_Type> getAllHardWare_TypeList();
/**
* 根据厂家代码查找电子厂
*
* @param factoryCode
* @return
*/
@Select("SELECT factory_code,factory_name,create_time,is_tax from tbl_factory_list WHERE factory_code = #{code}")
Tbl_Factory_List getFactory_ListByCode(@Param("code") String factoryCode);
/**
* 修改电子厂是否收税信息
*
* @param isTax
* @param factoryCode
* @return
*/
@Update("UPDATE tbl_factory_list SET is_tax = #{isTax} WHERE factory_code = #{code}")
Integer updateFactoryIsTax(@Param("isTax") String isTax, @Param("code") String factoryCode);
/**
* 删除电子厂
*
* @param factoryCode
* @return
*/
@Delete("Delete from tbl_factory_list where factory_code = #{code}")
Integer deleteFactory(@Param("code") String factoryCode);
/**
* 修改电子厂名称
*
* @param name
* @param code
* @return
*/
@Update("UPDATE tbl_factory_list SET factory_name = #{name} WHERE factory_code = #{code}")
Integer updateFactory(@Param("name") String name, @Param("code") String code);
/**
* 修改设备类型所属电子厂
*
* @param factoryCode
* @param hardwareType
* @return
*/
@Update("UPDATE tbl_hardware_type set factory_code = #{code} where hardware_type = #{type}")
Integer updateHardWareType(@Param("code") String factoryCode, @Param("type") String hardwareType);
/**
* 删除电子厂和鱼缸厂的关系
*
* @param factoryCode
* @param brandCode
* @return
*/
@Delete("Delete from tbl_factory_vender where factory_code = #{factorycode}")
Integer deleteFactoryVender(@Param("factorycode") String factoryCode);
/**
* 插入电子厂和鱼缸厂的关系
*
* @param factoryCode
* @param brandCode
* @return
*/
@Insert("INSERT INTO tbl_factory_vender(factory_code,brand_code) VALUES(#{factorycode},#{brandcode})")
Integer insertFactoryVender(@Param("factorycode") String factoryCode, @Param("brandcode") String brandCode);
}

View File

@ -77,7 +77,7 @@ public class Tbl_Push_List_MapperSql {
sb.append(" AND e.phone_number = #{phoneNumber}");
}
if (StringUtils.isNotBlank(mac)) {
sb.append(" AND b.mac_address = #{mac}");
sb.append(" AND b.mac_address like '%" + mac + "%'");
}
if (StringUtils.isBlank(sortField)) {
sortField = "push_id";

View File

@ -129,7 +129,7 @@
<li>
<a href="#"> 厂家管理 <i class="im-dribbble2"></i></a>
<ul class="nav sub">
<li><a href="forms.html"><i class="im-user2"></i> 电子厂信息</a>
<li><a href="factorylist"><i class="im-user2"></i> 电子厂信息</a>
</li>
<li><a href="form-validation.html"><i class="im-users2"></i> 鱼缸场信息</a>
</li>

View File

@ -35,4 +35,14 @@
<definition name="pushlist" extends="base">
<put-attribute name="body" value="/WEB-INF/views/pushlist/list.jsp" />
</definition>
<!-- 电子厂列表 -->
<definition name="factorylist" extends="base">
<put-attribute name="body" value="/WEB-INF/views/factory/list.jsp" />
</definition>
<!-- 电子厂详情 -->
<definition name="factorydetail" extends="base">
<put-attribute name="body" value="/WEB-INF/views/factory/detail.jsp" />
</definition>
</tiles-definitions>

View File

@ -0,0 +1,123 @@
<%--
Document : detail
Created on : 2017-8-3, 13:56:26
Author : Administrator
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<form class="form-horizontal group-border hover-stripped" role="form">
<div class="form-group">
<label class="col-lg-2 col-md-2 col-sm-12 control-label">电子厂编号:</label>
<div class="col-lg-10 col-md-10">
<input type="text" value="${factory.factoryCode}" disabled="disabled" class="form-control input-xlarge">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 col-md-2 col-sm-12 control-label">电子厂名称:</label>
<div class="col-lg-10 col-md-10">
<input type="text" class="form-control input-xlarge" id="factoryName" value="${factory.factoryName}">
</div>
</div><div class="form-group">
<label class="col-lg-2 col-md-2 col-sm-12 control-label">鱼缸厂:</label>
<div class="col-lg-10 col-md-10" >
<c:forEach items="${vendlist}" var="item">
<label class="checkbox-inline">
<div class="icheckbox_flat-blue" style="position: relative;">
<c:choose>
<c:when test="${item.check == true}">
<input type="checkbox" class="venderListCheckbox" value="${item.brandCode}" checked="checked" style="position: absolute; opacity: 0;">
</c:when>
<c:otherwise>
<input type="checkbox" class="venderListCheckbox" value="${item.brandCode}" style="position: absolute; opacity: 0;">
</c:otherwise>
</c:choose>
<ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0;">
</ins>
</div>${item.brandName}
</label>
</c:forEach>
<input type="hidden" id="brandCodes" name="brandCodes">
</div>
</div><div class="form-group">
<label class="col-lg-2 col-md-2 col-sm-12 control-label">硬件类型:</label>
<div class="col-lg-10 col-md-10">
<c:forEach items="${hardlist}" var="item">
<label class="checkbox-inline">
<div class="icheckbox_flat-blue" style="position: relative;">
<c:choose>
<c:when test="${fn:contains(item.factoryCode,factory.factoryCode)}">
<input type="checkbox" class="hardwareTypeCheckbox" value="${item.hardwareType}" checked="checked" style="position: absolute; opacity: 0;">
</c:when>
<c:otherwise>
<input type="checkbox" class="hardwareTypeCheckbox" value="${item.hardwareType}" style="position: absolute; opacity: 0;">
</c:otherwise>
</c:choose>
<ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0;">
</ins>
</div>${item.hardwareName}
</label>
</c:forEach>
<input type="hidden" id="hardwareTypes" name="hardwareTypes">
</div>
</div>
</form>
<div class="form-group" style="margin-left: 418px;margin-top: 40px">
<button class="btn btn-primary" id="btnSend"><i class="fa-ok bigger-110"></i>提交</button>
&nbsp;&nbsp;&nbsp;
<button class="btn" id="btnfalse"><i class="fa-undo bigger-110" ></i>取消</button>
</div>
<script>
$(function () {
var a = $('#crumb');
a.children()[1].remove();
a.append('<li>用户详情<li>');
var b = $('.hasSub')[3];
b.children[0].className = 'expand active-state';
b.children[1].className = 'nav sub show';
b.children[0].children[0].style.transform = 'rotate(-180deg)';
b.children[1].children[0].children[0].className = 'active';
$('#btnSend').click(function () {
var checkboxs = $(".venderListCheckbox");
var brandCodes = new Array();
for (var i = 0; i < checkboxs.length; i++) {
if (checkboxs[i].checked) {
brandCodes.push($(checkboxs[i]).val());
}
}
$("#brandCodes").val(brandCodes);
console.log(brandCodes);
var checkboxs = $(".hardwareTypeCheckbox");
var hardwareTypes = new Array();
for (var i = 0; i < checkboxs.length; i++) {
if (checkboxs[i].checked) {
hardwareTypes.push($(checkboxs[i]).val());
}
}
$("#hardwareTypes").val(hardwareTypes);
console.log(hardwareTypes);
$.ajax({
url: 'updateFactory',
type: 'post',
data: {"brandCodes": $('#brandCodes').val(), "hardwareTypes": $('#hardwareTypes').val(), "factoryName": $('#factoryName').val(), "factoryCode": '${factory.factoryCode}'},
success: function (data) {
alert(data);
},
error: function (data) {
alert(data);
}
});
});
$('#btnfalse').click(function () {
window.opener = null;
window.open('', '_self');
window.close();
});
});
</script>

View File

@ -0,0 +1,144 @@
<%--
Document : list
Created on : 2017-8-2, 13:21:45
Author : Administrator
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<table class="dataTable cell-border" id="datatable" >
<thead>
<tr>
<th>编号</th>
<th>名称</th>
<th>是否收税</th>
<th>鱼缸厂</th>
<th>硬件类型</th>
<th>创建时间</th>
<th>操作</th>
</tr>
</thead>
</table>
<script>
function changeIsTax(a, code) {
var isTax = a.checked ? "1" : "0";
$.ajax({
url: 'updateFactoryIsTax',
type: 'post',
data: {"code": code, "isTax": isTax},
success: function (data) {
console.log(data);
},
error: function (data) {
console.log(data);
}
});
}
$(document).ready(function () {
var table = $('#datatable').on('init.dt', function () {
var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch'));
elems.forEach(function (html) {
var switchery = new Switchery(html);
});
}).DataTable({
//记录用户状态
stateSave: true,
//中文自定义
language: {
"sProcessing": "处理中...",
"sLengthMenu": "显示 _MENU_ 项结果",
"sZeroRecords": "没有匹配结果",
"sInfo": "显示第 _START_ 至 _END_ 项结果,共 _TOTAL_ 项",
"sInfoEmpty": "显示第 0 至 0 项结果,共 0 项",
"sInfoFiltered": "(由 _MAX_ 项结果过滤)",
"sInfoPostFix": "",
"sSearch": "搜索:",
"sUrl": "",
"sEmptyTable": "表中数据为空",
"sLoadingRecords": "载入中...",
"sInfoThousands": ",",
"oPaginate": {
"sFirst": "首页",
"sPrevious": "上页",
"sNext": "下页",
"sLast": "末页"
},
"oAria": {
"sSortAscending": ": 以升序排列此列",
"sSortDescending": ": 以降序排列此列"
}
},
//是否显示排序
bSort: false,
//是否显示过滤搜索
bFilter: false,
//页脚展示风格
pagingType: "full_numbers",
//是否启动服务器数据处理
serverSide: true,
autoWidth: false,
//ajax获取服务器数据
ajax: {
url: 'factorylistData',
type: 'post'
},
//数据展示
columns: [
{
"data": "factoryCode",
"width": "28px"
},
{
"data": "factoryName",
"width": "28px"
},
{
"data": "isTax",
"width": "28px",
render: function (data, type, row, meta) {
var str = "";
if (row.isTax === '0') {
str = '<input type="checkbox" id="isTaxCheck" onclick="changeIsTax(this,\'' + row.factoryCode + '\');" class="js-switch" style="display: none;" value="0">';
} else {
str = '<input type="checkbox" id="isTaxCheck" onclick="changeIsTax(this,\'' + row.factoryCode + '\');" class="js-switch" style="display: none;" value="1" checked="checked">';
}
return str;
}
},
{
"data": "vendString",
"width": "28px"
},
{
"data": "hardWareString",
"width": "28px"
},
{
"data": "createTime",
"width": "28px"
},
{
"data": "userId",
"width": "28px",
render: function (data, type, row, meta) {
var str = "<a href='userDetail?userId=" + row.userId + "' target='_blank' title='查看报表' class='label label-success'><span class='im-profile'></span></a>";
str = str + "<a href='updateFactoryDetail?code=" + row.factoryCode + "' target='_blank' title='修改' class='label label-primary'><span class='fa-edit'></span></a>";
str = str + "<a href='userDetail?userId=" + row.userId + "' target='_blank' title='删除' class='label label-danger'><span class='im-profile'></span></a>";
return str;
}
}
]
});
$(document).keyup(function (event) {
if (event.keyCode == 13) {
table.ajax.reload(null, true);
}
});
});
</script>

View File

@ -187,14 +187,14 @@
<script>
//解除绑定设备
function deleteDevice(userId, deviceId) {
if (window.confirm('你确定要取消交易吗?')) {
if (window.confirm('你确定要解除绑定吗?')) {
$(document).ready(function () {
$.ajax({
url: 'deleteDeviceUser',
type: 'post',
data: {"userId": userId, "deviceId": deviceId},
success: function (e) {
alert(e.data);
alert("已解除");
window.location.reload();
},
error: function (e) {}
@ -211,7 +211,10 @@
var a = $('#crumb');
a.children()[1].remove();
a.append('<li>用户详情<li>');
var b = $('.hasSub')[1].children[1];
b.className = 'nav sub show';
var c = b.children[0].children;
c[0].className = 'active'
//绑定摄像头
$('#bindCameraModal').on('show.bs.modal', function (event) {
});

View File

@ -0,0 +1 @@
.switchery{background-color:#fff;border:1px solid #dfdfdf;border-radius:20px;cursor:pointer;display:inline-block;height:30px;position:relative;vertical-align:middle;width:50px}.switchery>small{background:#fff;border-radius:100%;box-shadow:0 1px 3px rgba(0,0,0,0.4);height:30px;position:absolute;top:0;width:30px}

View File

@ -0,0 +1,297 @@
(function () {
function require(path, parent, orig) {
var resolved = require.resolve(path);
if (null == resolved) {
orig = orig || path;
parent = parent || "root";
var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
err.path = orig;
err.parent = parent;
err.require = true;
throw err
}
var module = require.modules[resolved];
if (!module._resolving && !module.exports) {
var mod = {};
mod.exports = {};
mod.client = mod.component = true;
module._resolving = true;
module.call(this, mod.exports, require.relative(resolved), mod);
delete module._resolving;
module.exports = mod.exports
}
return module.exports
}
require.modules = {};
require.aliases = {};
require.resolve = function (path) {
if (path.charAt(0) === "/")
path = path.slice(1);
var paths = [path, path + ".js", path + ".json", path + "/index.js", path + "/index.json"];
for (var i = 0; i < paths.length; i++) {
var path = paths[i];
if (require.modules.hasOwnProperty(path))
return path;
if (require.aliases.hasOwnProperty(path))
return require.aliases[path]
}
}
;
require.normalize = function (curr, path) {
var segs = [];
if ("." != path.charAt(0))
return path;
curr = curr.split("/");
path = path.split("/");
for (var i = 0; i < path.length; ++i) {
if (".." == path[i]) {
curr.pop()
} else if ("." != path[i] && "" != path[i]) {
segs.push(path[i])
}
}
return curr.concat(segs).join("/")
}
;
require.register = function (path, definition) {
require.modules[path] = definition
}
;
require.alias = function (from, to) {
if (!require.modules.hasOwnProperty(from)) {
throw new Error('Failed to alias "' + from + '", it does not exist')
}
require.aliases[to] = from
}
;
require.relative = function (parent) {
var p = require.normalize(parent, "..");
function lastIndexOf(arr, obj) {
var i = arr.length;
while (i--) {
if (arr[i] === obj)
return i
}
return -1
}
function localRequire(path) {
var resolved = localRequire.resolve(path);
return require(resolved, parent, path)
}
localRequire.resolve = function (path) {
var c = path.charAt(0);
if ("/" == c)
return path.slice(1);
if ("." == c)
return require.normalize(p, path);
var segs = parent.split("/");
var i = lastIndexOf(segs, "deps") + 1;
if (!i)
i = 0;
path = segs.slice(0, i + 1).join("/") + "/deps/" + path;
return path
}
;
localRequire.exists = function (path) {
return require.modules.hasOwnProperty(localRequire.resolve(path))
}
;
return localRequire
}
;
require.register("abpetkov-transitionize/transitionize.js", function (exports, require, module) {
module.exports = Transitionize;
function Transitionize(element, props) {
if (!(this instanceof Transitionize))
return new Transitionize(element, props);
this.element = element;
this.props = props || {};
this.init()
}
Transitionize.prototype.isSafari = function () {
return /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor)
}
;
Transitionize.prototype.init = function () {
var transitions = [];
for (var key in this.props) {
transitions.push(key + " " + this.props[key])
}
this.element.style.transition = transitions.join(", ");
if (this.isSafari())
this.element.style.webkitTransition = transitions.join(", ")
}
});
require.register("switchery/switchery.js", function (exports, require, module) {
var transitionize = require("transitionize");
module.exports = Switchery;
var defaults = {
color: "#64bd63",
secondaryColor: "#dfdfdf",
className: "switchery",
disabled: false,
disabledOpacity: .5,
speed: "0.4s"
};
function Switchery(element, options) {
if (!(this instanceof Switchery))
return new Switchery(element, options);
this.element = element;
this.options = options || {};
for (var i in defaults) {
if (this.options[i] == null) {
this.options[i] = defaults[i]
}
}
if (this.element.type == "checkbox")
this.init()
}
Switchery.prototype.hide = function () {
this.element.style.display = "none"
}
;
Switchery.prototype.show = function () {
var switcher = this.create();
this.insertAfter(this.element, switcher)
}
;
Switchery.prototype.create = function () {
this.switcher = document.createElement("span");
this.jack = document.createElement("small");
this.switcher.appendChild(this.jack);
this.switcher.className = this.options.className;
return this.switcher
}
;
Switchery.prototype.insertAfter = function (reference, target) {
reference.parentNode.insertBefore(target, reference.nextSibling)
}
;
Switchery.prototype.isChecked = function () {
return this.element.checked
}
;
Switchery.prototype.isDisabled = function () {
return this.options.disabled || this.element.disabled
}
;
Switchery.prototype.setPosition = function (clicked) {
var checked = this.isChecked()
, switcher = this.switcher
, jack = this.jack;
if (clicked && checked)
checked = false;
else if (clicked && !checked)
checked = true;
if (checked === true) {
this.element.checked = true;
if (window.getComputedStyle)
jack.style.left = parseInt(window.getComputedStyle(switcher).width) - jack.offsetWidth + "px";
else
jack.style.left = parseInt(switcher.currentStyle["width"]) - jack.offsetWidth + "px";
if (this.options.color)
this.colorize();
this.setSpeed()
} else {
jack.style.left = 0;
this.element.checked = false;
this.switcher.style.boxShadow = "inset 0 0 0 0 " + this.options.secondaryColor;
this.switcher.style.borderColor = this.options.secondaryColor;
this.switcher.style.backgroundColor = "";
this.setSpeed()
}
}
;
Switchery.prototype.setSpeed = function () {
var switcherProp = {}
, jackProp = {
left: this.options.speed.replace(/[a-z]/, "") / 2 + "s"
};
if (this.isChecked()) {
switcherProp = {
border: this.options.speed,
"box-shadow": this.options.speed,
"background-color": this.options.speed.replace(/[a-z]/, "") * 3 + "s"
}
} else {
switcherProp = {
border: this.options.speed,
"box-shadow": this.options.speed
}
}
transitionize(this.switcher, switcherProp);
transitionize(this.jack, jackProp)
}
;
Switchery.prototype.setAttributes = function () {
var id = this.element.getAttribute("id")
, name = this.element.getAttribute("name");
if (id)
this.switcher.setAttribute("id", id);
if (name)
this.switcher.setAttribute("name", name)
}
;
Switchery.prototype.colorize = function () {
this.switcher.style.backgroundColor = this.options.color;
this.switcher.style.borderColor = this.options.color;
this.switcher.style.boxShadow = "inset 0 0 0 16px " + this.options.color
}
;
Switchery.prototype.handleOnchange = function (state) {
var evt = new Event("click");
this.element.dispatchEvent(evt);
if (typeof Event === "function") {
var event = new Event("change", {
cancelable: true
});
this.element.dispatchEvent(event)
} else {
this.element.fireEvent("onchange")
}
}
;
Switchery.prototype.handleClick = function () {
var self = this
, switcher = this.switcher;
if (this.isDisabled() === false) {
if (switcher.addEventListener) {
switcher.addEventListener("click", function () {
self.setPosition(true);
self.handleOnchange(self.element.checked)
})
} else {
switcher.attachEvent("onclick", function () {
self.setPosition(true);
self.handleOnchange(self.element.checked)
})
}
} else {
this.element.disabled = true;
this.switcher.style.opacity = this.options.disabledOpacity
}
}
;
Switchery.prototype.init = function () {
this.hide();
this.show();
this.setPosition();
this.setAttributes();
this.handleClick()
}
});
require.alias("abpetkov-transitionize/transitionize.js", "switchery/deps/transitionize/transitionize.js");
require.alias("abpetkov-transitionize/transitionize.js", "switchery/deps/transitionize/index.js");
require.alias("abpetkov-transitionize/transitionize.js", "transitionize/index.js");
require.alias("abpetkov-transitionize/transitionize.js", "abpetkov-transitionize/index.js");
require.alias("switchery/switchery.js", "switchery/index.js");
if (typeof exports == "object") {
module.exports = require("switchery")
} else if (typeof define == "function" && define.amd) {
define(function () {
return require("switchery")
})
} else {
this["Switchery"] = require("switchery")
}
})();