Compare commits
No commits in common. "master" and "v4.6.9" have entirely different histories.
52
pom.xml
52
pom.xml
|
|
@ -38,49 +38,49 @@
|
|||
<artifactId>spring-core</artifactId>
|
||||
<version>4.1.6.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>4.1.6.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-orm</artifactId>
|
||||
<version>4.1.6.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
<version>4.1.6.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
<version>1.8.5</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
<version>4.1.6.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>4.3.11.Final</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jboss.logging</groupId>
|
||||
<artifactId>jboss-logging-annotations</artifactId>
|
||||
<version>2.0.1.Final</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>c3p0</groupId>
|
||||
<artifactId>c3p0</artifactId>
|
||||
|
|
@ -92,31 +92,31 @@
|
|||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.7.13</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.mina</groupId>
|
||||
<artifactId>mina-core</artifactId>
|
||||
<version>2.0.17</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.mina</groupId>
|
||||
<artifactId>mina-integration-spring</artifactId>
|
||||
<version>1.1.7</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.mina</groupId>
|
||||
<artifactId>mina-integration-beans</artifactId>
|
||||
<version>2.0.17</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.mina</groupId>
|
||||
<artifactId>mina-filter-compression</artifactId>
|
||||
<version>2.0.17</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
|
|
@ -140,25 +140,19 @@
|
|||
<artifactId>json</artifactId>
|
||||
<version>20090211</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>30.1.1-jre</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>3.0-alpha-1</version>
|
||||
|
||||
<!-- <dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>3.0-alpha-1</version>
|
||||
</dependency> -->
|
||||
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>ifishSocket</finalName>
|
||||
|
|
@ -175,9 +169,9 @@
|
|||
</webResources>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>2.5.4</version>
|
||||
<extensions>true</extensions>
|
||||
</plugin>
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
package com.ifish.dao;
|
||||
|
||||
import com.ifish.entity.DevicePetUser;
|
||||
import org.hibernate.criterion.Criterion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: DeviceUserDao
|
||||
* @Description: TODO
|
||||
* @author ggw
|
||||
*
|
||||
*/
|
||||
public interface DevicePetUserDao{
|
||||
|
||||
List<DevicePetUser> getListByProperty(Criterion... criterions);
|
||||
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
package com.ifish.dao;
|
||||
|
||||
import com.ifish.entity.Device;
|
||||
import com.ifish.entity.DevicePower;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: DeviceDao
|
||||
* @Description: TODO
|
||||
* @author ggw
|
||||
*
|
||||
*/
|
||||
public interface DevicePowerDao {
|
||||
|
||||
public DevicePower findById(Integer id);
|
||||
|
||||
public DevicePower save(DevicePower device);
|
||||
|
||||
public DevicePower update(DevicePower device);
|
||||
|
||||
public DevicePower getUniqueByProperty(String property,Object value);
|
||||
|
||||
public List<DevicePower> getByProperty(String property,Object value);
|
||||
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
package com.ifish.dao;
|
||||
|
||||
import com.ifish.entity.DevicePowerMonth;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: DeviceDao
|
||||
* @Description: TODO
|
||||
* @author ggw
|
||||
*
|
||||
*/
|
||||
public interface DevicePowerMonthDao {
|
||||
|
||||
public DevicePowerMonth findById(Integer id);
|
||||
|
||||
public DevicePowerMonth save(DevicePowerMonth device);
|
||||
|
||||
public DevicePowerMonth update(DevicePowerMonth device);
|
||||
|
||||
public DevicePowerMonth getUniqueByProperty(String property,Object value);
|
||||
|
||||
public List<DevicePowerMonth> getByProperty(String property,Object value);
|
||||
|
||||
DevicePowerMonth findByDate(String macAddress, String year, String month);
|
||||
|
||||
}
|
||||
|
|
@ -13,10 +13,8 @@ import com.ifish.entity.DeviceUser;
|
|||
*/
|
||||
public interface DeviceUserDao {
|
||||
|
||||
DeviceUser getUniqueByProperty(Criterion... criterions);
|
||||
public DeviceUser getUniqueByProperty(Criterion... criterions);
|
||||
|
||||
List<DeviceUser> getListByProperty(Criterion... criterions);
|
||||
|
||||
void saveDeviceUser(DeviceUser deviceUser);
|
||||
public List<DeviceUser> getListByProperty(Criterion... criterions);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
package com.ifish.daoImpl;
|
||||
|
||||
import com.ifish.dao.DevicePetUserDao;
|
||||
import com.ifish.entity.DevicePetUser;
|
||||
import com.ifish.entity.DeviceUser;
|
||||
import com.ifish.entity.PriId;
|
||||
import com.ifish.hibernate.HibernateBaseDao;
|
||||
import org.hibernate.criterion.Criterion;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: DeviceUserDaoImpl
|
||||
* @Description: TODO
|
||||
* @author ggw
|
||||
*
|
||||
*/
|
||||
|
||||
@Repository("devicePetUserDao")
|
||||
public class DevicePetUserDaoImpl extends HibernateBaseDao<DevicePetUser, PriId> implements DevicePetUserDao {
|
||||
|
||||
@Override
|
||||
protected Class<DevicePetUser> getEntityClass() {
|
||||
return DevicePetUser.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DevicePetUser> getListByProperty(Criterion... criterions) {
|
||||
return this.findByProperty(criterions);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
package com.ifish.daoImpl;
|
||||
|
||||
import com.ifish.dao.DeviceDao;
|
||||
import com.ifish.dao.DevicePowerDao;
|
||||
import com.ifish.entity.Device;
|
||||
import com.ifish.entity.DevicePower;
|
||||
import com.ifish.hibernate.HibernateBaseDao;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: DeviceDaoImpl
|
||||
* @Description: TODO
|
||||
* @author ggw
|
||||
*
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public class DevicePowerDaoImpl extends HibernateBaseDao<DevicePower, Integer> implements DevicePowerDao {
|
||||
|
||||
|
||||
@Override
|
||||
protected Class<DevicePower> getEntityClass() {
|
||||
return DevicePower.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevicePower findById(Integer id) {
|
||||
return this.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevicePower getUniqueByProperty(String property, Object value) {
|
||||
return this.findUniqueByProperty(Restrictions.eq(property, value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevicePower save(DevicePower device) {
|
||||
this.getSession().save(device);
|
||||
return device;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevicePower update(DevicePower device) {
|
||||
this.getSession().update(device);
|
||||
return device;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DevicePower> getByProperty(String property, Object value) {
|
||||
return this.findByProperty(Restrictions.eq(property, value));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
package com.ifish.daoImpl;
|
||||
|
||||
import com.ifish.dao.DevicePowerMonthDao;
|
||||
import com.ifish.entity.DevicePowerMonth;
|
||||
import com.ifish.enums.BooleanEnum;
|
||||
import com.ifish.hibernate.HibernateBaseDao;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.hibernate.transform.Transformers;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: DeviceDaoImpl
|
||||
* @Description: TODO
|
||||
* @author ggw
|
||||
*
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public class DevicePowerMonthDaoImpl extends HibernateBaseDao<DevicePowerMonth, Integer> implements DevicePowerMonthDao {
|
||||
|
||||
|
||||
@Override
|
||||
protected Class<DevicePowerMonth> getEntityClass() {
|
||||
return DevicePowerMonth.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevicePowerMonth findById(Integer id) {
|
||||
return this.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevicePowerMonth getUniqueByProperty(String property, Object value) {
|
||||
return this.findUniqueByProperty(Restrictions.eq(property, value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevicePowerMonth save(DevicePowerMonth device) {
|
||||
this.getSession().save(device);
|
||||
return device;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevicePowerMonth update(DevicePowerMonth device) {
|
||||
this.getSession().update(device);
|
||||
return device;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DevicePowerMonth> getByProperty(String property, Object value) {
|
||||
return this.findByProperty(Restrictions.eq(property, value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevicePowerMonth findByDate(String macAddress, String year, String month) {
|
||||
String sql = "select id,mac_address macAddress,year_s yearS,month_s monthS,power from tbl_device_power_month where mac_address = ? and year_s = ? and month_s = ? ";
|
||||
List<DevicePowerMonth> list = this.getSession().createSQLQuery(sql)
|
||||
.setParameter(0, macAddress)
|
||||
.setParameter(1, year)
|
||||
.setParameter(2, month)
|
||||
.setResultTransformer(Transformers.aliasToBean(DevicePowerMonth.class)).list();
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -35,8 +35,4 @@ public class DeviceUserDaoImpl extends HibernateBaseDao<DeviceUser, PriId> imple
|
|||
return this.findByProperty(criterions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveDeviceUser(DeviceUser deviceUser) {
|
||||
this.getSession().save(deviceUser);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,87 +0,0 @@
|
|||
package com.ifish.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName: tbl_device_user
|
||||
* @date 2015年7月2日 下午16:40:00
|
||||
*
|
||||
*/
|
||||
public class DevicePetUser implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -6056043883433438749L;
|
||||
//ID
|
||||
private PriId priId = new PriId();
|
||||
//显示名称
|
||||
private String showName;
|
||||
private String storeName;
|
||||
private Integer isMaster;
|
||||
//创建时间
|
||||
private Date createTime;
|
||||
|
||||
//用户
|
||||
private User user = new User();
|
||||
//设备
|
||||
private Device device = new Device();
|
||||
public DevicePetUser() {}
|
||||
|
||||
public DevicePetUser(PriId priId, String showName, String storeName) {
|
||||
this.priId = priId;
|
||||
this.showName = showName;
|
||||
this.storeName = storeName;
|
||||
}
|
||||
|
||||
public PriId getPriId() {
|
||||
return priId;
|
||||
}
|
||||
public void setPriId(PriId priId) {
|
||||
this.priId = priId;
|
||||
}
|
||||
public String getShowName() {
|
||||
return showName;
|
||||
}
|
||||
public void setShowName(String showName) {
|
||||
this.showName = showName;
|
||||
}
|
||||
|
||||
public String getStoreName() {
|
||||
return storeName;
|
||||
}
|
||||
|
||||
public void setStoreName(String storeName) {
|
||||
this.storeName = storeName;
|
||||
}
|
||||
|
||||
public Integer getIsMaster() {
|
||||
return isMaster;
|
||||
}
|
||||
|
||||
public void setIsMaster(Integer isMaster) {
|
||||
this.isMaster = isMaster;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Device getDevice() {
|
||||
return device;
|
||||
}
|
||||
|
||||
public void setDevice(Device device) {
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
package com.ifish.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author: yan.y
|
||||
* @Description:
|
||||
* @Date: Created in 20:35 2022/4/23
|
||||
* @Modified by:
|
||||
*/
|
||||
public class DevicePower implements Serializable {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String macAddress;
|
||||
|
||||
private String yearS;
|
||||
|
||||
private String monthS;
|
||||
|
||||
private String dayPower;
|
||||
private String monthPower;
|
||||
|
||||
private String dayS;
|
||||
|
||||
private String ph;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getMacAddress() {
|
||||
return macAddress;
|
||||
}
|
||||
|
||||
public void setMacAddress(String macAddress) {
|
||||
this.macAddress = macAddress;
|
||||
}
|
||||
|
||||
public String getYearS() {
|
||||
return yearS;
|
||||
}
|
||||
|
||||
public void setYearS(String yearS) {
|
||||
this.yearS = yearS;
|
||||
}
|
||||
|
||||
public String getMonthS() {
|
||||
return monthS;
|
||||
}
|
||||
|
||||
public void setMonthS(String monthS) {
|
||||
this.monthS = monthS;
|
||||
}
|
||||
|
||||
public String getDayPower() {
|
||||
return dayPower;
|
||||
}
|
||||
|
||||
public void setDayPower(String dayPower) {
|
||||
this.dayPower = dayPower;
|
||||
}
|
||||
|
||||
public String getMonthPower() {
|
||||
return monthPower;
|
||||
}
|
||||
|
||||
public void setMonthPower(String monthPower) {
|
||||
this.monthPower = monthPower;
|
||||
}
|
||||
|
||||
public String getDayS() {
|
||||
return dayS;
|
||||
}
|
||||
|
||||
public void setDayS(String dayS) {
|
||||
this.dayS = dayS;
|
||||
}
|
||||
|
||||
public String getPh() {
|
||||
return ph;
|
||||
}
|
||||
|
||||
public void setPh(String ph) {
|
||||
this.ph = ph;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
package com.ifish.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author: yan.y
|
||||
* @Description:
|
||||
* @Date: Created in 20:35 2022/4/23
|
||||
* @Modified by:
|
||||
*/
|
||||
public class DevicePowerMonth implements Serializable {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String macAddress;
|
||||
|
||||
private String yearS;
|
||||
|
||||
private String monthS;
|
||||
|
||||
private String monthPower;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getMacAddress() {
|
||||
return macAddress;
|
||||
}
|
||||
|
||||
public void setMacAddress(String macAddress) {
|
||||
this.macAddress = macAddress;
|
||||
}
|
||||
|
||||
public String getYearS() {
|
||||
return yearS;
|
||||
}
|
||||
|
||||
public void setYearS(String yearS) {
|
||||
this.yearS = yearS;
|
||||
}
|
||||
|
||||
public String getMonthS() {
|
||||
return monthS;
|
||||
}
|
||||
|
||||
public void setMonthS(String monthS) {
|
||||
this.monthS = monthS;
|
||||
}
|
||||
|
||||
public String getMonthPower() {
|
||||
return monthPower;
|
||||
}
|
||||
|
||||
public void setMonthPower(String monthPower) {
|
||||
this.monthPower = monthPower;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
package com.ifish.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName: tbl_device_user
|
||||
|
|
@ -9,76 +8,32 @@ import java.util.Date;
|
|||
*
|
||||
*/
|
||||
public class DeviceUser implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -6056043883433438749L;
|
||||
|
||||
private static final long serialVersionUID = 6845058501114939424L;
|
||||
//ID
|
||||
private DeviceUserId priId = new DeviceUserId();
|
||||
private PriId priId = new PriId();
|
||||
//1、主控制权,0、被分享者
|
||||
private String isMaster;
|
||||
//显示名称
|
||||
private String showName;
|
||||
//保存的显示图标
|
||||
private String customIconName;
|
||||
//保存的显示名称
|
||||
private String customShowName;
|
||||
//修改时间
|
||||
private Date updateTime;
|
||||
//创建时间
|
||||
private Date createTime;
|
||||
|
||||
public DeviceUser() {}
|
||||
|
||||
public DeviceUser(DeviceUserId priId, String isMaster, String showName) {
|
||||
this.priId = priId;
|
||||
this.isMaster = isMaster;
|
||||
this.showName = showName;
|
||||
this.customIconName = "";
|
||||
this.customShowName = "";
|
||||
this.updateTime = new Date();
|
||||
this.createTime = new Date();
|
||||
}
|
||||
|
||||
public DeviceUserId getPriId() {
|
||||
|
||||
public PriId getPriId() {
|
||||
return priId;
|
||||
}
|
||||
public void setPriId(DeviceUserId priId) {
|
||||
public void setPriId(PriId priId) {
|
||||
this.priId = priId;
|
||||
}
|
||||
public String getShowName() {
|
||||
return showName;
|
||||
}
|
||||
public void setShowName(String showName) {
|
||||
this.showName = showName;
|
||||
}
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
public String getIsMaster() {
|
||||
return isMaster;
|
||||
}
|
||||
public void setIsMaster(String isMaster) {
|
||||
this.isMaster = isMaster;
|
||||
}
|
||||
public String getCustomIconName() {
|
||||
return customIconName;
|
||||
public String getShowName() {
|
||||
return showName;
|
||||
}
|
||||
public void setCustomIconName(String customIconName) {
|
||||
this.customIconName = customIconName;
|
||||
public void setShowName(String showName) {
|
||||
this.showName = showName;
|
||||
}
|
||||
public String getCustomShowName() {
|
||||
return customShowName;
|
||||
}
|
||||
public void setCustomShowName(String customShowName) {
|
||||
this.customShowName = customShowName;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
package com.ifish.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class DeviceUserId implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer userId;
|
||||
private Integer deviceId;
|
||||
|
||||
public DeviceUserId() {}
|
||||
|
||||
public DeviceUserId(Integer userId, Integer deviceId) {
|
||||
this.userId = userId;
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
public Integer getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
public void setDeviceId(Integer deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj instanceof DeviceUserId){
|
||||
DeviceUserId pk=(DeviceUserId)obj;
|
||||
if(this.userId.equals(pk.userId)&&this.deviceId.equals(pk.deviceId)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping package="com.ifish.entity">
|
||||
<class name="DevicePetUser" table="tbl_pet_list" dynamic-insert="true" dynamic-update="true">
|
||||
<meta attribute="sync-DAO">false</meta>
|
||||
<composite-id name="priId" class="com.ifish.entity.PriId">
|
||||
<key-property name="userId" column="user_id" type="java.lang.Integer" />
|
||||
<key-property name="deviceId" column="device_id" type="java.lang.Integer" />
|
||||
</composite-id>
|
||||
<property name="showName" column="device_name" type="string" length="255" />
|
||||
<property name="storeName" column="store_name" type="string" length="255" />
|
||||
<property name="isMaster" column="is_master" type="java.lang.Integer" length="10" />
|
||||
<property name="createTime" column="create_time" type="java.util.Date" />
|
||||
<many-to-one name="user" column="user_id" class="com.ifish.entity.User" update="false" insert="false" lazy="false"/>
|
||||
<many-to-one name="device" column="device_id" class="com.ifish.entity.Device" update="false" insert="false" lazy="false"/>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping package="com.ifish.entity">
|
||||
<class name="DevicePower" table="tbl_device_power" dynamic-insert="true" dynamic-update="true">
|
||||
<meta attribute="sync-DAO">false</meta>
|
||||
<id name="id" type="java.lang.Integer" column="id">
|
||||
<generator class="identity"/>
|
||||
</id>
|
||||
<property name="macAddress" column="mac_address" type="string" length="10"/>
|
||||
<property name="yearS" column="year_s" type="string" length="6"/>
|
||||
<property name="monthS" column="month_s" type="string" length="2"/>
|
||||
<property name="dayPower" column="day_power" type="string" length="5"/>
|
||||
<property name="monthPower" column="month_power" type="string" length="5"/>
|
||||
<property name="dayS" column="day_s" type="string" length="5"/>
|
||||
<property name="ph" column="ph" type="string" length="5"/>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping package="com.ifish.entity">
|
||||
<class name="DevicePowerMonth" table="tbl_device_power_month" dynamic-insert="true" dynamic-update="true">
|
||||
<meta attribute="sync-DAO">false</meta>
|
||||
<id name="id" type="java.lang.Integer" column="id">
|
||||
<generator class="identity"/>
|
||||
</id>
|
||||
<property name="macAddress" column="mac_address" type="string" length="10"/>
|
||||
<property name="yearS" column="year_s" type="string" length="6"/>
|
||||
<property name="monthS" column="month_s" type="string" length="2"/>
|
||||
<property name="monthPower" column="month_power" type="string" length="5"/>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
|
|
@ -3,15 +3,12 @@
|
|||
<hibernate-mapping package="com.ifish.entity">
|
||||
<class name="DeviceUser" table="tbl_device_user" dynamic-insert="true" dynamic-update="true">
|
||||
<meta attribute="sync-DAO">false</meta>
|
||||
<composite-id name="priId" class="com.ifish.entity.DeviceUserId">
|
||||
<cache usage="read-write" region="myCache" />
|
||||
<composite-id name="priId" class="com.ifish.entity.PriId">
|
||||
<key-property name="userId" column="user_id" type="java.lang.Integer" />
|
||||
<key-property name="deviceId" column="device_id" type="java.lang.Integer" />
|
||||
</composite-id>
|
||||
<property name="isMaster" column="is_master" type="string" length="1" />
|
||||
<property name="showName" column="show_name" type="string" length="50" />
|
||||
<property name="customIconName" column="custom_icon_name" type="string" length="100"/>
|
||||
<property name="customShowName" column="custom_show_name" type="string" length="100"/>
|
||||
<property name="createTime" column="create_time" type="timestamp" />
|
||||
<property name="updateTime" column="update_time" type="timestamp" />
|
||||
<property name="isMaster" column="is_master" type="string" length="1" />
|
||||
<property name="showName" column="show_name" type="string" length="50" />
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
|
|
@ -6,10 +6,8 @@ public enum PushTypeEnum {
|
|||
qu_reply("qu_reply","问题反馈"),
|
||||
app_update("app_update","IOS更新推送"),
|
||||
remind_water("remind_water","换水提醒"),
|
||||
offline_push("offline_push","离线通知"),
|
||||
water_warn("water_warn","水位预警"),
|
||||
ph_warn("ph_warn","水流量预警");
|
||||
|
||||
offline_push("offline_push","离线通知");
|
||||
|
||||
private PushTypeEnum(String key,String value){
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class ScheduleJob {
|
|||
*/
|
||||
public void addJob(JobGroup jobGroup){
|
||||
try {
|
||||
// log.info(String.format("添加任务:%s.%s",jobGroup.getJobName(),jobGroup.getTriggerName()));
|
||||
log.info(String.format("添加任务:%s.%s",jobGroup.getJobName(),jobGroup.getTriggerName()));
|
||||
// log.info("添加任务:{}.{}",jobGroup.getJobName(),jobGroup.getTriggerName());
|
||||
//任务
|
||||
JobDetail jobDetail= JobBuilder.newJob(ExecuteJob.class)
|
||||
|
|
@ -63,7 +63,7 @@ public class ScheduleJob {
|
|||
*/
|
||||
public void deleteJob(JobGroup jobGroup){
|
||||
try {
|
||||
// log.info(String.format("移除任务:%s.%s",jobGroup.getJobName(),jobGroup.getTriggerName()));
|
||||
log.info(String.format("移除任务:%s.%s",jobGroup.getJobName(),jobGroup.getTriggerName()));
|
||||
//触发器
|
||||
TriggerKey triggerKey = TriggerKey.triggerKey(jobGroup.getTriggerName(),jobGroup.getTriggerGroup());
|
||||
//停止触发器
|
||||
|
|
|
|||
|
|
@ -6,23 +6,23 @@ import com.ifish.entity.*;
|
|||
import com.ifish.socketNew.model.receive.BackFunctionCodeHeater;
|
||||
import com.ifish.socketNew.model.send.OrderFunctionCode1;
|
||||
|
||||
/**
|
||||
* @ClassName: DeviceService
|
||||
* @Description: TODO
|
||||
/**
|
||||
* @ClassName: DeviceService
|
||||
* @Description: TODO
|
||||
* @author ggw
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface DeviceService {
|
||||
|
||||
|
||||
Device update(Device device);
|
||||
|
||||
|
||||
Device update(OrderFunctionCode1 model);
|
||||
|
||||
DeviceHeater save(BackFunctionCodeHeater model);
|
||||
DeviceHeater update(DeviceHeater deviceHeater);
|
||||
|
||||
void updateWarnOnoff(String macAddress,String onOff);
|
||||
|
||||
|
||||
Device getUniqueByProperty(String property,Object value);
|
||||
|
||||
List<Device> getByProperty(String property,Object value);
|
||||
|
|
@ -30,24 +30,14 @@ public interface DeviceService {
|
|||
List<DeviceHeater> getDeviceHeaterByProperty(String hour,String macAddress,String date);
|
||||
|
||||
DeviceUser getUniqueByProperty(String macAddress);
|
||||
|
||||
|
||||
List<DeviceUser> getListByProperty(Integer deviceId);
|
||||
|
||||
List<DevicePetUser> getPetListByProperty(Integer deviceId);
|
||||
|
||||
|
||||
LoginRecord save(LoginRecord loginRecord);
|
||||
|
||||
|
||||
FactoryList getFactoryListById(String factoryCode);
|
||||
|
||||
|
||||
HardwareType getHardwareTypeById(String typeCode);
|
||||
|
||||
void saveDeviceOffline(DeviceOffline deviceOffline);
|
||||
|
||||
void saveDevicePower(DevicePower devicePower);
|
||||
|
||||
void saveDeviceMonthPower(DevicePowerMonth devicePowerMonth);
|
||||
|
||||
DevicePower getForMac(String macAddress);
|
||||
|
||||
DevicePowerMonth getMonthPowerForMac(String macAddress, String year, String month);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.ifish.service;
|
||||
|
||||
import com.ifish.entity.DeviceUser;
|
||||
import com.ifish.entity.PushList;
|
||||
import com.ifish.entity.User;
|
||||
|
||||
|
|
@ -11,12 +10,7 @@ import com.ifish.entity.User;
|
|||
*
|
||||
*/
|
||||
public interface UserService {
|
||||
User findById(Integer userId);
|
||||
public User findById(Integer userId);
|
||||
|
||||
PushList save(PushList pushList);
|
||||
|
||||
DeviceUser findUserDevice(Integer userId, Integer deviceId);
|
||||
|
||||
void saveDeviceUser(DeviceUser deviceUser);
|
||||
|
||||
public PushList save(PushList pushList);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.ifish.serviceImpl;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
|
@ -23,11 +22,11 @@ import com.ifish.service.DeviceService;
|
|||
import com.ifish.socketNew.model.send.OrderFunctionCode1;
|
||||
import com.ifish.util.ByteUtil;
|
||||
|
||||
/**
|
||||
* @ClassName: DeviceServiceImpl
|
||||
* @Description: TODO
|
||||
/**
|
||||
* @ClassName: DeviceServiceImpl
|
||||
* @Description: TODO
|
||||
* @author ggw
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@Service
|
||||
|
|
@ -35,7 +34,7 @@ import com.ifish.util.ByteUtil;
|
|||
public class DeviceServiceImpl implements DeviceService {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(DeviceServiceImpl.class);
|
||||
|
||||
|
||||
@Autowired
|
||||
private DeviceDao deviceDao;
|
||||
@Autowired
|
||||
|
|
@ -45,23 +44,17 @@ public class DeviceServiceImpl implements DeviceService {
|
|||
@Autowired
|
||||
private DeviceUserDao deviceUserDao;
|
||||
@Autowired
|
||||
private DevicePetUserDao devicePetUserDao;
|
||||
@Autowired
|
||||
private FactoryListDao factoryListDao;
|
||||
@Autowired
|
||||
private HardwareTypeDao hardwareTypeDao;
|
||||
@Autowired
|
||||
private DeviceOfflineDao deviceOfflineDao;
|
||||
@Autowired
|
||||
private DevicePowerDao devicePowerDao;
|
||||
@Autowired
|
||||
private DevicePowerMonthDao devicePowerMonthDao;
|
||||
|
||||
|
||||
@Override
|
||||
public Device update(Device device) {
|
||||
return this.deviceDao.update(device);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Device update(OrderFunctionCode1 model) {
|
||||
//macAddr地址
|
||||
|
|
@ -141,7 +134,7 @@ public class DeviceServiceImpl implements DeviceService {
|
|||
public DeviceUser getUniqueByProperty(String macAddress) {
|
||||
Device device = deviceDao.getUniqueByProperty("macAddress", macAddress);
|
||||
if(device!=null){
|
||||
DeviceUser deviceUser = deviceUserDao.getUniqueByProperty(Restrictions.eq("isMaster", BooleanEnum.YES.getKey()),Restrictions.eq("priId.deviceId", device.getDeviceId()));
|
||||
DeviceUser deviceUser = deviceUserDao.getUniqueByProperty(Restrictions.eq("isMaster", BooleanEnum.YES.getKey()),Restrictions.eq("priId.deviceId", device.getDeviceId()));
|
||||
return deviceUser;
|
||||
}
|
||||
return null;
|
||||
|
|
@ -149,12 +142,7 @@ public class DeviceServiceImpl implements DeviceService {
|
|||
|
||||
@Override
|
||||
public List<DeviceUser> getListByProperty(Integer deviceId) {
|
||||
return deviceUserDao.getListByProperty(Restrictions.eq("priId.deviceId", deviceId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DevicePetUser> getPetListByProperty(Integer deviceId) {
|
||||
return devicePetUserDao.getListByProperty(Restrictions.eq("priId.deviceId", deviceId));
|
||||
return deviceUserDao.getListByProperty(Restrictions.eq("priId.deviceId", deviceId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -212,24 +200,4 @@ public class DeviceServiceImpl implements DeviceService {
|
|||
public void saveDeviceOffline(DeviceOffline deviceOffline) {
|
||||
this.deviceOfflineDao.save(deviceOffline);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveDevicePower(DevicePower devicePower) {
|
||||
this.devicePowerDao.update(devicePower);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveDeviceMonthPower(DevicePowerMonth devicePowerMonth) {
|
||||
this.devicePowerMonthDao.save(devicePowerMonth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevicePower getForMac(String macAddress) {
|
||||
return this.devicePowerDao.getUniqueByProperty("macAddress", macAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevicePowerMonth getMonthPowerForMac(String macAddress, String year, String month) {
|
||||
return this.devicePowerMonthDao.findByDate(macAddress, year, month);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
package com.ifish.serviceImpl;
|
||||
|
||||
import com.ifish.dao.DeviceUserDao;
|
||||
import com.ifish.entity.DeviceUser;
|
||||
import com.ifish.enums.BooleanEnum;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -34,9 +30,6 @@ public class UserServiceImpl implements UserService {
|
|||
@Autowired
|
||||
private PushListDao pushListDao;
|
||||
|
||||
@Autowired
|
||||
private DeviceUserDao deviceUserDao;
|
||||
|
||||
@Override
|
||||
public User findById(Integer userId) {
|
||||
return this.userDao.findById(userId);
|
||||
|
|
@ -47,13 +40,5 @@ public class UserServiceImpl implements UserService {
|
|||
return pushListDao.save(pushList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceUser findUserDevice(Integer userId, Integer deviceId) {
|
||||
return this.deviceUserDao.getUniqueByProperty(Restrictions.eq("priId.userId", userId), Restrictions.eq("priId.deviceId", deviceId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveDeviceUser(DeviceUser deviceUser) {
|
||||
this.deviceUserDao.saveDeviceUser(deviceUser);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ public class MinaServerHandler extends IoHandlerAdapter {
|
|||
jobGroup.setTimestamp(IfishUtil.format(new Date()));
|
||||
//10分钟后推送 update 30分钟
|
||||
// jobGroup.setStartTime(new Date(System.currentTimeMillis() + 600000L * 3));
|
||||
jobGroup.setStartTime(new Date(System.currentTimeMillis() + 600000L));
|
||||
jobGroup.setStartTime(new Date(System.currentTimeMillis() + 60000L));
|
||||
scheduleJob.addJob(jobGroup);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@ package com.ifish.socketNew;
|
|||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.ifish.entity.*;
|
||||
import com.ifish.entity.event.QueueEventBody;
|
||||
import com.ifish.entity.event.QueueEventEntity;
|
||||
|
|
@ -15,7 +12,10 @@ import com.ifish.quartz.JobGroup;
|
|||
import com.ifish.quartz.ScheduleJob;
|
||||
import com.ifish.service.DeviceService;
|
||||
import com.ifish.service.UserService;
|
||||
import com.ifish.socketNew.model.receive.*;
|
||||
import com.ifish.socketNew.model.receive.BackFunctionCode0;
|
||||
import com.ifish.socketNew.model.receive.BackFunctionCode1;
|
||||
import com.ifish.socketNew.model.receive.BackFunctionCode8;
|
||||
import com.ifish.socketNew.model.receive.BackFunctionCodeHeater;
|
||||
import com.ifish.socketNew.model.send.*;
|
||||
import com.ifish.socketNew.util.OrderModel;
|
||||
import com.ifish.util.ByteUtil;
|
||||
|
|
@ -26,15 +26,17 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
import org.springframework.jms.core.MessageCreator;
|
||||
|
||||
import javax.jms.Destination;
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.Message;
|
||||
import javax.jms.Session;
|
||||
import java.util.*;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -62,17 +64,7 @@ public class SomeServer {
|
|||
public static final ConcurrentHashMap<String, String> remoteAddress = new ConcurrentHashMap<String, String>();
|
||||
public static final ConcurrentHashMap<String, IoSession> sessions_cz = new ConcurrentHashMap<String, IoSession>();
|
||||
private ConcurrentHashMap<String, CopyOnWriteArraySet<IoSession>> sessions_sjs = new ConcurrentHashMap<String, CopyOnWriteArraySet<IoSession>>();
|
||||
private volatile Map<String,Integer> heaterPushStatus = new HashMap<>();
|
||||
|
||||
private static LoadingCache<String, Long> limitCaches = CacheBuilder.newBuilder()
|
||||
.maximumSize(10000)
|
||||
.expireAfterWrite(10, TimeUnit.MINUTES)
|
||||
.build(new CacheLoader<String, Long>() {
|
||||
@Override
|
||||
public Long load(String s) {
|
||||
return 0L;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* 过滤收到的数据 服务器收到数据,进行协议类型匹配,如果不匹配,则不执行相应操作。
|
||||
* @param session
|
||||
|
|
@ -114,63 +106,12 @@ public class SomeServer {
|
|||
} else {
|
||||
deviceService.save(heater);
|
||||
}
|
||||
//功能码
|
||||
if (heater.getCheck_code() == 5 || heater.getCheck_code() == 6 || heater.getCheck_code() == 8) {
|
||||
Integer status = heaterPushStatus.get(macAddress);
|
||||
//当前水流量不正常 并且更新过正常水流标记 或者是第一次出现没有水流
|
||||
if (heater.getPh() != 499 && ((status != null && status.intValue() == 2) || status == null)) {
|
||||
//已推送标记
|
||||
heaterPushStatus.put(macAddress, 1);
|
||||
log.info(heater.toString());
|
||||
pushNotifcationByPh(macAddress,PushTypeEnum.ph_warn.getValue(),"没有水流, 请及时查看!");
|
||||
} else {
|
||||
if (heater.getPh() == 499) {
|
||||
heaterPushStatus.put(macAddress, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//设备重新连接上,则移除延时推送的任务
|
||||
JobGroup jobGroup = new JobGroup();
|
||||
jobGroup.setJobName(macAddress);
|
||||
jobGroup.setTriggerName(macAddress);
|
||||
scheduleJob.deleteJob(jobGroup);
|
||||
sendToApp(session,macAddress,heater.getByteMessage());
|
||||
} else if (message instanceof BackBytes45) {
|
||||
BackBytes45 backBytes45 = (BackBytes45) message;
|
||||
String macAddress = ByteUtil.bytesToHexString(backBytes45.getSrc());
|
||||
if (backBytes45.getCheck_code() == 3 ||
|
||||
backBytes45.getCheck_code() == 5 ||
|
||||
backBytes45.getCheck_code() == 6 ||
|
||||
backBytes45.getCheck_code() == 8) {
|
||||
//需要推送预警
|
||||
if (backBytes45.getHumidity() == 2) {
|
||||
log.info("macAddress : " + macAddress + ", 水位预警 : " + backBytes45);
|
||||
pushNotifcationByPh(macAddress,PushTypeEnum.water_warn.getValue(),"水位预警, 请及时查看!");
|
||||
}
|
||||
}
|
||||
sendToApp(session, macAddress, backBytes45.getByteMessage());
|
||||
} else if (message instanceof BackBytes45_4_5f) {
|
||||
BackBytes45_4_5f backBytes45 = (BackBytes45_4_5f) message;
|
||||
String macAddress = ByteUtil.bytesToHexString(backBytes45.getSrc());
|
||||
sendToApp(session, macAddress, backBytes45.getByteMessage());
|
||||
try {
|
||||
if (limitCaches.get(macAddress) == 0L) {
|
||||
//发送获取电量指令
|
||||
String strDest = ByteUtil.bytesToHexString(backBytes45.getDest());
|
||||
OrderFunctionCode18Power orderFunctionCode18Power = new OrderFunctionCode18Power();
|
||||
orderFunctionCode18Power.setType((byte) 1);
|
||||
orderFunctionCode18Power.setCheck_code((byte) 22);
|
||||
orderFunctionCode18Power.setDest(backBytes45.getDest());
|
||||
orderFunctionCode18Power.setSrc(backBytes45.getSrc());
|
||||
orderFunctionCode18Power.setRemote_len((byte) 18);
|
||||
sendToDevice(session,strDest, orderFunctionCode18Power);
|
||||
limitCaches.put(macAddress, 1L);
|
||||
}
|
||||
} catch (ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
//设置设备温度报警
|
||||
else if(message instanceof OrderFunctionCode5) {
|
||||
|
|
@ -196,71 +137,14 @@ public class SomeServer {
|
|||
//推送类型
|
||||
Integer warnType = receive.getWarn_type() & 0xff;
|
||||
if(warnType==0){
|
||||
log.info("mac : " + strSrc + ", 低温预警 : " + receive);
|
||||
pushNotifcation(strSrc,PushTypeEnum.wendu_warn.getValue(),"温度达到"+(float)receive.getWendu()/10f+"℃,已低于"+(float)receive.getWarn_wendu()/10f+"℃,请及时查看!");
|
||||
}
|
||||
else if(warnType==1){
|
||||
log.info("mac : " + strSrc + ", 高温预警 : " + receive);
|
||||
pushNotifcation(strSrc,PushTypeEnum.wendu_warn.getValue(),"温度达到"+(float)receive.getWendu()/10f+"℃,已高于"+(float)receive.getWarn_wendu()/10f+"℃,请及时查看!");
|
||||
}
|
||||
else{
|
||||
log.error("error warn_type:{},macAddress:{}",warnType,strSrc);
|
||||
}
|
||||
} //设备登录服务器
|
||||
else if(message instanceof OrderFunctionCode1_1) {
|
||||
OrderFunctionCode1_1 receive = (OrderFunctionCode1_1) message;
|
||||
byte[] srcBytes = receive.getSrc();
|
||||
byte[] destBytes = receive.getDest();
|
||||
String strSrc = ByteUtil.bytesToHexString(srcBytes);
|
||||
StringBuilder userId = new StringBuilder();
|
||||
for (byte b : receive.getUserId()) {
|
||||
char character = (char) b;
|
||||
userId.append(character);
|
||||
}
|
||||
//服务器回复设备登录请求
|
||||
BackFunctionCode1 model = OrderModel.BackFunctionCode1(destBytes, srcBytes);
|
||||
//直接往本次session写回去
|
||||
session.write(model);
|
||||
//保存连接
|
||||
sessions_cz.put(strSrc, session);
|
||||
remoteAddress.put(session.getRemoteAddress().toString(), strSrc);
|
||||
//设备重新连接上,则移除延时推送的任务
|
||||
JobGroup jobGroup = new JobGroup();
|
||||
jobGroup.setJobName(strSrc);
|
||||
jobGroup.setTriggerName(strSrc);
|
||||
scheduleJob.deleteJob(jobGroup);
|
||||
try {
|
||||
log.info("设备登录服务器 ********** mac : " + strSrc + " 用户ID : " + userId);
|
||||
if (limitCaches.get(strSrc) == 0L) {
|
||||
//更新设备信息
|
||||
deviceService.update(receive);
|
||||
limitCaches.put(strSrc, 1L);
|
||||
}
|
||||
if (!"".contentEquals(userId) && userId.length() > 0) {
|
||||
Device device = deviceService.getUniqueByProperty("macAddress", strSrc);
|
||||
if (device != null) {
|
||||
int user = Integer.parseInt(userId.toString());
|
||||
DeviceUser userDevice = userService.findUserDevice(user, device.getDeviceId());
|
||||
if (userDevice != null) {
|
||||
DeviceUser deviceUser = null;
|
||||
//新增关联关系
|
||||
DeviceUserId priId = new DeviceUserId();
|
||||
if (device.getHardwareType() != null && device.getHardwareType().equals("3a")) {
|
||||
deviceUser = new DeviceUser(priId, BooleanEnum.YES.getKey(), "加热器"+(int)(Math.random()*9000+1000));
|
||||
} else {
|
||||
deviceUser = new DeviceUser(priId, BooleanEnum.YES.getKey(), "鱼缸"+(int)(Math.random()*9000+1000));
|
||||
}
|
||||
//关联设备
|
||||
userService.saveDeviceUser(deviceUser);
|
||||
log.info("设备绑定成功 *********** mac : " + strSrc + " 用户ID : " + userId + " 设备名称 : " + deviceUser.getShowName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("save device login error:macAddress:{},error msg:{}",strSrc,e.toString());
|
||||
}
|
||||
}
|
||||
//设备登录服务器
|
||||
else if(message instanceof OrderFunctionCode1) {
|
||||
|
|
@ -281,12 +165,8 @@ public class SomeServer {
|
|||
jobGroup.setTriggerName(strSrc);
|
||||
scheduleJob.deleteJob(jobGroup);
|
||||
try {
|
||||
if (limitCaches.get(strSrc) == 0L) {
|
||||
//更新设备信息
|
||||
deviceService.update(receive);
|
||||
limitCaches.put(strSrc, 1L);
|
||||
}
|
||||
|
||||
//更新设备信息
|
||||
deviceService.update(receive);
|
||||
// if(device==null){
|
||||
// String HexDump = ByteUtil.toHex(receive.getType())+ByteUtil.toHex(receive.getCheck_code())+ByteUtil.bytesToHexString(receive.getSrc())+ByteUtil.bytesToHexString(destBytes)+ByteUtil.toHex(receive.getRemote_len())+ByteUtil.toHex(receive.getVendor())+ByteUtil.toHex(receive.getHardware_type())+ByteUtil.toHex(receive.getVersion())+ByteUtil.bytesToHexString(receive.getLogin_ip())+ByteUtil.bytesToHexString(receive.getCrc16_code());
|
||||
// log.error("HexDump:{}",HexDump);
|
||||
|
|
@ -294,10 +174,10 @@ public class SomeServer {
|
|||
// }
|
||||
// else{
|
||||
//记录登录时间
|
||||
// LoginRecord loginRecord = new LoginRecord();
|
||||
// loginRecord.setMacAddress(strSrc);
|
||||
// loginRecord.setLoginTime(new Date());
|
||||
// deviceService.save(loginRecord);
|
||||
LoginRecord loginRecord = new LoginRecord();
|
||||
loginRecord.setMacAddress(strSrc);
|
||||
loginRecord.setLoginTime(new Date());
|
||||
deviceService.save(loginRecord);
|
||||
// }
|
||||
} catch (Exception e) {
|
||||
log.error("save device login error:macAddress:{},error msg:{}",strSrc,e.toString());
|
||||
|
|
@ -430,7 +310,6 @@ public class SomeServer {
|
|||
*/
|
||||
public void sendToDevice(IoSession session,String strDest,Object message) {
|
||||
IoSession cz_session = sessions_cz.get(strDest);
|
||||
log.info("sendToDevice : {}", message);
|
||||
if(cz_session!=null && cz_session.getRemoteAddress()!=null){
|
||||
cz_session.write(message);
|
||||
}
|
||||
|
|
@ -441,33 +320,12 @@ public class SomeServer {
|
|||
session.write(model);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 智能加热棒 水流量提醒
|
||||
* 温度预警推送
|
||||
* @param strSrc
|
||||
* @param title
|
||||
* @param contont
|
||||
*/
|
||||
public void pushNotifcationByPh(String strSrc,String title,String contont) {
|
||||
Device device = deviceService.getUniqueByProperty("macAddress", strSrc);
|
||||
try {
|
||||
if(device!=null) {
|
||||
Integer deviceId = device.getDeviceId();
|
||||
//绑定设备的用户
|
||||
List<DeviceUser> list = deviceService.getListByProperty(device.getDeviceId());
|
||||
for (DeviceUser deviceUser : list) {
|
||||
Integer userId = deviceUser.getPriId().getUserId();
|
||||
String showName = deviceUser.getShowName();
|
||||
String msg = "【" + title + "】你的水族箱“" + showName + "”" + contont;
|
||||
setPushMsg(title, device, deviceId, userId, showName, msg, PushTypeEnum.ph_warn);
|
||||
}
|
||||
}
|
||||
}catch (Exception e) {
|
||||
log.error(e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 温度预警推送
|
||||
* @param strSrc
|
||||
|
|
@ -482,25 +340,38 @@ public class SomeServer {
|
|||
//是否开启预警
|
||||
String onOff = device.getOnOff();
|
||||
if(onOff!=null && onOff.equals(BooleanEnum.YES.getKey())){
|
||||
//宠物笼设备
|
||||
if (device.getHardwareType().equals("3f")) {
|
||||
List<DevicePetUser> petUserList = deviceService.getPetListByProperty(deviceId);
|
||||
for (DevicePetUser deviceUser : petUserList) {
|
||||
Integer userId = deviceUser.getPriId().getUserId();
|
||||
String showName = deviceUser.getShowName();
|
||||
String timestamp = IfishUtil.format(new Date());
|
||||
String msg = "【"+title+"】你的宠物笼“"+showName+"”在"+timestamp+contont;
|
||||
setPushMsg(title, device, deviceId, userId, showName, msg, PushTypeEnum.wendu_warn);
|
||||
}
|
||||
} else {
|
||||
//绑定设备的用户
|
||||
List<DeviceUser> list = deviceService.getListByProperty(device.getDeviceId());
|
||||
for (DeviceUser deviceUser : list) {
|
||||
Integer userId = deviceUser.getPriId().getUserId();
|
||||
String showName = deviceUser.getShowName();
|
||||
String timestamp = IfishUtil.format(new Date());
|
||||
String msg = "【"+title+"】你的水族箱“"+showName+"”在"+timestamp+contont;
|
||||
setPushMsg(title, device, deviceId, userId, showName, msg, PushTypeEnum.wendu_warn);
|
||||
//绑定设备的用户
|
||||
List<DeviceUser> list = deviceService.getListByProperty(device.getDeviceId());
|
||||
for (DeviceUser deviceUser : list) {
|
||||
Integer userId = deviceUser.getPriId().getUserId();
|
||||
String showName = deviceUser.getShowName();
|
||||
String timestamp = IfishUtil.format(new Date());
|
||||
String msg = "【"+title+"】你的水族箱“"+showName+"”在"+timestamp+contont;
|
||||
User user = userService.findById(userId);
|
||||
if(user!=null){
|
||||
//推送记录
|
||||
PushList pushList = new PushList();
|
||||
//记录推送
|
||||
pushList.setUserId(userId);
|
||||
pushList.setDeviceId(deviceId);
|
||||
pushList.setPhoneType("ALL");
|
||||
pushList.setShowName(showName);
|
||||
pushList.setPushType(PushTypeEnum.wendu_warn.getKey());
|
||||
pushList.setPushTitle(title);
|
||||
pushList.setPushContext(msg);
|
||||
pushList.setNumber1(device.getNumber1());
|
||||
pushList.setNumber2(device.getNumber2());
|
||||
pushList.setNumber3(device.getNumber3());
|
||||
pushList.setNumber4(device.getNumber4());
|
||||
pushList.setNumber5(device.getNumber5());
|
||||
JSONObject data = JSON.parseObject(JSON.toJSONString(pushList));
|
||||
QueueEventEntity eventEntity = new QueueEventEntity();
|
||||
eventEntity.setEventName("com.ifish7.mq.queues.event.PushNotifcationEvent");
|
||||
eventEntity.setEventProcess("deviceNotifcationPlus");
|
||||
QueueEventBody eventBody = new QueueEventBody("com.ifish7.mq.business.user.entity.TblPushList",data);
|
||||
eventEntity.setEventBody(eventBody);
|
||||
//推送至消息推送队列
|
||||
sendPushQueueMessage(JSONObject.toJSONString(eventEntity));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -510,35 +381,6 @@ public class SomeServer {
|
|||
}
|
||||
}
|
||||
|
||||
private void setPushMsg(String title, Device device, Integer deviceId, Integer userId, String showName, String msg, PushTypeEnum wendu_warn) throws JMSException {
|
||||
User user = userService.findById(userId);
|
||||
if (user != null) {
|
||||
//推送记录
|
||||
PushList pushList = new PushList();
|
||||
//记录推送
|
||||
pushList.setUserId(userId);
|
||||
pushList.setDeviceId(deviceId);
|
||||
pushList.setPhoneType("ALL");
|
||||
pushList.setShowName(showName);
|
||||
pushList.setPushType(wendu_warn.getKey());
|
||||
pushList.setPushTitle(title);
|
||||
pushList.setPushContext(msg);
|
||||
pushList.setNumber1(device.getNumber1());
|
||||
pushList.setNumber2(device.getNumber2());
|
||||
pushList.setNumber3(device.getNumber3());
|
||||
pushList.setNumber4(device.getNumber4());
|
||||
pushList.setNumber5(device.getNumber5());
|
||||
JSONObject data = JSON.parseObject(JSON.toJSONString(pushList));
|
||||
QueueEventEntity eventEntity = new QueueEventEntity();
|
||||
eventEntity.setEventName("com.ifish7.mq.queues.event.PushNotifcationEvent");
|
||||
eventEntity.setEventProcess("deviceNotifcationPlus");
|
||||
QueueEventBody eventBody = new QueueEventBody("com.ifish7.mq.business.user.entity.TblPushList", data);
|
||||
eventEntity.setEventBody(eventBody);
|
||||
//推送至消息推送队列
|
||||
sendPushQueueMessage(JSONObject.toJSONString(eventEntity));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 推送Push消息队列
|
||||
|
|
|
|||
|
|
@ -1,30 +1,23 @@
|
|||
package com.ifish.socketNew.codeFactory;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import com.ifish.service.DeviceService;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import org.apache.mina.filter.codec.ProtocolCodecFactory;
|
||||
import org.apache.mina.filter.codec.ProtocolDecoder;
|
||||
import org.apache.mina.filter.codec.ProtocolEncoder;
|
||||
|
||||
public class ServerCodecFactory implements ProtocolCodecFactory{
|
||||
|
||||
|
||||
private static final Charset charset = Charset.forName("UTF-8");
|
||||
|
||||
private DeviceService deviceService;
|
||||
|
||||
|
||||
@Override
|
||||
public ProtocolDecoder getDecoder(IoSession session) throws Exception {
|
||||
return new ServerDecode(charset, deviceService);
|
||||
return new ServerDecode(charset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtocolEncoder getEncoder(IoSession session) throws Exception {
|
||||
return new ServerEncode(charset);
|
||||
}
|
||||
|
||||
public void setDeviceService(DeviceService deviceService) {
|
||||
this.deviceService = deviceService;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,33 +1,26 @@
|
|||
package com.ifish.socketNew.codeFactory;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.ifish.entity.Device;
|
||||
import com.ifish.entity.DevicePower;
|
||||
import com.ifish.entity.DevicePowerMonth;
|
||||
import com.ifish.service.DeviceService;
|
||||
import com.ifish.socketNew.model.receive.*;
|
||||
import com.ifish.socketNew.model.send.*;
|
||||
import com.ifish.util.ByteUtil;
|
||||
import org.apache.http.client.utils.DateUtils;
|
||||
import com.ifish.socketNew.model.receive.BackFunctionCodeHeater;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.session.AttributeKey;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import org.apache.mina.filter.codec.ProtocolDecoder;
|
||||
import org.apache.mina.filter.codec.ProtocolDecoderOutput;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import com.ifish.socketNew.model.send.OrderFunctionCode0;
|
||||
import com.ifish.socketNew.model.send.OrderFunctionCode1;
|
||||
import com.ifish.socketNew.model.send.OrderFunctionCode16;
|
||||
import com.ifish.socketNew.model.send.OrderFunctionCode17;
|
||||
import com.ifish.socketNew.model.send.OrderFunctionCode5;
|
||||
import com.ifish.socketNew.model.send.OrderFunctionCode9;
|
||||
|
||||
|
||||
/**
|
||||
* 解码
|
||||
*
|
||||
*
|
||||
* @author
|
||||
*/
|
||||
|
||||
|
|
@ -36,26 +29,14 @@ public class ServerDecode implements ProtocolDecoder {
|
|||
private final AttributeKey CONTEXT = new AttributeKey(getClass(), "context");
|
||||
private final Charset charset;
|
||||
private static Logger log = Logger.getLogger(ServerDecode.class);
|
||||
private static LoadingCache<String, Long> limitCaches = CacheBuilder.newBuilder()
|
||||
.maximumSize(10000)
|
||||
.expireAfterWrite(10, TimeUnit.MINUTES)
|
||||
.build(new CacheLoader<String, Long>() {
|
||||
@Override
|
||||
public Long load(String s) {
|
||||
return 0L;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
public ServerDecode() {
|
||||
this(Charset.defaultCharset());
|
||||
}
|
||||
|
||||
public ServerDecode(Charset charset) {
|
||||
this.charset = charset;
|
||||
}
|
||||
private DeviceService deviceService;
|
||||
|
||||
public ServerDecode(Charset charset, DeviceService deviceService) {
|
||||
this.charset = charset;
|
||||
this.deviceService = deviceService;
|
||||
}
|
||||
|
||||
private Context getContext(IoSession session) {
|
||||
Context ctx = (Context) session.getAttribute(CONTEXT);
|
||||
|
|
@ -80,7 +61,7 @@ public class ServerDecode implements ProtocolDecoder {
|
|||
//验证
|
||||
getValid(session, buf, out);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 验证协议
|
||||
* @param session
|
||||
|
|
@ -105,7 +86,7 @@ public class ServerDecode implements ProtocolDecoder {
|
|||
buf.position(0);
|
||||
buf.clear();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解码成对象
|
||||
* @param buf
|
||||
|
|
@ -122,16 +103,9 @@ public class ServerDecode implements ProtocolDecoder {
|
|||
//boolean bln = CRC16.calcCrc16(ByteUtil.hexStringToBytes(hexDump));
|
||||
switch (length) {
|
||||
case 31: {
|
||||
log.info("length:[" + length + "];limit:[" + buf.limit() + "],HexDump:[" + buf.getHexDump() + "]");
|
||||
functionBackHeater(bytes,buf, out);
|
||||
break;
|
||||
}
|
||||
case 45: {
|
||||
log.info("length:[" + length + "];limit:[" + buf.limit() + "],HexDump:[" + buf.getHexDump() + "]");
|
||||
functionBack2f(bytes, buf, out);
|
||||
break;
|
||||
}
|
||||
//长度为22
|
||||
}//长度为22
|
||||
case 22:{
|
||||
//设置报警温度
|
||||
if(check_code==5){
|
||||
|
|
@ -139,7 +113,6 @@ public class ServerDecode implements ProtocolDecoder {
|
|||
}
|
||||
//设备报警
|
||||
else if(check_code==9){
|
||||
log.info("length:[" + length + "];limit:[" + buf.limit() + "],HexDump:[" + buf.getHexDump() + "]");
|
||||
functionCode9(buf, out);
|
||||
}
|
||||
//模块版本指令
|
||||
|
|
@ -152,7 +125,7 @@ public class ServerDecode implements ProtocolDecoder {
|
|||
break;
|
||||
}
|
||||
//长度为24,设备发登录请求
|
||||
case 24: {
|
||||
case 24:{
|
||||
if(check_code==1){
|
||||
functionCode1(buf, out);
|
||||
} else {
|
||||
|
|
@ -160,14 +133,6 @@ public class ServerDecode implements ProtocolDecoder {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 34: {
|
||||
if(check_code==1){
|
||||
functionCode1_34(buf, out);
|
||||
} else {
|
||||
out.write(bytes);
|
||||
}
|
||||
break;
|
||||
}
|
||||
//长度为25,手机发登录请求
|
||||
case 25:{
|
||||
if(check_code==0){
|
||||
|
|
@ -187,84 +152,11 @@ public class ServerDecode implements ProtocolDecoder {
|
|||
break;
|
||||
}
|
||||
default:{
|
||||
if (check_code == 22) {
|
||||
functionPower(buf, out);
|
||||
}
|
||||
out.write(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void functionPower(IoBuffer buf, ProtocolDecoderOutput out) {
|
||||
log.info("limit:[" + buf.limit() + "],HexDump:[" + buf.getHexDump() + "]");
|
||||
BackBytesPower model = new BackBytesPower();
|
||||
//15字节数据包头
|
||||
model.setType(buf.get());
|
||||
model.setCheck_code(buf.get());
|
||||
byte[] src = model.getSrc();
|
||||
for (int i = 0; i < src.length; i++) {
|
||||
src[i] = buf.get();
|
||||
}
|
||||
model.setSrc(src);
|
||||
byte[] dest = model.getDest();
|
||||
for (int i = 0; i < dest.length; i++) {
|
||||
dest[i] = buf.get();
|
||||
}
|
||||
model.setNum(buf.get());
|
||||
model.setDef(buf.get());
|
||||
model.setDayPower(buf.get());
|
||||
model.setMonthPower(buf.get());
|
||||
model.setPh(buf.get());
|
||||
String macAddress = ByteUtil.bytesToHexString(src);
|
||||
log.info("functionPower : " + macAddress + " 电量更新");
|
||||
Device device = deviceService.getUniqueByProperty("macAddress", macAddress);
|
||||
if (device == null) {
|
||||
return;
|
||||
}
|
||||
if ("4f".equals(device.getHardwareType()) || "5f".equals(device.getHardwareType())) {
|
||||
try {
|
||||
if (limitCaches.get(macAddress) == 0L) {
|
||||
DevicePower devicePower1 = deviceService.getForMac(macAddress);
|
||||
if (devicePower1 != null) {
|
||||
DevicePower devicePower = new DevicePower();
|
||||
devicePower.setMacAddress(macAddress);
|
||||
devicePower.setYearS(DateUtils.formatDate(new Date(), "yyyy"));
|
||||
devicePower.setMonthS(DateUtils.formatDate(new Date(), "MM"));
|
||||
devicePower.setDayS(DateUtils.formatDate(new Date(), "dd"));
|
||||
devicePower.setMonthPower(String.valueOf(model.getMonthPower()));
|
||||
devicePower.setDayPower(String.valueOf(model.getDayPower()));
|
||||
devicePower.setPh(String.valueOf(model.getPh()));
|
||||
deviceService.saveDevicePower(devicePower);
|
||||
} else {
|
||||
devicePower1.setYearS(DateUtils.formatDate(new Date(), "yyyy"));
|
||||
devicePower1.setMonthS(DateUtils.formatDate(new Date(), "MM"));
|
||||
devicePower1.setDayS(DateUtils.formatDate(new Date(), "dd"));
|
||||
devicePower1.setMonthPower(String.valueOf(model.getMonthPower()));
|
||||
devicePower1.setDayPower(String.valueOf(model.getDayPower()));
|
||||
devicePower1.setPh(String.valueOf(model.getPh()));
|
||||
deviceService.saveDevicePower(devicePower1);
|
||||
}
|
||||
DevicePowerMonth monthPowerForMac = deviceService.getMonthPowerForMac(macAddress, DateUtils.formatDate(new Date(), "yyyy"), DateUtils.formatDate(new Date(), "MM"));
|
||||
if (monthPowerForMac == null) {
|
||||
DevicePowerMonth devicePowerMonth = new DevicePowerMonth();
|
||||
devicePowerMonth.setMacAddress(macAddress);
|
||||
devicePowerMonth.setMonthPower(String.valueOf(model.getMonthPower()));
|
||||
devicePowerMonth.setYearS(DateUtils.formatDate(new Date(), "yyyy"));
|
||||
devicePowerMonth.setMonthS(DateUtils.formatDate(new Date(), "MM"));
|
||||
deviceService.saveDeviceMonthPower(devicePowerMonth);
|
||||
} else {
|
||||
monthPowerForMac.setMonthPower(String.valueOf(model.getMonthPower()));
|
||||
deviceService.saveDeviceMonthPower(monthPowerForMac);
|
||||
}
|
||||
|
||||
limitCaches.put(macAddress, 1L);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备登陆服务器
|
||||
* @param buf
|
||||
|
|
@ -302,49 +194,6 @@ public class ServerDecode implements ProtocolDecoder {
|
|||
out.write(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备登陆服务器
|
||||
* @param buf
|
||||
* @param out
|
||||
*/
|
||||
private void functionCode1_34(IoBuffer buf, ProtocolDecoderOutput out) {
|
||||
OrderFunctionCode1_1 model = new OrderFunctionCode1_1();
|
||||
log.info("login bytes : " + buf.getHexDump());
|
||||
//15字节数据包头
|
||||
model.setType(buf.get());
|
||||
model.setCheck_code(buf.get());
|
||||
byte[] src = model.getSrc();
|
||||
for (int i = 0; i < src.length; i++) {
|
||||
src[i] = buf.get();
|
||||
}
|
||||
model.setSrc(src);
|
||||
byte[] dest = model.getDest();
|
||||
for (int i = 0; i < dest.length; i++) {
|
||||
dest[i] = buf.get();
|
||||
}
|
||||
model.setDest(dest);
|
||||
model.setRemote_len(buf.get());
|
||||
//登陆信息
|
||||
model.setVendor(buf.get());
|
||||
model.setHardware_type(buf.get());
|
||||
model.setVersion(buf.get());
|
||||
byte[] login_ip = model.getLogin_ip();
|
||||
for (int i = 0; i < login_ip.length; i++) {
|
||||
login_ip[i] = buf.get();
|
||||
}
|
||||
model.setLogin_ip(login_ip);
|
||||
byte[] userId = model.getUserId();
|
||||
for (int i = 0; i < userId.length; i++) {
|
||||
userId[i] = buf.get();
|
||||
}
|
||||
model.setUserId(userId);
|
||||
byte[] crc16_code = model.getCrc16_code();
|
||||
for (int i = 0; i < crc16_code.length; i++) {
|
||||
crc16_code[i] = buf.get();
|
||||
}
|
||||
out.write(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* APP登陆服务器
|
||||
* @param buf
|
||||
|
|
@ -526,6 +375,8 @@ public class ServerDecode implements ProtocolDecoder {
|
|||
BackFunctionCodeHeater model = new BackFunctionCodeHeater();
|
||||
model.setByteMessage(bytes);
|
||||
|
||||
buf.getHexDump();
|
||||
|
||||
//15字节头
|
||||
model.setType(buf.get());
|
||||
model.setCheck_code(buf.get());
|
||||
|
|
@ -540,7 +391,9 @@ public class ServerDecode implements ProtocolDecoder {
|
|||
}
|
||||
model.setDest(dest);
|
||||
model.setRemote_len(buf.get());
|
||||
model.setMainSwitch(buf.getShort());
|
||||
|
||||
model.setMainNumber(buf.get());
|
||||
model.setMainSwitch(buf.get());
|
||||
model.setControlState(buf.get());
|
||||
model.setWaterTemperature(buf.getShort());
|
||||
model.setHeatingTemperature(buf.getShort());
|
||||
|
|
@ -554,93 +407,6 @@ public class ServerDecode implements ProtocolDecoder {
|
|||
}
|
||||
out.write(model);
|
||||
}
|
||||
private void functionBack2f(byte[] bytes, IoBuffer buf, ProtocolDecoderOutput out){
|
||||
BackBytes45 model = new BackBytes45();
|
||||
model.setByteMessage(bytes);
|
||||
//15字节头
|
||||
model.setType(buf.get());
|
||||
model.setCheck_code(buf.get());
|
||||
byte[] src = model.getSrc();
|
||||
for (int i = 0; i < src.length; i++) {
|
||||
src[i] = buf.get();
|
||||
}
|
||||
model.setSrc(src);
|
||||
byte[] dest = model.getDest();
|
||||
for (int i = 0; i < dest.length; i++) {
|
||||
dest[i] = buf.get();
|
||||
}
|
||||
String macAddress = ByteUtil.bytesToHexString(src);
|
||||
Device device = deviceService.getUniqueByProperty("macAddress", macAddress);
|
||||
model.setDest(dest);
|
||||
model.setRemote_len(buf.get());
|
||||
model.setNumber1(buf.get());
|
||||
model.setNumber2(buf.get());
|
||||
model.setNumber3(buf.get());
|
||||
model.setNumber4(buf.get());
|
||||
model.setNumber5(buf.get());
|
||||
model.setNumber6(buf.get());
|
||||
model.setNumber7(buf.get());
|
||||
model.setOnoff1(buf.get());
|
||||
model.setOnoff2(buf.get());
|
||||
model.setOnoff3(buf.get());
|
||||
model.setOnoff4(buf.get());
|
||||
model.setOnoff5(buf.get());
|
||||
model.setOnoff6(buf.get());
|
||||
model.setOnoff7(buf.get());
|
||||
if ("4f".equals(device.getHardwareType()) || "5f".equals(device.getHardwareType())) {
|
||||
BackBytes45_4_5f model1 = new BackBytes45_4_5f();
|
||||
model1.setByteMessage(bytes);
|
||||
model1.setType(model.getType());
|
||||
model1.setCheck_code(model.getCheck_code());
|
||||
model1.setSrc(src);
|
||||
model1.setDest(model.getDest());
|
||||
model1.setRemote_len(model.getRemote_len());
|
||||
model1.setNumber1(model.getNumber1());
|
||||
model1.setNumber2(model.getNumber2());
|
||||
model1.setNumber3(model.getNumber3());
|
||||
model1.setNumber4(model.getNumber4());
|
||||
model1.setNumber5(model.getNumber5());
|
||||
model1.setNumber6(model.getNumber6());
|
||||
model1.setNumber7(model.getNumber7());
|
||||
model1.setOnoff1(model.getOnoff1());
|
||||
model1.setOnoff2(model.getOnoff2());
|
||||
model1.setOnoff3(model.getOnoff3());
|
||||
model1.setOnoff4(model.getOnoff4());
|
||||
model1.setOnoff5(model.getOnoff5());
|
||||
model1.setOnoff6(model.getOnoff6());
|
||||
model1.setOnoff7(model.getOnoff7());
|
||||
model1.setHeatStatus(buf.get());
|
||||
model1.setWendu(buf.getShort());
|
||||
model1.setHeatWendu(buf.getShort());
|
||||
model1.setSarkLamp(buf.get());
|
||||
model1.setWy_off(buf.get());
|
||||
model1.setPh(buf.getShort());
|
||||
model1.setWarn_onoff(buf.get());
|
||||
model1.setLow_wendu(buf.getShort());
|
||||
model1.setHigh_wendu(buf.getShort());
|
||||
byte[] crc16_code = model.getCrc16_code();
|
||||
for (int i = 0; i < crc16_code.length; i++) {
|
||||
crc16_code[i] = buf.get();
|
||||
}
|
||||
out.write(model1);
|
||||
} else {
|
||||
model.setHeatStatus(buf.get());
|
||||
model.setWendu(buf.getShort());
|
||||
model.setHeatWendu(buf.getShort());
|
||||
model.setSarkLamp(buf.get());
|
||||
model.setDianliang(buf.getShort());
|
||||
model.setWarn_onoff(buf.get());
|
||||
model.setLow_wendu(buf.getShort());
|
||||
model.setHigh_wendu(buf.getShort());
|
||||
model.setHumidity(buf.get());
|
||||
byte[] crc16_code = model.getCrc16_code();
|
||||
for (int i = 0; i < crc16_code.length; i++) {
|
||||
crc16_code[i] = buf.get();
|
||||
}
|
||||
out.write(model);
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void dispose(IoSession session) throws Exception {
|
||||
Context ctx = (Context) session.getAttribute(CONTEXT);
|
||||
|
|
|
|||
|
|
@ -1,285 +0,0 @@
|
|||
package com.ifish.socketNew.model.receive;
|
||||
|
||||
import com.ifish.socketNew.model.HeadModel;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 查询反馈信息45字节(15字节协议头+42字节结果)
|
||||
* @author guogw
|
||||
*
|
||||
*/
|
||||
public class BackBytes45 extends HeadModel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2740442296642889777L;
|
||||
/*********灯和开关(4字节)**********/
|
||||
//气泵
|
||||
private byte number1;
|
||||
//灯1
|
||||
private byte number2;
|
||||
//灯2
|
||||
private byte number3;
|
||||
//水泵
|
||||
private byte number4;
|
||||
//UV
|
||||
private byte number5;
|
||||
//造浪
|
||||
private byte number6;
|
||||
//加热制冷
|
||||
private byte number7;
|
||||
//气泵开关
|
||||
private byte onoff1;
|
||||
//灯1开关
|
||||
private byte onoff2;
|
||||
//灯2开关
|
||||
private byte onoff3;
|
||||
//水泵开关
|
||||
private byte onoff4;
|
||||
//UV开关
|
||||
private byte onoff5;
|
||||
//造浪开关
|
||||
private byte onoff6;
|
||||
//造浪开关
|
||||
private byte onoff7;
|
||||
//加热状态
|
||||
private byte heatStatus;
|
||||
//温度
|
||||
private short wendu;
|
||||
//加热温度
|
||||
private short heatWendu;
|
||||
//护理灯
|
||||
private byte sarkLamp;
|
||||
//电量
|
||||
private short dianliang;
|
||||
//报警开关,0关,1开
|
||||
private byte warn_onoff;
|
||||
//最低报警温度
|
||||
private short low_wendu;
|
||||
//最高报警温度
|
||||
private short high_wendu;
|
||||
//湿度(水位报警)。0关,1开(默认为0)
|
||||
private byte humidity;
|
||||
|
||||
private byte[] byteMessage;
|
||||
|
||||
public byte getNumber1() {
|
||||
return number1;
|
||||
}
|
||||
|
||||
public void setNumber1(byte number1) {
|
||||
this.number1 = number1;
|
||||
}
|
||||
|
||||
public byte getNumber2() {
|
||||
return number2;
|
||||
}
|
||||
|
||||
public void setNumber2(byte number2) {
|
||||
this.number2 = number2;
|
||||
}
|
||||
|
||||
public byte getNumber3() {
|
||||
return number3;
|
||||
}
|
||||
|
||||
public void setNumber3(byte number3) {
|
||||
this.number3 = number3;
|
||||
}
|
||||
|
||||
public byte getNumber4() {
|
||||
return number4;
|
||||
}
|
||||
|
||||
public void setNumber4(byte number4) {
|
||||
this.number4 = number4;
|
||||
}
|
||||
|
||||
public byte getNumber5() {
|
||||
return number5;
|
||||
}
|
||||
|
||||
public void setNumber5(byte number5) {
|
||||
this.number5 = number5;
|
||||
}
|
||||
|
||||
public byte getNumber6() {
|
||||
return number6;
|
||||
}
|
||||
|
||||
public void setNumber6(byte number6) {
|
||||
this.number6 = number6;
|
||||
}
|
||||
|
||||
public byte getNumber7() {
|
||||
return number7;
|
||||
}
|
||||
|
||||
public void setNumber7(byte number7) {
|
||||
this.number7 = number7;
|
||||
}
|
||||
|
||||
public byte getOnoff1() {
|
||||
return onoff1;
|
||||
}
|
||||
|
||||
public void setOnoff1(byte onoff1) {
|
||||
this.onoff1 = onoff1;
|
||||
}
|
||||
|
||||
public byte getOnoff2() {
|
||||
return onoff2;
|
||||
}
|
||||
|
||||
public void setOnoff2(byte onoff2) {
|
||||
this.onoff2 = onoff2;
|
||||
}
|
||||
|
||||
public byte getOnoff3() {
|
||||
return onoff3;
|
||||
}
|
||||
|
||||
public void setOnoff3(byte onoff3) {
|
||||
this.onoff3 = onoff3;
|
||||
}
|
||||
|
||||
public byte getOnoff4() {
|
||||
return onoff4;
|
||||
}
|
||||
|
||||
public void setOnoff4(byte onoff4) {
|
||||
this.onoff4 = onoff4;
|
||||
}
|
||||
|
||||
public byte getOnoff5() {
|
||||
return onoff5;
|
||||
}
|
||||
|
||||
public void setOnoff5(byte onoff5) {
|
||||
this.onoff5 = onoff5;
|
||||
}
|
||||
|
||||
public byte getOnoff6() {
|
||||
return onoff6;
|
||||
}
|
||||
|
||||
public void setOnoff6(byte onoff6) {
|
||||
this.onoff6 = onoff6;
|
||||
}
|
||||
|
||||
public byte getOnoff7() {
|
||||
return onoff7;
|
||||
}
|
||||
|
||||
public void setOnoff7(byte onoff7) {
|
||||
this.onoff7 = onoff7;
|
||||
}
|
||||
|
||||
public byte getHeatStatus() {
|
||||
return heatStatus;
|
||||
}
|
||||
|
||||
public void setHeatStatus(byte heatStatus) {
|
||||
this.heatStatus = heatStatus;
|
||||
}
|
||||
|
||||
public short getWendu() {
|
||||
return wendu;
|
||||
}
|
||||
|
||||
public void setWendu(short wendu) {
|
||||
this.wendu = wendu;
|
||||
}
|
||||
|
||||
public short getHeatWendu() {
|
||||
return heatWendu;
|
||||
}
|
||||
|
||||
public void setHeatWendu(short heatWendu) {
|
||||
this.heatWendu = heatWendu;
|
||||
}
|
||||
|
||||
public byte getSarkLamp() {
|
||||
return sarkLamp;
|
||||
}
|
||||
|
||||
public void setSarkLamp(byte sarkLamp) {
|
||||
this.sarkLamp = sarkLamp;
|
||||
}
|
||||
|
||||
public short getDianliang() {
|
||||
return dianliang;
|
||||
}
|
||||
|
||||
public void setDianliang(short dianliang) {
|
||||
this.dianliang = dianliang;
|
||||
}
|
||||
|
||||
public byte getWarn_onoff() {
|
||||
return warn_onoff;
|
||||
}
|
||||
|
||||
public void setWarn_onoff(byte warn_onoff) {
|
||||
this.warn_onoff = warn_onoff;
|
||||
}
|
||||
|
||||
public short getLow_wendu() {
|
||||
return low_wendu;
|
||||
}
|
||||
|
||||
public void setLow_wendu(short low_wendu) {
|
||||
this.low_wendu = low_wendu;
|
||||
}
|
||||
|
||||
public short getHigh_wendu() {
|
||||
return high_wendu;
|
||||
}
|
||||
|
||||
public void setHigh_wendu(short high_wendu) {
|
||||
this.high_wendu = high_wendu;
|
||||
}
|
||||
|
||||
public byte getHumidity() {
|
||||
return humidity;
|
||||
}
|
||||
|
||||
public void setHumidity(byte humidity) {
|
||||
this.humidity = humidity;
|
||||
}
|
||||
|
||||
public byte[] getByteMessage() {
|
||||
return byteMessage;
|
||||
}
|
||||
|
||||
public void setByteMessage(byte[] byteMessage) {
|
||||
this.byteMessage = byteMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BackBytes45{" +
|
||||
"number1=" + number1 +
|
||||
", number2=" + number2 +
|
||||
", number3=" + number3 +
|
||||
", number4=" + number4 +
|
||||
", number5=" + number5 +
|
||||
", number6=" + number6 +
|
||||
", number7=" + number7 +
|
||||
", onoff1=" + onoff1 +
|
||||
", onoff2=" + onoff2 +
|
||||
", onoff3=" + onoff3 +
|
||||
", onoff4=" + onoff4 +
|
||||
", onoff5=" + onoff5 +
|
||||
", onoff6=" + onoff6 +
|
||||
", onoff7=" + onoff7 +
|
||||
", heatStatus=" + heatStatus +
|
||||
", wendu=" + wendu +
|
||||
", heatWendu=" + heatWendu +
|
||||
", sarkLamp=" + sarkLamp +
|
||||
", dianliang=" + dianliang +
|
||||
", warn_onoff=" + warn_onoff +
|
||||
", low_wendu=" + low_wendu +
|
||||
", high_wendu=" + high_wendu +
|
||||
", humidity=" + humidity +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -1,256 +0,0 @@
|
|||
package com.ifish.socketNew.model.receive;
|
||||
|
||||
import com.ifish.socketNew.model.HeadModel;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 查询反馈信息45字节(15字节协议头+42字节结果)
|
||||
* @author guogw
|
||||
*
|
||||
*/
|
||||
public class BackBytes45_4_5f extends HeadModel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2740442296642889777L;
|
||||
/*********灯和开关(4字节)**********/
|
||||
//气泵
|
||||
private byte number1;
|
||||
//灯1
|
||||
private byte number2;
|
||||
//灯2
|
||||
private byte number3;
|
||||
//水泵
|
||||
private byte number4;
|
||||
//UV
|
||||
private byte number5;
|
||||
//造浪
|
||||
private byte number6;
|
||||
//加热制冷
|
||||
private byte number7;
|
||||
//气泵开关
|
||||
private byte onoff1;
|
||||
//灯1开关
|
||||
private byte onoff2;
|
||||
//灯2开关
|
||||
private byte onoff3;
|
||||
//水泵开关
|
||||
private byte onoff4;
|
||||
//UV开关
|
||||
private byte onoff5;
|
||||
//造浪开关
|
||||
private byte onoff6;
|
||||
//造浪开关
|
||||
private byte onoff7;
|
||||
//加热状态
|
||||
private byte heatStatus;
|
||||
//温度
|
||||
private short wendu;
|
||||
//加热温度
|
||||
private short heatWendu;
|
||||
//护理灯
|
||||
private byte sarkLamp;
|
||||
//一键喂鱼0 关,1开(背光)
|
||||
private byte wy_off;
|
||||
//电量
|
||||
private short ph;
|
||||
//报警开关,0关,1开
|
||||
private byte warn_onoff;
|
||||
//最低报警温度
|
||||
private short low_wendu;
|
||||
//最高报警温度
|
||||
private short high_wendu;
|
||||
|
||||
private byte[] byteMessage;
|
||||
|
||||
public byte getNumber1() {
|
||||
return number1;
|
||||
}
|
||||
|
||||
public void setNumber1(byte number1) {
|
||||
this.number1 = number1;
|
||||
}
|
||||
|
||||
public byte getNumber2() {
|
||||
return number2;
|
||||
}
|
||||
|
||||
public void setNumber2(byte number2) {
|
||||
this.number2 = number2;
|
||||
}
|
||||
|
||||
public byte getNumber3() {
|
||||
return number3;
|
||||
}
|
||||
|
||||
public void setNumber3(byte number3) {
|
||||
this.number3 = number3;
|
||||
}
|
||||
|
||||
public byte getNumber4() {
|
||||
return number4;
|
||||
}
|
||||
|
||||
public void setNumber4(byte number4) {
|
||||
this.number4 = number4;
|
||||
}
|
||||
|
||||
public byte getNumber5() {
|
||||
return number5;
|
||||
}
|
||||
|
||||
public void setNumber5(byte number5) {
|
||||
this.number5 = number5;
|
||||
}
|
||||
|
||||
public byte getNumber6() {
|
||||
return number6;
|
||||
}
|
||||
|
||||
public void setNumber6(byte number6) {
|
||||
this.number6 = number6;
|
||||
}
|
||||
|
||||
public byte getNumber7() {
|
||||
return number7;
|
||||
}
|
||||
|
||||
public void setNumber7(byte number7) {
|
||||
this.number7 = number7;
|
||||
}
|
||||
|
||||
public byte getOnoff1() {
|
||||
return onoff1;
|
||||
}
|
||||
|
||||
public void setOnoff1(byte onoff1) {
|
||||
this.onoff1 = onoff1;
|
||||
}
|
||||
|
||||
public byte getOnoff2() {
|
||||
return onoff2;
|
||||
}
|
||||
|
||||
public void setOnoff2(byte onoff2) {
|
||||
this.onoff2 = onoff2;
|
||||
}
|
||||
|
||||
public byte getOnoff3() {
|
||||
return onoff3;
|
||||
}
|
||||
|
||||
public void setOnoff3(byte onoff3) {
|
||||
this.onoff3 = onoff3;
|
||||
}
|
||||
|
||||
public byte getOnoff4() {
|
||||
return onoff4;
|
||||
}
|
||||
|
||||
public void setOnoff4(byte onoff4) {
|
||||
this.onoff4 = onoff4;
|
||||
}
|
||||
|
||||
public byte getOnoff5() {
|
||||
return onoff5;
|
||||
}
|
||||
|
||||
public void setOnoff5(byte onoff5) {
|
||||
this.onoff5 = onoff5;
|
||||
}
|
||||
|
||||
public byte getOnoff6() {
|
||||
return onoff6;
|
||||
}
|
||||
|
||||
public void setOnoff6(byte onoff6) {
|
||||
this.onoff6 = onoff6;
|
||||
}
|
||||
|
||||
public byte getOnoff7() {
|
||||
return onoff7;
|
||||
}
|
||||
|
||||
public void setOnoff7(byte onoff7) {
|
||||
this.onoff7 = onoff7;
|
||||
}
|
||||
|
||||
public byte getHeatStatus() {
|
||||
return heatStatus;
|
||||
}
|
||||
|
||||
public void setHeatStatus(byte heatStatus) {
|
||||
this.heatStatus = heatStatus;
|
||||
}
|
||||
|
||||
public short getWendu() {
|
||||
return wendu;
|
||||
}
|
||||
|
||||
public void setWendu(short wendu) {
|
||||
this.wendu = wendu;
|
||||
}
|
||||
|
||||
public short getHeatWendu() {
|
||||
return heatWendu;
|
||||
}
|
||||
|
||||
public void setHeatWendu(short heatWendu) {
|
||||
this.heatWendu = heatWendu;
|
||||
}
|
||||
|
||||
public byte getSarkLamp() {
|
||||
return sarkLamp;
|
||||
}
|
||||
|
||||
public void setSarkLamp(byte sarkLamp) {
|
||||
this.sarkLamp = sarkLamp;
|
||||
}
|
||||
public byte getWarn_onoff() {
|
||||
return warn_onoff;
|
||||
}
|
||||
|
||||
public void setWarn_onoff(byte warn_onoff) {
|
||||
this.warn_onoff = warn_onoff;
|
||||
}
|
||||
|
||||
public short getLow_wendu() {
|
||||
return low_wendu;
|
||||
}
|
||||
|
||||
public void setLow_wendu(short low_wendu) {
|
||||
this.low_wendu = low_wendu;
|
||||
}
|
||||
|
||||
public short getHigh_wendu() {
|
||||
return high_wendu;
|
||||
}
|
||||
|
||||
public void setHigh_wendu(short high_wendu) {
|
||||
this.high_wendu = high_wendu;
|
||||
}
|
||||
|
||||
|
||||
public byte[] getByteMessage() {
|
||||
return byteMessage;
|
||||
}
|
||||
|
||||
public void setByteMessage(byte[] byteMessage) {
|
||||
this.byteMessage = byteMessage;
|
||||
}
|
||||
|
||||
public byte getWy_off() {
|
||||
return wy_off;
|
||||
}
|
||||
|
||||
public void setWy_off(byte wy_off) {
|
||||
this.wy_off = wy_off;
|
||||
}
|
||||
|
||||
public short getPh() {
|
||||
return ph;
|
||||
}
|
||||
|
||||
public void setPh(short ph) {
|
||||
this.ph = ph;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
package com.ifish.socketNew.model.receive;
|
||||
|
||||
import com.ifish.socketNew.model.HeadModel;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 查询反馈信息28字节(15字节协议头+13字节结果)
|
||||
* @author guogw
|
||||
*
|
||||
*/
|
||||
public class BackBytesPower extends HeadModel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2740442296642889777L;
|
||||
|
||||
private byte num;
|
||||
|
||||
private byte def;
|
||||
|
||||
private byte dayPower;
|
||||
|
||||
private byte monthPower;
|
||||
|
||||
private byte ph;
|
||||
|
||||
public byte getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public void setNum(byte num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
public byte getDef() {
|
||||
return def;
|
||||
}
|
||||
|
||||
public void setDef(byte def) {
|
||||
this.def = def;
|
||||
}
|
||||
|
||||
public byte getDayPower() {
|
||||
return dayPower;
|
||||
}
|
||||
|
||||
public void setDayPower(byte dayPower) {
|
||||
this.dayPower = dayPower;
|
||||
}
|
||||
|
||||
public byte getMonthPower() {
|
||||
return monthPower;
|
||||
}
|
||||
|
||||
public void setMonthPower(byte monthPower) {
|
||||
this.monthPower = monthPower;
|
||||
}
|
||||
|
||||
public byte getPh() {
|
||||
return ph;
|
||||
}
|
||||
|
||||
public void setPh(byte ph) {
|
||||
this.ph = ph;
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,9 @@ public class BackFunctionCodeHeater extends HeadModel implements Serializable {
|
|||
|
||||
private byte[] byteMessage;
|
||||
|
||||
private short mainSwitch;
|
||||
private byte mainNumber;
|
||||
|
||||
private byte mainSwitch;
|
||||
|
||||
private byte controlState;
|
||||
|
||||
|
|
@ -39,11 +41,19 @@ public class BackFunctionCodeHeater extends HeadModel implements Serializable {
|
|||
this.byteMessage = byteMessage;
|
||||
}
|
||||
|
||||
public short getMainSwitch() {
|
||||
public byte getMainNumber() {
|
||||
return mainNumber;
|
||||
}
|
||||
|
||||
public void setMainNumber(byte mainNumber) {
|
||||
this.mainNumber = mainNumber;
|
||||
}
|
||||
|
||||
public byte getMainSwitch() {
|
||||
return mainSwitch;
|
||||
}
|
||||
|
||||
public void setMainSwitch(short mainSwitch) {
|
||||
public void setMainSwitch(byte mainSwitch) {
|
||||
this.mainSwitch = mainSwitch;
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +116,8 @@ public class BackFunctionCodeHeater extends HeadModel implements Serializable {
|
|||
@Override
|
||||
public String toString() {
|
||||
final StringBuffer sb = new StringBuffer("BackFunctionCodeHeater{");
|
||||
sb.append("mainSwitch=").append(mainSwitch);
|
||||
sb.append("mainNumber=").append(mainNumber);
|
||||
sb.append(", mainSwitch=").append(mainSwitch);
|
||||
sb.append(", controlState=").append(controlState);
|
||||
sb.append(", waterTemperature=").append(waterTemperature);
|
||||
sb.append(", heatingTemperature=").append(heatingTemperature);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import com.ifish.socketNew.model.HeadModel;
|
|||
*
|
||||
*/
|
||||
public class OrderFunctionCode1 extends HeadModel implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 5329299292101065390L;
|
||||
//厂商
|
||||
private byte vendor;
|
||||
|
|
@ -20,7 +20,7 @@ public class OrderFunctionCode1 extends HeadModel implements Serializable {
|
|||
private byte version;
|
||||
//登陆IP
|
||||
private byte[] login_ip = new byte[4];
|
||||
|
||||
|
||||
|
||||
public byte getVendor() {
|
||||
return vendor;
|
||||
|
|
@ -53,4 +53,5 @@ public class OrderFunctionCode1 extends HeadModel implements Serializable {
|
|||
public void setLogin_ip(byte[] login_ip) {
|
||||
this.login_ip = login_ip;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
package com.ifish.socketNew.model.send;
|
||||
|
||||
import com.ifish.socketNew.model.HeadModel;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 获取电量
|
||||
* @author guogw
|
||||
*
|
||||
*/
|
||||
public class OrderFunctionCode18Power extends HeadModel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4716919320112205973L;
|
||||
//编号8
|
||||
private byte code = 8;
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
package com.ifish.socketNew.model.send;
|
||||
|
||||
import com.ifish.socketNew.model.HeadModel;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 新增字段
|
||||
* @author guogw
|
||||
*
|
||||
*/
|
||||
public class OrderFunctionCode1_1 extends OrderFunctionCode1 implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//用户ID
|
||||
private byte[] userId = new byte[10];
|
||||
|
||||
public byte[] getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(byte[] userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
}
|
||||
|
|
@ -37,13 +37,6 @@ public class OrderFunctionCode9 extends HeadModel implements Serializable {
|
|||
public void setWarn_wendu(short warn_wendu) {
|
||||
this.warn_wendu = warn_wendu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OrderFunctionCode9{" +
|
||||
"warn_type=" + warn_type +
|
||||
", wendu=" + wendu +
|
||||
", warn_wendu=" + warn_wendu +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
c3p0.driverClassName=com.mysql.jdbc.Driver
|
||||
#c3p0.url=jdbc\:mysql\://localhost\:3306/myfishdb?characterEncoding\=UTF-8
|
||||
c3p0.url=jdbc\:mysql\://10.174.60.12\:3306/myfishdb?characterEncoding\=UTF-8
|
||||
#c3p0.username=ifish
|
||||
#c3p0.password=ifish7pwd
|
||||
c3p0.username=root
|
||||
c3p0.password=ifish7mysql
|
||||
c3p0.url=jdbc\:mysql\://localhost\:3306/myfishdb?characterEncoding\=UTF-8
|
||||
#c3p0.url=jdbc\:mysql\://139.196.24.156\:3306/myfishdb?characterEncoding\=UTF-8
|
||||
c3p0.username=ifish
|
||||
c3p0.password=ifish7pwd
|
||||
#c3p0.username=root
|
||||
#c3p0.password=ifish7mysql
|
||||
#c3p0.username=root
|
||||
#c3p0.password=123456
|
||||
|
||||
|
|
@ -32,4 +32,4 @@ hibernate.jdbc.batch_size=50
|
|||
hibernate.query.substitutions=true 1,false 0
|
||||
hibernate.cache.use_second_level_cache=false
|
||||
hibernate.cache.use_query_cache=false
|
||||
hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory
|
||||
hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory
|
||||
|
|
@ -6,17 +6,16 @@
|
|||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
|
||||
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
|
||||
|
||||
<!-- webService -->
|
||||
<bean id="serviceBean" class="com.ifish.webService.ServiceBean"></bean>
|
||||
<!-- 消息处理类 -->
|
||||
<bean id="someServer" class="com.ifish.socketNew.SomeServer"></bean>
|
||||
<bean id="deviceService" class="com.ifish.serviceImpl.DeviceServiceImpl"></bean>
|
||||
<!-- 实现job中注入bean -->
|
||||
<bean name="jobFactory" class="com.ifish.quartz.JobFactory"/>
|
||||
<!-- 调度任务 -->
|
||||
<bean id="scheduleJob" init-method="init" destroy-method="shutdown" class="com.ifish.quartz.ScheduleJob"></bean>
|
||||
|
||||
|
||||
<!-- 自定义的serverHandler -->
|
||||
<bean id="serverHandler" class="com.ifish.socketNew.MinaServerHandler"></bean>
|
||||
|
||||
|
|
@ -34,25 +33,23 @@
|
|||
|
||||
<!-- 黑名单filter
|
||||
<bean id="minaBlacklistFilter" class="com.ifish.socketNew.filter.MinaBlacklistFilter" init-method="init"></bean> -->
|
||||
|
||||
|
||||
<!-- 编码filter -->
|
||||
<bean id="codecFilter" class="org.apache.mina.filter.codec.ProtocolCodecFilter">
|
||||
<constructor-arg>
|
||||
<!-- 自定义的字符编码类 -->
|
||||
<bean class="com.ifish.socketNew.codeFactory.ServerCodecFactory">
|
||||
<property name="deviceService" ref="deviceService" />
|
||||
</bean>
|
||||
<bean class="com.ifish.socketNew.codeFactory.ServerCodecFactory"></bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
|
||||
<!-- 日志filter -->
|
||||
<bean id="loggingFilter" class="org.apache.mina.filter.logging.LoggingFilter"></bean>
|
||||
|
||||
|
||||
<!-- <bean id="noopFilter" class="org.apache.mina.filter.util.NoopFilter"></bean> -->
|
||||
|
||||
|
||||
<!-- 连接控制过滤器,对同一IP地址频繁的创建连接的时间间隔进行控制 -->
|
||||
<!-- <bean id="connectionThrottleFilter" class="org.apache.mina.filter.firewall.ConnectionThrottleFilter"></bean> -->
|
||||
|
||||
|
||||
<!-- 过滤器链 -->
|
||||
<bean id="filterChainBuilder" class="org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder">
|
||||
<property name="filters">
|
||||
|
|
@ -70,7 +67,7 @@
|
|||
<property name="minReadBufferSize" value="512" />
|
||||
<property name="maxReadBufferSize" value="3072" />
|
||||
</bean>
|
||||
|
||||
|
||||
<!-- 开始运行socket服务 -->
|
||||
<bean id="ioAcceptor" class="org.apache.mina.transport.socket.nio.NioSocketAcceptor"
|
||||
init-method="bind" destroy-method="unbind">
|
||||
|
|
@ -80,4 +77,4 @@
|
|||
<property name="reuseAddress" value="true" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
</beans>
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
broker_url=tcp://localhost:61616
|
||||
#broker_url=tcp://test.ifish7.com:61616
|
||||
broker_url=tcp://www.ifish7.com:61616
|
||||
username=admin
|
||||
#password=admin
|
||||
password=adminifish7
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#\u672c\u5730
|
||||
#ifish.ip=192.168.31.185
|
||||
#ifish.ip=192.168.1.7
|
||||
#\u6d4b\u8bd5\u4e91
|
||||
ifish.ip=10.174.60.12
|
||||
#ifish.ip=139.196.24.156
|
||||
#\u6b63\u5f0f\u4e91
|
||||
#ifish.ip=10.46.65.60
|
||||
ifish.ip=120.55.190.56
|
||||
#\u670d\u52a1\u5668\u7aef\u53e3
|
||||
ifish.port=9955
|
||||
ifish.port=9955
|
||||
Loading…
Reference in New Issue