update
This commit is contained in:
parent
28e634b761
commit
d5ddab8043
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,19 +140,25 @@
|
|||
<artifactId>json</artifactId>
|
||||
<version>20090211</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>3.0-alpha-1</version>
|
||||
|
||||
<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> -->
|
||||
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>ifishSocket</finalName>
|
||||
|
|
@ -169,9 +175,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>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
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);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
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);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?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>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?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>
|
||||
|
|
@ -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,16 +30,24 @@ 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,5 +1,6 @@
|
|||
package com.ifish.serviceImpl;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
|
@ -22,11 +23,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
|
||||
|
|
@ -34,7 +35,7 @@ import com.ifish.util.ByteUtil;
|
|||
public class DeviceServiceImpl implements DeviceService {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(DeviceServiceImpl.class);
|
||||
|
||||
|
||||
@Autowired
|
||||
private DeviceDao deviceDao;
|
||||
@Autowired
|
||||
|
|
@ -51,12 +52,16 @@ public class DeviceServiceImpl implements DeviceService {
|
|||
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地址
|
||||
|
|
@ -73,6 +78,9 @@ public class DeviceServiceImpl implements DeviceService {
|
|||
ipStr.append("."+v);
|
||||
}
|
||||
}
|
||||
String userId = new String(model.getUserId(), StandardCharsets.UTF_8);
|
||||
log.info("用户登陆信息 :::::: mac : {}, ip : {}, userId : {}", stcMac, ipStr, userId);
|
||||
|
||||
//版本
|
||||
Integer version = model.getVersion() & 0xff;
|
||||
//电子厂
|
||||
|
|
@ -136,7 +144,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;
|
||||
|
|
@ -144,7 +152,7 @@ public class DeviceServiceImpl implements DeviceService {
|
|||
|
||||
@Override
|
||||
public List<DeviceUser> getListByProperty(Integer deviceId) {
|
||||
return deviceUserDao.getListByProperty(Restrictions.eq("priId.deviceId", deviceId));
|
||||
return deviceUserDao.getListByProperty(Restrictions.eq("priId.deviceId", deviceId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -207,4 +215,24 @@ 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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ 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;
|
||||
|
|
@ -30,6 +33,8 @@ import javax.jms.Session;
|
|||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -59,6 +64,15 @@ public class SomeServer {
|
|||
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
|
||||
|
|
@ -136,6 +150,27 @@ public class SomeServer {
|
|||
}
|
||||
}
|
||||
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) {
|
||||
|
|
@ -191,8 +226,13 @@ public class SomeServer {
|
|||
jobGroup.setTriggerName(strSrc);
|
||||
scheduleJob.deleteJob(jobGroup);
|
||||
try {
|
||||
//更新设备信息
|
||||
deviceService.update(receive);
|
||||
String stcMac = ByteUtil.bytesToHexString(model.getSrc());
|
||||
if (limitCaches.get(stcMac) == 0L) {
|
||||
//更新设备信息
|
||||
deviceService.update(receive);
|
||||
limitCaches.put(stcMac, 1L);
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
|
@ -200,10 +240,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());
|
||||
|
|
@ -336,6 +376,7 @@ 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,30 @@
|
|||
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);
|
||||
return new ServerDecode(charset, deviceService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtocolEncoder getEncoder(IoSession session) throws Exception {
|
||||
return new ServerEncode(charset);
|
||||
}
|
||||
|
||||
|
||||
public void setDeviceService(DeviceService deviceService) {
|
||||
this.deviceService = deviceService;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,20 @@
|
|||
package com.ifish.socketNew.codeFactory;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.ifish.socketNew.model.receive.BackBytes45;
|
||||
import com.ifish.socketNew.model.receive.BackBytes57;
|
||||
import com.ifish.socketNew.model.receive.BackFunctionCodeHeater;
|
||||
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 org.apache.log4j.Logger;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.session.AttributeKey;
|
||||
|
|
@ -12,17 +22,10 @@ import org.apache.mina.core.session.IoSession;
|
|||
import org.apache.mina.filter.codec.ProtocolDecoder;
|
||||
import org.apache.mina.filter.codec.ProtocolDecoderOutput;
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
|
|
@ -31,14 +34,26 @@ 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);
|
||||
|
||||
public ServerDecode() {
|
||||
this(Charset.defaultCharset());
|
||||
}
|
||||
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(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);
|
||||
|
|
@ -63,7 +78,7 @@ public class ServerDecode implements ProtocolDecoder {
|
|||
//验证
|
||||
getValid(session, buf, out);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 验证协议
|
||||
* @param session
|
||||
|
|
@ -88,7 +103,7 @@ public class ServerDecode implements ProtocolDecoder {
|
|||
buf.position(0);
|
||||
buf.clear();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解码成对象
|
||||
* @param buf
|
||||
|
|
@ -162,11 +177,84 @@ 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
|
||||
|
|
@ -197,6 +285,11 @@ public class ServerDecode implements ProtocolDecoder {
|
|||
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();
|
||||
|
|
@ -428,6 +521,8 @@ public class ServerDecode implements ProtocolDecoder {
|
|||
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());
|
||||
|
|
@ -444,21 +539,59 @@ public class ServerDecode implements ProtocolDecoder {
|
|||
model.setOnoff5(buf.get());
|
||||
model.setOnoff6(buf.get());
|
||||
model.setOnoff7(buf.get());
|
||||
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();
|
||||
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);
|
||||
}
|
||||
out.write(model);
|
||||
|
||||
}
|
||||
@Override
|
||||
public void dispose(IoSession session) throws Exception {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,256 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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,8 @@ public class OrderFunctionCode1 extends HeadModel implements Serializable {
|
|||
private byte version;
|
||||
//登陆IP
|
||||
private byte[] login_ip = new byte[4];
|
||||
|
||||
private byte[] userId = new byte[2];
|
||||
|
||||
|
||||
public byte getVendor() {
|
||||
return vendor;
|
||||
|
|
@ -54,4 +55,11 @@ public class OrderFunctionCode1 extends HeadModel implements Serializable {
|
|||
this.login_ip = login_ip;
|
||||
}
|
||||
|
||||
public byte[] getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(byte[] userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
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,10 +1,10 @@
|
|||
c3p0.driverClassName=com.mysql.jdbc.Driver
|
||||
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.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,16 +6,17 @@
|
|||
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>
|
||||
|
||||
|
|
@ -33,23 +34,25 @@
|
|||
|
||||
<!-- 黑名单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"></bean>
|
||||
<bean class="com.ifish.socketNew.codeFactory.ServerCodecFactory">
|
||||
<property name="deviceService" ref="deviceService" />
|
||||
</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">
|
||||
|
|
@ -67,7 +70,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">
|
||||
|
|
@ -77,4 +80,4 @@
|
|||
<property name="reuseAddress" value="true" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
</beans>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#\u672c\u5730
|
||||
#ifish.ip=192.168.1.14
|
||||
#ifish.ip=192.168.31.185
|
||||
#\u6d4b\u8bd5\u4e91
|
||||
#ifish.ip=139.196.24.156
|
||||
ifish.ip=10.174.60.12
|
||||
#\u6b63\u5f0f\u4e91
|
||||
ifish.ip=120.55.190.56
|
||||
#ifish.ip=120.55.190.56
|
||||
#\u670d\u52a1\u5668\u7aef\u53e3
|
||||
ifish.port=9955
|
||||
ifish.port=9955
|
||||
|
|
|
|||
Loading…
Reference in New Issue